summaryrefslogtreecommitdiff
path: root/Acceleration/include/accel_infra/IxQMgr.h
blob: faf46669d5ea058733281173f3d0ca28967d49d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
/**
 * @file    IxQMgr.h
 *
 *
 * @brief This file contains the Moher Software public API of IxQMgr component.
 *
 * 
 * @par
 * This file is provided under a dual BSD/GPLv2 license.  When using or 
 *   redistributing this file, you may do so under either license.
 * 
 *   GPL LICENSE SUMMARY
 * 
 *   Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
 * 
 *   This program is free software; you can redistribute it and/or modify 
 *   it under the terms of version 2 of the GNU General Public License as
 *   published by the Free Software Foundation.
 * 
 *   This program is distributed in the hope that it will be useful, but 
 *   WITHOUT ANY WARRANTY; without even the implied warranty of 
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
 *   General Public License for more details.
 * 
 *   You should have received a copy of the GNU General Public License 
 *   along with this program; if not, write to the Free Software 
 *   Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
 *   The full GNU General Public License is included in this distribution 
 *   in the file called LICENSE.GPL.
 * 
 *   Contact Information:
 *   Intel Corporation
 * 
 *   BSD LICENSE 
 * 
 *   Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
 *   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 Intel Corporation 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 *   "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 THE COPYRIGHT 
 *   OWNER OR CONTRIBUTORS 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.
 * 
 * 
 *
 */
 
/* ------------------------------------------------------
   Doxygen group definitions
   ------------------------------------------------------ */
/**
 * @defgroup IxQMgrAPI Software Queue Manager (IxQMgr) API
 *
 * @brief The public API for the Software QMgr component.
 *
 * @{
 */

#ifndef IXQMGR_H
#define IXQMGR_H

/*
 * User defined include files
 */
 
 
#include "IxOsal.h"
#include "icp.h"
#include "IxSwQueue.h"


/**
*
* @ingroup IxQMgrAPI
*
* @def IX_COMPONENT_NAME
*
* @brief defines the name of this component
*
*/
#define IX_COMPONENT_NAME IX_QMGR


/*
 * #defines and macros
 */

/**
*
* @ingroup IxQMgrAPI
*
* @def IX_QMGR_INLINE
*
* @brief Inline definition, for inlining of Queue Access functions on API
*
* Please read the header information in this file for more details on the
* use of function inlining in this component.
*
*/
#ifdef IXQMGRQACCESS_C
/* If IXQMGRQACCESS_C is set then the IxQmgrQAccess.c is including this file
   and must instantiate a concrete definition for each inlineable API function
   whether or not that function actually gets inlined. */
#    ifdef NO_INLINE_APIS
#        undef NO_INLINE_APIS
#    endif
#    define IX_QMGR_INLINE  /* Empty Define */
#else
#    ifndef NO_INLINE_APIS
#       define IX_QMGR_INLINE __inline__ extern
#    else
#       define IX_QMGR_INLINE /* Empty Define */
#    endif
#endif


/**
*
* @ingroup IxQMgrAPI
*
* @def IX_QMGR_MAX_NUM_QUEUES
*
* @brief Number of software queues supported by the QMgr component.
*
* This constant is used to indicate the number of queues
*
*/
#define IX_QMGR_MAX_NUM_QUEUES  (512)


/**
*
* @ingroup IxQMgrAPI
*
* @def IX_QMGR_MAX_QNAME_LEN
*
* @brief Maximum queue name length.
*
* This constant is used to indicate the maximum null terminated string length
* (excluding '\0') for a queue name
*
*/
#define IX_QMGR_MAX_QNAME_LEN (16)

/**
 *
 * @ingroup IxQMgrAPI
 *
 * @def IX_QMGR_Q_MAX_SIZE
 *
 * @brief Maximum Allowed Size for a Queue
 * 
 * As Head and Tail are Max 16-bits this figure must be less than 2^16
 * If this size is ever increased > 2^16, additional overflow checks will be
 * required during config.
 */
#define IX_QMGR_Q_MAX_SIZE (32768)


/**
 *
 * @ingroup IxQMgrAPI
 *
 * @def IX_QMGR_Q_MAX_ENTRY_SIZE
 *
 * @brief Maximum Allowed Entry Size for a Queue in words
 *
 * Entry Size will also be limited to 2^n values:   1,2,4,8.
 *
 */
#define IX_QMGR_Q_ENTRY_MAX_SIZE (8)

/**
 *
 * @ingroup IxQMgrAPI
 *
 * @def IX_QMGR_MAX_BYTE_COUNT
 *
 * @brief Max count value of 8-bits 
 *
 */
#define IX_QMGR_MAX_BYTE_COUNT (256) 


/**
 *
 * @ingroup IxQMgrAPI
 *
 * @def IX_QMGR_SIZEOF_WORD
 *
 * @brief The sizeof() a 32-bit word. value in bytes.
 *
 */
#define IX_QMGR_SIZEOF_WORD (4)

/**
 *
 * @ingroup IxQMgrAPI
 *
 * @def IX_QMGR_SIZEOF_BYTE
 *
 * @brief The sizeof() a 8-bit byte. value in bytes.
 *
 */
#define IX_QMGR_SIZEOF_BYTE (1)

/*
 * Mechanism to validate the upper (MAX) and lower (0) bounds
 * of a positive enumeration
 *
 * param int [in] VALUE - the integer value to test
 * param int [in] MAX - the maximum value to test against
 *
 * This macro returns TRUE if the bounds are invalid and FALSE if
 * they are okay. NOTE: MAX will be an invalid value, so check >=
 *
 */
#define IX_QMGR_ENUM_IS_INVALID(VALUE, MAX)   \
        ((((VALUE) < 0) || ((VALUE) >= (MAX))) ? TRUE : FALSE)


/**
 *
 * @ingroup IxQMgrAPI
 *
 * @def IX_QMGR_MASK_8BIT
 *
 * @brief A mask for 8-bits.
 *
 */
#define IX_QMGR_MASK_8BIT (0xFF)


/**
 *
 * @ingroup IxQMgrAPI
 *
 * @def IX_QMGR_MASK_16BIT
 *
 * @brief A mask for 16-bits.
 *
 */
#define IX_QMGR_MASK_16BIT (0xFFFF)

/*
 * Typedefs
 */

/**
 *
 * @typedef IxQMgrQId
 *
 * @ingroup IxQMgrAPI
 *
 * @brief Generic identifiers for queues.
 *
 * This defines generic identifiers for the queues.
 */
typedef UINT32 IxQMgrQId;


/**
 *
 * @typedef IxQMgrQEntryType
 *
 * @ingroup IxQMgrAPI
 *
 * @brief Entry Type for all Queue Entries
 *
 * This defines generic Entry for the queues.
 */
typedef UINT32 IxQMgrQEntryType;


/**
 * @enum IxQMgrNotificationCondition
 *
 * @ingroup IxQMgrAPI
 *
 * @brief Queue interrupt condition.
 *
 * This enum defines the different conditions on a queue that the client can register for
 * a callback notification by the dispatcher.
 *
 */
typedef enum
{
    IX_QMGR_Q_SOURCE_ID_E = 0,       /**< Queue Empty due to last read */
    IX_QMGR_Q_SOURCE_ID_NOT_E,  /**< Queue Not Empty  */
    IX_QMGR_Q_SOURCE_ID_BW,     /**< Queue Number of entries Below Watermark */
    IX_QMGR_Q_SOURCE_ID_AW,     /**< Queue Number of entries Above Watermark */
    IX_QMGR_Q_SOURCE_ID_NOT_F,  /**< Queue Not Full  */
    IX_QMGR_Q_SOURCE_ID_F,      /**< Queue Full  */
    IX_QMGR_Q_SOURCE_INVALID	/**< For Parameter validation purposes only */
} IxQMgrNotificationCondition;

/**
 * @typedef IxQMgrQState
 *
 * @ingroup IxQMgrAPI
 *
 * @brief Queue state.
 *
 * A queues status is defined by its relative fullness or relative emptiness.
 * Each of the queues can be in the following states: Below Watermark, 
 * Above Watermark, Empty, Full.
 *
 */
typedef enum
{
   IX_QMGR_Q_STATE_E = IX_QMGR_Q_SOURCE_ID_E,  /**< Queue Empty  */
   IX_QMGR_Q_STATE_BW = IX_QMGR_Q_SOURCE_ID_BW,     /**< Queue Number of Entries Below Watermark */
   IX_QMGR_Q_STATE_AW = IX_QMGR_Q_SOURCE_ID_AW,     /**< Queue Number of entries Above Watermark */
   IX_QMGR_Q_STATE_F = IX_QMGR_Q_SOURCE_ID_F        /**< Queue Full */
} IxQMgrQState;

/**
 * @typedef IxQMgrQSize
 *
 * @ingroup IxQMgrAPI
 *
 * @brief QMgr queue sizes.
 *
 * These values define the allowed queue sizes for a queue. The sizes are
 * specified in words, 1 word per entry. The Queue Size must be equal to 2^n. 
 * the theoritical maximum size for a queue will be 2^15 as the last bit 
 * is reserved and the queue counter used to manipulate the queues are 16 bits long.
 * however native size for xscale is 32 bits, so for better efficiency 32 bit 
 * long variables are used.
 *
 */
typedef UINT32 IxQMgrQSize;


/**
 * @typedef IxQMgrQEntrySizeInWords
 *
 * @ingroup IxQMgrAPI
 *
 * @brief QMgr queue entry sizes in owrds.
 *
 * These values define the allowed queue entry sizes for a queue. The Entry Size 
 * must be equal to 2^n. The maximum size for a queue will be 
 * IX_QMGR_Q_ENTRY_MAX_SIZE
 *
 */
typedef UINT32 IxQMgrQEntrySizeInWords;


/**
 * @typedef IxQMgrWMLevel
 *
 * @ingroup IxQMgrAPI
 *
 * @brief QMgr watermark levels.
 *
 * defines the watermark level for queues, 
 * the level will be limited to a range from 1 to the Queue Size minus 1.
 * This restriction will be enforced when setting the watermark level.
 */
typedef UINT32 IxQMgrWMLevel;


/**
 * @ingroup IxQMgrAPI
 * 
 * @typedef IxQMgrDispatchGroup
 *
 * @brief QMgr dispatch group identifiers.
 *
 * This type defines the logical groups of queues which the  dispatcher should 
 * process when called. each queue belongs to a single group. A group will be 
 * used as an input to ixQMgrDispatcherLoopRun().When configuring a Queue, 
 * the client will specify the group which it belongs to. 
 * valid group ID will be between 0 and MAX_DISPATCH_GRP_ID.
 *
 */
typedef UINT32 IxQMgrDispatchGroup;


/**
 *
 * @ingroup IxQMgrAPI
 *
 * @def IX_QMGR_DISPATCH_ETH
 *
 * @brief Reserved Dispatch Group ID for Ethernet 10/100 feature
 *
 */
#define IX_QMGR_DISPATCH_ETH (0)



/**
 *
 * @ingroup IxQMgrAPI
 *
 * @def IX_QMGR_DISPATCH_HSS
 *
 * @brief Reserved Dispatch Group ID for HSS feature Transmit Queues
 *
 */
