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

[win-pv-devel] [PATCH 1/3] Move check for split event channels into Frontend module



Reduce code duplication and efficiency a little by checking the xenstore
key once in Frontend and then providing a function with Transmitter and
Receiver can use to grab the value.

Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
 src/xenvif/frontend.c    | 49 +++++++++++++++++++++++++++++++++++++++++++++++-
 src/xenvif/frontend.h    |  5 +++++
 src/xenvif/receiver.c    | 20 ++------------------
 src/xenvif/transmitter.c | 36 +++++++++++++++--------------------
 4 files changed, 70 insertions(+), 40 deletions(-)

diff --git a/src/xenvif/frontend.c b/src/xenvif/frontend.c
index 98efee5..b066d0b 100644
--- a/src/xenvif/frontend.c
+++ b/src/xenvif/frontend.c
@@ -70,6 +70,7 @@ struct _XENVIF_FRONTEND {
     USHORT                      BackendDomain;
     ULONG                       MaxQueues;
     ULONG                       NumQueues;
+    BOOLEAN                     Split;
 
     PXENVIF_MAC                 Mac;
     PXENVIF_RECEIVER            Receiver;
@@ -1674,7 +1675,8 @@ FrontendSetNumQueues(
         BackendMaxQueues = 1;
     }
 
-    Frontend->NumQueues = __min(Frontend->MaxQueues, BackendMaxQueues);
+    Frontend->NumQueues = __min(__FrontendGetMaxQueues(Frontend),
+                                BackendMaxQueues);
 
     Info("%s: %u\n", __FrontendGetPath(Frontend), Frontend->NumQueues);
 }
@@ -1695,6 +1697,50 @@ FrontendGetNumQueues(
     return __FrontendGetNumQueues(Frontend);
 }
 
