Training courses

Kernel and Embedded Linux

Bootlin training courses

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

Bootlin logo

Elixir Cross Referencer

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

 © 1995-2003, 2004, 2005-2011 Freescale Semiconductor, Inc.
 All rights reserved.

 This is proprietary source code of Freescale Semiconductor Inc.,
 and its use is subject to the NetComm Device Drivers EULA.
 The copyright notice above does not evidence any actual or intended
 publication of such source code.

 ALTERNATIVELY, 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.

 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          qm_ext.h

 @Description   QM & Portal API
*//***************************************************************************/
#ifndef __QM_EXT_H
#define __QM_EXT_H

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


/**************************************************************************//**
 @Group         QM_grp Queue Manager API

 @Description   QM API functions, definitions and enums.

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

/**************************************************************************//**
 @Description   This callback type is used when receiving frame.

                User provides this function. Driver invokes it.

 @Param[in]     h_App       A user argument to the callback
 @Param[in]     h_QmFqr     A handle to an QM-FQR Module.
 @Param[in]     fqidOffset  fqid offset from the FQR's fqid base.
 @Param[in]     p_Frame     The Received Frame

 @Retval        e_RX_STORE_RESPONSE_CONTINUE - order the driver to continue Rx
                                               operation for all ready data.
 @Retval        e_RX_STORE_RESPONSE_PAUSE    - order the driver to stop Rx operation.

 @Cautions      p_Frame is local parameter; i.e. users must NOT access or use
                this parameter in any means outside this callback context.
*//***************************************************************************/
typedef e_RxStoreResponse (t_QmReceivedFrameCallback)(t_Handle h_App,
                                                      t_Handle h_QmFqr,
                                                      t_Handle h_QmPortal,
                                                      uint32_t fqidOffset,
                                                      t_DpaaFD *p_Frame);

/**************************************************************************//**
 @Description   This callback type is used when the FQR is completely was drained.

                User provides this function. Driver invokes it.

 @Param[in]     h_App       A user argument to the callback
 @Param[in]     h_QmFqr     A handle to an QM-FQR Module.

 @Retval        E_OK on success; Error code otherwise.
*//***************************************************************************/
typedef t_Error (t_QmFqrDrainedCompletionCB)(t_Handle h_App,
                                             t_Handle h_QmFqr);

/**************************************************************************//**
 @Description   QM Rejection code enum
*//***************************************************************************/
typedef enum e_QmRejectionCode
{
    e_QM_RC_NONE,

    e_QM_RC_CG_TAILDROP,    /**< This frames was rejected due to congestion
                                     group taildrop situation */
    e_QM_RC_CG_WRED,            /**< This frames was rejected due to congestion
                                     group WRED situation */
    e_QM_RC_FQ_TAILDROP         /**< This frames was rejected due to FQID TD
                                     situation */
/*  e_QM_RC_ERROR
    e_QM_RC_ORPWINDOW_EARLY
    e_QM_RC_ORPWINDOW_LATE
    e_QM_RC_ORPWINDOW_RETIRED */
} e_QmRejectionCode;

/**************************************************************************//**
 @Description   QM Rejected frame information
*//***************************************************************************/
typedef struct t_QmRejectedFrameInfo
{
    e_QmRejectionCode    rejectionCode; /**< Rejection code */
    union
    {
        struct
        {
            uint8_t cgId;               /**< congestion group id*/
        } cg;                           /**< rejection parameters when rejectionCode =
                                             e_QM_RC_CG_TAILDROP or e_QM_RC_CG_WRED. */
    };
} t_QmRejectedFrameInfo;

/**************************************************************************//**
 @Description   This callback type is used when receiving rejected frames.

                User provides this function. Driver invokes it.

 @Param[in]     h_App                   A user argument to the callback
 @Param[in]     h_QmFqr                 A handle to an QM-FQR Module.
 @Param[in]     fqidOffset              fqid offset from the FQR's fqid base.
 @Param[in]     p_Frame                 The Rejected Frame
 @Param[in]     p_QmRejectedFrameInfo   Rejected Frame information

 @Retval        e_RX_STORE_RESPONSE_CONTINUE - order the driver to continue Rx
                                               operation for all ready data.
 @Retval        e_RX_STORE_RESPONSE_PAUSE    - order the driver to stop Rx operation.

 @Cautions      p_Frame is local parameter; i.e. users must NOT access or use
                this parameter in any means outside this callback context.
*//***************************************************************************/
typedef e_RxStoreResponse (t_QmRejectedFrameCallback)(t_Handle h_App,
                                                      t_Handle h_QmFqr,
                                                      t_Handle h_QmPortal,
                                                      uint32_t fqidOffset,
                                                      t_DpaaFD *p_Frame,
                                                      t_QmRejectedFrameInfo *p_QmRejectedFrameInfo);



