Reviewed-by: Jiaxin Wu <[email protected]>
> -----Original Message----- > From: Zhang, Lubo > Sent: Friday, April 29, 2016 10:09 AM > To: Fu, Siyuan <[email protected]>; [email protected] > Cc: Ye, Ting <[email protected]>; Wu, Jiaxin <[email protected]> > Subject: RE: [edk2] [patch] Nt32Pkg: Fix SnpNt32 GetStatus bug > > A good comment to me, I will change it at the commit time, thanks > > -----Original Message----- > From: Fu, Siyuan > Sent: Friday, April 29, 2016 10:04 AM > To: Zhang, Lubo <[email protected]>; [email protected] > Cc: Ye, Ting <[email protected]>; Wu, Jiaxin <[email protected]> > Subject: RE: [edk2] [patch] Nt32Pkg: Fix SnpNt32 GetStatus bug > > Hi, Lubo > > The allocate memory in SnpNt32InitializeGlobalData is better to use > AllocatePool (sizeof (UINT64) * This->MaxRecycledTxBuf); to avoid > possible macro value update in future. > Other parts are good to me. > > > Reviewed-by: Fu Siyuan <[email protected]> > > > > > > -----Original Message----- > > From: edk2-devel [mailto:[email protected]] On Behalf Of > > Zhang Lubo > > Sent: Friday, April 29, 2016 9:50 AM > > To: [email protected] > > Cc: Ye, Ting <[email protected]>; Fu, Siyuan <[email protected]>; > > Wu, Jiaxin <[email protected]> > > Subject: [edk2] [patch] Nt32Pkg: Fix SnpNt32 GetStatus bug > > > > According to UEFI spec, the Snp.GetStatus should return the recycled > > transmit buffer address, while the NT32 SNP always return value 1 for > > the Txbuffer. > > > > Cc: Fu Siyuan <[email protected]> > > Cc: Ye Ting <[email protected]> > > Cc: Wu Jiaxin <[email protected]> > > Contributed-under: TianoCore Contribution Agreement 1.0 > > Signed-off-by: Zhang Lubo <[email protected]> > > --- > > Nt32Pkg/SnpNt32Dxe/SnpNt32.c | 42 > > ++++++++++++++++++++++++++++++++++++++++-- > > Nt32Pkg/SnpNt32Dxe/SnpNt32.h | 22 +++++++++++++++++++++- > > 2 files changed, 61 insertions(+), 3 deletions(-) > > > > diff --git a/Nt32Pkg/SnpNt32Dxe/SnpNt32.c > > b/Nt32Pkg/SnpNt32Dxe/SnpNt32.c index 4dee182..6d22c2f 100644 > > --- a/Nt32Pkg/SnpNt32Dxe/SnpNt32.c > > +++ b/Nt32Pkg/SnpNt32Dxe/SnpNt32.c > > @@ -1,8 +1,8 @@ > > /** @file > > > > -Copyright (c) 2006 - 2013, Intel Corporation. All rights > > reserved.<BR> > > +Copyright (c) 2006 - 2016, Intel Corporation. All rights > > +reserved.<BR> > > This program and the accompanying materials are licensed and made > > available under the terms and conditions of the BSD License which > > accompanies this distribution. The full text of the license may be > > found at http://opensource.org/licenses/bsd-license.php > > > > @@ -42,10 +42,13 @@ SNPNT32_GLOBAL_DATA gSnpNt32GlobalData > = { > > { > > 0, > > 0, > > EfiLockUninitialized > > }, // Lock > > + NULL, // RecycledTxBuf > > + 0, // RecycledTxBufCount > > + 32, // MaxRecycledTxBuf > > // > > // Private functions > > // > > SnpNt32InitializeGlobalData, // InitializeGlobalData > > SnpNt32InitializeInstanceData, // InitializeInstanceData > > @@ -859,13 +862,24 @@ SnpNt32GetStatus ( > > IN EFI_SIMPLE_NETWORK_PROTOCOL *This, > > OUT UINT32 *InterruptStatus, > > OUT VOID **TxBuffer > > ) > > { > > + SNPNT32_INSTANCE_DATA *Instance; > > + SNPNT32_GLOBAL_DATA *GlobalData; > > + > > + Instance = SNP_NT32_INSTANCE_DATA_FROM_SNP_THIS (This); > > + > > + GlobalData = Instance->GlobalData; > > > > if (TxBuffer != NULL) { > > - *((UINT8 **) TxBuffer) = (UINT8 *)(UINTN) 1; > > + if (GlobalData->RecycledTxBufCount != 0) { > > + GlobalData->RecycledTxBufCount --; > > + *((UINT8 **) TxBuffer) = (UINT8 *) (UINTN)GlobalData- > > >RecycledTxBuf[GlobalData->RecycledTxBufCount]; > > + } else { > > + *((UINT8 **) TxBuffer) = NULL; > > + } > > } > > > > if (InterruptStatus != NULL) { > > *InterruptStatus = EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT; > > } > > @@ -916,10 +930,11 @@ SnpNt32Transmit ( > > ) > > { > > SNPNT32_INSTANCE_DATA *Instance; > > SNPNT32_GLOBAL_DATA *GlobalData; > > INT32 ReturnValue; > > + UINT64 *Tmp; > > > > Instance = SNP_NT32_INSTANCE_DATA_FROM_SNP_THIS (This); > > > > GlobalData = Instance->GlobalData; > > > > @@ -943,10 +958,28 @@ SnpNt32Transmit ( > > > > EfiReleaseLock (&GlobalData->Lock); > > > > if (ReturnValue < 0) { > > return EFI_DEVICE_ERROR; > > + } else { > > + if ((GlobalData->MaxRecycledTxBuf + > > SNP_TX_BUFFER_INCREASEMENT) >= SNP_MAX_TX_BUFFER_NUM) { > > + return EFI_NOT_READY; > > + } > > + > > + if (GlobalData->RecycledTxBufCount < GlobalData->MaxRecycledTxBuf) > { > > + GlobalData->RecycledTxBuf[GlobalData->RecycledTxBufCount] = > > + (UINT64) > > Buffer; > > + GlobalData->RecycledTxBufCount ++; > > + } else { > > + Tmp = AllocatePool (sizeof (UINT64) * > > + (GlobalData->MaxRecycledTxBuf + > > SNP_TX_BUFFER_INCREASEMENT)); > > + if (Tmp == NULL) { > > + return EFI_DEVICE_ERROR; > > + } > > + CopyMem (Tmp, GlobalData->RecycledTxBuf, sizeof (UINT64) * > > GlobalData->RecycledTxBufCount); > > + FreePool (GlobalData->RecycledTxBuf); > > + GlobalData->RecycledTxBuf = Tmp; > > + GlobalData->MaxRecycledTxBuf += SNP_TX_BUFFER_INCREASEMENT; > > + } > > } > > > > return EFI_SUCCESS; > > } > > > > @@ -1081,10 +1114,15 @@ SnpNt32InitializeGlobalData ( > > InterfaceCount = MAX_INTERFACE_INFO_NUMBER; > > > > InitializeListHead (&This->InstanceList); > > EfiInitializeLock (&This->Lock, TPL_CALLBACK); > > > > + This->RecycledTxBuf = AllocatePool (sizeof (UINT64) * > > MAX_XMIT_BUFFERS); > > + if (This->RecycledTxBuf == NULL) { > > + return EFI_OUT_OF_RESOURCES; > > + } > > + > > // > > // Get the WinNT thunk > > // > > Status = gBS->LocateProtocol (&gEfiWinNtThunkProtocolGuid, NULL, > > (VOID **)&This->WinNtThunk); > > > > diff --git a/Nt32Pkg/SnpNt32Dxe/SnpNt32.h > > b/Nt32Pkg/SnpNt32Dxe/SnpNt32.h index 07f6129..cb95c57 100644 > > --- a/Nt32Pkg/SnpNt32Dxe/SnpNt32.h > > +++ b/Nt32Pkg/SnpNt32Dxe/SnpNt32.h > > @@ -1,8 +1,8 @@ > > /** @file > > > > -Copyright (c) 2006 - 2007, Intel Corporation. All rights > > reserved.<BR> > > +Copyright (c) 2006 - 2016, Intel Corporation. All rights > > +reserved.<BR> > > This program and the accompanying materials are licensed and made > > available under the terms and conditions of the BSD License which > > accompanies this distribution. The full text of the license may be > > found at http://opensource.org/licenses/bsd-license.php > > > > @@ -56,10 +56,16 @@ typedef struct _NT_NET_INTERFACE_INFO { > > #define NET_ETHER_HEADER_SIZE 14 > > > > #define MAX_INTERFACE_INFO_NUMBER 16 > > #define MAX_FILE_NAME_LENGTH 280 > > > > +#define SNP_MAX_TX_BUFFER_NUM 65536 > > +#define SNP_TX_BUFFER_INCREASEMENT 32 > > + > > + > > + > > + > > // > > // Functions in Net Library > > // > > typedef > > INT32 > > @@ -153,10 +159,24 @@ struct _SNPNT32_GLOBAL_DATA { > > NT_NET_UTILITY_TABLE NtNetUtilityTable; > > > > EFI_LOCK Lock; > > > > // > > + // Array of the recycled transmit buffer address. > > + // > > + UINT64 *RecycledTxBuf; > > + > > + // > > + // Current number of recycled buffer pointers in RecycledTxBuf. > > + // > > + UINT32 RecycledTxBufCount; > > + > > + // The maximum number of recycled buffer pointers in RecycledTxBuf. > > + // > > + UINT32 MaxRecycledTxBuf; > > + > > + // > > // Private functions > > // > > SNPNT32_INITIALIZE_GLOBAL_DATA InitializeGlobalData; > > SNPNT32_INITIALIZE_INSTANCE_DATA InitializeInstanceData; > > SNPNT32_CLOSE_INSTANCE CloseInstance; > > -- > > 1.9.5.msysgit.1 > > > > _______________________________________________ > > edk2-devel mailing list > > [email protected] > > https://lists.01.org/mailman/listinfo/edk2-devel _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

