[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/2] Remove varargs from AdapterVifCallback.


  • To: <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Martin Harvey <Martin.Harvey@xxxxxxxxxx>
  • Date: Fri, 13 May 2022 11:24:13 +0100
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Martin Harvey <Martin.Harvey@xxxxxxxxxx>, Martin Harvey <martin.harvey@xxxxxxxxxx>
  • Delivery-date: Fri, 13 May 2022 10:24:41 +0000
  • Ironport-data: A9a23:KJOaMqr2iyOzme2ydRzYazpQX31eBmJMZRIvgKrLsJaIsI4StFCzt garIBmFbKuKM2X0L9tyO4Sxpk5SsMLUzNNjSVZsqXgwRC9BpJuZCYyVIHmrMnLJJKUvbq7GA +byyDXkBJppJpMJjk71atANlVEliefQAOCU5NfsYkidfyc9IMsaoU8lyrdRbrJA24DjWVvQ4 Iiq+qUzBXf+s9JKGjNMg068gEsHUMTa4Fv0aXRnOJinFHeH/5UkJMp3yZOZdhMUcaENdgKOf M7RzanRw4/s10xF5uVJMFrMWhZirrb6ZWBig5fNMkSoqkAqSicais7XOBeAAKv+Zvrgc91Zk b1wWZKMpQgBZ67QyP0hbjRkKTBYOYNHwJHBA3eivpnGp6HGWyOEL/RGCUg3OcsT+/ptAHEI/ vsdQNwPRknd3aTsmuv9E7QywJR4RCXoFNp3VnVIyDjDEfcgB5DKWbvH9PdT3Ssqh9AIFvHbD yYcQWU2Nk+cPkIeUrsRINVvtuaSrEntSRp/p3C7q4A7+HDo1SUkhdABN/KKI4fXFK25hH2wu WPAunznRx0XKtGb4T6E6W63wP/CmzvhX4AfH6H+8eRl6GB/3URKVkdQDwHi56Dk1AjuALqzN nD45AJ3rrRi7XCWY+XHTju8jn+8kBg+VMdfRrhSBB629oLY5AOQB24hRzFHacA7uMJeeQHGx mNljPuyW2Ux7eT9pWa1s+7N8GjsYXR9wXoqP3dscOcT3zX0TGjfZDrrR80rLqO6h8ad9drYk 2HT93hWa1n+YKc2O0SHEbLv3mrESnvhFFddCuDrsoWNtFsRWWJdT9b0gWU3FN4ZRGpjcnGPv WIfh++V5/0UAJeGmUSlGbtQRur5v6raaGWG2TaD+qXNEBz3oRaekX14umkidC+FzO5aEdMWX KMjkVwIv8ICVJdbRaR2f5iwG6wXIVvITrzYugTvRoMWOPBZLVbflAk3PB749z28yyAEzPBgU ap3hO7xVB72/4w8lGroLwrcuJd2rh0DKZT7H86klUj3iurODJNXIJ9cWGazgikCxPvsiG3oH xx3bqNmFz03vDXCXxTq
  • Ironport-hdrordr: A9a23:BdHFKqwhyt3l9DQNPj6UKrPwFL1zdoMgy1knxilNoRw8SKKlfq eV7ZImPH7P+U4ssR4b+exoVJPtfZqYz+8R3WBzB8bEYOCFghrKEGgK1+KLqFeMJ8S9zJ846U 4JSdkGNDSaNzlHZKjBjzVQa+xQouW6zA==
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

VifEnable allows the client to pass in an adapter callback,
which is called to push and return packets, and signal
adapter state changes. The parameters for this callback
were never fully specified (depending on varargs).
This change formally specifies those params in the Vif interface.

Signed-off-by: Martin Harvey <martin.harvey@xxxxxxxxxx>
---
 include/vif_interface.h | 104 ++++++++++++++++++++++++++++++++++++----
 src/xennet/adapter.c    |  67 ++++++--------------------
 2 files changed, 110 insertions(+), 61 deletions(-)

diff --git a/include/vif_interface.h b/include/vif_interface.h
index c034657..c416f81 100644
--- a/include/vif_interface.h
+++ b/include/vif_interface.h
@@ -408,7 +408,7 @@ typedef VOID
     IN  PINTERFACE  Interface
     );
 
-/*! \typedef XENVIF_VIF_CALLBACK
+/*! \typedef XENVIF_VIF_CALLBACK_VARARGS
     \brief Provider to subscriber callback function
 
     \param Argument An optional context argument passed to the callback
@@ -436,13 +436,72 @@ typedef VOID
     No additional arguments
 */
 typedef VOID
-(*XENVIF_VIF_CALLBACK)(
+(*XENVIF_VIF_CALLBACK_VARARGS)(
     IN  PVOID                       Argument OPTIONAL,
     IN  XENVIF_VIF_CALLBACK_TYPE    Type,
     ...
     );
 
-/*! \typedef XENVIF_VIF_ENABLE
+/*! \typedef XENVIF_VIF_ENABLE_VARARGS
+    \brief Enable the VIF interface
+
+    All packets queued for transmit will be rejected and no packets will
+    be queued for receive until this method completes. 
+
+    \param Interface The interface header
+    \param Callback The subscriber's callback function
+    \param Argument An optional context argument passed to the callback
+*/
+typedef NTSTATUS
+(*XENVIF_VIF_ENABLE_VARARGS)(
+    IN  PINTERFACE          Interface,
+    IN  XENVIF_VIF_CALLBACK_VARARGS Callback,
+    IN  PVOID               Argument OPTIONAL
+    );
+
+
+typedef union _XENVIF_VIF_CALLBACK_PARAMS {
+    struct _XENVIF_VIF_CALLBACK_RETURN_PACKET_PARAMS {
+        PVOID Cookie;
+        PXENVIF_TRANSMITTER_PACKET_COMPLETION_INFO Completion;
+    } ReturnPacketParams;
+    struct _XENVIF_VIF_CALLBACK_QUEUE_PACKET_PARAMS {
+        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;
+        PBOOLEAN NdisFinished;
+    } QueuePacketParams;
+    /*
+    struct _XENVIF_VIF_CALLBACK_STATE_CHANGE_PARAMS {
+        No parameters here
+    } StateChangeParams;
+    */
+} XENVIF_VIF_CALLBACK_PARAMS, *PXENVIF_VIF_CALLBACK_PARAMS;
+
+/*! \typedef XENVIF_VIF_CALLBACK
+    \brief Provider to subscriber callback function
+
+    \param Argument An optional context argument passed to the callback
+    \param Type The callback type
+    \param Params Additional paramaters required by \a Type
+*/
+
+typedef VOID
+(*XENVIF_VIF_CALLBACK)(
+    IN  PVOID                       Argument OPTIONAL,
+    IN  XENVIF_VIF_CALLBACK_TYPE    Type,
+    IN  PXENVIF_VIF_CALLBACK_PARAMS Params
+    );
+
+/*! \typedef XENVIF_VIF_ENABLE_VARARGS
     \brief Enable the VIF interface
 
     All packets queued for transmit will be rejected and no packets will
@@ -834,7 +893,7 @@ struct _XENVIF_VIF_INTERFACE_V6 {
     INTERFACE                                       Interface;
     XENVIF_VIF_ACQUIRE                              Acquire;
     XENVIF_VIF_RELEASE                              Release;
-    XENVIF_VIF_ENABLE                               Enable;
+    XENVIF_VIF_ENABLE_VARARGS                       Enable;
     XENVIF_VIF_DISABLE                              Disable;
     XENVIF_VIF_QUERY_STATISTIC                      QueryStatistic;
     XENVIF_VIF_QUERY_RING_COUNT                     QueryRingCount;
@@ -868,7 +927,7 @@ struct _XENVIF_VIF_INTERFACE_V7 {
     INTERFACE                                       Interface;
     XENVIF_VIF_ACQUIRE                              Acquire;
     XENVIF_VIF_RELEASE                              Release;
-    XENVIF_VIF_ENABLE                               Enable;
+    XENVIF_VIF_ENABLE_VARARGS                       Enable;
     XENVIF_VIF_DISABLE                              Disable;
     XENVIF_VIF_QUERY_STATISTIC                      QueryStatistic;
     XENVIF_VIF_QUERY_RING_COUNT                     QueryRingCount;
@@ -902,7 +961,7 @@ struct _XENVIF_VIF_INTERFACE_V8 {
     INTERFACE                                       Interface;
     XENVIF_VIF_ACQUIRE                              Acquire;
     XENVIF_VIF_RELEASE                              Release;
-    XENVIF_VIF_ENABLE                               Enable;
+    XENVIF_VIF_ENABLE_VARARGS                       Enable;
     XENVIF_VIF_DISABLE                              Disable;
     XENVIF_VIF_QUERY_STATISTIC                      QueryStatistic;
     XENVIF_VIF_QUERY_RING_COUNT                     QueryRingCount;
@@ -928,10 +987,37 @@ struct _XENVIF_VIF_INTERFACE_V8 {
     XENVIF_VIF_MAC_QUERY_FILTER_LEVEL               MacQueryFilterLevel;
 };
 
-/* V9 is exactly the same as V8 */
-typedef struct _XENVIF_VIF_INTERFACE_V8 XENVIF_VIF_INTERFACE_V9;
+struct _XENVIF_VIF_INTERFACE_V9 {
+    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_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;
+};
 
-typedef XENVIF_VIF_INTERFACE_V9 XENVIF_VIF_INTERFACE, *PXENVIF_VIF_INTERFACE;
+typedef struct _XENVIF_VIF_INTERFACE_V9 XENVIF_VIF_INTERFACE, 
*PXENVIF_VIF_INTERFACE;
 
 /*! \def XENVIF_VIF
     \brief Macro at assist in method invocation
diff --git a/src/xennet/adapter.c b/src/xennet/adapter.c
index a1bf9e8..9e8bebe 100644
--- a/src/xennet/adapter.c
+++ b/src/xennet/adapter.c
@@ -201,67 +201,32 @@ static VOID
 AdapterVifCallback(
     IN  PVOID                       Context,
     IN  XENVIF_VIF_CALLBACK_TYPE    Type,
-    ...
+    IN  PXENVIF_VIF_CALLBACK_PARAMS Params
     )
 {
     PXENNET_ADAPTER     Adapter = Context;
-    va_list             Arguments;
-
-    va_start(Arguments, Type);
 
     switch (Type) {
     case XENVIF_TRANSMITTER_RETURN_PACKET: {
-        PVOID                                       Cookie;
-        PXENVIF_TRANSMITTER_PACKET_COMPLETION_INFO  Completion;
-
-        Cookie = va_arg(Arguments, PVOID);
-        Completion = va_arg(Arguments, 
PXENVIF_TRANSMITTER_PACKET_COMPLETION_INFO);
-
         TransmitterReturnPacket(Adapter->Transmitter,
-                                Cookie,
-                                Completion);
+                                Params->ReturnPacketParams.Cookie,
+                                Params->ReturnPacketParams.Completion);
         break;
     }
     case XENVIF_RECEIVER_QUEUE_PACKET: {
-        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;
-        PBOOLEAN                        NdisFinished;
-
-        Index = va_arg(Arguments, ULONG);
-        Mdl = va_arg(Arguments, PMDL);
-        Offset = va_arg(Arguments, ULONG);
-        Length = va_arg(Arguments, ULONG);
-        Flags = va_arg(Arguments, XENVIF_PACKET_CHECKSUM_FLAGS);
-        MaximumSegmentSize = va_arg(Arguments, USHORT);
-        TagControlInformation = va_arg(Arguments, USHORT);
-        Info = va_arg(Arguments, PXENVIF_PACKET_INFO);
-        Hash = va_arg(Arguments, PXENVIF_PACKET_HASH);
-        More = va_arg(Arguments, BOOLEAN);
-        Cookie = va_arg(Arguments, PVOID);
-        NdisFinished = va_arg(Arguments, PBOOLEAN);
-
         ReceiverQueuePacket(Adapter->Receiver,
-                            Index,
-                            Mdl,
-                            Offset,
-                            Length,
-                            Flags,
-                            MaximumSegmentSize,
-                            TagControlInformation,
-                            Info,
-                            Hash,
-                            More,
-                            Cookie,
-                            NdisFinished);
+                            Params->QueuePacketParams.Index,
+                            Params->QueuePacketParams.Mdl,
+                            Params->QueuePacketParams.Offset,
+                            Params->QueuePacketParams.Length,
+                            Params->QueuePacketParams.Flags,
+                            Params->QueuePacketParams.MaximumSegmentSize,
+                            Params->QueuePacketParams.TagControlInformation,
+                            Params->QueuePacketParams.Info,
+                            Params->QueuePacketParams.Hash,
+                            Params->QueuePacketParams.More,
+                            Params->QueuePacketParams.Cookie,
+                            Params->QueuePacketParams.NdisFinished);
         break;
     }
     case XENVIF_MAC_STATE_CHANGE: {
@@ -269,8 +234,6 @@ AdapterVifCallback(
         break;
     }
     }
-
-    va_end(Arguments);
 }
 
 static VOID
-- 
2.25.0.windows.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.