/**************************************************************************//**
 @Group         QM_lib_grp QM common API

 @Description   QM common API functions, definitions and enums.

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

/**************************************************************************//**
 @Description   QM Exceptions
*//***************************************************************************/
typedef enum e_QmExceptions {
    e_QM_EX_CORENET_INITIATOR_DATA = 0,         /**< Initiator Data Error */
    e_QM_EX_CORENET_TARGET_DATA,                /**< CoreNet Target Data Error */
    e_QM_EX_CORENET_INVALID_TARGET_TRANSACTION, /**< Invalid Target Transaction */
    e_QM_EX_PFDR_THRESHOLD,                     /**< PFDR Low Watermark Interrupt */
    e_QM_EX_PFDR_ENQUEUE_BLOCKED,               /**< PFDR Enqueues Blocked Interrupt */
    e_QM_EX_SINGLE_ECC,                         /**< Single Bit ECC Error Interrupt */
    e_QM_EX_MULTI_ECC,                          /**< Multi Bit ECC Error Interrupt */
    e_QM_EX_INVALID_COMMAND,                    /**< Invalid Command Verb Interrupt */
    e_QM_EX_DEQUEUE_DCP,                        /**< Invalid Dequeue Direct Connect Portal Interrupt */
    e_QM_EX_DEQUEUE_FQ,                         /**< Invalid Dequeue FQ Interrupt */
    e_QM_EX_DEQUEUE_SOURCE,                     /**< Invalid Dequeue Source Interrupt */
    e_QM_EX_DEQUEUE_QUEUE,                      /**< Invalid Dequeue Queue Interrupt */
    e_QM_EX_ENQUEUE_OVERFLOW,                   /**< Invalid Enqueue Overflow Interrupt */
    e_QM_EX_ENQUEUE_STATE,                      /**< Invalid Enqueue State Interrupt */
    e_QM_EX_ENQUEUE_CHANNEL,                    /**< Invalid Enqueue Channel Interrupt */
    e_QM_EX_ENQUEUE_QUEUE,                      /**< Invalid Enqueue Queue Interrupt */
    e_QM_EX_CG_STATE_CHANGE                     /**< CG change state notification */
} e_QmExceptions;

/**************************************************************************//**
 @Group         QM_init_grp QM (common) Initialization Unit

 @Description   QM (common) Initialization Unit

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

/**************************************************************************//**
 @Function      t_QmExceptionsCallback

 @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_QmExceptionsCallback) ( t_Handle              h_App,
                                        e_QmExceptions        exception);

/**************************************************************************//**
 @Description    Frame's Type to poll
*//***************************************************************************/
typedef enum e_QmPortalPollSource {
    e_QM_PORTAL_POLL_SOURCE_DATA_FRAMES = 0,    /**< Poll only data frames */
    e_QM_PORTAL_POLL_SOURCE_CONTROL_FRAMES,     /**< Poll only control frames */
    e_QM_PORTAL_POLL_SOURCE_BOTH                /**< Poll both */
} e_QmPortalPollSource;

/**************************************************************************//**
 @Description   structure representing QM contextA of FQ initialization parameters
                Note that this is only "space-holder" for the Context-A. The "real"
                Context-A is described in each specific driver (E.g. FM driver
                has its own Context-A API).
*//***************************************************************************/
typedef struct {
    uint32_t    res[2];     /**< reserved size for context-a */
} t_QmContextA;

/**************************************************************************//**
 @Description   structure representing QM contextB of FQ initialization parameters
                Note that this is only "space-holder" for the Context-B. The "real"
                Context-B is described in each specific driver (E.g. FM driver
                has its own Context-B API).
*//***************************************************************************/
typedef  uint32_t   t_QmContextB;

/**************************************************************************//**
 @Description   structure representing QM initialization parameters
*//***************************************************************************/
typedef struct {
    uint8_t                 guestId;                /**< QM Partition Id */

    uintptr_t               baseAddress;            /**< Qm base address (virtual)
                                                         NOTE: this parameter relevant only for BM in master mode ('guestId'=NCSW_MASTER_ID). */
    uintptr_t               swPortalsBaseAddress;   /**< QM Software Portals Base Address (virtual) */
    uint16_t                liodn;                  /**< This value is attached to every transaction initiated by QMan when accessing its private data structures */
    uint32_t                totalNumOfFqids;        /**< Total number of frame-queue-ids in the system */
    uint32_t                fqdMemPartitionId;      /**< FQD's mem partition id;
                                                         NOTE: The memory partition must be non-cacheable and no-coherent area. */
    uint32_t                pfdrMemPartitionId;     /**< PFDR's mem partition id;
                                                         NOTE: The memory partition must be non-cacheable and no-coherent area. */
    t_QmExceptionsCallback  *f_Exception;           /**< An application callback routine to handle exceptions.*/
    t_Handle                h_App;                  /**< A handle to an application layer object; This handle will
                                                         be passed by the driver upon calling the above callbacks */
    uintptr_t               errIrq;                 /**< error interrupt line; NO_IRQ if interrupts not used */
    uint32_t                partFqidBase;           /**< The first frame-queue-id dedicated to this partition.
                                                         NOTE: this parameter relevant only when working with multiple partitions. */
    uint32_t                partNumOfFqids;         /**< Number of frame-queue-ids dedicated to this partition.
                                                         NOTE: this parameter relevant only when working with multiple partitions. */
    uint16_t                partCgsBase;            /**< The first cgr dedicated to this partition.
                                                         NOTE: this parameter relevant only when working with multiple partitions. */
    uint16_t                partNumOfCgs;           /**< Number of cgr's dedicated to this partition.
                                                         NOTE: this parameter relevant only when working with multiple partitions. */
} t_QmParam;


/**************************************************************************//**
 @Function      QM_Config

 @Description   Creates descriptor for the QM module.

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

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

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

 @Retval        Handle to the QM object, or NULL for Failure.
*//***************************************************************************/
t_Handle QM_Config(t_QmParam *p_QmParam);

/**************************************************************************//**
 @Function      QM_Init

 @Description   Initializes the QM module

 @Param[in]     h_Qm - A handle to the QM module

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

/**************************************************************************//**
 @Function      QM_Free

 @Description   Frees all resources that were assigned to the QM module.

                Calling this routine invalidates the descriptor.

 @Param[in]     h_Qm - A handle to the QM module

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


/**************************************************************************//**
 @Group         QM_advanced_init_grp    QM (common) Advanced Configuration Unit

 @Description   Configuration functions used to change default values.

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

/**************************************************************************//**
 @Description   structure for defining DC portal ERN destination
*//***************************************************************************/
typedef struct t_QmDcPortalParams {
    bool            sendToSw;
    e_DpaaSwPortal  swPortalId;
} t_QmDcPortalParams;


