[ovs-dev] [PATCH 08/10] datapath-windows: Rename switch context's portHashArray and vport's portLink

Alin Serdean aserdean at cloudbasesolutions.com
Thu Oct 9 00:21:09 UTC 2014


The field portLink of the OVS_VPORT_ENTRY is the link within the
OVS_SWITCH_CONTEXT's hash array of vports portHashArray, hashed by the
portId field of the OVS_VPORT_ENTRY.

Later on, we will need to modify the OVS_VPORT_ENTRY so that its port
numbers are set to maximum MAXUINT16. This will require that the field
vportArray of OVS_SWITCH_CONTEXT be removed and replaced with a hash
array, portNoHashArray. Also, a new field, portNoLink, will need to be
added to OVS_VPORT_ENTRY. In order to differentiate between portHashArray
and portNoHashArray, portHashArray is renamed to portIdHashArray. Also,
in order to differentiate between portLink and portNoLink, portLink
is renamed to portIdLink.

In a future patch the vport functionality will be changed to constraint
the port numbers to MAXUINT16.

Signed-off-by: Samuel Ghinet <sghinet at cloudbasesolutions.com>
Co-authored-by: Alin Gabriel Serdean <aserdean at cloudbasesolutions.com>
---
 datapath-windows/ovsext/Datapath.c |  4 ++--
 datapath-windows/ovsext/Switch.c   | 12 ++++++------
 datapath-windows/ovsext/Switch.h   |  2 +-
 datapath-windows/ovsext/Vport.c    | 10 +++++-----
 datapath-windows/ovsext/Vport.h    |  2 +-
 5 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/datapath-windows/ovsext/Datapath.c b/datapath-windows/ovsext/Datapath.c
