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
|
/*
** *************************************************************************
**
**
** R C L A N M T L . C $Revision: 6 $
**
**
** RedCreek I2O LAN Message Transport Layer program module.
**
** ---------------------------------------------------------------------
** --- Copyright (c) 1997-1999, RedCreek Communications Inc. ---
** --- All rights reserved. ---
** ---------------------------------------------------------------------
**
** File Description:
**
** Host side I2O (Intelligent I/O) LAN message transport layer.
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**
** 1998-1999, LAN API was modified and enhanced by Alice Hennessy.
**
** Sometime in 1997, LAN API was written from scratch by Wendell Nichols.
** *************************************************************************
*/
#define DEBUG 1
#define RC_LINUX_MODULE
#include "rclanmtl.h"
/* RedCreek LAN device Target ID */
#define RC_LAN_TARGET_ID 0x10
/* RedCreek's OSM default LAN receive Initiator */
#define DEFAULT_RECV_INIT_CONTEXT 0xA17
/*
** I2O message structures
*/
#define I2O_TID_SZ 12
#define I2O_FUNCTION_SZ 8
/* Transaction Reply Lists (TRL) Control Word structure */
#define I2O_TRL_FLAGS_SINGLE_FIXED_LENGTH 0x00
#define I2O_TRL_FLAGS_SINGLE_VARIABLE_LENGTH 0x40
#define I2O_TRL_FLAGS_MULTIPLE_FIXED_LENGTH 0x80
/* LAN Class specific functions */
#define I2O_LAN_PACKET_SEND 0x3B
#define I2O_LAN_SDU_SEND 0x3D
#define I2O_LAN_RECEIVE_POST 0x3E
#define I2O_LAN_RESET 0x35
#define I2O_LAN_SHUTDOWN 0x37
/* Private Class specfic function */
#define I2O_PRIVATE 0xFF
/* I2O Executive Function Codes. */
#define I2O_EXEC_ADAPTER_ASSIGN 0xB3
#define I2O_EXEC_ADAPTER_READ 0xB2
#define I2O_EXEC_ADAPTER_RELEASE 0xB5
#define I2O_EXEC_BIOS_INFO_SET 0xA5
#define I2O_EXEC_BOOT_DEVICE_SET 0xA7
#define I2O_EXEC_CONFIG_VALIDATE 0xBB
#define I2O_EXEC_CONN_SETUP 0xCA
#define I2O_EXEC_DEVICE_ASSIGN 0xB7
#define I2O_EXEC_DEVICE_RELEASE 0xB9
#define I2O_EXEC_HRT_GET 0xA8
#define I2O_EXEC_IOP_CLEAR 0xBE
#define I2O_EXEC_IOP_CONNECT 0xC9
#define I2O_EXEC_IOP_RESET 0xBD
#define I2O_EXEC_LCT_NOTIFY 0xA2
#define I2O_EXEC_OUTBOUND_INIT 0xA1
#define I2O_EXEC_PATH_ENABLE 0xD3
#define I2O_EXEC_PATH_QUIESCE 0xC5
#define I2O_EXEC_PATH_RESET 0xD7
#define I2O_EXEC_STATIC_MF_CREATE 0xDD
#define I2O_EXEC_STATIC_MF_RELEASE 0xDF
#define I2O_EXEC_STATUS_GET 0xA0
#define I2O_EXEC_SW_DOWNLOAD 0xA9
#define I2O_EXEC_SW_UPLOAD 0xAB
#define I2O_EXEC_SW_REMOVE 0xAD
#define I2O_EXEC_SYS_ENABLE 0xD1
#define I2O_EXEC_SYS_MODIFY 0xC1
#define I2O_EXEC_SYS_QUIESCE 0xC3
#define I2O_EXEC_SYS_TAB_SET 0xA3
/* Init Outbound Q status */
#define I2O_EXEC_OUTBOUND_INIT_IN_PROGRESS 0x01
#define I2O_EXEC_OUTBOUND_INIT_REJECTED 0x02
#define I2O_EXEC_OUTBOUND_INIT_FAILED 0x03
#define I2O_EXEC_OUTBOUND_INIT_COMPLETE 0x04
#define I2O_UTIL_NOP 0x00
/* I2O Get Status State values */
#define I2O_IOP_STATE_INITIALIZING 0x01
#define I2O_IOP_STATE_RESET 0x02
#define I2O_IOP_STATE_HOLD 0x04
#define I2O_IOP_STATE_READY 0x05
#define I2O_IOP_STATE_OPERATIONAL 0x08
#define I2O_IOP_STATE_FAILED 0x10
#define I2O_IOP_STATE_FAULTED 0x11
/* Defines for Request Status Codes: Table 3-1 Reply Status Codes. */
#define I2O_REPLY_STATUS_SUCCESS 0x00
#define I2O_REPLY_STATUS_ABORT_DIRTY 0x01
#define I2O_REPLY_STATUS_ABORT_NO_DATA_TRANSFER 0x02
#define I2O_REPLY_STATUS_ABORT_PARTIAL_TRANSFER 0x03
#define I2O_REPLY_STATUS_ERROR_DIRTY 0x04
#define I2O_REPLY_STATUS_ERROR_NO_DATA_TRANSFER 0x05
#define I2O_REPLY_STATUS_ERROR_PARTIAL_TRANSFER 0x06
#define I2O_REPLY_STATUS_PROCESS_ABORT_DIRTY 0x07
#define I2O_REPLY_STATUS_PROCESS_ABORT_NO_DATA_TRANSFER 0x08
#define I2O_REPLY_STATUS_PROCESS_ABORT_PARTIAL_TRANSFER 0x09
#define I2O_REPLY_STATUS_TRANSACTION_ERROR 0x0A
#define I2O_REPLY_STATUS_PROGRESS_REPORT 0x80
/* DetailedStatusCode defines for ALL messages: Table 3-2 Detailed Status Codes.*/
#define I2O_DETAIL_STATUS_SUCCESS 0x0000
#define I2O_DETAIL_STATUS_BAD_KEY 0x0001
#define I2O_DETAIL_STATUS_CHAIN_BUFFER_TOO_LARGE 0x0002
#define I2O_DETAIL_STATUS_DEVICE_BUSY 0x0003
#define I2O_DETAIL_STATUS_DEVICE_LOCKED 0x0004
#define I2O_DETAIL_STATUS_DEVICE_NOT_AVAILABLE 0x0005
#define I2O_DETAIL_STATUS_DEVICE_RESET 0x0006
#define I2O_DETAIL_STATUS_INAPPROPRIATE_FUNCTION 0x0007
#define I2O_DETAIL_STATUS_INSUFFICIENT_RESOURCE_HARD 0x0008
#define I2O_DETAIL_STATUS_INSUFFICIENT_RESOURCE_SOFT 0x0009
#define I2O_DETAIL_STATUS_INVALID_INITIATOR_ADDRESS 0x000A
#define I2O_DETAIL_STATUS_INVALID_MESSAGE_FLAGS 0x000B
#define I2O_DETAIL_STATUS_INVALID_OFFSET 0x000C
#define I2O_DETAIL_STATUS_INVALID_PARAMETER 0x000D
#define I2O_DETAIL_STATUS_INVALID_REQUEST 0x000E
#define I2O_DETAIL_STATUS_INVALID_TARGET_ADDRESS 0x000F
#define I2O_DETAIL_STATUS_MESSAGE_TOO_LARGE 0x0010
#define I2O_DETAIL_STATUS_MESSAGE_TOO_SMALL 0x0011
#define I2O_DETAIL_STATUS_MISSING_PARAMETER 0x0012
#define I2O_DETAIL_STATUS_NO_SUCH_PAGE 0x0013
#define I2O_DETAIL_STATUS_REPLY_BUFFER_FULL 0x0014
#define I2O_DETAIL_STATUS_TCL_ERROR 0x0015
#define I2O_DETAIL_STATUS_TIMEOUT 0x0016
#define I2O_DETAIL_STATUS_UNKNOWN_ERROR 0x0017
#define I2O_DETAIL_STATUS_UNKNOWN_FUNCTION 0x0018
#define I2O_DETAIL_STATUS_UNSUPPORTED_FUNCTION 0x0019
#define I2O_DETAIL_STATUS_UNSUPPORTED_VERSION 0x001A
/* I2O msg header defines for VersionOffset */
#define I2OMSGVER_1_5 0x0001
#define SGL_OFFSET_0 I2OMSGVER_1_5
#define SGL_OFFSET_4 (0x0040 | I2OMSGVER_1_5)
#define TRL_OFFSET_5 (0x0050 | I2OMSGVER_1_5)
#define TRL_OFFSET_6 (0x0060 | I2OMSGVER_1_5)
/* I2O msg header defines for MsgFlags */
#define MSG_STATIC 0x0100
#define MSG_64BIT_CNTXT 0x0200
#define MSG_MULTI_TRANS 0x1000
#define MSG_FAIL 0x2000
#define MSG_LAST 0x4000
#define MSG_REPLY 0x8000
/* normal LAN request message MsgFlags and VersionOffset (0x1041) */
#define LAN_MSG_REQST (MSG_MULTI_TRANS | SGL_OFFSET_4)
/* minimum size msg */
#define THREE_WORD_MSG_SIZE 0x00030000
#define FOUR_WORD_MSG_SIZE 0x00040000
#define FIVE_WORD_MSG_SIZE 0x00050000
#define SIX_WORD_MSG_SIZE 0x00060000
#define SEVEN_WORD_MSG_SIZE 0x00070000
#define EIGHT_WORD_MSG_SIZE 0x00080000
#define NINE_WORD_MSG_SIZE 0x00090000
/* Special TID Assignments */
#define I2O_IOP_TID 0
#define I2O_HOST_TID 0xB91
/* RedCreek I2O private message codes */
#define RC_PRIVATE_GET_MAC_ADDR 0x0001/**/ /* OBSOLETE */
#define RC_PRIVATE_SET_MAC_ADDR 0x0002
#define RC_PRIVATE_GET_NIC_STATS 0x0003
#define RC_PRIVATE_GET_LINK_STATUS 0x0004
#define RC_PRIVATE_SET_LINK_SPEED 0x0005
#define RC_PRIVATE_SET_IP_AND_MASK 0x0006
/* #define RC_PRIVATE_GET_IP_AND_MASK 0x0007 */ /* OBSOLETE */
#define RC_PRIVATE_GET_LINK_SPEED 0x0008
#define RC_PRIVATE_GET_FIRMWARE_REV 0x0009
/* #define RC_PRIVATE_GET_MAC_ADDR 0x000A */
#define RC_PRIVATE_GET_IP_AND_MASK 0x000B
#define RC_PRIVATE_DEBUG_MSG 0x000C
#define RC_PRIVATE_REPORT_DRIVER_CAPABILITY 0x000D
#define RC_PRIVATE_SET_PROMISCUOUS_MODE 0x000e
#define RC_PRIVATE_GET_PROMISCUOUS_MODE 0x000f
#define RC_PRIVATE_SET_BROADCAST_MODE 0x0010
#define RC_PRIVATE_GET_BROADCAST_MODE 0x0011
#define RC_PRIVATE_REBOOT 0x00FF
/* I2O message header */
typedef struct _I2O_MESSAGE_FRAME
{
U8 VersionOffset;
U8 MsgFlags;
U16 MessageSize;
BF TargetAddress:I2O_TID_SZ;
BF InitiatorAddress:I2O_TID_SZ;
BF Function:I2O_FUNCTION_SZ;
U32 InitiatorContext;
/* SGL[] */
}
I2O_MESSAGE_FRAME, *PI2O_MESSAGE_FRAME;
/* assumed a 16K minus 256 byte space for outbound queue message frames */
#define MSG_FRAME_SIZE 512
#define NMBR_MSG_FRAMES 30
/*
** in reserved space right after PAB in host memory is area for returning
** values from card
*/
/*
** typedef NICSTAT
**
** Data structure for NIC statistics retruned from PCI card. Data copied from
** here to user allocated RCLINKSTATS (see rclanmtl.h) structure.
*/
typedef struct tag_NicStat
{
unsigned long TX_good;
unsigned long TX_maxcol;
unsigned long TX_latecol;
unsigned long TX_urun;
unsigned long TX_crs; /* lost carrier sense */
unsigned long TX_def; /* transmit deferred */
unsigned long TX_singlecol; /* single collisions */
unsigned long TX_multcol;
unsigned long TX_totcol;
unsigned long Rcv_good;
unsigned long Rcv_CRCerr;
unsigned long Rcv_alignerr;
unsigned long Rcv_reserr; /* rnr'd pkts */
unsigned long Rcv_orun;
unsigned long Rcv_cdt;
unsigned long Rcv_runt;
unsigned long dump_status; /* last field directly from the chip */
}
NICSTAT, *P_NICSTAT;
#define DUMP_DONE 0x0000A005 /* completed statistical dump */
#define DUMP_CLEAR 0x0000A007 /* completed stat dump and clear counters */
static volatile int msgFlag;
/* local function prototypes */
static void ProcessOutboundI2OMsg(PPAB pPab, U32 phyMsgAddr);
static int FillI2OMsgSGLFromTCB(PU32 pMsg, PRCTCB pXmitCntrlBlock);
static int GetI2OStatus(PPAB pPab);
static int SendI2OOutboundQInitMsg(PPAB pPab);
static int SendEnableSysMsg(PPAB pPab);
/*
** =========================================================================
** RCInitI2OMsgLayer()
**
** Initialize the RedCreek I2O Module and adapter.
**
** Inputs: dev - the devices net_device struct
** TransmitCallbackFunction - address of transmit callback function
** ReceiveCallbackFunction - address of receive callback function
**
** private message block is allocated by user. It must be in locked pages.
** p_msgbuf and p_phymsgbuf point to the same location. Must be contigous
** memory block of a minimum of 16K byte and long word aligned.
** =========================================================================
*/
RC_RETURN
RCInitI2OMsgLayer(struct net_device *dev,
PFNTXCALLBACK TransmitCallbackFunction,
PFNRXCALLBACK ReceiveCallbackFunction,
PFNCALLBACK RebootCallbackFunction)
{
int result;
PPAB pPab;
U32 pciBaseAddr = dev->base_addr;
PDPA pDpa = dev->priv;
PU8 p_msgbuf = pDpa->PLanApiPA;
PU8 p_phymsgbuf = (PU8)virt_to_bus((void *) p_msgbuf);
dprintk("InitI2O: Adapter:0x%04ux ATU:0x%08ulx msgbuf:0x%08ulx phymsgbuf:0x%08ulx\n"
"TransmitCallbackFunction:0x%08ulx ReceiveCallbackFunction:0x%08ulx\n",
pDpa->id, pciBaseAddr, (u32)p_msgbuf, (u32)p_phymsgbuf,
(u32)TransmitCallbackFunction, (u32)ReceiveCallbackFunction);
/* Check if this interface already initialized - if so, shut it down */
if (pDpa->pPab != NULL) {
printk(KERN_WARNING "(rcpci45 driver:) pDpa->pPab [%d] != NULL\n", pDpa->id);
/* RCResetLANCard(pDpa->id, 0, (PU32)NULL, (PFNCALLBACK)NULL); */
pDpa->pPab = NULL;
}
/* store adapter instance values in adapter block.
* Adapter block is at beginning of message buffer */
pPab = kmalloc(sizeof(*pPab), GFP_KERNEL);
if (!pPab) {
printk(KERN_ERR "(rcpci45 driver:) RCInitI2OMsgLayer: Could not allocate memory for PAB struct!\n");
result = RC_RTN_MALLOC_ERROR;
goto err_out;
}
memset(pPab, 0, sizeof(*pPab));
pDpa->pPab = pPab;
pPab->p_atu = (PATU)pciBaseAddr;
pPab->pPci45LinBaseAddr = (PU8)pciBaseAddr;
/* Set outbound message frame addr */
pPab->outMsgBlockPhyAddr = (U32)p_phymsgbuf;
pPab->pLinOutMsgBlock = (PU8)p_msgbuf;
/* store callback function addresses */
pPab->pTransCallbackFunc = TransmitCallbackFunction;
pPab->pRecvCallbackFunc = ReceiveCallbackFunction;
pPab->pRebootCallbackFunc = RebootCallbackFunction;
pPab->pCallbackFunc = (PFNCALLBACK)NULL;
/*
** Initialize I2O IOP
*/
result = GetI2OStatus(pPab);
if (result != RC_RTN_NO_ERROR)
goto err_out_dealloc;
if (pPab->IOPState == I2O_IOP_STATE_OPERATIONAL) {
printk(KERN_INFO "(rcpci45 driver:) pPab->IOPState == op: resetting adapter\n");
RCResetLANCard(dev, 0, (PU32)NULL, (PFNCALLBACK)NULL);
}
result = SendI2OOutboundQInitMsg(pPab);
if (result != RC_RTN_NO_ERROR)
goto err_out_dealloc;
result = SendEnableSysMsg(pPab);
if (result != RC_RTN_NO_ERROR)
goto err_out_dealloc;
return RC_RTN_NO_ERROR;
err_out_dealloc:
kfree(pPab);
err_out:
return result;
}
/*
** =========================================================================
** Disable and Enable I2O interrupts. I2O interrupts are enabled at Init time
** but can be disabled and re-enabled through these two function calls.
** Packets will still be put into any posted received buffers and packets will
** be sent through RCI2OSendPacket() functions. Disabling I2O interrupts
** will prevent hardware interrupt to host even though the outbound I2O msg
** queue is not emtpy.
** =========================================================================
*/
#define i960_OUT_POST_Q_INT_BIT 0x0008 /* bit set masks interrupts */
RC_RETURN RCDisableI2OInterrupts(struct net_device *dev)
{
PPAB pPab = ((PDPA)dev->priv)->pPab;
if (pPab == NULL)
return RC_RTN_ADPTR_NOT_REGISTERED;
pPab->p_atu->OutIntMask |= i960_OUT_POST_Q_INT_BIT;
return RC_RTN_NO_ERROR;
}
RC_RETURN RCEnableI2OInterrupts(struct net_device *dev)
{
PPAB pPab = ((PDPA)dev->priv)->pPab;
if (pPab == NULL)
return RC_RTN_ADPTR_NOT_REGISTERED;
pPab->p_atu->OutIntMask &= ~i960_OUT_POST_Q_INT_BIT;
return RC_RTN_NO_ERROR;
}
/*
** =========================================================================
** RCI2OSendPacket()
** =========================================================================
*/
RC_RETURN
RCI2OSendPacket(struct net_device *dev, U32 InitiatorContext,
PRCTCB pTransCtrlBlock)
{
U32 msgOffset;
PU32 pMsg;
int size;
PPAB pPab = ((PDPA)dev->priv)->pPab;
dprintk("RCI2OSendPacket()...\n");
if (pPab == NULL)
return RC_RTN_ADPTR_NOT_REGISTERED;
/* get Inbound free Q entry - reading from In Q gets free Q entry */
/* offset to Msg Frame in PCI msg block */
msgOffset = pPab->p_atu->InQueue;
if (msgOffset == 0xFFFFFFFF)
{
dprintk("RCI2OSendPacket(): Inbound Free Q empty!\n");
return RC_RTN_FREE_Q_EMPTY;
}
/* calc virual address of msg - virual already mapped to physical */
pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset);
size = FillI2OMsgSGLFromTCB(pMsg + 4, pTransCtrlBlock);
if (size == -1) /* error processing TCB - send NOP msg */
{
dprintk("RCI2OSendPacket(): Error Rrocess TCB!\n");
pMsg[0] = THREE_WORD_MSG_SIZE | SGL_OFFSET_0;
pMsg[1] = I2O_UTIL_NOP << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
return RC_RTN_TCB_ERROR;
}
else /* send over msg header */
{
pMsg[0] = (size + 4) << 16 | LAN_MSG_REQST; /* send over message size and flags */
pMsg[1] = I2O_LAN_PACKET_SEND << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
pMsg[2] = InitiatorContext;
pMsg[3] = 0; /* batch reply */
/* post to Inbound Post Q */
pPab->p_atu->InQueue = msgOffset;
return RC_RTN_NO_ERROR;
}
}
/*
** =========================================================================
** RCI2OPostRecvBuffer()
**
** inputs: pBufrCntrlBlock - pointer to buffer control block
**
** returns TRUE if successful in sending message, else FALSE.
** =========================================================================
*/
RC_RETURN
RCPostRecvBuffers(struct net_device *dev, PRCTCB pTransCtrlBlock)
{
U32 msgOffset;
PU32 pMsg;
int size;
PPAB pPab = ((PDPA)dev->priv)->pPab;
dprintk("RCPostRecvBuffers()...\n");
/* search for DeviceHandle */
if (pPab == NULL)
return RC_RTN_ADPTR_NOT_REGISTERED;
/* get Inbound free Q entry - reading from In Q gets free Q entry */
/* offset to Msg Frame in PCI msg block */
msgOffset = pPab->p_atu->InQueue;
if (msgOffset == 0xFFFFFFFF)
{
dprintk("RCPostRecvBuffers(): Inbound Free Q empty!\n");
return RC_RTN_FREE_Q_EMPTY;
}
/* calc virual address of msg - virual already mapped to physical */
pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset);
size = FillI2OMsgSGLFromTCB(pMsg + 4, pTransCtrlBlock);
if (size == -1) /* error prcessing TCB - send 3 DWORD private msg == NOP */
{
dprintk("RCPostRecvBuffers(): Error Processing TCB! size = %d\n", size);
pMsg[0] = THREE_WORD_MSG_SIZE | SGL_OFFSET_0;
pMsg[1] = I2O_UTIL_NOP << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
/* post to Post Q */
pPab->p_atu->InQueue = msgOffset;
return RC_RTN_TCB_ERROR;
}
else /* send over size msg header */
{
pMsg[0] = (size + 4) << 16 | LAN_MSG_REQST; /* send over message size and flags */
pMsg[1] = I2O_LAN_RECEIVE_POST << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
pMsg[2] = DEFAULT_RECV_INIT_CONTEXT;
pMsg[3] = *(PU32)pTransCtrlBlock; /* number of packet buffers */
/* post to Post Q */
pPab->p_atu->InQueue = msgOffset;
return RC_RTN_NO_ERROR;
}
}
/*
** =========================================================================
** RCProcI2OMsgQ()
**
** Process I2O outbound message queue until empty.
** =========================================================================
*/
void
RCProcI2OMsgQ(struct net_device *dev)
{
U32 phyAddrMsg;
PU8 p8Msg;
PU32 p32;
U16 count;
PPAB pPab = ((PDPA)dev->priv)->pPab;
unsigned char debug_msg[20];
if (pPab == NULL)
return;
phyAddrMsg = pPab->p_atu->OutQueue;
while (phyAddrMsg != 0xFFFFFFFF)
{
p8Msg = pPab->pLinOutMsgBlock + (phyAddrMsg - pPab->outMsgBlockPhyAddr);
p32 = (PU32)p8Msg;
dprintk("msg: 0x%x 0x%x \n", p8Msg[7], p32[5]);
/* Send Packet Reply Msg */
if (I2O_LAN_PACKET_SEND == p8Msg[7]) { /* function code byte */
count = *(PU16)(p8Msg+2);
count -= p8Msg[0] >> 4;
/* status, count, context[], adapter */
(*pPab->pTransCallbackFunc)(p8Msg[19], count, p32+5, dev);
} else if (I2O_LAN_RECEIVE_POST == p8Msg[7]) { /* Receive Packet Reply Msg */
dprintk("I2O_RECV_REPLY pPab:0x%08ulx p8Msg:0x%08ulx p32:0x%08ulx\n", (u32)pPab, (u32)p8Msg, (u32)p32);
dprintk("msg: 0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n",
p32[0], p32[1], p32[2], p32[3]);
dprintk(" 0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n",
p32[4], p32[5], p32[6], p32[7]);
dprintk(" 0x%08ulx:0X%08ulx:0x%08ulx:0x%08ulx\n",
p32[8], p32[9], p32[10], p32[11]);
/* status, count, buckets remaining, packetParmBlock, adapter */
(*pPab->pRecvCallbackFunc)(p8Msg[19], p8Msg[12], p32[5], p32+6, dev);
} else if (I2O_LAN_RESET == p8Msg[7] || I2O_LAN_SHUTDOWN == p8Msg[7])
if (pPab->pCallbackFunc)
(*pPab->pCallbackFunc)(p8Msg[19],0,0,dev);
else
pPab->pCallbackFunc = (PFNCALLBACK) 1;
else if (I2O_PRIVATE == p8Msg[7]) {
dprintk("i2o private 0x%x, 0x%x \n", p8Msg[7], p32[5]);
switch (p32[5])
{
case RC_PRIVATE_DEBUG_MSG:
msgFlag = 1;
dprintk("Received I2O_PRIVATE msg\n");
debug_msg[15] = (p32[6]&0xff000000) >> 24;
debug_msg[14] = (p32[6]&0x00ff0000) >> 16;
debug_msg[13] = (p32[6]&0x0000ff00) >> 8;
debug_msg[12] = (p32[6]&0x000000ff);
debug_msg[11] = (p32[7]&0xff000000) >> 24;
debug_msg[10] = (p32[7]&0x00ff0000) >> 16;
debug_msg[ 9] = (p32[7]&0x0000ff00) >> 8;
debug_msg[ 8] = (p32[7]&0x000000ff);
debug_msg[ 7] = (p32[8]&0xff000000) >> 24;
debug_msg[ 6] = (p32[8]&0x00ff0000) >> 16;
debug_msg[ 5] = (p32[8]&0x0000ff00) >> 8;
debug_msg[ 4] = (p32[8]&0x000000ff);
debug_msg[ 3] = (p32[9]&0xff000000) >> 24;
debug_msg[ 2] = (p32[9]&0x00ff0000) >> 16;
debug_msg[ 1] = (p32[9]&0x0000ff00) >> 8;
debug_msg[ 0] = (p32[9]&0x000000ff);
debug_msg[16] = '\0';
dprintk("%s", debug_msg);
break;
case RC_PRIVATE_REBOOT:
dprintk("Adapter reboot initiated...\n");
if (pPab->pRebootCallbackFunc)
(*pPab->pRebootCallbackFunc)(0,0,0,dev);
break;
default:
printk(KERN_WARNING "(rcpci45 driver:) Unknown private I2O msg received: 0x%x\n", p32[5]);
break;
}
}
/*
** Process other Msg's
*/
else
ProcessOutboundI2OMsg(pPab, phyAddrMsg);
/* return MFA to outbound free Q*/
pPab->p_atu->OutQueue = phyAddrMsg;
/* any more msgs? */
phyAddrMsg = pPab->p_atu->OutQueue;
}
}
/*
** =========================================================================
** Returns LAN interface statistical counters to space provided by caller at
** StatsReturnAddr. Returns 0 if success, else RC_RETURN code.
** This function will call the WaitCallback function provided by
** user while waiting for card to respond.
** =========================================================================
*/
RC_RETURN
RCGetLinkStatistics(struct net_device *dev,
P_RCLINKSTATS StatsReturnAddr,
PFNWAITCALLBACK WaitCallback)
{
U32 msgOffset;
volatile U32 timeout;
volatile PU32 pMsg;
volatile PU32 p32, pReturnAddr;
P_NICSTAT pStats;
int i;
PPAB pPab = ((PDPA)dev->priv)->pPab;
/*dprintk("Get82558Stats() StatsReturnAddr:0x%08ulx\n", StatsReturnAddr); */
if (pPab == NULL)
return RC_RTN_ADPTR_NOT_REGISTERED;
msgOffset = pPab->p_atu->InQueue;
if (msgOffset == 0xFFFFFFFF)
{
dprintk("Get8255XStats(): Inbound Free Q empty!\n");
return RC_RTN_FREE_Q_EMPTY;
}
/* calc virual address of msg - virual already mapped to physical */
pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset);
/*dprintk("Get82558Stats - pMsg = 0x%08ulx, InQ msgOffset = 0x%08ulx\n", pMsg, msgOffset);*/
/*dprintk("Get82558Stats - pMsg = 0x%08X, InQ msgOffset = 0x%08X\n", pMsg, msgOffset);*/
pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
pMsg[2] = DEFAULT_RECV_INIT_CONTEXT;
pMsg[3] = 0x112; /* transaction context */
pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_NIC_STATS;
pMsg[5] = pPab->outMsgBlockPhyAddr;
p32 = (PU32) pPab->outMsgBlockPhyAddr;
pStats = (P_NICSTAT)pPab->pLinOutMsgBlock;
pStats->dump_status = 0xFFFFFFFF;
/* post to Inbound Post Q */
pPab->p_atu->InQueue = msgOffset;
timeout = 100000;
while (1)
{
if (WaitCallback)
(*WaitCallback)();
udelay(10);
if (pStats->dump_status != 0xFFFFFFFF)
break;
if (!timeout--)
{
dprintk("RCGet82558Stats() Timeout waiting for NIC statistics\n");
return RC_RTN_MSG_REPLY_TIMEOUT;
}
}
pReturnAddr = (PU32)StatsReturnAddr;
/* copy Nic stats to user's structure */
for (i = 0; i < (int) sizeof(RCLINKSTATS) / 4; i++)
pReturnAddr[i] = p32[i];
return RC_RTN_NO_ERROR;
}
/*
** =========================================================================
** Get82558LinkStatus()
** =========================================================================
*/
RC_RETURN
RCGetLinkStatus(struct net_device *dev, PU32 ReturnAddr,
PFNWAITCALLBACK WaitCallback)
{
U32 msgOffset;
volatile U32 timeout;
volatile PU32 pMsg;
volatile PU32 p32;
PPAB pPab = ((PDPA)dev->priv)->pPab;
dprintk("Get82558LinkStatus() ReturnPhysAddr:0x%08ulx\n", (u32)ReturnAddr);
if (pPab == NULL)
return RC_RTN_ADPTR_NOT_REGISTERED;
msgOffset = pPab->p_atu->InQueue;
if (msgOffset == 0xFFFFFFFF)
{
dprintk("Get82558LinkStatus(): Inbound Free Q empty!\n");
return RC_RTN_FREE_Q_EMPTY;
}
/* calc virual address of msg - virual already mapped to physical */
pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset);
/*dprintk("Get82558LinkStatus - pMsg = 0x%08ulx, InQ msgOffset = 0x%08ulx\n", pMsg, msgOffset);*/
/*dprintk("Get82558LinkStatus - pMsg = 0x%08X, InQ msgOffset = 0x%08X\n", pMsg, msgOffset);*/
pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
pMsg[2] = DEFAULT_RECV_INIT_CONTEXT;
pMsg[3] = 0x112; /* transaction context */
pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_LINK_STATUS;
pMsg[5] = pPab->outMsgBlockPhyAddr;
p32 = (PU32)pPab->pLinOutMsgBlock;
*p32 = 0xFFFFFFFF;
/* post to Inbound Post Q */
pPab->p_atu->InQueue = msgOffset;
timeout = 100000;
while (1) {
if (WaitCallback)
(*WaitCallback)();
udelay(10);
if (*p32 != 0xFFFFFFFF)
break;
if (!timeout--) {
dprintk("Timeout waiting for link status\n");
return RC_RTN_MSG_REPLY_TIMEOUT;
}
}
*ReturnAddr = *p32; /* 1 = up 0 = down */
return RC_RTN_NO_ERROR;
}
/*
** =========================================================================
** RCGetMAC()
**
** get the MAC address the adapter is listening for in non-promiscous mode.
** MAC address is in media format.
** =========================================================================
*/
RC_RETURN
RCGetMAC(struct net_device *dev, PFNWAITCALLBACK WaitCallback)
{
unsigned timeout;
U32 off;
PU8 mac = dev->dev_addr;
PU32 p;
U32 temp[2];
PPAB pPab = ((PDPA)dev->priv)->pPab;
PATU p_atu;
if (pPab == NULL)
return RC_RTN_ADPTR_NOT_REGISTERED;
p_atu = pPab->p_atu;
p_atu->EtherMacLow = 0; /* first zero return data */
p_atu->EtherMacHi = 0;
off = p_atu->InQueue; /* get addresss of message */
if (0xFFFFFFFF == off)
return RC_RTN_FREE_Q_EMPTY;
p = (PU32)(pPab->pPci45LinBaseAddr + off);
dprintk("RCGetMAC: p_atu 0x%08x, off 0x%08x, p 0x%08x\n",
(uint)p_atu, (uint)off, (uint)p);
/* setup private message */
p[0] = FIVE_WORD_MSG_SIZE | SGL_OFFSET_0;
p[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
p[2] = 0; /* initiator context */
p[3] = 0x218; /* transaction context */
p[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_MAC_ADDR;
p_atu->InQueue = off; /* send it to the I2O device */
dprintk("RCGetMAC: p_atu 0x%08x, off 0x%08x, p 0x%08x\n",
(uint)p_atu, (uint)off, (uint)p);
/* wait for the rcpci45 board to update the info */
timeout = 1000000;
while (0 == p_atu->EtherMacLow)
{
if (WaitCallback)
(*WaitCallback)();
udelay(10);
if (!timeout--)
{
printk("rc_getmac: Timeout\n");
return RC_RTN_MSG_REPLY_TIMEOUT;
}
}
/* read the mac address */
temp[0] = p_atu->EtherMacLow;
temp[1] = p_atu->EtherMacHi;
memcpy((char *)mac, (char *)temp, 6);
dprintk("rc_getmac: 0x%x\n", (u32)mac);
return RC_RTN_NO_ERROR;
}
/*
** =========================================================================
** RCSetMAC()
**
** set MAC address the adapter is listening for in non-promiscous mode.
** MAC address is in media format.
** =========================================================================
*/
RC_RETURN
RCSetMAC(struct net_device *dev, PU8 mac)
{
U32 off;
PU32 pMsg;
PPAB pPab = ((PDPA)dev->priv)->pPab;
if (pPab == NULL)
return RC_RTN_ADPTR_NOT_REGISTERED;
off = pPab->p_atu->InQueue; /* get addresss of message */
if (0xFFFFFFFF == off)
return RC_RTN_FREE_Q_EMPTY;
pMsg = (PU32)(pPab->pPci45LinBaseAddr + off);
/* setup private message */
pMsg[0] = SEVEN_WORD_MSG_SIZE | SGL_OFFSET_0;
pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
pMsg[2] = 0; /* initiator context */
pMsg[3] = 0x219; /* transaction context */
pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_SET_MAC_ADDR;
pMsg[5] = *(unsigned *)mac; /* first four bytes */
pMsg[6] = *(unsigned *)(mac + 4); /* last two bytes */
pPab->p_atu->InQueue = off; /* send it to the I2O device */
return RC_RTN_NO_ERROR ;
}
/*
** =========================================================================
** RCSetLinkSpeed()
**
** set ethernet link speed.
** input: speedControl - determines action to take as follows
** 0 = reset and auto-negotiate (NWay)
** 1 = Full Duplex 100BaseT
** 2 = Half duplex 100BaseT
** 3 = Full Duplex 10BaseT
** 4 = Half duplex 10BaseT
** all other values are ignore (do nothing)
** =========================================================================
*/
RC_RETURN
RCSetLinkSpeed(struct net_device *dev, U16 LinkSpeedCode)
{
U32 off;
PU32 pMsg;
PPAB pPab = ((PDPA)dev->priv)->pPab;
if (pPab == NULL)
return RC_RTN_ADPTR_NOT_REGISTERED;
off = pPab->p_atu->InQueue; /* get addresss of message */
if (0xFFFFFFFF == off)
return RC_RTN_FREE_Q_EMPTY;
pMsg = (PU32)(pPab->pPci45LinBaseAddr + off);
/* setup private message */
pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
pMsg[2] = 0; /* initiator context */
pMsg[3] = 0x219; /* transaction context */
pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_SET_LINK_SPEED;
pMsg[5] = LinkSpeedCode; /* link speed code */
pPab->p_atu->InQueue = off; /* send it to the I2O device */
return RC_RTN_NO_ERROR ;
}
/*
** =========================================================================
** RCSetPromiscuousMode()
**
** Defined values for Mode:
** 0 - turn off promiscuous mode
** 1 - turn on promiscuous mode
**
** =========================================================================
*/
RC_RETURN
RCSetPromiscuousMode(struct net_device *dev, U16 Mode)
{
U32 off;
PU32 pMsg;
PPAB pPab = ((PDPA)dev->priv)->pPab;
if (pPab == NULL)
return RC_RTN_ADPTR_NOT_REGISTERED;
off = pPab->p_atu->InQueue; /* get addresss of message */
if (0xFFFFFFFF == off)
return RC_RTN_FREE_Q_EMPTY;
pMsg = (PU32)(pPab->pPci45LinBaseAddr + off);
/* setup private message */
pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
pMsg[2] = 0; /* initiator context */
pMsg[3] = 0x219; /* transaction context */
pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_SET_PROMISCUOUS_MODE;
pMsg[5] = Mode; /* promiscuous mode setting */
pPab->p_atu->InQueue = off; /* send it to the device */
return RC_RTN_NO_ERROR ;
}
/*
** =========================================================================
** RCGetPromiscuousMode()
**
** get promiscuous mode setting
**
** Possible return values placed in pMode:
** 0 = promisuous mode not set
** 1 = promisuous mode is set
**
** =========================================================================
*/
RC_RETURN
RCGetPromiscuousMode(struct net_device *dev, PU32 pMode,
PFNWAITCALLBACK WaitCallback)
{
U32 msgOffset, timeout;
PU32 pMsg;
volatile PU32 p32;
PPAB pPab = ((PDPA)dev->priv)->pPab;
msgOffset = pPab->p_atu->InQueue;
if (msgOffset == 0xFFFFFFFF)
{
printk(KERN_WARNING "(rcpci45 driver:) RCGetLinkSpeed(): Inbound Free Q empty!\n");
return RC_RTN_FREE_Q_EMPTY;
}
/* calc virtual address of msg - virtual already mapped to physical */
pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset);
/* virtual pointer to return buffer - clear first two dwords */
p32 = (volatile PU32)pPab->pLinOutMsgBlock;
p32[0] = 0xff;
/* setup private message */
pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
pMsg[2] = 0; /* initiator context */
pMsg[3] = 0x219; /* transaction context */
pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_PROMISCUOUS_MODE;
/* phys address to return status - area right after PAB */
pMsg[5] = pPab->outMsgBlockPhyAddr;
/* post to Inbound Post Q */
pPab->p_atu->InQueue = msgOffset;
/* wait for response */
timeout = 1000000;
while(1) {
if (WaitCallback)
(*WaitCallback)();
udelay(10); /* please don't hog the bus!!! */
if (p32[0] != 0xff)
break;
if (!timeout--)
{
dprintk("Timeout waiting for promiscuous mode from adapter\n");
dprintk("0x%8x\n", p32[0]);
return RC_RTN_NO_LINK_SPEED;
}
}
/* get mode */
*pMode = (U8)((volatile PU8)p32)[0] & 0x0f;
return RC_RTN_NO_ERROR;
}
/*
** =========================================================================
** RCSetBroadcastMode()
**
** Defined values for Mode:
** 0 - turn off promiscuous mode
** 1 - turn on promiscuous mode
**
** =========================================================================
*/
RC_RETURN
RCSetBroadcastMode(struct net_device *dev, U16 Mode)
{
U32 off;
PU32 pMsg;
PPAB pPab = ((PDPA)dev->priv)->pPab;
if (pPab == NULL)
return RC_RTN_ADPTR_NOT_REGISTERED;
off = pPab->p_atu->InQueue; /* get addresss of message */
if (0xFFFFFFFF == off)
return RC_RTN_FREE_Q_EMPTY;
pMsg = (PU32)(pPab->pPci45LinBaseAddr + off);
/* setup private message */
pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
pMsg[2] = 0; /* initiator context */
pMsg[3] = 0x219; /* transaction context */
pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_SET_BROADCAST_MODE;
pMsg[5] = Mode; /* promiscuous mode setting */
pPab->p_atu->InQueue = off; /* send it to the device */
return RC_RTN_NO_ERROR ;
}
/*
** =========================================================================
** RCGetBroadcastMode()
**
** get promiscuous mode setting
**
** Possible return values placed in pMode:
** 0 = promisuous mode not set
** 1 = promisuous mode is set
**
** =========================================================================
*/
RC_RETURN
RCGetBroadcastMode(struct net_device *dev, PU32 pMode,
PFNWAITCALLBACK WaitCallback)
{
U32 msgOffset, timeout;
PU32 pMsg;
volatile PU32 p32;
PPAB pPab = ((PDPA)dev->priv)->pPab;
msgOffset = pPab->p_atu->InQueue;
if (msgOffset == 0xFFFFFFFF)
{
printk(KERN_WARNING "(rcpci45 driver:) RCGetLinkSpeed(): Inbound Free Q empty!\n");
return RC_RTN_FREE_Q_EMPTY;
}
/* calc virtual address of msg - virtual already mapped to physical */
pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset);
/* virtual pointer to return buffer - clear first two dwords */
p32 = (volatile PU32)pPab->pLinOutMsgBlock;
p32[0] = 0xff;
/* setup private message */
pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
pMsg[2] = 0; /* initiator context */
pMsg[3] = 0x219; /* transaction context */
pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_BROADCAST_MODE;
/* phys address to return status - area right after PAB */
pMsg[5] = pPab->outMsgBlockPhyAddr;
/* post to Inbound Post Q */
pPab->p_atu->InQueue = msgOffset;
/* wait for response */
timeout = 1000000;
while(1) {
if (WaitCallback)
(*WaitCallback)();
udelay(10); /* please don't hog the bus!!! */
if (p32[0] != 0xff)
break;
if (!timeout--)
{
printk(KERN_WARNING "(rcpci45 driver:) Timeout waiting for promiscuous mode from adapter\n");
printk(KERN_WARNING "(rcpci45 driver:) 0x%8x\n", p32[0]);
return RC_RTN_NO_LINK_SPEED;
}
}
/* get mode */
*pMode = (U8)((volatile PU8)p32)[0] & 0x0f;
return RC_RTN_NO_ERROR;
}
/*
** =========================================================================
** RCGetLinkSpeed()
**
** get ethernet link speed.
**
** 0 = Unknown
** 1 = Full Duplex 100BaseT
** 2 = Half duplex 100BaseT
** 3 = Full Duplex 10BaseT
** 4 = Half duplex 10BaseT
**
** =========================================================================
*/
RC_RETURN
RCGetLinkSpeed(struct net_device *dev, PU32 pLinkSpeedCode,
PFNWAITCALLBACK WaitCallback)
{
U32 msgOffset, timeout;
PU32 pMsg;
volatile PU32 p32;
U8 IOPLinkSpeed;
PPAB pPab = ((PDPA)dev->priv)->pPab;
msgOffset = pPab->p_atu->InQueue;
if (msgOffset == 0xFFFFFFFF)
{
printk(KERN_WARNING "(rcpci45 driver:) RCGetLinkSpeed(): Inbound Free Q empty!\n");
return RC_RTN_FREE_Q_EMPTY;
}
/* calc virtual address of msg - virtual already mapped to physical */
pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset);
/* virtual pointer to return buffer - clear first two dwords */
p32 = (volatile PU32)pPab->pLinOutMsgBlock;
p32[0] = 0xff;
/* setup private message */
pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
pMsg[2] = 0; /* initiator context */
pMsg[3] = 0x219; /* transaction context */
pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_LINK_SPEED;
/* phys address to return status - area right after PAB */
pMsg[5] = pPab->outMsgBlockPhyAddr;
/* post to Inbound Post Q */
pPab->p_atu->InQueue = msgOffset;
/* wait for response */
timeout = 1000000;
while(1) {
if (WaitCallback)
(*WaitCallback)();
udelay(10); /* please don't hog the bus!!! */
if (p32[0] != 0xff)
break;
if (!timeout--)
{
dprintk("Timeout waiting for link speed from IOP\n");
dprintk("0x%8x\n", p32[0]);
return RC_RTN_NO_LINK_SPEED;
}
}
/* get Link speed */
IOPLinkSpeed = (U8)((volatile PU8)p32)[0] & 0x0f;
*pLinkSpeedCode= IOPLinkSpeed;
return RC_RTN_NO_ERROR;
}
/*
** =========================================================================
** RCReportDriverCapability(struct net_device *dev, U32 capability)
**
** Currently defined bits:
** WARM_REBOOT_CAPABLE 0x01
**
** =========================================================================
*/
RC_RETURN
RCReportDriverCapability(struct net_device *dev, U32 capability)
{
U32 off;
PU32 pMsg;
PPAB pPab = ((PDPA)dev->priv)->pPab;
if (pPab == NULL)
return RC_RTN_ADPTR_NOT_REGISTERED;
off = pPab->p_atu->InQueue; /* get addresss of message */
if (0xFFFFFFFF == off)
return RC_RTN_FREE_Q_EMPTY;
pMsg = (PU32)(pPab->pPci45LinBaseAddr + off);
/* setup private message */
pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
pMsg[2] = 0; /* initiator context */
pMsg[3] = 0x219; /* transaction context */
pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_REPORT_DRIVER_CAPABILITY;
pMsg[5] = capability;
pPab->p_atu->InQueue = off; /* send it to the I2O device */
return RC_RTN_NO_ERROR ;
}
/*
** =========================================================================
** RCGetFirmwareVer()
**
** Return firmware version in the form "SoftwareVersion : Bt BootVersion"
**
** =========================================================================
*/
RC_RETURN
RCGetFirmwareVer(struct net_device *dev, PU8 pFirmString,
PFNWAITCALLBACK WaitCallback)
{
U32 msgOffset, timeout;
PU32 pMsg;
volatile PU32 p32;
PPAB pPab = ((PDPA)dev->priv)->pPab;
msgOffset = pPab->p_atu->InQueue;
if (msgOffset == 0xFFFFFFFF)
{
dprintk("RCGetFirmwareVer(): Inbound Free Q empty!\n");
return RC_RTN_FREE_Q_EMPTY;
}
/* calc virtual address of msg - virtual already mapped to physical */
pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset);
/* virtual pointer to return buffer - clear first two dwords */
p32 = (volatile PU32)pPab->pLinOutMsgBlock;
p32[0] = 0xff;
/* setup private message */
pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
pMsg[2] = 0; /* initiator context */
pMsg[3] = 0x219; /* transaction context */
pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_FIRMWARE_REV;
/* phys address to return status - area right after PAB */
pMsg[5] = pPab->outMsgBlockPhyAddr;
/* post to Inbound Post Q */
pPab->p_atu->InQueue = msgOffset;
/* wait for response */
timeout = 1000000;
while(1) {
if (WaitCallback)
(*WaitCallback)();
udelay(10); /* please don't hog the bus!!! */
if (p32[0] != 0xff)
break;
if (!timeout--)
{
dprintk("Timeout waiting for link speed from IOP\n");
return RC_RTN_NO_FIRM_VER;
}
}
strcpy(pFirmString, (PU8)p32);
return RC_RTN_NO_ERROR;
}
/*
** =========================================================================
** RCResetLANCard()
**
** ResourceFlags indicates whether to return buffer resource explicitly
** to host or keep and reuse.
** CallbackFunction (if not NULL) is the function to be called when
** reset is complete.
** If CallbackFunction is NULL, ReturnAddr will have a 1 placed in it when
** reset is done (if not NULL).
**
** =========================================================================
*/
RC_RETURN
RCResetLANCard(struct net_device *dev, U16 ResourceFlags, PU32 ReturnAddr,
PFNCALLBACK CallbackFunction)
{
unsigned long off;
PU32 pMsg;
PPAB pPab = ((PDPA)dev->priv)->pPab;
long timeout = 0;
if (pPab == NULL)
return RC_RTN_ADPTR_NOT_REGISTERED;
off = pPab->p_atu->InQueue; /* get addresss of message */
if (0xFFFFFFFF == off)
return RC_RTN_FREE_Q_EMPTY;
pPab->pCallbackFunc = CallbackFunction;
pMsg = (PU32)(pPab->pPci45LinBaseAddr + off);
/* setup message */
pMsg[0] = FOUR_WORD_MSG_SIZE | SGL_OFFSET_0;
pMsg[1] = I2O_LAN_RESET << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
pMsg[2] = DEFAULT_RECV_INIT_CONTEXT;
pMsg[3] = ResourceFlags << 16; /* resource flags */
pPab->p_atu->InQueue = off; /* send it to the I2O device */
if (CallbackFunction == (PFNCALLBACK)NULL)
{
/* call RCProcI2OMsgQ() until something in pPab->pCallbackFunc
or until timer goes off */
while (pPab->pCallbackFunc == (PFNCALLBACK)NULL)
{
RCProcI2OMsgQ(dev);
udelay(1000); /* please don't hog the bus!!! */
timeout++;
if (timeout > 10000)
{
break;
}
}
if (ReturnAddr != (PU32)NULL)
*ReturnAddr = (U32)pPab->pCallbackFunc;
}
return RC_RTN_NO_ERROR ;
}
/*
** =========================================================================
** RCResetIOP()
**
** Send StatusGet Msg, wait for results return directly to buffer.
**
** =========================================================================
*/
RC_RETURN
RCResetIOP(struct net_device *dev)
{
U32 msgOffset, timeout;
PU32 pMsg;
PPAB pPab = ((PDPA)dev->priv)->pPab;
volatile PU32 p32;
msgOffset = pPab->p_atu->InQueue;
if (msgOffset == 0xFFFFFFFF)
{
return RC_RTN_FREE_Q_EMPTY;
}
/* calc virtual address of msg - virtual already mapped to physical */
pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset);
pMsg[0] = NINE_WORD_MSG_SIZE | SGL_OFFSET_0;
pMsg[1] = I2O_EXEC_IOP_RESET << 24 | I2O_HOST_TID << 12 | I2O_IOP_TID;
pMsg[2] = 0; /* universal context */
pMsg[3] = 0; /* universal context */
pMsg[4] = 0; /* universal context */
pMsg[5] = 0; /* universal context */
/* phys address to return status - area right after PAB */
pMsg[6] = pPab->outMsgBlockPhyAddr;
pMsg[7] = 0;
pMsg[8] = 1; /* return 1 byte */
/* virual pointer to return buffer - clear first two dwords */
p32 = (volatile PU32)pPab->pLinOutMsgBlock;
p32[0] = 0;
p32[1] = 0;
/* post to Inbound Post Q */
pPab->p_atu->InQueue = msgOffset;
/* wait for response */
timeout = 1000000;
while(1) {
udelay(10); /* please don't hog the bus!!! */
if (p32[0] || p32[1])
break;
if (!timeout--)
{
dprintk("RCResetIOP timeout\n");
return RC_RTN_MSG_REPLY_TIMEOUT;
}
}
return RC_RTN_NO_ERROR;
}
/*
** =========================================================================
** RCShutdownLANCard()
**
** ResourceFlags indicates whether to return buffer resource explicitly
** to host or keep and reuse.
** CallbackFunction (if not NULL) is the function to be called when
** shutdown is complete.
** If CallbackFunction is NULL, ReturnAddr will have a 1 placed in it when
** shutdown is done (if not NULL).
**
** =========================================================================
*/
RC_RETURN
RCShutdownLANCard(struct net_device *dev, U16 ResourceFlags,
PU32 ReturnAddr, PFNCALLBACK CallbackFunction)
{
volatile PU32 pMsg;
U32 off;
PPAB pPab = ((PDPA)dev->priv)->pPab;
long timeout = 0;
if (pPab == NULL)
return RC_RTN_ADPTR_NOT_REGISTERED;
off = pPab->p_atu->InQueue; /* get addresss of message */
if (0xFFFFFFFF == off)
return RC_RTN_FREE_Q_EMPTY;
pPab->pCallbackFunc = CallbackFunction;
pMsg = (PU32)(pPab->pPci45LinBaseAddr + off);
/* setup message */
pMsg[0] = FOUR_WORD_MSG_SIZE | SGL_OFFSET_0;
pMsg[1] = I2O_LAN_SHUTDOWN << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
pMsg[2] = DEFAULT_RECV_INIT_CONTEXT;
pMsg[3] = ResourceFlags << 16; /* resource flags */
pPab->p_atu->InQueue = off; /* send it to the I2O device */
if (CallbackFunction == (PFNCALLBACK)NULL)
{
/* call RCProcI2OMsgQ() until something in pPab->pCallbackFunc
or until timer goes off */
while (pPab->pCallbackFunc == (PFNCALLBACK)NULL)
{
RCProcI2OMsgQ(dev);
udelay(1000); /* please don't hog the bus!!! */
timeout++;
if (timeout > 10000)
{
printk(KERN_WARNING "(rcpci45 driver:) RCShutdownLANCard(): timeout\n");
break;
}
}
if (ReturnAddr != (PU32)NULL)
*ReturnAddr = (U32)pPab->pCallbackFunc;
}
return RC_RTN_NO_ERROR ;
}
/*
** =========================================================================
** RCSetRavlinIPandMask()
**
** Set the Ravlin 45/PCI cards IP address and network mask.
**
** IP address and mask must be in network byte order.
** For example, IP address 1.2.3.4 and mask 255.255.255.0 would be
** 0x04030201 and 0x00FFFFFF on a little endian machine.
**
** =========================================================================
*/
RC_RETURN
RCSetRavlinIPandMask(struct net_device *dev, U32 ipAddr, U32 netMask)
{
volatile PU32 pMsg;
U32 off;
PPAB pPab = ((PDPA)dev->priv)->pPab;
if (pPab == NULL)
return RC_RTN_ADPTR_NOT_REGISTERED;
off = pPab->p_atu->InQueue; /* get addresss of message */
if (0xFFFFFFFF == off)
return RC_RTN_FREE_Q_EMPTY;
pMsg = (PU32)(pPab->pPci45LinBaseAddr + off);
/* setup private message */
pMsg[0] = SEVEN_WORD_MSG_SIZE | SGL_OFFSET_0;
pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
pMsg[2] = 0; /* initiator context */
pMsg[3] = 0x219; /* transaction context */
pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_SET_IP_AND_MASK;
pMsg[5] = ipAddr;
pMsg[6] = netMask;
pPab->p_atu->InQueue = off; /* send it to the I2O device */
return RC_RTN_NO_ERROR ;
}
/*
** =========================================================================
** RCGetRavlinIPandMask()
**
** get the IP address and MASK from the card
**
** =========================================================================
*/
RC_RETURN
RCGetRavlinIPandMask(struct net_device *dev, PU32 pIpAddr, PU32 pNetMask,
PFNWAITCALLBACK WaitCallback)
{
unsigned timeout;
U32 off;
PU32 pMsg, p32;
PPAB pPab = ((PDPA)dev->priv)->pPab;
PATU p_atu;
dprintk("RCGetRavlinIPandMask: pIpAddr is 0x%08ulx, *IpAddr is 0x%08ulx\n", (u32)pIpAddr, *pIpAddr);
if (pPab == NULL)
return RC_RTN_ADPTR_NOT_REGISTERED;
p_atu = pPab->p_atu;
off = p_atu->InQueue; /* get addresss of message */
if (0xFFFFFFFF == off)
return RC_RTN_FREE_Q_EMPTY;
p32 = (volatile PU32)pPab->pLinOutMsgBlock;
*p32 = 0xFFFFFFFF;
pMsg = (PU32)(pPab->pPci45LinBaseAddr + off);
dprintk("RCGetRavlinIPandMask: p_atu 0x%08ulx, off 0x%08ulx, p32 0x%08ulx\n", (u32)p_atu, off, (u32)p32);
/* setup private message */
pMsg[0] = FIVE_WORD_MSG_SIZE | SGL_OFFSET_0;
pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
pMsg[2] = 0; /* initiator context */
pMsg[3] = 0x218; /* transaction context */
pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_IP_AND_MASK;
pMsg[5] = pPab->outMsgBlockPhyAddr;
p_atu->InQueue = off; /* send it to the I2O device */
dprintk("RCGetRavlinIPandMask: p_atu 0x%08ulx, off 0x%08ulx, p32 0x%08ulx\n", (u32)p_atu, off, (u32)p32);
/* wait for the rcpci45 board to update the info */
timeout = 100000;
while (0xffffffff == *p32)
{
if (WaitCallback)
(*WaitCallback)();
udelay(10);
if (!timeout--)
{
dprintk("RCGetRavlinIPandMask: Timeout\n");
return RC_RTN_MSG_REPLY_TIMEOUT;
}
}
dprintk("RCGetRavlinIPandMask: after time out\np32[0] (IpAddr) 0x%08ulx, p32[1] (IPmask) 0x%08ulx\n", p32[0], p32[1]);
/* send IP and mask to user's space */
*pIpAddr = p32[0];
*pNetMask = p32[1];
dprintk("RCGetRavlinIPandMask: pIpAddr is 0x%08ulx, *IpAddr is 0x%08ulx\n", (u32)pIpAddr, *pIpAddr);
return RC_RTN_NO_ERROR;
}
/*
** /////////////////////////////////////////////////////////////////////////
** /////////////////////////////////////////////////////////////////////////
**
** local functions
**
** /////////////////////////////////////////////////////////////////////////
** /////////////////////////////////////////////////////////////////////////
*/
/*
** =========================================================================
** SendI2OOutboundQInitMsg()
**
** =========================================================================
*/
static int
SendI2OOutboundQInitMsg(PPAB pPab)
{
U32 msgOffset, timeout, phyOutQFrames, i;
volatile PU32 pMsg;
volatile PU32 p32;
msgOffset = pPab->p_atu->InQueue;
if (msgOffset == 0xFFFFFFFF)
{
dprintk("SendI2OOutboundQInitMsg(): Inbound Free Q empty!\n");
return RC_RTN_FREE_Q_EMPTY;
}
/* calc virual address of msg - virual already mapped to physical */
pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset);
dprintk("SendI2OOutboundQInitMsg - pMsg = 0x%08ulx, InQ msgOffset = 0x%08ulx\n", (u32)pMsg, msgOffset);
pMsg[0] = EIGHT_WORD_MSG_SIZE | TRL_OFFSET_6;
pMsg[1] = I2O_EXEC_OUTBOUND_INIT << 24 | I2O_HOST_TID << 12 | I2O_IOP_TID;
pMsg[2] = DEFAULT_RECV_INIT_CONTEXT;
pMsg[3] = 0x106; /* transaction context */
pMsg[4] = 4096; /* Host page frame size */
pMsg[5] = MSG_FRAME_SIZE << 16 | 0x80; /* outbound msg frame size and Initcode */
pMsg[6] = 0xD0000004; /* simple sgl element LE, EOB */
/* phys address to return status - area right after PAB */
pMsg[7] = pPab->outMsgBlockPhyAddr;
/* virual pointer to return buffer - clear first two dwords */
p32 = (PU32)pPab->pLinOutMsgBlock;
p32[0] = 0;
/* post to Inbound Post Q */
pPab->p_atu->InQueue = msgOffset;
/* wait for response */
timeout = 100000;
while(1)
{
udelay(10); /* please don't hog the bus!!! */
if (p32[0])
break;
if (!timeout--)
{
dprintk("Timeout wait for InitOutQ InPrgress status from IOP\n");
return RC_RTN_NO_I2O_STATUS;
}
}
timeout = 100000;
while(1)
{
udelay(10); /* please don't hog the bus!!! */
if (p32[0] == I2O_EXEC_OUTBOUND_INIT_COMPLETE)
break;
if (!timeout--)
{
dprintk("Timeout wait for InitOutQ Complete status from IOP\n");
return RC_RTN_NO_I2O_STATUS;
}
}
/* load PCI outbound free Q with MF physical addresses */
phyOutQFrames = pPab->outMsgBlockPhyAddr;
for (i = 0; i < NMBR_MSG_FRAMES; i++)
{
pPab->p_atu->OutQueue = phyOutQFrames;
phyOutQFrames += MSG_FRAME_SIZE;
}
return RC_RTN_NO_ERROR;
}
/*
** =========================================================================
** GetI2OStatus()
**
** Send StatusGet Msg, wait for results return directly to buffer.
**
** =========================================================================
*/
static int
GetI2OStatus(PPAB pPab)
{
U32 msgOffset, timeout;
PU32 pMsg;
volatile PU32 p32;
msgOffset = pPab->p_atu->InQueue;
dprintk("GetI2OStatus: msg offset = 0x%x\n", msgOffset);
if (msgOffset == 0xFFFFFFFF)
{
dprintk("GetI2OStatus(): Inbound Free Q empty!\n");
return RC_RTN_FREE_Q_EMPTY;
}
/* calc virual address of msg - virual already mapped to physical */
pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset);
pMsg[0] = NINE_WORD_MSG_SIZE | SGL_OFFSET_0;
pMsg[1] = I2O_EXEC_STATUS_GET << 24 | I2O_HOST_TID << 12 | I2O_IOP_TID;
pMsg[2] = 0; /* universal context */
pMsg[3] = 0; /* universal context */
pMsg[4] = 0; /* universal context */
pMsg[5] = 0; /* universal context */
/* phys address to return status - area right after PAB */
pMsg[6] = pPab->outMsgBlockPhyAddr;
pMsg[7] = 0;
pMsg[8] = 88; /* return 88 bytes */
/* virual pointer to return buffer - clear first two dwords */
p32 = (volatile PU32)pPab->pLinOutMsgBlock;
p32[0] = 0;
p32[1] = 0;
dprintk("GetI2OStatus - pMsg:0x%08ulx, msgOffset:0x%08ulx, [1]:0x%08ulx, [6]:0x%08ulx\n",
(u32)pMsg, msgOffset, pMsg[1], pMsg[6]);
/* post to Inbound Post Q */
pPab->p_atu->InQueue = msgOffset;
dprintk("Return status to p32 = 0x%08ulx\n", (u32)p32);
/* wait for response */
timeout = 1000000;
while(1) {
udelay(10); /* please don't hog the bus!!! */
if (p32[0] && p32[1])
break;
if (!timeout--)
{
dprintk("Timeout waiting for status from IOP\n");
dprintk("0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n", p32[0], p32[1], p32[2], p32[3]);
dprintk("0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n", p32[4], p32[5], p32[6], p32[7]);
dprintk("0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n", p32[8], p32[9], p32[10], p32[11]);
return RC_RTN_NO_I2O_STATUS;
}
}
dprintk("0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n", p32[0], p32[1], p32[2], p32[3]);
dprintk("0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n", p32[4], p32[5], p32[6], p32[7]);
dprintk("0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n", p32[8], p32[9], p32[10], p32[11]);
/* get IOP state */
pPab->IOPState = ((volatile PU8)p32)[10];
pPab->InboundMFrameSize = ((volatile PU16)p32)[6];
dprintk("IOP state 0x%02x InFrameSize = 0x%04x\n",
pPab->IOPState, pPab->InboundMFrameSize);
return RC_RTN_NO_ERROR;
}
/*
** =========================================================================
** SendEnableSysMsg()
**
**
** =========================================================================
*/
static int
SendEnableSysMsg(PPAB pPab)
{
U32 msgOffset;
volatile PU32 pMsg;
msgOffset = pPab->p_atu->InQueue;
if (msgOffset == 0xFFFFFFFF)
{
dprintk("SendEnableSysMsg(): Inbound Free Q empty!\n");
return RC_RTN_FREE_Q_EMPTY;
}
/* calc virual address of msg - virual already mapped to physical */
pMsg = (PU32)(pPab->pPci45LinBaseAddr + msgOffset);
dprintk("SendEnableSysMsg - pMsg = 0x%08ulx, InQ msgOffset = 0x%08ulx\n", (u32)pMsg, msgOffset);
pMsg[0] = FOUR_WORD_MSG_SIZE | SGL_OFFSET_0;
pMsg[1] = I2O_EXEC_SYS_ENABLE << 24 | I2O_HOST_TID << 12 | I2O_IOP_TID;
pMsg[2] = DEFAULT_RECV_INIT_CONTEXT;
pMsg[3] = 0x110; /* transaction context */
pMsg[4] = 0x50657465; /* RedCreek Private */
/* post to Inbound Post Q */
pPab->p_atu->InQueue = msgOffset;
return RC_RTN_NO_ERROR;
}
/*
** =========================================================================
** FillI2OMsgFromTCB()
**
** inputs pMsgU32 - virual pointer (mapped to physical) of message frame
** pXmitCntrlBlock - pointer to caller buffer control block.
**
** fills in LAN SGL after Transaction Control Word or Bucket Count.
** =========================================================================
*/
static int
FillI2OMsgSGLFromTCB(PU32 pMsgFrame, PRCTCB pTransCtrlBlock)
{
unsigned int nmbrBuffers, nmbrSeg, nmbrDwords, context, flags;
PU32 pTCB, pMsg;
/* SGL element flags */
#define EOB 0x40000000
#define LE 0x80000000
#define SIMPLE_SGL 0x10000000
#define BC_PRESENT 0x01000000
pTCB = (PU32)pTransCtrlBlock;
pMsg = pMsgFrame;
nmbrDwords = 0;
dprintk("FillI2OMsgSGLFromTCBX\n");
dprintk("TCB 0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n",
pTCB[0], pTCB[1], pTCB[2], pTCB[3], pTCB[4]);
dprintk("pTCB 0x%08ulx, pMsg 0x%08ulx\n", (u32)pTCB, (u32)pMsg);
nmbrBuffers = *pTCB++;
if (!nmbrBuffers)
{
return -1;
}
do
{
context = *pTCB++; /* buffer tag (context) */
nmbrSeg = *pTCB++; /* number of segments */
if (!nmbrSeg)
{
return -1;
}
flags = SIMPLE_SGL | BC_PRESENT;
if (1 == nmbrSeg)
{
flags |= EOB;
if (1 == nmbrBuffers)
flags |= LE;
}
/* 1st SGL buffer element has context */
pMsg[0] = pTCB[0] | flags ; /* send over count (segment size) */
pMsg[1] = context;
pMsg[2] = pTCB[1]; /* send buffer segment physical address */
nmbrDwords += 3;
pMsg += 3;
pTCB += 2;
if (--nmbrSeg)
{
do
{
flags = SIMPLE_SGL;
if (1 == nmbrSeg)
{
flags |= EOB;
if (1 == nmbrBuffers)
flags |= LE;
}
pMsg[0] = pTCB[0] | flags; /* send over count */
pMsg[1] = pTCB[1]; /* send buffer segment physical address */
nmbrDwords += 2;
pTCB += 2;
pMsg += 2;
} while (--nmbrSeg);
}
} while (--nmbrBuffers);
return nmbrDwords;
}
/*
** =========================================================================
** ProcessOutboundI2OMsg()
**
** process I2O reply message
** * change to msg structure *
** =========================================================================
*/
static void
ProcessOutboundI2OMsg(PPAB pPab, U32 phyAddrMsg)
{
PU8 p8Msg;
PU32 p32;
/* U16 count; */
p8Msg = pPab->pLinOutMsgBlock + (phyAddrMsg - pPab->outMsgBlockPhyAddr);
p32 = (PU32)p8Msg;
dprintk("VXD: ProcessOutboundI2OMsg - pPab 0x%08ulx, phyAdr 0x%08ulx, linAdr 0x%08ulx\n", (u32)pPab, phyAddrMsg, (u32)p8Msg);
dprintk("msg :0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n", p32[0], p32[1], p32[2], p32[3]);
dprintk("msg :0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n", p32[4], p32[5], p32[6], p32[7]);
if (p32[4] >> 24 != I2O_REPLY_STATUS_SUCCESS)
{
dprintk("Message reply status not success\n");
return;
}
switch (p8Msg[7] ) /* function code byte */
{
case I2O_EXEC_SYS_TAB_SET:
msgFlag = 1;
dprintk("Received I2O_EXEC_SYS_TAB_SET reply\n");
break;
case I2O_EXEC_HRT_GET:
msgFlag = 1;
dprintk("Received I2O_EXEC_HRT_GET reply\n");
break;
case I2O_EXEC_LCT_NOTIFY:
msgFlag = 1;
dprintk("Received I2O_EXEC_LCT_NOTIFY reply\n");
break;
case I2O_EXEC_SYS_ENABLE:
msgFlag = 1;
dprintk("Received I2O_EXEC_SYS_ENABLE reply\n");
break;
default:
dprintk("Received UNKNOWN reply\n");
break;
}
}
|