/**************************************************************************//**
 @Function      QM_ConfigRTFramesDepth

 @Description   Change the run-time frames depth (i.e. the maximum total number
                of frames that may be inside QM at a certain time) from its default
                configuration [30000].

 @Param[in]     h_Qm            - A handle to the QM module
 @Param[in]     rtFramesDepth   - run-time max num of frames.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following QM_Config() and before QM_Init().
*//***************************************************************************/
t_Error QM_ConfigRTFramesDepth(t_Handle h_Qm, uint32_t rtFramesDepth);

/**************************************************************************//**
 @Function      QM_ConfigPfdrThreshold

 @Description   Change the pfdr threshold from its default
                configuration [0].
                An interrupt if enables is asserted when the number of PFDRs is below this threshold.

 @Param[in]     h_Qm            - A handle to the QM module
 @Param[in]     threshold       - threshold value.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following QM_Config() and before QM_Init().
*//***************************************************************************/
t_Error QM_ConfigPfdrThreshold(t_Handle h_Qm, uint32_t threshold);

/**************************************************************************//**
 @Function      QM_ConfigSfdrReservationThreshold

 @Description   Change the sfdr threshold from its default
                configuration [0].

 @Param[in]     h_Qm            - A handle to the QM module
 @Param[in]     threshold       - threshold value.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following QM_Config() and before QM_Init().
*//***************************************************************************/
t_Error QM_ConfigSfdrReservationThreshold(t_Handle h_Qm, uint32_t threshold);

/**************************************************************************//**
 @Function      QM_ConfigErrorRejectionNotificationDest

 @Description   Change the destination of rejected frames for DC portals.
                By default, depending on chip, some DC portals are set to reject
                frames to HW and some to SW.

 @Param[in]     h_Qm            - A handle to the QM module
 @Param[in]     id              - DC Portal id.
 @Param[in]     p_Params        - Destination parameters.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following QM_Config() and before QM_Init().
*//***************************************************************************/
t_Error QM_ConfigErrorRejectionNotificationDest(t_Handle h_Qm, e_DpaaDcPortal id, t_QmDcPortalParams *p_Params);

/** @} */ /* end of QM_advanced_init_grp group */
/** @} */ /* end of QM_init_grp group */


/**************************************************************************//**
 @Group         QM_runtime_control_grp QM (common) Runtime Control Unit

 @Description   QM (common) Runtime control unit API functions, definitions and enums.

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

/**************************************************************************//**
 @Description   enum for defining QM counters
*//***************************************************************************/
typedef enum e_QmCounters {
    e_QM_COUNTERS_SFDR_IN_USE = 0,          /**< Total Single Frame Descriptor Record (SFDR) currently in use */
    e_QM_COUNTERS_PFDR_IN_USE,              /**< Total Packed Frame Descriptor Record (PFDR) currently in use */
    e_QM_COUNTERS_PFDR_FREE_POOL            /**< Total Packed Frame Descriptor Record (PFDR) Free Pool Count in external memory */
} e_QmCounters;

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

/**************************************************************************//**
 @Description   structure representing QM FQ-Range reservation parameters
*//***************************************************************************/
typedef struct t_QmRsrvFqrParams {
    bool                useForce;       /**< TRUE - force reservation of specific fqids;
                                             FALSE - reserve several fqids */
    uint32_t            numOfFqids;     /**< number of fqids to be reserved. */
    union{
        struct {
            uint32_t    align;          /**< alignment. will be used if useForce=FALSE */
        } nonFrcQs;
        struct {
            uint32_t    fqid;           /**< the fqid base of the forced fqids. will be used if useForce=TRUE */
        } frcQ;
    } qs;
} t_QmRsrvFqrParams;

/**************************************************************************//**
 @Description   structure representing QM Error information
*//***************************************************************************/
typedef struct t_QmErrorInfo {
    bool                portalValid;
    bool                hwPortal;
    e_DpaaSwPortal      swPortalId;         /**< Sw Portal id */
    e_DpaaDcPortal      dcpId;              /**< Dcp (hw Portal) id */
    bool                fqidValid;
    uint32_t            fqid;
} t_QmErrorInfo;


/**************************************************************************//**
 @Function      QM_ReserveQueues

 @Description   Request to Reserved queues for future use.

 @Param[in]     h_Qm            - A handle to the QM Module.
 @Param[in]     p_QmFqrParams   - A structure of parameters for defining the
                                  desired queues parameters.
 @Param[out]    p_BaseFqid      - base-fqid on success; '0' code otherwise.

 @Return        E_OK on success;

 @Cautions      Allowed only after QM_Init().
*//***************************************************************************/
t_Error QM_ReserveQueues(t_Handle h_Qm, t_QmRsrvFqrParams *p_QmFqrParams, uint32_t  *p_BaseFqid);

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

 @Description   Dumps all QM registers

 @Param[in]     h_Qm        - A handle to the QM Module.

 @Return        E_OK on success;

 @Cautions      Allowed only after QM_Init().
*//***************************************************************************/
t_Error QM_DumpRegs(t_Handle h_Qm);
#endif /* (defined(DEBUG_ERRORS) && ... */