#define IX_QMGR_DISPATCH_TX_HSS (1)



/**
 *
 * @ingroup IxQMgrAPI
 *
 * @def IX_QMGR_DISPATCH_HSS
 *
 * @brief Reserved Dispatch Group ID for HSS feature Voice Receive Queues
 *
 */
#define IX_QMGR_DISPATCH_VOICE_RX_HSS (2)


/**
 *
 * @ingroup IxQMgrAPI
 *
 * @def IX_QMGR_DISPATCH_HSS
 *
 * @brief Reserved Dispatch Group ID for HSS feature HDLC Receive Queues
 *
 */
#define IX_QMGR_DISPATCH_HDLC_RX_HSS (3)



/**
 *
 * @ingroup IxQMgrAPI
 *
 * @def IX_QMGR_MAX_DISPATCH_GRP_ID
 *
 * @brief Maximum Dispatch group ID authorised
 *
 */
#define IX_QMGR_MAX_NUM_DISPATCH_GRP (IX_QMGR_MAX_NUM_QUEUES)


/**
 * @ingroup IxQMgrAPI
 * 
 * @typedef IxQMgrCallbackId
 *
 * @brief Uniquely identifies a callback function.
 *
 * A unique callback identifier associated with each callback
 * registered by clients.
 *
 */
typedef UINT32 IxQMgrCallbackId;


/**
 * 
 * @ingroup IxQMgrAPI
 * 
 * @typedef IxQMgrCallback
 *
 * @brief QMgr notification callback type.
 *
 * This defines the interface to all client callback functions.
 *
 * @param IxQMgrQId qId(in) - the queue identifier
 * @param IxQMgrCallbackId cbId(in) - the callback identifier
 */
typedef void (*IxQMgrCallback)(IxQMgrQId qId,
                               IxQMgrCallbackId cbId);

/**
 * @ingroup IxQMgrAPI
 * 
 * @typedef IxSwQueueOfType_IxQMgrQEntryType
 * 
 * @brief the macro used here creates the Software Queue Type used 
 * throughout the Queue Manager.
 */
IX_SWQ_TYPE(IxQMgrQEntryType,IxQMgrSwQueue);


/**
 * @ingroup IxQMgrAPI
 * 
 * @typedef IxQMgrHeadAndTailCountFormat
 * 
 * @brief The count type of the Head and Tail pointer 
 *
 * This enum is used to indicate whether the Head and Tail pointers for a queue
 * count by the number of bytes or by the number of entries.
 */
typedef enum
{
   IX_QMGR_Q_COUNT_BYTES = 0,  
   IX_QMGR_Q_COUNT_ENTRIES,
   IX_QMGR_Q_COUNT_INVALID
   
} IxQMgrHeadAndTailCountFormat;

/**
 * @ingroup IxQMgrAPI
 * 
 * @typedef IxQMgrHeadAndTailAlignment
 * 
 * @brief The alignment of the Head and Tail
 *
 * This enum is used to indicate the alignment of the Head and Tail pointers of 
 * a queue. Note that in the case of Word alignment, only 16-bits are actually
 * used for counting. 
 */
typedef enum
{
   IX_QMGR_Q_ALIGN_BYTE = 0,  
   IX_QMGR_Q_ALIGN_WORD, 
   IX_QMGR_Q_ALIGN_INVALID
} IxQMgrHeadAndTailAlignment;


/**
 * @ingroup IxQMgrAPI
 * 
 * @typedef IxQMgrShadowCounter
 *
 * @brief Data Structure containing the shadowing information (the shadow tail 
 * and the real tail counters) for a queue.
 *
 */
 
typedef struct
{
    union
    {
         UINT8 byteShadowTailCounter;
         UINT32 wordShadowTailCounter;
    };
    union
    {
         volatile UINT8 *byteRealTailCounter;
         volatile UINT32 *wordRealTailCounter;
    };    
        
} IxQMgrShadowCounter;



/**
 * @ingroup IxQMgrAPI
 * 
 * @typedef IxQMgrHeadAndTailShadowing
 * 
 * @brief The shadowing of the queue counters 
 *
 * This enum is used to indicate the type of shadowing that should be usd for a 
 * queue. 
 */
typedef enum
{
   IX_QMGR_Q_NO_SHADOWING = 0,  
   IX_QMGR_Q_SHADOW_TAIL_ONLY, 
   IX_QMGR_Q_SHADOW_HEAD_ONLY,    
   IX_QMGR_Q_SHADOW_HEAD_TAIL,   
   IX_QMGR_Q_SHADOW_INVALID
} IxQMgrHeadAndTailShadowing;
/**
 * @ingroup IxQMgrAPI
 * 
 * @typedef IxQMgrQueue
 *
 * @brief Data Structure containing all the relevant information regarding a queue
 *
 */
typedef struct
{
    char qName[IX_QMGR_MAX_QNAME_LEN];          /**< name of the queue */
    IxQMgrQSize qSize;			        /**< queue size in entries */
    IxQMgrQEntrySizeInWords qEntrySize;		/**< queue entry size in words */
    IxQMgrSwQueue queue;			/**< the queue */
    IxQMgrDispatchGroup group;			/**< the group the queue belongs to*/
    IxQMgrQId nextQId;				/**< the next Q in the list for 
						   the group the Q belongs to, only 
						   set once notification is enabled */
    IxQMgrQId prevQId;				/**< the previous Q in the list */ 
    IxQMgrCallback callback;		        /**< the callback function to be 
						   used in case of notification */
    IxQMgrCallbackId callbackId;	        /**< the Id to be used when using 
						   the callback */
    IxQMgrWMLevel waterMark;		        /**< the watermark level for this queue */
    IxQMgrNotificationCondition notifCond;	/**< The condition that will 
						   trigger a notif by the dispatcher*/
    IxQMgrHeadAndTailCountFormat htCountFormat; /**<the head (write) and tail 
                                                (read) count format*/
    IxQMgrHeadAndTailAlignment htAlignment;     /**<the head (write) and tail 
                                                (read) alignment */
    IxQMgrHeadAndTailShadowing shadowing;       /**<the head (write) and tail 
                                                (read) shadowing */
    IxQMgrShadowCounter shadowInfo;             /**<the shadowing data struct */
} IxQMgrQueue;


/* for inline function include the private queue data */
#ifndef NO_INLINE_APIS
extern IxQMgrQueue ixQMgrQueues [IX_QMGR_MAX_NUM_QUEUES]; 
#endif


/*
 * Function Prototypes
 */


/* ------------------------------------------------------------
   Initialisation related functions
   ---------------------------------------------------------- */
/**
 *
 * @ingroup IxQMgrAPI
 *
 * @fn ixQMgrInit (void)
 *
 * @brief Initialise the QMgr.
 *
 * This function must be called before any other QMgr function. It
 * sets up internal data structures.
 *
 * - Reentrant    - no
 * - ISR Callable - no
 *
 * @return @li ICP_STATUS_SUCCESS, the IxQMgr successfully initialised
 * @return @li ICP_STATUS_FAIL, failed to initialize the QMgr
 *
 */
icp_status_t
ixQMgrInit (void);

/**
 *
 * @ingroup IxQMgrAPI
 *
 * @fn ixQMgrUnload (void)
 *
 * @brief Uninitialise the QMgr.
 *
 * This function will perform the tasks required to unload the QMgr component
 * cleanly.  This should be called before a soft reboot or unloading of a 
 * kernel module.
 * It is normal behaviour for this function to return a fail if it cannot be 
 * unloaded due to it being still used by another client. 
 *
 * @pre It should only be called if @ref ixQMgrInit has already been called. It 
 * will only be successful if all groups of queues that were configured have 
 * been unconfigured using the ixQMgrUnconfigGroup() function.
 * 
 *
 * @post No QMgr functions should be called until ixQMgrInit is called again.
 *
 * - Reentrant    - no
 * - ISR Callable - no
 *
 * @return @li ICP_STATUS_SUCCESS, the IxQMgr successfully uninitialised
 * @return @li ICP_STATUS_FAIL, failed to uninitialize the Qmgr
 * @return @li ICP_STATUS_RESOURCE, A configure queue operation is in progress, 
 *                             IxQMgr cannot be unloaded at this time
 *
 */
 
icp_status_t
ixQMgrUnload (void);

/**
 *
 * @ingroup IxQMgrAPI
 *
 * @fn ixQMgrShow (void)
 *
 * @brief Describe queue configuration and statistics.
 *
 * This function shows configured queues, their configurations and overall statistics.
 *
 * - Reentrant    - no
 * - ISR Callable - no
 *
 * @return @li void
 *
 */
 void
ixQMgrShow (void);

/**
 *
 * @ingroup IxQMgrAPI
 *
 * @fn ixQMgrQShow (IxQMgrQId qId)
 *
 * @brief Display a queue configuration and current state.
 *
 * This function shows queue configuration.
 *
 * @param IxQMgrQId (in)qId - the queue identifier.
 *
 * - Reentrant    - no
 * - ISR Callable - no
 *
 * @return @li ICP_STATUS_SUCCESS, success
 * @return @li ICP_STATUS_INVALID_PARAM, queue not configured for this QId
 *
 */
icp_status_t
ixQMgrQShow (IxQMgrQId qId);


/**
 *
 * @ingroup IxQMgrAPI
 *
 * @fn ixQMgrGroupMemoryConfig (IxQMgrDispatchGroup group, void * baseAddressToFlush, void * baseAddressToInvalidate, UINT32 size)
 *
 * @brief Sets the base address and the size of the memory area that will be invalidated when the dispatch loop function will run.
 *
 * @param IxQMgrDispatchGroup (in)group - the Dispatch Group Identifier
 * @param void * (in)baseAddress - address of the start of the cached memory
 * @param UINT32 (in)size - size of cache.
 *
 * - Reentrant    - no
 * - ISR Callable - no
 *
 * @return @li ICP_STATUS_SUCCESS, success
 * @return @li ICP_STATUS_INVALID_PARAMOR, invalid parameter
 *
 */
icp_status_t
ixQMgrGroupMemoryConfig (IxQMgrDispatchGroup group, 
			 void * baseAddressToFlush,
			 void * baseAddressToInvalidate,
			 UINT32 size);


/* ------------------------------------------------------------
   Configuration related functions
   ---------------------------------------------------------- */ 
