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
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _SYS_IB_ADAPTERS_HERMON_HW_H
#define _SYS_IB_ADAPTERS_HERMON_HW_H
/*
* hermon_hw.h
* Contains all the structure definitions and #defines for all Hermon
* hardware resources and registers (as defined by the Hermon register
* specification). Wherever possible, the names in the Hermon spec
* have been preserved in the structure and field names below.
*/
#include <sys/types.h>
#include <sys/conf.h>
#include <sys/ddi.h>
#include <sys/sunddi.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* PCI IDs for supported chipsets
*/
#define PCI_VENID_MLX 0x15b3
#define PCI_DEVID_HERMON_SDR 0x6340 /* Mellanox MT25208-SDR PCIe Gen1 */
#define PCI_DEVID_HERMON_DDR 0x634A /* Mellanox MT25208-DDR PCIe Gen1 */
#define PCI_DEVID_HERMON_DDRG2 0x6732 /* Mellanox MT25208-DDR PCIe Gen2 */
#define PCI_DEVID_HERMON_QDRG2 0x673C /* Mellanox MT25208-QDR PCIe Gen2 */
#define PCI_DEVID_HERMON_QDRG2V 0x6746 /* Mellanox MT25208-QDR PCIe Gen2 */
#define PCI_DEVID_HERMON_MAINT 0x0191 /* Maintenance/Mem Controller Mode */
/*
* Native page size of the adapter
*/
#define HERMON_PAGESIZE 0x1000 /* 4Kb */
#define HERMON_PAGEOFFSET (HERMON_PAGESIZE - 1)
#define HERMON_PAGEMASK (~HERMON_PAGEOFFSET)
#define HERMON_PAGESHIFT 0xC /* 12 */
/*
* Offsets into the CMD BAR (BAR 0) for many of the more interesting hardware
* registers. These registers include the HCR (more below), and the software
* reset register (SW_RESET).
*/
#define HERMON_CMD_HCR_OFFSET 0x80680 /* PRM */
#define HERMON_CMD_SW_RESET_OFFSET 0xF0010 /* PRM */
#define HERMON_CMD_SW_SEMAPHORE_OFFSET 0xF03FC /* PRM */
#define HERMON_CMD_OFFSET_MASK 0xFFFFF /* per MLX instruction */
/*
* Ownership flags used to define hardware or software ownership for
* various Hermon resources
*/
#define HERMON_HW_OWNER 0x1
#define HERMON_SW_OWNER 0x0
/*
* Determines whether or not virtual-to-physical address translation is
* required. Several of the Hermon hardware structures can be optionally
* accessed by Hermon without going through the TPT address translation
* tables.
*/
#define HERMON_VA2PA_XLAT_ENABLED 0x1
#define HERMON_VA2PA_XLAT_DISABLED 0x0
/*
* HCA Command Register (HCR)
* The HCR command interface provides privileged access to the HCA in
* order to query, configure and modify HCA execution. It is the
* primary mechanism through which mailboxes may be posted to Hermon
* firmware. To use this interface software fills the HCR with pointers
* to input and output mailboxes. Some commands support immediate
* parameters, however, and for these commands the HCR will contain the
* input or output parameters. Command execution completion can be
* detected either by the software polling the HCR or by waiting for a
* command completion event.
*/
struct hermon_hw_hcr_s {
uint32_t in_param0;
uint32_t in_param1;
uint32_t input_modifier;
uint32_t out_param0;
uint32_t out_param1;
uint32_t token;
uint32_t cmd;
};
#define HERMON_HCR_TOKEN_MASK 0xFFFF0000
#define HERMON_HCR_TOKEN_SHIFT 16
#define HERMON_HCR_CMD_STATUS_MASK 0xFF000000
#define HERMON_HCR_CMD_GO_MASK 0x00800000
#define HERMON_HCR_CMD_E_MASK 0x00400000
#define HERMON_HCR_CMD_T_MASK 0x00200000
#define HERMON_HCR_CMD_OPMOD_MASK 0x0000F000
#define HERMON_HCR_CMD_OPCODE_MASK 0x00000FFF
#define HERMON_HCR_CMD_STATUS_SHFT 24
#define HERMON_HCR_CMD_GO_SHFT 23
#define HERMON_HCR_CMD_E_SHFT 22
#define HERMON_HCR_CMD_T_SHFT 21
#define HERMON_HCR_CMD_OPMOD_SHFT 12
/*
* Arbel/tavor "QUERY_DEV_LIM" == Hermon "QUERY_DEV_CAP" - Same hex code
* same function as tavor/arbel QUERY_DEV_LIM, just renamed (whatever).
* The QUERY_DEV_LIM command returns the device limits and capabilities
* supported by the Hermon device. This command must be run before
* running the INIT_HCA command (below) in order to determine the maximum
* capabilities of the device and which optional features are supported.
*/
#ifdef _LITTLE_ENDIAN
struct hermon_hw_querydevlim_s {
uint32_t rsrv0[4];
uint32_t log_max_scqs :4;
uint32_t :4;
uint32_t num_rsvd_scqs :6;
uint32_t :2;
uint32_t log_max_srq :5;
uint32_t :7;
uint32_t log_rsvd_srq :4;
uint32_t log_max_qp :5;
uint32_t :3;
uint32_t log_rsvd_qp :4;
uint32_t :4;
uint32_t log_max_qp_sz :8;
uint32_t log_max_srq_sz :8;
uint32_t log_max_eq :4;
uint32_t :4;
uint32_t num_rsvd_eq :4;
uint32_t :4;
uint32_t log_max_dmpt :6;
uint32_t :2;
uint32_t log_max_eq_sz :8;
uint32_t log_max_cq :5;
uint32_t :3;
uint32_t log_rsvd_cq :4;
uint32_t :4;
uint32_t log_max_cq_sz :8;
uint32_t :8;
uint32_t :32;
uint32_t log_max_mtt :6;
uint32_t :2;
uint32_t log_rsvd_dmpt :4;
uint32_t :4;
uint32_t log_max_mrw_sz :7;
uint32_t :5;
uint32_t log_rsvd_mtt :4;
uint32_t log_max_ra_glob :6;
uint32_t :2;
uint32_t log_max_rss_tbl_sz :4;
uint32_t rss_toep :1; /* rss toeplitz hashing */
uint32_t rss_xor :1; /* rss xor hashing */
uint32_t :2;
uint32_t log_max_gso_sz :5; /* Lge Send Offload */
uint32_t :11; /* new w/ 0.35, RSS info */
uint32_t log_max_ra_res_qp :6;
uint32_t :10;
uint32_t log_max_ra_req_qp :6;
uint32_t :10;
uint32_t num_ports :4;
uint32_t :12;
uint32_t ca_ack_delay :5;
uint32_t cqmep :3; /* cq moderation policies */
uint32_t :4;
uint32_t :1;
uint32_t :3;
uint32_t mod_wr_srq :1; /* resize SRQ supported */
uint32_t :31;
uint32_t :16;
uint32_t stat_rate_sup :16;
uint32_t :8;
uint32_t :4;
uint32_t :4;
uint32_t :8;
uint32_t log_max_msg :5;
uint32_t :3;
uint32_t rc :1; /* 0x44 */
uint32_t uc :1;
uint32_t ud :1;
uint32_t xrc :1;
uint32_t rcm :1;
uint32_t fcoib :1;
uint32_t srq :1;
uint32_t ipoib_cksm :1;
uint32_t pkey_v :1;
uint32_t qkey_v :1;
uint32_t vmm :1;
uint32_t fcoe :1;
uint32_t dpdp :1; /* dual port diff protocol */
uint32_t raw_etype :1;
uint32_t raw_ipv4 :1;
uint32_t blh :1; /* big LSO header, bit in WQE */
uint32_t mem_win :1;
uint32_t apm :1;
uint32_t atomic :1;
uint32_t raw_multi :1;
uint32_t avp :1;
uint32_t ud_multi :1;
uint32_t udm_ipv4 :1;
uint32_t dif :1; /* DIF supported */
uint32_t pg_on_demand :1;
uint32_t router :1;
uint32_t l2mc :1; /* lev 2 enet multicast */
uint32_t :1;
uint32_t ud_swp :1; /* sw parse for UD xport */
uint32_t ipv6_ex :1; /* offload w/ IPV6 ext hdrs */
uint32_t lle :1; /* low latency enet */
uint32_t fcoe_t11 :1; /* fcoenet T11 frame support */
/* 0x40 */
uint32_t eth_uc_lb :1; /* enet unicast loopback */
uint32_t :3;
uint32_t hdr_split :1;
uint32_t hdr_lookahead :1;
uint32_t :2;
uint32_t rss_udp :1;
uint32_t :7;
uint32_t :16;
uint32_t log_max_bf_page :6; /* 0x4c */
uint32_t :2;
uint32_t log_max_bf_req_ppg :6;
uint32_t :2;
uint32_t log_bf_reg_sz :5;
uint32_t :10;
uint32_t blu_flm :1;
uint32_t log_pg_sz :8; /* 0x48 */
uint32_t :8;
uint32_t log_max_uar_sz :6;
uint32_t :6;
uint32_t num_rsvd_uar :4;
uint32_t max_desc_sz_rq :16; /* 0x54 */
uint32_t max_sg_rq :8;
uint32_t :8;
uint32_t max_desc_sz_sq :16; /* 0x50 */
uint32_t max_sg_sq :8;
uint32_t :8;
uint32_t rsvd_fcoib; /* 0x5C */
uint32_t :1; /* 0x58 */
uint32_t fexch_base_mpt :7; /* FC exch base mpt num */
uint32_t fcp_ud_base_qp :16; /* RC UD base qp num */
uint32_t fexch_base_qp :8; /* FC exch base qp num */
uint32_t log_max_xrcd :5; /* 0x64 */
uint32_t :7;
uint32_t num_rsvd_xrcds :4;
uint32_t log_max_pd :5;
uint32_t :7;
uint32_t num_rsvd_pd :4;
uint32_t log_max_mcg :8; /* 0x60 */
uint32_t num_rsvd_mcg :4;
uint32_t :4;
uint32_t log_max_qp_mcg :8;
uint32_t :8;
uint32_t rsrv2[6];
uint32_t altc_entry_sz :16; /* 0x84 */
uint32_t aux_entry_sz :16;
uint32_t qpc_entry_sz :16; /* 0x80 */
uint32_t rdmardc_entry_sz :16;
uint32_t cmpt_entry_sz :16; /* 0x8C */
uint32_t srq_entry_sz :16;
uint32_t cqc_entry_sz :16; /* 0x88 */
uint32_t eqc_entry_sz :16;
uint32_t bmme :1; /* 0x94 */
uint32_t win_type :1;
uint32_t mps :1;
uint32_t bl :1;
uint32_t zb :1;
uint32_t lif :1;
uint32_t local_inv :1;
uint32_t remote_inv :1;
uint32_t :1;
uint32_t win_type2 :1;
uint32_t reserved_lkey :1;
uint32_t fast_reg_wr :1;
uint32_t :20;
uint32_t dmpt_entry_sz :16; /* 0x90 */
uint32_t mtt_entry_sz :16;
uint32_t :32;
uint32_t rsv_lkey;
/* 0xA0 */
uint64_t max_icm_size;
uint32_t rsrv3[22];
};
#else /* BIG ENDIAN */
struct hermon_hw_querydevlim_s {
uint32_t rsrv0[4];
uint32_t log_max_srq_sz :8;
uint32_t log_max_qp_sz :8;
uint32_t :4;
uint32_t log_rsvd_qp :4;
uint32_t :3;
uint32_t log_max_qp :5;
uint32_t log_rsvd_srq :4;
uint32_t :7;
uint32_t log_max_srq :5;
uint32_t :2;
uint32_t num_rsvd_scqs :6;
uint32_t :4;
uint32_t log_max_scqs :4;
uint32_t :8;
uint32_t log_max_cq_sz :8;
uint32_t :4;
uint32_t log_rsvd_cq :4;
uint32_t :3;
uint32_t log_max_cq :5;
uint32_t log_max_eq_sz :8;
uint32_t :2;
uint32_t log_max_dmpt :6;
uint32_t :4;
uint32_t num_rsvd_eq :4;
uint32_t :4;
uint32_t log_max_eq :4;
uint32_t log_rsvd_mtt :4;
uint32_t :5;
uint32_t log_max_mrw_sz :7;
uint32_t :4;
uint32_t log_rsvd_dmpt :4;
uint32_t :2;
uint32_t log_max_mtt :6;
uint32_t :32;
uint32_t :10;
uint32_t log_max_ra_req_qp :6;
uint32_t :10;
uint32_t log_max_ra_res_qp :6;
uint32_t :11; /* new w/ 0.35, RSS info */
uint32_t log_max_gso_sz :5; /* Lge Send Offload */
uint32_t :2;
uint32_t rss_xor :1; /* rss xor hashing */
uint32_t rss_toep :1; /* rss toeplitz hashing */
uint32_t log_max_rss_tbl_sz :4;
uint32_t :2;
uint32_t log_max_ra_glob :6;
uint32_t :31;
uint32_t mod_wr_srq :1; /* resize SRQ supported */
uint32_t :3;
uint32_t :1;
uint32_t :4;
uint32_t cqmep :3; /* cq moderation policies */
uint32_t ca_ack_delay :5;
uint32_t :12;
uint32_t num_ports :4;
uint32_t :3;
uint32_t log_max_msg :5;
uint32_t :8;
uint32_t :4;
uint32_t :4;
uint32_t :8;
uint32_t stat_rate_sup :16;
uint32_t :16;
uint32_t :16; /* 0x40 */
uint32_t :7;
uint32_t rss_udp :1;
uint32_t :2;
uint32_t hdr_lookahead :1;
uint32_t hdr_split :1;
uint32_t :3;
uint32_t eth_uc_lb :1; /* enet unicast loopback */
/* 0x44 */
uint32_t fcoe_t11 :1; /* fcoenet T11 frame support */
uint32_t lle :1; /* low latency enet */
uint32_t ipv6_ex :1; /* offload w/ IPV6 ext hdrs */
uint32_t ud_swp :1; /* sw parse for UD xport */
uint32_t :1;
uint32_t l2mc :1; /* lev 2 enet multicast */
uint32_t router :1;
uint32_t pg_on_demand :1;
uint32_t dif :1; /* DIF supported */
uint32_t udm_ipv4 :1;
uint32_t ud_multi :1;
uint32_t avp :1;
uint32_t raw_multi :1;
uint32_t atomic :1;
uint32_t apm :1;
uint32_t mem_win :1;
uint32_t blh :1; /* big LSO header, bit in WQE */
uint32_t raw_ipv4 :1;
uint32_t raw_etype :1;
uint32_t dpdp :1; /* dual port diff protocol */
uint32_t fcoe :1;
uint32_t vmm :1;
uint32_t qkey_v :1;
uint32_t pkey_v :1;
uint32_t ipoib_cksm :1;
uint32_t srq :1;
uint32_t fcoib :1;
uint32_t rcm :1;
uint32_t xrc :1;
uint32_t ud :1;
uint32_t uc :1;
uint32_t rc :1;
uint32_t num_rsvd_uar :4; /* 0x48 */
uint32_t :6;
uint32_t log_max_uar_sz :6;
uint32_t :8;
uint32_t log_pg_sz :8;
uint32_t blu_flm :1; /* 0x4c */
uint32_t :10;
uint32_t log_bf_reg_sz :5;
uint32_t :2;
uint32_t log_max_bf_req_ppg :6;
uint32_t :2;
uint32_t log_max_bf_page :6;
uint32_t :8; /* 0x50 */
uint32_t max_sg_sq :8;
uint32_t max_desc_sz_sq :16;
uint32_t :8; /* 0x54 */
uint32_t max_sg_rq :8;
uint32_t max_desc_sz_rq :16;
/* 0x58 */
uint32_t fexch_base_qp :8; /* FC exch base qp num */
uint32_t fcp_ud_base_qp :16; /* RC UD base qp num */
uint32_t fexch_base_mpt :7; /* FC exch base mpt num */
uint32_t :1;
uint32_t rsvd_fcoib; /* 0x5C */
uint32_t :8; /* 0x60 */
uint32_t log_max_qp_mcg :8;
uint32_t :4;
uint32_t num_rsvd_mcg :4;
uint32_t log_max_mcg :8;
uint32_t num_rsvd_pd :4; /* 0x64 */
uint32_t :7;
uint32_t log_max_pd :5;
uint32_t num_rsvd_xrcds :4;
uint32_t :7;
uint32_t log_max_xrcd :5;
uint32_t rsrv2[6];
uint32_t rdmardc_entry_sz :16; /* 0x80 */
uint32_t qpc_entry_sz :16;
uint32_t aux_entry_sz :16; /* 0x84 */
uint32_t altc_entry_sz :16;
uint32_t eqc_entry_sz :16; /* 0x88 */
uint32_t cqc_entry_sz :16;
uint32_t srq_entry_sz :16; /* 0x8C */
uint32_t cmpt_entry_sz :16;
uint32_t mtt_entry_sz :16; /* 0x90 */
uint32_t dmpt_entry_sz :16;
uint32_t :20; /* 0x94 */
uint32_t fast_reg_wr :1;
uint32_t reserved_lkey :1;
uint32_t win_type2 :1;
uint32_t :1;
uint32_t remote_inv :1;
uint32_t local_inv :1;
uint32_t lif :1;
uint32_t zb :1;
uint32_t bl :1;
uint32_t mps :1;
uint32_t win_type :1;
uint32_t bmme :1;
uint32_t rsv_lkey;
uint32_t :32;
uint64_t max_icm_size;
/* 0xA0 */
uint32_t rsrv3[22];
};
#endif
/*
* Hermon "QUERY_FW" command
* The QUERY_FW command retrieves the firmware revision and the Command
* Interface revision. The command also returns the HCA attached local
* memory area (DDR) which is used by the firmware. Below we also
* include some defines which are used to enforce a minimum firmware
* version check (see hermon_fw_version_check() for more details).
*/
#ifdef _LITTLE_ENDIAN
struct hermon_hw_queryfw_s {
uint32_t fw_rev_minor :16;
uint32_t fw_rev_subminor :16;
uint32_t fw_rev_major :16;
uint32_t fw_pages :16;
uint32_t log_max_cmd :8;
uint32_t :23;
uint32_t dbg_trace :1;
uint32_t cmd_intf_rev :16;
uint32_t :16;
uint32_t fw_day :8;
uint32_t fw_month :8;
uint32_t fw_year :16;
uint32_t :1;
uint32_t ccq :1; /* currently not def'd */
uint32_t :6;
uint32_t fw_sec :8;
uint32_t fw_min :8;
uint32_t fw_hour :8;
uint32_t rsrv0[2];
uint64_t clr_intr_offs;
uint32_t :32;
uint32_t :30;
uint32_t clr_int_bar :2;
uint64_t error_buf_addr;
uint32_t :30;
uint32_t err_buf_bar :2;
uint32_t error_buf_sz;
uint64_t vf_com_ch_addr;
uint32_t :32;
uint32_t :30;
uint32_t vf_com_ch_bar :2;
uint32_t rsrv2[44];
};
#else /* BIG ENDIAN */
struct hermon_hw_queryfw_s {
uint32_t fw_pages :16;
uint32_t fw_rev_major :16;
uint32_t fw_rev_subminor :16;
uint32_t fw_rev_minor :16;
uint32_t :16;
uint32_t cmd_intf_rev :16;
uint32_t dbg_trace :1;
uint32_t :23;
uint32_t log_max_cmd :8;
uint32_t fw_hour :8;
uint32_t fw_min :8;
uint32_t fw_sec :8;
uint32_t :6;
uint32_t ccq :1; /* currently not def'd */
uint32_t :1;
uint32_t fw_year :16;
uint32_t fw_month :8;
uint32_t fw_day :8;
uint32_t rsrv1[2];
uint64_t clr_intr_offs;
uint32_t clr_int_bar :2;
uint32_t :30;
uint32_t :32;
uint64_t error_buf_addr;
uint32_t error_buf_sz;
uint32_t err_buf_bar :2;
uint32_t :30;
uint64_t vf_com_ch_addr;
uint32_t vf_com_ch_bar :2;
uint32_t :30;
uint32_t :32;
uint32_t rsrv2[44];
};
#endif
/*
* 2.6.000 is critical for some performance features, e.g., Reserved_Lkey,
* and 2.7.000 is needed for FRWR and FCoIB. Requiring 2.6.000 now so that
* existing customers get the performance, but are not required to upgrade
* to the latest. Less than 2.6.000 will cause the driver to attach in
* maintenance mode, and throw an FMA event about upgrading the firmware.
*/
#define HERMON_FW_VER_MAJOR 0x0002
#define HERMON_FW_VER_MINOR 0x0006
#define HERMON_FW_VER_SUBMINOR 0x0000
/*
* Hermon "QUERY_ADAPTER" command
* The QUERY_ADAPTER command retrieves adapter specific parameters. The
* command also retrieves the PCI(X) interrupt pin routing for each of
* the INTx# pins supported by the device. This information is used by
* the driver during interrupt processing in order to clear the appropriate
* interrupt bit.
*/
#ifdef _LITTLE_ENDIAN
struct hermon_hw_queryadapter_s {
uint32_t rsrv0[4];
uint32_t :32;
uint32_t :24;
uint32_t inta_pin :8;
uint32_t vsd_vend_id :16; /* added v35 hermon */
uint32_t :16;
uint32_t :32;
uint32_t vsd[52];
uint32_t psid[4];
};
#else
struct hermon_hw_queryadapter_s {
uint32_t rsrv0[4];
uint32_t inta_pin :8;
uint32_t :24;
uint32_t :32;
uint32_t :32;
uint32_t :16;
uint32_t vsd_vend_id :16; /* added v35 hermon */
uint32_t vsd[52];
uint32_t psid[4];
};
#endif
#define HERMON_REV_A0 0xA0
#define HERMON_REV_A1 0xA1
/*
* Virtual physical mapping structure for: MAP_FA, MAP_ICM_AUX, and
* MAP_ICM commands.
*/
#ifdef _LITTLE_ENDIAN
struct hermon_hw_vpm_s {
uint32_t :12;
uint32_t vaddr_l :20;
uint32_t vaddr_h;
uint32_t log2sz :5; /* in 4KB pages */
uint32_t :7;
uint32_t paddr_l :20;
uint32_t paddr_h;
};
#else
struct hermon_hw_vpm_s {
uint32_t vaddr_h;
uint32_t vaddr_l :20;
uint32_t :12;
uint32_t paddr_h;
uint32_t paddr_l :20;
uint32_t :7;
uint32_t log2sz :5; /* in 4KB pages */
};
#endif
/*
* Hermon "INIT_HCA" and "QUERY_HCA" commands
* The INIT_HCA command configures all HCA resources in HCA attached local
* memory and some system relevant information. The same mailbox output
* format is used by the QUERY_HCA command. All parameters, which are
* specifically the output of the QUERY_HCA command are marked as
* "QUERY_HCA only". These parameters are not configurable through the
* INIT_HCA command, but can be retrieved as read-only through the
* QUERY_HCA command.
*
* Below we first define several structures which help make up the whole
* of the INIT_HCA/QUERY_HCA command. These are:
* hermon_hw_qp_ee_cq_eq_rdb_t for "QPC/EEC/CQC/EQC/RDB Parameters",
* hermon_udav_mem_param_t for "Memory Access Parameters for UDAV Table",
* hermon_multicast_param_t for "Multicast Support Parameters",
* hermon_tpt_param_t for "Translation and Protection Table Parameters",
* and hermon_uar_param_t for Hermon "UAR Parameters".
*/
/*
* need to consider removing any ref to "ee", hermon doesn't support
* ee/rd stuff, and they've taken away the pretense
*/
#ifdef _LITTLE_ENDIAN
typedef struct hermon_hw_qp_ee_cq_eq_rdb_s {
uint32_t rsrv0[4];
uint32_t log_num_qp :5;
uint32_t qpc_baseaddr_l :27;
uint32_t qpc_baseaddr_h;
uint32_t rsrv1[4];
uint32_t log_num_srq :5;
uint32_t srqc_baseaddr_l :27;
uint32_t srqc_baseaddr_h;
uint32_t log_num_cq :5;
uint32_t cqc_baseaddr_l :27;
uint32_t cqc_baseaddr_h;
uint32_t rsrv2[2];
uint64_t altc_baseaddr;
uint32_t rsrv3[2];
uint64_t auxc_baseaddr;
uint32_t rsrv4[2];
uint32_t log_num_eq :5;
uint32_t eqc_baseaddr_l :27;
uint32_t eqc_baseaddr_h;
uint32_t rsv5[2];
uint32_t log_num_rdmardc :3;
uint32_t :2;
uint32_t rdmardc_baseaddr_l :27;
uint32_t rdmardc_baseaddr_h;
uint32_t rsrv6[2];
} hermon_hw_qp_ee_cq_eq_rdb_t;
#else /* BIG ENDIAN */
typedef struct hermon_hw_qp_ee_cq_eq_rdb_s {
uint32_t rsrv0[4];
uint32_t qpc_baseaddr_h;
uint32_t qpc_baseaddr_l :27;
uint32_t log_num_qp :5;
uint32_t rsrv1[4];
uint32_t srqc_baseaddr_h;
uint32_t srqc_baseaddr_l :27;
uint32_t log_num_srq :5;
uint32_t cqc_baseaddr_h;
uint32_t cqc_baseaddr_l :27;
uint32_t log_num_cq :5;
uint32_t rsrv2[2];
uint64_t altc_baseaddr;
uint32_t rsrv3[2];
uint64_t auxc_baseaddr;
uint32_t rsrv4[2];
uint32_t eqc_baseaddr_h;
uint32_t eqc_baseaddr_l :27;
uint32_t log_num_eq :5;
uint32_t rsv5[2];
uint32_t rdmardc_baseaddr_h;
uint32_t rdmardc_baseaddr_l :27;
uint32_t :2;
uint32_t log_num_rdmardc :3;
uint32_t rsrv6[2];
} hermon_hw_qp_ee_cq_eq_rdb_t;
#endif
#ifdef _LITTLE_ENDIAN
typedef struct hermon_multicast_param_s {
uint64_t mc_baseaddr;
uint32_t rsrv0[2];
uint32_t log_mc_tbl_hash_sz :5;
uint32_t :27;
uint32_t log_mc_tbl_ent :5;
uint32_t :27;
uint32_t :32;
uint32_t log_mc_tbl_sz :5;
uint32_t :19;
uint32_t mc_hash_fn :3;
uint32_t :5;
} hermon_multicast_param_t;
#else /* BIG ENDIAN */
typedef struct hermon_multicast_param_s {
uint64_t mc_baseaddr;
uint32_t rsrv0[2];
uint32_t :27;
uint32_t log_mc_tbl_ent :5;
uint32_t :27;
uint32_t log_mc_tbl_hash_sz :5;
uint32_t :5;
uint32_t mc_hash_fn :3;
uint32_t :19;
uint32_t log_mc_tbl_sz :5;
uint32_t :32;
} hermon_multicast_param_t;
#endif
#define HERMON_MCG_DEFAULT_HASH_FN 0x0
#ifdef _LITTLE_ENDIAN
typedef struct hermon_tpt_param_s {
uint64_t dmpt_baseaddr;
uint32_t :32;
uint32_t log_dmpt_sz :6;
uint32_t :2;
uint32_t pgfault_rnr_to :5;
uint32_t :19;
uint64_t mtt_baseaddr;
uint64_t cmpt_baseaddr;
} hermon_tpt_param_t;
#else /* BIG ENDIAN */
typedef struct hermon_tpt_param_s {
uint64_t dmpt_baseaddr;
uint32_t :19;
uint32_t pgfault_rnr_to :5;
uint32_t :2;
uint32_t log_dmpt_sz :6;
uint32_t :32;
uint64_t mtt_baseaddr;
uint64_t cmpt_baseaddr;
} hermon_tpt_param_t;
#endif
#ifdef _LITTLE_ENDIAN
typedef struct hermon_uar_param_s {
uint32_t rsvd0[2];
uint32_t :32;
uint32_t uar_pg_sz :8;
uint32_t log_max_uars :4;
uint32_t :20;
uint32_t resvd1[4];
} hermon_uar_param_t;
#else
typedef struct hermon_uar_param_s {
uint32_t rsvd0[2];
uint32_t :20;
uint32_t log_max_uars :4;
uint32_t uar_pg_sz :8;
uint32_t :32;
uint32_t resvd1[4];
} hermon_uar_param_t;
#endif
/*
* NEW for Hermon
* QP Allocation Params
* NOTE: as of PRM v0.50 no longer needed (ccq not supported
* leave structure here, just in case ccq comes back )
* but adjust the overall structure
* not to use it
*
*/
#ifdef _LITTLE_ENDIAN
typedef struct hermon_qp_alloc_param_s {
uint32_t :32;
uint32_t ccq_base :24;
uint32_t log2ccqs :5;
uint32_t :2;
uint32_t ccq_en :1;
uint32_t rsvd[6]; /* but 0x14 def'd for fibre channel */
} hermon_qp_alloc_param_t;
#else /* BIG ENDIAN */
typedef struct hermon_qp_alloc_param_s {
uint32_t ccq_en :1;
uint32_t :2;
uint32_t log2ccqs :5;
uint32_t ccq_base :24;
uint32_t :32;
uint32_t rsvd[6]; /* but 0x14 def'd for fibre channel */
} hermon_qp_alloc_param_t;
#endif
#ifdef _LITTLE_ENDIAN
struct hermon_hw_initqueryhca_s {
uint32_t :32;
uint32_t :24;
uint32_t version :8;
uint32_t :13;
uint32_t log2_cacheline :3;
uint32_t hca_core_clock :16; /* QUERY_HCA only */
uint32_t :32;
uint32_t udav_port_chk :1;
uint32_t big_endian :1;
uint32_t qos :1;
uint32_t chsum_en :1;
uint32_t :12;
uint32_t cqpm_short_pkt_lim :14; /* short pkt limit for qpm */
uint32_t cqmp :2; /* cq moderation policy */
uint32_t router_qp :24;
uint32_t :5;
uint32_t ipr2 :1;
uint32_t ipr1 :1;
uint32_t router_en :1;
uint32_t rsrv1[2];
hermon_hw_qp_ee_cq_eq_rdb_t context;
uint32_t rsrv2[8];
hermon_multicast_param_t multi;
uint32_t rsrv3[4];
hermon_tpt_param_t tpt;
uint32_t rsrv4[4];
hermon_uar_param_t uar;
uint32_t rsrv5[36];
hermon_multicast_param_t enet_multi;
uint32_t rsrv6[24]; /* to 0x24C */
uint32_t :32;
uint32_t fcoe_t11 :1; /* fcoe t11 frame enable */
uint32_t :31;
uint32_t rsrv7[42]; /* 0x254 - 0x2FC */
};
#else /* BIG ENDIAN */
struct hermon_hw_initqueryhca_s {
uint32_t version :8;
uint32_t :24;
uint32_t :32;
uint32_t :32;
uint32_t hca_core_clock :16; /* QUERY_HCA only */
uint32_t log2_cacheline :3;
uint32_t :13;
uint32_t router_en :1;
uint32_t ipr1 :1;
uint32_t ipr2 :1;
uint32_t :5;
uint32_t router_qp :24;
uint32_t cqmp :2; /* cq moderation policy */
uint32_t cqpm_short_pkt_lim :14; /* short pkt limit for qpm */
uint32_t :12;
uint32_t chsum_en :1;
uint32_t qos :1;
uint32_t big_endian :1;
uint32_t udav_port_chk :1;
uint32_t rsrv1[2];
hermon_hw_qp_ee_cq_eq_rdb_t context;
uint32_t rsrv2[8];
hermon_multicast_param_t multi;
uint32_t rsrv3[4];
hermon_tpt_param_t tpt;
uint32_t rsrv4[4];
hermon_uar_param_t uar;
uint32_t rsrv5[36];
hermon_multicast_param_t enet_multi;
uint32_t rsrv6[24]; /* to 0x24C */
uint32_t :31;
uint32_t fcoe_t11 :1; /* fcoe t11 frame enable */
uint32_t :32;
uint32_t rsrv7[42]; /* 0x254 - 0x2FC */
};
#endif
#define HERMON_UDAV_PROTECT_DISABLED 0x0
#define HERMON_UDAV_PROTECT_ENABLED 0x1
#define HERMON_UDAV_PORTCHK_DISABLED 0x0
#define HERMON_UDAV_PORTCHK_ENABLED 0x1
/*
* Hermon "INIT_IB"/"INIT_PORT" command
* The INIT_IB/INIT_PORT command enables the physical layer of an IB port.
* It provides control over the IB port attributes. The capabilities
* requested here should not exceed the device limits, as retrieved by
* the QUERY_DEV_LIM/CAP command (above). To query information about the IB
* port or node, the driver may submit GetPortInfo or GetNodeInfo MADs
* through the Hermon MAD_IFC command.
*
* Changed name to initport, but operates similar to initib - but as of
* PRM v0.35c the initport just does that, and the params set previously
* by initib are now set in SET_PORT
*/
/*
* HERMON query_port and set_port commands. QUERY_PORT is new for hermon,
* doing some of what used to be done in the QUERY_DEV_CAP command. It is
* introduced in PRM v0.35 and will need to be added to the list of
* supported HCA commands
*
* SET_PORT is similar to the SET_IB command from tavor and arbel. Here,
* tho, it's more extensive and will be easier to deal with I suspect by
* making it a structure and filling it in and then doing the copy to the
* mailbox (instead of just writing the minimal information to the mailbox
* directly as was done for the previous HCAs).
*/
/*
* PRM 0.4X and 0.50 changed the query_port to integrate the ethernet
* stuff as well, so this is a signficant change to the structure
*/
#ifdef _LITTLE_ENDIAN
struct hermon_hw_query_port_s {
/* 0x04 */
uint32_t log_max_pkey :4; /* pkey table size */
uint32_t log_max_gid :4; /* max gids / port */
uint32_t ib_port_wid :8;
/*
* Enet link speed - 0x0 10Gb XAUI, 0x01 10Gb XFI,
* 0x02 1Gb, 0xF other
*/
uint32_t eth_link_spd :4;
uint32_t :4;
/*
* IB Link speed - bit 0 SDR, bit1 DDR, Bit 2 QDR
*/
uint32_t ib_link_spd :8;
/* 0x00 */
uint32_t eth_mtu :16; /* in bytes */
/*
* IB MTU - 0x0 rsvd, 0x1=256, 0x2=512, 0x3=1024, 0x4=2048, 0x5=4096
*/
uint32_t ib_mtu :4;
uint32_t :4;
/*
* for next two if link down
* -> what port supports, if up
* -> what port is running
*/
uint32_t ib_link :1;
uint32_t eth_link :1;
uint32_t :1;
uint32_t vpi :1;
uint32_t :3;
uint32_t link_up :1;
uint32_t :32; /* 0x0C */
/* max vl's supported (not incl vl_15) */
uint32_t max_vl :4; /* 0x08 */
uint32_t :4;
uint32_t log_max_mac :4;
uint32_t log_max_vlan :4;
uint32_t :16;
uint32_t mac_lo;
uint32_t mac_hi :16;
uint32_t :16;
uint32_t rsvd1[2];
};
#else /* BIG ENDIAN */
struct hermon_hw_query_port_s {
/* 0x00 */
uint32_t link_up :1;
uint32_t :3;
uint32_t vpi :1;
uint32_t :1;
/*
* for next two if link down
* -> what port supports, if up
* -> what port is running
*/
uint32_t eth_link :1;
uint32_t ib_link :1;
uint32_t :4;
/*
* IB MTU - 0x0 rsvd, 0x1=256, 0x2=512, 0x3=1024, 0x4=2048, 0x5=4096
*/
uint32_t ib_mtu :4;
uint32_t eth_mtu :16; /* in bytes */
/* 0x04 */
/*
* IB Link speed - bit 0 SDR, bit1 DDR, Bit 2 QDR
*/
uint32_t ib_link_spd :8;
uint32_t :4;
/*
* Enet link speed - 0x0 10Gb XAUI, 0x01 10Gb XFI,
* 0x02 1Gb, 0xF other
*/
uint32_t eth_link_spd :4;
uint32_t ib_port_wid :8;
uint32_t log_max_gid :4; /* max gids / port */
uint32_t log_max_pkey :4; /* pkey table size */
uint32_t :16; /* 0x08 */
uint32_t log_max_vlan :4;
uint32_t log_max_mac :4;
uint32_t :4;
/* max vl's supported (not incl vl_15) */
uint32_t max_vl :4;
uint32_t :32; /* 0x0C */
uint32_t :16;
uint32_t mac_hi :16;
uint32_t mac_lo;
uint32_t rsvd1[2];
};
#endif
/*
* the following structure is used for IB set port
* others following are for ethernet set port
*/
#define HERMON_HW_OPMOD_SETPORT_IB 0x0
#define HERMON_HW_OPMOD_SETPORT_EN 0x1
#define HERMON_HW_OPMOD_SETPORT_EXT 0x2
#ifdef _LITTLE_ENDIAN
struct hermon_hw_set_port_s {
uint32_t cap_mask;
uint32_t rqk :1; /* reset qkey violation cntr */
uint32_t rcm :1; /* reset capability mask */
uint32_t :2;
uint32_t vl_cap :4;
uint32_t :4;
uint32_t mtu_cap :4;
uint32_t g0 :1; /* set port GUID0 */
uint32_t ng :1; /* set node GUID (all ports) */
uint32_t sig :1; /* set sys image */
uint32_t mg :1; /* change GID table */
uint32_t mp :1; /* change pkey table size */
uint32_t mvc :1; /* change vl_cap */
uint32_t mmc :1; /* change mtu_cap */
uint32_t :9;
uint64_t sys_img_guid;
uint64_t guid0;
uint64_t node_guid;
uint32_t ingress_sniff_qpn :24;
uint32_t ingress_sniff_mode :1;
uint32_t :7;
uint32_t egress_sniff_qpn :24;
uint32_t egress_sniff_mode :1;
uint32_t :7;
uint32_t :32;
uint32_t max_gid :16; /* valid if noted above */
uint32_t max_pkey :16; /* valid if noted above */
uint32_t rsrd0[500];
};
#else /* BIG ENDIAN */
struct hermon_hw_set_port_s {
uint32_t :9;
uint32_t mmc :1; /* change mtu_cap */
uint32_t mvc :1; /* change vl_cap */
uint32_t mp :1; /* change pkey table size */
uint32_t mg :1; /* change GID table size */
uint32_t sig :1; /* set sys image GUID */
uint32_t ng :1; /* set node GUID (all ports) */
uint32_t g0 :1; /* set port GUID0 */
uint32_t mtu_cap :4;
uint32_t :4;
uint32_t vl_cap :4;
uint32_t :2;
uint32_t rcm :1; /* reset capability mask */
uint32_t rqk :1; /* reset qkey violation cntr */
uint32_t cap_mask;
uint64_t sys_img_guid;
uint64_t guid0;
uint64_t node_guid;
uint32_t :7;
uint32_t egress_sniff_mode :1;
uint32_t egress_sniff_qpn :24;
uint32_t :7;
uint32_t ingress_sniff_mode :1;
uint32_t ingress_sniff_qpn :24;
uint32_t max_pkey :16; /* valid if noted above */
uint32_t max_gid :16; /* valid if noted above */
uint32_t :32;
uint32_t rsrd0[500];
};
#endif
/*
* structures for ethernet setport
* Which structure is used depends on low-16 of opmod
* Low 8 == port number, 15:8 == selector
* Or the following with port number
*/
#define HERMON_HW_ENET_OPMOD_SELECT_GEN 0x0000 /* general params */
#define HERMON_HW_ENET_OPMOD_SELECT_RQN 0x0100 /* rcv qpn calc */
#define HERMON_HW_ENET_OPMOD_SELECT_MAC 0x0200 /* MAC table conf */
#define HERMON_HW_ENET_OPMOD_SELECT_VLAN 0x0300 /* VLAN table conf */
#define HERMON_HW_ENET_OPMOD_SELECT_PRIO 0x0400 /* Priority table */
#define HERMON_HW_ENET_OPMOD_SELECT_GID 0x0500 /* GID Table */
/*
* set port for enthernet, general parameters
* Which structure
*/
#ifdef _LITTLE_ENDIAN
struct hermon_hw_set_port_en_s {
uint32_t mtu :16;
uint32_t :16;
uint32_t v_mtu :1;
uint32_t v_pprx :1;
uint32_t v_pptx :1;
uint32_t :29;
uint32_t :16;
uint32_t pfcrx :8;
uint32_t :7;
uint32_t pprx :1;
uint32_t :16;
uint32_t pfctx :8;
uint32_t :7;
uint32_t pptx :1;
uint32_t rsvd0[4];
};
#else /* BIG ENDIAN */
struct hermon_hw_set_port_en_s {
uint32_t :29;
uint32_t v_pptx :1;
uint32_t v_pprx :1;
uint32_t v_mtu :1;
uint32_t :16;
uint32_t mtu :16;
uint32_t pptx :1;
uint32_t :7;
uint32_t pfctx :8;
uint32_t :16;
uint32_t pprx :1;
uint32_t :7;
uint32_t pfcrx :8;
uint32_t :16;
uint32_t rsvd0[4];
};
#endif
/* set_port for enet, RX QPM calculations Parameters */
#ifdef _LITTLE_ENDIAN
struct hermon_hw_set_port_en_rqpn_s {
uint32_t n_p :2;
uint32_t :6;
uint32_t n_v :3;
uint32_t :5;
uint32_t n_m :4;
uint32_t :12;
uint32_t base_qpn :24;
uint32_t :8;
uint32_t vlan_miss_idx :7;
uint32_t :8;
uint32_t intra_vlan_miss :1;
uint32_t no_vlan_idx :7;
uint32_t :8;
uint32_t intra_no_vlan :1;
uint32_t mac_miss_idx :8;
uint32_t :24;
uint32_t promisc_qpn :24;
uint32_t :7;
uint32_t en_uc_promisc :1;
uint32_t no_vlan_prio :3;
uint32_t :29;
uint32_t :32;
uint32_t def_mcast_qpn :24;
uint32_t :5;
uint32_t mc_by_vlan :1;
uint32_t mc_promisc_mode :2;
uint32_t rsvd0[4];
};
#else /* BIG ENDIAN */
struct hermon_hw_set_port_en_rqpn_s {
uint32_t :8;
uint32_t base_qpn :24;
uint32_t :12;
uint32_t n_m :4;
uint32_t :5;
uint32_t n_v :3;
uint32_t :6;
uint32_t n_p :2;
uint32_t :24;
uint32_t mac_miss_idx :8;
uint32_t intra_no_vlan :1;
uint32_t :8;
uint32_t no_vlan_idx :7;
uint32_t intra_vlan_miss :1;
uint32_t :8;
uint32_t vlan_miss_idx :7;
uint32_t :29;
uint32_t no_vlan_prio :3;
uint32_t en_uc_promisc :1;
uint32_t :7;
uint32_t promisc_qpn :24;
uint32_t mc_promisc_mode :2;
uint32_t mc_by_vlan :1;
uint32_t :5;
uint32_t def_mcast_qpn :24;
uint32_t :32;
uint32_t rsvd0[4];
};
#endif
#ifdef _LITTLE_ENDIAN
struct hermon_hw_set_port_mact_entry_s {
uint32_t mac_lo :32;
uint32_t mac_hi :16;
uint32_t :7;
uint32_t mac_valid :1;
};
#else /* BIG ENDIAN */
struct hermon_hw_set_port_mact_entry_s {
uint32_t mac_valid :1;
uint32_t :7;
uint32_t mac_hi :16;
uint32_t mac_lo :32;
};
#endif
/* set_port for enet, MAC Table Configuration */
#ifdef _LITTLE_ENDIAN
struct hermon_hw_set_port_en_mact_s {
struct hermon_hw_set_port_mact_entry_s mtable[128];
};
#else /* BIG ENDIAN */
struct hermon_hw_set_port_en_mact_s {
struct hermon_hw_set_port_mact_entry_s mtable[128];
};
#endif
/* set_port for enet, VLAN Table Configuration */
#ifdef _LITTLE_ENDIAN
struct hermon_hw_set_port_vlant_entry_s {
uint32_t vlan_id :12;
uint32_t :18;
uint32_t intra :1;
uint32_t valid :1;
};
#else /* BIG ENDIAN */
struct hermon_hw_set_port_vlant_entry_s {
uint32_t valid :1;
uint32_t intra :1;
uint32_t :18;
uint32_t vlan_id :12;
};
#endif
#ifdef _LITTLE_ENDIAN
struct hermon_hw_set_port_en_vlant_s {
uint32_t rsvd[2];
struct hermon_hw_set_port_vlant_entry_s table[126];
};
#else /* BIG ENDIAN */
struct hermon_hw_set_port_en_vlant_s {
uint32_t rsvd[2];
struct hermon_hw_set_port_vlant_entry_s table[126];
};
#endif
/* set_port for enet, Priority table Parameters */
#ifdef _LITTLE_ENDIAN
struct hermon_hw_set_port_en_priot_s {
uint32_t :32;
uint32_t prio0 :3;
uint32_t :1;
uint32_t prio1 :3;
uint32_t :1;
uint32_t prio2 :3;
uint32_t :1;
uint32_t prio3 :3;
uint32_t :1;
uint32_t prio4 :3;
uint32_t :1;
uint32_t prio5 :3;
uint32_t :1;
uint32_t prio6 :3;
uint32_t :1;
uint32_t prio7 :3;
uint32_t :1;
uint32_t rsvd[2];
};
#else /* BIG ENDIAN */
struct hermon_hw_set_port_en_priot_s {
uint32_t :1;
uint32_t prio7 :3;
uint32_t :1;
uint32_t prio6 :3;
uint32_t :1;
uint32_t prio5 :3;
uint32_t :1;
uint32_t prio4 :3;
uint32_t :1;
uint32_t prio3 :3;
uint32_t :1;
uint32_t prio2 :3;
uint32_t :1;
uint32_t prio1 :3;
uint32_t :1;
uint32_t prio0 :3;
uint32_t :32;
uint32_t rsvd[2];
};
#endif
/* note: GID table is same BIG or LITTLE ENDIAN */
struct hermon_hw_set_port_gidtable_s {
uint64_t gid[128];
};
#ifdef _LITTLE_ENDIAN
struct hermon_hw_conf_int_mod_s {
uint32_t :32;
uint32_t int_vect :16;
uint32_t min_delay :16;
};
#else /* BIG ENDIAN */
struct hermon_hw_conf_int_mod_s {
uint32_t min_delay :16;
uint32_t int_vect :16;
uint32_t :32;
};
#endif
/*
* Hermon Memory Protection Table (MPT) entries
*
* The Memory Protection Table (MPT) contains the information associated
* with all the regions and windows. The MPT table resides in a virtually-
* contiguous area in ICM, and the memory key (R_Key or L_Key) is used to
* calculate the physical address for accessing the entries in the table.
*
*
* The SW2HW_MPT command transfers ownership of an MPT entry from software
* to hardware. The command takes the MPT entry from the input mailbox and
* stores it in the MPT in the hardware. The command will fail if the
* requested MPT entry is already owned by the hardware or if the MPT index
* given in the command is inconsistent with the MPT entry memory key.
* The QUERY_MPT command retrieves a snapshot of an MPT entry. The command
* takes the current state of an MPT entry from the hardware and stores it
* in the output mailbox. The command will fail if the requested MPT entry
* is already owned by software.
* Finally, the HW2SW_MPT command transfers ownership of an MPT entry from
* the hardware to the software. The command takes the MPT entry from the
* hardware, invalidates it, and stores it in the output mailbox. The
* command will fail if the requested entry is already owned by software.
* The command will also fail if the MPT entry in question is a Memory
* Region which has Memory Windows currently bound to it.
*
* The following structure is used in the SW2HW_MPT, QUERY_MPT, and
* HW2SW_MPT commands, and ONLY for the dMPT - for data.
*/
#ifdef _LITTLE_ENDIAN
struct hermon_hw_dmpt_s {
uint32_t :7;
uint32_t bnd_qp :1;
uint32_t qpn :24; /* dw 1, byte 4-7 */
uint32_t :8;
uint32_t reg_win :1;
uint32_t phys_addr :1;
uint32_t lr :1;
uint32_t lw :1;
uint32_t rr :1;
uint32_t rw :1;
uint32_t atomic :1;
uint32_t en_bind :1;
uint32_t atc_req :1;
uint32_t atc_xlat :1;
uint32_t :1;
uint32_t no_snoop :1;
uint32_t :8;
uint32_t status :4; /* dw 0, byte 0-3 */
uint32_t pd :24;
uint32_t ren_inval :1;
uint32_t en_inval :1;
uint32_t net_cache :1;
uint32_t fast_reg_en :1;
uint32_t rem_acc_en :1;
uint32_t w_dif :1;
uint32_t m_dif :1;
uint32_t :1; /* dw 2, byte 0xc-f */
uint32_t mem_key;
uint64_t start_addr; /* dw 4-5, byte 0x10-17 */
uint64_t reg_win_len; /* dw 6-7, byte 0x18-1f */
uint32_t win_cnt :24;
uint32_t :8; /* dw 9, byte 0x24-27 */
uint32_t lkey; /* dw 8, byte 0x20-23 */
uint32_t mtt_addr_h :8;
uint32_t :24; /* dw 11, byte 0x2c-2f */
uint32_t mtt_rep :4;
uint32_t :17;
uint32_t blk_mode :1;
uint32_t len_b64 :1; /* bit 64 of length */
uint32_t fbo_en :1;
uint32_t :8; /* dw 10, byte 0x28-2b */
uint32_t mtt_size; /* dw 13, byte 0x34-37 */
uint32_t :3;
uint32_t mtt_addr_l :29; /* dw 12, byte 0x30-33 */
uint32_t mtt_fbo :21;
uint32_t :11; /* dw 15, byte 0x3c-3f */
uint32_t entity_sz :21;
uint32_t :11; /* dw 14, byte 0x38-3b */
uint32_t dif_m_atag :16;
uint32_t :16; /* dw 17, 0x44-47 */
uint32_t dif_a_msk :16;
uint32_t dif_v_msk :2;
uint32_t dif_rep :2;
uint32_t :4;
uint32_t dif_err :3;
uint32_t :5; /* dw 16, 0x40-43 */
uint32_t dif_w_atag :16;
uint32_t :16; /* dw 19, 0x4c-4f */
uint32_t dif_m_rtagb; /* dw 18, 0x48-4b */
uint32_t :32;
uint32_t dif_w_rtagb; /* dw 20, 0x50-53 */
uint32_t rsvd[10];
};
#else /* BIG ENDIAN */
struct hermon_hw_dmpt_s {
uint32_t status :4;
uint32_t :8;
uint32_t no_snoop :1;
uint32_t :1;
uint32_t atc_xlat :1;
uint32_t atc_req :1;
uint32_t en_bind :1;
uint32_t atomic :1;
uint32_t rw :1;
uint32_t rr :1;
uint32_t lw :1;
uint32_t lr :1;
uint32_t phys_addr :1;
uint32_t reg_win :1;
uint32_t :8; /* dw 0, byte 0x0-3 */
uint32_t qpn :24;
uint32_t bnd_qp :1;
uint32_t :7; /* dw 1, byte 0x4-7 */
uint32_t mem_key; /* dw 2, byte 0x8-b */
uint32_t :1;
uint32_t m_dif :1;
uint32_t w_dif :1;
uint32_t rem_acc_en :1;
uint32_t fast_reg_en :1;
uint32_t net_cache :1;
uint32_t en_inval :1;
uint32_t ren_inval :1;
uint32_t pd :24; /* dw 3, byte 0xc-f */
uint64_t start_addr; /* dw 4-5, byte 0x10-17 */
uint64_t reg_win_len; /* dw 6-7, byte 0x18-1f */
uint32_t lkey; /* dw 8, bytd 0x20-23 */
uint32_t :8;
uint32_t win_cnt :24; /* dw 9, byte 0x24-27 */
uint32_t :8;
uint32_t fbo_en :1;
uint32_t len_b64 :1; /* bit 64 of length */
uint32_t blk_mode :1;
uint32_t :17;
uint32_t mtt_rep :4; /* dw 10, byte 0x28-2b */
uint32_t :24;
uint32_t mtt_addr_h :8; /* dw 11, byte 0x2c-2f */
uint32_t mtt_addr_l :29;
uint32_t :3; /* dw 12, byte 0x30-33 */
uint32_t mtt_size; /* dw 13, byte 0x34-37 */
uint32_t :11;
uint32_t entity_sz :21; /* dw 14, byte 0x38-3b */
uint32_t :11;
uint32_t mtt_fbo :21; /* dw 15, byte 0x3c-3f */
uint32_t :5;
uint32_t dif_err :3;
uint32_t :4;
uint32_t dif_rep :2;
uint32_t dif_v_msk :2;
uint32_t dif_a_msk :16; /* dw 16, 0x40-43 */
uint32_t :16;
uint32_t dif_m_atag :16; /* dw 17, 0x44-47 */
uint32_t dif_m_rtagb; /* dw 18, 0x48-4b */
uint32_t :16;
uint32_t dif_w_atag :16; /* dw 19, 0x4c-4f */
uint32_t dif_w_rtagb; /* dw 20, 0x50-53 */
uint32_t :32;
uint32_t rsvd[10];
};
#endif
/*
* The following structure is for the CMPTs. This is NEVER actually built and
* passed to the hardware - we use it to track information needed for the
* context entries, and to facilitate the alloc tracking. It differs from
* the dMPT sturcture above in that it does not have/need the "dif" stuff.
*
*/
#ifdef _LITTLE_ENDIAN
struct hermon_hw_cmpt_s {
uint32_t :7;
uint32_t bnd_qp :1;
uint32_t qpn :24; /* dw 1, byte 4-7 */
uint32_t :8;
uint32_t reg_win :1;
uint32_t phys_addr :1;
uint32_t lr :1;
uint32_t lw :1;
uint32_t rr :1;
uint32_t rw :1;
uint32_t atomic :1;
uint32_t en_bind :1;
uint32_t atc_req :1;
uint32_t atc_xlat :1;
uint32_t :1;
uint32_t no_snoop :1;
uint32_t :8;
uint32_t status :4; /* dw 0, byte 0-3 */
uint32_t pd :24;
uint32_t ren_inval :1;
uint32_t en_inval :1;
uint32_t net_cache :1;
uint32_t fast_reg_en :1;
uint32_t rem_acc_en :1;
uint32_t w_dif :1;
uint32_t m_dif :1;
uint32_t :1; /* dw 2, byte 0xc-f */
uint32_t mem_key;
uint64_t start_addr; /* dw 4-5, byte 0x10-17 */
uint64_t reg_win_len; /* dw 6-7, byte 0x18-1f */
uint32_t win_cnt :24;
uint32_t :8; /* dw 9, byte 0x24-27 */
uint32_t lkey; /* dw 8, byte 0x20-23 */
uint32_t mtt_addr_h :8;
uint32_t :24; /* dw 11, byte 0x2c-2f */
uint32_t mtt_rep :4;
uint32_t :17;
uint32_t blk_mode :1;
uint32_t len_b64 :1; /* bit 64 of length */
uint32_t fbo_en :1;
uint32_t :8; /* dw 10, byte 0x28-2b */
uint32_t mtt_size; /* dw 13, byte 0x34-37 */
uint32_t :3;
uint32_t mtt_addr_l :29; /* dw 12, byte 0x30-33 */
uint32_t mtt_fbo :21;
uint32_t :11; /* dw 15, byte 0x3c-3f */
uint32_t entity_sz :21;
uint32_t :11; /* dw 14, byte 0x38-3b */
};
#else /* BIG ENDIAN */
struct hermon_hw_cmpt_s {
uint32_t status :4;
uint32_t :8;
uint32_t no_snoop :1;
uint32_t :1;
uint32_t atc_xlat :1;
uint32_t atc_req :1;
uint32_t en_bind :1;
uint32_t atomic :1;
uint32_t rw :1;
uint32_t rr :1;
uint32_t lw :1;
uint32_t lr :1;
uint32_t phys_addr :1;
uint32_t reg_win :1;
uint32_t :8; /* dw 0, byte 0x0-3 */
uint32_t qpn :24;
uint32_t bnd_qp :1;
uint32_t :7; /* dw 1, byte 0x4-7 */
uint32_t mem_key; /* dw 2, byte 0x8-b */
uint32_t :1;
uint32_t m_dif :1;
uint32_t w_dif :1;
uint32_t rem_acc_en :1;
uint32_t fast_reg_en :1;
uint32_t net_cache :1;
uint32_t en_inval :1;
uint32_t ren_inval :1;
uint32_t pd :24; /* dw 3, byte 0xc-f */
uint64_t start_addr; /* dw 4-5, byte 0x10-17 */
uint64_t reg_win_len; /* dw 6-7, byte 0x18-1f */
uint32_t lkey; /* dw 8, bytd 0x20-23 */
uint32_t :8;
uint32_t win_cnt :24; /* dw 9, byte 0x24-27 */
uint32_t :8;
uint32_t fbo_en :1;
uint32_t len_b64 :1; /* bit 64 of length */
uint32_t blk_mode :1;
uint32_t :17;
uint32_t mtt_rep :4; /* dw 10, byte 0x28-2b */
uint32_t :24;
uint32_t mtt_addr_h :8; /* dw 11, byte 0x2c-2f */
uint32_t mtt_addr_l :29;
uint32_t :3; /* dw 12, byte 0x30-33 */
uint32_t mtt_size; /* dw 13, byte 0x34-37 */
uint32_t :11;
uint32_t entity_sz :21; /* dw 14, byte 0x38-3b */
uint32_t :11; /* dw 15, byte 0x3c-3f */
uint32_t mtt_fbo :21;
};
#endif
#define HERMON_MEM_CYCLE_GENERATE 0x1
#define HERMON_IO_CYCLE_GENERATE 0x0
#define HERMON_MPT_IS_WINDOW 0x0
#define HERMON_MPT_IS_REGION 0x1
#define HERMON_MPT_DEFAULT_VERSION 0x0
#define HERMON_UNLIMITED_WIN_BIND 0x0
#define HERMON_PHYSADDR_ENABLED 0x1
#define HERMON_PHYSADDR_DISABLED 0x0
/*
* Hermon Memory Translation Table (MTT) entries
* After accessing the MPT table (above) and validating the access rights
* to the region/window, Hermon address translation moves to the next step
* where it translates the virtual address to a physical address. This
* translation is performed using the Memory Translation Table entries
* (MTT). Note: The MTT in hardware is organized into segments and each
* segment contains multiple address translation pages (MTT entries).
* Each memory region (MPT above) points to the first segment in the MTT
* that corresponds to that region.
*/
#ifdef _LITTLE_ENDIAN
struct hermon_hw_mtt_s {
uint32_t present :1;
uint32_t :2;
uint32_t ptag_l :29;
uint32_t ptag_h;
};
#else /* BIG_ENDIAN */
struct hermon_hw_mtt_s {
uint32_t ptag_h;
uint32_t ptag_l :29;
uint32_t :2;
uint32_t present :1;
};
#endif
#define HERMON_MTT_ENTRY_NOTPRESENT 0x0
#define HERMON_MTT_ENTRY_PRESENT 0x1
/*
* Hermon Event Queue Context Table (EQC) entries
* Hermon supports 512 Event Queues, and the status of Event Queues is stored
* in the Event Queue Context (EQC) table. The EQC table is a virtually-
* contiguous memory structure in the ICM. Each EQC
* table entry contains Event Queue status and information required by
* the hardware in order to access the event queue.
* NOTE that in Hermon (as opposed to earlier HCAs),
* you have to allocate ICM for 2**32 (or about 16 M), even though
* it doesn't support that many. See PRM v35. Also, some set of them
* will be available for each domain in a virtual environment, needing to
* rething the allocation and usage model for EQs - in the future.
*
* The following structure is used in the SW2HW_EQ, QUERY_EQ, and HW2SW_EQ
* commands.
* The SW2HW_EQ command transfers ownership of an EQ context from software
* to hardware. The command takes the EQC entry from the input mailbox and
* stores it in the EQC in the hardware. The command will fail if the
* requested EQC entry is already owned by the hardware. NOTE: the
* initialization of the cMPT for the EQC occurs implicitly as a result
* of executing this command, and MR has/had to be adjusted for it.
* The QUERY_EQ command retrieves a snapshot of an EQC entry. The command
* stores the snapshot in the output mailbox. The EQC state and its values
* are not affected by the QUERY_EQ command.
* Finally, the HW2SW_EQ command transfers ownership of an EQC entry from
* the hardware to the software. The command takes the EQC entry from the
* hardware and stores it in the output mailbox. The EQC entry will be
* invalidated as a result of the command. It is the responsibility of the
* software to unmap all the events, which might have been previously
* mapped to the EQ, prior to issuing the HW2SW_EQ command.
*/
#ifdef _LITTLE_ENDIAN
struct hermon_hw_eqc_s {
uint32_t :32;
uint32_t :8;
uint32_t state :4;
uint32_t :5;
uint32_t overrun_ignore :1;
uint32_t ev_coalesc :1;
uint32_t :9;
uint32_t status :4;
uint32_t :24;
uint32_t log_eq_sz :5;
uint32_t :3;
uint32_t :5;
uint32_t pg_offs :7;
uint32_t :20;
uint32_t intr :10;
uint32_t :22;
uint32_t eq_max_cnt :16;
uint32_t eq_period :16;
uint32_t :3;
uint32_t mtt_base_addrl :29;
uint32_t mtt_base_addrh :8;
uint32_t :16;
uint32_t log2_pgsz :6; /* in 4K pages */
uint32_t :2;
uint32_t rsrv0[2];
uint32_t prod_indx :24;
uint32_t :8;
uint32_t cons_indx :24;
uint32_t :8;
uint64_t rsrv1[2]; /* force it to 8b alignment */
};
#else /* BIG ENDIAN */
struct hermon_hw_eqc_s {
uint32_t status :4;
uint32_t :9;
uint32_t ev_coalesc :1;
uint32_t overrun_ignore :1;
uint32_t :5;
uint32_t state :4;
uint32_t :8;
uint32_t :32;
uint32_t :20;
uint32_t pg_offs :7;
uint32_t :5;
uint32_t :3;
uint32_t log_eq_sz :5;
uint32_t :24;
uint32_t eq_period :16;
uint32_t eq_max_cnt :16;
uint32_t :22;
uint32_t intr :10;
uint32_t :2;
uint32_t log2_pgsz :6; /* in 4K pages */
uint32_t :16;
uint32_t mtt_base_addrh :8;
uint32_t mtt_base_addrl :29;
uint32_t :3;
uint32_t rsrv0[2];
uint32_t :8;
uint32_t cons_indx :24;
uint32_t :8;
uint32_t prod_indx :24;
uint64_t rsrv1[2]; /* force it to 8b alignment */
};
#endif
#define HERMON_EQ_STATUS_OK 0x0
#define HERMON_EQ_STATUS_OVERFLOW 0x9
#define HERMON_EQ_STATUS_WRITE_FAILURE 0xA
#define HERMON_EQ_ARMED 0x9
#define HERMON_EQ_FIRED 0xA
#define HERMON_EQ_ALWAYS_ARMED 0xB
/*
* Hermon Event Queue Entries (EQE)
* Each EQE contains enough information for the software to identify the
* source of the event. The following structures are used to define each
* of the various kinds of events that the Hermon hardware will generate.
* Note: The hermon_hw_eqe_t below is the generic "Event Queue Entry". All
* other EQEs differ only in the contents of their "event_data" field.
*
* Below we first define several structures which define the contents of
* the "event_data" fields:
* hermon_hw_eqe_cq_t for "Completion Queue Events"
* hermon_hw_eqe_qp_evt_t for "Queue Pair Events" such as Path Migration
* Succeeded, Path Migration Failed, Communication Established, Send
* Queue Drained, Local WQ Catastrophic Error, Invalid Request Local
* WQ Error, and Local Access Violation WQ Error.
* hermon_hw_eqe_cqerr_t for "Completion Queue Error Events"
* hermon_hw_eqe_portstate_t for "Port State Change Events"
* hermon_hw_eqe_gpio_t for "GPIO State Change Events"
* hermon_hw_eqe_cmdcmpl_t for "Command Interface Completion Events"
* hermon_hw_eqe_operr_t for "Operational and Catastrophic Error Events"
* such as EQ Overflow, Misbehaved UAR page, Internal Parity Error,
* Uplink bus error, and DDR data error.
* hermon_hw_eqe_pgflt_t for "Not-present Page Fault on WQE or Data
* Buffer Access". (Note: Currently, this event is unsupported).
*
* Note also: The following structures are not #define'd with both
* little-endian and big-endian definitions. This is because their
* individual fields are not directly accessed except through the macros
* defined below.
*/
typedef struct hermon_hw_eqe_cq_s {
uint32_t :8;
uint32_t cqn :24;
uint32_t rsrv0[5];
} hermon_hw_eqe_cq_t;
typedef struct hermon_hw_eqe_qp_evt_s {
uint32_t :8;
uint32_t qpn :24;
uint32_t rsrv0[5];
} hermon_hw_eqe_qpevt_t;
typedef struct hermon_hw_eqe_cqerr_s {
uint32_t :8;
uint32_t cqn :24;
uint32_t :32;
uint32_t :24;
uint32_t syndrome :8;
uint32_t rsrv0[3];
} hermon_hw_eqe_cqerr_t;
#define HERMON_CQERR_OVERFLOW 0x1
#define HERMON_CQERR_ACCESS_VIOLATION 0x2
typedef struct hermon_hw_eqe_portstate_s {
uint32_t rsrv0[2];
uint32_t :2;
uint32_t port :2;
uint32_t :28;
uint32_t rsrv1[3];
} hermon_hw_eqe_portstate_t;
#define HERMON_PORT_LINK_ACTIVE 0x4
#define HERMON_PORT_LINK_DOWN 0x1
typedef struct hermon_hw_eqe_gpio_s {
uint32_t rsrv0[3];
uint32_t gpio_ev0;
uint32_t gpio_ev1;
uint32_t :32;
} hermon_hw_eqe_gpio_t;
typedef struct hermon_hw_eqe_cmdcmpl_s {
uint32_t :16;
uint32_t token :16;
uint32_t :32;
uint32_t :24;
uint32_t status :8;
uint32_t out_param0;
uint32_t out_param1;
uint32_t :32;
} hermon_hw_eqe_cmdcmpl_t;
typedef struct hermon_hw_eqe_operr_s {
uint32_t rsrv0[2];
uint32_t :24;
uint32_t error_type :8;
uint32_t data;
uint32_t rsrv1[2];
} hermon_hw_eqe_operr_t;
#define HERMON_ERREVT_EQ_OVERFLOW 0x1
#define HERMON_ERREVT_BAD_UARPG 0x2
#define HERMON_ERREVT_UPLINK_BUSERR 0x3
#define HERMON_ERREVT_DDR_DATAERR 0x4
#define HERMON_ERREVT_INTERNAL_PARITY 0x5
typedef struct hermon_hw_eqe_fcerr_s {
uint32_t :14;
uint32_t port :2;
uint32_t fexch :16; /* fexch number */
uint32_t :32;
uint32_t :24;
uint32_t fcsyndrome :8;
uint32_t rsvd[3];
} hermon_hw_eqe_fcerr_t;
#define HERMON_ERR_FC_BADIU 0x0
#define HERMON_ERR_FC_SEQUENCE 0x01
typedef struct hermon_hw_eqe_pgflt_s {
uint32_t rsrv0[2];
uint32_t :24;
uint32_t fault_type :4;
uint32_t wqv :1;
uint32_t wqe_data :1;
uint32_t rem_loc :1;
uint32_t snd_rcv :1;
uint32_t vaddr_h;
uint32_t vaddr_l;
uint32_t mem_key;
} hermon_hw_eqe_pgflt_t;
#define HERMON_PGFLT_PG_NOTPRESENT 0x8
#define HERMON_PGFLT_PG_WRACC_VIOL 0xA
#define HERMON_PGFLT_UNSUP_NOTPRESENT 0xE
#define HERMON_PGFLT_UNSUP_WRACC_VIOL 0xF
#define HERMON_PGFLT_WQE_CAUSED 0x1
#define HERMON_PGFLT_DATA_CAUSED 0x0
#define HERMON_PGFLT_REMOTE_CAUSED 0x1
#define HERMON_PGFLT_LOCAL_CAUSED 0x0
#define HERMON_PGFLT_SEND_CAUSED 0x1
#define HERMON_PGFLT_RECV_CAUSED 0x0
#define HERMON_PGFLT_DESC_CONSUMED 0x1
#define HERMON_PGFLT_DESC_NOTCONSUMED 0x0
struct hermon_hw_eqe_s {
uint32_t :8;
uint32_t event_type :8;
uint32_t :8;
uint32_t event_subtype :8;
union {
hermon_hw_eqe_cq_t eqe_cq;
hermon_hw_eqe_qpevt_t eqe_qpevt;
hermon_hw_eqe_cqerr_t eqe_cqerr;
hermon_hw_eqe_portstate_t eqe_portstate;
hermon_hw_eqe_gpio_t eqe_gpio;
hermon_hw_eqe_cmdcmpl_t eqe_cmdcmpl;
hermon_hw_eqe_operr_t eqe_operr;
hermon_hw_eqe_pgflt_t eqe_pgflt;
hermon_hw_eqe_fcerr_t eqe_fcerr;
} event_data;
uint32_t :24;
uint32_t owner :1;
uint32_t :7;
};
#define eqe_cq event_data.eqe_cq
#define eqe_qpevt event_data.eqe_qpevt
#define eqe_cqerr event_data.eqe_cqerr
#define eqe_portstate event_data.eqe_portstate
#define eqe_gpio event_data.eqe_gpio
#define eqe_cmdcmpl event_data.eqe_cmdcmpl
#define eqe_operr event_data.eqe_operr
#define eqe_pgflt event_data.eqe_pgflt
#define eqe_fcerr event_data.eqe_fcerr
/*
* The following macros are used for extracting (and in some cases filling in)
* information from EQEs
*/
#define HERMON_EQE_CQNUM_MASK 0x00FFFFFF
#define HERMON_EQE_CQNUM_SHIFT 0
#define HERMON_EQE_QPNUM_MASK 0x00FFFFFF
#define HERMON_EQE_QPNUM_SHIFT 0
#define HERMON_EQE_PORTNUM_MASK 0x30
#define HERMON_EQE_PORTNUM_SHIFT 4
#define HERMON_EQE_OWNER_MASK 0x00000080
#define HERMON_EQE_OWNER_SHIFT 7
#define HERMON_EQE_EVTTYPE_GET(eq, eqe) \
(((uint8_t *)(eqe))[1])
#define HERMON_EQE_EVTSUBTYPE_GET(eq, eqe) \
(((uint8_t *)(eqe))[3])
#define HERMON_EQE_CQNUM_GET(eq, eqe) \
((htonl(((uint32_t *)(eqe))[1]) & HERMON_EQE_CQNUM_MASK) >> \
HERMON_EQE_CQNUM_SHIFT)
#define HERMON_EQE_QPNUM_GET(eq, eqe) \
((htonl(((uint32_t *)(eqe))[1]) & HERMON_EQE_QPNUM_MASK) >> \
HERMON_EQE_QPNUM_SHIFT)
#define HERMON_EQE_PORTNUM_GET(eq, eqe) \
(((((uint8_t *)(eqe))[12]) & HERMON_EQE_PORTNUM_MASK) >> \
HERMON_EQE_PORTNUM_SHIFT)
#define HERMON_EQE_CMDTOKEN_GET(eq, eqe) \
htons(((uint16_t *)(eqe))[3])
#define HERMON_EQE_CMDSTATUS_GET(eq, eqe) \
(((uint8_t *)(eqe))[0xf])
#define HERMON_EQE_CMDOUTP0_GET(eq, eqe) \
htonl(((uint32_t *)(eqe))[4])
#define HERMON_EQE_CMDOUTP1_GET(eq, eqe) \
htonl(((uint32_t *)(eqe))[5])
#define HERMON_EQE_OPERRTYPE_GET(eq, eqe) \
(((uint8_t *)(eqe))[0xf])
#define HERMON_EQE_OPERRDATA_GET(eq, eqe) \
htonl(((uint32_t *)(eqe))[4])
#define HERMON_EQE_FEXCH_PORTNUM_GET(eq, eqe) \
(((uint8_t *)(eqe))[5] & 0x3)
#define HERMON_EQE_FEXCH_FEXCH_GET(eq, eqe) \
htons(((uint16_t *)(eqe))[3])
#define HERMON_EQE_FEXCH_SYNDROME_GET(eq, eqe) \
(((uint8_t *)(eqe))[15])
/*
* Hermon does ownership of CQ and EQ differently from Arbel & Tavor.
* Now, you keep track of the TOTAL number of CQE's or EQE's that have been
* processed, and the sense of the ownership bit changes each time through.
* That is, if the size of the queue is 16, so 4 bits [3:0] are the index
* number, then bit [4] is the ownership bit in the count. So you mask that
* bit and compare it to the owner bit in the entry - if the same, then the
* entry is in SW onwership. Otherwise, it's in hardware and the driver
* does not consume it.
*/
#define HERMON_EQE_OWNER_IS_SW(eq, eqe, consindx, shift) \
((((uint8_t *)(eqe))[0x1f] & HERMON_EQE_OWNER_MASK) == \
(((consindx) & eq->eq_bufsz) >> (shift)))
/*
* Hermon Completion Queue Context Table (CQC) entries
* The CQC table is a virtually-contiguous memory area residing in HCA's
* ICM. Each CQC table entry contains information
* required by the hardware to access the completion queue to post
* completions (CQE).
*
* The following structure is used in the SW2HW_CQ, QUERY_CQ, RESIZE_CQ,
* and HW2SW_CQ commands.
* The SW2HW_CQ command transfers ownership of an CQ context from software
* to hardware. The command takes the CQC entry from the input mailbox and
* stores it in the CQC in the hardware. The command will fail if the
* requested CQC entry is already owned by the hardware.
* The QUERY_CQ command retrieves a snapshot of a CQC entry. The command
* stores the snapshot in the output mailbox. The CQC state and its values
* are not affected by the QUERY_CQ command.
* Finally, the HW2SW_CQ command transfers ownership of a CQC entry from
* the hardware to the software. The command takes the CQC entry from the
* hardware and stores it in the output mailbox. The CQC entry will be
* invalidated as a result of the command.
*/
#ifdef _LITTLE_ENDIAN
struct hermon_hw_cqc_s {
uint32_t :32;
uint32_t :8;
uint32_t state :4;
uint32_t :5;
uint32_t overrun_ignore :1;
uint32_t cqe_coalesc :1;
uint32_t :9;
uint32_t status :4;
uint32_t usr_page :24;
uint32_t log_cq_sz :5;
uint32_t :3;
uint32_t :5;
uint32_t pg_offs :7;
uint32_t :20;
uint32_t c_eqn :9;
uint32_t :23;
uint32_t cq_max_cnt :16;
uint32_t cq_period :16;
uint32_t :3;
uint32_t mtt_base_addl :29;
uint32_t mtt_base_addh :8;
uint32_t :16;
uint32_t log2_pgsz :6;
uint32_t :2;
uint32_t solicit_prod_indx :24;
uint32_t :8;
uint32_t last_notified_indx :24;
uint32_t :8;
uint32_t prod_cntr :24; /* producer counter */
uint32_t :8;
uint32_t cons_cntr :24; /* consumer counter */
uint32_t :8;
uint32_t rsrv0[2];
uint32_t :3;
uint32_t dbr_addrl :29;
uint32_t dbr_addrh;
uint64_t rsrv1[8]; /* hermon, match DEV_CAP size */
};
#else
struct hermon_hw_cqc_s {
uint32_t status :4;
uint32_t :9;
uint32_t cqe_coalesc :1;
uint32_t overrun_ignore :1;
uint32_t :5;
uint32_t state :4;
uint32_t :8;
uint32_t :32;
uint32_t :20;
uint32_t pg_offs :7;
uint32_t :5;
uint32_t :3;
uint32_t log_cq_sz :5;
uint32_t usr_page :24;
uint32_t cq_period :16;
uint32_t cq_max_cnt :16;
uint32_t :23;
uint32_t c_eqn :9;
uint32_t :2;
uint32_t log2_pgsz :6;
uint32_t :16;
uint32_t mtt_base_addh :8;
uint32_t mtt_base_addl :29;
uint32_t :3;
uint32_t :8;
uint32_t last_notified_indx :24;
uint32_t :8;
uint32_t solicit_prod_indx :24;
uint32_t :8;
uint32_t cons_cntr :24; /* consumer counter */
uint32_t :8;
uint32_t prod_cntr :24; /* priducer counter */
uint32_t rsrv0[2];
uint32_t dbr_addrh;
uint32_t dbr_addrl :29;
uint32_t :3;
uint64_t rsrv1[8]; /* hermon, match DEV_CAP size */
};
#endif
#define HERMON_CQ_STATUS_OK 0x0
#define HERMON_CQ_STATUS_OVERFLOW 0x9
#define HERMON_CQ_STATUS_WRITE_FAILURE 0xA
#define HERMON_CQ_DISARMED 0x0
#define HERMON_CQ_ARMED 0x1
#define HERMON_CQ_ARMED_SOLICITED 0x4
#define HERMON_CQ_FIRED 0xA
/*
* Hermon Completion Queue Entries (CQE)
* Each CQE contains enough information for the software to associate the
* completion with the Work Queue Element (WQE) to which it corresponds.
*
* Note: The following structure is not #define'd with both little-endian
* and big-endian definitions. This is because each CQE's individual
* fields are not directly accessed except through the macros defined below.
*/
struct hermon_hw_cqe_s {
uint32_t dife :1;
uint32_t vlan :2;
uint32_t fl :1;
uint32_t fcrc_sd :1;
uint32_t d2s :1;
uint32_t :2;
uint32_t my_qpn :24;
uint32_t immed_rss_val_key;
uint32_t grh :1;
uint32_t ml_path :7;
uint32_t srq_rqpn :24;
uint32_t sl :4;
uint32_t vid :12;
uint32_t slid :16; /* SMAC 47:32 or SLID */
uint32_t ipoib_status; /* SMAC 31:0 or enet/ipoib/EoIB status */
uint32_t byte_cnt;
uint32_t wqe_cntr :16;
uint32_t checksum :16;
uint32_t :8;
uint32_t :16;
uint32_t owner :1;
uint32_t send_or_recv :1;
uint32_t inline_scatter :1;
uint32_t opcode :5;
};
#define HERMON_COMPLETION_RECV 0x0
#define HERMON_COMPLETION_SEND 0x1
#define HERMON_CQE_DEFAULT_VERSION 0x0
/*
* The following macros are used for extracting (and in some cases filling in)
* information from CQEs
*/
#define HERMON_CQE_QPNUM_MASK 0x00FFFFFF
#define HERMON_CQE_QPNUM_SHIFT 0
#define HERMON_CQE_DQPN_MASK 0x00FFFFFF
#define HERMON_CQE_DQPN_SHIFT 0
#define HERMON_CQE_SL_SHIFT 4
#define HERMON_CQE_GRH_MASK 0x80
#define HERMON_CQE_PATHBITS_MASK 0x7F
#define HERMON_CQE_SLID_15_8 0xe
#define HERMON_CQE_SLID_7_0 0xf
#define HERMON_CQE_OPCODE_MASK 0x1F
#define HERMON_CQE_SENDRECV_MASK 0x40
#define HERMON_CQE_SENDRECV_SHIFT 6
#define HERMON_CQE_OWNER_MASK 0x80
#define HERMON_CQE_OWNER_SHIFT 7
#define HERMON_CQE_WQECNTR_15_8 0x18
#define HERMON_CQE_WQECNTR_7_0 0x19
/* Byte offsets for IPoIB Checksum Offload fields */
#define HERMON_CQE_CKSUM_15_8 0x1a
#define HERMON_CQE_CKSUM_7_0 0x1b
#define HERMON_CQE_IPOK 0x10 /* byte 0x10 in cqe */
#define HERMON_CQE_IPOK_BIT 0x10 /* bitmask for OK bit */
#define HERMON_CQE_IS_IPOK(cq, cqe) \
(((uint8_t *)(cqe))[HERMON_CQE_IPOK] & HERMON_CQE_IPOK_BIT)
#define HERMON_CQE_CKSUM(cq, cqe) \
((((uint8_t *)(cqe))[HERMON_CQE_CKSUM_15_8] << 8) | \
(((uint8_t *)(cqe))[HERMON_CQE_CKSUM_7_0]))
#define HERMON_CQE_IPOIB_STATUS(cq, cqe) \
htonl((((uint32_t *)(cqe)))[4])
#define HERMON_CQE_QPNUM_GET(cq, cqe) \
((htonl((((uint32_t *)(cqe)))[0]) & HERMON_CQE_QPNUM_MASK) >> \
HERMON_CQE_QPNUM_SHIFT)
#define HERMON_CQE_IMM_ETH_PKEY_CRED_GET(cq, cqe) \
htonl(((uint32_t *)(cqe))[1])
#define HERMON_CQE_DQPN_GET(cq, cqe) \
((htonl(((uint32_t *)(cqe))[2]) & HERMON_CQE_DQPN_MASK) >> \
HERMON_CQE_DQPN_SHIFT)
#define HERMON_CQE_GRH_GET(cq, cqe) \
(((uint8_t *)(cqe))[8] & HERMON_CQE_GRH_MASK)
#define HERMON_CQE_PATHBITS_GET(cq, cqe) \
(((uint8_t *)(cqe))[8] & HERMON_CQE_PATHBITS_MASK)
#define HERMON_CQE_DLID_GET(cq, cqe) \
((((uint8_t *)(cqe))[HERMON_CQE_SLID_15_8] << 8) | \
(((uint8_t *)(cqe))[HERMON_CQE_SLID_7_0]))
#define HERMON_CQE_SL_GET(cq, cqe) \
((((uint8_t *)(cqe))[12]) >> HERMON_CQE_SL_SHIFT)
#define HERMON_CQE_BYTECNT_GET(cq, cqe) \
htonl(((uint32_t *)(cqe))[5])
#define HERMON_CQE_WQECNTR_GET(cq, cqe) \
((((uint8_t *)(cqe))[HERMON_CQE_WQECNTR_15_8] << 8) | \
(((uint8_t *)(cqe))[HERMON_CQE_WQECNTR_7_0]))
#define HERMON_CQE_ERROR_SYNDROME_GET(cq, cqe) \
(((uint8_t *)(cqe))[27])
#define HERMON_CQE_ERROR_VENDOR_SYNDROME_GET(cq, cqe) \
(((uint8_t *)(cqe))[26])
#define HERMON_CQE_OPCODE_GET(cq, cqe) \
((((uint8_t *)(cqe))[31]) & HERMON_CQE_OPCODE_MASK)
#define HERMON_CQE_SENDRECV_GET(cq, cqe) \
(((((uint8_t *)(cqe))[31]) & HERMON_CQE_SENDRECV_MASK) >> \
HERMON_CQE_SENDRECV_SHIFT)
#define HERMON_CQE_FEXCH_SEQ_CNT(cq, cqe) \
HERMON_CQE_CKSUM(cq, cqe)
#define HERMON_CQE_FEXCH_TX_BYTES(cq, cqe) \
htonl(((uint32_t *)(cqe))[3])
#define HERMON_CQE_FEXCH_RX_BYTES(cq, cqe) \
htonl(((uint32_t *)(cqe))[4])
#define HERMON_CQE_FEXCH_SEQ_ID(cq, cqe) \
(((uint8_t *)(cqe))[8])
#define HERMON_CQE_FEXCH_DETAIL(cq, cqe) \
htonl(((uint32_t *)(cqe))[0])
#define HERMON_CQE_FEXCH_DIFE(cq, cqe) \
((((uint8_t *)(cqe))[0]) & 0x80)
/* See Comment above for EQE - ownership of CQE is handled the same */
#define HERMON_CQE_OWNER_IS_SW(cq, cqe, considx, shift, mask) \
(((((uint8_t *)(cqe))[31] & HERMON_CQE_OWNER_MASK) >> \
HERMON_CQE_OWNER_SHIFT) == \
(((considx) & (mask)) >> (shift)))
/*
* Hermon Shared Receive Queue (SRQ) Context Entry Format
*/
#ifdef _LITTLE_ENDIAN
struct hermon_hw_srqc_s {
uint32_t xrc_domain :16;
uint32_t :8;
uint32_t log_rq_stride :3;
uint32_t :5;
uint32_t srqn :24;
uint32_t log_srq_size :4;
uint32_t state :4;
uint32_t :32;
uint32_t cqn_xrc :24;
uint32_t :2;
uint32_t page_offs :6;
uint32_t :3;
uint32_t mtt_base_addrl :29;
uint32_t mtt_base_addrh :8;
uint32_t :16;
uint32_t log2_pgsz :6;
uint32_t :2;
uint32_t wqe_cnt :16;
uint32_t lwm :16;
uint32_t pd :24;
uint32_t :8;
uint32_t :32;
uint32_t srq_wqe_cntr :16;
uint32_t :16;
uint32_t :2;
uint32_t dbr_addrl :30;
uint32_t dbr_addrh;
uint32_t rsrc0[80]; /* to match DEV_CAP size of 0x80 */
};
#else /* BIG ENDIAN */
struct hermon_hw_srqc_s {
uint32_t state :4;
uint32_t log_srq_size :4;
uint32_t srqn :24;
uint32_t :5;
uint32_t log_rq_stride :3;
uint32_t :8;
uint32_t xrc_domain :16;
uint32_t page_offs :6;
uint32_t :2;
uint32_t cqn_xrc :24;
uint32_t :32;
uint32_t :2;
uint32_t log2_pgsz :6;
uint32_t :16;
uint32_t mtt_base_addrh :8;
uint32_t mtt_base_addrl :29;
uint32_t :3;
uint32_t :8;
uint32_t pd :24;
uint32_t lwm :16;
uint32_t wqe_cnt :16;
uint32_t :16;
uint32_t srq_wqe_cntr :16;
uint32_t :32;
uint32_t dbr_addrh;
uint32_t dbr_addrl :30;
uint32_t :2;
uint32_t rsrc0[80]; /* to match DEV_CAP size of 0x80 */
};
#endif
/*
* Hermon MOD_STAT_CFG input mailbox structure
*/
#ifdef _LITTLE_ENDIAN
struct hermon_hw_mod_stat_cfg_s {
uint32_t :16;
uint32_t qdr_rx_op :4;
uint32_t :3;
uint32_t qdr_rx_opt_m :1;
uint32_t qdr_tx_op :4;
uint32_t :3;
uint32_t qdr_tx_opt_m :1;
uint32_t log_pg_sz :8;
uint32_t log_pg_sz_m :1;
uint32_t :5;
uint32_t dife :1;
uint32_t dife_m :1;
uint32_t rx_options :4;
uint32_t :3;
uint32_t rx_options_m :1;
uint32_t tx_options :4;
uint32_t :3;
uint32_t tx_options_m :1;
uint32_t lid :16;
uint32_t lid_m :1;
uint32_t :3;
uint32_t port_en :1;
uint32_t port_en_m :1;
uint32_t :10;
uint32_t :32;
uint32_t guid_hi;
uint32_t :31;
uint32_t guid_hi_m :1;
uint32_t guid_lo;
uint32_t :31;
uint32_t guid_lo_m :1;
uint32_t rsvd[4];
uint32_t inbuf_ind_en :3;
uint32_t :1;
uint32_t sd_main :4;
uint32_t :4;
uint32_t sd_equal :4;
uint32_t :4;
uint32_t sd_mux_main :2;
uint32_t :2;
uint32_t mux_eq :2;
uint32_t :2;
uint32_t sigdet_th :3;
uint32_t :1;
uint32_t ob_preemp_pre :5;
uint32_t :3;
uint32_t op_preemp_post :5;
uint32_t :3;
uint32_t ob_preemp_main :5;
uint32_t :3;
uint32_t ob_preemp :5;
uint32_t :2;
uint32_t serdes_m :1;
uint32_t reserved[22];
uint32_t mac_lo :32;
uint32_t mac_hi :16;
uint32_t :15;
uint32_t mac_m :1;
};
#else /* BIG ENDIAN */
struct hermon_hw_mod_stat_cfg_s {
uint32_t tx_options_m :1;
uint32_t :3;
uint32_t tx_options :4;
uint32_t rx_options_m :1;
uint32_t :3;
uint32_t rx_options :4;
uint32_t dife_m :1;
uint32_t dife :1;
uint32_t :5;
uint32_t log_pg_sz_m :1;
uint32_t log_pg_sz :8;
uint32_t qdr_tx_opt_m :1;
uint32_t :3;
uint32_t qdr_tx_op :4;
uint32_t qdr_rx_opt_m :1;
uint32_t :3;
uint32_t qdr_rx_op :4;
uint32_t :16;
uint32_t :32;
uint32_t :10;
uint32_t port_en_m :1;
uint32_t port_en :1;
uint32_t :3;
uint32_t lid_m :1;
uint32_t lid :16;
uint32_t guid_hi_m :1;
uint32_t :31;
uint32_t guid_hi;
uint32_t guid_lo_m :1;
uint32_t :31;
uint32_t guid_lo;
uint32_t rsvd[4];
uint32_t serdes_m :1;
uint32_t :2;
uint32_t ob_preemp :5;
uint32_t :3;
uint32_t ob_preemp_main :5;
uint32_t :3;
uint32_t op_preemp_post :5;
uint32_t :3;
uint32_t ob_preemp_pre :5;
uint32_t :1;
uint32_t sigdet_th :3;
uint32_t :2;
uint32_t mux_eq :2;
uint32_t :2;
uint32_t sd_mux_main :2;
uint32_t :4;
uint32_t sd_equal :4;
uint32_t :4;
uint32_t sd_main :4;
uint32_t :1;
uint32_t inbuf_ind_en :3;
uint32_t reserved[22]; /* get to new enet stuff */
uint32_t mac_m :1;
uint32_t :15;
uint32_t mac_hi :16;
uint32_t mac_lo :32;
};
#endif
/*
* Hermon MOD_STAT_CFG input modifier structure
* NOTE: this might end up defined ONLY one way,
* if usage is access via macros
*/
struct hermon_hw_msg_in_mod_s {
#ifdef _LITTLE_ENDIAN
uint32_t offset :8;
uint32_t port_num :8;
uint32_t lane_num :4;
uint32_t link_speed :3;
uint32_t auto_neg :1;
uint32_t :8;
#else
uint32_t :8;
uint32_t auto_neg :1;
uint32_t link_speed :3;
uint32_t lane_num :4;
uint32_t port_num :8;
uint32_t offset :8;
#endif
};
/*
* Hermon UD Address Vector (UDAV)
* Hermon UDAV are used in conjunction with Unreliable Datagram (UD) send
* WQEs. Each UD send message contains an address vector in in the datagram
* segment. The verbs consumer must use special verbs to create and modify
* address handles, each of which contains a UDAV structure. When posting
* send WQEs to UD QP, the verbs consumer must supply a valid address
* handle/UDAV.
*/
#ifdef _LITTLE_ENDIAN
struct hermon_hw_udav_s {
uint32_t rlid :16;
uint32_t ml_path :7; /* mlid or SMAC idx */
uint32_t grh :1;
uint32_t :8;
uint32_t pd :24;
uint32_t portnum :2;
uint32_t :5;
uint32_t force_lb :1;
uint32_t flow_label :20;
uint32_t tclass :8;
uint32_t sl :4;
uint32_t hop_limit :8;
uint32_t max_stat_rate :4;
uint32_t :4;
uint32_t mgid_index :7;
uint32_t :9;
uint64_t rgid_h;
uint64_t rgid_l;
};
#else
struct hermon_hw_udav_s {
uint32_t force_lb :1;
uint32_t :5;
uint32_t portnum :2;
uint32_t pd :24;
uint32_t :8;
uint32_t grh :1;
uint32_t ml_path :7; /* mlid or SMAC idx */
uint32_t rlid :16;
uint32_t :9;
uint32_t mgid_index :7;
uint32_t :4;
uint32_t max_stat_rate :4;
uint32_t hop_limit :8;
uint32_t sl :4;
uint32_t tclass :8;
uint32_t flow_label :20;
uint64_t rgid_h;
uint64_t rgid_l;
};
#endif
#define HERMON_UDAV_MODIFY_MASK0 0xFCFFFFFFFF000000ULL
#define HERMON_UDAV_MODIFY_MASK1 0xFF80F00000000000ULL
/* UDAV for enthernet */
#ifdef _LITTLE_ENDIAN
struct hermon_hw_udav_enet_s {
uint32_t :16;
uint32_t smac_idx :7;
uint32_t :9;
uint32_t pd :24;
uint32_t portnum :2;
uint32_t :3;
uint32_t cv :1;
uint32_t :1;
uint32_t force_lb :1;
uint32_t flow_label :20;
uint32_t tclass :8;
uint32_t sl :4;
uint32_t hop_limit :8;
uint32_t max_stat_rate :4;
uint32_t :4;
uint32_t mgid_index :7;
uint32_t :9;
uint64_t rgid_h;
uint64_t rgid_l;
uint32_t rsrv[2];
uint32_t dmac_lo;
uint32_t dmac_hi :16;
uint32_t vlan :16;
};
#else
struct hermon_hw_udav_enet_s {
uint32_t force_lb :1;
uint32_t :1;
uint32_t cv :1;
uint32_t :3;
uint32_t portnum :2;
uint32_t pd :24;
uint32_t :9;
uint32_t smac_idx :7;
uint32_t :16;
uint32_t :9;
uint32_t mgid_index :7;
uint32_t :4;
uint32_t max_stat_rate :4;
uint32_t hop_limit :8;
uint32_t sl :4;
uint32_t tclass :8;
uint32_t flow_label :20;
uint64_t rgid_h;
uint64_t rgid_l;
uint32_t rsrv[2];
uint32_t vlan :16;
uint32_t dmac_hi :16;
uint32_t dmac_low;
};
#endif
/*
* Hermon Queue Pair Context Table (QPC) entries
* The QPC table is a virtually-contiguous memory area residing in HCA
* ICM. Each QPC entry is accessed for reads and writes
* by the HCA while executing work requests on the associated QP.
*
* The following structure is used in the RST2INIT_QP, INIT2INIT_QP,
* INIT2RTR_QP, RTR2RTS_QP, RTS2RTS_QP, SQERR2RTS_QP, TOERR_QP, RTS2SQD_QP,
* SQD2RTS_QP, TORST_QP, and QUERY_QP commands.
* With the exception of the QUERY_QP command, each of these commands reads
* from some portion of the QPC in the input mailbox and modified the QPC
* stored in the hardware. The QUERY_QP command retrieves a snapshot of a
* QPC entry. The command stores the snapshot in the output mailbox. The
* QPC state and its values are not affected by the QUERY_QP command.
*
* Below we first define the hermon_hw_addr_path_t or "Hermon Address Path"
* structure. This structure is used to provide address path information
* (both primary and secondary) for each QP context. Note: Since this
* structure is _very_ similar to the hermon_hw_udav_t structure above,
* we are able to leverage the similarity with filling in and reading from
* the two types of structures. See hermon_get_addr_path() and
* hermon_set_addr_path() in hermon_misc.c for more details.
*/
#if (DATAMODEL_NATIVE == DATAMODEL_LP64)
#pragma pack(4)
#endif
#ifdef _LITTLE_ENDIAN
struct hermon_hw_addr_path_s {
uint32_t rlid :16;
uint32_t mlid :7; /* mlid or SMAC idx */
uint32_t grh :1;
uint32_t cntr_idx :8;
uint32_t pkey_indx :7;
uint32_t :22;
uint32_t :1; /* but may be used for enet */
uint32_t cv :1;
uint32_t force_lb :1;
uint32_t flow_label :20;
uint32_t tclass :8;
uint32_t sniff_s_in :1;
uint32_t sniff_s_out :1;
uint32_t sniff_r_in :1;
uint32_t sniff_r_out :1; /* sniff-rcv-egress */
uint32_t hop_limit :8;
uint32_t max_stat_rate :4;
uint32_t :4;
uint32_t mgid_index :7;
uint32_t :1;
uint32_t link_type :3;
uint32_t ack_timeout :5;
uint64_t rgid_h;
uint64_t rgid_l;
uint32_t dmac_hi :16;
uint32_t :16;
uint32_t :8; /* but may be used for enet */
uint32_t sp :1;
uint32_t :2;
uint32_t fvl :1;
uint32_t fsip :1;
uint32_t fsm :1;
uint32_t :2;
uint32_t vlan_idx :7;
uint32_t :1;
uint32_t sched_q :8;
uint32_t dmac_lo :32;
};
#else
struct hermon_hw_addr_path_s {
uint32_t force_lb :1;
uint32_t cv :1;
uint32_t :1; /* but may be used for enet */
uint32_t :22;
uint32_t pkey_indx :7;
uint32_t cntr_idx :8;
uint32_t grh :1;
uint32_t mlid :7; /* mlid or SMAC idx */
uint32_t rlid :16;
uint32_t ack_timeout :5;
uint32_t link_type :3;
uint32_t :1;
uint32_t mgid_index :7;
uint32_t :4;
uint32_t max_stat_rate :4;
uint32_t hop_limit :8;
uint32_t sniff_r_out :1; /* sniff-rcv-egress */
uint32_t sniff_r_in :1;
uint32_t sniff_s_out :1;
uint32_t sniff_s_in :1;
uint32_t tclass :8;
uint32_t flow_label :20;
uint64_t rgid_h;
uint64_t rgid_l;
uint32_t sched_q :8;
uint32_t :1;
uint32_t vlan_idx :7;
uint32_t :2;
uint32_t fsm :1;
uint32_t fsip :1;
uint32_t fvl :1;
uint32_t :2;
uint32_t sp :1;
uint32_t :8; /* but may be used for enet */
uint32_t :16;
uint32_t dmac_hi :16;
uint32_t dmac_lo :32;
};
#endif /* LITTLE ENDIAN */
/* The addr path includes RSS fields for RSS QPs */
#ifdef _LITTLE_ENDIAN
struct hermon_hw_rss_s {
uint32_t rlid :16;
uint32_t mlid :7;
uint32_t grh :1;
uint32_t cntr_idx :8;
uint32_t pkey_indx :7;
uint32_t :22;
uint32_t :1; /* but may be used for enet */
uint32_t cv :1;
uint32_t force_lb :1;
uint32_t flow_label :20;
uint32_t tclass :8;
uint32_t sniff_s_in :1;
uint32_t sniff_s_out :1;
uint32_t sniff_r_in :1;
uint32_t sniff_r_out :1; /* sniff-rcv-egress */
uint32_t hop_limit :8;
uint32_t max_stat_rate :4;
uint32_t :4;
uint32_t mgid_index :7;
uint32_t :1;
uint32_t link_type :3;
uint32_t ack_timeout :5;
uint64_t rgid_h;
uint64_t rgid_l;
uint32_t base_qpn :24;
uint32_t log2_tbl_sz :4;
uint32_t :4;
uint32_t :8; /* but may be used for enet */
uint32_t sp :1;
uint32_t :2;
uint32_t fvl :1;
uint32_t fsip :1;
uint32_t fsm :1;
uint32_t :2;
uint32_t vlan_idx :7;
uint32_t :1;
uint32_t sched_q :8;
uint32_t :2;
uint32_t tcp_ipv6 :1;
uint32_t ipv6 :1;
uint32_t tcp_ipv4 :1;
uint32_t ipv4 :1;
uint32_t :2;
uint32_t hash_fn :2;
uint32_t :22;
uint32_t default_qpn :24;
uint32_t :8;
uint8_t rss_key[40];
};
#else /* BIG ENDIAN */
struct hermon_hw_rss_s {
uint32_t force_lb :1;
uint32_t cv :1;
uint32_t :1; /* but may be used for enet */
uint32_t :22;
uint32_t pkey_indx :7;
uint32_t cntr_idx :8;
uint32_t grh :1;
uint32_t mlid :7;
uint32_t rlid :16;
uint32_t ack_timeout :5;
uint32_t link_type :3;
uint32_t :1;
uint32_t mgid_index :7;
uint32_t :4;
uint32_t max_stat_rate :4;
uint32_t hop_limit :8;
uint32_t sniff_r_out :1; /* sniff-rcv-egress */
uint32_t sniff_r_in :1;
uint32_t sniff_s_out :1;
uint32_t sniff_s_in :1;
uint32_t tclass :8;
uint32_t flow_label :20;
uint64_t rgid_h;
uint64_t rgid_l;
uint32_t sched_q :8;
uint32_t :1;
uint32_t vlan_idx :7;
uint32_t :2;
uint32_t fsm :1;
uint32_t fsip :1;
uint32_t fvl :1;
uint32_t :2;
uint32_t sp :1;
uint32_t :8; /* but may be used for enet */
uint32_t :4;
uint32_t log2_tbl_sz :4;
uint32_t base_qpn :24;
uint32_t :8;
uint32_t default_qpn :24;
uint32_t :22;
uint32_t hash_fn :2;
uint32_t :2;
uint32_t ipv4 :1;
uint32_t tcp_ipv4 :1;
uint32_t ipv6 :1;
uint32_t tcp_ipv6 :1;
uint32_t :2;
uint8_t rss_key[40];
};
#endif /* LITTLE ENDIAN */
#if (DATAMODEL_NATIVE == DATAMODEL_LP64)
#pragma pack()
#endif
#if (DATAMODEL_NATIVE == DATAMODEL_LP64)
#pragma pack(4)
#endif
#ifdef _LITTLE_ENDIAN
struct hermon_hw_qpc_s {
uint32_t pd :24;
uint32_t :8;
uint32_t :11;
uint32_t pm_state :2;
uint32_t rss :1;
uint32_t :2;
uint32_t serv_type :8;
uint32_t :4;
uint32_t state :4;
uint32_t usr_page :24;
uint32_t :8;
uint32_t :4;
uint32_t rlky :1;
uint32_t :3;
uint32_t log_sq_stride :3;
uint32_t log_sq_size :4;
uint32_t sq_no_prefetch :1;
uint32_t log_rq_stride :3;
uint32_t log_rq_size :4;
uint32_t :1;
uint32_t msg_max :5;
uint32_t mtu :3;
uint32_t rem_qpn :24;
uint32_t :8;
uint32_t loc_qpn :24;
uint32_t :8;
hermon_hw_addr_path_t pri_addr_path;
hermon_hw_addr_path_t alt_addr_path;
uint32_t :32;
uint32_t :5;
uint32_t cur_retry_cnt :3;
uint32_t cur_rnr_retry :3;
uint32_t fre :1;
uint32_t :1;
uint32_t rnr_retry :3;
uint32_t retry_cnt :3;
uint32_t :2;
uint32_t sra_max :3;
uint32_t :4;
uint32_t ack_req_freq :4;
uint32_t cqn_snd :24;
uint32_t :8;
uint32_t next_snd_psn :24;
uint32_t :8;
uint32_t :32;
uint32_t :32;
uint32_t ssn :24;
uint32_t :8;
uint32_t last_acked_psn :24;
uint32_t :8;
uint32_t next_rcv_psn :24;
uint32_t min_rnr_nak :5;
uint32_t :3;
uint32_t :4;
uint32_t ric :1;
uint32_t :1;
uint32_t page_offs :6;
uint32_t :1;
uint32_t rae :1;
uint32_t rwe :1;
uint32_t rre :1;
uint32_t :5;
uint32_t rra_max :3;
uint32_t :8;
uint32_t cqn_rcv :24;
uint32_t :8;
uint32_t xrcd :16;
uint32_t :16;
uint32_t :2;
uint32_t dbr_addrl :30;
uint32_t dbr_addrh :32;
uint32_t srq_number :24;
uint32_t srq_en :1;
uint32_t :7;
uint32_t qkey;
uint32_t sq_wqe_counter :16;
uint32_t rq_wqe_counter :16;
uint32_t rmsn :24;
uint32_t :8;
uint32_t rsrv0[2];
/* new w/ hermon */
uint32_t base_mkey :24; /* bits 32-8, low 7 m/b 0 */
uint32_t num_rmc_peers :8;
uint32_t rmc_parent_qpn :24;
uint32_t header_sep :1;
uint32_t inline_scatter :1; /* m/b 0 for srq */
uint32_t :1;
uint32_t rmc_enable :2;
uint32_t :2; /* may use one bit for enet */
uint32_t mkey_remap :1;
uint32_t :3;
uint32_t mtt_base_addrl :29;
uint32_t mtt_base_addrh :8;
uint32_t :16;
uint32_t log2_pgsz :6;
uint32_t :2;
uint32_t exch_base :16;
uint32_t exch_size :4;
uint32_t :12;
uint32_t vft_vf_id :12;
uint32_t vft_prior :3;
uint32_t :16;
uint32_t ve :1;
uint32_t :32;
uint32_t :16;
uint32_t my_fc_id_idx :8;
uint32_t vft_hop_cnt :8;
uint32_t rsvd[8];
};
#else /* BIG ENDIAN */
struct hermon_hw_qpc_s {
uint32_t state :4;
uint32_t :4;
uint32_t serv_type :8;
uint32_t :2;
uint32_t rss :1;
uint32_t pm_state :2;
uint32_t :11;
uint32_t :8;
uint32_t pd :24;
uint32_t mtu :3;
uint32_t msg_max :5;
uint32_t :1;
uint32_t log_rq_size :4;
uint32_t log_rq_stride :3;
uint32_t sq_no_prefetch :1;
uint32_t log_sq_size :4;
uint32_t log_sq_stride :3;
uint32_t :3;
uint32_t rlky :1;
uint32_t :4;
uint32_t :8;
uint32_t usr_page :24;
uint32_t :8;
uint32_t loc_qpn :24;
uint32_t :8;
uint32_t rem_qpn :24;
hermon_hw_addr_path_t pri_addr_path;
hermon_hw_addr_path_t alt_addr_path;
uint32_t ack_req_freq :4;
uint32_t :4;
uint32_t sra_max :3;
uint32_t :2;
uint32_t retry_cnt :3;
uint32_t rnr_retry :3;
uint32_t :1;
uint32_t fre :1;
uint32_t cur_rnr_retry :3;
uint32_t cur_retry_cnt :3;
uint32_t :5;
uint32_t :32;
uint32_t :8;
uint32_t next_snd_psn :24;
uint32_t :8;
uint32_t cqn_snd :24;
uint32_t :32;
uint32_t :32;
uint32_t :8;
uint32_t last_acked_psn :24;
uint32_t :8;
uint32_t ssn :24;
uint32_t :8;
uint32_t rra_max :3;
uint32_t :5;
uint32_t rre :1;
uint32_t rwe :1;
uint32_t rae :1;
uint32_t :1;
uint32_t page_offs :6;
uint32_t :1;
uint32_t ric :1;
uint32_t :4;
uint32_t :3;
uint32_t min_rnr_nak :5;
uint32_t next_rcv_psn :24;
uint32_t :16;
uint32_t xrcd :16;
uint32_t :8;
uint32_t cqn_rcv :24;
uint32_t dbr_addrh :32;
uint32_t dbr_addrl :30;
uint32_t :2;
uint32_t qkey;
uint32_t :7;
uint32_t srq_en :1;
uint32_t srq_number :24;
uint32_t :8;
uint32_t rmsn :24;
uint32_t rq_wqe_counter :16;
uint32_t sq_wqe_counter :16;
uint32_t rsrv0[2];
/* new w/ hermon */
uint32_t mkey_remap :1;
uint32_t :2; /* may use one bit for enet */
uint32_t rmc_enable :2;
uint32_t :1;
uint32_t inline_scatter :1; /* m/b 0 for srq */
uint32_t header_sep :1;
uint32_t rmc_parent_qpn :24;
uint32_t num_rmc_peers :8;
uint32_t base_mkey :24; /* bits 32-8, low 7 m/b 0 */
uint32_t :2;
uint32_t log2_pgsz :6;
uint32_t :16;
uint32_t mtt_base_addrh :8;
uint32_t mtt_base_addrl :29;
uint32_t :3;
uint32_t ve :1;
uint32_t :16;
uint32_t vft_prior :3;
uint32_t vft_vf_id :12;
uint32_t :12;
uint32_t exch_size :4;
uint32_t exch_base :16;
uint32_t vft_hop_cnt :8;
uint32_t my_fc_id_idx :8;
uint32_t :16;
uint32_t :32;
uint32_t rsvd[8];
};
#endif /* LITTLE ENDIAN */
#if (DATAMODEL_NATIVE == DATAMODEL_LP64)
#pragma pack()
#endif
#define HERMON_QP_RESET 0x0
#define HERMON_QP_INIT 0x1
#define HERMON_QP_RTR 0x2
#define HERMON_QP_RTS 0x3
#define HERMON_QP_SQERR 0x4
#define HERMON_QP_SQD 0x5
#define HERMON_QP_ERR 0x6
#define HERMON_QP_SQDRAINING 0x7
#define HERMON_QP_RC 0x0
#define HERMON_QP_UC 0x1
#define HERMON_QP_UD 0x3
#define HERMON_QP_FCMND 0x4
#define HERMON_QP_FEXCH 0x5
#define HERMON_QP_XRC 0x6
#define HERMON_QP_MLX 0x7
#define HERMON_QP_RFCI 0x9
#define HERMON_QP_PMSTATE_MIGRATED 0x3
#define HERMON_QP_PMSTATE_ARMED 0x0
#define HERMON_QP_PMSTATE_REARM 0x1
#define HERMON_QP_DESC_EVT_DISABLED 0x0
#define HERMON_QP_DESC_EVT_ENABLED 0x1
#define HERMON_QP_FLIGHT_LIM_UNLIMITED 0xF
#define HERMON_QP_SQ_ALL_SIGNALED 0x1
#define HERMON_QP_SQ_WR_SIGNALED 0x0
#define HERMON_QP_RQ_ALL_SIGNALED 0x1
#define HERMON_QP_RQ_WR_SIGNALED 0x0
#define HERMON_QP_SRQ_ENABLED 0x1
#define HERMON_QP_SRQ_DISABLED 0x0
#define HERMON_QP_WQE_BASE_SHIFT 0x6
/*
* Hermon Multicast Group Member (MCG)
* Hermon MCG are organized in a virtually-contiguous memory table (the
* Multicast Group Table) in the ICM. This table is
* actually comprised of two consecutive tables: the Multicast Group Hash
* Table (MGHT) and the Additional Multicast Group Members Table (AMGM).
* Each such entry contains an MGID and a list of QPs that are attached to
* the multicast group. Each such entry may also include an index to an
* Additional Multicast Group Member Table (AMGM) entry. The AMGMs are
* used to form a linked list of MCG entries that all map to the same hash
* value. The MCG entry size is configured through the INIT_HCA command.
* Note: An MCG actually consists of a single hermon_hw_mcg_t and some
* number of hermon_hw_mcg_qp_list_t (such that the combined structure is a
* power-of-2).
*
* The following structures are used in the READ_MGM and WRITE_MGM commands.
* The READ_MGM command reads an MCG entry from the multicast table and
* returns it in the output mailbox. Note: This operation does not affect
* the MCG entry state or values.
* The WRITE_MGM command retrieves an MCG entry from the input mailbox and
* stores it in the multicast group table at the index specified in the
* command. Once the command has finished execution, the multicast group
* table is updated. The old entry contents are lost.
*/
#ifdef _LITTLE_ENDIAN
struct hermon_hw_mcg_s {
uint32_t member_cnt :24;
uint32_t :6;
uint32_t protocol :2;
uint32_t :6;
uint32_t next_gid_indx :26;
uint32_t :32;
uint32_t :32;
uint64_t mgid_h;
uint64_t mgid_l;
};
#else
struct hermon_hw_mcg_s {
uint32_t next_gid_indx :26;
uint32_t :6;
uint32_t protocol :2;
uint32_t :6;
uint32_t member_cnt :24;
uint32_t :32;
uint32_t :32;
uint64_t mgid_h;
uint64_t mgid_l;
};
#endif
#ifdef _LITTLE_ENDIAN
struct hermon_hw_mcg_en_s {
uint32_t member_cnt :24;
uint32_t :6;
uint32_t protocol :2;
uint32_t :6;
uint32_t next_gid_indx :26;
uint32_t :32;
uint32_t :32;
uint32_t vlan_present :1;
uint32_t :31;
uint32_t :32;
uint32_t mac_lo :32;
uint32_t mac_hi :16;
uint32_t vlan_id :12;
uint32_t vlan_cfi :1;
uint32_t vlan_prior :3;
};
#else
struct hermon_hw_mcg_en_s {
uint32_t next_gid_indx :26;
uint32_t :6;
uint32_t protocol :2;
uint32_t :6;
uint32_t member_cnt :24;
uint32_t :32;
uint32_t :32;
uint32_t :32;
uint32_t :31;
uint32_t vlan_present :1;
uint32_t vlan_prior :3;
uint32_t vlan_cfi :1;
uint32_t vlan_id :12;
uint32_t mac_hi :16;
uint32_t mac_lo :32;
};
#endif
/* Multicast Group Member - QP List entries */
#ifdef _LITTLE_ENDIAN
struct hermon_hw_mcg_qp_list_s {
uint32_t qpn :24;
uint32_t :6;
uint32_t blk_lb :1;
uint32_t :1;
};
#else
struct hermon_hw_mcg_qp_list_s {
uint32_t :1;
uint32_t blk_lb :1;
uint32_t :6;
uint32_t qpn :24;
};
#endif
#define HERMON_MCG_QPN_BLOCK_LB 0x40000000
/*
* ETHERNET ONLY Commands
* The follow are new commands, used only for an Ethernet Port
*/
#ifdef _LITTLE_ENDIAN
struct hermon_hw_set_mcast_fltr_s {
uint32_t mac_lo;
uint32_t mac_hi :16;
uint32_t :15;
uint32_t sfs :1;
};
#else /* BIG ENDIAN */
struct hermon_hw_set_mcast_fltr_s {
uint32_t sfs :1;
uint32_t :15;
uint32_t mac_hi :16;
uint32_t mac_lo;
};
#endif
/* opmod for set_mcast_fltr */
#define HERMON_SET_MCAST_FLTR_CONF 0x0
#define HERMON_SET_MCAST_FLTR_DIS 0x1
#define HERMON_SET_MCAST_FLTR_EN 0x2
/*
* FC Command structures
*/
#ifdef _LITTLE_ENDIAN
struct hermon_hw_config_fc_basic_s {
uint32_t n_p :2;
uint32_t :6;
uint32_t n_v :3;
uint32_t :5;
uint32_t n_m :4;
uint32_t :12;
uint32_t :16;
uint32_t fexch_base_hi :8;
uint32_t :8;
uint32_t rfci_base :24;
uint32_t log2_num_rfci :3;
uint32_t :5;
uint32_t fx_base_mpt_lo :8;
uint32_t :17;
uint32_t fx_base_mpt_hi :7;
uint32_t fcoe_prom_qpn :24;
uint32_t uint32_t :8;
uint32_t :32;
uint32_t rsrv[58];
};
#else
struct hermon_hw_config_fc_basic_s {
uint32_t :8;
uint32_t fexch_base_hi :8;
uint32_t :16;
uint32_t :12;
uint32_t n_m :4;
uint32_t :5;
uint32_t n_v :3;
uint32_t :6;
uint32_t n_p :2;
uint32_t fx_base_mpt_hi :7;
uint32_t :17;
uint32_t fx_base_mpt_lo :8;
uint32_t :5;
uint32_t log2_num_rfci :3;
uint32_t rfci_base :24;
uint32_t :32;
uint32_t uint32_t :8;
uint32_t fcoe_prom_qpn :24;
uint32_t rsrv[58];
};
#endif
#define HERMON_HW_FC_PORT_ENABLE 0x0
#define HERMON_HW_FC_PORT_DISABLE 0x1
#define HERMON_HW_FC_CONF_BASIC 0x0000
#define HERMON_HW_FC_CONF_NPORT 0x0100
#ifdef _LITTLE_ENDIAN
struct hermon_hw_query_fc_s {
uint32_t :32;
uint32_t log2_max_rfci :3;
uint32_t :5;
uint32_t log2_max_fexch :5;
uint32_t :3;
uint32_t log2_max_nports :3;
uint32_t :13;
uint32_t rsrv[62];
};
#else
struct hermon_hw_query_fc_s {
uint32_t :13;
uint32_t log2_max_nports :3;
uint32_t :3;
uint32_t log2_max_fexch :5;
uint32_t :5;
uint32_t log2_max_rfci :3;
uint32_t :32;
uint32_t rsrv[62];
};
#endif
/* ARM_RQ - limit water mark for srq & rq */
#ifdef _LITTLE_ENDIAN
struct hermon_hw_arm_req_s {
uint32_t lwm :16;
uint32_t :16;
uint32_t :32;
};
#else
struct hermon_hw_arm_req_s {
uint32_t :32;
uint32_t :16;
uint32_t lwm :16;
};
#endif
/*
* Structure for getting the peformance counters from the HCA
*/
#ifdef _LITTLE_ENDIAN
struct hermon_hw_sm_perfcntr_s {
uint32_t linkdown :8;
uint32_t linkerrrec :8;
uint32_t symerr :16;
uint32_t cntrsel :16;
uint32_t portsel :8;
uint32_t :8;
uint32_t portxmdiscard :16;
uint32_t portrcvswrelay :16;
uint32_t portrcvrem :16;
uint32_t portrcv :16;
uint32_t vl15drop :16;
uint32_t :16;
uint32_t xsbuffovrun :4;
uint32_t locallinkint :4;
uint32_t :8;
uint32_t portrcconstr :8;
uint32_t portxmconstr :8;
uint32_t portrcdata;
uint32_t portxmdata;
uint32_t portrcpkts;
uint32_t portxmpkts;
uint32_t reserved;
uint32_t portxmwait;
};
#else /* BIG ENDIAN */
struct hermon_hw_sm_perfcntr_s {
uint32_t :8;
uint32_t portsel :8;
uint32_t cntrsel :16;
uint32_t symerr :16;
uint32_t linkerrrec :8;
uint32_t linkdown :8;
uint32_t portrcv :16;
uint32_t portrcvrem :16;
uint32_t portrcvswrelay :16;
uint32_t portxmdiscard :16;
uint32_t portxmconstr :8;
uint32_t portrcconstr :8;
uint32_t :8;
uint32_t locallinkint :4;
uint32_t xsbuffovrun :4;
uint32_t :16;
uint32_t vl15drop :16;
uint32_t portxmdata;
uint32_t portrcdata;
uint32_t portxmpkts;
uint32_t portrcpkts;
uint32_t portxmwait;
uint32_t reserved;
};
#endif
/*
* Structure for getting the extended peformance counters from the HCA
*/
#ifdef _LITTLE_ENDIAN
struct hermon_hw_sm_extperfcntr_s {
uint32_t rsvd;
uint32_t cntrsel :16;
uint32_t portsel :8;
uint32_t :8;
uint64_t portxmdata;
uint64_t portrcdata;
uint64_t portxmpkts;
uint64_t portrcpkts;
uint64_t portunicastxmpkts;
uint64_t portunicastrcpkts;
uint64_t portmulticastxmpkts;
uint64_t portmulticastrcpkts;
};
#else /* BIG ENDIAN */
struct hermon_hw_sm_extperfcntr_s {
uint32_t :8;
uint32_t portsel :8;
uint32_t cntrsel :16;
uint32_t rsvd;
uint64_t portxmdata;
uint64_t portrcdata;
uint64_t portxmpkts;
uint64_t portrcpkts;
uint64_t portunicastxmpkts;
uint64_t portunicastrcpkts;
uint64_t portmulticastxmpkts;
uint64_t portmulticastrcpkts;
};
#endif
/*
* Hermon User Access Region (UAR)
*
* JBDB : writeup on the UAR for memfree
*
* JBDB : writeup on the structures
* UAR page
* DB register
* DB record
* UCE
*
* [es] and change it even further for hermon
* the whole UAR and doorbell record (dbr) approach is changed again
* from arbel, and needs commenting
*
* -- Tavor comment
*
*
* Tavor doorbells are each rung by writing to the doorbell registers that
* form a User Access Region (UAR). A doorbell is a write-only hardware
* register which enables passing information from software to hardware
* with minimum software latency. A write operation from the host software
* to these doorbell registers passes information about the HCA resources
* and initiates processing of the doorbell data. There are 6 types of
* doorbells in Tavor.
*
* "Send Doorbell" for synchronizing the attachment of a WQE (or a chain
* of WQEs) to the send queue.
* "RD Send Doorbell" (Same as above, except for RD QPs) is not supported.
* "Receive Doorbell" for synchronizing the attachment of a WQE (or a chain
* of WQEs) to the receive queue.
* "CQ Doorbell" for updating the CQ consumer index and requesting
* completion notifications.
* "EQ Doorbell" for updating the EQ consumer index, arming interrupt
* triggering, and disarming CQ notification requests.
* "InfiniBlast" (which would have enabled access to the "InfiniBlast
* buffer") is not supported.
*
* Note: The tavor_hw_uar_t below is the container for all of the various
* doorbell types. Below we first define several structures which make up
* the contents of those doorbell types.
*
* Note also: The following structures are not #define'd with both little-
* endian and big-endian definitions. This is because each doorbell type
* is not directly accessed except through a single ddi_put64() operation
* (see tavor_qp_send_doorbell, tavor_qp_recv_doorbell, tavor_cq_doorbell,
* or tavor_eq_doorbell)
*/
/*
* Send doorbell register structure
*/
typedef struct hermon_hw_send_db_reg_s {
uint32_t :32;
uint32_t snd_q_num :24;
uint32_t :8;
} hermon_hw_send_db_reg_t;
#define HERMON_QPSNDDB_QPN_SHIFT 0x8
/* Max descriptors per Hermon doorbell */
#define HERMON_QP_MAXDESC_PER_DB 256
/*
* CQ doorbell register structure
*/
typedef struct hermon_hw_cq_db_reg_s {
uint32_t :2;
uint32_t cmd_sn :2;
uint32_t :2;
uint32_t cmd :2;
uint32_t cqn :24;
uint32_t :8;
/* consumer cntr of last polled completion */
uint32_t cq_ci :24;
} hermon_hw_cq_db_reg_t;
#define HERMON_CQDB_CMD_SHIFT 0x18 /* dec 24 */
#define HERMON_CQDB_CMDSN_SHIFT 0x1C /* dec 28 */
#define HERMON_CQDB_NOTIFY_CQ 0x02
#define HERMON_CQDB_NOTIFY_CQ_SOLICIT 0x01
/* Default value for use in NOTIFY_CQ doorbell */
#define HERMON_CQDB_DEFAULT_PARAM 0xFFFFFFFF
typedef struct hermon_hw_guest_eq_ci_s { /* guest op eq consumer index */
uint32_t armed :1;
uint32_t :7;
uint32_t guestos_ci :24;
uint32_t :32;
} hermon_hw_guest_eq_ci_t;
/*
* UAR page structure, containing all doorbell registers
*/
struct hermon_hw_uar_s {
uint32_t rsrv0[4];
hermon_hw_send_db_reg_t send;
uint32_t rsrv1[2];
hermon_hw_cq_db_reg_t cq;
uint32_t rsrv2[502]; /* next is at offset 0x800 */
hermon_hw_guest_eq_ci_t g_eq0;
hermon_hw_guest_eq_ci_t g_eq1;
hermon_hw_guest_eq_ci_t g_eq2;
hermon_hw_guest_eq_ci_t g_eq3;
uint32_t rsrv3[504]; /* end of page */
};
/*
* QP (RQ, SRQ) doorbell record-specific data
* Note that this structure is NOT in ICM, but just kept in host memory
* and managed independently of PRM or other constraints. Also, though
* the qp/srq doorbell need to be only 4 bytes, it is 8 bytes in memory for
* ease of management. Hermon defines its usage in the QP chapter.
*/
typedef struct hermon_hw_qp_db_s {
uint32_t :16;
uint32_t rcv_wqe_cntr :16; /* wqe_counter */
uint32_t :32;
} hermon_hw_qp_db_t;
/*
* CQ (ARM and SET_CI) doorbell record-specific data
* See comment above re: QP doorbell. This dbr is 8 bytes long, and its
* usage is defined in PRM chapter on Completion Queues
*/
typedef struct hermon_hw_cq_arm_db_s {
uint32_t :8;
uint32_t update_ci :24;
uint32_t :2;
/* sequence number of the doorbell ring % 4 */
uint32_t cmd_sn :2;
uint32_t :1;
uint32_t cmd :3; /* command */
uint32_t cq_ci :24;
} hermon_hw_cq_db_t;
#define HERMON_CQ_DB_CMD_SOLICTED 0x01
#define HERMON_CQ_DB_CMD_NEXT 0x02
/*
* Hermon Blue Flame (BF)
* Hermon has the ability to do a low-latency write of successive WQEs
* for the HCA. This utilizes part of the memory area behind the
* same BAR as the UAR page (see above) - half the area is devoted to
* UAR pages, the other half to BlueFlame (though in fairness, the return
* information from QUERY_DEV_CAP should be consulted _in case_ they ever
* decide to change it.
*
* We define the structures to access them below.
*/
/*
* Hermon Send Work Queue Element (WQE)
* A Hermon Send WQE is built of the following segments, each of which is a
* multiple of 16 bytes. Note: Each individual WQE may contain only a
* subset of these segments described below (according to the operation type
* and transport type of the QP).
*
* The first 16 bytes of ever WQE are formed from the "Ctrl" segment.
* This segment contains the address of the next WQE to be executed and the
* information required in order to allocate the resources to execute the
* next WQE. The "Ctrl" part of this segment contains the control
* information required to execute the WQE, including the opcode and other
* control information.
* The "Datagram" segment contains address information required in order to
* form a UD message.
* The "Bind" segment contains the parameters required for a Bind Memory
* Window operation.
* The "Remote Address" segment is present only in RDMA or Atomic WQEs and
* specifies remote virtual addresses and RKey, respectively. Length of
* the remote access is calculated from the scatter/gather list (for
* RDMA-write/RDMA-read) or set to eight (for Atomic).
* The "Atomic" segment is present only in Atomic WQEs and specifies
* Swap/Add and Compare data.
*
* Note: The following structures are not #define'd with both little-endian
* and big-endian definitions. This is because their individual fields are
* not directly accessed except through macros defined below.
*/
struct hermon_hw_snd_wqe_ctrl_s {
uint32_t owner :1;
uint32_t :1;
uint32_t nec :1;
uint32_t :5;
uint32_t fceof :8;
uint32_t :9;
uint32_t rr :1;
uint32_t :1;
uint32_t opcode :5;
uint32_t vlan :16;
uint32_t :1;
uint32_t cv :1;
uint32_t :7;
uint32_t fence :1;
uint32_t ds :6; /* WQE size in octowords */
/*
* XRC remote buffer if impl
* XRC 23:0, or DMAC 47:32& 8 bits of pad
*/
uint32_t xrc_rem_buf :24;
uint32_t so :1;
uint32_t fcrc :1; /* fc crc calc */
uint32_t tcp_udp :1; /* Checksumming */
uint32_t ip :1; /* Checksumming */
uint32_t cq_gen :2; /* 00=no cqe, 11= gen cqe */
/* s-bit set means solicit bit in last packet */
uint32_t s :1;
uint32_t force_lb :1;
/*
* immediate OR invalidation key OR DMAC 31:0 depending
*/
uint32_t immediate :32;
};
struct hermon_hw_srq_wqe_next_s {
uint32_t :16;
uint32_t next_wqe_idx :16;
uint32_t rsvd[3];
};
struct hermonw_hw_fcp3_ctrl_s {
uint32_t owner :1;
uint32_t :1;
uint32_t nec :1;
uint32_t :24;
uint32_t opcode :5;
uint32_t :24;
uint32_t sit :1;
uint32_t :1;
uint32_t ds :6;
uint32_t seq_id :8;
uint32_t info :4;
uint32_t :3;
uint32_t ls :1;
uint32_t :8;
uint32_t so :1;
uint32_t :3;
uint32_t cq_gen :2;
uint32_t :2;
uint32_t param :32;
};
struct hermon_hw_fcp3_init_s {
uint32_t :8;
uint32_t pe :1;
uint32_t :23;
uint32_t csctl_prior :8;
uint32_t seqid_tx :8;
uint32_t :6;
uint32_t mtu :10;
uint32_t rem_id :24;
uint32_t abort :2;
uint32_t :1;
uint32_t op :2;
uint32_t :1;
uint32_t org :1;
uint32_t :1;
uint32_t rem_exch :16;
uint32_t loc_exch_idx :16;
};
struct hermon_hw_fcmd_o_enet_s {
uint32_t :4;
uint32_t stat_rate :4;
uint32_t :24;
uint32_t :32;
uint32_t :16;
uint32_t dmac_hi :16;
uint32_t dmac_lo :32;
};
struct hermon_hw_fcmd_o_ib_s {
uint32_t :32;
uint32_t :8;
uint32_t grh :1;
uint32_t :7;
uint32_t rlid :16;
uint32_t :20;
uint32_t stat_rate :4;
uint32_t hop_limit :8;
uint32_t sl :4;
uint32_t tclass :8;
uint32_t flow_label :20;
uint64_t rgid_hi;
uint64_t rgid_lo;
uint32_t :8;
uint32_t rqp :24;
uint32_t rsrv[3];
};
#define HERMON_WQE_SEND_FENCE_MASK 0x40
#define HERMON_WQE_SEND_NOPCODE_NOP 0x00
#define HERMON_WQE_SEND_NOPCODE_SND_INV 0x01
#define HERMON_WQE_SEND_NOPCODE_RDMAW 0x8
#define HERMON_WQE_SEND_NOPCODE_RDMAWI 0x9
#define HERMON_WQE_SEND_NOPCODE_SEND 0xA
#define HERMON_WQE_SEND_NOPCODE_SENDI 0xB
#define HERMON_WQE_SEND_NOPCODE_INIT_AND_SEND 0xD
#define HERMON_WQE_SEND_NOPCODE_LSO 0xE
#define HERMON_WQE_SEND_NOPCODE_RDMAR 0x10
#define HERMON_WQE_SEND_NOPCODE_ATMCS 0x11
#define HERMON_WQE_SEND_NOPCODE_ATMFA 0x12
#define HERMON_WQE_SEND_NOPCODE_ATMCSE 0x14
#define HERMON_WQE_SEND_NOPCODE_ATMFAE 0x15
#define HERMON_WQE_SEND_NOPCODE_BIND 0x18
#define HERMON_WQE_SEND_NOPCODE_FRWR 0x19
#define HERMON_WQE_SEND_NOPCODE_LCL_INV 0x1B
#define HERMON_WQE_SEND_NOPCODE_CONFIG 0x1F /* for ccq only */
#define HERMON_WQE_FCP_OPCODE_INIT_AND_SEND 0xD
#define HERMON_WQE_FCP_OPCODE_INIT_FEXCH 0xC
#define HERMON_WQE_SEND_SIGNALED_MASK 0x0000000C00000000ull
#define HERMON_WQE_SEND_SOLICIT_MASK 0x0000000200000000ull
#define HERMON_WQE_SEND_IMMEDIATE_MASK 0x0000000100000000ull
struct hermon_hw_snd_wqe_ud_s {
struct hermon_hw_udav_s ud_addr_v;
uint32_t :8;
uint32_t dest_qp :24;
uint32_t qkey :32;
uint32_t vlan :16;
uint32_t dmac_hi :16;
uint32_t dmac_lo :32;
};
#define HERMON_WQE_SENDHDR_UD_AV_MASK 0xFFFFFFFFFFFFFFE0ull
#define HERMON_WQE_SENDHDR_UD_DQPN_MASK 0xFFFFFF
struct hermon_hw_snd_wqe_bind_s {
uint32_t ae :1;
uint32_t rw :1;
uint32_t rr :1;
uint32_t :3;
uint32_t l_64 :1;
uint32_t :25;
uint32_t win_t :1;
uint32_t z_base :1;
uint32_t :30;
uint32_t new_rkey;
uint32_t reg_lkey;
uint64_t addr;
uint64_t len;
};
#define HERMON_WQE_SENDHDR_BIND_ATOM 0x8000000000000000ull
#define HERMON_WQE_SENDHDR_BIND_WR 0x4000000000000000ull
#define HERMON_WQE_SENDHDR_BIND_RD 0x2000000000000000ull
struct hermon_hw_snd_wqe_lso_s {
uint32_t mss :16;
uint32_t :6;
uint32_t hdr_size :10;
};
struct hermon_hw_snd_wqe_remaddr_s {
uint64_t vaddr;
uint32_t rkey;
uint32_t :32;
};
struct hermon_hw_snd_wqe_atomic_s {
uint64_t swap_add;
uint64_t compare;
};
struct hermon_hw_snd_wqe_atomic_ext_s {
uint64_t swap_add;
uint64_t compare;
uint64_t swapmask;
uint64_t cmpmask;
};
struct hermon_hw_snd_wqe_local_inv_s {
uint32_t :6;
uint32_t atc_shoot :1;
uint32_t :25;
uint32_t :32;
uint32_t mkey;
uint32_t rsrv0;
uint32_t rsrv1;
uint32_t :25;
uint32_t guest_id :7; /* for atc shootdown */
uint32_t p_addrh;
uint32_t p_addrl :23;
uint32_t :9;
};
struct hermon_hw_snd_rem_addr_s {
uint64_t rem_vaddr;
uint32_t rkey;
uint32_t rsrv;
};
struct hermon_hw_snd_wqe_frwr_s {
uint32_t rem_atomic :1;
uint32_t rem_write :1;
uint32_t rem_read :1;
uint32_t loc_write :1;
uint32_t loc_read :1;
uint32_t fbo_en :1;
uint32_t len_64 :1;
uint32_t :2;
uint32_t dif :1; /* FCoIB */
uint32_t bind_en :1;
uint32_t blk_pg_mode :1;
uint32_t mtt_rep :4;
uint32_t :16;
uint32_t mkey; /* swapped w/ addrh relative to arbel */
uint64_t pbl_addr;
uint64_t start_addr;
uint64_t reg_len; /* w/ len_64 allows 65 bits of length */
uint32_t :11;
uint32_t fbo :21;
uint32_t :11;
uint32_t pge_blk_sz :21;
uint32_t rsrv0[2];
};
struct hermon_hw_snd_wqe_frwr_ext_s {
uint32_t dif_in_mem :1;
uint32_t dif_on_wire :1;
uint32_t valid_ref :1;
uint32_t valid_crc :1;
uint32_t repl_ref_tag :1;
uint32_t repl_app_tag :1;
uint32_t :10;
uint32_t app_mask :16;
uint32_t wire_app_tag :16;
uint32_t mem_app_tag :16;
uint32_t wire_ref_tag_base;
uint32_t mem_ref_tag_base;
};
/*
* Hermon "MLX transport" Work Queue Element (WQE)
* The format of the MLX WQE is similar to that of the Send WQE (above)
* with the following exceptions. MLX WQEs are used for sending MADs on
* special QPs 0 and 1. Everything following the "Next/Ctrl" header
* (defined below) consists of scatter-gather list entries. The contents
* of these SGLs (also defined below) will be put on the wire exactly as
* they appear in the buffers. In addition, the VCRC and the ICRC of each
* sent packet can be modified by changing values in the following header
* or in the payload of the packet itself.
*/
struct hermon_hw_mlx_wqe_nextctrl_s {
uint32_t owner :1;
uint32_t :23;
uint32_t :3;
uint32_t opcode :5; /* is 0x0A (send) for MLX */
uint32_t :26;
uint32_t ds :6; /* WQE size in octowords */
uint32_t :14;
uint32_t vl15 :1;
uint32_t slr :1;
uint32_t max_srate :4;
uint32_t sl :4;
uint32_t :3; /* FCoIB usage */
uint32_t icrc :1; /* 1==don't replace icrc fld */
uint32_t cq_gen :2; /* 00= no cqe, 11==cqe */
uint32_t :1;
uint32_t force_lb :1;
uint32_t rlid :16;
uint32_t :16;
};
#define HERMON_WQE_MLXHDR_VL15_MASK 0x0002000000000000ull
#define HERMON_WQE_MLXHDR_SLR_MASK 0x0001000000000000ull
#define HERMON_WQE_MLXHDR_SRATE_SHIFT 44
#define HERMON_WQE_MLXHDR_SL_SHIFT 40
#define HERMON_WQE_MLXHDR_SIGNALED_MASK 0x0000000800000000ull
#define HERMON_WQE_MLXHDR_RLID_SHIFT 16
/*
* Hermon Receive Work Queue Element (WQE)
* Unlike the Send WQE, the Receive WQE is built ONLY of 16-byte segments. A
* "Next/Ctrl" segment is no longer needed, because of the fixed
* receive queue stride (RQ.STRIDE). It contains just
* some number of scatter list entries for the incoming message.
*
* The format of the scatter-gather list entries is shown below. For
* Receive WQEs the "inline_data" field must be cleared (i.e. data segments
* cannot contain inline data).
*/
struct hermon_hw_wqe_sgl_s {
uint32_t inline_data :1;
uint32_t byte_cnt :31;
uint32_t lkey;
uint64_t addr;
};
#define HERMON_WQE_SGL_BYTE_CNT_MASK 0x7FFFFFFF
#define HERMON_WQE_SGL_INLINE_MASK 0x80000000
/*
* The following defines are used when building descriptors for special QP
* work requests (i.e. MLX transport WQEs). Note: Because Hermon MLX transport
* requires the driver to build actual IB packet headers, we use these defines
* for the most common fields in those headers.
*/
#define HERMON_MLX_VL15_LVER 0xF0000000
#define HERMON_MLX_VL0_LVER 0x00000000
#define HERMON_MLX_IPVER_TC_FLOW 0x60000000
#define HERMON_MLX_TC_SHIFT 20
#define HERMON_MLX_DEF_PKEY 0xFFFF
#define HERMON_MLX_GSI_QKEY 0x80010000
#define HERMON_MLX_UDSEND_OPCODE 0x64000000
#define HERMON_MLX_DQPN_MASK 0xFFFFFF
/*
* The following macros are used for building each of the individual
* segments that can make up a Hermon WQE. Note: We try not to use the
* structures (with their associated bitfields) here, instead opting to
* build and put 64-bit or 32-bit chunks to the WQEs as appropriate,
* primarily because using the bitfields appears to force more read-modify-
* write operations.
*
* HERMON_WQE_BUILD_UD - Builds Unreliable Datagram Segment
*
* HERMON_WQE_BUILD_REMADDR - Builds Remote Address Segment using
* RDMA info from the work request
* HERMON_WQE_BUILD_RC_ATOMIC_REMADDR - Builds Remote Address Segment
* for RC Atomic work requests
* HERMON_WQE_BUILD_ATOMIC - Builds Atomic Segment using atomic
* info from the work request
* HERMON_WQE_BUILD_BIND - Builds the Bind Memory Window
* Segment using bind info from the
* work request
* HERMON_WQE_BUILD_DATA_SEG - Builds the individual Data Segments
* for Send, Receive, and MLX WQEs
* HERMON_WQE_BUILD_INLINE - Builds an "inline" Data Segment
* (primarily for MLX transport)
* HERMON_WQE_BUILD_INLINE_ICRC - Also builds an "inline" Data Segment
* (but used primarily in the ICRC
* portion of MLX transport WQEs)
* HERMON_WQE_LINKNEXT - Links the current WQE to the
* previous one
* HERMON_WQE_LINKFIRST - Links the first WQE on the current
* chain to the previous WQE
* HERMON_WQE_BUILD_MLX_LRH - Builds the inline LRH header for
* MLX transport MADs
* HERMON_WQE_BUILD_MLX_GRH - Builds the inline GRH header for
* MLX transport MADs
* HERMON_WQE_BUILD_MLX_BTH - Builds the inline BTH header for
* MLX transport MADs
* HERMON_WQE_BUILD_MLX_DETH - Builds the inline DETH header for
* MLX transport MADs
*/
#define HERMON_WQE_BUILD_UD(qp, ud, ah, dest) \
{ \
uint64_t *tmp; \
uint64_t *udav; \
\
tmp = (uint64_t *)(ud); \
udav = (uint64_t *)(ah)->ah_udav; \
tmp[0] = ntohll(udav[0]); \
tmp[1] = ntohll(udav[1]); \
tmp[2] = ntohll(udav[2]); \
tmp[3] = ntohll(udav[3]); \
tmp[4] = ntohll((((uint64_t)((dest)->ud_dst_qpn & \
HERMON_WQE_SENDHDR_UD_DQPN_MASK) << 32) | \
(dest)->ud_qkey)); \
tmp[5] = 0; \
}
#define HERMON_WQE_BUILD_LSO(qp, ds, mss, hdr_sz) \
*(uint32_t *)(ds) = htonl(((mss) << 16) | hdr_sz);
#define HERMON_WQE_BUILD_REMADDR(qp, ra, wr_rdma) \
{ \
uint64_t *tmp; \
\
tmp = (uint64_t *)(ra); \
tmp[0] = htonll((wr_rdma)->rdma_raddr); \
tmp[1] = htonll((uint64_t)(wr_rdma)->rdma_rkey << 32); \
}
#define HERMON_WQE_BUILD_RC_ATOMIC_REMADDR(qp, rc, wr) \
{ \
uint64_t *tmp; \
\
tmp = (uint64_t *)(rc); \
tmp[0] = htonll((wr)->wr.rc.rcwr.atomic->atom_raddr); \
tmp[1] = htonll((uint64_t)(wr)->wr.rc.rcwr.atomic->atom_rkey << 32); \
}
#define HERMON_WQE_BUILD_ATOMIC(qp, at, wr_atom) \
{ \
uint64_t *tmp; \
\
tmp = (uint64_t *)(at); \
tmp[0] = htonll((wr_atom)->atom_arg2); \
tmp[1] = htonll((wr_atom)->atom_arg1); \
}
#define HERMON_WQE_BUILD_BIND(qp, bn, wr_bind) \
{ \
uint64_t *tmp; \
uint64_t bn0_tmp; \
ibt_bind_flags_t bind_flags; \
\
tmp = (uint64_t *)(bn); \
bind_flags = (wr_bind)->bind_flags; \
bn0_tmp = (bind_flags & IBT_WR_BIND_ATOMIC) ? \
HERMON_WQE_SENDHDR_BIND_ATOM : 0; \
bn0_tmp |= (bind_flags & IBT_WR_BIND_WRITE) ? \
HERMON_WQE_SENDHDR_BIND_WR : 0; \
bn0_tmp |= (bind_flags & IBT_WR_BIND_READ) ? \
HERMON_WQE_SENDHDR_BIND_RD : 0; \
tmp[0] = htonll(bn0_tmp); \
tmp[1] = htonll(((uint64_t)(wr_bind)->bind_rkey_out << 32) | \
(wr_bind)->bind_lkey); \
tmp[2] = htonll((wr_bind)->bind_va); \
tmp[3] = htonll((wr_bind)->bind_len); \
}
#define HERMON_WQE_BUILD_FRWR(qp, frwr_arg, pmr_arg) \
{ \
ibt_mr_flags_t flags; \
ibt_lkey_t lkey; \
ibt_wr_reg_pmr_t *pmr = (pmr_arg); \
uint64_t *frwr64 = (uint64_t *)(frwr_arg); \
\
flags = pmr->pmr_flags; \
((uint32_t *)frwr64)[0] = htonl(0x08000000 | \
((flags & IBT_MR_ENABLE_REMOTE_ATOMIC) ? 0x80000000 : 0) | \
((flags & IBT_MR_ENABLE_REMOTE_WRITE) ? 0x40000000 : 0) | \
((flags & IBT_MR_ENABLE_REMOTE_READ) ? 0x20000000 : 0) | \
((flags & IBT_MR_ENABLE_LOCAL_WRITE) ? 0x10000000 : 0) | \
((flags & IBT_MR_ENABLE_WINDOW_BIND) ? 0x00200000 : 0)); \
lkey = (pmr->pmr_lkey & ~0xff) | pmr->pmr_key; \
pmr->pmr_rkey = pmr->pmr_lkey = lkey; \
((uint32_t *)frwr64)[1] = htonl(lkey); \
frwr64[1] = htonll(pmr->pmr_addr_list->p_laddr); \
frwr64[2] = htonll(pmr->pmr_iova); \
frwr64[3] = htonll(pmr->pmr_len); \
((uint32_t *)frwr64)[8] = htonl(pmr->pmr_offset); \
((uint32_t *)frwr64)[9] = htonl(pmr->pmr_buf_sz); \
frwr64[5] = 0; \
}
#define HERMON_WQE_BUILD_LI(qp, li_arg, wr_li) \
{ \
uint64_t *li64 = (uint64_t *)(void *)(li_arg); \
\
li64[0] = 0; \
((uint32_t *)li64)[2] = htonl((wr_li)->li_rkey); \
((uint32_t *)li64)[3] = 0; \
li64[2] = 0; \
li64[3] = 0; \
}
#define HERMON_WQE_BUILD_FCP3_INIT(ds, fctl, cs_pri, seq_id, mtu, \
dest_id, op, rem_exch, local_exch_idx) \
{ \
uint32_t *fc_init; \
\
fc_init = (uint32_t *)ds; \
fc_init[1] = htonl((cs_pri) << 24 | (seq_id) << 16 | (mtu)); \
fc_init[2] = htonl((dest_id) << 8 | \
IBT_FCTL_GET_ABORT_FIELD(fctl) << 6 | (op) << 3 | 0x2); \
fc_init[3] = htonl((rem_exch) << 16 | (local_exch_idx)); \
membar_producer(); /* fc_init[0] is where the stamping is */ \
fc_init[0] = htonl(((fctl) & IBT_FCTL_PRIO) << 6); \
}
#define HERMON_WQE_BUILD_DATA_SEG_RECV(ds, sgl) \
{ \
uint64_t *tmp; \
\
tmp = (uint64_t *)(ds); \
tmp[0] = htonll((((uint64_t)((sgl)->ds_len & \
HERMON_WQE_SGL_BYTE_CNT_MASK) << 32) | (sgl)->ds_key)); \
tmp[1] = htonll((sgl)->ds_va); \
}
#define HERMON_WQE_BUILD_DATA_SEG_SEND(ds, sgl) \
{ \
((uint64_t *)(ds))[1] = htonll((sgl)->ds_va); \
((uint32_t *)(ds))[1] = htonl((sgl)->ds_key); \
membar_producer(); \
((uint32_t *)(ds))[0] = \
htonl((sgl)->ds_len & HERMON_WQE_SGL_BYTE_CNT_MASK); \
}
#define HERMON_WQE_BUILD_INLINE(qp, ds, sz) \
*(uint32_t *)(ds) = htonl(HERMON_WQE_SGL_INLINE_MASK | (sz))
#define HERMON_WQE_BUILD_INLINE_ICRC(qp, ds, sz, icrc) \
{ \
uint32_t *tmp; \
\
tmp = (uint32_t *)(ds); \
tmp[1] = htonl(icrc); \
membar_producer(); \
tmp[0] = htonl(HERMON_WQE_SGL_INLINE_MASK | (sz)); \
}
#define HERMON_WQE_SET_CTRL_SEGMENT(desc, desc_sz, fence, \
imm, sol, sig, cksum, qp, strong, fccrc) \
{ \
uint32_t *tmp; \
uint32_t cntr_tmp; \
\
/* do not set the first dword (owner/opcode) here */ \
tmp = (uint32_t *)desc; \
cntr_tmp = (fence << 6) | desc_sz; \
tmp[1] = ntohl(cntr_tmp); \
cntr_tmp = strong | fccrc | sol | sig | cksum; \
tmp[2] = ntohl(cntr_tmp); \
tmp[3] = ntohl(imm); \
}
#define HERMON_WQE_SET_MLX_CTRL_SEGMENT(desc, desc_sz, sig, maxstat, \
lid, qp, sl) \
{ \
uint32_t *tmp; \
uint32_t cntr_tmp; \
\
tmp = (uint32_t *)desc; \
cntr_tmp = htonl(tmp[0]); \
cntr_tmp &= 0x80000000; \
cntr_tmp |= HERMON_WQE_SEND_NOPCODE_SEND; \
tmp[0] = ntohl(cntr_tmp); \
tmp[1] = ntohl(desc_sz); \
cntr_tmp = (((maxstat << 4) | (sl & 0xff)) << 8) | sig; \
if (qp->qp_is_special == HERMON_QP_SMI) \
cntr_tmp |= (0x02 << 16); \
if (lid == IB_LID_PERMISSIVE) \
cntr_tmp |= (0x01 << 16); \
tmp[2] = ntohl(cntr_tmp); \
tmp[3] = ntohl((lid) << 16); \
}
#define HERMON_WQE_BUILD_MLX_LRH(lrh, qp, udav, pktlen) \
{ \
uint32_t *tmp; \
uint32_t lrh_tmp; \
\
tmp = (uint32_t *)(void *)(lrh); \
\
if ((qp)->qp_is_special == HERMON_QP_SMI) { \
lrh_tmp = HERMON_MLX_VL15_LVER; \
} else { \
lrh_tmp = HERMON_MLX_VL0_LVER | ((udav)->sl << 20); \
} \
if ((udav)->grh) { \
lrh_tmp |= (IB_LRH_NEXT_HDR_GRH << 16); \
} else { \
lrh_tmp |= (IB_LRH_NEXT_HDR_BTH << 16); \
} \
lrh_tmp |= (udav)->rlid; \
tmp[0] = htonl(lrh_tmp); \
\
lrh_tmp = (pktlen) << 16; \
if ((udav)->rlid == IB_LID_PERMISSIVE) { \
lrh_tmp |= IB_LID_PERMISSIVE; \
} else { \
lrh_tmp |= (udav)->ml_path; \
} \
tmp[1] = htonl(lrh_tmp); \
}
/*
* Note: The GRH payload length, calculated below, is the overall packet
* length (in bytes) minus LRH header and GRH headers.
*
* Also note: Filling in the GIDs in the way we do below is helpful because
* it avoids potential alignment restrictions and/or conflicts.
*/
#define HERMON_WQE_BUILD_MLX_GRH(state, grh, qp, udav, pktlen) \
{ \
uint32_t *tmp; \
uint32_t grh_tmp; \
ib_gid_t sgid; \
\
tmp = (uint32_t *)(grh); \
\
grh_tmp = HERMON_MLX_IPVER_TC_FLOW; \
grh_tmp |= (udav)->tclass << HERMON_MLX_TC_SHIFT; \
grh_tmp |= (udav)->flow_label; \
tmp[0] = htonl(grh_tmp); \
\
grh_tmp = (((pktlen) << 2) - (sizeof (ib_lrh_hdr_t) + \
sizeof (ib_grh_t))) << 16; \
grh_tmp |= (IB_GRH_NEXT_HDR_BTH << 8); \
grh_tmp |= (udav)->hop_limit; \
tmp[1] = htonl(grh_tmp); \
\
sgid.gid_prefix = (state)->hs_sn_prefix[(qp)->qp_portnum]; \
sgid.gid_guid = (state)->hs_guid[(qp)->qp_portnum] \
[(udav)->mgid_index]; \
bcopy(&sgid, &tmp[2], sizeof (ib_gid_t)); \
bcopy(&(udav)->rgid_h, &tmp[6], sizeof (ib_gid_t)); \
}
#define HERMON_WQE_BUILD_MLX_BTH(state, bth, qp, wr) \
{ \
uint32_t *tmp; \
uint32_t bth_tmp; \
\
tmp = (uint32_t *)(bth); \
\
bth_tmp = HERMON_MLX_UDSEND_OPCODE; \
if ((wr)->wr_flags & IBT_WR_SEND_SOLICIT) { \
bth_tmp |= (IB_BTH_SOLICITED_EVENT_MASK << 16); \
} \
if (qp->qp_is_special == HERMON_QP_SMI) { \
bth_tmp |= HERMON_MLX_DEF_PKEY; \
} else { \
bth_tmp |= (state)->hs_pkey[(qp)->qp_portnum] \
[(qp)->qp_pkeyindx]; \
} \
tmp[0] = htonl(bth_tmp); \
tmp[1] = htonl((wr)->wr.ud.udwr_dest->ud_dst_qpn & \
HERMON_MLX_DQPN_MASK); \
tmp[2] = 0x0; \
}
#define HERMON_WQE_BUILD_MLX_DETH(deth, qp) \
{ \
uint32_t *tmp; \
\
tmp = (uint32_t *)(deth); \
\
if ((qp)->qp_is_special == HERMON_QP_SMI) { \
tmp[0] = 0x0; \
tmp[1] = 0x0; \
} else { \
tmp[0] = htonl(HERMON_MLX_GSI_QKEY); \
tmp[1] = htonl(0x1); \
} \
}
/*
* Flash interface:
* Below we have PCI config space space offsets for flash interface
* access, offsets within Hermon CR space for accessing flash-specific
* information or settings, masks used for flash settings, and
* timeout values for flash operations.
*/
#define HERMON_HW_FLASH_CFG_HWREV 8
#define HERMON_HW_FLASH_CFG_ADDR 88
#define HERMON_HW_FLASH_CFG_DATA 92
#define HERMON_HW_FLASH_RESET_AMD 0xF0
#define HERMON_HW_FLASH_RESET_INTEL 0xFF
#define HERMON_HW_FLASH_CPUMODE 0xF0150
#define HERMON_HW_FLASH_ADDR 0xF01A4
#define HERMON_HW_FLASH_DATA 0xF01A8
#define HERMON_HW_FLASH_GPIO_SEMA 0xF03FC
#define HERMON_HW_FLASH_WRCONF_SEMA 0xF0380
#define HERMON_HW_FLASH_GPIO_DATA 0xF0040
#define HERMON_HW_FLASH_GPIO_MOD1 0xF004C
#define HERMON_HW_FLASH_GPIO_MOD0 0xF0050
#define HERMON_HW_FLASH_GPIO_DATACLEAR 0xF00D4
#define HERMON_HW_FLASH_GPIO_DATASET 0xF00DC
#define HERMON_HW_FLASH_GPIO_LOCK 0xF0048
#define HERMON_HW_FLASH_GPIO_UNLOCK_VAL 0xD42F
#define HERMON_HW_FLASH_GPIO_PIN_ENABLE 0x1E000000
#define HERMON_HW_FLASH_CPU_MASK 0xC0000000
#define HERMON_HW_FLASH_CPU_SHIFT 30
#define HERMON_HW_FLASH_ADDR_MASK 0x0007FFFC
#define HERMON_HW_FLASH_CMD_MASK 0xE0000000
#define HERMON_HW_FLASH_BANK_MASK 0xFFF80000
#define HERMON_HW_FLASH_SPI_BUSY 0x40000000
#define HERMON_HW_FLASH_SPI_WIP 0x01000000
#define HERMON_HW_FLASH_SPI_READ_OP 0x00000001
#define HERMON_HW_FLASH_SPI_USE_INSTR 0x00000040
#define HERMON_HW_FLASH_SPI_NO_ADDR 0x00000020
#define HERMON_HW_FLASH_SPI_NO_DATA 0x00000010
#define HERMON_HW_FLASH_SPI_TRANS_SZ_4B 0x00000200
#define HERMON_HW_FLASH_SPI_SECTOR_ERASE 0xD8
#define HERMON_HW_FLASH_SPI_READ 0x03
#define HERMON_HW_FLASH_SPI_PAGE_PROGRAM 0x02
#define HERMON_HW_FLASH_SPI_READ_STATUS_REG 0x05
#define HERMON_HW_FLASH_SPI_WRITE_ENABLE 0x06
#define HERMON_HW_FLASH_SPI_READ_ESIGNATURE 0xAB
#define HERMON_HW_FLASH_SPI_GW 0xF0400
#define HERMON_HW_FLASH_SPI_ADDR 0xF0404
#define HERMON_HW_FLASH_SPI_DATA 0xF0410
#define HERMON_HW_FLASH_SPI_DATA4 0xF0414
#define HERMON_HW_FLASH_SPI_DATA8 0xF0418
#define HERMON_HW_FLASH_SPI_DATA12 0xF041C
#define HERMON_HW_FLASH_SPI_ADDR_MASK 0x00FFFFFF
#define HERMON_HW_FLASH_SPI_INSTR_PHASE_OFF 0x04
#define HERMON_HW_FLASH_SPI_ADDR_PHASE_OFF 0x08
#define HERMON_HW_FLASH_SPI_DATA_PHASE_OFF 0x10
#define HERMON_HW_FLASH_SPI_ENABLE_OFF 0x2000
#define HERMON_HW_FLASH_SPI_CS_OFF 0x800
#define HERMON_HW_FLASH_SPI_INSTR_OFF 0x10000
#define HERMON_HW_FLASH_SPI_INSTR_SHIFT 0x10
#define HERMON_HW_FLASH_SPI_BOOT_ADDR_REG 0xF0000
#define HERMON_HW_FLASH_TIMEOUT_WRITE 300
#define HERMON_HW_FLASH_TIMEOUT_ERASE 1000000
#define HERMON_HW_FLASH_TIMEOUT_GPIO_SEMA 1000
#define HERMON_HW_FLASH_TIMEOUT_CONFIG 50
#define HERMON_HW_FLASH_ICS_ERASE 0x20
#define HERMON_HW_FLASH_ICS_ERROR 0x3E
#define HERMON_HW_FLASH_ICS_WRITE 0x40
#define HERMON_HW_FLASH_ICS_STATUS 0x70
#define HERMON_HW_FLASH_ICS_READY 0x80
#define HERMON_HW_FLASH_ICS_CONFIRM 0xD0
#define HERMON_HW_FLASH_ICS_READ 0xFF
#ifdef __cplusplus
}
#endif
#endif /* _SYS_IB_ADAPTERS_HERMON_HW_H */
|