/**************************************************************************//**
 @Function      QM_SetException

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

 @Param[in]     h_Qm        - A handle to the QM 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 QM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error QM_SetException(t_Handle h_Qm, e_QmExceptions exception, bool enable);

/**************************************************************************//**
 @Function      QM_ErrorIsr

 @Description   QM interrupt-service-routine for errors.

 @Param[in]     h_Qm            - A handle to the QM module

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

/**************************************************************************//**
 @Function      QM_GetErrorInformation

 @Description   Reads the last error information.

 @Param[in]     h_Qm        - A handle to the QM Module.
 @Param[out]    p_errInfo   - the information will be loaded to this struct.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following QM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error QM_GetErrorInformation(t_Handle h_Qm, t_QmErrorInfo *p_errInfo);

/**************************************************************************//**
 @Function      QM_GetCounter

 @Description   Reads one of the QM counters.

 @Param[in]     h_Qm        - A handle to the QM Module.
 @Param[in]     counter     - The requested counter.

 @Return        Counter's current value.

 @Cautions      Allowed only following QM_Init().
*//***************************************************************************/
uint32_t    QM_GetCounter(t_Handle h_Qm, e_QmCounters counter);

/**************************************************************************//**
 @Function      QM_GetRevision

 @Description   Returns the QM revision

 @Param[in]     h_Qm                A handle to a QM Module.
 @Param[out]    p_QmRevisionInfo    A structure of revision information parameters.

 @Return        None.

 @Cautions      Allowed only following QM_Init().
*//***************************************************************************/
t_Error QM_GetRevision(t_Handle h_Qm, t_QmRevisionInfo *p_QmRevisionInfo);

/** @} */ /* end of QM_runtime_control_grp group */


/**************************************************************************//**
 @Group         QM_runtime_data_grp QM (common) Runtime Data Unit

 @Description   QM (common) Runtime data unit API functions, definitions and enums.

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

/**************************************************************************//**
 @Function      QM_Poll

 @Description   Poll frames from QM.

 @Param[in]     h_Qm            - A handle to the QM module
 @Param[in]     source          - The selected frames type to poll

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following QM_Init().
*//***************************************************************************/
t_Error QM_Poll(t_Handle h_Qm, e_QmPortalPollSource source);

/** @} */ /* end of QM_runtime_data_grp group */
/** @} */ /* end of QM_lib_grp group */


/**************************************************************************//**
 @Group         QM_portal_grp QM-Portal API

 @Description   QM common API functions, definitions and enums.

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

/**************************************************************************//**
 @Group         QM_portal_init_grp QM-Portal Initialization Unit

 @Description   QM-Portal Initialization Unit

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

/**************************************************************************//**
 @Description   structure representing QM-Portal Stash parameters
*//***************************************************************************/
typedef struct {
    uint8_t                         stashDestQueue;         /**< This value is used to direct all stashing transactions initiated on behalf of this software portal
                                                                 to the specific Stashing Request Queues (SRQ) */
    uint8_t                         eqcr;                   /**< If 0, disabled. If 1, for every EQCR entry consumed by QMan a new stash transaction is performed.
                                                                 If 2-7, after 2-7 EQCR entries being consumed by QMAN a new stash transaction is performed. */
    bool                            eqcrHighPri;            /**< EQCR entry stash transactions for this software portal will be signaled with higher priority. */
    bool                            dqrr;                   /**< DQRR entry stash enable/disable */
    uint16_t                        dqrrLiodn;              /**< This value is attached to every transaction initiated by QMan when performing DQRR entry or EQCR_CI stashing
                                                                 on behalf of this software portal */
    bool                            dqrrHighPri;            /**< DQRR entry stash transactions for this software portal will be signaled with higher priority. */
    bool                            fdFq;                   /**< Dequeued Frame Data, Annotation, and FQ Context Stashing enable/disable */
    uint16_t                        fdFqLiodn;              /**< This value is attached to every transaction initiated by QMan when performing dequeued frame data and
                                                                 annotation stashing, or FQ context stashing on behalf of this software portal */
    bool                            fdFqHighPri;            /**< Dequeued frame data, annotation, and FQ context stash transactions for this software portal will be signaled
                                                                 with higher priority. */
    bool                            fdFqDrop;               /**< If True, Dequeued frame data, annotation, and FQ context stash transactions for this software portal will be dropped
                                                                          by QMan if the target SRQ is almost full, to prevent QMan sequencer stalling. Stash transactions that are
                                                                          dropped will result in a fetch from main memory when a core reads the addressed coherency granule.
                                                                 If FALSE, Dequeued frame data, annotation, and FQ context stash transactions for this software portal will never be
                                                                           dropped by QMan. If the target SRQ is full a sequencer will stall until each stash transaction can be completed. */
} t_QmPortalStashParam;

/**************************************************************************//**
 @Description   structure representing QM-Portal initialization parameters
*//***************************************************************************/
typedef struct {
    uintptr_t                       ceBaseAddress;          /**< Cache-enabled base address (virtual) */
    uintptr_t                       ciBaseAddress;          /**< Cache-inhibited base address (virtual) */
    t_Handle                        h_Qm;                   /**< Qm Handle */
    e_DpaaSwPortal                  swPortalId;             /**< Portal id */
    uintptr_t                       irq;                    /**< portal interrupt line; used only if useIrq set to TRUE */
    uint16_t                        fdLiodnOffset;                /**< liodn to be used for all frames enqueued via this software portal */
    t_QmReceivedFrameCallback       *f_DfltFrame;           /**< this callback will be called unless specific callback assigned to the FQ*/
    t_QmRejectedFrameCallback       *f_RejectedFrame;       /**< this callback will be called for rejected frames. */
    t_Handle                        h_App;                  /**< a handle to the upper layer; It will be passed by the driver upon calling the CB */
} t_QmPortalParam;