/**
 *
 * @ingroup IxQMgrAPI
 * 
 * @fn ixQMgrQConfig (char *qName,
	       IxQMgrQId *qId,
	       IxQMgrQSize qSize,
	       IxQMgrQEntrySizeInWords qEntrySize,
	       IxQMgrHeadAndTailCountFormat htCountFormat,
   	       IxQMgrHeadAndTailAlignment htAlignment,
	       IxQMgrDispatchGroup group,
	       IxQMgrHeadAndTailShadowing shadowing,
	       void *qBaseAddress,
	       void *qHeadCountPtr,
	       void *qTailCountPtr)
 *
 * @brief Configure a Software queue.
 *
 * This function is called by a client to setup a queue, the queue stores 
 * entries in memory, each entry will be of size qEntrySize words. All parameters
 * are checked for valid values. This function must be called for each queue, 
 * before any queue accesses are made and after ixQMgrInit() has been called. 
 * qName is assumed to be a '\0' terminated array of 16 characters or less.
 * The Queue Manager component allocates a QId on configuration and returns
 * it to the client. Both Head and Tail Counter are 16bits, the queue manager component
 * will only support these counters in Big Endian mode, there will be no support 
 * for Little Endian.
 *
 * @param char(in) *qName - is the name provided by the client and is associated
 *                          with a QId by the QMgr.
 * @param IxQMgrQId(out)  *qId - the returned qId of this queue
 * @param IxQMgrQSize(in) qSize - the 2^n number of entries of the queue. 
 * @param IxQMgrQEntrySizeInWords(in) qEntrySize - the 2^n size of the queue entry 
 * can be up to 8 words (i.e. must be 1,2,4 or 8 words in size).
 * @param IxQMgrHeadAndTailCountFormat(in) htCountFormat - the format that Head 
 * and Tail counters will use. Either count by bytes or count by entries.
 * @param IxQMgrHeadAndTailAlignment(in) htAlignment - the alignment of the Head 
 * and Tail Counters. Either Word or byte aligned.
 * @param IxQMgrDispatchGroup(in) group - the group this queue belongs to. this 
 * will be used by the dispatcher to determine which queues to service.
 * @param IxQMgrHeadAndTailShadowing(in) shadowing - the counters that should be 
 * shadowed 
 * @param void*(in) qBaseAddress - The address of the area of memory to use for the 
 * Queue entries, the client allocates the memory, it will need to 
 * allocate "qSize" words of data.
 * @param void* (in)qHeadCountPtr - the pointer to the area of memory for the 
 * Head Counter, the client should allocate a single word, its location 
 * must be word-aligned.
 * @param void* (in)qTailCountPtr - the pointer to the area of memory for 
 * the Tail Counter, the client should allocate a single word, its location
 * must be word aligned.
 * 
 * @Note The total size of a queue (number of entries * size of each entry) 
 * can be up to 32768 words.
 *
 * @Note the head and tail counters are 16 bits in size (lower part of a word),
 *  however the QMgr is NOT designed to be able to handle non-word aligned pointers
 *
 * @Note the head and tail counters will be stored in big endian format
 *
 * - Reentrant    - yes
 * - ISR Callable - no
 *
 * @return @li ICP_STATUS_SUCCESS, a specified queue has been successfully configured.
 * @return @li ICP_STATUS_FAIL, component not initialised.
 * @return @li ICP_RESOURCE_ERR, all available queues are already configured, a 
 *         different queue configure operation is in progress - please retry.,
 * @return @li ICP_STATUS_INVALID_PARAM, invalid queue size
 * @return @li ICP_STATUS_INVALID_PARAM invalid queue entry size
 * @return @li ICP_STATUS_INVALID_PARAM, queue already configured
 * @return @li ICP_STATUS_INVALID_PARAM, Base Address is invalid
 * @return @li ICP_STATUS_INVALID_PARAM, Counter Ptr is invalid
 *
 */
icp_status_t
ixQMgrQConfig (char *qName,
	       IxQMgrQId *qId,
	       IxQMgrQSize qSize,
	       IxQMgrQEntrySizeInWords qEntrySize,
	       IxQMgrHeadAndTailCountFormat htCountFormat,
   	       IxQMgrHeadAndTailAlignment htAlignment,
	       IxQMgrDispatchGroup group,
	       IxQMgrHeadAndTailShadowing shadowing,
	       void *qBaseAddress,
	       void *qHeadCountPtr,
	       void *qTailCountPtr);
	       
/**
 *
 * @ingroup IxQMgrAPI
 * 
 * @fn ixQMgrQSizeReconfig (IxQMgrQId qId,
			IxQMgrQSize qSize)

 *
 * @brief Reconfigures the max number of entries in a Software queue. 
 *
 *
 * This function is called by the client in order to resize the max number of 
 * entries in an existing queue. 
 * 
 * Preconditions to successfully calling this function are as follows:
 * 1. The QMgr must be initialised 
 * 2. The queue must have been successfully configured using ixQMgrQConfig()
 * 3. The queue must be empty
 * 4. The queue must have it's Notifications disabled. (default)
 * 5. The memory pool allocated by the client for ixQMgrQConfig should be big 
 *    enough to accomodate the new number of entries. 
 * 
 * Conditions 1-4 are checked and the function will return with an
 * appropriate error code should any of conditions not be met.
 * Condition 5 is not checked. It is the clients responsiblity to ensurse the 
 * buffer it allcoated for this queue that was passed as an argument to 
 * ixQMgrQConfig() is of sufficient size for this queue.
 *
 * The qSize will be checked against the selected Head and Tail alignment and 
 * counting format (entries or bytes). It will return an error if it is possible 
 * that the qSize could be greater than the Head and Tail can count. 
 *
 * Postconditions to successfully calling this function are as follows: 
 * 1. The queue will have a max number of entries as specified by qSize. 
 * 2. The Head and Tail pointers for the queue will be reset.
 * 3. The watermark for the queue will be reset.
 * 4. Any registered queue callbacks and callbackId's will be unchanged.
 *
 *
 * @param IxQMgrQId(in)  qId - the qId 
 * @param IxQMgrQSize(in) qSize - the new amount of entries in the queue. 
 * qSize must = 2^n, where n is a positive integer. 
 * 
 * @Note The total size of a queue (number of entries * size of each entry) 
 * can be up to 32768 words.
 *
 * @Note The queue entry size cannot be reconfigured using this function 
 *
 * - Reentrant    - yes
 * - ISR Callable - no
 *
 * @return @li ICP_STATUS_SUCCESS, a specified queue has been successfully configured.
 * @return @li ICP_STATUS_FAIL, component not initialised.
 * @return @li ICP_STATUS_INVALID_PARAM , invalid queue, invalid queue size
 * @return @li ICP_STATUS_RESOURCE, Q is not empty, Q Notifications are not disabled
 *
 */
icp_status_t
ixQMgrQSizeReconfig (IxQMgrQId qId,
		     IxQMgrQSize qSize);




/**
 *
 * @ingroup IxQMgrAPI
 * 
 * @fn ixQMgrUnconfigGroup (IxQMgrDispatchGroup group)
 *
 * @brief Unconfigures the queues in a group
 *
 * This function is called by the client in order to unconfigure a group of 
 * queues. It should be called when a group of queues are no longer needed by 
 * the client. 
 * 
 * Preconditions to successfully calling this function are as follows:
 * 1. The QMgr must be initialised 
 * 
 * It is not explicitly checked but this function is only useful if the there
 * are queues configured in the group that is being unconfigured. 
 *
 * Postconditions to successfully calling this function are as follows: 
 * 1. All queues that had their group set to the parameter will be completely
 *    reset. Reseting means that the all counters will be cleared and the QMgr 
 *    will remove it's association with queue buffer. The qId of each queue will 
 *    be available for reuse through the ixQMgrQConfig function. 
 *
 * @param IxQMgrDispatchGroup(in)  group - the queue group 
 * 
 * @Note This function should be called before calling ixQMgrUnload
 *
 * @Note Memory allocation/freeing is the clients responsiblity. 
 *
 * - Reentrant    - no
 * - ISR Callable - no
 *
 * @return @li ICP_STATUS_SUCCESS, the group has been unconfigured
 * @return @li ICP_STATUS_FAIL, component not initialised.
 * @return @li ICP_STATUS_INVALID_PARAM , invalid group
 *
 */
 icp_status_t
ixQMgrUnconfigGroup(IxQMgrDispatchGroup group);



/**
 * 
 * @ingroup IxQMgrAPI
 * 
 * @fn ixQMgrQSizeGet (IxQMgrQId qId,
		IxQMgrQSize *qSize)
 *
 * @brief Return the size of a queue.
 *
 * This function returns the the size of the queue in entries.
 *
 * @param IxQMgrQId(in) qId - the queue identifier
 * @param IxQMgrQSize(out) *qSize - queue size in entries
 *
 * - Reentrant    - no
 * - ISR Callable - no
 *
 * @return @li ICP_STATUS_SUCCESS, successfully retrieved the size
 * @return @li ICP_STATUS_INVALID_PARAM, invalid queue id
 * @return @li ICP_STATUS_INVALID_PARAM, queue not configured for this QId
 * @return @li ICP_STATUS_INVALID_PARAM, invalid parameter(s).
 *
 */
 icp_status_t
ixQMgrQSizeGet (IxQMgrQId qId,
		IxQMgrQSize *qSize);




/**
 *
 * @ingroup IxQMgrAPI
 * 
 * @fn ixQMgrWatermarkSet (IxQMgrQId qId,
		    IxQMgrWMLevel waterM)
 *
 * @brief Set the Watermark of a queue.
 *
 * This function is called by a client to set the watermark for the
 * queue specified by qId.
 * The queue must be empty at the time this function is called, it is the clients
 * responsibility to ensure that the queue is empty.
 *
 * @param IxQMgrQId(in) qId -  the QId of the queue.
 * @param IxQMgrWMLevel(in) waterM  - range (1..qSize-1) the watermark for this queue.
 *
 * - Reentrant    - no
 * - ISR Callable - no
 *
 * @return @li ICP_STATUS_SUCCESS, watermark have been set for the queue
 * @return @li ICP_STATUS_INVALID_PARAM, invalid queue id
 * @return @li ICP_STATUS_INVALID_PARAM, queue not configured for this QId
 * @return @li ICP_STATUS_INVALID_PARAM, invalid watermark
 *
 */
 icp_status_t
ixQMgrWatermarkSet (IxQMgrQId qId,
		    IxQMgrWMLevel waterM);


/* ------------------------------------------------------------
   Queue access related functions
   ---------------------------------------------------------- */

/**
 *
 * @ingroup IxQMgrAPI
 * 
 * @fn ixQMgrQReadWithChecks (IxQMgrQId qId,
                       IxQMgrQEntryType *entryPtr)
 *
 * @brief Read an entry from a queue.
 *
 * This function reads an entire entry from a queue returning it in *entryPtr. 
 *
 *
 * @param  IxQMgrQId(in)  qId   - the queue identifier.
 * @param  IxQMgrQEntryType(out) *entryPtr - array to copy the entry word(s) into.
 *
 * - Reentrant    - no
 * - ISR Callable - yes
 *
 * @return @li ICP_STATUS_SUCCESS, entry was successfully read.
 * @return @li ICP_STATUS_INVALID_PARAM, invalid paramter(s).
 * @return @li ICP_STATUS_INVALID_PARAM, queue not configured for this QId
 * @return @li ICP_STATUS_UNDERFLOW, attempt to read from an empty queue
 *
 */
icp_status_t
ixQMgrQReadWithChecks (IxQMgrQId qId,
                       IxQMgrQEntryType *entryPtr);


/**
 *
 * @ingroup IxQMgrAPI
 * 
 * @fn ixQMgrQRead (IxQMgrQId qId,
	     IxQMgrQEntryType *entryPtr)
 *
 * @brief Fast read of an entry from a queue.
 *
 * This function is a heavily streamlined version of ixQMgrQReadWithChecks(),
 * This function reads an entire entry from a queue returning it in *entryPtr. 
 * 
 *
 * @note - This function is inlined, to reduce unnecessary function call
 * overhead.  It does not perform any parameter checks, or update any statistics.
 * Also, it does not check that the queue specified by qId has been configured.
 * or is in range. It simply checks for underflow and reads an entry from the queue.
 *
 *
 * @param  IxQMgrQId(in)  qId - the queue identifier.
 * @param  IxQMgrQEntryType(out) *entryPtr - pointer to the entry word(s).
 *
 * - Reentrant    - no
 * - ISR Callable - yes
 *
 * @return @li ICP_STATUS_SUCCESS, entry was successfully read.
 * @return @li ICP_STATUS_UNDERFLOW, attempt to read from an empty queue
 *
 */
IX_QMGR_INLINE  icp_status_t
ixQMgrQRead (IxQMgrQId qId,
	     IxQMgrQEntryType *entryPtr)
#ifdef NO_INLINE_APIS
    ;
#else
{
    IxQMgrQueue *info = &ixQMgrQueues[qId];
           
           
    if (info->htCountFormat == IX_QMGR_Q_COUNT_BYTES)
    {    
        /* 
         * Currently the only layer using this type of queue will have 
         * invalidate and flush done in the dispatcher 
         */  
                      
        if (IX_SWQ_WA_CB_QUEUE_EMPTY(info->queue))
        {
    	    return ICP_STATUS_UNDERFLOW;
        }
        IX_SWQ_WA_CB_ENTRY_DEQUEUE(info->queue, entryPtr);
        

    }  
    else  
    {  

          
        if(info->htAlignment == IX_QMGR_Q_ALIGN_WORD) 
        {  
            IX_SWQ_WA_HEAD_INVALIDATE(info->queue);   
                                      
            if (IX_SWQ_WA_CE_QUEUE_EMPTY(info->queue))
            {
        	    return ICP_STATUS_UNDERFLOW;
            }
            IX_SWQ_WA_CE_ENTRY_DEQUEUE(info->queue, entryPtr);
            
            IX_SWQ_WA_TAIL_FLUSH(info->queue);
        }  
        else  
        {  
            IX_SWQ_BA_HEAD_INVALIDATE(info->queue);   
                          
            if (IX_SWQ_BA_CE_QUEUE_EMPTY(info->queue))
            {
        	    return ICP_STATUS_UNDERFLOW;
            }
            IX_SWQ_BA_CE_ENTRY_DEQUEUE(info->queue, entryPtr);
            
            IX_SWQ_BA_TAIL_FLUSH(info->queue);            
        }  
        

    }  


    return ICP_STATUS_SUCCESS;
}
#endif




/**
 *
 * @ingroup IxQMgrAPI
 * 
 * @fn ixQMgrQBurstRead (IxQMgrQId qId,
		  UINT32 numEntries,
		  IxQMgrQEntryType *entriesPtr)
 *
 * @brief Read a number of entries from a software queue.
 *
 * This function will burst read a number of entries from the specified queue.
 * The function will attempt to read as many entries as specified by the 
 * numEntries parameter and will return an UNDERFLOW if the sufficient number 
 * of entries is not in the queue at the start of the function.
 * This function reads a number of entries from a queue returning them in entriesPtr.
 *
 * @note
 * This function is intended for fast draining of queues, so to make it
 * as efficient as possible, it has the following features:
 * - This function is inlined, to reduce unnecessary function call overhead.
 * - It does not perform any parameter checks apart from underflow, 
 * or update any statistics.
 * - It does not check that the queue specified by qId has been configured.
 * - It will only check there are enough entries to fulfill the clients request
 *
 * @param IxQMgrQId(in) qId   - the queue identifier.
 * @param UINT32(in) numEntries - the number of entries to read. 
 *                     This number should be greater than 0
 * @param IxQMgrQEntryType(out) *entriesPtr - array with the entries read.
 *
 * - Reentrant    - no
 * - ISR Callable - yes
 *
 * @return @li ICP_STATUS_SUCCESS, entries were successfully read.
 * @return @li ICP_STATUS_UNDERFLOW, the component will check before read any 
 * entries that there are enough entries in teh queue to satisfy the burst read.
 *
 */
IX_QMGR_INLINE  icp_status_t
ixQMgrQBurstRead (IxQMgrQId qId,
		  UINT32 numEntries,
		  IxQMgrQEntryType *entriesPtr)
#ifdef NO_INLINE_APIS
;
#else
{
    IxQMgrQueue *info = &ixQMgrQueues[qId];
    VUINT32 *qEntry = NULL;
#ifndef NDEBUG
    UINT32 qEntries = 0;
#endif
	UINT32 xfrSizeWords = 0;
	VUINT32 *lastEntry = NULL;
	
    
    if (info->htCountFormat == IX_QMGR_Q_COUNT_BYTES)
    {
        /* 
         * This code is specific to queues which Head and Tails are 
         *  word aligned and count in bytes 
         */                                   
        qEntry = &IX_SWQ_WA_CB_TAIL_ENTRY_GET((info->queue));
    
#ifndef NDEBUG
        IX_SWQ_WA_CB_NUM_ENTRIES_GET(info->queue, qEntries);
        if (numEntries > qEntries)
        {
    	    return ICP_STATUS_UNDERFLOW;
        }
#endif

        /* preload the first cache line */
        IX_OSAL_CACHE_PRELOAD((void *)qEntry, 0);
        
        /* Compare head and tail, if head is greater than tail then there is 
           no wrap around and the all entries to be read are situated in the 
           same block of memory that can be read in one go. if head is not 
           greater than tail then the head counter has wrapped around and the 
           entries will have to be read one at a time as they are not situated 
           in consecutives addresses in memory.*/
        if ( IX_SWQ_WA_CB_HEAD(info->queue) > IX_SWQ_WA_CB_TAIL(info->queue) ) 
        {
        	xfrSizeWords = numEntries * info->qEntrySize;
        	lastEntry = qEntry + xfrSizeWords;
        
        	/* preload */
        	IX_OSAL_CACHE_PRELOAD(qEntry, xfrSizeWords << IX_SWQ_BYTES_POW_IN_WORD);
        
        	/* memcpy */
        	while( lastEntry != qEntry )
        	{
        	    *entriesPtr++ = *qEntry++;
        	}
        
        	/* invalidate the queue memory just being read */
        	IX_SWQ_WA_CB_TAIL_INVALIDATE_AFTER_DEQUEUE(info->queue, numEntries);
        	/* move the queue counter */
        	IX_SWQ_WA_CB_TAIL_ADVANCE(info->queue, numEntries);
        }
        else
        {
        	while(numEntries > 0)
        	{     
                numEntries--;
        	    IX_SWQ_WA_CB_ENTRY_DEQUEUE(info->queue, entriesPtr);
        	    entriesPtr = entriesPtr + (info->qEntrySize);
        	}
        }                            
    }
    else
    {
        if(info->htAlignment == IX_QMGR_Q_ALIGN_WORD) 
        {
            IX_SWQ_WA_HEAD_INVALIDATE(info->queue);                               
            /* 
             * This code is specific to queues which Head and Tails are 
             *  word aligned and count in entries 
             */                                   
             qEntry = &IX_SWQ_WA_CE_TAIL_ENTRY_GET((info->queue));
        
#ifndef NDEBUG
            IX_SWQ_WA_CE_NUM_ENTRIES_GET(info->queue, qEntries);
            if (numEntries > qEntries)
            {
        	return ICP_STATUS_UNDERFLOW;
            }
#endif
        
            /* preload the first cache line */
            IX_OSAL_CACHE_PRELOAD((void *)qEntry, 0);
            
            /* Compare head and tail, if head is greater than tail then there 
               is no wrap around and the all entries to be read are situated 
               in the same block of memory that can be read in one go. if head 
               is not greater than tail then the head counter has wrapped around
               and the entries will have to be read one at a time as they are 
               not situated in consecutives addresses in memory.*/
            if (IX_SWQ_WA_CE_HEAD(info->queue) > IX_SWQ_WA_CE_TAIL(info->queue)) 
            {
            	xfrSizeWords = numEntries * info->qEntrySize;
            	lastEntry = qEntry + xfrSizeWords;
            
            	/* preload */
            	IX_OSAL_CACHE_PRELOAD(qEntry, xfrSizeWords << IX_SWQ_BYTES_POW_IN_WORD);
            
            	/* memcpy */
            	while( lastEntry != qEntry )
            	{
            	    *entriesPtr++ = *qEntry++;
            	}
            
            	/* invalidate the queue memory just being read */
            	IX_SWQ_WA_CE_TAIL_INVALIDATE_AFTER_DEQUEUE(info->queue, numEntries);
            	/* move the queue counter */
            	IX_SWQ_WA_CE_TAIL_ADVANCE(info->queue, numEntries);
            }
            else
            {
            	while(numEntries > 0)
            	{     
                    numEntries--;
            	    IX_SWQ_WA_CE_ENTRY_DEQUEUE(info->queue, entriesPtr);
            	    entriesPtr = entriesPtr + (info->qEntrySize);
            	}
            }     
            IX_SWQ_WA_TAIL_FLUSH(info->queue);                           
        }
        else
        {
            IX_SWQ_BA_HEAD_INVALIDATE(info->queue);              
            /* 
             * This code is specific to queues which Head and Tails are 
             *  byte aligned and count in entries 
             */                                   
            qEntry = &IX_SWQ_BA_CE_TAIL_ENTRY_GET((info->queue));
        
#ifndef NDEBUG
            IX_SWQ_BA_CE_NUM_ENTRIES_GET(info->queue, qEntries);
            if (numEntries > qEntries)
            {
        	   return ICP_STATUS_UNDERFLOW;
            }
#endif
        
            /* preload the first cache line */
            IX_OSAL_CACHE_PRELOAD((void *)qEntry, 0);
            
            /* Compare head and tail, if head is greater than tail then there 
               is no wrap around and the all entries to be read are situated 
               in the same block of memory that can be read in one go. if head 
               is not greater than tail then the head counter has wrapped around
               and the entries will have to be read one at a time as they are 
               not situated in consecutives addresses in memory.*/
            if (IX_SWQ_BA_CE_HEAD(info->queue) > IX_SWQ_BA_CE_TAIL(info->queue)) 
            {
            	xfrSizeWords = numEntries * info->qEntrySize;
            	lastEntry = qEntry + xfrSizeWords;
            
            	/* preload */
            	IX_OSAL_CACHE_PRELOAD(qEntry, xfrSizeWords << IX_SWQ_BYTES_POW_IN_WORD);
            
            	/* memcpy */
            	while( lastEntry != qEntry )
            	{
            	    *entriesPtr++ = *qEntry++;
            	}
            
            	/* invalidate the queue memory just being read */
            	IX_SWQ_BA_CE_TAIL_INVALIDATE_AFTER_DEQUEUE(info->queue, numEntries);
            	/* move the queue counter */
            	IX_SWQ_BA_CE_TAIL_ADVANCE(info->queue, numEntries);
            }
            else
            {
            	while(numEntries > 0)
            	{
                    numEntries--;     
            	    IX_SWQ_BA_CE_ENTRY_DEQUEUE(info->queue, entriesPtr);
            	    entriesPtr = entriesPtr + (info->qEntrySize);
            	}
            }   
            IX_SWQ_BA_TAIL_FLUSH(info->queue);                   
        }

    }

    return ICP_STATUS_SUCCESS;
}
#endif

