Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1412 lines
45 KiB

  1. /*++
  2. Copyright (c) 1998-1999 Microsoft Corporation
  3. Module Name:
  4. config.c
  5. Abstract:
  6. This file contains all routines necessary for the support of dynamic
  7. configuration.
  8. Author:
  9. Rajesh Sundaram (rajeshsu)
  10. Environment:
  11. Kernel Mode
  12. Revision History:
  13. --*/
  14. #include "psched.h"
  15. #pragma hdrstop
  16. //
  17. // Forward declaration for using #pragma
  18. NDIS_STATUS
  19. PsReadAdapterRegistryDataInit(PADAPTER Adapter,
  20. PNDIS_STRING AdapterKey
  21. );
  22. NDIS_STATUS
  23. PsReadAdapterRegistryData(PADAPTER Adapter,
  24. PNDIS_STRING MachineKey,
  25. PNDIS_STRING AdapterKey);
  26. #pragma alloc_text(PAGE, PsReadAdapterRegistryData)
  27. #pragma alloc_text(PAGE, PsReadAdapterRegistryDataInit)
  28. //
  29. // Local functions used to access the registry.
  30. //
  31. NDIS_STATUS
  32. PsReadRegistryInt(
  33. IN NDIS_HANDLE ConfigHandle,
  34. IN PNDIS_STRING ValueName,
  35. IN ULONG ValueDefault,
  36. IN OUT PULONG ValuePtr,
  37. IN ULONG ValueMin,
  38. IN ULONG ValueMax,
  39. IN BOOLEAN Subkey,
  40. IN PNDIS_STRING SubKeyName,
  41. IN HANDLE SubKeyHandle,
  42. IN BOOLEAN ZAW
  43. )
  44. {
  45. PNDIS_CONFIGURATION_PARAMETER ConfigParam;
  46. NDIS_STATUS Status;
  47. NTSTATUS NtStatus;
  48. ULONG Value;
  49. RTL_QUERY_REGISTRY_TABLE ServiceKeys[] =
  50. {
  51. {NULL,
  52. 0,
  53. NULL,
  54. NULL,
  55. 0,
  56. NULL,
  57. 0},
  58. {NULL,
  59. 0,
  60. NULL,
  61. NULL,
  62. 0,
  63. NULL,
  64. 0},
  65. {NULL,
  66. 0,
  67. NULL,
  68. NULL,
  69. 0,
  70. NULL,
  71. 0}
  72. };
  73. if(Subkey)
  74. {
  75. PsDbgOut(DBG_INFO, DBG_INIT | DBG_ZAW,
  76. ("[PsReadSingleParameter]: Subkey %ws, Key %ws \n",
  77. SubKeyName->Buffer, ValueName->Buffer));
  78. NdisReadConfiguration(&Status,
  79. &ConfigParam,
  80. SubKeyHandle,
  81. ValueName,
  82. NdisParameterInteger);
  83. }
  84. else
  85. {
  86. PsDbgOut(DBG_INFO, DBG_INIT | DBG_ZAW,
  87. ("[PsReadSingleParameter]: Subkey NULL, Key %ws \n", ValueName->Buffer));
  88. NdisReadConfiguration(&Status,
  89. &ConfigParam,
  90. ConfigHandle,
  91. ValueName,
  92. NdisParameterInteger);
  93. }
  94. if(Status == NDIS_STATUS_SUCCESS)
  95. {
  96. *ValuePtr = ConfigParam->ParameterData.IntegerData;
  97. if(*ValuePtr < ValueMin || *ValuePtr > ValueMax)
  98. {
  99. PsDbgOut(DBG_FAILURE, DBG_INIT | DBG_ZAW,
  100. ("[PsReadSingleParameter]: Per adapter: %d does not fall in range (%d - %d) \n",
  101. *ValuePtr, ValueMin, ValueMax));
  102. *ValuePtr = ValueDefault;
  103. }
  104. PsDbgOut(DBG_INFO, DBG_INIT | DBG_ZAW,
  105. ("\t\t Per adapter: 0x%x \n", *ValuePtr));
  106. return Status;
  107. }
  108. else
  109. {
  110. if(ZAW)
  111. {
  112. //
  113. // See if we can read it from the per machine area. We need to use the RtlAPIs for this.
  114. //
  115. if(Subkey)
  116. {
  117. ServiceKeys[0].QueryRoutine = NULL;
  118. ServiceKeys[0].Flags = RTL_QUERY_REGISTRY_SUBKEY;
  119. ServiceKeys[0].Name = SubKeyName->Buffer;
  120. ServiceKeys[0].EntryContext = NULL;
  121. ServiceKeys[0].DefaultType = REG_NONE;
  122. ServiceKeys[0].DefaultData = NULL;
  123. ServiceKeys[0].DefaultLength = 0;
  124. ServiceKeys[1].QueryRoutine = NULL;
  125. ServiceKeys[1].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_REQUIRED;
  126. ServiceKeys[1].Name = ValueName->Buffer;
  127. ServiceKeys[1].EntryContext = &Value;
  128. ServiceKeys[1].DefaultType = REG_NONE;
  129. ServiceKeys[1].DefaultData = NULL;
  130. ServiceKeys[1].DefaultLength = 0;
  131. }
  132. else
  133. {
  134. ServiceKeys[0].QueryRoutine = NULL;
  135. ServiceKeys[0].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_REQUIRED;
  136. ServiceKeys[0].Name = ValueName->Buffer;
  137. ServiceKeys[0].EntryContext = &Value;
  138. ServiceKeys[0].DefaultType = REG_NONE;
  139. ServiceKeys[0].DefaultData = NULL;
  140. ServiceKeys[0].DefaultLength = 0;
  141. }
  142. NtStatus = RtlQueryRegistryValues(
  143. RTL_REGISTRY_ABSOLUTE,
  144. MachineRegistryKey.Buffer,
  145. ServiceKeys,
  146. NULL,
  147. NULL);
  148. if(NT_SUCCESS(NtStatus))
  149. {
  150. *ValuePtr = Value;
  151. if(*ValuePtr < ValueMin || *ValuePtr > ValueMax)
  152. {
  153. PsDbgOut(DBG_FAILURE, DBG_INIT | DBG_ZAW,
  154. ("[PsReadSingleParameter]: ZAW %ws %d does not fall in range (%d - %d) \n",
  155. ValueName->Buffer, *ValuePtr, ValueMin, ValueMax));
  156. *ValuePtr = ValueDefault;
  157. }
  158. PsDbgOut(DBG_INFO, DBG_INIT | DBG_ZAW, ("\t\tZAW 0x%x \n", *ValuePtr));
  159. return NDIS_STATUS_SUCCESS;
  160. }
  161. else
  162. {
  163. *ValuePtr = ValueDefault;
  164. PsDbgOut(DBG_INFO, DBG_INIT | DBG_ZAW,
  165. ("\t\tNot in ZAW/Adapter, Using default %d \n", *ValuePtr));
  166. return NtStatus;
  167. }
  168. }
  169. else
  170. {
  171. *ValuePtr = ValueDefault;
  172. PsDbgOut(DBG_INFO, DBG_INIT | DBG_ZAW,
  173. ("\t\tNot in ZAW/Adapter, Using default %d \n", *ValuePtr));
  174. return Status;
  175. }
  176. }
  177. }
  178. NTSTATUS
  179. PsReadRegistryString(IN NDIS_HANDLE ConfigHandle,
  180. IN PNDIS_STRING Key,
  181. IN PNDIS_STRING Buffer
  182. )
  183. {
  184. NDIS_STATUS Status;
  185. PNDIS_CONFIGURATION_PARAMETER ConfigParam;
  186. NdisReadConfiguration(&Status,
  187. &ConfigParam,
  188. ConfigHandle,
  189. Key,
  190. NdisParameterMultiString);
  191. if(Status == NDIS_STATUS_SUCCESS)
  192. {
  193. Buffer->Length = ConfigParam->ParameterData.StringData.Length;
  194. Buffer->MaximumLength = Buffer->Length + sizeof(WCHAR);
  195. PsAllocatePool(Buffer->Buffer,
  196. Buffer->MaximumLength,
  197. PsMiscTag);
  198. if(Buffer->Buffer)
  199. {
  200. RtlCopyUnicodeString(Buffer, &ConfigParam->ParameterData.StringData);
  201. }
  202. }
  203. return Status;
  204. }
  205. STATIC VOID
  206. ReadProfiles(
  207. NDIS_HANDLE ConfigHandle
  208. )
  209. /*++
  210. Routine Description:
  211. This routine is used by the driver to read the Profiles key from the
  212. registry. The profile is a multiple string list of available profiles.
  213. Each entry on this list identifies another value under Psched\Parameters
  214. which contains the list of modules that comprise the profile.
  215. Arguments:
  216. ConfigHandle - Handle to the registry entry
  217. Return Value:
  218. --*/
  219. {
  220. NDIS_STATUS Status;
  221. PNDIS_CONFIGURATION_PARAMETER pConfigParam;
  222. PNDIS_CONFIGURATION_PARAMETER pProfileParam;
  223. PPS_PROFILE pProfileInfo;
  224. PWSTR r, p;
  225. UINT i, j, cnt;
  226. NDIS_STRING ProfileKey = NDIS_STRING_CONST("Profiles");
  227. NDIS_STRING StringName;
  228. BOOLEAN StubFlag;
  229. NDIS_STRING StubComponent = NDIS_STRING_CONST("SchedulerStub");
  230. NdisReadConfiguration( &Status,
  231. &pConfigParam,
  232. ConfigHandle,
  233. &ProfileKey,
  234. NdisParameterMultiString);
  235. if ( NT_SUCCESS( Status ))
  236. {
  237. //
  238. // pConfigParam now contains a list of profiles.
  239. //
  240. for (p = pConfigParam->ParameterData.StringData.Buffer, i = 0;
  241. *p != L'\0';
  242. i++)
  243. {
  244. //
  245. // Allocate a new PS_PROFILE entry and store it into
  246. // a global list.
  247. //
  248. PsAllocatePool(pProfileInfo, sizeof(PS_PROFILE), ProfileTag);
  249. if(!pProfileInfo)
  250. {
  251. //
  252. // Don't have to worry about freeing the previous profiles as they will get freed
  253. // when we clear the PsProfileList.
  254. //
  255. PsDbgOut(DBG_CRITICAL_ERROR, DBG_INIT,
  256. ("[ReadProfiles]: cannot allocate memory to hold profile \n"));
  257. break;
  258. }
  259. NdisZeroMemory(pProfileInfo, sizeof(PS_PROFILE));
  260. InsertHeadList( &PsProfileList, &pProfileInfo->Links );
  261. // Copy the Profile Name
  262. // 1. Initialize the unicode strings
  263. // 2. Allocate memory for the string
  264. // 3. Copy the string over.
  265. RtlInitUnicodeString(&StringName, p);
  266. RtlInitUnicodeString(&pProfileInfo->ProfileName, p);
  267. PsAllocatePool(pProfileInfo->ProfileName.Buffer,
  268. pProfileInfo->ProfileName.MaximumLength,
  269. ProfileTag);
  270. if(!pProfileInfo->ProfileName.Buffer)
  271. {
  272. //
  273. // Again, cleanup of the other profils will be done when we clean up the ProfileList
  274. //
  275. PsDbgOut(DBG_CRITICAL_ERROR, DBG_INIT,
  276. ("[ReadProfiles]: cannot allocate memory to hold profile's name \n"));
  277. break;
  278. }
  279. NdisZeroMemory(pProfileInfo->ProfileName.Buffer,
  280. pProfileInfo->ProfileName.MaximumLength);
  281. RtlCopyUnicodeString(&pProfileInfo->ProfileName, &StringName);
  282. PsDbgOut(DBG_TRACE,
  283. DBG_INIT,
  284. ("[ReadProfiles]: Adding profile %ws \n",
  285. pProfileInfo->ProfileName.Buffer));
  286. // The last scheduling component of every profile should
  287. // be a stub component. If this component is not present
  288. // in the profile, we have to add it manually.
  289. StubFlag = FALSE;
  290. cnt = 0;
  291. //
  292. // Each of the name identifies another value under
  293. // "Psched\Parameters". This value contains the list of
  294. // components that comprize the profile.
  295. //
  296. NdisReadConfiguration( &Status,
  297. &pProfileParam,
  298. ConfigHandle,
  299. &pProfileInfo->ProfileName,
  300. NdisParameterMultiString);
  301. if(NT_SUCCESS (Status))
  302. {
  303. // Read the components and associate with a
  304. // PSI_INFO.
  305. NDIS_STRING ComponentName;
  306. for (r = pProfileParam->ParameterData.StringData.Buffer, j=0;
  307. *r != L'\0'; j++)
  308. {
  309. PSI_INFO *PsiComponentInfo = 0;
  310. RtlInitUnicodeString(&ComponentName, r);
  311. PsDbgOut(DBG_TRACE, DBG_INIT,
  312. ("[ReadProfiles]: Adding component %ws to "
  313. "Profile %ws \n",
  314. ComponentName.Buffer,
  315. pProfileInfo->ProfileName.Buffer));
  316. if(!StubFlag && (RtlCompareUnicodeString(&ComponentName,
  317. &StubComponent,
  318. FALSE)== 0))
  319. StubFlag = TRUE;
  320. if(cnt == MAX_COMPONENT_PER_PROFILE)
  321. {
  322. PsDbgOut(DBG_CRITICAL_ERROR,
  323. DBG_INIT,
  324. ("[ReadProfiles]: Profile %ws cannot have "
  325. "more than %d components \n",
  326. pProfileInfo->ProfileName.Buffer,
  327. MAX_COMPONENT_PER_PROFILE));
  328. }
  329. else
  330. {
  331. if(FindSchedulingComponent(&ComponentName, &PsiComponentInfo) ==
  332. NDIS_STATUS_FAILURE)
  333. {
  334. //
  335. // The component does not exist. Therefore, we
  336. // store the unregistered component in the list
  337. //
  338. PsDbgOut(DBG_TRACE, DBG_INIT,
  339. ("[ReadProfiles]: Adding add-in component"
  340. " %ws to list\n", ComponentName.Buffer));
  341. PsAllocatePool(PsiComponentInfo,
  342. sizeof(PSI_INFO),
  343. ComponentTag);
  344. if(!PsiComponentInfo)
  345. {
  346. PsDbgOut(DBG_CRITICAL_ERROR, DBG_INIT,
  347. ("[ReadProfiles]: No memory to store add-in components \n"));
  348. break;
  349. }
  350. pProfileInfo->UnregisteredAddInCnt ++;
  351. NdisZeroMemory(PsiComponentInfo, sizeof(PSI_INFO));
  352. RtlInitUnicodeString(&PsiComponentInfo->ComponentName, r);
  353. PsAllocatePool(
  354. PsiComponentInfo->ComponentName.Buffer,
  355. ComponentName.MaximumLength,
  356. ComponentTag);
  357. if(!PsiComponentInfo->ComponentName.Buffer)
  358. {
  359. PsDbgOut(DBG_CRITICAL_ERROR, DBG_INIT,
  360. ("[ReadProfiles]: No memory to store add-in components \n"));
  361. PsFreePool(PsiComponentInfo);
  362. break;
  363. }
  364. RtlCopyUnicodeString(&PsiComponentInfo->ComponentName,
  365. &ComponentName);
  366. PsiComponentInfo->Registered = FALSE;
  367. PsiComponentInfo->AddIn = TRUE;
  368. InsertHeadList(&PsComponentList, &PsiComponentInfo->Links );
  369. }
  370. // Add the component to the profile.
  371. pProfileInfo->ComponentList[cnt++]=PsiComponentInfo;
  372. pProfileInfo->ComponentCnt = cnt;
  373. }
  374. r = (PWSTR)((PUCHAR)r + ComponentName.Length +
  375. sizeof(WCHAR));
  376. }
  377. }
  378. if(!StubFlag)
  379. {
  380. PsDbgOut(DBG_INFO, DBG_INIT,
  381. ("[ReadProfiles]: Profile %ws should end in a stub "
  382. "component. Adding a stub component \n",
  383. pProfileInfo->ProfileName.Buffer));
  384. // Needn't worry about overflow, as we have allocated an
  385. // extra one for the stub component.
  386. pProfileInfo->ComponentList[cnt++] = &SchedulerStubInfo;
  387. pProfileInfo->ComponentCnt = cnt;
  388. }
  389. p = (PWSTR)((PUCHAR)p + pProfileInfo->ProfileName.Length
  390. + sizeof(WCHAR));
  391. }
  392. }
  393. }
  394. NDIS_STATUS
  395. PsReadDriverRegistryDataInit (
  396. )
  397. /*++
  398. Routine Description:
  399. This routine is called by the driver to get information from the configuration
  400. management routines. We read the registry, starting at RegistryPath,
  401. to get the parameters. If they don't exist, we use the defaults in this module.
  402. Arguments:
  403. RegistryPath - The name of the driver's node in the registry.
  404. ConfigurationInfo - A pointer to the configuration information structure.
  405. Return Value:
  406. Status - STATUS_SUCCESS if everything OK, STATUS_INSUFFICIENT_RESOURCES
  407. otherwise.
  408. --*/
  409. {
  410. NDIS_HANDLE ConfigHandle;
  411. NDIS_STATUS Status;
  412. NDIS_STRING PSParamsKey = NDIS_STRING_CONST("PSched\\Parameters");
  413. #if DBG
  414. ULONG Size;
  415. NTSTATUS NtStatus;
  416. NDIS_STRING DebugLevelKey = NDIS_STRING_CONST("DebugLevel");
  417. NDIS_STRING DebugMaskKey = NDIS_STRING_CONST("DebugMask");
  418. NDIS_STRING TraceLogLevelKey = NDIS_STRING_CONST("TraceLogLevel");
  419. NDIS_STRING TraceLogMaskKey = NDIS_STRING_CONST("TraceLogMask");
  420. NDIS_STRING TraceBufferSizeKey = NDIS_STRING_CONST("TraceBufferSize");
  421. #endif
  422. NdisOpenProtocolConfiguration(&Status, &ConfigHandle, &PSParamsKey);
  423. if(!NT_SUCCESS(Status))
  424. {
  425. PsDbgOut(DBG_CRITICAL_ERROR, DBG_INIT,
  426. ("[PsReadDriverRegistryDataInit]: cannot read registry \n"));
  427. return Status;
  428. }
  429. #if DBG
  430. PsReadRegistryInt(
  431. ConfigHandle,
  432. &DebugLevelKey,
  433. 0,
  434. &DbgTraceLevel,
  435. 0,
  436. 0xffffffff,
  437. FALSE,
  438. NULL,
  439. NULL,
  440. FALSE);
  441. PsReadRegistryInt(
  442. ConfigHandle,
  443. &DebugMaskKey,
  444. 0,
  445. &DbgTraceMask,
  446. 0,
  447. 0xffffffff,
  448. FALSE,
  449. NULL,
  450. NULL,
  451. FALSE);
  452. PsReadRegistryInt(
  453. ConfigHandle,
  454. &TraceLogLevelKey,
  455. DBG_VERBOSE,
  456. &LogTraceLevel,
  457. 0,
  458. 0xffffffff,
  459. FALSE,
  460. NULL,
  461. NULL,
  462. FALSE);
  463. PsReadRegistryInt(
  464. ConfigHandle,
  465. &TraceLogMaskKey,
  466. (DBG_INIT | DBG_IO | DBG_GPC_QOS | DBG_MINIPORT | DBG_PROTOCOL |
  467. DBG_VC | DBG_WMI | DBG_STATE | DBG_WAN),
  468. &LogTraceMask,
  469. 0,
  470. 0xffffffff,
  471. FALSE,
  472. NULL,
  473. NULL,
  474. FALSE);
  475. PsReadRegistryInt(
  476. ConfigHandle,
  477. &TraceBufferSizeKey,
  478. TRACE_BUFFER_SIZE,
  479. &Size,
  480. 0,
  481. 0xffffffff,
  482. FALSE,
  483. NULL,
  484. NULL,
  485. FALSE);
  486. SchedInitialize(Size);
  487. #endif
  488. ReadProfiles(ConfigHandle);
  489. NdisCloseConfiguration( ConfigHandle );
  490. return STATUS_SUCCESS;
  491. }
  492. NDIS_STATUS
  493. PsReadDriverRegistryData(
  494. )
  495. {
  496. ULONG TimerResolution;
  497. ULONG desiredResolution;
  498. NDIS_STRING PSParamsKey = NDIS_STRING_CONST("PSched\\Parameters");
  499. NDIS_STRING TimerResolutionKey = NDIS_STRING_CONST("TimerResolution");
  500. NTSTATUS NtStatus;
  501. NDIS_HANDLE ConfigHandle;
  502. NDIS_STATUS Status;
  503. NdisOpenProtocolConfiguration(&Status, &ConfigHandle, &PSParamsKey);
  504. if(!NT_SUCCESS(Status))
  505. {
  506. PsDbgOut(DBG_CRITICAL_ERROR, DBG_INIT,
  507. ("[PsReadDriverRegistryData]: cannot read registry \n"));
  508. return Status;
  509. }
  510. NtStatus = PsReadRegistryInt(
  511. ConfigHandle,
  512. &TimerResolutionKey,
  513. TIMER_GRANULARITY,
  514. &TimerResolution,
  515. 0,
  516. 0xffffffff,
  517. FALSE,
  518. NULL,
  519. NULL,
  520. TRUE);
  521. NdisCloseConfiguration(ConfigHandle);
  522. if(NT_SUCCESS(NtStatus))
  523. {
  524. //
  525. // convert from usecs to 100 nsecs
  526. //
  527. TimerResolution *= 10;
  528. if(gTimerSet)
  529. {
  530. //
  531. // We might have to cancel the old timer.
  532. //
  533. if(gTimerResolutionActualTime < TimerResolution)
  534. {
  535. //
  536. // We are moving from a low timer to a high timer. We should always set the high
  537. // timer before resetting the low one.
  538. //
  539. gTimerResolutionActualTime = ExSetTimerResolution(TimerResolution, TRUE);
  540. ExSetTimerResolution(0, FALSE);
  541. }
  542. else
  543. {
  544. //
  545. // Moving from a high timer to a low timer. Let's cancel the high timer first
  546. //
  547. ExSetTimerResolution(0, FALSE);
  548. gTimerResolutionActualTime = ExSetTimerResolution(TimerResolution, TRUE);
  549. }
  550. }
  551. else
  552. {
  553. // The Timer has never been set before.
  554. gTimerResolutionActualTime = ExSetTimerResolution(TimerResolution, TRUE);
  555. gTimerSet = 1;
  556. }
  557. }
  558. else
  559. {
  560. // No value was specified in the registry. Let's just keep it at the system's default.
  561. // But, we need to query this value so that we can respond correctly to OID_QOS_TIMER_RESOLUTION
  562. //
  563. if(gTimerSet)
  564. {
  565. //
  566. // Timer was set initially, but now it has been blown away. So, let's get back to the
  567. // system default.
  568. //
  569. gTimerSet = 0;
  570. gTimerResolutionActualTime = ExSetTimerResolution(0, FALSE);
  571. }
  572. else
  573. {
  574. //
  575. // Timer has never been set. Let's remember the system defaults.
  576. //
  577. gTimerResolutionActualTime = KeQueryTimeIncrement();
  578. }
  579. }
  580. return STATUS_SUCCESS;
  581. }
  582. NDIS_STATUS
  583. PsReadAdapterRegistryDataInit(PADAPTER Adapter,
  584. PNDIS_STRING AdapterKey
  585. )
  586. {
  587. ULONG DisableDRR, IntermediateSystem;
  588. NTSTATUS NtStatus;
  589. NDIS_HANDLE ConfigHandle, ServiceKeyHandle;
  590. NDIS_STRING DisableDRRKey = NDIS_STRING_CONST("DisableDRR");
  591. NDIS_STRING IntermediateSystemKey = NDIS_STRING_CONST("IntermediateSystem");
  592. NDIS_STRING BestEffortLimitKey = NDIS_STRING_CONST("BestEffortLimit");
  593. NDIS_STRING ISSLOWTokenRateKey = NDIS_STRING_CONST("ISSLOWTokenRate");
  594. NDIS_STRING ISSLOWPacketSizeKey = NDIS_STRING_CONST("ISSLOWPacketSize");
  595. NDIS_STRING ISSLOWLinkSpeedKey = NDIS_STRING_CONST("ISSLOWLinkSpeed");
  596. NDIS_STRING ISSLOWFragmentSizeKey = NDIS_STRING_CONST("ISSLOWFragmentSize");
  597. NDIS_STRING BestEffortKey = NDIS_STRING_CONST("ServiceTypeBestEffort");
  598. NDIS_STRING NonConformingKey = NDIS_STRING_CONST("ServiceTypeNonConforming");
  599. NDIS_STRING ControlledLoadKey = NDIS_STRING_CONST("ServiceTypeControlledLoad");
  600. NDIS_STRING GuaranteedKey = NDIS_STRING_CONST("ServiceTypeGuaranteed");
  601. NDIS_STRING QualitativeKey = NDIS_STRING_CONST("ServiceTypeQualitative");
  602. NDIS_STRING NetworkControlKey = NDIS_STRING_CONST("ServiceTypeNetworkControl");
  603. NDIS_STRING ShapeDiscardModeKey = NDIS_STRING_CONST("ShapeDiscardMode");
  604. NDIS_STRING UpperBindingsKey = NDIS_STRING_CONST("UpperBindings");
  605. NDIS_STRING ProfileKey = NDIS_STRING_CONST("Profile");
  606. NDIS_STATUS Status;
  607. PAGED_CODE();
  608. NdisOpenProtocolConfiguration(&Status, &ConfigHandle, AdapterKey);
  609. if(Status != NDIS_STATUS_SUCCESS)
  610. {
  611. PsDbgOut(DBG_FAILURE, DBG_INIT ,
  612. ("[PsReadAdapterRegistryDataInit]: Adapter %08X, Could not open config handle \n",
  613. Adapter));
  614. return Status;
  615. }
  616. PsReadRegistryString(
  617. ConfigHandle,
  618. &UpperBindingsKey,
  619. &Adapter->UpperBinding);
  620. if(!Adapter->UpperBinding.Buffer)
  621. {
  622. PsAdapterWriteEventLog(
  623. (ULONG)EVENT_PS_MISSING_ADAPTER_REGISTRY_DATA,
  624. 0,
  625. &Adapter->MpDeviceName,
  626. 0,
  627. NULL);
  628. PsDbgOut(DBG_FAILURE, DBG_PROTOCOL | DBG_INIT,
  629. ("[PsReadAdapterRegistryDataInit]: Adapter %08X: Missing UpperBindings key ", Adapter));
  630. NdisCloseConfiguration(ConfigHandle);
  631. return NDIS_STATUS_FAILURE;
  632. }
  633. PsReadRegistryString(
  634. ConfigHandle,
  635. &ProfileKey,
  636. &Adapter->ProfileName);
  637. PsReadRegistryInt(
  638. ConfigHandle,
  639. &DisableDRRKey,
  640. 0,
  641. &DisableDRR,
  642. 0,
  643. 0xffffffff,
  644. FALSE,
  645. NULL,
  646. NULL,
  647. FALSE);
  648. PsReadRegistryInt(
  649. ConfigHandle,
  650. &IntermediateSystemKey,
  651. 0,
  652. &IntermediateSystem,
  653. 0,
  654. 0xffffffff,
  655. FALSE,
  656. NULL,
  657. NULL,
  658. FALSE);
  659. PsReadRegistryInt(
  660. ConfigHandle,
  661. &BestEffortLimitKey,
  662. UNSPECIFIED_RATE,
  663. &Adapter->BestEffortLimit,
  664. 0,
  665. 0xffffffff,
  666. FALSE,
  667. NULL,
  668. NULL,
  669. FALSE);
  670. //
  671. // Read the ISSLOW related parameters.
  672. //
  673. PsReadRegistryInt(
  674. ConfigHandle,
  675. &ISSLOWFragmentSizeKey,
  676. DEFAULT_ISSLOW_FRAGMENT_SIZE,
  677. &Adapter->ISSLOWFragmentSize,
  678. 0,
  679. 0xffffffff,
  680. FALSE,
  681. NULL,
  682. NULL,
  683. FALSE);
  684. PsReadRegistryInt(
  685. ConfigHandle,
  686. &ISSLOWTokenRateKey,
  687. DEFAULT_ISSLOW_TOKENRATE,
  688. &Adapter->ISSLOWTokenRate,
  689. 0,
  690. 0xffffffff,
  691. FALSE,
  692. NULL,
  693. NULL,
  694. FALSE);
  695. PsReadRegistryInt(
  696. ConfigHandle,
  697. &ISSLOWPacketSizeKey,
  698. DEFAULT_ISSLOW_PACKETSIZE,
  699. &Adapter->ISSLOWPacketSize,
  700. 0,
  701. 0xffffffff,
  702. FALSE,
  703. NULL,
  704. NULL,
  705. FALSE);
  706. PsReadRegistryInt(
  707. ConfigHandle,
  708. &ISSLOWLinkSpeedKey,
  709. DEFAULT_ISSLOW_LINKSPEED,
  710. &Adapter->ISSLOWLinkSpeed,
  711. 0,
  712. 0xffffffff,
  713. FALSE,
  714. NULL,
  715. NULL,
  716. FALSE);
  717. //
  718. // Read the ShapeDiscardMode for the service types.
  719. //
  720. NdisOpenConfigurationKeyByName(&Status,
  721. ConfigHandle,
  722. &ShapeDiscardModeKey,
  723. &ServiceKeyHandle);
  724. if(!NT_SUCCESS(Status))
  725. {
  726. PsDbgOut(DBG_FAILURE, DBG_PROTOCOL | DBG_INIT,
  727. ("[PsReadAdapterRegistryDataInit]: Adapter %08X, Using defaults for ShapeDiscardMode"
  728. "since key cannot be opened \n", Adapter));
  729. Adapter->SDModeGuaranteed = TC_NONCONF_SHAPE;
  730. Adapter->SDModeControlledLoad = TC_NONCONF_BORROW;
  731. Adapter->SDModeQualitative = TC_NONCONF_BORROW;
  732. Adapter->SDModeNetworkControl = TC_NONCONF_BORROW;
  733. }
  734. else
  735. {
  736. PsReadRegistryInt(
  737. ConfigHandle,
  738. &GuaranteedKey,
  739. TC_NONCONF_SHAPE,
  740. &Adapter->SDModeGuaranteed,
  741. TC_NONCONF_BORROW,
  742. TC_NONCONF_BORROW_PLUS,
  743. TRUE,
  744. &ShapeDiscardModeKey,
  745. ServiceKeyHandle,
  746. FALSE);
  747. PsReadRegistryInt(
  748. ConfigHandle,
  749. &ControlledLoadKey,
  750. TC_NONCONF_BORROW,
  751. &Adapter->SDModeControlledLoad,
  752. TC_NONCONF_BORROW,
  753. TC_NONCONF_BORROW_PLUS,
  754. TRUE,
  755. &ShapeDiscardModeKey,
  756. ServiceKeyHandle,
  757. FALSE);
  758. PsReadRegistryInt(
  759. ConfigHandle,
  760. &QualitativeKey,
  761. TC_NONCONF_BORROW,
  762. &Adapter->SDModeQualitative,
  763. TC_NONCONF_BORROW,
  764. TC_NONCONF_BORROW_PLUS,
  765. TRUE,
  766. &ShapeDiscardModeKey,
  767. ServiceKeyHandle,
  768. FALSE);
  769. PsReadRegistryInt(
  770. ConfigHandle,
  771. &NetworkControlKey,
  772. TC_NONCONF_BORROW,
  773. &Adapter->SDModeNetworkControl,
  774. TC_NONCONF_BORROW,
  775. TC_NONCONF_BORROW_PLUS,
  776. TRUE,
  777. &ShapeDiscardModeKey,
  778. ServiceKeyHandle,
  779. FALSE);
  780. NdisCloseConfiguration(ServiceKeyHandle);
  781. }
  782. NdisCloseConfiguration(ConfigHandle);
  783. if(DisableDRR)
  784. {
  785. Adapter->PipeFlags |= PS_DISABLE_DRR;
  786. }
  787. if(IntermediateSystem)
  788. {
  789. Adapter->PipeFlags |= PS_INTERMEDIATE_SYS;
  790. }
  791. return NDIS_STATUS_SUCCESS;
  792. }
  793. NDIS_STATUS
  794. PsReadAdapterRegistryData(PADAPTER Adapter,
  795. PNDIS_STRING MachineKey,
  796. PNDIS_STRING AdapterKey)
  797. /*++
  798. Routine Description:
  799. Obtain the PSched specific info associated with the underlying MP.
  800. Arguments:
  801. AdapterKey - location of the per adapter key in the registry
  802. MachineKey - location of the per Machine key in the registry
  803. Adapter - pointer to the adapter structure
  804. Return Value:
  805. NDIS_STATUS_SUCCESS if everything worked ok
  806. --*/
  807. {
  808. NDIS_STRING BestEffortKey = NDIS_STRING_CONST("ServiceTypeBestEffort");
  809. NDIS_STRING NonConformingKey = NDIS_STRING_CONST("ServiceTypeNonConforming");
  810. NDIS_STRING ControlledLoadKey = NDIS_STRING_CONST("ServiceTypeControlledLoad");
  811. NDIS_STRING GuaranteedKey = NDIS_STRING_CONST("ServiceTypeGuaranteed");
  812. NDIS_STRING QualitativeKey = NDIS_STRING_CONST("ServiceTypeQualitative");
  813. NDIS_STRING NetworkControlKey = NDIS_STRING_CONST("ServiceTypeNetworkControl");
  814. NDIS_STRING TcpTrafficKey = NDIS_STRING_CONST("ServiceTypeTcpTraffic");
  815. NDIS_STRING MaxOutstandingSendsKey = NDIS_STRING_CONST("MaxOutstandingSends");
  816. NDIS_STRING NonBestEffortLimitKey = NDIS_STRING_CONST("NonBestEffortLimit");
  817. NDIS_STRING DiffservKeyC = NDIS_STRING_CONST("DiffservByteMappingConforming");
  818. NDIS_STRING DiffservKeyNC = NDIS_STRING_CONST("DiffservByteMappingNonConforming");
  819. NDIS_STRING UserKey = NDIS_STRING_CONST("UserPriorityMapping");
  820. NDIS_STATUS Status;
  821. NDIS_HANDLE SubKeyHandle, ConfigHandle;
  822. ULONG Value;
  823. PAGED_CODE();
  824. PsDbgOut(DBG_INFO, DBG_INIT | DBG_ZAW,
  825. ("\n [PsReadAdapterRegistryData]: Adapter %08X (%ws): Reading Registry Data \n",
  826. Adapter, Adapter->RegistryPath.Buffer));
  827. NdisOpenProtocolConfiguration(&Status, &ConfigHandle, &Adapter->RegistryPath);
  828. if(Status != NDIS_STATUS_SUCCESS)
  829. {
  830. PsDbgOut(DBG_FAILURE, DBG_INIT | DBG_ZAW,
  831. ("[PsReadAdapterRegistryData]: Adapter %08X, Could not open config handle \n",
  832. Adapter));
  833. return Status;
  834. }
  835. PsReadRegistryInt(ConfigHandle,
  836. &MaxOutstandingSendsKey,
  837. DEFAULT_MAX_OUTSTANDING_SENDS,
  838. &Adapter->MaxOutstandingSends,
  839. 1,
  840. 0xffffffff,
  841. FALSE,
  842. NULL,
  843. NULL,
  844. TRUE);
  845. PsReadRegistryInt(ConfigHandle,
  846. &NonBestEffortLimitKey,
  847. RESERVABLE_FRACTION,
  848. &Adapter->ReservationLimitValue,
  849. 0,
  850. 200,
  851. FALSE,
  852. NULL,
  853. NULL,
  854. TRUE);
  855. //
  856. // Read the conforming values of DiffservByteMapping.
  857. //
  858. NdisOpenConfigurationKeyByName(&Status,
  859. ConfigHandle,
  860. &DiffservKeyC,
  861. &SubKeyHandle);
  862. if(!NT_SUCCESS(Status))
  863. {
  864. PsDbgOut(DBG_FAILURE, DBG_PROTOCOL | DBG_INIT,
  865. ("[PsReadAdapterRegistryData]: Adapter %08X, Using defaults for "
  866. "DiffservByteMappingConforming since key cannot be opened \n", Adapter));
  867. Adapter->IPServiceTypeBestEffort = PS_IP_SERVICETYPE_CONFORMING_BESTEFFORT_DEFAULT;
  868. Adapter->IPServiceTypeControlledLoad = PS_IP_SERVICETYPE_CONFORMING_CONTROLLEDLOAD_DEFAULT;
  869. Adapter->IPServiceTypeGuaranteed = PS_IP_SERVICETYPE_CONFORMING_GUARANTEED_DEFAULT;
  870. Adapter->IPServiceTypeQualitative = PS_IP_SERVICETYPE_CONFORMING_QUALITATIVE_DEFAULT;
  871. Adapter->IPServiceTypeNetworkControl = PS_IP_SERVICETYPE_CONFORMING_NETWORK_CONTROL_DEFAULT;
  872. Adapter->IPServiceTypeTcpTraffic = PS_IP_SERVICETYPE_CONFORMING_TCPTRAFFIC_DEFAULT;
  873. }
  874. else
  875. {
  876. PsReadRegistryInt(ConfigHandle,
  877. &TcpTrafficKey,
  878. PS_IP_SERVICETYPE_CONFORMING_TCPTRAFFIC_DEFAULT,
  879. &Value,
  880. 0,
  881. PREC_MAX_VALUE,
  882. TRUE,
  883. &DiffservKeyC,
  884. SubKeyHandle,
  885. TRUE);
  886. Adapter->IPServiceTypeTcpTraffic = (UCHAR)Value;
  887. PsReadRegistryInt(ConfigHandle,
  888. &BestEffortKey,
  889. PS_IP_SERVICETYPE_CONFORMING_BESTEFFORT_DEFAULT,
  890. &Value,
  891. 0,
  892. PREC_MAX_VALUE,
  893. TRUE,
  894. &DiffservKeyC,
  895. SubKeyHandle,
  896. TRUE);
  897. Adapter->IPServiceTypeBestEffort = (UCHAR)Value;
  898. PsReadRegistryInt(ConfigHandle,
  899. &ControlledLoadKey,
  900. PS_IP_SERVICETYPE_CONFORMING_CONTROLLEDLOAD_DEFAULT,
  901. &Value,
  902. 0,
  903. PREC_MAX_VALUE,
  904. TRUE,
  905. &DiffservKeyC,
  906. SubKeyHandle,
  907. TRUE);
  908. Adapter->IPServiceTypeControlledLoad = (UCHAR)Value;
  909. PsReadRegistryInt(ConfigHandle,
  910. &GuaranteedKey,
  911. PS_IP_SERVICETYPE_CONFORMING_GUARANTEED_DEFAULT,
  912. &Value,
  913. 0,
  914. PREC_MAX_VALUE,
  915. TRUE,
  916. &DiffservKeyC,
  917. SubKeyHandle,
  918. TRUE);
  919. Adapter->IPServiceTypeGuaranteed = (UCHAR)Value;
  920. PsReadRegistryInt(ConfigHandle,
  921. &QualitativeKey,
  922. PS_IP_SERVICETYPE_CONFORMING_QUALITATIVE_DEFAULT,
  923. &Value,
  924. 0,
  925. PREC_MAX_VALUE,
  926. TRUE,
  927. &DiffservKeyC,
  928. SubKeyHandle,
  929. TRUE);
  930. Adapter->IPServiceTypeQualitative = (UCHAR)Value;
  931. PsReadRegistryInt(ConfigHandle,
  932. &NetworkControlKey,
  933. PS_IP_SERVICETYPE_CONFORMING_NETWORK_CONTROL_DEFAULT,
  934. &Value,
  935. 0,
  936. PREC_MAX_VALUE,
  937. TRUE,
  938. &DiffservKeyC,
  939. SubKeyHandle,
  940. TRUE);
  941. Adapter->IPServiceTypeNetworkControl = (UCHAR)Value;
  942. NdisCloseConfiguration(SubKeyHandle);
  943. }
  944. //
  945. // Read the non-conforming values of DiffservByteMapping.
  946. //
  947. NdisOpenConfigurationKeyByName(&Status,
  948. ConfigHandle,
  949. &DiffservKeyNC,
  950. &SubKeyHandle);
  951. if(!NT_SUCCESS(Status))
  952. {
  953. PsDbgOut(DBG_FAILURE, DBG_PROTOCOL | DBG_INIT,
  954. ("[PsReadAdapterRegistryData]: Adapter %08X, Using defaults for "
  955. "DiffservByteMappingNonConforming since key cannot be opened \n", Adapter));
  956. Adapter->IPServiceTypeBestEffortNC = PS_IP_SERVICETYPE_NONCONFORMING_BESTEFFORT_DEFAULT;
  957. Adapter->IPServiceTypeControlledLoadNC = PS_IP_SERVICETYPE_NONCONFORMING_CONTROLLEDLOAD_DEFAULT;
  958. Adapter->IPServiceTypeGuaranteedNC = PS_IP_SERVICETYPE_NONCONFORMING_GUARANTEED_DEFAULT;
  959. Adapter->IPServiceTypeQualitativeNC = PS_IP_SERVICETYPE_NONCONFORMING_QUALITATIVE_DEFAULT;
  960. Adapter->IPServiceTypeNetworkControlNC = PS_IP_SERVICETYPE_NONCONFORMING_BESTEFFORT_DEFAULT;
  961. Adapter->IPServiceTypeTcpTrafficNC = PS_IP_SERVICETYPE_NONCONFORMING_TCPTRAFFIC_DEFAULT;
  962. }
  963. else
  964. {
  965. PsReadRegistryInt(ConfigHandle,
  966. &TcpTrafficKey,
  967. PS_IP_SERVICETYPE_NONCONFORMING_TCPTRAFFIC_DEFAULT,
  968. &Value,
  969. 0,
  970. PREC_MAX_VALUE,
  971. TRUE,
  972. &DiffservKeyNC,
  973. SubKeyHandle,
  974. TRUE);
  975. Adapter->IPServiceTypeTcpTrafficNC = (UCHAR)Value;
  976. PsReadRegistryInt(ConfigHandle,
  977. &BestEffortKey,
  978. PS_IP_SERVICETYPE_NONCONFORMING_BESTEFFORT_DEFAULT,
  979. &Value,
  980. 0,
  981. PREC_MAX_VALUE,
  982. TRUE,
  983. &DiffservKeyNC,
  984. SubKeyHandle,
  985. TRUE);
  986. Adapter->IPServiceTypeBestEffortNC = (UCHAR)Value;
  987. PsReadRegistryInt(ConfigHandle,
  988. &ControlledLoadKey,
  989. PS_IP_SERVICETYPE_NONCONFORMING_CONTROLLEDLOAD_DEFAULT,
  990. &Value,
  991. 0,
  992. PREC_MAX_VALUE,
  993. TRUE,
  994. &DiffservKeyNC,
  995. SubKeyHandle,
  996. TRUE);
  997. Adapter->IPServiceTypeControlledLoadNC = (UCHAR)Value;
  998. PsReadRegistryInt(ConfigHandle,
  999. &GuaranteedKey,
  1000. PS_IP_SERVICETYPE_NONCONFORMING_GUARANTEED_DEFAULT,
  1001. &Value,
  1002. 0,
  1003. PREC_MAX_VALUE,
  1004. TRUE,
  1005. &DiffservKeyNC,
  1006. SubKeyHandle,
  1007. TRUE);
  1008. Adapter->IPServiceTypeGuaranteedNC = (UCHAR)Value;
  1009. PsReadRegistryInt(ConfigHandle,
  1010. &QualitativeKey,
  1011. PS_IP_SERVICETYPE_NONCONFORMING_QUALITATIVE_DEFAULT,
  1012. &Value,
  1013. 0,
  1014. PREC_MAX_VALUE,
  1015. TRUE,
  1016. &DiffservKeyNC,
  1017. SubKeyHandle,
  1018. TRUE);
  1019. Adapter->IPServiceTypeQualitativeNC = (UCHAR)Value;
  1020. PsReadRegistryInt(ConfigHandle,
  1021. &NetworkControlKey,
  1022. PS_IP_SERVICETYPE_NONCONFORMING_NETWORK_CONTROL_DEFAULT,
  1023. &Value,
  1024. 0,
  1025. PREC_MAX_VALUE,
  1026. TRUE,
  1027. &DiffservKeyNC,
  1028. SubKeyHandle,
  1029. TRUE);
  1030. Adapter->IPServiceTypeNetworkControlNC = (UCHAR)Value;
  1031. NdisCloseConfiguration(SubKeyHandle);
  1032. }
  1033. //
  1034. // Read the 802.1p values. The nonconforming in 802.1p does not depend on the
  1035. // service type.
  1036. //
  1037. NdisOpenConfigurationKeyByName(&Status,
  1038. ConfigHandle,
  1039. &UserKey,
  1040. &SubKeyHandle);
  1041. if(!NT_SUCCESS(Status))
  1042. {
  1043. PsDbgOut(DBG_FAILURE, DBG_PROTOCOL | DBG_INIT,
  1044. ("[PsReadAdapterRegistryData]: Adapter %08X, Using defaults for "
  1045. "UserPriorityMapping since key cannot be opened \n", Adapter));
  1046. Adapter->UserServiceTypeBestEffort = PS_USER_SERVICETYPE_BESTEFFORT_DEFAULT;
  1047. Adapter->UserServiceTypeControlledLoad = PS_USER_SERVICETYPE_CONTROLLEDLOAD_DEFAULT;
  1048. Adapter->UserServiceTypeGuaranteed = PS_USER_SERVICETYPE_GUARANTEED_DEFAULT;
  1049. Adapter->UserServiceTypeQualitative = PS_USER_SERVICETYPE_QUALITATIVE_DEFAULT;
  1050. Adapter->UserServiceTypeNetworkControl = PS_USER_SERVICETYPE_NETWORK_CONTROL_DEFAULT;
  1051. Adapter->UserServiceTypeNonConforming = PS_USER_SERVICETYPE_NONCONFORMING_DEFAULT;
  1052. Adapter->UserServiceTypeTcpTraffic = PS_USER_SERVICETYPE_TCPTRAFFIC_DEFAULT;
  1053. }
  1054. else
  1055. {
  1056. PsReadRegistryInt(ConfigHandle,
  1057. &TcpTrafficKey,
  1058. PS_USER_SERVICETYPE_TCPTRAFFIC_DEFAULT,
  1059. &Value,
  1060. 0,
  1061. USER_PRIORITY_MAX_VALUE,
  1062. TRUE,
  1063. &UserKey,
  1064. SubKeyHandle,
  1065. TRUE);
  1066. Adapter->UserServiceTypeTcpTraffic = (UCHAR)Value;
  1067. PsReadRegistryInt(ConfigHandle,
  1068. &BestEffortKey,
  1069. PS_USER_SERVICETYPE_BESTEFFORT_DEFAULT,
  1070. &Value,
  1071. 0,
  1072. USER_PRIORITY_MAX_VALUE,
  1073. TRUE,
  1074. &UserKey,
  1075. SubKeyHandle,
  1076. TRUE);
  1077. Adapter->UserServiceTypeBestEffort = (UCHAR)Value;
  1078. PsReadRegistryInt(ConfigHandle,
  1079. &ControlledLoadKey,
  1080. PS_USER_SERVICETYPE_CONTROLLEDLOAD_DEFAULT,
  1081. &Value,
  1082. 0,
  1083. USER_PRIORITY_MAX_VALUE,
  1084. TRUE,
  1085. &UserKey,
  1086. SubKeyHandle,
  1087. TRUE);
  1088. Adapter->UserServiceTypeControlledLoad = (UCHAR)Value;
  1089. PsReadRegistryInt(ConfigHandle,
  1090. &GuaranteedKey,
  1091. PS_USER_SERVICETYPE_GUARANTEED_DEFAULT,
  1092. &Value,
  1093. 0,
  1094. USER_PRIORITY_MAX_VALUE,
  1095. TRUE,
  1096. &UserKey,
  1097. SubKeyHandle,
  1098. TRUE);
  1099. Adapter->UserServiceTypeGuaranteed = (UCHAR)Value;
  1100. PsReadRegistryInt(ConfigHandle,
  1101. &QualitativeKey,
  1102. PS_USER_SERVICETYPE_QUALITATIVE_DEFAULT,
  1103. &Value,
  1104. 0,
  1105. USER_PRIORITY_MAX_VALUE,
  1106. TRUE,
  1107. &UserKey,
  1108. SubKeyHandle,
  1109. TRUE);
  1110. Adapter->UserServiceTypeQualitative = (UCHAR)Value;
  1111. PsReadRegistryInt(ConfigHandle,
  1112. &NonConformingKey,
  1113. PS_USER_SERVICETYPE_NONCONFORMING_DEFAULT,
  1114. &Value,
  1115. 0,
  1116. USER_PRIORITY_MAX_VALUE,
  1117. TRUE,
  1118. &UserKey,
  1119. SubKeyHandle,
  1120. TRUE);
  1121. Adapter->UserServiceTypeNonConforming = (UCHAR)Value;
  1122. PsReadRegistryInt(ConfigHandle,
  1123. &NetworkControlKey,
  1124. PS_USER_SERVICETYPE_NETWORK_CONTROL_DEFAULT,
  1125. &Value,
  1126. 0,
  1127. USER_PRIORITY_MAX_VALUE,
  1128. TRUE,
  1129. &UserKey,
  1130. SubKeyHandle,
  1131. TRUE);
  1132. Adapter->UserServiceTypeNetworkControl = (UCHAR)Value;
  1133. NdisCloseConfiguration(SubKeyHandle);
  1134. }
  1135. //
  1136. // Now, we need to take this number, swap the bits around and put it in the higher order bits.
  1137. // The DSCP codepoint is as follows:
  1138. //
  1139. // --------------------------------
  1140. // Bits | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  1141. // --------------------------------
  1142. // | DSCP | CU |
  1143. // --------------------------------
  1144. //
  1145. // Where DSCP - Differentiated services code point
  1146. // CU - Currently unused.
  1147. //
  1148. Adapter->IPServiceTypeBestEffort = Adapter->IPServiceTypeBestEffort << 2;
  1149. Adapter->IPServiceTypeControlledLoad = Adapter->IPServiceTypeControlledLoad << 2;
  1150. Adapter->IPServiceTypeGuaranteed = Adapter->IPServiceTypeGuaranteed << 2;
  1151. Adapter->IPServiceTypeQualitative = Adapter->IPServiceTypeQualitative << 2;
  1152. Adapter->IPServiceTypeNetworkControl = Adapter->IPServiceTypeNetworkControl << 2;
  1153. Adapter->IPServiceTypeBestEffortNC = Adapter->IPServiceTypeBestEffortNC << 2;
  1154. Adapter->IPServiceTypeControlledLoadNC = Adapter->IPServiceTypeControlledLoadNC << 2;
  1155. Adapter->IPServiceTypeGuaranteedNC = Adapter->IPServiceTypeGuaranteedNC << 2;
  1156. Adapter->IPServiceTypeQualitativeNC = Adapter->IPServiceTypeQualitativeNC << 2;
  1157. Adapter->IPServiceTypeNetworkControlNC = Adapter->IPServiceTypeNetworkControlNC << 2;
  1158. Adapter->IPServiceTypeTcpTraffic = Adapter->IPServiceTypeTcpTraffic << 2;
  1159. Adapter->IPServiceTypeTcpTrafficNC = Adapter->IPServiceTypeTcpTrafficNC << 2;
  1160. NdisCloseConfiguration(ConfigHandle);
  1161. return NDIS_STATUS_SUCCESS;
  1162. }