DPDK logo

Elixir Cross Referencer

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
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
2564
2565
2566
2567
2568
/* SPDX-License-Identifier: BSD-3-Clause
 * Copyright(c) 2019-2021 Broadcom
 * All rights reserved.
 */

#ifndef _TF_CORE_H_
#define _TF_CORE_H_

#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include "hcapi_cfa_defs.h"
#include "tf_project.h"

/**
 * @file
 *
 * Truflow Core API Header File
 */

/********** BEGIN Truflow Core DEFINITIONS **********/

#define TF_KILOBYTE  1024
#define TF_MEGABYTE  (1024 * 1024)

/**
 * direction
 */
enum tf_dir {
	TF_DIR_RX,  /**< Receive */
	TF_DIR_TX,  /**< Transmit */
	TF_DIR_MAX
};

/**
 * memory choice
 */
enum tf_mem {
	TF_MEM_INTERNAL, /**< Internal */
	TF_MEM_EXTERNAL, /**< External */
	TF_MEM_MAX
};

/**
 * External memory control channel type
 */
enum tf_ext_mem_chan_type {
	/**
	 * Direct memory write(Wh+/SR)
	 */
	TF_EXT_MEM_CHAN_TYPE_DIRECT = 0,
	/**
	 * Ring interface MPC
	 */
	TF_EXT_MEM_CHAN_TYPE_RING_IF,
	/**
	 * Use HWRM message to firmware
	 */
	TF_EXT_MEM_CHAN_TYPE_FW,
	/**
	 * Use ring_if message to firmware
	 */
	TF_EXT_MEM_CHAN_TYPE_RING_IF_FW,
	TF_EXT_MEM_CHAN_TYPE_MAX
};

/**
 * WC TCAM number of slice per row that devices supported
 */
enum tf_wc_num_slice {
	TF_WC_TCAM_1_SLICE_PER_ROW = 1,
	TF_WC_TCAM_2_SLICE_PER_ROW = 2,
	TF_WC_TCAM_4_SLICE_PER_ROW = 4,
	TF_WC_TCAM_8_SLICE_PER_ROW = 8,
};

/**
 * Bank identifier
 */
enum tf_sram_bank_id {
	TF_SRAM_BANK_ID_0,		/**< SRAM Bank 0 id */
	TF_SRAM_BANK_ID_1,		/**< SRAM Bank 1 id */
	TF_SRAM_BANK_ID_2,		/**< SRAM Bank 2 id */
	TF_SRAM_BANK_ID_3,		/**< SRAM Bank 3 id */
	TF_SRAM_BANK_ID_MAX		/**< SRAM Bank index limit */
};

/**
 * EEM record AR helper
 *
 * Helper to handle the Action Record Pointer in the EEM Record Entry.
 *
 * Convert absolute offset to action record pointer in EEM record entry
 * Convert action record pointer in EEM record entry to absolute offset
 */
#define TF_ACT_REC_OFFSET_2_PTR(offset) ((offset) >> 4)
#define TF_ACT_REC_PTR_2_OFFSET(offset) ((offset) << 4)

/*
 * Helper Macros
 */
#define TF_BITS_2_BYTES(num_bits) (((num_bits) + 7) / 8)

/********** BEGIN API FUNCTION PROTOTYPES/PARAMETERS **********/

/**
 * @page general General
 *
 * @ref tf_open_session
 *
 * @ref tf_attach_session
 *
 * @ref tf_close_session
 */

/**
 * Session Version defines
 *
 * The version controls the format of the tf_session and
 * tf_session_info structure. This is to assure upgrade between
 * versions can be supported.
 */
#define TF_SESSION_VER_MAJOR  1   /**< Major Version */
#define TF_SESSION_VER_MINOR  0   /**< Minor Version */
#define TF_SESSION_VER_UPDATE 0   /**< Update Version */

/**
 * Session Name
 *
 * Name of the TruFlow control channel interface.  Expects
 * format to be RTE Name specific, i.e. rte_eth_dev_get_name_by_port()
 */
#define TF_SESSION_NAME_MAX       64

#define TF_FW_SESSION_ID_INVALID  0xFF  /**< Invalid FW Session ID define */

/**
 * Session Identifier
 *
 * Unique session identifier which includes PCIe bus info to
 * distinguish the PF and session info to identify the associated
 * TruFlow session. Session ID is constructed from the passed in
 * ctrl_chan_name in tf_open_session() together with an allocated
 * fw_session_id. Done by TruFlow on tf_open_session().
 */
union tf_session_id {
	uint32_t id;
	struct {
		uint8_t domain;
		uint8_t bus;
		uint8_t device;
		uint8_t fw_session_id;
	} internal;
};

/**
 * Session Client Identifier
 *
 * Unique identifier for a client within a session. Session Client ID
 * is constructed from the passed in session and a firmware allocated
 * fw_session_client_id. Done by TruFlow on tf_open_session().
 */
union tf_session_client_id {
	uint16_t id;
	struct {
		uint8_t fw_session_id;
		uint8_t fw_session_client_id;
	} internal;
};

/**
 * Session Version
 *
 * The version controls the format of the tf_session and
 * tf_session_info structure. This is to assure upgrade between
 * versions can be supported.
 *
 * Please see the TF_VER_MAJOR/MINOR and UPDATE defines.
 */
struct tf_session_version {
	uint8_t major;
	uint8_t minor;
	uint8_t update;
};

/**
 * Session supported device types
 */
enum tf_device_type {
	TF_DEVICE_TYPE_WH = 0, /**< Whitney+  */
	TF_DEVICE_TYPE_SR,     /**< Stingray  */
	TF_DEVICE_TYPE_THOR,   /**< Thor      */
	TF_DEVICE_TYPE_MAX     /**< Maximum   */
};

/**
 * Module types
 */
enum tf_module_type {
	/**
	 * Identifier module
	 */
	TF_MODULE_TYPE_IDENTIFIER,
	/**
	 * Table type module
	 */
	TF_MODULE_TYPE_TABLE,
	/**
	 * TCAM module
	 */
	TF_MODULE_TYPE_TCAM,
	/**
	 * EM module
	 */
	TF_MODULE_TYPE_EM,
	TF_MODULE_TYPE_MAX
};

/**
 * Identifier resource types
 */
enum tf_identifier_type {
	/**
	 *  WH/SR/TH
	 *  The L2 Context is returned from the L2 Ctxt TCAM lookup
	 *  and can be used in WC TCAM or EM keys to virtualize further
	 *  lookups.
	 */
	TF_IDENT_TYPE_L2_CTXT_HIGH,
	/**
	 *  WH/SR/TH
	 *  The L2 Context is returned from the L2 Ctxt TCAM lookup
	 *  and can be used in WC TCAM or EM keys to virtualize further
	 *  lookups.
	 */
	TF_IDENT_TYPE_L2_CTXT_LOW,
	/**
	 *  WH/SR/TH
	 *  The WC profile func is returned from the L2 Ctxt TCAM lookup
	 *  to enable virtualization of the profile TCAM.
	 */
	TF_IDENT_TYPE_PROF_FUNC,
	/**
	 *  WH/SR/TH
	 *  The WC profile ID is included in the WC lookup key
	 *  to enable virtualization of the WC TCAM hardware.
	 */
	TF_IDENT_TYPE_WC_PROF,
	/**
	 *  WH/SR/TH
	 *  The EM profile ID is included in the EM lookup key
	 *  to enable virtualization of the EM hardware.
	 */
	TF_IDENT_TYPE_EM_PROF,
	/**
	 *  (Future)
	 *  The L2 func is included in the ILT result and from recycling to
	 *  enable virtualization of further lookups.
	 */
	TF_IDENT_TYPE_L2_FUNC,
	TF_IDENT_TYPE_MAX
};

/**
 * Enumeration of TruFlow table types. A table type is used to identify a
 * resource object.
 *
 * NOTE: The table type TF_TBL_TYPE_EXT is unique in that it is
 * the only table type that is connected with a table scope.
 */
enum tf_tbl_type {
	/* Internal */