/**************************************************************************//**
 @Function      QM_PORTAL_Config

 @Description   Creates descriptor for a QM-Portal module.

                The routine returns a handle (descriptor) to a QM-Portal object.
                This descriptor must be passed as first parameter to all other
                QM-Portal function calls.

                No actual initialization or configuration of QM-Portal hardware is
                done by this routine.

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

 @Retval        Handle to a QM-Portal object, or NULL for Failure.
*//***************************************************************************/
t_Handle QM_PORTAL_Config(t_QmPortalParam *p_QmPortalParam);

/**************************************************************************//**
 @Function      QM_PORTAL_Init

 @Description   Initializes a QM-Portal module

 @Param[in]     h_QmPortal - A handle to a QM-Portal module

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

/**************************************************************************//**
 @Function      QM_PORTAL_Free

 @Description   Frees all resources that were assigned to a QM-Portal module.

                Calling this routine invalidates the descriptor.

 @Param[in]     h_QmPortal - A handle to a QM-Portal module

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

/**************************************************************************//**
 @Group         QM_portal_advanced_init_grp    QM-Portal Advanced Configuration Unit

 @Description   Configuration functions used to change default values.

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

/**************************************************************************//**
 @Function      QM_PORTAL_ConfigDcaMode

 @Description   Change the Discrate Consumption Acknowledge mode
                from its default configuration [FALSE].

 @Param[in]     h_QmPortal  - A handle to a QM-Portal module
 @Param[in]     enable      - Enable/Disable DCA mode

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following QM_PORTAL_Config() and before QM_PORTAL_Init().
*//***************************************************************************/
t_Error QM_PORTAL_ConfigDcaMode(t_Handle h_QmPortal, bool enable);

/**************************************************************************//**
 @Function      QM_PORTAL_ConfigStash

 @Description   Config the portal to active stash mode.

 @Param[in]     h_QmPortal      - A handle to a QM-Portal module
 @Param[in]     p_StashParams   - Pointer to data structure of parameters

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following QM_PORTAL_Config() and before QM_PORTAL_Init().
*//***************************************************************************/
t_Error QM_PORTAL_ConfigStash(t_Handle h_QmPortal, t_QmPortalStashParam *p_StashParams);


/**************************************************************************//**
 @Function      QM_PORTAL_ConfigPullMode

 @Description   Change the Pull Mode from its default configuration [FALSE].

 @Param[in]     h_QmPortal  - A handle to a QM-Portal module
 @Param[in]     pullMode    - When TRUE, the Portal will work in pull mode.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following QM_PORTAL_Config() and before QM_PORTAL_Init().
*//***************************************************************************/
t_Error QM_PORTAL_ConfigPullMode(t_Handle h_QmPortal, bool pullMode);

/** @} */ /* end of QM_portal_advanced_init_grp group */
/** @} */ /* end of QM_portal_init_grp group */


/**************************************************************************//**
 @Group         QM_portal_runtime_control_grp QM-Portal Runtime Control Unit

 @Description   QM-Portal Runtime control unit API functions, definitions and enums.

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

/**************************************************************************//**
 @Function      QM_PORTAL_AddPoolChannel

 @Description   Adding the pool channel to the SW-Portal's scheduler.
                the sw-portal will get frames that came from the pool channel.

 @Param[in]     h_QmPortal      - A handle to a QM-Portal module
 @Param[in]     poolChannelId   - Pool channel id. must between '0' to QM_MAX_NUM_OF_POOL_CHANNELS

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following QM_PORTAL_Init().
*//***************************************************************************/
t_Error QM_PORTAL_AddPoolChannel(t_Handle h_QmPortal, uint8_t poolChannelId);

/** @} */ /* end of QM_portal_runtime_control_grp group */


/**************************************************************************//**
 @Group         QM_portal_runtime_data_grp QM-Portal Runtime Data Unit

 @Description   QM-Portal Runtime data unit API functions, definitions and enums.

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

/**************************************************************************//**
 @Description structure representing QM Portal Frame Info
*//***************************************************************************/
typedef struct t_QmPortalFrameInfo {
    t_Handle    h_App;
    t_Handle    h_QmFqr;
    uint32_t    fqidOffset;
    t_DpaaFD    frame;
} t_QmPortalFrameInfo;

/**************************************************************************//**
 @Function      QM_PORTAL_Poll

 @Description   Poll frames from the specified sw-portal.

 @Param[in]     h_QmPortal      - A handle to a QM-Portal module
 @Param[in]     source          - The selected frames type to poll

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following QM_PORTAL_Init().
*//***************************************************************************/
t_Error QM_PORTAL_Poll(t_Handle h_QmPortal, e_QmPortalPollSource source);

/**************************************************************************//**
 @Function      QM_PORTAL_PollFrame

 @Description   Poll frames from the specified sw-portal. will poll only data frames

 @Param[in]     h_QmPortal      - A handle to a QM-Portal module
 @Param[out]    p_frameInfo     - A structure to hold the dequeued frame information

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following QM_PORTAL_Init().
*//***************************************************************************/
t_Error QM_PORTAL_PollFrame(t_Handle h_QmPortal, t_QmPortalFrameInfo *p_frameInfo);


/** @} */ /* end of QM_portal_runtime_data_grp group */
/** @} */ /* end of QM_portal_grp group */


/**************************************************************************//**
 @Group         QM_fqr_grp QM Frame-Queue-Range API

 @Description   QM-FQR API functions, definitions and enums.

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

/**************************************************************************//**
 @Group         QM_fqr_init_grp QM-FQR Initialization Unit

 @Description   QM-FQR Initialization Unit

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


/**************************************************************************//**
 @Description structure representing QM FQ-Range congestion group parameters
*//***************************************************************************/
typedef struct {
    t_Handle    h_QmCg;                     /**< A handle to the congestion group. */
    int8_t      overheadAccountingLength;   /**< For each frame add this number for CG calculation
                                                 (may be negative), if 0 - disable feature */
    uint32_t    fqTailDropThreshold;        /**< if not "0" - enable tail drop on this FQR */
} t_QmFqrCongestionAvoidanceParams;

