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

[win-pv-devel] [PATCH 08/10] Stear transmitter packets to queues



Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
---
 src/xenvif/transmitter.c | 109 +++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 92 insertions(+), 17 deletions(-)

diff --git a/src/xenvif/transmitter.c b/src/xenvif/transmitter.c
index f1a3e9e..38e9c62 100644
--- a/src/xenvif/transmitter.c
+++ b/src/xenvif/transmitter.c
@@ -3782,6 +3782,96 @@ fail1:
     return status;
 }
 
+static FORCEINLINE ULONG
+__TransmitterGetQueue(
+    IN  PXENVIF_TRANSMITTER             Transmitter,
+    IN  PXENVIF_TRANSMITTER_PACKET_V2   Packet
+    )
+{
+    PXENVIF_FRONTEND    Frontend;
+
+    Frontend = Transmitter->Frontend;
+
+    // simplistic mod of hash value
+    // this should become a lookup operation using a shared table
+    return (ULONG)(Packet->HashValue % FrontendGetQueueCount(Frontend));
+}
+
+static FORCEINLINE PXENVIF_TRANSMITTER_RING
+__TransmitterGetRing(
+    IN  PXENVIF_TRANSMITTER             Transmitter,
+    IN  ULONG                           Index
+    )
+{
+    PLIST_ENTRY     ListEntry;
+
+    ASSERT3U(Index, <, FrontendGetQueueCount(Transmitter->Frontend));
+
+    for (ListEntry = Transmitter->List.Flink;
+         ListEntry != &Transmitter->List;
+         ListEntry = ListEntry->Flink) {
+        PXENVIF_TRANSMITTER_RING    Ring;
+
+        Ring = CONTAINING_RECORD(ListEntry, XENVIF_TRANSMITTER_RING, 
ListEntry);
+        if (Ring->Index != Index)
+            continue;
+
+        return Ring;
+    }
+
+    // return queue-0
+    ListEntry = Transmitter->List.Flink;
+    return CONTAINING_RECORD(ListEntry, XENVIF_TRANSMITTER_RING, ListEntry);
+}
+
+static FORCEINLINE VOID
+__TransmitterQueuePackets(
+    IN  PXENVIF_TRANSMITTER     Transmitter,
+    IN  PLIST_ENTRY             List
+    )
+{
+    PXENVIF_FRONTEND            Frontend;
+    PLIST_ENTRY                 ListEntry;
+    PXENVIF_TRANSMITTER_RING    Ring;
+
+    Frontend = Transmitter->Frontend;
+
+    if (FrontendGetQueueCount(Frontend) == 1) {
+        ListEntry = Transmitter->List.Flink;
+        Ring = CONTAINING_RECORD(ListEntry, XENVIF_TRANSMITTER_RING, 
ListEntry);
+
+        __TransmitterRingQueuePackets(Ring, List);
+    } else {
+        while (!IsListEmpty(List)) {
+            LIST_ENTRY                      SubList;
+            PXENVIF_TRANSMITTER_PACKET_V2   Packet;
+            ULONG                           Queue;
+
+            InitializeListHead(&SubList);
+
+            Packet = CONTAINING_RECORD(List->Flink, 
XENVIF_TRANSMITTER_PACKET_V2, ListEntry);
+            Queue = __TransmitterGetQueue(Transmitter, Packet);
+
+            ListEntry = RemoveHeadList(List);
+            ASSERT3U(ListEntry, !=, List);
+            InsertTailList(&SubList, ListEntry);
+
+            while (!IsListEmpty(List)) {
+                Packet = CONTAINING_RECORD(List->Flink, 
XENVIF_TRANSMITTER_PACKET_V2, ListEntry);
+                if (__TransmitterGetQueue(Transmitter, Packet) != Queue)
+                    break;
+
+                ListEntry = RemoveHeadList(List);
+                ASSERT3U(ListEntry, !=, List);
+                InsertTailList(&SubList, ListEntry);
+            }
+
+            Ring = __TransmitterGetRing(Transmitter, Queue);
+            __TransmitterRingQueuePackets(Ring, &SubList);
+        }
+    }
+}
+
 VOID
 TransmitterQueuePacketsV1(
     IN  PXENVIF_TRANSMITTER             Transmitter,
@@ -3798,8 +3888,6 @@ TransmitterQueuePacketsV1(
          NULL)
 
     LIST_ENTRY                      List;
-    PLIST_ENTRY                     ListEntry;
-    PXENVIF_TRANSMITTER_RING        Ring;
 
     InitializeListHead(&List);
     while (HeadPacket != NULL) {
@@ -3828,12 +3916,7 @@ TransmitterQueuePacketsV1(
         HeadPacket = HeadPacket->Next;
     }
     
-    // We need to hash for a ring eventually. Since there is only a
-    // single ring for now, we just use that.
-    ListEntry = Transmitter->List.Flink;
-    Ring = CONTAINING_RECORD(ListEntry, XENVIF_TRANSMITTER_RING, ListEntry);
-
-    __TransmitterRingQueuePackets(Ring, &List);
+    __TransmitterQueuePackets(Transmitter, &List);
 
     // if HeadPacket != NULL, errors occured and need returning
     if (HeadPacket != NULL) {
@@ -3861,15 +3944,7 @@ TransmitterQueuePacketsV2(
     IN  PLIST_ENTRY         List
     )
 {
-    PLIST_ENTRY             ListEntry;
-    PXENVIF_TRANSMITTER_RING    Ring;
-
-    // We need to hash for a ring eventually. Since there is only a
-    // single ring for now, we just use that.
-    ListEntry = Transmitter->List.Flink;
-    Ring = CONTAINING_RECORD(ListEntry, XENVIF_TRANSMITTER_RING, ListEntry);
-
-    __TransmitterRingQueuePackets(Ring, List);
+    __TransmitterQueuePackets(Transmitter, List);
 }
 
 static BOOLEAN
-- 
1.9.4.msysgit.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®.