Message ID | 20170821214523.17860-1-rams@vmware.com |
---|---|
State | Accepted |
Headers | show |
Acked-by: Anand Kumar <kumaranand@vmware.com> Thanks, Anand Kumar On 8/21/17, 2:45 PM, "ovs-dev-bounces@openvswitch.org on behalf of Shashank Ram" <ovs-dev-bounces@openvswitch.org on behalf of rams@vmware.com> wrote: Moves function OvsCreateNewNBLsFromMultipleNBs() to BufferMgmt.c to facilitate consumption from outside PacketIO.c. Signed-off-by: Shashank Ram <rams@vmware.com> --- datapath-windows/ovsext/BufferMgmt.c | 47 ++++++++++++++++++++++++++++++++++++ datapath-windows/ovsext/BufferMgmt.h | 4 +++ datapath-windows/ovsext/PacketIO.c | 42 -------------------------------- 3 files changed, 51 insertions(+), 42 deletions(-) diff --git a/datapath-windows/ovsext/BufferMgmt.c b/datapath-windows/ovsext/BufferMgmt.c index 1ede4a3..5c9e562 100644 --- a/datapath-windows/ovsext/BufferMgmt.c +++ b/datapath-windows/ovsext/BufferMgmt.c @@ -1783,3 +1783,50 @@ OvsGetCtxSourcePortNo(PNET_BUFFER_LIST nbl, *portNo = ctx->srcPortNo; return NDIS_STATUS_SUCCESS; } + +/* + * -------------------------------------------------------------------------- + * OvsCreateNewNBLsFromMultipleNBs -- + * Creates an NBL chain where each NBL has a single NB, + * from an NBL which has multiple NBs. + * Sets 'curNbl' and 'lastNbl' to the first and last NBL in the + * newly created NBL chain respectively, and completes the original NBL. + * -------------------------------------------------------------------------- + */ +NTSTATUS +OvsCreateNewNBLsFromMultipleNBs(POVS_SWITCH_CONTEXT switchContext, + PNET_BUFFER_LIST *curNbl, + PNET_BUFFER_LIST *lastNbl) +{ + NTSTATUS status = STATUS_SUCCESS; + PNET_BUFFER_LIST newNbls = NULL; + PNET_BUFFER_LIST nbl = NULL; + BOOLEAN error = TRUE; + + do { + /* Create new NBLs from curNbl with multiple net buffers. */ + newNbls = OvsPartialCopyToMultipleNBLs(switchContext, + *curNbl, 0, 0, TRUE); + if (NULL == newNbls) { + OVS_LOG_ERROR("Failed to allocate NBLs with single NB."); + status = NDIS_STATUS_RESOURCES; + break; + } + + nbl = newNbls; + while (nbl) { + *lastNbl = nbl; + nbl = NET_BUFFER_LIST_NEXT_NBL(nbl); + } + + (*curNbl)->Next = NULL; + + OvsCompleteNBL(switchContext, *curNbl, TRUE); + + *curNbl = newNbls; + + error = FALSE; + } while (error); + + return status; +} diff --git a/datapath-windows/ovsext/BufferMgmt.h b/datapath-windows/ovsext/BufferMgmt.h index e6cc0fe..dcf310a 100644 --- a/datapath-windows/ovsext/BufferMgmt.h +++ b/datapath-windows/ovsext/BufferMgmt.h @@ -141,4 +141,8 @@ NDIS_STATUS OvsSetCtxSourcePortNo(PNET_BUFFER_LIST nbl, UINT32 portNo); NDIS_STATUS OvsGetCtxSourcePortNo(PNET_BUFFER_LIST nbl, UINT32 *portNo); +NTSTATUS OvsCreateNewNBLsFromMultipleNBs(PVOID context, + PNET_BUFFER_LIST *curNbl, + PNET_BUFFER_LIST *lastNbl); + #endif /* __BUFFER_MGMT_H_ */ diff --git a/datapath-windows/ovsext/PacketIO.c b/datapath-windows/ovsext/PacketIO.c index 81c574e..38e3e5f 100644 --- a/datapath-windows/ovsext/PacketIO.c +++ b/datapath-windows/ovsext/PacketIO.c @@ -46,10 +46,6 @@ extern NDIS_STRING ovsExtFriendlyNameUC; static VOID OvsFinalizeCompletionList(OvsCompletionList *completionList); static VOID OvsCompleteNBLIngress(POVS_SWITCH_CONTEXT switchContext, PNET_BUFFER_LIST netBufferLists, ULONG sendCompleteFlags); -static NTSTATUS OvsCreateNewNBLsFromMultipleNBs( - POVS_SWITCH_CONTEXT switchContext, - PNET_BUFFER_LIST *curNbl, - PNET_BUFFER_LIST *lastNbl); VOID OvsInitCompletionList(OvsCompletionList *completionList, @@ -500,41 +496,3 @@ OvsExtCancelSendNBL(NDIS_HANDLE filterModuleContext, /* All send requests get completed synchronously, so there is no need to * implement this callback. */ } - -static NTSTATUS -OvsCreateNewNBLsFromMultipleNBs(POVS_SWITCH_CONTEXT switchContext, - PNET_BUFFER_LIST *curNbl, - PNET_BUFFER_LIST *lastNbl) -{ - NTSTATUS status = STATUS_SUCCESS; - PNET_BUFFER_LIST newNbls = NULL; - PNET_BUFFER_LIST nbl = NULL; - BOOLEAN error = TRUE; - - do { - /* Create new NBLs from curNbl with multiple net buffers. */ - newNbls = OvsPartialCopyToMultipleNBLs(switchContext, - *curNbl, 0, 0, TRUE); - if (NULL == newNbls) { - OVS_LOG_ERROR("Failed to allocate NBLs with single NB."); - status = NDIS_STATUS_RESOURCES; - break; - } - - nbl = newNbls; - while (nbl) { - *lastNbl = nbl; - nbl = NET_BUFFER_LIST_NEXT_NBL(nbl); - } - - (*curNbl)->Next = NULL; - - OvsCompleteNBL(switchContext, *curNbl, TRUE); - - *curNbl = newNbls; - - error = FALSE; - } while (error); - - return status; -} -- 2.9.3.windows.2 _______________________________________________ dev mailing list dev@openvswitch.org https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.openvswitch.org_mailman_listinfo_ovs-2Ddev&d=DwICAg&c=uilaK90D4TOVoH58JNXRgQ&r=Q5z9tBe-nAOpE7LIHSPV8uy5-437agMXvkeHHMkR8Us&m=t_wDc_rR7F3izwWXzz2ggoGTVY1ef-5eg6Far3OtVxk&s=Avhf6HHWujbRuxSiVZeev9YkXpvgI3vO_Rry3lpWQTI&e=
Thanks Anand and Shashank! Acked-by: Alin Gabriel Serdean <aserdean@ovn.org> I applied this on branch-2.8 and master. Thanks, Alin. > -----Original Message----- > From: ovs-dev-bounces@openvswitch.org [mailto:ovs-dev- > bounces@openvswitch.org] On Behalf Of Anand Kumar > Sent: Tuesday, August 22, 2017 12:53 AM > To: Shashank Ram <rams@vmware.com>; dev@openvswitch.org > Subject: Re: [ovs-dev] [PATCH] datapath-windows: Move > OvsCreateNewNBLsFromMultipleNBs to BuggerMgmt > > Acked-by: Anand Kumar <kumaranand@vmware.com> > > Thanks, > Anand Kumar > > On 8/21/17, 2:45 PM, "ovs-dev-bounces@openvswitch.org on behalf of > Shashank Ram" <ovs-dev-bounces@openvswitch.org on behalf of > rams@vmware.com> wrote: > > Moves function OvsCreateNewNBLsFromMultipleNBs() to BufferMgmt.c > to facilitate consumption from outside PacketIO.c. > > Signed-off-by: Shashank Ram <rams@vmware.com> > --- > datapath-windows/ovsext/BufferMgmt.c | 47 > ++++++++++++++++++++++++++++++++++++ > datapath-windows/ovsext/BufferMgmt.h | 4 +++ > datapath-windows/ovsext/PacketIO.c | 42 -------------------------------- > 3 files changed, 51 insertions(+), 42 deletions(-) > > diff --git a/datapath-windows/ovsext/BufferMgmt.c b/datapath- > windows/ovsext/BufferMgmt.c > index 1ede4a3..5c9e562 100644 > --- a/datapath-windows/ovsext/BufferMgmt.c > +++ b/datapath-windows/ovsext/BufferMgmt.c > @@ -1783,3 +1783,50 @@ OvsGetCtxSourcePortNo(PNET_BUFFER_LIST > nbl, > *portNo = ctx->srcPortNo; > return NDIS_STATUS_SUCCESS; > } > + > +/* > + * -------------------------------------------------------------------------- > + * OvsCreateNewNBLsFromMultipleNBs -- > + * Creates an NBL chain where each NBL has a single NB, > + * from an NBL which has multiple NBs. > + * Sets 'curNbl' and 'lastNbl' to the first and last NBL in the > + * newly created NBL chain respectively, and completes the original > NBL. > + * -------------------------------------------------------------------------- > + */ > +NTSTATUS > +OvsCreateNewNBLsFromMultipleNBs(POVS_SWITCH_CONTEXT > switchContext, > + PNET_BUFFER_LIST *curNbl, > + PNET_BUFFER_LIST *lastNbl) > +{ > + NTSTATUS status = STATUS_SUCCESS; > + PNET_BUFFER_LIST newNbls = NULL; > + PNET_BUFFER_LIST nbl = NULL; > + BOOLEAN error = TRUE; > + > + do { > + /* Create new NBLs from curNbl with multiple net buffers. */ > + newNbls = OvsPartialCopyToMultipleNBLs(switchContext, > + *curNbl, 0, 0, TRUE); > + if (NULL == newNbls) { > + OVS_LOG_ERROR("Failed to allocate NBLs with single NB."); > + status = NDIS_STATUS_RESOURCES; > + break; > + } > + > + nbl = newNbls; > + while (nbl) { > + *lastNbl = nbl; > + nbl = NET_BUFFER_LIST_NEXT_NBL(nbl); > + } > + > + (*curNbl)->Next = NULL; > + > + OvsCompleteNBL(switchContext, *curNbl, TRUE); > + > + *curNbl = newNbls; > + > + error = FALSE; > + } while (error); > + > + return status; > +} > diff --git a/datapath-windows/ovsext/BufferMgmt.h b/datapath- > windows/ovsext/BufferMgmt.h > index e6cc0fe..dcf310a 100644 > --- a/datapath-windows/ovsext/BufferMgmt.h > +++ b/datapath-windows/ovsext/BufferMgmt.h > @@ -141,4 +141,8 @@ NDIS_STATUS > OvsSetCtxSourcePortNo(PNET_BUFFER_LIST nbl, UINT32 portNo); > > NDIS_STATUS OvsGetCtxSourcePortNo(PNET_BUFFER_LIST nbl, UINT32 > *portNo); > > +NTSTATUS OvsCreateNewNBLsFromMultipleNBs(PVOID context, > + PNET_BUFFER_LIST *curNbl, > + PNET_BUFFER_LIST *lastNbl); > + > #endif /* __BUFFER_MGMT_H_ */ > diff --git a/datapath-windows/ovsext/PacketIO.c b/datapath- > windows/ovsext/PacketIO.c > index 81c574e..38e3e5f 100644 > --- a/datapath-windows/ovsext/PacketIO.c > +++ b/datapath-windows/ovsext/PacketIO.c > @@ -46,10 +46,6 @@ extern NDIS_STRING ovsExtFriendlyNameUC; > static VOID OvsFinalizeCompletionList(OvsCompletionList > *completionList); > static VOID OvsCompleteNBLIngress(POVS_SWITCH_CONTEXT > switchContext, > PNET_BUFFER_LIST netBufferLists, ULONG sendCompleteFlags); > -static NTSTATUS OvsCreateNewNBLsFromMultipleNBs( > - POVS_SWITCH_CONTEXT switchContext, > - PNET_BUFFER_LIST *curNbl, > - PNET_BUFFER_LIST *lastNbl); > > VOID > OvsInitCompletionList(OvsCompletionList *completionList, > @@ -500,41 +496,3 @@ OvsExtCancelSendNBL(NDIS_HANDLE > filterModuleContext, > /* All send requests get completed synchronously, so there is no need > to > * implement this callback. */ > } > - > -static NTSTATUS > -OvsCreateNewNBLsFromMultipleNBs(POVS_SWITCH_CONTEXT > switchContext, > - PNET_BUFFER_LIST *curNbl, > - PNET_BUFFER_LIST *lastNbl) > -{ > - NTSTATUS status = STATUS_SUCCESS; > - PNET_BUFFER_LIST newNbls = NULL; > - PNET_BUFFER_LIST nbl = NULL; > - BOOLEAN error = TRUE; > - > - do { > - /* Create new NBLs from curNbl with multiple net buffers. */ > - newNbls = OvsPartialCopyToMultipleNBLs(switchContext, > - *curNbl, 0, 0, TRUE); > - if (NULL == newNbls) { > - OVS_LOG_ERROR("Failed to allocate NBLs with single NB."); > - status = NDIS_STATUS_RESOURCES; > - break; > - } > - > - nbl = newNbls; > - while (nbl) { > - *lastNbl = nbl; > - nbl = NET_BUFFER_LIST_NEXT_NBL(nbl); > - } > - > - (*curNbl)->Next = NULL; > - > - OvsCompleteNBL(switchContext, *curNbl, TRUE); > - > - *curNbl = newNbls; > - > - error = FALSE; > - } while (error); > - > - return status; > -} > -- > 2.9.3.windows.2 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > https://urldefense.proofpoint.com/v2/url?u=https- > 3A__mail.openvswitch.org_mailman_listinfo_ovs- > 2Ddev&d=DwICAg&c=uilaK90D4TOVoH58JNXRgQ&r=Q5z9tBe- > nAOpE7LIHSPV8uy5- > 437agMXvkeHHMkR8Us&m=t_wDc_rR7F3izwWXzz2ggoGTVY1ef- > 5eg6Far3OtVxk&s=Avhf6HHWujbRuxSiVZeev9YkXpvgI3vO_Rry3lpWQTI&e= > > > > > _______________________________________________ > dev mailing list > dev@openvswitch.org > https://mail.openvswitch.org/mailman/listinfo/ovs-dev
diff --git a/datapath-windows/ovsext/BufferMgmt.c b/datapath-windows/ovsext/BufferMgmt.c index 1ede4a3..5c9e562 100644 --- a/datapath-windows/ovsext/BufferMgmt.c +++ b/datapath-windows/ovsext/BufferMgmt.c @@ -1783,3 +1783,50 @@ OvsGetCtxSourcePortNo(PNET_BUFFER_LIST nbl, *portNo = ctx->srcPortNo; return NDIS_STATUS_SUCCESS; } + +/* + * -------------------------------------------------------------------------- + * OvsCreateNewNBLsFromMultipleNBs -- + * Creates an NBL chain where each NBL has a single NB, + * from an NBL which has multiple NBs. + * Sets 'curNbl' and 'lastNbl' to the first and last NBL in the + * newly created NBL chain respectively, and completes the original NBL. + * -------------------------------------------------------------------------- + */ +NTSTATUS +OvsCreateNewNBLsFromMultipleNBs(POVS_SWITCH_CONTEXT switchContext, + PNET_BUFFER_LIST *curNbl, + PNET_BUFFER_LIST *lastNbl) +{ + NTSTATUS status = STATUS_SUCCESS; + PNET_BUFFER_LIST newNbls = NULL; + PNET_BUFFER_LIST nbl = NULL; + BOOLEAN error = TRUE; + + do { + /* Create new NBLs from curNbl with multiple net buffers. */ + newNbls = OvsPartialCopyToMultipleNBLs(switchContext, + *curNbl, 0, 0, TRUE); + if (NULL == newNbls) { + OVS_LOG_ERROR("Failed to allocate NBLs with single NB."); + status = NDIS_STATUS_RESOURCES; + break; + } + + nbl = newNbls; + while (nbl) { + *lastNbl = nbl; + nbl = NET_BUFFER_LIST_NEXT_NBL(nbl); + } + + (*curNbl)->Next = NULL; + + OvsCompleteNBL(switchContext, *curNbl, TRUE); + + *curNbl = newNbls; + + error = FALSE; + } while (error); + + return status; +} diff --git a/datapath-windows/ovsext/BufferMgmt.h b/datapath-windows/ovsext/BufferMgmt.h index e6cc0fe..dcf310a 100644 --- a/datapath-windows/ovsext/BufferMgmt.h +++ b/datapath-windows/ovsext/BufferMgmt.h @@ -141,4 +141,8 @@ NDIS_STATUS OvsSetCtxSourcePortNo(PNET_BUFFER_LIST nbl, UINT32 portNo); NDIS_STATUS OvsGetCtxSourcePortNo(PNET_BUFFER_LIST nbl, UINT32 *portNo); +NTSTATUS OvsCreateNewNBLsFromMultipleNBs(PVOID context, + PNET_BUFFER_LIST *curNbl, + PNET_BUFFER_LIST *lastNbl); + #endif /* __BUFFER_MGMT_H_ */ diff --git a/datapath-windows/ovsext/PacketIO.c b/datapath-windows/ovsext/PacketIO.c index 81c574e..38e3e5f 100644 --- a/datapath-windows/ovsext/PacketIO.c +++ b/datapath-windows/ovsext/PacketIO.c @@ -46,10 +46,6 @@ extern NDIS_STRING ovsExtFriendlyNameUC; static VOID OvsFinalizeCompletionList(OvsCompletionList *completionList); static VOID OvsCompleteNBLIngress(POVS_SWITCH_CONTEXT switchContext, PNET_BUFFER_LIST netBufferLists, ULONG sendCompleteFlags); -static NTSTATUS OvsCreateNewNBLsFromMultipleNBs( - POVS_SWITCH_CONTEXT switchContext, - PNET_BUFFER_LIST *curNbl, - PNET_BUFFER_LIST *lastNbl); VOID OvsInitCompletionList(OvsCompletionList *completionList, @@ -500,41 +496,3 @@ OvsExtCancelSendNBL(NDIS_HANDLE filterModuleContext, /* All send requests get completed synchronously, so there is no need to * implement this callback. */ } - -static NTSTATUS -OvsCreateNewNBLsFromMultipleNBs(POVS_SWITCH_CONTEXT switchContext, - PNET_BUFFER_LIST *curNbl, - PNET_BUFFER_LIST *lastNbl) -{ - NTSTATUS status = STATUS_SUCCESS; - PNET_BUFFER_LIST newNbls = NULL; - PNET_BUFFER_LIST nbl = NULL; - BOOLEAN error = TRUE; - - do { - /* Create new NBLs from curNbl with multiple net buffers. */ - newNbls = OvsPartialCopyToMultipleNBLs(switchContext, - *curNbl, 0, 0, TRUE); - if (NULL == newNbls) { - OVS_LOG_ERROR("Failed to allocate NBLs with single NB."); - status = NDIS_STATUS_RESOURCES; - break; - } - - nbl = newNbls; - while (nbl) { - *lastNbl = nbl; - nbl = NET_BUFFER_LIST_NEXT_NBL(nbl); - } - - (*curNbl)->Next = NULL; - - OvsCompleteNBL(switchContext, *curNbl, TRUE); - - *curNbl = newNbls; - - error = FALSE; - } while (error); - - return status; -}
Moves function OvsCreateNewNBLsFromMultipleNBs() to BufferMgmt.c to facilitate consumption from outside PacketIO.c. Signed-off-by: Shashank Ram <rams@vmware.com> --- datapath-windows/ovsext/BufferMgmt.c | 47 ++++++++++++++++++++++++++++++++++++ datapath-windows/ovsext/BufferMgmt.h | 4 +++ datapath-windows/ovsext/PacketIO.c | 42 -------------------------------- 3 files changed, 51 insertions(+), 42 deletions(-) -- 2.9.3.windows.2