	/** Wh+/SR/TH Action Record */
	TF_TBL_TYPE_FULL_ACT_RECORD,
	/** TH Compact Action Record */
	TF_TBL_TYPE_COMPACT_ACT_RECORD,
	/** (Future) Multicast Groups */
	TF_TBL_TYPE_MCAST_GROUPS,
	/** Wh+/SR/TH Action Encap 8 Bytes */
	TF_TBL_TYPE_ACT_ENCAP_8B,
	/** Wh+/SR/TH Action Encap 16 Bytes */
	TF_TBL_TYPE_ACT_ENCAP_16B,
	/** WH+/SR/TH Action Encap 32 Bytes */
	TF_TBL_TYPE_ACT_ENCAP_32B,
	/** Wh+/SR/TH Action Encap 64 Bytes */
	TF_TBL_TYPE_ACT_ENCAP_64B,
	/** WH+/SR/TH Action Source Properties SMAC */
	TF_TBL_TYPE_ACT_SP_SMAC,
	/** Wh+/SR/TH Action Source Properties SMAC IPv4 */
	TF_TBL_TYPE_ACT_SP_SMAC_IPV4,
	/** WH+/SR/TH Action Source Properties SMAC IPv6 */
	TF_TBL_TYPE_ACT_SP_SMAC_IPV6,
	/** Wh+/SR/TH Action Statistics 64 Bits */
	TF_TBL_TYPE_ACT_STATS_64,
	/** Wh+/SR Action Modify IPv4 Source */
	TF_TBL_TYPE_ACT_MODIFY_IPV4,
	/** TH 8B Modify Record */
	TF_TBL_TYPE_ACT_MODIFY_8B,
	/** TH 16B Modify Record */
	TF_TBL_TYPE_ACT_MODIFY_16B,
	/** TH 32B Modify Record */
	TF_TBL_TYPE_ACT_MODIFY_32B,
	/** TH 64B Modify Record */
	TF_TBL_TYPE_ACT_MODIFY_64B,
	/** Meter Profiles */
	TF_TBL_TYPE_METER_PROF,
	/** Meter Instance */
	TF_TBL_TYPE_METER_INST,
	/** Wh+/SR/Th Mirror Config */
	TF_TBL_TYPE_MIRROR_CONFIG,
	/** (Future) UPAR */
	TF_TBL_TYPE_UPAR,
	/** (Future) TH Metadata  */
	TF_TBL_TYPE_METADATA,
	/** (Future) TH CT State  */
	TF_TBL_TYPE_CT_STATE,
	/** (Future) TH Range Profile  */
	TF_TBL_TYPE_RANGE_PROF,
	/** TH EM Flexible Key builder */
	TF_TBL_TYPE_EM_FKB,
	/** TH WC Flexible Key builder */
	TF_TBL_TYPE_WC_FKB,
	/** Meter Drop Counter */
	TF_TBL_TYPE_METER_DROP_CNT,

	/* External */

	/**
	 * External table type - initially 1 poolsize entries.
	 * All External table types are associated with a table
	 * scope. Internal types are not.  Currently this is
	 * a pool of 64B entries.
	 */
	TF_TBL_TYPE_EXT,
	TF_TBL_TYPE_MAX
};

/** Enable Shared TCAM Management
 *
 *  This feature allows for management of high and low pools within
 *  the WC TCAM.  These pools are only valid when this feature is enabled.
 *
 *  For normal OVS-DPDK operation, this feature is not required and can
 *  be disabled by commenting out TF_TCAM_SHARED in this header file.
 *
 *  Operation:
 *
 *  When a shared session is created with WC TCAM entries allocated during
 *  tf_open_session(), the TF_TCAM_TBL_TYPE_WC_TCAM pool entries will be divided
 *  into 2 equal pools - TF_TCAM_TBL_TYPE_WC_TCAM_HIGH and
 *  TF_TCAM_TBL_TYPE_WC_TCAM_LOW.
 *
 *  The user will allocate and free entries from either of these pools to obtain
 *  WC_TCAM entry offsets.  For the WC_TCAM_HI/LO management, alloc/free is done
 *  using the tf_alloc_tcam_entry()/tf_free_tcam_entry() APIs for the shared
 *  session.
 *
 *  The use case for this feature is so that applications can have a shared
 *  session and use the TF core to allocate/set/free entries within a given
 *  region of the WC_TCAM within the shared session.  Application A only writes
 *  to the LOW region for example and Application B only writes to the HIGH
 *  region during normal operation.  After Application A goes down, Application
 *  B may decide to overwrite the LOW region with the HIGH region's entries
 *  and switch to the low region.
 *
 *  For other TCAM types in the  shared session, no alloc/free operations are
 *  permitted. Only set should be used for other TCAM table types after getting
 *  the range as provided by the tf_get_resource_info() API.
 *
 */
#define TF_TCAM_SHARED 1

/**
 * TCAM table type
 */
enum tf_tcam_tbl_type {
	/** L2 Context TCAM */
	TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_HIGH,
	/** L2 Context TCAM */
	TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_LOW,
	/** Profile TCAM */
	TF_TCAM_TBL_TYPE_PROF_TCAM,
	/** Wildcard TCAM */
	TF_TCAM_TBL_TYPE_WC_TCAM,
	/** Source Properties TCAM */
	TF_TCAM_TBL_TYPE_SP_TCAM,
	/** Connection Tracking Rule TCAM */
	TF_TCAM_TBL_TYPE_CT_RULE_TCAM,
	/** Virtual Edge Bridge TCAM */
	TF_TCAM_TBL_TYPE_VEB_TCAM,
#ifdef TF_TCAM_SHARED
	/** Wildcard TCAM HI Priority */
	TF_TCAM_TBL_TYPE_WC_TCAM_HIGH,
	/** Wildcard TCAM Low Priority */
	TF_TCAM_TBL_TYPE_WC_TCAM_LOW,
#endif /* TF_TCAM_SHARED */
	TF_TCAM_TBL_TYPE_MAX
};

/**
 * SEARCH STATUS
 */
enum tf_search_status {
	/** The entry was not found, but an idx was allocated if requested. */
	MISS,
	/** The entry was found, and the result/idx are valid */
	HIT,
	/** The entry was not found and the table is full */
	REJECT
};

/**
 * EM Resources
 * These defines are provisioned during
 * tf_open_session()
 */
enum tf_em_tbl_type {
	/** The number of internal EM records for the session */
	TF_EM_TBL_TYPE_EM_RECORD,
	/** The number of table scopes requested */
	TF_EM_TBL_TYPE_TBL_SCOPE,
	TF_EM_TBL_TYPE_MAX
};

/**
 * TruFlow Session Information
 *
 * Structure defining a TruFlow Session, also known as a Management
 * session. This structure is initialized at time of
 * tf_open_session(). It is passed to all of the TruFlow APIs as way
 * to prescribe and isolate resources between different TruFlow ULP
 * Applications.
 *
 * Ownership of the elements is split between ULP and TruFlow. Please
 * see the individual elements.
 */
struct tf_session_info {
	/**
	 * TruFlow Version. Used to control the structure layout when
	 * sharing sessions. No guarantee that a secondary process
	 * would come from the same version of an executable.
	 * TruFlow initializes this variable on tf_open_session().
	 *
	 * Owner:  TruFlow
	 * Access: TruFlow
	 */
	struct tf_session_version ver;
	/**
	 * will be STAILQ_ENTRY(tf_session_info) next
	 *
	 * Owner:  ULP
	 * Access: ULP
	 */
	void                 *next;
	/**
	 * Session ID is a unique identifier for the session. TruFlow
	 * initializes this variable during tf_open_session()
	 * processing.
	 *
	 * Owner:  TruFlow
	 * Access: Truflow & ULP
	 */
	union tf_session_id   session_id;
	/**
	 * Protects access to core_data. Lock is initialized and owned
	 * by ULP. TruFlow can access the core_data without checking
	 * the lock.
	 *
	 * Owner:  ULP
	 * Access: ULP
	 */
	uint8_t               spin_lock;
	/**
	 * The core_data holds the TruFlow tf_session data
	 * structure. This memory is allocated and owned by TruFlow on
	 * tf_open_session().
	 *
	 * TruFlow uses this memory for session management control
	 * until the session is closed by ULP. Access control is done
	 * by the spin_lock which ULP controls ahead of TruFlow API
	 * calls.
	 *
	 * Please see tf_open_session_parms for specification details
	 * on this variable.
	 *
	 * Owner:  TruFlow
	 * Access: TruFlow
	 */
	void                 *core_data;
	/**
	 * The core_data_sz_bytes specifies the size of core_data in
	 * bytes.
	 *
	 * The size is set by TruFlow on tf_open_session().
	 *
	 * Please see tf_open_session_parms for specification details
	 * on this variable.
	 *
	 * Owner:  TruFlow
	 * Access: TruFlow
	 */
	uint32_t              core_data_sz_bytes;
};

/**
 * TruFlow handle
 *
 * Contains a pointer to the session info. Allocated by ULP and passed
 * to TruFlow using tf_open_session(). TruFlow will populate the
 * session info at that time. A TruFlow Session can be used by more
 * than one PF/VF by using the tf_open_session().
 *
 * It is expected that ULP allocates this memory as shared memory.
 *
 * NOTE: This struct must be within the BNXT PMD struct bnxt
 *       (bp). This allows use of container_of() to get access to the PMD.
 */
struct tf {
	struct tf_session_info *session;
	/**
	 * the pointer to the parent bp struct
	 */
	void *bp;
};

/**
 * Identifier resource definition
 */
struct tf_identifier_resources {
	/**
	 * Array of TF Identifiers where each entry is expected to be
	 * set to the requested resource number of that specific type.
	 * The index used is tf_identifier_type.
	 */
	uint16_t cnt[TF_IDENT_TYPE_MAX];
};

/**
 * Table type resource definition
 */
