]> xenbits.xensource.com Git - pvdrivers/win/xennet.git/commitdiff
Use NDIS 6.60 interfaces, if supported
authorOwen Smith <owen.smith@citrix.com>
Tue, 26 Oct 2021 07:12:10 +0000 (08:12 +0100)
committerPaul Durrant <pdurrant@amazon.com>
Sun, 28 Nov 2021 20:31:48 +0000 (12:31 -0800)
Server 2016 introduced NDIS 6.60, update the interfaces to use NDIS 6.60 if
the reported NDIS runtime version supports this. No additional features of
NDIS 6.60 are used.
Also corrects the PhysicalMediaType property, which would otherwise block
functionality

Signed-off-by: Owen Smith <owen.smith@citrix.com>
src/xennet.inf
src/xennet/adapter.c
src/xennet/miniport.c
vs2015/xennet/xennet.vcxproj
vs2017/xennet/xennet.vcxproj
vs2019/xennet/xennet.vcxproj

index fc4f9fdfe8407497793ea9d33a668548b3a8574d..c44f4af1807524fccebc618efbce92a67e1d777e 100644 (file)
@@ -70,7 +70,7 @@ Characteristics=0x84
 BusType=1
 *IfType=6              ; IF_TYPE_ETHERNET_CSMACD
 *MediaType=0           ; NdisMedium802_3
-*PhysicalMediaType=0   ; NdisPhysicalMediumUnspecified
+*PhysicalMediaType=14  ; NdisPhysicalMedium802_3
 CopyFiles=XenNet_Copyfiles
 AddReg=Xennet_Inst_AddReg
 
