Skip to content

Commit

Permalink
datapath-windows: Rename switch context's portHashArray and vport's p…
Browse files Browse the repository at this point in the history
…ortLink

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 <[email protected]>
Co-authored-by: Alin Gabriel Serdean <[email protected]>
Acked-by: Ankur Sharma <[email protected]>
Acked-by: Eitan Eliahu <[email protected]>
Acked-by: Nithin Raju <[email protected]>
Tested-by: Nithin Raju <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
Alin Serdean authored and blp committed Oct 9, 2014
1 parent 147c91d commit 91c261c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions datapath-windows/ovsext/Datapath.c
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,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;
Expand All @@ -1488,7 +1488,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,
Expand Down
12 changes: 6 additions & 6 deletions datapath-windows/ovsext/Switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
}
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion datapath-windows/ovsext/Switch.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions datapath-windows/ovsext/Vport.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,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;
}
Expand Down Expand Up @@ -762,8 +762,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;
}
Expand Down Expand Up @@ -806,7 +806,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;
Expand Down
2 changes: 1 addition & 1 deletion datapath-windows/ovsext/Vport.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 91c261c

Please sign in to comment.