[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH xennet 2/2] Update to XENVIF_VIF_INTERFACE version 10
From: Paul Durrant <pdurrant@xxxxxxxxxx> This based on an original patch [1] by Martin Harvey at Citrix. The new Pause flag added to the XENVIF_RECEIVER_QUEUE_PACKET callback parameters is used when 'low resources' is indicated to NDIS to request that XENVIF stops queueing packets for a short period of time (i.e. the time taked to re-schedule the DPC). [1] https://lists.xenproject.org/archives/html/win-pv-devel/2022-05/msg00044.html Signed-off-by: Paul Durrant <pdurrant@xxxxxxxxxx> --- Cc: Martin Harvey <Martin.Harvey@xxxxxxxxxx> include/vif_interface.h | 80 ++++++++++++++++++++++++++++++++++++++--- src/xennet.inf | 6 ++-- src/xennet/adapter.c | 3 +- src/xennet/receiver.c | 22 +++++++++--- src/xennet/receiver.h | 3 +- 5 files changed, 99 insertions(+), 15 deletions(-) diff --git a/include/vif_interface.h b/include/vif_interface.h index c157c5ca798e..a600d35e8f23 100644 --- a/include/vif_interface.h +++ b/include/vif_interface.h @@ -388,7 +388,27 @@ typedef enum _XENVIF_VIF_CALLBACK_TYPE { XENVIF_MAC_STATE_CHANGE } XENVIF_VIF_CALLBACK_TYPE, *PXENVIF_VIF_CALLBACK_TYPE; -/*! \typedef XENVIF_VIF_CALLBACK_PARAMETERS_V9 +union _XENVIF_VIF_CALLBACK_PARAMETERS_V9 { + struct { + PVOID Cookie; + PXENVIF_TRANSMITTER_PACKET_COMPLETION_INFO Completion; + } TransmitterReturnPacket; + struct { + ULONG Index; + PMDL Mdl; + ULONG Offset; + ULONG Length; + XENVIF_PACKET_CHECKSUM_FLAGS Flags; + USHORT MaximumSegmentSize; + USHORT TagControlInformation; + PXENVIF_PACKET_INFO Info; + PXENVIF_PACKET_HASH Hash; + BOOLEAN More; + PVOID Cookie; + } ReceiverQueuePacket; +}; + +/*! \typedef XENVIF_VIF_CALLBACK_PARAMETERS_V10 \brief VIF interface version 9 parameters for provider to subscriber callback function \b XENVIF_TRANSMITTER_RETURN_PACKET: @@ -407,11 +427,12 @@ typedef enum _XENVIF_VIF_CALLBACK_TYPE { \param Hash Hash information for the packet \param More A flag to indicate whether more packets will be queued for the same CPU \param Cookie Cookie that should be passed to XENVIF_RECEIVER_RETURN_PACKET method + \param Pause A flag to request that no more packets be queued for a short period of time \b XENVIF_MAC_STATE_CHANGE: No additional arguments */ -union _XENVIF_VIF_CALLBACK_PARAMETERS_V9 { +union _XENVIF_VIF_CALLBACK_PARAMETERS_V10 { struct { PVOID Cookie; PXENVIF_TRANSMITTER_PACKET_COMPLETION_INFO Completion; @@ -428,6 +449,7 @@ union _XENVIF_VIF_CALLBACK_PARAMETERS_V9 { PXENVIF_PACKET_HASH Hash; BOOLEAN More; PVOID Cookie; + BOOLEAN Pause; } ReceiverQueuePacket; }; @@ -458,7 +480,14 @@ typedef VOID ... ); -typedef union _XENVIF_VIF_CALLBACK_PARAMETERS_V9 XENVIF_VIF_CALLBACK_PARAMETERS, *PXENVIF_VIF_CALLBACK_PARAMETERS; +typedef VOID +(*XENVIF_VIF_CALLBACK_V9)( + IN PVOID Argument OPTIONAL, + IN XENVIF_VIF_CALLBACK_TYPE Type, + IN union _XENVIF_VIF_CALLBACK_PARAMETERS_V9 *Parameters + ); + +typedef union _XENVIF_VIF_CALLBACK_PARAMETERS_V10 XENVIF_VIF_CALLBACK_PARAMETERS, *PXENVIF_VIF_CALLBACK_PARAMETERS; /*! \typedef XENVIF_VIF_CALLBACK \brief Provider to subscriber callback function @@ -481,6 +510,13 @@ typedef NTSTATUS IN PVOID Argument OPTIONAL ); +typedef NTSTATUS +(*XENVIF_VIF_ENABLE_V9)( + IN PINTERFACE Interface, + IN XENVIF_VIF_CALLBACK_V9 Callback, + IN PVOID Argument OPTIONAL + ); + /*! \typedef XENVIF_VIF_ENABLE \brief Enable the VIF interface @@ -891,6 +927,40 @@ struct _XENVIF_VIF_INTERFACE_V8 { \ingroup interfaces */ struct _XENVIF_VIF_INTERFACE_V9 { + INTERFACE Interface; + XENVIF_VIF_ACQUIRE Acquire; + XENVIF_VIF_RELEASE Release; + XENVIF_VIF_ENABLE_V9 EnableVersion9; + XENVIF_VIF_DISABLE Disable; + XENVIF_VIF_QUERY_STATISTIC QueryStatistic; + XENVIF_VIF_QUERY_RING_COUNT QueryRingCount; + XENVIF_VIF_UPDATE_HASH_MAPPING UpdateHashMapping; + XENVIF_VIF_RECEIVER_RETURN_PACKET ReceiverReturnPacket; + XENVIF_VIF_RECEIVER_SET_OFFLOAD_OPTIONS ReceiverSetOffloadOptions; + XENVIF_VIF_RECEIVER_SET_BACKFILL_SIZE ReceiverSetBackfillSize; + XENVIF_VIF_RECEIVER_QUERY_RING_SIZE ReceiverQueryRingSize; + XENVIF_VIF_RECEIVER_SET_HASH_ALGORITHM ReceiverSetHashAlgorithm; + XENVIF_VIF_RECEIVER_QUERY_HASH_CAPABILITIES ReceiverQueryHashCapabilities; + XENVIF_VIF_RECEIVER_UPDATE_HASH_PARAMETERS ReceiverUpdateHashParameters; + XENVIF_VIF_TRANSMITTER_QUEUE_PACKET TransmitterQueuePacket; + XENVIF_VIF_TRANSMITTER_QUERY_OFFLOAD_OPTIONS TransmitterQueryOffloadOptions; + XENVIF_VIF_TRANSMITTER_QUERY_LARGE_PACKET_SIZE TransmitterQueryLargePacketSize; + XENVIF_VIF_TRANSMITTER_QUERY_RING_SIZE TransmitterQueryRingSize; + XENVIF_VIF_MAC_QUERY_STATE MacQueryState; + XENVIF_VIF_MAC_QUERY_MAXIMUM_FRAME_SIZE MacQueryMaximumFrameSize; + XENVIF_VIF_MAC_QUERY_PERMANENT_ADDRESS MacQueryPermanentAddress; + XENVIF_VIF_MAC_QUERY_CURRENT_ADDRESS MacQueryCurrentAddress; + XENVIF_VIF_MAC_QUERY_MULTICAST_ADDRESSES MacQueryMulticastAddresses; + XENVIF_VIF_MAC_SET_MULTICAST_ADDRESSES MacSetMulticastAddresses; + XENVIF_VIF_MAC_SET_FILTER_LEVEL MacSetFilterLevel; + XENVIF_VIF_MAC_QUERY_FILTER_LEVEL MacQueryFilterLevel; +}; + +/*! \struct _XENVIF_VIF_INTERFACE_V10 + \brief VIF interface version 10 + \ingroup interfaces +*/ +struct _XENVIF_VIF_INTERFACE_V10 { INTERFACE Interface; XENVIF_VIF_ACQUIRE Acquire; XENVIF_VIF_RELEASE Release; @@ -920,7 +990,7 @@ struct _XENVIF_VIF_INTERFACE_V9 { XENVIF_VIF_MAC_QUERY_FILTER_LEVEL MacQueryFilterLevel; }; -typedef struct _XENVIF_VIF_INTERFACE_V9 XENVIF_VIF_INTERFACE, *PXENVIF_VIF_INTERFACE; +typedef struct _XENVIF_VIF_INTERFACE_V10 XENVIF_VIF_INTERFACE, *PXENVIF_VIF_INTERFACE; /*! \def XENVIF_VIF \brief Macro at assist in method invocation @@ -931,6 +1001,6 @@ typedef struct _XENVIF_VIF_INTERFACE_V9 XENVIF_VIF_INTERFACE, *PXENVIF_VIF_INTER #endif // _WINDLL #define XENVIF_VIF_INTERFACE_VERSION_MIN 8 -#define XENVIF_VIF_INTERFACE_VERSION_MAX 9 +#define XENVIF_VIF_INTERFACE_VERSION_MAX 10 #endif // _XENVIF_INTERFACE_H diff --git a/src/xennet.inf b/src/xennet.inf index 58ea5d79fd3e..43c5573ce3ba 100644 --- a/src/xennet.inf +++ b/src/xennet.inf @@ -61,9 +61,9 @@ xennet_coinst_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.dll ; DisplayName Section DeviceID ; ----------- ------- -------- -%XenNetName% =XenNet_Inst, XENVIF\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_NET&REV_09000002 -%XenNetName% =XenNet_Inst, XENVIF\VEN_@VENDOR_PREFIX@0001&DEV_NET&REV_09000002 -%XenNetName% =XenNet_Inst, XENVIF\VEN_@VENDOR_PREFIX@0002&DEV_NET&REV_09000002 +%XenNetName% =XenNet_Inst, XENVIF\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_NET&REV_09000003 +%XenNetName% =XenNet_Inst, XENVIF\VEN_@VENDOR_PREFIX@0001&DEV_NET&REV_09000003 +%XenNetName% =XenNet_Inst, XENVIF\VEN_@VENDOR_PREFIX@0002&DEV_NET&REV_09000003 [XenNet_Inst] Characteristics=0x84 diff --git a/src/xennet/adapter.c b/src/xennet/adapter.c index 50cd3e63e382..7a083e91b854 100644 --- a/src/xennet/adapter.c +++ b/src/xennet/adapter.c @@ -225,7 +225,8 @@ AdapterVifCallback( Parameters->ReceiverQueuePacket.Info, Parameters->ReceiverQueuePacket.Hash, Parameters->ReceiverQueuePacket.More, - Parameters->ReceiverQueuePacket.Cookie); + Parameters->ReceiverQueuePacket.Cookie, + &Parameters->ReceiverQueuePacket.Pause); break; case XENVIF_MAC_STATE_CHANGE: diff --git a/src/xennet/receiver.c b/src/xennet/receiver.c index 65527c51af8f..ae9207cccfb7 100644 --- a/src/xennet/receiver.c +++ b/src/xennet/receiver.c @@ -378,7 +378,8 @@ static FORCEINLINE VOID __IndicateReceiveNetBufferLists( static VOID __ReceiverPushPackets( IN PXENNET_RECEIVER Receiver, - IN ULONG Index + IN ULONG Index, + OUT PBOOLEAN Pause ) { ULONG Flags; @@ -412,8 +413,10 @@ __ReceiverPushPackets( NDIS_RECEIVE_FLAGS_PERFECT_FILTERED; ASSERT3S(Indicated - Returned, >=, 0); - if (Indicated - Returned > IN_NDIS_MAX) + if (Indicated - Returned > IN_NDIS_MAX) { Flags |= NDIS_RECEIVE_FLAGS_RESOURCES; + *Pause = TRUE; + } __IndicateReceiveNetBufferLists(Receiver, NetBufferList, @@ -544,12 +547,14 @@ ReceiverQueuePacket( IN PXENVIF_PACKET_INFO Info, IN PXENVIF_PACKET_HASH Hash, IN BOOLEAN More, - IN PVOID Cookie + IN PVOID Cookie, + OUT PBOOLEAN Pause ) { PXENVIF_VIF_INTERFACE VifInterface; PNET_BUFFER_LIST NetBufferList; PXENNET_RECEIVER_QUEUE Queue; + BOOLEAN Push = !More; VifInterface = AdapterGetVifInterface(Receiver->Adapter); @@ -583,11 +588,18 @@ ReceiverQueuePacket( } Queue->Count++; + // If we need to indicate low resources, then push the queued packets to NDIS. + if (!Push && + Receiver->Indicated + Queue->Count - Receiver->Returned > IN_NDIS_MAX) + Push = TRUE; + KeReleaseSpinLockFromDpcLevel(&Queue->Lock); done: - if (!More) - __ReceiverPushPackets(Receiver, Index); + *Pause = FALSE; + + if (Push) + __ReceiverPushPackets(Receiver, Index, Pause); } PXENVIF_VIF_OFFLOAD_OPTIONS diff --git a/src/xennet/receiver.h b/src/xennet/receiver.h index 5fc9e6679f65..5a1e82ea1592 100644 --- a/src/xennet/receiver.h +++ b/src/xennet/receiver.h @@ -68,7 +68,8 @@ ReceiverQueuePacket( IN PXENVIF_PACKET_INFO Info, IN PXENVIF_PACKET_HASH Hash, IN BOOLEAN More, - IN PVOID Cookie + IN PVOID Cookie, + OUT PBOOLEAN Pause ); extern PXENVIF_VIF_OFFLOAD_OPTIONS -- 2.17.1
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |