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
|
// ************************************************************************************************
// * FILE PURPOSE: Packet processing on PDSPs without LUTs
// ************************************************************************************************
// * FILE NAME: pam.p
// *
// * DESCRIPTION: PDPS without LUTs can do the following processing:
// * checksum insertion
// * crc insertion
// * blind data insertion
// * multi route forwarding
// * basic forwarding
// *
// ************************************************************************************************
//
//
// TEXAS INSTRUMENTS TEXT FILE LICENSE
//
// Copyright (c) 2016 Texas Instruments Incorporated
//
// All rights reserved not granted herein.
//
// Limited License.
//
// Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive
// license under copyrights and patents it now or hereafter owns or controls to
// make, have made, use, import, offer to sell and sell ("Utilize") this software
// subject to the terms herein. With respect to the foregoing patent license,
// such license is granted solely to the extent that any such patent is necessary
// to Utilize the software alone. The patent license shall not apply to any
// combinations which include this software, other than combinations with devices
// manufactured by or for TI (“TI Devices”). No hardware patent is licensed hereunder.
//
// Redistributions must preserve existing copyright notices and reproduce this license
// (including the above copyright notice and the disclaimer and (if applicable) source
// code license limitations below) in the documentation and/or other materials provided
// with the distribution.
//
// Redistribution and use in binary form, without modification, are permitted provided
// that the following conditions are met:
// No reverse engineering, decompilation, or disassembly of this software is
// permitted with respect to any software provided in binary form.
// Any redistribution and use are licensed by TI for use only with TI Devices.
// Nothing shall obligate TI to provide you with source code for the software
// licensed and provided to you in object code.
//
// If software source code is provided to you, modification and redistribution of the
// source code are permitted provided that the following conditions are met:
// Any redistribution and use of the source code, including any resulting derivative
// works, are licensed by TI for use only with TI Devices.
// Any redistribution and use of any object code compiled from the source code
// and any resulting derivative works, are licensed by TI for use only with TI Devices.
//
// Neither the name of Texas Instruments Incorporated nor the names of its suppliers
// may be used to endorse or promote products derived from this software without
// specific prior written permission.
//
// DISCLAIMER.
//
// THIS SOFTWARE IS PROVIDED BY TI AND TI’S LICENSORS "AS IS" AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL TI AND TI’S
// LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//
//
#define PDSP_PAM 1
#include "pdsp_pa.h"
#include "pdsp_mem.h"
#include "pdsp_subs.h"
#include "pm_config.h"
#include "pdsp_ver.h"
#include "pm_constants.h"
#include "parsescope.h"
#define PASS_PROC_CMDSET
#define PASS_PROC_MULTI_ROUTE
#define PASS_PROC_USR_STATS
#define PASS_PROC_LUT2
#define HEADER_MAGIC 0xBABE0003 // PASS modifier1
#define PASS_M1_VER PASS_VERSION // 0x01.0x00.0x00.0x03
.origin 0
.entrypoint f_mInit
f_mInit:
jmp f_mStart
header:
.codeword HEADER_MAGIC
.codeword PASS_M1_VER
#ifdef PASS_GLOBAL_INIT
#include "meminit.p"
#endif
.using globalScopeM
f_mStart:
// f_mLocalInit is no longer needed since eventflag is removed
//call f_mLocalInit
// Clear the mailbox
zero &r2, 12
sbco r2, FIRMWARE_MBOX, 4, 12
// Write a non-zero value to mailbox slot 0.
mov r2, 1
sbco r2, FIRMWARE_MBOX, 0, 4
// Wait for the set command to take hold
wbs s_flags.info.tStatus_Command0
// The host will clear the flag when it is ready for the PDSP to run
wbc s_flags.info.tStatus_Command0
#ifdef PASS_GLOBAL_INIT
//only PDSP0 should do global init
// Do common initialization if the host has requested it
// The host requests a global init by writing a non-zero value into mailbox slot 1
// (Before clearing mailbox slot 0)
qbbc l_mStart0, s_flags.info.tStatus_Command1
call f_commonInit
mov r2, 0
sbco r2, FIRMWARE_MBOX, 4, 4 // Clear the mailbox
#endif
l_mStart0:
// Store the PDSP ID Information in LSB
lbco s_modCxt.flags, PAMEM_CONST_PDSP_INFO, OFFSET_ID, SIZE(s_modCxt.flags)
and s_modCxt.flags, s_modCxt.flags, 1
mov s_modCxt.usrStatsPdsp, 0
// Store the version number
mov r2.w0, PASS_M1_VER & 0xFFFF
mov r2.w2, PASS_M1_VER >> 16
sbco r2, PAMEM_CONST_PDSP_INFO, OFFSET_VER, 4
// Zero out debug
zero &r0, 16
sbco r0, PAMEM_CONST_PDSP_INFO, 0x10, 16
zero &s_statsFlags, SIZE(s_statsFlags)
// *******************************************************************************
// * FUNCTION PURPOSE: The main processing loop
// *******************************************************************************
// * DESCRIPTION: Packet commands are processed
// *
// * Register Usage:
// *
// * R0:
// * R1:
// * R2:
// * R3:
// * R4: | CDE commands - cdeScope
// * R5: | -
// * R6: |
// * R7: |
// * R8: |
// * R9: |
// * R10: |
// * R11: |
// * R12: |
// * R13: |
// * R14: |
// * R15: |
// * R16: |
// * R17: |
// * R18: |
// * R19: |
// * R20: |
// * R21: |
// * R22:
// * R23:
// * R24:
// * R25:
// * R26: Packet ID
// * R27:
// * R28: statistics (s_statsFlags) - Global scope
// * R29:
// * R30: w0-function return address -
// * R31: System Flags (s_flags) -
// *
// ************************************************************************************
f_mainLoop:
fci_mainLoop7: // For compatibility with classify1.p
// Look for command (FIRMWARE_CMD_PKT_CTRL_CFG only)
qbbc l_mainLoop, s_flags.info.tStatus_Command3
// Process Packet Control Configuration Update
lbco r1, FIRMWARE_MBOX, FIRMWARE_CMD_PKT_CTRL_CFG_OFFSET, 4
// Clear the valid bit fields
not r1.b2, r1.b1
// force clear valid bits to zero and retain valid bits positions
and s_modCxt.flags, s_modCxt.flags, r1.b2
// set the run time flags
or s_modCxt.flags, s_modCxt.flags, r1.b0
// clear the command flag
mov r1, 0
sbco r1, FIRMWARE_MBOX, FIRMWARE_CMD_PKT_CTRL_CFG_OFFSET, 4
l_mainLoop:
qbeq l_mainLoop0, s_statsFlags, 0
sbco s_statsFlags.event, cStatistics, OFFSET_STATS_FLAGS, 4
zero &s_statsFlags, SIZE(s_statsFlags)
.using modifyScope
l_mainLoop0:
//
// User Statistics Request Polling Engine:
// - Poll the User Statistic Request FIFO from the strating PDSP
// - If pending entry exists, process the entry, record the next PDSP as starting PDSP and exit
// - Otherwise, poll the request FIFO for next PDSP in round-robin
// - Exit if no entry found in all four PDSPs
// Only process user_statistics FIFO at PDSP4
qbbs l_mainLoop1, s_modCxt.flags.t_isPdsp5
// Process the user statistics FIFOs
mov s_rxUsrStatsFifoCxt.cnt, 4
mov s_rxUsrStatsFifoCxt.pdsp, s_modCxt.usrStatsPdsp
l_mainLoop0_1:
qbeq l_mainLoop0_2, s_rxUsrStatsFifoCxt.cnt, 0
lsl s_rxUsrStatsFifoCxt.cbOffset, s_rxUsrStatsFifoCxt.pdsp, 8
add s_rxUsrStatsFifoCxt.offset, s_rxUsrStatsFifoCxt.cbOffset, OFFSET_PDSP_USR_STATS_FIFO
add s_rxUsrStatsFifoCxt.cbOffset, s_rxUsrStatsFifoCxt.cbOffset, OFFSET_PDSP_USR_STATS_FIFO_CB
lbco s_rxFifoCb, PAMEM_USR_STATS_BASE, s_rxUsrStatsFifoCxt.cbOffset, SIZE(s_rxFifoCb)
add s_rxUsrStatsFifoCxt.pdsp, s_rxUsrStatsFifoCxt.pdsp, 1
and s_rxUsrStatsFifoCxt.pdsp, s_rxUsrStatsFifoCxt.pdsp, PA_USR_STATS_START_PDSP_MASK
sub s_rxUsrStatsFifoCxt.cnt, s_rxUsrStatsFifoCxt.cnt, 1
qbeq l_mainLoop0_1, s_rxFifoCb.in, s_rxFifoCb.out // FIFO is empty
// FIFO is not empty
add r1.w0, s_rxFifoCb.out, s_rxUsrStatsFifoCxt.offset
lbco s_rxUsrStatsReq, PAMEM_USR_STATS_BASE, r1.w0, SIZE(s_rxUsrStatsReq)
add s_rxFifoCb.out, s_rxFifoCb.out, 4
and s_rxFifoCb.out, s_rxFifoCb.out, 0x1F
sbco s_rxFifoCb.out, PAMEM_USR_STATS_BASE, s_rxUsrStatsFifoCxt.cbOffset, SIZE(s_rxFifoCb.out)
call f_usrStatsUpdate
l_mainLoop0_2:
// Record the start PDSP for round-robbin polling operation
mov s_modCxt.usrStatsPdsp, s_rxUsrStatsFifoCxt.pdsp
// Pass through
// Process the Tx user statistics FIFOs (from PDSP5)
lbco s_rxFifoCb, PAMEM_CONST_TX_USR_STATS_FIFO, OFFSET_PDSP_TX_USR_STATS_FIFO_CB, SIZE(s_rxFifoCb)
qbeq l_mainLoop1, s_rxFifoCb.in, s_rxFifoCb.out // FIFO is empty
// FIFO is not empty
add r1.w0, s_rxFifoCb.out, OFFSET_PDSP_TX_USR_STATS_FIFO
lbco s_rxUsrStatsReq, PAMEM_CONST_TX_USR_STATS_FIFO, r1.w0, SIZE(s_rxUsrStatsReq)
add s_rxFifoCb.out, s_rxFifoCb.out, 4
and s_rxFifoCb.out, s_rxFifoCb.out, 0x1F
sbco s_rxFifoCb.out, PAMEM_CONST_TX_USR_STATS_FIFO, OFFSET_PDSP_TX_USR_STATS_FIFO_CB, SIZE(s_rxFifoCb.out)
call f_usrStatsUpdate
// pass through
.leave modifyScope
l_mainLoop1:
qbbc f_mainLoop, s_flags.info.tStatus_CDENewPacket
// Fall through to f_mProc
// ************************************************************************************
// * FUNCTION PURPOSE: Process a packet
// ************************************************************************************
// * DESCRIPTION: A packet is examined for command info and processed.
// *
// * Register Usage:
// *
// * R0:
// * R1:
// * R2:
// * R3:
// * R4: | CDE commands - cdeScope
// * R5: | -
// * R6: |
// * R7: |
// * R8: |
// * R9: |
// * R10: |
// * R11: |
// * R12: |
// * R13: |
// * R14: |
// * R15: |
// * R16: |
// * R17: |
// * R18: | Packet ID
// * R19: |
// * R20: | Modify State machine (s_modState)
// * R21: |
// * R22: |
// * R23: |
// * R24: | Packet context
// * R25: |
// * R26: |
// * R27: |
// * R28: statistics (s_statsFlags) - Global scope
// * R29: Modify context (s_modCxt) -
// * R30: w0-function return address -
// * R31: System Flags (s_flags) -
// *
// ************************************************************************************
.using cdeScope
.using pktScope
.using modifyScope
.using currentFwdScope
f_mProc:
// packet counter
// this count gets updates even when the capture/mirror is set
lbco r1, FIRMWARE_MBOX, 0, 4
add r1, r1, 1
sbco r1, FIRMWARE_MBOX, 0, 4
zero &s_modState, SIZE(s_modState)
mov r24, 0
mov s_modCxt.paddingCnt, 0
mov s_modCxt.cmdFlushBytes, 0
// Debug code to duplicate the packet: The user can set up circular queue to record the last N entries
// Enable by writing configuration parameters to PDSP Info location + 0x10
// b3 = enable/disable b2 = flow Id w0 = queue number
lbco r0, PAMEM_CONST_PDSP_INFO, 0x10, 4
qbeq l_mProc00, r0.b3, 0
zero &s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
mov s_cdeCmdPkt.optionsFlag, CDE_FLG_SET_THREADID | CDE_FLG_SET_FLOWID | CDE_FLG_SET_DESTQUEUE
mov s_cdeCmdPkt.operation, CDE_CMD_PACKET_COPY
mov s_cdeCmdPkt.threadId, PA_DEST_CDMA
mov s_cdeCmdPkt.destQueue, r0.w0
mov s_cdeCmdPkt.flowId, r0.b2
xout XID_CDECTRL, s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
// Wait for new packet to be ready
wbs s_flags.info.tStatus_CDENewPacket
l_mProc00:
xin XID_CDEDATA, s_pktDescr, SIZE(s_pktDescr)
// Record the ctrl size associated with the packet
mov s_modState3.remCmdSize, s_pktDescr.ctrlDataSize
// Record packet size
mov s_modState.pktSize, s_pktDescr.pktDataSize
#ifdef TO_BE_DELETE
// Assign a packet ID if this is the first packet seen by the PDSPs
qbbs l_mProc2a, s_pktDescr.pktId.t_pktIdAllocated
l_mProc2:
// Have a new packet ID. Set the alloc bit
set s_pktDescr.pktId, r18.w0.t_pktIdAllocated
xout XID_CDEDATA, s_pktDescr, SIZE(s_pktDescr)
#endif
l_mProc2:
// There must be a command in the control section for this PDSP
qbne fci_mProc3, s_pktDescr.ctrlDataSize, 0
#ifdef TO_BE_DELETE
// Load the error routing info for this error type
mov r30.w2, EROUTE_SYSTEM_FAIL << 4 // multiply by 16, the size of struct_paFwdPlace
lbco s_curFmPlace, PAMEM_CONST_EROUTE, r30.w2, SIZE(s_curFmPlace)
// r3 holds the stats bits to set
zero &r3, 4
set r3.t_nCommandFail
mov r30.w0, f_mainLoop // return address
jmp f_curPktForward
#else
// just drop this illegal packet
set s_statsFlags.event.t_nCommandFail
// Discard the packet
zero &s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
mov s_cdeCmdPkt.operation, CDE_CMD_PACKET_FLUSH
xout XID_CDECTRL, s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
jmp f_mainLoop
#endif
fci_mProc3:
// Advance to the control section
mov s_cdeCmdWd.operation, CDE_CMD_ADVANCE_TO_CONTROL
xout XID_CDECTRL, s_cdeCmdWd, 4
// Insert 32 bytes of PS info
// This is legal even though the window has advanced to control
//mov s_cdeInsert.operation, CDE_CMD_INSERT_PSDATA
//mov s_cdeInsert.byteCount, 32
ldi r4, CDE_CMD_INSERT_PSDATA | (32 << 8)
xout XID_CDECTRL, s_cdeCmdWd, 4
fci_mProc4:
// Read in the command header
// The size of a complete packet context is read in, since this will
// used for the multi route and command set case.
xin XID_CDEDATA, s_msg, SIZE(s_pktCxt)
// Extract the command ID and process
lsr r1.b0, s_msg.cmdId, PA_MSG_CMD_ID_SHIFT
// Search based on expected occurance of header type
qbeq f_insChksum, r1.b0, PSH_CMD_PA_TX_CHKSUM
qbeq f_nextRoute, r1.b0, PSH_CMD_PA_TX_NEXT_ROUTE
qbeq f_blindPatch, r1.b0, PSH_CMD_PA_TX_BLIND_PATCH
qbeq f_insCrc, r1.b0, PSH_CMD_PA_TX_CRC
qbeq l_jmp_f_paSetupRxFwd, r1.b0, PSH_CMD_RX_FWD
// Fix for conditional jump out of range
jmp l_no_jmp_f_paSetupRxFwd
l_jmp_f_paSetupRxFwd:
jmp f_paSetupRxFwd
l_no_jmp_f_paSetupRxFwd:
qbeq l_jmp_f_paSetupConfigure, r1.b0, PSH_CMD_CONFIG
// Fix for conditional jump out of range
jmp l_no_jmp_f_paSetupConfigure
l_jmp_f_paSetupConfigure:
jmp f_paSetupConfigure
l_no_jmp_f_paSetupConfigure:
qbeq f_rptTimestamp, r1.b0, PSH_CMD_PA_TX_RPT_TS
qbeq f_group7Cmd, r1.b0, PSH_CMD_PA_GROUP_7
fci_mProc5:
// set s_statsFlags.event.t_nInvalidControl
// Discard the packet
zero &s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
mov s_cdeCmdPkt.operation, CDE_CMD_PACKET_FLUSH
xout XID_CDECTRL, s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
jmp f_mainLoop
.leave currentFwdScope
.leave cdeScope
.leave pktScope
.leave modifyScope
// ********************************************************************************************
// * FUNCTION PURPOSE: Tx Cmd Error handling
// ********************************************************************************************
// * DESCRIPTION: Error handling during a tx cmd error
// *
// * Register Usage:
// *
// * R0:
// * R1:
// * R2:
// * R3: | bit mask for stat to update on silent discard
// * R4:
// * R5:
// * R6: |
// * R7: |
// * R8: |
// * R9: |
// * R10:
// * R11:
// * R12:
// * R13:
// * R14: | (packet extended descriptor)
// * R15: |
// * R16: |
// * R17: |
// * R18: |
// * R19:
// * R20:
// * R21:
// * R22: |
// * R23: | Packet context - pktScope
// * R24: |
// * R25: |
// * R26: |
// * R27: |
// * R28:
// * R29: c2RunContext (s_runCxt) - Global Scope
// * R30: w2-Error Index w0-function return address -
// * R31: System Flags (s_flags) -
// *
// ****************************************************************************************************
.using cdeScope
f_txCmdErrHandle:
set s_statsFlags.event.t_nCommandFail
// Discard the packet
zero &s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
mov s_cdeCmdPkt.operation, CDE_CMD_PACKET_FLUSH
xout XID_CDECTRL, s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
jmp f_mainLoop
.leave cdeScope
// *******************************************************************************
// * FUNCTION PURPOSE: handle a checksum calculate request
// *******************************************************************************
// * DESCRIPTION: The checksum command is stored. It will be activated when
// * the packet is scrolled to the packet data section
// *
// *
// * Register Usage:
// *
// * R0:
// * R1:
// * R2:
// * R3:
// * R4: | CDE commands - cdeScope
// * R5: | -
// * R6: |
// * R7: |
// * R8: |
// * R9: |
// * R10: |
// * R11: |
// * R12: |
// * R13: |
// * R14: |
// * R15: |
// * R16: |
// * R17: |
// * R18: | Packet ID
// * R19: |
// * R20: | Modify State machine (s_modState)
// * R21: |
// * R22: |
// * R23: |
// * R24: | Packet context
// * R25: |
// * R26: | Packet ID
// * R27: |
// * R28: statistics (s_statsFlags) - Global scope
// * R29: Modify context (s_modCxt) -
// * R30: w0-function return address -
// * R31: System Flags (s_flags) -
// *
// ************************************************************************
.using cdeScope
.using modifyScope
f_insChksum:
xin XID_CDEDATA, s_cmdChkCrc, SIZE(s_cmdChkCrc)
// Delete the command from the control info
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_FLUSH
mov s_cdeCmdWd.byteCount, SIZE(s_cmdChkCrc)
// Check if we still have any commands left
qbgt f_txCmdErrHandle, s_modState3.remCmdSize, s_cdeCmdWd.byteCount
sub s_modState3.remCmdSize, s_modState3.remCmdSize, s_cdeCmdWd.byteCount
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
// Only two checksums can be computed at one time
qble l_insChksum0, s_modState.chkSumCount, 2
// Store the checksum command. It will be executed when
// the CDE advances to the start of the packet
mov r2, OFFSET_INSERT_CHKSUM
qbeq l_insChksumX, s_modState.chkSumCount, 0
add r2, r2, SIZE(s_cmdChkCrc)
l_insChksumX:
sbco s_cmdChkCrc, PAMEM_CONST_MODIFY, r2, SIZE(s_cmdChkCrc)
add s_modState.chkSumCount, s_modState.chkSumCount, 1
qbbc fci_mProc4, s_modState.flags.t_subsMCxtTerminate
// The terminate bit was set. Jump to the terminate address
//jmp s_modState.termAddress
jmp fci_nextRoute0
l_insChksum0:
// Number of checksum commands exceeds the maximum
set s_statsFlags.event.t_nCommandFail
// Discard the packet
zero &s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
mov s_cdeCmdPkt.operation, CDE_CMD_PACKET_FLUSH
xout XID_CDECTRL, s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
jmp f_mainLoop
.leave cdeScope
.leave modifyScope
// *****************************************************************************
// * FUNCTION PURPOSE: Insert CRC
// *****************************************************************************
// * DESCRIPTION: The compute and insert CRC command is stored. It will be
// * computed when the CDE is advanced to the packet data
// *
// * Register Usage:
// *
// * R0:
// * R1:
// * R2:
// * R3:
// * R4: | CDE commands - cdeScope
// * R5: | -
// * R6: |
// * R7: |
// * R8: |
// * R9: |
// * R10: |
// * R11: |
// * R12: |
// * R13: |
// * R14: |
// * R15: |
// * R16: |
// * R17: |
// * R18: | Packet ID
// * R19: |
// * R20: | Modify State machine (s_modState)
// * R21: |
// * R22:
// * R23:
// * R24:
// * R25:
// * R26: Packet ID
// * R27:
// * R28: statistics (s_statsFlags) - Global scope
// * R29: Modify context (s_modCxt) -
// * R30: w0-function return address -
// * R31: System Flags (s_flags) -
// *
// **********************************************************************************
.using cdeScope
.using modifyScope
f_insCrc:
xin XID_CDEDATA, s_cmdChkCrc, SIZE(s_cmdChkCrc)
// Delete the command from the control info
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_FLUSH
mov s_cdeCmdWd.byteCount, SIZE(s_cmdChkCrc)
qbgt f_txCmdErrHandle, s_modState3.remCmdSize, s_cdeCmdWd.byteCount
sub s_modState3.remCmdSize, s_modState3.remCmdSize, s_cdeCmdWd.byteCount
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
// Only one CRC command can be stored
qbbs l_insCrc0, s_modState.flags.t_subsMCxtCrc
// Store the crc command. It will be executed when
// the CDE advances to the start of the packet
sbco s_cmdChkCrc, PAMEM_CONST_MODIFY, OFFSET_INSERT_CRC, SIZE(s_cmdChkCrc)
set s_modState.flags.t_subsMCxtCrc
qbbc fci_mProc4, s_modState.flags.t_subsMCxtTerminate
// The terminate bit was set. Jump to the terminate address
//jmp s_modState.termAddress
jmp fci_nextRoute0
l_insCrc0:
// Two CRC commands
set s_statsFlags.event.t_nCommandFail
// Discard the packet
zero &s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
mov s_cdeCmdPkt.operation, CDE_CMD_PACKET_FLUSH
xout XID_CDECTRL, s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
jmp f_mainLoop
.leave cdeScope
.leave modifyScope
// ******************************************************************************
// * FUNCTION PURPOSE: Perform a blind patch
// ******************************************************************************
// * DESCRIPTION: The blind patch command is stored. The patches will be done
// * when the CDE is advanced to the desired point in the packet
// *
// * Register Usage:
// *
// * R0:
// * R1:
// * R2:
// * R3:
// * R4: | CDE commands - cdeScope
// * R5: | -
// * R6: |
// * R7: |
// * R8: |
// * R9: |
// * R10: |
// * R11: |
// * R12: |
// * R13: |
// * R14: |
// * R15: |
// * R16: |
// * R17: |
// * R18: | Packet Id
// * R19: |
// * R20: | Modify State machine (s_modState)
// * R21: |
// * R22:
// * R23:
// * R24:
// * R25:
// * R26: Packet ID
// * R27:
// * R28: statistics (s_statsFlags) - Global scope
// * R29: Modify context (s_modCxt) -
// * R30: w0-function return address -
// * R31: System Flags (s_flags) -
// *
// **********************************************************************************
.using cdeScope
.using modifyScope
f_blindPatch:
xin XID_CDEDATA, s_blindPatch, SIZE(s_blindPatch)
// Advance the CDE, flushing the command
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_FLUSH
lsr s_cdeCmdWd.byteCount, s_blindPatch.cmdLen_insert, 4 // dont count the insert flag
lsl s_cdeCmdWd.byteCount, s_cdeCmdWd.byteCount, 2 // convert 32 bit word count to bytes
qbgt f_txCmdErrHandle, s_modState3.remCmdSize, s_cdeCmdWd.byteCount
sub s_modState3.remCmdSize, s_modState3.remCmdSize, s_cdeCmdWd.byteCount
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
add s_modCxt.cmdFlushBytes, s_modCxt.cmdFlushBytes, s_cdeCmdWd.byteCount
qble l_blindPatch0, s_modState.patchCount, SUBS_MOD_CXT_MAX_PATCHES
// Copy the entire command, including pad, to memory
// The command length is in 4 byte units, from bits 7:4. Strip
// bit 3:0 and convert to bytes
lsr r0.b0, s_blindPatch.cmdLen_insert, 4
lsl r0.b0, r0.b0, 2
lsl r3.w2, s_modState.patchCount, 5 // Offset to memory (32 bytes each entry)
add r3.w2, r3.w2, OFFSET_BLIND_PATCH // Base offset
sbco s_blindPatch, PAMEM_CONST_MODIFY, r3.w2, b0
// keep count of the number of patch commands are stored
add s_modState.patchCount, s_modState.patchCount, 1
qbbc fci_mProc4, s_modState.flags.t_subsMCxtTerminate
// The terminate bit was set. Complete all processing
//jmp s_modState.termAddress
jmp fci_nextRoute0
l_blindPatch0:
// Too many patch commands
set s_statsFlags.event.t_nCommandFail
l_blindPatch1:
// Discard the packet
zero &s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
mov s_cdeCmdPkt.operation, CDE_CMD_PACKET_FLUSH
xout XID_CDECTRL, s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
jmp f_mainLoop
.leave cdeScope
.leave modifyScope
// *******************************************************************************
// * FUNCTION PURPOSE: Insert timestamp
// *******************************************************************************
// * DESCRIPTION: Insert Timestamp to the packet descriptor
// *
// * Register Usage:
// *
// * R0:
// * R1:
// * R2:
// * R3:
// * R4: | CDE commands - cdeScope
// * R5: | -
// * R6: |
// * R7: |
// * R8: |
// * R9: |
// * R10: |
// * R11: |
// * R12: |
// * R13: |
// * R14: |
// * R15: |
// * R16: |
// * R17: |
// * R18: |
// * R19: | next route stub (s_nRouteStub)
// * R20: | Modify State machine (s_modState)
// * R21: |
// * R22:
// * R23:
// * R24:
// * R25:
// * R26: Packet ID
// * R27:
// * R28: statistics (s_statsFlags) - Global scope
// * R29: Modify context (s_modCxt) -
// * R30: w0-function return address -
// * R31: System Flags (s_flags) -
// *
// *******************************************************************************
.using cdeScope
.using pktScope // For offset info
.using modifyScope
f_rptTimestamp:
xin XID_CDEDATA, s_reportTs, SIZE(s_reportTs)
// Attempt to check if the command is valid
and r0.b0, s_reportTs.cmdId, PA_RPT_TIME_STAMP_NOT_CMD_MASK
qbne f_txCmdErrHandle, r0.b0, 0
// Store the timestamp command. It will be executed when
// the CDE forward the packets out
sbco s_reportTs, PAMEM_CONST_MODIFY, OFFSET_REPORT_TIMESTAMP, SIZE(s_reportTs)
set s_modState.flags.t_subsMCxtTs
// Advance past the command
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_FLUSH
mov s_cdeCmdWd.byteCount, SIZE(s_reportTs)
qbgt f_txCmdErrHandle, s_modState3.remCmdSize, s_cdeCmdWd.byteCount
sub s_modState3.remCmdSize, s_modState3.remCmdSize, s_cdeCmdWd.byteCount
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
jmp fci_mProc4
.leave cdeScope
.leave pktScope
.leave modifyScope
// *******************************************************************************
// * FUNCTION PURPOSE: Forward a packet
// *******************************************************************************
// * DESCRIPTION: The next route command is used to forward a packet.
// * If the next command process bit (N bit) is set then
// * the command is stored and processed after the next
// * command in the list is processed.
// *
// * Register Usage:
// *
// * R0:
// * R1:
// * R2:
// * R3:
// * R4: | CDE commands - cdeScope
// * R5: | -
// * R6: | | can be re-used user Stats update context | EQoS parsing header
// * R7: | | at packet forwarding |
// * R8: | | |
// * R9: | | | s_paComIfEQoS
// * R10: | | Can be re-used for usrStats Global configuration |
// * R11: | (timestamp) [for packet descriptor updated] (report timestamp only)
// * R12: | (swInfo0) [IP fragmentation only]
// * R13: | (swInfo1)
// * R14: | | EQoS etherType
// * R15: | | reused as user_stats request |
// * R16: | | |
// * R17: | |
// * R18: | Packet ID | s_eqosQueueFlow
// * R19: | next route stub (s_nRouteStub)
// * R20: | Modify State machine (s_modState)
// * R21: |
// * R22:
// * R23:
// * R24:
// * R25:
// * R26: Packet ID
// * R27:
// * R28: statistics (s_statsFlags) - Global scope
// * R29: Modify context (s_modCxt) -
// * R30: w0-function return address -
// * R31: System Flags (s_flags) -
// *
// *******************************************************************************
.using cdeScope
.using modifyScope
.using pktScope // For offset info
.using pktCaptureScope
f_nextRoute:
xin XID_CDEDATA, s_nextRoute, SIZE(s_nextRoute)
// The software info words can be patched even if the next command
// must be processed
mov s_cdeCmdWd.byteCount, SIZE(s_nextRoute) - 4
// make sure that the output buffer is raedy for patch
wbs s_flags.info.tStatus_CDEOutPacket
qbbc f_nextRoute_dest_cdma, s_nextRoute.cmdId_N_E_Dest.t_nextRouteE
// Increase the byteCount for extension parameter
add s_cdeCmdWd.byteCount, s_cdeCmdWd.byteCount, 4
// record L2 padding flag
qbbc l_nextRoute_1_0, s_nextRoute.ctrlFlags.t_nextRoute_ctrl_l2padding
set s_modState.flags.t_subsMCxtPadding
l_nextRoute_1_0:
qbbc l_nextRoute_1, s_nextRoute.ctrlFlags.t_nextRoute_ctrl_txUsrStats
set s_modState.flags.t_subsMCxtUsrStats
mov s_modState.statsIndex, s_nextRoute.statsIndex
l_nextRoute_1:
and r2.b2, s_nextRoute.cmdId_N_E_Dest, PA_NEXT_ROUTE_DEST_MASK
qbne f_nextRoute_dest_eth_cdma, r2.b2, PA_DEST_SRIO
//SRIO operation
//Restore the destination field
and s_nextRoute.cmdId_N_E_Dest, s_nextRoute.cmdId_N_E_Dest, NOT_PA_NEXT_ROUTE_DEST_MASK
or s_nextRoute.cmdId_N_E_Dest, s_nextRoute.cmdId_N_E_Dest, PA_DEST_CDMA
// pactch the packet type
lbco r2.b0, cCdeOutPkt, OFFSET(s_pktDescr.pktType_pvtFlags), 1
and r2.b0, r2.b0, NOT_PA_PKT_TYPE_MASK
lsl r2.b1, s_nextRoute.pktType_psFlags, PA_PKT_TYPE_SHIFT
or r2.b0, r2.b0, r2.b1
sbco r2.b0, cCdeOutPkt, OFFSET(s_pktDescr.pktType_pvtFlags), 1
// store modified pktType for IP fragmentation
mov s_modState.pktType_psFlags, r2.b0
// Patch the PS Info
sbco s_nextRoute.swInfo0, cCdeOutPkt, SIZE(s_pktDescr), 8
mov s_cdeCmdWd.byteCount, SIZE(s_nextRoute)
set s_modState.flags.t_subsMCxtSrio
jmp f_nextRoute_dest_common
f_nextRoute_dest_eth_cdma:
//ETH, CDMA operations
//patch the psFlags
lbco r2.b0, cCdeOutPkt, OFFSET(s_pktDescr.psFlags_errorFlags), 1
and r2.b0, r2.b0, NOT_PA_PKT_PS_FLAGS_MASK
or r2.b0, r2.b0, s_nextRoute.pktType_psFlags
sbco r2.b0, cCdeOutPkt, OFFSET(s_pktDescr.psFlags_errorFlags), 1
// store modified psFlags for IP fragmentation
mov s_modState.pktType_psFlags, r2.b0
set s_modState.flags.t_subsMCxtPsFlags
qbeq f_nextRoute_dest_common, r2.b2, PA_DEST_ETH
f_nextRoute_dest_cdma:
sbco s_nextRoute.swInfo0, cCdeOutPkt, OFFSET(s_pktDescr.swinfo0), 8
f_nextRoute_dest_common:
// Store the route info stub. This allows the same structure to be
// used regardless of the next command state
// this is really mvid s_routeStub, *&s_nextRoute
mvid r19, *&s_nextRoute
// store softeware Info for IP fragmentation
mov s_pktDescr.swinfo0, s_nextRoute.swInfo0
mov s_pktDescr.swinfo1, s_nextRoute.swInfo1
// Advance past the command
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_FLUSH
qbbs l_nextRoute_txChkSkip, s_modCxt.flags.t_MCxtCopyState
qbgt f_txCmdErrHandle, s_modState3.remCmdSize, s_cdeCmdWd.byteCount
sub s_modState3.remCmdSize, s_modState3.remCmdSize, s_cdeCmdWd.byteCount
l_nextRoute_txChkSkip:
xout XID_CDECTRL, s_cdeCmdWd, 4
add s_modCxt.cmdFlushBytes, s_modCxt.cmdFlushBytes, s_cdeCmdWd.byteCount
qbbc fci_nextRoute0, s_nextRoute.cmdId_N_E_Dest.t_nextRouteN
// The next command bit is set. Setup the mod state to handle the termination
set s_modState.flags.t_subsMCxtTerminate
//mov s_modState.termAddress, fci_nextRoute0
//mov s_modState.termAddress.w2, fci_nextRoute0 >> 16
jmp fci_mProc4
fci_nextRoute0:
// Verify whether EQoS operation is enabled and required
// r2.w0: current packet offset
mov r2.w0, 0
qbbc l_nextRoute0, s_modCxt.flags.t_eqos_feature
qbbs l_nextRoute0, s_modState.flags.t_subsMCxtTs
and r2.b2, s_nRouteStub.cmdId_N_E_Dest, PA_NEXT_ROUTE_DEST_MASK
qbne l_nextRoute0, r2.b2, PA_DEST_ETH
and r2.b2, s_modState.pktType_psFlags, 0x70
qbeq l_nextRoute0, r2.b2, 0
call f_EQoS_PraseL2
l_nextRoute0:
// skip f_modComplete if ipFrag is required
// The IP fragmenation can only be combined with the blind patch command to insert the IPSEC
// AH authentication, all other modify commands will be ignored
qbbs fci_ipFrag, s_modState.flags.t_subsMCxtIpFrag // no return
call f_modComplete
fci_nextRoute_skipModComplete:
// Tx padding verification
qbbc l_nextRoute_copy, s_modState.flags.t_subsMCxtPadding
qble l_nextRoute_copy, s_modState.pktSize, 60
// Move to the end of the packet
mov s_cdeCmd.v0.w0, CDE_CMD_ADVANCE_TO_END
xout XID_CDECTRL, s_cdeCmd, 4 // Send the command
// Insert packet data
mov s_cdeCmd.v0.w0, CDE_CMD_INSERT_PACKET
rsb s_cdeCmd.v0.b1, s_modState.pktSize, 60
xout XID_CDECTRL, s_cdeCmd, 4 // Send the command
//Update padding cnt
add s_modCxt.paddingCnt, s_modCxt.paddingCnt, 1
mov s_modState.pktSize, 60
l_nextRoute_copy:
// Check whether copy is already done or not
qbbs l_nextRoute_capture_done, s_modCxt.flags.t_MCxtCopyState
// Check if IP fragment command is executed, if yes jump to normal operations.
qbbs l_nextRoute_txStats_update, s_modState.flags.t_subsMCxtIpFrag
// Check if mod context has PsFlags set, if not jump to normal operations.
qbbc l_nextRoute_txStats_update, s_modState.flags.t_subsMCxtPsFlags
// Check whether global packet capture for egress is set for copy, else normal-op
qbbc l_nextRoute_txStats_update, s_modCxt.flags.t_egress_pCapEnable
// ETH destination, get the ethernet port destined
// Shift right by 1 bit to get the correct configuration size per port
and r1.b0, s_modState.pktType_psFlags, PA_ETH_PS_FLAGS_PORT_MASK
lsr r1.w0, r1.b0, 1
// Update r1 with offset for interface
add r1.w0, r1.w0, OFFSET_EGRESS_PKT_CAP_CFG_BASE
// load the configurations
lbco s_paPktCapScr, PAMEM_CONST_PORTCFG, r1.w0, SIZE(s_paPktCapScr)
// Check the enable bit for ethernet capture
qbbc l_nextRoute_txStats_update, s_paPktCapScr.ctrlBitMap.t_pkt_cap_enable
// Copy is needed, set the bit in the modify context
set s_modCxt.flags.t_MCxtCopyState
// Issue Copy command (either to Host or Destination)
// Check is the copy to be done to host?
zero &s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
qbbs l_nextRoute_eth_dest_copy_host, s_paPktCapScr.ctrlBitMap.t_pkt_cap_host
// Port mirror activity
// Routing to ETH
// Patch the psflags
lbco r2.b0, cCdeOutPkt, OFFSET(s_pktDescr.psFlags_errorFlags), 1
and r2.b0, r2.b0, NOT_PA_PKT_PS_FLAGS_MASK
or r2.b0, r2.b0, s_paPktCapScr.mport_flow
sbco r2.b0, cCdeOutPkt, OFFSET(s_pktDescr.psFlags_errorFlags), 1
// Send the packet to ethernet mirror port
mov s_cdeCmdPkt.threadId, PA_DEST_ETH
// Jump to send packet and normal operation
jmp l_nextRoute_eth_dest_copy_send
l_nextRoute_eth_dest_copy_host:
l_nextRoute_eth_dest_copy_host_queue_bounce:
// Check for Queue Bounce operation
l_nextRoute_eth_dest_copy_host_queue_bounce_ddr:
qbbc l_nextRoute_eth_dest_copy_host_queue_bounce_msmc, s_paPktCapScr.destQueue.t_pa_forward_queue_bounce_ddr
clr s_paPktCapScr.destQueue.t_pa_forward_queue_bounce_ddr
sbco s_paPktCapScr.destQueue, cCdeOutPkt, OFFSET(s_pktDescr.swinfo1) + 2, 2
lbco s_paPktCapScr.destQueue, PAMEM_CONST_CUSTOM, OFFSET_QUEUE_BOUNCE_CFG, 2
jmp l_nextRoute_eth_dest_copy_host_queue_bounce_end
l_nextRoute_eth_dest_copy_host_queue_bounce_msmc:
qbbc l_nextRoute_eth_dest_copy_host_queue_bounce_end, s_paPktCapScr.destQueue.t_pa_forward_queue_bounce_msmc
clr s_paPktCapScr.destQueue.t_pa_forward_queue_bounce_msmc
sbco s_paPktCapScr.destQueue, cCdeOutPkt, OFFSET(s_pktDescr.swinfo1) + 2, 2
lbco s_paPktCapScr.destQueue, PAMEM_CONST_CUSTOM, OFFSET_QUEUE_BOUNCE_CFG+2, 2
// pass through
l_nextRoute_eth_dest_copy_host_queue_bounce_end:
// Packet Capture activity
mov s_cdeCmdPkt.threadId, PA_DEST_CDMA
mov s_cdeCmdPkt.destQueue, s_paPktCapScr.destQueue
mov s_cdeCmdPkt.flowId, s_paPktCapScr.mport_flow
sbco s_paPktCapScr.context, cCdeOutPkt, OFFSET(s_pktDescr.swinfo0), SIZE(s_paPktCapScr.context)
l_nextRoute_eth_dest_copy_send:
mov s_cdeCmdPkt.operation, CDE_CMD_PACKET_COPY
mov s_cdeCmdPkt.optionsFlag, (CDE_FLG_SET_THREADID | CDE_FLG_SET_FLOWID | CDE_FLG_SET_PSINFO | CDE_FLG_SET_DESTQUEUE)
mov s_cdeCmdPkt.psInfoSize, 0
xout XID_CDECTRL, s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
// Wait for new packet to be ready
// wbs s_flags.info.tStatus_CDENewPacket
jmp f_mainLoop
l_nextRoute_capture_done:
// clear copy done state and continue regular operations
clr s_modCxt.flags.t_MCxtCopyState
l_nextRoute_txStats_update:
qbbc l_nextRoute_padding_cnt_updtae, s_modState.flags.t_subsMCxtUsrStats
// prepare and update user-stats
mov s_rxUsrStatsReq.index, s_modState.statsIndex
mov s_rxUsrStatsReq.pktSize, s_modState.pktSize
// Only update user-defined statistics at PDSP4
qbbc l_nextRoute_txStats_update_1, s_modCxt.flags.t_isPdsp5
// Call the common user-statistic update routine
call f_usrStatsUpdate
jmp l_nextRoute_padding_cnt_updtae
l_nextRoute_txStats_update_1:
// Just push the statistics update request into PDSP5 FIFO to be processed by PDSP4
lbco s_rxFifoCb, PAMEM_CONST_TX_USR_STATS_FIFO, OFFSET_PDSP_TX_USR_STATS_FIFO_CB, SIZE(s_rxFifoCb)
add r0.b0, s_rxFifoCb.in, 4
and r0.b0, r0.b0, 0x1F
qbne l_nextRoute_txStats_update_2, s_rxFifoCb.out, r0.b0
// FIFO is full, bump the system error
set s_statsFlags.event.t_nSystemFail
jmp l_nextRoute_padding_cnt_updtae
l_nextRoute_txStats_update_2:
// Insert the request into the FIFO
add r0.w2, s_rxFifoCb.in, OFFSET_PDSP_TX_USR_STATS_FIFO
sbco s_rxUsrStatsReq, PAMEM_CONST_TX_USR_STATS_FIFO, r0.w2, SIZE(s_rxUsrStatsReq)
sbco r0.b0, PAMEM_CONST_TX_USR_STATS_FIFO, OFFSET_PDSP_TX_USR_STATS_FIFO_CB + OFFSET(s_rxFifoCb.in), SIZE(s_rxFifoCb.in)
// pass through
l_nextRoute_padding_cnt_updtae:
qbeq l_nextRoute_fwdPkt, s_modCxt.paddingCnt, 0
//
// All the user-statistics update registers are free at this moment
// Prepare and request tx padding statistics update
//
// store the user statistics info
lbco s_rxUsrStatsReq.index, PAMEM_CONST_CUSTOM, OFFSET_MAC_PADDING_CFG + OFFSET(struct_paMacPaddingCfg.txPaddingCntIndex), 2
mov s_rxUsrStatsReq.pktSize, s_modCxt.paddingCnt // used padding count as packet size
// Make sure that the tx padding counter is a (pseudo) byte counter
lsl r0.w0, s_rxUsrStatsReq.index, 1
lbco r0.w2, PAMEM_CONST_USR_STATS_CB, r0.w0, 2
qbbs l_nextRoute_padding_cnt_updtae_1, r0.w2.t_pa_usr_stats_cb_byte_cnt
set r0.w2.t_pa_usr_stats_cb_byte_cnt
sbco r0.w2, PAMEM_CONST_USR_STATS_CB, r0.w0, 2
l_nextRoute_padding_cnt_updtae_1:
// Only update user-defined statistics at PDSP4
qbbs l_nextRoute_padding_cnt_updtae_2, s_modCxt.flags.t_isPdsp5
// Call the common user-statistic update routine
call f_usrStatsUpdate
jmp l_nextRoute_fwdPkt
l_nextRoute_padding_cnt_updtae_2:
// Just push the statistics update request into PDSP5 FIFO to be processed by PDSP4
lbco s_rxFifoCb, PAMEM_CONST_TX_USR_STATS_FIFO, OFFSET_PDSP_TX_USR_STATS_FIFO_CB, SIZE(s_rxFifoCb)
add r0.b0, s_rxFifoCb.in, 4
and r0.b0, r0.b0, 0x1F
qbne l_nextRoute_padding_cnt_updtae_3, s_rxFifoCb.out, r0.b0
// FIFO is full, bump the system error
set s_statsFlags.event.t_nSystemFail
jmp l_nextRoute_fwdPkt
l_nextRoute_padding_cnt_updtae_3:
// Insert the request into the FIFO
add r0.w2, s_rxFifoCb.in, OFFSET_PDSP_TX_USR_STATS_FIFO
sbco s_rxUsrStatsReq, PAMEM_CONST_TX_USR_STATS_FIFO, r0.w2, SIZE(s_rxUsrStatsReq)
sbco r0.b0, PAMEM_CONST_TX_USR_STATS_FIFO, OFFSET_PDSP_TX_USR_STATS_FIFO_CB + OFFSET(s_rxFifoCb.in), SIZE(s_rxFifoCb.in)
// pass through
//sub s_modCxt.paddingCnt, s_modCxt.paddingCnt, 1
//jmp l_nextRoute_paddingLoop
// pass through
l_nextRoute_fwdPkt:
// Forward the packet
zero &s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
mov s_cdeCmdPkt.operation, CDE_CMD_PACKET_ADVANCE
and s_cdeCmdPkt.threadId, s_nRouteStub.cmdId_N_E_Dest, PA_NEXT_ROUTE_DEST_MASK
mov s_cdeCmdPkt.optionsFlag, (CDE_FLG_SET_THREADID | CDE_FLG_SET_DESTQUEUE | CDE_FLG_SET_FLOWID | CDE_FLG_SET_PSINFO)
mov s_cdeCmdPkt.destQueue, s_nRouteStub.destQueue
mov s_cdeCmdPkt.flowId, s_nRouteStub.flowId
qbbc f_nextRoute0_1, s_modState.flags.t_subsMCxtSrio
// SRIO use 8 byte PSINFO
mov s_cdeCmdPkt.psInfoSize, 8
// pass through
f_nextRoute0_1:
// Should we report timestamp
qbbc f_nextRoute0_2, s_modState.flags.t_subsMCxtTs
// Load the timestamp command
lbco s_reportTs, PAMEM_CONST_MODIFY, OFFSET_REPORT_TIMESTAMP, SIZE(s_reportTs)
// Copy and forward the packet out
mov s_cdeCmdPkt.operation, CDE_CMD_PACKET_COPY
xout XID_CDECTRL, s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
// Calculate, load and insert timestamp
ldi r1, PDSP0_TIMER
lbbo r0, r1, 8, 4
mov r0.w2, 0xffff
sub r0.w0, r0.w2, r0.w0
//lbco r0.w2, PAMEM_CONST_PARSE, OFFSET_SYS_TIMESTAMP+2, 2
lbco r1, PAMEM_CONST_PARSE, OFFSET_SYS_TIMESTAMP, 8
mov r0.w2, r1.w0
mov s_pktDescr.swInfo1, r1.w2
mov s_pktDescr.swInfo1.w2, r2.w0
// Wait for new packet to be ready
wbs s_flags.info.tStatus_CDENewPacket
// Update packet descriptor
// xin XID_CDEDATA, s_pktDescr.timestamp, 8
mov s_pktDescr.timestamp, r0
mov s_pktDescr.swInfo0, s_reportTs.swInfo0
xout XID_CDEDATA, s_pktDescr.timestamp, 12
// Flush out the packet
mov s_cdeCmdWd.operation, CDE_CMD_ADVANCE_TO_PACKET
xout XID_CDECTRL, s_cdeCmdWd, 4
mov s_cdeCmdWd.operation, CDE_CMD_FLUSH_TO_END
xout XID_CDECTRL, s_cdeCmdWd, 4
// Forward the packet
zero &s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
mov s_cdeCmdPkt.operation, CDE_CMD_PACKET_ADVANCE
mov s_cdeCmdPkt.threadId, PA_DEST_CDMA
mov s_cdeCmdPkt.optionsFlag, (CDE_FLG_SET_THREADID | CDE_FLG_SET_DESTQUEUE | CDE_FLG_SET_FLOWID | CDE_FLG_SET_PSINFO)
mov s_cdeCmdPkt.destQueue, s_reportTs.destQueue
mov s_cdeCmdPkt.flowId, s_reportTs.flowId
// Pass through
f_nextRoute0_2:
xout XID_CDECTRL, s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
jmp f_mainLoop
.leave cdeScope
.leave modifyScope
.leave pktScope
.leave pktCaptureScope
// *******************************************************************************
// * FUNCTION PURPOSE: Group 7 (Dummy and IP Fragments) Command
// *******************************************************************************
// * DESCRIPTION: Process the dummy command
// *
// * Register Usage:
// *
// * R0:
// * R1:
// * R2: | Message Length Patch 1
// * R3: | Message Length Patch 2
// * R4: | CDE commands - cdeScope
// * R5: | -
// * R6: | pktDesc (s_bPatchStub)
// * R7: |
// * R8: | &
// * R9: |
// * R10: | ipHeader
// * R11: | (timestamp) [for packet descriptor updated}
// * R12: | (swInfo0)
// * R13: | (swInfo1)
// * R14: | ip Fragment Control block
// * R15: |
// * R16: |
// * R17: | swInfo0
// * R18: | Packet ID
// * R19: | next route stub (s_nRouteStub)
// * R20: | Modify State machine (s_modState)
// * R21: |
// * R22: | s_msg or s_ipFrag
// * R23: | It will be over-written by the command loaded
// * R24: |
// * R25: |
// * R26: Packet ID |
// * R27:
// * R28: statistics (s_statsFlags) - Global scope
// * R29: Modify context (s_modCxt) -
// * R30: w0-function return address -
// * R31: System Flags (s_flags) -
// *
// *******************************************************************************
.using cdeScope
.using pktScope // For offset info
.using ipScope
.using modifyScope
f_group7Cmd:
// Advance past the command
// Dummy, IP fragment and Patch Message Length commands: 4 bytes
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_FLUSH
mov s_cdeCmdWd.byteCount, 4
qbgt f_txCmdErrHandle, s_modState3.remCmdSize, s_cdeCmdWd.byteCount
sub s_modState3.remCmdSize, s_modState3.remCmdSize, s_cdeCmdWd.byteCount
xout XID_CDECTRL, s_cdeCmdWd, 4
add s_modCxt.cmdFlushBytes, s_modCxt.cmdFlushBytes, s_cdeCmdWd.byteCount
// Extract the sub command code
and r1.b0, s_ipFrag.cmdId_subCode, PA_SUB_CMD_CODE_MASK
qbeq fci_mProc4, r1.b0, PA_SUB_CMD_CODE_DUMMY
qbeq l_group7Cmd_crcVerify, r1.b0, PA_SUB_CMD_CODE_EMAC_CRC_VERIFY
qbne f_ipFrag, r1.b0, PA_SUB_CMD_CODE_PATCH_MSG_LEN
f_patchMsgLen:
// Ignore this command if the number of message length commands exceed the limit
// Note: checksum command will not be in conjunction with IP
// fragmentation and message length patching command
qble fci_mProc4, s_modState.chkSumCount, SUBS_MOD_CXT_MAX_MSGLEN_PATCHES
// Convert and Copy the entire command to memory
// The message length size is stored as a flag in the msgLen field
mov s_patchMsgLen3.msgLenSize, 2 //default message length size is 16-bit
qbbc l_patchMsgLen1, s_patchMsgLenCmd.msgLen.t_patch_msg_len_size32
mov s_patchMsgLen3.msgLenSize, 4
clr s_patchMsgLenCmd.msgLen.t_patch_msg_len_size32
//pass through
l_patchMsgLen1:
lsl r3.w2, s_modState.chkSumCount, 2 // Offset to memory (4 bytes each entry)
add r3.w2, r3.w2, OFFSET_PATCH_MSG_LEN // Base offset
sbco s_patchMsgLen3, PAMEM_CONST_MODIFY, r3.w2, SIZE(s_patchMsgLen3)
// keep count of the number of message length patching commands are stored
add s_modState.chkSumCount, s_modState.chkSumCount, 1
jmp fci_mProc4
l_group7Cmd_crcVerify:
jmp f_emacCrcVerify
f_ipFrag:
qbbs l_ipFrag1, s_modState.flags.t_subsMCxtTerminate
// Store the commad if the next route info is not received provided
set s_modState.flags.t_subsMCxtIpFrag
set s_modState.flags.t_subsMCxtPadding // padding is always on if IP fragments is required
sbco s_ipFrag, PAMEM_CONST_MODIFY, OFFSET_IP_FRAG, SIZE(s_ipFrag)
jmp fci_mProc4
fci_ipFrag:
//Load the IP fragmentation data
lbco s_ipFrag, PAMEM_CONST_MODIFY, OFFSET_IP_FRAG, SIZE(s_ipFrag)
l_ipFrag1:
// Clear out and initialize the IP Fragmentation working Context
zero &s_ipFragCxt, SIZE(s_ipFragCxt)
mov s_ipFragCxt.mtuSize, s_ipFrag.mtuSize
mov s_ipFragCxt.ipOffset, s_ipFrag.ipOffset
qbne l_ipFrag1_skipPktMove, r2.w0, 0
// Advance the CDE to the beginning of the packet data
mov s_cdeCmdWd.operation, CDE_CMD_ADVANCE_TO_PACKET
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
l_ipFrag1_skipPktMove:
// Advance to the IP header
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_ADVANCE
sub s_cdeCmdWd.byteCount, s_ipFragCxt.ipOffset, r2.w0
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
//Load the message length patching data (r2, r3)
lbco s_patchMsgLen1, PAMEM_CONST_MODIFY, OFFSET_PATCH_MSG_LEN, 2*SIZE(s_patchMsgLen1)
//
// Process IPv4
//
l_ipFrag_ProcessIp:
// Load the packet Ip header
xin XID_CDEDATA, s_Ip, SIZE(s_Ip)
// Support IP Version 4 only
and r0.b0, s_Ip.VerLen, 0xF0
qbeq l_ipFrag_ProcessIp_1, r0.b0, 0x40
//Must be IPv6: Error check may be required
//
qbeq fci_ipv6Frag, r0.b0, 0x60
jmp l_ipFrag_ProcessIp_none
l_ipFrag_ProcessIp_1:
// Save off the length reported by IP
mov s_ipFragCxt.ipLen, s_Ip.TotalLen
// Set offset to L4
and s_ipFragCxt.ipHdrLen, s_Ip.VerLen, 0xF
lsl s_ipFragCxt.ipHdrLen, s_ipFragCxt.ipHdrLen, 2
// If the packet fits in the MTU, we simply forward it
qble l_ipFrag_ProcessIp_none, s_ipFragCxt.mtuSize, s_ipFragCxt.ipLen
// If the DF flag is set, we are done
qbbs l_ipFrag_ProcessIp_none, s_Ip.FragOff.t_ipv4_frag_df
// Save the base offset
mov s_ipFragCxt.baseOffset, s_Ip.FragOff
// Get the payload bytes per frag amount
sub s_ipFragCxt.payloadSize, s_ipFragCxt.mtuSize, s_ipFragCxt.ipHdrLen
and s_ipFragCxt.payloadSize.b0, s_ipFragCxt.payloadSize.b0, 0xF8
// Clear the frag loop index
//mov s_ipFragCxt.loopOffset, 0
l_ipFrag_Loop:
// Patch the frag offset
lsr r1, s_ipFragCxt.loopOffset, 3
add s_Ip.FragOff, s_ipFragCxt.baseOffset, r1
// Get the payload size for this fragment
add r0, s_ipFragCxt.loopOffset, s_ipFragCxt.payloadSize
sub r1, s_ipFragCxt.ipLen, s_ipFragCxt.ipHdrLen
qblt l_ipFrag_NotLast, r1, r0
// This is the last frag - adjust the final size
sub s_ipFragCxt.payloadSize, r1, s_ipFragCxt.loopOffset
jmp l_ipFrag_CommonFrag
l_ipFrag_NotLast:
// Set more fragments
set s_Ip.FragOff.t_ipv4_frag_m
l_ipFrag_CommonFrag:
// Patch the IP length
add s_Ip.TotalLen, s_ipFragCxt.payloadSize, s_ipFragCxt.ipHdrLen
mov s_Ip.Checksum, 0
// Write out the new IP header
xout XID_CDEDATA, s_Ip, SIZE(s_Ip)-8 // We never update the last 8 bytes (or options)
// record IP fragment size
add s_modState.pktSize, s_Ip.TotalLen, s_ipFragCxt.ipOffset
// update tx stats
set s_statsFlags.event.t_nTxIpFrag
sbco s_statsFlags.event, cStatistics, OFFSET_STATS_FLAGS, 4
zero &s_statsFlags, SIZE(s_statsFlags)
// Perform message length patching if any
qbeq l_ipFrag_CommonFrag_5, s_modState.chkSumCount, 0
// first message patch command
mov s_cdeCmdPatch.operation, CDE_CMD_PATCH_PACKET
mov s_cdeCmdPatch.len, s_patchMsgLen1.msgLenSize
mov s_cdeCmdPatch.offset, s_patchMsgLen1.offset
qbeq l_ipFrag_CommonFrag_1, s_cdeCmdPatch.len, 2
// 32-bit message length
add s_cdeCmdPatch.data, s_patchMsgLen1.msgLen, s_Ip.TotalLen
jmp l_ipFrag_CommonFrag_2
l_ipFrag_CommonFrag_1:
// 16-bit message length
add s_cdeCmdPatch.data.w2, s_patchMsgLen1.msgLen, s_Ip.TotalLen
l_ipFrag_CommonFrag_2:
xout XID_CDECTRL, s_cdeCmdPatch, SIZE(s_cdeCmdPatch)
qbeq l_ipFrag_CommonFrag_5, s_modState.chkSumCount, 1
// second message patch command
mov s_cdeCmdPatch.len, s_patchMsgLen2.msgLenSize
mov s_cdeCmdPatch.offset, s_patchMsgLen2.offset
qbeq l_ipFrag_CommonFrag_3, s_cdeCmdPatch.len, 2
// 32-bit message length
add s_cdeCmdPatch.data, s_patchMsgLen2.msgLen, s_Ip.TotalLen
jmp l_ipFrag_CommonFrag_4
l_ipFrag_CommonFrag_3:
// 16-bit message length
add s_cdeCmdPatch.data.w2, s_patchMsgLen2.msgLen, s_Ip.TotalLen
l_ipFrag_CommonFrag_4:
xout XID_CDECTRL, s_cdeCmdPatch, SIZE(s_cdeCmdPatch)
l_ipFrag_CommonFrag_5:
// Start the IP checksum.
zero &s_cdeCmdChk, SIZE(s_cdeCmdChk)
mov s_cdeCmdChk.operation,CDE_CMD_CHECKSUM1_COMPUTE
mov s_cdeCmdChk.byteLen, s_ipFragCxt.ipHdrLen
mov s_cdeCmdChk.offset, OFFSET(s_Ip.Checksum) // Starting sum is 0, offset is 10
xout XID_CDECTRL, s_cdeCmdChk, SIZE(s_cdeCmdChk)
// Slide the window past the IP header
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_ADVANCE
mov s_cdeCmdWd.byteCount, s_ipFragCxt.ipHdrLen
xout XID_CDECTRL, s_cdeCmdWd, 4
qbeq l_ipFrag_Patch, s_ipFragCxt.loopOffset, 0
// Now flush any data contained in s_ipFragCxt.loopOffset
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_FLUSH
mov s_cdeCmdWd.byteCount, s_ipFragCxt.loopOffset
xout XID_CDECTRL, s_cdeCmdWd, 4
// r1.w0 store the payload offset from the IP payload due to potential patch operation
mov r1.w0, 0
l_ipFrag_NoFlush:
// re-enter from l_ipFrag_Patch as well:r1.w0 store the payload offset from the IP payload due to potential patch operation
// Slide the window past the valid data
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_ADVANCE
sub s_cdeCmdWd.byteCount, s_ipFragCxt.payloadSize, r1.w0
xout XID_CDECTRL, s_cdeCmdWd, 4
// Setup the offset for the next packet (jump out if final frag)
add s_ipFragCxt.loopOffset, s_ipFragCxt.loopOffset, s_ipFragCxt.payloadSize
add r1, s_ipFragCxt.loopOffset, s_ipFragCxt.ipHdrLen
qble l_ipFrag_LastPacket, r1, s_ipFragCxt.ipLen
// Flush out the remaining packet
// Note: It is not necessary if we can use CDE_FLG_TRUNCATE.
// However, CDE_FLG_TRUNCATE flag will prevent the IP header checksum to be calculated due to a silicon bug
// It is just a workaround for IP header checksum
mov s_cdeCmdPkt.operation, CDE_CMD_FLUSH_TO_END
xout XID_CDECTRL, s_cdeCmdPkt, 4
// IP fragment padding check
// Make sure the fragment is at least 60 bytes long
qble l_ipFrag_ForwardPkt_0, s_modState.pktSize, 60
// Insert packet data
mov s_cdeCmd.v0.w0, CDE_CMD_INSERT_PACKET
rsb s_cdeCmd.v0.b1, s_modState.pktSize, 60
xout XID_CDECTRL, s_cdeCmd, 4 // Send the command
//Update padding cnt
add s_modCxt.paddingCnt, s_modCxt.paddingCnt, 1
// pass through
l_ipFrag_ForwardPkt_0:
// Forward the packet
zero &s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
mov s_cdeCmdPkt.operation, CDE_CMD_PACKET_COPY
and s_cdeCmdPkt.threadId, s_nRouteStub.cmdId_N_E_Dest, PA_NEXT_ROUTE_DEST_MASK
//mov s_cdeCmdPkt.optionsFlag, (CDE_FLG_RETAIN_CHKSUM | CDE_FLG_TRUNCATE | CDE_FLG_SET_THREADID | CDE_FLG_SET_DESTQUEUE | CDE_FLG_SET_FLOWID | CDE_FLG_SET_PSINFO)
mov s_cdeCmdPkt.optionsFlag, (CDE_FLG_RETAIN_CHKSUM | CDE_FLG_SET_THREADID | CDE_FLG_SET_DESTQUEUE | CDE_FLG_SET_FLOWID | CDE_FLG_SET_PSINFO)
mov s_cdeCmdPkt.destQueue, s_nRouteStub.destQueue
mov s_cdeCmdPkt.flowId, s_nRouteStub.flowId
qbbc l_ipFrag_ForwardPkt, s_modState.flags.t_subsMCxtSrio
// SRIO use 8 byte PSINFO
mov s_cdeCmdPkt.psInfoSize, 8
l_ipFrag_ForwardPkt:
xout XID_CDECTRL, s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
// pass through
// jmp l_ipFrag_WaitForCopy // Let the new packet bit clear
l_ipFrag_WaitForCopy:
// Wait for a new packet
qbbc l_ipFrag_WaitForCopy, s_flags.info.tStatus_CDENewPacket
// Read packet descriptor
//
// xin XID_CDEDATA, s_pktDescr, OFFSET(s_pktDescr.pktDataSize)
qbbc l_ipFrag_WaitForCopy_1, s_modState.flags.t_subsMCxtSrio
// Update the pktType
mov s_pktDescr.pktType_pvtFlags, s_modState.pktType_psFlags
xout XID_CDEDATA, s_pktDescr.pktType_pvtFlags, SIZE(s_pktDescr.pktType_pvtFlags)
//jmp l_ipFrag_WaitForCopy_2 // the next check will fail and so jmp
l_ipFrag_WaitForCopy_1:
qbbc l_ipFrag_WaitForCopy_2, s_modState.flags.t_subsMCxtPsFlags
// Update the psFlags
mov s_pktDescr.psFlags_errorFlags, s_modState.pktType_psFlags
xout XID_CDEDATA, s_pktDescr.psFlags_errorFlags, SIZE(s_pktDescr.psFlags_errorFlags)
// Pass through
l_ipFrag_WaitForCopy_2:
// Update swInfo0 and swinfo1
xout XID_CDEDATA, s_pktDescr.swInfo0, 8
// Advance to the control section
mov s_cdeCmdWd.operation, CDE_CMD_ADVANCE_TO_CONTROL
xout XID_CDECTRL, s_cdeCmdWd, 4
qbbc l_ipFrag_WaitForCopy_3, s_modState.flags.t_subsMCxtSrio
// Insert 8 bytes of PS info
// This is legal even though the window has advanced to control
mov s_cdeInsert.operation, CDE_CMD_INSERT_PSDATA
mov s_cdeInsert.byteCount, 4
mov s_cdeInsert.bytes, s_pktDescr.swInfo0
xout XID_CDECTRL, s_cdeInsert, SIZE(s_cdeInsert)
mov s_cdeInsert.bytes, s_pktDescr.swInfo1
xout XID_CDECTRL, s_cdeInsert, SIZE(s_cdeInsert)
l_ipFrag_WaitForCopy_3:
// Flush out the control info
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_FLUSH
mov s_cdeCmdWd.byteCount, s_modCxt.cmdFlushBytes
xout XID_CDECTRL, s_cdeCmdWd, 4
mov s_cdeCmdWd.operation, CDE_CMD_ADVANCE_TO_PACKET
xout XID_CDECTRL, s_cdeCmdWd, 4
//mov s_cdeCmdWd.operation, CDE_CMD_FLUSH_TO_PACKET
//xout XID_CDECTRL, s_cdeCmdWd, 4
// Advance to the IP header
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_ADVANCE
mov s_cdeCmdWd.byteCount, s_ipFragCxt.ipOffset
xout XID_CDECTRL, s_cdeCmdWd, 4
// Load the packet Ip header
xin XID_CDEDATA, s_Ip, SIZE(s_Ip)
jmp l_ipFrag_Loop
l_ipFrag_LastPacket:
// Make sure the packet is at least 60 bytes long
//add s_modState.pktSize, s_Ip.TotalLen, s_ipFragCxt.ipOffset
jmp fci_nextRoute_skipModComplete
l_ipFrag_ProcessIp_none:
// There is no IP fragmentation
// Perform message length patching if any
qbeq l_ipFrag_ProcessIp_none_5, s_modState.chkSumCount, 0
// first message patch command
mov s_cdeCmdPatch.operation, CDE_CMD_PATCH_PACKET
mov s_cdeCmdPatch.len, s_patchMsgLen1.msgLenSize
mov s_cdeCmdPatch.offset, s_patchMsgLen1.offset
qbeq l_ipFrag_ProcessIp_none_1, s_cdeCmdPatch.len, 2
// 32-bit message length
add s_cdeCmdPatch.data, s_patchMsgLen1.msgLen, s_ipFragCxt.ipLen
jmp l_ipFrag_ProcessIp_none_2
l_ipFrag_ProcessIp_none_1:
// 16-bit message length
add s_cdeCmdPatch.data.w2, s_patchMsgLen1.msgLen, s_ipFragCxt.ipLen
l_ipFrag_ProcessIp_none_2:
xout XID_CDECTRL, s_cdeCmdPatch, SIZE(s_cdeCmdPatch)
qbeq l_ipFrag_ProcessIp_none_5, s_modState.chkSumCount, 1
// second message patch command
mov s_cdeCmdPatch.len, s_patchMsgLen2.msgLenSize
mov s_cdeCmdPatch.offset, s_patchMsgLen2.offset
qbeq l_ipFrag_ProcessIp_none_3, s_cdeCmdPatch.len, 2
// 32-bit message length
add s_cdeCmdPatch.data, s_patchMsgLen2.msgLen, s_ipFragCxt.ipLen
jmp l_ipFrag_ProcessIp_none_4
l_ipFrag_ProcessIp_none_3:
// 16-bit message length
add s_cdeCmdPatch.data.w2, s_patchMsgLen2.msgLen, s_ipFragCxt.ipLen
l_ipFrag_ProcessIp_none_4:
xout XID_CDECTRL, s_cdeCmdPatch, SIZE(s_cdeCmdPatch)
l_ipFrag_ProcessIp_none_5:
// Prepare and jump to the modify operation
mov r2.w0, s_ipFragCxt.ipOffset
mov r30.w0, fci_nextRoute_skipModComplete
jmp fci_modComplete5 // only patch command is allowed
l_ipFrag_Patch:
// Only one potential patch command (insert the authentication tag to the AH header)
// Local variable: r1.w0 record the payload offset from IP after the patch operation
mov r1.w0, 0
qbne l_ipFrag_NoFlush, s_modState.patchCount, 1
// Blind patch
// Set the buffer address
mov r0.w0, (PAMEM_BASE_BLIND_PATCH + 4) & 0xffff // patch address
mov r0.w2, (PAMEM_BASE_BLIND_PATCH + 4) >> 16
// Need to update the patch address for PDSP5
qbbc l_ipFrag_Patch_1, s_modCxt.flags.t_isPdsp5
add r0.b1, r0.b1, 1 // Adding 0x100 to r0.w0
l_ipFrag_Patch_1:
// read in the stub
mov r1.b2, OFFSET_BLIND_PATCH // Stub offset
lbco s_bPatchStub, PAMEM_CONST_MODIFY, r1.b2, SIZE(s_bPatchStub)
add r1.w2, s_ipFragCxt.ipHdrLen, s_ipFragCxt.ipOffset
// Verify the offset is in range, otherwise, ignore the patch command
qbgt l_ipFrag_NoFlush, s_bPatchStub.patchOffset, r1.w2
// Only the replacement command is supported since we can not change IP payload length
qbbc l_ipFrag_NoFlush, s_bPatchStub.cmdLen_insert.t_paBlindPatchOverwrite
// Advance to the patch point
// mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_ADVANCE
sub s_cdeCmdWd.byteCount, s_bPatchStub.patchOffset, r1.w2
mov r1.w0, s_cdeCmdWd.byteCount
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
// Flush out the data
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_FLUSH
and s_cdeCmdWd.byteCount, s_bPatchStub.cmdId_Len, PA_BLIND_PATCH_LEN_MASK
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
add r1.w0, r1.w0, s_cdeCmdWd.byteCount
// Do the patch
mov s_cdeCmdInD.operation, CDE_CMD_INSERT_PACKET_BUFFER
and s_cdeCmdInD.lenLsb, s_bPatchStub.cmdId_Len, PA_BLIND_PATCH_LEN_MASK
mov s_cdeCmdInD.lenMsbs, 0
mov s_cdeCmdInD.dataP, r0
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
// The packet actually advanced during the insert
// Make no change to the tracking offset since the commands are all
// relative to the original packet, not the patched packet
jmp l_ipFrag_NoFlush
.struct struct_ipv6FragUtil
.u8 nextHdr
.u8 hdrExtLen
.ends
.struct struct_ipv6FragUtil_ctr
.u16 offset
.ends
.struct struct_ipv6FragCtrl
.u8 ctrlFlag
#define finishParse t0
#define foundNonFrag t1
#define saveNextHdr t2
.u8 fragNextHdr
.u16 fragHdrOffset
.ends
.assign struct_ipv6FragUtil, r0.w0, r0.w0, ipv6FragUtil
.assign struct_ipv6FragUtil_ctr, r0.w2, r0.w2, ipv6FragUtil_ctr
.assign struct_ipv6FragCtrl, r1, r1, ipv6FragCtrl
.assign struct_ipv6Frag, r22, r23, s_ipv6Fragv1
// Macro for parsing for unfragmentable IPv6 ext headers
.macro m_ipv6FindUnfragHdr
.mparam proto
l_ipv6FindUnfragHdr0:
// Route header is non-fragmentable
qbeq l_ipv6FindUnfragHdr6, proto, IP_PROTO_NEXT_IPV6_ROUTE
// Hop-by-hop header is non-fragmentable
qbeq l_ipv6FindUnfragHdr6, proto, IP_PROTO_NEXT_IPV6_HOP_BY_HOP
//l_ipv6FindUnfragHdr1:
// qbeq l_ipv6FindUnfragHdr7, proto, IP_PROTO_NEXT_IPV6_IN_IPV4
qbeq l_ipv6FindUnfragHdr7, proto, IP_PROTO_NEXT_IPV6_NO_NEXT
qbeq l_ipv6FindUnfragHdr7, proto, IP_PROTO_NEXT_IPV6_DEST_OPT
qbeq l_ipv6FindUnfragHdr7, proto, IP_PROTO_NEXT_IPV6_FRAG
set ipv6FragCtrl.ctrlFlag.finishParse
jmp l_ipv6FindUnfragHdr7
l_ipv6FindUnfragHdr6:
set ipv6FragCtrl.ctrlFlag.foundNonFrag
// Save nextHdr for fragHdr
set ipv6FragCtrl.ctrlFlag.saveNextHdr
l_ipv6FindUnfragHdr7:
// normal processing
.endm
fci_ipv6Frag:
l_ipv6Frag_ProcessIp:
// Ip header has already been loaded
//xin XID_CDEDATA, s_Ipv6a, SIZE(s_Ipv6a)
l_ipv6Frag_ProcessIp_1:
// mtu should be 8-byte alignned
and s_ipFragCxt.mtuSize.b0, s_ipFragCxt.mtuSize.b0, 0xf8
// Save off the payload length reported by IP
add s_ipFragCxt.ipLen, s_Ipv6a.payloadLen, IPV6_HEADER_LEN_BYTES
mov s_ipFragCxt.ipHdrLen, IPV6_HEADER_LEN_BYTES
// If the packet fits in the MTU, we simply forward it
qble l_ipFrag_ProcessIp_none, s_ipFragCxt.mtuSize, s_ipFragCxt.ipLen
// Look for ipv6 non-fragmentable header
mov s_ipFragCxt.nextHdr, s_Ipv6a.next
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_ADVANCE
mov s_cdeCmdWd.byteCount, IPV6_HEADER_LEN_BYTES
l_ipv6Frag_ShiftCheck:
qbeq l_ipv6Frag_ProcessIp_none, s_ipFragCxt.nextHdr, IP_PROTO_NEXT_IPV6_FRAG // Can't frag a fragged packet
qbeq l_ipv6Frag_CheckNext, s_ipFragCxt.nextHdr, IP_PROTO_NEXT_IPV6_HOP_BY_HOP
qbeq l_ipv6Frag_CheckNext, s_ipFragCxt.nextHdr, IP_PROTO_NEXT_IPV6_ROUTE
qbeq l_ipv6Frag_CheckNext, s_ipFragCxt.nextHdr, IP_PROTO_NEXT_IPV6_DEST_OPT
jmp l_ipv6Frag_HdrDone
l_ipv6Frag_CheckNext:
// Step past the last header checked
xout XID_CDECTRL, s_cdeCmdWd, 4
// Load the next header
xin XID_CDEDATA, s_Ipv6Opt, SIZE(s_Ipv6Opt)
// Check for hdr size greater than 255
qble l_ipv6Frag_HdrDone, s_Ipv6Opt.optlen, 63
mov s_ipFragCxt.nextHdr, s_Ipv6Opt.proto
add s_cdeCmdWd.byteCount, s_Ipv6Opt.optlen, 1
lsl s_cdeCmdWd.byteCount, s_cdeCmdWd.byteCount, 3
add s_ipFragCxt.ipHdrLen, s_ipFragCxt.ipHdrLen, s_cdeCmdWd.byteCount
jmp l_ipv6Frag_ShiftCheck
l_ipv6Frag_HdrDone:
add r0, s_ipFragCxt.ipHdrLen, IPV6_OPT_FRAG_EXTENSION_LEN_BYTES
sub s_ipFragCxt.payloadSize, s_ipFragCxt.mtuSize, r0
// If the non-fragmentable portion consumes the full mtu, we can't frag
qbge l_ipv6Frag_ProcessIp_none, s_ipFragCxt.mtuSize, r0
// FragTotalSize (length of fragmentable data) = ipLen - ipHdrLen
sub s_ipFragCxt.fragTotalSize, s_ipFragCxt.ipLen, s_ipFragCxt.ipHdrLen
// Clear the frag loop index
// The entire ipFragCxt are initialized to 0
//mov s_ipFragCxt.loopOffset, 0
// Record and update the fragmentation Id
lbco s_ipFragCxt.fragId, PAMEM_CONST_CUSTOM, OFFSET_IPV6_FRAG_ID, 4
add s_ipFragCxt.fragId, s_ipFragCxt.fragId, 1
sbco s_ipFragCxt.fragId, PAMEM_CONST_CUSTOM, OFFSET_IPV6_FRAG_ID, 4
// If ipHdrLen==IPV6_HEADER_LEN_BYTES, then we still have the original IP header,
// else we need to patch
qbeq l_ipv6Frag_only_fixed_header, s_ipFragCxt.ipHdrLen, IPV6_HEADER_LEN_BYTES
// Found non-fragmentable extension header
mov s_Ipv6Opt.proto, IP_PROTO_NEXT_IPV6_FRAG
xout XID_CDEDATA, s_Ipv6Opt, SIZE(s_Ipv6Opt)
// Step past the last header we checked
xout XID_CDECTRL, s_cdeCmdWd, 4
// Patch the IPv6 header Length
mov s_cdeCmdPatch.operation, CDE_CMD_PATCH_PACKET
mov s_cdeCmdPatch.len, SIZE(s_Ipv6a.payloadLen)
add s_cdeCmdPatch.offset, s_ipFragCxt.ipOffset, OFFSET(s_Ipv6a.payloadLen)
sub s_cdeCmdPatch.data.w2, s_ipFragCxt.mtuSize, IPV6_HEADER_LEN_BYTES
xout XID_CDECTRL, s_cdeCmdPatch, SIZE(s_cdeCmdPatch)
jmp l_ipv6Frag_Loop
l_ipv6Frag_only_fixed_header:
// Set next header in IPv6 fixed header to frag
mov s_Ipv6a.next, IP_PROTO_NEXT_IPV6_FRAG
sub s_Ipv6a.payloadLen, s_ipFragCxt.mtuSize, IPV6_HEADER_LEN_BYTES
xout XID_CDEDATA, s_Ipv6a, SIZE(s_Ipv6a)
// Step past the last header we checked
xout XID_CDECTRL, s_cdeCmdWd, 4
l_ipv6Frag_Loop:
// update tx stats
set s_statsFlags.event.t_nTxIpFrag
sbco s_statsFlags.event, cStatistics, OFFSET_STATS_FLAGS, 4
zero &s_statsFlags, SIZE(s_statsFlags)
// Perform message length patching if any
qbeq l_ipv6Frag_CommonFrag_5, s_modState.chkSumCount, 0
add r1.w0, s_ipFragCxt.ipHdrLen, s_ipFragCxt.payloadSize
add r1.w0, r1.w0, IPV6_OPT_FRAG_EXTENSION_LEN_BYTES
// first message patch command
mov s_cdeCmdPatch.operation, CDE_CMD_PATCH_PACKET
mov s_cdeCmdPatch.len, s_patchMsgLen1.msgLenSize
mov s_cdeCmdPatch.offset, s_patchMsgLen1.offset
qbeq l_ipv6Frag_CommonFrag_1, s_cdeCmdPatch.len, 2
// 32-bit message length
add s_cdeCmdPatch.data, s_patchMsgLen1.msgLen, r1.w0
jmp l_ipv6Frag_CommonFrag_2
l_ipv6Frag_CommonFrag_1:
// 16-bit message length
add s_cdeCmdPatch.data.w2, s_patchMsgLen1.msgLen, r1.w0
l_ipv6Frag_CommonFrag_2:
xout XID_CDECTRL, s_cdeCmdPatch, SIZE(s_cdeCmdPatch)
qbeq l_ipv6Frag_CommonFrag_5, s_modState.chkSumCount, 1
// second message patch command
mov s_cdeCmdPatch.len, s_patchMsgLen2.msgLenSize
mov s_cdeCmdPatch.offset, s_patchMsgLen2.offset
qbeq l_ipv6Frag_CommonFrag_3, s_cdeCmdPatch.len, 2
// 32-bit message length
add s_cdeCmdPatch.data, s_patchMsgLen2.msgLen, r1.w0
jmp l_ipv6Frag_CommonFrag_4
l_ipv6Frag_CommonFrag_3:
// 16-bit message length
add s_cdeCmdPatch.data.w2, s_patchMsgLen2.msgLen, r1.w0
l_ipv6Frag_CommonFrag_4:
xout XID_CDECTRL, s_cdeCmdPatch, SIZE(s_cdeCmdPatch)
l_ipv6Frag_CommonFrag_5:
// Update and insert the Fragmentation header
mov s_cdeCmdIn2.operation, CDE_CMD_INSERT_PACKET
mov s_cdeCmdIn2.len, 4
lsl s_cdeCmdIn2.data.w2, s_ipFragCxt.nextHdr, 8
mov s_cdeCmdIn2.data.w0, s_ipFragCxt.loopOffset
// Get the payload size for this fragment
add r0, s_ipFragCxt.loopOffset, s_ipFragCxt.payloadSize
qble l_ipv6Frag_CommonFrag_6, r0, s_ipFragCxt.fragTotalSize
// There are more fragments
set s_cdeCmdIn2.data.w0.t_ipv6_frag_m
l_ipv6Frag_CommonFrag_6:
// Complete the fragmentation header
xout XID_CDECTRL, s_cdeCmdIn2, SIZE(s_cdeCmdIn2)
mov s_cdeCmdIn2.data, s_ipFragCxt.fragId
xout XID_CDECTRL, s_cdeCmdIn2, SIZE(s_cdeCmdIn2)
// specify the window move because of the potential patch operation
mov r1.w0, 0
qbeq l_ipv6Frag_Patch, s_ipFragCxt.loopOffset, 0
// Now flush any data contained in s_ipFragCxt.loopOffset
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_FLUSH
mov s_cdeCmdWd.byteCount, s_ipFragCxt.loopOffset
xout XID_CDECTRL, s_cdeCmdWd, 4
// r1.w0 store the payload offset from the IP payload due to potential patch operation
mov r1.w0, 0
l_ipv6Frag_NoFlush:
// re-enter from l_ipv6Frag_Patch as well:r1.w0 store the payload offset from the IP payload due to potential patch operation
// Slide the window past the valid data
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_ADVANCE
sub s_cdeCmdWd.byteCount, s_ipFragCxt.payloadSize, r1.w0
xout XID_CDECTRL, s_cdeCmdWd, 4
l_ipv6Frag_FragReady:
// Setup the offset for the next packet (jump out if final frag)
add s_ipFragCxt.loopOffset, s_ipFragCxt.loopOffset, s_ipFragCxt.payloadSize
qble l_ipv6Frag_LastPacket, s_ipFragCxt.loopOffset, s_ipFragCxt.fragTotalSize
// Flush out the remaining packet
l_ipv6Frag_ForwardPkt_0:
// Forward the packet
zero &s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
mov s_cdeCmdPkt.operation, CDE_CMD_PACKET_COPY
and s_cdeCmdPkt.threadId, s_nRouteStub.cmdId_N_E_Dest, PA_NEXT_ROUTE_DEST_MASK
mov s_cdeCmdPkt.optionsFlag, (CDE_FLG_TRUNCATE | CDE_FLG_SET_THREADID | CDE_FLG_SET_DESTQUEUE | CDE_FLG_SET_FLOWID | CDE_FLG_SET_PSINFO)
mov s_cdeCmdPkt.destQueue, s_nRouteStub.destQueue
mov s_cdeCmdPkt.flowId, s_nRouteStub.flowId
qbbc l_ipv6Frag_ForwardPkt, s_modState.flags.t_subsMCxtSrio
// SRIO use 8 byte PSINFO
mov s_cdeCmdPkt.psInfoSize, 8
l_ipv6Frag_ForwardPkt:
xout XID_CDECTRL, s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
// pass through
// jmp l_ipv6Frag_WaitForCopy // Let the new packet bit clear
l_ipv6Frag_WaitForCopy:
// Wait for a new packet
qbbc l_ipv6Frag_WaitForCopy, s_flags.info.tStatus_CDENewPacket
// Read packet descriptor
//
// xin XID_CDEDATA, s_pktDescr, OFFSET(s_pktDescr.pktDataSize)
qbbc l_ipv6Frag_WaitForCopy_1, s_modState.flags.t_subsMCxtSrio
// Update the pktType
mov s_pktDescr.pktType_pvtFlags, s_modState.pktType_psFlags
xout XID_CDEDATA, s_pktDescr.pktType_pvtFlags, SIZE(s_pktDescr.pktType_pvtFlags)
//jmp l_ipv6Frag_WaitForCopy_2 // the next check will fail and so jmp
l_ipv6Frag_WaitForCopy_1:
qbbc l_ipv6Frag_WaitForCopy_2, s_modState.flags.t_subsMCxtPsFlags
// Update the psFlags
mov s_pktDescr.psFlags_errorFlags, s_modState.pktType_psFlags
xout XID_CDEDATA, s_pktDescr.psFlags_errorFlags, SIZE(s_pktDescr.psFlags_errorFlags)
// Pass through
l_ipv6Frag_WaitForCopy_2:
// Update swInfo0 and swinfo1
xout XID_CDEDATA, s_pktDescr.swInfo0, 8
// Advance to the control section
mov s_cdeCmdWd.operation, CDE_CMD_ADVANCE_TO_CONTROL
xout XID_CDECTRL, s_cdeCmdWd, 4
qbbc l_ipv6Frag_WaitForCopy_3, s_modState.flags.t_subsMCxtSrio
// Insert 8 bytes of PS info
// This is legal even though the window has advanced to control
mov s_cdeInsert.operation, CDE_CMD_INSERT_PSDATA
mov s_cdeInsert.byteCount, 4
mov s_cdeInsert.bytes, s_pktDescr.swInfo0
xout XID_CDECTRL, s_cdeInsert, SIZE(s_cdeInsert)
mov s_cdeInsert.bytes, s_pktDescr.swInfo1
xout XID_CDECTRL, s_cdeInsert, SIZE(s_cdeInsert)
l_ipv6Frag_WaitForCopy_3:
// Flush out the control info
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_FLUSH
mov s_cdeCmdWd.byteCount, s_modCxt.cmdFlushBytes
xout XID_CDECTRL, s_cdeCmdWd, 4
mov s_cdeCmdWd.operation, CDE_CMD_ADVANCE_TO_PACKET
xout XID_CDECTRL, s_cdeCmdWd, 4
//mov s_cdeCmdWd.operation, CDE_CMD_FLUSH_TO_PACKET
//xout XID_CDECTRL, s_cdeCmdWd, 4
// Advance to the IP header
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_ADVANCE
mov s_cdeCmdWd.byteCount, s_ipFragCxt.ipOffset
xout XID_CDECTRL, s_cdeCmdWd, 4
// Load the packet Ip header
xin XID_CDEDATA, s_Ipv6a, SIZE(s_Ipv6a)
// Calc the size for this loop
add r0, s_ipFragCxt.loopOffset, s_ipFragCxt.payloadSize
qbge l_ipv6Frag_NoAdjust, r0, s_ipFragCxt.fragTotalSize
sub s_ipFragCxt.payloadSize, s_ipFragCxt.fragTotalSize, s_ipFragCxt.loopOffset
// pass through
l_ipv6Frag_NoAdjust:
add s_Ipv6a.payloadLen, s_ipFragCxt.payloadSize, s_ipFragCxt.ipHdrLen
sub s_Ipv6a.payloadLen, s_Ipv6a.payloadLen, IPV6_HEADER_LEN_BYTES - IPV6_OPT_FRAG_EXTENSION_LEN_BYTES
xout XID_CDEDATA, s_Ipv6a, SIZE(s_Ipv6a)
mov s_cdeCmdWd.byteCount, s_ipFragCxt.ipHdrLen
xout XID_CDECTRL, s_cdeCmdWd, 4
jmp l_ipv6Frag_Loop
l_ipv6Frag_LastPacket:
// Make sure the packet is at least 60 bytes long
//add s_modState.pktSize, s_Ip.TotalLen, s_ipFragCxt.ipOffset
jmp fci_nextRoute_skipModComplete
l_ipv6Frag_Patch:
// Only one potential patch command (insert the authentication tag to the AH header)
// Local variable: r1.w0 record the payload offset from IP after the patch operation
mov r1.w0, 0
qbne l_ipv6Frag_NoFlush, s_modState.patchCount, 1
// Blind patch
// Set the buffer address
mov r0.w0, (PAMEM_BASE_BLIND_PATCH + 4) & 0xffff // patch address
mov r0.w2, (PAMEM_BASE_BLIND_PATCH + 4) >> 16
// Need to update the patch address for PDSP5
qbbc l_ipv6Frag_Patch_1, s_modCxt.flags.t_isPdsp5
add r0.b1, r0.b1, 1 // Adding 0x100 to r0.w0
l_ipv6Frag_Patch_1:
// read in the stub
mov r1.b2, OFFSET_BLIND_PATCH // Stub offset
lbco s_bPatchStub, PAMEM_CONST_MODIFY, r1.b2, SIZE(s_bPatchStub)
add r1.w2, s_ipFragCxt.ipHdrLen, s_ipFragCxt.ipOffset
// Verify the offset is in range, otherwise, ignore the patch command
qbgt l_ipv6Frag_NoFlush, s_bPatchStub.patchOffset, r1.w2
// Only the replacement command is supported since we can not change IP payload length
qbbc l_ipv6Frag_NoFlush, s_bPatchStub.cmdLen_insert.t_paBlindPatchOverwrite
// Advance to the patch point
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_ADVANCE
sub s_cdeCmdWd.byteCount, s_bPatchStub.patchOffset, r1.w2
mov r1.w0, s_cdeCmdWd.byteCount
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
// Flush out the data
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_FLUSH
and s_cdeCmdWd.byteCount, s_bPatchStub.cmdId_Len, PA_BLIND_PATCH_LEN_MASK
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
add r1.w0, r1.w0, s_cdeCmdWd.byteCount
// Do the patch
mov s_cdeCmdInD.operation, CDE_CMD_INSERT_PACKET_BUFFER
and s_cdeCmdInD.lenLsb, s_bPatchStub.cmdId_Len, PA_BLIND_PATCH_LEN_MASK
mov s_cdeCmdInD.lenMsbs, 0
mov s_cdeCmdInD.dataP, r0
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
// The packet actually advanced during the insert
// Make no change to the tracking offset since the commands are all
// relative to the original packet, not the patched packet
jmp l_ipv6Frag_NoFlush
l_ipv6Frag_ProcessIp_none:
// Need to adjust the packet offset to be consistent with l_ipFrag_ProcessIp_none for patching operation
// Step past the last header we checked
xout XID_CDECTRL, s_cdeCmdWd, 4
l_ipv6Frag_ProcessIp_none2:
add s_ipFragCxt.ipOffset, s_ipFragCxt.ipOffset, s_ipFragCxt.ipHdrLen
jmp l_ipFrag_ProcessIp_none
.leave cdeScope
.leave pktScope
.leave ipScope
.leave modifyScope
// *********************************************************************************
// * FUNCTION PURPOSE: Parse L2 layer
// *********************************************************************************
// * DESCRIPTION: Parse L2 Layer in EQoS Mode operation
// * - Extract VLAN P-bit
// * - Extract IP DSCP value
// * - Replace VLAN ID
// * - Update flow number and Queue number per EQoS algorithm
// *
// * Register Usage:
// *
// * R0: scratch
// * R1: r1.w2: EQoS table offset (local)
// * R2: r2.w0: packet parsing offset (pass in/out)
// * R3:
// * R4: | CDE commands - cdeScope
// * R5: | -
// * R6: | L2 Header
// * R7: |
// * R8: |
// * R9: | s_paComIfEQoS
// * R10: |
// * R11: | timestamp
// * R12: | swInfo0
// * R13: | swInfo2
// * R14: | etherTypes
// * R15: |
// * R16: |
// * R17: |
// * R18: | s_paEQosScratch
// * R19: | next route stub (s_nRouteStub)
// * R20: | Modify State machine (s_modState)
// * R21: |
// * R22:
// * R23:
// * R24:
// * R25:
// * R26:
// * R27:
// * R28: statistics (s_statsFlags) - Global scope
// * R29: Modify context (s_modCxt) -
// * R30: w0-function return address -
// * R31: System Flags (s_flags) -
// *
// ***********************************************************************************
.using cdeScope
.using modifyScope
.using eQosCompScope
f_EQoS_PraseL2:
// Advance the CDE to the beginning of the packet data
mov s_cdeCmdWd.operation, CDE_CMD_ADVANCE_TO_PACKET
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
// r2.w0 has the current packet offset
// mov r2.w0, 0
//qbbc fci_modComplete1, s_modCxt.flags.t_eqos_feature
// walk through the packet to derive queue and flow
// clear vlan tag indicator, IP PKT indicator
zero &s_paEQosScratch.status, SIZE(s_paEQosScratch)
// clear the eqos queue and flow
// mov s_eqosQueueFlow, 0
// load per port configuration from the scratch memory
// get the port number to be captured and obtain the offset
mov r1.w0, OFFSET_EQOS_CFG_BASE
and r1.w2, s_modState.pktType_psFlags, 0x70
sub r1.w2, r1.w2, 0x10
lsl r1.w2, r1.w2, 8 - 4
// point to per port configuration structure
add r1.w2, r1.w2, r1.w0
// load the port control and other information
lbco s_paComIfEQoS, PAMEM_CONST_PORTCFG, r1.w2, SIZE(s_paComIfEQoS)
// Move to the VLAN offset table
add r1.w2, r1.w2, 8
// load default priority
mov r1.w0, OFFSET_EQOS_CFG_EG_DEF_PRI
lbco s_paEQosScratch.priority , PAMEM_CONST_PORTCFG, r1.w0, 1
// Pass off macAddr bytes
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_ADVANCE
mov s_cdeCmdWd.byteCount, SIZE(struct_MacAddr)
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
mov r2.w0, s_cdeCmdWd.byteCount
// Load the ethertype table from memory
lbco s_ethertypes, PAMEM_CONST_PARSE, OFFSET_ETYPE_TABLE, SIZE(s_ethertypes)
l_EQoS_ParseL2_Loop:
mov s_cdeCmdWd.byteCount, 2 // minimum 2 bytes for ethertype
// Read in enough data to cover the llc/snap header if present
xin XID_CDEDATA, s_tagOrLen, SIZE(s_tagOrLen)
mov r3, 1500
qblt l_EQoS_ParseL2_0, s_tagOrLen.len, r3
// tag/len < 1500, so verify DSP, SSAP and ctrl
//qbne l_EQoS_ParseL2_8, s_tagOrLen.dsap, 0xaa
//qbne l_EQoS_ParseL2_8, s_tagOrLen.asap, 0xaa
//qbne l_EQoS_ParseL2_8, s_tagOrLen.ctrl, 0x03
// 802.3
// Copy the new ethertype value to the common location
mov s_tagOrLen.len, s_tagOrLen.etype2
// scroll past the 8 bytes of llc/snap header
add s_cdeCmdWd.byteCount, s_cdeCmdWd.byteCount, 8
l_EQoS_ParseL2_0:
// scroll past the ethertype/llc snap
// cdeCmdWd.operation already has the value CDE_CMD_WINDOW_ADVANCE
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
// Track the active parse
add r2.w0, r2.w0, s_cdeCmdWd.byteCount
qbne l_EQoS_ParseL2_1, s_tagOrLen.len, s_ethertypes.vlan
l_EQoS_ParseL2_Vlan:
// Hdr is PA_HDR_VLAN
xin XID_CDEDATA, s_vtag.tag, SIZE(s_vtag.tag)
// Should we replace vlan id
qbbc l_EQoS_ParseL2_Vlan_1, s_paComIfEQoS.ctrlBitMap.t_eqos_vlan_override
// Clear the vlan id (lower 12 bits)
// set the new vlan id (lower 12 bits)
mov r2.w2, 0xF000
and s_vtag.tag, s_vtag.tag, r2.w2
or s_vtag.tag, s_vtag.tag, s_paComIfEQoS.vlanId
xout XID_CDEDATA, s_vtag.tag, SIZE(s_vtag.tag)
l_EQoS_ParseL2_Vlan_1:
// Indicate and store the P-bit as priority
set s_paEQosScratch.status.t_eqos_status_vlan_tag
lsr s_paEQosScratch.vlanPri, s_vtag.tag, VLAN_PCP_SHIFT
// Scroll the CDE past the tag to point to the next ethertype candidate
mov s_cdeCmdWd.byteCount, SIZE(s_vtag.tag)
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
add r2.w0, r2.w0, s_cdeCmdWd.byteCount
jmp l_EQoS_ParseL2_Loop
l_EQoS_ParseL2_1:
qbne l_EQoS_ParseL2_2, s_tagOrLen.len, s_ethertypes.Spvlan
// Hdr is PA_HDR_VLAN
// Scroll the CDE past the tag to point to the next ethertype candidate
mov s_cdeCmdWd.byteCount, SIZE(s_vtag.tag)
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
add r2.w0, r2.w0, s_cdeCmdWd.byteCount
jmp l_EQoS_ParseL2_Loop
l_EQoS_ParseL2_2:
qbne l_EQoS_ParseL2_3, s_tagOrLen.len, s_ethertypes.ip
l_EQoS_ParseL2_Ipv4:
// Hdr is PA_HDR_IPv4, get IPV4 DSCP priority
xin XID_CDEDATA, s_Ipv4qos, SIZE(s_Ipv4qos)
// Store DSCP in case we need DSCP priority routing
lsr s_paEQosScratch.dscp, s_Ipv4qos.Tos, 2
set s_paEQosScratch.status.t_eqos_status_is_ip
jmp l_EQoS_ParseL2_8
l_EQoS_ParseL2_3:
qbne l_EQoS_ParseL2_4, s_tagOrLen.len, s_ethertypes.ipv6
l_EQoS_ParseL2_Ipv6:
//next Hdr is PA_HDR_IPv6, get IpV6 DSCP priority
xin XID_CDEDATA, s_Ipv6qos, SIZE(s_Ipv6qos)
// Store DSCP in case we need DSCP priority routing
lsr s_paEQosScratch.dscp, s_Ipv6qos.ver_tclass_flow.w2, 4
lsr s_paEQosScratch.dscp, s_paEQosScratch.dscp, 2
set s_paEQosScratch.status.t_eqos_status_is_ip
jmp l_EQoS_ParseL2_8
l_EQoS_ParseL2_4:
qbne l_EQoS_ParseL2_5, s_tagOrLen.len, s_ethertypes.mpls
l_EQoS_ParseL2_Mpls:
// Hdr is PA_HDR_MPLS
// get the next ethertype to proceed and continue parsing
// Read in a single tag
xin XID_CDEDATA, s_mpls, SIZE(s_mpls)
// Advance the mpls header
mov s_cdeCmdWd.byteCount, SIZE(s_mpls.tagTtl)
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
add r2.w0, r2.w0, s_cdeCmdWd.byteCount
// Extract the S bit. If set then get a potential IP version number
// For possible IPv4 and IPv6 continue parse
qbbc l_EQoS_ParseL2_7, s_mpls.tagTtl.t_s
lsr r3.b0, s_mpls.ipVer, 4
qbeq l_EQoS_ParseL2_Ipv4, r3.b0, 4
qbeq l_EQoS_ParseL2_Ipv6, r3.b0, 6
jmp l_EQoS_ParseL2_8
l_EQoS_ParseL2_5:
qbeq l_EQoS_ParseL2_Mpls, s_tagOrLen.len, s_ethertypes.mplsMulti
// pass through
l_EQoS_ParseL2_6:
qbne l_EQoS_ParseL2_7, s_tagOrLen.len, s_ethertypes.PPPoE
l_EQoS_ParseL2_PPPoE:
// Hdr is PA_HDR_PPPoE
// get the next ethertype to proceed and continue parsing
xin XID_CDEDATA, s_pppoe, SIZE(s_pppoe)
// Read in the PPPoE header
//qbne l_EQoS_ParseL2_8, s_pppoe.verType, PPPoE_VER_TYPE
//qbne l_EQoS_ParseL2_8, s_pppoe.code, PPPoE_CODE_SESSION
// Find out the next prot
// Advance the PPPoE payload header
mov s_cdeCmdWd.byteCount, SIZE(s_pppoe)
add r2.w0, r2.w0, s_cdeCmdWd.byteCount
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
mov r2.w2, PPPoE_PROT_IPv4
qbeq l_EQoS_ParseL2_Ipv4, s_pppoe.prot, r2.w2
mov r2.w2, PPPoE_PROT_IPv6
qbeq l_EQoS_ParseL2_Ipv6, s_pppoe.prot, r2.w2
jmp l_EQoS_ParseL2_8
l_EQoS_ParseL2_7:
qbeq l_EQoS_ParseL2_PPPoE, s_tagOrLen.len, s_ethertypes.PPPoE_discov
// pass through
l_EQoS_ParseL2_8:
// Execute EQoS algorithm
// check mode, whether DSCP mode or DP-BIT mode
qbbc l_EQoS_ParseL2_DscpEqosMode, s_paComIfEQoS.ctrlBitMap.t_eqos_dp_bit_mode
qbbc l_EQoS_ParseL2_NotVlanTag, s_paEQosScratch.status.t_eqos_status_vlan_tag
mov s_paEQosScratch.priority, s_paEQosScratch.vlanPri
jmp l_EQoS_ParseL2_comp
l_EQoS_ParseL2_NotVlanTag:
qbbs l_EQoS_ParseL2_comp, s_paComIfEQoS.ctrlBitMap.t_eqos_pri_override
l_EQoS_ParseL2_DscpEqosMode:
qbbc l_EQoS_ParseL2_comp, s_paEQosScratch.status.t_eqos_status_is_ip
mov s_paEQosScratch.priority, s_paEQosScratch.dscp
add r1.w2, r1.w2, 16
// pass through
l_EQoS_ParseL2_comp:
// multiply priority by 2
lsl s_paEQosScratch.priority, s_paEQosScratch.priority, 1
// point to the dscp priority containing queue and flow offsets
add r1.w2, r1.w2, s_paEQosScratch.priority
lbco r1.w0, PAMEM_CONST_PORTCFG, r1.w2, 2
add s_nRouteStub.flowId, s_paComIfEQoS.flowBase, r1.b1
add s_nRouteStub.destQueue, s_paComIfEQoS.queueBase, r1.b0
mov s_nRouteStub.cmdId_N_E_Dest, PA_DEST_CDMA
ret
.leave cdeScope
.leave modifyScope
.leave eQosCompScope
// *********************************************************************************
// * FUNCTION PURPOSE: Packet modifications are completed
// *********************************************************************************
// * DESCRIPTION: The checksums, crcs, and blind patch commands are
// * performed.
// *
// * Register Usage:
// *
// * R0:
// * R1:
// * R2: r2.w0: current packet offset
// * R3:
// * R4: | CDE commands - cdeScope
// * R5: | -
// * R6: |
// * R7: |
// * R8: |
// * R9: |
// * R10: |
// * R11: |
// * R12: |
// * R13: |
// * R14: | scratch
// * R15: |
// * R16: |
// * R17: |
// * R18: | packet ID
// * R19: | next route stub (s_nRouteStub)
// * R20: | Modify State machine (s_modState)
// * R21: |
// * R22:
// * R23:
// * R24:
// * R25:
// * R26:
// * R27:
// * R28: statistics (s_statsFlags) - Global scope
// * R29: Modify context (s_modCxt) -
// * R30: w0-function return address -
// * R31: System Flags (s_flags) -
// *
// ***********************************************************************************
.using cdeScope
.using modifyScope
.using eQosCompScope
f_modComplete:
qbne fci_modComplete1, r2.w0, 0
// Advance the CDE to the beginning of the packet data
mov s_cdeCmdWd.operation, CDE_CMD_ADVANCE_TO_PACKET
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
// r2.w0 has the current packet offset
// mov r2.w0, 0
fci_modComplete1:
// Setup the checksums
qbeq l_modComplete3, s_modState.chkSumCount, 0
// The first checksum
lbco s_cmdChkCrc, PAMEM_CONST_MODIFY, OFFSET_INSERT_CHKSUM, SIZE(s_cmdChkCrc)
// Verify the range
qbgt l_modComplete1, s_cmdChkCrc.startOffset, r2.w0
// Scroll to the start of the first checksum
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_ADVANCE
sub s_cdeCmdWd.byteCount, s_cmdChkCrc.startOffset, r2.w0
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
sub s_cdeCmdWd.byteCount, s_cmdChkCrc.startOffset, r2.w0
add r2.w0, r2.w0, s_cdeCmdWd.byteCount
mov s_cdeCmdChk.operation, CDE_CMD_CHECKSUM1_COMPUTE
mov s_cdeCmdChk.byteLen, s_cmdChkCrc.length
mov s_cdeCmdChk.initSum, s_cmdChkCrc.initVal
mov s_cdeCmdChk.offset, s_cmdChkCrc.resultOffset
lsr s_cdeCmdChk.options, s_cmdChkCrc.flags, 7
xout XID_CDECTRL, s_cdeCmdChk, SIZE(s_cdeCmdChk)
l_modComplete1:
qbge l_modComplete3, s_modState.chkSumCount, 1
// The second checksum
lbco s_cmdChkCrc, PAMEM_CONST_MODIFY, OFFSET_INSERT_CHKSUM+SIZE(s_cmdChkCrc), SIZE(s_cmdChkCrc)
// Make sure the range is valid
qble l_modComplete2, s_cmdChkCrc.startOffset, r2.w0
// Invalid checksum specified. Discard the packet
set s_statsFlags.event.t_nCommandFail
mov s_cdeCmdPkt.operation, CDE_CMD_PACKET_FLUSH
xout XID_CDECTRL, s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
jmp f_mainLoop
l_modComplete2:
// Scroll to the start of the second checksum
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_ADVANCE
sub s_cdeCmdWd.byteCount, s_cmdChkCrc.startOffset, r2.w0
add r2.w0, r2.w0, s_cdeCmdWd.byteCount
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
mov s_cdeCmdChk.operation, CDE_CMD_CHECKSUM2_COMPUTE
mov s_cdeCmdChk.byteLen, s_cmdChkCrc.length
mov s_cdeCmdChk.initSum, s_cmdChkCrc.initVal
mov s_cdeCmdChk.offset, s_cmdChkCrc.resultOffset
lsr s_cdeCmdChk.options, s_cmdChkCrc.flags, 7
xout XID_CDECTRL, s_cdeCmdChk, SIZE(s_cdeCmdChk)
l_modComplete3:
// CRC calculation
qbbc fci_modComplete5, s_modState.flags.t_subsMCxtCrc
lbco s_cmdChkCrc, PAMEM_CONST_MODIFY, OFFSET_INSERT_CRC, SIZE(s_cmdChkCrc)
// Verify the range
qble l_modComplete4, s_cmdChkCrc.startOffset, r2.w0
// Invalid CRC specified Discard the packet
set s_statsFlags.event.t_nCommandFail
mov s_cdeCmdPkt.operation, CDE_CMD_PACKET_FLUSH
xout XID_CDECTRL, s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
// fix for conditional jump out of range
l_mod_jmp_mainloop:
jmp f_mainLoop
l_modComplete4:
// Scroll to the start of the CRC
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_ADVANCE
sub s_cdeCmdWd.byteCount, s_cmdChkCrc.startOffset, r2.w0
add r2.w0, r2.w0, s_cdeCmdWd.byteCount
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
mov s_cdeCmdChk.operation, CDE_CMD_CRC_COMPUTE
mov s_cdeCmdChk.byteLen, s_cmdChkCrc.length
mov s_cdeCmdChk.initSum, s_cmdChkCrc.initVal
mov s_cdeCmdChk.offset, s_cmdChkCrc.resultOffset
and s_cdeCmdChk.options, s_cmdChkCrc.flags, PA_CRC_FLAGS_MASK
xout XID_CDECTRL, s_cdeCmdChk, SIZE(s_cdeCmdChk)
fci_modComplete5:
qbeq l_modComplete8, s_modState.patchCount, 0
// Blind patch
mov r3.b0, 0 // Loop count
mov r3.b1, OFFSET_BLIND_PATCH // Stub offset
mov r0.w0, (PAMEM_BASE_BLIND_PATCH + 4) & 0xffff // patch address
mov r0.w2, (PAMEM_BASE_BLIND_PATCH + 4) >> 16
// Need to update the patch address for PDSP5
qbbc l_modComplete6, s_modCxt.flags.t_isPdsp5
add r0.b1, r0.b1, 1 // Adding 0x100 to r0.w0
l_modComplete6:
qbge l_modComplete8, s_modState.patchCount, r3.b0
// read in the stub
lbco s_bPatchStub, PAMEM_CONST_MODIFY, r3.b1, SIZE(s_bPatchStub)
// Verify the offset is in range
qble l_modComplete7, s_bPatchStub.patchOffset, r2.w0
// Invalid Patch. Discard the packet
set s_statsFlags.event.t_nCommandFail
mov s_cdeCmdPkt.operation, CDE_CMD_PACKET_FLUSH
xout XID_CDECTRL, s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
jmp f_mainLoop
l_modComplete7:
// Advance to the patch point
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_ADVANCE
sub s_cdeCmdWd.byteCount, s_bPatchStub.patchOffset, r2.w0
add r2.w0, r2.w0, s_cdeCmdWd.byteCount
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
// Use r14.b0 as an advance flag. In the case of data overwrite the CDE is
// not advanced after patch, but for data addition the CDE must be advanced
// to keep all of the stored patch/checksum/crc offsets correct
//mov r14.b0, 0
// If the patch is a replace then the bytes must be deleted first
qbbc l_modComplete7b, s_bPatchStub.cmdLen_insert.t_paBlindPatchOverwrite
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_FLUSH
and s_cdeCmdWd.byteCount, s_bPatchStub.cmdId_Len, PA_BLIND_PATCH_LEN_MASK
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
//mov r14.b0, 1
add r2.w0, r2.w0, s_cdeCmdWd.byteCount
//Adjust packet size
sub s_modState.pktSize, s_modState.pktSize, s_cdeCmdWd.byteCount
l_modComplete7b:
qbbs l_modComplete7c, s_bPatchStub.cmdLen_insert.t_paBlindPatchDelete
// Do the patch
mov s_cdeCmdInD.operation, CDE_CMD_INSERT_PACKET_BUFFER
and s_cdeCmdInD.lenLsb, s_bPatchStub.cmdId_Len, PA_BLIND_PATCH_LEN_MASK
mov s_cdeCmdInD.lenMsbs, 0
mov s_cdeCmdInD.dataP, r0
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
//Adjust packet size
add s_modState.pktSize, s_modState.pktSize, s_cdeCmdInD.lenLsb
// The packet actually advanced during the insert
// Make no change to the tracking offset since the commands are all
// relative to the original packet, not the patched packet
l_modComplete7c:
// context for the next loop
add r3.b0, r3.b0, 1 // Increment loop count
add r3.b1, r3.b1, 32 // Increment offset
add r0, r0, 32 // Increment absolute address
jmp l_modComplete6
l_modComplete8:
ret
.leave cdeScope
.leave modifyScope
.leave eQosCompScope
// *******************************************************************************
// * FUNCTION PURPOSE: EMAC CRC Verify Command
// *******************************************************************************
// * DESCRIPTION: Process the EMAC CRC Verify
// *
// * Register Usage:
// *
// * R0: | CRC recalculated
// * R1:
// * R2:
// * R3:
// * R4: | CDE commands - cdeScope
// * R5: |
// * R6: | CRC stored
// * R7:
// * R8:
// * R9:
// * R10:
// * R11:
// * R12:
// * R13:
// * R14:
// * R15:
// * R16:
// * R17:
// * R18:
// * R19:
// * R20: | Modify State machine (s_modState)
// * R21:
// * R22: | s_msg or s_emacCrcVerify
// * R23:
// * R24:
// * R25:
// * R26:
// * R27:
// * R28: statistics (s_statsFlags) - Global scope
// * R29: Modify context (s_modCxt) -
// * R30: w0-function return address -
// * R31: System Flags (s_flags) -
// *
// *******************************************************************************
.using cdeScope
.using pktScope // For offset info
.using modifyScope
f_emacCrcVerify:
// Flush out the control info (ignore all other commands)
mov s_cdeCmdWd.operation, CDE_CMD_FLUSH_TO_PACKET
xout XID_CDECTRL, s_cdeCmdWd, 4
// Check if the packet is a valid packet (at least has 4 bytes)
qbgt l_emacCrcVerify_badCRC, s_modState.pktSize, 4
//
// Generate CRC and place it at packet description swinfo0 for comparison
//
mov s_cdeCmd.v0, CDE_CMD_CRC_COMPUTE | ((PA_CRC_FLAG_CRC_OFFSET_VALID | PA_CRC_FLAG_CRC_OFFSET_FROM_DESC)<< 8)
//mov s_cdeCmdChk.operation, CDE_CMD_CRC_COMPUTE
//mov s_cdeCmdChk.options, PA_CRC_FLAG_CRC_OFFSET_VALID
sub s_cdeCmdChk.byteLen, s_modState.pktSize, 4
// mov s_cdeCmdChk.initSum, 0
mov s_cdeCmdChk.offset, OFFSET(s_pktDescr.swinfo0)
xout XID_CDECTRL, s_cdeCmdChk, SIZE(s_cdeCmdChk)
//Advance the packet to the end of packet (keep the same length)
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_ADVANCE
xout XID_CDECTRL, s_cdeCmdWd, 4
// Record the original CRC
xin XID_CDEDATA, r6, 4
// Trim CRC (to the current window) from the packet and hold
mov s_cdeCmd.v0, CDE_CMD_PACKET_ADVANCE | ((CDE_FLG_HOLD_PACKET | CDE_FLG_TRUNCATE)<<8)
mov s_cdeCmd.v1, (4<<8)
xout XID_CDECTRL, s_cdeCmd, 8 // Send the command
// Wait for the held packet to appear in the CDE
wbs s_flags.info.tStatus_CDEHeldPacket
// Wait for the CDE to be idle
wbc s_flags.info.tStatus_CDEBusy
// Get the CRC
lbco r0, cCdeHeldPkt, OFFSET(s_pktDescr.swinfo0), 4
// Verify CRC
qbne l_emacCrcVerify_badCRC, r0, r6
// Forward the packet out
// Patch the psflags
// Note: There will be no errorFlags for host-generated packets,
// therefor, the following code can be commented out
//
//lbco r2.b0, cCdeHeldPkt, OFFSET(s_pktDescr.psFlags_errorFlags), 1
//and r2.b0, r2.b0, NOT_PA_PKT_PS_FLAGS_MASK
//or r2.b0, r2.b0, s_emacCrcVerify.psflags
//sbco r2.b0, cCdeHeldPkt, OFFSET(s_pktDescr.psFlags_errorFlags), 1
sbco s_emacCrcVerify.psflags, cCdeHeldPkt, OFFSET(s_pktDescr.psFlags_errorFlags), 1
// Send the packet on its way
mov s_cdeCmd.v0, CDE_CMD_HPKT_RELEASE | (CDE_FLG_SET_THREADID << 8)
mov s_cdeCmdPkt.threadId, PA_DEST_ETH
xout XID_CDECTRL, s_cdeCmdPkt, SIZE( s_cdeCmdPkt)
jmp f_mainLoop
l_emacCrcVerify_badCRC:
// CRC is bad - Discard Packet
mov s_cdeCmdPkt.operation, CDE_CMD_HPKT_DISCARD
xout XID_CDECTRL, s_cdeCmdPkt, 4 // Send the command
// Increment Tx CRC drop stats
set s_statsFlags.event.t_nTxEthCrcErr
jmp f_mainLoop
.leave cdeScope
.leave pktScope
.leave modifyScope
// ***********************************************************************************
// * FUNCTION PURPOSE: Setup the system to process a PA Configure message
// ***********************************************************************************
// * DESCRIPTION: On entry the packet descriptor is in place. Where the packet
// * context would go for a normal packet instead is the start
// * of the paConfigure command.
// *
// * The f_paConfigure function requires that the packet scratch
// * field contain the packet ID, so this is put into place
// * before calling that function.
// *
// **********************************************************************************
.using pktScope
.using modifyScope
f_paSetupConfigure:
#ifdef PASS_USE_PKTID
mov s_pktCxt.scratch, s_pktDescr.pktId
#endif
jmp f_paConfigure
.leave pktScope
.leave modifyScope
// ***********************************************************************************
// * FUNCTION PURPOSE: Setup the system to process a PA Multi-route message
// ***********************************************************************************
// * DESCRIPTION: On entry the packet descriptor is in place. Where the packet
// * context would go for a normal packet instead is the start
// * of the paConfigure command.
// *
// * The f_paMultiFwd function requires the packet scratch
// * field with the packet ID, and the return address. So put it into place
// * before calling that function.
// *
// **********************************************************************************
.using pktScope
.using modifyScope
f_paSetupRxFwd:
mov r30.w0, f_mainLoop
//Enhance to handle other commands
qbbc l_paSetupRxFwd_1, s_pktCxt.flag.t_flag_multi_route
jmp f_paMultiFwd
l_paSetupRxFwd_1:
qbbs l_paSetupRxFwd_2, s_pktCxt.flag.t_flag_crc_verify // CRC verification at DSP4 or Payload split at PDSP 5
qbbs f_paRxCmdSet, s_pktCxt.flag.t_flag_cmdset
// Illeagal flag, pass through to drop the packet
f_paSetupRxFwd_end:
// drop the packet
jmp fci_mProc5
l_paSetupRxFwd_2:
qbbs f_paRxPayloadSplit, s_modCxt.flags.t_isPdsp5
jmp f_paRxVerifyCRC
.leave pktScope
.leave modifyScope
// *********************************************************************************
// * FUNCTION PURPOSE: Rx Command Set Processing
// *********************************************************************************
// * DESCRIPTION: Process all the commands in the rxcommand set
// *
// * On entry:
// * - CDE points to the Control Info section
// * - r30.w0 has the return address
// * - s_pktCxt has valid packet context
// *
// * On exit:
// * - CDE points to the end of packets
// *
// * Register Usage:
// *
// * R0:
// * R1:
// * R2:
// * R3:
// * R4: | CDE commands - cdeScope
// * R5: | -
// * R6: | Rx Command Header
// * R7: |
// * R8: | Rx Commands
// * R9: |
// * R10: |
// * R11: |
// * R12: | RxCommand Conext
// * R13: |
// * R14: |
// * R15: | Packet Data
// * R16: |
// * R17: |
// * R18: | Packet ID
// * R19: |
// * R20: | Modify State machine (s_modState)
// * R21: |
// * R22: |
// * R23: |
// * R24: | Packet context
// * R25: |
// * R26: | Packet ID
// * R27:
// * R28: statistics (s_statsFlags) - Global scope
// * R29: Modify context (s_modCxt) -
// * R30: w0-function return address -
// * R31: System Flags (s_flags) -
// *
// ************************************************************************
.using cdeScope
.using modifyScope
.using pktScope
f_paRxCmdSet:
// Scroll past and flush the control info
// mov s_cdeCmdWd.operation, CDE_CMD_FLUSH_TO_PACKET
// xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
// Delete only the pktCxt from the control info
mov s_cdeCmdWd.operation, CDE_CMD_FLUSH
mov s_cdeCmdWd.byteCount, (SIZE(s_pktCxt) + 7) & 0xf8 // Round up to multiple of 8 bytes
xout XID_CDECTRL, s_cdeCmdWd, 4
mov s_cdeCmdWd.operation, CDE_CMD_ADVANCE_TO_PACKET
xout XID_CDECTRL, s_cdeCmdWd, 4
// Clear the cmdset flag From the packet context, extract the command set index
clr s_pktCxt.flag.t_flag_cmdset
mov r0.b0, s_pktCxt5.cmdSetIdx
// zero out the processing context
zero &s_rxCmdCxt, SIZE(s_rxCmdCxt)
mov s_rxCmdCxt.psInfoSize, (SIZE(s_pktCxt) + 7) & 0xf8 // 8-byte alignment
mov s_modState2.usrDataOffset, (SIZE(s_pktCxt) + 7) & 0xf8 // 8-byte alignment
// Read the command set global comfiguration
lbco s_rxCmdSetCfg, PAMEM_CONST_CUSTOM, OFFSET_CMDSET_CFG, SIZE(s_rxCmdSetCfg)
lsl s_rxCmdCxt.cmdOffset, r0.b0, 6 // Multiply by 64 to get the mem offset
qbne l_paRxCmdSet_0, s_rxCmdSetCfg.cmdSetSize, 128
lsl s_rxCmdCxt.cmdOffset, s_rxCmdCxt.cmdOffset, 1 // Multiply by 128 to get the mem offset
l_paRxCmdSet_0:
// Load the command set header information
lbco s_rxCmdCxt, PAMEM_CONST_CMDSET_TABLE, s_rxCmdCxt.cmdOffset, 2
add s_rxCmdCxt.cmdOffset, s_rxCmdCxt.cmdOffset, SIZE(struct_paCommandSet)
// discard the packet if command set does not match
qbne l_paRxcmdSet_jmp_mProc5, s_rxCmdCxt.cmdSetIndex, r0.b0
qblt l_paRxcmdSet_jmp_mProc5, s_rxCmdCxt.nCmds, 10
jmp l_paRxcmdSet_no_jmp_mProc5
l_paRxcmdSet_jmp_mProc5:
jmp fci_mProc5
l_paRxcmdSet_no_jmp_mProc5:
fci_paRxCmdSet_1:
// number of command should never reach 0 without next route or multi-route
qbeq l_paRxCmdSet_3, s_rxCmdCxt.nCmds, 0
// Read in the command header
lbco s_rxCmdHdr, PAMEM_CONST_CMDSET_TABLE, s_rxCmdCxt.cmdOffset, SIZE(s_rxCmdHdr)
add s_rxCmdCxt.cmdOffset, s_rxCmdCxt.cmdOffset, SIZE(s_rxCmdHdr)
// Search based on expected occurance of header type
qbeq f_rxNextRoute, s_rxCmdHdr.cmd, PA_RX_CMD_NEXT_ROUTE
qbeq f_rxCrcOp, s_rxCmdHdr.cmd, PA_RX_CMD_CRC_OP
qbeq f_rxCopyData, s_rxCmdHdr.cmd, PA_RX_CMD_COPY_DATA
qbeq f_rxPatchData, s_rxCmdHdr.cmd, PA_RX_CMD_PATCH_DATA
qbeq f_rxRmHhr, s_rxCmdHdr.cmd, PA_RX_CMD_REMOVE_HDR
qbeq f_rxRmTail, s_rxCmdHdr.cmd, PA_RX_CMD_REMOVE_TAIL
qbeq f_rxMultiRoute, s_rxCmdHdr.cmd, PA_RX_CMD_MULTI_ROUTE
qbeq f_rxUsrStats, s_rxCmdHdr.cmd, PA_RX_CMD_USR_STATS
qbeq f_rxVerifyPktErr, s_rxCmdHdr.cmd, PA_RX_CMD_VERIFY_PKT_ERROR
qbeq f_rxSplitOp, s_rxCmdHdr.cmd, PA_RX_CMD_SPLIT
l_paRxCmdSet_2:
// illegal command included, discard the packet
jmp fci_mProc5
l_paRxCmdSet_3:
// number of command should never reach 0 without next route or multi-route
// forward the packet as if the next route command without multi-route or other special routes present
mov s_rxCmdNextRoute.ctrlFlags, 0
jmp fci_rxNextRoute0
f_rxNextRoute:
// Read in the nextRoute header
lbco s_rxCmdNextRoute, PAMEM_CONST_CMDSET_TABLE, s_rxCmdCxt.cmdOffset, SIZE(s_rxCmdNextRoute)
//It is the last command to be processed. It is not necessary to update the command offset
//add s_rxCmdCxt.cmdOffset, s_rxCmdCxt.cmdOffset, SIZE(s_rxCmdNextRoute)
fci_rxNextRoute0:
// TBD: Use usrDataOffset to handle more general operation
//qbbs l_rxNextRoute2, s_modState2.flags.t_rx_cmd_ctrl_no_ctx
qbbc l_rxNextRoute1, s_modState2.flags.t_rx_cmd_ctrl_no_hdr
// The header has been removed, adjust offsets
sub s_pktCxt.endOffset, s_pktCxt.endOffset, s_pktCxt.startOffset
mov s_pktCxt.startOffset, 0
l_rxNextRoute1:
// update and copy pkt context
// adjust the end offset with the number of insertion bytes
mov r1.w0, 0
qbbc l_rxNextRoute1_1, s_rxCmdCxt.updateLen.t7
// negative number, 1 extension
mov r1.b1, 0xff
l_rxNextRoute1_1:
mov r1.b0, s_rxCmdCxt.updateLen
add s_pktCxt.endOffset, s_pktCxt.endOffset, r1.w0
and s_pktCxt.paCmdId_Length, s_pktCxt.paCmdId_Length, 0xe0
add s_pktCxt.paCmdId_Length, s_pktCxt.paCmdId_Length, s_modState2.usrDataOffset
sub r0.b0, s_modState2.usrDataOffset, 4
wbs s_flags.info.tStatus_CDEOutPacket
sbco s_pktCxt, cCdeOutPkt, SIZE(s_pktDescr), b0
l_rxNextRoute2:
qbbs l_rxNextRoute4, s_rxCmdNextRoute.ctrlFlags.t_rx_cmd_next_route_ctrl_emac_route
// Prepare the packet command
mov s_cdeCmdPkt.threadId, PA_DEST_CDMA
mov s_cdeCmdPkt.optionsFlag, (CDE_FLG_SET_THREADID | CDE_FLG_SET_PSINFO)
mov s_cdeCmdPkt.psInfoSize, s_rxCmdCxt.psInfoSize
qbbs l_rxNextRoute3, s_rxCmdNextRoute.ctrlFlags.t_rx_cmd_next_route_ctrl_multi_route
// Note: We do not support payload split and multi-route within the same command set
qbbc l_rxNextRoute2_1, s_pktCxt.flag.t_flag_split
// Store payload split context
add r0.b0, s_modState2.usrDataOffset, SIZE(s_pktDescr) - 4
wbs s_flags.info.tStatus_CDEOutPacket
sbco s_modState2.hdrSize, cCdeOutPkt, r0.b0, SIZE(s_rxCmdSplitCxt)
// forward packet to PDSP5
mov s_cdeCmdPkt.threadId, PA_DEST_PA_M_1
// pass through
l_rxNextRoute2_1:
// Forward the packet
mov s_cdeCmdPkt.operation, CDE_CMD_PACKET_ADVANCE
xout XID_CDECTRL, s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
// Next route must be the end of rx command
ret
l_rxNextRoute3:
// Copy the packet and then perform multi-route
mov s_cdeCmdPkt.operation, CDE_CMD_PACKET_COPY
xout XID_CDECTRL, s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
// Debug code and patch (new packet is ready)
// Read the descriptor
// xin XID_CDEDATA, s_pktDescr, SIZE(s_pktDescr)
// The context is read from the control section. Advance
// to the control section
mov s_cdeCmdWd.operation, CDE_CMD_ADVANCE_TO_CONTROL
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
// Insert 32 bytes of PS info
// This is legal even though the window has advanced to control
mov s_cdeInsert.operation, CDE_CMD_INSERT_PSDATA
mov s_cdeInsert.byteCount, 32
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
// Scroll past and flush the control info
mov s_cdeCmdWd.operation, CDE_CMD_FLUSH_TO_PACKET
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
// store the multi-route index
lsl s_pktCxt2.eP1C2Id, s_rxCmdNextRoute.multiRouteIndex, PKT2_EIDX_SHIFT // set the multi route index
jmp fci_paMultiFwd1 // It does not return here
l_rxNextRoute4:
qbbc l_rxNextRoute4_1, s_rxCmdNextRoute.ctrlFlags.t_rx_cmd_next_route_ctrl_psflags_valid
//patch the psFlags
lbco r2.b0, cCdeOutPkt, OFFSET(s_pktDescr.psFlags_errorFlags), 1
and r2.b0, r2.b0, NOT_PA_PKT_PS_FLAGS_MASK
or r2.b0, r2.b0, s_rxCmdNextRoute.psFlags
sbco r2.b0, cCdeOutPkt, OFFSET(s_pktDescr.psFlags_errorFlags), 1
l_rxNextRoute4_1:
ldi r4, CDE_CMD_PACKET_ADVANCE | ((CDE_FLG_SET_THREADID | CDE_FLG_SET_PSINFO) << 8)
mov s_cdeCmdPkt.psInfoSize, 0
mov s_cdeCmdPkt.threadId, PA_DEST_ETH
xout XID_CDECTRL, s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
ret
f_rxCrcOp:
// Scratch variables: r1.w0 CRC length
// r1.b2 payload offset to the byte CRC calculation starts
// r1.b3 frame type
// Read in the crcOP header
lbco s_rxCmdCrcOp, PAMEM_CONST_CMDSET_TABLE, s_rxCmdCxt.cmdOffset, SIZE(s_rxCmdCrcOp)
add s_rxCmdCxt.cmdOffset, s_rxCmdCxt.cmdOffset, SIZE(s_rxCmdCrcOp)
sub s_rxCmdCxt.nCmds, s_rxCmdCxt.nCmds, 1
// Initialize CRC length to len, payload offset to 0
mov r1.w0, s_rxCmdCrcOp.len
mov r1.b2, 0
// Adjust offset fields related to the parsed header
add s_rxCmdCrcOp.startOffset, s_rxCmdCrcOp.startOffset, s_pktCxt.startOffset
add s_rxCmdCrcOp.crcOffset, s_rxCmdCrcOp.crcOffset, s_pktCxt.startOffset
qbbc l_rxCrcOp1, s_rxCmdCrcOp.ctrlFlags.t_rx_cmd_crc_op_ctrl_len_in_header
qbbc l_rxCrcOp_lenOffset_1, s_rxCmdCrcOp.ctrlFlags.t_rx_cmd_crc_op_ctrl_len_offset_negative
qblt fci_paRxCmdSet_1, s_rxCmdCrcOp.lenOffset, s_pktCxt.startOffset
sub s_rxCmdCrcOp.lenOffset, s_pktCxt.startOffset, s_rxCmdCrcOp.lenOffset
jmp l_rxCrcOp_lenOffset_2
l_rxCrcOp_lenOffset_1:
add s_rxCmdCrcOp.lenOffset, s_rxCmdCrcOp.lenOffset, s_pktCxt.startOffset
l_rxCrcOp_lenOffset_2:
// Extract and adjust the payload length from pktIn sideband data
add r0.w2, s_rxCmdCrcOp.lenOffset, (32+32)
// wait for the sideband data to be ready
wbc s_flags.info.tStatus_CDEBusy
lbco r14.w2, cCdeInPkt, r0.w2, 2
and r1.w0, r14.w2, s_rxCmdCrcOp.lenMask
sub r1.w0, r1.w0, s_rxCmdCrcOp.lenAdjust
l_rxCrcOp1:
qbbc l_rxCrcOp2, s_rxCmdCrcOp.ctrlFlags.t_rx_cmd_crc_op_ctrl_frame_type_included
//calculate the payload offset based on the frame type
// FP HS-DSCH Type 2:
// n = number of PDUs at b15:b11
// payload offset = 6 + 2.5n (n: even)
// = 6 + 2.5n + 0.5 (n:odd)
// FP HS-DSCH Type 3:
// n = number of PDUs at b7:b3
// payload offset = 4 + 2.5n (n: even)
// = 4 + 2.5n + 0.5 (n:odd)
// Extract pkt Info from pktIn sideband data
add r0.w2, s_rxCmdCrcOp.startOffset, (32+32)
// wait for the sideband data to be ready
wbc s_flags.info.tStatus_CDEBusy
lbco r14, cCdeInPkt, r0.w2, 4
and r1.b3, s_rxCmdCrcOp.ctrlFlags, PA_RX_CMD_CRC_OP_FRAME_TYPE_MASK
qbne l_rxCrcOp_type_hs_dsch_type3, r1.b3, PA_RX_CMD_CRC_OP_FRAME_TYPE_IUB_FP_HS_DSCH_TYPE2
l_rxCrcOp_type_hs_dsch_type2:
lsr r14.b1, r14.b1, 3
mov r1.b2, 6
jmp l_rxCrcOp_payload_offset
l_rxCrcOp_type_hs_dsch_type3:
lsr r14.b1, r14.b0, 3
mov r1.b2, 4
l_rxCrcOp_payload_offset:
lsl r14.b2, r14.b1, 1 // 2n
lsr r14.b3, r14.b1, 1 // 0.5n
add r14.b2, r14.b2, r14.b3
add r1.b2, r1.b2, r14.b2
qbbc l_rxCrcOp_payload_offset_2, r14.b1, 0
add r1.b2, r1.b2, 1
l_rxCrcOp_payload_offset_2:
// adjust start offset
add s_rxCmdCrcOp.startOffset, s_rxCmdCrcOp.startOffset, r1.b2
// pass through
l_rxCrcOp2:
// Ignore the command if the current location passes over the CRC or message message offset
qblt fci_paRxCmdSet_1, s_rxCmdCxt.pktOffset, s_rxCmdCrcOp.startOffset
// Scroll to the CRC or payload start offset
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_ADVANCE
sub s_cdeCmdWd.byteCount, s_rxCmdCrcOp.startOffset, s_rxCmdCxt.pktOffset
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
mov s_rxCmdCxt.pktOffset, s_rxCmdCrcOp.startOffset
zero &s_cdeCmdCrcChk, SIZE(s_cdeCmdCrcChk)
qbbs l_rxCrcOp3 , s_rxCmdCrcOp.ctrlFlags.t_rx_cmd_crc_op_ctrl_crc_follow_payload
// crc offset should be specified
set s_cdeCmdCrcChk.options.t_cde_crc_cmd_option_crcOffset
sub s_cdeCmdCrcChk.offset, s_rxCmdCrcOp.crcOffset, s_rxCmdCrcOp.startOffset
l_rxCrcOp3:
mov s_cdeCmdCrcChk.operation, CDE_CMD_CRC_VALIDATE
sub s_cdeCmdCrcChk.byteLen, r1.w0, r1.b2
xout XID_CDECTRL, s_cdeCmdCrcChk, SIZE(s_cdeCmdCrcChk)
jmp fci_paRxCmdSet_1
f_rxSplitOp:
// Scratch variables: r1.b2 payload offset to the byte CRC calculation starts
// Read in the splitOp configuration
lbco s_rxCmdSplitOp, PAMEM_CONST_CMDSET_TABLE, s_rxCmdCxt.cmdOffset, SIZE(s_rxCmdSplitOp)
add s_rxCmdCxt.cmdOffset, s_rxCmdCxt.cmdOffset, SIZE(s_rxCmdSplitOp)
sub s_rxCmdCxt.nCmds, s_rxCmdCxt.nCmds, 1
// Adjust offset fields related to the parsed header
add s_modState2.hdrSize, s_rxCmdSplitOp.startOffset, s_pktCxt.startOffset
l_rxSplitOp1:
qbbc l_rxSplitOp2, s_rxCmdSplitOp.ctrlFlags.t_rx_cmd_split_op_ctrl_frame_type_included
//calculate the payload offset based on the frame type
// FP HS-DSCH Type 2:
// n = number of PDUs at b15:b11
// payload offset = 6 + 2.5n (n: even)
// = 6 + 2.5n + 0.5 (n:odd)
// FP HS-DSCH Type 3:
// n = number of PDUs at b7:b3
// payload offset = 4 + 2.5n (n: even)
// = 4 + 2.5n + 0.5 (n:odd)
// Extract pkt Info from pktIn sideband data
add r0.w2, s_modState2.hdrSize, (32+32)
// wait for the sideband data to be ready
wbc s_flags.info.tStatus_CDEBusy
lbco r14, cCdeInPkt, r0.w2, 4
qbne l_rxSplitOp_type_hs_dsch_type3, s_rxCmdSplitOp.frameType, PA_RX_CMD_CRC_OP_FRAME_TYPE_IUB_FP_HS_DSCH_TYPE2
l_rxSplitOp_type_hs_dsch_type2:
lsr r14.b1, r14.b1, 3
mov r1.b2, 6
jmp l_rxSplitOp_payload_offset
l_rxSplitOp_type_hs_dsch_type3:
lsr r14.b1, r14.b0, 3
mov r1.b2, 4
l_rxSplitOp_payload_offset:
lsl r14.b2, r14.b1, 1 // 2n
lsr r14.b3, r14.b1, 1 // 0.5n
add r14.b2, r14.b2, r14.b3
add r1.b2, r1.b2, r14.b2
qbbc l_rxSplitOp_payload_offset_2, r14.b1, 0
add r1.b2, r1.b2, 1
l_rxSplitOp_payload_offset_2:
// adjust start offset
add s_modState2.hdrSize, s_modState2.hdrSize, r1.b2
// pass through
l_rxSplitOp2:
// Store the split context at the end of pktInfo and set the indication flag
set s_pktCxt.flag.t_flag_split
qble l_rxSplitOp3, s_modState2.usrDataOffset, 8
// Need to reserve 8-byte for payload splitting operation
mov s_modState2.usrDataOffset, 8
l_rxSplitOp3:
// Record payload splitting parameters
mov s_modState2.destQueue, s_rxCmdSplitCxt.destQueue
mov s_modState2.flowId, s_rxCmdSplitCxt.flowId
jmp fci_paRxCmdSet_1
f_rxCopyData:
// Read in the copy header
lbco s_rxCmdCopy, PAMEM_CONST_CMDSET_TABLE, s_rxCmdCxt.cmdOffset, SIZE(s_rxCmdCopy)
add s_rxCmdCxt.cmdOffset, s_rxCmdCxt.cmdOffset, SIZE(s_rxCmdCopy)
sub s_rxCmdCxt.nCmds, s_rxCmdCxt.nCmds, 1
qbbs l_rxCopyData1, s_rxCmdCopy.ctrlFlags.t_rx_cmd_copy_ctrl_from_end
// Adjust length fields related to the parsed header
add s_rxCmdCopy.srcOffset, s_rxCmdCopy.srcOffset, s_pktCxt.startOffset
jmp l_rxCopyData2
l_rxCopyData1:
sub s_rxCmdCopy.srcOffset, s_pktCxt.endOffset, s_rxCmdCopy.numBytes
l_rxCopyData2:
// Read copy data from pktIn sideband data
add r0.w2, s_rxCmdCopy.srcOffset, (32+32)
// wait for the sideband data to be ready
wbc s_flags.info.tStatus_CDEBusy
lbco r14, cCdeInPkt, r0.w2, 16
// Ignore the command if the expected copy exceeds the limit
add r0.b0, s_rxCmdCopy.destOffset, s_rxCmdCopy.numBytes
qblt fci_paRxCmdSet_1, r0.b0, 32
qble l_rxCopyData2_1, s_rxCmdCxt.psInfoSize, r0.b0
add s_rxCmdCxt.psInfoSize, r0.b0, 3
and s_rxCmdCxt.psInfoSize, s_rxCmdCxt.psInfoSize, 0xfc
l_rxCopyData2_1:
// Special check if payload splitting is enabled
qbbc l_rxCopyData2_2, s_pktCxt.flag.t_flag_split
// The first 8-byte is reserved for pktInfo and payload splitting context
qbgt fci_paRxCmdSet_1, s_rxCmdCopy.destOffset, 8
// pass through
l_rxCopyData2_2:
qble l_rxCopyData3, s_rxCmdCopy.destOffset, s_modState2.usrDataOffset
and s_modState2.usrDataOffset, s_rxCmdCopy.destOffset, 0xfc
//jmp l_rxCopyData3
// pass through
l_rxCopyData2_3:
// TBD: Determine whether the packet context should be overwritten
// qble l_rxCopyData3, s_rxCmdCopy.destOffset, SIZE(s_pktCxt)
// set s_modState2.flags.t_rx_cmd_ctrl_no_ctx
l_rxCopyData3:
// copy the data
mov r0.b0, s_rxCmdCopy.numBytes
add r0.b1, s_rxCmdCopy.destOffset, SIZE(s_pktDescr)
wbs s_flags.info.tStatus_CDEOutPacket
sbco r14, cCdeOutPkt, r0.b1, b0
jmp fci_paRxCmdSet_1
f_rxPatchData:
// Scratch: r0.w2: patch data offset
// Read in the patch header
sub r0.b0, s_rxCmdHdr.len, SIZE(s_rxCmdHdr)
lbco s_rxCmdPatch, PAMEM_CONST_CMDSET_TABLE, s_rxCmdCxt.cmdOffset, b0
add r0.w2, s_rxCmdCxt.cmdOffset, 4
add s_rxCmdCxt.cmdOffset, s_rxCmdCxt.cmdOffset, r0.b0
sub s_rxCmdCxt.nCmds, s_rxCmdCxt.nCmds, 1
qbbc l_rxPatchData1, s_rxCmdPatch.ctrlFlags.t_rx_cmd_patch_ctrl_mac_hdr
// MAC patch: replace the entire MAC header
// Ignore the command if the packet offset is non-zero since MAC patch has to be the first command
qbne fci_paRxCmdSet_1, s_rxCmdCxt.pktOffset, 0
//
// Note: Make sure that the l3Offset points to the outer IP
//
qbne l_rxPatchData0, s_pktCxt.l3Offset, 0
mov s_pktCxt.l3Offset, s_pktCxt.startOffset
l_rxPatchData0:
// flush out the original MAC header
mov s_cdeCmdWd.operation, CDE_CMD_FLUSH
mov s_cdeCmdWd.byteCount, s_pktCxt.l3Offset
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
mov s_rxCmdCxt.pktOffset, s_pktCxt.l3Offset
jmp l_rxPatchData2
l_rxPatchData1:
// Normal Patch opertaion
add s_rxCmdPatch.offset, s_rxCmdPatch.offset, s_pktCxt.startOffset
// Ignore the command if the current location passes over the Patch start offset
qblt fci_paRxCmdSet_1, s_rxCmdCxt.pktOffset, s_rxCmdPatch.offset
// Scroll to the Patch start offset
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_ADVANCE
sub s_cdeCmdWd.byteCount, s_rxCmdPatch.offset, s_rxCmdCxt.pktOffset
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
mov s_rxCmdCxt.pktOffset, s_rxCmdPatch.offset
qbbc l_rxPatchData1_1, s_rxCmdPatch.ctrlFlags.t_rx_cmd_patch_ctrl_delete
// Delete Data
mov s_cdeCmdWd.operation, CDE_CMD_FLUSH
mov s_cdeCmdWd.byteCount, s_rxCmdPatch.numBytes
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
//
// Adjust the hdrSize if some of the header portion is deleted
//
qbge l_rxPatchData1_0, s_modState2.hdrSize, s_rxCmdCxt.pktOffset
sub r0.b0, s_modState2.hdrSize, s_rxCmdCxt.pktOffset
qbge l_rxPatchData1_00, r0.b0, s_rxCmdPatch.numBytes
sub s_modState2.hdrSize, s_modState2.hdrSize, s_rxCmdPatch.numBytes
jmp l_rxPatchData1_0
l_rxPatchData1_00:
sub s_modState2.hdrSize, s_modState2.hdrSize, r0.b0
// pass through
l_rxPatchData1_0:
//adjust the pktOffset and length
add s_rxCmdCxt.pktOffset, s_rxCmdCxt.pktOffset, s_rxCmdPatch.numBytes
//sub s_pktCxt.endOffset, s_pktCxt.endOffset, s_rxCmdPatch.numBytes
sub s_rxCmdCxt.updateLen, s_rxCmdCxt.updateLen, s_rxCmdPatch.numBytes
jmp fci_paRxCmdSet_1
l_rxPatchData1_1:
qbbs l_rxPatchData2, s_rxCmdPatch.ctrlFlags.t_rx_cmd_patch_ctrl_insert
// Patch data
mov r0.b0, s_rxCmdPatch.numBytes
lbco r14, PAMEM_CONST_CMDSET_TABLE, r0.w2, b0
xout XID_CDEDATA, r14, b0
jmp fci_paRxCmdSet_1
l_rxPatchData2:
// Insert command
mov s_cdeCmdInD.dataP.w2, PAMEM_BASE_CMDSET_TABLE >> 16
mov s_cdeCmdInD.dataP.w0, PAMEM_BASE_CMDSET_TABLE & 0xffff
mov s_cdeCmdInD.operation, CDE_CMD_INSERT_PACKET_BUFFER
mov s_cdeCmdInD.lenLsb, s_rxCmdPatch.numBytes
mov s_cdeCmdInD.lenMsbs, 0
add s_cdeCmdInD.dataP.w0, s_cdeCmdInD.dataP.w0, r0.w2
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdInD)
qbbc l_rxPatchData3, s_rxCmdPatch.ctrlFlags.t_rx_cmd_patch_ctrl_mac_hdr
// Assume that there is no other command which will adjust the packet length if
// MAC routing is required
// Adjust the startOffset and the endOffset
//add s_pktCxt.endOffset, s_pktCxt.endOffset, s_rxCmdPatch.numBytes
//sub s_pktCxt.endOffset, s_pktCxt.endOffset, s_pktCxt.l3Offset
sub s_rxCmdCxt.updateLen, s_rxCmdPatch.numBytes, s_pktCxt.l3Offset
qbeq l_rxPatchData2_1, s_pktCxt.l4Offset, 0
add s_pktCxt.l4Offset, s_pktCxt.l4Offset, s_rxCmdPatch.numBytes
sub s_pktCxt.l4Offset, s_pktCxt.l4Offset, s_pktCxt.l3Offset
l_rxPatchData2_1:
qbeq l_rxPatchData2_2, s_pktCxt.l5Offset, 0
add s_pktCxt.l5Offset, s_pktCxt.l5Offset, s_rxCmdPatch.numBytes
sub s_pktCxt.l5Offset, s_pktCxt.l5Offset, s_pktCxt.l3Offset
l_rxPatchData2_2:
qbeq l_rxPatchData2_3, s_pktCxt.espAhOffset, 0
add s_pktCxt.espAhOffset, s_pktCxt.espAhOffset, s_rxCmdPatch.numBytes
sub s_pktCxt.espAhOffset, s_pktCxt.espAhOffset, s_pktCxt.l3Offset
l_rxPatchData2_3:
qbeq l_rxPatchData2_4, s_pktCxt6.l3Offset2, 0
add s_pktCxt6.l3Offset2, s_pktCxt6.l3Offset2, s_rxCmdPatch.numBytes
sub s_pktCxt6.l3Offset2, s_pktCxt6.l3Offset2, s_pktCxt.l3Offset
l_rxPatchData2_4:
add s_pktCxt.startOffset, s_pktCxt.startOffset, s_rxCmdPatch.numBytes
sub s_pktCxt.startOffset, s_pktCxt.startOffset, s_pktCxt.l3Offset
mov s_pktCxt.l3Offset, s_rxCmdPatch.numBytes
jmp fci_paRxCmdSet_1
l_rxPatchData3:
//
// We can not adjust the end packet offset until the packet is ready to be forwarded
// Record the size of the data insertion here (insert size <= 16)
//
//
//and r1.b0, s_rxCmdCxt.ctrl, PA_RX_CMD_INS_SIZE_MASK
//add r1.b0, r1.b0, s_rxCmdPatch.numBytes
//and s_rxCmdCxt.ctrl, s_rxCmdCxt.ctrl, NOT_PA_RX_CMD_INS_SIZE_MASK
//add s_rxCmdCxt.ctrl, s_rxCmdCxt.ctrl, r1.b0
//
// Adjust the hdrSize if data is inserted into the header
//
qbgt l_rxPatchData3_1, s_modState2.hdrSize, s_rxCmdCxt.pktOffset
add s_modState2.hdrSize, s_modState2.hdrSize, s_rxCmdPatch.numBytes
// pass through
l_rxPatchData3_1:
add s_rxCmdCxt.updateLen, s_rxCmdCxt.updateLen, s_rxCmdPatch.numBytes
jmp fci_paRxCmdSet_1
f_rxRmHhr:
sub s_rxCmdCxt.nCmds, s_rxCmdCxt.nCmds, 1
// Ignore the command if pkt offset is not zero
qbne fci_paRxCmdSet_1, s_rxCmdCxt.pktOffset, 0
mov s_rxCmdCxt.pktOffset, s_pktCxt.startOffset
set s_modState2.flags.t_rx_cmd_ctrl_no_hdr
// Scroll to the start of the first checksum
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_FLUSH
mov s_cdeCmdWd.byteCount, s_pktCxt.startOffset
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
jmp fci_paRxCmdSet_1
f_rxRmTail:
sub s_rxCmdCxt.nCmds, s_rxCmdCxt.nCmds, 1
// Ignore the command if pkt offset exceeds the end of packet
qblt fci_paRxCmdSet_1, s_rxCmdCxt.pktOffset, s_pktCxt.endOffset
// Scroll to the end of parsed packet
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_ADVANCE
sub s_cdeCmdWd.byteCount, s_pktCxt.endOffset, s_rxCmdCxt.pktOffset
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
mov s_rxCmdCxt.pktOffset, s_pktCxt.endOffset
// Flush out the tail
//mov s_cdeCmdWd.operation, CDE_CMD_FLUSH_TO_END
// TBD: It is a temporary patch due to a simulator bug
// the original code should e be restored when the simulator fix is available
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_FLUSH
sub s_cdeCmdWd.byteCount, s_pktDescr.pktDataSize, s_pktCxt.endOffset
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
jmp fci_paRxCmdSet_1
f_rxUsrStats:
sub s_rxCmdCxt.nCmds, s_rxCmdCxt.nCmds, 1
// store the user statistics info
mov s_rxUsrStatsReq.index, s_rxCmdUsrStats.index
mov s_rxUsrStatsReq.pktSize, s_pktCxt.endOffset
// Call the common user-statistic update routine
call f_usrStatsUpdate
jmp fci_paRxCmdSet_1
f_rxMultiRoute:
// store the multi-route index
lsl s_pktCxt2.eP1C2Id, s_rxCmdMultiRoute.index, PKT2_EIDX_SHIFT // set the multi route index
jmp fci_paMultiFwd1 // It does not return here
f_rxVerifyPktErr:
// Read in the verifyPktErrCmd
lbco s_rxCmdVerifyPktErr, PAMEM_CONST_CMDSET_TABLE, s_rxCmdCxt.cmdOffset, SIZE(s_rxCmdVerifyPktErr)
add s_rxCmdCxt.cmdOffset, s_rxCmdCxt.cmdOffset, SIZE(s_rxCmdVerifyPktErr)
sub s_rxCmdCxt.nCmds, s_rxCmdCxt.nCmds, 1
// load the error flags
lbco r0.b0, cCdeInPkt, OFFSET(struct_pktDscFine.psFlags_errorFlags), 1
and r0.b0, r0.b0, s_rxCmdVerifyPktErr.errMask
// Process the next command if no err
qbeq fci_paRxCmdSet_1, r0.b0, 0
// Forward the error packet accordingly
// Forwarding packets to the host
qbne l_rxVerifyPktErr_2, s_rxCmdVerifyPktErr.forwardType, PA_FORWARD_TYPE_HOST
// Patch swinfo0
wbs s_flags.info.tStatus_CDEOutPacket
sbco s_rxCmdVerifyPktErr.swInfo0, cCdeOutPkt, OFFSET(s_pktDescr.swinfo0), 4
//qbbs l_rxVerifyPktErr_1_3, s_modState2.flags.t_rx_cmd_ctrl_no_ctx
qbbc l_rxVerifyPktErr_1_1, s_modState2.flags.t_rx_cmd_ctrl_no_hdr
// The header has been removed, adjust offsets
sub s_pktCxt.endOffset, s_pktCxt.endOffset, s_pktCxt.startOffset
mov s_pktCxt.startOffset, 0
l_rxVerifyPktErr_1_1:
// update and copy pkt context
// adjust the end offset with the number of insertion bytes
//and r1.b0, s_rxCmdCxt.ctrl, PA_RX_CMD_INS_SIZE_MASK
//add s_pktCxt.endOffset, s_pktCxt.endOffset, r1.b0
mov r1.w0, 0
qbbc l_rxVerifyPktErr_1_2, s_rxCmdCxt.updateLen.t7
// negative number, 1 extension
mov r1.b1, 0xff
l_rxVerifyPktErr_1_2:
mov r1.b0, s_rxCmdCxt.updateLen
add s_pktCxt.endOffset, s_pktCxt.endOffset, r1.w0
//wbs s_flags.info.tStatus_CDEOutPacket (wait above)
sub r0.b0, s_modState2.usrDataOffset, 4
sbco s_pktCxt, cCdeOutPkt, SIZE(s_pktDescr), b0
l_rxVerifyPktErr_1_3:
l_rxVerifyPktErr_1_3_queue_bounce:
// Check for Queue Bounce operation
l_rxVerifyPktErr_1_3_queue_bounce_ddr:
qbbc l_rxVerifyPktErr_1_3_queue_bounce_msmc, s_rxCmdVerifyPktErr.queue.t_pa_forward_queue_bounce_ddr
clr s_rxCmdVerifyPktErr.queue.t_pa_forward_queue_bounce_ddr
sbco s_rxCmdVerifyPktErr.queue, cCdeOutPkt, OFFSET(s_pktDescr.swinfo1) + 2, 2
lbco s_rxCmdVerifyPktErr.queue, PAMEM_CONST_CUSTOM, OFFSET_QUEUE_BOUNCE_CFG, 2
jmp l_rxVerifyPktErr_1_3_queue_bounce_end
l_rxVerifyPktErr_1_3_queue_bounce_msmc:
qbbc l_rxVerifyPktErr_1_3_queue_bounce_end, s_rxCmdVerifyPktErr.queue.t_pa_forward_queue_bounce_msmc
clr s_rxCmdVerifyPktErr.queue.t_pa_forward_queue_bounce_msmc
sbco s_rxCmdVerifyPktErr.queue, cCdeOutPkt, OFFSET(s_pktDescr.swinfo1) + 2, 2
lbco s_rxCmdVerifyPktErr.queue, PAMEM_CONST_CUSTOM, OFFSET_QUEUE_BOUNCE_CFG+2, 2
// pass through
l_rxVerifyPktErr_1_3_queue_bounce_end:
// Send the packet on its way
ldi r4, CDE_CMD_PACKET_ADVANCE | ((CDE_FLG_SET_THREADID | CDE_FLG_SET_PSINFO | CDE_FLG_SET_FLOWID | CDE_FLG_SET_DESTQUEUE) << 8)
mov s_cdeCmdPkt.psInfoSize, s_rxCmdCxt.psInfoSize
mov s_cdeCmdPkt.threadId, PA_DEST_CDMA
mov s_cdeCmdPkt.destQueue, s_rxCmdVerifyPktErr.queue
mov s_cdeCmdPkt.flowId, s_rxCmdVerifyPktErr.flowId
xout XID_CDECTRL, s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
ret
l_rxVerifyPktErr_2:
// Only supported forward types: Host, Discard
// Discard the packet
mov s_cdeCmdPkt.operation, CDE_CMD_PACKET_FLUSH
xout XID_CDECTRL, s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
ret
.leave cdeScope
.leave modifyScope
.leave pktScope
// *********************************************************************************
// * FUNCTION PURPOSE: Rx CRC Verification Processing
// *********************************************************************************
// * DESCRIPTION: Verify the CRC calculation result with pre-stored data
// *
// * On entry:
// * - CDE points to the Control Info section
// * - r30.w0 has the return address
// * - s_pktCxt has valid packet context
// *
// * On exit:
// * - packet is forwarded
// *
// * Register Usage:
// *
// * R0:
// * R1:
// * R2:
// * R3:
// * R4: | CDE commands - cdeScope
// * R5: | -
// * R6: |
// * R7: |
// * R8: | Not used
// * R9: |
// * R10: |
// * R11: | CRC context
// * R12: |
// * R13:
// * R14: |
// * R15: | Packet Data
// * R16: |
// * R17: |
// * R18: | Packet ID (not used)
// * R19: |
// * R20: | Modify State machine (s_modState)
// * R21: |
// * R22: |
// * R23: |
// * R24: | Packet context
// * R25: |
// * R26: | Packet ID
// * R27:
// * R28: statistics (s_statsFlags) - Global scope
// * R29: Modify context (s_modCxt) -
// * R30: w0-function return address -
// * R31: System Flags (s_flags) -
// *
// ************************************************************************
.using cdeScope
.using modifyScope
.using pktScope
f_paRxVerifyCRC:
// Read in the CRC context
xin XID_CDEDATA, s_rxCrcCxt, SIZE(s_rxCrcCxt)
// Scroll past and flush the control info
//mov s_cdeCmdWd.operation, CDE_CMD_FLUSH_TO_PACKET
//xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
// Scroll past and flush the packet info (ling info only)
mov s_cdeCmdWd.operation, CDE_CMD_FLUSH
mov s_cdeCmdWd.byteCount, 32
xout XID_CDECTRL, s_cdeCmdWd, 4
mov s_cdeCmdWd.operation, CDE_CMD_ADVANCE_TO_PACKET
xout XID_CDECTRL, s_cdeCmdWd, 4
// Scroll to the CRC location in the packet
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_ADVANCE
mov s_cdeCmdWd.byteCount, s_rxCrcCxt.offset
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
// Read and compare the CRC
xin XID_CDEDATA, r14, 4
qbeq l_paRxVerifyCRC1, s_rxCrcCxt.crc, r14
// CRC is incorrect
mov r14, s_rxCrcCxt.crc
xout XID_CDEDATA, r14, 4
// Set the CRC error flag
lbco r1.b0, cCdeOutPkt, OFFSET(s_pktDescr.psFlags_errorFlags), SIZE(s_pktDescr.psFlags_errorFlags)
set r1.b0.t_pkt_desc_err_flag_chksum2
sbco r1.b0, cCdeOutPkt, OFFSET(s_pktDescr.psFlags_errorFlags), SIZE(s_pktDescr.psFlags_errorFlags)
l_paRxVerifyCRC1:
// Update and copy the pkt context
clr s_pktCxt.flag.t_flag_crc_verify
sbco s_pktCxt, cCdeOutPkt, SIZE(s_pktDescr), SIZE(s_pktCxt)
// forward the packet out
mov s_cdeCmdPkt.threadId, PA_DEST_CDMA
mov s_cdeCmdPkt.optionsFlag, (CDE_FLG_SET_THREADID | CDE_FLG_SET_PSINFO)
mov s_cdeCmdPkt.psInfoSize, (SIZE(s_pktCxt) + 7) & 0xf8 // Round up to multiple of 8 bytes
mov s_cdeCmdPkt.operation, CDE_CMD_PACKET_ADVANCE
xout XID_CDECTRL, s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
ret
.leave cdeScope
.leave modifyScope
.leave pktScope
// *********************************************************************************
// * FUNCTION PURPOSE: Rx Payload Splitting Processing
// *********************************************************************************
// * DESCRIPTION: Split packet into header and payload portion and deliver them to
// * different queue with different flow
// *
// * On entry:
// * - CDE points to the Control Info section
// * - r30.w0 has the return address
// * - s_pktCxt has valid packet context
// *
// * On exit:
// * - packet is forwarded
// *
// * Register Usage:
// *
// * R0:
// * R1:
// * R2:
// * R3:
// * R4: | CDE commands - cdeScope
// * R5: | -
// * R6: |
// * R7: |
// * R8: | Not used
// * R9: |
// * R10: |
// * R11: | Payload split context
// * R12:
// * R13:
// * R14: |
// * R15: | Packet Data
// * R16: |
// * R17: |
// * R18: | Packet ID (not used)
// * R19: |
// * R20: | Modify State machine (s_modState)
// * R21: |
// * R22: |
// * R23: |
// * R24: | Packet context
// * R25: |
// * R26: | Packet ID
// * R27: statistics (s_statsFlags) - Global scope
// * R28: event (INTD) enabled mask register (s_eventFlags) -
// * R29: Modify context (s_modCxt) -
// * R30: w0-function return address -
// * R31: System Flags (s_flags) -
// *
// ************************************************************************
.using cdeScope
.using modifyScope
.using pktScope
f_paRxPayloadSplit:
// Read in the packet split context
and r0.b0, s_pktCxt.paCmdId_Length, 0x1f
add r0.b0, r0.b0, SIZE(s_pktDescr) - 4
wbc s_flags.info.tStatus_CDEBusy
lbco s_rxSplitCxt, cCdeInPkt, r0.b0, SIZE(s_rxSplitCxt)
// Pass through the control info (note: The new psInfo section has been inserted already and should be ignored)
mov s_cdeCmdWd.operation, CDE_CMD_ADVANCE_TO_PACKET
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
// Scroll to the payload location in the packet
mov s_cdeCmdWd.operation, CDE_CMD_WINDOW_ADVANCE
mov s_cdeCmdWd.byteCount, s_rxSplitCxt.hdrSize
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
// Flush out the payload portion
mov s_cdeCmdWd.operation, CDE_CMD_FLUSH_TO_END
xout XID_CDECTRL, s_cdeCmdWd, 4
l_paRxPayloadSplit1:
// Copy the pkt context
//wbs s_flags.info.tStatus_CDEOutPacket
//sbco s_pktCxt, cCdeOutPkt, SIZE(s_pktDescr), SIZE(s_pktCxt)
// forward the packet out
// TBD: instruction can be simplified
mov s_cdeCmdPkt.threadId, PA_DEST_CDMA
mov s_cdeCmdPkt.optionsFlag, (CDE_FLG_SET_THREADID | CDE_FLG_SET_PSINFO)
mov s_cdeCmdPkt.psInfoSize, 0
mov s_cdeCmdPkt.operation, CDE_CMD_PACKET_COPY
xout XID_CDECTRL, s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
l_paRxPayloadSplit2:
wbs s_flags.info.tStatus_CDENewPacket
// Move to the packet
mov s_cdeCmdWd.operation, CDE_CMD_ADVANCE_TO_PACKET
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
// Flush the packet header
mov s_cdeCmdWd.operation, CDE_CMD_FLUSH
mov s_cdeCmdWd.byteCount, s_rxSplitCxt.hdrSize
xout XID_CDECTRL, s_cdeCmdWd, SIZE(s_cdeCmdWd)
l_paRxPayloadSplit2_queue_bounce:
// Move to the end of the packet
mov s_cdeCmd.v0.w0, CDE_CMD_ADVANCE_TO_END
xout XID_CDECTRL, s_cdeCmd, 4 // Send the command
// Check for Queue Bounce operation
wbs s_flags.info.tStatus_CDEOutPacket
l_paRxPayloadSplit2_queue_bounce_ddr:
qbbc l_paRxPayloadSplit2_queue_bounce_msmc, s_rxSplitCxt.destQueue.t_pa_forward_queue_bounce_ddr
clr s_rxSplitCxt.destQueue.t_pa_forward_queue_bounce_ddr
sbco s_rxSplitCxt.destQueue, cCdeOutPkt, OFFSET(s_pktDescr.swinfo1) + 2, 2
lbco s_rxSplitCxt.destQueue, PAMEM_CONST_CUSTOM, OFFSET_QUEUE_BOUNCE_CFG, 2
jmp l_paRxPayloadSplit2_queue_bounce_end
l_paRxPayloadSplit2_queue_bounce_msmc:
qbbc l_paRxPayloadSplit2_queue_bounce_end, s_rxSplitCxt.destQueue.t_pa_forward_queue_bounce_msmc
clr s_rxSplitCxt.destQueue.t_pa_forward_queue_bounce_msmc
sbco s_rxSplitCxt.destQueue, cCdeOutPkt, OFFSET(s_pktDescr.swinfo1) + 2, 2
lbco s_rxSplitCxt.destQueue, PAMEM_CONST_CUSTOM, OFFSET_QUEUE_BOUNCE_CFG+2, 2
// pass through
l_paRxPayloadSplit2_queue_bounce_end:
// Forward the packet out
zero &s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
mov s_cdeCmdPkt.optionsFlag, CDE_FLG_SET_THREADID | CDE_FLG_SET_FLOWID | CDE_FLG_SET_PSINFO | CDE_FLG_SET_DESTQUEUE
mov s_cdeCmdPkt.operation, CDE_CMD_PACKET_ADVANCE
mov s_cdeCmdPkt.threadId, PA_DEST_CDMA
mov s_cdeCmdPkt.destQueue, s_rxSplitCxt.destQueue
mov s_cdeCmdPkt.flowId, s_rxSplitCxt.flowId
xout XID_CDECTRL, s_cdeCmdPkt, SIZE(s_cdeCmdPkt)
ret
.leave cdeScope
.leave modifyScope
.leave pktScope
// *********************************************************************************
// * FUNCTION PURPOSE: Update User Statistics
// *********************************************************************************
// * DESCRIPTION: Process the user-statistics update from command set and user-statistics
// * FIFO
// *
// * On entry:
// * - s_pktCxt has valid packet context
// *
// * On exit:
// * - CDE does not move
// *
// * Register Usage:
// *
// * R0:
// * R1:
// * R2:
// * R3:
// * R4: | CDE commands - cdeScope
// * R5: | -
// * R6: | Rx Command Header (User-Statistics command ==> can be re-used
// * R7: | user Stats update context
// * R8: |
// * R9: |
// * R10: | Usr Stats Global Configuration
// * R11:
// * R12: | RxCommand Conext (reserved, do not touch)
// * R13: |
// * R14: | Rx user Stats FIFO context (reserved)
// * R15: | Rx user stats FIFO control block (reserved)
// * R16: | Rx user Stats FIFO request (used)
// * R17: |
// * R18: | Packet ID (reserved, do not touch)
// * R19: |
// * R20: | Modify State machine (s_modState) (reserved, do not touch)
// * R21: |
// * R22: |
// * R23: |
// * R24: | Packet context
// * R25: |
// * R26: | Packet ID
// * R27:
// * R28: statistics (s_statsFlags) - Global scope
// * R29: Modify context (s_modCxt) -
// * R30: w0-function return address -
// * R31: System Flags (s_flags) -
// *
// ************************************************************************
.using cdeScope
.using modifyScope
.using pktScope
f_usrStatsUpdate:
lbco s_paUsrStatsCfg, PAMEM_CONST_CUSTOM, OFFSET_USR_STATS_CFG, SIZE(s_paUsrStatsCfg)
lsl s_rxUsrStatsUpdateCxt.cnt32Offset, s_paUsrStatsCfg.num64bCounters, 3
l_usrStatsUpdates_0:
lsl s_rxUsrStatsUpdateCxt.lnkOffset, s_rxUsrStatsReq.index, 1
lbco s_rxUsrStatsUpdateCxt.lnkIndex, PAMEM_CONST_USR_STATS_CB, s_rxUsrStatsUpdateCxt.lnkOffset, SIZE(s_rxUsrStatsUpdateCxt.lnkIndex)
qbbs l_usrStatsUpdates_4, s_rxUsrStatsUpdateCxt.lnkIndex.t_pa_usr_stats_cb_disable
qble l_usrStatsUpdates_2, s_rxUsrStatsReq.index, s_paUsrStatsCfg.num64bCounters
l_usrStatsUpdates_1:
// 64-bit counter
lsl s_rxUsrStatsUpdateCxt.cntOffset, s_rxUsrStatsReq.index, 3
lbco s_rxUsrStatsUpdateCxt.data1, PAMEM_CONST_USR_STATS_COUNTERS, s_rxUsrStatsUpdateCxt.cntOffset, 8
qbbs l_usrStatsUpdates_1_1, s_rxUsrStatsUpdateCxt.lnkIndex.t_pa_usr_stats_cb_byte_cnt
// packet Counter
add s_rxUsrStatsUpdateCxt.data2, s_rxUsrStatsUpdateCxt.data2, 1
jmp l_usrStatsUpdates_1_2
l_usrStatsUpdates_1_1:
// byte Counter
add s_rxUsrStatsUpdateCxt.data2, s_rxUsrStatsUpdateCxt.data2, s_rxUsrStatsReq.pktSize
// Common operation
l_usrStatsUpdates_1_2:
adc s_rxUsrStatsUpdateCxt.data1, s_rxUsrStatsUpdateCxt.data1, 0
sbco s_rxUsrStatsUpdateCxt.data1, PAMEM_CONST_USR_STATS_COUNTERS, s_rxUsrStatsUpdateCxt.cntOffset, 8
jmp l_usrStatsUpdates_3
l_usrStatsUpdates_2:
// 32-bit counter
sub r1.w0, s_rxUsrStatsReq.index, s_paUsrStatsCfg.num64bCounters
lsl s_rxUsrStatsUpdateCxt.cntOffset, r1.w0, 2
add s_rxUsrStatsUpdateCxt.cntOffset, s_rxUsrStatsUpdateCxt.cntOffset, s_rxUsrStatsUpdateCxt.cnt32Offset
lbco s_rxUsrStatsUpdateCxt.data1, PAMEM_CONST_USR_STATS_COUNTERS, s_rxUsrStatsUpdateCxt.cntOffset, 4
qbbs l_usrStatsUpdates_2_1, s_rxUsrStatsUpdateCxt.lnkIndex.t_pa_usr_stats_cb_byte_cnt
// packet Counter
add s_rxUsrStatsUpdateCxt.data1, s_rxUsrStatsUpdateCxt.data1, 1
jmp l_usrStatsUpdates_2_2
l_usrStatsUpdates_2_1:
// byte Counter
add s_rxUsrStatsUpdateCxt.data1, s_rxUsrStatsUpdateCxt.data1, s_rxUsrStatsReq.pktSize
// Common operation
l_usrStatsUpdates_2_2:
sbco s_rxUsrStatsUpdateCxt.data1, PAMEM_CONST_USR_STATS_COUNTERS, s_rxUsrStatsUpdateCxt.cntOffset, 4
l_usrStatsUpdates_3:
qbbs l_usrStatsUpdates_4, s_rxUsrStatsUpdateCxt.lnkIndex.t_pa_usr_stats_cb_no_lnk
// prepare for next layer
mov s_rxUsrStatsReq.index, s_rxUsrStatsUpdateCxt.lnkIndex
and s_rxUsrStatsReq.index.b1, s_rxUsrStatsReq.index.b1, PA_USR_STATS_LNK_MASK_MSB
jmp l_usrStatsUpdates_0
l_usrStatsUpdates_4:
ret
.leave cdeScope
.leave modifyScope
.leave pktScope
#include "pacfgcmn.p"
// ****************************************************************************
// * FUNCTION PURPOSE: Handle commands that are invalid for the modify pdsp
// ****************************************************************************
// * DESCRIPTION: Commands which configure LUTs are invalid
// *
// ****************************************************************************
.using configScope
.using cdeScope
f_paComAddRepLut2:
// Process Queue Divert response
// Read in the command info to check the control flag.
xin XID_CDEDATA, s_paAddL2Std, SIZE(s_paAddL2Std)
qbbc l_paComAddRepLut2_1, s_paAddL2Std.ctrlBitMap.t_pa_lut2_ctrl_queue_divert
// Clear the queue divert flag at PDSP3 mailbox register
mov r1, 0
sbbo r1, r1, 0x34, 4
jmp f_cfgReply
l_paComAddRepLut2_1:
f_paComAddRepLut1:
f_paComDelLut1:
f_paComDelLut2:
mov s_paCmd1.commandResult, PA_COMMAND_RESULT_INVALID_DESTINATION
xout XID_CDEDATA, s_paCmd1.commandResult, SIZE(s_paCmd1.commandResult)
jmp f_cfgReply
.leave configScope
.leave cdeScope
#ifdef TO_BE_DELETE
// *********************************************************************************
// * FUNCTION PURPOSE: Initialize the Modify PDSPs
// *********************************************************************************
// * DESCRIPTION: Global setup is done
// *
// *********************************************************************************
f_mLocalInit:
// clear event flag by default
ret
#endif
// *****************************************************************************************
// * FUNCTION PURPOSE: Hold the command reply
// *****************************************************************************************
// * DESCRIPTION: Forwards the reply only if the destination is the host
// *
// * Register Usage:
// *
// * R0: w0 - the packet length (input)
// * R1:
// * R2:
// * R3:
// * R4: | CDE commands - cdeScope
// * R5: | -
// * R6: |
// * R7: |
// * R8: |
// * R9: | LUT1 View1 - lut1Scope
// * R10: |
// * R11: |
// * R12: |
// * R13: |
// * R14: |
// * R15: |
// * R16: |
// * R17: | LUT1 View2 - lut1Scope
// * R18: |
// * R19: |
// * R20: |
// * R21: |
// * R22: |
// * R23: | Packet context - pktScope
// * R24: |
// * R25: |
// * R26: | b3: ctrlFlag, b2:command result offset < 256: w0: pktId
// * R27:
// * R28: statistics (s_statsFlags) -
// * R29: c1RunContext (s_runCxt) - Global Scope
// * R30: w2-param.action w0-function return address -
// * R31: System Flags (s_flags) -
// *
// *****************************************************************************************/
// dumy function
f_cfgReplyHoldPkt:
ret
.leave globalScopeM
|