]> xenbits.xensource.com Git - pvdrivers/win/xenvif.git/commitdiff
Allow advertised 'wire' speed to be overridden by a registry value...
authorPaul Durrant <paul.durrant@citrix.com>
Fri, 2 Nov 2018 17:16:58 +0000 (17:16 +0000)
committerPaul Durrant <paul.durrant@citrix.com>
Tue, 6 Nov 2018 09:40:35 +0000 (09:40 +0000)
...and change the default to 100G.

This patch adds code to check for a new 'MacSpeed' XENVIF parameter
(sampled at initialization time), defaulting to a wire speed of 100G if
it is not present (rather than the 1G default prior to this patch).

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
src/xenvif/mac.c

index 06a9a18b2aeedf20999c1fec21525e2556a194ca..0b17a54d2d72f47e607e5c5f44533f9082a5ef16 100644 (file)
@@ -35,6 +35,7 @@
 #include <ethernet.h>
 
 #include "pdo.h"
+#include "registry.h"
 #include "frontend.h"
 #include "mac.h"
 #include "thread.h"
@@ -52,6 +53,7 @@ struct _XENVIF_MAC {
     EX_SPIN_LOCK            Lock;
     BOOLEAN                 Connected;
     BOOLEAN                 Enabled;
+    ULONG                   Speed;
     ULONG                   MaximumFrameSize;
     ETHERNET_ADDRESS        PermanentAddress;
     ETHERNET_ADDRESS        CurrentAddress;
@@ -207,6 +209,8 @@ MacInitialize(
     OUT PXENVIF_MAC         *Mac
     )
 {
+    HANDLE                  ParametersKey;
+    ULONG                   MacSpeed;
     NTSTATUS                status;
 
     *Mac = __MacAllocate(sizeof (XENVIF_MAC));
@@ -215,6 +219,18 @@ MacInitialize(
     if (*Mac == NULL)
         goto fail1;
 
+    ParametersKey = DriverGetParametersKey();
+
+    (*Mac)->Speed = 100;
+
+    if (ParametersKey != NULL) {
+        status = RegistryQueryDwordValue(ParametersKey,
+                                         "MacSpeed",
+                                        &MacSpeed);
+        if (NT_SUCCESS(status))
+            (*Mac)->Speed = MacSpeed;
+    }
+
     InitializeListHead(&(*Mac)->MulticastList);
 
     FdoGetDebugInterface(PdoGetFdo(FrontendGetPdo(Frontend)),
@@ -667,6 +683,8 @@ MacTeardown(
 
     Mac->Lock = 0;
 
+    Mac->Speed = 0;
+
     ASSERT(IsZeroMemory(Mac, sizeof (XENVIF_MAC)));
     __MacFree(Mac);
 }
@@ -691,7 +709,7 @@ __MacGetSpeed(
                           "speed",
                           &Buffer);
     if (!NT_SUCCESS(status)) {
-        Speed = 1;
+        Speed = Mac->Speed;
         Unit = "G";
     } else {
         Speed = _strtoui64(Buffer, &Unit, 10);