index 9725571..f5d08a3 100644
--- a/datapath-windows/ovsext/Datapath.c
+++ b/datapath-windows/ovsext/Datapath.c
@@ -1433,7 +1433,7 @@ OvsGetVportDumpNext(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
 
         for (i = inBucket; i < OVS_MAX_VPORT_ARRAY_SIZE; i++) {
             PLIST_ENTRY head, link;
-            head = &(gOvsSwitchContext->portHashArray[i]);
+            head = &(gOvsSwitchContext->portIdHashArray[i]);
             POVS_VPORT_ENTRY vport = NULL;
 
             outIndex = 0;
@@ -1445,7 +1445,7 @@ OvsGetVportDumpNext(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
                  * inIndex + 1 vport from the bucket.
                 */
                 if (outIndex >= inIndex) {
-                    vport = CONTAINING_RECORD(link, OVS_VPORT_ENTRY, portLink);
+                    vport = CONTAINING_RECORD(link, OVS_VPORT_ENTRY, portIdLink);
 
                     if (vport->portNo != OVS_DPPORT_NUMBER_INVALID) {
                         OvsCreateMsgFromVport(vport, msgIn,
diff --git a/datapath-windows/ovsext/Switch.c b/datapath-windows/ovsext/Switch.c
index d9c7617..7d8aa7a 100644
--- a/datapath-windows/ovsext/Switch.c
+++ b/datapath-windows/ovsext/Switch.c
@@ -358,7 +358,7 @@ OvsInitSwitchContext(POVS_SWITCH_CONTEXT switchContext)
         (PVOID *)OvsAllocateMemory(sizeof (PVOID) * OVS_MAX_VPORT_ARRAY_SIZE);
     switchContext->ovsPortNameHashArray = (PLIST_ENTRY)
          OvsAllocateMemory(sizeof (LIST_ENTRY) * OVS_MAX_VPORT_ARRAY_SIZE);
-    switchContext->portHashArray = (PLIST_ENTRY)
+    switchContext->portIdHashArray= (PLIST_ENTRY)
        OvsAllocateMemory(sizeof (LIST_ENTRY) * OVS_MAX_VPORT_ARRAY_SIZE);
     status = OvsAllocateFlowTable(&switchContext->datapath, switchContext);
 
@@ -369,7 +369,7 @@ OvsInitSwitchContext(POVS_SWITCH_CONTEXT switchContext)
         switchContext->dispatchLock == NULL ||
         switchContext->vportArray == NULL ||
         switchContext->ovsPortNameHashArray == NULL ||
-        switchContext->portHashArray == NULL) {
+        switchContext->portIdHashArray== NULL) {
         if (switchContext->dispatchLock) {
             NdisFreeRWLock(switchContext->dispatchLock);
         }
@@ -379,8 +379,8 @@ OvsInitSwitchContext(POVS_SWITCH_CONTEXT switchContext)
         if (switchContext->ovsPortNameHashArray) {
             OvsFreeMemory(switchContext->ovsPortNameHashArray);
         }
-        if (switchContext->portHashArray) {
-            OvsFreeMemory(switchContext->portHashArray);
+        if (switchContext->portIdHashArray) {
+            OvsFreeMemory(switchContext->portIdHashArray);
         }
         OvsDeleteFlowTable(&switchContext->datapath);
         OvsCleanupBufferPool(switchContext);
@@ -393,7 +393,7 @@ OvsInitSwitchContext(POVS_SWITCH_CONTEXT switchContext)
         InitializeListHead(&switchContext->ovsPortNameHashArray[i]);
     }
     for (i = 0; i < OVS_MAX_VPORT_ARRAY_SIZE; i++) {
-        InitializeListHead(&switchContext->portHashArray[i]);
+        InitializeListHead(&switchContext->portIdHashArray[i]);
     }
     RtlZeroMemory(switchContext->vportArray,
                   sizeof (PVOID) * OVS_MAX_VPORT_ARRAY_SIZE);
@@ -418,7 +418,7 @@ OvsCleanupSwitchContext(POVS_SWITCH_CONTEXT switchContext)
 
     NdisFreeRWLock(switchContext->dispatchLock);
     OvsFreeMemory(switchContext->ovsPortNameHashArray);
-    OvsFreeMemory(switchContext->portHashArray);
+    OvsFreeMemory(switchContext->portIdHashArray);
     OvsFreeMemory(switchContext->vportArray);
     OvsDeleteFlowTable(&switchContext->datapath);
     OvsCleanupBufferPool(switchContext);
diff --git a/datapath-windows/ovsext/Switch.h b/datapath-windows/ovsext/Switch.h
index 697be44..d9761b4 100644
--- a/datapath-windows/ovsext/Switch.h
+++ b/datapath-windows/ovsext/Switch.h
@@ -111,7 +111,7 @@ typedef struct _OVS_SWITCH_CONTEXT
 
     PVOID                  *vportArray;
     PLIST_ENTRY             ovsPortNameHashArray;  // based on ovsName
-    PLIST_ENTRY             portHashArray;  // based on portId
+    PLIST_ENTRY             portIdHashArray;  // based on portId
 
     UINT32                  numPhysicalNics;
     UINT32                  numVports;     // include validation port
diff --git a/datapath-windows/ovsext/Vport.c b/datapath-windows/ovsext/Vport.c
index f61b95f..f5d61f6 100644
--- a/datapath-windows/ovsext/Vport.c
+++ b/datapath-windows/ovsext/Vport.c
@@ -510,9 +510,9 @@ OvsFindVportByPortIdAndNicIndex(POVS_SWITCH_CONTEXT switchContext,
         POVS_VPORT_ENTRY vport;
         UINT32 hash;
         hash = OvsJhashWords((UINT32 *)&portId, 1, OVS_HASH_BASIS);
-        head = &(switchContext->portHashArray[hash & OVS_VPORT_MASK]);
+        head = &(switchContext->portIdHashArray[hash & OVS_VPORT_MASK]);
         LIST_FORALL(head, link) {
-            vport = CONTAINING_RECORD(link, OVS_VPORT_ENTRY, portLink);
+            vport = CONTAINING_RECORD(link, OVS_VPORT_ENTRY, portIdLink);
             if (portId == vport->portId && index == vport->nicIndex) {
                 return vport;
             }
@@ -760,8 +760,8 @@ POVS_VPORT_ENTRY vport)
     InsertHeadList(&switchContext->ovsPortNameHashArray[hash & OVS_VPORT_MASK],
                    &vport->ovsNameLink);
     hash = OvsJhashWords(&vport->portId, 1, OVS_HASH_BASIS);
-    InsertHeadList(&switchContext->portHashArray[hash & OVS_VPORT_MASK],
-                   &vport->portLink);
+    InsertHeadList(&switchContext->portIdHashArray[hash & OVS_VPORT_MASK],
+                   &vport->portIdLink);
     switchContext->numVports++;
     return NDIS_STATUS_SUCCESS;
 }
@@ -804,7 +804,7 @@ OvsRemoveAndDeleteVport(POVS_SWITCH_CONTEXT switchContext,
     }
 
     RemoveEntryList(&vport->ovsNameLink);
-    RemoveEntryList(&vport->portLink);
+    RemoveEntryList(&vport->portIdLink);
     gen = (gen + 1) & 0xff;
     switchContext->vportArray[OVS_VPORT_INDEX(vport->portNo)] =
                      (PVOID)(UINT64)gen;
diff --git a/datapath-windows/ovsext/Vport.h b/datapath-windows/ovsext/Vport.h
index b005cdb..b6d3776 100644
--- a/datapath-windows/ovsext/Vport.h
+++ b/datapath-windows/ovsext/Vport.h
@@ -66,7 +66,7 @@ typedef struct _OVS_VPORT_FULL_STATS {
  */
 typedef struct _OVS_VPORT_ENTRY {
     LIST_ENTRY             ovsNameLink;
-    LIST_ENTRY             portLink;
+    LIST_ENTRY             portIdLink;
 
     OVS_VPORT_STATE        ovsState;
     OVS_VPORT_TYPE         ovsType;
-- 
1.9.4.msysgit.1



More information about the dev mailing list