/**
 *
 * @ingroup IxQMgrAPI
 * 
 * @fn ixQMgrQReadAdvance (IxQMgrQId qId,
		           UINT32 numEntries)
 *
 * @brief Advance the Queue Read pointer a number of entries
 *
 * This function will advance the tail pointer of a specific Queue. In doing so
 * it will seem like numEntries entries have been read from queue. The benefits
 * of this is that the overhead of actually reading the Queue entries is avoided
 * It will return an UNDERFLOW if the sufficient number of entries is not in the 
 * queue at the start of the function.
 *
 * @note
 * This function is intended for very fast draining of queues, so to make it
 * as efficient as possible, it has the following features:
 * - This function is inlined, to reduce unnecessary function call overhead.
 * - It does not perform any parameter checks apart from underflow, 
 * or update any statistics.
 * - It does not check that the queue specified by qId has been configured.
 * - It doesn't bother reading the Queue Entries themselves
 * - It will only check there are enough entries to fulfill the clients request
 *
 * @param IxQMgrQId(in) qId   - the queue identifier.
 * @param UINT32(in) numEntries - the number of entries to advance the tail
 * count by. This number should be greater than 0
 *
 * - Reentrant    - no
 * - ISR Callable - yes
 *
 * @return @li ICP_STATUS_SUCCESS, entries were successfully read.
 * @return @li ICP_STATUS_UNDERFLOW, the component will check before read any 
 * entries that there are enough entries in teh queue to satisfy the burst read.
 *
 */
IX_QMGR_INLINE  icp_status_t
ixQMgrQReadAdvance (IxQMgrQId qId,
		    UINT32 numEntries)
#ifdef NO_INLINE_APIS
;
#else
{
    IxQMgrQueue *info = &ixQMgrQueues[qId];
    UINT32 qEntries;


    if (info->htCountFormat == IX_QMGR_Q_COUNT_BYTES)
    {
        IX_SWQ_WA_CB_NUM_ENTRIES_GET(info->queue, qEntries);
        if (numEntries > qEntries)
        {
    	   return ICP_STATUS_UNDERFLOW;
        }
        IX_SWQ_WA_CB_TAIL_ADVANCE((info->queue), numEntries); 
    }  
    else  
    {  
        if(info->htAlignment == IX_QMGR_Q_ALIGN_WORD) 
        {  
            IX_SWQ_WA_HEAD_INVALIDATE(info->queue);    
                                         
            IX_SWQ_WA_CE_NUM_ENTRIES_GET(info->queue, qEntries);
            if (numEntries > qEntries)
            {
        	   return ICP_STATUS_UNDERFLOW;
            }
            IX_SWQ_WA_CE_TAIL_ADVANCE((info->queue), numEntries); 
            
            IX_SWQ_WA_TAIL_FLUSH(info->queue);             
        }  
        else  
        {  
            IX_SWQ_BA_HEAD_INVALIDATE(info->queue);    
                          
            IX_SWQ_BA_CE_NUM_ENTRIES_GET(info->queue, qEntries);
            if (numEntries > qEntries)
            {
        	   return ICP_STATUS_UNDERFLOW;
            }
            IX_SWQ_BA_CE_TAIL_ADVANCE((info->queue), numEntries); 
            IX_SWQ_BA_TAIL_FLUSH(info->queue);             
        }  
    }  

    return ICP_STATUS_SUCCESS;
}
#endif


/**
 *
 * @ingroup IxQMgrAPI
 * 
 * @fn ixQMgrQWriteWithChecks (IxQMgrQId qId,
			       IxQMgrQEntryType *entry)
 *
 * @brief Write an entry to a Software Queue.
 *
 * This function will write the entry to the queue specified by qId.
 *
 * @param IxQMgrQId(in) qId - the queue identifier.
 * @param IxQMgrQEntryType(in) entry - Pointer to the entry word(s) to write.
 *
 * - Reentrant    - no
 * - ISR Callable - yes
 *
 * @return @li ICP_STATUS_SUCCESS, value was successfully written.
 * @return @li ICP_STATUS_INVALID_PARAM, invalid paramter(s).
 * @return @li ICP_STATUS_INVALID_PARAM, queue not configured for this QId
 * @return @li ICP_STATUS_OVERFLOW, attempt to write to a full queue
 *
 */
icp_status_t
ixQMgrQWriteWithChecks (IxQMgrQId qId,
                        IxQMgrQEntryType *entry);


/**
 *
 * @ingroup IxQMgrAPI
 * 
 * @fn ixQMgrQWrite (IxQMgrQId qId,
                     IxQMgrQEntryType *entry)
 *
 * @brief Fast write of an entry to a queue.
 *
 * This function is a heavily streamlined version of ixQMgrQWriteWithChecks(),
 * but performs essentially the same task.  It will write the entry word(s)
 * to the queue specified by qId.
 *
 * @note - This function is inlined, to reduce unnecessary function call
 * overhead.  It does not perform any parameter checks, or update any
 * statistics. Also, it does not check that the queue specified by qId has
 * been configured. It simply writes an entry to the queue, and checks for
 * overflow.
 *
 *
 * @param  IxQMgrQId(in)  qId   - the queue identifier.
 * @param  IxQMgrQEntryType(in) *entry - array holding entry word(s) to be written
 * - Reentrant    - no
 * - ISR Callable - yes
 *
 *
 * @return @li ICP_STATUS_SUCCESS, entry was successfully read.
 * @return @li ICP_STATUS_OVERFLOW, attempt to write to a full queue
 *
 */

IX_QMGR_INLINE icp_status_t
ixQMgrQWrite (IxQMgrQId qId,
	      IxQMgrQEntryType *entry)
#ifdef NO_INLINE_APIS
    ;
#else
{
    IxQMgrQueue *info = &ixQMgrQueues[qId];
    if (info->htCountFormat == IX_QMGR_Q_COUNT_BYTES)
    {
        if ( IX_SWQ_WA_CB_QUEUE_FULL(info->queue) )
        {
    	return ICP_STATUS_OVERFLOW;
        }
        IX_SWQ_WA_CB_ENTRY_ENQUEUE(info->queue, entry);
    }  
    else  
    {  

                  
        if(info->htAlignment == IX_QMGR_Q_ALIGN_WORD) 
        {  
            IX_SWQ_WA_TAIL_INVALIDATE(info->queue);                             
            
            if ( IX_SWQ_WA_CE_QUEUE_FULL(info->queue) )
            {
        	return ICP_STATUS_OVERFLOW;
            }
            IX_SWQ_WA_CE_ENTRY_ENQUEUE(info->queue, entry);

            IX_SWQ_WA_HEAD_FLUSH(info->queue);            
        }  
        else  
        {  
            IX_SWQ_BA_TAIL_INVALIDATE(info->queue);
                          
            if ( IX_SWQ_BA_CE_QUEUE_FULL(info->queue) )
            {
        	return ICP_STATUS_OVERFLOW;
            }
            IX_SWQ_BA_CE_ENTRY_ENQUEUE(info->queue, entry);

            IX_SWQ_BA_HEAD_FLUSH(info->queue);            
        }  
    }  

    return ICP_STATUS_SUCCESS;
}
#endif

/**
 *
 * @ingroup IxQMgrAPI
 * 
 * @fn ixQMgrQBurstWrite (IxQMgrQId qId,
		   UINT32 numEntries,
		   IxQMgrQEntryType *entriesPtr)
 *
 * @brief Write a number of entries to a Software queue.
 *
 * This function will burst write a number of entries to the specified queue.
 * The function will attempt to write as many entries as specified 
 * by the numEntries parameter and will return an OVERFLOW if 
 * there isnt sufficient space in the queue.
 *
 * @note
 * This function is intended for fast population of queues, so to make it
 * as efficient as possible, it has the following features:
 * - This function is inlined, to reduce unnecessary function call overhead.
 * - It does not perform any parameter checks, or update any statistics.
 * - It does not check that the queue specified by qId has been configured.
 * - It only checks that the queue has enough free space to hold the entries
 * before writing performed.Therefore, the client should ensure before calling this function
 * that there is enough free space in the queue to hold the number of entries
 * to be written.  ixQMgrQWrite() or ixQMgrQWriteWithChecks(), which only writes
 * a single queue entry per call, should be used instead if the user requires
 * checks for OVERFLOW before each entry written.
 *
 * @param IxQMgrQId(in) qId   - the queue identifier.
 * @param UINT32(in) numEntries - the number of entries to write.
 * @param IxQMgrQEntryType(in) *entriesPtr - the list of entries to write.
 *
 * - Reentrant    - no
 * - ISR Callable - yes
 *
 * @return @li ICP_STATUS_SUCCESS, value was successfully written.
 * @return @li ICP_STATUS_OVERFLOW, attempt to write to a queue with an 
 * insufficient number of free entries
 *
 */
IX_QMGR_INLINE  icp_status_t
ixQMgrQBurstWrite (IxQMgrQId qId,
		   UINT32 numEntries,
		   IxQMgrQEntryType *entriesPtr)
#ifdef NO_INLINE_APIS
;
#else
{
 
    IxQMgrQueue* info = &ixQMgrQueues[qId];
    UINT32 qEntries;

    if (info->htCountFormat == IX_QMGR_Q_COUNT_BYTES)
    {
        IX_SWQ_WA_CB_NUM_ENTRIES_GET(info->queue, qEntries);
        if (numEntries > (IX_SWQ_SIZE(info->queue) - qEntries))
        {
    	    return ICP_STATUS_OVERFLOW;
        }
        
        /* write each queue entry */
        while (numEntries)
        {
            numEntries--;
    	    IX_SWQ_WA_CB_ENTRY_ENQUEUE(info->queue, entriesPtr);
    	    entriesPtr = entriesPtr + (info->qEntrySize);
        }
    }  
    else  
    {  
        if(info->htAlignment == IX_QMGR_Q_ALIGN_WORD) 
        {  
            IX_SWQ_WA_TAIL_INVALIDATE(info->queue); 
                                         
            IX_SWQ_WA_CE_NUM_ENTRIES_GET(info->queue, qEntries);
            if (numEntries > (IX_SWQ_SIZE(info->queue) - qEntries))
            {
        	return ICP_STATUS_OVERFLOW;
            }
            
            /* write each queue entry */
            while (numEntries)
            {
                numEntries--;
        	    IX_SWQ_WA_CE_ENTRY_ENQUEUE(info->queue, entriesPtr);
        	    entriesPtr = entriesPtr + (info->qEntrySize);
            }
            /*Head flush done in IX_SWQ_WA_CE_ENTRY_ENQUEUE macro*/

        }  
        else  
        {  
            IX_SWQ_BA_TAIL_INVALIDATE(info->queue); 
                          
            IX_SWQ_BA_CE_NUM_ENTRIES_GET(info->queue, qEntries);
            if (numEntries > (IX_SWQ_SIZE(info->queue) - qEntries))
            {
        	return ICP_STATUS_OVERFLOW;
            }
            
            /* write each queue entry */
            while (numEntries)
            {
                numEntries--;
        	    IX_SWQ_BA_CE_ENTRY_ENQUEUE(info->queue, entriesPtr);
        	    entriesPtr = entriesPtr + (info->qEntrySize);
            }

            /*Head flush done in IX_SWQ_WA_CE_ENTRY_ENQUEUE macro*/
        }  
    }  

    return ICP_STATUS_SUCCESS;
}
#endif


/**
 *
 * @ingroup IxQMgrAPI
 * 
 * @fn ixQMgrQNumEntriesGetWithChecks (IxQMgrQId qId,
		      UINT32 *numEntries)
 *
 * @brief Get a snapshot of the number of entries in a queue.
 *
 * This function gets the number of entries in a queue.
 *
 * @param IxQMgrQId(in) qId - the queue idenfifier
 * @param UINT32(out) *numEntries - the number of entries in a queue
 *
 * - Reentrant    - no
 * - ISR Callable - yes
 *
 * @return @li ICP_STATUS_SUCCESS, got the number of entries for the queue
 * @return @li ICP_STATUS_INVALID_PARAM, invalid paramter(s).
 * @return @li ICP_STATUS_INVALID_PARAM, the specified qId has not been configured
 *
 */
icp_status_t
ixQMgrQNumEntriesGetWithChecks (IxQMgrQId qId,
				UINT32 *numEntries);


/**
 *
 * @ingroup IxQMgrAPI
 * 
 * @fn ixQMgrQNumEntriesGet (IxQMgrQId qId,
		      UINT32 *numEntries)
 *
 * @brief Get a snapshot of the number of entries in a queue. this 
 * is an inlined version of ixQMgrQNumEntriesGetWithChecks. it does 
 * not perform any checks on the parameters given, the client must 
 * ensure that these are correct.
 *
 * This function gets the number of entries in a queue.
 *
 * @param IxQMgrQId(in) qId - the queue idenfifier
 * @param UINT32(out) *numEntries - the number of entries in a queue
 *
 * - Reentrant    - no
 * - ISR Callable - yes
 *
 * @return @li ICP_STATUS_SUCCESS, got the number of entries for the queue
 *
 */
IX_QMGR_INLINE  icp_status_t
ixQMgrQNumEntriesGet (IxQMgrQId qId,
		      UINT32 *numEntries)
#ifdef NO_INLINE_APIS
;
#else
{
    IxQMgrQueue *info = &ixQMgrQueues[qId];
if (info->htCountFormat == IX_QMGR_Q_COUNT_BYTES)
    {
        IX_SWQ_WA_CB_NUM_ENTRIES_GET(info->queue, (*numEntries));
    }  
    else  
    {  
        if(info->htAlignment == IX_QMGR_Q_ALIGN_WORD) 
        {  
           IX_SWQ_WA_HEAD_INVALIDATE(info->queue);
           IX_SWQ_WA_TAIL_INVALIDATE(info->queue);                                                         
           IX_SWQ_WA_CE_NUM_ENTRIES_GET(info->queue, (*numEntries));
        }  
        else  
        {  
           IX_SWQ_BA_HEAD_INVALIDATE(info->queue);
           IX_SWQ_BA_TAIL_INVALIDATE(info->queue);               
           IX_SWQ_BA_CE_NUM_ENTRIES_GET(info->queue, (*numEntries));
        }  
    }  
    return ICP_STATUS_SUCCESS;
}
#endif

/**
 *
 * @ingroup IxQMgrAPI
 *
 * @fn ixQMgrQStatusGetWithChecks (IxQMgrQId qId,
                            IxQMgrQState *qState)
 *
 * @brief Get a queues status.
 *
 * This function computes the specified queues status using its head and tail counters.
 *  A queues status is defined as E,AW,BW,or F.
 *
 * @param IxQMgrQId(in) qId - the queue identifier.
 * @param IxQMgrQState(out) *qState - the status of the specified queue.
 *
 * - Reentrant    - no
 * - ISR Callable - yes
 *
 * @return @li ICP_STATUS_SUCCESS, queue status was successfully read.
 * @return @li ICP_STATUS_INVALID_PARAM, the specified qId has not been configured
 * @return @li ICP_STATUS_INVALID_PARAM, invalid paramter.
 *
 */
icp_status_t
ixQMgrQStatusGetWithChecks (IxQMgrQId qId,
                            IxQMgrQState *qState);

/**
 *
 * @ingroup IxQMgrAPI
 * 
 * @fn ixQMgrQStatusGet (IxQMgrQId qId,
		  IxQMgrQState *qState)
 *
 * @brief Fast get of a queue's status.
 *
 * This function is a streamlined version of ixQMgrQStatusGetWithChecks(), but
 * performs essentially the same task.  It computes the specified queue's status.
 * A queues status is defined by its Head and Tail Counters. The Queue's state 
 * can be E,AW,BW,F. 
 *
 * @note - This function is inlined, to reduce unnecessary function call
 * overhead.  It does not perform any parameter checks, or update any
 * statistics.  Also, it does not check that the queue specified by qId has
 * been configured.  It simply returns the specified queue's status.
 *
 * @param IxQMgrQId(in) qId - the queue identifier.
 * @param IxQMgrQState(out) *qState - the status of the specified queue.
 *
 * - Reentrant    - no
 * - ISR Callable - yes
 *
 * @return @li ICP_STATUS_SUCCESS, queue status was successfully read.
 *
 */

#ifdef NO_INLINE_APIS
icp_status_t
ixQMgrQStatusGet (IxQMgrQId qId,
		  IxQMgrQState *qState);
#else  
IX_QMGR_INLINE  icp_status_t
ixQMgrQStatusGet (IxQMgrQId qId,
		  IxQMgrQState *qState)
{
    IxQMgrQueue *info = &ixQMgrQueues[qId];
    UINT32 num_entries;

    if (info->htCountFormat == IX_QMGR_Q_COUNT_BYTES)
    {
       IX_SWQ_WA_CB_NUM_ENTRIES_GET(info->queue, num_entries);
       
    }  
    else  
    {  
        if(info->htAlignment == IX_QMGR_Q_ALIGN_WORD) 
        {  
           IX_SWQ_WA_HEAD_INVALIDATE(info->queue);
           IX_SWQ_WA_TAIL_INVALIDATE(info->queue);                               
           IX_SWQ_WA_CE_NUM_ENTRIES_GET(info->queue, num_entries);

        }  
        else  
        {  
           IX_SWQ_BA_HEAD_INVALIDATE(info->queue);
           IX_SWQ_BA_TAIL_INVALIDATE(info->queue);                
           IX_SWQ_BA_CE_NUM_ENTRIES_GET(info->queue, num_entries);       
        }  
    }  

    /* Calculate number of enqueued entries */
    /* Compare to E,F and W to get status */
    if (num_entries == info->qSize)
    {
	*qState = IX_QMGR_Q_STATE_F;	
    }
    else if (num_entries == 0)
    {
	*qState = IX_QMGR_Q_STATE_E;	
    }
    else if ( num_entries < info->waterMark)
    {
	*qState = IX_QMGR_Q_STATE_BW;
    }
    else
    {
	*qState = IX_QMGR_Q_STATE_AW;
    }
    
    return ICP_STATUS_SUCCESS;
}
#endif




/* ------------------------------------------------------------
   Queue dispatch related functions
   ---------------------------------------------------------- */
/**
 *
 * @ingroup IxQMgrAPI
 * 
 * @fn ixQMgrNotificationEnable (IxQMgrQId qId,
			  IxQMgrNotificationCondition sourceId)
 *
 * @brief Enable notification on a queue for a specified queue State.
 *
 * This function is called by a client of the QMgr to enable notifications on a
 * specified condition.
 *
 *
 * This function is re-entrant. and can be used from an interrupt context
 *
 * - Reentrant    - yes
 * - ISR Callable - yes
 *
 * @param IxQMgrQId(in) qId - the queue identifier
 * @param IxQMgrNotificationCondition(in) sourceId - the notification condition identifier
 *
 * @return @li ICP_STATUS_SUCCESS, the notification has been enabled for the specified condition
 * @return @li ICP_STATUS_INVALID_PARAM, the specified qId has not been configured
 * @return @li ICP_STATUS_INVALID_PARAM, interrupt source invalid for this queue
 *
 */
icp_status_t
ixQMgrNotificationEnable (IxQMgrQId qId,
			  IxQMgrNotificationCondition sourceId);

/**
 * @ingroup IxQMgrAPI
 * 
 * @fn ixQMgrNotificationDisable (IxQMgrQId qId)
 *
 * @brief Disable notifications on a queue.
 *
 * This function is called to disable notifications on a specified queue.
 *
 * This function is re-entrant. and can be used from an interrupt context
 *
 * - Reentrant    - yes
 * - ISR Callable - yes
 *
 * @param IxQMgrQId(in) qId - the queue identifier
 *
 * @return @li ICP_STATUS_SUCCESS, the notification has been disabled
 * @return @li ICP_STATUS_INVALID_PARAM, the specified qId has not been configured
 *
 */
icp_status_t
ixQMgrNotificationDisable (IxQMgrQId qId);

/**
 *
 * @ingroup IxQMgrAPI
 * 
 * @fn ixQMgrDispatcherLoopRun (IxQMgrDispatchGroup group)
 *
 * @brief Run the callback dispatcher, 
 * service the first queue enabled in the group first.
 *
 * The function runs the dispatcher for a group of queues.
 * Callbacks are made for conditions fulfilled on queues within
 * the group that have registered callbacks. The order in which queues are
 * serviced is fixed.
 * This  function may be called from interrupt or task context. the function 
 * could be called within the context of a polling mechanism based on a timer 
 * interrupt or could be called in the context of an ISR called in the event 
 * of a HW interrupt. However, for optimal performance the choice of context 
 * depends also on the operating system used.
 *
 * This function is not re-entrant.
 *
 * - Reentrant    - no
 * - ISR Callable - yes
 *
 * @param IxQMgrDispatchGroup(in) group - the group of queues over which the
 *                                        dispatcher will run
 *
 * @return @li void
 *
 */
void
ixQMgrDispatcherLoopRun (IxQMgrDispatchGroup group);

/**
 *
 * @ingroup IxQMgrAPI
 * 
 * @fn ixQMgrDispatcherLoopRunReverse (IxQMgrDispatchGroup group)
 *
 * @brief Run the callback dispatcher, 
 * service the last Queue Enabled in the group first.
 *
 * The function runs the dispatcher for a group of queues.
 * Callbacks are made for conditions fulfilled on queues within
 * the group that have registered callbacks. The order in which queues are
 * serviced is fixed.
 * This  function may be called from interrupt or task context. the function 
 * could be called within the context of a polling mechanism based on a timer 
 * interrupt or could be called in the context of an ISR called in the event 
 * of a HW mailbox interrupt
 *
 * This function is not re-entrant. This function may be called from interrupt 
 * or task context.
 * However, for optimal performance the choice of context depends also on the
 * operating system used.
 *
 * - Reentrant    - no
 * - ISR Callable - yes
 *
 * @param IxQMgrDispatchGroup(in) group - the group of queues over which the
 *                                        dispatcher will run
 *
 * @return @li void
 *
 */
