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
|
/*++
Copyright (c) Microsoft Corporation. All rights reserved.
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
PURPOSE.
Module Name:
CtrlPath.c
Abstract:
This module implements the miniport's control path. It contains the main
miniport entrypoint for OID handling.
--*/
#include "netvmin6.h"
#include "ctrlpath.tmh"
static
NDIS_STATUS
MPMethodRequest(
_In_ PMP_ADAPTER Adapter,
_In_ PNDIS_OID_REQUEST NdisRequest);
static
NDIS_STATUS
MPSynchronousMethodRequest(
_In_ PMP_ADAPTER Adapter,
_In_ PNDIS_OID_REQUEST NdisRequest);
static
NDIS_STATUS
MPSetInformation(
_In_ PMP_ADAPTER Adapter,
_In_ PNDIS_OID_REQUEST NdisSetRequest);
static
NDIS_STATUS
MPQueryInformation(
_In_ PMP_ADAPTER Adapter,
_Inout_ PNDIS_OID_REQUEST NdisQueryRequest);
static
NDIS_STATUS
NICSetMulticastList(
_In_ PMP_ADAPTER Adapter,
_In_ PNDIS_OID_REQUEST NdisSetRequest);
static
NDIS_STATUS
NICSetPacketFilter(
_In_ PMP_ADAPTER Adapter,
_In_ ULONG PacketFilter);
#if (NDIS_SUPPORT_NDIS620)
static
NDIS_STATUS
NICAllocateRxQueue(
_In_ PMP_ADAPTER Adapter,
_In_ PNDIS_OID_REQUEST NdisMethodRequest);
static
NDIS_STATUS
NICCompleteAllocationRxQueue(
_In_ PMP_ADAPTER Adapter,
_In_ PNDIS_OID_REQUEST NdisMethodRequest);
static
NDIS_STATUS
NICFreeRxQueue(
_In_ PMP_ADAPTER Adapter,
_In_ PNDIS_OID_REQUEST NdisSetRequest);
static
NDIS_STATUS
NICSetRxFilter(
_In_ PMP_ADAPTER Adapter,
_In_ PNDIS_OID_REQUEST NdisMethodRequest);
static
NDIS_STATUS
NICClearRxFilter(
_In_ PMP_ADAPTER Adapter,
_In_ PNDIS_OID_REQUEST NdisSetRequest);
static
NDIS_STATUS
NICUpdateRxQueue(
_In_ PMP_ADAPTER Adapter,
_In_ PNDIS_OID_REQUEST NdisSetRequest);
_IRQL_requires_(PASSIVE_LEVEL)
static
NDIS_STATUS
NICSetQOSParameters(
_In_ PMP_ADAPTER Adapter,
_In_ PNDIS_OID_REQUEST NdisMethodRequest);
#pragma NDIS_PAGEABLE_FUNCTION(NICFreeRxQueue)
#pragma NDIS_PAGEABLE_FUNCTION(NICClearRxFilter)
#pragma NDIS_PAGEABLE_FUNCTION(NICUpdateRxQueue)
#pragma NDIS_PAGEABLE_FUNCTION(NICAllocateRxQueue)
#pragma NDIS_PAGEABLE_FUNCTION(NICCompleteAllocationRxQueue)
#pragma NDIS_PAGEABLE_FUNCTION(NICSetRxFilter)
#pragma NDIS_PAGEABLE_FUNCTION(NICSetQOSParameters)
#endif
#if (NDIS_SUPPORT_NDIS680)
static
NDIS_STATUS
MPSetRSSv2Parameters(
_In_ PMP_ADAPTER Adapter,
_In_ PNDIS_OID_REQUEST NdisSetRequest);
static
NDIS_STATUS
MPSetRSSv2IndirectionTableEntries(
_In_ PMP_ADAPTER Adapter,
_In_ PNDIS_OID_REQUEST NdisSetRequest);
#endif
static
NDIS_STATUS
MPSetPower(
_In_ PMP_ADAPTER Adapter,
_In_ PNDIS_OID_REQUEST NdisSetRequest);
static
NDIS_STATUS
MPSetPowerD0(
_In_ PMP_ADAPTER Adapter);
static
NDIS_STATUS
MPSetPowerLow(
_In_ PMP_ADAPTER Adapter,
_In_ NDIS_DEVICE_POWER_STATE PowerState);
#pragma NDIS_PAGEABLE_FUNCTION(MPOidRequest)
#pragma NDIS_PAGEABLE_FUNCTION(MPQueryInformation)
#pragma NDIS_PAGEABLE_FUNCTION(MPSetInformation)
#pragma NDIS_PAGEABLE_FUNCTION(MPMethodRequest)
#pragma NDIS_PAGEABLE_FUNCTION(MPSetPower)
#pragma NDIS_PAGEABLE_FUNCTION(MPSetPowerD0)
#pragma NDIS_PAGEABLE_FUNCTION(MPSetPowerLow)
#pragma NDIS_PAGEABLE_FUNCTION(NICSetMulticastList)
#pragma NDIS_PAGEABLE_FUNCTION(NICSetPacketFilter)
NDIS_STATUS
MPOidRequest(
_In_ NDIS_HANDLE MiniportAdapterContext,
_In_ PNDIS_OID_REQUEST NdisRequest)
/*++
Routine Description:
Entry point called by NDIS to get or set the value of a specified OID.
Arguments:
MiniportAdapterContext - Our adapter handle
NdisRequest - The OID request to handle
Return Value:
Return code from the NdisRequest below.
--*/
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
PMP_ADAPTER Adapter = MP_ADAPTER_FROM_CONTEXT(MiniportAdapterContext);
PAGED_CODE();
DEBUGP(MP_LOUD, "[%p] ---> MPOidRequest\n", Adapter);
switch (NdisRequest->RequestType)
{
case NdisRequestMethod:
Status = MPMethodRequest(Adapter, NdisRequest);
break;
case NdisRequestSetInformation:
Status = MPSetInformation(Adapter, NdisRequest);
break;
case NdisRequestQueryInformation:
case NdisRequestQueryStatistics:
Status = MPQueryInformation(Adapter, NdisRequest);
break;
default:
//
// The entry point may by used by other requests
//
Status = NDIS_STATUS_NOT_SUPPORTED;
break;
}
DEBUGP(MP_LOUD, "[%p] <--- MPOidRequest Status = 0x%08x\n", Adapter, Status);
return Status;
}
#if (NDIS_SUPPORT_NDIS680)
NDIS_STATUS
MPSynchronousOidRequest(
_In_ NDIS_HANDLE MiniportAdapterContext,
_In_ PNDIS_OID_REQUEST NdisRequest)
/*++
Routine Description:
Entry point called by NDIS to get or set the value of a specified
synchronous OID.
Arguments:
MiniportAdapterContext - Our adapter handle
NdisRequest - The OID request to handle
Return Value:
Return code from the NdisRequest below.
--*/
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
PMP_ADAPTER Adapter = MP_ADAPTER_FROM_CONTEXT(MiniportAdapterContext);
DEBUGP(MP_LOUD, "[%p] ---> MPSynchronousOidRequest\n", Adapter);
switch (NdisRequest->RequestType)
{
case NdisRequestMethod:
Status = MPSynchronousMethodRequest(Adapter, NdisRequest);
break;
default:
//
// The entry point may by used by other requests
//
Status = NDIS_STATUS_NOT_SUPPORTED;
break;
}
DEBUGP(MP_LOUD, "[%p] <--- MPSynchronousOidRequest Status = 0x%08x\n", Adapter, Status);
return Status;
}
#endif
VOID
MPCancelOidRequest(
_In_ NDIS_HANDLE MiniportAdapterContext,
_In_ PVOID RequestId)
/*++
Routine Description:
Entry point called by NDIS to abort an asynchronous OID request.
Arguments:
MiniportAdapterContext - Our adapter handle
RequestId - An identifier that corresponds to the RequestId
field of the NDIS_OID_REQUEST
Return Value:
None.
--*/
{
PMP_ADAPTER Adapter = MP_ADAPTER_FROM_CONTEXT(MiniportAdapterContext);
DEBUGP(MP_LOUD, "[%p] ---> MPCancelOidRequest", Adapter);
UNREFERENCED_PARAMETER(Adapter);
UNREFERENCED_PARAMETER(RequestId);
//
// This miniport sample does not pend any OID requests, so we don't have
// to worry about cancelling them.
//
DEBUGP(MP_LOUD, "[%p] <--- MPCancelOidRequest", Adapter);
}
NDIS_STATUS
MPQueryInformation(
_In_ PMP_ADAPTER Adapter,
_Inout_ PNDIS_OID_REQUEST NdisQueryRequest)
/*++
Routine Description:
Helper function to perform a query OID request
Arguments:
Adapter -
NdisQueryRequest - The OID that is being queried
Return Value:
NDIS_STATUS
--*/
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
struct _QUERY *Query = &NdisQueryRequest->DATA.QUERY_INFORMATION;
NDIS_HARDWARE_STATUS HardwareStatus = NdisHardwareStatusReady;
UCHAR VendorDesc[] = NIC_VENDOR_DESC;
NDIS_MEDIUM Medium = NIC_MEDIUM_TYPE;
ULONG ulInfo;
USHORT usInfo;
ULONG64 ulInfo64;
// Default to returning the ULONG value
PVOID pInfo=NULL;
ULONG ulInfoLen = sizeof(ulInfo);
PAGED_CODE();
DEBUGP(MP_LOUD, "[%p] ---> MPQueryInformation ", Adapter);
DbgPrintOidName(Query->Oid);
switch(Query->Oid)
{
case OID_GEN_HARDWARE_STATUS:
//
// Specify the current hardware status of the underlying NIC as
// one of the following NDIS_HARDWARE_STATUS-type values.
//
pInfo = (PVOID) &HardwareStatus;
ulInfoLen = sizeof(NDIS_HARDWARE_STATUS);
break;
case OID_GEN_MAXIMUM_TOTAL_SIZE:
//
// Specify the maximum total packet length, in bytes, the NIC
// supports including the header. A protocol driver might use
// this returned length as a gauge to determine the maximum
// size packet that a NIC driver could forward to the
// protocol driver. The miniport driver must never indicate
// up to the bound protocol driver packets received over the
// network that are longer than the packet size specified by
// OID_GEN_MAXIMUM_TOTAL_SIZE.
//
__fallthrough;
case OID_GEN_TRANSMIT_BLOCK_SIZE:
//
// The OID_GEN_TRANSMIT_BLOCK_SIZE OID specifies the minimum
// number of bytes that a single net packet occupies in the
// transmit buffer space of the NIC. For example, a NIC that
// has a transmit space divided into 256-byte pieces would have
// a transmit block size of 256 bytes. To calculate the total
// transmit buffer space on such a NIC, its driver multiplies
// the number of transmit buffers on the NIC by its transmit
// block size. In our case, the transmit block size is
// identical to its maximum packet size.
__fallthrough;
case OID_GEN_RECEIVE_BLOCK_SIZE:
//
// The OID_GEN_RECEIVE_BLOCK_SIZE OID specifies the amount of
// storage, in bytes, that a single packet occupies in the receive
// buffer space of the NIC.
//
ulInfo = (ULONG) HW_MAX_FRAME_SIZE;
pInfo = &ulInfo;
break;
case OID_GEN_TRANSMIT_BUFFER_SPACE:
//
// Specify the amount of memory, in bytes, on the NIC that
// is available for buffering transmit data. A protocol can
// use this OID as a guide for sizing the amount of transmit
// data per send.
//
ulInfo = HW_MAX_FRAME_SIZE * Adapter->ulMaxBusySends;
pInfo = &ulInfo;
break;
case OID_GEN_RECEIVE_BUFFER_SPACE:
//
// Specify the amount of memory on the NIC that is available
// for buffering receive data. A protocol driver can use this
// OID as a guide for advertising its receive window after it
// establishes sessions with remote nodes.
//
ulInfo = HW_MAX_FRAME_SIZE * Adapter->ulMaxBusyRecvs;
pInfo = &ulInfo;
break;
case OID_GEN_MEDIA_SUPPORTED:
//
// Return an array of media that are supported by the miniport.
// This miniport only supports one medium (Ethernet), so the OID
// returns identical results to OID_GEN_MEDIA_IN_USE.
//
__fallthrough;
case OID_GEN_MEDIA_IN_USE:
//
// Return an array of media that are currently in use by the
// miniport. This array should be a subset of the array returned
// by OID_GEN_MEDIA_SUPPORTED.
//
pInfo = &Medium;
ulInfoLen = sizeof(Medium);
break;
case OID_GEN_MAXIMUM_SEND_PACKETS:
ulInfo = NIC_MAX_BUSY_SENDS;
pInfo = &ulInfo;
break;
case OID_GEN_XMIT_ERROR:
ulInfo = (ULONG)
(Adapter->TxAbortExcessCollisions +
Adapter->TxDmaUnderrun +
Adapter->TxLostCRS +
Adapter->TxLateCollisions+
Adapter->TransmitFailuresOther);
pInfo = &ulInfo;
break;
case OID_GEN_RCV_ERROR:
ulInfo = (ULONG)
(Adapter->RxCrcErrors +
Adapter->RxAlignmentErrors +
Adapter->RxDmaOverrunErrors +
Adapter->RxRuntErrors);
pInfo = &ulInfo;
break;
case OID_GEN_RCV_DISCARDS:
ulInfo = (ULONG)Adapter->RxResourceErrors;
pInfo = &ulInfo;
break;
case OID_GEN_RCV_NO_BUFFER:
ulInfo = (ULONG)
Adapter->RxResourceErrors;
pInfo = &ulInfo;
break;
case OID_GEN_VENDOR_ID:
//
// Specify a three-byte IEEE-registered vendor code, followed
// by a single byte that the vendor assigns to identify a
// particular NIC. The IEEE code uniquely identifies the vendor
// and is the same as the three bytes appearing at the beginning
// of the NIC hardware address. Vendors without an IEEE-registered
// code should use the value 0xFFFFFF.
//
ulInfo = NIC_VENDOR_ID;
pInfo = &ulInfo;
break;
case OID_GEN_VENDOR_DESCRIPTION:
//
// Specify a zero-terminated string describing the NIC vendor.
//
pInfo = VendorDesc;
ulInfoLen = sizeof(VendorDesc);
break;
case OID_GEN_VENDOR_DRIVER_VERSION:
//
// Specify the vendor-assigned version number of the NIC driver.
// The low-order half of the return value specifies the minor
// version; the high-order half specifies the major version.
//
ulInfo = NIC_VENDOR_DRIVER_VERSION;
pInfo = &ulInfo;
break;
case OID_GEN_DRIVER_VERSION:
//
// Specify the NDIS version in use by the NIC driver. The high
// byte is the major version number; the low byte is the minor
// version number.
//
usInfo = (USHORT) (MP_NDIS_MAJOR_VERSION<<8) + MP_NDIS_MINOR_VERSION;
pInfo = (PVOID) &usInfo;
ulInfoLen = sizeof(USHORT);
break;
#if (NDIS_SUPPORT_NDIS61 && !NDIS_SUPPORT_NDIS620)
case OID_PNP_CAPABILITIES:
//
// This OID is obsolete for NDIS 6.20 drivers
//
// Return the wake-up capabilities of its NIC. If you return
// NDIS_STATUS_NOT_SUPPORTED, NDIS considers the miniport driver
// to be not Power management aware and doesn't send any power
// or wake-up related queries such as
// OID_PNP_SET_POWER, OID_PNP_QUERY_POWER,
// OID_PNP_ADD_WAKE_UP_PATTERN, OID_PNP_REMOVE_WAKE_UP_PATTERN,
// OID_PNP_ENABLE_WAKE_UP.
//
Status = NDIS_STATUS_NOT_SUPPORTED;
break;
#endif
//
// Following 4 OIDs are for querying Ethernet Operational
// Characteristics.
//
case OID_802_3_PERMANENT_ADDRESS:
//
// Return the MAC address of the NIC burnt in the hardware.
//
pInfo = Adapter->PermanentAddress;
ulInfoLen = NIC_MACADDR_SIZE;
break;
case OID_802_3_CURRENT_ADDRESS:
//
// Return the MAC address the NIC is currently programmed to
// use. Note that this address could be different from the
// permananent address as the user can override using
// registry. Read NdisReadNetworkAddress doc for more info.
//
pInfo = Adapter->CurrentAddress;
ulInfoLen = NIC_MACADDR_SIZE;
break;
case OID_802_3_MAXIMUM_LIST_SIZE:
//
// The maximum number of multicast addresses the NIC driver
// can manage. This list is global for all protocols bound
// to (or above) the NIC. Consequently, a protocol can receive
// NDIS_STATUS_MULTICAST_FULL from the NIC driver when
// attempting to set the multicast address list, even if
// the number of elements in the given list is less than
// the number originally returned for this query.
//
ulInfo = NIC_MAX_MCAST_LIST;
pInfo = &ulInfo;
break;
//
// Following list consists of both general and Ethernet
// specific statistical OIDs.
//
case OID_GEN_XMIT_OK:
ulInfo64 = Adapter->FramesTxBroadcast
+ Adapter->FramesTxMulticast
+ Adapter->FramesTxDirected;
pInfo = &ulInfo64;
if (Query->InformationBufferLength >= sizeof(ULONG64) ||
Query->InformationBufferLength == 0)
{
ulInfoLen = sizeof(ULONG64);
}
else
{
ulInfoLen = sizeof(ULONG);
}
// We should always report that only 8 bytes are required to keep ndistest happy
Query->BytesNeeded = sizeof(ULONG64);
break;
case OID_GEN_RCV_OK:
ulInfo64 = Adapter->FramesRxBroadcast
+ Adapter->FramesRxMulticast
+ Adapter->FramesRxDirected;
pInfo = &ulInfo64;
if (Query->InformationBufferLength >= sizeof(ULONG64) ||
Query->InformationBufferLength == 0)
{
ulInfoLen = sizeof(ULONG64);
}
else
{
ulInfoLen = sizeof(ULONG);
}
// We should always report that only 8 bytes are required to keep ndistest happy
Query->BytesNeeded = sizeof(ULONG64);
break;
case OID_GEN_STATISTICS:
if (Query->InformationBufferLength < sizeof(NDIS_STATISTICS_INFO))
{
Status = NDIS_STATUS_INVALID_LENGTH;
Query->BytesNeeded = sizeof(NDIS_STATISTICS_INFO);
break;
}
else
{
PNDIS_STATISTICS_INFO Statistics = (PNDIS_STATISTICS_INFO)Query->InformationBuffer;
{C_ASSERT(sizeof(NDIS_STATISTICS_INFO) >= NDIS_SIZEOF_STATISTICS_INFO_REVISION_1);}
Statistics->Header.Type = NDIS_OBJECT_TYPE_DEFAULT;
Statistics->Header.Size = NDIS_SIZEOF_STATISTICS_INFO_REVISION_1;
Statistics->Header.Revision = NDIS_STATISTICS_INFO_REVISION_1;
Statistics->SupportedStatistics = NIC_SUPPORTED_STATISTICS;
/* Bytes in */
Statistics->ifHCInOctets =
Adapter->BytesRxDirected +
Adapter->BytesRxMulticast +
Adapter->BytesRxBroadcast;
Statistics->ifHCInUcastOctets =
Adapter->BytesRxDirected;
Statistics->ifHCInMulticastOctets =
Adapter->BytesRxMulticast;
Statistics->ifHCInBroadcastOctets =
Adapter->BytesRxBroadcast;
/* Packets in */
Statistics->ifHCInUcastPkts =
Adapter->FramesRxDirected;
Statistics->ifHCInMulticastPkts =
Adapter->FramesRxMulticast;
Statistics->ifHCInBroadcastPkts =
Adapter->FramesRxBroadcast;
/* Errors in */
Statistics->ifInErrors =
Adapter->RxCrcErrors +
Adapter->RxAlignmentErrors +
Adapter->RxDmaOverrunErrors +
Adapter->RxRuntErrors;
Statistics->ifInDiscards =
Adapter->RxResourceErrors;
/* Bytes out */
Statistics->ifHCOutOctets =
Adapter->BytesTxDirected +
Adapter->BytesTxMulticast +
Adapter->BytesTxBroadcast;
Statistics->ifHCOutUcastOctets =
Adapter->BytesTxDirected;
Statistics->ifHCOutMulticastOctets =
Adapter->BytesTxMulticast;
Statistics->ifHCOutBroadcastOctets =
Adapter->BytesTxBroadcast;
/* Packets out */
Statistics->ifHCOutUcastPkts =
Adapter->FramesTxDirected;
Statistics->ifHCOutMulticastPkts =
Adapter->FramesTxMulticast;
Statistics->ifHCOutBroadcastPkts =
Adapter->FramesTxBroadcast;
/* Errors out */
Statistics->ifOutErrors =
Adapter->TxAbortExcessCollisions +
Adapter->TxDmaUnderrun +
Adapter->TxLostCRS +
Adapter->TxLateCollisions+
Adapter->TransmitFailuresOther;
Statistics->ifOutDiscards =
0ULL;
ulInfoLen = NDIS_SIZEOF_STATISTICS_INFO_REVISION_1;
}
break;
case OID_GEN_TRANSMIT_QUEUE_LENGTH:
ulInfo = Adapter->nBusySend;
pInfo = &ulInfo;
break;
case OID_802_3_RCV_ERROR_ALIGNMENT:
ulInfo = Adapter->RxAlignmentErrors;
pInfo = &ulInfo;
break;
case OID_802_3_XMIT_ONE_COLLISION:
ulInfo = Adapter->OneRetry;
pInfo = &ulInfo;
break;
case OID_802_3_XMIT_MORE_COLLISIONS:
ulInfo = Adapter->MoreThanOneRetry;
pInfo = &ulInfo;
break;
case OID_802_3_XMIT_DEFERRED:
ulInfo = Adapter->TxOKButDeferred;
pInfo = &ulInfo;
break;
case OID_802_3_XMIT_MAX_COLLISIONS:
ulInfo = Adapter->TxAbortExcessCollisions;
pInfo = &ulInfo;
break;
case OID_802_3_RCV_OVERRUN:
ulInfo = Adapter->RxDmaOverrunErrors;
pInfo = &ulInfo;
break;
case OID_802_3_XMIT_UNDERRUN:
ulInfo = Adapter->TxDmaUnderrun;
pInfo = &ulInfo;
break;
case OID_802_3_XMIT_HEARTBEAT_FAILURE:
ulInfo = Adapter->TxLostCRS;
pInfo = &ulInfo;
break;
case OID_802_3_XMIT_TIMES_CRS_LOST:
ulInfo = Adapter->TxLostCRS;
pInfo = &ulInfo;
break;
case OID_802_3_XMIT_LATE_COLLISIONS:
ulInfo = Adapter->TxLateCollisions;
pInfo = &ulInfo;
break;
case OID_GEN_INTERRUPT_MODERATION:
{
PNDIS_INTERRUPT_MODERATION_PARAMETERS Moderation = (PNDIS_INTERRUPT_MODERATION_PARAMETERS)Query->InformationBuffer;
Moderation->Header.Type = NDIS_OBJECT_TYPE_DEFAULT;
Moderation->Header.Revision = NDIS_INTERRUPT_MODERATION_PARAMETERS_REVISION_1;
Moderation->Header.Size = NDIS_SIZEOF_INTERRUPT_MODERATION_PARAMETERS_REVISION_1;
Moderation->Flags = 0;
Moderation->InterruptModeration = NdisInterruptModerationNotSupported;
ulInfoLen = NDIS_SIZEOF_INTERRUPT_MODERATION_PARAMETERS_REVISION_1;
}
break;
case OID_PNP_QUERY_POWER:
// simply succeed this.
break;
default:
Status = NDIS_STATUS_NOT_SUPPORTED;
break;
}
if (Status == NDIS_STATUS_SUCCESS)
{
ASSERT(ulInfoLen > 0);
if (ulInfoLen <= Query->InformationBufferLength)
{
if(pInfo)
{
// Copy result into InformationBuffer
NdisMoveMemory(Query->InformationBuffer, pInfo, ulInfoLen);
}
Query->BytesWritten = ulInfoLen;
}
else
{
// too short
Query->BytesNeeded = ulInfoLen;
Status = NDIS_STATUS_BUFFER_TOO_SHORT;
}
}
DEBUGP(MP_LOUD, "[%p] <--- MPQueryInformation Status = 0x%08x\n", Adapter, Status);
return Status;
}
NDIS_STATUS
MPSetInformation(
_In_ PMP_ADAPTER Adapter,
_In_ PNDIS_OID_REQUEST NdisSetRequest)
/*++
Routine Description:
Helper function to perform a set OID request
Arguments:
Adapter -
NdisSetRequest - The OID to set
Return Value:
NDIS_STATUS
--*/
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
struct _SET *Set = &NdisSetRequest->DATA.SET_INFORMATION;
PAGED_CODE();
DEBUGP(MP_LOUD, "[%p] ---> MPSetInformation ", Adapter);
DbgPrintOidName(Set->Oid);
switch(Set->Oid)
{
case OID_802_3_MULTICAST_LIST:
//
// Set the multicast address list on the NIC for packet reception.
// The NIC driver can set a limit on the number of multicast
// addresses bound protocol drivers can enable simultaneously.
// NDIS returns NDIS_STATUS_MULTICAST_FULL if a protocol driver
// exceeds this limit or if it specifies an invalid multicast
// address.
//
Status = NICSetMulticastList(Adapter, NdisSetRequest);
break;
case OID_GEN_CURRENT_PACKET_FILTER:
//
// Program the hardware to indicate the packets
// of certain filter types.
//
if(Set->InformationBufferLength != sizeof(ULONG))
{
Set->BytesNeeded = sizeof(ULONG);
Status = NDIS_STATUS_INVALID_LENGTH;
break;
}
Set->BytesRead = Set->InformationBufferLength;
Status = NICSetPacketFilter(
Adapter,
*((PULONG)Set->InformationBuffer));
break;
case OID_GEN_CURRENT_LOOKAHEAD:
//
// A protocol driver can set a suggested value for the number
// of bytes to be used in its binding; however, the underlying
// NIC driver is never required to limit its indications to
// the value set.
//
if (Set->InformationBufferLength != sizeof(ULONG))
{
Set->BytesNeeded = sizeof(ULONG);
Status = NDIS_STATUS_INVALID_LENGTH;
break;
}
Adapter->ulLookahead = *(PULONG)Set->InformationBuffer;
Set->BytesRead = sizeof(ULONG);
Status = NDIS_STATUS_SUCCESS;
break;
#if (NDIS_SUPPORT_NDIS620)
case OID_RECEIVE_FILTER_FREE_QUEUE:
//
// Free the requested receive queue.
//
Status = NICFreeRxQueue(
Adapter,
NdisSetRequest);
break;
case OID_RECEIVE_FILTER_CLEAR_FILTER:
//
// Remove the requested filter on the requested receive queue.
//
Status = NICClearRxFilter(
Adapter,
NdisSetRequest);
break;
case OID_RECEIVE_FILTER_QUEUE_PARAMETERS:
//
// Update the queue information.
//
Status = NICUpdateRxQueue(
Adapter,
NdisSetRequest);
break;
#endif
case OID_PNP_SET_POWER:
//
// Update power state
//
Status = MPSetPower(
Adapter,
NdisSetRequest);
break;
#if (NDIS_SUPPORT_NDIS680)
case OID_GEN_RECEIVE_SCALE_PARAMETERS_V2:
//
// Update RSSv2 parameters
//
Status = MPSetRSSv2Parameters(Adapter, NdisSetRequest);
break;
#endif
#if (NDIS_SUPPORT_NDIS620)
case OID_PM_ADD_WOL_PATTERN:
case OID_PM_REMOVE_WOL_PATTERN:
case OID_PM_ADD_PROTOCOL_OFFLOAD:
case OID_PM_REMOVE_PROTOCOL_OFFLOAD:
case OID_PM_PARAMETERS:
#else if (NDIS_SUPPORT_NDIS61)
case OID_PNP_ADD_WAKE_UP_PATTERN:
case OID_PNP_REMOVE_WAKE_UP_PATTERN:
case OID_PNP_ENABLE_WAKE_UP:
#endif
ASSERT(!"NIC does not support wake on LAN OIDs");
default:
Status = NDIS_STATUS_NOT_SUPPORTED;
break;
}
if(Status == NDIS_STATUS_SUCCESS)
{
Set->BytesRead = Set->InformationBufferLength;
}
DEBUGP(MP_LOUD, "[%p] <--- MPSetInformation Status = 0x%08x\n", Adapter, Status);
return Status;
}
NDIS_STATUS
MPMethodRequest(
_In_ PMP_ADAPTER Adapter,
_In_ PNDIS_OID_REQUEST NdisRequest)
/*++
Routine Description:
Helper function to perform a WMI OID request
Arguments:
Adapter -
NdisRequest - THe WMI OID request
Return Value:
NDIS_STATUS_SUCCESS
NDIS_STATUS_NOT_SUPPORTED
--*/
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
NDIS_OID Oid = NdisRequest->DATA.METHOD_INFORMATION.Oid;
PAGED_CODE();
UNREFERENCED_PARAMETER(Adapter);
UNREFERENCED_PARAMETER(NdisRequest);
DEBUGP(MP_LOUD, "[%p] ---> MPMethodRequest ", Adapter);
DbgPrintOidName(Oid);
switch (Oid)
{
#if (NDIS_SUPPORT_NDIS620)
case OID_RECEIVE_FILTER_ALLOCATE_QUEUE:
//
// Allocate the requested receive queue.
//
Status = NICAllocateRxQueue(
Adapter,
NdisRequest);
break;
case OID_RECEIVE_FILTER_QUEUE_ALLOCATION_COMPLETE:
//
// Complete any remaining allocation for receive queues.
//
Status = NICCompleteAllocationRxQueue(
Adapter,
NdisRequest);
break;
case OID_RECEIVE_FILTER_SET_FILTER:
//
// Add a filter to the requested queue.
//
Status = NICSetRxFilter(
Adapter,
NdisRequest);
break;
#endif
#if (NDIS_SUPPORT_NDIS630)
case OID_QOS_PARAMETERS:
//
// Set NDIS QoS configuration parameters.
//
Status = NICSetQOSParameters(
Adapter,
NdisRequest);
break;
#endif
default:
Status = NDIS_STATUS_NOT_SUPPORTED;
break;
}
DEBUGP(MP_LOUD, "[%p] <--- MPMethodRequest Status = 0x%08x\n", Adapter, Status);
return Status;
}
#if (NDIS_SUPPORT_NDIS680)
NDIS_STATUS
MPSynchronousMethodRequest(
_In_ PMP_ADAPTER Adapter,
_In_ PNDIS_OID_REQUEST NdisRequest)
/*++
Routine Description:
Helper function to perform a synchronous method OID request
Arguments:
Adapter -
NdisRequest - THe synchronous method OID request
Return Value:
NDIS_STATUS_SUCCESS
NDIS_STATUS_NOT_SUPPORTED
--*/
{
NDIS_STATUS Status;
NDIS_OID Oid;
DEBUGP(MP_LOUD, "[%p] ---> MPSynchronousMethodRequest ", Adapter);
Oid = NdisRequest->DATA.METHOD_INFORMATION.Oid;
DbgPrintOidName(Oid);
switch (Oid)
{
case OID_GEN_RSS_SET_INDIRECTION_TABLE_ENTRIES:
//
// Handle RSSv2 traffic steering OID.
//
Status = MPSetRSSv2IndirectionTableEntries(Adapter, NdisRequest);
break;
default:
Status = NDIS_STATUS_NOT_SUPPORTED;
break;
}
DEBUGP(MP_LOUD, "[%p] <--- MPSynchronousMethodRequest Status = 0x%08x\n", Adapter, Status);
return Status;
}
#endif
NDIS_STATUS
NICSetPacketFilter(
_In_ PMP_ADAPTER Adapter,
_In_ ULONG PacketFilter)
/*++
Routine Description:
This routine will set up the adapter so that it accepts packets
that match the specified packet filter.
Arguments:
Adapter - pointer to adapter block
PacketFilter - the new packet filter
Return Value:
NDIS_STATUS_SUCCESS
NDIS_STATUS_NOT_SUPPORTED
--*/
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
PAGED_CODE();
DEBUGP(MP_TRACE, "[%p] ---> NICSetPacketFilter\n", Adapter);
// any bits not supported?
if (PacketFilter & ~(NIC_SUPPORTED_FILTERS))
{
DEBUGP(MP_WARNING, "[%p] Unsupported packet filter: 0x%08x\n", Adapter, PacketFilter);
return NDIS_STATUS_NOT_SUPPORTED;
}
// any filtering changes?
if (PacketFilter != Adapter->PacketFilter)
{
//
// Change the filtering modes on hardware
//
// Save the new packet filter value
Adapter->PacketFilter = PacketFilter;
}
DEBUGP(MP_TRACE, "[%p] <--- NICSetPacketFilter Status = 0x%08x\n", Adapter, Status);
return Status;
}
NDIS_STATUS
NICSetMulticastList(
_In_ PMP_ADAPTER Adapter,
_In_ PNDIS_OID_REQUEST NdisSetRequest)
/*++
Routine Description:
This routine will set up the adapter for a specified multicast
address list.
Arguments:
Adapter - Pointer to adapter block
NdisSetRequest - The OID request with the new multicast list
Return Value:
NDIS_STATUS
--*/
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
struct _SET *Set = &NdisSetRequest->DATA.SET_INFORMATION;
#if DBG
ULONG index;
#endif
PAGED_CODE();
DEBUGP(MP_TRACE, "[%p] ---> NICSetMulticastList\n", Adapter);
//
// Initialize.
//
Set->BytesNeeded = NIC_MACADDR_SIZE;
Set->BytesRead = Set->InformationBufferLength;
do
{
if (Set->InformationBufferLength % NIC_MACADDR_SIZE)
{
Status = NDIS_STATUS_INVALID_LENGTH;
break;
}
if (Set->InformationBufferLength > (NIC_MAX_MCAST_LIST * NIC_MACADDR_SIZE))
{
Status = NDIS_STATUS_MULTICAST_FULL;
Set->BytesNeeded = NIC_MAX_MCAST_LIST * NIC_MACADDR_SIZE;
break;
}
//
// Protect the list update with a lock if it can be updated by
// another thread simultaneously.
//
NdisZeroMemory(Adapter->MCList,
NIC_MAX_MCAST_LIST * NIC_MACADDR_SIZE);
NdisMoveMemory(Adapter->MCList,
Set->InformationBuffer,
Set->InformationBufferLength);
Adapter->ulMCListSize = Set->InformationBufferLength / NIC_MACADDR_SIZE;
#if DBG
// display the multicast list
for(index = 0; index < Adapter->ulMCListSize; index++)
{
DEBUGP(MP_LOUD, "[%p] MC(%d) = ", Adapter, index);
DbgPrintAddress(Adapter->MCList[index]);
}
#endif
}
while (FALSE);
//
// Program the hardware to add suport for these muticast addresses
//
DEBUGP(MP_TRACE, "[%p] <--- NICSetMulticastList Status 0x%08x\n", Adapter, Status);
return Status;
}
#if (NDIS_SUPPORT_NDIS620)
#define VERIFY_OID_SET(_Request, _MinRevision, _MinLength)\
_Request->DATA.SET_INFORMATION.BytesNeeded = _MinLength;\
if(_Request->Header.Revision < _MinRevision)\
{ \
Status = NDIS_STATUS_NOT_SUPPORTED;\
break;\
}\
if(_Request->DATA.SET_INFORMATION.InformationBufferLength < _MinLength)\
{\
Status = NDIS_STATUS_INVALID_LENGTH;\
break;\
}\
#define VERIFY_OID_METHOD(_Request, _MinRevision, _MinLength)\
_Request->DATA.METHOD_INFORMATION.BytesNeeded = _MinLength;\
if(_Request->Header.Revision < _MinRevision)\
{ \
Status = NDIS_STATUS_NOT_SUPPORTED;\
break;\
}\
if(_Request->DATA.METHOD_INFORMATION.InputBufferLength < _MinLength)\
{\
Status = NDIS_STATUS_INVALID_LENGTH;\
break;\
}\
NDIS_STATUS
NICAllocateRxQueue(
_In_ PMP_ADAPTER Adapter,
_In_ PNDIS_OID_REQUEST NdisMethodRequest)
/*++
Routine Description:
This routine will allocate a receive queue according to the passed in allocation request. It verifies that the request
is well formed, then passes the request to underlying queue management code.
Arguments:
Adapter - Pointer to adapter block
NdisSetRequest - The OID data for the request
Return Value:
NDIS_STATUS
--*/
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
struct _METHOD *Method = &NdisMethodRequest->DATA.METHOD_INFORMATION;
PNDIS_RECEIVE_QUEUE_PARAMETERS QueueParams = (PNDIS_RECEIVE_QUEUE_PARAMETERS)Method->InformationBuffer;
PAGED_CODE();
DEBUGP(MP_TRACE, "[%p] ---> NICAllocateRxQueue\n", Adapter);
do
{
//
// Verify that the request matches our requirements
//
VERIFY_OID_METHOD(NdisMethodRequest,
NDIS_RECEIVE_QUEUE_PARAMETERS_REVISION_1,
NDIS_SIZEOF_RECEIVE_QUEUE_PARAMETERS_REVISION_1);
//
// Request is well formed, set bytes read
//
Method->BytesRead = NDIS_SIZEOF_RECEIVE_QUEUE_PARAMETERS_REVISION_1;
//
// Should not ask to allocate default queue, or non VMQ type
//
if(QueueParams->QueueId==NDIS_DEFAULT_RECEIVE_QUEUE_ID
||
QueueParams->QueueType != NdisReceiveQueueTypeVMQueue)
{
DEBUGP(MP_ERROR, "[%p] Unsupported QueueId (%i) or QueueType (%i) for allocation.\n", Adapter, QueueParams->QueueId, QueueParams->QueueType);
Status = NDIS_STATUS_INVALID_PARAMETER;
break;
}
//
// Ready to allocate
//
Status = AllocateRxQueue(Adapter, QueueParams);
} while(FALSE);
DEBUGP(MP_TRACE, "[%p] <--- NICAllocateRxQueuee Status 0x%08x\n", Adapter, Status);
return Status;
}
NDIS_STATUS
NICCompleteAllocationRxQueue(
_In_ PMP_ADAPTER Adapter,
_In_ PNDIS_OID_REQUEST NdisMethodRequest)
/*++
Routine Description:
This routine will complete any remaining queue allocation, including shared memory. It verifies that the request
is well formed, then passes the request to underlying queue management code.
Arguments:
Adapter - Pointer to adapter block
NdisSetRequest - The OID data for the request
Return Value:
NDIS_STATUS
--*/
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
struct _METHOD *Method = &NdisMethodRequest->DATA.METHOD_INFORMATION;
PNDIS_RECEIVE_QUEUE_ALLOCATION_COMPLETE_ARRAY CompleteArray = (PNDIS_RECEIVE_QUEUE_ALLOCATION_COMPLETE_ARRAY)Method->InformationBuffer;
PAGED_CODE();
DEBUGP(MP_TRACE, "[%p] ---> NICCompleteAllocationRxQueue\n", Adapter);
do
{
//
// Verify that the request matches our requirements
//
VERIFY_OID_METHOD(NdisMethodRequest,
NDIS_RECEIVE_QUEUE_ALLOCATION_COMPLETE_ARRAY_REVISION_1,
NDIS_SIZEOF_RECEIVE_QUEUE_ALLOCATION_COMPLETE_ARRAY_REVISION_1);
//
// Request is well formed, set bytes read
//
Method->BytesRead = NDIS_SIZEOF_RECEIVE_QUEUE_ALLOCATION_COMPLETE_ARRAY_REVISION_1+
(CompleteArray->NumElements * CompleteArray->ElementSize);
//
// Ready to complete allocation
//
Status = CompleteAllocationRxQueue(Adapter, CompleteArray);
}while(FALSE);
DEBUGP(MP_TRACE, "[%p] <--- NICCompleteAllocationRxQueue Status 0x%08x\n", Adapter, Status);
return Status;
}
NDIS_STATUS
NICFreeRxQueue(
_In_ PMP_ADAPTER Adapter,
_In_ PNDIS_OID_REQUEST NdisSetRequest)
/*++
Routine Description:
This routine will handle the passed in queue free request. It verifies that the request
is well formed, then passes the request to underlying queue management code.
Arguments:
Adapter - Pointer to adapter block
NdisSetRequest - The OID data for the request
Return Value:
NDIS_STATUS
--*/
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
struct _SET *Set = &NdisSetRequest->DATA.SET_INFORMATION;
PNDIS_RECEIVE_QUEUE_FREE_PARAMETERS QueueFreeParams = (PNDIS_RECEIVE_QUEUE_FREE_PARAMETERS)Set->InformationBuffer;
PAGED_CODE();
DEBUGP(MP_TRACE, "[%p] ---> NICFreeRxQueue\n", Adapter);
do
{
//
// Verify that the request matches our requirements
//
VERIFY_OID_SET(NdisSetRequest,
NDIS_RECEIVE_QUEUE_FREE_PARAMETERS_REVISION_1,
NDIS_SIZEOF_RECEIVE_QUEUE_FREE_PARAMETERS_REVISION_1);
//
// Request is well formed, set bytes read
//
Set->BytesRead = NDIS_SIZEOF_RECEIVE_QUEUE_FREE_PARAMETERS_REVISION_1;
//
// Default queue cannot be freed
//
if(QueueFreeParams->QueueId==NDIS_DEFAULT_RECEIVE_QUEUE_ID)
{
DEBUGP(MP_ERROR, "[%p] Received request to free default queue.\n", Adapter);
Status = NDIS_STATUS_INVALID_PARAMETER;
break;
}
//
// Ready to attempt a free.
//
Status = FreeRxQueue(Adapter, QueueFreeParams, NdisSetRequest);
}while(FALSE);
DEBUGP(MP_TRACE, "[%p] <--- NICFreeRxQueuee Status 0x%08x\n", Adapter, Status);
return Status;
}
static
NDIS_STATUS
NICSetRxFilter(
_In_ PMP_ADAPTER Adapter,
_In_ PNDIS_OID_REQUEST NdisMethodRequest)
/*++
Routine Description:
This routine will handle the passed filter set request. It verifies that the request
is well formed, then passes the request to underlying filter management code.
Arguments:
Adapter - Pointer to adapter block
NdisSetRequest - The OID data for the request
Return Value:
NDIS_STATUS
--*/
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
struct _METHOD *Method = &NdisMethodRequest->DATA.METHOD_INFORMATION;
PNDIS_RECEIVE_FILTER_PARAMETERS FilterParams = (PNDIS_RECEIVE_FILTER_PARAMETERS)Method->InformationBuffer;
PAGED_CODE();
do
{
//
// Verify that the request matches our requirements
//
VERIFY_OID_METHOD(NdisMethodRequest,
NDIS_RECEIVE_FILTER_PARAMETERS_REVISION_1,
NDIS_SIZEOF_RECEIVE_FILTER_PARAMETERS_REVISION_1);
//
// Request is well formed, set bytes read
//
Method->BytesRead = NDIS_SIZEOF_RECEIVE_FILTER_PARAMETERS_REVISION_1;
//
// Ready to set Filter
//
Status = SetRxFilter(Adapter, FilterParams);
}while(FALSE);
return Status;
}
static
NDIS_STATUS
NICClearRxFilter(
_In_ PMP_ADAPTER Adapter,
_In_ PNDIS_OID_REQUEST NdisSetRequest)
/*++
Routine Description:
This routine will handle the passed filter clear request. It verifies that the request
is well formed, then passes the request to underlying filter management code.
Arguments:
Adapter - Pointer to adapter block
NdisSetRequest - The OID data for the request
Return Value:
NDIS_STATUS
--*/
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
struct _SET *Set = &NdisSetRequest->DATA.SET_INFORMATION;
PNDIS_RECEIVE_FILTER_CLEAR_PARAMETERS FilterParams = (PNDIS_RECEIVE_FILTER_CLEAR_PARAMETERS)Set->InformationBuffer;
PAGED_CODE();
do
{
//
// Verify that the request matches our requirements
//
VERIFY_OID_SET(NdisSetRequest,
NDIS_RECEIVE_FILTER_CLEAR_PARAMETERS_REVISION_1,
NDIS_SIZEOF_RECEIVE_FILTER_CLEAR_PARAMETERS_REVISION_1);
//
// Request is well formed, set bytes read
//
Set->BytesRead = NDIS_SIZEOF_RECEIVE_FILTER_CLEAR_PARAMETERS_REVISION_1;
//
// Ready to clear the filter
//
Status = ClearRxFilter(Adapter, FilterParams);
}while(FALSE);
return Status;
}
static
NDIS_STATUS
NICUpdateRxQueue(
_In_ PMP_ADAPTER Adapter,
_In_ PNDIS_OID_REQUEST NdisSetRequest)
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
struct _SET *Set = &NdisSetRequest->DATA.SET_INFORMATION;
PNDIS_RECEIVE_QUEUE_PARAMETERS FilterParams = (PNDIS_RECEIVE_QUEUE_PARAMETERS)Set->InformationBuffer;
PAGED_CODE();
do
{
//
// Verify that the request matches our requirements
//
VERIFY_OID_SET(NdisSetRequest,
NDIS_RECEIVE_QUEUE_PARAMETERS_REVISION_1,
NDIS_SIZEOF_RECEIVE_QUEUE_PARAMETERS_REVISION_1);
//
// Request is well formed, set bytes read
//
Set->BytesRead = NDIS_SIZEOF_RECEIVE_FILTER_CLEAR_PARAMETERS_REVISION_1;
//
// Ready to clear the filter
//
Status = UpdateRxQueue(Adapter, FilterParams);
} while(FALSE);
return Status;
}
#endif
#if (NDIS_SUPPORT_NDIS630)
_IRQL_requires_(PASSIVE_LEVEL)
NDIS_STATUS
NICSetQOSParameters(
_In_ PMP_ADAPTER Adapter,
_In_ PNDIS_OID_REQUEST NdisMethodRequest)
/*++
Routine Description:
This routine will build a classification table according to the request. It verifies that
the request is well formed, then passes the request to the underlying classification
management code. On the other hand, hardware-oriented parameters such as PFC and ETS are
validated but not enforceable in a software implementation.
Arguments:
Adapter - Pointer to adapter block
NdisSetRequest - The OID data for the request
Return Value:
NDIS_STATUS
--*/
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
struct _METHOD *Method = &NdisMethodRequest->DATA.METHOD_INFORMATION;
PNDIS_QOS_PARAMETERS Params = (PNDIS_QOS_PARAMETERS)Method->InformationBuffer;
PAGED_CODE();
DEBUGP(MP_TRACE, "[%p] ---> NICSetQOSParameters\n", Adapter);
do
{
//
// Verify that the request matches our requirements.
//
VERIFY_OID_METHOD(NdisMethodRequest,
NDIS_QOS_PARAMETERS_REVISION_1,
NDIS_SIZEOF_QOS_PARAMETERS_REVISION_1);
//
// Request is well formed, set bytes read.
//
Method->BytesRead = NDIS_SIZEOF_QOS_PARAMETERS_REVISION_1 +
Params->NumClassificationElements * Params->ClassificationElementSize;
Status = SetQOSParameters(Adapter, Params);
if (Status != NDIS_STATUS_SUCCESS)
{
break;
}
//
// Set bytes written for in-place write, basically same as bytes read.
//
Method->BytesWritten = Method->BytesRead;
} while(FALSE);
DEBUGP(MP_TRACE, "[%p] <--- NICSetQOSParameters Status 0x%08x\n", Adapter, Status);
return Status;
}
#endif
static
NDIS_STATUS
MPSetPower(
_In_ PMP_ADAPTER Adapter,
_In_ PNDIS_OID_REQUEST NdisSetRequest)
/*++
Routine Description:
This routine handles OID_PNP_SET_POWER request.
Arguments:
Adapter - Pointer to adapter block
NdisSetRequest - The OID data for the request
Return Value:
NDIS_STATUS
--*/
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
struct _SET *Set = &NdisSetRequest->DATA.SET_INFORMATION;
NDIS_DEVICE_POWER_STATE PowerState;
PAGED_CODE();
if (Set->InformationBufferLength < sizeof(NDIS_DEVICE_POWER_STATE))
{
return NDIS_STATUS_INVALID_LENGTH;
}
PowerState = *(PNDIS_DEVICE_POWER_STATE UNALIGNED)Set->InformationBuffer;
Set->BytesRead = sizeof(NDIS_DEVICE_POWER_STATE);
if(PowerState < NdisDeviceStateD0 ||
PowerState > NdisDeviceStateD3)
{
return NDIS_STATUS_INVALID_DATA;
}
if (PowerState == NdisDeviceStateD0)
{
Status = MPSetPowerD0(Adapter);
}
else
{
Status = MPSetPowerLow(Adapter, PowerState);
}
return Status;
}
static
NDIS_STATUS
MPSetPowerD0(
_In_ PMP_ADAPTER Adapter)
/*++
Routine Description:
NIC power has been restored to the working power state (D0).
Prepare the NIC for normal operation:
- Restore hardware context (packet filters, multicast addresses, MAC address, etc.)
- Enable interrupts and the NIC's DMA engine.
Arguments:
Adapter - Pointer to adapter block
Return Value:
NDIS_STATUS
--*/
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
PAGED_CODE();
Adapter->CurrentPowerState = NdisDeviceStateD0;
MP_CLEAR_FLAG(Adapter, fMP_ADAPTER_LOW_POWER);
NICStartTheDatapath(Adapter);
return Status;
}
static
NDIS_STATUS
MPSetPowerLow(
_In_ PMP_ADAPTER Adapter,
_In_ NDIS_DEVICE_POWER_STATE PowerState)
/*++
Routine Description:
The NIC is about to be transitioned to a low power state.
Prepare the NIC for the sleeping state:
- Disable interrupts and the NIC's DMA engine, cancel timers.
- Save any hardware context that the NIC cannot preserve in
a sleeping state (packet filters, multicast addresses,
the current MAC address, etc.)
A miniport driver cannot access the NIC hardware after
the NIC has been set to the D3 state by the bus driver.
Miniport drivers NDIS v6.30 and above
Do NOT wait for NDIS to return the ownership of all
NBLs from outstanding receive indications
Retain ownership of all the receive descriptors and
packet buffers previously owned by the hardware.
Arguments:
Adapter - Pointer to adapter block
PowerState - New power state
Return Value:
NDIS_STATUS
--*/
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
LONG nSendWaitCount = 0;
PAGED_CODE();
MP_SET_FLAG(Adapter, fMP_ADAPTER_LOW_POWER);
Adapter->CurrentPowerState = PowerState;
#if (NDIS_SUPPORT_NDIS630)
//
// Miniport drivers NDIS v6.30 and above are not
// necessarily paused prior the low power transition
//
//
// Prevent future sends and receives on the data path
//
NICStopTheDatapath(Adapter);
//
// Wait for outstanding sends
// Do NOT wait for outstanding receives
//
while(Adapter->nBusySend)
{
if (++nSendWaitCount % 100)
{
DEBUGP(MP_ERROR, "[%p] MPSetPowerLow timed out!\n", Adapter);
ASSERT(FALSE);
}
DEBUGP(MP_INFO, "[%p] MPSetPowerLow - waiting ...\n", Adapter);
NdisMSleep(1000);
}
#else
UNREFERENCED_PARAMETER(nSendWaitCount);
//
// Miniport drivers NDIS v6.20 and below are
// paused prior the low power transition
//
ASSERT(MP_TEST_FLAG(Adapter, fMP_ADAPTER_PAUSED));
ASSERT(!NICIsBusy(Adapter));
#endif
return Status;
}
#if (NDIS_SUPPORT_NDIS680)
static
NDIS_STATUS
MPSetRSSv2Parameters(
_In_ PMP_ADAPTER Adapter,
_In_ PNDIS_OID_REQUEST NdisSetRequest)
/*++
Routine Description:
This routine handles OID_GEN_RECEIVE_SCALE_PARAMETERS_V2 set request.
Arguments:
Adapter - Pointer to adapter block
NdisSetRequest - The OID data for the request
Return Value:
NDIS_STATUS
--*/
{
struct _SET *Set;
Set = &NdisSetRequest->DATA.SET_INFORMATION;
//
// Validate the request
//
if (Set->InformationBufferLength <
NDIS_SIZEOF_RECEIVE_SCALE_PARAMETERS_V2_REVISION_1)
{
DEBUGP(MP_ERROR, "OID_GEN_RECEIVE_SCALE_PARAMETERS_V2: Invalid InformationBufferLength\n");
return NDIS_STATUS_INVALID_LENGTH;
}
return NICSetRSSv2Parameters(Adapter, NdisSetRequest);
}
static
NDIS_STATUS
MPSetRSSv2IndirectionTableEntries(
_In_ PMP_ADAPTER Adapter,
_In_ PNDIS_OID_REQUEST NdisMethodRequest)
/*++
Routine Description:
This routine handles OID_GEN_RSS_SET_INDIRECTION_TABLE_ENTRIES method request.
Arguments:
Adapter - Pointer to adapter block
NdisSetRequest - The OID data for the request
Return Value:
NDIS_STATUS
--*/
{
struct _METHOD *Method;
ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
Method = &NdisMethodRequest->DATA.METHOD_INFORMATION;
//
// Validate the request
//
if (Method->InputBufferLength <
NDIS_SIZEOF_RSS_SET_INDIRECTION_ENTRIES_REVISION_1)
{
DEBUGP(MP_ERROR, "OID_GEN_RSS_SET_INDIRECTION_TABLE_ENTRIES: Invalid InformationBufferLength\n");
return NDIS_STATUS_INVALID_LENGTH;
}
return NICSetRSSv2IndirectionTableEntries(Adapter, NdisMethodRequest);
}
#endif
|