/**************************************************************************//**
 @Description   structure representing QM FQ-Range initialization parameters
*//***************************************************************************/
typedef struct {
    t_Handle            h_Qm;           /**< A handle to a QM module */
    t_Handle            h_QmPortal;     /**< A handle to a QM Portal Module;
                                             will be used only for Init and Free routines;
                                             NOTE : if NULL, assuming affinity */
    bool                initParked;     /**< This FQ-Range will be initialize in park state (un-schedule) */
    bool                holdActive;     /**< This FQ-Range can be parked (un-schedule);
                                             This affects only on queues destined to software portals*/
    bool                preferInCache;  /**< Prefer this FQ-Range to be in QMAN's internal cache for all states */
    bool                useContextAForStash;/**< This FQ-Range will use context A for stash */
    union {
        struct {
            uint8_t     frameAnnotationSize;/**< Size of Frame Annotation to be stashed */
            uint8_t     frameDataSize;      /**< Size of Frame Data to be stashed. */
            uint8_t     fqContextSize;      /**< Size of FQ context to be stashed. */
            uint64_t    fqContextAddr;      /**< 40 bit memory address containing the FQ context information to be stashed;
                                                 Must be cacheline-aligned */
        } stashingParams;
        t_QmContextA    *p_ContextA;    /**< context-A field to be written in the FQ structure */
    };
    t_QmContextB        *p_ContextB;    /**< context-B field to be written in the FQ structure;
                                             Note that this field may be used for Tx queues only! */
    e_QmFQChannel       channel;        /**< Qm Channel */
    uint8_t             wq;             /**< Work queue within the channel */
    bool                shadowMode;     /**< If TRUE, useForce MUST set to TRUE and numOfFqids MUST set to '1' */
    uint32_t            numOfFqids;     /**< number of fqids to be allocated*/
    bool                useForce;       /**< TRUE - force allocation of specific fqids;
                                             FALSE - allocate several fqids */
    union{
        struct {
            uint32_t    align;          /**< alignment. will be used if useForce=FALSE */
        } nonFrcQs;
        struct {
            uint32_t    fqid;           /**< the fqid base of the forced fqids. will be used if useForce=TRUE */
        } frcQ;
    } qs;
    bool                congestionAvoidanceEnable;
                                        /**< TRUE to enable congestion avoidance mechanism */
    t_QmFqrCongestionAvoidanceParams    congestionAvoidanceParams;
                                        /**< Parameters for congestion avoidance */
} t_QmFqrParams;


/**************************************************************************//**
 @Function      QM_FQR_Create

 @Description   Initializing and enabling a Frame-Queue-Range.
                This routine should be called for adding an FQR.

 @Param[in]     p_QmFqrParams   - A structure of parameters for defining the
                                  desired queues parameters.

 @Return        A handle to the initialized FQR on success; NULL code otherwise.

 @Cautions      Allowed only following QM_Init().
*//***************************************************************************/
t_Handle QM_FQR_Create(t_QmFqrParams *p_QmFqrParams);

/**************************************************************************//**
 @Function      QM_FQR_Free

 @Description   Deleting and free all resources of an initialized FQR.

 @Param[in]     h_QmFqr         - A handle to a QM-FQR Module.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following QM_Init() and QM_FQR_Create() for this FQR.
*//***************************************************************************/
t_Error QM_FQR_Free(t_Handle h_QmFqr);

/**************************************************************************//**
 @Function      QM_FQR_FreeWDrain

 @Description   Deleting and free all resources of an initialized FQR
                with the option of draining.

 @Param[in]     h_QmFqr         - A handle to a QM-FQR Module.
 @Param[in]     f_CompletionCB  - Pointer to a completion callback to be used in non-blocking mode.
 @Param[in]     deliverFrame    - TRUE for deliver the drained frames to the user;
                                  FALSE for not deliver the frames.
 @Param[in]     f_CallBack      - Pointer to a callback to handle the delivered frames.
 @Param[in]     h_App           - User's application descriptor.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following QM_Init() and QM_FQR_Create() for this FQR.
*//***************************************************************************/
t_Error QM_FQR_FreeWDrain(t_Handle                     h_QmFqr,
                          t_QmFqrDrainedCompletionCB   *f_CompletionCB,
                          bool                         deliverFrame,
                          t_QmReceivedFrameCallback    *f_CallBack,
                          t_Handle                     h_App);

/** @} */ /* end of QM_fqr_init_grp group */


/**************************************************************************//**
 @Group         QM_fqr_runtime_control_grp QM-FQR Runtime Control Unit

 @Description   QM-FQR Runtime control unit API functions, definitions and enums.

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

/**************************************************************************//**
 @Description   enum for defining QM-FQR counters
*//***************************************************************************/
typedef enum e_QmFqrCounters {
    e_QM_FQR_COUNTERS_FRAME = 0,        /**< Total number of frames on this frame queue */
    e_QM_FQR_COUNTERS_BYTE              /**< Total number of bytes in all frames on this frame queue */
} e_QmFqrCounters;

