[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [win-pv-devel] [PATCH 5/7] Update to VIF Interface v2
Renames XENVIF_TRANSMITTER_PACKET to XENVIF_TRANSMITTER_PACKET_V1 and adds XENVIF_TRANSMITTER_PACKET_V2 for future patches. VIF v2 will be implemented in another patch. Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx> --- include/vif_interface.h | 94 ++++++++++++++++++++++++++++++++++++++++++++---- src/xenvif/transmitter.c | 88 +++++++++++++++++++++++++-------------------- src/xenvif/transmitter.h | 6 ++-- src/xenvif/vif.c | 18 +++++----- src/xenvif/vif.h | 6 ++-- 5 files changed, 153 insertions(+), 59 deletions(-) diff --git a/include/vif_interface.h b/include/vif_interface.h index 498ed8f..d083fd1 100644 --- a/include/vif_interface.h +++ b/include/vif_interface.h @@ -257,7 +257,7 @@ struct _XENVIF_TRANSMITTER_PACKET_V1 { }; }; -typedef struct _XENVIF_TRANSMITTER_PACKET_V1 XENVIF_TRANSMITTER_PACKET, *PXENVIF_TRANSMITTER_PACKET; +typedef struct _XENVIF_TRANSMITTER_PACKET_V1 XENVIF_TRANSMITTER_PACKET_V1, *PXENVIF_TRANSMITTER_PACKET_V1; #pragma warning(pop) @@ -265,6 +265,30 @@ typedef struct _XENVIF_TRANSMITTER_PACKET_V1 XENVIF_TRANSMITTER_PACKET, *PXENVIF C_ASSERT(sizeof (struct _XENVIF_TRANSMITTER_PACKET_V1) <= (3 * sizeof (PVOID))); +/*! \struct _XENVIF_TRANSMITTER_PACKET_V2 + \brief Transmit-side packet structure (v2) +*/ +struct _XENVIF_TRANSMITTER_PACKET_V2 { + /*! List entry used for chaining packets together */ + LIST_ENTRY ListEntry; + /*! Opaque cookie used to store context information for packet return */ + PVOID Cookie; + /*! Hash value set by subscriber */ + ULONG Value; + /*! Packet information passed from subscriber to provider */ + XENVIF_TRANSMITTER_PACKET_SEND_INFO Send; + /*! Packet information passed from provider to subscriber on packet return */ + XENVIF_TRANSMITTER_PACKET_COMPLETION_INFO Completion; + /*! Packet data MDL */ + PMDL Mdl; + /*! Offset into MDL to start of packet */ + ULONG Offset; + /*! Packet length */ + ULONG Length; +}; + +typedef struct _XENVIF_TRANSMITTER_PACKET_V2 XENVIF_TRANSMITTER_PACKET, *PXENVIF_TRANSMITTER_PACKET; + /*! \enum _XENVIF_TRANSMITTER_PACKET_OFFSET \brief Offsets of packet metadata relative to XENVIF_TRANSMITTER_PACKET pointer @@ -474,16 +498,44 @@ typedef NTSTATUS IN LONG_PTR Value ); +/*! \typedef XENVIF_VIF_TRANSMITTER_GET_PACKET_HEADERS + \brief Get the packet headers into supplied buffer + + \param Interface The interface header + \param Packet The packet to acquire headers for. + \param Headers The buffer to receive headers. + \param Info The offsets into Headers for relevant headers +*/ +typedef NTSTATUS +(*XENVIF_VIF_TRANSMITTER_GET_PACKET_HEADERS)( + IN PINTERFACE Interface, + IN PXENVIF_TRANSMITTER_PACKET Packet, + OUT PVOID Headers, + OUT PXENVIF_PACKET_INFO Info + ); + /*! \typedef XENVIF_VIF_TRANSMITTER_QUEUE_PACKETS \brief Queue transmit side packets at the provider \param Interface The interface header - \param Head The head of a chain of XENVIF_TRANSMITTER_PACKET + \param Head The head of a chain of _XENVIF_TRANSMITTER_PACKET_V1 */ typedef NTSTATUS (*XENVIF_VIF_TRANSMITTER_QUEUE_PACKETS)( - IN PINTERFACE Interface, - IN PXENVIF_TRANSMITTER_PACKET Head + IN PINTERFACE Interface, + IN PXENVIF_TRANSMITTER_PACKET_V1 Head + ); + +/*! \typedef XENVIF_VIF_TRANSMITTER_QUEUE_PACKETS_V2 + \brief Queue transmit side packets at the provider + + \param Interface The interface header + \param List List of _XENVIF_TRANSMITTER_PACKET_V2 +*/ +typedef NTSTATUS +(*XENVIF_VIF_TRANSMITTER_QUEUE_PACKETS_V2)( + IN PINTERFACE Interface, + IN PLIST_ENTRY List ); /*! \typedef XENVIF_VIF_TRANSMITTER_QUERY_OFFLOAD_OPTIONS @@ -708,7 +760,37 @@ struct _XENVIF_VIF_INTERFACE_V1 { XENVIF_VIF_MAC_QUERY_FILTER_LEVEL MacQueryFilterLevel; }; -typedef struct _XENVIF_VIF_INTERFACE_V1 XENVIF_VIF_INTERFACE, *PXENVIF_VIF_INTERFACE; + +/*! \struct _XENVIF_VIF_INTERFACE_V2 + \brief VIF interface version 2 + \ingroup interfaces +*/ +struct _XENVIF_VIF_INTERFACE_V2 { + INTERFACE Interface; + XENVIF_VIF_ACQUIRE Acquire; + XENVIF_VIF_RELEASE Release; + XENVIF_VIF_ENABLE Enable; + XENVIF_VIF_DISABLE Disable; + XENVIF_VIF_QUERY_STATISTIC QueryStatistic; + XENVIF_VIF_RECEIVER_RETURN_PACKETS ReceiverReturnPackets; + XENVIF_VIF_RECEIVER_SET_OFFLOAD_OPTIONS ReceiverSetOffloadOptions; + XENVIF_VIF_RECEIVER_QUERY_RING_SIZE ReceiverQueryRingSize; + XENVIF_VIF_TRANSMITTER_GET_PACKET_HEADERS TransmitterGetPacketHeaders; + XENVIF_VIF_TRANSMITTER_QUEUE_PACKETS_V2 TransmitterQueuePackets; + 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; +}; + +typedef struct _XENVIF_VIF_INTERFACE_V2 XENVIF_VIF_INTERFACE, *PXENVIF_VIF_INTERFACE; /*! \def XENVIF_VIF \brief Macro at assist in method invocation @@ -719,6 +801,6 @@ typedef struct _XENVIF_VIF_INTERFACE_V1 XENVIF_VIF_INTERFACE, *PXENVIF_VIF_INTER #endif // _WINDLL #define XENVIF_VIF_INTERFACE_VERSION_MIN 1 -#define XENVIF_VIF_INTERFACE_VERSION_MAX 1 +#define XENVIF_VIF_INTERFACE_VERSION_MAX 2 #endif // _XENVIF_INTERFACE_H diff --git a/src/xenvif/transmitter.c b/src/xenvif/transmitter.c index e482392..41bab7c 100644 --- a/src/xenvif/transmitter.c +++ b/src/xenvif/transmitter.c @@ -89,7 +89,7 @@ typedef struct _XENVIF_TRANSMITTER_FRAGMENT { #define XENVIF_TRANSMITTER_MAXIMUM_FRAGMENT_ID 0x03FF typedef struct _XENVIF_TRANSMITTER_STATE { - PXENVIF_TRANSMITTER_PACKET Packet; + PXENVIF_TRANSMITTER_PACKET_V1 Packet; XENVIF_TRANSMITTER_PACKET_SEND_INFO Send; PUCHAR StartVa; XENVIF_PACKET_INFO Info; @@ -101,8 +101,8 @@ typedef struct _XENVIF_TRANSMITTER_STATE { #define XENVIF_TRANSMITTER_RING_SIZE (__CONST_RING_SIZE(netif_tx, PAGE_SIZE)) typedef struct _XENVIF_TRANSMITTER_PACKET_LIST { - PXENVIF_TRANSMITTER_PACKET HeadPacket; - PXENVIF_TRANSMITTER_PACKET *TailPacket; + PXENVIF_TRANSMITTER_PACKET_V1 HeadPacket; + PXENVIF_TRANSMITTER_PACKET_V1 *TailPacket; } XENVIF_TRANSMITTER_PACKET_LIST, *PXENVIF_TRANSMITTER_PACKET_LIST; typedef struct _XENVIF_TRANSMITTER_RING { @@ -123,7 +123,7 @@ typedef struct _XENVIF_TRANSMITTER_RING { BOOLEAN Connected; BOOLEAN Enabled; BOOLEAN Stopped; - PXENVIF_TRANSMITTER_PACKET Lock; + PVOID Lock; PKTHREAD LockThread; XENVIF_TRANSMITTER_PACKET_LIST Queued; XENVIF_TRANSMITTER_STATE State; @@ -558,7 +558,7 @@ __TransmitterRingCopyPayload( PXENVIF_TRANSMITTER Transmitter; PXENVIF_FRONTEND Frontend; PXENVIF_TRANSMITTER_STATE State; - PXENVIF_TRANSMITTER_PACKET Packet; + PXENVIF_TRANSMITTER_PACKET_V1 Packet; XENVIF_PACKET_PAYLOAD Payload; PXENVIF_TRANSMITTER_FRAGMENT Fragment; PXENVIF_TRANSMITTER_BUFFER Buffer; @@ -705,7 +705,7 @@ __TransmitterRingGrantPayload( PXENVIF_TRANSMITTER Transmitter; PXENVIF_FRONTEND Frontend; PXENVIF_TRANSMITTER_STATE State; - PXENVIF_TRANSMITTER_PACKET Packet; + PXENVIF_TRANSMITTER_PACKET_V1 Packet; PXENVIF_PACKET_PAYLOAD Payload; PMDL Mdl; ULONG Offset; @@ -852,7 +852,7 @@ __TransmitterRingPrepareHeader( PXENVIF_FRONTEND Frontend; PXENVIF_MAC Mac; PXENVIF_TRANSMITTER_STATE State; - PXENVIF_TRANSMITTER_PACKET Packet; + PXENVIF_TRANSMITTER_PACKET_V1 Packet; PXENVIF_PACKET_PAYLOAD Payload; PXENVIF_PACKET_INFO Info; PXENVIF_TRANSMITTER_FRAGMENT Fragment; @@ -1129,7 +1129,7 @@ __TransmitterRingUnprepareFragments( while (State->Count != 0) { PLIST_ENTRY ListEntry; PXENVIF_TRANSMITTER_FRAGMENT Fragment; - PXENVIF_TRANSMITTER_PACKET Packet; + PXENVIF_TRANSMITTER_PACKET_V1 Packet; --State->Count; @@ -1185,8 +1185,8 @@ __TransmitterRingUnprepareFragments( static FORCEINLINE NTSTATUS __TransmitterRingPreparePacket( - IN PXENVIF_TRANSMITTER_RING Ring, - IN PXENVIF_TRANSMITTER_PACKET Packet + IN PXENVIF_TRANSMITTER_RING Ring, + IN PXENVIF_TRANSMITTER_PACKET_V1 Packet ) { #define OFFSET_EXISTS(_Ring, _Packet, _Type) \ @@ -1337,13 +1337,13 @@ fail1: #undef OFFSET_EXISTS } -static FORCEINLINE PXENVIF_TRANSMITTER_PACKET +static FORCEINLINE PXENVIF_TRANSMITTER_PACKET_V1 __TransmitterRingUnpreparePacket( IN PXENVIF_TRANSMITTER_RING Ring ) { PXENVIF_TRANSMITTER_STATE State; - PXENVIF_TRANSMITTER_PACKET Packet; + PXENVIF_TRANSMITTER_PACKET_V1 Packet; State = &Ring->State; Packet = State->Packet; @@ -1702,7 +1702,7 @@ __TransmitterRingPostFragments( PXENVIF_TRANSMITTER Transmitter; PXENVIF_FRONTEND Frontend; PXENVIF_TRANSMITTER_STATE State; - PXENVIF_TRANSMITTER_PACKET Packet; + PXENVIF_TRANSMITTER_PACKET_V1 Packet; PXENVIF_PACKET_PAYLOAD Payload; RING_IDX req_prod; RING_IDX rsp_cons; @@ -1927,8 +1927,8 @@ __TransmitterRingFakeResponses( static FORCEINLINE VOID __TransmitterRingCompletePacket( - IN PXENVIF_TRANSMITTER_RING Ring, - IN PXENVIF_TRANSMITTER_PACKET Packet + IN PXENVIF_TRANSMITTER_RING Ring, + IN PXENVIF_TRANSMITTER_PACKET_V1 Packet ) { PXENVIF_TRANSMITTER Transmitter; @@ -2026,7 +2026,7 @@ TransmitterRingPoll( netif_tx_response_t *rsp; uint16_t id; PXENVIF_TRANSMITTER_FRAGMENT Fragment; - PXENVIF_TRANSMITTER_PACKET Packet; + PXENVIF_TRANSMITTER_PACKET_V1 Packet; rsp = RING_GET_RESPONSE(&Ring->Front, rsp_cons); rsp_cons++; @@ -2231,17 +2231,17 @@ __TransmitterRingPushRequests( static FORCEINLINE ULONG __TransmitterReversePacketList( - IN PXENVIF_TRANSMITTER_PACKET *Packet + IN PXENVIF_TRANSMITTER_PACKET_V1 *Packet ) { - PXENVIF_TRANSMITTER_PACKET HeadPacket; + PXENVIF_TRANSMITTER_PACKET_V1 HeadPacket; ULONG Count; HeadPacket = NULL; Count = 0; while (*Packet != NULL) { - PXENVIF_TRANSMITTER_PACKET Next; + PXENVIF_TRANSMITTER_PACKET_V1 Next; ASSERT(((ULONG_PTR)*Packet & XENVIF_TRANSMITTER_LOCK_BIT) == 0); @@ -2266,8 +2266,8 @@ TransmitterRingSwizzle( { ULONG_PTR Old; ULONG_PTR New; - PXENVIF_TRANSMITTER_PACKET HeadPacket; - PXENVIF_TRANSMITTER_PACKET *TailPacket; + PXENVIF_TRANSMITTER_PACKET_V1 HeadPacket; + PXENVIF_TRANSMITTER_PACKET_V1 *TailPacket; ULONG Count; ASSERT3P(Ring->LockThread, ==, KeGetCurrentThread()); @@ -2307,8 +2307,8 @@ TransmitterRingSchedule( State = &Ring->State; for (;;) { - PXENVIF_TRANSMITTER_PACKET Packet; - NTSTATUS status; + PXENVIF_TRANSMITTER_PACKET_V1 Packet; + NTSTATUS status; if (State->Count != 0) { status = __TransmitterRingPostFragments(Ring); @@ -2402,6 +2402,20 @@ TransmitterRingSchedule( __TransmitterRingPushRequests(Ring); } +static FORCEINLINE VOID +__TransmitterReturnPackets( + IN PXENVIF_TRANSMITTER Transmitter, + IN PXENVIF_TRANSMITTER_PACKET_V1 HeadPacket + ) +{ + PXENVIF_FRONTEND Frontend; + + Frontend = Transmitter->Frontend; + + VifTransmitterReturnPacketsV1(PdoGetVifContext(FrontendGetPdo(Frontend)), + HeadPacket); +} + static FORCEINLINE BOOLEAN __drv_requiresIRQL(DISPATCH_LEVEL) __TransmitterRingTryAcquireLock( @@ -2499,8 +2513,8 @@ __TransmitterRingReleaseLock( IN PXENVIF_TRANSMITTER_RING Ring ) { - PXENVIF_TRANSMITTER_PACKET HeadPacket; - PXENVIF_TRANSMITTER_PACKET *TailPacket; + PXENVIF_TRANSMITTER_PACKET_V1 HeadPacket; + PXENVIF_TRANSMITTER_PACKET_V1 *TailPacket; HeadPacket = NULL; TailPacket = &HeadPacket; @@ -2525,13 +2539,11 @@ __TransmitterRingReleaseLock( if (HeadPacket != NULL) { PXENVIF_TRANSMITTER Transmitter; - PXENVIF_FRONTEND Frontend; Transmitter = Ring->Transmitter; - Frontend = Transmitter->Frontend; - VifTransmitterReturnPackets(PdoGetVifContext(FrontendGetPdo(Frontend)), - HeadPacket); + __TransmitterReturnPackets(Transmitter, + HeadPacket); } } @@ -3139,7 +3151,7 @@ __TransmitterRingDisable( { PXENVIF_TRANSMITTER Transmitter; PXENVIF_FRONTEND Frontend; - PXENVIF_TRANSMITTER_PACKET Packet; + PXENVIF_TRANSMITTER_PACKET_V1 Packet; PCHAR Buffer; XenbusState State; ULONG Attempt; @@ -3339,11 +3351,11 @@ __TransmitterRingTeardown( static FORCEINLINE VOID __TransmitterRingQueuePackets( - IN PXENVIF_TRANSMITTER_RING Ring, - IN PXENVIF_TRANSMITTER_PACKET HeadPacket + IN PXENVIF_TRANSMITTER_RING Ring, + IN PXENVIF_TRANSMITTER_PACKET_V1 HeadPacket ) { - PXENVIF_TRANSMITTER_PACKET *TailPacket; + PXENVIF_TRANSMITTER_PACKET_V1 *TailPacket; ULONG_PTR Old; ULONG_PTR LockBit; ULONG_PTR New; @@ -3376,7 +3388,7 @@ __TransmitterRingAbortPackets( IN PXENVIF_TRANSMITTER_RING Ring ) { - PXENVIF_TRANSMITTER_PACKET Packet; + PXENVIF_TRANSMITTER_PACKET_V1 Packet; __TransmitterRingAcquireLock(Ring); @@ -3388,7 +3400,7 @@ __TransmitterRingAbortPackets( Ring->Queued.TailPacket = &Ring->Queued.HeadPacket; while (Packet != NULL) { - PXENVIF_TRANSMITTER_PACKET Next; + PXENVIF_TRANSMITTER_PACKET_V1 Next; Next = Packet->Next; Packet->Next = NULL; @@ -3882,9 +3894,9 @@ fail1: } VOID -TransmitterQueuePackets( - IN PXENVIF_TRANSMITTER Transmitter, - IN PXENVIF_TRANSMITTER_PACKET HeadPacket +TransmitterQueuePacketsV1( + IN PXENVIF_TRANSMITTER Transmitter, + IN PXENVIF_TRANSMITTER_PACKET_V1 HeadPacket ) { PXENVIF_TRANSMITTER_RING Ring; diff --git a/src/xenvif/transmitter.h b/src/xenvif/transmitter.h index 9c3bfaa..6a7fcd5 100644 --- a/src/xenvif/transmitter.h +++ b/src/xenvif/transmitter.h @@ -108,9 +108,9 @@ TransmitterAdvertiseAddresses( ); extern VOID -TransmitterQueuePackets( - IN PXENVIF_TRANSMITTER Transmitter, - IN PXENVIF_TRANSMITTER_PACKET HeadPacket +TransmitterQueuePacketsV1( + IN PXENVIF_TRANSMITTER Transmitter, + IN PXENVIF_TRANSMITTER_PACKET_V1 HeadPacket ); extern VOID diff --git a/src/xenvif/vif.c b/src/xenvif/vif.c index 97ce84a..b858d8f 100644 --- a/src/xenvif/vif.c +++ b/src/xenvif/vif.c @@ -275,9 +275,9 @@ VifReceiverReturnPackets( static NTSTATUS -VifTransmitterQueuePackets( - IN PINTERFACE Interface, - IN PXENVIF_TRANSMITTER_PACKET Head +VifTransmitterQueuePacketsV1( + IN PINTERFACE Interface, + IN PXENVIF_TRANSMITTER_PACKET_V1 Head ) { PXENVIF_VIF_CONTEXT Context = Interface->Context; @@ -289,8 +289,8 @@ VifTransmitterQueuePackets( if (Context->Enabled == FALSE) goto fail1; - TransmitterQueuePackets(FrontendGetTransmitter(Context->Frontend), - Head); + TransmitterQueuePacketsV1(FrontendGetTransmitter(Context->Frontend), + Head); ReleaseMrswLockShared(&Context->Lock); @@ -642,7 +642,7 @@ static struct _XENVIF_VIF_INTERFACE_V1 VifInterfaceVersion1 = { VifReceiverSetOffloadOptions, VifReceiverQueryRingSize, VifTransmitterSetPacketOffset, - VifTransmitterQueuePackets, + VifTransmitterQueuePacketsV1, VifTransmitterQueryOffloadOptions, VifTransmitterQueryLargePacketSize, VifTransmitterQueryRingSize, @@ -783,9 +783,9 @@ VifReceiverQueuePackets( } VOID -VifTransmitterReturnPackets( - IN PXENVIF_VIF_CONTEXT Context, - IN PXENVIF_TRANSMITTER_PACKET Head +VifTransmitterReturnPacketsV1( + IN PXENVIF_VIF_CONTEXT Context, + IN PXENVIF_TRANSMITTER_PACKET_V1 Head ) { Context->Callback(Context->Argument, diff --git a/src/xenvif/vif.h b/src/xenvif/vif.h index 17a04db..a26aa1b 100644 --- a/src/xenvif/vif.h +++ b/src/xenvif/vif.h @@ -69,9 +69,9 @@ VifReceiverQueuePackets( ); extern VOID -VifTransmitterReturnPackets( - IN PXENVIF_VIF_CONTEXT Context, - IN PXENVIF_TRANSMITTER_PACKET Head +VifTransmitterReturnPacketsV1( + IN PXENVIF_VIF_CONTEXT Context, + IN PXENVIF_TRANSMITTER_PACKET_V1 Head ); extern PXENVIF_THREAD -- 1.9.4.msysgit.1 _______________________________________________ win-pv-devel mailing list win-pv-devel@xxxxxxxxxxxxxxxxxxxx http://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |