- Timestamp:
- Sep 18, 2015 4:20:34 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/drv/VBoxNetLwf-win.cpp
r57576 r57831 186 186 /** Counter for pending sends (both to wire and host) */ 187 187 int32_t cPendingBuffers; 188 /** Work Item to deliver offloading indications at passive IRQL */ 189 NDIS_HANDLE hWorkItem; 188 190 #endif /* !VBOXNETLWF_SYNC_SEND */ 189 191 /** Name of underlying adapter */ … … 759 761 } 760 762 763 static void vboxNetLwfWinUpdateSavedOffloadConfig(PVBOXNETLWF_MODULE pModuleCtx, PNDIS_OFFLOAD pOffload) 764 { 765 pModuleCtx->SavedOffloadConfig = *pOffload; 766 pModuleCtx->fOffloadConfigValid = true; 767 } 761 768 762 769 static NDIS_STATUS vboxNetLwfWinAttach(IN NDIS_HANDLE hFilter, IN NDIS_HANDLE hDriverCtx, … … 778 785 NdisZeroMemory(pModuleCtx, sizeof(VBOXNETLWF_MODULE)); 779 786 787 pModuleCtx->hWorkItem = NdisAllocateIoWorkItem(g_VBoxNetLwfGlobals.hFilterDriver); 788 if (!pModuleCtx->hWorkItem) 789 { 790 Log(("ERROR! vboxNetLwfWinAttach: Failed to allocate work item for %ls\n", 791 pParameters->BaseMiniportName)); 792 NdisFreeMemory(pModuleCtx, 0, 0); 793 return NDIS_STATUS_RESOURCES; 794 } 795 780 796 /* We use the miniport name to associate this filter module with the netflt instance */ 781 797 NTSTATUS rc = RtlUnicodeStringToAnsiString(&pModuleCtx->strMiniportName, … … 786 802 Log(("ERROR! vboxNetLwfWinAttach: RtlUnicodeStringToAnsiString(%ls) failed with 0x%x\n", 787 803 pParameters->BaseMiniportName, rc)); 804 NdisFreeIoWorkItem(pModuleCtx->hWorkItem); 788 805 NdisFreeMemory(pModuleCtx, 0, 0); 789 806 return NDIS_STATUS_FAILURE; … … 795 812 NdisMoveMemory(&pModuleCtx->MacAddr, pParameters->CurrentMacAddress, RT_MIN(sizeof(RTMAC), pParameters->MacAddressLength)); 796 813 if (pParameters->DefaultOffloadConfiguration) 797 { 798 pModuleCtx->SavedOffloadConfig = *pParameters->DefaultOffloadConfiguration; 799 pModuleCtx->fOffloadConfigValid = true; 800 } 814 vboxNetLwfWinUpdateSavedOffloadConfig(pModuleCtx, pParameters->DefaultOffloadConfiguration); 801 815 802 816 pModuleCtx->pGlobals = pGlobals; … … 831 845 Log(("ERROR! vboxNetLwfWinAttach: NdisAllocateNetBufferListPool failed\n")); 832 846 RtlFreeAnsiString(&pModuleCtx->strMiniportName); 847 NdisFreeIoWorkItem(pModuleCtx->hWorkItem); 833 848 NdisFreeMemory(pModuleCtx, 0, 0); 834 849 return NDIS_STATUS_RESOURCES; … … 849 864 Log4(("vboxNetLwfWinAttach: freed NBL+NB pool 0x%p\n", pModuleCtx->hPool)); 850 865 RtlFreeAnsiString(&pModuleCtx->strMiniportName); 866 NdisFreeIoWorkItem(pModuleCtx->hWorkItem); 851 867 NdisFreeMemory(pModuleCtx, 0, 0); 852 868 return NDIS_STATUS_RESOURCES; … … 902 918 } 903 919 RtlFreeAnsiString(&pModuleCtx->strMiniportName); 920 NdisFreeIoWorkItem(pModuleCtx->hWorkItem); 904 921 NdisFreeMemory(hModuleCtx, 0, 0); 905 922 Log4(("vboxNetLwfWinDetach: freed module context 0x%p\n", pModuleCtx)); … … 947 964 PVBOXNETLWF_MODULE pModuleCtx = (PVBOXNETLWF_MODULE)hModuleCtx; 948 965 vboxNetLwfWinChangeState(pModuleCtx, LwfState_Restarting, LwfState_Paused); 949 #if 1950 if (pModuleCtx->fOffloadConfigValid)951 {952 if (ASMAtomicReadBool(&pModuleCtx->fActive))953 {954 /* Disable offloading temporarily by indicating offload config change. */955 /** @todo Be sure to revise this when implementing offloading support! */956 NDIS_OFFLOAD OffloadConfig;957 OffloadConfig = pModuleCtx->SavedOffloadConfig;958 OffloadConfig.Checksum.IPv4Transmit.Encapsulation = NDIS_ENCAPSULATION_NOT_SUPPORTED;959 OffloadConfig.Checksum.IPv4Transmit.IpOptionsSupported = NDIS_OFFLOAD_NOT_SUPPORTED;960 OffloadConfig.Checksum.IPv4Transmit.TcpOptionsSupported = NDIS_OFFLOAD_NOT_SUPPORTED;961 OffloadConfig.Checksum.IPv4Transmit.TcpChecksum = NDIS_OFFLOAD_NOT_SUPPORTED;962 OffloadConfig.Checksum.IPv4Transmit.UdpChecksum = NDIS_OFFLOAD_NOT_SUPPORTED;963 OffloadConfig.Checksum.IPv4Transmit.IpChecksum = NDIS_OFFLOAD_NOT_SUPPORTED;964 OffloadConfig.Checksum.IPv4Receive.Encapsulation = NDIS_ENCAPSULATION_NOT_SUPPORTED;965 OffloadConfig.Checksum.IPv4Receive.IpOptionsSupported = NDIS_OFFLOAD_NOT_SUPPORTED;966 OffloadConfig.Checksum.IPv4Receive.TcpOptionsSupported = NDIS_OFFLOAD_NOT_SUPPORTED;967 OffloadConfig.Checksum.IPv4Receive.TcpChecksum = NDIS_OFFLOAD_NOT_SUPPORTED;968 OffloadConfig.Checksum.IPv4Receive.UdpChecksum = NDIS_OFFLOAD_NOT_SUPPORTED;969 OffloadConfig.Checksum.IPv4Receive.IpChecksum = NDIS_OFFLOAD_NOT_SUPPORTED;970 OffloadConfig.Checksum.IPv6Transmit.Encapsulation = NDIS_ENCAPSULATION_NOT_SUPPORTED;971 OffloadConfig.Checksum.IPv6Transmit.IpExtensionHeadersSupported = NDIS_OFFLOAD_NOT_SUPPORTED;972 OffloadConfig.Checksum.IPv6Transmit.TcpOptionsSupported = NDIS_OFFLOAD_NOT_SUPPORTED;973 OffloadConfig.Checksum.IPv6Transmit.TcpChecksum = NDIS_OFFLOAD_NOT_SUPPORTED;974 OffloadConfig.Checksum.IPv6Transmit.UdpChecksum = NDIS_OFFLOAD_NOT_SUPPORTED;975 OffloadConfig.Checksum.IPv6Receive.Encapsulation = NDIS_ENCAPSULATION_NOT_SUPPORTED;976 OffloadConfig.Checksum.IPv6Receive.IpExtensionHeadersSupported = NDIS_OFFLOAD_NOT_SUPPORTED;977 OffloadConfig.Checksum.IPv6Receive.TcpOptionsSupported = NDIS_OFFLOAD_NOT_SUPPORTED;978 OffloadConfig.Checksum.IPv6Receive.TcpChecksum = NDIS_OFFLOAD_NOT_SUPPORTED;979 OffloadConfig.Checksum.IPv6Receive.UdpChecksum = NDIS_OFFLOAD_NOT_SUPPORTED;980 OffloadConfig.LsoV1.IPv4.Encapsulation = NDIS_ENCAPSULATION_NOT_SUPPORTED;981 OffloadConfig.LsoV1.IPv4.TcpOptions = NDIS_OFFLOAD_NOT_SUPPORTED;982 OffloadConfig.LsoV1.IPv4.IpOptions = NDIS_OFFLOAD_NOT_SUPPORTED;983 OffloadConfig.LsoV2.IPv4.Encapsulation = NDIS_ENCAPSULATION_NOT_SUPPORTED;984 OffloadConfig.LsoV2.IPv6.Encapsulation = NDIS_ENCAPSULATION_NOT_SUPPORTED;985 OffloadConfig.LsoV2.IPv6.IpExtensionHeadersSupported = NDIS_OFFLOAD_NOT_SUPPORTED;986 OffloadConfig.LsoV2.IPv6.TcpOptionsSupported = NDIS_OFFLOAD_NOT_SUPPORTED;987 vboxNetLwfWinIndicateOffload(pModuleCtx, &OffloadConfig);988 Log(("vboxNetLwfWinRestart: set offloading off\n"));989 }990 else991 {992 /* The filter is inactive -- restore offloading configuration. */993 vboxNetLwfWinIndicateOffload(pModuleCtx, &pModuleCtx->SavedOffloadConfig);994 Log(("vboxNetLwfWinRestart: restored offloading config\n"));995 }996 }997 #endif998 966 999 967 vboxNetLwfWinChangeState(pModuleCtx, LwfState_Running, LwfState_Restarting); … … 1341 1309 } 1342 1310 1311 static void vboxNetLwfWinDisableOffloading(PNDIS_OFFLOAD pOffloadConfig) 1312 { 1313 pOffloadConfig->Checksum.IPv4Transmit.Encapsulation = NDIS_ENCAPSULATION_NOT_SUPPORTED; 1314 pOffloadConfig->Checksum.IPv4Transmit.IpOptionsSupported = NDIS_OFFLOAD_NOT_SUPPORTED; 1315 pOffloadConfig->Checksum.IPv4Transmit.TcpOptionsSupported = NDIS_OFFLOAD_NOT_SUPPORTED; 1316 pOffloadConfig->Checksum.IPv4Transmit.TcpChecksum = NDIS_OFFLOAD_NOT_SUPPORTED; 1317 pOffloadConfig->Checksum.IPv4Transmit.UdpChecksum = NDIS_OFFLOAD_NOT_SUPPORTED; 1318 pOffloadConfig->Checksum.IPv4Transmit.IpChecksum = NDIS_OFFLOAD_NOT_SUPPORTED; 1319 pOffloadConfig->Checksum.IPv6Transmit.Encapsulation = NDIS_ENCAPSULATION_NOT_SUPPORTED; 1320 pOffloadConfig->Checksum.IPv6Transmit.IpExtensionHeadersSupported = NDIS_OFFLOAD_NOT_SUPPORTED; 1321 pOffloadConfig->Checksum.IPv6Transmit.TcpOptionsSupported = NDIS_OFFLOAD_NOT_SUPPORTED; 1322 pOffloadConfig->Checksum.IPv6Transmit.TcpChecksum = NDIS_OFFLOAD_NOT_SUPPORTED; 1323 pOffloadConfig->Checksum.IPv6Transmit.UdpChecksum = NDIS_OFFLOAD_NOT_SUPPORTED; 1324 pOffloadConfig->LsoV1.IPv4.Encapsulation = NDIS_ENCAPSULATION_NOT_SUPPORTED; 1325 pOffloadConfig->LsoV1.IPv4.TcpOptions = NDIS_OFFLOAD_NOT_SUPPORTED; 1326 pOffloadConfig->LsoV1.IPv4.IpOptions = NDIS_OFFLOAD_NOT_SUPPORTED; 1327 pOffloadConfig->LsoV2.IPv4.Encapsulation = NDIS_ENCAPSULATION_NOT_SUPPORTED; 1328 pOffloadConfig->LsoV2.IPv6.Encapsulation = NDIS_ENCAPSULATION_NOT_SUPPORTED; 1329 pOffloadConfig->LsoV2.IPv6.IpExtensionHeadersSupported = NDIS_OFFLOAD_NOT_SUPPORTED; 1330 pOffloadConfig->LsoV2.IPv6.TcpOptionsSupported = NDIS_OFFLOAD_NOT_SUPPORTED; 1331 } 1332 1343 1333 VOID vboxNetLwfWinStatus(IN NDIS_HANDLE hModuleCtx, IN PNDIS_STATUS_INDICATION pIndication) 1344 1334 { … … 1356 1346 case NDIS_STATUS_TASK_OFFLOAD_CURRENT_CONFIG: 1357 1347 Log5(("vboxNetLwfWinStatus: offloading currently set to:\n")); 1348 vboxNetLwfWinDumpOffloadSettings((PNDIS_OFFLOAD)pIndication->StatusBuffer); 1349 vboxNetLwfWinUpdateSavedOffloadConfig(pModuleCtx, (PNDIS_OFFLOAD)pIndication->StatusBuffer); 1350 if (ASMAtomicReadBool(&pModuleCtx->fActive)) 1351 vboxNetLwfWinDisableOffloading((PNDIS_OFFLOAD)pIndication->StatusBuffer); 1352 Log5(("vboxNetLwfWinStatus: reporting offloading up as:\n")); 1358 1353 vboxNetLwfWinDumpOffloadSettings((PNDIS_OFFLOAD)pIndication->StatusBuffer); 1359 1354 break; … … 2112 2107 } 2113 2108 2109 2110 NDIS_IO_WORKITEM_FUNCTION vboxNetLwfWinToggleOffloading; 2111 2112 VOID vboxNetLwfWinToggleOffloading(PVOID WorkItemContext, NDIS_HANDLE NdisIoWorkItemHandle) 2113 { 2114 /* WARNING! Call this with IRQL=Passive! */ 2115 PVBOXNETLWF_MODULE pModuleCtx = (PVBOXNETLWF_MODULE)WorkItemContext; 2116 2117 if (ASMAtomicReadBool(&pModuleCtx->fActive)) 2118 { 2119 /* Disable offloading temporarily by indicating offload config change. */ 2120 /** @todo Be sure to revise this when implementing offloading support! */ 2121 NDIS_OFFLOAD OffloadConfig; 2122 if (pModuleCtx->fOffloadConfigValid) 2123 { 2124 OffloadConfig = pModuleCtx->SavedOffloadConfig; 2125 vboxNetLwfWinDisableOffloading(&OffloadConfig); 2126 } 2127 else 2128 { 2129 DbgPrint("VBoxNetLwf: no saved offload config to modify for %Z\n", pModuleCtx->strMiniportName); 2130 NdisZeroMemory(&OffloadConfig, sizeof(OffloadConfig)); 2131 OffloadConfig.Header.Type = NDIS_OBJECT_TYPE_OFFLOAD; 2132 OffloadConfig.Header.Revision = NDIS_OFFLOAD_REVISION_1; 2133 OffloadConfig.Header.Size = NDIS_SIZEOF_NDIS_OFFLOAD_REVISION_1; 2134 } 2135 vboxNetLwfWinIndicateOffload(pModuleCtx, &OffloadConfig); 2136 Log(("vboxNetLwfWinToggleOffloading: set offloading off\n")); 2137 } 2138 else 2139 { 2140 /* The filter is inactive -- restore offloading configuration. */ 2141 if (pModuleCtx->fOffloadConfigValid) 2142 { 2143 vboxNetLwfWinIndicateOffload(pModuleCtx, &pModuleCtx->SavedOffloadConfig); 2144 Log(("vboxNetLwfWinToggleOffloading: restored offloading config\n")); 2145 } 2146 else 2147 DbgPrint("VBoxNetLwf: no saved offload config to restore for %Z\n", pModuleCtx->strMiniportName); 2148 } 2149 } 2150 2151 2114 2152 void vboxNetFltPortOsSetActive(PVBOXNETFLTINS pThis, bool fActive) 2115 2153 { … … 2126 2164 if (fOldActive != fActive) 2127 2165 { 2166 NdisQueueIoWorkItem(pModuleCtx->hWorkItem, vboxNetLwfWinToggleOffloading, pModuleCtx); 2128 2167 Status = vboxNetLwfWinSetPacketFilter(pModuleCtx, fActive); 2129 2168 LogFlow(("<==vboxNetFltPortOsSetActive: vboxNetLwfWinSetPacketFilter() returned 0x%x\n", Status));
Note:
See TracChangeset
for help on using the changeset viewer.