/**************************************************************************//**
 @Function      QM_FQR_RegisterCB

 @Description   Register a callback routine to be called when a frame comes from this FQ-Range

 @Param[in]     h_QmFqr         - A handle to a QM-FQR Module.
 @Param[in]     f_CallBack      - An application callback
 @Param[in]     h_App           - User's application descriptor

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following QM_FQR_Create().
*//***************************************************************************/
t_Error QM_FQR_RegisterCB(t_Handle h_QmFqr, t_QmReceivedFrameCallback *f_CallBack, t_Handle h_App);

/**************************************************************************//**
 @Function      QM_FQR_Resume

 @Description   Request to Re-Schedule this Fqid.

 @Param[in]     h_QmFqr         - A handle to a QM-FQR Module.
 @Param[in]     h_QmPortal      - A handle to a QM Portal Module;
                                  NOTE : if NULL, assuming affinity.
 @Param[in]     fqidOffset      - Fqid offset within the FQ-Range.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following QM_FQR_Create().
*//***************************************************************************/
t_Error QM_FQR_Resume(t_Handle h_QmFqr, t_Handle h_QmPortal, uint32_t fqidOffset);

/**************************************************************************//**
 @Function      QM_FQR_Suspend

 @Description   Request to Un-Schedule this Fqid.

 @Param[in]     h_QmFqr         - A handle to a QM-FQR Module.
 @Param[in]     h_QmPortal      - A handle to a QM Portal Module;
                                  NOTE : if NULL, assuming affinity.
 @Param[in]     fqidOffset      - Fqid offset within the FQ-Range.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following QM_FQR_Create().
*//***************************************************************************/
t_Error QM_FQR_Suspend(t_Handle h_QmFqr, t_Handle h_QmPortal, uint32_t fqidOffset);

/**************************************************************************//**
 @Function      QM_FQR_GetFqid

 @Description   Returned the Fqid base of the FQ-Range

 @Param[in]     h_QmFqr         - A handle to a QM-FQR Module.

 @Return        Fqid base.

 @Cautions      Allowed only following QM_FQR_Create().
*//***************************************************************************/
uint32_t QM_FQR_GetFqid(t_Handle h_QmFqr);

/**************************************************************************//**
 @Function      QM_FQR_GetCounter

 @Description   Reads one of the QM-FQR counters.

 @Param[in]     h_QmFqr         - A handle to a QM-FQR Module.
 @Param[in]     h_QmPortal      - A handle to a QM Portal Module;
                                  NOTE : if NULL, assuming affinity.
 @Param[in]     fqidOffset      - Fqid offset within the FQ-Range.
 @Param[in]     counter         - The requested counter.

 @Return        Counter's current value.

 @Cautions      Allowed only following QM_FQR_Create().
*//***************************************************************************/
uint32_t QM_FQR_GetCounter(t_Handle h_QmFqr, t_Handle h_QmPortal, uint32_t fqidOffset, e_QmFqrCounters counter);

/** @} */ /* end of QM_fqr_runtime_control_grp group */


/**************************************************************************//**
 @Group         QM_fqr_runtime_data_grp QM-FQR Runtime Data Unit

 @Description   QM-FQR Runtime data unit API functions, definitions and enums.

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

/**************************************************************************//**
 @Function      QM_FQR_Enqueue

 @Description   Enqueue the frame into the FQ to be transmitted.

 @Param[in]     h_QmFqr         - A handle to a QM-FQR Module.
 @Param[in]     h_QmPortal      - A handle to a QM Portal Module;
                                  NOTE : if NULL, assuming affinity.
 @Param[in]     fqidOffset      - Fqid offset within the FQ-Range.
 @Param[in]     p_Frame         - Pointer to the frame to be enqueued.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following QM_FQR_Create().
*//***************************************************************************/
t_Error QM_FQR_Enqueue(t_Handle h_QmFqr, t_Handle h_QmPortal, uint32_t fqidOffset, t_DpaaFD *p_Frame);

/**************************************************************************//**
 @Function      QM_FQR_PullFrame

 @Description   Perform a Pull command.

 @Param[in]     h_QmFqr         - A handle to a QM-FQR Module.
 @Param[in]     h_QmPortal      - A handle to a QM Portal Module;
                                  NOTE : if NULL, assuming affinity.
 @Param[in]     fqidOffset      - Fqid offset within the FQ-Range.
 @Param[out]    p_Frame         - The Received Frame

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following QM_PORTAL_Init().
*//***************************************************************************/
t_Error QM_FQR_PullFrame(t_Handle h_QmFqr, t_Handle h_QmPortal, uint32_t fqidOffset, t_DpaaFD *p_Frame);


/** @} */ /* end of QM_fqr_runtime_data_grp group */
/** @} */ /* end of QM_fqr_grp group */


/**************************************************************************//**
 @Group         QM_cg_grp QM Congestion Group API

 @Description   QM-CG API functions, definitions and enums.

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

/**************************************************************************//**
 @Group         QM_cg_init_grp QM-Congestion Group Initialization Unit

 @Description   QM-CG Initialization Unit

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

/**************************************************************************//**
 @Description   structure representing QM CG WRED curve
*//***************************************************************************/
typedef struct t_QmCgWredCurve {
    uint32_t    maxTh;                  /**< minimum threshold - below this level
                                             all packets are rejected (approximated
                                             to be expressed as x*2^y due to HW
                                             implementation)*/
    uint32_t    minTh;                  /**< minimum threshold - below this level
                                             all packets are accepted (approximated
                                             due to HW implementation)*/
    uint8_t    probabilityDenominator;  /**< 1-64, the fraction of packets dropped
                                             when the average queue depth is at the
                                             maximum threshold.(approximated due to HW
                                             implementation). */
} t_QmCgWredCurve;