struct tf_tbl_resources {
	/**
	 * Array of TF Table types where each entry is expected to be
	 * set to the requested resource number of that specific
	 * type. The index used is tf_tbl_type.
	 */
	uint16_t cnt[TF_TBL_TYPE_MAX];
};

/**
 * TCAM type resource definition
 */
struct tf_tcam_resources {
	/**
	 * Array of TF TCAM types where each entry is expected to be
	 * set to the requested resource number of that specific
	 * type. The index used is tf_tcam_tbl_type.
	 */
	uint16_t cnt[TF_TCAM_TBL_TYPE_MAX];
};

/**
 * EM type resource definition
 */
struct tf_em_resources {
	/**
	 * Array of TF EM table types where each entry is expected to
	 * be set to the requested resource number of that specific
	 * type. The index used is tf_em_tbl_type.
	 */
	uint16_t cnt[TF_EM_TBL_TYPE_MAX];
};

/**
 * tf_session_resources parameter definition.
 */
struct tf_session_resources {
	/**
	 * [in] Requested Identifier Resources
	 *
	 * Number of identifier resources requested for the
	 * session.
	 */
	struct tf_identifier_resources ident_cnt[TF_DIR_MAX];
	/**
	 * [in] Requested Index Table resource counts
	 *
	 * The number of index table resources requested for the
	 * session.
	 */
	struct tf_tbl_resources tbl_cnt[TF_DIR_MAX];
	/**
	 * [in] Requested TCAM Table resource counts
	 *
	 * The number of TCAM table resources requested for the
	 * session.
	 */

	struct tf_tcam_resources tcam_cnt[TF_DIR_MAX];
	/**
	 * [in] Requested EM resource counts
	 *
	 * The number of internal EM table resources requested for the
	 * session.
	 */
	struct tf_em_resources em_cnt[TF_DIR_MAX];
};

/**
 * tf_open_session parameters definition.
 */
struct tf_open_session_parms {
	/**
	 * [in] ctrl_chan_name
	 *
	 * String containing name of control channel interface to be
	 * used for this session to communicate with firmware.
	 *
	 * The ctrl_chan_name can be looked up by using
	 * rte_eth_dev_get_name_by_port() within the ULP.
	 *
	 * ctrl_chan_name will be used as part of a name for any
	 * shared memory allocation. The ctrl_chan_name is usually in format
	 * 0000:02:00.0. The name for shared session is 0000:02:00.0-tf_shared.
	 */
	char ctrl_chan_name[TF_SESSION_NAME_MAX];
	/**
	 * [in] shadow_copy
	 *
	 * Boolean controlling the use and availability of shadow
	 * copy. Shadow copy will allow the TruFlow to keep track of
	 * resource content on the firmware side without having to
	 * query firmware. Additional private session core_data will
	 * be allocated if this boolean is set to 'true', default
	 * 'false'.
	 *
	 * Size of memory depends on the NVM Resource settings for the
	 * control channel.
	 */
	bool shadow_copy;
	/**
	 * [in/out] session_id
	 *
	 * Session_id is unique per session.
	 *
	 * Session_id is composed of domain, bus, device and
	 * fw_session_id. The construction is done by parsing the
	 * ctrl_chan_name together with allocation of a fw_session_id.
	 *
	 * The session_id allows a session to be shared between devices.
	 */
	union tf_session_id session_id;
	/**
	 * [in/out] session_client_id
	 *
	 * Session_client_id is unique per client.
	 *
	 * Session_client_id is composed of session_id and the
	 * fw_session_client_id fw_session_id. The construction is
	 * done by parsing the ctrl_chan_name together with allocation
	 * of a fw_session_client_id during tf_open_session().
	 *
	 * A reference count will be incremented in the session on
	 * which a client is created.
	 *
	 * A session can first be closed if there is one Session
	 * Client left. Session Clients should closed using
	 * tf_close_session().
	 */
	union tf_session_client_id session_client_id;
	/**
	 * [in] device type
	 *
	 * Device type for the session.
	 */
	enum tf_device_type device_type;
	/**
	 * [in] resources
	 *
	 * Resource allocation for the session.
	 */
	struct tf_session_resources resources;

	/**
	 * [in] bp
	 * The pointer to the parent bp struct. This is only used for HWRM
	 * message passing within the portability layer. The type is struct
	 * bnxt.
	 */
	void *bp;

	/**
	 * [in]
	 *
	 * The number of slices per row for WC TCAM entry.
	 */
	enum tf_wc_num_slice wc_num_slices;

	/**
	 * [out] shared_session_creator
	 *
	 * Indicates whether the application created the session if set.
	 * Otherwise the shared session already existed.  Just for information
	 * purposes.
	 */
	int shared_session_creator;
};

/**
 * Opens a new TruFlow Session or session client.
 *
 * What gets created depends on the passed in tfp content. If the tfp does not
 * have prior session data a new session with associated session client. If tfp
 * has a session already a session client will be created. In both cases the
 * session client is created using the provided ctrl_chan_name.
 *
 * In case of session creation TruFlow will allocate session specific memory to
 * hold its session data. This data is private to TruFlow.
 *
 * No other TruFlow APIs will succeed unless this API is first called
 * and succeeds.
 *
 * tf_open_session() returns a session id and session client id.  These are
 * also stored within the tfp structure passed in to all other APIs.
 *
 * A Session or session client can be closed using tf_close_session().
 *
 * There are 2 types of sessions - shared and not.  For non-shared all
 * the allocated resources are owned and managed by a single session instance.
 * No other applications have access to the resources owned by the non-shared
 * session.  For a shared session, resources are shared between 2 applications.
 *
 * When the caller of tf_open_session() sets the ctrl_chan_name[] to a name
 * like "0000:02:00.0-tf_shared", it is a request to create a new "shared"
 * session in the firmware or access the existing shared session. There is
 * only 1 shared session that can be created. If the shared session has
 * already been created in the firmware, this API will return this indication
 * by clearing the shared_session_creator flag. Only the first shared session
 * create will have the shared_session_creator flag set.
 *
 * The shared session should always be the first session to be created by
 * application and the last session closed due to RM management preference.
 *
 * Sessions remain open in the firmware until the last client of the session
 * closes the session (tf_close_session()).
 *
 * [in] tfp
 *   Pointer to TF handle
 *
 * [in] parms
 *   Pointer to open parameters
 *
 * Returns
 *   - (0) if successful.
 *   - (-EINVAL) on failure.
 */
int tf_open_session(struct tf *tfp,
		    struct tf_open_session_parms *parms);

/**
 * General internal resource info
 *
 */
struct tf_resource_info {
	uint16_t start;
	uint16_t stride;
};

/**
 * Identifier resource definition
 */
struct tf_identifier_resource_info {
	/**
	 * Array of TF Identifiers. The index used is tf_identifier_type.
	 */
	struct tf_resource_info info[TF_IDENT_TYPE_MAX];
};

/**
 * Table type resource info definition
 */
struct tf_tbl_resource_info {
	/**
	 * Array of TF Table types. The index used is tf_tbl_type.
	 */
	struct tf_resource_info info[TF_TBL_TYPE_MAX];
};

/**
 * TCAM type resource definition
 */
struct tf_tcam_resource_info {
	/**
	 * Array of TF TCAM types. The index used is tf_tcam_tbl_type.
	 */
	struct tf_resource_info info[TF_TCAM_TBL_TYPE_MAX];
};

/**
 * EM type resource definition
 */
struct tf_em_resource_info {
	/**
	 * Array of TF EM table types. The index used is tf_em_tbl_type.
	 */
	struct tf_resource_info info[TF_EM_TBL_TYPE_MAX];
};

/**
 * tf_session_resources parameter definition.
 */
struct tf_session_resource_info {
	/**
	 * [in] Requested Identifier Resources
	 *
	 * Number of identifier resources requested for the
	 * session.
	 */
	struct tf_identifier_resource_info ident[TF_DIR_MAX];
	/**
	 * [in] Requested Index Table resource counts
	 *
	 * The number of index table resources requested for the
	 * session.
	 */
	struct tf_tbl_resource_info tbl[TF_DIR_MAX];
	/**
	 * [in] Requested TCAM Table resource counts
	 *
	 * The number of TCAM table resources requested for the
	 * session.
	 */

	struct tf_tcam_resource_info tcam[TF_DIR_MAX];
	/**
	 * [in] Requested EM resource counts
	 *
	 * The number of internal EM table resources requested for the
	 * session.
	 */
	struct tf_em_resource_info em[TF_DIR_MAX];
};

/**
 * tf_get_session_resources parameter definition.
 */
struct tf_get_session_info_parms {
	/**
	 * [out] the structure is used to return the information of
	 * allocated resources.
	 *
	 */
	struct tf_session_resource_info session_info;
};

/** (experimental)
 * Gets info about a TruFlow Session
 *
 * Get info about the session which has been created.  Whether it exists and
 * what resource start and stride offsets are in use.  This API is primarily
 * intended to be used by an application which has created a shared session
 * This application needs to obtain the resources which have already been
 * allocated for the shared session.
 *
 * [in] tfp
 *   Pointer to TF handle
 *
 * [in] parms
 *   Pointer to get parameters
 *
 * Returns
 *   - (0) if successful.
 *   - (-EINVAL) on failure.
 */
int tf_get_session_info(struct tf *tfp,
			struct tf_get_session_info_parms *parms);
/**
 * Experimental
 *
 * tf_attach_session parameters definition.
 */
struct tf_attach_session_parms {
	/**
	 * [in] ctrl_chan_name
	 *
	 * String containing name of control channel interface to be
	 * used for this session to communicate with firmware.
	 *
	 * The ctrl_chan_name can be looked up by using
	 * rte_eth_dev_get_name_by_port() within the ULP.
	 *
	 * ctrl_chan_name will be used as part of a name for any
	 * shared memory allocation.
	 */
	char ctrl_chan_name[TF_SESSION_NAME_MAX];

	/**
	 * [in] attach_chan_name
	 *
	 * String containing name of attach channel interface to be
	 * used for this session.
	 *
	 * The attach_chan_name must be given to a 2nd process after
	 * the primary process has been created. This is the
	 * ctrl_chan_name of the primary process and is used to find
	 * the shared memory for the session that the attach is going
	 * to use.
	 */
	char attach_chan_name[TF_SESSION_NAME_MAX];

	/**
	 * [in] session_id
	 *
	 * Session_id is unique per session. For Attach the session_id
	 * should be the session_id that was returned on the first
	 * open.
	 *
	 * Session_id is composed of domain, bus, device and
	 * fw_session_id. The construction is done by parsing the
	 * ctrl_chan_name together with allocation of a fw_session_id
	 * during tf_open_session().
	 *
	 * A reference count will be incremented on attach. A session
	 * is first fully closed when reference count is zero by
	 * calling tf_close_session().
	 */
	union tf_session_id session_id;
};

/**
 * Experimental
 *
 * Allows a 2nd application instance to attach to an existing
 * session. Used when a session is to be shared between two processes.
 *
 * Attach will increment a ref count as to manage the shared session data.
 *
 * [in] tfp
 *   Pointer to TF handle
 *
 * [in] parms
 *   Pointer to attach parameters
 *
 * Returns
 *   - (0) if successful.
 *   - (-EINVAL) on failure.
 */
int tf_attach_session(struct tf *tfp,
		      struct tf_attach_session_parms *parms);

/**
 * Closes an existing session client or the session it self. The
 * session client is default closed and if the session reference count
 * is 0 then the session is closed as well.
 *
 * On session close all hardware and firmware state associated with
 * the TruFlow application is cleaned up.
 *
 * The session client is extracted from the tfp. Thus tf_close_session()
 * cannot close a session client on behalf of another function.
 *
 * Returns success or failure code.
 */
int tf_close_session(struct tf *tfp);

/**
 * @page  ident Identity Management
 *
 * @ref tf_alloc_identifier
 *
 * @ref tf_free_identifier
 */
/**
 * tf_alloc_identifier parameter definition
 */
struct tf_alloc_identifier_parms {
	/**
	 * [in]	 receive or transmit direction
	 */
	enum tf_dir dir;
	/**
	 * [in] Identifier type
	 */
	enum tf_identifier_type ident_type;
	/**
	 * [out] Allocated identifier
	 */
	uint32_t id;
};

/**
 * tf_free_identifier parameter definition
 */
struct tf_free_identifier_parms {
	/**
	 * [in]	 receive or transmit direction
	 */
	enum tf_dir dir;
	/**
	 * [in] Identifier type
	 */
	enum tf_identifier_type ident_type;
	/**
	 * [in] ID to free
	 */
	uint32_t id;
	/**
	 * (experimental)
	 * [out] Current refcnt after free
	 */
	uint32_t ref_cnt;
};

/**
 * tf_search_identifier parameter definition (experimental)
 */
struct tf_search_identifier_parms {
	/**
	 * [in]	 receive or transmit direction
	 */
	enum tf_dir dir;
	/**
	 * [in] Identifier type
	 */
	enum tf_identifier_type ident_type;
	/**
	 * [in] Identifier data to search for
	 */
	uint32_t search_id;
	/**
	 * [out] Set if matching identifier found
	 */
	bool hit;
	/**
	 * [out] Current ref count after allocation
	 */
	uint32_t ref_cnt;
};

/**
 * allocate identifier resource
 *
 * TruFlow core will allocate a free id from the per identifier resource type
 * pool reserved for the session during tf_open().  No firmware is involved.
 *
 * If shadow copy is enabled, the internal ref_cnt is set to 1 in the
 * shadow table for a newly allocated resource.
 *
 * Returns success or failure code.
 */
int tf_alloc_identifier(struct tf *tfp,
			struct tf_alloc_identifier_parms *parms);

/**
 * free identifier resource
 *
 * TruFlow core will return an id back to the per identifier resource type pool
 * reserved for the session.  No firmware is involved.  During tf_close, the
 * complete pool is returned to the firmware.
 *
 * additional operation (experimental)
 * Decrement reference count.  Only release resource once refcnt goes to 0 if
 * shadow copy is enabled.
 *
 * Returns success or failure code.
 */
int tf_free_identifier(struct tf *tfp,
		       struct tf_free_identifier_parms *parms);

/**
 * Search identifier resource (experimental)
 *
 * If the shadow copy is enabled search_id is used to search for a matching
 * entry in the shadow table.  The shadow table consists of an array of
 * reference counts indexed by identifier.  If a matching entry is found hit is
 * set to TRUE, refcnt is increased by 1 and returned.  Otherwise, hit is
 * set to false and refcnt is set to 0.
 *
 * TODO: we may need a per table internal shadow copy enable flag to stage
 * the shadow table implementation.  We do not need the shadow table for other
 * tables at this time so we may only want to enable the identifier shadow.
 *
 * TODO: remove this pseudocode below added to show that if search fails
 * we shouldn't allocate a new entry but return.
 *
 * identifier alloc (search_en=1)
 * if (ident is allocated and ref_cnt >=1)
 *      return ident - hit is set, incr refcnt
 * else (not found)
 *      return
 *
 */
int tf_search_identifier(struct tf *tfp,
			 struct tf_search_identifier_parms *parms);

/**
 * @page dram_table DRAM Table Scope Interface
 *
 * @ref tf_alloc_tbl_scope
 *
 * @ref tf_free_tbl_scope
 *
 * If we allocate the EEM memory from the core, we need to store it in
 * the shared session data structure to make sure it can be freed later.
 * (for example if the PF goes away)
 *
 * Current thought is that memory is allocated within core.
 */

/**
 * tf_alloc_tbl_scope_parms definition
 */
struct tf_alloc_tbl_scope_parms {
	/**
	 * [in] All Maximum key size required.
	 */
	uint16_t rx_max_key_sz_in_bits;
	/**
	 * [in] Maximum Action size required (includes inlined items)
	 */
	uint16_t rx_max_action_entry_sz_in_bits;
	/**
	 * [in] Memory size in Megabytes
	 * Total memory size allocated by user to be divided
	 * up for actions, hash, counters.  Only inline external actions.
	 * Use this variable or the number of flows, do not set both.
	 */
	uint32_t rx_mem_size_in_mb;
	/**
	 * [in] Number of flows * 1000. If set, rx_mem_size_in_mb must equal 0.
	 */
	uint32_t rx_num_flows_in_k;
	/**
	 * [in] All Maximum key size required.
	 */
	uint16_t tx_max_key_sz_in_bits;
	/**
	 * [in] Maximum Action size required (includes inlined items)
	 */
	uint16_t tx_max_action_entry_sz_in_bits;
	/**
	 * [in] Memory size in Megabytes
	 * Total memory size allocated by user to be divided
	 * up for actions, hash, counters.  Only inline external actions.
	 */
	uint32_t tx_mem_size_in_mb;
	/**
	 * [in] Number of flows * 1000
	 */
	uint32_t tx_num_flows_in_k;
	/**
	 * [in] Flush pending HW cached flows every 1/10th of value
	 * set in seconds, both idle and active flows are flushed
	 * from the HW cache. If set to 0, this feature will be disabled.
	 */
	uint8_t hw_flow_cache_flush_timer;
	/**
	 * [out] table scope identifier
	 */
	uint32_t tbl_scope_id;
};
/**
 * tf_free_tbl_scope_parms definition
 */
struct tf_free_tbl_scope_parms {
	/**
	 * [in] table scope identifier
	 */
	uint32_t tbl_scope_id;
};

/**
 * tf_map_tbl_scope_parms definition
 */
struct tf_map_tbl_scope_parms {
	/**
	 * [in] table scope identifier
	 */
	uint32_t tbl_scope_id;
	/**
	 * [in] Which parifs are associated with this table scope.  Bit 0
	 *      indicates parif 0.
	 */
	uint16_t parif_bitmask;
};

/**
 * allocate a table scope
 *
 * The scope is a software construct to identify an EEM table.  This function will
 * divide the hash memory/buckets and records according to the device
 * device constraints based upon calculations using either the number of flows
 * requested or the size of memory indicated.  Other parameters passed in
 * determine the configuration (maximum key size, maximum external action record
 * size).
 *
 * A single API is used to allocate a common table scope identifier in both
 * receive and transmit CFA. The scope identifier is common due to nature of
 * connection tracking sending notifications between RX and TX direction.
 *
 * The receive and transmit table access identifiers specify which rings will
 * be used to initialize table DRAM.  The application must ensure mutual
 * exclusivity of ring usage for table scope allocation and any table update
 * operations.
 *
 * The hash table buckets, EM keys, and EM lookup results are stored in the
 * memory allocated based on the rx_em_hash_mb/tx_em_hash_mb parameters.  The
 * hash table buckets are stored at the beginning of that memory.
 *
 * NOTE:  No EM internal setup is done here. On chip EM records are managed
 * internally by TruFlow core.
 *
 * Returns success or failure code.
 */
int tf_alloc_tbl_scope(struct tf *tfp,
		       struct tf_alloc_tbl_scope_parms *parms);

/**
 * map a table scope (legacy device only Wh+/SR)
 *
 * Map a table scope to one or more partition interfaces (parifs).
 * The parif can be remapped in the L2 context lookup for legacy devices.  This
 * API allows a number of parifs to be mapped to the same table scope.  On
 * legacy devices a table scope identifies one of 16 sets of EEM table base
 * addresses and is associated with a PF communication channel.  The associated
 * PF must be configured for the table scope to operate.
 *
 * An L2 context TCAM lookup returns a remapped parif value used to
 * index into the set of 16 parif_to_pf registers which are used to map to one
 * of the 16 table scopes.  This API allows the user to map the parifs in the
 * mask to the previously allocated table scope (EEM table).

 * Returns success or failure code.
 */
int tf_map_tbl_scope(struct tf *tfp,
		      struct tf_map_tbl_scope_parms *parms);
/**
 * free a table scope
 *
 * Firmware checks that the table scope ID is owned by the TruFlow
 * session, verifies that no references to this table scope remains
 * or Profile TCAM entries for either CFA (RX/TX) direction,
 * then frees the table scope ID.
 *
 * Returns success or failure code.
 */
int tf_free_tbl_scope(struct tf *tfp,
		      struct tf_free_tbl_scope_parms *parms);

/**
 * @page tcam TCAM Access
 *
 * @ref tf_search_tcam_entry
 *
 * @ref tf_alloc_tcam_entry
 *
 * @ref tf_set_tcam_entry
 *
 * @ref tf_get_tcam_entry
 *
 * @ref tf_free_tcam_entry
 *
#ifdef TF_TCAM_SHARED
 * @ref tf_move_tcam_shared_entries
 *
 * @ref tf_clear_tcam_shared_entries
#endif
 */

/**
 * tf_search_tcam_entry parameter definition (experimental)
 */
struct tf_search_tcam_entry_parms {
	/**
	 * [in] receive or transmit direction
	 */
	enum tf_dir dir;
	/**
	 * [in] TCAM table type
	 */
	enum tf_tcam_tbl_type tcam_tbl_type;
	/**
	 * [in] Key data to match on
	 */
	uint8_t *key;
	/**
	 * [in] key size in bits
	 */
	uint16_t key_sz_in_bits;
	/**
	 * [in] Mask data to match on
	 */
	uint8_t *mask;
	/**
	 * [in] Priority of entry requested (definition TBD)
	 */
	uint32_t priority;
	/**
	 * [in] Allocate on miss.
	 */
	uint8_t alloc;
	/**
	 * [out] Set if matching entry found
	 */
	uint8_t hit;
	/**
	 * [out] Search result status (hit, miss, reject)
	 */
	enum tf_search_status search_status;
	/**
	 * [out] Current refcnt after allocation
	 */
	uint16_t ref_cnt;
	/**
	 * [in out] The result data from the search is copied here
	 */
	uint8_t *result;
	/**
	 * [in out] result size in bits for the result data
	 */
	uint16_t result_sz_in_bits;
	/**
	 * [out] Index found
	 */
	uint16_t idx;
};

/**
 * search TCAM entry (experimental)
 *
 * Search for a TCAM entry
 *
 * This function searches the shadow copy of the TCAM table for a matching
 * entry.  Key and mask must match for hit to be set.  Only TruFlow core data
 * is accessed.  If shadow_copy is not enabled, an error is returned.
 *
 * Implementation:
 *
 * A hash is performed on the key/mask data and mapped to a shadow copy entry
 * where the full key/mask is populated.  If the full key/mask matches the
 * entry, hit is set, ref_cnt is incremented, and search_status indicates what
 * action the caller can take regarding setting the entry.
 *
 * search_status should be used as follows:
 * - On Miss, the caller should create a result and call tf_set_tcam_entry with
 * returned index.
 *
 * - On Reject, the hash table is full and the entry cannot be added.
 *
 * - On Hit, the result data is returned to the caller.  Additionally, the
 * ref_cnt is updated.
 *
 * Also returns success or failure code.
 */
int tf_search_tcam_entry(struct tf *tfp,
			 struct tf_search_tcam_entry_parms *parms);

/**
 * tf_alloc_tcam_entry parameter definition
 */
struct tf_alloc_tcam_entry_parms {
	/**
	 * [in] receive or transmit direction
	 */
	enum tf_dir dir;
	/**
	 * [in] TCAM table type
	 */
	enum tf_tcam_tbl_type tcam_tbl_type;
	/**
	 * [in] Enable search for matching entry
	 */
	uint8_t search_enable;
	/**
	 * [in] Key data to match on (if search)
	 */
	uint8_t *key;
	/**
	 * [in] key size in bits (if search)
	 */
	uint16_t key_sz_in_bits;
	/**
	 * [in] Mask data to match on (if search)
	 */
	uint8_t *mask;
	/**
	 * [in] Priority of entry requested (definition TBD)
	 */
	uint32_t priority;
	/**
	 * [out] If search, set if matching entry found
	 */
	uint8_t hit;
	/**
	 * [out] Current refcnt after allocation
	 */
	uint16_t ref_cnt;
	/**
	 * [out] Idx allocated
	 *
	 */
	uint16_t idx;
};

/**
 * allocate TCAM entry
 *
 * Allocate a TCAM entry - one of these types:
 *
 * L2 Context
 * Profile TCAM
 * WC TCAM
 * VEB TCAM
 *
 * This function allocates a TCAM table record.	 This function
 * will attempt to allocate a TCAM table entry from the session
 * owned TCAM entries or search a shadow copy of the TCAM table for a
 * matching entry if search is enabled.	 Key, mask and result must match for
 * hit to be set.  Only TruFlow core data is accessed.
 * A hash table to entry mapping is maintained for search purposes.  If
 * search is not enabled, the first available free entry is returned based
 * on priority and alloc_cnt is set to 1.  If search is enabled and a matching
 * entry to entry_data is found, hit is set to TRUE and alloc_cnt is set to 1.
 * RefCnt is also returned.
 *
 * Also returns success or failure code.
 */
int tf_alloc_tcam_entry(struct tf *tfp,
			struct tf_alloc_tcam_entry_parms *parms);

/**
 * tf_set_tcam_entry parameter definition
 */
struct	tf_set_tcam_entry_parms {
	/**
	 * [in] receive or transmit direction
	 */
	enum tf_dir dir;
	/**
	 * [in] TCAM table type
	 */
	enum tf_tcam_tbl_type tcam_tbl_type;
	/**
	 * [in] base index of the entry to program
	 */
	uint16_t idx;
	/**
	 * [in] struct containing key
	 */
	uint8_t *key;
	/**
	 * [in] struct containing mask fields
	 */
	uint8_t *mask;
	/**
	 * [in] key size in bits (if search)
	 */
	uint16_t key_sz_in_bits;
	/**
	 * [in] struct containing result
	 */
	uint8_t *result;
	/**
	 * [in] struct containing result size in bits
	 */
	uint16_t result_sz_in_bits;
};

/**
 * set TCAM entry
 *
 * Program a TCAM table entry for a TruFlow session.
 *
 * If the entry has not been allocated, an error will be returned.
 *
 * Returns success or failure code.
 */
int tf_set_tcam_entry(struct tf	*tfp,
		      struct tf_set_tcam_entry_parms *parms);

/**
 * tf_get_tcam_entry parameter definition
 */
struct tf_get_tcam_entry_parms {
	/**
	 * [in] receive or transmit direction
	 */
	enum tf_dir dir;
	/**
	 * [in] TCAM table type
	 */
	enum tf_tcam_tbl_type  tcam_tbl_type;
	/**
	 * [in] index of the entry to get
	 */
	uint16_t idx;
	/**
	 * [out] struct containing key
	 */
	uint8_t *key;
	/**
	 * [out] struct containing mask fields
	 */
	uint8_t *mask;
	/**
	 * [in/out] key size in bits
	 */
	uint16_t key_sz_in_bits;
	/**
	 * [out] struct containing result
	 */
	uint8_t *result;
	/**
	 * [in/out] struct containing result size in bits
	 */
	uint16_t result_sz_in_bits;
};

/**
 * get TCAM entry
 *
 * Program a TCAM table entry for a TruFlow session.
 *
 * If the entry has not been allocated, an error will be returned.
 *
 * Returns success or failure code.
 */
int tf_get_tcam_entry(struct tf *tfp,
		      struct tf_get_tcam_entry_parms *parms);

/**
 * tf_free_tcam_entry parameter definition
 */
struct tf_free_tcam_entry_parms {
	/**
	 * [in] receive or transmit direction
	 */
	enum tf_dir dir;
	/**
	 * [in] TCAM table type
	 */
	enum tf_tcam_tbl_type tcam_tbl_type;
	/**
	 * [in] Index to free
	 */
	uint16_t idx;
	/**
	 * [out] reference count after free
	 */
	uint16_t ref_cnt;
};

/**
 * free TCAM entry
 *
 * Free TCAM entry.
 *
 * Firmware checks to ensure the TCAM entries are owned by the TruFlow
 * session.  TCAM entry will be invalidated.  All-ones mask.
 * writes to hw.
 *
 * WCTCAM profile id of 0 must be used to invalidate an entry.
 *
 * Returns success or failure code.
 */
int tf_free_tcam_entry(struct tf *tfp,
		       struct tf_free_tcam_entry_parms *parms);

#ifdef TF_TCAM_SHARED
/**
 * tf_move_tcam_shared_entries parameter definition
 */
struct tf_move_tcam_shared_entries_parms {
	/**
	 * [in] receive or transmit direction
	 */
	enum tf_dir dir;
	/**
	 * [in] TCAM table type
	 */
	enum tf_tcam_tbl_type tcam_tbl_type;
};

/**
 * Move TCAM entries
 *
 * This API only affects the following TCAM pools within a shared session:
 *
 * TF_TCAM_TBL_TYPE_WC_TCAM_HIGH
 * TF_TCAM_TBL_TYPE_WC_TCAM_LOW
 *
 * When called, all allocated entries from the high pool will be moved to
 * the low pool.  Then the allocated entries in the high pool will be
 * cleared and freed.
 *
 * This API is not supported on a non-shared session.
 *
 * Returns success or failure code.
 */
int tf_move_tcam_shared_entries(struct tf *tfp,
				struct tf_move_tcam_shared_entries_parms *parms);

/**
 * tf_clear_tcam_shared_entries parameter definition
 */
struct tf_clear_tcam_shared_entries_parms {
	/**
	 * [in] receive or transmit direction
	 */
	enum tf_dir dir;
	/**
	 * [in] TCAM table type
	 */
	enum tf_tcam_tbl_type tcam_tbl_type;
};

/**
 * Clear TCAM shared entries pool
 *
 * This API only affects the following TCAM pools within a shared session:
 *
 * TF_TCAM_TBL_TYPE_WC_TCAM_HIGH
 * TF_TCAM_TBL_TYPE_WC_TCAM_LOW
 *
 * When called, the indicated WC TCAM high or low pool will be cleared.
 *
 * This API is not supported on a non-shared session.
 *
 * Returns success or failure code.
 */
int tf_clear_tcam_shared_entries(struct tf *tfp,
			      struct tf_clear_tcam_shared_entries_parms *parms);

#endif /* TF_TCAM_SHARED */
/**
 * @page table Table Access
 *
 * @ref tf_alloc_tbl_entry
 *
 * @ref tf_free_tbl_entry
 *
 * @ref tf_set_tbl_entry
 *
 * @ref tf_get_tbl_entry
 *
 * @ref tf_bulk_get_tbl_entry
 *
 * @ref tf_get_shared_tbl_increment
 */

/**
 * tf_alloc_tbl_entry parameter definition
 */
struct tf_alloc_tbl_entry_parms {
	/**
	 * [in] Receive or transmit direction
	 */
	enum tf_dir dir;
	/**
	 * [in] Type of the allocation
	 */
	enum tf_tbl_type type;
	/**
	 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
	 */
	uint32_t tbl_scope_id;

	/**
	 * [out] Idx of allocated entry
	 */
	uint32_t idx;
};

/**
 * allocate index table entries
 *
 * Internal types:
 *
 * Allocate an on chip index table entry or search for a matching
 * entry of the indicated type for this TruFlow session.
 *
 * Allocates an index table record. This function will attempt to
 * allocate an index table entry.
 *
 * External types:
 *
 * These are used to allocate inlined action record memory.
 *
 * Allocates an external index table action record.
 *
 * NOTE:
 * Implementation of the internals of the external function will be a stack with
 * push and pop.
 *
 * Returns success or failure code.
 */
int tf_alloc_tbl_entry(struct tf *tfp,
		       struct tf_alloc_tbl_entry_parms *parms);

/**
 * tf_free_tbl_entry parameter definition
 */
struct tf_free_tbl_entry_parms {
	/**
	 * [in] Receive or transmit direction
	 */
	enum tf_dir dir;
	/**
	 * [in] Type of the allocation type
	 */
	enum tf_tbl_type type;
	/**
	 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
	 */
	uint32_t tbl_scope_id;
	/**
	 * [in] Index to free
	 */
	uint32_t idx;
};

/**
 * free index table entry
 *
 * Used to free a previously allocated table entry.
 *
 * Internal types:
 *
 * The element is freed and given back to the session pool.
 *
 * External types:
 *
 * Frees an external index table action record.
 *
 * NOTE:
 * Implementation of the internals of the external table will be a stack with
 * push and pop.
 *
 * Returns success or failure code.
 */
int tf_free_tbl_entry(struct tf *tfp,
		      struct tf_free_tbl_entry_parms *parms);

/**
 * tf_set_tbl_entry parameter definition
 */
struct tf_set_tbl_entry_parms {
	/**
	 * [in] Table scope identifier
	 */
	uint32_t tbl_scope_id;
	/**
	 * [in] Receive or transmit direction
	 */
	enum tf_dir dir;
	/**
	 * [in] Type of object to set
	 */
	enum tf_tbl_type type;
	/**
	 * [in] Entry data
	 */
	uint8_t *data;
	/**
	 * [in] Entry size
	 */
	uint16_t data_sz_in_bytes;
	/**
	 * [in] External memory channel type to use
	 */
	enum tf_ext_mem_chan_type chan_type;
	/**
	 * [in] Entry index to write to
	 */
	uint32_t idx;
};

/**
 * set index table entry
 *
 * Used to set an application programmed index table entry into a
 * previous allocated table location.
 *
 * Returns success or failure code.
 */
int tf_set_tbl_entry(struct tf *tfp,
		     struct tf_set_tbl_entry_parms *parms);

/**
 * tf_get_shared_tbl_increment parameter definition
 */
struct tf_get_shared_tbl_increment_parms {
	/**
	 * [in] Receive or transmit direction
	 */
	enum tf_dir dir;
	/**
	 * [in] Type of object to set
	 */
	enum tf_tbl_type type;
	/**
	 * [out] Value to increment by for resource type
	 */
	uint32_t increment_cnt;
};

/**
 * tf_get_shared_tbl_increment
 *
 * This API is currently only required for use in the shared
 * session for Thor (p58) actions.  An increment count is returned per
 * type to indicate how much to increment the start by for each
 * entry (see tf_resource_info)
 *
 * Returns success or failure code.
 */
int tf_get_shared_tbl_increment(struct tf *tfp,
				struct tf_get_shared_tbl_increment_parms *parms);

/**
 * tf_get_tbl_entry parameter definition
 */
struct tf_get_tbl_entry_parms {
	/**
	 * [in] Receive or transmit direction
	 */
	enum tf_dir dir;
	/**
	 * [in] Type of object to get
	 */
	enum tf_tbl_type type;
	/**
	 * [out] Entry data
	 */
	uint8_t *data;
	/**
	 * [in] Entry size
	 */
	uint16_t data_sz_in_bytes;
	/**
	 * [in] External memory channel type to use
	 */
	enum tf_ext_mem_chan_type chan_type;
	/**
	 * [in] Entry index to read
	 */
	uint32_t idx;
};

/**
 * get index table entry
 *
 * Used to retrieve a previous set index table entry.
 *
 * Reads and compares with the shadow table copy (if enabled) (only
 * for internal objects).
 *
 * Returns success or failure code. Failure will be returned if the
 * provided data buffer is too small for the data type requested.
 */
int tf_get_tbl_entry(struct tf *tfp,
		     struct tf_get_tbl_entry_parms *parms);

/**
 * tf_bulk_get_tbl_entry parameter definition
 */
struct tf_bulk_get_tbl_entry_parms {
	/**
	 * [in] Receive or transmit direction
	 */
	enum tf_dir dir;
	/**
	 * [in] Type of object to get
	 */
	enum tf_tbl_type type;
	/**
	 * [in] Starting index to read from
	 */
	uint32_t starting_idx;
	/**
	 * [in] Number of sequential entries
	 */
	uint16_t num_entries;
	/**
	 * [in] Size of the single entry
	 */
	uint16_t entry_sz_in_bytes;
	/**
	 * [out] Host physical address, where the data
	 * will be copied to by the firmware.
	 * Use tfp_calloc() API and mem_pa
	 * variable of the tfp_calloc_parms
	 * structure for the physical address.
	 */
	uint64_t physical_mem_addr;
	/**
	 * [in] External memory channel type to use
	 */
	enum tf_ext_mem_chan_type chan_type;
};

/**
 * Bulk get index table entry
 *
 * Used to retrieve a set of index table entries.
 *
 * Entries within the range may not have been allocated using
 * tf_alloc_tbl_entry() at the time of access. But the range must
 * be within the bounds determined from tf_open_session() for the
 * given table type.  Currently, this is only used for collecting statistics.
 *
 * Returns success or failure code. Failure will be returned if the
 * provided data buffer is too small for the data type requested.
 */
int tf_bulk_get_tbl_entry(struct tf *tfp,
			  struct tf_bulk_get_tbl_entry_parms *parms);

/**
 * @page exact_match Exact Match Table
 *
 * @ref tf_insert_em_entry
 *
 * @ref tf_delete_em_entry
 *
 * @ref tf_search_em_entry
 *
 */
/**
 * tf_insert_em_entry parameter definition
 */
struct tf_insert_em_entry_parms {
	/**
	 * [in] receive or transmit direction
	 */
	enum tf_dir dir;
	/**
	 * [in] internal or external
	 */
	enum tf_mem mem;
	/**
	 * [in] ID of table scope to use (external only)
	 */
	uint32_t tbl_scope_id;
	/**
	 * [in] ptr to structure containing key fields
	 */
	uint8_t *key;
	/**
	 * [in] key bit length
	 */
	uint16_t key_sz_in_bits;
	/**
	 * [in] ptr to structure containing result field
	 */
	uint8_t *em_record;
	/**
	 * [out] result size in bits
	 */
	uint16_t em_record_sz_in_bits;
	/**
	 * [in] duplicate check flag
	 */
	uint8_t	dup_check;
	/**
	 * [in] External memory channel type to use
	 */
	enum tf_ext_mem_chan_type chan_type;
	/**
	 * [out] Flow handle value for the inserted entry.  This is encoded
	 * as the entries[4]:bucket[2]:hashId[1]:hash[14]
	 */
	uint64_t flow_handle;
	/**
	 * [out] Flow id is returned as null (internal)
	 * Flow id is the GFID value for the inserted entry (external)
	 * This is the value written to the BD and useful information for mark.
	 */
	uint64_t flow_id;
};
/**
 * tf_delete_em_entry parameter definition
 */
struct tf_delete_em_entry_parms {
	/**
	 * [in] receive or transmit direction
	 */
	enum tf_dir dir;
	/**
	 * [in] internal or external
	 */
	enum tf_mem mem;
	/**
	 * [in] ID of table scope to use (external only)
	 */
	uint32_t tbl_scope_id;
	/**
	 * [out] The index of the entry
	 */
	uint16_t index;
	/**
	 * [in] External memory channel type to use
	 */
	enum tf_ext_mem_chan_type chan_type;
	/**
	 * [in] structure containing flow delete handle information
	 */
	uint64_t flow_handle;
};
/**
 * tf_move_em_entry parameter definition
 */
struct tf_move_em_entry_parms {
	/**
	 * [in] receive or transmit direction
	 */
	enum tf_dir dir;
	/**
	 * [in] internal or external
	 */
	enum tf_mem mem;
	/**
	 * [in] ID of table scope to use (external only)
	 */
	uint32_t tbl_scope_id;
	/**
	 * [in] ID of table interface to use (SR2 only)
	 */
	uint32_t tbl_if_id;
	/**
	 * [in] epoch group IDs of entry to delete
	 * 2 element array with 2 ids. (SR2 only)
	 */
	uint16_t *epochs;
	/**
	 * [out] The index of the entry
	 */
	uint16_t index;
	/**
	 * [in] External memory channel type to use
	 */
	enum tf_ext_mem_chan_type chan_type;
	/**
	 * [in] The index of the new EM record
	 */
	uint32_t new_index;
	/**
	 * [in] structure containing flow delete handle information
	 */
	uint64_t flow_handle;
};
/**
 * tf_search_em_entry parameter definition (Future)
 */
struct tf_search_em_entry_parms {
	/**
	 * [in] receive or transmit direction
	 */
	enum tf_dir dir;
	/**
	 * [in] internal or external
	 */
	enum tf_mem mem;
	/**
	 * [in] ID of table scope to use (external only)
	 */
	uint32_t tbl_scope_id;
	/**
	 * [in] ptr to structure containing key fields
	 */
	uint8_t *key;
	/**
	 * [in] key bit length
	 */
	uint16_t key_sz_in_bits;
	/**
	 * [in/out] ptr to structure containing EM record fields
	 */
	uint8_t *em_record;
	/**
	 * [out] result size in bits
	 */
	uint16_t em_record_sz_in_bits;
	/**
	 * [in] External memory channel type to use
	 */
	enum tf_ext_mem_chan_type chan_type;
	/**
	 * [in] ptr to structure containing flow delete handle
	 */
	uint64_t flow_handle;
};

/**
 * insert em hash entry in internal table memory
 *
 * Internal:
 *
 * This API inserts an exact match entry into internal EM table memory
 * of the specified direction.
 *
 * Note: The EM record is managed within the TruFlow core and not the
 * application.
 *
 * Shadow copy of internal record table an association with hash and 1,2, or 4
 * associated buckets
 *
 * External:
 * This API inserts an exact match entry into DRAM EM table memory of the
 * specified direction and table scope.
 *
 * The insertion of duplicate entries in an EM table is not permitted.	If a
 * TruFlow application can guarantee that it will never insert duplicates, it
 * can disable duplicate checking by passing a zero value in the  dup_check
 * parameter to this API.  This will optimize performance. Otherwise, the
 * TruFlow library will enforce protection against inserting duplicate entries.
 *
 * Flow handle is defined in this document:
 *
 * https://docs.google.com
 * /document/d/1NESu7RpTN3jwxbokaPfYORQyChYRmJgs40wMIRe8_-Q/edit
 *
 * Returns success or busy code.
 *
 */
int tf_insert_em_entry(struct tf *tfp,
		       struct tf_insert_em_entry_parms *parms);

/**
 * delete em hash entry table memory
 *
 * Internal:
 *
 * This API deletes an exact match entry from internal EM table memory of the
 * specified direction. If a valid flow ptr is passed in then that takes
 * precedence over the pointer to the complete key passed in.
 *
 *
 * External:
 *
 * This API deletes an exact match entry from EM table memory of the specified
 * direction and table scope. If a valid flow handle is passed in then that
 * takes precedence over the pointer to the complete key passed in.
 *
 * The TruFlow library may release a dynamic bucket when an entry is deleted.
 *
 *
 * Returns success or not found code
 *
 *
 */
int tf_delete_em_entry(struct tf *tfp,
		       struct tf_delete_em_entry_parms *parms);

/**
 * search em hash entry table memory (Future)
 *
 * Internal:

 * This API looks up an EM entry in table memory with the specified EM
 * key or flow (flow takes precedence) and direction.
 *
 * The status will be one of: success or entry not found.  If the lookup
 * succeeds, a pointer to the matching entry and the result record associated
 * with the matching entry will be provided.
 *
 * If flow_handle is set, search shadow copy.
 *
 * Otherwise, query the fw with key to get result.
 *
 * External:
 *
 * This API looks up an EM entry in table memory with the specified EM
 * key or flow_handle (flow takes precedence), direction and table scope.
 *
 * The status will be one of: success or entry not found.  If the lookup
 * succeeds, a pointer to the matching entry and the result record associated
 * with the matching entry will be provided.
 *
 * Returns success or not found code
 *
 */
int tf_search_em_entry(struct tf *tfp,
		       struct tf_search_em_entry_parms *parms);

/**
 * @page global Global Configuration
 *
 * @ref tf_set_global_cfg
 *
 * @ref tf_get_global_cfg
 */
/**
 * Tunnel Encapsulation Offsets
 */
enum tf_tunnel_encap_offsets {
	TF_TUNNEL_ENCAP_L2,
	TF_TUNNEL_ENCAP_NAT,
	TF_TUNNEL_ENCAP_MPLS,
	TF_TUNNEL_ENCAP_VXLAN,
	TF_TUNNEL_ENCAP_GENEVE,
	TF_TUNNEL_ENCAP_NVGRE,
	TF_TUNNEL_ENCAP_GRE,
	TF_TUNNEL_ENCAP_FULL_GENERIC
};
/**
 * Global Configuration Table Types
 */
