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

[win-pv-devel] [PATCH 2/2] Dynamic multicast control



Only use the multicast control feature of the backend if it supported
"feature-dynamic-multicast-control" otherwise attempts to enable the 'all
multicast' filter level in XENVIF will have no effect and the NDISTest 6.5
MultiCast Address test will fail.

Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
 src/xenvif/frontend.c    | 41 +++++++++++++++++++++++++++++++
 src/xenvif/frontend.h    |  7 ++++++
 src/xenvif/transmitter.c | 64 +++++++++++++++++++++++++++++++++++++++++++-----
 src/xenvif/transmitter.h |  6 +++++
 src/xenvif/vif.c         |  2 +-
 5 files changed, 113 insertions(+), 7 deletions(-)

diff --git a/src/xenvif/frontend.c b/src/xenvif/frontend.c
index 8f5a492..e513790 100644
--- a/src/xenvif/frontend.c
+++ b/src/xenvif/frontend.c
@@ -1119,6 +1119,47 @@ fail1:
     return status;
 }
 
+NTSTATUS
+FrontendSetFilterLevel(
+    IN  PXENVIF_FRONTEND        Frontend,
+    IN  ETHERNET_ADDRESS_TYPE   Type,
+    IN  XENVIF_MAC_FILTER_LEVEL Level
+    )
+{
+    PXENVIF_MAC                 Mac;
+    KIRQL                       Irql;
+    NTSTATUS                    status;
+
+    Mac = FrontendGetMac(Frontend);
+
+    KeRaiseIrql(DISPATCH_LEVEL, &Irql);
+
+    status = MacSetFilterLevel(Mac, Type, Level);
+    if (!NT_SUCCESS(status))
+        goto fail1;
+
+    if (Type == ETHERNET_ADDRESS_MULTICAST) {
+        PXENVIF_TRANSMITTER Transmitter;
+        BOOLEAN             Enabled;
+
+        Transmitter = FrontendGetTransmitter(Frontend);
+        Enabled = (Level != XENVIF_MAC_FILTER_ALL) ? TRUE : FALSE;
+
+        (VOID) TransmitterRequestMulticastControl(Transmitter, Enabled);
+    }
+
+    KeLowerIrql(Irql);
+
+    return STATUS_SUCCESS;
+
+fail1:
+    Error("fail1 (%08x)\n", status);
+
+    KeLowerIrql(Irql);
+
+    return status;
+}
+
 VOID
 FrontendAdvertiseIpAddresses(
     IN  PXENVIF_FRONTEND    Frontend
diff --git a/src/xenvif/frontend.h b/src/xenvif/frontend.h
index d90f977..9cac412 100644
--- a/src/xenvif/frontend.h
+++ b/src/xenvif/frontend.h
@@ -186,6 +186,13 @@ FrontendSetMulticastAddresses(
     IN  ULONG               Count
     );
 
+extern NTSTATUS
+FrontendSetFilterLevel(
+    IN  PXENVIF_FRONTEND        Frontend,
+    IN  ETHERNET_ADDRESS_TYPE   Type,
+    IN  XENVIF_MAC_FILTER_LEVEL Level
+    );
+
 extern VOID
 FrontendAdvertiseIpAddresses(
     IN  PXENVIF_FRONTEND        Frontend
diff --git a/src/xenvif/transmitter.c b/src/xenvif/transmitter.c
index 7165ecc..5289c6c 100644
--- a/src/xenvif/transmitter.c
+++ b/src/xenvif/transmitter.c
@@ -4312,7 +4312,7 @@ TransmitterConnect(
                           &Transmitter->StoreInterface,
                           NULL,
                           FrontendGetBackendPath(Frontend),
-                          "feature-multicast-control",
+                          "feature-dynamic-multicast-control",
                           &Buffer);
     if (!NT_SUCCESS(status)) {
         Transmitter->MulticastControl = FALSE;
@@ -4409,15 +4409,15 @@ fail1:
     return status;
 }
 
-NTSTATUS
-TransmitterStoreWrite(
+static FORCEINLINE NTSTATUS
+__TransmitterRequestMulticastControl(
     IN  PXENVIF_TRANSMITTER         Transmitter,
-    IN  PXENBUS_STORE_TRANSACTION   Transaction
+    IN  PXENBUS_STORE_TRANSACTION   Transaction,
+    IN  BOOLEAN                     Enabled
     )
 {
     PXENVIF_FRONTEND                Frontend;
     NTSTATUS                        status;
-    LONG                            Index;
 
     Frontend = Transmitter->Frontend;
 
@@ -4427,10 +4427,62 @@ TransmitterStoreWrite(
                           FrontendGetPath(Frontend),
                           "request-multicast-control",
                           "%u",
-                          TRUE);
+                          Enabled);
     if (!NT_SUCCESS(status))
         goto fail1;
 
+    return STATUS_SUCCESS;
+
+fail1:
+    Error("fail1 (%08x)\n", status);
+
+    return status;
+}
+
+NTSTATUS
+TransmitterRequestMulticastControl(
+    IN  PXENVIF_TRANSMITTER Transmitter,
+    IN  BOOLEAN             Enabled
+    )
+{
+    NTSTATUS                status;
+
+    status = STATUS_NOT_SUPPORTED;
+    if (!__TransmitterHasMulticastControl(Transmitter))
+        goto fail1;
+
+    status = __TransmitterRequestMulticastControl(Transmitter, NULL,
+                                                  Enabled);
+    if (!NT_SUCCESS(status))
+        goto fail2;
+
+    return STATUS_SUCCESS;
+
+fail2:
+fail1:
+    return status;
+}
+
+NTSTATUS
+TransmitterStoreWrite(
+    IN  PXENVIF_TRANSMITTER         Transmitter,
+    IN  PXENBUS_STORE_TRANSACTION   Transaction
+    )
+{
+    PXENVIF_FRONTEND                Frontend;
+    NTSTATUS                        status;
+    LONG                            Index;
+
+    Frontend = Transmitter->Frontend;
+
+    if (__TransmitterHasMulticastControl(Transmitter)) {
+        status = __TransmitterRequestMulticastControl(Transmitter,
+                                                      Transaction,
+                                                      TRUE);
+        if (!NT_SUCCESS(status))
+            goto fail1;
+    }
+
     Index = 0;
     while (Index < (LONG)FrontendGetNumQueues(Frontend)) {
         PXENVIF_TRANSMITTER_RING    Ring = Transmitter->Ring[Index];
diff --git a/src/xenvif/transmitter.h b/src/xenvif/transmitter.h
index 3e72b74..5e74667 100644
--- a/src/xenvif/transmitter.h
+++ b/src/xenvif/transmitter.h
@@ -146,4 +146,10 @@ TransmitterHasMulticastControl(
     IN  PXENVIF_TRANSMITTER Transmitter
     );
 
+NTSTATUS
+TransmitterRequestMulticastControl(
+    IN  PXENVIF_TRANSMITTER Transmitter,
+    IN  BOOLEAN             Enabled
+    );
+
 #endif  // _XENVIF_TRANSMITTER_H
diff --git a/src/xenvif/vif.c b/src/xenvif/vif.c
index 74df4ac..ce94a56 100644
--- a/src/xenvif/vif.c
+++ b/src/xenvif/vif.c
@@ -819,7 +819,7 @@ VifMacSetFilterLevel(
 
     AcquireMrswLockShared(&Context->Lock);
 
-    status = MacSetFilterLevel(FrontendGetMac(Context->Frontend), Type, Level);
+    status = FrontendSetFilterLevel(Context->Frontend, Type, Level);
 
     ReleaseMrswLockShared(&Context->Lock);
 
-- 
2.1.1


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel


 


Rackspace

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