/**************************************************************************//**
 @Description   structure representing QM CG WRED parameters
*//***************************************************************************/
typedef struct t_QmCgWredParams {
    bool            enableGreen;
    t_QmCgWredCurve greenCurve;
    bool            enableYellow;
    t_QmCgWredCurve yellowCurve;
    bool            enableRed;
    t_QmCgWredCurve redCurve;
} t_QmCgWredParams;

/**************************************************************************//**
 @Description   structure representing QM CG configuration parameters
*//***************************************************************************/
typedef struct t_QmCgParams {
    t_Handle                h_Qm;           /**< A handle to a QM module */
    t_Handle                h_QmPortal;     /**< A handle to a QM Portal Module;
                                                 will be used for Init, Free and as
                                                 an interrupt destination for cg state
                                                 change (if CgStateChangeEnable = TRUE) */
    bool                    frameCount;     /**< TRUE for frame count, FALSE - byte count */
    bool                    wredEnable;     /**< if TRUE - WRED enabled. Each color is enabled independently
                                                 so that some colors may use WRED, but others may use
                                                 Tail drop - if enabled, or none.  */
    t_QmCgWredParams        wredParams;     /**< WRED parameters, relevant if wredEnable = TRUE*/
    bool                    tailDropEnable; /**< if TRUE - Tail drop enabled */
    uint32_t                threshold;      /**< If Tail drop - used as Tail drop threshold, otherwise
                                                 'threshold' may still be used to receive notifications
                                                 when threshold is passed. If threshold and f_Exception
                                                 are set, interrupts are set defaultly by driver. */
    bool                    notifyDcPortal; /**< Relevant if this CG receives enqueues from a direct portal
                                                 e_DPAA_DCPORTAL0 or e_DPAA_DCPORTAL1. TRUE to notify
                                                 the DC portal, FALSE to notify this SW portal. */
    e_DpaaDcPortal          dcPortalId;     /**< relevant if notifyDcPortal=TRUE - DC Portal id */
    t_QmExceptionsCallback  *f_Exception;   /**< relevant and mandatory if threshold is configured and
                                                 notifyDcPortal = FALSE. If threshold and f_Exception
                                                 are set, interrupts are set defaultly by driver */
    t_Handle                h_App;          /**< A handle to the application layer, will be passed as
                                                 argument to f_Exception */
} t_QmCgParams;


/**************************************************************************//**
 @Function      QM_CG_Create

 @Description   Create and configure a congestion Group.

 @Param[in]     p_CgParams      - CG parameters

 @Return        A handle to the CG module

 @Cautions      Allowed only following QM_Init().
*//***************************************************************************/
t_Handle    QM_CG_Create(t_QmCgParams *p_CgParams);

/**************************************************************************//**
 @Function      QM_CG_Free

 @Description   Deleting and free all resources of an initialized CG.

 @Param[in]     h_QmCg         - A handle to a QM-CG Module.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following QM_Init() and QM_CR_Create() for this CG.
*//***************************************************************************/
t_Error QM_CG_Free(t_Handle h_QmCg);

/** @} */ /* end of QM_cg_init_grp group */


/**************************************************************************//**
 @Group         QM_cg_runtime_control_grp QM-CG Runtime Control Unit

 @Description   QM-CG Runtime control unit API functions, definitions and enums.

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

/**************************************************************************//**
 @Description   structure representing QM CG WRED colors
*//***************************************************************************/
typedef enum e_QmCgColor {
    e_QM_CG_COLOR_GREEN,
    e_QM_CG_COLOR_YELLOW,
    e_QM_CG_COLOR_RED
} e_QmCgColor;

/**************************************************************************//**
 @Description   structure representing QM CG modification parameters
*//***************************************************************************/
typedef struct t_QmCgModifyWredParams {
    e_QmCgColor         color;
    bool                enable;
    t_QmCgWredCurve     wredParams;
} t_QmCgModifyWredParams;


/**************************************************************************//**
 @Function      QM_CG_SetException

 @Description   Set CG exception.

 @Param[in]     h_QmCg         - A handle to a QM-CG Module.
 @Param[in]     exception      - exception enum
 @Param[in]     enable         - TRUE to enable, FALSE to disable.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following QM_Init() and QM_CG_Create() for this CG.
*//***************************************************************************/
t_Error QM_CG_SetException(t_Handle h_QmCg, e_QmExceptions exception, bool enable);

/**************************************************************************//**
 @Function      QM_CG_ModifyWredCurve

 @Description   Change WRED curve parameters for a selected color.
                Note that this routine may be called only for valid CG's that
                already have been configured for WRED, and only need a change
                in the WRED parameters.

 @Param[in]     h_QmCg              - A handle to a QM-CG Module.
 @Param[in]     p_QmCgModifyParams  - A structure of new WRED parameters.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following QM_Init() and QM_CG_Create() for this CG.
*//***************************************************************************/
t_Error QM_CG_ModifyWredCurve(t_Handle h_QmCg, t_QmCgModifyWredParams *p_QmCgModifyParams);

/**************************************************************************//**
 @Function      QM_CG_ModifyTailDropThreshold

 @Description   Change WRED curve parameters for a selected color.
                Note that this routine may be called only for valid CG's that
                already have been configured for tail drop, and only need a change
                in the threshold value.

 @Param[in]     h_QmCg              - A handle to a QM-CG Module.
 @Param[in]     threshold           - New threshold.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following QM_Init() and QM_CG_Create() for this CG.
*//***************************************************************************/
t_Error QM_CG_ModifyTailDropThreshold(t_Handle h_QmCg, uint32_t threshold);


/** @} */ /* end of QM_cg_runtime_control_grp group */
/** @} */ /* end of QM_cg_grp group */
/** @} */ /* end of QM_grp group */


#endif /* __QM_EXT_H */