[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/4] Update to NDIS 6.30


  • To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
  • From: "Durrant, Paul" <xadimgnik@xxxxxxxxx>
  • Date: Tue, 2 Nov 2021 10:08:52 +0000
  • Delivery-date: Tue, 02 Nov 2021 10:08:56 +0000
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

On 26/10/2021 08:12, Owen Smith wrote:
NDIS 6.30 was introduced in Server 2012. Update XenNet to use the NDIS 6.30
interfaces. No additional features of NDIS 6.30 are used.

This doesn't seem to be the case. You've clearly updated RSS in this patch. Could you expand the commit comment accordingly?

  Paul

Also fixes "NDIS 6.5 GlitchFreeDevice" test by correctly reporting XenNet uses
a WDM lower edge.

Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
---
  src/xennet.inf               |  7 +++
  src/xennet/adapter.c         | 89 +++++++++++++++++++-----------------
  vs2015/xennet/xennet.vcxproj |  2 +-
  vs2017/xennet/xennet.vcxproj |  2 +-
  vs2019/xennet/xennet.vcxproj |  2 +-
  5 files changed, 56 insertions(+), 46 deletions(-)

diff --git a/src/xennet.inf b/src/xennet.inf
index b36b1e3..f93acba 100644
--- a/src/xennet.inf
+++ b/src/xennet.inf
@@ -166,6 +166,12 @@ HKR, Ndi\params\*RSS,                             Optional,   0, 
"0"
  HKR, Ndi\params\*RSS\enum,                        "0",        0, %Disabled%
  HKR, Ndi\params\*RSS\enum,                        "1",        0, %Enabled%
+HKR, Ndi\params\*NumRSSQueues, ParamDesc, 0, %NumRSSQueues%
+HKR, Ndi\params\*NumRSSQueues,                    Type,       0, "int"
+HKR, Ndi\params\*NumRSSQueues,                    Default,    0, "8"
+HKR, Ndi\params\*NumRSSQueues,                    Min,        0, "1"
+HKR, Ndi\params\*NumRSSQueues,                    Max,        0, "8"
+
  [XenNet_Inst.Services]
  AddService=xennet,0x02,XenNet_Service,XenNet_EventLog
@@ -211,6 +217,7 @@ LSOV2IPv6="Large Send Offload V2 (IPv6)"
  LROIPv4="Large Receive Offload (IPv4)"
  LROIPv6="Large Receive Offload (IPv6)"
  RSS="Receive Side Scaling"
+NumRSSQueues="Maximum Number of RSS Queues"
  HeaderDataSplit="Header Data Split"
  Disabled="Disabled"
  Enabled="Enabled"
diff --git a/src/xennet/adapter.c b/src/xennet/adapter.c
index eaa2c1b..7bfdc4a 100644
--- a/src/xennet/adapter.c
+++ b/src/xennet/adapter.c
@@ -61,17 +61,18 @@ typedef struct _PROPERTIES {
      int lrov4;
      int lrov6;
      int rss;
+    int numrssqueues;
  } PROPERTIES, *PPROPERTIES;
typedef struct _XENNET_RSS {
-    BOOLEAN Supported;
-    BOOLEAN HashEnabled;
-    BOOLEAN ScaleEnabled;
-    ULONG   Types;
-    UCHAR   Key[NDIS_RSS_HASH_SECRET_KEY_MAX_SIZE_REVISION_1];
-    ULONG   KeySize;
-    CCHAR   Table[NDIS_RSS_INDIRECTION_TABLE_MAX_SIZE_REVISION_1];
-    ULONG   TableSize;
+    BOOLEAN             Supported;
+    BOOLEAN             HashEnabled;
+    BOOLEAN             ScaleEnabled;
+    ULONG               Types;
+    UCHAR               Key[NDIS_RSS_HASH_SECRET_KEY_MAX_SIZE_REVISION_2];
+    ULONG               KeySize;
+    PROCESSOR_NUMBER    Table[NDIS_RSS_INDIRECTION_TABLE_MAX_SIZE_REVISION_2 / 
sizeof(PROCESSOR_NUMBER)];
+    ULONG               TableCount;
  } XENNET_RSS, *PXENNET_RSS;