enum tf_global_config_type {
	TF_TUNNEL_ENCAP,  /**< Tunnel Encap Config(TECT) */
	TF_ACTION_BLOCK,  /**< Action Block Config(ABCR) */
	TF_COUNTER_CFG,   /**< Counter Configuration (CNTRS_CTRL) */
	TF_METER_CFG,     /**< Meter Config(ACTP4_FMTCR) */
	TF_METER_INTERVAL_CFG, /**< Meter Interval Config(FMTCR_INTERVAL)  */
	TF_GLOBAL_CFG_TYPE_MAX
};

/**
 * tf_global_cfg parameter definition
 */
struct tf_global_cfg_parms {
	/**
	 * [in] receive or transmit direction
	 */
	enum tf_dir dir;
	/**
	 * [in] Global config type
	 */
	enum tf_global_config_type type;
	/**
	 * [in] Offset @ the type
	 */
	uint32_t offset;
	/**
	 * [in/out] Value of the configuration
	 * set - Read, Modify and Write
	 * get - Read the full configuration
	 */
	uint8_t *config;
	/**
	 * [in] Configuration mask
	 * set - Read, Modify with mask and Write
	 * get - unused
	 */
	uint8_t *config_mask;
	/**
	 * [in] struct containing size
	 */
	uint16_t config_sz_in_bytes;
};

/**
 * Get global configuration
 *
 * Retrieve the configuration
 *
 * Returns success or failure code.
 */
int tf_get_global_cfg(struct tf *tfp,
		      struct tf_global_cfg_parms *parms);

/**
 * Update the global configuration table
 *
 * Read, modify write the value.
 *
 * Returns success or failure code.
 */
int tf_set_global_cfg(struct tf *tfp,
		      struct tf_global_cfg_parms *parms);

/**
 * @page if_tbl Interface Table Access
 *
 * @ref tf_set_if_tbl_entry
 *
 * @ref tf_get_if_tbl_entry
 *
 * @ref tf_restore_if_tbl_entry
 */
/**
 * Enumeration of TruFlow interface table types.
 */
enum tf_if_tbl_type {
	/** Default Profile L2 Context Entry */
	TF_IF_TBL_TYPE_PROF_SPIF_DFLT_L2_CTXT,
	/** Default Profile TCAM/Lookup Action Record Pointer Table */
	TF_IF_TBL_TYPE_PROF_PARIF_DFLT_ACT_REC_PTR,
	/** Error Profile TCAM Miss Action Record Pointer Table */
	TF_IF_TBL_TYPE_PROF_PARIF_ERR_ACT_REC_PTR,
	/** Default Error Profile TCAM Miss Action Record Pointer Table */
	TF_IF_TBL_TYPE_LKUP_PARIF_DFLT_ACT_REC_PTR,
	/** Ingress lookup table */
	TF_IF_TBL_TYPE_ILT,
	/** VNIC/SVIF Properties Table */
	TF_IF_TBL_TYPE_VSPT,
	TF_IF_TBL_TYPE_MAX
};

/**
 * tf_set_if_tbl_entry parameter definition
 */
struct tf_set_if_tbl_entry_parms {
	/**
	 * [in] Receive or transmit direction
	 */
	enum tf_dir dir;
	/**
	 * [in] Type of object to set
	 */
	enum tf_if_tbl_type type;
	/**
	 * [in] Entry data
	 */
	uint8_t *data;
	/**
	 * [in] Entry size
	 */
	uint16_t data_sz_in_bytes;
	/**
	 * [in] Interface to write
	 */
	uint32_t idx;
};

/**
 * set interface table entry
 *
 * Used to set an interface table. This API is used for managing tables indexed
 * by SVIF/SPIF/PARIF interfaces. In current implementation only the value is
 * set.
 * Returns success or failure code.
 */
int tf_set_if_tbl_entry(struct tf *tfp,
			struct tf_set_if_tbl_entry_parms *parms);

/**
 * tf_get_if_tbl_entry parameter definition
 */
struct tf_get_if_tbl_entry_parms {
	/**
	 * [in] Receive or transmit direction
	 */
	enum tf_dir dir;
	/**
	 * [in] Type of table to get
	 */
	enum tf_if_tbl_type type;
	/**
	 * [out] Entry data
	 */
	uint8_t *data;
	/**
	 * [in] Entry size
	 */
	uint16_t data_sz_in_bytes;
	/**
	 * [in] Entry index to read
	 */
	uint32_t idx;
};

/**
 * get interface table entry
 *
 * Used to retrieve an interface table entry.
 *
 * Reads the interface table entry value
 *
 * Returns success or failure code. Failure will be returned if the
 * provided data buffer is too small for the data type requested.
 */
int tf_get_if_tbl_entry(struct tf *tfp,
			struct tf_get_if_tbl_entry_parms *parms);

/**
 * tf_get_version parameters definition.
 */
struct tf_get_version_parms {
	/**
	 * [in] device type
	 *
	 * Device type for the session.
	 */
	enum tf_device_type device_type;

	/**
	 * [in] bp
	 * The pointer to the parent bp struct. This is only used for HWRM
	 * message passing within the portability layer. The type is struct
	 * bnxt.
	 */
	void *bp;

	/* [out] major
	 *
	 * Version Major number.
	 */
	uint8_t	major;

	/* [out] minor
	 *
	 * Version Minor number.
	 */
	uint8_t	minor;

	/* [out] update
	 *
	 * Version Update number.
	 */
	uint8_t	update;

	/**
	 * [out] dev_ident_caps
	 *
	 * fw available identifier resource list
	 */
	uint32_t dev_ident_caps;

	/**
	 * [out] dev_tbl_caps
	 *
	 * fw available table resource list
	 */
	uint32_t dev_tbl_caps;

	/**
	 * [out] dev_tcam_caps
	 *
	 * fw available tcam resource list
	 */
	uint32_t dev_tcam_caps;

	/**
	 * [out] dev_em_caps
	 *
	 * fw available em resource list
	 */
	uint32_t dev_em_caps;
};

/**
 * Get tf fw version
 *
 * Used to retrieve Truflow fw version information.
 *
 * Returns success or failure code.
 */
int tf_get_version(struct tf *tfp,
		   struct tf_get_version_parms *parms);

/**
 * tf_query_sram_resources parameter definition
 */
struct tf_query_sram_resources_parms {
	/**
	 * [in] Device type
	 *
	 * Device type for the session.
	 */
	enum tf_device_type device_type;

	/**
	 * [in] bp
	 * The pointer to the parent bp struct. This is only used for HWRM
	 * message passing within the portability layer. The type is struct
	 * bnxt.
	 */
	void *bp;

	/**
	 * [in] Receive or transmit direction
	 */
	enum tf_dir dir;

	/**
	 * [out] Bank resource count in 8 bytes entry
	 */

	uint32_t bank_resc_count[TF_SRAM_BANK_ID_MAX];

	/**
	 * [out] Dynamic SRAM Enable
	 */
	bool dynamic_sram_capable;

	/**
	 * [out] SRAM profile
	 */
	uint8_t sram_profile;
};

/**
 * Get SRAM resources information
 *
 * Used to retrieve sram bank partition information
 *
 * Returns success or failure code.
 */
int tf_query_sram_resources(struct tf *tfp,
			    struct tf_query_sram_resources_parms *parms);

/**
 * tf_set_sram_policy parameter definition
 */
struct tf_set_sram_policy_parms {
	/**
	 * [in] Device type
	 *
	 * Device type for the session.
	 */
	enum tf_device_type device_type;

	/**
	 * [in] Receive or transmit direction
	 */
	enum tf_dir dir;

	/**
	 * [in] Array of Bank id for each truflow tbl type
	 */
	enum tf_sram_bank_id bank_id[TF_TBL_TYPE_ACT_MODIFY_64B + 1];
};

/**
 * Set SRAM policy
 *
 * Used to assign SRAM bank index to all truflow table type.
 *
 * Returns success or failure code.
 */
int tf_set_sram_policy(struct tf *tfp,
		       struct tf_set_sram_policy_parms *parms);

/**
 * tf_get_sram_policy parameter definition
 */
struct tf_get_sram_policy_parms {
	/**
	 * [in] Device type
	 *
	 * Device type for the session.
	 */
	enum tf_device_type device_type;

	/**
	 * [in] Receive or transmit direction
	 */
	enum tf_dir dir;

	/**
	 * [out] Array of Bank id for each truflow tbl type
	 */
	enum tf_sram_bank_id bank_id[TF_TBL_TYPE_ACT_MODIFY_64B + 1];
};

/**
 * Get SRAM policy
 *
 * Used to get the assigned bank of table types.
 *
 * Returns success or failure code.
 */
int tf_get_sram_policy(struct tf *tfp,
		       struct tf_get_sram_policy_parms *parms);

#endif /* _TF_CORE_H_ */