index 7bfdc4ac17ef4f87e3d8d70f19c680dab306396f..b47e5e7542aa9593e37b0087f38f53f58f6e0721 100644 (file)
@@ -359,8 +359,14 @@ AdapterIndicateOffloadChanged(
 
     RtlZeroMemory(&Current, sizeof(Current));
     Current.Header.Type = NDIS_OBJECT_TYPE_OFFLOAD;
-    Current.Header.Revision = NDIS_OFFLOAD_REVISION_2;
-    Current.Header.Size = NDIS_SIZEOF_NDIS_OFFLOAD_REVISION_2;
+
+    if (NdisGetVersion() >= NDIS_RUNTIME_VERSION_660) {
+        Current.Header.Revision = NDIS_OFFLOAD_REVISION_4;
+        Current.Header.Size = NDIS_SIZEOF_NDIS_OFFLOAD_REVISION_4;
+    } else {
+        Current.Header.Revision = NDIS_OFFLOAD_REVISION_3;
+        Current.Header.Size = NDIS_SIZEOF_NDIS_OFFLOAD_REVISION_3;
+    }
 
     Current.Checksum.IPv4Receive.Encapsulation = NDIS_ENCAPSULATION_IEEE_802_3;
 
@@ -446,7 +452,11 @@ AdapterIndicateOffloadChanged(
     Status.Header.Size = NDIS_SIZEOF_STATUS_INDICATION_REVISION_1;
     Status.StatusCode = NDIS_STATUS_TASK_OFFLOAD_CURRENT_CONFIG;
     Status.StatusBuffer = &Current;
-    Status.StatusBufferSize = NDIS_SIZEOF_NDIS_OFFLOAD_REVISION_2;
+
+    if (NdisGetVersion() >= NDIS_RUNTIME_VERSION_660)
+        Status.StatusBufferSize = NDIS_SIZEOF_NDIS_OFFLOAD_REVISION_4;
+    else
+        Status.StatusBufferSize = NDIS_SIZEOF_NDIS_OFFLOAD_REVISION_3;
 
     NdisMIndicateStatusEx(Adapter->NdisAdapterHandle, &Status);
 }
@@ -939,14 +949,21 @@ DisplayRss(
 static NDIS_STATUS
 AdapterGetReceiveScaleParameters(
     IN  PXENNET_ADAPTER                 Adapter,
-    IN  PNDIS_RECEIVE_SCALE_PARAMETERS  Parameters
+    IN  PNDIS_RECEIVE_SCALE_PARAMETERS  Parameters,
+    OUT PULONG                          BytesRead
     )
 {
     NDIS_STATUS                         ndisStatus;
 
     ASSERT3U(Parameters->Header.Type, ==, NDIS_OBJECT_TYPE_RSS_PARAMETERS);
-    ASSERT3U(Parameters->Header.Revision, ==, NDIS_RECEIVE_SCALE_PARAMETERS_REVISION_2);
-    ASSERT3U(Parameters->Header.Size, >=, NDIS_SIZEOF_RECEIVE_SCALE_PARAMETERS_REVISION_2);
+
+    if (NdisGetVersion() >= NDIS_RUNTIME_VERSION_660) {
+        ASSERT3U(Parameters->Header.Revision, ==, NDIS_RECEIVE_SCALE_PARAMETERS_REVISION_3);
+        ASSERT3U(Parameters->Header.Size, >=, NDIS_SIZEOF_RECEIVE_SCALE_PARAMETERS_REVISION_3);
+    } else {
+        ASSERT3U(Parameters->Header.Revision, ==, NDIS_RECEIVE_SCALE_PARAMETERS_REVISION_2);
+        ASSERT3U(Parameters->Header.Size, >=, NDIS_SIZEOF_RECEIVE_SCALE_PARAMETERS_REVISION_2);
+    }
 
     if (!Adapter->Rss.Supported)
         return NDIS_STATUS_NOT_SUPPORTED;
@@ -957,6 +974,11 @@ AdapterGetReceiveScaleParameters(
     if (Adapter->Rss.HashEnabled)
         return NDIS_STATUS_NOT_SUPPORTED;
 
+    if (NdisGetVersion() >= NDIS_RUNTIME_VERSION_660)
+        *BytesRead = NDIS_SIZEOF_RECEIVE_SCALE_PARAMETERS_REVISION_3;
+    else
+        *BytesRead = NDIS_SIZEOF_RECEIVE_SCALE_PARAMETERS_REVISION_2;
+
     if (!(Parameters->Flags & NDIS_RSS_PARAM_FLAG_DISABLE_RSS)) {
         Adapter->Rss.ScaleEnabled = TRUE;
     } else {
@@ -976,6 +998,7 @@ AdapterGetReceiveScaleParameters(
                                          Parameters->HashSecretKeySize);
         if (ndisStatus != NDIS_STATUS_SUCCESS)
             goto fail;
+        *BytesRead += Parameters->HashSecretKeySize;
     }
 
     if (!(Parameters->Flags & NDIS_RSS_PARAM_FLAG_ITABLE_UNCHANGED)) {
@@ -984,6 +1007,7 @@ AdapterGetReceiveScaleParameters(
                                            Parameters->IndirectionTableSize);
         if (ndisStatus != NDIS_STATUS_SUCCESS)
             goto fail;
+        *BytesRead += Parameters->IndirectionTableSize;
     }
 
     DisplayRss(&Adapter->Rss);
@@ -2111,7 +2135,8 @@ AdapterSetInformation(
         if (BufferLength == BytesNeeded) {
             ndisStatus = AdapterSetPacketFilter(Adapter,
                                                 (PULONG)Buffer);
-            BytesRead = sizeof(ULONG);
+            if (ndisStatus == NDIS_STATUS_SUCCESS)
+                BytesRead = sizeof(ULONG);
         }
         break;
 
@@ -2141,24 +2166,26 @@ AdapterSetInformation(
         break;
 
     case OID_TCP_OFFLOAD_PARAMETERS:
-        BytesNeeded = NDIS_OFFLOAD_PARAMETERS_REVISION_2;
+        BytesNeeded = NDIS_SIZEOF_OFFLOAD_PARAMETERS_REVISION_3;
         if (BufferLength >= BytesNeeded) {
             ndisStatus = AdapterGetTcpOffloadParameters(Adapter,
                                                         (PNDIS_OFFLOAD_PARAMETERS)Buffer);
             if (ndisStatus == NDIS_STATUS_SUCCESS)
-                BytesRead = NDIS_OFFLOAD_PARAMETERS_REVISION_2;
+                BytesRead = NDIS_SIZEOF_OFFLOAD_PARAMETERS_REVISION_3;
         } else {
             ndisStatus = NDIS_STATUS_INVALID_LENGTH;
         }
         break;
 
     case OID_GEN_RECEIVE_SCALE_PARAMETERS:
-        BytesNeeded = NDIS_SIZEOF_RECEIVE_SCALE_PARAMETERS_REVISION_1;
+        if (NdisGetVersion() >= NDIS_RUNTIME_VERSION_660)
+            BytesNeeded = NDIS_SIZEOF_RECEIVE_SCALE_PARAMETERS_REVISION_3;
+        else
+            BytesNeeded = NDIS_SIZEOF_RECEIVE_SCALE_PARAMETERS_REVISION_2;
         if (BufferLength >= BytesNeeded) {
             ndisStatus = AdapterGetReceiveScaleParameters(Adapter,
-                                                          (PNDIS_RECEIVE_SCALE_PARAMETERS)Buffer);
-            if (ndisStatus == NDIS_STATUS_SUCCESS)
-                BytesRead = sizeof(NDIS_RECEIVE_SCALE_PARAMETERS);
+                                                          (PNDIS_RECEIVE_SCALE_PARAMETERS)Buffer,
+                                                          &BytesRead);
         } else {
             ndisStatus = NDIS_STATUS_INVALID_LENGTH;
         }
@@ -2183,7 +2210,7 @@ AdapterSetInformation(
         /*FALLTHRU*/
     default:
         if (Warn)
-            Warning("UNSUPPORTED OID %08x\n", Request->DATA.QUERY_INFORMATION.Oid);
+            Warning("UNSUPPORTED OID %08x\n", Request->DATA.SET_INFORMATION.Oid);
 
         ndisStatus = NDIS_STATUS_NOT_SUPPORTED;
         break;
@@ -2384,11 +2411,19 @@ AdapterQueryInformation(
 
     case OID_GEN_DRIVER_VERSION:
         BytesNeeded = sizeof(ULONG);
-        ndisStatus = __SetUlong(Buffer,
-                                BufferLength,
-                                (NDIS_MINIPORT_MAJOR_VERSION << 8) |
-                                NDIS_MINIPORT_MINOR_VERSION,
-                                &BytesWritten);
+        if (NdisGetVersion() >= NDIS_RUNTIME_VERSION_660) {
+            ndisStatus = __SetUlong(Buffer,
+                                    BufferLength,
+                                    (NDIS_MINIPORT_MAJOR_VERSION << 8) |
+                                    NDIS_MINIPORT_MINOR_VERSION,
+                                    &BytesWritten);
+        } else {
+            ndisStatus = __SetUlong(Buffer,
+                                    BufferLength,
+                                    (NDIS_MINIPORT_MINIMUM_MAJOR_VERSION << 8) |
+                                    NDIS_MINIPORT_MINIMUM_MINOR_VERSION,
+                                    &BytesWritten);
+        }
         break;
 
     case OID_GEN_MAC_OPTIONS:
@@ -2729,9 +2764,9 @@ AdapterQueryInformation(
     case OID_GEN_MAC_ADDRESS:
     case OID_GEN_MAX_LINK_SPEED:
         // ignore these common unwanted OIDs
-       case OID_GEN_INIT_TIME_MS:
-       case OID_GEN_RESET_COUNTS:
-       case OID_GEN_MEDIA_SENSE_COUNTS:
+    case OID_GEN_INIT_TIME_MS:
+    case OID_GEN_RESET_COUNTS:
+    case OID_GEN_MEDIA_SENSE_COUNTS:
         Warn = FALSE;
         /*FALLTHRU*/
     default:
@@ -2971,6 +3006,11 @@ AdapterSetGeneralAttributes(
     NDIS_STATUS                                 ndisStatus;
     NTSTATUS                                    status;
 
+    RtlZeroMemory(&Adapter->Capabilities, sizeof(Adapter->Capabilities));
+    Adapter->Capabilities.Header.Type = NDIS_OBJECT_TYPE_DEFAULT;
+    Adapter->Capabilities.Header.Revision = NDIS_PM_CAPABILITIES_REVISION_2;
+    Adapter->Capabilities.Header.Size = NDIS_SIZEOF_NDIS_PM_CAPABILITIES_REVISION_2;
+
     RtlZeroMemory(&Attribs, sizeof(Attribs));
     Attribs.Header.Type = NDIS_OBJECT_TYPE_MINIPORT_ADAPTER_GENERAL_ATTRIBUTES;
     Attribs.Header.Revision = NDIS_MINIPORT_ADAPTER_GENERAL_ATTRIBUTES_REVISION_2;
@@ -3051,8 +3091,14 @@ AdapterSetGeneralAttributes(
 
     RtlZeroMemory(&Rss, sizeof(Rss));
     Rss.Header.Type = NDIS_OBJECT_TYPE_RSS_CAPABILITIES;
-    Rss.Header.Revision = NDIS_RECEIVE_SCALE_CAPABILITIES_REVISION_2;
-    Rss.Header.Size = NDIS_SIZEOF_RECEIVE_SCALE_CAPABILITIES_REVISION_2;
+
+    if (NdisGetVersion() >= NDIS_RUNTIME_VERSION_660) {
+        Rss.Header.Revision = NDIS_RECEIVE_SCALE_CAPABILITIES_REVISION_3;
+        Rss.Header.Size = NDIS_SIZEOF_RECEIVE_SCALE_CAPABILITIES_REVISION_3;
+    } else {
+        Rss.Header.Revision = NDIS_RECEIVE_SCALE_CAPABILITIES_REVISION_2;
+        Rss.Header.Size = NDIS_SIZEOF_RECEIVE_SCALE_CAPABILITIES_REVISION_2;
+    }
 
     Rss.CapabilitiesFlags = NDIS_RSS_CAPS_MESSAGE_SIGNALED_INTERRUPTS |
                             NDIS_RSS_CAPS_CLASSIFICATION_AT_ISR |
@@ -3135,8 +3181,14 @@ AdapterSetOffloadAttributes(
 
     RtlZeroMemory(&Supported, sizeof(Supported));
     Supported.Header.Type = NDIS_OBJECT_TYPE_OFFLOAD;
-    Supported.Header.Revision = NDIS_OFFLOAD_REVISION_2;
-    Supported.Header.Size = NDIS_SIZEOF_NDIS_OFFLOAD_REVISION_2;
+
+    if (NdisGetVersion() >= NDIS_RUNTIME_VERSION_660) {
+        Supported.Header.Revision = NDIS_OFFLOAD_REVISION_4;
+        Supported.Header.Size = NDIS_SIZEOF_NDIS_OFFLOAD_REVISION_4;
+    } else {
+        Supported.Header.Revision = NDIS_OFFLOAD_REVISION_3;
+        Supported.Header.Size = NDIS_SIZEOF_NDIS_OFFLOAD_REVISION_3;
+    }
 
     Supported.Checksum.IPv4Receive.Encapsulation = NDIS_ENCAPSULATION_IEEE_802_3;
 
index 5b6931516586b8e5575b470ae3d5ed7523c75c09..e24e1ad1ccfb4b9462f01f383a9182c03b4a8f15 100644 (file)
@@ -338,12 +338,18 @@ MiniportRegister(
 
     NdisZeroMemory(&MiniportDriverCharacteristics, sizeof (MiniportDriverCharacteristics));
 
-    MiniportDriverCharacteristics.Header.Type = NDIS_OBJECT_TYPE_MINIPORT_DRIVER_CHARACTERISTICS,
+    MiniportDriverCharacteristics.Header.Type = NDIS_OBJECT_TYPE_MINIPORT_DRIVER_CHARACTERISTICS;
     MiniportDriverCharacteristics.Header.Size = NDIS_SIZEOF_MINIPORT_DRIVER_CHARACTERISTICS_REVISION_2;
     MiniportDriverCharacteristics.Header.Revision = NDIS_MINIPORT_DRIVER_CHARACTERISTICS_REVISION_2;
 
-    MiniportDriverCharacteristics.MajorNdisVersion = NDIS_MINIPORT_MAJOR_VERSION;
-    MiniportDriverCharacteristics.MinorNdisVersion = NDIS_MINIPORT_MINOR_VERSION;
+    if (NdisGetVersion() >= NDIS_RUNTIME_VERSION_660) {
+        MiniportDriverCharacteristics.MajorNdisVersion = NDIS_MINIPORT_MAJOR_VERSION; // 6
+        MiniportDriverCharacteristics.MinorNdisVersion = NDIS_MINIPORT_MINOR_VERSION; // 60
+    } else {
+        MiniportDriverCharacteristics.MajorNdisVersion = NDIS_MINIPORT_MINIMUM_MAJOR_VERSION; // 6
+        MiniportDriverCharacteristics.MinorNdisVersion = NDIS_MINIPORT_MINIMUM_MINOR_VERSION; // 30
+    }
+
     MiniportDriverCharacteristics.MajorDriverVersion = MAJOR_VERSION;
     MiniportDriverCharacteristics.MinorDriverVersion = MINOR_VERSION;
     MiniportDriverCharacteristics.Flags = NDIS_WDM_DRIVER;
index b68d7345d7589cc3774921cb7f379514cc373322..966de3aee91720123d5b787bff6b6bd16b8177da 100644 (file)
@@ -22,7 +22,7 @@
   </PropertyGroup>
   <ItemDefinitionGroup>
     <ClCompile>
-      <PreprocessorDefinitions>PROJECT=$(ProjectName);NDIS_MINIPORT_DRIVER;NDIS_WDM=1;NDIS630_MINIPORT=1;POOL_NX_OPTIN=1;NT_PROCESSOR_GROUPS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>PROJECT=$(ProjectName);NDIS_MINIPORT_DRIVER;NDIS_WDM=1;NDIS630_MINIPORT=1;NDIS660_MINIPORT=1;POOL_NX_OPTIN=1;NT_PROCESSOR_GROUPS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <AdditionalIncludeDirectories>$(WindowsSdkDir)\include\km;..\..\include;..\..\include\xen;</AdditionalIncludeDirectories>
       <WarningLevel>EnableAllWarnings</WarningLevel>
       <DisableSpecificWarnings>4464;4711;4548;4820;4668;4255;6001;6054;28160;28196;30030;30029;%(DisableSpecificWarnings)</DisableSpecificWarnings>
index 130b0e6baac4aac86ad33b5e3fe96116be10c413..8df984079c16f408319641af3ee439e87181b335 100644 (file)
@@ -22,7 +22,7 @@
   </PropertyGroup>
   <ItemDefinitionGroup>
     <ClCompile>
-      <PreprocessorDefinitions>PROJECT=$(ProjectName);NDIS_MINIPORT_DRIVER;NDIS_WDM=1;NDIS630_MINIPORT=1;POOL_NX_OPTIN=1;NT_PROCESSOR_GROUPS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>PROJECT=$(ProjectName);NDIS_MINIPORT_DRIVER;NDIS_WDM=1;NDIS630_MINIPORT=1;NDIS660_MINIPORT=1;POOL_NX_OPTIN=1;NT_PROCESSOR_GROUPS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <IntrinsicFunctions>true</IntrinsicFunctions>
       <AdditionalIncludeDirectories>$(WindowsSdkDir)\include\km;..\..\include;..\..\include\xen;</AdditionalIncludeDirectories>
       <WarningLevel>EnableAllWarnings</WarningLevel>
index 1ad56011478396a0efadf8932f22424f26b47158..2eba0394fb3437ad683ecc9c6de8ebf038ed0520 100644 (file)
@@ -21,7 +21,7 @@
   </PropertyGroup>
   <ItemDefinitionGroup>
     <ClCompile>
-      <PreprocessorDefinitions>PROJECT=$(ProjectName);NDIS_MINIPORT_DRIVER;NDIS_WDM=1;NDIS630_MINIPORT=1;POOL_NX_OPTIN=1;NT_PROCESSOR_GROUPS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>PROJECT=$(ProjectName);NDIS_MINIPORT_DRIVER;NDIS_WDM=1;NDIS630_MINIPORT=1;NDIS660_MINIPORT=1;POOL_NX_OPTIN=1;NT_PROCESSOR_GROUPS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <IntrinsicFunctions>true</IntrinsicFunctions>
       <AdditionalIncludeDirectories>$(WindowsSdkDir)\include\km;..\..\include;..\..\include\xen;</AdditionalIncludeDirectories>
       <WarningLevel>EnableAllWarnings</WarningLevel>