void
ixQMgrDispatcherLoopRunReverse (IxQMgrDispatchGroup group);



/**
 *
 * @ingroup IxQMgrAPI
 * 
 * @fn ixQMgrNotificationCallbackSet (IxQMgrQId qId,
			       IxQMgrCallback callback,
			       IxQMgrCallbackId callbackId)
 *
 * @brief Set the notification callback for a queue.
 *
 * This function sets the callback for the specified queue. This callback will
 * be called by the dispatcher, and may be called in the context of a interrupt
 * If callback has a value of NULL the previously registered callback, if one
 * exists will be unregistered.
 *
 * It is possible to change the callback function 'on the fly' at any time, 
 * and from any context (interrupt or task) when the application needs to 
 * register a new callback function which has a different behaviour than
 * the current one. Typical scenarios include dropping received data or
 * handling transmission timeouts.
 *
 * - Reentrant    - yes
 * - ISR Callable - yes
 *
 * @param IxQMgrQId(in) qId - the queue idenfifier
 * @param IxQMgrCallback(in) callback - the callback registered for this queue
 * @param IxQMgrCallbackId(in) callbackid - the callback identifier
 *
 * @return @li ICP_STATUS_SUCCESS, the callback for the specified queue has been set
 * @return @li ICP_STATUS_INVALID_PARAM, the specified qId has not been configured
 *
 */
icp_status_t
ixQMgrNotificationCallbackSet (IxQMgrQId qId,
			       IxQMgrCallback callback,
			       IxQMgrCallbackId callbackId);

/**
 *
 * @ingroup IxQMgrAPI
 * 
 * @fn ixQMgrShadowAdvanceWithChecks(IxQMgrQId qId, 
                                     IxQMgrHeadAndTailShadowing shadowingCounterType, 
                                     UINT32 numEntries)
 *
 * @brief Advances the shadow counter by the specifed number of entries. 
 *
 *
 * This function is called by the client in order to advance a shadow counter. 
 * At present only a shadow tail is supported. This function will only ever 
 * advance the head or tail shadow counter. Seperate call would be required to 
 * advance both. 
 * 
 * This function is a non-inline version of ixQMgrShadowAdvance.
 *
 * Preconditions to successfully calling this function are as follows:
 * 1. The QMgr must be initialised 
 * 2. The queue must have been successfully configured using ixQMgrQConfig()
 * 3. The queue must have configured to use an shadow counter config that is 
 *    equal or a superset of of shadowingCounter.
 * 4. When the queue was configured using the ixQMgrQConfig() function, it 
 * must have been configured to queue whose head and tail counters count by 
 * entries, as shadowing is only supported on these types of queues.
 * 
 * Conditions 1-4 are checked in this function. 
 * Also checked in this function are
 * 1. That numEntries is greater than 0.
 * 2. That numEntries is not greater then the max amount of entries.
 *
 * Postconditions to successfully calling this function are as follows: 
 * 1. If there is at least numEntries delta between the shadow and real counter,
 * the shadow counter will be advanced by numEntries.
 * 2. If there is less then numEntries delta between the shadow and real 
 * counters, the shadow counter will not be advanced.
 *
 *
 * @param IxQMgrQId(in)  qId - the qId 
 * @param IxQMgrHeadAndTailShadowing(in) shadowingCounterType - the counter to be   
 * advanced
 * @param UINT32(in) numEntries - the amount of entries to advance the 
 * shadow counter  
 * 
 * @Note At present tail shadowing only is supported 
 *
 * - Reentrant    - no
 * - ISR Callable - no
 *
 * @return @li ICP_STATUS_INVALID_PARAM, the specified queue is not configured,  
 * numEntries ==0, numEntries > max amount of entries.
 * @return @li ICP_STATUS_RESOURCE, the queue does not use shadowing, the queue uses 
 * a count by bytes format for it's counters. 
 * @return @li ICP_STATUS_SUCCESS, the queue's counter has been advanced by numEntries
 * @return @li ICP_STATUS_FAIL, the ixQMgr is not initialised, or it was not possible
 * to advance shadow counter by numEntries as the delta between the shadow and 
 * real counters was less then numEntries. 
 *
 */
icp_status_t
ixQMgrShadowAdvanceWithChecks(IxQMgrQId qId, 
                              IxQMgrHeadAndTailShadowing shadowingCounterType, 
                              UINT32 numEntries);
 
 

/**
 *
 * @ingroup IxQMgrAPI
 * 
 * @fn ixQMgrShadowAdvance(IxQMgrQId qId, 
                           IxQMgrHeadAndTailShadowing shadowingCounterType, 
                           UINT32 numEntries)
 *
 * @brief Advances the shadow counter by the specifed number of entries. 
 *
 *
 * This function is called by the client in order to advance a shadow counter. 
 *
 * 
 * Preconditions to successfully calling this function are as follows:
 * 1. The QMgr must be initialised 
 * 2. The queue must have been successfully configured using ixQMgrQConfig()
 * 3. The queue must have configured to use an shadow counter config that is 
 *    equal or a superset of shadowingCounter.
 * 4. The queue must have been configured to have its head and tail counters to 
 *    count by entries.
 * 
 * Conditions 1-4 are not checked in this function. 
 * This function is expected to be called on the data path and such it does not 
 * contain checks. A non-inline version of this function which includes checks 
 * can used by calling ixQMgrShadowAdvanceWithChecks instead.
 *
 * 
 * Postconditions to successfully calling this function are as follows: 
 * 1. If there is at least numEntries delta between the shadow and real counter,
 * the shadow counter will be advance by numEntries.
 * 2. If there is less then numEntries delta between the shadow and real 
 * counters, the shadow counter will not be advanced.
 *
 *
 * @param IxQMgrQId(in)  qId - the qId 
 * @param IxQMgrHeadAndTailShadowing(in) shadowingCounterType - the counter to be   
 * advanced
 * @param UINT32(in) numEntries - the amount of entries to advance the 
 * shadow counter  
 * 
 * @Note At present tail shadowing only is supported 
 *
 * @Note The shadowingCounterType parameter is not used in this function. It is 
 * a parameter in this function so that ixQMgrShadowAdvance() and 
 * ixQMgrShadowAdvanceWithChecks() have the same signatures.
 *
 * - Reentrant    - no
 * - ISR Callable - no
 *
 * @return @li ICP_STATUS_SUCCESS, the queue's counter has been advanced by numEntries
 * @return @li ICP_STATUS_FAIL, it was not possible to advance shadow counter by 
 * numEntries as the delta between the shadow and real counters was less then numEntries. 
 *
 */
IX_QMGR_INLINE  icp_status_t
ixQMgrShadowAdvance(IxQMgrQId qId, 
                    IxQMgrHeadAndTailShadowing shadowingCounterType, 
                    UINT32 numEntries)
#ifdef NO_INLINE_APIS
;
#else
{  
    IxQMgrQueue *info = &ixQMgrQueues[qId]; 
    UINT32 shadowRealDelta = 0;

    if (info->htAlignment == IX_QMGR_Q_ALIGN_BYTE)
    {
         /*Invalidate the real tail*/
         IX_SWQ_CACHE_INVALIDATE((info->shadowInfo.byteRealTailCounter),IX_QMGR_SIZEOF_BYTE);
         /*
          * Test the delta between the shadow tail and the real tail up until 
          * the number of entries 
          */ 
          shadowRealDelta = 
              (IX_OSAL_READ_BE_SHARED_BYTE(info->shadowInfo.byteRealTailCounter)) - 
              (IX_OSAL_READ_BE_SHARED_BYTE(&(info->shadowInfo.byteShadowTailCounter)));      
          /*
           * shadowRealDelta is an unsigned => overflow implicitly handled 
           * IX_QMGR_Q_ALIGN_BYTE means we must only use 8-bits
           */  
          if ((shadowRealDelta & IX_QMGR_MASK_8BIT) >= numEntries)
          {
             IX_SWQ_BA_CE_TAIL_ADVANCE(info->queue,numEntries);    
                        
             return ICP_STATUS_SUCCESS;                               
          }
          else
          {
              return ICP_STATUS_UNDERFLOW;    
          }                                                  
    }
    else
    {
         /*Invalidate the real tail*/
         IX_SWQ_CACHE_INVALIDATE((info->shadowInfo.wordRealTailCounter),IX_QMGR_SIZEOF_WORD);
         /*
          * Test the delta between the shadow tail and the real tail up until 
          * the number of entries 
          */ 
          shadowRealDelta = 
              (IX_OSAL_READ_BE_SHARED_LONG(info->shadowInfo.wordRealTailCounter)) - 
              (IX_OSAL_READ_BE_SHARED_LONG(&(info->shadowInfo.wordShadowTailCounter)));  

          /*
           * shadowRealDelta is an unsigned => overflow implicitly handled 
           * IX_QMGR_Q_ALIGN_WORD, but we only use 16-bits for counters
           */                     
          if ((shadowRealDelta & IX_QMGR_MASK_16BIT) >= numEntries)
          {
             IX_SWQ_WA_CE_TAIL_ADVANCE(info->queue,numEntries);          
               
             return ICP_STATUS_SUCCESS;                               
          }
          else
          {
              return ICP_STATUS_UNDERFLOW;    
          }   
    }
}    
#endif

/**
 *
 * @ingroup IxQMgrAPI
 * 
 * @fn ixQMgrShadowDeltaGetWithChecks(IxQMgrQId qId, 
                           IxQMgrHeadAndTailShadowing shadowingCounterType, 
                           UINT32 *numEntries)
 *
 * @brief Gets the amount of entries that the shadow counter is behind the real 
 * counter 
 *
 * This function is a non-inline version of ixQMgrShadowDeltaGet.
 *
 * This function is called by the client in order to get the amount of entries 
 * that the shadow is behind the real counter 
 * 
 * Preconditions to successfully calling this function are as follows:
 * 1. The QMgr must be initialised 
 * 2. The queue must have been successfully configured using ixQMgrQConfig()
 * 3. The queue must have configured to use a shadow counter config that is 
 *    equal or a superset of of shadowingCounter.
 * 4. The queue must have been configured to have its head and tail counters to 
 *    count by entries.
 * 5. That numEntries is a valid pointer.
 * 
 * Conditions 1-4 are checked in this function. 
 * Also checked in this function are
 * 1. That numEntries is a valid pointer
 *
 * Postconditions to successfully calling this function are as follows: 
 * 1. The numEntries parameter will be set to the the amount of entires that 
 * the shadow counter trails behind the real counter. 
 *
 *
 * @param IxQMgrQId(in)  qId - the qId 
 * @param IxQMgrHeadAndTailShadowing(in) shadowingCounterType - the counter to be 
 * checked
 * @param UINT32(out) *numEntries - the amount of entries the shadow 
 * counter trails the real counter by 
 * 
 * @Note At present tail shadowing only is supported 
 *
 * - Reentrant    - no
 * - ISR Callable - no
 *
 * @return @li ICP_STATUS_INVALID_PARAM, the queue manager is not initialised, 
 * the specified queue is not configured, numEntries ==0, numEntries > max 
 * amount of entries.
 * @return @li ICP_STATUS_RESOURCE, the queue does not use shadowing, the queue 
 * uses a count by bytes format for it's counters.  
 * @return @li ICP_STATUS_SUCCESS, numEntries has been updated with to indicate the 
 * amount of entries that the shadow counter trails the real counter by. 
 * @return @li ICP_STATUS_FAIL, the ixQMgr is not initialised. 
 *
 */
icp_status_t
ixQMgrShadowDeltaGetWithChecks(IxQMgrQId qId, 
                               IxQMgrHeadAndTailShadowing shadowingCounterType, 
                               UINT32 *numEntries);

/**
 *
 * @ingroup IxQMgrAPI
 * 
 * @fn ixQMgrShadowDeltaGet(IxQMgrQId qId, 
                           IxQMgrHeadAndTailShadowing shadowingCounterType, 
                           UINT32 *numEntries)

 *
 * @brief Gets the amount of entries that the shadow counter is behind the real 
 * counter 
 *
 *
 * This function is called by the client in order to get the amount of entries 
 * that the shadow is behind the real counter 
 * 
 * Preconditions to successfully calling this function are as follows:
 * 1. The QMgr must be initialised 
 * 2. The queue must have been successfully configured using ixQMgrQConfig()
 * 3. The queue must have configured to use a shadow counter config that is 
 *    equal or a superset of of shadowingCounter.
 * 4. The queue must have been configured to have its head and tail counters to 
 *    count by entries.
 * 
 * Conditions 1-4 are not checked in this function. 
 * This function is expected to be called on the data path and such it does not 
 * contain checks. A non-inline version of this function which includes checks 
 * can used by calling ixQMgrShadowDeltaGetWithChecks instead.
 *
 * 
 * Postconditions to successfully calling this function are as follows: 
 * 1. The numEntries parameter will be set to the the amount of entires that 
 * the shadow counter trails behind the real counter. 
 *
 *
 * @param IxQMgrQId(in)  qId - the qId 
 * @param IxQMgrHeadAndTailShadowing(in) shadowingCounterType - the counter to be 
 * checked
 * @param UINT32(out) *numEntries - the amount of entries the shadow 
 * counter trails the real counter by 
 * 
 * @Note At present tail shadowing only is supported 
 *
 * @Note The shadowingCounterType parameter is not used in this function. It is 
 * a parameter in this function so that ixQMgrShadowDeltaGet() and 
 * ixQMgrShadowDeltaGetWithChecks() have the same signatures.
 *
 * - Reentrant    - no
 * - ISR Callable - no
 *
 * @return @li ICP_STATUS_SUCCESS, this function always return this value, but it 
 * used so that the inline and non-inline versions of this function will have 
 * the same signature 
 *
 */
IX_QMGR_INLINE  icp_status_t
ixQMgrShadowDeltaGet(IxQMgrQId qId, 
                     IxQMgrHeadAndTailShadowing shadowingCounterType, 
                     UINT32 *numEntries)
#ifdef NO_INLINE_APIS
;
#else
{
    IxQMgrQueue *info = &ixQMgrQueues[qId];
    UINT32 temp =0; 

    if (info->htAlignment == IX_QMGR_Q_ALIGN_BYTE)
    {
         /*Invalidate the real tail*/
         IX_SWQ_CACHE_INVALIDATE((info->shadowInfo.byteRealTailCounter),IX_QMGR_SIZEOF_BYTE);
         
         /* Get the delta between the shadow tail and the real tail. */
         temp = 
              (IX_OSAL_READ_BE_SHARED_BYTE(info->shadowInfo.byteRealTailCounter)) - 
              (IX_OSAL_READ_BE_SHARED_BYTE(&(info->shadowInfo.byteShadowTailCounter)));  
         /*In case of overflow, this is byte aligned */     
         *numEntries = (temp & 0xFF);    
         return ICP_STATUS_SUCCESS;                                                                    
     }
     else
     {
         /*Invalidate the real tail*/
         IX_SWQ_CACHE_INVALIDATE((info->shadowInfo.wordRealTailCounter),IX_QMGR_SIZEOF_WORD);

         /* Get the delta between the shadow tail and the real tail. */
         temp = 
              (IX_OSAL_READ_BE_SHARED_LONG(info->shadowInfo.wordRealTailCounter)) - 
              (IX_OSAL_READ_BE_SHARED_LONG(&(info->shadowInfo.wordShadowTailCounter)));    
         /*In case of overflow, this is 4 byte (word) aligned, but only 16-bits are used */       
         *numEntries = (temp & 0xFFFF);
         return ICP_STATUS_SUCCESS;            
     }                                                                                                                                   
}
#endif


/**
 *
 * @ingroup IxQMgrAPI
 *
 * @fn ixQMgrQWriteRollbackWithChecks (IxQMgrQId qId,
                                       UINT32 numEntries)
 *
 * @brief Rollback the last entries written to the specified queue. 
 *
 * This function moves back the write/head counter by the specfied number of 
 * entries.
 *
 * This function is a non-inline version of ixQMgrQWriteRollback.
 * 
 * Preconditions to successfully calling this function:
 * 1. The QMgr must be initialised 
 * 2. The queue must have been successfully configured using ixQMgrQConfig()
 * 3. The queue must have configured to use an shadow counter.
 * 4. The queue must have been configured to have its head and tail counters to 
 *    count by entries.                 
 * 
 * Conditions 1-4 are checked in this function. 
 *
 * Postconditions to successfully calling this function are as follows: 
 * 1. If there is at least numEntries delta between the head counter and 
 * the shadow tail counter, the head counter will have numEntries 
 * subtracted from it. 
 * 2. If there is less then numEntries delta between the head counter and the 
 * shadow tail counter, the head counter will not be modified. 
 *
 * @param IxQMgrQId(in) qId - the queue identifier.
 * @param UINT32(in) numEntries - the number of entries that should be rolled back
 *
 * - Reentrant    - no
 * - ISR Callable - no
 *
 * @return @li ICP_STATUS_INVALID_PARAM, the queue manager is not initialised, 
 * the specified queue is not configured, the queue does not use shadowing, 
 * numEntries ==0, numEntries > max possible amount of entries, 
 * . 
 * @return @li ICP_STATUS_SUCCESS, queue status was successfully read.
 * @return @li ICP_STATUS_RESOURCE, the queue uses a count by bytes format for it's 
 *                             counters, shadowing is not enabled on the queue, 
 * @return @li ICP_STATUS_FAIL, the number of entries to rollback would corrupt the queue
 *
 */
IX_QMGR_INLINE icp_status_t
ixQMgrQWriteRollbackWithChecks (IxQMgrQId qId,
		                        UINT32 numEntries);
		      
		      
		      
/**
 *
 * @ingroup IxQMgrAPI
 *
 * @fn ixQMgrQWriteR (IxQMgrQId qId,
                      UINT32 numEntries)
 *
 * @brief Rollback the last entries written to the specified queue. 
 *
 * This function moves back the write/head counter by the specfied number of 
 * entries.
 * 
 * Preconditions to successfully calling this function:
 * 1. The QMgr must be initialised 
 * 2. The queue must have been successfully configured using ixQMgrQConfig()
 * 3. The queue must have been configured to have its head and tail counters to 
 *    count by entries.                 
 * 
 * Conditions 1-3 are not checked in this function. 
 * This function is expected to be called on the data path and such it does not 
 * contain checks for these preconditions. A non-inline version of this function 
 * which includes checks can used by calling ixQMgrQWriteRollbackWithChecks instead.
 *
 * Postconditions to successfully calling this function are as follows: 
 * 1. If there is at least numEntries delta between the write/head counter and 
 * the shadow tail counter, the head counter will be will have numEntries 
 * subtracted from it. 
 * 2. If there is less then numEntries delta between the head counter and the 
 * shadow tail counter, the head counter will not be modified. 
 *
 * @param IxQMgrQId(in) qId - the queue identifier.
 * @param UINT32(in) numEntries - the number of entries that should be rolled back
 *
 * - Reentrant    - no
 * - ISR Callable - yes
 *
 * @return @li ICP_STATUS_SUCCESS, queue status was successfully read.
 * @return @li ICP_STATUS_FAIL, the number of entries to rollback would corrupt the queue
 *
 *
 * @Note this function checks that the rollback will not go beyond the real 
 * tail counter as to do so would corrupt the queue.
 *
 *
 */
IX_QMGR_INLINE icp_status_t
ixQMgrQWriteRollback (IxQMgrQId qId, UINT32 numEntries)
#ifdef NO_INLINE_APIS
;
#else
{
    IxQMgrQueue *info = &ixQMgrQueues[qId];     
    UINT32  entryCount = 0;

    if (info->htAlignment == IX_QMGR_Q_ALIGN_BYTE)
    {
      IX_SWQ_BA_TAIL_INVALIDATE(info->queue);
      
      /* Get the current number of entries */
      IX_SWQ_BA_CE_NUM_ENTRIES_GET(info->queue,entryCount);  
      
      if((UINT8) numEntries > (UINT8) entryCount)
        {
          /*not enough entries to rollback by numEntries*/   
          return ICP_STATUS_FAIL;               
        }
      else
        {
          /*rollback the head. set it to (present head val - numEntries)*/
          IX_SWQ_BA_CE_HEAD_SET(info->queue,(IX_SWQ_BE_SHARED_BYTE_READ(IX_SWQ_BA_CE_HEAD_PTR(info->queue))) - (UINT8) numEntries);
          
          IX_SWQ_BA_HEAD_FLUSH(info->queue);             
          return ICP_STATUS_SUCCESS;
        }
    }
    else
      {
        
         /*invalidate real tail counter*/
         IX_SWQ_WA_TAIL_INVALIDATE(info->queue);
         
         /* Get the current number of entries */
         IX_SWQ_WA_CE_NUM_ENTRIES_GET(info->queue,entryCount);

         if(numEntries > entryCount)
         {
             /*not enough entries to rollback by numEntries*/     
             return ICP_STATUS_FAIL;               
         }
         else
         {
         
             /*rollback the head. set it to (present head val - numEntries)*/
             IX_SWQ_WA_CE_HEAD_SET(info->queue,((IX_SWQ_BE_SHARED_LONG_READ(IX_SWQ_WA_CE_HEAD_PTR(info->queue))) - numEntries));
             IX_SWQ_WA_HEAD_FLUSH(info->queue);
             return ICP_STATUS_SUCCESS;
         }        
    } 
}
#endif



/* Restore IX_COMPONENT_NAME */
#undef IX_COMPONENT_NAME
#define IX_COMPONENT_NAME IX_QMGR_SAVED_COMPONENT_NAME

#endif /* IXQMGR_H */

/**
 * @} defgroup IxQMgrAPI
 */