struct _XENNET_ADAPTER {
@@ -88,7 +89,7 @@ struct _XENNET_ADAPTER {
NDIS_HANDLE NdisAdapterHandle;
      NDIS_HANDLE                 NdisDmaHandle;
-    NDIS_PNP_CAPABILITIES       Capabilities;
+    NDIS_PM_CAPABILITIES        Capabilities;
      NDIS_OFFLOAD                Offload;
      PROPERTIES                  Properties;
      XENNET_RSS                  Rss;
@@ -108,6 +109,7 @@ static NDIS_OID XennetSupportedOids[] =
      OID_GEN_MEDIA_SUPPORTED,
      OID_GEN_MEDIA_IN_USE,
      OID_GEN_PHYSICAL_MEDIUM,
+    OID_GEN_PHYSICAL_MEDIUM_EX,
      OID_GEN_CURRENT_LOOKAHEAD,
      OID_GEN_MAXIMUM_LOOKAHEAD,
      OID_GEN_MAXIMUM_FRAME_SIZE,
@@ -150,7 +152,7 @@ static NDIS_OID XennetSupportedOids[] =
      OID_802_3_XMIT_MORE_COLLISIONS,
      OID_OFFLOAD_ENCAPSULATION,
      OID_TCP_OFFLOAD_PARAMETERS,
-    OID_PNP_CAPABILITIES,
+    OID_PM_CURRENT_CAPABILITIES,
      OID_PNP_QUERY_POWER,
      OID_PNP_SET_POWER,
      OID_GEN_RECEIVE_SCALE_PARAMETERS,
@@ -721,14 +723,12 @@ AdapterDisableRSSHash(
static NDIS_STATUS
  AdapterUpdateRSSTable(
-    IN  PXENNET_ADAPTER Adapter,
-    IN  PCCHAR          Table,
-    IN  ULONG           TableSize
+    IN  PXENNET_ADAPTER     Adapter,
+    IN  PPROCESSOR_NUMBER   Table,
+    IN  ULONG               TableSize
      )
  {
-    PROCESSOR_NUMBER    
Mapping[NDIS_RSS_INDIRECTION_TABLE_MAX_SIZE_REVISION_1];
-    ULONG               Index;
-    NTSTATUS            status;
+    NTSTATUS                status;
if (TableSize == 0) {
          AdapterDisableRSSHash(Adapter);
@@ -740,18 +740,12 @@ AdapterUpdateRSSTable(
RtlZeroMemory(Adapter->Rss.Table, sizeof (Adapter->Rss.Table)) ;
      RtlCopyMemory(Adapter->Rss.Table, Table, TableSize);
-    Adapter->Rss.TableSize = TableSize;
-
-    RtlZeroMemory(Mapping, sizeof (Mapping));
-    for (Index = 0; Index < TableSize; Index++) {
-        Mapping[Index].Group = 0;
-        Mapping[Index].Number = Table[Index];
-    }
+    Adapter->Rss.TableCount = TableSize / sizeof(PROCESSOR_NUMBER);
status = XENVIF_VIF(UpdateHashMapping,
                          &Adapter->VifInterface,
-                        Mapping,
-                        TableSize);
+                        Table,
+                        Adapter->Rss.TableCount);
return (NT_SUCCESS(status)) ? NDIS_STATUS_SUCCESS : NDIS_STATUS_INVALID_DATA;
  }
@@ -900,12 +894,12 @@ DisplayRss(
          }
      }
- if (Rss->TableSize != 0) {
+    if (Rss->TableCount != 0) {
          ULONG   Index;
Trace("Table:\n"); - for (Index = 0; Index < Rss->TableSize; ) {
+        for (Index = 0; Index < Rss->TableCount; ) {
              CHAR    Buffer[80];
              STRING  String;
              ULONG   Count;
@@ -916,8 +910,8 @@ DisplayRss(
              String.Length = 0;
Count = 8;
-            if (Index + Count >= Rss->TableSize)
-                Count = Rss->TableSize - Index;
+            if (Index + Count >= Rss->TableCount)
+                Count = Rss->TableCount - Index;
(VOID) StringPrintf(&String, "[%2u - %2u]: ",
                                  Index,
@@ -928,8 +922,9 @@ DisplayRss(
              String.Length = 0;
for (Column = 0; Column < Count; Column++, Index++) {
-                (VOID) StringPrintf(&String, "%02x ",
-                                    Rss->Table[Index]);
+                (VOID) StringPrintf(&String, "%02x:%02x ",
+                                    Rss->Table[Index].Group,
+                                    Rss->Table[Index].Number);
String.Buffer += String.Length;
                  String.MaximumLength -= String.Length;
@@ -950,8 +945,8 @@ AdapterGetReceiveScaleParameters(
      NDIS_STATUS                         ndisStatus;
ASSERT3U(Parameters->Header.Type, ==, NDIS_OBJECT_TYPE_RSS_PARAMETERS);
-    ASSERT3U(Parameters->Header.Revision, ==, 
NDIS_RECEIVE_SCALE_PARAMETERS_REVISION_1);
-    ASSERT3U(Parameters->Header.Size, >=, 
NDIS_SIZEOF_RECEIVE_SCALE_PARAMETERS_REVISION_1);
+    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;
@@ -985,7 +980,7 @@ AdapterGetReceiveScaleParameters(
if (!(Parameters->Flags & NDIS_RSS_PARAM_FLAG_ITABLE_UNCHANGED)) {
          ndisStatus = AdapterUpdateRSSTable(Adapter,
-                                           (PCCHAR)Parameters + 
Parameters->IndirectionTableOffset,
+                                           (PPROCESSOR_NUMBER)((PCCHAR)Parameters 
+ Parameters->IndirectionTableOffset),
                                             Parameters->IndirectionTableSize);
          if (ndisStatus != NDIS_STATUS_SUCCESS)
              goto fail;
@@ -2277,7 +2272,7 @@ AdapterQueryInformation(
      ndisStatus = NDIS_STATUS_SUCCESS;
switch (Request->DATA.QUERY_INFORMATION.Oid) {
-    case OID_PNP_CAPABILITIES:
+    case OID_PM_CURRENT_CAPABILITIES:
          BytesNeeded = sizeof(Adapter->Capabilities);
          ndisStatus = __CopyBuffer(Buffer,
                                    BufferLength,
@@ -2926,6 +2921,7 @@ AdapterGetAdvancedSettings(
      READ_PROPERTY(Adapter->Properties.lrov6, L"LROIPv6", 1, Handle);
      READ_PROPERTY(Adapter->Properties.need_csum_value, L"NeedChecksumValue", 
1, Handle);
      READ_PROPERTY(Adapter->Properties.rss, L"*RSS", 1, Handle);
+    READ_PROPERTY(Adapter->Properties.numrssqueues, L"*NumRSSQueues", 8, 
Handle);
NdisCloseConfiguration(Handle); @@ -2949,11 +2945,12 @@ AdapterSetRegistrationAttributes( RtlZeroMemory(&Attribs, sizeof(Attribs));
      Attribs.Header.Type = 
NDIS_OBJECT_TYPE_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES;
-    Attribs.Header.Revision = 
NDIS_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES_REVISION_1;
-    Attribs.Header.Size = 
NDIS_SIZEOF_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES_REVISION_1;
+    Attribs.Header.Revision = 
NDIS_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES_REVISION_2;
+    Attribs.Header.Size = 
NDIS_SIZEOF_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES_REVISION_2;
      Attribs.MiniportAdapterContext = (NDIS_HANDLE)Adapter;
      Attribs.AttributeFlags = NDIS_MINIPORT_ATTRIBUTES_BUS_MASTER |
-                             NDIS_MINIPORT_ATTRIBUTES_NO_HALT_ON_SUSPEND;
+                             NDIS_MINIPORT_ATTRIBUTES_NO_HALT_ON_SUSPEND |
+                             NDIS_MINIPORT_ATTRIBUTES_NDIS_WDM;
      Attribs.CheckForHangTimeInSeconds = 0;
      Attribs.InterfaceType = XENNET_INTERFACE_TYPE;
@@ -2976,8 +2973,8 @@ AdapterSetGeneralAttributes( RtlZeroMemory(&Attribs, sizeof(Attribs));
      Attribs.Header.Type = 
NDIS_OBJECT_TYPE_MINIPORT_ADAPTER_GENERAL_ATTRIBUTES;
-    Attribs.Header.Revision = 
NDIS_MINIPORT_ADAPTER_GENERAL_ATTRIBUTES_REVISION_1;
-    Attribs.Header.Size = 
NDIS_SIZEOF_MINIPORT_ADAPTER_GENERAL_ATTRIBUTES_REVISION_1;
+    Attribs.Header.Revision = 
NDIS_MINIPORT_ADAPTER_GENERAL_ATTRIBUTES_REVISION_2;
+    Attribs.Header.Size = 
NDIS_SIZEOF_MINIPORT_ADAPTER_GENERAL_ATTRIBUTES_REVISION_2;
      Attribs.MediaType = XENNET_MEDIA_TYPE;
XENVIF_VIF(MacQueryMaximumFrameSize,
@@ -2992,7 +2989,7 @@ AdapterSetGeneralAttributes(
      Attribs.MediaConnectState = MediaConnectStateConnected;
      Attribs.MediaDuplexState = MediaDuplexStateFull;
      Attribs.LookaheadSize = Adapter->MaximumFrameSize;
-    Attribs.PowerManagementCapabilities = &Adapter->Capabilities;
+    Attribs.PowerManagementCapabilitiesEx = &Adapter->Capabilities;
      Attribs.MacOptions = XENNET_MAC_OPTIONS;
      Attribs.SupportedPacketFilters = XENNET_SUPPORTED_PACKET_FILTERS;
      Attribs.MaxMulticastListSize = 32;
@@ -3054,8 +3051,8 @@ AdapterSetGeneralAttributes(
RtlZeroMemory(&Rss, sizeof(Rss));
      Rss.Header.Type = NDIS_OBJECT_TYPE_RSS_CAPABILITIES;
-    Rss.Header.Revision = NDIS_RECEIVE_SCALE_CAPABILITIES_REVISION_1;
-    Rss.Header.Size = NDIS_SIZEOF_RECEIVE_SCALE_CAPABILITIES_REVISION_1;
+    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 |
@@ -3073,6 +3070,12 @@ AdapterSetGeneralAttributes(
                 &Rss.NumberOfReceiveQueues);
      Rss.NumberOfInterruptMessages = Rss.NumberOfReceiveQueues;
+ if ((ULONG)Adapter->Properties.numrssqueues < Rss.NumberOfReceiveQueues)
+        Rss.NumberOfReceiveQueues = Adapter->Properties.numrssqueues;
+
+    Rss.NumberOfInterruptMessages = Rss.NumberOfReceiveQueues;
+    Rss.NumberOfIndirectionTableEntries = 128; // WHQL requirement for NDIS 
6.30
+
      Info("%ws: RSS ENABLED (%u QUEUES)\n",
           Adapter->Location,
           Rss.NumberOfReceiveQueues);
diff --git a/vs2015/xennet/xennet.vcxproj b/vs2015/xennet/xennet.vcxproj
index 2d04c4e..b68d734 100644
--- a/vs2015/xennet/xennet.vcxproj
+++ b/vs2015/xennet/xennet.vcxproj
@@ -22,7 +22,7 @@
    </PropertyGroup>
    <ItemDefinitionGroup>
      <ClCompile>
-      
<PreprocessorDefinitions>PROJECT=$(ProjectName);NDIS_MINIPORT_DRIVER;NDIS_WDM=1;NDIS61_MINIPORT=1;POOL_NX_OPTIN=1;NT_PROCESSOR_GROUPS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      
<PreprocessorDefinitions>PROJECT=$(ProjectName);NDIS_MINIPORT_DRIVER;NDIS_WDM=1;NDIS630_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>
diff --git a/vs2017/xennet/xennet.vcxproj b/vs2017/xennet/xennet.vcxproj
index 0c27304..130b0e6 100644
--- a/vs2017/xennet/xennet.vcxproj
+++ b/vs2017/xennet/xennet.vcxproj
@@ -22,7 +22,7 @@
    </PropertyGroup>
    <ItemDefinitionGroup>
      <ClCompile>
-      
<PreprocessorDefinitions>PROJECT=$(ProjectName);NDIS_MINIPORT_DRIVER;NDIS_WDM=1;NDIS61_MINIPORT=1;POOL_NX_OPTIN=1;NT_PROCESSOR_GROUPS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      
<PreprocessorDefinitions>PROJECT=$(ProjectName);NDIS_MINIPORT_DRIVER;NDIS_WDM=1;NDIS630_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>
diff --git a/vs2019/xennet/xennet.vcxproj b/vs2019/xennet/xennet.vcxproj
index d79a691..1ad5601 100644
--- a/vs2019/xennet/xennet.vcxproj
+++ b/vs2019/xennet/xennet.vcxproj
@@ -21,7 +21,7 @@
    </PropertyGroup>
    <ItemDefinitionGroup>
      <ClCompile>
-      
<PreprocessorDefinitions>PROJECT=$(ProjectName);NDIS_MINIPORT_DRIVER;NDIS_WDM=1;NDIS61_MINIPORT=1;POOL_NX_OPTIN=1;NT_PROCESSOR_GROUPS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      
<PreprocessorDefinitions>PROJECT=$(ProjectName);NDIS_MINIPORT_DRIVER;NDIS_WDM=1;NDIS630_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>





 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.