+static VOID
+FrontendSetSplit(
+    IN  PXENVIF_FRONTEND    Frontend
+    )
+{
+    PCHAR                   Buffer;
+    NTSTATUS                status;
+
+    status = XENBUS_STORE(Read,
+                          &Frontend->StoreInterface,
+                          NULL,
+                          __FrontendGetBackendPath(Frontend),
+                          "feature-split-event-channels",
+                          &Buffer);
+    if (NT_SUCCESS(status)) {
+        Frontend->Split = (BOOLEAN)strtol(Buffer, NULL, 2);
+
+        XENBUS_STORE(Free,
+                     &Frontend->StoreInterface,
+                     Buffer);
+    } else {
+        Frontend->Split = FALSE;
+    }
+
+    Info("%s: %s\n", __FrontendGetPath(Frontend),
+         (Frontend->Split) ? "TRUE" : "FALSE");
+}
+
+static FORCEINLINE BOOLEAN
+__FrontendIsSplit(
+    IN  PXENVIF_FRONTEND    Frontend
+    )
+{
+    return Frontend->Split;
+}
+
+BOOLEAN
+FrontendIsSplit(
+    IN  PXENVIF_FRONTEND    Frontend
+    )
+{
+    return __FrontendIsSplit(Frontend);
+}
+
 static NTSTATUS
 FrontendConnect(
     IN  PXENVIF_FRONTEND    Frontend
@@ -1731,6 +1777,7 @@ FrontendConnect(
         goto fail4;
 
     FrontendSetNumQueues(Frontend);
+    FrontendSetSplit(Frontend);
 
     status = ReceiverConnect(__FrontendGetReceiver(Frontend));
     if (!NT_SUCCESS(status))
diff --git a/src/xenvif/frontend.h b/src/xenvif/frontend.h
index bd39767..eda9e3d 100644
--- a/src/xenvif/frontend.h
+++ b/src/xenvif/frontend.h
@@ -122,6 +122,11 @@ FrontendGetNumQueues(
     IN  PXENVIF_FRONTEND    Frontend
     );
 
+extern BOOLEAN
+FrontendIsSplit(
+    IN  PXENVIF_FRONTEND    Frontend
+    );
+
 extern PCHAR
 FrontendFormatPath(
     IN  PXENVIF_FRONTEND    Frontend,
diff --git a/src/xenvif/receiver.c b/src/xenvif/receiver.c
index c6f64b5..36557b7 100644
--- a/src/xenvif/receiver.c
+++ b/src/xenvif/receiver.c
@@ -2859,7 +2859,6 @@ ReceiverConnect(
 {
     PXENVIF_FRONTEND        Frontend;
     LONG                    Index;
-    PCHAR                   Buffer;
     NTSTATUS                status;
 
     Trace("====>\n");
@@ -2886,21 +2885,7 @@ ReceiverConnect(
     if (!NT_SUCCESS(status))
         goto fail5;
 
-    status = XENBUS_STORE(Read,
-                          &Receiver->StoreInterface,
-                          NULL,
-                          FrontendGetBackendPath(Frontend),
-                          "feature-split-event-channels",
-                          &Buffer);
-    if (!NT_SUCCESS(status)) {
-        Receiver->Split = FALSE;
-    } else {
-        Receiver->Split = (BOOLEAN)strtol(Buffer, NULL, 2);
-
-        XENBUS_STORE(Free,
-                     &Receiver->StoreInterface,
-                     Buffer);
-    }
+    Receiver->Split = FrontendIsSplit(Frontend);
 
     Receiver->NumQueues = FrontendGetNumQueues(Frontend);
     ASSERT3U(Receiver->NumQueues, <=, Receiver->MaxQueues);
@@ -3211,8 +3196,6 @@ ReceiverDisconnect(
 
     Frontend = Receiver->Frontend;
 
-    Receiver->Split = FALSE;
-
     XENBUS_DEBUG(Deregister,
                  &Receiver->DebugInterface,
                  Receiver->DebugCallback);
@@ -3226,6 +3209,7 @@ ReceiverDisconnect(
     }
 
     Receiver->NumQueues = 0;
+    Receiver->Split = FALSE;
 
     XENBUS_GNTTAB(Release, &Receiver->GnttabInterface);
 
diff --git a/src/xenvif/transmitter.c b/src/xenvif/transmitter.c
index 5f84eb5..615d2d0 100644
--- a/src/xenvif/transmitter.c
+++ b/src/xenvif/transmitter.c
@@ -710,6 +710,15 @@ TransmitterRingDebugCallback(
                  Ring->PacketsUnprepared,
                  Ring->PacketsSent,
                  Ring->PacketsCompleted);
+
+    if (Transmitter->Split) {
+        // Dump event channel
+        XENBUS_DEBUG(Printf,
+                     &Transmitter->DebugInterface,
+                     "Events = %lu Dpcs = %lu\n",
+                     Ring->Events,
+                     Ring->Dpcs);
+    }
 }
 
 static BOOLEAN
@@ -3618,8 +3627,6 @@ __TransmitterRingDisconnect(
     Transmitter = Ring->Transmitter;
     Frontend = Transmitter->Frontend;
 
-    Transmitter->Split = FALSE;
-
     if (Ring->Channel != NULL) {
         XENBUS_EVTCHN(Close,
                       &Transmitter->EvtchnInterface,
@@ -4189,22 +4196,6 @@ TransmitterConnect(
                           &Transmitter->StoreInterface,
                           NULL,
                           FrontendGetBackendPath(Frontend),
-                          "feature-split-event-channels",
-                          &Buffer);
-    if (!NT_SUCCESS(status)) {
-        Transmitter->Split = FALSE;
-    } else {
-        Transmitter->Split = (BOOLEAN)strtol(Buffer, NULL, 2);
-
-        XENBUS_STORE(Free,
-                     &Transmitter->StoreInterface,
-                     Buffer);
-    }
-
-    status = XENBUS_STORE(Read,
-                          &Transmitter->StoreInterface,
-                          NULL,
-                          FrontendGetBackendPath(Frontend),
                           "feature-multicast-control",
                           &Buffer);
     if (!NT_SUCCESS(status)) {
@@ -4217,6 +4208,8 @@ TransmitterConnect(
                      Buffer);
     }
 
+    Transmitter->Split = FrontendIsSplit(Frontend);
+
     Transmitter->NumQueues = FrontendGetNumQueues(Frontend);
     ASSERT3U(Transmitter->NumQueues, <=, Transmitter->MaxQueues);
 
@@ -4260,6 +4253,8 @@ fail9:
     }
 
     Transmitter->NumQueues = 0;
+    Transmitter->Split = FALSE;
+    Transmitter->MulticastControl = FALSE;
 
     XENBUS_CACHE(Destroy,
                  &Transmitter->CacheInterface,
@@ -4401,9 +4396,6 @@ TransmitterDisconnect(
 
     Frontend = Transmitter->Frontend;
 
-    Transmitter->MulticastControl = FALSE;
-    Transmitter->Split = FALSE;
-
     XENBUS_DEBUG(Deregister,
                  &Transmitter->DebugInterface,
                  Transmitter->DebugCallback);
@@ -4417,6 +4409,8 @@ TransmitterDisconnect(
     }
 
     Transmitter->NumQueues = 0;
+    Transmitter->MulticastControl = FALSE;
+    Transmitter->Split = FALSE;
 
     XENBUS_CACHE(Destroy,
                  &Transmitter->CacheInterface,
-- 
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®.