Microsoft Hyper-V drivers for Linux
Subsystems (2)
cover Microsoft Hyper-V drivers for Linux
Hi all,
I'm happy to announce, that after many months of discussions, Microsoft has released their Hyper-V Linux drivers under the GPLv2. Following this message, will be the patches that add the drivers to the drivers/staging/ tree, and a whole bunch of cleanups.
It's taken a long road to get here, and I'd like to thank the following people who made this possible:
- Steve Hemminger for the initial prodding and extreme patience
- Hank Janssen for providing the code and working with me to get it into a workable and semi-mergable state. His involvement within Microsoft was also invaluable.
- Sam Ramji for his push within Microsoft to make this happen in a manner that works with the Linux community.
- Novell for sponsoring my work on the Linux Driver project, without which, this would not have even been possible.
And there are many others both within Novell and Microsoft, who I do not want to slight by not naming, but the list would be too long to go into.
These drivers are to enable Linux to work better when running as a guest on top of the Hyper-V system. There is still a lot of work to do in getting this into "proper" mergable state, and moving it out of the staging directory, but Hank and I will be undertaking this task. See the TODO file in the drivers/staging/hv/ directory if anyone wishes to help out with this task.
The code should be showing up in the linux-next tree soon, as the patches are now in my public tree.
If anyone has any questions about this code, please let me and Hank know about it.
thanks,
greg k-h
PATCH 1/54 Staging: hv: add the Hyper-V api header files
From: Hank Janssen <[email protected]>
These are the header files for the API to talk to the Hyper-V core.
--- drivers/staging/hv/include/ChannelMessages.h | 312 +++++++ drivers/staging/hv/include/HvHalApi.h | 32 drivers/staging/hv/include/HvHcApi.h | 60 + drivers/staging/hv/include/HvPtApi.h | 86 ++ drivers/staging/hv/include/HvStatus.h | 718 ++++++++++++++++++ drivers/staging/hv/include/HvSynicApi.h | 490 ++++++++++++ drivers/staging/hv/include/HvTypes.h | 31 drivers/staging/hv/include/HvVpApi.h | 51 + drivers/staging/hv/include/List.h | 269 ++++++ drivers/staging/hv/include/VmbusChannelInterface.h | 131 +++ drivers/staging/hv/include/VmbusPacketFormat.h | 322 ++++++++ drivers/staging/hv/include/nvspprotocol.h | 306 +++++++ drivers/staging/hv/include/rndis.h | 836 +++++++++++++++++++++ drivers/staging/hv/include/vstorage.h | 309 +++++++ 14 files changed, 3953 insertions(+) create mode 100644 drivers/staging/hv/include/ChannelMessages.h create mode 100644 drivers/staging/hv/include/HvHalApi.h create mode 100644 drivers/staging/hv/include/HvHcApi.h create mode 100644 drivers/staging/hv/include/HvPtApi.h create mode 100644 drivers/staging/hv/include/HvStatus.h create mode 100644 drivers/staging/hv/include/HvSynicApi.h create mode 100644 drivers/staging/hv/include/HvTypes.h create mode 100644 drivers/staging/hv/include/HvVpApi.h create mode 100644 drivers/staging/hv/include/List.h create mode 100644 drivers/staging/hv/include/VmbusChannelInterface.h create mode 100644 drivers/staging/hv/include/VmbusPacketFormat.h create mode 100644 drivers/staging/hv/include/nvspprotocol.h create mode 100644 drivers/staging/hv/include/rndis.h create mode 100644 drivers/staging/hv/include/vstorage.h
drivers/staging/hv/include/ChannelMessages.h new file +312 -0
@@ -0,0 +1,312 @@ +/* +* +* Copyright (c) 2009, Microsoft Corporation. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program; if not, write to the Free Software Foundation, Inc., 59 Temple +* Place - Suite 330, Boston, MA 02111-1307 USA. +* +* Authors: +* Haiyang Zhang <[email protected]> +* Hank Janssen <[email protected]> +* +*/ + + +#pragma once + +#include <VmbusPacketFormat.h> + +#define C_ASSERT (x) +typedef UINT32 NTSTATUS ; + +#pragma pack(push,1) + +// +// Version 1 messages +// + +typedef enum _VMBUS_CHANNEL_MESSAGE_TYPE +{ + ChannelMessageInvalid =0 , + ChannelMessageOfferChannel =1 , + ChannelMessageRescindChannelOffer =2 , + ChannelMessageRequestOffers =3 , + ChannelMessageAllOffersDelivered =4 , + ChannelMessageOpenChannel =5 , + ChannelMessageOpenChannelResult =6 , + ChannelMessageCloseChannel =7 , + ChannelMessageGpadlHeader =8 , + ChannelMessageGpadlBody =9 , + ChannelMessageGpadlCreated =10 , + ChannelMessageGpadlTeardown =11 , + ChannelMessageGpadlTorndown =12 , + ChannelMessageRelIdReleased =13 , + ChannelMessageInitiateContact =14 , + ChannelMessageVersionResponse =15 , + ChannelMessageUnload =16 , +#ifdef VMBUS_FEATURE_PARENT_OR_PEER_MEMORY_MAPPED_INTO_A_CHILD + ChannelMessageViewRangeAdd =17 , + ChannelMessageViewRangeRemove =18 , +#endif + ChannelMessageCount +}VMBUS_CHANNEL_MESSAGE_TYPE , *PVMBUS_CHANNEL_MESSAGE_TYPE ; + +// begin_wpp config +// CUSTOM_TYPE(ChannelMessageType, ItemEnum(_VMBUS_CHANNEL_MESSAGE_TYPE)); +// end_wpp + +typedef struct _VMBUS_CHANNEL_MESSAGE_HEADER +{ +VMBUS_CHANNEL_MESSAGE_TYPE MessageType; +UINT32 Padding; +}VMBUS_CHANNEL_MESSAGE_HEADER , *PVMBUS_CHANNEL_MESSAGE_HEADER ; + +// Query VMBus Version parameters +typedef struct _VMBUS_CHANNEL_QUERY_VMBUS_VERSION +{ +VMBUS_CHANNEL_MESSAGE_HEADER Header; +UINT32 Version; +}VMBUS_CHANNEL_QUERY_VMBUS_VERSION , *PVMBUS_CHANNEL_QUERY_VMBUS_VERSION ; + +// VMBus Version Supported parameters +typedef struct _VMBUS_CHANNEL_VERSION_SUPPORTED +{ +VMBUS_CHANNEL_MESSAGE_HEADER Header; +BOOLEAN VersionSupported; +}VMBUS_CHANNEL_VERSION_SUPPORTED , *PVMBUS_CHANNEL_VERSION_SUPPORTED ; + +// Offer Channel parameters +typedef struct _VMBUS_CHANNEL_OFFER_CHANNEL +{ +VMBUS_CHANNEL_MESSAGE_HEADER Header; +VMBUS_CHANNEL_OFFER Offer; +UINT32 ChildRelId; +UINT8 MonitorId; +BOOLEAN MonitorAllocated; +}VMBUS_CHANNEL_OFFER_CHANNEL , *PVMBUS_CHANNEL_OFFER_CHANNEL ; + +// +// Make sure VMBUS_CHANNEL_OFFER_CHANNEL fits into Synic message. +// +C_ASSERT (sizeof (VMBUS_CHANNEL_OFFER_CHANNEL ) <=MAXIMUM_SYNIC_MESSAGE_BYTES ); + +// Rescind Offer parameters +typedef struct _VMBUS_CHANNEL_RESCIND_OFFER +{ +VMBUS_CHANNEL_MESSAGE_HEADER Header; +UINT32 ChildRelId; +}VMBUS_CHANNEL_RESCIND_OFFER , *PVMBUS_CHANNEL_RESCIND_OFFER ; + +// Request Offer -- no parameters, SynIC message contains the partition ID +// Set Snoop -- no parameters, SynIC message contains the partition ID +// Clear Snoop -- no parameters, SynIC message contains the partition ID +// All Offers Delivered -- no parameters, SynIC message contains the partition ID +// Flush Client -- no parameters, SynIC message contains the partition ID + +// Open Channel parameters +typedef struct _VMBUS_CHANNEL_OPEN_CHANNEL +{ +VMBUS_CHANNEL_MESSAGE_HEADER Header; + +// +// Identifies the specific VMBus channel that is being opened. +// +UINT32 ChildRelId; + +// +// ID making a particular open request at a channel offer unique. +// +UINT32 OpenId; + +// +// GPADL for the channel's ring buffer. +// +GPADL_HANDLE RingBufferGpadlHandle; + +// +// GPADL for the channel's server context save area. +// +GPADL_HANDLE ServerContextAreaGpadlHandle; + +// +// The upstream ring buffer begins at offset zero in the memory described +// by RingBufferGpadlHandle. The downstream ring buffer follows it at this +// offset (in pages). +// +UINT32 DownstreamRingBufferPageOffset; + +// +// User-specific data to be passed along to the server endpoint. +// +UCHAR UserData[MAX_USER_DEFINED_BYTES ]; + +}VMBUS_CHANNEL_OPEN_CHANNEL , *PVMBUS_CHANNEL_OPEN_CHANNEL ; + +// Reopen Channel parameters; +typedef VMBUS_CHANNEL_OPEN_CHANNEL VMBUS_CHANNEL_REOPEN_CHANNEL , *PVMBUS_CHANNEL_REOPEN_CHANNEL ; + +// Open Channel Result parameters +typedef struct _VMBUS_CHANNEL_OPEN_RESULT +{ +VMBUS_CHANNEL_MESSAGE_HEADER Header; +UINT32 ChildRelId; +UINT32 OpenId; +NTSTATUS Status; +}VMBUS_CHANNEL_OPEN_RESULT , *PVMBUS_CHANNEL_OPEN_RESULT ; + +// Close channel parameters; +typedef struct _VMBUS_CHANNEL_CLOSE_CHANNEL +{ +VMBUS_CHANNEL_MESSAGE_HEADER Header; +UINT32 ChildRelId; +}VMBUS_CHANNEL_CLOSE_CHANNEL , *PVMBUS_CHANNEL_CLOSE_CHANNEL ; + +// Channel Message GPADL +#define GPADL_TYPE_RING_BUFFER 1 +#define GPADL_TYPE_SERVER_SAVE_AREA 2 +#define GPADL_TYPE_TRANSACTION 8 + +// +// The number of PFNs in a GPADL message is defined by the number of pages +// that would be spanned by ByteCount and ByteOffset. If the implied number +// of PFNs won't fit in this packet, there will be a follow-up packet that +// contains more. +// + +typedef struct _VMBUS_CHANNEL_GPADL_HEADER +{ +VMBUS_CHANNEL_MESSAGE_HEADER Header; +UINT32 ChildRelId; +UINT32 Gpadl; +UINT16 RangeBufLen; +UINT16 RangeCount; +GPA_RANGE Range[0 ]; +}VMBUS_CHANNEL_GPADL_HEADER , *PVMBUS_CHANNEL_GPADL_HEADER ; + + +// +// This is the followup packet that contains more PFNs. +// + +typedef struct _VMBUS_CHANNEL_GPADL_BODY +{ +VMBUS_CHANNEL_MESSAGE_HEADER Header; +UINT32 MessageNumber; +UINT32 Gpadl; +UINT64 Pfn[0 ]; +}VMBUS_CHANNEL_GPADL_BODY , *PVMBUS_CHANNEL_GPADL_BODY ; + + +typedef struct _VMBUS_CHANNEL_GPADL_CREATED +{ +VMBUS_CHANNEL_MESSAGE_HEADER Header; +UINT32 ChildRelId; +UINT32 Gpadl; +UINT32 CreationStatus; +}VMBUS_CHANNEL_GPADL_CREATED , *PVMBUS_CHANNEL_GPADL_CREATED ; + +typedef struct _VMBUS_CHANNEL_GPADL_TEARDOWN +{ +VMBUS_CHANNEL_MESSAGE_HEADER Header; +UINT32 ChildRelId; +UINT32 Gpadl; +}VMBUS_CHANNEL_GPADL_TEARDOWN , *PVMBUS_CHANNEL_GPADL_TEARDOWN ; + +typedef struct _VMBUS_CHANNEL_GPADL_TORNDOWN +{ +VMBUS_CHANNEL_MESSAGE_HEADER Header; +UINT32 Gpadl; +}VMBUS_CHANNEL_GPADL_TORNDOWN , *PVMBUS_CHANNEL_GPADL_TORNDOWN ; + +#ifdef VMBUS_FEATURE_PARENT_OR_PEER_MEMORY_MAPPED_INTO_A_CHILD +typedef struct _VMBUS_CHANNEL_VIEW_RANGE_ADD +{ +VMBUS_CHANNEL_MESSAGE_HEADER Header; +PHYSICAL_ADDRESS ViewRangeBase; +UINT64 ViewRangeLength; +UINT32 ChildRelId; +}VMBUS_CHANNEL_VIEW_RANGE_ADD , *PVMBUS_CHANNEL_VIEW_RANGE_ADD ; + +typedef struct _VMBUS_CHANNEL_VIEW_RANGE_REMOVE +{ +VMBUS_CHANNEL_MESSAGE_HEADER Header; +PHYSICAL_ADDRESS ViewRangeBase; +UINT32 ChildRelId; +}VMBUS_CHANNEL_VIEW_RANGE_REMOVE , *PVMBUS_CHANNEL_VIEW_RANGE_REMOVE ; +#endif + +typedef struct _VMBUS_CHANNEL_RELID_RELEASED +{ +VMBUS_CHANNEL_MESSAGE_HEADER Header; +UINT32 ChildRelId; +}VMBUS_CHANNEL_RELID_RELEASED , *PVMBUS_CHANNEL_RELID_RELEASED ; + +typedef struct _VMBUS_CHANNEL_INITIATE_CONTACT +{ +VMBUS_CHANNEL_MESSAGE_HEADER Header; +UINT32 VMBusVersionRequested; +UINT32 Padding2; +UINT64 InterruptPage; +UINT64 MonitorPage1; +UINT64 MonitorPage2; +}VMBUS_CHANNEL_INITIATE_CONTACT , *PVMBUS_CHANNEL_INITIATE_CONTACT ; + +typedef struct _VMBUS_CHANNEL_VERSION_RESPONSE +{ +VMBUS_CHANNEL_MESSAGE_HEADER Header; +BOOLEAN VersionSupported; +}VMBUS_CHANNEL_VERSION_RESPONSE , *PVMBUS_CHANNEL_VERSION_RESPONSE ; + +typedef VMBUS_CHANNEL_MESSAGE_HEADER VMBUS_CHANNEL_UNLOAD , *PVMBUS_CHANNEL_UNLOAD ; + +// +// Kind of a table to use the preprocessor to get us the right type for a +// specified message ID. Used with ChAllocateSendMessage() +// +#define ChannelMessageQueryVmbusVersion_TYPE VMBUS_CHANNEL_MESSAGE_HEADER +#define ChannelMessageVmbusVersionSupported_TYPE VMBUS_CHANNEL_VERSION_SUPPORTED +#define ChannelMessageOfferChannel_TYPE VMBUS_CHANNEL_OFFER_CHANNEL +#define ChannelMessageRescindChannelOffer_TYPE VMBUS_CHANNEL_RESCIND_OFFER +#define ChannelMessageRequestOffers_TYPE VMBUS_CHANNEL_MESSAGE_HEADER +#define ChannelMessageAllOffersDelivered_TYPE VMBUS_CHANNEL_MESSAGE_HEADER +#define ChannelMessageOpenChannel_TYPE VMBUS_CHANNEL_OPEN_CHANNEL +#define ChannelMessageOpenChannelResult_TYPE VMBUS_CHANNEL_OPEN_RESULT +#define ChannelMessageCloseChannel_TYPE VMBUS_CHANNEL_CLOSE_CHANNEL +#define ChannelMessageAllGpadlsUnmapped_TYPE VMBUS_CHANNEL_CLOSE_CHANNEL +#define ChannelMessageGpadlHeader_TYPE VMBUS_CHANNEL_GPADL_HEADER +#define ChannelMessageGpadlBody_TYPE VMBUS_CHANNEL_GPADL_BODY +#define ChannelMessageGpadlCreated_TYPE VMBUS_CHANNEL_GPADL_CREATED +#define ChannelMessageGpadlTeardown_TYPE VMBUS_CHANNEL_GPADL_TEARDOWN +#define ChannelMessageGpadlTorndown_TYPE VMBUS_CHANNEL_GPADL_TORNDOWN +#define ChannelMessageViewRangeAdd_TYPE VMBUS_CHANNEL_VIEW_RANGE_ADD +#define ChannelMessageViewRangeRemove_TYPE VMBUS_CHANNEL_VIEW_RANGE_REMOVE +#define ChannelMessageRelIdReleased_TYPE VMBUS_CHANNEL_RELID_RELEASED +#define ChannelMessageInitiateContact_TYPE VMBUS_CHANNEL_INITIATE_CONTACT +#define ChannelMessageVersionResponse_TYPE VMBUS_CHANNEL_VERSION_RESPONSE +#define ChannelMessageUnload_TYPE VMBUS_CHANNEL_UNLOAD + +// +// Preprocessor wrapper to ChAllocateSendMessageSize() converting the return +// value to the correct pointer and calculate the needed size. +// +// Argument: +// +// Id - the numberic ID (type VMBUS_CHANNEL_MESSAGE_TYPE) of the message to +// send. +// +#define ChAllocateSendMessage (Id, Fn, Context) \ + (Id##_TYPE*)ChAllocateSendMessageSized(sizeof(Id##_TYPE), Id, Fn, Context) + + +#pragma pack(pop) +
drivers/staging/hv/include/HvHalApi.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* +* Copyright (c) 2009, Microsoft Corporation. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program; if not, write to the Free Software Foundation, Inc., 59 Temple +* Place - Suite 330, Boston, MA 02111-1307 USA. +* +* Authors: +* Haiyang Zhang <[email protected]> +* Hank Janssen <[email protected]> +* +*/ + + +#pragma once + + +// +// Time in the hypervisor is measured in 100 nanosecond units +// +typedef UINT64 HV_NANO100_TIME , *PHV_NANO100_TIME ; +typedef UINT64 HV_NANO100_DURATION , *PHV_NANO100_DURATION ;
drivers/staging/hv/include/HvHcApi.h new file +60 -0
60 lines not on this page · raw message
drivers/staging/hv/include/HvPtApi.h new file +86 -0
86 lines not on this page · raw message
drivers/staging/hv/include/HvStatus.h new file +718 -0
718 lines not on this page · raw message
drivers/staging/hv/include/HvSynicApi.h new file +490 -0
490 lines not on this page · raw message
drivers/staging/hv/include/HvTypes.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* +* Copyright (c) 2009, Microsoft Corporation. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program; if not, write to the Free Software Foundation, Inc., 59 Temple +* Place - Suite 330, Boston, MA 02111-1307 USA. +* +* Authors: +* Haiyang Zhang <[email protected]> +* Hank Janssen <[email protected]> +* +*/ + + +#pragma once + +typedef UINT64 HV_GPA , *PHV_GPA ; + +#define HV_X64_PAGE_SIZE (4096) +#define HV_PAGE_SIZE HV_X64_PAGE_SIZE +
drivers/staging/hv/include/HvVpApi.h new file +51 -0
51 lines not on this page · raw message
drivers/staging/hv/include/List.h new file +269 -0
269 lines not on this page · raw message
drivers/staging/hv/include/nvspprotocol.h new file +306 -0
306 lines not on this page · raw message
drivers/staging/hv/include/rndis.h new file +836 -0
645 lines not on this page · raw message
drivers/staging/hv/include/VmbusChannelInterface.h new file +131 -0
131 lines not on this page · raw message
drivers/staging/hv/include/VmbusPacketFormat.h new file +322 -0
322 lines not on this page · raw message
drivers/staging/hv/include/vstorage.h new file +309 -0
309 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
PATCH 2/54 Staging: hv: add the Hyper-V driver header files
In reply to Greg Kroah-HartmanFrom: Hank Janssen <[email protected]>
These are the header files for the different Linux Hyper-V drivers to use.
--- drivers/staging/hv/include/NetVscApi.h | 145 +++++++++++++++++ drivers/staging/hv/include/StorVscApi.h | 137 ++++++++++++++++ drivers/staging/hv/include/VmbusApi.h | 262 +++++++++++++++++++++++++++++++ drivers/staging/hv/include/logging.h | 134 ++++++++++++++++ drivers/staging/hv/include/osd.h | 263 ++++++++++++++++++++++++++++++++ drivers/staging/hv/include/vmbus.h | 111 +++++++++++++ 6 files changed, 1052 insertions(+) create mode 100644 drivers/staging/hv/include/NetVscApi.h create mode 100644 drivers/staging/hv/include/StorVscApi.h create mode 100644 drivers/staging/hv/include/VmbusApi.h create mode 100644 drivers/staging/hv/include/logging.h create mode 100644 drivers/staging/hv/include/osd.h create mode 100644 drivers/staging/hv/include/vmbus.h
drivers/staging/hv/include/logging.h new file +134 -0
@@ -0,0 +1,134 @@ +/* +* +* Copyright (c) 2009, Microsoft Corporation. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program; if not, write to the Free Software Foundation, Inc., 59 Temple +* Place - Suite 330, Boston, MA 02111-1307 USA. +* +* Authors: +* Haiyang Zhang <[email protected]> +* Hank Janssen <[email protected]> +* +*/ + + +#ifndef _LOGGING_H_ +#define _LOGGING_H_ + +//#include <linux/init.h> +//#include <linux/module.h> + +#include "osd.h" + +#define VMBUS 0x0001 +#define STORVSC 0x0002 +#define NETVSC 0x0004 +#define INPUTVSC 0x0008 +#define BLKVSC 0x0010 +#define VMBUS_DRV 0x0100 +#define STORVSC_DRV 0x0200 +#define NETVSC_DRV 0x0400 +#define INPUTVSC_DRV 0x0800 +#define BLKVSC_DRV 0x1000 + +#define ALL_MODULES (VMBUS |\ + STORVSC |\ + NETVSC |\ + INPUTVSC |\ + BLKVSC |\ + VMBUS_DRV |\ + STORVSC_DRV |\ + NETVSC_DRV |\ + INPUTVSC_DRV|\ + BLKVSC_DRV) + +// Logging Level +#define CRITICAL_LVL 2 +#define ERROR_LVL 3 +#define WARNING_LVL 4 +#define INFO_LVL 6 +#define DEBUG_LVL 7 +#define DEBUG_LVL_ENTEREXIT 8 +#define DEBUG_RING_LVL 9 + +extern unsigned int vmbus_loglevel; + +#define ASSERT (expr) \ + if (!(expr)) { \ + LogMsg("<%d>Assertion failed! %s,%s,%s,line=%d\n", CRITICAL_LVL, #expr,__FILE__,__FUNCTION__,__LINE__); \ + __asm__ __volatile__("int3"); \ + } + +#define DPRINT(mod, lvl, fmt, args...) do {\ + if (mod & (HIWORD(vmbus_loglevel))) \ + (lvl <= LOWORD(vmbus_loglevel))?(LogMsg("<%d>" #mod": %s() " fmt "\n", DEBUG_LVL, __FUNCTION__, ## args)):(0);\ + } while (0) + +#define DPRINT_DBG(mod, fmt, args...) do {\ + if (mod & (HIWORD(vmbus_loglevel))) \ + (DEBUG_LVL <= LOWORD(vmbus_loglevel))?(LogMsg("<%d>" #mod": %s() " fmt "\n", DEBUG_LVL, __FUNCTION__, ## args)):(0);\ + } while (0) + +#define DPRINT_INFO(mod, fmt, args...) do {\ + if (mod & (HIWORD(vmbus_loglevel))) \ + (INFO_LVL <= LOWORD(vmbus_loglevel))?(LogMsg("<%d>" #mod": " fmt "\n", INFO_LVL, ## args)):(0);\ + } while (0) + +#define DPRINT_WARN(mod, fmt, args...) do {\ + if (mod & (HIWORD(vmbus_loglevel))) \ + (WARNING_LVL <= LOWORD(vmbus_loglevel))?(LogMsg("<%d>" #mod": WARNING! " fmt "\n", WARNING_LVL, ## args)):(0);\ + } while (0) + +#define DPRINT_ERR(mod, fmt, args...) do {\ + if (mod & (HIWORD(vmbus_loglevel))) \ + (ERROR_LVL <= LOWORD(vmbus_loglevel))?(LogMsg("<%d>" #mod": %s() ERROR!! " fmt "\n", ERROR_LVL, __FUNCTION__, ## args)):(0);\ + } while (0) + +#ifdef DEBUG +#define DPRINT_ENTER (mod) do {\ + if (mod & (HIWORD(vmbus_loglevel))) \ + (DEBUG_LVL_ENTEREXIT <= LOWORD(vmbus_loglevel))?(LogMsg("<%d>" "["#mod"]: %s() enter\n", DEBUG_LVL, __FUNCTION__)):(0);\ + } while (0) + +#define DPRINT_EXIT (mod) do {\ + if (mod & (HIWORD(vmbus_loglevel))) \ + (DEBUG_LVL_ENTEREXIT <= LOWORD(vmbus_loglevel))?(LogMsg("<%d>" "["#mod"]: %s() exit\n", DEBUG_LVL, __FUNCTION__)):(0);\ + } while (0) +#else +#define DPRINT_ENTER (mod) +#define DPRINT_EXIT (mod) +#endif + +static inline void PrintBytes (const unsigned char * bytes,int len) +{ +int i=0 ; + +LogMsg ("\n<< " ); +for (i=0 ; i< len; i++) + { +LogMsg ("0x%x " , bytes[i]); + } +LogMsg (">>\n" ); +} + +// +// Inline +// +//static inline void GuidToStr(const GUID g, char *str) +//{ +// sprintf(str, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x%02x%02x}", +// g[3], g[2], g[1], g[0], g[5], g[4], g[7], g[6], g[8], g[9], g[10], g[11], g[12], g[13], g[14], g[15]); +// +//} + +#endif //_LOGGING_H_
drivers/staging/hv/include/NetVscApi.h new file +145 -0
145 lines not on this page · raw message
drivers/staging/hv/include/osd.h new file +263 -0
263 lines not on this page · raw message
drivers/staging/hv/include/StorVscApi.h new file +137 -0
137 lines not on this page · raw message
drivers/staging/hv/include/VmbusApi.h new file +262 -0
262 lines not on this page · raw message
drivers/staging/hv/include/vmbus.h new file +111 -0
111 lines not on this page · raw message
PATCH 3/54 Staging: hv: add the Hyper-V virtual bus
In reply to Greg Kroah-HartmanFrom: Hank Janssen <[email protected]>
This is the virtual bus that all of the Linux Hyper-V drivers use.
--- drivers/staging/hv/Channel.c | 1199 +++++++++++++++++++++++++++++++++ drivers/staging/hv/Channel.h | 157 ++++ drivers/staging/hv/ChannelInterface.c | 222 ++++++ drivers/staging/hv/ChannelInterface.h | 41 + drivers/staging/hv/ChannelMgmt.c | 826 ++++++++++++++++++++++ drivers/staging/hv/ChannelMgmt.h | 156 ++++ drivers/staging/hv/Connection.c | 432 +++++++++++ drivers/staging/hv/Hv.c | 672 ++++++++++++++++++ drivers/staging/hv/Hv.h | 184 +++++ drivers/staging/hv/RingBuffer.c | 630 +++++++++++++++++ drivers/staging/hv/RingBuffer.h | 123 +++ drivers/staging/hv/Sources.c | 31 drivers/staging/hv/VersionInfo.h | 29 drivers/staging/hv/Vmbus.c | 508 ++++++++++++++ drivers/staging/hv/VmbusPrivate.h | 170 ++++ drivers/staging/hv/osd.c | 500 +++++++++++++ drivers/staging/hv/vmbus_drv.c | 1228 ++++++++++++++++++++++++++++++++++ 17 files changed, 7108 insertions(+)
drivers/staging/hv/Channel.c new file +1199 -0
@@ -0,0 +1,1199 @@ +/* +* +* Copyright (c) 2009, Microsoft Corporation. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program; if not, write to the Free Software Foundation, Inc., 59 Temple +* Place - Suite 330, Boston, MA 02111-1307 USA. +* +* Authors: +* Haiyang Zhang <[email protected]> +* Hank Janssen <[email protected]> +* +*/ + + +#include "osd.h" +#include "logging.h" + +#include "VmbusPrivate.h" + +// +// Internal routines +// +static int +VmbusChannelCreateGpadlHeader ( +PVOID Kbuffer,// must be phys and virt contiguous +UINT32 Size,// page-size multiple +VMBUS_CHANNEL_MSGINFO **msgInfo, +UINT32 *MessageCount + ); + +static void +DumpVmbusChannel ( +VMBUS_CHANNEL *Channel + ); + + +static void +VmbusChannelSetEvent ( +VMBUS_CHANNEL *Channel + ); + + +#if 0 +static void +DumpMonitorPage ( +HV_MONITOR_PAGE *MonitorPage + ) +{ +int i=0 ; +int j=0 ; + +DPRINT_DBG (VMBUS ,"monitorPage - %p, trigger state - %d" , MonitorPage, MonitorPage->TriggerState); + +for (i=0 ; i<4 ; i++) + { +DPRINT_DBG (VMBUS ,"trigger group (%d) - %llx" , i, MonitorPage->TriggerGroup[i].AsUINT64); + } + +for (i=0 ; i<4 ; i++) + { +for (j=0 ; j<32 ; j++) + { +DPRINT_DBG (VMBUS ,"latency (%d)(%d) - %llx" , i, j, MonitorPage->Latency[i][j]); + } + } +for (i=0 ; i<4 ; i++) + { +for (j=0 ; j<32 ; j++) + { +DPRINT_DBG (VMBUS ,"param-conn id (%d)(%d) - %d" , i, j, MonitorPage->Parameter[i][j].ConnectionId.AsUINT32); +DPRINT_DBG (VMBUS ,"param-flag (%d)(%d) - %d" , i, j, MonitorPage->Parameter[i][j].FlagNumber); + + } + } +} +#endif + +/*++ + +Name: +VmbusChannelSetEvent() + +Description: +Trigger an event notification on the specified channel. + +--*/ +static void +VmbusChannelSetEvent ( +VMBUS_CHANNEL *Channel + ) +{ +HV_MONITOR_PAGE *monitorPage; + +DPRINT_ENTER (VMBUS ); + +if (Channel->OfferMsg.MonitorAllocated) + { +// Each UINT32 represents 32 channels +BitSet ((UINT32 *)gVmbusConnection.SendInterruptPage + (Channel->OfferMsg.ChildRelId >>5 ), Channel->OfferMsg.ChildRelId &31 ); + + monitorPage = (HV_MONITOR_PAGE *)gVmbusConnection.MonitorPages; + monitorPage++;// Get the child to parent monitor page + +BitSet ((UINT32 *) &monitorPage->TriggerGroup[Channel->MonitorGroup].Pending, Channel->MonitorBit); + } +else + { +VmbusSetEvent (Channel->OfferMsg.ChildRelId); + } + +DPRINT_EXIT (VMBUS ); +} + +#if 0 +static void +VmbusChannelClearEvent ( +VMBUS_CHANNEL *Channel + ) +{ +HV_MONITOR_PAGE *monitorPage; + +DPRINT_ENTER (VMBUS ); + +if (Channel->OfferMsg.MonitorAllocated) + { +// Each UINT32 represents 32 channels +BitClear ((UINT32 *)gVmbusConnection.SendInterruptPage + (Channel->OfferMsg.ChildRelId >>5 ), Channel->OfferMsg.ChildRelId &31 ); + + monitorPage = (HV_MONITOR_PAGE *)gVmbusConnection.MonitorPages; + monitorPage++;// Get the child to parent monitor page + +BitClear ((UINT32 *) &monitorPage->TriggerGroup[Channel->MonitorGroup].Pending, Channel->MonitorBit); + } + +DPRINT_EXIT (VMBUS ); +} + +#endif +/*++; + +Name: +VmbusChannelGetDebugInfo() + +Description: +Retrieve various channel debug info + +--*/ +void +VmbusChannelGetDebugInfo ( +VMBUS_CHANNEL *Channel, +VMBUS_CHANNEL_DEBUG_INFO *DebugInfo + ) +{ +HV_MONITOR_PAGE *monitorPage; +UINT8 monitorGroup = (UINT8 )Channel->OfferMsg.MonitorId /32 ; +UINT8 monitorOffset = (UINT8 )Channel->OfferMsg.MonitorId %32 ; +//UINT32 monitorBit = 1 << monitorOffset; + + DebugInfo->RelId = Channel->OfferMsg.ChildRelId; + DebugInfo->State = Channel->State; +memcpy (&DebugInfo->InterfaceType, &Channel->OfferMsg.Offer.InterfaceType,sizeof (GUID )); +memcpy (&DebugInfo->InterfaceInstance, &Channel->OfferMsg.Offer.InterfaceInstance,sizeof (GUID )); + + monitorPage = (HV_MONITOR_PAGE *)gVmbusConnection.MonitorPages; + + DebugInfo->MonitorId = Channel->OfferMsg.MonitorId; + + DebugInfo->ServerMonitorPending = monitorPage->TriggerGroup[monitorGroup].Pending; + DebugInfo->ServerMonitorLatency = monitorPage->Latency[monitorGroup][ monitorOffset]; + DebugInfo->ServerMonitorConnectionId = monitorPage->Parameter[monitorGroup][ monitorOffset].ConnectionId.u.Id; + + monitorPage++; + + DebugInfo->ClientMonitorPending = monitorPage->TriggerGroup[monitorGroup].Pending; + DebugInfo->ClientMonitorLatency = monitorPage->Latency[monitorGroup][ monitorOffset]; + DebugInfo->ClientMonitorConnectionId = monitorPage->Parameter[monitorGroup][ monitorOffset].ConnectionId.u.Id; + +RingBufferGetDebugInfo (&Channel->Inbound, &DebugInfo->Inbound); +RingBufferGetDebugInfo (&Channel->Outbound, &DebugInfo->Outbound); +} + + +/*++; + +Name: +VmbusChannelOpen() + +Description: +Open the specified channel. + +--*/ +int +VmbusChannelOpen ( +VMBUS_CHANNEL *NewChannel, +UINT32 SendRingBufferSize, +UINT32 RecvRingBufferSize, +PVOID UserData, +UINT32 UserDataLen, +PFN_CHANNEL_CALLBACK pfnOnChannelCallback, +PVOID Context + ) +{ +int ret=0 ; +VMBUS_CHANNEL_OPEN_CHANNEL * openMsg; +VMBUS_CHANNEL_MSGINFO * openInfo; +void *in, *out; + +DPRINT_ENTER (VMBUS ); + +// Aligned to page size +ASSERT (!(SendRingBufferSize & (PAGE_SIZE -1 ))); +ASSERT (!(RecvRingBufferSize & (PAGE_SIZE -1 ))); + + NewChannel->OnChannelCallback = pfnOnChannelCallback; + NewChannel->ChannelCallbackContext = Context; + +// Allocate the ring buffer + out =PageAlloc ((SendRingBufferSize + RecvRingBufferSize) >>PAGE_SHIFT ); +//out = MemAllocZeroed(sendRingBufferSize + recvRingBufferSize); +ASSERT (out); +ASSERT (((ULONG_PTR )out & (PAGE_SIZE -1 )) ==0 ); + + in = (void *)((ULONG_PTR )out + SendRingBufferSize); + + NewChannel->RingBufferPages = out; + NewChannel->RingBufferPageCount = (SendRingBufferSize + RecvRingBufferSize) >>PAGE_SHIFT ; + +RingBufferInit (&NewChannel->Outbound, out, SendRingBufferSize); + +RingBufferInit (&NewChannel->Inbound, in, RecvRingBufferSize); + +// Establish the gpadl for the ring buffer +DPRINT_DBG (VMBUS ,"Establishing ring buffer's gpadl for channel %p..." , NewChannel); + + NewChannel->RingBufferGpadlHandle =0 ; + + ret =VmbusChannelEstablishGpadl (NewChannel, + NewChannel->Outbound.RingBuffer, + SendRingBufferSize + RecvRingBufferSize, + &NewChannel->RingBufferGpadlHandle); + +DPRINT_DBG (VMBUS ,"channel %p <relid %d gpadl 0x%x send ring %p size %d recv ring %p size %d, downstreamoffset %d>" , + NewChannel, + NewChannel->OfferMsg.ChildRelId, + NewChannel->RingBufferGpadlHandle, + NewChannel->Outbound.RingBuffer, + NewChannel->Outbound.RingSize, + NewChannel->Inbound.RingBuffer, + NewChannel->Inbound.RingSize, + SendRingBufferSize); + +// Create and init the channel open message + openInfo = + (VMBUS_CHANNEL_MSGINFO *)MemAlloc (sizeof (VMBUS_CHANNEL_MSGINFO ) +sizeof (VMBUS_CHANNEL_OPEN_CHANNEL )); +ASSERT (openInfo !=NULL ); + + openInfo->WaitEvent =WaitEventCreate (); + + openMsg = (VMBUS_CHANNEL_OPEN_CHANNEL *)openInfo->Msg; + openMsg->Header.MessageType = ChannelMessageOpenChannel; + openMsg->OpenId = NewChannel->OfferMsg.ChildRelId;// FIXME + openMsg->ChildRelId = NewChannel->OfferMsg.ChildRelId; + openMsg->RingBufferGpadlHandle = NewChannel->RingBufferGpadlHandle; +ASSERT (openMsg->RingBufferGpadlHandle); + openMsg->DownstreamRingBufferPageOffset = SendRingBufferSize >>PAGE_SHIFT ; + openMsg->ServerContextAreaGpadlHandle =0 ;// TODO + +ASSERT (UserDataLen <=MAX_USER_DEFINED_BYTES ); +if (UserDataLen) + { +memcpy (openMsg->UserData, UserData, UserDataLen); + } + +SpinlockAcquire (gVmbusConnection.ChannelMsgLock); +INSERT_TAIL_LIST (&gVmbusConnection.ChannelMsgList, &openInfo->MsgListEntry); +SpinlockRelease (gVmbusConnection.ChannelMsgLock); + +DPRINT_DBG (VMBUS ,"Sending channel open msg..." ); + + ret =VmbusPostMessage (openMsg,sizeof (VMBUS_CHANNEL_OPEN_CHANNEL )); +if (ret !=0 ) + { +DPRINT_ERR (VMBUS ,"unable to open channel - %d" , ret); + goto Cleanup; + } + +// FIXME: Need to time-out here +WaitEventWait (openInfo->WaitEvent); + +if (openInfo->Response.OpenResult.Status ==0 ) + { +DPRINT_INFO (VMBUS ,"channel <%p> open success!!" , NewChannel); + } +else + { +DPRINT_INFO (VMBUS ,"channel <%p> open failed - %d!!" , NewChannel, openInfo->Response.OpenResult.Status); + } + +Cleanup: +SpinlockAcquire (gVmbusConnection.ChannelMsgLock); +REMOVE_ENTRY_LIST (&openInfo->MsgListEntry); +SpinlockRelease (gVmbusConnection.ChannelMsgLock); + +WaitEventClose (openInfo->WaitEvent); +MemFree (openInfo); + +DPRINT_EXIT (VMBUS ); + +return 0 ; +} + +/*++; + +Name: +DumpGpadlBody() + +Description: +Dump the gpadl body message to the console for debugging purposes. + +--*/ +static void DumpGpadlBody ( +VMBUS_CHANNEL_GPADL_BODY *Gpadl, +UINT32 Len) +{ +int i=0 ; +int pfnCount=0 ; + + pfnCount = (Len -sizeof (VMBUS_CHANNEL_GPADL_BODY ))/sizeof (UINT64 ); +DPRINT_DBG (VMBUS ,"gpadl body - len %d pfn count %d" , Len, pfnCount); + +for (i=0 ; i< pfnCount; i++) + { +DPRINT_DBG (VMBUS ,"gpadl body - %d) pfn %llu" , i, Gpadl->Pfn[i]); + } +} + + +/*++; + +Name: +DumpGpadlHeader() + +Description: +Dump the gpadl header message to the console for debugging purposes. + +--*/ +static void DumpGpadlHeader ( +VMBUS_CHANNEL_GPADL_HEADER *Gpadl + ) +{ +int i=0 ,j=0 ; +int pageCount=0 ; + + +DPRINT_DBG (VMBUS ,"gpadl header - relid %d, range count %d, range buflen %d" , + Gpadl->ChildRelId, + Gpadl->RangeCount, + Gpadl->RangeBufLen); +for (i=0 ; i< Gpadl->RangeCount; i++) + { + pageCount = Gpadl->Range[i].ByteCount >>PAGE_SHIFT ; + pageCount = (pageCount >26 )?26 : pageCount; + +DPRINT_DBG (VMBUS ,"gpadl range %d - len %d offset %d page count %d" , + i, Gpadl->Range[i].ByteCount, Gpadl->Range[i].ByteOffset, pageCount); + +for (j=0 ; j< pageCount; j++) + { +DPRINT_DBG (VMBUS ,"%d) pfn %llu" , j, Gpadl->Range[i].PfnArray[j]); + } + } +} + +/*++; + +Name: +VmbusChannelCreateGpadlHeader() + +Description: +Creates a gpadl for the specified buffer + +--*/ +static int +VmbusChannelCreateGpadlHeader ( +PVOID Kbuffer,// from kmalloc() +UINT32 Size,// page-size multiple +VMBUS_CHANNEL_MSGINFO **MsgInfo, +UINT32 *MessageCount) +{ +int i; +int pageCount; +unsigned long long pfn; +VMBUS_CHANNEL_GPADL_HEADER * gpaHeader; +VMBUS_CHANNEL_GPADL_BODY * gpadlBody; +VMBUS_CHANNEL_MSGINFO * msgHeader; +VMBUS_CHANNEL_MSGINFO * msgBody; +UINT32 msgSize; + +int pfnSum, pfnCount, pfnLeft, pfnCurr, pfnSize; + +//ASSERT( (kbuffer & (PAGE_SIZE-1)) == 0); +ASSERT ( (Size & (PAGE_SIZE -1 )) ==0 ); + + pageCount = Size >>PAGE_SHIFT ; + pfn =GetPhysicalAddress (Kbuffer) >>PAGE_SHIFT ; + +// do we need a gpadl body msg + pfnSize =MAX_SIZE_CHANNEL_MESSAGE -sizeof (VMBUS_CHANNEL_GPADL_HEADER ) -sizeof (GPA_RANGE ); + pfnCount = pfnSize /sizeof (UINT64 ); + +if (pageCount > pfnCount)// we need a gpadl body + { +// fill in the header + msgSize =sizeof (VMBUS_CHANNEL_MSGINFO ) +sizeof (VMBUS_CHANNEL_GPADL_HEADER ) +sizeof (GPA_RANGE ) + pfnCount*sizeof (UINT64 ); + msgHeader =MemAllocZeroed (msgSize); + +INITIALIZE_LIST_HEAD (&msgHeader->SubMsgList); + msgHeader->MessageSize=msgSize; + + gpaHeader = (VMBUS_CHANNEL_GPADL_HEADER *)msgHeader->Msg; + gpaHeader->RangeCount =1 ; + gpaHeader->RangeBufLen =sizeof (GPA_RANGE ) + pageCount*sizeof (UINT64 ); + gpaHeader->Range[0 ].ByteOffset =0 ; + gpaHeader->Range[0 ].ByteCount = Size; +for (i=0 ; i<pfnCount; i++) + { + gpaHeader->Range[0 ].PfnArray[i] = pfn+i; + } + *MsgInfo = msgHeader; + *MessageCount =1 ; + + pfnSum = pfnCount; + pfnLeft = pageCount - pfnCount; + +// how many pfns can we fit + pfnSize =MAX_SIZE_CHANNEL_MESSAGE -sizeof (VMBUS_CHANNEL_GPADL_BODY ); + pfnCount = pfnSize /sizeof (UINT64 ); + +// fill in the body +while (pfnLeft) + { +if (pfnLeft > pfnCount) + { + pfnCurr = pfnCount; + } +else + { + pfnCurr = pfnLeft; + } + + msgSize =sizeof (VMBUS_CHANNEL_MSGINFO ) +sizeof (VMBUS_CHANNEL_GPADL_BODY ) + pfnCurr*sizeof (UINT64 ); + msgBody =MemAllocZeroed (msgSize); +ASSERT (msgBody); + msgBody->MessageSize = msgSize; + (*MessageCount)++; + gpadlBody = (VMBUS_CHANNEL_GPADL_BODY *)msgBody->Msg; + +// FIXME: Gpadl is UINT32 and we are using a pointer which could be 64-bit +//gpadlBody->Gpadl = kbuffer; +for (i=0 ; i<pfnCurr; i++) + { + gpadlBody->Pfn[i] = pfn + pfnSum + i; + } + +// add to msg header +INSERT_TAIL_LIST (&msgHeader->SubMsgList, &msgBody->MsgListEntry); + pfnSum += pfnCurr; + pfnLeft -= pfnCurr; + } + } +else + { +// everything fits in a header + msgSize =sizeof (VMBUS_CHANNEL_MSGINFO ) +sizeof (VMBUS_CHANNEL_GPADL_HEADER ) +sizeof (GPA_RANGE ) + pageCount*sizeof (UINT64 ); + msgHeader =MemAllocZeroed (msgSize); + msgHeader->MessageSize=msgSize; + + gpaHeader = (VMBUS_CHANNEL_GPADL_HEADER *)msgHeader->Msg; + gpaHeader->RangeCount =1 ; + gpaHeader->RangeBufLen =sizeof (GPA_RANGE ) + pageCount*sizeof (UINT64 ); + gpaHeader->Range[0 ].ByteOffset =0 ; + gpaHeader->Range[0 ].ByteCount = Size; +for (i=0 ; i<pageCount; i++) + { + gpaHeader->Range[0 ].PfnArray[i] = pfn+i; + } + + *MsgInfo = msgHeader; + *MessageCount =1 ; + } + +return 0 ; +} + + +/*++; + +Name: +VmbusChannelEstablishGpadl() + +Description: +Estabish a GPADL for the specified buffer + +--*/ +int +VmbusChannelEstablishGpadl ( +VMBUS_CHANNEL *Channel, +PVOID Kbuffer,// from kmalloc() +UINT32 Size,// page-size multiple +UINT32 *GpadlHandle + ) +{ +int ret=0 ; +VMBUS_CHANNEL_GPADL_HEADER * gpadlMsg; +VMBUS_CHANNEL_GPADL_BODY * gpadlBody; +//VMBUS_CHANNEL_GPADL_CREATED* gpadlCreated; + +VMBUS_CHANNEL_MSGINFO *msgInfo; +VMBUS_CHANNEL_MSGINFO *subMsgInfo; + +UINT32 msgCount; +LIST_ENTRY * anchor; +LIST_ENTRY * curr; +UINT32 nextGpadlHandle; + +DPRINT_ENTER (VMBUS ); + + nextGpadlHandle = gVmbusConnection.NextGpadlHandle; +InterlockedIncrement ((int *)&gVmbusConnection.NextGpadlHandle); + +VmbusChannelCreateGpadlHeader (Kbuffer, Size, &msgInfo, &msgCount); +ASSERT (msgInfo !=NULL ); +ASSERT (msgCount >0 ); + + msgInfo->WaitEvent =WaitEventCreate (); + gpadlMsg = (VMBUS_CHANNEL_GPADL_HEADER *)msgInfo->Msg; + gpadlMsg->Header.MessageType = ChannelMessageGpadlHeader; + gpadlMsg->ChildRelId = Channel->OfferMsg.ChildRelId; + gpadlMsg->Gpadl = nextGpadlHandle; + +DumpGpadlHeader (gpadlMsg); + +SpinlockAcquire (gVmbusConnection.ChannelMsgLock); +INSERT_TAIL_LIST (&gVmbusConnection.ChannelMsgList, &msgInfo->MsgListEntry); +SpinlockRelease (gVmbusConnection.ChannelMsgLock); + +DPRINT_DBG (VMBUS ,"buffer %p, size %d msg cnt %d" , Kbuffer, Size, msgCount); + +DPRINT_DBG (VMBUS ,"Sending GPADL Header - len %d" , msgInfo->MessageSize -sizeof (VMBUS_CHANNEL_MSGINFO )); + + ret =VmbusPostMessage (gpadlMsg, msgInfo->MessageSize -sizeof (VMBUS_CHANNEL_MSGINFO )); +if (ret !=0 ) + { +DPRINT_ERR (VMBUS ,"Unable to open channel - %d" , ret); + goto Cleanup; + } + +if (msgCount>1 ) + { + ITERATE_LIST_ENTRIES(anchor, curr, &msgInfo->SubMsgList) + { + subMsgInfo = (VMBUS_CHANNEL_MSGINFO *) curr; + gpadlBody = (VMBUS_CHANNEL_GPADL_BODY *)subMsgInfo->Msg; + + gpadlBody->Header.MessageType = ChannelMessageGpadlBody; + gpadlBody->Gpadl = nextGpadlHandle; + +DPRINT_DBG (VMBUS ,"Sending GPADL Body - len %d" , subMsgInfo->MessageSize -sizeof (VMBUS_CHANNEL_MSGINFO )); + +DumpGpadlBody (gpadlBody, subMsgInfo->MessageSize -sizeof (VMBUS_CHANNEL_MSGINFO )); + ret =VmbusPostMessage (gpadlBody, subMsgInfo->MessageSize -sizeof (VMBUS_CHANNEL_MSGINFO )); +ASSERT (ret ==0 ); + } + } +WaitEventWait (msgInfo->WaitEvent); + +// At this point, we received the gpadl created msg +DPRINT_DBG (VMBUS ,"Received GPADL created (relid %d, status %d handle %x)" , + Channel->OfferMsg.ChildRelId, + msgInfo->Response.GpadlCreated.CreationStatus, + gpadlMsg->Gpadl); + + *GpadlHandle = gpadlMsg->Gpadl; + +Cleanup: +SpinlockAcquire (gVmbusConnection.ChannelMsgLock); +REMOVE_ENTRY_LIST (&msgInfo->MsgListEntry); +SpinlockRelease (gVmbusConnection.ChannelMsgLock); + +WaitEventClose (msgInfo->WaitEvent); +MemFree (msgInfo); + +DPRINT_EXIT (VMBUS ); + +return ret; +} + + + +/*++; + +Name: +VmbusChannelTeardownGpadl() + +Description: +Teardown the specified GPADL handle + +--*/ +int +VmbusChannelTeardownGpadl ( +VMBUS_CHANNEL *Channel, +UINT32 GpadlHandle + ) +{ +int ret=0 ; +VMBUS_CHANNEL_GPADL_TEARDOWN *msg; +VMBUS_CHANNEL_MSGINFO * info; + +DPRINT_ENTER (VMBUS ); + +ASSERT (GpadlHandle !=0 ); + + info = + (VMBUS_CHANNEL_MSGINFO *)MemAlloc (sizeof (VMBUS_CHANNEL_MSGINFO ) +sizeof (VMBUS_CHANNEL_GPADL_TEARDOWN )); +ASSERT (info !=NULL ); + + info->WaitEvent =WaitEventCreate (); + + msg = (VMBUS_CHANNEL_GPADL_TEARDOWN *)info->Msg; + + msg->Header.MessageType = ChannelMessageGpadlTeardown; + msg->ChildRelId = Channel->OfferMsg.ChildRelId; + msg->Gpadl = GpadlHandle; + +SpinlockAcquire (gVmbusConnection.ChannelMsgLock); +INSERT_TAIL_LIST (&gVmbusConnection.ChannelMsgList, &info->MsgListEntry); +SpinlockRelease (gVmbusConnection.ChannelMsgLock); + + ret =VmbusPostMessage (msg,sizeof (VMBUS_CHANNEL_GPADL_TEARDOWN )); +if (ret !=0 ) + { +// TODO: + } + +WaitEventWait (info->WaitEvent); + +// Received a torndown response +SpinlockAcquire (gVmbusConnection.ChannelMsgLock); +REMOVE_ENTRY_LIST (&info->MsgListEntry); +SpinlockRelease (gVmbusConnection.ChannelMsgLock); + +WaitEventClose (info->WaitEvent); +MemFree (info); + +DPRINT_EXIT (VMBUS ); + +return ret; +} + + +/*++ + +Name: +VmbusChannelClose() + +Description: +Close the specified channel + +--*/ +VOID +VmbusChannelClose ( +VMBUS_CHANNEL *Channel + ) +{ +int ret=0 ; +VMBUS_CHANNEL_CLOSE_CHANNEL * msg; +VMBUS_CHANNEL_MSGINFO * info; + +DPRINT_ENTER (VMBUS ); + +// Stop callback and cancel the timer asap + Channel->OnChannelCallback =NULL ; +TimerStop (Channel->PollTimer); + +// Send a closing message + info = + (VMBUS_CHANNEL_MSGINFO *)MemAlloc (sizeof (VMBUS_CHANNEL_MSGINFO ) +sizeof (VMBUS_CHANNEL_CLOSE_CHANNEL )); +ASSERT (info !=NULL ); + +//info->waitEvent = WaitEventCreate(); + + msg = (VMBUS_CHANNEL_CLOSE_CHANNEL *)info->Msg; + msg->Header.MessageType = ChannelMessageCloseChannel; + msg->ChildRelId = Channel->OfferMsg.ChildRelId; + + ret =VmbusPostMessage (msg,sizeof (VMBUS_CHANNEL_CLOSE_CHANNEL )); +if (ret !=0 ) + { +// TODO: + } + +// Tear down the gpadl for the channel's ring buffer +if (Channel->RingBufferGpadlHandle) + { +VmbusChannelTeardownGpadl (Channel, Channel->RingBufferGpadlHandle); + } + +// TODO: Send a msg to release the childRelId + +// Cleanup the ring buffers for this channel +RingBufferCleanup (&Channel->Outbound); +RingBufferCleanup (&Channel->Inbound); + +PageFree (Channel->RingBufferPages, Channel->RingBufferPageCount); + +MemFree (info); + +// If we are closing the channel during an error path in opening the channel, don't free the channel +// since the caller will free the channel +if (Channel->State ==CHANNEL_OPEN_STATE ) + { +SpinlockAcquire (gVmbusConnection.ChannelLock); +REMOVE_ENTRY_LIST (&Channel->ListEntry); +SpinlockRelease (gVmbusConnection.ChannelLock); + +FreeVmbusChannel (Channel); + } + +DPRINT_EXIT (VMBUS ); +} + + +/*++ + +Name: +VmbusChannelSendPacket() + +Description: +Send the specified buffer on the given channel + +--*/ +int +VmbusChannelSendPacket ( +VMBUS_CHANNEL *Channel, +const PVOID Buffer, +UINT32 BufferLen, +UINT64 RequestId, +VMBUS_PACKET_TYPE Type, +UINT32 Flags +) +{ +int ret=0 ; +VMPACKET_DESCRIPTOR desc; +UINT32 packetLen =sizeof (VMPACKET_DESCRIPTOR ) + BufferLen; +UINT32 packetLenAligned =ALIGN_UP (packetLen,sizeof (UINT64 )); +SG_BUFFER_LIST bufferList[3 ]; +UINT64 alignedData=0 ; + +DPRINT_ENTER (VMBUS ); +DPRINT_DBG (VMBUS ,"channel %p buffer %p len %d" , Channel, Buffer, BufferLen); + +DumpVmbusChannel (Channel); + +ASSERT ((packetLenAligned - packetLen) <sizeof (UINT64 )); + +// Setup the descriptor + desc.Type = Type;//VmbusPacketTypeDataInBand; + desc.Flags = Flags;//VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED; + desc.DataOffset8 =sizeof (VMPACKET_DESCRIPTOR ) >>3 ;// in 8-bytes granularity + desc.Length8 = (UINT16 )(packetLenAligned >>3 ); + desc.TransactionId = RequestId; + + bufferList[0 ].Data = &desc; + bufferList[0 ].Length =sizeof (VMPACKET_DESCRIPTOR ); + + bufferList[1 ].Data = Buffer; + bufferList[1 ].Length = BufferLen; + + bufferList[2 ].Data = &alignedData; + bufferList[2 ].Length = packetLenAligned - packetLen; + + ret =RingBufferWrite ( + &Channel->Outbound, + bufferList, +3 ); + +// TODO: We should determine if this is optional +if (ret ==0 && !GetRingBufferInterruptMask (&Channel->Outbound)) + { +VmbusChannelSetEvent (Channel); + } + +DPRINT_EXIT (VMBUS ); + +return ret; +} + + +/*++ + +Name: +VmbusChannelSendPacketPageBuffer() + +Description: +Send a range of single-page buffer packets using a GPADL Direct packet type. + +--*/ +int +VmbusChannelSendPacketPageBuffer ( +VMBUS_CHANNEL *Channel, +PAGE_BUFFER PageBuffers[], +UINT32 PageCount, +PVOID Buffer, +UINT32 BufferLen, +UINT64 RequestId +) +{ +int ret=0 ; +int i=0 ; +VMBUS_CHANNEL_PACKET_PAGE_BUFFER desc; +UINT32 descSize; +UINT32 packetLen; +UINT32 packetLenAligned; +SG_BUFFER_LIST bufferList[3 ]; +UINT64 alignedData=0 ; + +DPRINT_ENTER (VMBUS ); + +ASSERT (PageCount <=MAX_PAGE_BUFFER_COUNT ); + +DumpVmbusChannel (Channel); + +// Adjust the size down since VMBUS_CHANNEL_PACKET_PAGE_BUFFER is the largest size we support + descSize =sizeof (VMBUS_CHANNEL_PACKET_PAGE_BUFFER ) - ((MAX_PAGE_BUFFER_COUNT - PageCount)*sizeof (PAGE_BUFFER )); + packetLen = descSize + BufferLen; + packetLenAligned =ALIGN_UP (packetLen,sizeof (UINT64 )); + +ASSERT ((packetLenAligned - packetLen) <sizeof (UINT64 )); + +// Setup the descriptor + desc.Type = VmbusPacketTypeDataUsingGpaDirect; + desc.Flags =VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED ; + desc.DataOffset8 = descSize >>3 ;// in 8-bytes grandularity + desc.Length8 = (UINT16 )(packetLenAligned >>3 ); + desc.TransactionId = RequestId; + desc.RangeCount = PageCount; + +for (i=0 ; i<PageCount; i++) + { + desc.Range[i].Length = PageBuffers[i].Length; + desc.Range[i].Offset = PageBuffers[i].Offset; + desc.Range[i].Pfn = PageBuffers[i].Pfn; + } + + bufferList[0 ].Data = &desc; + bufferList[0 ].Length = descSize; + + bufferList[1 ].Data = Buffer; + bufferList[1 ].Length = BufferLen; + + bufferList[2 ].Data = &alignedData; + bufferList[2 ].Length = packetLenAligned - packetLen; + + ret =RingBufferWrite ( + &Channel->Outbound, + bufferList, +3 ); + +// TODO: We should determine if this is optional +if (ret ==0 && !GetRingBufferInterruptMask (&Channel->Outbound)) + { +VmbusChannelSetEvent (Channel); + } + +DPRINT_EXIT (VMBUS ); + +return ret; +} + + + +/*++ + +Name: +VmbusChannelSendPacketMultiPageBuffer() + +Description: +Send a multi-page buffer packet using a GPADL Direct packet type. + +--*/ +int +VmbusChannelSendPacketMultiPageBuffer ( +VMBUS_CHANNEL *Channel, +MULTIPAGE_BUFFER *MultiPageBuffer, +PVOID Buffer, +UINT32 BufferLen, +UINT64 RequestId +) +{ +int ret=0 ; +VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER desc; +UINT32 descSize; +UINT32 packetLen; +UINT32 packetLenAligned; +SG_BUFFER_LIST bufferList[3 ]; +UINT64 alignedData=0 ; +UINT32 PfnCount =NUM_PAGES_SPANNED (MultiPageBuffer->Offset, MultiPageBuffer->Length); + +DPRINT_ENTER (VMBUS ); + +DumpVmbusChannel (Channel); + +DPRINT_DBG (VMBUS ,"data buffer - offset %u len %u pfn count %u" , MultiPageBuffer->Offset, MultiPageBuffer->Length, PfnCount); + +ASSERT (PfnCount >0 ); +ASSERT (PfnCount <=MAX_MULTIPAGE_BUFFER_COUNT ); + +// Adjust the size down since VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER is the largest size we support + descSize =sizeof (VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER ) - ((MAX_MULTIPAGE_BUFFER_COUNT - PfnCount)*sizeof (UINT64 )); + packetLen = descSize + BufferLen; + packetLenAligned =ALIGN_UP (packetLen,sizeof (UINT64 )); + +ASSERT ((packetLenAligned - packetLen) <sizeof (UINT64 )); + +// Setup the descriptor + desc.Type = VmbusPacketTypeDataUsingGpaDirect; + desc.Flags =VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED ; + desc.DataOffset8 = descSize >>3 ;// in 8-bytes grandularity + desc.Length8 = (UINT16 )(packetLenAligned >>3 ); + desc.TransactionId = RequestId; + desc.RangeCount =1 ; + + desc.Range.Length = MultiPageBuffer->Length; + desc.Range.Offset = MultiPageBuffer->Offset; + +memcpy (desc.Range.PfnArray, MultiPageBuffer->PfnArray, PfnCount*sizeof (UINT64 )); + + bufferList[0 ].Data = &desc; + bufferList[0 ].Length = descSize; + + bufferList[1 ].Data = Buffer; + bufferList[1 ].Length = BufferLen; + + bufferList[2 ].Data = &alignedData; + bufferList[2 ].Length = packetLenAligned - packetLen; + + ret =RingBufferWrite ( + &Channel->Outbound, + bufferList, +3 ); + +// TODO: We should determine if this is optional +if (ret ==0 && !GetRingBufferInterruptMask (&Channel->Outbound)) + { +VmbusChannelSetEvent (Channel); + } + +DPRINT_EXIT (VMBUS ); + +return ret; +} + + +/*++ + +Name: +VmbusChannelRecvPacket() + +Description: +Retrieve the user packet on the specified channel + +--*/ +// TODO: Do we ever receive a gpa direct packet other than the ones we send ? +int +VmbusChannelRecvPacket ( +VMBUS_CHANNEL *Channel, +PVOID Buffer, +UINT32 BufferLen, +UINT32 * BufferActualLen, +UINT64 * RequestId + ) +{ +VMPACKET_DESCRIPTOR desc; +UINT32 packetLen; +UINT32 userLen; +int ret; + +DPRINT_ENTER (VMBUS ); + + *BufferActualLen =0 ; + *RequestId =0 ; + +SpinlockAcquire (Channel->InboundLock); + + ret =RingBufferPeek (&Channel->Inbound, &desc,sizeof (VMPACKET_DESCRIPTOR )); +if (ret !=0 ) + { +SpinlockRelease (Channel->InboundLock); + +//DPRINT_DBG(VMBUS, "nothing to read!!"); +DPRINT_EXIT (VMBUS ); +return 0 ; + } + +//VmbusChannelClearEvent(Channel); + + packetLen = desc.Length8 <<3 ; + userLen = packetLen - (desc.DataOffset8 <<3 ); +//ASSERT(userLen > 0); + +DPRINT_DBG (VMBUS ,"packet received on channel %p relid %d <type %d flag %d tid %llx pktlen %d datalen %d> " , + Channel, + Channel->OfferMsg.ChildRelId, + desc.Type, + desc.Flags, + desc.TransactionId, packetLen, userLen); + + *BufferActualLen = userLen; + +if (userLen > BufferLen) + { +SpinlockRelease (Channel->InboundLock); + +DPRINT_ERR (VMBUS ,"buffer too small - got %d needs %d" , BufferLen, userLen); +DPRINT_EXIT (VMBUS ); + +return -1 ; + } + + *RequestId = desc.TransactionId; + +// Copy over the packet to the user buffer + ret =RingBufferRead (&Channel->Inbound, Buffer, userLen, (desc.DataOffset8 <<3 )); + +SpinlockRelease (Channel->InboundLock); + +DPRINT_EXIT (VMBUS ); + +return 0 ; +} + +/*++ + +Name: +VmbusChannelRecvPacketRaw() + +Description: +Retrieve the raw packet on the specified channel + +--*/ +int +VmbusChannelRecvPacketRaw ( +VMBUS_CHANNEL *Channel, +PVOID Buffer, +UINT32 BufferLen, +UINT32 * BufferActualLen, +UINT64 * RequestId + ) +{ +VMPACKET_DESCRIPTOR desc; +UINT32 packetLen; +UINT32 userLen; +int ret; + +DPRINT_ENTER (VMBUS ); + + *BufferActualLen =0 ; + *RequestId =0 ; + +SpinlockAcquire (Channel->InboundLock); + + ret =RingBufferPeek (&Channel->Inbound, &desc,sizeof (VMPACKET_DESCRIPTOR )); +if (ret !=0 ) + { +SpinlockRelease (Channel->InboundLock); + +//DPRINT_DBG(VMBUS, "nothing to read!!"); +DPRINT_EXIT (VMBUS ); +return 0 ; + } + +//VmbusChannelClearEvent(Channel); + + packetLen = desc.Length8 <<3 ; + userLen = packetLen - (desc.DataOffset8 <<3 ); + +DPRINT_DBG (VMBUS ,"packet received on channel %p relid %d <type %d flag %d tid %llx pktlen %d datalen %d> " , + Channel, + Channel->OfferMsg.ChildRelId, + desc.Type, + desc.Flags, + desc.TransactionId, packetLen, userLen); + + *BufferActualLen = packetLen; + +if (packetLen > BufferLen) + { +SpinlockRelease (Channel->InboundLock); + +DPRINT_ERR (VMBUS ,"buffer too small - needed %d bytes but got space for only %d bytes" , packetLen, BufferLen); +DPRINT_EXIT (VMBUS ); +return -2 ; + } + + *RequestId = desc.TransactionId; + +// Copy over the entire packet to the user buffer + ret =RingBufferRead (&Channel->Inbound, Buffer, packetLen,0 ); + +SpinlockRelease (Channel->InboundLock); + +DPRINT_EXIT (VMBUS ); + +return 0 ; +} + + +/*++ + +Name: +VmbusChannelOnChannelEvent() + +Description: +Channel event callback + +--*/ +void +VmbusChannelOnChannelEvent ( +VMBUS_CHANNEL *Channel + ) +{ +DumpVmbusChannel (Channel); +ASSERT (Channel->OnChannelCallback); +#ifdef ENABLE_POLLING +TimerStop (Channel->PollTimer); + Channel->OnChannelCallback (Channel->ChannelCallbackContext); +TimerStart (Channel->PollTimer,100 /* 100us */ ); +#else + Channel->OnChannelCallback (Channel->ChannelCallbackContext); +#endif +} + +/*++ + +Name: +VmbusChannelOnTimer() + +Description: +Timer event callback + +--*/ +void +VmbusChannelOnTimer ( +void *Context + ) +{ +VMBUS_CHANNEL *channel = (VMBUS_CHANNEL *)Context; + +if (channel->OnChannelCallback) + { + channel->OnChannelCallback (channel->ChannelCallbackContext); +#ifdef ENABLE_POLLING +TimerStart (channel->PollTimer,100 /* 100us */ ); +#endif + } +} + + +/*++ + +Name: +DumpVmbusChannel() + +Description: +Dump vmbus channel info to the console + +--*/ +static void +DumpVmbusChannel ( +VMBUS_CHANNEL *Channel + ) +{ +DPRINT_DBG (VMBUS ,"Channel (%d)" , Channel->OfferMsg.ChildRelId); +DumpRingInfo (&Channel->Outbound,"Outbound " ); +DumpRingInfo (&Channel->Inbound,"Inbound " ); +} + + +// eof
drivers/staging/hv/Channel.h new file +157 -0
157 lines not on this page · raw message
drivers/staging/hv/ChannelInterface.c new file +222 -0
222 lines not on this page · raw message
drivers/staging/hv/ChannelInterface.h new file +41 -0
41 lines not on this page · raw message
drivers/staging/hv/ChannelMgmt.c new file +826 -0
826 lines not on this page · raw message
drivers/staging/hv/ChannelMgmt.h new file +156 -0
156 lines not on this page · raw message
drivers/staging/hv/Connection.c new file +432 -0
399 lines not on this page · raw message
drivers/staging/hv/Hv.c new file +672 -0
672 lines not on this page · raw message
drivers/staging/hv/Hv.h new file +184 -0
184 lines not on this page · raw message
drivers/staging/hv/osd.c new file +500 -0
500 lines not on this page · raw message
drivers/staging/hv/RingBuffer.c new file +630 -0
630 lines not on this page · raw message
drivers/staging/hv/RingBuffer.h new file +123 -0
123 lines not on this page · raw message
drivers/staging/hv/Sources.c new file +31 -0
Lines of this file are not shown. View the raw message.
drivers/staging/hv/VersionInfo.h new file +29 -0
Lines of this file are not shown. View the raw message.
drivers/staging/hv/Vmbus.c new file +508 -0
508 lines not on this page · raw message
drivers/staging/hv/vmbus_drv.c new file +1228 -0
1,228 lines not on this page · raw message
drivers/staging/hv/VmbusPrivate.h new file +170 -0
170 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
PATCH 4/54 Staging: hv: add the Hyper-V virtual block driver
In reply to Greg Kroah-HartmanFrom: Hank Janssen <[email protected]>
This is the virtual block driver when running Linux on top of Hyper-V.
--- drivers/staging/hv/BlkVsc.c | 107 ++ drivers/staging/hv/blkvsc_drv.c | 1547 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1654 insertions(+) create mode 100644 drivers/staging/hv/blkvsc.c
drivers/staging/hv/BlkVsc.c new file +107 -0
@@ -0,0 +1,107 @@ +/* +* +* Copyright (c) 2009, Microsoft Corporation. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program; if not, write to the Free Software Foundation, Inc., 59 Temple +* Place - Suite 330, Boston, MA 02111-1307 USA. +* +* Authors: +* Hank Janssen <[email protected]> +* +*/ + + +#include "../storvsc/StorVsc.c" + +static const char * gBlkDriverName="blkvsc" ; + +//{32412632-86cb-44a2-9b5c-50d1417354f5} +static const GUID gBlkVscDeviceType={ + .Data = {0x32 ,0x26 ,0x41 ,0x32 ,0xcb ,0x86 ,0xa2 ,0x44 ,0x9b ,0x5c ,0x50 ,0xd1 ,0x41 ,0x73 ,0x54 ,0xf5 } +}; + +// Static routines +static int +BlkVscOnDeviceAdd ( +DEVICE_OBJECT *Device, +void *AdditionalInfo + ); + + +int +BlkVscInitialize ( +DRIVER_OBJECT *Driver + ) +{ +STORVSC_DRIVER_OBJECT * storDriver = (STORVSC_DRIVER_OBJECT *)Driver; +int ret=0 ; + +DPRINT_ENTER (BLKVSC ); + +// Make sure we are at least 2 pages since 1 page is used for control +ASSERT (storDriver->RingBufferSize >= (PAGE_SIZE <<1 )); + + Driver->name = gBlkDriverName; +memcpy (&Driver->deviceType, &gBlkVscDeviceType,sizeof (GUID )); + + storDriver->RequestExtSize =sizeof (STORVSC_REQUEST_EXTENSION ); +// Divide the ring buffer data size (which is 1 page less than the ring buffer size since that page is reserved for the ring buffer indices) +// by the max request size (which is VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER + VSTOR_PACKET + UINT64) + storDriver->MaxOutstandingRequestsPerChannel = + ((storDriver->RingBufferSize -PAGE_SIZE ) /ALIGN_UP (MAX_MULTIPAGE_BUFFER_PACKET +sizeof (VSTOR_PACKET ) +sizeof (UINT64 ),sizeof (UINT64 ))); + +DPRINT_INFO (BLKVSC ,"max io outstd %u" , storDriver->MaxOutstandingRequestsPerChannel); + +// Setup the dispatch table + storDriver->Base.OnDeviceAdd = BlkVscOnDeviceAdd; + storDriver->Base.OnDeviceRemove = StorVscOnDeviceRemove; + storDriver->Base.OnCleanup = StorVscOnCleanup; + + storDriver->OnIORequest = StorVscOnIORequest; + +DPRINT_EXIT (BLKVSC ); + +return ret; +} + +int +BlkVscOnDeviceAdd ( +DEVICE_OBJECT *Device, +void *AdditionalInfo + ) +{ +int ret=0 ; +STORVSC_DEVICE_INFO *deviceInfo = (STORVSC_DEVICE_INFO *)AdditionalInfo; + +DPRINT_ENTER (BLKVSC ); + + ret =StorVscOnDeviceAdd (Device, AdditionalInfo); + +if (ret !=0 ) + { +DPRINT_EXIT (BLKVSC ); + +return ret; + } + +// We need to use the device instance guid to set the path and target id. For IDE devices, the +// device instance id is formatted as <bus id> - <device id> - 8899 - 000000000000. + deviceInfo->PathId = Device->deviceInstance.Data[3 ] <<24 | Device->deviceInstance.Data[2 ] <<16 | + Device->deviceInstance.Data[1 ] <<8 |Device->deviceInstance.Data[0 ]; + + deviceInfo->TargetId = Device->deviceInstance.Data[5 ] <<8 | Device->deviceInstance.Data[4 ]; + +DPRINT_EXIT (BLKVSC ); + +return ret; +}
drivers/staging/hv/blkvsc_drv.c new file +1547 -0
1,547 lines not on this page · raw message
PATCH 5/54 Staging: hv: add the Hyper-V virtual network driver
In reply to Greg Kroah-HartmanFrom: Hank Janssen <[email protected]>
This is the virtual network driver when running Linux on top of Hyper-V.
--- drivers/staging/hv/NetVsc.c | 1499 +++++++++++++++++++++++++++++++++++++++ drivers/staging/hv/NetVsc.h | 91 ++ drivers/staging/hv/RndisFilter.c | 1162 ++++++++++++++++++++++++++++++ drivers/staging/hv/RndisFilter.h | 61 + drivers/staging/hv/netvsc_drv.c | 720 ++++++++++++++++++ 5 files changed, 3533 insertions(+) create mode 100644 drivers/staging/hv/netvsc.c
drivers/staging/hv/NetVsc.c new file +1499 -0
@@ -0,0 +1,1499 @@ +/* +* +* Copyright (c) 2009, Microsoft Corporation. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program; if not, write to the Free Software Foundation, Inc., 59 Temple +* Place - Suite 330, Boston, MA 02111-1307 USA. +* +* Authors: +* Hank Janssen <[email protected]> +* +*/ + + +#include "logging.h" +#include "NetVsc.h" +#include "RndisFilter.h" + + +// +// Globals +// +static const char * gDriverName="netvsc" ; + +// {F8615163-DF3E-46c5-913F-F2D2F965ED0E} +static const GUID gNetVscDeviceType={ + .Data = {0x63 ,0x51 ,0x61 ,0xF8 ,0x3E ,0xDF ,0xc5 ,0x46 ,0x91 ,0x3F ,0xF2 ,0xD2 ,0xF9 ,0x65 ,0xED ,0x0E } +}; + + +// +// Internal routines +// +static int +NetVscOnDeviceAdd ( +DEVICE_OBJECT *Device, +void *AdditionalInfo + ); + +static int +NetVscOnDeviceRemove ( +DEVICE_OBJECT *Device + ); + +static void +NetVscOnCleanup ( +DRIVER_OBJECT *Driver + ); + +static void +NetVscOnChannelCallback ( +PVOID context + ); + +static int +NetVscInitializeSendBufferWithNetVsp ( +DEVICE_OBJECT *Device + ); + +static int +NetVscInitializeReceiveBufferWithNetVsp ( +DEVICE_OBJECT *Device + ); + +static int +NetVscDestroySendBuffer ( +NETVSC_DEVICE *NetDevice + ); + +static int +NetVscDestroyReceiveBuffer ( +NETVSC_DEVICE *NetDevice + ); + +static int +NetVscConnectToVsp ( +DEVICE_OBJECT *Device + ); + +static void +NetVscOnSendCompletion ( +DEVICE_OBJECT *Device, +VMPACKET_DESCRIPTOR *Packet + ); + +static int +NetVscOnSend ( +DEVICE_OBJECT *Device, +NETVSC_PACKET *Packet + ); + +static void +NetVscOnReceive ( +DEVICE_OBJECT *Device, +VMPACKET_DESCRIPTOR *Packet + ); + +static void +NetVscOnReceiveCompletion ( +PVOID Context + ); + +static void +NetVscSendReceiveCompletion ( +DEVICE_OBJECT *Device, +UINT64 TransactionId + ); + +static inline NETVSC_DEVICE *AllocNetDevice (DEVICE_OBJECT *Device) +{ +NETVSC_DEVICE *netDevice; + + netDevice =MemAllocZeroed (sizeof (NETVSC_DEVICE )); +if (!netDevice) +return NULL ; + +// Set to 2 to allow both inbound and outbound traffic +InterlockedCompareExchange (&netDevice->RefCount,2 ,0 ); + + netDevice->Device = Device; + Device->Extension = netDevice; + +return netDevice; +} + +static inline void FreeNetDevice (NETVSC_DEVICE *Device) +{ +ASSERT (Device->RefCount ==0 ); + Device->Device->Extension =NULL ; +MemFree (Device); +} + + +// Get the net device object iff exists and its refcount > 1 +static inline NETVSC_DEVICE *GetOutboundNetDevice (DEVICE_OBJECT *Device) +{ +NETVSC_DEVICE *netDevice; + + netDevice = (NETVSC_DEVICE *)Device->Extension; +if (netDevice && netDevice->RefCount >1 ) + { +InterlockedIncrement (&netDevice->RefCount); + } +else + { + netDevice =NULL ; + } + +return netDevice; +} + +// Get the net device object iff exists and its refcount > 0 +static inline NETVSC_DEVICE *GetInboundNetDevice (DEVICE_OBJECT *Device) +{ +NETVSC_DEVICE *netDevice; + + netDevice = (NETVSC_DEVICE *)Device->Extension; +if (netDevice && netDevice->RefCount) + { +InterlockedIncrement (&netDevice->RefCount); + } +else + { + netDevice =NULL ; + } + +return netDevice; +} + +static inline void PutNetDevice (DEVICE_OBJECT *Device) +{ +NETVSC_DEVICE *netDevice; + + netDevice = (NETVSC_DEVICE *)Device->Extension; +ASSERT (netDevice); + +InterlockedDecrement (&netDevice->RefCount); +} + +static inline NETVSC_DEVICE *ReleaseOutboundNetDevice (DEVICE_OBJECT *Device) +{ +NETVSC_DEVICE *netDevice; + + netDevice = (NETVSC_DEVICE *)Device->Extension; +if (netDevice ==NULL ) +return NULL ; + +// Busy wait until the ref drop to 2, then set it to 1 +while (InterlockedCompareExchange (&netDevice->RefCount,1 ,2 ) !=2 ) + { +Sleep (100 ); + } + +return netDevice; +} + +static inline NETVSC_DEVICE *ReleaseInboundNetDevice (DEVICE_OBJECT *Device) +{ +NETVSC_DEVICE *netDevice; + + netDevice = (NETVSC_DEVICE *)Device->Extension; +if (netDevice ==NULL ) +return NULL ; + +// Busy wait until the ref drop to 1, then set it to 0 +while (InterlockedCompareExchange (&netDevice->RefCount,0 ,1 ) !=1 ) + { +Sleep (100 ); + } + + Device->Extension =NULL ; +return netDevice; +} + +/*++; + + +Name: +NetVscInitialize() + +Description: +Main entry point + +--*/ +int +NetVscInitialize ( +DRIVER_OBJECT *drv + ) +{ +NETVSC_DRIVER_OBJECT * driver = (NETVSC_DRIVER_OBJECT *)drv; +int ret=0 ; + +DPRINT_ENTER (NETVSC ); + +DPRINT_DBG (NETVSC ,"sizeof(NETVSC_PACKET)=%d, sizeof(NVSP_MESSAGE)=%d, sizeof(VMTRANSFER_PAGE_PACKET_HEADER)=%d" , +sizeof (NETVSC_PACKET ),sizeof (NVSP_MESSAGE ),sizeof (VMTRANSFER_PAGE_PACKET_HEADER )); + +// Make sure we are at least 2 pages since 1 page is used for control +ASSERT (driver->RingBufferSize >= (PAGE_SIZE <<1 )); + + drv->name = gDriverName; +memcpy (&drv->deviceType, &gNetVscDeviceType,sizeof (GUID )); + +// Make sure it is set by the caller +ASSERT (driver->OnReceiveCallback); +ASSERT (driver->OnLinkStatusChanged); + +// Setup the dispatch table + driver->Base.OnDeviceAdd = NetVscOnDeviceAdd; + driver->Base.OnDeviceRemove = NetVscOnDeviceRemove; + driver->Base.OnCleanup = NetVscOnCleanup; + + driver->OnSend = NetVscOnSend; + +RndisFilterInit (driver); + +DPRINT_EXIT (NETVSC ); + +return ret; +} + +static int +NetVscInitializeReceiveBufferWithNetVsp ( +DEVICE_OBJECT *Device + ) +{ +int ret=0 ; +NETVSC_DEVICE *netDevice; +NVSP_MESSAGE *initPacket; + +DPRINT_ENTER (NETVSC ); + + netDevice =GetOutboundNetDevice (Device); +if (!netDevice) + { +DPRINT_ERR (NETVSC ,"unable to get net device...device being destroyed?" ); +DPRINT_EXIT (NETVSC ); +return -1 ; + } +ASSERT (netDevice->ReceiveBufferSize >0 ); +ASSERT ((netDevice->ReceiveBufferSize & (PAGE_SIZE -1 )) ==0 );// page-size grandularity + + netDevice->ReceiveBuffer =PageAlloc (netDevice->ReceiveBufferSize >>PAGE_SHIFT ); +if (!netDevice->ReceiveBuffer) + { +DPRINT_ERR (NETVSC ,"unable to allocate receive buffer of size %d" , netDevice->ReceiveBufferSize); + ret =-1 ; + goto Cleanup; + } +ASSERT (((ULONG_PTR )netDevice->ReceiveBuffer & (PAGE_SIZE -1 )) ==0 );// page-aligned buffer + +DPRINT_INFO (NETVSC ,"Establishing receive buffer's GPADL..." ); + +// Establish the gpadl handle for this buffer on this channel. +// Note: This call uses the vmbus connection rather than the channel to establish +// the gpadl handle. + ret = Device->Driver->VmbusChannelInterface.EstablishGpadl (Device, + netDevice->ReceiveBuffer, + netDevice->ReceiveBufferSize, + &netDevice->ReceiveBufferGpadlHandle); + +if (ret !=0 ) + { +DPRINT_ERR (NETVSC ,"unable to establish receive buffer's gpadl" ); + goto Cleanup; + } + +//WaitEventWait(ext->ChannelInitEvent); + +// Notify the NetVsp of the gpadl handle +DPRINT_INFO (NETVSC ,"Sending NvspMessage1TypeSendReceiveBuffer..." ); + + initPacket = &netDevice->ChannelInitPacket; + +memset (initPacket,0 ,sizeof (NVSP_MESSAGE )); + + initPacket->Header.MessageType = NvspMessage1TypeSendReceiveBuffer; + initPacket->Messages.Version1Messages.SendReceiveBuffer.GpadlHandle = netDevice->ReceiveBufferGpadlHandle; + initPacket->Messages.Version1Messages.SendReceiveBuffer.Id =NETVSC_RECEIVE_BUFFER_ID ; + +// Send the gpadl notification request + ret = Device->Driver->VmbusChannelInterface.SendPacket (Device, + initPacket, +sizeof (NVSP_MESSAGE ), + (ULONG_PTR )initPacket, + VmbusPacketTypeDataInBand, +VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED ); +if (ret !=0 ) + { +DPRINT_ERR (NETVSC ,"unable to send receive buffer's gpadl to netvsp" ); + goto Cleanup; + } + +WaitEventWait (netDevice->ChannelInitEvent); + +// Check the response +if (initPacket->Messages.Version1Messages.SendReceiveBufferComplete.Status != NvspStatusSuccess) + { +DPRINT_ERR (NETVSC , +"Unable to complete receive buffer initialzation with NetVsp - status %d" , + initPacket->Messages.Version1Messages.SendReceiveBufferComplete.Status); + ret =-1 ; + goto Cleanup; + } + +// Parse the response +ASSERT (netDevice->ReceiveSectionCount ==0 ); +ASSERT (netDevice->ReceiveSections ==NULL ); + + netDevice->ReceiveSectionCount = initPacket->Messages.Version1Messages.SendReceiveBufferComplete.NumSections; + + netDevice->ReceiveSections =MemAlloc (netDevice->ReceiveSectionCount *sizeof (NVSP_1_RECEIVE_BUFFER_SECTION )); +if (netDevice->ReceiveSections ==NULL ) + { + ret =-1 ; + goto Cleanup; + } + +memcpy (netDevice->ReceiveSections, + initPacket->Messages.Version1Messages.SendReceiveBufferComplete.Sections, + netDevice->ReceiveSectionCount *sizeof (NVSP_1_RECEIVE_BUFFER_SECTION )); + +DPRINT_INFO (NETVSC , +"Receive sections info (count %d, offset %d, endoffset %d, suballoc size %d, num suballocs %d)" , + netDevice->ReceiveSectionCount, netDevice->ReceiveSections[0 ].Offset, netDevice->ReceiveSections[0 ].EndOffset, + netDevice->ReceiveSections[0 ].SubAllocationSize, netDevice->ReceiveSections[0 ].NumSubAllocations); + + +//For 1st release, there should only be 1 section that represents the entire receive buffer +if (netDevice->ReceiveSectionCount !=1 || + netDevice->ReceiveSections->Offset !=0 ) + { + ret =-1 ; + goto Cleanup; + } + + goto Exit; + +Cleanup: +NetVscDestroyReceiveBuffer (netDevice); + +Exit: +PutNetDevice (Device); +DPRINT_EXIT (NETVSC ); +return ret; +} + + +static int +NetVscInitializeSendBufferWithNetVsp ( +DEVICE_OBJECT *Device + ) +{ +int ret=0 ; +NETVSC_DEVICE *netDevice; +NVSP_MESSAGE *initPacket; + +DPRINT_ENTER (NETVSC ); + + netDevice =GetOutboundNetDevice (Device); +if (!netDevice) + { +DPRINT_ERR (NETVSC ,"unable to get net device...device being destroyed?" ); +DPRINT_EXIT (NETVSC ); +return -1 ; + } +ASSERT (netDevice->SendBufferSize >0 ); +ASSERT ((netDevice->SendBufferSize & (PAGE_SIZE -1 )) ==0 );// page-size grandularity + + netDevice->SendBuffer =PageAlloc (netDevice->SendBufferSize >>PAGE_SHIFT ); +if (!netDevice->SendBuffer) + { +DPRINT_ERR (NETVSC ,"unable to allocate send buffer of size %d" , netDevice->SendBufferSize); + ret =-1 ; + goto Cleanup; + } +ASSERT (((ULONG_PTR )netDevice->SendBuffer & (PAGE_SIZE -1 )) ==0 );// page-aligned buffer + +DPRINT_INFO (NETVSC ,"Establishing send buffer's GPADL..." ); + +// Establish the gpadl handle for this buffer on this channel. +// Note: This call uses the vmbus connection rather than the channel to establish +// the gpadl handle. + ret = Device->Driver->VmbusChannelInterface.EstablishGpadl (Device, + netDevice->SendBuffer, + netDevice->SendBufferSize, + &netDevice->SendBufferGpadlHandle); + +if (ret !=0 ) + { +DPRINT_ERR (NETVSC ,"unable to establish send buffer's gpadl" ); + goto Cleanup; + } + +//WaitEventWait(ext->ChannelInitEvent); + +// Notify the NetVsp of the gpadl handle +DPRINT_INFO (NETVSC ,"Sending NvspMessage1TypeSendSendBuffer..." ); + + initPacket = &netDevice->ChannelInitPacket; + +memset (initPacket,0 ,sizeof (NVSP_MESSAGE )); + + initPacket->Header.MessageType = NvspMessage1TypeSendSendBuffer; + initPacket->Messages.Version1Messages.SendReceiveBuffer.GpadlHandle = netDevice->SendBufferGpadlHandle; + initPacket->Messages.Version1Messages.SendReceiveBuffer.Id =NETVSC_SEND_BUFFER_ID ; + +// Send the gpadl notification request + ret = Device->Driver->VmbusChannelInterface.SendPacket (Device, + initPacket, +sizeof (NVSP_MESSAGE ), + (ULONG_PTR )initPacket, + VmbusPacketTypeDataInBand, +VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED ); +if (ret !=0 ) + { +DPRINT_ERR (NETVSC ,"unable to send receive buffer's gpadl to netvsp" ); + goto Cleanup; + } + +WaitEventWait (netDevice->ChannelInitEvent); + +// Check the response +if (initPacket->Messages.Version1Messages.SendSendBufferComplete.Status != NvspStatusSuccess) + { +DPRINT_ERR (NETVSC , +"Unable to complete send buffer initialzation with NetVsp - status %d" , + initPacket->Messages.Version1Messages.SendSendBufferComplete.Status); + ret =-1 ; + goto Cleanup; + } + + netDevice->SendSectionSize = initPacket->Messages.Version1Messages.SendSendBufferComplete.SectionSize; + + goto Exit; + +Cleanup: +NetVscDestroySendBuffer (netDevice); + +Exit: +PutNetDevice (Device); +DPRINT_EXIT (NETVSC ); +return ret; +} + +static int +NetVscDestroyReceiveBuffer ( +NETVSC_DEVICE *NetDevice + ) +{ +NVSP_MESSAGE *revokePacket; +int ret=0 ; + + +DPRINT_ENTER (NETVSC ); + +// If we got a section count, it means we received a SendReceiveBufferComplete msg +// (ie sent NvspMessage1TypeSendReceiveBuffer msg) therefore, we need to send a revoke msg here +if (NetDevice->ReceiveSectionCount) + { +DPRINT_INFO (NETVSC ,"Sending NvspMessage1TypeRevokeReceiveBuffer..." ); + +// Send the revoke receive buffer + revokePacket = &NetDevice->RevokePacket; +memset (revokePacket,0 ,sizeof (NVSP_MESSAGE )); + + revokePacket->Header.MessageType = NvspMessage1TypeRevokeReceiveBuffer; + revokePacket->Messages.Version1Messages.RevokeReceiveBuffer.Id =NETVSC_RECEIVE_BUFFER_ID ; + + ret = NetDevice->Device->Driver->VmbusChannelInterface.SendPacket (NetDevice->Device, + revokePacket, +sizeof (NVSP_MESSAGE ), + (ULONG_PTR )revokePacket, + VmbusPacketTypeDataInBand, +0 ); +// If we failed here, we might as well return and have a leak rather than continue and a bugchk +if (ret !=0 ) + { +DPRINT_ERR (NETVSC ,"unable to send revoke receive buffer to netvsp" ); +DPRINT_EXIT (NETVSC ); +return -1 ; + } + } + +// Teardown the gpadl on the vsp end +if (NetDevice->ReceiveBufferGpadlHandle) + { +DPRINT_INFO (NETVSC ,"Tearing down receive buffer's GPADL..." ); + + ret = NetDevice->Device->Driver->VmbusChannelInterface.TeardownGpadl (NetDevice->Device, + NetDevice->ReceiveBufferGpadlHandle); + +// If we failed here, we might as well return and have a leak rather than continue and a bugchk +if (ret !=0 ) + { +DPRINT_ERR (NETVSC ,"unable to teardown receive buffer's gpadl" ); +DPRINT_EXIT (NETVSC ); +return -1 ; + } + NetDevice->ReceiveBufferGpadlHandle =0 ; + } + +if (NetDevice->ReceiveBuffer) + { +DPRINT_INFO (NETVSC ,"Freeing up receive buffer..." ); + +// Free up the receive buffer +PageFree (NetDevice->ReceiveBuffer, NetDevice->ReceiveBufferSize >>PAGE_SHIFT ); + NetDevice->ReceiveBuffer =NULL ; + } + +if (NetDevice->ReceiveSections) + { +MemFree (NetDevice->ReceiveSections); + NetDevice->ReceiveSections =NULL ; + NetDevice->ReceiveSectionCount =0 ; + } + +DPRINT_EXIT (NETVSC ); + +return ret; +} + + + + +static int +NetVscDestroySendBuffer ( +NETVSC_DEVICE *NetDevice + ) +{ +NVSP_MESSAGE *revokePacket; +int ret=0 ; + + +DPRINT_ENTER (NETVSC ); + +// If we got a section count, it means we received a SendReceiveBufferComplete msg +// (ie sent NvspMessage1TypeSendReceiveBuffer msg) therefore, we need to send a revoke msg here +if (NetDevice->SendSectionSize) + { +DPRINT_INFO (NETVSC ,"Sending NvspMessage1TypeRevokeSendBuffer..." ); + +// Send the revoke send buffer + revokePacket = &NetDevice->RevokePacket; +memset (revokePacket,0 ,sizeof (NVSP_MESSAGE )); + + revokePacket->Header.MessageType = NvspMessage1TypeRevokeSendBuffer; + revokePacket->Messages.Version1Messages.RevokeSendBuffer.Id =NETVSC_SEND_BUFFER_ID ; + + ret = NetDevice->Device->Driver->VmbusChannelInterface.SendPacket (NetDevice->Device, + revokePacket, +sizeof (NVSP_MESSAGE ), + (ULONG_PTR )revokePacket, + VmbusPacketTypeDataInBand, +0 ); +// If we failed here, we might as well return and have a leak rather than continue and a bugchk +if (ret !=0 ) + { +DPRINT_ERR (NETVSC ,"unable to send revoke send buffer to netvsp" ); +DPRINT_EXIT (NETVSC ); +return -1 ; + } + } + +// Teardown the gpadl on the vsp end +if (NetDevice->SendBufferGpadlHandle) + { +DPRINT_INFO (NETVSC ,"Tearing down send buffer's GPADL..." ); + + ret = NetDevice->Device->Driver->VmbusChannelInterface.TeardownGpadl (NetDevice->Device, + NetDevice->SendBufferGpadlHandle); + +// If we failed here, we might as well return and have a leak rather than continue and a bugchk +if (ret !=0 ) + { +DPRINT_ERR (NETVSC ,"unable to teardown send buffer's gpadl" ); +DPRINT_EXIT (NETVSC ); +return -1 ; + } + NetDevice->SendBufferGpadlHandle =0 ; + } + +if (NetDevice->SendBuffer) + { +DPRINT_INFO (NETVSC ,"Freeing up send buffer..." ); + +// Free up the receive buffer +PageFree (NetDevice->SendBuffer, NetDevice->SendBufferSize >>PAGE_SHIFT ); + NetDevice->SendBuffer =NULL ; + } + +DPRINT_EXIT (NETVSC ); + +return ret; +} + + + +static int +NetVscConnectToVsp ( +DEVICE_OBJECT *Device + ) +{ +int ret=0 ; +NETVSC_DEVICE *netDevice; +NVSP_MESSAGE *initPacket; +int ndisVersion; + +DPRINT_ENTER (NETVSC ); + + netDevice =GetOutboundNetDevice (Device); +if (!netDevice) + { +DPRINT_ERR (NETVSC ,"unable to get net device...device being destroyed?" ); +DPRINT_EXIT (NETVSC ); +return -1 ; + } + + initPacket = &netDevice->ChannelInitPacket; + +memset (initPacket,0 ,sizeof (NVSP_MESSAGE )); + initPacket->Header.MessageType = NvspMessageTypeInit; + initPacket->Messages.InitMessages.Init.MinProtocolVersion =NVSP_MIN_PROTOCOL_VERSION ; + initPacket->Messages.InitMessages.Init.MaxProtocolVersion =NVSP_MAX_PROTOCOL_VERSION ; + +DPRINT_INFO (NETVSC ,"Sending NvspMessageTypeInit..." ); + +// Send the init request + ret = Device->Driver->VmbusChannelInterface.SendPacket (Device, + initPacket, +sizeof (NVSP_MESSAGE ), + (ULONG_PTR )initPacket, + VmbusPacketTypeDataInBand, +VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED ); + +if ( ret !=0 ) + { +DPRINT_ERR (NETVSC ,"unable to send NvspMessageTypeInit" ); + goto Cleanup; + } + +WaitEventWait (netDevice->ChannelInitEvent); + +// Now, check the response +//ASSERT(initPacket->Messages.InitMessages.InitComplete.MaximumMdlChainLength <= MAX_MULTIPAGE_BUFFER_COUNT); +DPRINT_INFO (NETVSC ,"NvspMessageTypeInit status(%d) max mdl chain (%d)" , + initPacket->Messages.InitMessages.InitComplete.Status, + initPacket->Messages.InitMessages.InitComplete.MaximumMdlChainLength); + +if (initPacket->Messages.InitMessages.InitComplete.Status != NvspStatusSuccess) + { +DPRINT_ERR (NETVSC ,"unable to initialize with netvsp (status 0x%x)" , initPacket->Messages.InitMessages.InitComplete.Status); + ret =-1 ; + goto Cleanup; + } + +if (initPacket->Messages.InitMessages.InitComplete.NegotiatedProtocolVersion !=NVSP_PROTOCOL_VERSION_1 ) + { +DPRINT_ERR (NETVSC ,"unable to initialize with netvsp (version expected 1 got %d)" , + initPacket->Messages.InitMessages.InitComplete.NegotiatedProtocolVersion); + ret =-1 ; + goto Cleanup; + } +DPRINT_INFO (NETVSC ,"Sending NvspMessage1TypeSendNdisVersion..." ); + +// Send the ndis version +memset (initPacket,0 ,sizeof (NVSP_MESSAGE )); + + ndisVersion =0x00050000 ; + + initPacket->Header.MessageType = NvspMessage1TypeSendNdisVersion; + initPacket->Messages.Version1Messages.SendNdisVersion.NdisMajorVersion = (ndisVersion &0xFFFF0000 ) >>16 ; + initPacket->Messages.Version1Messages.SendNdisVersion.NdisMinorVersion = ndisVersion &0xFFFF ; + +// Send the init request + ret = Device->Driver->VmbusChannelInterface.SendPacket (Device, + initPacket, +sizeof (NVSP_MESSAGE ), + (ULONG_PTR )initPacket, + VmbusPacketTypeDataInBand, +0 ); +if (ret !=0 ) + { +DPRINT_ERR (NETVSC ,"unable to send NvspMessage1TypeSendNdisVersion" ); + ret =-1 ; + goto Cleanup; + } +// +// BUGBUG - We have to wait for the above msg since the netvsp uses KMCL which acknowledges packet (completion packet) +// since our Vmbus always set the VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED flag +//WaitEventWait(NetVscChannel->ChannelInitEvent); + +// Post the big receive buffer to NetVSP + ret =NetVscInitializeReceiveBufferWithNetVsp (Device); +if (ret ==0 ) + { + ret =NetVscInitializeSendBufferWithNetVsp (Device); + } + +Cleanup: +PutNetDevice (Device); +DPRINT_EXIT (NETVSC ); +return ret; +} + +static void +NetVscDisconnectFromVsp ( +NETVSC_DEVICE *NetDevice + ) +{ +DPRINT_ENTER (NETVSC ); + +NetVscDestroyReceiveBuffer (NetDevice); +NetVscDestroySendBuffer (NetDevice); + +DPRINT_EXIT (NETVSC ); +} + + +/*++ + +Name: +NetVscOnDeviceAdd() + +Description: +Callback when the device belonging to this driver is added + +--*/ +int +NetVscOnDeviceAdd ( +DEVICE_OBJECT *Device, +void *AdditionalInfo + ) +{ +int ret=0 ; +int i; + +NETVSC_DEVICE * netDevice; +NETVSC_PACKET * packet; +LIST_ENTRY *entry; + +NETVSC_DRIVER_OBJECT *netDriver = (NETVSC_DRIVER_OBJECT *) Device->Driver;; + +DPRINT_ENTER (NETVSC ); + + netDevice =AllocNetDevice (Device); +if (!netDevice) + { + ret =-1 ; + goto Cleanup; + } + +DPRINT_DBG (NETVSC ,"netvsc channel object allocated - %p" , netDevice); + +// Initialize the NetVSC channel extension + netDevice->ReceiveBufferSize =NETVSC_RECEIVE_BUFFER_SIZE ; + netDevice->ReceivePacketListLock =SpinlockCreate (); + + netDevice->SendBufferSize =NETVSC_SEND_BUFFER_SIZE ; + +INITIALIZE_LIST_HEAD (&netDevice->ReceivePacketList); + +for (i=0 ; i <NETVSC_RECEIVE_PACKETLIST_COUNT ; i++) + { + packet =MemAllocZeroed (sizeof (NETVSC_PACKET ) + (NETVSC_RECEIVE_SG_COUNT *sizeof (PAGE_BUFFER ))); +if (!packet) + { +DPRINT_DBG (NETVSC ,"unable to allocate netvsc pkts for receive pool (wanted %d got %d)" ,NETVSC_RECEIVE_PACKETLIST_COUNT , i); +break ; + } + +INSERT_TAIL_LIST (&netDevice->ReceivePacketList, &packet->ListEntry); + } + netDevice->ChannelInitEvent =WaitEventCreate (); + +// Open the channel + ret = Device->Driver->VmbusChannelInterface.Open (Device, + netDriver->RingBufferSize, + netDriver->RingBufferSize, +NULL ,0 , + NetVscOnChannelCallback, + Device + ); + +if (ret !=0 ) + { +DPRINT_ERR (NETVSC ,"unable to open channel: %d" , ret); + ret =-1 ; + goto Cleanup; + } + +// Channel is opened +DPRINT_INFO (NETVSC ,"*** NetVSC channel opened successfully! ***" ); + +// Connect with the NetVsp + ret =NetVscConnectToVsp (Device); +if (ret !=0 ) + { +DPRINT_ERR (NETVSC ,"unable to connect to NetVSP - %d" , ret); + ret =-1 ; + goto Close; + } + +DPRINT_INFO (NETVSC ,"*** NetVSC channel handshake result - %d ***" , ret); + +DPRINT_EXIT (NETVSC ); +return ret; + +Close: +// Now, we can close the channel safely + Device->Driver->VmbusChannelInterface.Close (Device); + +Cleanup: + +if (netDevice) + { +WaitEventClose (netDevice->ChannelInitEvent); + +while (!IsListEmpty (&netDevice->ReceivePacketList)) + { + entry =REMOVE_HEAD_LIST (&netDevice->ReceivePacketList); + packet =CONTAINING_RECORD (entry,NETVSC_PACKET , ListEntry); +MemFree (packet); + } + +SpinlockClose (netDevice->ReceivePacketListLock); + +ReleaseOutboundNetDevice (Device); +ReleaseInboundNetDevice (Device); + +FreeNetDevice (netDevice); + } + +DPRINT_EXIT (NETVSC ); +return ret; +} + + +/*++ + +Name: +NetVscOnDeviceRemove() + +Description: +Callback when the root bus device is removed + +--*/ +int +NetVscOnDeviceRemove ( +DEVICE_OBJECT *Device + ) +{ +NETVSC_DEVICE *netDevice; +NETVSC_PACKET *netvscPacket; +int ret=0 ; +LIST_ENTRY *entry; + +DPRINT_ENTER (NETVSC ); + +DPRINT_INFO (NETVSC ,"Disabling outbound traffic on net device (%p)..." , Device->Extension); + +// Stop outbound traffic ie sends and receives completions + netDevice =ReleaseOutboundNetDevice (Device); +if (!netDevice) + { +DPRINT_ERR (NETVSC ,"No net device present!!" ); +return -1 ; + } + +// Wait for all send completions +while (netDevice->NumOutstandingSends) + { +DPRINT_INFO (NETVSC ,"waiting for %d requests to complete..." , netDevice->NumOutstandingSends); + +Sleep (100 ); + } + +DPRINT_INFO (NETVSC ,"Disconnecting from netvsp..." ); + +NetVscDisconnectFromVsp (netDevice); + +DPRINT_INFO (NETVSC ,"Disabling inbound traffic on net device (%p)..." , Device->Extension); + +// Stop inbound traffic ie receives and sends completions + netDevice =ReleaseInboundNetDevice (Device); + +// At this point, no one should be accessing netDevice except in here +DPRINT_INFO (NETVSC ,"net device (%p) safe to remove" , netDevice); + +// Now, we can close the channel safely + Device->Driver->VmbusChannelInterface.Close (Device); + +// Release all resources +while (!IsListEmpty (&netDevice->ReceivePacketList)) + { + entry =REMOVE_HEAD_LIST (&netDevice->ReceivePacketList); + netvscPacket =CONTAINING_RECORD (entry,NETVSC_PACKET , ListEntry); + +MemFree (netvscPacket); + } + +SpinlockClose (netDevice->ReceivePacketListLock); +WaitEventClose (netDevice->ChannelInitEvent); +FreeNetDevice (netDevice); + +DPRINT_EXIT (NETVSC ); +return ret; +} + + + +/*++ + +Name: +NetVscOnCleanup() + +Description: +Perform any cleanup when the driver is removed + +--*/ +void +NetVscOnCleanup ( +DRIVER_OBJECT *drv + ) +{ +DPRINT_ENTER (NETVSC ); + +DPRINT_EXIT (NETVSC ); +} + +static void +NetVscOnSendCompletion ( +DEVICE_OBJECT *Device, +VMPACKET_DESCRIPTOR *Packet + ) +{ +NETVSC_DEVICE * netDevice; +NVSP_MESSAGE *nvspPacket; +NETVSC_PACKET *nvscPacket; + +DPRINT_ENTER (NETVSC ); + + netDevice =GetInboundNetDevice (Device); +if (!netDevice) + { +DPRINT_ERR (NETVSC ,"unable to get net device...device being destroyed?" ); +DPRINT_EXIT (NETVSC ); +return ; + } + + nvspPacket = (NVSP_MESSAGE *)((ULONG_PTR )Packet + (Packet->DataOffset8 <<3 )); + +DPRINT_DBG (NETVSC ,"send completion packet - type %d" , nvspPacket->Header.MessageType); + +if (nvspPacket->Header.MessageType == NvspMessageTypeInitComplete || + nvspPacket->Header.MessageType == NvspMessage1TypeSendReceiveBufferComplete || + nvspPacket->Header.MessageType == NvspMessage1TypeSendSendBufferComplete) + { +// Copy the response back +memcpy (&netDevice->ChannelInitPacket, nvspPacket,sizeof (NVSP_MESSAGE )); +WaitEventSet (netDevice->ChannelInitEvent); + } +else if (nvspPacket->Header.MessageType == NvspMessage1TypeSendRNDISPacketComplete) + { +// Get the send context + nvscPacket = (NETVSC_PACKET *)(ULONG_PTR )Packet->TransactionId; +ASSERT (nvscPacket); + +// Notify the layer above us + nvscPacket->Completion.Send.OnSendCompletion (nvscPacket->Completion.Send.SendCompletionContext); + +InterlockedDecrement (&netDevice->NumOutstandingSends); + } +else + { +DPRINT_ERR (NETVSC ,"Unknown send completion packet type - %d received!!" , nvspPacket->Header.MessageType); + } + +PutNetDevice (Device); +DPRINT_EXIT (NETVSC ); +} + + + +static int +NetVscOnSend ( +DEVICE_OBJECT *Device, +NETVSC_PACKET *Packet + ) +{ +NETVSC_DEVICE * netDevice; +int ret=0 ; + +NVSP_MESSAGE sendMessage; + +DPRINT_ENTER (NETVSC ); + + netDevice =GetOutboundNetDevice (Device); +if (!netDevice) + { +DPRINT_ERR (NETVSC ,"net device (%p) shutting down...ignoring outbound packets" , netDevice); +DPRINT_EXIT (NETVSC ); +return -2 ; + } + + sendMessage.Header.MessageType = NvspMessage1TypeSendRNDISPacket; +if (Packet->IsDataPacket) + sendMessage.Messages.Version1Messages.SendRNDISPacket.ChannelType =0 ;// 0 is RMC_DATA; +else + sendMessage.Messages.Version1Messages.SendRNDISPacket.ChannelType =1 ;// 1 is RMC_CONTROL; + +// Not using send buffer section + sendMessage.Messages.Version1Messages.SendRNDISPacket.SendBufferSectionIndex =0xFFFFFFFF ; + sendMessage.Messages.Version1Messages.SendRNDISPacket.SendBufferSectionSize =0 ; + +if (Packet->PageBufferCount) + { + ret = Device->Driver->VmbusChannelInterface.SendPacketPageBuffer (Device, + Packet->PageBuffers, + Packet->PageBufferCount, + &sendMessage, +sizeof (NVSP_MESSAGE ), + (ULONG_PTR )Packet); + } +else + { + ret = Device->Driver->VmbusChannelInterface.SendPacket (Device, + &sendMessage, +sizeof (NVSP_MESSAGE ), + (ULONG_PTR )Packet, + VmbusPacketTypeDataInBand, +VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED ); + + } + +if (ret !=0 ) + { +DPRINT_ERR (NETVSC ,"Unable to send packet %p ret %d" , Packet, ret); + } + +InterlockedIncrement (&netDevice->NumOutstandingSends); +PutNetDevice (Device); + +DPRINT_EXIT (NETVSC ); +return ret; +} + + +static void +NetVscOnReceive ( +DEVICE_OBJECT *Device, +VMPACKET_DESCRIPTOR *Packet + ) +{ +NETVSC_DEVICE * netDevice; +VMTRANSFER_PAGE_PACKET_HEADER *vmxferpagePacket; +NVSP_MESSAGE *nvspPacket; +NETVSC_PACKET *netvscPacket=NULL ; +LIST_ENTRY * entry; +ULONG_PTR start; +ULONG_PTR end, endVirtual; +//NETVSC_DRIVER_OBJECT *netvscDriver; +XFERPAGE_PACKET *xferpagePacket=NULL ; +LIST_ENTRY listHead; + +int i=0 , j=0 ; +int count=0 , bytesRemain=0 ; + +DPRINT_ENTER (NETVSC ); + + netDevice =GetInboundNetDevice (Device); +if (!netDevice) + { +DPRINT_ERR (NETVSC ,"unable to get net device...device being destroyed?" ); +DPRINT_EXIT (NETVSC ); +return ; + } + +// All inbound packets other than send completion should be xfer page packet +if (Packet->Type != VmbusPacketTypeDataUsingTransferPages) + { +DPRINT_ERR (NETVSC ,"Unknown packet type received - %d" , Packet->Type); +PutNetDevice (Device); +return ; + } + + nvspPacket = (NVSP_MESSAGE *)((ULONG_PTR )Packet + (Packet->DataOffset8 <<3 )); + +// Make sure this is a valid nvsp packet +if (nvspPacket->Header.MessageType != NvspMessage1TypeSendRNDISPacket ) + { +DPRINT_ERR (NETVSC ,"Unknown nvsp packet type received - %d" , nvspPacket->Header.MessageType); +PutNetDevice (Device); +return ; + } + +DPRINT_DBG (NETVSC ,"NVSP packet received - type %d" , nvspPacket->Header.MessageType); + + vmxferpagePacket = (VMTRANSFER_PAGE_PACKET_HEADER *)Packet; + +if (vmxferpagePacket->TransferPageSetId !=NETVSC_RECEIVE_BUFFER_ID ) + { +DPRINT_ERR (NETVSC ,"Invalid xfer page set id - expecting %x got %x" ,NETVSC_RECEIVE_BUFFER_ID , vmxferpagePacket->TransferPageSetId); +PutNetDevice (Device); +return ; + } + +DPRINT_DBG (NETVSC ,"xfer page - range count %d" , vmxferpagePacket->RangeCount); + +INITIALIZE_LIST_HEAD (&listHead); + +// Grab free packets (range count + 1) to represent this xfer page packet. +1 to represent +// the xfer page packet itself. We grab it here so that we know exactly how many we can fulfil +SpinlockAcquire (netDevice->ReceivePacketListLock); +while (!IsListEmpty (&netDevice->ReceivePacketList)) + { + entry =REMOVE_HEAD_LIST (&netDevice->ReceivePacketList); + netvscPacket =CONTAINING_RECORD (entry,NETVSC_PACKET , ListEntry); + +INSERT_TAIL_LIST (&listHead, &netvscPacket->ListEntry); + +if (++count == vmxferpagePacket->RangeCount +1 ) +break ; + } +SpinlockRelease (netDevice->ReceivePacketListLock); + +// We need at least 2 netvsc pkts (1 to represent the xfer page and at least 1 for the range) +// i.e. we can handled some of the xfer page packet ranges... +if (count <2 ) + { +DPRINT_ERR (NETVSC ,"Got only %d netvsc pkt...needed %d pkts. Dropping this xfer page packet completely!" , count, vmxferpagePacket->RangeCount+1 ); + +// Return it to the freelist +SpinlockAcquire (netDevice->ReceivePacketListLock); +for (i=count; i !=0 ; i--) + { + entry =REMOVE_HEAD_LIST (&listHead); + netvscPacket =CONTAINING_RECORD (entry,NETVSC_PACKET , ListEntry); + +INSERT_TAIL_LIST (&netDevice->ReceivePacketList, &netvscPacket->ListEntry); + } +SpinlockRelease (netDevice->ReceivePacketListLock); + +NetVscSendReceiveCompletion (Device, vmxferpagePacket->d.TransactionId); + +PutNetDevice (Device); +return ; + } + +// Remove the 1st packet to represent the xfer page packet itself + entry =REMOVE_HEAD_LIST (&listHead); + xferpagePacket =CONTAINING_RECORD (entry,XFERPAGE_PACKET , ListEntry); + xferpagePacket->Count = count -1 ;// This is how much we can satisfy +ASSERT (xferpagePacket->Count >0 && xferpagePacket->Count <= vmxferpagePacket->RangeCount); + +if (xferpagePacket->Count != vmxferpagePacket->RangeCount) + { +DPRINT_INFO (NETVSC ,"Needed %d netvsc pkts to satisy this xfer page...got %d" , vmxferpagePacket->RangeCount, xferpagePacket->Count); + } + +// Each range represents 1 RNDIS pkt that contains 1 ethernet frame +for (i=0 ; i < (count -1 ); i++) + { + entry =REMOVE_HEAD_LIST (&listHead); + netvscPacket =CONTAINING_RECORD (entry,NETVSC_PACKET , ListEntry); + +// Initialize the netvsc packet + netvscPacket->XferPagePacket = xferpagePacket; + netvscPacket->Completion.Recv.OnReceiveCompletion = NetVscOnReceiveCompletion; + netvscPacket->Completion.Recv.ReceiveCompletionContext = netvscPacket; + netvscPacket->Device = Device; + netvscPacket->Completion.Recv.ReceiveCompletionTid = vmxferpagePacket->d.TransactionId;// Save this so that we can send it back + + netvscPacket->TotalDataBufferLength = vmxferpagePacket->Ranges[i].ByteCount; + netvscPacket->PageBufferCount =1 ; + +ASSERT (vmxferpagePacket->Ranges[i].ByteOffset + vmxferpagePacket->Ranges[i].ByteCount < netDevice->ReceiveBufferSize); + + netvscPacket->PageBuffers[0 ].Length = vmxferpagePacket->Ranges[i].ByteCount; + + start =GetPhysicalAddress ((void *)((ULONG_PTR )netDevice->ReceiveBuffer + vmxferpagePacket->Ranges[i].ByteOffset)); + + netvscPacket->PageBuffers[0 ].Pfn = start >>PAGE_SHIFT ; + endVirtual = (ULONG_PTR )netDevice->ReceiveBuffer + + vmxferpagePacket->Ranges[i].ByteOffset + + vmxferpagePacket->Ranges[i].ByteCount -1 ; + end =GetPhysicalAddress ((void *)endVirtual); + +// Calculate the page relative offset + netvscPacket->PageBuffers[0 ].Offset = vmxferpagePacket->Ranges[i].ByteOffset & (PAGE_SIZE -1 ); +if ((end >>PAGE_SHIFT ) != (start>>PAGE_SHIFT )) { +//Handle frame across multiple pages: + netvscPacket->PageBuffers[0 ].Length = + (netvscPacket->PageBuffers[0 ].Pfn <<PAGE_SHIFT ) +PAGE_SIZE - start; + bytesRemain = netvscPacket->TotalDataBufferLength - netvscPacket->PageBuffers[0 ].Length; +for (j=1 ; j<NETVSC_PACKET_MAXPAGE ; j++) { + netvscPacket->PageBuffers[j].Offset =0 ; +if (bytesRemain <=PAGE_SIZE ) { + netvscPacket->PageBuffers[j].Length = bytesRemain; + bytesRemain =0 ; + }else { + netvscPacket->PageBuffers[j].Length =PAGE_SIZE ; + bytesRemain -=PAGE_SIZE ; + } + netvscPacket->PageBuffers[j].Pfn = +GetPhysicalAddress ((void *)(endVirtual - bytesRemain)) >>PAGE_SHIFT ; + netvscPacket->PageBufferCount++; +if (bytesRemain ==0 ) +break ; + } +ASSERT (bytesRemain ==0 ); + } +DPRINT_DBG (NETVSC ,"[%d] - (abs offset %u len %u) => (pfn %llx, offset %u, len %u)" , + i, + vmxferpagePacket->Ranges[i].ByteOffset, + vmxferpagePacket->Ranges[i].ByteCount, + netvscPacket->PageBuffers[0 ].Pfn, + netvscPacket->PageBuffers[0 ].Offset, + netvscPacket->PageBuffers[0 ].Length); + +// Pass it to the upper layer + ((NETVSC_DRIVER_OBJECT *)Device->Driver)->OnReceiveCallback (Device, netvscPacket); + +NetVscOnReceiveCompletion (netvscPacket->Completion.Recv.ReceiveCompletionContext); + } + +ASSERT (IsListEmpty (&listHead)); + +PutNetDevice (Device); +DPRINT_EXIT (NETVSC ); +} + + +static void +NetVscSendReceiveCompletion ( +DEVICE_OBJECT *Device, +UINT64 TransactionId + ) +{ +NVSP_MESSAGE recvcompMessage; +int retries=0 ; +int ret=0 ; + +DPRINT_DBG (NETVSC ,"Sending receive completion pkt - %llx" , TransactionId); + + recvcompMessage.Header.MessageType = NvspMessage1TypeSendRNDISPacketComplete; + +// FIXME: Pass in the status + recvcompMessage.Messages.Version1Messages.SendRNDISPacketComplete.Status = NvspStatusSuccess; + +retry_send_cmplt: +// Send the completion + ret = Device->Driver->VmbusChannelInterface.SendPacket (Device, + &recvcompMessage, +sizeof (NVSP_MESSAGE ), + TransactionId, + VmbusPacketTypeCompletion, +0 ); +if (ret ==0 )// success + { +// no-op + } +else if (ret ==-1 )// no more room...wait a bit and attempt to retry 3 times + { + retries++; +DPRINT_ERR (NETVSC ,"unable to send receive completion pkt (tid %llx)...retrying %d" , TransactionId, retries); + +if (retries <4 ) + { +Sleep (100 ); + goto retry_send_cmplt; + } +else + { +DPRINT_ERR (NETVSC ,"unable to send receive completion pkt (tid %llx)...give up retrying" , TransactionId); + } + } +else + { +DPRINT_ERR (NETVSC ,"unable to send receive completion pkt - %llx" , TransactionId); + } +} + +// +// Send a receive completion packet to RNDIS device (ie NetVsp) +// +static void +NetVscOnReceiveCompletion ( +PVOID Context) +{ +NETVSC_PACKET *packet = (NETVSC_PACKET *)Context; +DEVICE_OBJECT *device = (DEVICE_OBJECT *)packet->Device; +NETVSC_DEVICE * netDevice; +UINT64 transactionId=0 ; +BOOL fSendReceiveComp = FALSE; + +DPRINT_ENTER (NETVSC ); + +ASSERT (packet->XferPagePacket); + +// Even though it seems logical to do a GetOutboundNetDevice() here to send out receive completion, +// we are using GetInboundNetDevice() since we may have disable outbound traffic already. + netDevice =GetInboundNetDevice (device); +if (!netDevice) + { +DPRINT_ERR (NETVSC ,"unable to get net device...device being destroyed?" ); +DPRINT_EXIT (NETVSC ); +return ; + } + +// Overloading use of the lock. +SpinlockAcquire (netDevice->ReceivePacketListLock); + +ASSERT (packet->XferPagePacket->Count >0 ); + packet->XferPagePacket->Count--; + +// Last one in the line that represent 1 xfer page packet. +// Return the xfer page packet itself to the freelist +if (packet->XferPagePacket->Count ==0 ) + { + fSendReceiveComp = TRUE; + transactionId = packet->Completion.Recv.ReceiveCompletionTid; + +INSERT_TAIL_LIST (&netDevice->ReceivePacketList, &packet->XferPagePacket->ListEntry); + } + +// Put the packet back +INSERT_TAIL_LIST (&netDevice->ReceivePacketList, &packet->ListEntry); +SpinlockRelease (netDevice->ReceivePacketListLock); + +// Send a receive completion for the xfer page packet +if (fSendReceiveComp) + { +NetVscSendReceiveCompletion (device, transactionId); + } + +PutNetDevice (device); +DPRINT_EXIT (NETVSC ); +} + + + +void +NetVscOnChannelCallback ( +PVOID Context + ) +{ +const int netPacketSize=2048 ; +int ret=0 ; +DEVICE_OBJECT *device=(DEVICE_OBJECT *)Context; +NETVSC_DEVICE *netDevice; + +UINT32 bytesRecvd; +UINT64 requestId; +UCHAR packet[netPacketSize]; +VMPACKET_DESCRIPTOR *desc; +UCHAR *buffer=packet; +int bufferlen=netPacketSize; + + +DPRINT_ENTER (NETVSC ); + +ASSERT (device); + + netDevice =GetInboundNetDevice (device); +if (!netDevice) + { +DPRINT_ERR (NETVSC ,"net device (%p) shutting down...ignoring inbound packets" , netDevice); +DPRINT_EXIT (NETVSC ); +return ; + } + +do + { + ret = device->Driver->VmbusChannelInterface.RecvPacketRaw (device, + buffer, + bufferlen, + &bytesRecvd, + &requestId); + +if (ret ==0 ) + { +if (bytesRecvd >0 ) + { +DPRINT_DBG (NETVSC ,"receive %d bytes, tid %llx" , bytesRecvd, requestId); + + desc = (VMPACKET_DESCRIPTOR *)buffer; +switch (desc->Type) + { +case VmbusPacketTypeCompletion: +NetVscOnSendCompletion (device, desc); +break ; + +case VmbusPacketTypeDataUsingTransferPages: +NetVscOnReceive (device, desc); +break ; + +default : +DPRINT_ERR (NETVSC ,"unhandled packet type %d, tid %llx len %d\n" , desc->Type, requestId, bytesRecvd); +break ; + } + +// reset +if (bufferlen > netPacketSize) + { +MemFree (buffer); + + buffer = packet; + bufferlen = netPacketSize; + } + } +else + { +//DPRINT_DBG(NETVSC, "nothing else to read..."); + +// reset +if (bufferlen > netPacketSize) + { +MemFree (buffer); + + buffer = packet; + bufferlen = netPacketSize; + } + +break ; + } + } +else if (ret ==-2 )// Handle large packet + { + buffer =MemAllocAtomic (bytesRecvd); +if (buffer ==NULL ) + { +// Try again next time around +DPRINT_ERR (NETVSC ,"unable to allocate buffer of size (%d)!!" , bytesRecvd); +break ; + } + + bufferlen = bytesRecvd; + } +else + { +ASSERT (0 ); + } + }while (1 ); + +PutNetDevice (device); +DPRINT_EXIT (NETVSC ); +return ; +}
drivers/staging/hv/netvsc_drv.c new file +720 -0
720 lines not on this page · raw message
drivers/staging/hv/NetVsc.h new file +91 -0
91 lines not on this page · raw message
drivers/staging/hv/RndisFilter.c new file +1162 -0
690 lines not on this page · raw message
drivers/staging/hv/RndisFilter.h new file +61 -0
61 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
PATCH 6/54 Staging: hv: add the Hyper-V virtual storage driver
In reply to Greg Kroah-HartmanFrom: Hank Janssen <[email protected]>
This is the virtual storage driver when running Linux on top of Hyper-V.
--- drivers/staging/hv/StorVsc.c | 967 ++++++++++++++++++++++++++ drivers/staging/hv/storvsc_drv.c | 1413 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 2380 insertions(+)
drivers/staging/hv/StorVsc.c new file +967 -0
@@ -0,0 +1,967 @@ +/* +* +* Copyright (c) 2009, Microsoft Corporation. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program; if not, write to the Free Software Foundation, Inc., 59 Temple +* Place - Suite 330, Boston, MA 02111-1307 USA. +* +* Authors: +* Haiyang Zhang <[email protected]> +* Hank Janssen <[email protected]> +* +*/ + + +#include "logging.h" + +#include "StorVscApi.h" +#include "VmbusPacketFormat.h" +#include "vstorage.h" + + +// +// #defines +// + +// +// Data types +// + +typedef struct _STORVSC_REQUEST_EXTENSION { +//LIST_ENTRY ListEntry; + +STORVSC_REQUEST *Request; +DEVICE_OBJECT *Device; + +// Synchronize the request/response if needed +HANDLE WaitEvent; + +VSTOR_PACKET VStorPacket; +}STORVSC_REQUEST_EXTENSION ; + + +// A storvsc device is a device object that contains a vmbus channel +typedef struct _STORVSC_DEVICE { +DEVICE_OBJECT *Device; + +int RefCount;// 0 indicates the device is being destroyed + +int NumOutstandingRequests; + +// Each unique Port/Path/Target represents 1 channel ie scsi controller. In reality, the pathid, targetid is always 0 +// and the port is set by us +ULONG PortNumber; +UCHAR PathId; +UCHAR TargetId; + +//LIST_ENTRY OutstandingRequestList; +//HANDLE OutstandingRequestLock; + +// Used for vsc/vsp channel reset process +STORVSC_REQUEST_EXTENSION InitRequest; + +STORVSC_REQUEST_EXTENSION ResetRequest; + +}STORVSC_DEVICE ; + + +// +// Globals +// +static const char * gDriverName="storvsc" ; + +//{ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} +static const GUID gStorVscDeviceType={ + .Data = {0xd9 ,0x63 ,0x61 ,0xba ,0xa1 ,0x04 ,0x29 ,0x4d ,0xb6 ,0x05 ,0x72 ,0xe2 ,0xff ,0xb1 ,0xdc ,0x7f } +}; + +// +// Internal routines +// +static int +StorVscOnDeviceAdd ( +DEVICE_OBJECT *Device, +void *AdditionalInfo + ); + +static int +StorVscOnDeviceRemove ( +DEVICE_OBJECT *Device + ); + +static int +StorVscOnIORequest ( +DEVICE_OBJECT *Device, +STORVSC_REQUEST *Request + ); + +static int +StorVscOnHostReset ( +DEVICE_OBJECT *Device + ); + +static void +StorVscOnCleanup ( +DRIVER_OBJECT *Device + ); + +static void +StorVscOnChannelCallback ( +PVOID Context + ); + +static void +StorVscOnIOCompletion ( +DEVICE_OBJECT *Device, +VSTOR_PACKET *VStorPacket, +STORVSC_REQUEST_EXTENSION *RequestExt + ); + +static void +StorVscOnReceive ( +DEVICE_OBJECT *Device, +VSTOR_PACKET *VStorPacket, +STORVSC_REQUEST_EXTENSION *RequestExt + ); + +static int +StorVscConnectToVsp ( +DEVICE_OBJECT *Device + ); + +static inline STORVSC_DEVICE *AllocStorDevice (DEVICE_OBJECT *Device) +{ +STORVSC_DEVICE *storDevice; + + storDevice =MemAllocZeroed (sizeof (STORVSC_DEVICE )); +if (!storDevice) +return NULL ; + +// Set to 2 to allow both inbound and outbound traffics +// (ie GetStorDevice() and MustGetStorDevice()) to proceed. +InterlockedCompareExchange (&storDevice->RefCount,2 ,0 ); + + storDevice->Device = Device; + Device->Extension = storDevice; + +return storDevice; +} + +static inline void FreeStorDevice (STORVSC_DEVICE *Device) +{ +ASSERT (Device->RefCount ==0 ); +MemFree (Device); +} + +// Get the stordevice object iff exists and its refcount > 1 +static inline STORVSC_DEVICE *GetStorDevice (DEVICE_OBJECT *Device) +{ +STORVSC_DEVICE *storDevice; + + storDevice = (STORVSC_DEVICE *)Device->Extension; +if (storDevice && storDevice->RefCount >1 ) + { +InterlockedIncrement (&storDevice->RefCount); + } +else + { + storDevice =NULL ; + } + +return storDevice; +} + +// Get the stordevice object iff exists and its refcount > 0 +static inline STORVSC_DEVICE *MustGetStorDevice (DEVICE_OBJECT *Device) +{ +STORVSC_DEVICE *storDevice; + + storDevice = (STORVSC_DEVICE *)Device->Extension; +if (storDevice && storDevice->RefCount) + { +InterlockedIncrement (&storDevice->RefCount); + } +else + { + storDevice =NULL ; + } + +return storDevice; +} + +static inline void PutStorDevice (DEVICE_OBJECT *Device) +{ +STORVSC_DEVICE *storDevice; + + storDevice = (STORVSC_DEVICE *)Device->Extension; +ASSERT (storDevice); + +InterlockedDecrement (&storDevice->RefCount); +ASSERT (storDevice->RefCount); +} + +// Drop ref count to 1 to effectively disable GetStorDevice() +static inline STORVSC_DEVICE *ReleaseStorDevice (DEVICE_OBJECT *Device) +{ +STORVSC_DEVICE *storDevice; + + storDevice = (STORVSC_DEVICE *)Device->Extension; +ASSERT (storDevice); + +// Busy wait until the ref drop to 2, then set it to 1 +while (InterlockedCompareExchange (&storDevice->RefCount,1 ,2 ) !=2 ) + { +Sleep (100 ); + } + +return storDevice; +} + +// Drop ref count to 0. No one can use StorDevice object. +static inline STORVSC_DEVICE *FinalReleaseStorDevice (DEVICE_OBJECT *Device) +{ +STORVSC_DEVICE *storDevice; + + storDevice = (STORVSC_DEVICE *)Device->Extension; +ASSERT (storDevice); + +// Busy wait until the ref drop to 1, then set it to 0 +while (InterlockedCompareExchange (&storDevice->RefCount,0 ,1 ) !=1 ) + { +Sleep (100 ); + } + + Device->Extension =NULL ; +return storDevice; +} + +/*++; + + +Name: +StorVscInitialize() + +Description: +Main entry point + +--*/ +int +StorVscInitialize ( +DRIVER_OBJECT *Driver + ) +{ +STORVSC_DRIVER_OBJECT * storDriver = (STORVSC_DRIVER_OBJECT *)Driver; +int ret=0 ; + +DPRINT_ENTER (STORVSC ); + +DPRINT_DBG (STORVSC ,"sizeof(STORVSC_REQUEST)=%d sizeof(STORVSC_REQUEST_EXTENSION)=%d sizeof(VSTOR_PACKET)=%d, sizeof(VMSCSI_REQUEST)=%d" , +sizeof (STORVSC_REQUEST ),sizeof (STORVSC_REQUEST_EXTENSION ),sizeof (VSTOR_PACKET ),sizeof (VMSCSI_REQUEST )); + +// Make sure we are at least 2 pages since 1 page is used for control +ASSERT (storDriver->RingBufferSize >= (PAGE_SIZE <<1 )); + + Driver->name = gDriverName; +memcpy (&Driver->deviceType, &gStorVscDeviceType,sizeof (GUID )); + + storDriver->RequestExtSize =sizeof (STORVSC_REQUEST_EXTENSION ); + +// Divide the ring buffer data size (which is 1 page less than the ring buffer size since that page is reserved for the ring buffer indices) +// by the max request size (which is VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER + VSTOR_PACKET + UINT64) + storDriver->MaxOutstandingRequestsPerChannel = + ((storDriver->RingBufferSize -PAGE_SIZE ) /ALIGN_UP (MAX_MULTIPAGE_BUFFER_PACKET +sizeof (VSTOR_PACKET ) +sizeof (UINT64 ),sizeof (UINT64 ))); + +DPRINT_INFO (STORVSC ,"max io %u, currently %u\n" , storDriver->MaxOutstandingRequestsPerChannel,STORVSC_MAX_IO_REQUESTS ); + +// Setup the dispatch table + storDriver->Base.OnDeviceAdd = StorVscOnDeviceAdd; + storDriver->Base.OnDeviceRemove = StorVscOnDeviceRemove; + storDriver->Base.OnCleanup = StorVscOnCleanup; + + storDriver->OnIORequest = StorVscOnIORequest; + storDriver->OnHostReset = StorVscOnHostReset; + +DPRINT_EXIT (STORVSC ); + +return ret; +} + +/*++ + +Name: +StorVscOnDeviceAdd() + +Description: +Callback when the device belonging to this driver is added + +--*/ +int +StorVscOnDeviceAdd ( +DEVICE_OBJECT *Device, +void *AdditionalInfo + ) +{ +int ret=0 ; +STORVSC_DEVICE *storDevice; +//VMSTORAGE_CHANNEL_PROPERTIES *props; +STORVSC_DEVICE_INFO *deviceInfo = (STORVSC_DEVICE_INFO *)AdditionalInfo; + +DPRINT_ENTER (STORVSC ); + + storDevice =AllocStorDevice (Device); +if (!storDevice) + { + ret =-1 ; + goto Cleanup; + } + +// Save the channel properties to our storvsc channel +//props = (VMSTORAGE_CHANNEL_PROPERTIES*) channel->offerMsg.Offer.u.Standard.UserDefined; + +// FIXME: +// If we support more than 1 scsi channel, we need to set the port number here +// to the scsi channel but how do we get the scsi channel prior to the bus scan +/*storChannel->PortNumber = 0; +storChannel->PathId = props->PathId; +storChannel->TargetId = props->TargetId;*/ + + storDevice->PortNumber = deviceInfo->PortNumber; +// Send it back up + ret =StorVscConnectToVsp (Device); + +//deviceInfo->PortNumber = storDevice->PortNumber; + deviceInfo->PathId = storDevice->PathId; + deviceInfo->TargetId = storDevice->TargetId; + +DPRINT_DBG (STORVSC ,"assigned port %u, path %u target %u\n" , storDevice->PortNumber, storDevice->PathId, storDevice->TargetId); + +Cleanup: +DPRINT_EXIT (STORVSC ); + +return ret; +} + +static int StorVscChannelInit (DEVICE_OBJECT *Device) +{ +int ret=0 ; +STORVSC_DEVICE *storDevice; +STORVSC_REQUEST_EXTENSION *request; +VSTOR_PACKET *vstorPacket; + + storDevice =GetStorDevice (Device); +if (!storDevice) + { +DPRINT_ERR (STORVSC ,"unable to get stor device...device being destroyed?" ); +DPRINT_EXIT (STORVSC ); +return -1 ; + } + + request = &storDevice->InitRequest; + vstorPacket = &request->VStorPacket; + +// Now, initiate the vsc/vsp initialization protocol on the open channel + +memset (request,sizeof (STORVSC_REQUEST_EXTENSION ),0 ); + request->WaitEvent =WaitEventCreate (); + + vstorPacket->Operation = VStorOperationBeginInitialization; + vstorPacket->Flags =REQUEST_COMPLETION_FLAG ; + +/*SpinlockAcquire(gDriverExt.packetListLock); +INSERT_TAIL_LIST(&gDriverExt.packetList, &packet->listEntry.entry); +SpinlockRelease(gDriverExt.packetListLock);*/ + +DPRINT_INFO (STORVSC ,"BEGIN_INITIALIZATION_OPERATION..." ); + + ret = Device->Driver->VmbusChannelInterface.SendPacket (Device, + vstorPacket, +sizeof (VSTOR_PACKET ), + (ULONG_PTR )request, + VmbusPacketTypeDataInBand, +VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED ); +if ( ret !=0 ) + { +DPRINT_ERR (STORVSC ,"unable to send BEGIN_INITIALIZATION_OPERATION" ); + goto Cleanup; + } + +WaitEventWait (request->WaitEvent); + +if (vstorPacket->Operation != VStorOperationCompleteIo || vstorPacket->Status !=0 ) + { +DPRINT_ERR (STORVSC ,"BEGIN_INITIALIZATION_OPERATION failed (op %d status 0x%x)" , vstorPacket->Operation, vstorPacket->Status); + goto Cleanup; + } + +DPRINT_INFO (STORVSC ,"QUERY_PROTOCOL_VERSION_OPERATION..." ); + +// reuse the packet for version range supported +memset (vstorPacket,sizeof (VSTOR_PACKET ),0 ); + vstorPacket->Operation = VStorOperationQueryProtocolVersion; + vstorPacket->Flags =REQUEST_COMPLETION_FLAG ; + + vstorPacket->Version.MajorMinor =VMSTOR_PROTOCOL_VERSION_CURRENT ; +FILL_VMSTOR_REVISION (vstorPacket->Version.Revision); + + ret = Device->Driver->VmbusChannelInterface.SendPacket (Device, + vstorPacket, +sizeof (VSTOR_PACKET ), + (ULONG_PTR )request, + VmbusPacketTypeDataInBand, +VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED ); +if ( ret !=0 ) + { +DPRINT_ERR (STORVSC ,"unable to send BEGIN_INITIALIZATION_OPERATION" ); + goto Cleanup; + } + +WaitEventWait (request->WaitEvent); + +// TODO: Check returned version +if (vstorPacket->Operation != VStorOperationCompleteIo || vstorPacket->Status !=0 ) + { +DPRINT_ERR (STORVSC ,"QUERY_PROTOCOL_VERSION_OPERATION failed (op %d status 0x%x)" , vstorPacket->Operation, vstorPacket->Status); + goto Cleanup; + } + +// Query channel properties +DPRINT_INFO (STORVSC ,"QUERY_PROPERTIES_OPERATION..." ); + +memset (vstorPacket,sizeof (VSTOR_PACKET ),0 ); + vstorPacket->Operation = VStorOperationQueryProperties; + vstorPacket->Flags =REQUEST_COMPLETION_FLAG ; + vstorPacket->StorageChannelProperties.PortNumber = storDevice->PortNumber; + + ret = Device->Driver->VmbusChannelInterface.SendPacket (Device, + vstorPacket, +sizeof (VSTOR_PACKET ), + (ULONG_PTR )request, + VmbusPacketTypeDataInBand, +VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED ); + +if ( ret !=0 ) + { +DPRINT_ERR (STORVSC ,"unable to send QUERY_PROPERTIES_OPERATION" ); + goto Cleanup; + } + +WaitEventWait (request->WaitEvent); + +// TODO: Check returned version +if (vstorPacket->Operation != VStorOperationCompleteIo || vstorPacket->Status !=0 ) + { +DPRINT_ERR (STORVSC ,"QUERY_PROPERTIES_OPERATION failed (op %d status 0x%x)" , vstorPacket->Operation, vstorPacket->Status); + goto Cleanup; + } + +//storDevice->PortNumber = vstorPacket->StorageChannelProperties.PortNumber; + storDevice->PathId = vstorPacket->StorageChannelProperties.PathId; + storDevice->TargetId = vstorPacket->StorageChannelProperties.TargetId; + +DPRINT_DBG (STORVSC ,"channel flag 0x%x, max xfer len 0x%x" , vstorPacket->StorageChannelProperties.Flags, vstorPacket->StorageChannelProperties.MaxTransferBytes); + +DPRINT_INFO (STORVSC ,"END_INITIALIZATION_OPERATION..." ); + +memset (vstorPacket,sizeof (VSTOR_PACKET ),0 ); + vstorPacket->Operation = VStorOperationEndInitialization; + vstorPacket->Flags =REQUEST_COMPLETION_FLAG ; + + ret = Device->Driver->VmbusChannelInterface.SendPacket (Device, + vstorPacket, +sizeof (VSTOR_PACKET ), + (ULONG_PTR )request, + VmbusPacketTypeDataInBand, +VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED ); + +if ( ret !=0 ) + { +DPRINT_ERR (STORVSC ,"unable to send END_INITIALIZATION_OPERATION" ); + goto Cleanup; + } + +WaitEventWait (request->WaitEvent); + +if (vstorPacket->Operation != VStorOperationCompleteIo || vstorPacket->Status !=0 ) + { +DPRINT_ERR (STORVSC ,"END_INITIALIZATION_OPERATION failed (op %d status 0x%x)" , vstorPacket->Operation, vstorPacket->Status); + goto Cleanup; + } + +DPRINT_INFO (STORVSC ,"**** storage channel up and running!! ****" ); + +Cleanup: +if (request->WaitEvent) + { +WaitEventClose (request->WaitEvent); + request->WaitEvent =NULL ; + } + +PutStorDevice (Device); + +DPRINT_EXIT (STORVSC ); +return ret; +} + + +int +StorVscConnectToVsp ( +DEVICE_OBJECT *Device + ) +{ +int ret=0 ; +VMSTORAGE_CHANNEL_PROPERTIES props; + +STORVSC_DRIVER_OBJECT *storDriver = (STORVSC_DRIVER_OBJECT *) Device->Driver;; + +memset (&props,sizeof (VMSTORAGE_CHANNEL_PROPERTIES ),0 ); + +// Open the channel + ret = Device->Driver->VmbusChannelInterface.Open (Device, + storDriver->RingBufferSize, + storDriver->RingBufferSize, + (PVOID )&props, +sizeof (VMSTORAGE_CHANNEL_PROPERTIES ), + StorVscOnChannelCallback, + Device + ); + +DPRINT_DBG (STORVSC ,"storage props: path id %d, tgt id %d, max xfer %d" , props.PathId, props.TargetId, props.MaxTransferBytes); + +if (ret !=0 ) + { +DPRINT_ERR (STORVSC ,"unable to open channel: %d" , ret); +return -1 ; + } + + ret =StorVscChannelInit (Device); + +return ret; +} + + +/*++ + +Name: +StorVscOnDeviceRemove() + +Description: +Callback when the our device is being removed + +--*/ +int +StorVscOnDeviceRemove ( +DEVICE_OBJECT *Device + ) +{ +STORVSC_DEVICE *storDevice; +int ret=0 ; + +DPRINT_ENTER (STORVSC ); + +DPRINT_INFO (STORVSC ,"disabling storage device (%p)..." , Device->Extension); + + storDevice =ReleaseStorDevice (Device); + +// At this point, all outbound traffic should be disable. We only allow inbound traffic (responses) to proceed +// so that outstanding requests can be completed. +while (storDevice->NumOutstandingRequests) + { +DPRINT_INFO (STORVSC ,"waiting for %d requests to complete..." , storDevice->NumOutstandingRequests); + +Sleep (100 ); + } + +DPRINT_INFO (STORVSC ,"removing storage device (%p)..." , Device->Extension); + + storDevice =FinalReleaseStorDevice (Device); + +DPRINT_INFO (STORVSC ,"storage device (%p) safe to remove" , storDevice); + +// Close the channel + Device->Driver->VmbusChannelInterface.Close (Device); + +FreeStorDevice (storDevice); + +DPRINT_EXIT (STORVSC ); +return ret; +} + + +//static void +//StorVscOnTargetRescan( +// void *Context +// ) +//{ +// DEVICE_OBJECT *device=(DEVICE_OBJECT*)Context; +// STORVSC_DRIVER_OBJECT *storDriver; +// +// DPRINT_ENTER(STORVSC); +// +// storDriver = (STORVSC_DRIVER_OBJECT*) device->Driver; +// storDriver->OnHostRescan(device); +// +// DPRINT_EXIT(STORVSC); +//} + +int +StorVscOnHostReset ( +DEVICE_OBJECT *Device + ) +{ +int ret=0 ; + +STORVSC_DEVICE *storDevice; +STORVSC_REQUEST_EXTENSION *request; +VSTOR_PACKET *vstorPacket; + +DPRINT_ENTER (STORVSC ); + +DPRINT_INFO (STORVSC ,"resetting host adapter..." ); + + storDevice =GetStorDevice (Device); +if (!storDevice) + { +DPRINT_ERR (STORVSC ,"unable to get stor device...device being destroyed?" ); +DPRINT_EXIT (STORVSC ); +return -1 ; + } + + request = &storDevice->ResetRequest; + vstorPacket = &request->VStorPacket; + + request->WaitEvent =WaitEventCreate (); + + vstorPacket->Operation = VStorOperationResetBus; + vstorPacket->Flags =REQUEST_COMPLETION_FLAG ; + vstorPacket->VmSrb.PathId = storDevice->PathId; + + ret = Device->Driver->VmbusChannelInterface.SendPacket (Device, + vstorPacket, +sizeof (VSTOR_PACKET ), + (ULONG_PTR )&storDevice->ResetRequest, + VmbusPacketTypeDataInBand, +VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED ); +if (ret !=0 ) + { +DPRINT_ERR (STORVSC ,"Unable to send reset packet %p ret %d" , vstorPacket, ret); + goto Cleanup; + } + +// FIXME: Add a timeout +WaitEventWait (request->WaitEvent); + +WaitEventClose (request->WaitEvent); +DPRINT_INFO (STORVSC ,"host adapter reset completed" ); + +// At this point, all outstanding requests in the adapter should have been flushed out and return to us + +Cleanup: +PutStorDevice (Device); +DPRINT_EXIT (STORVSC ); +return ret; +} + +/*++ + +Name: +StorVscOnIORequest() + +Description: +Callback to initiate an I/O request + +--*/ +int +StorVscOnIORequest ( +DEVICE_OBJECT *Device, +STORVSC_REQUEST *Request + ) +{ +STORVSC_DEVICE *storDevice; +STORVSC_REQUEST_EXTENSION * requestExtension = (STORVSC_REQUEST_EXTENSION *) Request->Extension; +VSTOR_PACKET * vstorPacket =&requestExtension->VStorPacket; +int ret=0 ; + +DPRINT_ENTER (STORVSC ); + + storDevice =GetStorDevice (Device); + +DPRINT_DBG (STORVSC ,"enter - Device %p, DeviceExt %p, Request %p, Extension %p" , + Device, storDevice, Request, requestExtension); + +DPRINT_DBG (STORVSC ,"req %p len %d bus %d, target %d, lun %d cdblen %d" , + Request, Request->DataBuffer.Length, Request->Bus, Request->TargetId, Request->LunId, Request->CdbLen); + +if (!storDevice) + { +DPRINT_ERR (STORVSC ,"unable to get stor device...device being destroyed?" ); +DPRINT_EXIT (STORVSC ); +return -2 ; + } + +//PrintBytes(Request->Cdb, Request->CdbLen); + + requestExtension->Request = Request; + requestExtension->Device = Device; + +memset (vstorPacket,0 ,sizeof (VSTOR_PACKET )); + + vstorPacket->Flags |=REQUEST_COMPLETION_FLAG ; + + vstorPacket->VmSrb.Length =sizeof (VMSCSI_REQUEST ); + + vstorPacket->VmSrb.PortNumber = Request->Host; + vstorPacket->VmSrb.PathId = Request->Bus; + vstorPacket->VmSrb.TargetId = Request->TargetId; + vstorPacket->VmSrb.Lun = Request->LunId; + + vstorPacket->VmSrb.SenseInfoLength =SENSE_BUFFER_SIZE ; + +// Copy over the scsi command descriptor block + vstorPacket->VmSrb.CdbLength = Request->CdbLen; +memcpy (&vstorPacket->VmSrb.Cdb, Request->Cdb, Request->CdbLen); + + vstorPacket->VmSrb.DataIn = Request->Type; + vstorPacket->VmSrb.DataTransferLength = Request->DataBuffer.Length; + + vstorPacket->Operation = VStorOperationExecuteSRB; + +DPRINT_DBG (STORVSC ,"srb - len %d port %d, path %d, target %d, lun %d senselen %d cdblen %d" , + vstorPacket->VmSrb.Length, + vstorPacket->VmSrb.PortNumber, + vstorPacket->VmSrb.PathId, + vstorPacket->VmSrb.TargetId, + vstorPacket->VmSrb.Lun, + vstorPacket->VmSrb.SenseInfoLength, + vstorPacket->VmSrb.CdbLength); + +if (requestExtension->Request->DataBuffer.Length) + { + ret = Device->Driver->VmbusChannelInterface.SendPacketMultiPageBuffer (Device, + &requestExtension->Request->DataBuffer, + vstorPacket, +sizeof (VSTOR_PACKET ), + (ULONG_PTR )requestExtension); + } +else + { + ret = Device->Driver->VmbusChannelInterface.SendPacket (Device, + vstorPacket, +sizeof (VSTOR_PACKET ), + (ULONG_PTR )requestExtension, + VmbusPacketTypeDataInBand, +VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED ); + } + +if (ret !=0 ) + { +DPRINT_DBG (STORVSC ,"Unable to send packet %p ret %d" , vstorPacket, ret); + } + +InterlockedIncrement (&storDevice->NumOutstandingRequests); + +PutStorDevice (Device); + +DPRINT_EXIT (STORVSC ); +return ret; +} + +/*++ + +Name: +StorVscOnCleanup() + +Description: +Perform any cleanup when the driver is removed + +--*/ +void +StorVscOnCleanup ( +DRIVER_OBJECT *Driver + ) +{ +DPRINT_ENTER (STORVSC ); +DPRINT_EXIT (STORVSC ); +} + + +static void +StorVscOnIOCompletion ( +DEVICE_OBJECT *Device, +VSTOR_PACKET *VStorPacket, +STORVSC_REQUEST_EXTENSION *RequestExt + ) +{ +STORVSC_REQUEST *request; +STORVSC_DEVICE *storDevice; + +DPRINT_ENTER (STORVSC ); + + storDevice =MustGetStorDevice (Device); +if (!storDevice) + { +DPRINT_ERR (STORVSC ,"unable to get stor device...device being destroyed?" ); +DPRINT_EXIT (STORVSC ); +return ; + } + +DPRINT_DBG (STORVSC ,"IO_COMPLETE_OPERATION - request extension %p completed bytes xfer %u" , + RequestExt, VStorPacket->VmSrb.DataTransferLength); + +ASSERT (RequestExt !=NULL ); +ASSERT (RequestExt->Request !=NULL ); + + request = RequestExt->Request; + +ASSERT (request->OnIOCompletion !=NULL ); + +// Copy over the status...etc + request->Status = VStorPacket->VmSrb.ScsiStatus; + +if (request->Status !=0 || VStorPacket->VmSrb.SrbStatus !=1 ) + { +DPRINT_WARN (STORVSC ,"cmd 0x%x scsi status 0x%x srb status 0x%x\n" , + request->Cdb[0 ], + VStorPacket->VmSrb.ScsiStatus, + VStorPacket->VmSrb.SrbStatus); + } + +if ((request->Status &0xFF ) ==0x02 )// CHECK_CONDITION + { +if (VStorPacket->VmSrb.SrbStatus &0x80 )// autosense data available + { +DPRINT_WARN (STORVSC ,"storvsc pkt %p autosense data valid - len %d\n" , + RequestExt, VStorPacket->VmSrb.SenseInfoLength); + +ASSERT (VStorPacket->VmSrb.SenseInfoLength <= request->SenseBufferSize); +memcpy (request->SenseBuffer, + VStorPacket->VmSrb.SenseData, + VStorPacket->VmSrb.SenseInfoLength); + + request->SenseBufferSize = VStorPacket->VmSrb.SenseInfoLength; + } + } + +// TODO: + request->BytesXfer = VStorPacket->VmSrb.DataTransferLength; + + request->OnIOCompletion (request); + +InterlockedDecrement (&storDevice->NumOutstandingRequests); + +PutStorDevice (Device); + +DPRINT_EXIT (STORVSC ); +} + + +static void +StorVscOnReceive ( +DEVICE_OBJECT *Device, +VSTOR_PACKET *VStorPacket, +STORVSC_REQUEST_EXTENSION *RequestExt + ) +{ +switch (VStorPacket->Operation) + { +case VStorOperationCompleteIo: + +DPRINT_DBG (STORVSC ,"IO_COMPLETE_OPERATION" ); +StorVscOnIOCompletion (Device, VStorPacket, RequestExt); +break ; + +//case ENUMERATE_DEVICE_OPERATION: + +// DPRINT_INFO(STORVSC, "ENUMERATE_DEVICE_OPERATION"); + +// StorVscOnTargetRescan(Device); +// break; + +case VStorOperationRemoveDevice: + +DPRINT_INFO (STORVSC ,"REMOVE_DEVICE_OPERATION" ); +// TODO: +break ; + +default : +DPRINT_INFO (STORVSC ,"Unknown operation received - %d" , VStorPacket->Operation); +break ; + } +} + +void +StorVscOnChannelCallback ( +PVOID Context + ) +{ +int ret=0 ; +DEVICE_OBJECT *device = (DEVICE_OBJECT *)Context; +STORVSC_DEVICE *storDevice; +UINT32 bytesRecvd; +UINT64 requestId; +UCHAR packet[ALIGN_UP (sizeof (VSTOR_PACKET ),8 )]; +STORVSC_REQUEST_EXTENSION *request; + +DPRINT_ENTER (STORVSC ); + +ASSERT (device); + + storDevice =MustGetStorDevice (device); +if (!storDevice) + { +DPRINT_ERR (STORVSC ,"unable to get stor device...device being destroyed?" ); +DPRINT_EXIT (STORVSC ); +return ; + } + +do + { + ret = device->Driver->VmbusChannelInterface.RecvPacket (device, + packet, +ALIGN_UP (sizeof (VSTOR_PACKET ),8 ), + &bytesRecvd, + &requestId); +if (ret ==0 && bytesRecvd >0 ) + { +DPRINT_DBG (STORVSC ,"receive %d bytes - tid %llx" , bytesRecvd, requestId); + +//ASSERT(bytesRecvd == sizeof(VSTOR_PACKET)); + + request = (STORVSC_REQUEST_EXTENSION *)(ULONG_PTR )requestId; +ASSERT (request); + +//if (vstorPacket.Flags & SYNTHETIC_FLAG) +if ((request == &storDevice->InitRequest) || (request == &storDevice->ResetRequest)) + { +//DPRINT_INFO(STORVSC, "reset completion - operation %u status %u", vstorPacket.Operation, vstorPacket.Status); + +memcpy (&request->VStorPacket, packet,sizeof (VSTOR_PACKET )); + +WaitEventSet (request->WaitEvent); + } +else + { +StorVscOnReceive (device, (VSTOR_PACKET *)packet, request); + } + } +else + { +//DPRINT_DBG(STORVSC, "nothing else to read..."); +break ; + } + }while (1 ); + +PutStorDevice (device); + +DPRINT_EXIT (STORVSC ); +return ; +}
drivers/staging/hv/storvsc_drv.c new file +1413 -0
1,413 lines not on this page · raw message
PATCH 7/54 Staging: hv: add a TODO file
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
First cut at what needs to be done to this codebase.
--- drivers/staging/hv/TODO | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/staging/hv/TODO new file +15 -0
@@ -0,0 +1,15 @@ +TODO: + - fix checkpatch warnings/errors + - fix sparse issues + - remove compatibility layer + - fix HANDLE usage to be "real" pointers + - audit the vmbus to verify it is working properly with the + driver model + - see if the vmbus can be merged with the other virtual busses + in the kernel + - audit the network driver + - audit the block driver + - audit the scsi driver + +Please send patches for this code to Greg Kroah-Hartman <[email protected]> +and Hank Janssen <[email protected]>
PATCH 8/54 Staging: hv: make the Hyper-V virtual bus code build
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
The #define KERNEL_2_6_27 needs to be set, and I adjusted the include directories a bit to get things to build properly.
I also fixed up the direct access of bus_id, as that field is now gone.
The hv_vmbus code should now build properly, with no errors.
--- drivers/staging/hv/Channel.c | 4 ++-- drivers/staging/hv/Channel.h | 2 +- drivers/staging/hv/ChannelInterface.h | 2 +- drivers/staging/hv/ChannelMgmt.c | 4 ++-- drivers/staging/hv/ChannelMgmt.h | 8 ++++---- drivers/staging/hv/Connection.c | 2 +- drivers/staging/hv/Hv.c | 2 +- drivers/staging/hv/Hv.h | 16 ++++++++-------- drivers/staging/hv/RingBuffer.c | 2 +- drivers/staging/hv/RingBuffer.h | 2 +- drivers/staging/hv/Sources.c | 1 + drivers/staging/hv/Vmbus.c | 2 +- drivers/staging/hv/VmbusPrivate.h | 4 ++-- drivers/staging/hv/include/ChannelMessages.h | 2 +- drivers/staging/hv/osd.c | 3 ++- drivers/staging/hv/vmbus_drv.c | 15 ++++++++------- 16 files changed, 37 insertions(+), 34 deletions(-)
drivers/staging/hv/Channel.c +2 -2
@@ -22,8 +22,8 @@*/ -#include "osd.h" -#include "logging.h" +#include "include/osd.h" +#include "include/logging.h" #include "VmbusPrivate.h"
drivers/staging/hv/Channel.h +1 -1
@@ -25,7 +25,7 @@#ifndef _CHANNEL_H_#define _CHANNEL_H_ -#include "osd.h" +#include "include/osd.h" #include "ChannelMgmt.h" #pragma pack(push,1)
drivers/staging/hv/ChannelInterface.h +1 -1
@@ -25,7 +25,7 @@#ifndef _CHANNEL_INTERFACE_H_#define _CHANNEL_INTERFACE_H_ -#include "VmbusApi.h" +#include "include/VmbusApi.h" INTERNAL void GetChannelInterface(
drivers/staging/hv/ChannelMgmt.c +2 -2
@@ -22,8 +22,8 @@*/ -#include "osd.h" -#include "logging.h" +#include "include/osd.h" +#include "include/logging.h" #include "VmbusPrivate.h"
drivers/staging/hv/ChannelMgmt.h +4 -4
@@ -25,12 +25,12 @@#ifndef _CHANNEL_MGMT_H_#define _CHANNEL_MGMT_H_ -#include "osd.h" -#include "List.h" +#include "include/osd.h" +#include "include/List.h" #include "RingBuffer.h" -#include "VmbusChannelInterface.h" -#include "ChannelMessages.h" +#include "include/VmbusChannelInterface.h" +#include "include/ChannelMessages.h"
drivers/staging/hv/Connection.c +1 -1
@@ -22,7 +22,7 @@*/ -#include "logging.h" +#include "include/logging.h" #include "VmbusPrivate.h"
drivers/staging/hv/Hv.c +1 -1
@@ -22,7 +22,7 @@*/ -#include "logging.h" +#include "include/logging.h" #include "VmbusPrivate.h" //
drivers/staging/hv/Hv.h +8 -8
@@ -25,23 +25,23 @@#ifndef __HV_H__#define __HV_H__ -#include "osd.h" +#include "include/osd.h" -#include "HvTypes.h" -#include "HvStatus.h" +#include "include/HvTypes.h" +#include "include/HvStatus.h" //#include "HvVmApi.h" //#include "HvKeApi.h" //#include "HvMmApi.h" //#include "HvCpuApi.h" -#include "HvHalApi.h" -#include "HvVpApi.h" +#include "include/HvHalApi.h" +#include "include/HvVpApi.h" //#include "HvTrApi.h" -#include "HvSynicApi.h" +#include "include/HvSynicApi.h" //#include "HvAmApi.h" //#include "HvHkApi.h" //#include "HvValApi.h" -#include "HvHcApi.h" -#include "HvPtApi.h" +#include "include/HvHcApi.h" +#include "include/HvPtApi.h" enum {
drivers/staging/hv/include/ChannelMessages.h +1 -1
@@ -24,7 +24,7 @@#pragma once -#include <VmbusPacketFormat.h> +#include "VmbusPacketFormat.h" #define C_ASSERT (x)typedef UINT32 NTSTATUS ;
drivers/staging/hv/osd.c +2 -1
@@ -21,6 +21,7 @@* */ +#define KERNEL_2_6_27 #include <linux/module.h> #include <linux/init.h>
@@ -46,7 +47,7 @@#include <asm/kmap_types.h> #include <asm/atomic.h> -#include "osd.h" +#include "include/osd.h" // // Data types
drivers/staging/hv/RingBuffer.c +1 -1
@@ -22,7 +22,7 @@*/ -#include "logging.h" +#include "include/logging.h" #include "RingBuffer.h" //
drivers/staging/hv/RingBuffer.h +1 -1
@@ -25,7 +25,7 @@ #ifndef _RING_BUFFER_H_ #define _RING_BUFFER_H_ -#include "osd.h" +#include "include/osd.h" typedef struct _SG_BUFFER_LIST { PVOID Data;
drivers/staging/hv/Sources.c +1 -0
@@ -21,6 +21,7 @@* */ +#define KERNEL_2_6_27 #include "Vmbus.c" #include "Hv.c"
drivers/staging/hv/Vmbus.c +1 -1
@@ -22,7 +22,7 @@*/ -#include "logging.h" +#include "include/logging.h" #include "VersionInfo.h" #include "VmbusPrivate.h"
drivers/staging/hv/vmbus_drv.c +8 -7
@@ -21,6 +21,7 @@* */ +#define KERNEL_2_6_27 #include <linux/init.h> #include <linux/module.h>
@@ -29,8 +30,8 @@#include <linux/interrupt.h> #include <linux/sysctl.h> -#include "logging.h" -#include "vmbus.h" +#include "include/logging.h" +#include "include/vmbus.h" // // Defines
@@ -451,7 +452,7 @@ int vmbus_bus_init(PFN_DRIVERINITIALIZE goto cleanup; }//strcpy(dev_ctx->device.bus_id, dev_ctx->device_obj.name); -sprintf (dev_ctx->device.bus_id,"vmbus_0_0" ); +dev_set_name (&dev_ctx->device,"vmbus_0_0" );memcpy (&dev_ctx->class_id, &dev_ctx->device_obj.deviceType,sizeof (GUID ));memcpy (&dev_ctx->device_id, &dev_ctx->device_obj.deviceInstance,sizeof (GUID ));
@@ -656,16 +657,16 @@ static int vmbus_child_device_register(D// // Make sure we are not registered already // -if (child_device_ctx->device.bus_id[0 ] !='\0' ) +if (strlen (dev_name (&child_device_ctx->device)) !=0 ) { -DPRINT_ERR (VMBUS_DRV ,"child device (%p) already registered - busid %s" , child_device_ctx, child_device_ctx->device.bus_id); +DPRINT_ERR (VMBUS_DRV ,"child device (%p) already registered - busid %s" , child_device_ctx,dev_name (&child_device_ctx->device)); ret =-1 ; goto Cleanup; }// Set the device bus id. Otherwise, device_register()will fail. -sprintf (child_device_ctx->device.bus_id,"vmbus_0_%d" ,InterlockedIncrement (&device_num)); +dev_set_name (&child_device_ctx->device,"vmbus_0_%d" ,InterlockedIncrement (&device_num));// The new device belongs to this bus child_device_ctx->device.bus = &g_vmbus_drv.bus;//device->dev.bus;
@@ -924,7 +925,7 @@ static int vmbus_probe(struct device *ch ret = device_ctx->probe_error = driver_ctx->probe (child_device);if (ret !=0 ) { -DPRINT_ERR (VMBUS_DRV ,"probe() failed for device %s (%p) on driver %s (%d)..." , child_device->bus_id, child_device, child_device->driver->name, ret); +DPRINT_ERR (VMBUS_DRV ,"probe() failed for device %s (%p) on driver %s (%d)..." ,dev_name (child_device), child_device, child_device->driver->name, ret);#ifdef KERNEL_2_6_27 INIT_WORK (&device_ctx->probe_failed_work_item, vmbus_probe_failed_cb);
drivers/staging/hv/VmbusPrivate.h +2 -2
@@ -30,14 +30,14 @@#endif #include "Hv.h" -#include "VmbusApi.h" +#include "include/VmbusApi.h" #include "Channel.h" #include "ChannelMgmt.h" #include "ChannelInterface.h" //#include "ChannelMessages.h" #include "RingBuffer.h" //#include "Packet.h" -#include "List.h" +#include "include/List.h" // // Defines
PATCH 9/54 Staging: hv: use the correct #ifdef for x86-64
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
x86-64 needs a different config check. Thanks to Hank for the debugging to determine the fix for this.
--- drivers/staging/hv/Hv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/hv/Hv.c +1 -1
@@ -165,7 +165,7 @@ HvDoHypercall (void * Output ) { -#ifdef x86_64 +#ifdef CONFIG_X86_64 UINT64 hvStatus=0 ;UINT64 inputAddress = (Input)?GetPhysicalAddress (Input) :0 ;UINT64 outputAddress = (Output)?GetPhysicalAddress (Output) :0 ;
PATCH 10/54 Staging: hv: add the Hyper-V virtual bus to the build
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
Add the Hyper-V virtual bus to the kernel build system.
--- drivers/staging/Kconfig | 2 ++ drivers/staging/Makefile | 1 + drivers/staging/hv/Kconfig | 8 ++++++++ drivers/staging/hv/Makefile | 3 +++ 4 files changed, 14 insertions(+)
drivers/staging/Kconfig +2 -0
@@ -129,5 +129,7 @@ source "drivers/staging/pata_rdc/Kconfig source "drivers/staging/udlfb/Kconfig" +source "drivers/staging/hv/Kconfig" + endif # !STAGING_EXCLUDE_BUILD endif # STAGING
drivers/staging/Makefile +1 -0
@@ -46,3 +46,4 @@ obj-$(CONFIG_VT6655) += vt6655/ obj-$(CONFIG_USB_CPC) += cpc-usb/ obj-$(CONFIG_RDC_17F3101X) += pata_rdc/ obj-$(CONFIG_FB_UDL) += udlfb/ +obj-$(CONFIG_HYPERV) += hv/
drivers/staging/hv/Kconfig new file +8 -0
@@ -0,0 +1,8 @@ +config HYPERV + tristate "Microsoft Hyper-V client drivers" + depends on X86 + default n + help + Select this option to run Linux as a Hyper-V client operating + system. +
drivers/staging/hv/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +obj-$(CONFIG_HYPERV) += hv_vmbus.o + +hv_vmbus-objs := vmbus_drv.o osd.o Sources.o
PATCH 11/54 Staging: hv: make the Hyper-V virtual storage driver build
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
The #define KERNEL_2_6_27 needs to be set, and I adjusted the include directories a bit to get things to build properly.
I also fixed up the direct access of bus_id, as that field is now gone. Some minor scsi api changes were needed as well.
The hv_storvsc code should now build properly, with no errors.
--- drivers/staging/hv/StorVsc.c | 9 +++++---- drivers/staging/hv/storvsc_drv.c | 11 ++++++----- 2 files changed, 11 insertions(+), 9 deletions(-)
drivers/staging/hv/StorVsc.c +5 -4
@@ -21,12 +21,13 @@* */ +#define KERNEL_2_6_27 -#include "logging.h" +#include "include/logging.h" -#include "StorVscApi.h" -#include "VmbusPacketFormat.h" -#include "vstorage.h" +#include "include/StorVscApi.h" +#include "include/VmbusPacketFormat.h" +#include "include/vstorage.h" //
drivers/staging/hv/storvsc_drv.c +6 -5
@@ -21,6 +21,7 @@* */ +#define KERNEL_2_6_27 #include <linux/init.h> #include <linux/module.h>
@@ -40,10 +41,10 @@#include <scsi/scsi_dbg.h> #endif -#include "logging.h" -#include "vmbus.h" +#include "include/logging.h" +#include "include/vmbus.h" -#include "StorVscApi.h" +#include "include/StorVscApi.h" // // #defines
@@ -296,7 +297,7 @@ static int storvsc_probe(struct device *#if defined(KERNEL_2_6_27 ) host_device_ctx->request_pool =kmem_cache_create - (device_ctx->device.bus_id, + (dev_name (&device_ctx->device),sizeof (struct storvsc_cmd_request ) + storvsc_drv_obj->RequestExtSize,0 ,SLAB_HWCACHE_ALIGN ,NULL );
@@ -1250,7 +1251,7 @@ static int storvsc_report_luns(struct sc// cmd length *(unsigned int *)&cmd[6 ] =cpu_to_be32 (report_len); - result =scsi_execute_req (sdev, cmd,DMA_FROM_DEVICE , (unsigned char *)report_luns, report_len, &sshdr,30 *HZ ,3 ); + result =scsi_execute_req (sdev, cmd,DMA_FROM_DEVICE , (unsigned char *)report_luns, report_len, &sshdr,30 *HZ ,3 ,NULL );if (result !=0 ) {kfree (report_luns);
PATCH 12/54 Staging: hv: add the Hyper-V virtual scsi driver to the build
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
Add the Hyper-V virtual scsi driver to the kernel build system.
--- drivers/staging/hv/Kconfig | 6 ++++++ drivers/staging/hv/Makefile | 2 ++ 2 files changed, 8 insertions(+)
drivers/staging/hv/Kconfig +6 -0
@@ -6,3 +6,9 @@ config HYPERV Select this option to run Linux as a Hyper-V client operating system. +config HYPERV_STORAGE + tristate "Microsoft Hyper-V virtual storage driver" + depends on SCSI + default n + help + Select this option to enable the Hyper-V virtual storage driver.
drivers/staging/hv/Makefile +2 -0
@@ -1,3 +1,5 @@ obj-$(CONFIG_HYPERV) += hv_vmbus.o +obj-$(CONFIG_HYPERV_STORAGE) += hv_storvsc.o hv_vmbus-objs := vmbus_drv.o osd.o Sources.o +hv_storvsc-objs := storvsc_drv.o osd.o StorVsc.o
PATCH 13/54 Staging: hv: make the Hyper-V virtual block driver build
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
The #define KERNEL_2_6_27 needs to be set, and I adjusted the include directories a bit to get things to build properly.
I also fixed up the direct access of bus_id, as that field is now gone. Lots of block api changes were needed, and I don't think I got it all correct. It would be great of someone who knows the block api better could review it.
The hv_blkvsc code should now build, with no errors.
--- drivers/staging/hv/BlkVsc.c | 2 +- drivers/staging/hv/blkvsc_drv.c | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-)
drivers/staging/hv/BlkVsc.c +1 -1
@@ -21,7 +21,7 @@*/ -#include "../storvsc/StorVsc.c" +#include "StorVsc.c" static const char * gBlkDriverName="blkvsc" ;
drivers/staging/hv/blkvsc_drv.c +12 -11
@@ -20,6 +20,7 @@* */ +#define KERNEL_2_6_27 #include <linux/init.h> #include <linux/module.h>
@@ -34,10 +35,10 @@#include <scsi/scsi_eh.h> #include <scsi/scsi_dbg.h> -#include "logging.h" -#include "vmbus.h" +#include "include/logging.h" +#include "include/vmbus.h" -#include "StorVscApi.h" +#include "include/StorVscApi.h" // // #defines
@@ -313,7 +314,7 @@ static int blkvsc_probe(struct device *dASSERT (sizeof (struct blkvsc_request_group ) <=sizeof (struct blkvsc_request ));#ifdef KERNEL_2_6_27 - blkdev->request_pool =kmem_cache_create (device_ctx->device.bus_id, + blkdev->request_pool =kmem_cache_create (dev_name (&device_ctx->device),sizeof (struct blkvsc_request ) + storvsc_drv_obj->RequestExtSize,0 ,SLAB_HWCACHE_ALIGN ,NULL );#else
@@ -426,7 +427,7 @@ static int blkvsc_probe(struct device *d }set_capacity (blkdev->gd, blkdev->capacity * (blkdev->sector_size/512 )); -blk_queue_hardsect_size (blkdev->gd->queue, blkdev->sector_size); +blk_queue_logical_block_size (blkdev->gd->queue, blkdev->sector_size);// go! add_disk (blkdev->gd);
@@ -982,7 +983,7 @@ static int blkvsc_do_request(struct blocint pending=0 ;struct blkvsc_request_group *group=NULL ; -DPRINT_DBG (BLKVSC_DRV ,"blkdev %p req %p sect %llu \n" , blkdev, req, req->sector); +DPRINT_DBG (BLKVSC_DRV ,"blkdev %p req %p sect %llu \n" , blkdev, req,blk_rq_pos (req));// Create a group to tie req to list of blkvsc_reqs group = (struct blkvsc_request_group *)kmem_cache_alloc (blkdev->request_pool,GFP_ATOMIC );
@@ -994,7 +995,7 @@ static int blkvsc_do_request(struct blocINIT_LIST_HEAD (&group->blkvsc_req_list); group->outstanding = group->status =0 ; - start_sector = req->sector; + start_sector =blk_rq_pos (req);// foreach bio in the request if (req->bio)
@@ -1314,13 +1315,13 @@ static void blkvsc_request(struct requesint ret=0 ;DPRINT_DBG (BLKVSC_DRV ,"- enter \n" ); -while ((req =elv_next_request (queue)) !=NULL ) +while ((req =blk_peek_request (queue)) !=NULL ) {DPRINT_DBG (BLKVSC_DRV ,"- req %p\n" , req); blkdev = req->rq_disk->private_data;if (blkdev->shutting_down || !blk_fs_request (req) || blkdev->media_not_present) { -end_request (req,0 ); +__blk_end_request_cur (req,0 );continue ; }
@@ -1333,7 +1334,7 @@ static void blkvsc_request(struct requesbreak ; } -blkdev_dequeue_request (req); +blk_start_request (req); ret =blkvsc_do_request (blkdev, req);if (ret >0 )
@@ -1410,7 +1411,7 @@ static int blkvsc_revalidate_disk(struct {blkvsc_do_read_capacity (blkdev);set_capacity (blkdev->gd, blkdev->capacity * (blkdev->sector_size/512 )); -blk_queue_hardsect_size (gd->queue, blkdev->sector_size); +blk_queue_logical_block_size (gd->queue, blkdev->sector_size); }return 0 ; }
PATCH 14/54 Staging: hv: add the Hyper-V virtual block driver to the build
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
Add the Hyper-V virtual block driver to the kernel build system.
--- drivers/staging/hv/Kconfig | 7 +++++++ drivers/staging/hv/Makefile | 2 ++ 2 files changed, 9 insertions(+)
drivers/staging/hv/Kconfig +7 -0
@@ -12,3 +12,10 @@ config HYPERV_STORAGE default n help Select this option to enable the Hyper-V virtual storage driver. + +config HYPERV_BLOCK + tristate "Microsoft Hyper-V virtual block driver" + depends on BLOCK + default n + help + Select this option to enable the Hyper-V virtual block driver.
drivers/staging/hv/Makefile +2 -0
@@ -1,5 +1,7 @@ obj-$(CONFIG_HYPERV) += hv_vmbus.o obj-$(CONFIG_HYPERV_STORAGE) += hv_storvsc.o +obj-$(CONFIG_HYPERV_BLOCK) += hv_blkvsc.o hv_vmbus-objs := vmbus_drv.o osd.o Sources.o hv_storvsc-objs := storvsc_drv.o osd.o StorVsc.o +hv_blkvsc-objs := blkvsc_drv.o osd.o BlkVsc.o
PATCH 15/54 Staging: hv: make the Hyper-V virtual network driver build
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
The #define KERNEL_2_6_27 needs to be set, and I adjusted the include directories a bit to get things to build properly.
The driver was changed to use net_device_ops, as that is needed to build and operate properly now.
The hv_netvsc code should now build with no errors.
--- drivers/staging/hv/NetVsc.c | 3 ++- drivers/staging/hv/NetVsc.h | 8 ++++---- drivers/staging/hv/RndisFilter.c | 5 +++-- drivers/staging/hv/RndisFilter.h | 4 ++-- drivers/staging/hv/include/nvspprotocol.h | 2 +- drivers/staging/hv/netvsc_drv.c | 21 +++++++++++++-------- 6 files changed, 25 insertions(+), 18 deletions(-)
drivers/staging/hv/include/nvspprotocol.h +1 -1
@@ -24,7 +24,7 @@#pragma once -#include <VmbusChannelInterface.h> +#include "VmbusChannelInterface.h" #define NVSP_INVALID_PROTOCOL_VERSION ((UINT32)0xFFFFFFFF)
drivers/staging/hv/NetVsc.c +2 -1
@@ -20,8 +20,9 @@* */ +#define KERNEL_2_6_27 -#include "logging.h" +#include "include/logging.h" #include "NetVsc.h" #include "RndisFilter.h"
drivers/staging/hv/netvsc_drv.c +13 -8
@@ -20,6 +20,7 @@* */ +#define KERNEL_2_6_27 #include <linux/init.h> #include <linux/module.h>
@@ -41,10 +42,10 @@#include <net/sock.h> #include <net/pkt_sched.h> -#include "logging.h" -#include "vmbus.h" +#include "include/logging.h" +#include "include/vmbus.h" -#include "NetVscApi.h" +#include "include/NetVscApi.h" MODULE_LICENSE ("GPL" );
@@ -158,6 +159,14 @@ static void netvsc_set_multicast_list(UN } +static const struct net_device_ops device_ops = { + .ndo_open = netvsc_open, + .ndo_stop = netvsc_close, + .ndo_start_xmit = netvsc_start_xmit, + .ndo_get_stats = netvsc_get_stats, + .ndo_set_multicast_list = netvsc_set_multicast_list, +}; +/*++ Name: netvsc_probe()
@@ -225,11 +234,7 @@ static int netvsc_probe(struct device *dmemcpy (net->dev_addr, device_info.MacAddr,ETH_ALEN ); - net->open = netvsc_open; - net->hard_start_xmit = netvsc_start_xmit; - net->stop = netvsc_close; - net->get_stats = netvsc_get_stats; - net->set_multicast_list = netvsc_set_multicast_list; + net->netdev_ops = &device_ops;#if !defined(KERNEL_2_6_27 )SET_MODULE_OWNER (net);
drivers/staging/hv/NetVsc.h +4 -4
@@ -24,12 +24,12 @@#ifndef _NETVSC_H_#define _NETVSC_H_ -#include "VmbusPacketFormat.h" -#include "nvspprotocol.h" +#include "include/VmbusPacketFormat.h" +#include "include/nvspprotocol.h" -#include "List.h" +#include "include/List.h" -#include "NetVscApi.h" +#include "include/NetVscApi.h" // // #defines //
drivers/staging/hv/RndisFilter.c +3 -2
@@ -21,10 +21,11 @@* */ +#define KERNEL_2_6_27 -#include "logging.h" +#include "include/logging.h" -#include "NetVscApi.h" +#include "include/NetVscApi.h" #include "RndisFilter.h" //
drivers/staging/hv/RndisFilter.h +2 -2
@@ -27,10 +27,10 @@#define __struct_bcount (x) -#include "osd.h" +#include "include/osd.h" #include "NetVsc.h" -#include "rndis.h" +#include "include/rndis.h" #define RNDIS_HEADER_SIZE (sizeof(RNDIS_MESSAGE) - sizeof(RNDIS_MESSAGE_CONTAINER))
PATCH 16/54 Staging: hv: add the Hyper-V virtual network driver to the build
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
Add the Hyper-V virtual network driver to the kernel build system.
--- drivers/staging/hv/Kconfig | 7 +++++++ drivers/staging/hv/Makefile | 2 ++ 2 files changed, 9 insertions(+)
drivers/staging/hv/Kconfig +7 -0
@@ -19,3 +19,10 @@ config HYPERV_BLOCK default n help Select this option to enable the Hyper-V virtual block driver. + +config HYPERV_NET + tristate "Microsoft Hyper-V virtual network driver" + depends on NET + default n + help + Select this option to enable the Hyper-V virtual network driver.
drivers/staging/hv/Makefile +2 -0
@@ -1,7 +1,9 @@ obj-$(CONFIG_HYPERV) += hv_vmbus.o obj-$(CONFIG_HYPERV_STORAGE) += hv_storvsc.o obj-$(CONFIG_HYPERV_BLOCK) += hv_blkvsc.o +obj-$(CONFIG_HYPERV_NET) += hv_netvsc.o hv_vmbus-objs := vmbus_drv.o osd.o Sources.o hv_storvsc-objs := storvsc_drv.o osd.o StorVsc.o hv_blkvsc-objs := blkvsc_drv.o osd.o BlkVsc.o +hv_netvsc-objs := netvsc_drv.o osd.o NetVsc.o RndisFilter.o
PATCH 17/54 Staging: hv: remove INTERNAL typedef
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
The INTERNAL typedef is now removed from the Hyper-V driver code.
--- drivers/staging/hv/Channel.h | 24 ++++++++++++------------ drivers/staging/hv/ChannelInterface.c | 22 +++++++++++----------- drivers/staging/hv/ChannelInterface.h | 4 ++-- drivers/staging/hv/ChannelMgmt.h | 10 +++++----- drivers/staging/hv/Hv.h | 12 ++++++------ drivers/staging/hv/RingBuffer.h | 16 ++++++++-------- drivers/staging/hv/VmbusPrivate.h | 24 ++++++++++-------------- 7 files changed, 54 insertions(+), 58 deletions(-)
drivers/staging/hv/Channel.h +12 -12
@@ -62,7 +62,7 @@ typedef struct _VMBUS_CHANNEL_PACKET_MUL// Routines // -INTERNAL int +static int VmbusChannelOpen( VMBUS_CHANNEL *Channel, UINT32 SendRingBufferSize,
@@ -73,12 +73,12 @@ VmbusChannelOpen(PVOID Context ); -INTERNAL void +static void VmbusChannelClose (VMBUS_CHANNEL *Channel ); -INTERNAL int +static int VmbusChannelSendPacket( VMBUS_CHANNEL *Channel, const PVOID Buffer,
@@ -88,7 +88,7 @@ VmbusChannelSendPacket(UINT32 Flags ); -INTERNAL int +static int VmbusChannelSendPacketPageBuffer( VMBUS_CHANNEL *Channel, PAGE_BUFFER PageBuffers[],
@@ -98,7 +98,7 @@ VmbusChannelSendPacketPageBuffer(UINT64 RequestId ); -INTERNAL int +static int VmbusChannelSendPacketMultiPageBuffer( VMBUS_CHANNEL *Channel, MULTIPAGE_BUFFER *MultiPageBuffer,
@@ -107,7 +107,7 @@ VmbusChannelSendPacketMultiPageBuffer(UINT64 RequestId ); -INTERNAL int +static int VmbusChannelEstablishGpadl( VMBUS_CHANNEL *Channel, PVOID Kbuffer, // from kmalloc()
@@ -115,13 +115,13 @@ VmbusChannelEstablishGpadl(UINT32 *GpadlHandle ); -INTERNAL int +static int VmbusChannelTeardownGpadl (VMBUS_CHANNEL *Channel,UINT32 GpadlHandle ); -INTERNAL int +static int VmbusChannelRecvPacket( VMBUS_CHANNEL *Channel, PVOID Buffer,
@@ -130,7 +130,7 @@ VmbusChannelRecvPacket(UINT64 * RequestId ); -INTERNAL int +static int VmbusChannelRecvPacketRaw( VMBUS_CHANNEL *Channel, PVOID Buffer,
@@ -139,18 +139,18 @@ VmbusChannelRecvPacketRaw(UINT64 * RequestId ); -INTERNAL void +static void VmbusChannelOnChannelEvent (VMBUS_CHANNEL *Channel ); -INTERNAL void +static void VmbusChannelGetDebugInfo (VMBUS_CHANNEL *Channel,VMBUS_CHANNEL_DEBUG_INFO *DebugInfo ); -INTERNAL void +static void VmbusChannelOnTimer (void *Context );
drivers/staging/hv/ChannelInterface.c +11 -11
@@ -23,7 +23,7 @@#include "VmbusPrivate.h" -INTERNAL int +static int IVmbusChannelOpen( PDEVICE_OBJECT Device, UINT32 SendBufferSize,
@@ -44,7 +44,7 @@ IVmbusChannelOpen( } -INTERNAL void +static void IVmbusChannelClose (PDEVICE_OBJECT Device )
@@ -53,7 +53,7 @@ IVmbusChannelClose( } -INTERNAL int +static int IVmbusChannelSendPacket( PDEVICE_OBJECT Device, const PVOID Buffer,
@@ -71,7 +71,7 @@ IVmbusChannelSendPacket( Flags); } -INTERNAL int +static int IVmbusChannelSendPacketPageBuffer( PDEVICE_OBJECT Device, PAGE_BUFFER PageBuffers[],
@@ -89,7 +89,7 @@ IVmbusChannelSendPacketPageBuffer( RequestId); } -INTERNAL int +static int IVmbusChannelSendPacketMultiPageBuffer( PDEVICE_OBJECT Device, MULTIPAGE_BUFFER *MultiPageBuffer,
@@ -105,7 +105,7 @@ IVmbusChannelSendPacketMultiPageBuffer( RequestId); } -INTERNAL int +static int IVmbusChannelRecvPacket ( PDEVICE_OBJECT Device, PVOID Buffer,
@@ -121,7 +121,7 @@ IVmbusChannelRecvPacket ( RequestId); } -INTERNAL int +static int IVmbusChannelRecvPacketRaw( PDEVICE_OBJECT Device, PVOID Buffer,
@@ -137,7 +137,7 @@ IVmbusChannelRecvPacketRaw( RequestId); } -INTERNAL int +static int IVmbusChannelEstablishGpadl( PDEVICE_OBJECT Device, PVOID Buffer,
@@ -151,7 +151,7 @@ IVmbusChannelEstablishGpadl( GpadlHandle); } -INTERNAL int +static int IVmbusChannelTeardownGpadl (PDEVICE_OBJECT Device, UINT32 GpadlHandle
@@ -162,7 +162,7 @@ IVmbusChannelTeardownGpadl( } -INTERNAL void +static void GetChannelInterface (VMBUS_CHANNEL_INTERFACE *ChannelInterface )
@@ -180,7 +180,7 @@ GetChannelInterface( } -INTERNAL void +static void GetChannelInfo (PDEVICE_OBJECT Device, DEVICE_INFO *DeviceInfo
drivers/staging/hv/ChannelInterface.h +2 -2
@@ -27,12 +27,12 @@#include "include/VmbusApi.h" -INTERNAL void +static void GetChannelInterface (VMBUS_CHANNEL_INTERFACE *ChannelInterface ); -INTERNAL void +static void GetChannelInfo (PDEVICE_OBJECT Device, DEVICE_INFO *DeviceInfo
drivers/staging/hv/ChannelMgmt.h +5 -5
@@ -128,27 +128,27 @@ typedef struct _VMBUS_CHANNEL_MSGINFO {// Routines // -INTERNAL VMBUS_CHANNEL* +static VMBUS_CHANNEL *AllocVmbusChannel (void ); -INTERNAL void +static void FreeVmbusChannel (VMBUS_CHANNEL *Channel ); -INTERNAL void +static void VmbusOnChannelMessage (void *Context ); -INTERNAL int +static int VmbusChannelRequestOffers (void ); -INTERNAL void +static void VmbusChannelReleaseUnattachedChannels (void );
drivers/staging/hv/Hv.h +6 -6
@@ -148,17 +148,17 @@ static inline void WriteMsr(int msr, UIN// // Hv Interface // -INTERNAL int +static int HvInit (VOID ); -INTERNAL VOID +static VOID HvCleanup (VOID ); -INTERNAL HV_STATUS +static HV_STATUS HvPostMessage( HV_CONNECTION_ID connectionId, HV_MESSAGE_TYPE messageType,
@@ -166,17 +166,17 @@ HvPostMessage(SIZE_T payloadSize ); -INTERNAL HV_STATUS +static HV_STATUS HvSignalEvent (VOID ); -INTERNAL int +static int HvSynicInit (UINT32 irqVector ); -INTERNAL VOID +static VOID HvSynicCleanup (VOID );
drivers/staging/hv/RingBuffer.h +8 -8
@@ -69,33 +69,33 @@ typedef struct _RING_BUFFER_DEBUG_INFO {// Interface // -INTERNAL int +static int RingBufferInit (RING_BUFFER_INFO *RingInfo,PVOID Buffer,UINT32 BufferLen ); -INTERNAL void +static void RingBufferCleanup (RING_BUFFER_INFO *RingInfo ); -INTERNAL int +static int RingBufferWrite (RING_BUFFER_INFO *RingInfo,SG_BUFFER_LIST SgBuffers[],UINT32 SgBufferCount ); -INTERNAL int +static int RingBufferPeek (RING_BUFFER_INFO *RingInfo,PVOID Buffer,UINT32 BufferLen ); -INTERNAL int +static int RingBufferRead( RING_BUFFER_INFO *RingInfo, PVOID Buffer,
@@ -103,18 +103,18 @@ RingBufferRead(UINT32 Offset ); -INTERNAL UINT32 +static UINT32 GetRingBufferInterruptMask (RING_BUFFER_INFO *RingInfo ); -INTERNAL void +static void DumpRingInfo (RING_BUFFER_INFO * RingInfo,char *Prefix ); -INTERNAL void +static void RingBufferGetDebugInfo (RING_BUFFER_INFO *RingInfo, RING_BUFFER_DEBUG_INFO *DebugInfo
drivers/staging/hv/VmbusPrivate.h +10 -14
@@ -25,10 +25,6 @@#ifndef _VMBUS_PRIVATE_H_#define _VMBUS_PRIVATE_H_ -#ifndef INTERNAL -#define INTERNAL static -#endif -#include "Hv.h" #include "include/VmbusApi.h" #include "Channel.h"
@@ -114,25 +110,25 @@ extern VMBUS_CONNECTION gVmbusConnection// // General vmbus interface // -INTERNAL DEVICE_OBJECT* +static DEVICE_OBJECT *VmbusChildDeviceCreate (GUID deviceType,GUID deviceInstance,void *context); -INTERNAL int +static int VmbusChildDeviceAdd (DEVICE_OBJECT * Device); -INTERNAL void +static void VmbusChildDeviceRemove (DEVICE_OBJECT * Device); -//INTERNAL void +//static void //VmbusChildDeviceDestroy( // DEVICE_OBJECT*); -INTERNAL VMBUS_CHANNEL* +static VMBUS_CHANNEL *GetChannelFromRelId (UINT32 relId );
@@ -140,28 +136,28 @@ GetChannelFromRelId(// // Connection interface // -INTERNAL int +static int VmbusConnect (VOID ); -INTERNAL int +static int VmbusDisconnect (VOID ); -INTERNAL int +static int VmbusPostMessage (PVOID buffer,SIZE_T bufSize ); -INTERNAL int +static int VmbusSetEvent (UINT32 childRelId ); -INTERNAL VOID +static VOID VmbusOnEvents (VOID );
PATCH 18/54 Staging: hv: remove PVOID typedef
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
The PVOID typedef is now removed from the Hyper-V driver code.
--- drivers/staging/hv/Channel.c | 20 ++++++++++---------- drivers/staging/hv/Channel.h | 16 ++++++++-------- drivers/staging/hv/ChannelInterface.c | 16 ++++++++-------- drivers/staging/hv/ChannelMgmt.c | 8 ++++---- drivers/staging/hv/ChannelMgmt.h | 4 ++-- drivers/staging/hv/Connection.c | 6 +++--- drivers/staging/hv/Hv.c | 2 +- drivers/staging/hv/Hv.h | 2 +- drivers/staging/hv/NetVsc.c | 8 ++++---- drivers/staging/hv/NetVsc.h | 4 ++-- drivers/staging/hv/RingBuffer.c | 18 +++++++++--------- drivers/staging/hv/RingBuffer.h | 8 ++++---- drivers/staging/hv/StorVsc.c | 6 +++--- drivers/staging/hv/VmbusPrivate.h | 2 +- drivers/staging/hv/include/NetVscApi.h | 8 ++++---- drivers/staging/hv/include/StorVscApi.h | 4 ++-- drivers/staging/hv/include/VmbusApi.h | 18 +++++++++--------- drivers/staging/hv/include/VmbusPacketFormat.h | 2 +- drivers/staging/hv/include/osd.h | 5 ++--- drivers/staging/hv/include/rndis.h | 4 ++-- drivers/staging/hv/osd.c | 4 ++-- 21 files changed, 82 insertions(+), 83 deletions(-)
drivers/staging/hv/Channel.c +10 -10
@@ -32,7 +32,7 @@// static int VmbusChannelCreateGpadlHeader ( -PVOID Kbuffer,// must be phys and virt contiguous +void * Kbuffer,// must be phys and virt contiguous UINT32 Size,// page-size multiple VMBUS_CHANNEL_MSGINFO **msgInfo, UINT32 *MessageCount
@@ -204,10 +204,10 @@ VmbusChannelOpen(VMBUS_CHANNEL *NewChannel, UINT32 SendRingBufferSize, UINT32 RecvRingBufferSize, - PVOID UserData, + void * UserData, UINT32 UserDataLen, PFN_CHANNEL_CALLBACK pfnOnChannelCallback, - PVOID Context + void * Context ) { int ret=0;
@@ -392,7 +392,7 @@ Description:--*/ static int VmbusChannelCreateGpadlHeader ( -PVOID Kbuffer,// from kmalloc() +void * Kbuffer,// from kmalloc() UINT32 Size,// page-size multiple VMBUS_CHANNEL_MSGINFO **MsgInfo,UINT32 *MessageCount)
@@ -515,7 +515,7 @@ Description:int VmbusChannelEstablishGpadl (VMBUS_CHANNEL *Channel, -PVOID Kbuffer,// from kmalloc() +void * Kbuffer,// from kmalloc() UINT32 Size,// page-size multiple UINT32 *GpadlHandle )
@@ -752,7 +752,7 @@ Description: int VmbusChannelSendPacket( VMBUS_CHANNEL *Channel, - const PVOID Buffer, + const void * Buffer, UINT32 BufferLen, UINT64 RequestId, VMBUS_PACKET_TYPE Type,
@@ -820,7 +820,7 @@ VmbusChannelSendPacketPageBuffer(VMBUS_CHANNEL *Channel, PAGE_BUFFER PageBuffers[], UINT32 PageCount, - PVOID Buffer, + void * Buffer, UINT32 BufferLen, UINT64 RequestId )
@@ -902,7 +902,7 @@ intVmbusChannelSendPacketMultiPageBuffer (VMBUS_CHANNEL *Channel,MULTIPAGE_BUFFER *MultiPageBuffer, - PVOID Buffer, + void * Buffer, UINT32 BufferLen, UINT64 RequestId )
@@ -984,7 +984,7 @@ Description:int VmbusChannelRecvPacket (VMBUS_CHANNEL *Channel, -PVOID Buffer, +void * Buffer,UINT32 BufferLen,UINT32 * BufferActualLen, UINT64* RequestId
@@ -1061,7 +1061,7 @@ Description:int VmbusChannelRecvPacketRaw (VMBUS_CHANNEL *Channel, -PVOID Buffer, +void * Buffer,UINT32 BufferLen,UINT32 * BufferActualLen, UINT64* RequestId
drivers/staging/hv/Channel.h +8 -8
@@ -67,10 +67,10 @@ VmbusChannelOpen(VMBUS_CHANNEL *Channel, UINT32 SendRingBufferSize, UINT32 RecvRingBufferSize, - PVOID UserData, + void * UserData, UINT32 UserDataLen, PFN_CHANNEL_CALLBACK pfnOnChannelCallback, - PVOID Context + void * Context ); static void
@@ -81,7 +81,7 @@ VmbusChannelClose( static int VmbusChannelSendPacket( VMBUS_CHANNEL *Channel, - const PVOID Buffer, + const void * Buffer, UINT32 BufferLen, UINT64 RequestId, VMBUS_PACKET_TYPE Type,
@@ -93,7 +93,7 @@ VmbusChannelSendPacketPageBuffer(VMBUS_CHANNEL *Channel, PAGE_BUFFER PageBuffers[], UINT32 PageCount, - PVOID Buffer, + void * Buffer, UINT32 BufferLen, UINT64 RequestId );
@@ -102,7 +102,7 @@ static intVmbusChannelSendPacketMultiPageBuffer (VMBUS_CHANNEL *Channel,MULTIPAGE_BUFFER *MultiPageBuffer, - PVOID Buffer, + void * Buffer, UINT32 BufferLen, UINT64 RequestId );
@@ -110,7 +110,7 @@ VmbusChannelSendPacketMultiPageBuffer(static int VmbusChannelEstablishGpadl (VMBUS_CHANNEL *Channel, -PVOID Kbuffer,// from kmalloc() +void * Kbuffer,// from kmalloc() UINT32 Size,// page-size multiple UINT32 *GpadlHandle );
@@ -124,7 +124,7 @@ VmbusChannelTeardownGpadl(static int VmbusChannelRecvPacket (VMBUS_CHANNEL *Channel, -PVOID Buffer, +void * Buffer,UINT32 BufferLen,UINT32 * BufferActualLen, UINT64* RequestId
@@ -133,7 +133,7 @@ VmbusChannelRecvPacket(static int VmbusChannelRecvPacketRaw (VMBUS_CHANNEL *Channel, -PVOID Buffer, +void * Buffer,UINT32 BufferLen,UINT32 * BufferActualLen, UINT64* RequestId
drivers/staging/hv/ChannelInterface.c +8 -8
@@ -28,10 +28,10 @@ IVmbusChannelOpen(PDEVICE_OBJECT Device, UINT32 SendBufferSize, UINT32 RecvRingBufferSize, - PVOID UserData, + void * UserData, UINT32 UserDataLen, VMBUS_CHANNEL_CALLBACK ChannelCallback, - PVOID Context + void * Context ) { return VmbusChannelOpen( (VMBUS_CHANNEL*)Device->context,
@@ -56,7 +56,7 @@ IVmbusChannelClose( static int IVmbusChannelSendPacket( PDEVICE_OBJECT Device, - const PVOID Buffer, + const void * Buffer, UINT32 BufferLen, UINT64 RequestId, UINT32 Type,
@@ -76,7 +76,7 @@ IVmbusChannelSendPacketPageBuffer(PDEVICE_OBJECT Device, PAGE_BUFFER PageBuffers[], UINT32 PageCount, - PVOID Buffer, + void * Buffer, UINT32 BufferLen, UINT64 RequestId )
@@ -93,7 +93,7 @@ static intIVmbusChannelSendPacketMultiPageBuffer ( PDEVICE_OBJECT Device, MULTIPAGE_BUFFER *MultiPageBuffer, - PVOID Buffer, + void * Buffer, UINT32 BufferLen, UINT64 RequestId )
@@ -108,7 +108,7 @@ IVmbusChannelSendPacketMultiPageBuffer(static int IVmbusChannelRecvPacket (PDEVICE_OBJECT Device, -PVOID Buffer, +void * Buffer,UINT32 BufferLen,UINT32 * BufferActualLen, UINT64* RequestId
@@ -124,7 +124,7 @@ IVmbusChannelRecvPacket (static int IVmbusChannelRecvPacketRaw (PDEVICE_OBJECT Device, -PVOID Buffer, +void * Buffer,UINT32 BufferLen,UINT32 * BufferActualLen, UINT64* RequestId
@@ -140,7 +140,7 @@ IVmbusChannelRecvPacketRaw(static int IVmbusChannelEstablishGpadl (PDEVICE_OBJECT Device, -PVOID Buffer, +void * Buffer,UINT32 BufferLen,UINT32 * GpadlHandle )
drivers/staging/hv/ChannelMgmt.c +4 -4
@@ -82,12 +82,12 @@ VmbusChannelOnVersionResponse(static void VmbusChannelProcessOffer ( -PVOID context +void * context );static void VmbusChannelProcessRescindOffer ( -PVOID context +void * context );
@@ -233,7 +233,7 @@ Description:--*/ static void VmbusChannelProcessOffer ( -PVOID context +void * context ) {int ret=0 ;
@@ -317,7 +317,7 @@ Description:--*/ static void VmbusChannelProcessRescindOffer ( -PVOID context +void * context ) {VMBUS_CHANNEL * channel=(VMBUS_CHANNEL *)context;
drivers/staging/hv/ChannelMgmt.h +2 -2
@@ -34,7 +34,7 @@ -typedef void (*PFN_CHANNEL_CALLBACK )(PVOID context); +typedef void (*PFN_CHANNEL_CALLBACK )(void * context); typedef enum { CHANNEL_OFFER_STATE,
@@ -70,7 +70,7 @@ typedef struct _VMBUS_CHANNEL {//HANDLE dataWorkQueue; PFN_CHANNEL_CALLBACK OnChannelCallback; -PVOID ChannelCallbackContext; +void * ChannelCallbackContext; }VMBUS_CHANNEL ;
drivers/staging/hv/Connection.c +3 -3
@@ -103,7 +103,7 @@ VmbusConnect( msg->VMBusVersionRequested =VMBUS_REVISION_NUMBER ; msg->InterruptPage =GetPhysicalAddress (gVmbusConnection.InterruptPage); msg->MonitorPage1 =GetPhysicalAddress (gVmbusConnection.MonitorPages); - msg->MonitorPage2 =GetPhysicalAddress ((PVOID )((ULONG_PTR )gVmbusConnection.MonitorPages +PAGE_SIZE )); + msg->MonitorPage2 =GetPhysicalAddress ((void *)((ULONG_PTR )gVmbusConnection.MonitorPages +PAGE_SIZE ));// Add to list before we send the request since we may receive the response // before returning from this routine
@@ -290,7 +290,7 @@ Description:--*/ static void VmbusProcessChannelEvent ( -PVOID context +void * context ) {VMBUS_CHANNEL * channel;
@@ -385,7 +385,7 @@ Description:--*/ int VmbusPostMessage ( -PVOID buffer, +void * buffer,SIZE_T bufferLen ) {
drivers/staging/hv/Hv.c +1 -1
@@ -396,7 +396,7 @@ HV_STATUSHvPostMessage ( HV_CONNECTION_ID connectionId, HV_MESSAGE_TYPE messageType, - PVOID payload, + void * payload, SIZE_T payloadSize ) {
drivers/staging/hv/Hv.h +1 -1
@@ -162,7 +162,7 @@ static HV_STATUSHvPostMessage ( HV_CONNECTION_ID connectionId, HV_MESSAGE_TYPE messageType, - PVOID payload, + void * payload, SIZE_T payloadSize );
drivers/staging/hv/include/NetVscApi.h +4 -4
@@ -49,7 +49,7 @@ typedef int (*PFN_ON_CLOSE)(DEVICE_OBJECtypedef void (*PFN_QUERY_LINKSTATUS )(DEVICE_OBJECT *Device);typedef int (*PFN_ON_SEND )(DEVICE_OBJECT *dev,PNETVSC_PACKET packet); -typedef void (*PFN_ON_SENDRECVCOMPLETION )(PVOID Context); +typedef void (*PFN_ON_SENDRECVCOMPLETION )(void * Context);typedef int (*PFN_ON_RECVCALLBACK )(DEVICE_OBJECT *dev,PNETVSC_PACKET packet);typedef void (*PFN_ON_LINKSTATUS_CHANGED )(DEVICE_OBJECT *dev,UINT32 Status);
@@ -80,18 +80,18 @@ typedef struct _NETVSC_PACKET {union {struct {UINT64 ReceiveCompletionTid; -PVOID ReceiveCompletionContext; +void * ReceiveCompletionContext;PFN_ON_SENDRECVCOMPLETION OnReceiveCompletion; } Recv;struct {UINT64 SendCompletionTid; -PVOID SendCompletionContext; +void * SendCompletionContext;PFN_ON_SENDRECVCOMPLETION OnSendCompletion; } Send; } Completion;// This points to the memory after PageBuffers -PVOID Extension; +void * Extension;UINT32 TotalDataBufferLength;// Points to the send/receive buffer where the ethernet frame is
drivers/staging/hv/include/osd.h +2 -3
@@ -133,7 +133,6 @@ typedef long long LONGLONG;typedef unsigned long SIZE_T ;typedef void VOID ;//typedef unsigned char GUID[16]; -typedef void *PVOID ;typedef unsigned char BOOL ;typedef unsigned char BOOLEAN ;typedef void *HANDLE ;
@@ -246,9 +245,9 @@ extern void SpinlockRelease(HANDLE hSpinvoid *Physical2LogicalAddr (ULONG_PTR PhysAddr);#define GetPhysicalAddress Logical2PhysicalAddr -ULONG_PTR Logical2PhysicalAddr (PVOID LogicalAddr); +ULONG_PTR Logical2PhysicalAddr (void * LogicalAddr); -ULONG_PTR Virtual2Physical (PVOID VirtAddr); +ULONG_PTR Virtual2Physical (void * VirtAddr);void *PageMapVirtualAddress (unsigned long Pfn);void PageUnmapVirtualAddress (void * VirtAddr);
drivers/staging/hv/include/rndis.h +2 -2
@@ -827,10 +827,10 @@ typedef __struct_bcount(MessageLength) s// get pointer to contained message from NDIS_MESSAGE pointer #define RNDIS_MESSAGE_PTR_TO_MESSAGE_PTR (RndisMessage) \ - ((PVOID) &RndisMessage->Message) + ((void *) &RndisMessage->Message)// get pointer to contained message from NDIS_MESSAGE pointer #define RNDIS_MESSAGE_RAW_PTR_TO_MESSAGE_PTR (RndisMessage) \ - ((PVOID) RndisMessage) + ((void *) RndisMessage)#endif // _RNDIS_H_
drivers/staging/hv/include/StorVscApi.h +2 -2
@@ -83,12 +83,12 @@ typedef struct _STORVSC_REQUEST {UCHAR * SenseBuffer;UINT32 SenseBufferSize; -PVOID Context; +void * Context;PFN_ON_IO_REQUEST_COMPLTN OnIOCompletion;// This points to the memory after DataBuffer -PVOID Extension; +void * Extension;MULTIPAGE_BUFFER DataBuffer; }STORVSC_REQUEST ;
drivers/staging/hv/include/VmbusApi.h +9 -9
@@ -88,16 +88,16 @@ typedef int (*PFN_ON_CHILDDEVICE_ADD)(PDtypedef void (*PFN_ON_CHILDDEVICE_REMOVE )(PDEVICE_OBJECT Device);// Vmbus channel interface -typedef void (*VMBUS_CHANNEL_CALLBACK )(PVOID context); +typedef void (*VMBUS_CHANNEL_CALLBACK )(void * context);typedef int (*VMBUS_CHANNEL_OPEN )(PDEVICE_OBJECT Device,UINT32 SendBufferSize,UINT32 RecvRingBufferSize, -PVOID UserData, +void * UserData,UINT32 UserDataLen,VMBUS_CHANNEL_CALLBACK ChannelCallback, -PVOID Context +void * Context ); typedef void (*VMBUS_CHANNEL_CLOSE)(
@@ -106,7 +106,7 @@ typedef void (*VMBUS_CHANNEL_CLOSE)( typedef int (*VMBUS_CHANNEL_SEND_PACKET)( PDEVICE_OBJECT Device, - const PVOID Buffer, + const void * Buffer, UINT32 BufferLen, UINT64 RequestId, UINT32 Type,
@@ -117,7 +117,7 @@ typedef int (*VMBUS_CHANNEL_SEND_PACKET_PDEVICE_OBJECT Device, PAGE_BUFFER PageBuffers[], UINT32 PageCount, - PVOID Buffer, + void * Buffer, UINT32 BufferLen, UINT64 RequestId );
@@ -125,14 +125,14 @@ typedef int (*VMBUS_CHANNEL_SEND_PACKET_typedef int (*VMBUS_CHANNEL_SEND_PACKET_MULTIPAGEBUFFER )(PDEVICE_OBJECT Device,MULTIPAGE_BUFFER *MultiPageBuffer, -PVOID Buffer, +void * Buffer,UINT32 BufferLen,UINT64 RequestId );typedef int (*VMBUS_CHANNEL_RECV_PACKET )(PDEVICE_OBJECT Device, -PVOID Buffer, +void * Buffer,UINT32 BufferLen,UINT32 * BufferActualLen, UINT64* RequestId
@@ -140,7 +140,7 @@ typedef int (*VMBUS_CHANNEL_RECV_PACKET)typedef int (*VMBUS_CHANNEL_RECV_PACKET_PAW )(PDEVICE_OBJECT Device, -PVOID Buffer, +void * Buffer,UINT32 BufferLen,UINT32 * BufferActualLen, UINT64* RequestId
@@ -148,7 +148,7 @@ typedef int (*VMBUS_CHANNEL_RECV_PACKET_typedef int (*VMBUS_CHANNEL_ESTABLISH_GPADL )(PDEVICE_OBJECT Device, -PVOID Buffer,// from kmalloc() +void * Buffer,// from kmalloc() UINT32 BufferLen,// page-size multiple UINT32 * GpadlHandle );
drivers/staging/hv/include/VmbusPacketFormat.h +1 -1
@@ -287,7 +287,7 @@ typedef union { }VMPACKET_LARGEST_POSSIBLE_HEADER , *PVMPACKET_LARGEST_POSSIBLE_HEADER ;#define VMPACKET_DATA_START_ADDRESS (__packet) \ - (PVOID)(((PUCHAR)__packet) + ((PVMPACKET_DESCRIPTOR)__packet)->DataOffset8 * 8) + (void *)(((PUCHAR)__packet) + ((PVMPACKET_DESCRIPTOR)__packet)->DataOffset8 * 8)#define VMPACKET_DATA_LENGTH (__packet) \ ((((PVMPACKET_DESCRIPTOR)__packet)->Length8 - ((PVMPACKET_DESCRIPTOR)__packet)->DataOffset8) * 8)
drivers/staging/hv/NetVsc.c +4 -4
@@ -59,7 +59,7 @@ NetVscOnCleanup(static void NetVscOnChannelCallback ( -PVOID context +void * context ); static int
@@ -107,7 +107,7 @@ NetVscOnReceive(static void NetVscOnReceiveCompletion ( -PVOID Context +void * Context ); static void
@@ -1337,7 +1337,7 @@ retry_send_cmplt:// static void NetVscOnReceiveCompletion ( -PVOID Context) +void * Context) {NETVSC_PACKET *packet = (NETVSC_PACKET *)Context;DEVICE_OBJECT *device = (DEVICE_OBJECT *)packet->Device;
@@ -1393,7 +1393,7 @@ NetVscOnReceiveCompletion(void NetVscOnChannelCallback ( -PVOID Context +void * Context ) {const int netPacketSize=2048 ;
drivers/staging/hv/NetVsc.h +2 -2
@@ -65,13 +65,13 @@ typedef struct _NETVSC_DEVICE {HANDLE ReceivePacketListLock;// Send buffer allocated by us but manages by NetVSP -PVOID SendBuffer; +void * SendBuffer;UINT32 SendBufferSize;UINT32 SendBufferGpadlHandle;UINT32 SendSectionSize;// Receive buffer allocated by us but manages by NetVSP -PVOID ReceiveBuffer; +void * ReceiveBuffer;UINT32 ReceiveBufferSize;UINT32 ReceiveBufferGpadlHandle;UINT32 ReceiveSectionCount;
drivers/staging/hv/osd.c +2 -2
@@ -414,14 +414,14 @@ void* Physical2LogicalAddr(ULONG_PTR Phyreturn logicalAddr; } -ULONG_PTR Logical2PhysicalAddr (PVOID LogicalAddr) +ULONG_PTR Logical2PhysicalAddr (void * LogicalAddr) {BUG_ON (!virt_addr_valid (LogicalAddr));return virt_to_phys (LogicalAddr); } -ULONG_PTR Virtual2Physical (PVOID VirtAddr) +ULONG_PTR Virtual2Physical (void * VirtAddr) {ULONG_PTR pfn =vmalloc_to_pfn (VirtAddr);
drivers/staging/hv/RingBuffer.c +9 -9
@@ -156,10 +156,10 @@ Description:Get the start of the ring buffer --*/ -static inline PVOID +static inline void *GetRingBuffer (RING_BUFFER_INFO * RingInfo) { -return (PVOID )RingInfo->RingBuffer->Buffer; +return (void *)RingInfo->RingBuffer->Buffer; }
@@ -228,13 +228,13 @@ static UINT32CopyToRingBuffer (RING_BUFFER_INFO *RingInfo, UINT32 StartWriteOffset, - PVOID Src, + void * Src, UINT32 SrcLen);static UINT32 CopyFromRingBuffer (RING_BUFFER_INFO *RingInfo, -PVOID Dest, +void * Dest,UINT32 DestLen,UINT32 StartReadOffset);
@@ -486,7 +486,7 @@ Description:int RingBufferRead (RING_BUFFER_INFO * InRingInfo, -PVOID Buffer, +void * Buffer,UINT32 BufferLen,UINT32 Offset )
@@ -557,10 +557,10 @@ UINT32CopyToRingBuffer (RING_BUFFER_INFO *RingInfo, UINT32 StartWriteOffset, - PVOID Src, + void * Src, UINT32 SrcLen) { -PVOID ringBuffer=GetRingBuffer (RingInfo); +void * ringBuffer=GetRingBuffer (RingInfo);UINT32 ringBufferSize=GetRingBufferSize (RingInfo);UINT32 fragLen;
@@ -597,11 +597,11 @@ Description:UINT32 CopyFromRingBuffer (RING_BUFFER_INFO *RingInfo, -PVOID Dest, +void * Dest,UINT32 DestLen,UINT32 StartReadOffset) { -PVOID ringBuffer=GetRingBuffer (RingInfo); +void * ringBuffer=GetRingBuffer (RingInfo);UINT32 ringBufferSize=GetRingBufferSize (RingInfo);UINT32 fragLen;
drivers/staging/hv/RingBuffer.h +4 -4
@@ -28,7 +28,7 @@#include "include/osd.h" typedef struct _SG_BUFFER_LIST { -PVOID Data; +void * Data;UINT32 Length; }SG_BUFFER_LIST ;
@@ -72,7 +72,7 @@ typedef struct _RING_BUFFER_DEBUG_INFO {static int RingBufferInit (RING_BUFFER_INFO *RingInfo, -PVOID Buffer, +void * Buffer,UINT32 BufferLen );
@@ -91,14 +91,14 @@ RingBufferWrite(static int RingBufferPeek (RING_BUFFER_INFO *RingInfo, -PVOID Buffer, +void * Buffer,UINT32 BufferLen );static int RingBufferRead (RING_BUFFER_INFO *RingInfo, -PVOID Buffer, +void * Buffer,UINT32 BufferLen,UINT32 Offset );
drivers/staging/hv/StorVsc.c +3 -3
@@ -118,7 +118,7 @@ StorVscOnCleanup(static void StorVscOnChannelCallback ( -PVOID Context +void * Context ); static void
@@ -530,7 +530,7 @@ StorVscConnectToVsp( ret = Device->Driver->VmbusChannelInterface.Open (Device, storDriver->RingBufferSize, storDriver->RingBufferSize, - (PVOID )&props, + (void *)&props,sizeof (VMSTORAGE_CHANNEL_PROPERTIES ), StorVscOnChannelCallback, Device
@@ -901,7 +901,7 @@ StorVscOnReceive(void StorVscOnChannelCallback ( -PVOID Context +void * Context ) {int ret=0 ;
drivers/staging/hv/VmbusPrivate.h +1 -1
@@ -148,7 +148,7 @@ VmbusDisconnect(static int VmbusPostMessage ( -PVOID buffer, +void * buffer,SIZE_T bufSize );
PATCH 19/54 Staging: hv: remove VOID typedef
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
The VOID typedef is now removed from the Hyper-V driver code.
--- drivers/staging/hv/Channel.c | 2 +- drivers/staging/hv/ChannelMgmt.c | 6 +++--- drivers/staging/hv/ChannelMgmt.h | 2 +- drivers/staging/hv/Connection.c | 6 +++--- drivers/staging/hv/Hv.c | 4 ++-- drivers/staging/hv/Hv.h | 12 ++++++------ drivers/staging/hv/RingBuffer.c | 2 +- drivers/staging/hv/RndisFilter.c | 4 ++-- drivers/staging/hv/VmbusPrivate.h | 16 ++++++++-------- drivers/staging/hv/include/List.h | 14 +++++++------- drivers/staging/hv/include/osd.h | 3 +-- drivers/staging/hv/osd.c | 8 ++++---- 12 files changed, 39 insertions(+), 40 deletions(-)
drivers/staging/hv/Channel.c +1 -1
@@ -677,7 +677,7 @@ Description:Close the specified channel --*/ -VOID +void VmbusChannelClose (VMBUS_CHANNEL *Channel )
drivers/staging/hv/ChannelMgmt.c +3 -3
@@ -672,7 +672,7 @@ Description:This is invoked in the vmbus worker thread context. --*/ -VOID +void VmbusOnChannelMessage (void *Context )
@@ -722,7 +722,7 @@ Description:--*/ int VmbusChannelRequestOffers ( -VOID +void ) {int ret=0 ;
@@ -785,7 +785,7 @@ Description:--*/ void VmbusChannelReleaseUnattachedChannels ( -VOID +void ) {LIST_ENTRY *entry;
drivers/staging/hv/ChannelMgmt.h +1 -1
@@ -59,7 +59,7 @@ typedef struct _VMBUS_CHANNEL {UINT32 RingBufferGpadlHandle;// Allocated memory for ring buffer -VOID * RingBufferPages; +void * RingBufferPages;UINT32 RingBufferPageCount;RING_BUFFER_INFO Outbound;// send to parent RING_BUFFER_INFO Inbound;// receive from parent
drivers/staging/hv/Connection.c +3 -3
@@ -195,7 +195,7 @@ Description:--*/ int VmbusDisconnect ( -VOID +void ) {int ret=0 ;
@@ -323,9 +323,9 @@ Description:Handler for events --*/ -VOID +void VmbusOnEvents ( -VOID +void ) {int dword;
drivers/staging/hv/Hv.c +2 -2
@@ -621,9 +621,9 @@ Description:Cleanup routine for HvSynicInit(). --*/ -VOID +void HvSynicCleanup ( -VOID +void ) {HV_SYNIC_SINT sharedSint;
drivers/staging/hv/Hv.h +6 -6
@@ -150,12 +150,12 @@ static inline void WriteMsr(int msr, UIN// static int HvInit ( -VOID +void ); -static VOID +static void HvCleanup ( -VOID +void ); static HV_STATUS
@@ -168,7 +168,7 @@ HvPostMessage(static HV_STATUS HvSignalEvent ( -VOID +void ); static int
@@ -176,9 +176,9 @@ HvSynicInit(UINT32 irqVector ); -static VOID +static void HvSynicCleanup ( -VOID +void );#endif // __HV_H__
drivers/staging/hv/include/List.h +7 -7
@@ -44,7 +44,7 @@ typedef DLIST_ENTRY *PLIST_ENTRY;/* -* VOID +* void * InitializeListHead( * PLIST_ENTRY ListHead * );
@@ -132,7 +132,7 @@ typedef DLIST_ENTRY *PLIST_ENTRY;/* -* VOID +* void * RemoveEntryList( * PLIST_ENTRY Entry * );
@@ -148,7 +148,7 @@ typedef DLIST_ENTRY *PLIST_ENTRY;/* -* VOID +* void * AttachList( * PLIST_ENTRY ListHead, * PLIST_ENTRY ListEntry
@@ -168,7 +168,7 @@ typedef DLIST_ENTRY *PLIST_ENTRY;/* -* VOID +* void * InsertTailList( * PLIST_ENTRY ListHead, * PLIST_ENTRY Entry
@@ -188,7 +188,7 @@ typedef DLIST_ENTRY *PLIST_ENTRY;/* -* VOID +* void * InsertHeadList( * PLIST_ENTRY ListHead, * PLIST_ENTRY Entry
@@ -207,7 +207,7 @@ typedef DLIST_ENTRY *PLIST_ENTRY;/* -* VOID +* void * IterateListEntries( * PLIST_ENTRY anchor, * PLIST_ENTRY index,
@@ -245,7 +245,7 @@ typedef DLIST_ENTRY *PLIST_ENTRY;/* -* VOID +* void * PushEntryList( * PSINGLE_LIST_ENTRY ListHead, * PSINGLE_LIST_ENTRY Entry
drivers/staging/hv/include/osd.h +1 -2
@@ -131,7 +131,6 @@ typedef long long LONGLONG;// Other types // typedef unsigned long SIZE_T ; -typedef void VOID ;//typedef unsigned char GUID[16]; typedef unsigned char BOOL ;typedef unsigned char BOOLEAN ;
@@ -219,7 +218,7 @@ extern void* MemAlloc(unsigned int size)extern void *MemAllocZeroed (unsigned int size);extern void *MemAllocAtomic (unsigned int size);extern void MemFree (void * buf); -extern void MemoryFence (VOID ); +extern void MemoryFence (void );extern HANDLE TimerCreate (PFN_TIMER_CALLBACK pfnTimerCB,void * context);extern void TimerClose (HANDLE hTimer);
drivers/staging/hv/osd.c +4 -4
@@ -375,7 +375,7 @@ int WaitEventWaitEx(HANDLE hWait, UINT32return ret; } -HANDLE SpinlockCreate (VOID ) +HANDLE SpinlockCreate (void ) {SPINLOCK * spin =kmalloc (sizeof (SPINLOCK ),GFP_KERNEL );if (!spin)
@@ -387,21 +387,21 @@ HANDLE SpinlockCreate(VOID)return spin; } -VOID SpinlockAcquire (HANDLE hSpin) +void SpinlockAcquire (HANDLE hSpin) {SPINLOCK * spin = (SPINLOCK * )hSpin;spin_lock_irqsave (&spin->lock, spin->flags); } -VOID SpinlockRelease (HANDLE hSpin) +void SpinlockRelease (HANDLE hSpin) {SPINLOCK * spin = (SPINLOCK * )hSpin;spin_unlock_irqrestore (&spin->lock, spin->flags); } -VOID SpinlockClose (HANDLE hSpin) +void SpinlockClose (HANDLE hSpin) {SPINLOCK * spin = (SPINLOCK * )hSpin;kfree (spin);
drivers/staging/hv/RingBuffer.c +1 -1
@@ -301,7 +301,7 @@ Description:int RingBufferInit (RING_BUFFER_INFO *RingInfo, -VOID *Buffer, +void *Buffer,UINT32 BufferLen ) {
drivers/staging/hv/RndisFilter.c +2 -2
@@ -120,7 +120,7 @@ static intRndisFilterQueryDevice (RNDIS_DEVICE *Device, UINT32 Oid, -VOID *Result, + void *Result,UINT32 *ResultSize );
@@ -585,7 +585,7 @@ static intRndisFilterQueryDevice (RNDIS_DEVICE *Device, UINT32 Oid, -VOID *Result, + void *Result,UINT32 *ResultSize ) {
drivers/staging/hv/VmbusPrivate.h +8 -8
@@ -73,12 +73,12 @@ typedef struct _VMBUS_CONNECTION {// calls Hv to generate a port event. The other end // receives the port event and parse the recvInterruptPage // to see which bit is set -VOID * InterruptPage; -VOID * SendInterruptPage; -VOID * RecvInterruptPage; +void * InterruptPage; +void * SendInterruptPage; +void * RecvInterruptPage;// 2 pages - 1st page for parent->child notification and 2nd is child->parent notification -VOID * MonitorPages; +void * MonitorPages;LIST_ENTRY ChannelMsgList;HANDLE ChannelMsgLock;
@@ -138,12 +138,12 @@ GetChannelFromRelId(// static int VmbusConnect ( -VOID +void );static int VmbusDisconnect ( -VOID +void ); static int
@@ -157,9 +157,9 @@ VmbusSetEvent(UINT32 childRelId ); -static VOID +static void VmbusOnEvents ( -VOID +void );
PATCH 20/54 Staging: hv: remove UINT8 and INT8 typedefs
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
The UINT8 and INT8 typedefs are now removed from the Hyper-V driver code.
Had to include <linux/kernel.h> in a few places to get the build to work properly as well.
--- drivers/staging/hv/BlkVsc.c | 2 +- drivers/staging/hv/Channel.c | 6 +++--- drivers/staging/hv/ChannelMgmt.c | 4 ++-- drivers/staging/hv/ChannelMgmt.h | 4 ++-- drivers/staging/hv/NetVsc.c | 1 + drivers/staging/hv/RingBuffer.h | 4 ++-- drivers/staging/hv/RndisFilter.c | 1 + drivers/staging/hv/StorVsc.c | 1 + drivers/staging/hv/Vmbus.c | 2 +- drivers/staging/hv/include/ChannelMessages.h | 2 +- drivers/staging/hv/include/HvSynicApi.h | 14 +++++++------- drivers/staging/hv/include/StorVscApi.h | 2 +- drivers/staging/hv/include/VmbusPacketFormat.h | 6 +++--- drivers/staging/hv/include/osd.h | 2 -- 14 files changed, 26 insertions(+), 25 deletions(-)
drivers/staging/hv/BlkVsc.c +1 -1
@@ -20,7 +20,7 @@* */ - +#include <linux/kernel.h> #include "StorVsc.c" static const char * gBlkDriverName="blkvsc" ;
drivers/staging/hv/Channel.c +3 -3
@@ -21,7 +21,7 @@* */ - +#include <linux/kernel.h> #include "include/osd.h" #include "include/logging.h"
@@ -162,8 +162,8 @@ VmbusChannelGetDebugInfo( ) {HV_MONITOR_PAGE *monitorPage; -UINT8 monitorGroup = (UINT8 )Channel->OfferMsg.MonitorId /32 ; -UINT8 monitorOffset = (UINT8 )Channel->OfferMsg.MonitorId %32 ; +u8 monitorGroup = (u8 )Channel->OfferMsg.MonitorId /32 ; +u8 monitorOffset = (u8 )Channel->OfferMsg.MonitorId %32 ;//UINT32 monitorBit = 1 << monitorOffset; DebugInfo->RelId = Channel->OfferMsg.ChildRelId;
drivers/staging/hv/ChannelMgmt.c +2 -2
@@ -396,8 +396,8 @@ VmbusChannelOnOffer(DPRINT_DBG (VMBUS ,"channel object allocated - %p" , newChannel);memcpy (&newChannel->OfferMsg, offer,sizeof (VMBUS_CHANNEL_OFFER_CHANNEL )); - newChannel->MonitorGroup = (UINT8 )offer->MonitorId /32 ; - newChannel->MonitorBit = (UINT8 )offer->MonitorId %32 ; + newChannel->MonitorGroup = (u8 )offer->MonitorId /32 ; + newChannel->MonitorBit = (u8 )offer->MonitorId %32 ;// TODO: Make sure the offer comes from our parent partition WorkQueueQueueWorkItem (newChannel->ControlWQ, VmbusChannelProcessOffer, newChannel);
drivers/staging/hv/ChannelMgmt.h +2 -2
@@ -53,8 +53,8 @@ typedef struct _VMBUS_CHANNEL {VMBUS_CHANNEL_OFFER_CHANNEL OfferMsg;// These are based on the OfferMsg.MonitorId. Save it here for easy access. -UINT8 MonitorGroup; -UINT8 MonitorBit; +u8 MonitorGroup; +u8 MonitorBit;UINT32 RingBufferGpadlHandle;
drivers/staging/hv/include/ChannelMessages.h +1 -1
@@ -91,7 +91,7 @@ typedef struct _VMBUS_CHANNEL_OFFER_CHANVMBUS_CHANNEL_MESSAGE_HEADER Header;VMBUS_CHANNEL_OFFER Offer;UINT32 ChildRelId; -UINT8 MonitorId; +u8 MonitorId;BOOLEAN MonitorAllocated; }VMBUS_CHANNEL_OFFER_CHANNEL , *PVMBUS_CHANNEL_OFFER_CHANNEL ;
drivers/staging/hv/include/HvSynicApi.h +7 -7
@@ -264,11 +264,11 @@ typedef const HV_CONNECTION_INFO *PCHV_Ctypedef union _HV_MESSAGE_FLAGS { -UINT8 AsUINT8; +u8 Asu8;struct { -UINT8 MessagePending:1 ; -UINT8 Reserved:7 ; +u8 MessagePending:1 ; +u8 Reserved:7 ; }; }HV_MESSAGE_FLAGS , *PHV_MESSAGE_FLAGS ;
@@ -280,9 +280,9 @@ typedef union _HV_MESSAGE_FLAGS typedef struct _HV_MESSAGE_HEADER { HV_MESSAGE_TYPE MessageType; - UINT8 PayloadSize; + u8 PayloadSize; HV_MESSAGE_FLAGS MessageFlags; - UINT8 Reserved[2]; + u8 Reserved[2]; union { HV_PARTITION_ID Sender;
@@ -337,7 +337,7 @@ typedef struct _HV_MESSAGE_PAGEtypedef union _HV_SYNIC_EVENT_FLAGS { -UINT8 Flags8[HV_EVENT_FLAGS_BYTE_COUNT ]; +u8 Flags8[HV_EVENT_FLAGS_BYTE_COUNT ];UINT32 Flags32[HV_EVENT_FLAGS_DWORD_COUNT ]; }HV_SYNIC_EVENT_FLAGS , *PHV_SYNIC_EVENT_FLAGS ;
@@ -483,7 +483,7 @@ typedef struct _HV_MONITOR_PAGEHV_MONITOR_PARAMETER Parameter[4 ][32 ]; -UINT8 RsvdZ4[1984 ]; +u8 RsvdZ4[1984 ]; }HV_MONITOR_PAGE , *PHV_MONITOR_PAGE ;
drivers/staging/hv/include/osd.h +0 -2
@@ -97,7 +97,6 @@ typedef struct _DLIST_ENTRY {// // unsigned types // -typedef unsigned char UINT8 ;typedef unsigned short UINT16 ;typedef unsigned int UINT32 ;#ifdef __x86_64__
@@ -114,7 +113,6 @@ typedef unsigned char UCHAR;// // signed types // -typedef char INT8 ;typedef short INT16 ;typedef int INT32 ;#ifdef __x86_64__
drivers/staging/hv/include/StorVscApi.h +1 -1
@@ -75,7 +75,7 @@ typedef struct _STORVSC_REQUEST {UINT32 Bus;UINT32 TargetId;UINT32 LunId; -UINT8 * Cdb; +u8 * Cdb;UINT32 CdbLen;UINT32 Status;UINT32 BytesXfer;
drivers/staging/hv/include/VmbusPacketFormat.h +3 -3
@@ -65,14 +65,14 @@ typedef structVMRCB Control; }; -UINT8 Reserved[PAGE_SIZE ]; +u8 Reserved[PAGE_SIZE ]; };// // Beginning of the ring data. Note: It must be guaranteed that // this data does not share a page with the control structure. // -UINT8 Data[1 ]; +u8 Data[1 ]; }VMRING , *PVMRING ;#pragma pack(push, 1)
@@ -114,7 +114,7 @@ typedef struct VMTRANSFER_PAGE_PACKET_HEUINT16 TransferPageSetId;BOOLEAN SenderOwnsSet; -UINT8 Reserved; +u8 Reserved;UINT32 RangeCount;VMTRANSFER_PAGE_RANGE Ranges[1 ];
drivers/staging/hv/NetVsc.c +1 -0
@@ -22,6 +22,7 @@#define KERNEL_2_6_27 +#include <linux/kernel.h> #include "include/logging.h" #include "NetVsc.h" #include "RndisFilter.h"
drivers/staging/hv/RingBuffer.h +2 -2
@@ -37,12 +37,12 @@ typedef struct _RING_BUFFER {volatile UINT32 ReadIndex;// Offset in bytes from the start of ring data below volatile UINT32 InterruptMask; -UINT8 Reserved[4084 ];// Pad it to PAGE_SIZE so that data starts on page boundary +u8 Reserved[4084 ];// Pad it to PAGE_SIZE so that data starts on page boundary // NOTE: The InterruptMask field is used only for channels but since our vmbus connection // also uses this data structure and its data starts here, we commented out this field. // volatile UINT32 InterruptMask; // Ring data starts here + RingDataStartOffset !!! DO NOT place any fields below this !!! -UINT8 Buffer[0 ]; +u8 Buffer[0 ]; }STRUCT_PACKED RING_BUFFER ; typedef struct _RING_BUFFER_INFO {
drivers/staging/hv/RndisFilter.c +1 -0
@@ -23,6 +23,7 @@#define KERNEL_2_6_27 +#include <linux/kernel.h> #include "include/logging.h" #include "include/NetVscApi.h"
drivers/staging/hv/StorVsc.c +1 -0
@@ -23,6 +23,7 @@#define KERNEL_2_6_27 +#include <linux/kernel.h> #include "include/logging.h" #include "include/StorVscApi.h"
drivers/staging/hv/Vmbus.c +1 -1
@@ -21,7 +21,7 @@* */ - +#include <linux/kernel.h> #include "include/logging.h" #include "VersionInfo.h" #include "VmbusPrivate.h"
PATCH 21/54 Staging: hv: remove UINT16 and INT16 typedefs
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
The UINT16 and INT16 typedefs are now removed from the Hyper-V driver code.
--- drivers/staging/hv/Channel.c | 6 +++--- drivers/staging/hv/Channel.h | 16 ++++++++-------- drivers/staging/hv/include/ChannelMessages.h | 4 ++-- drivers/staging/hv/include/HvHcApi.h | 4 ++-- drivers/staging/hv/include/HvStatus.h | 2 +- drivers/staging/hv/include/HvSynicApi.h | 10 +++++----- drivers/staging/hv/include/VmbusChannelInterface.h | 4 ++-- drivers/staging/hv/include/VmbusPacketFormat.h | 14 +++++++------- drivers/staging/hv/include/nvspprotocol.h | 8 ++++---- drivers/staging/hv/include/osd.h | 2 -- 10 files changed, 34 insertions(+), 36 deletions(-)
drivers/staging/hv/Channel.c +3 -3
@@ -777,7 +777,7 @@ VmbusChannelSendPacket( desc.Type = Type;//VmbusPacketTypeDataInBand; desc.Flags = Flags;//VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED; desc.DataOffset8 =sizeof (VMPACKET_DESCRIPTOR ) >>3 ;// in 8-bytes granularity - desc.Length8 = (UINT16 )(packetLenAligned >>3 ); + desc.Length8 = (u16)(packetLenAligned >>3 ); desc.TransactionId = RequestId; bufferList[0 ].Data = &desc;
@@ -851,7 +851,7 @@ VmbusChannelSendPacketPageBuffer( desc.Type = VmbusPacketTypeDataUsingGpaDirect; desc.Flags =VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED ; desc.DataOffset8 = descSize >>3 ;// in 8-bytes grandularity - desc.Length8 = (UINT16 )(packetLenAligned >>3 ); + desc.Length8 = (u16)(packetLenAligned >>3 ); desc.TransactionId = RequestId; desc.RangeCount = PageCount;
@@ -936,7 +936,7 @@ VmbusChannelSendPacketMultiPageBuffer( desc.Type = VmbusPacketTypeDataUsingGpaDirect; desc.Flags =VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED ; desc.DataOffset8 = descSize >>3 ;// in 8-bytes grandularity - desc.Length8 = (UINT16 )(packetLenAligned >>3 ); + desc.Length8 = (u16)(packetLenAligned >>3 ); desc.TransactionId = RequestId; desc.RangeCount =1 ;
drivers/staging/hv/Channel.h +8 -8
@@ -33,10 +33,10 @@// The format must be the same as VMDATA_GPA_DIRECT typedef struct _VMBUS_CHANNEL_PACKET_PAGE_BUFFER { - UINT16 Type; - UINT16 DataOffset8; - UINT16 Length8; - UINT16 Flags; + u16 Type; + u16 DataOffset8; + u16 Length8; + u16 Flags; UINT64 TransactionId; UINT32 Reserved; UINT32 RangeCount;
@@ -46,10 +46,10 @@ typedef struct _VMBUS_CHANNEL_PACKET_PAG// The format must be the same as VMDATA_GPA_DIRECT typedef struct _VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER { - UINT16 Type; - UINT16 DataOffset8; - UINT16 Length8; - UINT16 Flags; + u16 Type; + u16 DataOffset8; + u16 Length8; + u16 Flags; UINT64 TransactionId; UINT32 Reserved; UINT32 RangeCount; // Always 1 in this case
drivers/staging/hv/include/ChannelMessages.h +2 -2
@@ -188,8 +188,8 @@ typedef struct _VMBUS_CHANNEL_GPADL_HEADVMBUS_CHANNEL_MESSAGE_HEADER Header;UINT32 ChildRelId;UINT32 Gpadl; -UINT16 RangeBufLen; -UINT16 RangeCount; +u16 RangeBufLen; +u16 RangeCount;GPA_RANGE Range[0 ]; }VMBUS_CHANNEL_GPADL_HEADER , *PVMBUS_CHANNEL_GPADL_HEADER ;
drivers/staging/hv/include/HvHcApi.h +2 -2
@@ -55,6 +55,6 @@ typedef struct _HV_INPUT_POST_MESSAGEtypedef struct _HV_INPUT_SIGNAL_EVENT {HV_CONNECTION_ID ConnectionId; -UINT16 FlagNumber; -UINT16 RsvdZ; +u16 FlagNumber; +u16 RsvdZ; }HV_INPUT_SIGNAL_EVENT , *PHV_INPUT_SIGNAL_EVENT ;
drivers/staging/hv/include/HvStatus.h +1 -1
@@ -26,7 +26,7 @@// // Status codes for hypervisor operations. // -typedef UINT16 HV_STATUS , *PHV_STATUS ; +typedef u16 HV_STATUS , *PHV_STATUS ;// // MessageId: HV_STATUS_SUCCESS
drivers/staging/hv/include/HvSynicApi.h +5 -5
@@ -217,8 +217,8 @@ typedef struct _HV_PORT_INFO {HV_SYNIC_SINT_INDEX TargetSint;HV_VP_INDEX TargetVp; -UINT16 BaseFlagNumber; -UINT16 FlagCount; +u16 BaseFlagNumber; +u16 FlagCount;UINT32 RsvdZ; } EventPortInfo;
@@ -431,8 +431,8 @@ typedef union _HV_MONITOR_TRIGGER_GROUPtypedef struct _HV_MONITOR_PARAMETER {HV_CONNECTION_ID ConnectionId; -UINT16 FlagNumber; -UINT16 RsvdZ; +u16 FlagNumber; +u16 RsvdZ; }HV_MONITOR_PARAMETER , *PHV_MONITOR_PARAMETER ; typedef union _HV_MONITOR_TRIGGER_STATE
@@ -478,7 +478,7 @@ typedef struct _HV_MONITOR_PAGEINT32 NextCheckTime[4 ][32 ]; -UINT16 Latency[4 ][32 ]; +u16 Latency[4 ][32 ];UINT64 RsvdZ3[32 ];HV_MONITOR_PARAMETER Parameter[4 ][32 ];
drivers/staging/hv/include/nvspprotocol.h +4 -4
@@ -144,7 +144,7 @@ typedef struct _NVSP_1_MESSAGE_SEND_NDIStypedef struct _NVSP_1_MESSAGE_SEND_RECEIVE_BUFFER {GPADL_HANDLE GpadlHandle; -UINT16 Id; +u16 Id; }NVSP_1_MESSAGE_SEND_RECEIVE_BUFFER , *PNVSP_1_MESSAGE_SEND_RECEIVE_BUFFER ; typedef struct _NVSP_1_RECEIVE_BUFFER_SECTION
@@ -192,7 +192,7 @@ typedef struct _NVSP_1_MESSAGE_SEND_RECE// typedef struct _NVSP_1_MESSAGE_REVOKE_RECEIVE_BUFFER { -UINT16 Id; +u16 Id; }NVSP_1_MESSAGE_REVOKE_RECEIVE_BUFFER , *PNVSP_1_MESSAGE_REVOKE_RECEIVE_BUFFER ;//
@@ -203,7 +203,7 @@ typedef struct _NVSP_1_MESSAGE_REVOKE_REtypedef struct _NVSP_1_MESSAGE_SEND_SEND_BUFFER {GPADL_HANDLE GpadlHandle; -UINT16 Id; +u16 Id; }NVSP_1_MESSAGE_SEND_SEND_BUFFER , *PNVSP_1_MESSAGE_SEND_SEND_BUFFER ;//
@@ -231,7 +231,7 @@ typedef struct _NVSP_1_MESSAGE_SEND_SEND// typedef struct _NVSP_1_MESSAGE_REVOKE_SEND_BUFFER { -UINT16 Id; +u16 Id; }NVSP_1_MESSAGE_REVOKE_SEND_BUFFER , *PNVSP_1_MESSAGE_REVOKE_SEND_BUFFER ;//
drivers/staging/hv/include/osd.h +0 -2
@@ -97,7 +97,6 @@ typedef struct _DLIST_ENTRY {// // unsigned types // -typedef unsigned short UINT16 ;typedef unsigned int UINT32 ;#ifdef __x86_64__typedef unsigned long UINT64 ;
@@ -113,7 +112,6 @@ typedef unsigned char UCHAR;// // signed types // -typedef short INT16 ;typedef int INT32 ;#ifdef __x86_64__typedef long INT64 ;
drivers/staging/hv/include/VmbusChannelInterface.h +2 -2
@@ -69,8 +69,8 @@ typedef structUINT64 InterruptLatencyIn100nsUnits;UINT32 InterfaceRevision;UINT32 ServerContextAreaSize;// in bytes -UINT16 ChannelFlags; -UINT16 MmioMegabytes;// in bytes * 1024 * 1024 +u16 ChannelFlags; +u16 MmioMegabytes;// in bytes * 1024 * 1024 union {
drivers/staging/hv/include/VmbusPacketFormat.h +7 -7
@@ -79,10 +79,10 @@ typedef structtypedef struct { -UINT16 Type; -UINT16 DataOffset8; -UINT16 Length8; -UINT16 Flags; +u16 Type; +u16 DataOffset8; +u16 Length8; +u16 Flags;UINT64 TransactionId; }VMPACKET_DESCRIPTOR , *PVMPACKET_DESCRIPTOR ;
@@ -112,7 +112,7 @@ typedef struct VMTRANSFER_PAGE_PACKET_HE#endif -UINT16 TransferPageSetId; +u16 TransferPageSetId;BOOLEAN SenderOwnsSet;u8 Reserved;UINT32 RangeCount;
@@ -152,8 +152,8 @@ typedef struct _VMADD_REMOVE_TRANSFER_PA#endif UINT32 Gpadl; -UINT16 TransferPageSetId; -UINT16 Reserved; +u16 TransferPageSetId; +u16 Reserved; }VMADD_REMOVE_TRANSFER_PAGE_SET , *PVMADD_REMOVE_TRANSFER_PAGE_SET ;
PATCH 22/54 Staging: hv: remove UINT32 and INT32 typedefs
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
The UINT32 and INT32 typedefs are now removed from the Hyper-V driver code.
--- drivers/staging/hv/Channel.c | 90 +++++------ drivers/staging/hv/Channel.h | 38 ++-- drivers/staging/hv/ChannelInterface.c | 32 +-- drivers/staging/hv/ChannelMgmt.h | 22 +- drivers/staging/hv/Connection.c | 14 - drivers/staging/hv/Hv.c | 20 +- drivers/staging/hv/Hv.h | 2 drivers/staging/hv/NetVsc.c | 2 drivers/staging/hv/NetVsc.h | 12 - drivers/staging/hv/RingBuffer.c | 96 +++++------ drivers/staging/hv/RingBuffer.h | 38 ++-- drivers/staging/hv/RndisFilter.c | 40 ++-- drivers/staging/hv/StorVsc.c | 2 drivers/staging/hv/Vmbus.c | 2 drivers/staging/hv/VmbusPrivate.h | 6 drivers/staging/hv/include/ChannelMessages.h | 52 +++--- drivers/staging/hv/include/HvHcApi.h | 4 drivers/staging/hv/include/HvSynicApi.h | 42 ++--- drivers/staging/hv/include/HvVpApi.h | 2 drivers/staging/hv/include/NetVscApi.h | 14 - drivers/staging/hv/include/StorVscApi.h | 22 +- drivers/staging/hv/include/VmbusApi.h | 68 ++++---- drivers/staging/hv/include/VmbusChannelInterface.h | 10 - drivers/staging/hv/include/VmbusPacketFormat.h | 40 ++-- drivers/staging/hv/include/nvspprotocol.h | 42 ++--- drivers/staging/hv/include/osd.h | 16 - drivers/staging/hv/include/rndis.h | 170 ++++++++++----------- drivers/staging/hv/osd.c | 4 28 files changed, 450 insertions(+), 452 deletions(-)
drivers/staging/hv/Channel.c +45 -45
@@ -33,9 +33,9 @@static int VmbusChannelCreateGpadlHeader (void * Kbuffer,// must be phys and virt contiguous -UINT32 Size,// page-size multiple +u32 Size,// page-size multiple VMBUS_CHANNEL_MSGINFO **msgInfo, -UINT32 *MessageCount +u32 *MessageCount ); static void
@@ -77,7 +77,7 @@ DumpMonitorPage( {for (j=0 ; j<32 ; j++) { -DPRINT_DBG (VMBUS ,"param-conn id (%d)(%d) - %d" , i, j, MonitorPage->Parameter[i][j].ConnectionId.AsUINT32); +DPRINT_DBG (VMBUS ,"param-conn id (%d)(%d) - %d" , i, j, MonitorPage->Parameter[i][j].ConnectionId.Asu32);DPRINT_DBG (VMBUS ,"param-flag (%d)(%d) - %d" , i, j, MonitorPage->Parameter[i][j].FlagNumber); }
@@ -105,13 +105,13 @@ VmbusChannelSetEvent(if (Channel->OfferMsg.MonitorAllocated) { -// Each UINT32 represents 32 channels -BitSet ((UINT32 *)gVmbusConnection.SendInterruptPage + (Channel->OfferMsg.ChildRelId >>5 ), Channel->OfferMsg.ChildRelId &31 ); +// Each u32 represents 32 channels +BitSet ((u32 *)gVmbusConnection.SendInterruptPage + (Channel->OfferMsg.ChildRelId >>5 ), Channel->OfferMsg.ChildRelId &31 ); monitorPage = (HV_MONITOR_PAGE *)gVmbusConnection.MonitorPages; monitorPage++;// Get the child to parent monitor page -BitSet ((UINT32 *) &monitorPage->TriggerGroup[Channel->MonitorGroup].Pending, Channel->MonitorBit); +BitSet ((u32 *) &monitorPage->TriggerGroup[Channel->MonitorGroup].Pending, Channel->MonitorBit); }else {
@@ -133,13 +133,13 @@ VmbusChannelClearEvent(if (Channel->OfferMsg.MonitorAllocated) { -// Each UINT32 represents 32 channels -BitClear ((UINT32 *)gVmbusConnection.SendInterruptPage + (Channel->OfferMsg.ChildRelId >>5 ), Channel->OfferMsg.ChildRelId &31 ); +// Each u32 represents 32 channels +BitClear ((u32 *)gVmbusConnection.SendInterruptPage + (Channel->OfferMsg.ChildRelId >>5 ), Channel->OfferMsg.ChildRelId &31 ); monitorPage = (HV_MONITOR_PAGE *)gVmbusConnection.MonitorPages; monitorPage++;// Get the child to parent monitor page -BitClear ((UINT32 *) &monitorPage->TriggerGroup[Channel->MonitorGroup].Pending, Channel->MonitorBit); +BitClear ((u32 *) &monitorPage->TriggerGroup[Channel->MonitorGroup].Pending, Channel->MonitorBit); }DPRINT_EXIT (VMBUS );
@@ -164,7 +164,7 @@ VmbusChannelGetDebugInfo(HV_MONITOR_PAGE *monitorPage;u8 monitorGroup = (u8 )Channel->OfferMsg.MonitorId /32 ;u8 monitorOffset = (u8 )Channel->OfferMsg.MonitorId %32 ; -//UINT32 monitorBit = 1 << monitorOffset; +//u32 monitorBit = 1 << monitorOffset; DebugInfo->RelId = Channel->OfferMsg.ChildRelId; DebugInfo->State = Channel->State;
@@ -202,10 +202,10 @@ Description:int VmbusChannelOpen (VMBUS_CHANNEL *NewChannel, -UINT32 SendRingBufferSize, -UINT32 RecvRingBufferSize, +u32 SendRingBufferSize, +u32 RecvRingBufferSize,void * UserData, -UINT32 UserDataLen, +u32 UserDataLen,PFN_CHANNEL_CALLBACK pfnOnChannelCallback,void * Context )
@@ -330,7 +330,7 @@ Description:--*/ static void DumpGpadlBody (VMBUS_CHANNEL_GPADL_BODY *Gpadl, -UINT32 Len) +u32 Len) {int i=0 ;int pfnCount=0 ;
@@ -393,9 +393,9 @@ Description:static int VmbusChannelCreateGpadlHeader (void * Kbuffer,// from kmalloc() -UINT32 Size,// page-size multiple +u32 Size,// page-size multiple VMBUS_CHANNEL_MSGINFO **MsgInfo, -UINT32 *MessageCount) +u32 *MessageCount) {int i;int pageCount;
@@ -404,7 +404,7 @@ VmbusChannelCreateGpadlHeader(VMBUS_CHANNEL_GPADL_BODY * gpadlBody;VMBUS_CHANNEL_MSGINFO * msgHeader;VMBUS_CHANNEL_MSGINFO * msgBody; -UINT32 msgSize; +u32 msgSize;int pfnSum, pfnCount, pfnLeft, pfnCurr, pfnSize;
@@ -465,7 +465,7 @@ VmbusChannelCreateGpadlHeader( (*MessageCount)++; gpadlBody = (VMBUS_CHANNEL_GPADL_BODY *)msgBody->Msg; -// FIXME: Gpadl is UINT32 and we are using a pointer which could be 64-bit +// FIXME: Gpadl is u32 and we are using a pointer which could be 64-bit //gpadlBody->Gpadl = kbuffer; for (i=0 ; i<pfnCurr; i++) {
@@ -516,8 +516,8 @@ intVmbusChannelEstablishGpadl (VMBUS_CHANNEL *Channel, void * Kbuffer,// from kmalloc() - UINT32 Size, // page-size multiple -UINT32 *GpadlHandle + u32 Size, // page-size multiple + u32 *GpadlHandle ) {int ret=0 ;
@@ -528,10 +528,10 @@ VmbusChannelEstablishGpadl(VMBUS_CHANNEL_MSGINFO *msgInfo;VMBUS_CHANNEL_MSGINFO *subMsgInfo; -UINT32 msgCount; +u32 msgCount;LIST_ENTRY * anchor;LIST_ENTRY * curr; -UINT32 nextGpadlHandle; +u32 nextGpadlHandle;DPRINT_ENTER (VMBUS );
@@ -619,7 +619,7 @@ Description:int VmbusChannelTeardownGpadl (VMBUS_CHANNEL *Channel, -UINT32 GpadlHandle +u32 GpadlHandle ) {int ret=0 ;
@@ -753,16 +753,16 @@ intVmbusChannelSendPacket (VMBUS_CHANNEL *Channel, const void * Buffer, - UINT32 BufferLen, + u32 BufferLen, UINT64 RequestId, VMBUS_PACKET_TYPE Type, - UINT32 Flags + u32 Flags ) {int ret=0 ;VMPACKET_DESCRIPTOR desc; -UINT32 packetLen =sizeof (VMPACKET_DESCRIPTOR ) + BufferLen; -UINT32 packetLenAligned =ALIGN_UP (packetLen,sizeof (UINT64 )); +u32 packetLen =sizeof (VMPACKET_DESCRIPTOR ) + BufferLen; +u32 packetLenAligned =ALIGN_UP (packetLen,sizeof (UINT64 ));SG_BUFFER_LIST bufferList[3 ];UINT64 alignedData=0 ;
@@ -819,18 +819,18 @@ intVmbusChannelSendPacketPageBuffer (VMBUS_CHANNEL *Channel, PAGE_BUFFER PageBuffers[], - UINT32 PageCount, + u32 PageCount, void * Buffer, - UINT32 BufferLen, + u32 BufferLen, UINT64 RequestId ) {int ret=0 ;int i=0 ;VMBUS_CHANNEL_PACKET_PAGE_BUFFER desc; -UINT32 descSize; -UINT32 packetLen; -UINT32 packetLenAligned; +u32 descSize; +u32 packetLen; +u32 packetLenAligned;SG_BUFFER_LIST bufferList[3 ];UINT64 alignedData=0 ;
@@ -903,18 +903,18 @@ VmbusChannelSendPacketMultiPageBuffer( VMBUS_CHANNEL *Channel, MULTIPAGE_BUFFER *MultiPageBuffer, void * Buffer, - UINT32 BufferLen, + u32 BufferLen, UINT64 RequestId ) {int ret=0 ;VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER desc; -UINT32 descSize; -UINT32 packetLen; -UINT32 packetLenAligned; +u32 descSize; +u32 packetLen; +u32 packetLenAligned;SG_BUFFER_LIST bufferList[3 ];UINT64 alignedData=0 ; -UINT32 PfnCount =NUM_PAGES_SPANNED (MultiPageBuffer->Offset, MultiPageBuffer->Length); +u32 PfnCount =NUM_PAGES_SPANNED (MultiPageBuffer->Offset, MultiPageBuffer->Length);DPRINT_ENTER (VMBUS );
@@ -985,14 +985,14 @@ intVmbusChannelRecvPacket (VMBUS_CHANNEL *Channel, void * Buffer, - UINT32 BufferLen, -UINT32 * BufferActualLen, + u32 BufferLen, + u32* BufferActualLen,UINT64 * RequestId ) {VMPACKET_DESCRIPTOR desc; -UINT32 packetLen; -UINT32 userLen; +u32 packetLen; +u32 userLen;int ret;DPRINT_ENTER (VMBUS );
@@ -1062,14 +1062,14 @@ intVmbusChannelRecvPacketRaw (VMBUS_CHANNEL *Channel, void * Buffer, - UINT32 BufferLen, -UINT32 * BufferActualLen, + u32 BufferLen, + u32* BufferActualLen,UINT64 * RequestId ) {VMPACKET_DESCRIPTOR desc; -UINT32 packetLen; -UINT32 userLen; +u32 packetLen; +u32 userLen;int ret;DPRINT_ENTER (VMBUS );
drivers/staging/hv/Channel.h +19 -19
@@ -38,8 +38,8 @@ typedef struct _VMBUS_CHANNEL_PACKET_PAGu16 Length8;u16 Flags;UINT64 TransactionId; -UINT32 Reserved; -UINT32 RangeCount; +u32 Reserved; +u32 RangeCount;PAGE_BUFFER Range[MAX_PAGE_BUFFER_COUNT ]; }VMBUS_CHANNEL_PACKET_PAGE_BUFFER ;
@@ -51,8 +51,8 @@ typedef struct _VMBUS_CHANNEL_PACKET_MULu16 Length8;u16 Flags;UINT64 TransactionId; -UINT32 Reserved; -UINT32 RangeCount;// Always 1 in this case +u32 Reserved; +u32 RangeCount;// Always 1 in this case MULTIPAGE_BUFFER Range; }VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER ;
@@ -65,10 +65,10 @@ typedef struct _VMBUS_CHANNEL_PACKET_MULstatic int VmbusChannelOpen (VMBUS_CHANNEL *Channel, -UINT32 SendRingBufferSize, -UINT32 RecvRingBufferSize, +u32 SendRingBufferSize, +u32 RecvRingBufferSize,void * UserData, -UINT32 UserDataLen, +u32 UserDataLen,PFN_CHANNEL_CALLBACK pfnOnChannelCallback,void * Context );
@@ -82,19 +82,19 @@ static intVmbusChannelSendPacket (VMBUS_CHANNEL *Channel, const void * Buffer, - UINT32 BufferLen, + u32 BufferLen, UINT64 RequestId, VMBUS_PACKET_TYPE Type, - UINT32 Flags + u32 Flags );static int VmbusChannelSendPacketPageBuffer (VMBUS_CHANNEL *Channel,PAGE_BUFFER PageBuffers[], -UINT32 PageCount, +u32 PageCount,void * Buffer, -UINT32 BufferLen, +u32 BufferLen,UINT64 RequestId );
@@ -103,7 +103,7 @@ VmbusChannelSendPacketMultiPageBuffer(VMBUS_CHANNEL *Channel,MULTIPAGE_BUFFER *MultiPageBuffer, void * Buffer, - UINT32 BufferLen, + u32 BufferLen, UINT64 RequestId );
@@ -111,22 +111,22 @@ static intVmbusChannelEstablishGpadl (VMBUS_CHANNEL *Channel, void * Kbuffer,// from kmalloc() - UINT32 Size, // page-size multiple -UINT32 *GpadlHandle + u32 Size, // page-size multiple + u32 *GpadlHandle );static int VmbusChannelTeardownGpadl (VMBUS_CHANNEL *Channel, -UINT32 GpadlHandle +u32 GpadlHandle );static int VmbusChannelRecvPacket (VMBUS_CHANNEL *Channel,void * Buffer, -UINT32 BufferLen, -UINT32 * BufferActualLen, +u32 BufferLen, +u32 * BufferActualLen,UINT64 * RequestId );
@@ -134,8 +134,8 @@ static intVmbusChannelRecvPacketRaw (VMBUS_CHANNEL *Channel, void * Buffer, - UINT32 BufferLen, -UINT32 * BufferActualLen, + u32 BufferLen, + u32* BufferActualLen,UINT64 * RequestId );
drivers/staging/hv/ChannelInterface.c +16 -16
@@ -26,10 +26,10 @@static int IVmbusChannelOpen (PDEVICE_OBJECT Device, -UINT32 SendBufferSize, -UINT32 RecvRingBufferSize, +u32 SendBufferSize, +u32 RecvRingBufferSize,void * UserData, -UINT32 UserDataLen, +u32 UserDataLen,VMBUS_CHANNEL_CALLBACK ChannelCallback,void * Context )
@@ -57,10 +57,10 @@ static int IVmbusChannelSendPacket( PDEVICE_OBJECT Device, const void * Buffer, - UINT32 BufferLen, + u32 BufferLen, UINT64 RequestId, - UINT32 Type, - UINT32 Flags + u32 Type, + u32 Flags ) { return VmbusChannelSendPacket((VMBUS_CHANNEL*)Device->context,
@@ -75,9 +75,9 @@ static intIVmbusChannelSendPacketPageBuffer ( PDEVICE_OBJECT Device, PAGE_BUFFER PageBuffers[], - UINT32 PageCount, + u32 PageCount, void * Buffer, - UINT32 BufferLen, + u32 BufferLen, UINT64 RequestId ) {
@@ -94,7 +94,7 @@ IVmbusChannelSendPacketMultiPageBuffer(PDEVICE_OBJECT Device, MULTIPAGE_BUFFER *MultiPageBuffer, void * Buffer, - UINT32 BufferLen, + u32 BufferLen, UINT64 RequestId ) {
@@ -109,8 +109,8 @@ static intIVmbusChannelRecvPacket ( PDEVICE_OBJECT Device, void * Buffer, - UINT32 BufferLen, - UINT32* BufferActualLen, + u32 BufferLen, + u32* BufferActualLen, UINT64* RequestId ) {
@@ -125,8 +125,8 @@ static intIVmbusChannelRecvPacketRaw ( PDEVICE_OBJECT Device, void * Buffer, - UINT32 BufferLen, - UINT32* BufferActualLen, + u32 BufferLen, + u32* BufferActualLen, UINT64* RequestId ) {
@@ -141,8 +141,8 @@ static int IVmbusChannelEstablishGpadl( PDEVICE_OBJECT Device, void * Buffer, - UINT32 BufferLen, - UINT32* GpadlHandle + u32 BufferLen, + u32* GpadlHandle ) { return VmbusChannelEstablishGpadl((VMBUS_CHANNEL*)Device->context,
@@ -154,7 +154,7 @@ IVmbusChannelEstablishGpadl(static int IVmbusChannelTeardownGpadl (PDEVICE_OBJECT Device, -UINT32 GpadlHandle +u32 GpadlHandle ) { return VmbusChannelTeardownGpadl((VMBUS_CHANNEL*)Device->context,
drivers/staging/hv/ChannelMgmt.h +11 -11
@@ -56,11 +56,11 @@ typedef struct _VMBUS_CHANNEL {u8 MonitorGroup;u8 MonitorBit; -UINT32 RingBufferGpadlHandle; +u32 RingBufferGpadlHandle;// Allocated memory for ring buffer void * RingBufferPages; -UINT32 RingBufferPageCount; +u32 RingBufferPageCount;RING_BUFFER_INFO Outbound;// send to parent RING_BUFFER_INFO Inbound;// receive from parent HANDLE InboundLock;
@@ -76,17 +76,17 @@ typedef struct _VMBUS_CHANNEL { typedef struct _VMBUS_CHANNEL_DEBUG_INFO { - UINT32 RelId; + u32 RelId; VMBUS_CHANNEL_STATE State; GUID InterfaceType; GUID InterfaceInstance; - UINT32 MonitorId; - UINT32 ServerMonitorPending; - UINT32 ServerMonitorLatency; - UINT32 ServerMonitorConnectionId; - UINT32 ClientMonitorPending; - UINT32 ClientMonitorLatency; - UINT32 ClientMonitorConnectionId; + u32 MonitorId; + u32 ServerMonitorPending; + u32 ServerMonitorLatency; + u32 ServerMonitorConnectionId; + u32 ClientMonitorPending; + u32 ClientMonitorLatency; + u32 ClientMonitorConnectionId; RING_BUFFER_DEBUG_INFO Inbound; RING_BUFFER_DEBUG_INFO Outbound;
@@ -117,7 +117,7 @@ typedef struct _VMBUS_CHANNEL_MSGINFO {VMBUS_CHANNEL_MESSAGE_RESPONSE Response; -UINT32 MessageSize; +u32 MessageSize;// The channel message that goes out on the "wire". // It will contain at minimum the VMBUS_CHANNEL_MESSAGE_HEADER header unsigned char Msg[0 ];
drivers/staging/hv/Connection.c +7 -7
@@ -253,7 +253,7 @@ Description:--*/ VMBUS_CHANNEL *GetChannelFromRelId ( -UINT32 relId +u32 relId ) {VMBUS_CHANNEL * channel;
@@ -294,7 +294,7 @@ VmbusProcessChannelEvent( ) {VMBUS_CHANNEL * channel; -UINT32 relId = (UINT32 )(ULONG_PTR )context; +u32 relId = (u32 )(ULONG_PTR )context;ASSERT (relId >0 );
@@ -333,7 +333,7 @@ VmbusOnEvents(int maxdword =MAX_NUM_CHANNELS_SUPPORTED >>5 ;int bit;int relid; -UINT32 * recvInterruptPage = gVmbusConnection.RecvInterruptPage; +u32 * recvInterruptPage = gVmbusConnection.RecvInterruptPage;//VMBUS_CHANNEL_MESSAGE* receiveMsg; DPRINT_ENTER (VMBUS );
@@ -393,7 +393,7 @@ VmbusPostMessage(HV_CONNECTION_ID connId; - connId.AsUINT32 =0 ; + connId.Asu32 =0 ; connId.u.Id =VMBUS_MESSAGE_CONNECTION_ID ; ret = HvPostMessage( connId,
@@ -414,14 +414,14 @@ Description:--*/ int -VmbusSetEvent (UINT32 childRelId) +VmbusSetEvent (u32 childRelId) {int ret=0 ;DPRINT_ENTER (VMBUS ); -// Each UINT32 represents 32 channels -BitSet ((UINT32 *)gVmbusConnection.SendInterruptPage + (childRelId >>5 ), childRelId &31 ); +// Each u32 represents 32 channels +BitSet ((u32 *)gVmbusConnection.SendInterruptPage + (childRelId >>5 ), childRelId &31 ); ret =HvSignalEvent ();DPRINT_EXIT (VMBUS );
drivers/staging/hv/Hv.c +10 -10
@@ -188,16 +188,16 @@ HvDoHypercall (#else -UINT32 controlHi = Control >>32 ; -UINT32 controlLo = Control &0xFFFFFFFF ; -UINT32 hvStatusHi =1 ; -UINT32 hvStatusLo =1 ; +u32 controlHi = Control >>32 ; +u32 controlLo = Control &0xFFFFFFFF ; +u32 hvStatusHi =1 ; +u32 hvStatusLo =1 ;UINT64 inputAddress = (Input) ?GetPhysicalAddress (Input) :0 ; -UINT32 inputAddressHi = inputAddress >>32 ; -UINT32 inputAddressLo = inputAddress &0xFFFFFFFF ; +u32 inputAddressHi = inputAddress >>32 ; +u32 inputAddressLo = inputAddress &0xFFFFFFFF ;UINT64 outputAddress = (Output) ?GetPhysicalAddress (Output) :0 ; -UINT32 outputAddressHi = outputAddress >>32 ; -UINT32 outputAddressLo = outputAddress &0xFFFFFFFF ; +u32 outputAddressHi = outputAddress >>32 ; +u32 outputAddressLo = outputAddress &0xFFFFFFFF ;volatile void * hypercallPage = gHvContext.HypercallPage; DPRINT_DBG(VMBUS, "Hypercall <control %llx input %p output %p>",
@@ -312,7 +312,7 @@ HvInit ( } gHvContext.SignalEventParam = (PHV_INPUT_SIGNAL_EVENT )(ALIGN_UP ((ULONG_PTR )gHvContext.SignalEventBuffer,HV_HYPERCALL_PARAM_ALIGN )); - gHvContext.SignalEventParam->ConnectionId.AsUINT32 =0 ; + gHvContext.SignalEventParam->ConnectionId.Asu32 =0 ; gHvContext.SignalEventParam->ConnectionId.u.Id =VMBUS_EVENT_CONNECTION_ID ; gHvContext.SignalEventParam->FlagNumber =0 ; gHvContext.SignalEventParam->RsvdZ =0 ;
@@ -471,7 +471,7 @@ Description:--*/ int HvSynicInit ( -UINT32 irqVector +u32 irqVector ) {UINT64 version;
drivers/staging/hv/Hv.h +1 -1
@@ -173,7 +173,7 @@ HvSignalEvent(static int HvSynicInit ( -UINT32 irqVector +u32 irqVector ); static void
drivers/staging/hv/include/ChannelMessages.h +26 -26
161 lines not on this page · raw message
drivers/staging/hv/include/HvHcApi.h +2 -2
@@ -41,9 +41,9 @@ typedef enum _HV_CALL_CODEtypedef struct _HV_INPUT_POST_MESSAGE {HV_CONNECTION_ID ConnectionId; -UINT32 Reserved; +u32 Reserved;HV_MESSAGE_TYPE MessageType; -UINT32 PayloadSize; +u32 PayloadSize;UINT64 Payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT ]; }HV_INPUT_POST_MESSAGE , *PHV_INPUT_POST_MESSAGE ;
drivers/staging/hv/include/HvSynicApi.h +21 -21
127 lines not on this page · raw message
drivers/staging/hv/include/HvVpApi.h +1 -1
@@ -26,7 +26,7 @@// // Virtual Processor Indices // -typedef UINT32 HV_VP_INDEX , *PHV_VP_INDEX ; +typedef u32 HV_VP_INDEX , *PHV_VP_INDEX ;// // The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent
drivers/staging/hv/include/NetVscApi.h +7 -7
@@ -52,14 +52,14 @@ typedef int (*PFN_ON_SEND)(DEVICE_OBJECTtypedef void (*PFN_ON_SENDRECVCOMPLETION )(void * Context);typedef int (*PFN_ON_RECVCALLBACK )(DEVICE_OBJECT *dev,PNETVSC_PACKET packet); -typedef void (*PFN_ON_LINKSTATUS_CHANGED )(DEVICE_OBJECT *dev,UINT32 Status); +typedef void (*PFN_ON_LINKSTATUS_CHANGED )(DEVICE_OBJECT *dev,u32 Status);// Represent the xfer page packet which contains 1 or more netvsc packet typedef struct _XFERPAGE_PACKET {DLIST_ENTRY ListEntry;// # of netvsc packets this xfer packet contains -UINT32 Count; +u32 Count; }XFERPAGE_PACKET ;
@@ -93,9 +93,9 @@ typedef struct _NETVSC_PACKET {// This points to the memory after PageBuffers void * Extension; -UINT32 TotalDataBufferLength; +u32 TotalDataBufferLength;// Points to the send/receive buffer where the ethernet frame is -UINT32 PageBufferCount; +u32 PageBufferCount;PAGE_BUFFER PageBuffers[NETVSC_PACKET_MAXPAGE ]; }NETVSC_PACKET ;
@@ -105,11 +105,11 @@ typedef struct _NETVSC_PACKET { typedef struct _NETVSC_DRIVER_OBJECT { DRIVER_OBJECT Base; // Must be the first field - UINT32 RingBufferSize; - UINT32 RequestExtSize; + u32 RingBufferSize; + u32 RequestExtSize; // Additional num of page buffers to allocate - UINT32 AdditionalRequestPageBufferCount; + u32 AdditionalRequestPageBufferCount; // This is set by the caller to allow us to callback when we receive a packet // from the "wire"
drivers/staging/hv/include/nvspprotocol.h +21 -21
114 lines not on this page · raw message
drivers/staging/hv/include/osd.h +7 -9
@@ -97,7 +97,6 @@ typedef struct _DLIST_ENTRY {// // unsigned types // -typedef unsigned int UINT32 ;#ifdef __x86_64__typedef unsigned long UINT64 ;#else
@@ -112,7 +111,6 @@ typedef unsigned char UCHAR;// // signed types // -typedef int INT32 ;#ifdef __x86_64__typedef long INT64 ;#else
@@ -131,7 +129,7 @@ typedef unsigned long SIZE_T;typedef unsigned char BOOL ;typedef unsigned char BOOLEAN ;typedef void *HANDLE ; -typedef UINT32 DWORD ; +typedef u32 DWORD ;typedef char *PCHAR ;typedef unsigned char BYTE ;
@@ -148,7 +146,7 @@ typedef void (*PFN_TIMER_CALLBACK)(void*#ifdef __x86_64__#define RDMSR (reg, v) { \ - UINT32 h, l; \ + u32 h, l; \ __asm__ __volatile__("rdmsr" \ : "=a" (l), "=d" (h) \ : "c" (reg)); \
@@ -156,9 +154,9 @@ typedef void (*PFN_TIMER_CALLBACK)(void* } #define WRMSR(reg, v) { \ - UINT32 h, l; \ - l = (UINT32)(((UINT64)(v)) & 0xFFFFFFFF); \ - h = (UINT32)((((UINT64)(v)) >> 32) & 0xFFFFFFFF); \ + u32 h, l; \ + l = (u32)(((UINT64)(v)) & 0xFFFFFFFF); \ + h = (u32)((((UINT64)(v)) >> 32) & 0xFFFFFFFF); \ __asm__ __volatile__("wrmsr" \ : /* no outputs */ \ : "c" (reg), "a" (l), "d" (h)); \
@@ -219,7 +217,7 @@ extern void MemoryFence(void);extern HANDLE TimerCreate (PFN_TIMER_CALLBACK pfnTimerCB,void * context);extern void TimerClose (HANDLE hTimer);extern int TimerStop (HANDLE hTimer); -extern void TimerStart (HANDLE hTimer,UINT32 expirationInUs); +extern void TimerStart (HANDLE hTimer,u32 expirationInUs);extern SIZE_T GetTickCount (void );extern HANDLE WaitEventCreate (void );
@@ -228,7 +226,7 @@ extern void WaitEventSet(HANDLE hWait);extern int WaitEventWait (HANDLE hWait);// If >0, hWait got signaled. If ==0, timeout. If < 0, error -extern int WaitEventWaitEx (HANDLE hWait,UINT32 TimeoutInMs); +extern int WaitEventWaitEx (HANDLE hWait,u32 TimeoutInMs);extern HANDLE SpinlockCreate (void );extern void SpinlockClose (HANDLE hSpin);
drivers/staging/hv/include/rndis.h +85 -85
321 lines not on this page · raw message
drivers/staging/hv/include/StorVscApi.h +11 -11
@@ -71,17 +71,17 @@ typedef enum _STORVSC_REQUEST_TYPE{ typedef struct _STORVSC_REQUEST { STORVSC_REQUEST_TYPE Type; - UINT32 Host; - UINT32 Bus; - UINT32 TargetId; - UINT32 LunId; + u32 Host; + u32 Bus; + u32 TargetId; + u32 LunId; u8 * Cdb; - UINT32 CdbLen; - UINT32 Status; - UINT32 BytesXfer; + u32 CdbLen; + u32 Status; + u32 BytesXfer; UCHAR* SenseBuffer; - UINT32 SenseBufferSize; + u32 SenseBufferSize; void * Context;
@@ -99,13 +99,13 @@ typedef struct _STORVSC_DRIVER_OBJECT {DRIVER_OBJECT Base;// Must be the first field // Set by caller (in bytes) -UINT32 RingBufferSize; +u32 RingBufferSize;// Allocate this much private extension for each I/O request -UINT32 RequestExtSize; +u32 RequestExtSize;// Maximum # of requests in flight per channel/device -UINT32 MaxOutstandingRequestsPerChannel; +u32 MaxOutstandingRequestsPerChannel;// Set by the caller to allow us to re-enumerate the bus on the host PFN_ON_HOST_RESCAN OnHostRescan;
drivers/staging/hv/include/VmbusApi.h +34 -34
139 lines not on this page · raw message
drivers/staging/hv/include/VmbusChannelInterface.h +5 -5
@@ -67,8 +67,8 @@ typedef structGUID InterfaceType;GUID InterfaceInstance;UINT64 InterruptLatencyIn100nsUnits; -UINT32 InterfaceRevision; -UINT32 ServerContextAreaSize;// in bytes +u32 InterfaceRevision; +u32 ServerContextAreaSize;// in bytes u16 ChannelFlags;u16 MmioMegabytes;// in bytes * 1024 * 1024
@@ -89,11 +89,11 @@ typedef struct// struct { -UINT32 PipeMode; +u32 PipeMode;UCHAR UserDefined[MAX_PIPE_USER_DEFINED_BYTES ]; } Pipe; } u; -UINT32 Padding; +u32 Padding; }VMBUS_CHANNEL_OFFER , *PVMBUS_CHANNEL_OFFER ;#pragma pack(pop)
@@ -107,7 +107,7 @@ typedef struct// FIELD_OFFSET(VMBUS_CHANNEL_OFFER, u.Standard.UserDefined))); // -typedef UINT32 GPADL_HANDLE ; +typedef u32 GPADL_HANDLE ;// // Server Flags
drivers/staging/hv/include/VmbusPacketFormat.h +20 -20
@@ -41,8 +41,8 @@ typedef struct {struct { -volatile UINT32 In;// Offset in bytes from the ring base -volatile UINT32 Out;// Offset in bytes from the ring base +volatile u32 In;// Offset in bytes from the ring base +volatile u32 Out;// Offset in bytes from the ring base };volatile LONGLONG InOut; };
@@ -52,7 +52,7 @@ typedef struct// endpoint should not send any interrupts. // -volatile UINT32 InterruptMask; +volatile u32 InterruptMask; }VMRCB , *PVMRCB ;
@@ -86,7 +86,7 @@ typedef structUINT64 TransactionId; }VMPACKET_DESCRIPTOR , *PVMPACKET_DESCRIPTOR ; -typedef UINT32 PREVIOUS_PACKET_OFFSET , *PPREVIOUS_PACKET_OFFSET ; +typedef u32 PREVIOUS_PACKET_OFFSET , *PPREVIOUS_PACKET_OFFSET ; typedef struct {
@@ -96,8 +96,8 @@ typedef structtypedef struct { -UINT32 ByteCount; -UINT32 ByteOffset; +u32 ByteCount; +u32 ByteOffset; }VMTRANSFER_PAGE_RANGE , *PVMTRANSFER_PAGE_RANGE ;#ifdef __cplusplus
@@ -115,7 +115,7 @@ typedef struct VMTRANSFER_PAGE_PACKET_HEu16 TransferPageSetId;BOOLEAN SenderOwnsSet;u8 Reserved; -UINT32 RangeCount; +u32 RangeCount;VMTRANSFER_PAGE_RANGE Ranges[1 ]; }VMTRANSFER_PAGE_PACKET_HEADER , *PVMTRANSFER_PAGE_PACKET_HEADER ;
@@ -134,8 +134,8 @@ typedef struct _VMGPADL_PACKET_HEADER {#endif -UINT32 Gpadl; -UINT32 Reserved; +u32 Gpadl; +u32 Reserved; }VMGPADL_PACKET_HEADER , *PVMGPADL_PACKET_HEADER ;
@@ -151,7 +151,7 @@ typedef struct _VMADD_REMOVE_TRANSFER_PA#endif -UINT32 Gpadl; +u32 Gpadl;u16 TransferPageSetId;u16 Reserved;
@@ -166,8 +166,8 @@ typedef struct _VMADD_REMOVE_TRANSFER_PAtypedef struct _GPA_RANGE { -UINT32 ByteCount; -UINT32 ByteOffset; +u32 ByteCount; +u32 ByteOffset;UINT64 PfnArray[0 ]; }GPA_RANGE , *PGPA_RANGE ;
@@ -196,8 +196,8 @@ typedef struct _VMESTABLISH_GPADL {#endif -UINT32 Gpadl; -UINT32 RangeCount; +u32 Gpadl; +u32 RangeCount;GPA_RANGE Range[1 ]; }VMESTABLISH_GPADL , *PVMESTABLISH_GPADL ;
@@ -220,8 +220,8 @@ typedef struct _VMTEARDOWN_GPADL {#endif -UINT32 Gpadl; -UINT32 Reserved;// for alignment to a 8-byte boundary +u32 Gpadl; +u32 Reserved;// for alignment to a 8-byte boundary }VMTEARDOWN_GPADL , *PVMTEARDOWN_GPADL ;
@@ -242,8 +242,8 @@ typedef struct _VMDATA_GPA_DIRECT {#endif -UINT32 Reserved; -UINT32 RangeCount; +u32 Reserved; +u32 RangeCount;GPA_RANGE Range[1 ]; }VMDATA_GPA_DIRECT , *PVMDATA_GPA_DIRECT ;
@@ -267,8 +267,8 @@ typedef struct _VMADDITIONAL_DATA {#endif UINT64 TotalBytes; -UINT32 ByteOffset; -UINT32 ByteCount; +u32 ByteOffset; +u32 ByteCount;UCHAR Data[1 ]; }VMADDITIONAL_DATA , *PVMADDITIONAL_DATA ;
drivers/staging/hv/NetVsc.c +1 -1
@@ -1402,7 +1402,7 @@ NetVscOnChannelCallback(DEVICE_OBJECT *device=(DEVICE_OBJECT *)Context;NETVSC_DEVICE *netDevice; -UINT32 bytesRecvd; +u32 bytesRecvd;UINT64 requestId;UCHAR packet[netPacketSize];VMPACKET_DESCRIPTOR *desc;
drivers/staging/hv/NetVsc.h +6 -6
@@ -66,15 +66,15 @@ typedef struct _NETVSC_DEVICE {// Send buffer allocated by us but manages by NetVSP void * SendBuffer; -UINT32 SendBufferSize; -UINT32 SendBufferGpadlHandle; -UINT32 SendSectionSize; +u32 SendBufferSize; +u32 SendBufferGpadlHandle; +u32 SendSectionSize;// Receive buffer allocated by us but manages by NetVSP void * ReceiveBuffer; -UINT32 ReceiveBufferSize; -UINT32 ReceiveBufferGpadlHandle; -UINT32 ReceiveSectionCount; +u32 ReceiveBufferSize; +u32 ReceiveBufferGpadlHandle; +u32 ReceiveSectionCount;PNVSP_1_RECEIVE_BUFFER_SECTION ReceiveSections;// Used for NetVSP initialization protocol
drivers/staging/hv/osd.c +2 -2
@@ -289,7 +289,7 @@ HANDLE TimerCreate(PFN_TIMER_CALLBACK pfreturn t; } -void TimerStart (HANDLE hTimer,UINT32 expirationInUs) +void TimerStart (HANDLE hTimer,u32 expirationInUs) {TIMER * t = (TIMER * )hTimer;
@@ -363,7 +363,7 @@ int WaitEventWait(HANDLE hWait)return ret; } -int WaitEventWaitEx (HANDLE hWait,UINT32 TimeoutInMs) +int WaitEventWaitEx (HANDLE hWait,u32 TimeoutInMs) {int ret=0 ;WAITEVENT * waitEvent = (WAITEVENT * )hWait;
drivers/staging/hv/RingBuffer.c +48 -48
230 lines not on this page · raw message
drivers/staging/hv/RingBuffer.h +19 -19
@@ -29,39 +29,39 @@typedef struct _SG_BUFFER_LIST {void * Data; -UINT32 Length; +u32 Length; }SG_BUFFER_LIST ;typedef struct _RING_BUFFER { -volatile UINT32 WriteIndex;// Offset in bytes from the start of ring data below -volatile UINT32 ReadIndex;// Offset in bytes from the start of ring data below +volatile u32 WriteIndex;// Offset in bytes from the start of ring data below +volatile u32 ReadIndex;// Offset in bytes from the start of ring data below -volatile UINT32 InterruptMask; +volatile u32 InterruptMask;u8 Reserved[4084 ];// Pad it to PAGE_SIZE so that data starts on page boundary // NOTE: The InterruptMask field is used only for channels but since our vmbus connection // also uses this data structure and its data starts here, we commented out this field. -// volatile UINT32 InterruptMask; +// volatile u32 InterruptMask; // Ring data starts here + RingDataStartOffset !!! DO NOT place any fields below this !!! u8 Buffer[0 ]; } STRUCT_PACKED RING_BUFFER;typedef struct _RING_BUFFER_INFO {RING_BUFFER * RingBuffer; -UINT32 RingSize;// Include the shared header +u32 RingSize;// Include the shared header HANDLE RingLock; -UINT32 RingDataSize;// < ringSize -UINT32 RingDataStartOffset; +u32 RingDataSize;// < ringSize +u32 RingDataStartOffset; }RING_BUFFER_INFO ;typedef struct _RING_BUFFER_DEBUG_INFO { -UINT32 CurrentInterruptMask; -UINT32 CurrentReadIndex; -UINT32 CurrentWriteIndex; -UINT32 BytesAvailToRead; -UINT32 BytesAvailToWrite; +u32 CurrentInterruptMask; +u32 CurrentReadIndex; +u32 CurrentWriteIndex; +u32 BytesAvailToRead; +u32 BytesAvailToWrite; }RING_BUFFER_DEBUG_INFO ;
@@ -73,7 +73,7 @@ static intRingBufferInit (RING_BUFFER_INFO *RingInfo, void * Buffer, - UINT32 BufferLen + u32 BufferLen ); static void
@@ -85,25 +85,25 @@ static intRingBufferWrite (RING_BUFFER_INFO *RingInfo, SG_BUFFER_LIST SgBuffers[], - UINT32 SgBufferCount + u32 SgBufferCount );static int RingBufferPeek (RING_BUFFER_INFO *RingInfo,void * Buffer, -UINT32 BufferLen +u32 BufferLen );static int RingBufferRead (RING_BUFFER_INFO *RingInfo,void * Buffer, -UINT32 BufferLen, -UINT32 Offset +u32 BufferLen, +u32 Offset ); -static UINT32 +static u32 GetRingBufferInterruptMask (RING_BUFFER_INFO *RingInfo );
drivers/staging/hv/RndisFilter.c +20 -20
@@ -50,8 +50,8 @@ typedef struct _RNDIS_DEVICE {NETVSC_DEVICE *NetDevice;RNDIS_DEVICE_STATE State; -UINT32 LinkStatus; -UINT32 NewRequestId; +u32 LinkStatus; +u32 NewRequestId;HANDLE RequestLock;LIST_ENTRY RequestList;
@@ -120,9 +120,9 @@ RndisFilterOnReceive(static int RndisFilterQueryDevice (RNDIS_DEVICE *Device, -UINT32 Oid, +u32 Oid,void *Result, -UINT32 *ResultSize +u32 *ResultSize ); static inline int
@@ -138,7 +138,7 @@ RndisFilterQueryDeviceLinkStatus(static int RndisFilterSetPacketFilter (RNDIS_DEVICE *Device, -UINT32 NewFilter +u32 NewFilter ); static int
@@ -235,7 +235,7 @@ static inline void PutRndisDevice(RNDIS_MemFree (Device); } -static inline RNDIS_REQUEST *GetRndisRequest (RNDIS_DEVICE *Device,UINT32 MessageType,UINT32 MessageLength) +static inline RNDIS_REQUEST *GetRndisRequest (RNDIS_DEVICE *Device,u32 MessageType,u32 MessageLength) {RNDIS_REQUEST *request;RNDIS_MESSAGE *rndisMessage;
@@ -465,7 +465,7 @@ RndisFilterReceiveData( ) {RNDIS_PACKET *rndisPacket; -UINT32 dataOffset; +u32 dataOffset;DPRINT_ENTER (NETVSC );
@@ -585,13 +585,13 @@ RndisFilterOnReceive(static int RndisFilterQueryDevice (RNDIS_DEVICE *Device, -UINT32 Oid, +u32 Oid,void *Result, -UINT32 *ResultSize +u32 *ResultSize ) {RNDIS_REQUEST *request; -UINT32 inresultSize = *ResultSize; +u32 inresultSize = *ResultSize;RNDIS_QUERY_REQUEST *query;RNDIS_QUERY_COMPLETE *queryComplete;int ret=0 ;
@@ -653,7 +653,7 @@ RndisFilterQueryDeviceMac(RNDIS_DEVICE *Device ) { -UINT32 size=HW_MACADDR_LEN ; +u32 size=HW_MACADDR_LEN ; return RndisFilterQueryDevice(Device, RNDIS_OID_802_3_PERMANENT_ADDRESS,
@@ -666,7 +666,7 @@ RndisFilterQueryDeviceLinkStatus(RNDIS_DEVICE *Device ) { -UINT32 size=sizeof (UINT32 ); +u32 size=sizeof (u32); return RndisFilterQueryDevice(Device, RNDIS_OID_GEN_MEDIA_CONNECT_STATUS,
@@ -677,20 +677,20 @@ RndisFilterQueryDeviceLinkStatus(static int RndisFilterSetPacketFilter (RNDIS_DEVICE *Device, -UINT32 NewFilter +u32 NewFilter ) {RNDIS_REQUEST *request;RNDIS_SET_REQUEST *set;RNDIS_SET_COMPLETE *setComplete; -UINT32 status; +u32 status;int ret;DPRINT_ENTER (NETVSC ); -ASSERT (RNDIS_MESSAGE_SIZE (RNDIS_SET_REQUEST ) +sizeof (UINT32 ) <=sizeof (RNDIS_MESSAGE )); +ASSERT (RNDIS_MESSAGE_SIZE (RNDIS_SET_REQUEST ) +sizeof (u32) <=sizeof (RNDIS_MESSAGE )); - request =GetRndisRequest (Device,REMOTE_NDIS_SET_MSG ,RNDIS_MESSAGE_SIZE (RNDIS_SET_REQUEST ) +sizeof (UINT32 )); + request =GetRndisRequest (Device,REMOTE_NDIS_SET_MSG ,RNDIS_MESSAGE_SIZE (RNDIS_SET_REQUEST ) +sizeof (u32));if (!request) { ret =-1 ;
@@ -700,10 +700,10 @@ RndisFilterSetPacketFilter(// Setup the rndis set set = &request->RequestMessage.Message.SetRequest; set->Oid =RNDIS_OID_GEN_CURRENT_PACKET_FILTER ; - set->InformationBufferLength =sizeof (UINT32 ); + set->InformationBufferLength =sizeof (u32); set->InformationBufferOffset =sizeof (RNDIS_SET_REQUEST ); -memcpy ((void *)(ULONG_PTR )set +sizeof (RNDIS_SET_REQUEST ), &NewFilter,sizeof (UINT32 )); +memcpy ((void *)(ULONG_PTR )set +sizeof (RNDIS_SET_REQUEST ), &NewFilter,sizeof (u32)); ret =RndisFilterSendRequest (Device, request);if (ret !=0 )
@@ -795,7 +795,7 @@ RndisFilterInitDevice(RNDIS_REQUEST *request;RNDIS_INITIALIZE_REQUEST *init;RNDIS_INITIALIZE_COMPLETE *initComplete; -UINT32 status; +u32 status;int ret;DPRINT_ENTER (NETVSC );
@@ -1091,7 +1091,7 @@ RndisFilterOnSend(RNDIS_FILTER_PACKET *filterPacket;RNDIS_MESSAGE *rndisMessage;RNDIS_PACKET *rndisPacket; -UINT32 rndisMessageSize; +u32 rndisMessageSize;DPRINT_ENTER (NETVSC );
drivers/staging/hv/StorVsc.c +1 -1
@@ -908,7 +908,7 @@ StorVscOnChannelCallback(int ret=0 ;DEVICE_OBJECT *device = (DEVICE_OBJECT *)Context;STORVSC_DEVICE *storDevice; -UINT32 bytesRecvd; +u32 bytesRecvd;UINT64 requestId;UCHAR packet[ALIGN_UP (sizeof (VSTOR_PACKET ),8 )];STORVSC_REQUEST_EXTENSION *request;
drivers/staging/hv/Vmbus.c +1 -1
@@ -307,7 +307,7 @@ VmbusOnDeviceAdd(void *AdditionalInfo ) { -UINT32 *irqvector = (UINT32 *) AdditionalInfo; +u32 *irqvector = (u32 *) AdditionalInfo;int ret=0 ;DPRINT_ENTER (VMBUS );
drivers/staging/hv/VmbusPrivate.h +3 -3
@@ -64,7 +64,7 @@ typedef struct _VMBUS_CONNECTION {VMBUS_CONNECT_STATE ConnectState; -UINT32 NextGpadlHandle; +u32 NextGpadlHandle;// Represents channel interrupts. Each bit position // represents a channel.
@@ -130,7 +130,7 @@ VmbusChildDeviceRemove(static VMBUS_CHANNEL *GetChannelFromRelId ( -UINT32 relId +u32 relId );//
@@ -154,7 +154,7 @@ VmbusPostMessage(static int VmbusSetEvent ( -UINT32 childRelId +u32 childRelId ); static void
PATCH 23/54 Staging: hv: remove UINT64 and INT64 and UCHAR typedefs
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
The UINT64 and INT64 and UCHAR typedefs are now removed from the Hyper-V driver code.
--- drivers/staging/hv/BlkVsc.c | 4 - drivers/staging/hv/Channel.c | 48 +++++++++---------- drivers/staging/hv/Channel.h | 14 ++--- drivers/staging/hv/ChannelInterface.c | 10 ++-- drivers/staging/hv/Hv.c | 24 ++++----- drivers/staging/hv/Hv.h | 12 ++-- drivers/staging/hv/NetVsc.c | 12 ++-- drivers/staging/hv/NetVsc.h | 2 drivers/staging/hv/RingBuffer.c | 16 +++--- drivers/staging/hv/RndisFilter.c | 2 drivers/staging/hv/StorVsc.c | 12 ++-- drivers/staging/hv/include/ChannelMessages.h | 12 ++-- drivers/staging/hv/include/HvHalApi.h | 4 - drivers/staging/hv/include/HvHcApi.h | 2 drivers/staging/hv/include/HvPtApi.h | 22 ++++---- drivers/staging/hv/include/HvSynicApi.h | 52 ++++++++++----------- drivers/staging/hv/include/HvTypes.h | 2 drivers/staging/hv/include/List.h | 4 - drivers/staging/hv/include/NetVscApi.h | 6 +- drivers/staging/hv/include/StorVscApi.h | 6 +- drivers/staging/hv/include/VmbusApi.h | 14 ++--- drivers/staging/hv/include/VmbusChannelInterface.h | 6 +- drivers/staging/hv/include/VmbusPacketFormat.h | 10 ++-- drivers/staging/hv/include/osd.h | 22 +------- drivers/staging/hv/include/rndis.h | 8 +-- drivers/staging/hv/include/vstorage.h | 34 ++++++------- 26 files changed, 173 insertions(+), 187 deletions(-)
drivers/staging/hv/BlkVsc.c +2 -2
@@ -56,9 +56,9 @@ BlkVscInitialize( storDriver->RequestExtSize =sizeof (STORVSC_REQUEST_EXTENSION );// Divide the ring buffer data size (which is 1 page less than the ring buffer size since that page is reserved for the ring buffer indices) -// by the max request size (which is VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER + VSTOR_PACKET + UINT64) +// by the max request size (which is VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER + VSTOR_PACKET + u64) storDriver->MaxOutstandingRequestsPerChannel = - ((storDriver->RingBufferSize -PAGE_SIZE ) /ALIGN_UP (MAX_MULTIPAGE_BUFFER_PACKET +sizeof (VSTOR_PACKET ) +sizeof (UINT64 ),sizeof (UINT64 ))); + ((storDriver->RingBufferSize -PAGE_SIZE ) /ALIGN_UP (MAX_MULTIPAGE_BUFFER_PACKET +sizeof (VSTOR_PACKET ) +sizeof (u64),sizeof (u64)));DPRINT_INFO (BLKVSC ,"max io outstd %u" , storDriver->MaxOutstandingRequestsPerChannel);
drivers/staging/hv/Channel.c +24 -24
169 lines not on this page · raw message
drivers/staging/hv/Channel.h +7 -7
@@ -37,7 +37,7 @@ typedef struct _VMBUS_CHANNEL_PACKET_PAGu16 DataOffset8;u16 Length8;u16 Flags; -UINT64 TransactionId; +u64 TransactionId;u32 Reserved;u32 RangeCount;PAGE_BUFFER Range[MAX_PAGE_BUFFER_COUNT ];
@@ -50,7 +50,7 @@ typedef struct _VMBUS_CHANNEL_PACKET_MULu16 DataOffset8;u16 Length8;u16 Flags; -UINT64 TransactionId; +u64 TransactionId;u32 Reserved;u32 RangeCount;// Always 1 in this case MULTIPAGE_BUFFER Range;
@@ -83,7 +83,7 @@ VmbusChannelSendPacket(VMBUS_CHANNEL *Channel, const void * Buffer, u32 BufferLen, - UINT64 RequestId, + u64 RequestId, VMBUS_PACKET_TYPE Type, u32 Flags );
@@ -95,7 +95,7 @@ VmbusChannelSendPacketPageBuffer(u32 PageCount, void * Buffer, u32 BufferLen, - UINT64 RequestId + u64 RequestId ); static int
@@ -104,7 +104,7 @@ VmbusChannelSendPacketMultiPageBuffer(MULTIPAGE_BUFFER *MultiPageBuffer, void * Buffer, u32 BufferLen, - UINT64 RequestId + u64 RequestId ); static int
@@ -127,7 +127,7 @@ VmbusChannelRecvPacket(void * Buffer, u32 BufferLen, u32* BufferActualLen, - UINT64* RequestId + u64* RequestId ); static int
@@ -136,7 +136,7 @@ VmbusChannelRecvPacketRaw(void * Buffer, u32 BufferLen, u32* BufferActualLen, - UINT64* RequestId + u64* RequestId ); static void
drivers/staging/hv/ChannelInterface.c +5 -5
@@ -58,7 +58,7 @@ IVmbusChannelSendPacket(PDEVICE_OBJECT Device, const void * Buffer, u32 BufferLen, - UINT64 RequestId, + u64 RequestId, u32 Type, u32 Flags )
@@ -78,7 +78,7 @@ IVmbusChannelSendPacketPageBuffer( u32 PageCount, void * Buffer, u32 BufferLen, - UINT64 RequestId + u64 RequestId ) { return VmbusChannelSendPacketPageBuffer((VMBUS_CHANNEL*)Device->context,
@@ -95,7 +95,7 @@ IVmbusChannelSendPacketMultiPageBuffer( MULTIPAGE_BUFFER *MultiPageBuffer, void * Buffer, u32 BufferLen, - UINT64 RequestId + u64 RequestId ) { return VmbusChannelSendPacketMultiPageBuffer((VMBUS_CHANNEL*)Device->context,
@@ -111,7 +111,7 @@ IVmbusChannelRecvPacket ( void * Buffer, u32 BufferLen, u32* BufferActualLen, - UINT64* RequestId + u64* RequestId ) { return VmbusChannelRecvPacket((VMBUS_CHANNEL*)Device->context,
@@ -127,7 +127,7 @@ IVmbusChannelRecvPacketRaw( void * Buffer, u32 BufferLen, u32* BufferActualLen, - UINT64* RequestId + u64* RequestId ) { return VmbusChannelRecvPacketRaw((VMBUS_CHANNEL*)Device->context,
drivers/staging/hv/Hv.c +12 -12
@@ -158,17 +158,17 @@ Description:Invoke the specified hypercall --*/ -static UINT64 +static u64 HvDoHypercall ( -UINT64 Control, +u64 Control,void * Input,void * Output ) {#ifdef CONFIG_X86_64 -UINT64 hvStatus=0 ; -UINT64 inputAddress = (Input)?GetPhysicalAddress (Input) :0 ; -UINT64 outputAddress = (Output)?GetPhysicalAddress (Output) :0 ; +u64 hvStatus=0 ; +u64 inputAddress = (Input)?GetPhysicalAddress (Input) :0 ; +u64 outputAddress = (Output)?GetPhysicalAddress (Output) :0 ;volatile void * hypercallPage = gHvContext.HypercallPage; DPRINT_DBG(VMBUS, "Hypercall <control %llx input phys %llx virt %p output phys %llx virt %p hypercall %p>",
@@ -192,10 +192,10 @@ HvDoHypercall (u32 controlLo = Control &0xFFFFFFFF ;u32 hvStatusHi =1 ;u32 hvStatusLo =1 ; -UINT64 inputAddress = (Input) ?GetPhysicalAddress (Input) :0 ; +u64 inputAddress = (Input) ?GetPhysicalAddress (Input) :0 ;u32 inputAddressHi = inputAddress >>32 ;u32 inputAddressLo = inputAddress &0xFFFFFFFF ; -UINT64 outputAddress = (Output) ?GetPhysicalAddress (Output) :0 ; +u64 outputAddress = (Output) ?GetPhysicalAddress (Output) :0 ;u32 outputAddressHi = outputAddress >>32 ;u32 outputAddressLo = outputAddress &0xFFFFFFFF ;volatile void * hypercallPage = gHvContext.HypercallPage;
@@ -208,9 +208,9 @@ HvDoHypercall ( __asm__ __volatile__ ("call *%8" :"=d" (hvStatusHi),"=a" (hvStatusLo) :"d" (controlHi),"a" (controlLo),"b" (inputAddressHi),"c" (inputAddressLo),"D" (outputAddressHi),"S" (outputAddressLo),"m" (hypercallPage)); -DPRINT_DBG (VMBUS ,"Hypercall <return %llx>" , hvStatusLo | ((UINT64 )hvStatusHi <<32 )); +DPRINT_DBG (VMBUS ,"Hypercall <return %llx>" , hvStatusLo | ((u64 )hvStatusHi <<32 )); -return (hvStatusLo | ((UINT64 )hvStatusHi <<32 )); +return (hvStatusLo | ((u64 )hvStatusHi <<32 ));#endif // x86_64 }
@@ -401,7 +401,7 @@ HvPostMessage( ) {struct alignedInput { -UINT64 alignment8; +u64 alignment8;HV_INPUT_POST_MESSAGE msg; };
@@ -474,12 +474,12 @@ HvSynicInit (u32 irqVector ) { -UINT64 version; +u64 version;HV_SYNIC_SIMP simp;HV_SYNIC_SIEFP siefp;HV_SYNIC_SINT sharedSint;HV_SYNIC_SCONTROL sctrl; -UINT64 guestID; +u64 guestID;int ret=0 ;DPRINT_ENTER (VMBUS );
drivers/staging/hv/Hv.h +6 -6
@@ -60,11 +60,11 @@ enum#define HV_XENLINUX_GUEST_ID_LO 0x00000000#define HV_XENLINUX_GUEST_ID_HI 0x0B00B135 -#define HV_XENLINUX_GUEST_ID (((UINT64)HV_XENLINUX_GUEST_ID_HI << 32) | HV_XENLINUX_GUEST_ID_LO) +#define HV_XENLINUX_GUEST_ID (((u64)HV_XENLINUX_GUEST_ID_HI << 32) | HV_XENLINUX_GUEST_ID_LO)#define HV_LINUX_GUEST_ID_LO 0x00000000#define HV_LINUX_GUEST_ID_HI 0xB16B00B5 -#define HV_LINUX_GUEST_ID (((UINT64)HV_LINUX_GUEST_ID_HI << 32) | HV_LINUX_GUEST_ID_LO) +#define HV_LINUX_GUEST_ID (((u64)HV_LINUX_GUEST_ID_HI << 32) | HV_LINUX_GUEST_ID_LO)#define HV_CPU_POWER_MANAGEMENT (1 << 0)#define HV_RECOMMENDATIONS_MAX 4
@@ -73,7 +73,7 @@ enum#define HV_CAPS_MAX 8 -#define HV_HYPERCALL_PARAM_ALIGN sizeof(UINT64) +#define HV_HYPERCALL_PARAM_ALIGN sizeof(u64)// // Service definitions
@@ -105,12 +105,12 @@ static const GUID VMBUS_SERVICE_ID = {.Dtypedef struct { -UINT64 Align8; +u64 Align8;HV_INPUT_SIGNAL_EVENT Event; }HV_INPUT_SIGNAL_EVENT_BUFFER ; typedef struct { - UINT64 GuestId; // XenLinux or native Linux. If XenLinux, the hypercall and synic pages has already been initialized + u64 GuestId; // XenLinux or native Linux. If XenLinux, the hypercall and synic pages has already been initialized void* HypercallPage; BOOL SynICInitialized;
@@ -138,7 +138,7 @@ static inline unsigned long long ReadMsrreturn val; } -static inline void WriteMsr (int msr,UINT64 val) +static inline void WriteMsr (int msr,u64 val) {WRMSR (msr, val);
drivers/staging/hv/NetVsc.c +6 -6
@@ -114,7 +114,7 @@ NetVscOnReceiveCompletion(static void NetVscSendReceiveCompletion (DEVICE_OBJECT *Device, -UINT64 TransactionId +u64 TransactionId );static inline NETVSC_DEVICE *AllocNetDevice (DEVICE_OBJECT *Device)
@@ -1286,7 +1286,7 @@ NetVscOnReceive(static void NetVscSendReceiveCompletion (DEVICE_OBJECT *Device, -UINT64 TransactionId +u64 TransactionId ) {NVSP_MESSAGE recvcompMessage;
@@ -1343,7 +1343,7 @@ NetVscOnReceiveCompletion(NETVSC_PACKET *packet = (NETVSC_PACKET *)Context;DEVICE_OBJECT *device = (DEVICE_OBJECT *)packet->Device;NETVSC_DEVICE * netDevice; -UINT64 transactionId=0 ; +u64 transactionId=0 ;BOOL fSendReceiveComp = FALSE;DPRINT_ENTER (NETVSC );
@@ -1403,10 +1403,10 @@ NetVscOnChannelCallback(NETVSC_DEVICE *netDevice;u32 bytesRecvd; -UINT64 requestId; -UCHAR packet[netPacketSize]; +u64 requestId; +unsigned char packet[netPacketSize];VMPACKET_DESCRIPTOR *desc; -UCHAR *buffer=packet; +unsigned char *buffer=packet;int bufferlen=netPacketSize;
drivers/staging/hv/NetVsc.h +1 -1
@@ -82,7 +82,7 @@ typedef struct _NETVSC_DEVICE {NVSP_MESSAGE ChannelInitPacket;NVSP_MESSAGE RevokePacket; -//UCHAR HwMacAddr[HW_MACADDR_LEN]; +//unsigned char HwMacAddr[HW_MACADDR_LEN]; // Holds rndis device info void *Extension;
drivers/staging/hv/RingBuffer.c +8 -8
@@ -184,13 +184,13 @@ Name:GetRingBufferIndices() Description: -Get the read and write indices as UINT64 of the specified ring buffer +Get the read and write indices as u64 of the specified ring buffer --*/ -static inline UINT64 +static inline u64 GetRingBufferIndices (RING_BUFFER_INFO * RingInfo) { -return ((UINT64 )RingInfo->RingBuffer->WriteIndex <<32 ) || RingInfo->RingBuffer->ReadIndex; +return ((u64 )RingInfo->RingBuffer->WriteIndex <<32 ) || RingInfo->RingBuffer->ReadIndex; }
@@ -359,7 +359,7 @@ RingBufferWrite(u32 totalBytesToWrite=0 ;volatile u32 nextWriteLocation; -UINT64 prevIndices=0 ; +u64 prevIndices=0 ;DPRINT_ENTER (VMBUS );
@@ -368,7 +368,7 @@ RingBufferWrite( totalBytesToWrite += SgBuffers[i].Length; } - totalBytesToWrite +=sizeof (UINT64 ); + totalBytesToWrite +=sizeof (u64);SpinlockAcquire (OutRingInfo->RingLock);
@@ -408,7 +408,7 @@ RingBufferWrite( nextWriteLocation =CopyToRingBuffer (OutRingInfo, nextWriteLocation, &prevIndices, -sizeof (UINT64 )); +sizeof (u64));// Make sure we flush all writes before updating the writeIndex MemoryFence ();
@@ -494,7 +494,7 @@ RingBufferRead(u32 bytesAvailToWrite;u32 bytesAvailToRead;u32 nextReadLocation=0 ; -UINT64 prevIndices=0 ; +u64 prevIndices=0 ;ASSERT (BufferLen >0 );
@@ -525,7 +525,7 @@ RingBufferRead( nextReadLocation =CopyFromRingBuffer (InRingInfo, &prevIndices, -sizeof (UINT64 ), +sizeof (u64), nextReadLocation);// Make sure all reads are done before we update the read index since
drivers/staging/hv/RndisFilter.c +1 -1
@@ -56,7 +56,7 @@ typedef struct _RNDIS_DEVICE {HANDLE RequestLock;LIST_ENTRY RequestList; -UCHAR HwMacAddr[HW_MACADDR_LEN ]; +unsigned char HwMacAddr[HW_MACADDR_LEN ]; }RNDIS_DEVICE ;
drivers/staging/hv/StorVsc.c +6 -6
@@ -63,8 +63,8 @@ typedef struct _STORVSC_DEVICE{// Each unique Port/Path/Target represents 1 channel ie scsi controller. In reality, the pathid, targetid is always 0 // and the port is set by us ULONG PortNumber; -UCHAR PathId; -UCHAR TargetId; +unsigned char PathId; +unsigned char TargetId;//LIST_ENTRY OutstandingRequestList; //HANDLE OutstandingRequestLock;
@@ -279,9 +279,9 @@ StorVscInitialize( storDriver->RequestExtSize =sizeof (STORVSC_REQUEST_EXTENSION );// Divide the ring buffer data size (which is 1 page less than the ring buffer size since that page is reserved for the ring buffer indices) -// by the max request size (which is VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER + VSTOR_PACKET + UINT64) +// by the max request size (which is VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER + VSTOR_PACKET + u64) storDriver->MaxOutstandingRequestsPerChannel = - ((storDriver->RingBufferSize -PAGE_SIZE ) /ALIGN_UP (MAX_MULTIPAGE_BUFFER_PACKET +sizeof (VSTOR_PACKET ) +sizeof (UINT64 ),sizeof (UINT64 ))); + ((storDriver->RingBufferSize -PAGE_SIZE ) /ALIGN_UP (MAX_MULTIPAGE_BUFFER_PACKET +sizeof (VSTOR_PACKET ) +sizeof (u64),sizeof (u64)));DPRINT_INFO (STORVSC ,"max io %u, currently %u\n" , storDriver->MaxOutstandingRequestsPerChannel,STORVSC_MAX_IO_REQUESTS );
@@ -909,8 +909,8 @@ StorVscOnChannelCallback(DEVICE_OBJECT *device = (DEVICE_OBJECT *)Context;STORVSC_DEVICE *storDevice;u32 bytesRecvd; -UINT64 requestId; -UCHAR packet[ALIGN_UP (sizeof (VSTOR_PACKET ),8 )]; +u64 requestId; +unsigned char packet[ALIGN_UP (sizeof (VSTOR_PACKET ),8 )];STORVSC_REQUEST_EXTENSION *request;DPRINT_ENTER (STORVSC );
drivers/staging/hv/include/ChannelMessages.h +6 -6
@@ -148,7 +148,7 @@ typedef struct _VMBUS_CHANNEL_OPEN_CHANN// // User-specific data to be passed along to the server endpoint. // -UCHAR UserData[MAX_USER_DEFINED_BYTES ]; +unsigned char UserData[MAX_USER_DEFINED_BYTES ]; }VMBUS_CHANNEL_OPEN_CHANNEL , *PVMBUS_CHANNEL_OPEN_CHANNEL ;
@@ -203,7 +203,7 @@ typedef struct _VMBUS_CHANNEL_GPADL_BODYVMBUS_CHANNEL_MESSAGE_HEADER Header;u32 MessageNumber;u32 Gpadl; -UINT64 Pfn[0 ]; +u64 Pfn[0 ]; }VMBUS_CHANNEL_GPADL_BODY , *PVMBUS_CHANNEL_GPADL_BODY ;
@@ -233,7 +233,7 @@ typedef struct _VMBUS_CHANNEL_VIEW_RANGE {VMBUS_CHANNEL_MESSAGE_HEADER Header;PHYSICAL_ADDRESS ViewRangeBase; -UINT64 ViewRangeLength; +u64 ViewRangeLength;u32 ChildRelId; }VMBUS_CHANNEL_VIEW_RANGE_ADD , *PVMBUS_CHANNEL_VIEW_RANGE_ADD ;
@@ -256,9 +256,9 @@ typedef struct _VMBUS_CHANNEL_INITIATE_CVMBUS_CHANNEL_MESSAGE_HEADER Header;u32 VMBusVersionRequested;u32 Padding2; -UINT64 InterruptPage; -UINT64 MonitorPage1; -UINT64 MonitorPage2; +u64 InterruptPage; +u64 MonitorPage1; +u64 MonitorPage2; }VMBUS_CHANNEL_INITIATE_CONTACT , *PVMBUS_CHANNEL_INITIATE_CONTACT ; typedef struct _VMBUS_CHANNEL_VERSION_RESPONSE
drivers/staging/hv/include/HvHalApi.h +2 -2
@@ -28,5 +28,5 @@// // Time in the hypervisor is measured in 100 nanosecond units // -typedef UINT64 HV_NANO100_TIME , *PHV_NANO100_TIME ; -typedef UINT64 HV_NANO100_DURATION , *PHV_NANO100_DURATION ; +typedef u64 HV_NANO100_TIME , *PHV_NANO100_TIME ; +typedef u64 HV_NANO100_DURATION , *PHV_NANO100_DURATION ;
drivers/staging/hv/include/HvHcApi.h +1 -1
@@ -44,7 +44,7 @@ typedef struct _HV_INPUT_POST_MESSAGEu32 Reserved;HV_MESSAGE_TYPE MessageType;u32 PayloadSize; -UINT64 Payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT ]; +u64 Payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT ]; }HV_INPUT_POST_MESSAGE , *PHV_INPUT_POST_MESSAGE ;
drivers/staging/hv/include/HvPtApi.h +11 -11
@@ -57,15 +57,15 @@ typedef enum _HV_GUEST_OS_MICROSOFT_IDStypedef union _HV_X64_MSR_GUEST_OS_ID_CONTENTS { -UINT64 AsUINT64; +u64 AsUINT64;struct { -UINT64 BuildNumber :16 ; -UINT64 ServiceVersion :8 ;// Service Pack, etc. -UINT64 MinorVersion :8 ; -UINT64 MajorVersion :8 ; -UINT64 OsId :8 ;// HV_GUEST_OS_MICROSOFT_IDS (If Vendor=MS) -UINT64 VendorId :16 ;// HV_GUEST_OS_VENDOR +u64 BuildNumber :16 ; +u64 ServiceVersion :8 ;// Service Pack, etc. +u64 MinorVersion :8 ; +u64 MajorVersion :8 ; +u64 OsId :8 ;// HV_GUEST_OS_MICROSOFT_IDS (If Vendor=MS) +u64 VendorId :16 ;// HV_GUEST_OS_VENDOR }; }HV_X64_MSR_GUEST_OS_ID_CONTENTS , *PHV_X64_MSR_GUEST_OS_ID_CONTENTS ;
@@ -76,11 +76,11 @@ typedef union _HV_X64_MSR_GUEST_OS_ID_COtypedef union _HV_X64_MSR_HYPERCALL_CONTENTS { -UINT64 AsUINT64; +u64 AsUINT64;struct { -UINT64 Enable :1 ; -UINT64 Reserved :11 ; -UINT64 GuestPhysicalAddress :52 ; +u64 Enable :1 ; +u64 Reserved :11 ; +u64 GuestPhysicalAddress :52 ; }; }HV_X64_MSR_HYPERCALL_CONTENTS , *PHV_X64_MSR_HYPERCALL_CONTENTS ;
drivers/staging/hv/include/HvSynicApi.h +26 -26
134 lines not on this page · raw message
drivers/staging/hv/include/HvTypes.h +1 -1
@@ -24,7 +24,7 @@#pragma once -typedef UINT64 HV_GPA , *PHV_GPA ; +typedef u64 HV_GPA , *PHV_GPA ;#define HV_X64_PAGE_SIZE (4096)#define HV_PAGE_SIZE HV_X64_PAGE_SIZE
drivers/staging/hv/include/List.h +2 -2
@@ -260,8 +260,8 @@ typedef DLIST_ENTRY *PLIST_ENTRY;#ifndef CONTAINING_RECORD #define CONTAINING_RECORD (address, type, field) ((type *)( \ - (PCHAR)(address) - \ - (PCHAR)(&((type *)0)->field))) + (char *)(address) - \ + (char *)(&((type *)0)->field)))#endif /* CONTAINING_RECORD */ #endif /* _LIST_H_ */
drivers/staging/hv/include/NetVscApi.h +3 -3
@@ -79,12 +79,12 @@ typedef struct _NETVSC_PACKET {union {struct { -UINT64 ReceiveCompletionTid; +u64 ReceiveCompletionTid;void * ReceiveCompletionContext;PFN_ON_SENDRECVCOMPLETION OnReceiveCompletion; } Recv;struct { -UINT64 SendCompletionTid; +u64 SendCompletionTid;void * SendCompletionContext;PFN_ON_SENDRECVCOMPLETION OnSendCompletion; } Send;
@@ -130,7 +130,7 @@ typedef struct _NETVSC_DRIVER_OBJECT {typedef struct _NETVSC_DEVICE_INFO { -UCHAR MacAddr[6 ]; +unsigned char MacAddr[6 ];BOOL LinkState;// 0 - link up, 1 - link down }NETVSC_DEVICE_INFO ;
drivers/staging/hv/include/StorVscApi.h +3 -3
@@ -80,7 +80,7 @@ typedef struct _STORVSC_REQUEST {u32 Status;u32 BytesXfer; -UCHAR * SenseBuffer; +unsigned char * SenseBuffer;u32 SenseBufferSize;void * Context;
@@ -118,8 +118,8 @@ typedef struct _STORVSC_DRIVER_OBJECT {typedef struct _STORVSC_DEVICE_INFO {ULONG PortNumber; -UCHAR PathId; -UCHAR TargetId; +unsigned char PathId; +unsigned char TargetId; }STORVSC_DEVICE_INFO ;//
drivers/staging/hv/include/VmbusApi.h +7 -7
@@ -51,7 +51,7 @@ typedef struct _DEVICE_OBJECT *PDEVICE_Otypedef struct _PAGE_BUFFER {u32 Length;u32 Offset; -UINT64 Pfn; +u64 Pfn; }PAGE_BUFFER ;// Multiple-page buffer
@@ -59,7 +59,7 @@ typedef struct _MULTIPAGE_BUFFER {// Length and Offset determines the # of pfns in the array u32 Length;u32 Offset; -UINT64 PfnArray[MAX_MULTIPAGE_BUFFER_COUNT ]; +u64 PfnArray[MAX_MULTIPAGE_BUFFER_COUNT ]; }MULTIPAGE_BUFFER ;//0x18 includes the proprietary packet header
@@ -108,7 +108,7 @@ typedef int (*VMBUS_CHANNEL_SEND_PACKET)PDEVICE_OBJECT Device, const void * Buffer, u32 BufferLen, - UINT64 RequestId, + u64 RequestId, u32 Type, u32 Flags );
@@ -119,7 +119,7 @@ typedef int (*VMBUS_CHANNEL_SEND_PACKET_u32 PageCount, void * Buffer, u32 BufferLen, - UINT64 RequestId + u64 RequestId ); typedef int (*VMBUS_CHANNEL_SEND_PACKET_MULTIPAGEBUFFER)(
@@ -127,7 +127,7 @@ typedef int (*VMBUS_CHANNEL_SEND_PACKET_MULTIPAGE_BUFFER *MultiPageBuffer, void * Buffer, u32 BufferLen, - UINT64 RequestId + u64 RequestId ); typedef int (*VMBUS_CHANNEL_RECV_PACKET)(
@@ -135,7 +135,7 @@ typedef int (*VMBUS_CHANNEL_RECV_PACKET)void * Buffer, u32 BufferLen, u32* BufferActualLen, - UINT64* RequestId + u64* RequestId ); typedef int (*VMBUS_CHANNEL_RECV_PACKET_PAW)(
@@ -143,7 +143,7 @@ typedef int (*VMBUS_CHANNEL_RECV_PACKET_void * Buffer, u32 BufferLen, u32* BufferActualLen, - UINT64* RequestId + u64* RequestId ); typedef int (*VMBUS_CHANNEL_ESTABLISH_GPADL)(
drivers/staging/hv/include/VmbusChannelInterface.h +3 -3
@@ -66,7 +66,7 @@ typedef structGUID InterfaceType;GUID InterfaceInstance; -UINT64 InterruptLatencyIn100nsUnits; +u64 InterruptLatencyIn100nsUnits;u32 InterfaceRevision;u32 ServerContextAreaSize;// in bytes u16 ChannelFlags;
@@ -79,7 +79,7 @@ typedef struct// struct { -UCHAR UserDefined[MAX_USER_DEFINED_BYTES ]; +unsigned char UserDefined[MAX_USER_DEFINED_BYTES ]; } Standard;//
@@ -90,7 +90,7 @@ typedef structstruct {u32 PipeMode; -UCHAR UserDefined[MAX_PIPE_USER_DEFINED_BYTES ]; +unsigned char UserDefined[MAX_PIPE_USER_DEFINED_BYTES ]; } Pipe; } u;u32 Padding;
drivers/staging/hv/include/VmbusPacketFormat.h +5 -5
@@ -83,7 +83,7 @@ typedef structu16 DataOffset8;u16 Length8;u16 Flags; -UINT64 TransactionId; +u64 TransactionId; }VMPACKET_DESCRIPTOR , *PVMPACKET_DESCRIPTOR ;typedef u32 PREVIOUS_PACKET_OFFSET , *PPREVIOUS_PACKET_OFFSET ;
@@ -168,7 +168,7 @@ typedef struct _GPA_RANGE {u32 ByteCount;u32 ByteOffset; -UINT64 PfnArray[0 ]; +u64 PfnArray[0 ]; }GPA_RANGE , *PGPA_RANGE ;
@@ -266,10 +266,10 @@ typedef struct _VMADDITIONAL_DATA {#endif -UINT64 TotalBytes; +u64 TotalBytes;u32 ByteOffset;u32 ByteCount; -UCHAR Data[1 ]; +unsigned char Data[1 ]; }VMADDITIONAL_DATA , *PVMADDITIONAL_DATA ;
@@ -287,7 +287,7 @@ typedef union { }VMPACKET_LARGEST_POSSIBLE_HEADER , *PVMPACKET_LARGEST_POSSIBLE_HEADER ;#define VMPACKET_DATA_START_ADDRESS (__packet) \ - (void *)(((PUCHAR)__packet) + ((PVMPACKET_DESCRIPTOR)__packet)->DataOffset8 * 8) + (void *)(((unsigned char *)__packet) + ((PVMPACKET_DESCRIPTOR)__packet)->DataOffset8 * 8)#define VMPACKET_DATA_LENGTH (__packet) \ ((((PVMPACKET_DESCRIPTOR)__packet)->Length8 - ((PVMPACKET_DESCRIPTOR)__packet)->DataOffset8) * 8)
drivers/staging/hv/include/osd.h +4 -18
@@ -97,28 +97,15 @@ typedef struct _DLIST_ENTRY {// // unsigned types // -#ifdef __x86_64__ -typedef unsigned long UINT64 ; -#else -typedef unsigned long long UINT64 ; -#endif typedef unsigned long long ULONGLONG ;typedef unsigned int ULONG ;typedef unsigned short USHORT ; -typedef unsigned char UCHAR ;// // signed types // -#ifdef __x86_64__ -typedef long INT64 ; -#else -typedef long long INT64 ; -#endif -typedef int LONG ; -typedef char CHAR ;typedef long long LONGLONG ;//
@@ -130,7 +117,6 @@ typedef unsigned char BOOL;typedef unsigned char BOOLEAN ;typedef void *HANDLE ;typedef u32 DWORD ; -typedef char *PCHAR ;typedef unsigned char BYTE ;typedef unsigned long ULONG_PTR ;
@@ -150,13 +136,13 @@ typedef void (*PFN_TIMER_CALLBACK)(void* __asm__ __volatile__("rdmsr" \ :"=a" (l),"=d" (h) \ :"c" (reg)); \ - v = (((UINT64 )h) <<32 ) | l; \ + v = (((u64 )h) <<32 ) | l; \ } #define WRMSR(reg, v) { \ u32 h, l; \ - l = (u32)(((UINT64)(v)) & 0xFFFFFFFF); \ - h = (u32)((((UINT64)(v)) >> 32) & 0xFFFFFFFF); \ + l = (u32)(((u64)(v)) & 0xFFFFFFFF); \ + h = (u32)((((u64)(v)) >> 32) & 0xFFFFFFFF); \ __asm__ __volatile__("wrmsr" \ : /* no outputs */ \ : "c" (reg), "a" (l), "d" (h)); \
@@ -172,7 +158,7 @@ typedef void (*PFN_TIMER_CALLBACK)(void* #define WRMSR(reg, v) \ __asm__ __volatile__("wrmsr" \ : /* no outputs */ \ - : "c" (reg), "A" ((UINT64)v)) + : "c" (reg), "A" ((u64)v))#endif
drivers/staging/hv/include/rndis.h +4 -4
@@ -811,19 +811,19 @@ typedef __struct_bcount(MessageLength) s// get pointer to info buffer with message pointer #define MESSAGE_TO_INFO_BUFFER (Message) \ - (((PUCHAR)(Message)) + Message->InformationBufferOffset) + (((unsigned char *)(Message)) + Message->InformationBufferOffset)// get pointer to status buffer with message pointer #define MESSAGE_TO_STATUS_BUFFER (Message) \ - (((PUCHAR)(Message)) + Message->StatusBufferOffset) + (((unsigned char *)(Message)) + Message->StatusBufferOffset)// get pointer to OOBD buffer with message pointer #define MESSAGE_TO_OOBD_BUFFER (Message) \ - (((PUCHAR)(Message)) + Message->OOBDataOffset) + (((unsigned char *)(Message)) + Message->OOBDataOffset)// get pointer to data buffer with message pointer #define MESSAGE_TO_DATA_BUFFER (Message) \ - (((PUCHAR)(Message)) + Message->PerPacketInfoOffset) + (((unsigned char *)(Message)) + Message->PerPacketInfoOffset)// get pointer to contained message from NDIS_MESSAGE pointer #define RNDIS_MESSAGE_PTR_TO_MESSAGE_PTR (RndisMessage) \
drivers/staging/hv/include/vstorage.h +17 -17
@@ -94,7 +94,7 @@#define MAX_TRANSFER_LENGTH 0x40000#define DEFAULT_PACKET_SIZE (sizeof(VMDATA_GPA_DIRECT) + \ sizeof(VSTOR_PACKET) + \ - (sizeof(UINT64) * (MAX_TRANSFER_LENGTH / PAGE_SIZE))) + (sizeof(u64) * (MAX_TRANSFER_LENGTH / PAGE_SIZE)))
@@ -142,28 +142,28 @@ C_ASSERT(SENSE_BUFFER_SIZE == 0x12);typedef struct {USHORT Length; -UCHAR SrbStatus; -UCHAR ScsiStatus; +unsigned char SrbStatus; +unsigned char ScsiStatus; -UCHAR PortNumber; -UCHAR PathId; -UCHAR TargetId; -UCHAR Lun; - -UCHAR CdbLength; -UCHAR SenseInfoLength; -UCHAR DataIn; -UCHAR Reserved; +unsigned char PortNumber; +unsigned char PathId; +unsigned char TargetId; +unsigned char Lun; + +unsigned char CdbLength; +unsigned char SenseInfoLength; +unsigned char DataIn; +unsigned char Reserved;ULONG DataTransferLength;union { -UCHAR Cdb[CDB16GENERIC_LENGTH ]; +unsigned char Cdb[CDB16GENERIC_LENGTH ]; -UCHAR SenseData[SENSE_BUFFER_SIZE ]; +unsigned char SenseData[SENSE_BUFFER_SIZE ]; -UCHAR ReservedArray[MAX_DATA_BUFFER_LENGTH_WITH_PADDING ]; +unsigned char ReservedArray[MAX_DATA_BUFFER_LENGTH_WITH_PADDING ]; }; }VMSCSI_REQUEST , *PVMSCSI_REQUEST ;
@@ -179,8 +179,8 @@ C_ASSERT((sizeof(VMSCSI_REQUEST) % 4) == typedef struct { USHORT ProtocolVersion; - UCHAR PathId; - UCHAR TargetId; + unsigned char PathId; + unsigned char TargetId; // // Note: port number is only really known on the client side
PATCH 24/54 Staging: hv: remove USHORT typedef
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
The USHORT typedef is now removed from the Hyper-V driver code.
--- drivers/staging/hv/include/osd.h | 1 - drivers/staging/hv/include/vstorage.h | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-)
drivers/staging/hv/include/osd.h +0 -1
@@ -100,7 +100,6 @@ typedef struct _DLIST_ENTRY {typedef unsigned long long ULONGLONG ;typedef unsigned int ULONG ; -typedef unsigned short USHORT ;// // signed types
drivers/staging/hv/include/vstorage.h +4 -4
@@ -141,7 +141,7 @@ C_ASSERT(SENSE_BUFFER_SIZE == 0x12); typedef struct { - USHORT Length; + unsigned short Length; unsigned char SrbStatus; unsigned char ScsiStatus;
@@ -178,7 +178,7 @@ C_ASSERT((sizeof(VMSCSI_REQUEST) % 4) == typedef struct { - USHORT ProtocolVersion; + unsigned short ProtocolVersion; unsigned char PathId; unsigned char TargetId;
@@ -213,7 +213,7 @@ typedef struct// Major (MSW) and minor (LSW) version numbers. // -USHORT MajorMinor; +unsigned short MajorMinor;//
@@ -222,7 +222,7 @@ typedef struct// indicate incompatibility--but it does indicate mismatched builds. // -USHORT Revision; +unsigned short Revision; }VMSTORAGE_PROTOCOL_VERSION , *PVMSTORAGE_PROTOCOL_VERSION ;
PATCH 25/54 Staging: hv: remove ULONGLONG and LONGLONG typedefs
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
The ULONGLONG and LONGLONG typedefs are now removed from the Hyper-V driver code.
--- drivers/staging/hv/include/VmbusPacketFormat.h | 2 +- drivers/staging/hv/include/osd.h | 3 --- drivers/staging/hv/include/vstorage.h | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-)
drivers/staging/hv/include/osd.h +0 -3
@@ -97,15 +97,12 @@ typedef struct _DLIST_ENTRY {// // unsigned types // - -typedef unsigned long long ULONGLONG ;typedef unsigned int ULONG ;// // signed types // typedef int LONG ; -typedef long long LONGLONG ;// // Other types
drivers/staging/hv/include/VmbusPacketFormat.h +1 -1
@@ -44,7 +44,7 @@ typedef structvolatile u32 In;// Offset in bytes from the ring base volatile u32 Out;// Offset in bytes from the ring base }; -volatile LONGLONG InOut; +volatile long long InOut; };//
drivers/staging/hv/include/vstorage.h +1 -1
@@ -196,7 +196,7 @@ typedef struct// vendor specific data in the inquirydata // -ULONGLONG UniqueId; +unsigned long long UniqueId; }VMSTORAGE_CHANNEL_PROPERTIES , *PVMSTORAGE_CHANNEL_PROPERTIES ;
PATCH 26/54 Staging: hv: remove ULONG_PTR typedef
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
The ULONG_PTR typedef is now removed from the Hyper-V driver code.
--- drivers/staging/hv/Channel.c | 4 ++-- drivers/staging/hv/Connection.c | 8 ++++---- drivers/staging/hv/Hv.c | 8 ++++---- drivers/staging/hv/NetVsc.c | 34 +++++++++++++++++----------------- drivers/staging/hv/RndisFilter.c | 16 ++++++++-------- drivers/staging/hv/StorVsc.c | 16 ++++++++-------- drivers/staging/hv/include/osd.h | 8 +++----- drivers/staging/hv/netvsc_drv.c | 4 ++-- drivers/staging/hv/osd.c | 8 ++++---- 9 files changed, 52 insertions(+), 54 deletions(-)
drivers/staging/hv/Channel.c +2 -2
@@ -228,9 +228,9 @@ VmbusChannelOpen( out =PageAlloc ((SendRingBufferSize + RecvRingBufferSize) >>PAGE_SHIFT );//out = MemAllocZeroed(sendRingBufferSize + recvRingBufferSize); ASSERT (out); -ASSERT (((ULONG_PTR )out & (PAGE_SIZE -1 )) ==0 ); +ASSERT (((unsigned long )out & (PAGE_SIZE -1 )) ==0 ); - in = (void *)((ULONG_PTR )out + SendRingBufferSize); + in = (void *)((unsigned long )out + SendRingBufferSize); NewChannel->RingBufferPages = out; NewChannel->RingBufferPageCount = (SendRingBufferSize + RecvRingBufferSize) >>PAGE_SHIFT ;
drivers/staging/hv/Connection.c +4 -4
@@ -79,7 +79,7 @@ VmbusConnect( } gVmbusConnection.RecvInterruptPage = gVmbusConnection.InterruptPage; - gVmbusConnection.SendInterruptPage = (void *)((ULONG_PTR )gVmbusConnection.InterruptPage + (PAGE_SIZE >>1 )); + gVmbusConnection.SendInterruptPage = (void *)((unsigned long )gVmbusConnection.InterruptPage + (PAGE_SIZE >>1 ));// Setup the monitor notification facility. The 1st page for parent->child and the 2nd page for child->parent gVmbusConnection.MonitorPages =PageAlloc (2 );
@@ -103,7 +103,7 @@ VmbusConnect( msg->VMBusVersionRequested =VMBUS_REVISION_NUMBER ; msg->InterruptPage =GetPhysicalAddress (gVmbusConnection.InterruptPage); msg->MonitorPage1 =GetPhysicalAddress (gVmbusConnection.MonitorPages); - msg->MonitorPage2 =GetPhysicalAddress ((void *)((ULONG_PTR )gVmbusConnection.MonitorPages +PAGE_SIZE )); + msg->MonitorPage2 =GetPhysicalAddress ((void *)((unsigned long )gVmbusConnection.MonitorPages +PAGE_SIZE ));// Add to list before we send the request since we may receive the response // before returning from this routine
@@ -294,7 +294,7 @@ VmbusProcessChannelEvent( ) {VMBUS_CHANNEL * channel; -u32 relId = (u32 )(ULONG_PTR )context; +u32 relId = (u32 )(unsigned long )context;ASSERT (relId >0 );
@@ -362,7 +362,7 @@ VmbusOnEvents( {//QueueWorkItem(VmbusProcessEvent, (void*)relid); //ret = WorkQueueQueueWorkItem(gVmbusConnection.workQueue, VmbusProcessChannelEvent, (void*)relid); -VmbusProcessChannelEvent ((void *)(ULONG_PTR )relid); +VmbusProcessChannelEvent ((void *)(unsigned long )relid); } } }
drivers/staging/hv/Hv.c +4 -4
@@ -233,7 +233,7 @@ HvInit (int maxLeaf;HV_X64_MSR_HYPERCALL_CONTENTS hypercallMsr;void * virtAddr=0 ; -ULONG_PTR physAddr=0 ; +unsigned long physAddr=0 ;DPRINT_ENTER (VMBUS );
@@ -311,7 +311,7 @@ HvInit ( goto Cleanup; } - gHvContext.SignalEventParam = (PHV_INPUT_SIGNAL_EVENT )(ALIGN_UP ((ULONG_PTR )gHvContext.SignalEventBuffer,HV_HYPERCALL_PARAM_ALIGN )); + gHvContext.SignalEventParam = (PHV_INPUT_SIGNAL_EVENT )(ALIGN_UP ((unsigned long )gHvContext.SignalEventBuffer,HV_HYPERCALL_PARAM_ALIGN )); gHvContext.SignalEventParam->ConnectionId.Asu32 =0 ; gHvContext.SignalEventParam->ConnectionId.u.Id =VMBUS_EVENT_CONNECTION_ID ; gHvContext.SignalEventParam->FlagNumber =0 ;
@@ -407,14 +407,14 @@ HvPostMessage(PHV_INPUT_POST_MESSAGE alignedMsg;HV_STATUS status; -ULONG_PTR addr; +unsigned long addr;if (payloadSize >HV_MESSAGE_PAYLOAD_BYTE_COUNT ) {return -1 ; } - addr = (ULONG_PTR )MemAllocAtomic (sizeof (struct alignedInput )); + addr = (unsigned long )MemAllocAtomic (sizeof (struct alignedInput ));if (!addr) {
drivers/staging/hv/include/osd.h +3 -5
@@ -115,8 +115,6 @@ typedef void* HANDLE;typedef u32 DWORD ;typedef unsigned char BYTE ; -typedef unsigned long ULONG_PTR ; -typedef struct {unsigned char Data[16 ]; }GUID ;
@@ -217,12 +215,12 @@ extern void SpinlockRelease(HANDLE hSpin#define GetVirtualAddress Physical2LogicalAddr -void *Physical2LogicalAddr (ULONG_PTR PhysAddr); +void *Physical2LogicalAddr (unsigned long PhysAddr);#define GetPhysicalAddress Logical2PhysicalAddr -ULONG_PTR Logical2PhysicalAddr (void * LogicalAddr); +unsigned long Logical2PhysicalAddr (void * LogicalAddr); -ULONG_PTR Virtual2Physical (void * VirtAddr); +unsigned long Virtual2Physical (void * VirtAddr);void *PageMapVirtualAddress (unsigned long Pfn);void PageUnmapVirtualAddress (void * VirtAddr);
drivers/staging/hv/NetVsc.c +17 -17
@@ -298,7 +298,7 @@ NetVscInitializeReceiveBufferWithNetVsp( ret =-1 ; goto Cleanup; } -ASSERT (((ULONG_PTR )netDevice->ReceiveBuffer & (PAGE_SIZE -1 )) ==0 );// page-aligned buffer +ASSERT (((unsigned long )netDevice->ReceiveBuffer & (PAGE_SIZE -1 )) ==0 );// page-aligned buffer DPRINT_INFO (NETVSC ,"Establishing receive buffer's GPADL..." );
@@ -333,7 +333,7 @@ NetVscInitializeReceiveBufferWithNetVsp( ret = Device->Driver->VmbusChannelInterface.SendPacket (Device, initPacket,sizeof (NVSP_MESSAGE ), - (ULONG_PTR )initPacket, + (unsigned long )initPacket, VmbusPacketTypeDataInBand,VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED );if (ret !=0 )
@@ -425,7 +425,7 @@ NetVscInitializeSendBufferWithNetVsp( ret =-1 ; goto Cleanup; } -ASSERT (((ULONG_PTR )netDevice->SendBuffer & (PAGE_SIZE -1 )) ==0 );// page-aligned buffer +ASSERT (((unsigned long )netDevice->SendBuffer & (PAGE_SIZE -1 )) ==0 );// page-aligned buffer DPRINT_INFO (NETVSC ,"Establishing send buffer's GPADL..." );
@@ -460,7 +460,7 @@ NetVscInitializeSendBufferWithNetVsp( ret = Device->Driver->VmbusChannelInterface.SendPacket (Device, initPacket,sizeof (NVSP_MESSAGE ), - (ULONG_PTR )initPacket, + (unsigned long )initPacket, VmbusPacketTypeDataInBand,VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED );if (ret !=0 )
@@ -521,7 +521,7 @@ NetVscDestroyReceiveBuffer( ret = NetDevice->Device->Driver->VmbusChannelInterface.SendPacket (NetDevice->Device, revokePacket,sizeof (NVSP_MESSAGE ), - (ULONG_PTR )revokePacket, + (unsigned long )revokePacket, VmbusPacketTypeDataInBand,0 );// If we failed here, we might as well return and have a leak rather than continue and a bugchk
@@ -602,7 +602,7 @@ NetVscDestroySendBuffer( ret = NetDevice->Device->Driver->VmbusChannelInterface.SendPacket (NetDevice->Device, revokePacket,sizeof (NVSP_MESSAGE ), - (ULONG_PTR )revokePacket, + (unsigned long )revokePacket, VmbusPacketTypeDataInBand,0 );// If we failed here, we might as well return and have a leak rather than continue and a bugchk
@@ -681,7 +681,7 @@ NetVscConnectToVsp( ret = Device->Driver->VmbusChannelInterface.SendPacket (Device, initPacket,sizeof (NVSP_MESSAGE ), - (ULONG_PTR )initPacket, + (unsigned long )initPacket, VmbusPacketTypeDataInBand,VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED );
@@ -728,7 +728,7 @@ NetVscConnectToVsp( ret = Device->Driver->VmbusChannelInterface.SendPacket (Device, initPacket,sizeof (NVSP_MESSAGE ), - (ULONG_PTR )initPacket, + (unsigned long )initPacket, VmbusPacketTypeDataInBand,0 );if (ret !=0 )
@@ -1000,7 +1000,7 @@ NetVscOnSendCompletion(return ; } - nvspPacket = (NVSP_MESSAGE *)((ULONG_PTR )Packet + (Packet->DataOffset8 <<3 )); + nvspPacket = (NVSP_MESSAGE *)((unsigned long )Packet + (Packet->DataOffset8 <<3 ));DPRINT_DBG (NETVSC ,"send completion packet - type %d" , nvspPacket->Header.MessageType);
@@ -1015,7 +1015,7 @@ NetVscOnSendCompletion(else if (nvspPacket->Header.MessageType == NvspMessage1TypeSendRNDISPacketComplete) {// Get the send context - nvscPacket = (NETVSC_PACKET *)(ULONG_PTR )Packet->TransactionId; + nvscPacket = (NETVSC_PACKET *)(unsigned long )Packet->TransactionId;ASSERT (nvscPacket);// Notify the layer above us
@@ -1072,14 +1072,14 @@ NetVscOnSend( Packet->PageBufferCount, &sendMessage,sizeof (NVSP_MESSAGE ), - (ULONG_PTR)Packet); + (unsigned long)Packet); }else { ret = Device->Driver->VmbusChannelInterface.SendPacket (Device, &sendMessage,sizeof (NVSP_MESSAGE ), - (ULONG_PTR )Packet, + (unsigned long )Packet, VmbusPacketTypeDataInBand,VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED );
@@ -1109,8 +1109,8 @@ NetVscOnReceive(NVSP_MESSAGE *nvspPacket;NETVSC_PACKET *netvscPacket=NULL ;LIST_ENTRY * entry; -ULONG_PTR start; -ULONG_PTR end, endVirtual; +unsigned long start; +unsigned long end, endVirtual;//NETVSC_DRIVER_OBJECT *netvscDriver; XFERPAGE_PACKET *xferpagePacket=NULL ;LIST_ENTRY listHead;
@@ -1136,7 +1136,7 @@ NetVscOnReceive(return ; } - nvspPacket = (NVSP_MESSAGE *)((ULONG_PTR )Packet + (Packet->DataOffset8 <<3 )); + nvspPacket = (NVSP_MESSAGE *)((unsigned long )Packet + (Packet->DataOffset8 <<3 ));// Make sure this is a valid nvsp packet if (nvspPacket->Header.MessageType != NvspMessage1TypeSendRNDISPacket )
@@ -1230,10 +1230,10 @@ NetVscOnReceive( netvscPacket->PageBuffers[0 ].Length = vmxferpagePacket->Ranges[i].ByteCount; - start =GetPhysicalAddress ((void *)((ULONG_PTR )netDevice->ReceiveBuffer + vmxferpagePacket->Ranges[i].ByteOffset)); + start =GetPhysicalAddress ((void *)((unsigned long )netDevice->ReceiveBuffer + vmxferpagePacket->Ranges[i].ByteOffset)); netvscPacket->PageBuffers[0 ].Pfn = start >>PAGE_SHIFT ; - endVirtual = (ULONG_PTR )netDevice->ReceiveBuffer + endVirtual = (unsigned long )netDevice->ReceiveBuffer + vmxferpagePacket->Ranges[i].ByteOffset + vmxferpagePacket->Ranges[i].ByteCount -1 ; end =GetPhysicalAddress ((void *)endVirtual);
drivers/staging/hv/netvsc_drv.c +2 -2
@@ -386,7 +386,7 @@ Desc: Send completion processingstatic void netvsc_xmit_completion (void *context) {NETVSC_PACKET *packet = (NETVSC_PACKET *)context; -struct sk_buff *skb = (struct sk_buff *)(ULONG_PTR )packet->Completion.Send.SendCompletionTid; +struct sk_buff *skb = (struct sk_buff *)(unsigned long )packet->Completion.Send.SendCompletionTid;struct net_device * net;DPRINT_ENTER (NETVSC_DRV );
@@ -478,7 +478,7 @@ static int netvsc_start_xmit (struct sk_// Set the completion routine packet->Completion.Send.OnSendCompletion = netvsc_xmit_completion; packet->Completion.Send.SendCompletionContext = packet; - packet->Completion.Send.SendCompletionTid = (ULONG_PTR )skb; + packet->Completion.Send.SendCompletionTid = (unsigned long )skb; retry_send: ret = net_drv_obj->OnSend (&net_device_ctx->device_ctx->device_obj, packet);
drivers/staging/hv/osd.c +4 -4
@@ -407,23 +407,23 @@ void SpinlockClose(HANDLE hSpin)kfree (spin); } -void *Physical2LogicalAddr (ULONG_PTR PhysAddr) +void *Physical2LogicalAddr (unsigned long PhysAddr) {void * logicalAddr =phys_to_virt (PhysAddr);BUG_ON (!virt_addr_valid (logicalAddr));return logicalAddr; } -ULONG_PTR Logical2PhysicalAddr (void * LogicalAddr) +unsigned long Logical2PhysicalAddr (void * LogicalAddr) {BUG_ON (!virt_addr_valid (LogicalAddr));return virt_to_phys (LogicalAddr); } -ULONG_PTR Virtual2Physical (void * VirtAddr) +unsigned long Virtual2Physical (void * VirtAddr) { -ULONG_PTR pfn =vmalloc_to_pfn (VirtAddr); +unsigned long pfn =vmalloc_to_pfn (VirtAddr);return pfn <<PAGE_SHIFT ; }
drivers/staging/hv/RndisFilter.c +8 -8
@@ -362,11 +362,11 @@ RndisFilterSendRequest( packet->PageBuffers[0 ].Pfn =GetPhysicalAddress (&Request->RequestMessage) >>PAGE_SHIFT ; packet->PageBuffers[0 ].Length = Request->RequestMessage.MessageLength; - packet->PageBuffers[0 ].Offset = (ULONG_PTR )&Request->RequestMessage & (PAGE_SIZE -1 ); + packet->PageBuffers[0 ].Offset = (unsigned long )&Request->RequestMessage & (PAGE_SIZE -1 ); packet->Completion.Send.SendCompletionContext = Request;//packet; packet->Completion.Send.OnSendCompletion = RndisFilterOnSendRequestCompletion; - packet->Completion.Send.SendCompletionTid = (ULONG_PTR )Device; + packet->Completion.Send.SendCompletionTid = (unsigned long )Device; ret = gRndisFilter.InnerDriver.OnSend (Device->NetDevice->Device, packet);DPRINT_EXIT (NETVSC );
@@ -523,7 +523,7 @@ RndisFilterOnReceive( rndisHeader = (RNDIS_MESSAGE *)PageMapVirtualAddress (Packet->PageBuffers[0 ].Pfn); - rndisHeader = (void *)((ULONG_PTR )rndisHeader + Packet->PageBuffers[0 ].Offset); + rndisHeader = (void *)((unsigned long )rndisHeader + Packet->PageBuffers[0 ].Offset);// Make sure we got a valid rndis message // FIXME: There seems to be a bug in set completion msg where its MessageLength is 16 bytes but
@@ -531,7 +531,7 @@ RndisFilterOnReceive(#if 0 if ( Packet->TotalDataBufferLength != rndisHeader->MessageLength ) { -PageUnmapVirtualAddress ((void *)(ULONG_PTR )rndisHeader - Packet->PageBuffers[0 ].Offset); +PageUnmapVirtualAddress ((void *)(unsigned long )rndisHeader - Packet->PageBuffers[0 ].Offset);DPRINT_ERR (NETVSC ,"invalid rndis message? (expected %u bytes got %u)...dropping this message!" , rndisHeader->MessageLength, Packet->TotalDataBufferLength);
@@ -548,7 +548,7 @@ RndisFilterOnReceive(memcpy (&rndisMessage, rndisHeader, (rndisHeader->MessageLength >sizeof (RNDIS_MESSAGE ))?sizeof (RNDIS_MESSAGE ):rndisHeader->MessageLength); -PageUnmapVirtualAddress ((void *)(ULONG_PTR )rndisHeader - Packet->PageBuffers[0 ].Offset); +PageUnmapVirtualAddress ((void *)(unsigned long )rndisHeader - Packet->PageBuffers[0 ].Offset);DumpRndisMessage (&rndisMessage);
@@ -633,7 +633,7 @@ RndisFilterQueryDevice( }memcpy (Result, - (void *)((ULONG_PTR )queryComplete + queryComplete->InformationBufferOffset), + (void *)((unsigned long )queryComplete + queryComplete->InformationBufferOffset), queryComplete->InformationBufferLength); *ResultSize = queryComplete->InformationBufferLength;
@@ -703,7 +703,7 @@ RndisFilterSetPacketFilter( set->InformationBufferLength =sizeof (u32); set->InformationBufferOffset =sizeof (RNDIS_SET_REQUEST ); -memcpy ((void *)(ULONG_PTR )set +sizeof (RNDIS_SET_REQUEST ), &NewFilter,sizeof (u32)); +memcpy ((void *)(unsigned long )set +sizeof (RNDIS_SET_REQUEST ), &NewFilter,sizeof (u32)); ret =RndisFilterSendRequest (Device, request);if (ret !=0 )
@@ -1113,7 +1113,7 @@ RndisFilterOnSend( Packet->IsDataPacket = TRUE; Packet->PageBuffers[0 ].Pfn =GetPhysicalAddress (rndisMessage) >>PAGE_SHIFT ; - Packet->PageBuffers[0 ].Offset = (ULONG_PTR )rndisMessage & (PAGE_SIZE -1 ); + Packet->PageBuffers[0 ].Offset = (unsigned long )rndisMessage & (PAGE_SIZE -1 ); Packet->PageBuffers[0 ].Length = rndisMessageSize;// Save the packet send completion and context
drivers/staging/hv/StorVsc.c +8 -8
@@ -388,7 +388,7 @@ static int StorVscChannelInit(DEVICE_OBJ ret = Device->Driver->VmbusChannelInterface.SendPacket (Device, vstorPacket,sizeof (VSTOR_PACKET ), - (ULONG_PTR )request, + (unsigned long )request, VmbusPacketTypeDataInBand,VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED );if ( ret !=0 )
@@ -418,7 +418,7 @@ static int StorVscChannelInit(DEVICE_OBJ ret = Device->Driver->VmbusChannelInterface.SendPacket (Device, vstorPacket,sizeof (VSTOR_PACKET ), - (ULONG_PTR )request, + (unsigned long )request, VmbusPacketTypeDataInBand,VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED );if ( ret !=0 )
@@ -447,7 +447,7 @@ static int StorVscChannelInit(DEVICE_OBJ ret = Device->Driver->VmbusChannelInterface.SendPacket (Device, vstorPacket,sizeof (VSTOR_PACKET ), - (ULONG_PTR )request, + (unsigned long )request, VmbusPacketTypeDataInBand,VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED );
@@ -481,7 +481,7 @@ static int StorVscChannelInit(DEVICE_OBJ ret = Device->Driver->VmbusChannelInterface.SendPacket (Device, vstorPacket,sizeof (VSTOR_PACKET ), - (ULONG_PTR )request, + (unsigned long )request, VmbusPacketTypeDataInBand,VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED );
@@ -650,7 +650,7 @@ StorVscOnHostReset( ret = Device->Driver->VmbusChannelInterface.SendPacket (Device, vstorPacket,sizeof (VSTOR_PACKET ), - (ULONG_PTR )&storDevice->ResetRequest, + (unsigned long )&storDevice->ResetRequest, VmbusPacketTypeDataInBand,VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED );if (ret !=0 )
@@ -752,14 +752,14 @@ StorVscOnIORequest( &requestExtension->Request->DataBuffer, vstorPacket,sizeof (VSTOR_PACKET ), - (ULONG_PTR)requestExtension); + (unsigned long)requestExtension); }else { ret = Device->Driver->VmbusChannelInterface.SendPacket (Device, vstorPacket,sizeof (VSTOR_PACKET ), - (ULONG_PTR )requestExtension, + (unsigned long )requestExtension, VmbusPacketTypeDataInBand,VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED ); }
@@ -938,7 +938,7 @@ StorVscOnChannelCallback(//ASSERT(bytesRecvd == sizeof(VSTOR_PACKET)); - request = (STORVSC_REQUEST_EXTENSION *)(ULONG_PTR )requestId; + request = (STORVSC_REQUEST_EXTENSION *)(unsigned long )requestId;ASSERT (request);//if (vstorPacket.Flags & SYNTHETIC_FLAG)
PATCH 27/54 Staging: hv: remove ULONG and LONG typedefs
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
The ULONG and LONG typedefs are now removed from the Hyper-V driver code.
--- drivers/staging/hv/StorVsc.c | 2 +- drivers/staging/hv/include/StorVscApi.h | 2 +- drivers/staging/hv/include/osd.h | 10 ---------- drivers/staging/hv/include/vstorage.h | 12 ++++++------ 4 files changed, 8 insertions(+), 18 deletions(-)
drivers/staging/hv/include/osd.h +0 -10
@@ -95,16 +95,6 @@ typedef struct _DLIST_ENTRY { }DLIST_ENTRY ;// -// unsigned types -// -typedef unsigned int ULONG ; - -// -// signed types -// -typedef int LONG ; - -// // Other types // typedef unsigned long SIZE_T ;
drivers/staging/hv/include/StorVscApi.h +1 -1
@@ -117,7 +117,7 @@ typedef struct _STORVSC_DRIVER_OBJECT { }STORVSC_DRIVER_OBJECT ;typedef struct _STORVSC_DEVICE_INFO { -ULONG PortNumber; +unsigned long PortNumber;unsigned char PathId;unsigned char TargetId; }STORVSC_DEVICE_INFO ;
drivers/staging/hv/include/vstorage.h +6 -6
@@ -155,7 +155,7 @@ typedef structunsigned char DataIn;unsigned char Reserved; -ULONG DataTransferLength; +unsigned long DataTransferLength;union {
@@ -185,11 +185,11 @@ typedef struct// // Note: port number is only really known on the client side // -ULONG PortNumber; +unsigned long PortNumber; -ULONG Flags; +unsigned long Flags; -ULONG MaxTransferBytes; +unsigned long MaxTransferBytes;// // This id is unique for each channel and will correspond with
@@ -249,13 +249,13 @@ typedef struct _VSTOR_PACKET// Flags - see below for values // -ULONG Flags; +unsigned long Flags;// // Status of the request returned from the server side. // -ULONG Status; +unsigned long Status;// // Data payload area
drivers/staging/hv/StorVsc.c +1 -1
@@ -62,7 +62,7 @@ typedef struct _STORVSC_DEVICE{// Each unique Port/Path/Target represents 1 channel ie scsi controller. In reality, the pathid, targetid is always 0 // and the port is set by us -ULONG PortNumber; +unsigned long PortNumber;unsigned char PathId;unsigned char TargetId;
Re: [patch 27/54] Staging: hv: remove ULONG and LONG typedefs
Quoted 5 lines · Greg Kroah-Hartman
From: Greg Kroah-Hartman <[email protected]>
The ULONG and LONG typedefs are now removed from the Hyper-V driver code
This conversion is not equivalent:
drivers/staging/hv/include/osd.h typedef struct _DLIST_ENTRY { · line 105
Quoted 9 lines
//
drivers/staging/hv/include/osd.h +0
-8-// unsigned types -// -typedef unsigned int ULONG ; - -// -// signed types -// -typedef int LONG ;
- // redefine the world, because we can
- extern char *i;
- void abs(unsigned u);
- #define FALSE (2)
;-)
drivers/staging/hv/include/StorVscApi.h typedef struct _STORVSC_DRIVER_OBJECT { · line 123
Quoted 11 lines
drivers/staging/hv/include/StorVscApi.h +1
-1@@ -117,7 +117,7 @@ typedef struct _STORVSC_DRIVER_OBJECT { }STORVSC_DRIVER_OBJECT ;typedef struct _STORVSC_DEVICE_INFO { -ULONG PortNumber; +unsigned long PortNumber;unsigned char PathId;unsigned char TargetId; }STORVSC_DEVICE_INFO ;
If this is an API (as the header file name suggests), you just changed it. Same for the other hunks in this patch.
Arnd <><
RE: [patch 27/54] Staging: hv: remove ULONG and LONG typedefs
Arnd,
Thanks for this and the other mails reviewing the code.
My TODO list keeps on getting bigger :). I will check into all of these and correct them.
Keep them coming!
Thanks!
Hank.
-----Original Message-----
From: Arnd Bergmann [mailto:[email protected]]
Sent: Monday, July 20, 2009 5:00 PM
To: [email protected]
Cc: Greg Kroah-Hartman; [email protected]; [email protected]; [email protected]; Greg KH; Sam Ramji; Haiyang Zhang; Hank Janssen; [email protected]
Subject: Re: [patch 27/54] Staging: hv: remove ULONG and LONG typedefs
Quoted 5 lines · Greg Kroah-Hartman
From: Greg Kroah-Hartman <[email protected]>
The ULONG and LONG typedefs are now removed from the Hyper-V driver code
This conversion is not equivalent:
drivers/staging/hv/include/osd.h typedef struct _DLIST_ENTRY { · line 105
Quoted 9 lines
//
drivers/staging/hv/include/osd.h +0
-8-// unsigned types -// -typedef unsigned int ULONG ; - -// -// signed types -// -typedef int LONG ;
- // redefine the world, because we can
- extern char *i;
- void abs(unsigned u);
- #define FALSE (2)
;-)
drivers/staging/hv/include/StorVscApi.h typedef struct _STORVSC_DRIVER_OBJECT { · line 123
Quoted 11 lines
drivers/staging/hv/include/StorVscApi.h +1
-1@@ -117,7 +117,7 @@ typedef struct _STORVSC_DRIVER_OBJECT { }STORVSC_DRIVER_OBJECT ;typedef struct _STORVSC_DEVICE_INFO { -ULONG PortNumber; +unsigned long PortNumber;unsigned char PathId;unsigned char TargetId; }STORVSC_DEVICE_INFO ;
If this is an API (as the header file name suggests), you just changed it. Same for the other hunks in this patch.
Arnd <><
Re: [patch 27/54] Staging: hv: remove ULONG and LONG typedefs
In reply to Arnd BergmannQuoted 31 lines · Arnd Bergmann
Quoted 5 lines · Greg Kroah-Hartman
From: Greg Kroah-Hartman <[email protected]>
The ULONG and LONG typedefs are now removed from the Hyper-V driver code
This conversion is not equivalent:
drivers/staging/hv/include/osd.h typedef struct _DLIST_ENTRY { · line 105
Quoted 9 lines
//
drivers/staging/hv/include/osd.h +0
-8-// unsigned types -// -typedef unsigned int ULONG ; - -// -// signed types -// -typedef int LONG ;- // redefine the world, because we can
- extern char *i;
- void abs(unsigned u);
- #define FALSE (2);-)
Quoted 5 lines
drivers/staging/hv/include/StorVscApi.h +0
-0@@ -117,7 +117,7 @@ typedef struct _STORVSC_DRIVER_OBJECT { }STORVSC_DRIVER_OBJECT ;
Quoted 9 lines
drivers/staging/hv/include/StorVscApi.h typedef struct _STORVSC_DRIVER_OBJECT { · line 123
Quoted 6 lines
drivers/staging/hv/include/StorVscApi.h +1
-1typedef struct _STORVSC_DEVICE_INFO { -ULONG PortNumber; +unsigned long PortNumber;unsigned char PathId;unsigned char TargetId; }STORVSC_DEVICE_INFO ;If this is an API (as the header file name suggests), you just changed it. Same for the other hunks in this patch.
Ah crap, you're right, that's all wrong, nice catch.
I'll go redo it to be "unsigned int", but for some reason, the code still seems to work properly :)
thanks,
greg k-h
Re: [patch 27/54] Staging: hv: remove ULONG and LONG typedefs
Quoted 42 lines · Greg KH
Quoted 31 lines · Arnd Bergmann
Quoted 5 lines · Greg Kroah-Hartman
From: Greg Kroah-Hartman <[email protected]>
The ULONG and LONG typedefs are now removed from the Hyper-V driver code
This conversion is not equivalent:
Review
Quoted 9 lines
//
(quoted diff) +0
-8-// unsigned types -// -typedef unsigned int ULONG; - -// -// signed types -// -typedef int LONG;- // redefine the world, because we can
- extern char *i;
- void abs(unsigned u);
- #define FALSE (2);-)
Quoted 5 lines
drivers/staging/hv/include/StorVscApi.h +0
-0@@ -117,7 +117,7 @@ typedef struct _STORVSC_DRIVER_OBJECT { }STORVSC_DRIVER_OBJECT ;Quoted 9 lines
drivers/staging/hv/include/StorVscApi.h typedef struct _STORVSC_DRIVER_OBJECT { · line 123
Quoted 6 lines
drivers/staging/hv/include/StorVscApi.h +1
-1typedef struct _STORVSC_DEVICE_INFO { -ULONG PortNumber; +unsigned long PortNumber;unsigned char PathId;unsigned char TargetId; }STORVSC_DEVICE_INFO ;If this is an API (as the header file name suggests), you just changed it. Same for the other hunks in this patch.
Quoted 4 lines
Ah crap, you're right, that's all wrong, nice catch.
I'll go redo it to be "unsigned int", but for some reason, the code still seems to work properly :)
Ok, here's the updated version. Thanks for the review.
Hank, a lot of these should probably be converted to "real" kernel types, like u32, or u64 if it's really needed. Especially if they are crossing the kernel/hypervisor boundry.
thanks,
greg k-h
-------------
From: Greg Kroah-Hartman <[email protected]>
Subject: Staging: hv: remove ULONG and LONG typedefs
From: Greg Kroah-Hartman <[email protected]>
The ULONG and LONG typedefs are now removed from the Hyper-V driver code.
--- drivers/staging/hv/StorVsc.c | 2 +- drivers/staging/hv/include/StorVscApi.h | 2 +- drivers/staging/hv/include/osd.h | 10 ---------- drivers/staging/hv/include/vstorage.h | 12 ++++++------ 4 files changed, 8 insertions(+), 18 deletions(-)
drivers/staging/hv/StorVsc.c +1 -1
@@ -62,7 +62,7 @@ typedef struct _STORVSC_DEVICE{// Each unique Port/Path/Target represents 1 channel ie scsi controller. In reality, the pathid, targetid is always 0 // and the port is set by us -ULONG PortNumber; +unsigned int PortNumber;unsigned char PathId;unsigned char TargetId;
drivers/staging/hv/include/StorVscApi.h +1 -1
@@ -117,7 +117,7 @@ typedef struct _STORVSC_DRIVER_OBJECT { }STORVSC_DRIVER_OBJECT ;typedef struct _STORVSC_DEVICE_INFO { -ULONG PortNumber; +unsigned int PortNumber;unsigned char PathId;unsigned char TargetId; }STORVSC_DEVICE_INFO ;
drivers/staging/hv/include/osd.h +0 -10
@@ -95,16 +95,6 @@ typedef struct _DLIST_ENTRY { }DLIST_ENTRY ;// -// unsigned types -// -typedef unsigned int ULONG ; - -// -// signed types -// -typedef int LONG ; - -// // Other types // typedef unsigned long SIZE_T ;
drivers/staging/hv/include/vstorage.h +6 -6
@@ -155,7 +155,7 @@ typedef structunsigned char DataIn;unsigned char Reserved; -ULONG DataTransferLength; +unsigned int DataTransferLength;union {
@@ -185,11 +185,11 @@ typedef struct// // Note: port number is only really known on the client side // -ULONG PortNumber; +unsigned int PortNumber; -ULONG Flags; +unsigned int Flags; -ULONG MaxTransferBytes; +unsigned int MaxTransferBytes;// // This id is unique for each channel and will correspond with
@@ -249,13 +249,13 @@ typedef struct _VSTOR_PACKET// Flags - see below for values // -ULONG Flags; +unsigned int Flags;// // Status of the request returned from the server side. // -ULONG Status; +unsigned int Status;// // Data payload area
Re: [patch 27/54] Staging: hv: remove ULONG and LONG typedefs
In reply to Arnd BergmannQuoted 7 lines · Arnd Bergmann
Quoted 4 lines · Greg Kroah-Hartman
From: Greg Kroah-Hartman <[email protected]>
The ULONG and LONG typedefs are now removed from the Hyper-V driver code
This conversion is not equivalent:
[...]
Quoted 1 line
- // redefine the world, because we can
[...]
Quoted 1 line
- #define FALSE (2)
That has been done already by the SNMP folks - see
http://www.faqs.org/rfcs/rfc1903.html under "TruthValue". S,CNR and for off-topic ...
Quoted 1 line
;-)
;-) either ....
Bernd
Signature · 3 lines
Firmix Software GmbH http://www.firmix.at/
mobil: +43 664 4416156 fax: +43 1 7890849-55
Embedded Linux Development and ServicesPATCH 28/54 Staging: hv: remove SIZE_T typedef
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
The SIZE_T typedef is now removed from the Hyper-V driver code.
--- drivers/staging/hv/Connection.c | 2 +- drivers/staging/hv/Hv.c | 2 +- drivers/staging/hv/Hv.h | 2 +- drivers/staging/hv/VmbusPrivate.h | 2 +- drivers/staging/hv/include/osd.h | 3 +-- drivers/staging/hv/osd.c | 2 +- 6 files changed, 6 insertions(+), 7 deletions(-)
drivers/staging/hv/Connection.c +1 -1
@@ -386,7 +386,7 @@ Description:int VmbusPostMessage (void * buffer, -SIZE_T bufferLen +size_t bufferLen ) {int ret=0 ;
drivers/staging/hv/Hv.c +1 -1
@@ -397,7 +397,7 @@ HvPostMessage(HV_CONNECTION_ID connectionId, HV_MESSAGE_TYPE messageType, void * payload, - SIZE_T payloadSize + size_t payloadSize ) { struct alignedInput {
drivers/staging/hv/Hv.h +1 -1
@@ -163,7 +163,7 @@ HvPostMessage(HV_CONNECTION_ID connectionId, HV_MESSAGE_TYPE messageType, void * payload, - SIZE_T payloadSize + size_t payloadSize ); static HV_STATUS
drivers/staging/hv/include/osd.h +1 -2
@@ -97,7 +97,6 @@ typedef struct _DLIST_ENTRY {// // Other types // -typedef unsigned long SIZE_T ;//typedef unsigned char GUID[16]; typedef unsigned char BOOL ;typedef unsigned char BOOLEAN ;
@@ -188,7 +187,7 @@ extern HANDLE TimerCreate(PFN_TIMER_CALLextern void TimerClose (HANDLE hTimer);extern int TimerStop (HANDLE hTimer);extern void TimerStart (HANDLE hTimer,u32 expirationInUs); -extern SIZE_T GetTickCount (void ); +extern size_t GetTickCount (void );extern HANDLE WaitEventCreate (void );extern void WaitEventClose (HANDLE hWait);
drivers/staging/hv/osd.c +1 -1
@@ -312,7 +312,7 @@ void TimerClose(HANDLE hTimer)kfree (t); } -SIZE_T GetTickCount (void ) +size_t GetTickCount (void ) {return jiffies; }
drivers/staging/hv/VmbusPrivate.h +1 -1
@@ -149,7 +149,7 @@ VmbusDisconnect(static int VmbusPostMessage (void * buffer, -SIZE_T bufSize +size_t bufSize ); static int
PATCH 29/54 Staging: hv: remove DWORD and BYTE typedefs
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
No one was even using them...
--- drivers/staging/hv/include/osd.h | 2 -- 1 file changed, 2 deletions(-)
drivers/staging/hv/include/osd.h +0 -2
@@ -101,8 +101,6 @@ typedef struct _DLIST_ENTRY {typedef unsigned char BOOL ;typedef unsigned char BOOLEAN ;typedef void *HANDLE ; -typedef u32 DWORD ; -typedef unsigned char BYTE ; typedef struct { unsigned char Data[16];
PATCH 30/54 Staging: hv: remove BOOL and BOOLEAN typedefs
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
The BOOL and BOOLEAN typedefs are now removed from the Hyper-V driver code.
--- drivers/staging/hv/ChannelMgmt.c | 2 +- drivers/staging/hv/Hv.h | 2 +- drivers/staging/hv/NetVsc.c | 2 +- drivers/staging/hv/RndisFilter.c | 2 +- drivers/staging/hv/include/ChannelMessages.h | 6 +++--- drivers/staging/hv/include/List.h | 2 +- drivers/staging/hv/include/NetVscApi.h | 4 ++-- drivers/staging/hv/include/VmbusPacketFormat.h | 2 +- drivers/staging/hv/include/osd.h | 2 -- 9 files changed, 11 insertions(+), 13 deletions(-)
drivers/staging/hv/ChannelMgmt.c +1 -1
@@ -240,7 +240,7 @@ VmbusChannelProcessOffer(VMBUS_CHANNEL * newChannel=(VMBUS_CHANNEL *)context;LIST_ENTRY * anchor;LIST_ENTRY * curr; -BOOL fNew=TRUE; +bool fNew=TRUE;VMBUS_CHANNEL * channel;DPRINT_ENTER (VMBUS );
drivers/staging/hv/Hv.h +1 -1
@@ -113,7 +113,7 @@ typedef struct {u64 GuestId;// XenLinux or native Linux. If XenLinux, the hypercall and synic pages has already been initialized void * HypercallPage; -BOOL SynICInitialized; +bool SynICInitialized;// This is used as an input param to HvCallSignalEvent hypercall. The input param is immutable // in our usage and must be dynamic mem (vs stack or global). HV_INPUT_SIGNAL_EVENT_BUFFER *SignalEventBuffer;
drivers/staging/hv/include/ChannelMessages.h +3 -3
@@ -82,7 +82,7 @@ typedef struct _VMBUS_CHANNEL_QUERY_VMBUtypedef struct _VMBUS_CHANNEL_VERSION_SUPPORTED {VMBUS_CHANNEL_MESSAGE_HEADER Header; -BOOLEAN VersionSupported; +bool VersionSupported; }VMBUS_CHANNEL_VERSION_SUPPORTED , *PVMBUS_CHANNEL_VERSION_SUPPORTED ;// Offer Channel parameters
@@ -92,7 +92,7 @@ typedef struct _VMBUS_CHANNEL_OFFER_CHANVMBUS_CHANNEL_OFFER Offer;u32 ChildRelId;u8 MonitorId; -BOOLEAN MonitorAllocated; +bool MonitorAllocated; }VMBUS_CHANNEL_OFFER_CHANNEL , *PVMBUS_CHANNEL_OFFER_CHANNEL ;//
@@ -264,7 +264,7 @@ typedef struct _VMBUS_CHANNEL_INITIATE_Ctypedef struct _VMBUS_CHANNEL_VERSION_RESPONSE {VMBUS_CHANNEL_MESSAGE_HEADER Header; -BOOLEAN VersionSupported; +bool VersionSupported; }VMBUS_CHANNEL_VERSION_RESPONSE , *PVMBUS_CHANNEL_VERSION_RESPONSE ;typedef VMBUS_CHANNEL_MESSAGE_HEADER VMBUS_CHANNEL_UNLOAD , *PVMBUS_CHANNEL_UNLOAD ;
drivers/staging/hv/include/List.h +1 -1
@@ -56,7 +56,7 @@ typedef DLIST_ENTRY *PLIST_ENTRY;/* -* BOOLEAN +* bool * IsListEmpty( * PLIST_ENTRY ListHead * );
drivers/staging/hv/include/NetVscApi.h +2 -2
@@ -72,7 +72,7 @@ typedef struct _NETVSC_PACKET {DLIST_ENTRY ListEntry;DEVICE_OBJECT *Device; -BOOL IsDataPacket; +bool IsDataPacket;// Valid only for receives when we break a xfer page packet into multiple netvsc packets XFERPAGE_PACKET *XferPagePacket;
@@ -131,7 +131,7 @@ typedef struct _NETVSC_DRIVER_OBJECT {typedef struct _NETVSC_DEVICE_INFO {unsigned char MacAddr[6 ]; -BOOL LinkState;// 0 - link up, 1 - link down +bool LinkState;// 0 - link up, 1 - link down }NETVSC_DEVICE_INFO ;//
drivers/staging/hv/include/osd.h +0 -2
@@ -98,8 +98,6 @@ typedef struct _DLIST_ENTRY {// Other types // //typedef unsigned char GUID[16]; -typedef unsigned char BOOL ; -typedef unsigned char BOOLEAN ;typedef void *HANDLE ; typedef struct {
drivers/staging/hv/include/VmbusPacketFormat.h +1 -1
@@ -113,7 +113,7 @@ typedef struct VMTRANSFER_PAGE_PACKET_HE#endif u16 TransferPageSetId; -BOOLEAN SenderOwnsSet; +bool SenderOwnsSet;u8 Reserved;u32 RangeCount;VMTRANSFER_PAGE_RANGE Ranges[1 ];
drivers/staging/hv/NetVsc.c +1 -1
@@ -1344,7 +1344,7 @@ NetVscOnReceiveCompletion(DEVICE_OBJECT *device = (DEVICE_OBJECT *)packet->Device;NETVSC_DEVICE * netDevice;u64 transactionId=0 ; -BOOL fSendReceiveComp = FALSE; +bool fSendReceiveComp = FALSE;DPRINT_ENTER (NETVSC );
drivers/staging/hv/RndisFilter.c +1 -1
@@ -383,7 +383,7 @@ RndisFilterReceiveResponse(LIST_ENTRY *anchor;LIST_ENTRY *curr;RNDIS_REQUEST *request=NULL ; -BOOL found=FALSE; +bool found=FALSE;DPRINT_ENTER (NETVSC );
PATCH 31/54 Staging: hv: remove #defines from osd.c
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
Remove the unneeded #defines from osd.c
--- drivers/staging/hv/osd.c | 42 ------------------------------------------ 1 file changed, 42 deletions(-)
drivers/staging/hv/osd.c +0 -42
@@ -21,15 +21,12 @@* */ -#define KERNEL_2_6_27 -#include <linux/module.h> #include <linux/init.h> #include <linux/types.h> #include <linux/mm.h> #include <linux/highmem.h> #include <linux/vmalloc.h> -//#include <linux/config.h> #include <linux/ioport.h> #include <linux/irq.h> #include <linux/interrupt.h>
@@ -86,20 +83,11 @@ typedef struct _WORKITEM {void LogMsg (const char *fmt, ...) { -#ifdef KERNEL_2_6_5 -char buf[1024 ]; -#endif va_list args;va_start (args, fmt); -#ifdef KERNEL_2_6_5 -vsnprintf (buf,1024 , fmt, args); -va_end (args); -printk (buf); -#else vprintk (fmt, args);va_end (args); -#endif }void BitSet (unsigned int * addr,int bit)
@@ -130,30 +118,12 @@ int BitTestAndSet(unsigned int* addr, inint InterlockedIncrement (int *val) { -#ifdef KERNEL_2_6_5 -int i; -local_irq_disable (); - i =atomic_read ((atomic_t *)val); -atomic_set ((atomic_t *)val, i+1 ); -local_irq_enable (); -return i+1 ; -#else return atomic_inc_return ((atomic_t *)val); -#endif }int InterlockedDecrement (int *val) { -#ifdef KERNEL_2_6_5 -int i; -local_irq_disable (); - i =atomic_read ((atomic_t *)val); -atomic_set ((atomic_t *)val, i-1 ); -local_irq_enable (); -return i-1 ; -#else return atomic_dec_return ((atomic_t *)val); -#endif }#ifndef atomic_cmpxchg
@@ -428,11 +398,7 @@ unsigned long Virtual2Physical(void * Vireturn pfn <<PAGE_SHIFT ; } -#ifdef KERNEL_2_6_27 void WorkItemCallback (struct work_struct *work) -#else -void WorkItemCallback(void* work) -#endif {WORKITEM * w = (WORKITEM *)work;
@@ -474,11 +440,7 @@ int WorkQueueQueueWorkItem(HANDLE hWorkQ w->callback = workItem, w->context = context; -#ifdef KERNEL_2_6_27 INIT_WORK (&w->work, WorkItemCallback); -#else -INIT_WORK (&w->work, WorkItemCallback, w); -#endif return queue_work (wq->queue, &w->work); }
@@ -492,10 +454,6 @@ void QueueWorkItem(PFN_WORKITEM_CALLBACK w->callback = workItem, w->context = context; -#ifdef KERNEL_2_6_27 INIT_WORK (&w->work, WorkItemCallback); -#else -INIT_WORK (&w->work, WorkItemCallback, w); -#endif schedule_work (&w->work); }
PATCH 32/54 Staging: hv: remove MIN and MAX usages
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
The kernel has the "correct" min() and max() functions, so use those.
--- drivers/staging/hv/include/osd.h | 3 --- drivers/staging/hv/storvsc_drv.c | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/staging/hv/include/osd.h +0 -3
@@ -67,9 +67,6 @@#define ALIGN_DOWN (value, align) ( (value) & ~(align-1) )#define NUM_PAGES_SPANNED (addr, len) ( (ALIGN_UP(addr+len, PAGE_SIZE) - ALIGN_DOWN(addr, PAGE_SIZE)) >> PAGE_SHIFT ) -#define MIN (a, b) ((a) < (b)? (a): (b)) -#define MAX (a, b) ((a) > (b)? (a): (b)) -#define LOWORD (dw) ((unsigned short) (dw))#define HIWORD (dw) ((unsigned short) (((unsigned int) (dw) >> 16) & 0xFFFF))
drivers/staging/hv/storvsc_drv.c +2 -2
@@ -623,7 +623,7 @@ static unsigned int copy_to_bounce_buffe dest = bounce_addr + bounce_sgl[j].length; destlen =PAGE_SIZE - bounce_sgl[j].length; - copylen =MIN (srclen, destlen); + copylen =min (srclen, destlen);memcpy ((void *)dest, (void *)src, copylen); total_copied += copylen;
@@ -698,7 +698,7 @@ static unsigned int copy_from_bounce_buf src = bounce_addr + bounce_sgl[j].offset; srclen = bounce_sgl[j].length - bounce_sgl[j].offset; - copylen =MIN (srclen, destlen); + copylen =min (srclen, destlen);memcpy ((void *)dest, (void *)src, copylen); total_copied += copylen;
PATCH 33/54 Staging: hv: remove PAGE_SIZE and PAGE_SHIFT and __builtin functions
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
The kernel provides all of this, and actually gets it correct, so don't try to redefine these types of things.
--- drivers/staging/hv/BlkVsc.c | 1 + drivers/staging/hv/NetVsc.c | 1 + drivers/staging/hv/RndisFilter.c | 1 + drivers/staging/hv/StorVsc.c | 2 ++ drivers/staging/hv/Vmbus.c | 1 + drivers/staging/hv/include/osd.h | 28 ---------------------------- 6 files changed, 6 insertions(+), 28 deletions(-)
drivers/staging/hv/BlkVsc.c +1 -0
@@ -21,6 +21,7 @@*/ #include <linux/kernel.h> +#include <linux/mm.h> #include "StorVsc.c" static const char * gBlkDriverName="blkvsc" ;
drivers/staging/hv/include/osd.h +0 -28
@@ -29,34 +29,6 @@// Defines // -#ifndef PAGE_SIZE -#define PAGE_SIZE 0x1000 -#endif - -#ifndef PAGE_SHIFT -#define PAGE_SHIFT 12 -#endif - -#ifndef memcpy -#define memcpy __builtin_memcpy -#endif - -#ifndef memset -#define memset __builtin_memset -#endif - -#ifndef memcmp -#define memcmp __builtin_memcmp -#endif - -#ifndef strcpy -#define strcpy __builtin_strcpy -#endif - -// -//#ifndef sprintf -//#define sprintf __builtin_sprintf -//#endif #define STRUCT_PACKED __attribute__((__packed__))#define STRUCT_ALIGNED (x) __attribute__((__aligned__(x)))
drivers/staging/hv/NetVsc.c +1 -0
@@ -23,6 +23,7 @@#define KERNEL_2_6_27 #include <linux/kernel.h> +#include <linux/mm.h> #include "include/logging.h" #include "NetVsc.h" #include "RndisFilter.h"
drivers/staging/hv/RndisFilter.c +1 -0
@@ -24,6 +24,7 @@#define KERNEL_2_6_27 #include <linux/kernel.h> +#include <linux/mm.h> #include "include/logging.h" #include "include/NetVscApi.h"
drivers/staging/hv/StorVsc.c +2 -0
@@ -24,6 +24,8 @@#define KERNEL_2_6_27 #include <linux/kernel.h> +#include <linux/string.h> +#include <linux/mm.h> #include "include/logging.h" #include "include/StorVscApi.h"
drivers/staging/hv/Vmbus.c +1 -0
@@ -22,6 +22,7 @@*/ #include <linux/kernel.h> +#include <linux/mm.h> #include "include/logging.h" #include "VersionInfo.h" #include "VmbusPrivate.h"
PATCH 34/54 Staging: hv: remove STRUCT_PACKED and STRUCT_ALIGNED defines
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
Use the correct __attribute__((packed)) one if it's really needed.
--- drivers/staging/hv/RingBuffer.h | 2 +- drivers/staging/hv/include/osd.h | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-)
drivers/staging/hv/include/osd.h +0 -3
@@ -30,9 +30,6 @@// -#define STRUCT_PACKED __attribute__((__packed__)) -#define STRUCT_ALIGNED (x) __attribute__((__aligned__(x))) -#define UNUSED_VAR (v) v __attribute__((__unused__))#define ALIGN_UP (value, align) ( ((value) & (align-1))? ( ((value) + (align-1)) & ~(align-1) ): (value) )
drivers/staging/hv/RingBuffer.h +1 -1
@@ -43,7 +43,7 @@ typedef struct _RING_BUFFER {// volatile u32 InterruptMask; // Ring data starts here + RingDataStartOffset !!! DO NOT place any fields below this !!! u8 Buffer[0 ]; -}STRUCT_PACKED RING_BUFFER ; +} __attribute__((packed)) RING_BUFFER; typedef struct _RING_BUFFER_INFO { RING_BUFFER* RingBuffer;
Re: [patch 34/54] Staging: hv: remove STRUCT_PACKED and STRUCT_ALIGNED defines
drivers/staging/hv/RingBuffer.h typedef struct _RING_BUFFER { · line 47
Quoted 7 lines · Greg Kroah-Hartman
drivers/staging/hv/RingBuffer.h +1
-1@@ -43,7 +43,7 @@ typedef struct _RING_BUFFER {// volatile u32 InterruptMask; // Ring data starts here + RingDataStartOffset !!! DO NOT place any fields below this !!! u8 Buffer[0 ]; -}STRUCT_PACKED RING_BUFFER ; +} __attribute__((packed)) RING_BUFFER;
The data structure is actually packed already, the attribute does not make it better and could be removed. We also have __packed as a shortcut for __attribute__((packed)).
Arnd <><
Re: [patch 34/54] Staging: hv: remove STRUCT_PACKED and STRUCT_ALIGNED defines
Quoted 11 lines · Arnd Bergmann
drivers/staging/hv/RingBuffer.h typedef struct _RING_BUFFER { · line 47
Quoted 7 lines · Greg Kroah-Hartman
drivers/staging/hv/RingBuffer.h +1
-1@@ -43,7 +43,7 @@ typedef struct _RING_BUFFER {// volatile u32 InterruptMask; // Ring data starts here + RingDataStartOffset !!! DO NOT place any fields below this !!! u8 Buffer[0 ]; -}STRUCT_PACKED RING_BUFFER ; +} __attribute__((packed)) RING_BUFFER;The data structure is actually packed already, the attribute does not make it better and could be removed. We also have
__packedas a shortcut for __attribute__((packed)).
Honestly, I don't know how useful __packed really is. In a shared kernel/userspace header, it is only defined for the kernel.
Jörn
Signature · 2 lines
Do not stop an army on its way home. -- Sun Tzu
Re: [patch 34/54] Staging: hv: remove STRUCT_PACKED and STRUCT_ALIGNED defines
Quoted 13 lines · On Fri, 24 Jul 2009 23:32:19 +0200 Jörn Engel <[email protected]> wrote:
Quoted 11 lines · Arnd Bergmann
drivers/staging/hv/RingBuffer.h typedef struct _RING_BUFFER { · line 47
Quoted 7 lines · Greg Kroah-Hartman
drivers/staging/hv/RingBuffer.h +1
-1@@ -43,7 +43,7 @@ typedef struct _RING_BUFFER {// volatile u32 InterruptMask; // Ring data starts here + RingDataStartOffset !!! DO NOT place any fields below this !!! u8 Buffer[0 ]; -}STRUCT_PACKED RING_BUFFER ; +} __attribute__((packed)) RING_BUFFER;The data structure is actually packed already, the attribute does not make it better and could be removed. We also have
__packedas a shortcut for __attribute__((packed)).
Quoted 3 lines
Honestly, I don't know how useful
__packedreally is. In a shared kernel/userspace header, it is only defined for the kernel.
As I remember, gcc generates worse code for packed structures on many architectures since it may have to do byte fetchs/recombining to avoid unaligned accesses.
Re: [patch 34/54] Staging: hv: remove STRUCT_PACKED and STRUCT_ALIGNED defines
Quoted 8 lines · Stephen Hemminger
Quoted 5 lines · On Fri, 24 Jul 2009 23:32:19 +0200 Jörn Engel <[email protected]> wrote:
Quoted 3 lines · Arnd Bergmann
The data structure is actually packed already, the attribute does not make it better and could be removed. We also have
__packedas a shortcut for __attribute__((packed)).
Quoted 6 lines
Quoted 2 lines
Honestly, I don't know how useful
__packedreally is. In a shared kernel/userspace header, it is only defined for the kernel.As I remember, gcc generates worse code for packed structures on many architectures since it may have to do byte fetchs/recombining to avoid unaligned accesses.
I was talking about "__packed" vs. "__attribute__((packed))". But yes, avoiding packed structures where possible is a good idea.
Jörn
Signature · 3 lines
"[One] doesn't need to know [...] how to cause a headache in order to take an aspirin." -- Scott Culp, Manager of the Microsoft Security Response Center, 2001
PATCH 35/54 Staging: hv: remove UNUSED_VAR usage
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
This isn't needed at all.
--- drivers/staging/hv/include/osd.h | 2 -- drivers/staging/hv/netvsc_drv.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/staging/hv/include/osd.h +0 -2
@@ -30,8 +30,6 @@// -#define UNUSED_VAR (v) v __attribute__((__unused__)) -#define ALIGN_UP (value, align) ( ((value) & (align-1))? ( ((value) + (align-1)) & ~(align-1) ): (value) )#define ALIGN_DOWN (value, align) ( (value) & ~(align-1) )#define NUM_PAGES_SPANNED (addr, len) ( (ALIGN_UP(addr+len, PAGE_SIZE) - ALIGN_DOWN(addr, PAGE_SIZE)) >> PAGE_SHIFT )
drivers/staging/hv/netvsc_drv.c +1 -1
@@ -154,7 +154,7 @@ Desc: Set the multicast listRemark: No-op here --*/ -static void netvsc_set_multicast_list (UNUSED_VAR (struct net_device *net)) +static void netvsc_set_multicast_list (struct net_device *net) { }
PATCH 36/54 Staging: hv: remove FIELD_OFFSET usage
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
This isn't needed, or even used, at all.
--- drivers/staging/hv/include/VmbusChannelInterface.h | 9 --------- drivers/staging/hv/include/osd.h | 2 -- 2 files changed, 11 deletions(-)
drivers/staging/hv/include/osd.h +0 -2
@@ -37,8 +37,6 @@#define LOWORD (dw) ((unsigned short) (dw))#define HIWORD (dw) ((unsigned short) (((unsigned int) (dw) >> 16) & 0xFFFF)) -#define FIELD_OFFSET (t, f) ((unsigned int)(unsigned long)&(((t *)0)->f)) -#ifdef FALSE #undef FALSE#endif
drivers/staging/hv/include/VmbusChannelInterface.h +0 -9
@@ -98,15 +98,6 @@ typedef struct#pragma pack(pop) -// -// Verify the MAX_PIPE_USER_DEFINED_BYTES value. -// -//C_ASSERT(MAX_PIPE_USER_DEFINED_BYTES == -// MAX_USER_DEFINED_BYTES - -// (FIELD_OFFSET(VMBUS_CHANNEL_OFFER, u.Pipe.UserDefined) - -// FIELD_OFFSET(VMBUS_CHANNEL_OFFER, u.Standard.UserDefined))); -// -typedef u32 GPADL_HANDLE ;//
PATCH 37/54 Staging: hv: remove TRUE, FALSE, and NULL usage
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
Don't define things that are either already provided (like NULL), or you shouldn't use (like TRUE and FALSE).
--- drivers/staging/hv/ChannelMgmt.c | 4 ++-- drivers/staging/hv/Hv.c | 8 ++++---- drivers/staging/hv/NetVsc.c | 4 ++-- drivers/staging/hv/RndisFilter.c | 10 +++++----- drivers/staging/hv/include/osd.h | 14 -------------- 5 files changed, 13 insertions(+), 27 deletions(-)
drivers/staging/hv/ChannelMgmt.c +2 -2
@@ -240,7 +240,7 @@ VmbusChannelProcessOffer(VMBUS_CHANNEL * newChannel=(VMBUS_CHANNEL *)context;LIST_ENTRY * anchor;LIST_ENTRY * curr; -bool fNew=TRUE; +bool fNew = true;VMBUS_CHANNEL * channel;DPRINT_ENTER (VMBUS );
@@ -255,7 +255,7 @@ VmbusChannelProcessOffer(if (!memcmp (&channel->OfferMsg.Offer.InterfaceType, &newChannel->OfferMsg.Offer.InterfaceType,sizeof (GUID )) && !memcmp (&channel->OfferMsg.Offer.InterfaceInstance, &newChannel->OfferMsg.Offer.InterfaceInstance,sizeof (GUID ))) { - fNew = FALSE; + fNew = false;break ; } }
drivers/staging/hv/Hv.c +4 -4
@@ -31,7 +31,7 @@// The one and only HV_CONTEXT gHvContext={ - .SynICInitialized = FALSE, + .SynICInitialized = false, .HypercallPage =NULL , .SignalEventParam =NULL , .SignalEventBuffer =NULL ,
@@ -571,8 +571,8 @@ HvSynicInit ( sharedSint.AsUINT64 =0 ; sharedSint.Vector = irqVector;//HV_SHARED_SINT_IDT_VECTOR + 0x20; - sharedSint.Masked = FALSE; - sharedSint.AutoEoi = TRUE; + sharedSint.Masked = false; + sharedSint.AutoEoi = true;DPRINT_DBG (VMBUS ,"HV_X64_MSR_SINT1 msr set to: %llx" , sharedSint.AsUINT64);
@@ -584,7 +584,7 @@ HvSynicInit (WriteMsr (HV_X64_MSR_SCONTROL , sctrl.AsUINT64); - gHvContext.SynICInitialized = TRUE; + gHvContext.SynICInitialized = true;DPRINT_EXIT (VMBUS );
drivers/staging/hv/include/osd.h +0 -14
@@ -37,20 +37,6 @@#define LOWORD (dw) ((unsigned short) (dw))#define HIWORD (dw) ((unsigned short) (((unsigned int) (dw) >> 16) & 0xFFFF)) -#ifdef FALSE -#undef FALSE -#endif -#define FALSE 0 - -#ifdef TRUE -#undef TRUE -#endif -#define TRUE 1 - -#ifndef NULL -#define NULL (void *)0 -#endif - typedef struct _DLIST_ENTRY { struct _DLIST_ENTRY *Flink; struct _DLIST_ENTRY *Blink;
drivers/staging/hv/NetVsc.c +2 -2
@@ -1345,7 +1345,7 @@ NetVscOnReceiveCompletion(DEVICE_OBJECT *device = (DEVICE_OBJECT *)packet->Device;NETVSC_DEVICE * netDevice;u64 transactionId=0 ; -bool fSendReceiveComp = FALSE; +bool fSendReceiveComp = false;DPRINT_ENTER (NETVSC );
@@ -1371,7 +1371,7 @@ NetVscOnReceiveCompletion(// Return the xfer page packet itself to the freelist if (packet->XferPagePacket->Count ==0 ) { - fSendReceiveComp = TRUE; + fSendReceiveComp = true; transactionId = packet->Completion.Recv.ReceiveCompletionTid;INSERT_TAIL_LIST (&netDevice->ReceivePacketList, &packet->XferPagePacket->ListEntry);
drivers/staging/hv/RndisFilter.c +5 -5
@@ -357,7 +357,7 @@ RndisFilterSendRequest(// Setup the packet to send it packet = &Request->Packet; - packet->IsDataPacket = FALSE; + packet->IsDataPacket = false; packet->TotalDataBufferLength = Request->RequestMessage.MessageLength; packet->PageBufferCount =1 ;
@@ -384,7 +384,7 @@ RndisFilterReceiveResponse(LIST_ENTRY *anchor;LIST_ENTRY *curr;RNDIS_REQUEST *request=NULL ; -bool found=FALSE; +bool found = false;DPRINT_ENTER (NETVSC );
@@ -399,7 +399,7 @@ RndisFilterReceiveResponse(DPRINT_DBG (NETVSC ,"found rndis request for this response (id 0x%x req type 0x%x res type 0x%x)" , request->RequestMessage.Message.InitializeRequest.RequestId, request->RequestMessage.NdisMessageType, Response->NdisMessageType); - found = TRUE; + found = true;break ; } }
@@ -485,7 +485,7 @@ RndisFilterReceiveData( Packet->PageBuffers[0 ].Offset += dataOffset; Packet->PageBuffers[0 ].Length -= dataOffset; - Packet->IsDataPacket = TRUE; + Packet->IsDataPacket = true; gRndisFilter.InnerDriver.OnReceiveCallback (Device->NetDevice->Device, Packet);
@@ -1112,7 +1112,7 @@ RndisFilterOnSend( rndisPacket->DataOffset =sizeof (RNDIS_PACKET ); rndisPacket->DataLength = Packet->TotalDataBufferLength; - Packet->IsDataPacket = TRUE; + Packet->IsDataPacket = true; Packet->PageBuffers[0 ].Pfn =GetPhysicalAddress (rndisMessage) >>PAGE_SHIFT ; Packet->PageBuffers[0 ].Offset = (unsigned long )rndisMessage & (PAGE_SIZE -1 ); Packet->PageBuffers[0 ].Length = rndisMessageSize;
PATCH 38/54 Staging: hv: osd: remove MemAlloc wrapper
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
Use the "real" kmalloc call instead of a wrapper function.
--- drivers/staging/hv/Channel.c | 9 +++------ drivers/staging/hv/ChannelMgmt.c | 3 +-- drivers/staging/hv/Hv.c | 2 +- drivers/staging/hv/NetVsc.c | 2 +- drivers/staging/hv/RndisFilter.c | 1 - drivers/staging/hv/include/osd.h | 1 - drivers/staging/hv/osd.c | 5 ----- 7 files changed, 6 insertions(+), 17 deletions(-)
drivers/staging/hv/Channel.c +3 -6
@@ -260,8 +260,7 @@ VmbusChannelOpen( SendRingBufferSize);// Create and init the channel open message - openInfo = - (VMBUS_CHANNEL_MSGINFO *)MemAlloc (sizeof (VMBUS_CHANNEL_MSGINFO ) +sizeof (VMBUS_CHANNEL_OPEN_CHANNEL )); + openInfo =kmalloc (sizeof (VMBUS_CHANNEL_MSGINFO ) +sizeof (VMBUS_CHANNEL_OPEN_CHANNEL ),GFP_KERNEL );ASSERT (openInfo !=NULL ); openInfo->WaitEvent =WaitEventCreate ();
@@ -630,8 +629,7 @@ VmbusChannelTeardownGpadl(ASSERT (GpadlHandle !=0 ); - info = - (VMBUS_CHANNEL_MSGINFO *)MemAlloc (sizeof (VMBUS_CHANNEL_MSGINFO ) +sizeof (VMBUS_CHANNEL_GPADL_TEARDOWN )); + info =kmalloc (sizeof (VMBUS_CHANNEL_MSGINFO ) +sizeof (VMBUS_CHANNEL_GPADL_TEARDOWN ),GFP_KERNEL );ASSERT (info !=NULL ); info->WaitEvent =WaitEventCreate ();
@@ -693,8 +691,7 @@ VmbusChannelClose(TimerStop (Channel->PollTimer);// Send a closing message - info = - (VMBUS_CHANNEL_MSGINFO *)MemAlloc (sizeof (VMBUS_CHANNEL_MSGINFO ) +sizeof (VMBUS_CHANNEL_CLOSE_CHANNEL )); + info =kmalloc (sizeof (VMBUS_CHANNEL_MSGINFO ) +sizeof (VMBUS_CHANNEL_CLOSE_CHANNEL ),GFP_KERNEL );ASSERT (info !=NULL );//info->waitEvent = WaitEventCreate();
drivers/staging/hv/ChannelMgmt.c +1 -2
@@ -731,8 +731,7 @@ VmbusChannelRequestOffers(DPRINT_ENTER (VMBUS ); - msgInfo = - (VMBUS_CHANNEL_MSGINFO *)MemAlloc (sizeof (VMBUS_CHANNEL_MSGINFO ) +sizeof (VMBUS_CHANNEL_MESSAGE_HEADER )); + msgInfo =kmalloc (sizeof (VMBUS_CHANNEL_MSGINFO ) +sizeof (VMBUS_CHANNEL_MESSAGE_HEADER ),GFP_KERNEL );ASSERT (msgInfo !=NULL ); msgInfo->WaitEvent =WaitEventCreate ();
drivers/staging/hv/Hv.c +1 -1
@@ -305,7 +305,7 @@ HvInit ( (unsigned long)hypercallMsr.GuestPhysicalAddress << PAGE_SHIFT);// Setup the global signal event param for the signal event hypercall - gHvContext.SignalEventBuffer =MemAlloc (sizeof (HV_INPUT_SIGNAL_EVENT_BUFFER )); + gHvContext.SignalEventBuffer =kmalloc (sizeof (HV_INPUT_SIGNAL_EVENT_BUFFER ),GFP_KERNEL );if (!gHvContext.SignalEventBuffer) { goto Cleanup;
drivers/staging/hv/include/osd.h +0 -1
@@ -121,7 +121,6 @@ extern void PageFree(void* page, unsigneextern void *MemMapIO (unsigned long phys,unsigned long size);extern void MemUnmapIO (void * virt); -extern void *MemAlloc (unsigned int size);extern void *MemAllocZeroed (unsigned int size);extern void *MemAllocAtomic (unsigned int size);extern void MemFree (void * buf);
drivers/staging/hv/NetVsc.c +1 -1
@@ -361,7 +361,7 @@ NetVscInitializeReceiveBufferWithNetVsp( netDevice->ReceiveSectionCount = initPacket->Messages.Version1Messages.SendReceiveBufferComplete.NumSections; - netDevice->ReceiveSections =MemAlloc (netDevice->ReceiveSectionCount *sizeof (NVSP_1_RECEIVE_BUFFER_SECTION )); + netDevice->ReceiveSections =kmalloc (netDevice->ReceiveSectionCount *sizeof (NVSP_1_RECEIVE_BUFFER_SECTION ),GFP_KERNEL );if (netDevice->ReceiveSections ==NULL ) { ret =-1 ;
drivers/staging/hv/osd.c +0 -5
@@ -189,11 +189,6 @@ void PageUnmapVirtualAddress(void* VirtAkunmap_atomic (VirtAddr,KM_IRQ0 ); } -void *MemAlloc (unsigned int size) -{ -return kmalloc (size,GFP_KERNEL ); -} -void *MemAllocZeroed (unsigned int size) {void *p =kmalloc (size,GFP_KERNEL );
drivers/staging/hv/RndisFilter.c +0 -1
@@ -943,7 +943,6 @@ RndisFilterOnDeviceAdd(DPRINT_ENTER (NETVSC ); -//rndisDevice = MemAlloc(sizeof(RNDIS_DEVICE)); rndisDevice =GetRndisDevice ();if (!rndisDevice) {
PATCH 39/54 Staging: hv: osd: remove MemAllocZeroed wrapper
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
Use the "real" kzalloc call instead of a wrapper function.
--- drivers/staging/hv/Channel.c | 8 ++++---- drivers/staging/hv/Connection.c | 4 ++-- drivers/staging/hv/NetVsc.c | 4 ++-- drivers/staging/hv/RndisFilter.c | 4 ++-- drivers/staging/hv/StorVsc.c | 2 +- drivers/staging/hv/include/osd.h | 1 - drivers/staging/hv/osd.c | 7 ------- 7 files changed, 11 insertions(+), 19 deletions(-)
drivers/staging/hv/Channel.c +4 -4
@@ -226,7 +226,7 @@ VmbusChannelOpen(// Allocate the ring buffer out =PageAlloc ((SendRingBufferSize + RecvRingBufferSize) >>PAGE_SHIFT ); -//out = MemAllocZeroed(sendRingBufferSize + recvRingBufferSize); +//out = kzalloc(sendRingBufferSize + recvRingBufferSize, GFP_KERNEL); ASSERT (out);ASSERT (((unsigned long )out & (PAGE_SIZE -1 )) ==0 );
@@ -421,7 +421,7 @@ VmbusChannelCreateGpadlHeader( {// fill in the header msgSize =sizeof (VMBUS_CHANNEL_MSGINFO ) +sizeof (VMBUS_CHANNEL_GPADL_HEADER ) +sizeof (GPA_RANGE ) + pfnCount*sizeof (u64); - msgHeader =MemAllocZeroed (msgSize); + msgHeader =kzalloc (msgSize,GFP_KERNEL );INITIALIZE_LIST_HEAD (&msgHeader->SubMsgList); msgHeader->MessageSize=msgSize;
@@ -458,7 +458,7 @@ VmbusChannelCreateGpadlHeader( } msgSize =sizeof (VMBUS_CHANNEL_MSGINFO ) +sizeof (VMBUS_CHANNEL_GPADL_BODY ) + pfnCurr*sizeof (u64); - msgBody =MemAllocZeroed (msgSize); + msgBody =kzalloc (msgSize,GFP_KERNEL );ASSERT (msgBody); msgBody->MessageSize = msgSize; (*MessageCount)++;
@@ -481,7 +481,7 @@ VmbusChannelCreateGpadlHeader( {// everything fits in a header msgSize =sizeof (VMBUS_CHANNEL_MSGINFO ) +sizeof (VMBUS_CHANNEL_GPADL_HEADER ) +sizeof (GPA_RANGE ) + pageCount*sizeof (u64); - msgHeader =MemAllocZeroed (msgSize); + msgHeader =kzalloc (msgSize,GFP_KERNEL ); msgHeader->MessageSize=msgSize; gpaHeader = (VMBUS_CHANNEL_GPADL_HEADER *)msgHeader->Msg;
drivers/staging/hv/Connection.c +2 -2
@@ -89,7 +89,7 @@ VmbusConnect( goto Cleanup; } - msgInfo = (VMBUS_CHANNEL_MSGINFO *)MemAllocZeroed (sizeof (VMBUS_CHANNEL_MSGINFO ) +sizeof (VMBUS_CHANNEL_INITIATE_CONTACT )); + msgInfo =kzalloc (sizeof (VMBUS_CHANNEL_MSGINFO ) +sizeof (VMBUS_CHANNEL_INITIATE_CONTACT ),GFP_KERNEL );if (msgInfo ==NULL ) { ret =-1 ;
@@ -207,7 +207,7 @@ VmbusDisconnect(if (gVmbusConnection.ConnectState != Connected)return -1 ; - msg =MemAllocZeroed (sizeof (VMBUS_CHANNEL_UNLOAD )); + msg =kzalloc (sizeof (VMBUS_CHANNEL_UNLOAD ),GFP_KERNEL ); msg->MessageType = ChannelMessageUnload;
drivers/staging/hv/include/osd.h +0 -1
@@ -121,7 +121,6 @@ extern void PageFree(void* page, unsigneextern void *MemMapIO (unsigned long phys,unsigned long size);extern void MemUnmapIO (void * virt); -extern void *MemAllocZeroed (unsigned int size);extern void *MemAllocAtomic (unsigned int size);extern void MemFree (void * buf);extern void MemoryFence (void );
drivers/staging/hv/NetVsc.c +2 -2
@@ -122,7 +122,7 @@ static inline NETVSC_DEVICE* AllocNetDev {NETVSC_DEVICE *netDevice; - netDevice =MemAllocZeroed (sizeof (NETVSC_DEVICE )); + netDevice =kzalloc (sizeof (NETVSC_DEVICE ),GFP_KERNEL );if (!netDevice)return NULL ;
@@ -815,7 +815,7 @@ NetVscOnDeviceAdd(for (i=0 ; i <NETVSC_RECEIVE_PACKETLIST_COUNT ; i++) { - packet =MemAllocZeroed (sizeof (NETVSC_PACKET ) + (NETVSC_RECEIVE_SG_COUNT *sizeof (PAGE_BUFFER ))); + packet =kzalloc (sizeof (NETVSC_PACKET ) + (NETVSC_RECEIVE_SG_COUNT *sizeof (PAGE_BUFFER )),GFP_KERNEL );if (!packet) {DPRINT_DBG (NETVSC ,"unable to allocate netvsc pkts for receive pool (wanted %d got %d)" ,NETVSC_RECEIVE_PACKETLIST_COUNT , i);
drivers/staging/hv/osd.c +0 -7
@@ -189,13 +189,6 @@ void PageUnmapVirtualAddress(void* VirtAkunmap_atomic (VirtAddr,KM_IRQ0 ); } -void *MemAllocZeroed (unsigned int size) -{ -void *p =kmalloc (size,GFP_KERNEL ); -if (p)memset (p,0 , size); -return p; -} -void *MemAllocAtomic (unsigned int size) {return kmalloc (size,GFP_ATOMIC );
drivers/staging/hv/RndisFilter.c +2 -2
@@ -210,7 +210,7 @@ static inline RNDIS_DEVICE* GetRndisDevi {RNDIS_DEVICE *device; - device =MemAllocZeroed (sizeof (RNDIS_DEVICE )); + device =kzalloc (sizeof (RNDIS_DEVICE ),GFP_KERNEL );if (!device) {return NULL ;
@@ -242,7 +242,7 @@ static inline RNDIS_REQUEST* GetRndisReqRNDIS_MESSAGE *rndisMessage;RNDIS_SET_REQUEST *set; - request =MemAllocZeroed (sizeof (RNDIS_REQUEST )); + request =kzalloc (sizeof (RNDIS_REQUEST ),GFP_KERNEL );if (!request) {return NULL ;
drivers/staging/hv/StorVsc.c +1 -1
@@ -147,7 +147,7 @@ static inline STORVSC_DEVICE* AllocStorD {STORVSC_DEVICE *storDevice; - storDevice =MemAllocZeroed (sizeof (STORVSC_DEVICE )); + storDevice =kzalloc (sizeof (STORVSC_DEVICE ),GFP_KERNEL );if (!storDevice)return NULL ;
PATCH 40/54 Staging: hv: osd: remove MemAllocAtomic wrapper
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
Use the "real" kmalloc call instead of a wrapper function.
--- drivers/staging/hv/ChannelMgmt.c | 3 +-- drivers/staging/hv/Hv.c | 2 +- drivers/staging/hv/NetVsc.c | 2 +- drivers/staging/hv/Vmbus.c | 2 +- drivers/staging/hv/include/osd.h | 1 - drivers/staging/hv/osd.c | 5 ----- 6 files changed, 4 insertions(+), 11 deletions(-)
drivers/staging/hv/ChannelMgmt.c +1 -2
@@ -143,13 +143,12 @@ VMBUS_CHANNEL* AllocVmbusChannel(void) {VMBUS_CHANNEL * channel; - channel = (VMBUS_CHANNEL *)MemAllocAtomic (sizeof (VMBUS_CHANNEL )); + channel =kzalloc (sizeof (VMBUS_CHANNEL ),GFP_ATOMIC );if (!channel) {return NULL ; } -memset (channel,0 ,sizeof (VMBUS_CHANNEL )); channel->InboundLock =SpinlockCreate ();if (!channel->InboundLock) {
drivers/staging/hv/Hv.c +1 -1
@@ -414,7 +414,7 @@ HvPostMessage(return -1 ; } - addr = (unsigned long )MemAllocAtomic (sizeof (struct alignedInput )); + addr = (unsigned long )kmalloc (sizeof (struct alignedInput ),GFP_ATOMIC );if (!addr) {
drivers/staging/hv/include/osd.h +0 -1
@@ -121,7 +121,6 @@ extern void PageFree(void* page, unsigneextern void *MemMapIO (unsigned long phys,unsigned long size);extern void MemUnmapIO (void * virt); -extern void *MemAllocAtomic (unsigned int size);extern void MemFree (void * buf);extern void MemoryFence (void );
drivers/staging/hv/NetVsc.c +1 -1
@@ -1480,7 +1480,7 @@ NetVscOnChannelCallback( }else if (ret ==-2 )// Handle large packet { - buffer =MemAllocAtomic (bytesRecvd); + buffer =kmalloc (bytesRecvd,GFP_ATOMIC );if (buffer ==NULL ) {// Try again next time around
drivers/staging/hv/osd.c +0 -5
@@ -189,11 +189,6 @@ void PageUnmapVirtualAddress(void* VirtAkunmap_atomic (VirtAddr,KM_IRQ0 ); } -void *MemAllocAtomic (unsigned int size) -{ -return kmalloc (size,GFP_ATOMIC ); -} -void MemFree (void * buf) {kfree (buf);
drivers/staging/hv/Vmbus.c +1 -1
@@ -411,7 +411,7 @@ VmbusOnMsgDPC( }else { - copied =MemAllocAtomic (sizeof (HV_MESSAGE )); + copied =kmalloc (sizeof (HV_MESSAGE ),GFP_ATOMIC );if (copied ==NULL ) {continue ;
PATCH 41/54 Staging: hv: osd: remove MemFree wrapper
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
Use the "real" kfree call instead of a wrapper function.
--- drivers/staging/hv/Channel.c | 8 ++++---- drivers/staging/hv/ChannelMgmt.c | 14 +++++++------- drivers/staging/hv/Connection.c | 6 +++--- drivers/staging/hv/Hv.c | 4 ++-- drivers/staging/hv/NetVsc.c | 12 ++++++------ drivers/staging/hv/RndisFilter.c | 8 ++++---- drivers/staging/hv/StorVsc.c | 2 +- drivers/staging/hv/include/osd.h | 1 - drivers/staging/hv/osd.c | 5 ----- 9 files changed, 27 insertions(+), 33 deletions(-)
drivers/staging/hv/Channel.c +4 -4
@@ -311,7 +311,7 @@ Cleanup:SpinlockRelease (gVmbusConnection.ChannelMsgLock);WaitEventClose (openInfo->WaitEvent); -MemFree (openInfo); +kfree (openInfo);DPRINT_EXIT (VMBUS );
@@ -597,7 +597,7 @@ Cleanup:SpinlockRelease (gVmbusConnection.ChannelMsgLock);WaitEventClose (msgInfo->WaitEvent); -MemFree (msgInfo); +kfree (msgInfo);DPRINT_EXIT (VMBUS );
@@ -658,7 +658,7 @@ VmbusChannelTeardownGpadl(SpinlockRelease (gVmbusConnection.ChannelMsgLock);WaitEventClose (info->WaitEvent); -MemFree (info); +kfree (info);DPRINT_EXIT (VMBUS );
@@ -720,7 +720,7 @@ VmbusChannelClose(PageFree (Channel->RingBufferPages, Channel->RingBufferPageCount); -MemFree (info); +kfree (info);// If we are closing the channel during an error path in opening the channel, don't free the channel // since the caller will free the channel
drivers/staging/hv/ChannelMgmt.c +7 -7
@@ -152,7 +152,7 @@ VMBUS_CHANNEL* AllocVmbusChannel(void) channel->InboundLock =SpinlockCreate ();if (!channel->InboundLock) { -MemFree (channel); +kfree (channel);return NULL ; }
@@ -160,7 +160,7 @@ VMBUS_CHANNEL* AllocVmbusChannel(void)if (!channel->PollTimer) {SpinlockClose (channel->InboundLock); -MemFree (channel); +kfree (channel);return NULL ; }
@@ -170,7 +170,7 @@ VMBUS_CHANNEL* AllocVmbusChannel(void) {TimerClose (channel->PollTimer);SpinlockClose (channel->InboundLock); -MemFree (channel); +kfree (channel);return NULL ; }
@@ -196,7 +196,7 @@ static inline void ReleaseVmbusChannel(vWorkQueueClose (channel->ControlWQ);DPRINT_DBG (VMBUS ,"channel released (%p)" , channel); -MemFree (channel); +kfree (channel);DPRINT_EXIT (VMBUS ); }
@@ -691,7 +691,7 @@ VmbusOnChannelMessage( {DPRINT_ERR (VMBUS ,"Received invalid channel message type %d size %d" , hdr->MessageType, size);PrintBytes ((unsigned char *)msg->u.Payload, size); -MemFree (msg); +kfree (msg);return ; }
@@ -705,7 +705,7 @@ VmbusOnChannelMessage( }// Free the msg that was allocated in VmbusOnMsgDPC() -MemFree (msg); +kfree (msg);DPRINT_EXIT (VMBUS ); }
@@ -764,7 +764,7 @@ Cleanup:if (msgInfo) {WaitEventClose (msgInfo->WaitEvent); -MemFree (msgInfo); +kfree (msgInfo); }DPRINT_EXIT (VMBUS );
drivers/staging/hv/Connection.c +3 -3
@@ -145,7 +145,7 @@ VmbusConnect(WaitEventClose (msgInfo->WaitEvent); -MemFree (msgInfo); +kfree (msgInfo);DPRINT_EXIT (VMBUS );return 0 ;
@@ -175,7 +175,7 @@ Cleanup:if (msgInfo->WaitEvent)WaitEventClose (msgInfo->WaitEvent); -MemFree (msgInfo); +kfree (msgInfo); }DPRINT_EXIT (VMBUS );
@@ -233,7 +233,7 @@ VmbusDisconnect( Cleanup:if (msg) { -MemFree (msg); +kfree (msg); }DPRINT_EXIT (VMBUS );
drivers/staging/hv/Hv.c +2 -2
@@ -361,7 +361,7 @@ HvCleanup (if (gHvContext.SignalEventBuffer) { -MemFree (gHvContext.SignalEventBuffer); +kfree (gHvContext.SignalEventBuffer); gHvContext.SignalEventBuffer =NULL ; gHvContext.SignalEventParam =NULL ; }
@@ -430,7 +430,7 @@ HvPostMessage( status =HvDoHypercall (HvCallPostMessage, alignedMsg,0 ) &0xFFFF ; -MemFree ((void *)addr); +kfree ((void *)addr);return status; }
drivers/staging/hv/include/osd.h +0 -1
@@ -121,7 +121,6 @@ extern void PageFree(void* page, unsigneextern void *MemMapIO (unsigned long phys,unsigned long size);extern void MemUnmapIO (void * virt); -extern void MemFree (void * buf);extern void MemoryFence (void );extern HANDLE TimerCreate (PFN_TIMER_CALLBACK pfnTimerCB,void * context);
drivers/staging/hv/NetVsc.c +6 -6
@@ -139,7 +139,7 @@ static inline void FreeNetDevice(NETVSC_ {ASSERT (Device->RefCount ==0 ); Device->Device->Extension =NULL ; -MemFree (Device); +kfree (Device); }
@@ -563,7 +563,7 @@ NetVscDestroyReceiveBuffer(if (NetDevice->ReceiveSections) { -MemFree (NetDevice->ReceiveSections); +kfree (NetDevice->ReceiveSections); NetDevice->ReceiveSections =NULL ; NetDevice->ReceiveSectionCount =0 ; }
@@ -873,7 +873,7 @@ Cleanup: { entry =REMOVE_HEAD_LIST (&netDevice->ReceivePacketList); packet =CONTAINING_RECORD (entry,NETVSC_PACKET , ListEntry); -MemFree (packet); +kfree (packet); }SpinlockClose (netDevice->ReceivePacketListLock);
@@ -949,7 +949,7 @@ NetVscOnDeviceRemove( entry =REMOVE_HEAD_LIST (&netDevice->ReceivePacketList); netvscPacket =CONTAINING_RECORD (entry,NETVSC_PACKET , ListEntry); -MemFree (netvscPacket); +kfree (netvscPacket); }SpinlockClose (netDevice->ReceivePacketListLock);
@@ -1456,7 +1456,7 @@ NetVscOnChannelCallback(// reset if (bufferlen > netPacketSize) { -MemFree (buffer); +kfree (buffer); buffer = packet; bufferlen = netPacketSize;
@@ -1469,7 +1469,7 @@ NetVscOnChannelCallback(// reset if (bufferlen > netPacketSize) { -MemFree (buffer); +kfree (buffer); buffer = packet; bufferlen = netPacketSize;
drivers/staging/hv/osd.c +0 -5
@@ -189,11 +189,6 @@ void PageUnmapVirtualAddress(void* VirtAkunmap_atomic (VirtAddr,KM_IRQ0 ); } -void MemFree (void * buf) -{ -kfree (buf); -} -void *MemMapIO (unsigned long phys,unsigned long size) {#if X2V_LINUX
drivers/staging/hv/RndisFilter.c +4 -4
@@ -219,7 +219,7 @@ static inline RNDIS_DEVICE* GetRndisDevi device->RequestLock =SpinlockCreate ();if (!device->RequestLock) { -MemFree (device); +kfree (device);return NULL ; }
@@ -233,7 +233,7 @@ static inline RNDIS_DEVICE* GetRndisDevistatic inline void PutRndisDevice (RNDIS_DEVICE *Device) {SpinlockClose (Device->RequestLock); -MemFree (Device); +kfree (Device); }static inline RNDIS_REQUEST *GetRndisRequest (RNDIS_DEVICE *Device,u32 MessageType,u32 MessageLength)
@@ -251,7 +251,7 @@ static inline RNDIS_REQUEST* GetRndisReq request->WaitEvent =WaitEventCreate ();if (!request->WaitEvent) { -MemFree (request); +kfree (request);return NULL ; }
@@ -279,7 +279,7 @@ static inline void PutRndisRequest(RNDISSpinlockRelease (Device->RequestLock);WaitEventClose (Request->WaitEvent); -MemFree (Request); +kfree (Request); }static inline void DumpRndisMessage (RNDIS_MESSAGE *RndisMessage)
drivers/staging/hv/StorVsc.c +1 -1
@@ -164,7 +164,7 @@ static inline STORVSC_DEVICE* AllocStorDstatic inline void FreeStorDevice (STORVSC_DEVICE *Device) {ASSERT (Device->RefCount ==0 ); -MemFree (Device); +kfree (Device); }// Get the stordevice object iff exists and its refcount > 1
PATCH 42/54 Staging: hv: make Channel->InboundLock a real spinlock
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
Don't use the wrapper functions for this lock, make it a real lock so that we know what is going on.
I don't think we really want to be doing a irqsave for this code, but I left it alone to preserve the original codepath. It should be reviewed later.
--- drivers/staging/hv/Channel.c | 18 ++++++++++-------- drivers/staging/hv/ChannelMgmt.c | 10 +--------- drivers/staging/hv/ChannelMgmt.h | 2 +- 3 files changed, 12 insertions(+), 18 deletions(-)
drivers/staging/hv/Channel.c +10 -8
@@ -991,18 +991,19 @@ VmbusChannelRecvPacket(u32 packetLen;u32 userLen;int ret; +unsigned long flags;DPRINT_ENTER (VMBUS ); *BufferActualLen =0 ; *RequestId =0 ; -SpinlockAcquire (Channel->InboundLock); +spin_lock_irqsave (&Channel->inbound_lock, flags); ret =RingBufferPeek (&Channel->Inbound, &desc,sizeof (VMPACKET_DESCRIPTOR ));if (ret !=0 ) { -SpinlockRelease (Channel->InboundLock); +spin_unlock_irqrestore (&Channel->inbound_lock, flags);//DPRINT_DBG(VMBUS, "nothing to read!!"); DPRINT_EXIT (VMBUS );
@@ -1026,7 +1027,7 @@ VmbusChannelRecvPacket(if (userLen > BufferLen) { -SpinlockRelease (Channel->InboundLock); +spin_unlock_irqrestore (&Channel->inbound_lock, flags);DPRINT_ERR (VMBUS ,"buffer too small - got %d needs %d" , BufferLen, userLen);DPRINT_EXIT (VMBUS );
@@ -1039,7 +1040,7 @@ VmbusChannelRecvPacket(// Copy over the packet to the user buffer ret =RingBufferRead (&Channel->Inbound, Buffer, userLen, (desc.DataOffset8 <<3 )); -SpinlockRelease (Channel->InboundLock); +spin_unlock_irqrestore (&Channel->inbound_lock, flags);DPRINT_EXIT (VMBUS );
@@ -1068,18 +1069,19 @@ VmbusChannelRecvPacketRaw(u32 packetLen;u32 userLen;int ret; +unsigned long flags;DPRINT_ENTER (VMBUS ); *BufferActualLen =0 ; *RequestId =0 ; -SpinlockAcquire (Channel->InboundLock); +spin_lock_irqsave (&Channel->inbound_lock, flags); ret =RingBufferPeek (&Channel->Inbound, &desc,sizeof (VMPACKET_DESCRIPTOR ));if (ret !=0 ) { -SpinlockRelease (Channel->InboundLock); +spin_unlock_irqrestore (&Channel->inbound_lock, flags);//DPRINT_DBG(VMBUS, "nothing to read!!"); DPRINT_EXIT (VMBUS );
@@ -1102,7 +1104,7 @@ VmbusChannelRecvPacketRaw(if (packetLen > BufferLen) { -SpinlockRelease (Channel->InboundLock); +spin_unlock_irqrestore (&Channel->inbound_lock, flags);DPRINT_ERR (VMBUS ,"buffer too small - needed %d bytes but got space for only %d bytes" , packetLen, BufferLen);DPRINT_EXIT (VMBUS );
@@ -1114,7 +1116,7 @@ VmbusChannelRecvPacketRaw(// Copy over the entire packet to the user buffer ret =RingBufferRead (&Channel->Inbound, Buffer, packetLen,0 ); -SpinlockRelease (Channel->InboundLock); +spin_unlock_irqrestore (&Channel->inbound_lock, flags);DPRINT_EXIT (VMBUS );
drivers/staging/hv/ChannelMgmt.c +1 -9
@@ -149,17 +149,11 @@ VMBUS_CHANNEL* AllocVmbusChannel(void)return NULL ; } - channel->InboundLock =SpinlockCreate (); -if (!channel->InboundLock) - { -kfree (channel); -return NULL ; - } +spin_lock_init (&channel->inbound_lock); channel->PollTimer =TimerCreate (VmbusChannelOnTimer, channel);if (!channel->PollTimer) { -SpinlockClose (channel->InboundLock);kfree (channel);return NULL ; }
@@ -169,7 +163,6 @@ VMBUS_CHANNEL* AllocVmbusChannel(void)if (!channel->ControlWQ) {TimerClose (channel->PollTimer); -SpinlockClose (channel->InboundLock);kfree (channel);return NULL ; }
@@ -212,7 +205,6 @@ Description:--*/ void FreeVmbusChannel (VMBUS_CHANNEL * Channel) { -SpinlockClose (Channel->InboundLock);TimerClose (Channel->PollTimer);// We have to release the channel's workqueue/thread in the vmbus's workqueue/thread context
drivers/staging/hv/ChannelMgmt.h +1 -1
@@ -63,7 +63,7 @@ typedef struct _VMBUS_CHANNEL {u32 RingBufferPageCount;RING_BUFFER_INFO Outbound;// send to parent RING_BUFFER_INFO Inbound;// receive from parent -HANDLE InboundLock; +spinlock_t inbound_lock;HANDLE ControlWQ;// Channel callback are invoked in this workqueue context
PATCH 43/54 Staging: hv: make RingInfo->RingLock a real spinlock
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
Don't use the wrapper functions for this lock, make it a real lock so that we know what is going on.
I don't think we really want to be doing a irqsave for this code, but I left it alone to preserve the original codepath. It should be reviewed later.
--- drivers/staging/hv/RingBuffer.c | 24 +++++++++++++----------- drivers/staging/hv/RingBuffer.h | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-)
drivers/staging/hv/RingBuffer.c +13 -11
@@ -315,7 +315,7 @@ RingBufferInit( RingInfo->RingSize = BufferLen; RingInfo->RingDataSize = BufferLen -sizeof (RING_BUFFER ); - RingInfo->RingLock =SpinlockCreate (); +spin_lock_init (&RingInfo->ring_lock);return 0 ; }
@@ -334,7 +334,6 @@ RingBufferCleanup(RING_BUFFER_INFO * RingInfo ) { -SpinlockClose (RingInfo->RingLock); }/*++
@@ -360,6 +359,7 @@ RingBufferWrite(volatile u32 nextWriteLocation;u64 prevIndices=0 ; +unsigned long flags;DPRINT_ENTER (VMBUS );
@@ -370,7 +370,7 @@ RingBufferWrite( totalBytesToWrite +=sizeof (u64); -SpinlockAcquire (OutRingInfo->RingLock); +spin_lock_irqsave (&OutRingInfo->ring_lock, flags);GetRingBufferAvailBytes (OutRingInfo, &byteAvailToRead, &byteAvailToWrite);
@@ -384,7 +384,7 @@ RingBufferWrite( {DPRINT_DBG (VMBUS ,"No more space left on outbound ring buffer (needed %u, avail %u)" , totalBytesToWrite, byteAvailToWrite); -SpinlockRelease (OutRingInfo->RingLock); +spin_unlock_irqrestore (&OutRingInfo->ring_lock, flags);DPRINT_EXIT (VMBUS );
@@ -418,7 +418,7 @@ RingBufferWrite(//DumpRingInfo(OutRingInfo, "AFTER "); -SpinlockRelease (OutRingInfo->RingLock); +spin_unlock_irqrestore (&OutRingInfo->ring_lock, flags);DPRINT_EXIT (VMBUS );
@@ -445,8 +445,9 @@ RingBufferPeek(u32 bytesAvailToWrite;u32 bytesAvailToRead;u32 nextReadLocation=0 ; +unsigned long flags; -SpinlockAcquire (InRingInfo->RingLock); +spin_lock_irqsave (&InRingInfo->ring_lock, flags);GetRingBufferAvailBytes (InRingInfo, &bytesAvailToRead, &bytesAvailToWrite);
@@ -455,7 +456,7 @@ RingBufferPeek( {//DPRINT_DBG(VMBUS, "got callback but not enough to read <avail to read %d read size %d>!!", bytesAvailToRead, BufferLen); -SpinlockRelease (InRingInfo->RingLock); +spin_unlock_irqrestore (&InRingInfo->ring_lock, flags);return -1 ; }
@@ -468,7 +469,7 @@ RingBufferPeek( BufferLen, nextReadLocation); -SpinlockRelease (InRingInfo->RingLock); +spin_unlock_irqrestore (&InRingInfo->ring_lock, flags);return 0 ; }
@@ -495,10 +496,11 @@ RingBufferRead(u32 bytesAvailToRead;u32 nextReadLocation=0 ;u64 prevIndices=0 ; +unsigned long flags;ASSERT (BufferLen >0 ); -SpinlockAcquire (InRingInfo->RingLock); +spin_lock_irqsave (&InRingInfo->ring_lock, flags);GetRingBufferAvailBytes (InRingInfo, &bytesAvailToRead, &bytesAvailToWrite);
@@ -511,7 +513,7 @@ RingBufferRead( {DPRINT_DBG (VMBUS ,"got callback but not enough to read <avail to read %d read size %d>!!" , bytesAvailToRead, BufferLen); -SpinlockRelease (InRingInfo->RingLock); +spin_unlock_irqrestore (&InRingInfo->ring_lock, flags);return -1 ; }
@@ -537,7 +539,7 @@ RingBufferRead(//DumpRingInfo(InRingInfo, "AFTER "); -SpinlockRelease (InRingInfo->RingLock); +spin_unlock_irqrestore (&InRingInfo->ring_lock, flags);return 0 ; }
drivers/staging/hv/RingBuffer.h +1 -1
@@ -48,7 +48,7 @@ typedef struct _RING_BUFFER { typedef struct _RING_BUFFER_INFO { RING_BUFFER* RingBuffer; u32 RingSize; // Include the shared header - HANDLE RingLock; + spinlock_t ring_lock; u32 RingDataSize; // < ringSize u32 RingDataStartOffset;
PATCH 44/54 Staging: hv: make Device->RequestLock a real spinlock
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
Don't use the wrapper functions for this lock, make it a real lock so that we know what is going on.
I don't think we really want to be doing a irqsave for this code, but I left it alone to preserve the original codepath. It should be reviewed later.
--- drivers/staging/hv/RndisFilter.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-)
drivers/staging/hv/RndisFilter.c +12 -14
@@ -54,7 +54,7 @@ typedef struct _RNDIS_DEVICE {u32 LinkStatus;u32 NewRequestId; -HANDLE RequestLock; +spinlock_t request_lock;LIST_ENTRY RequestList;unsigned char HwMacAddr[HW_MACADDR_LEN ];
@@ -216,12 +216,7 @@ static inline RNDIS_DEVICE* GetRndisDevireturn NULL ; } - device->RequestLock =SpinlockCreate (); -if (!device->RequestLock) - { -kfree (device); -return NULL ; - } +spin_lock_init (&device->request_lock);INITIALIZE_LIST_HEAD (&device->RequestList);
@@ -232,7 +227,6 @@ static inline RNDIS_DEVICE* GetRndisDevistatic inline void PutRndisDevice (RNDIS_DEVICE *Device) { -SpinlockClose (Device->RequestLock);kfree (Device); }
@@ -241,6 +235,7 @@ static inline RNDIS_REQUEST* GetRndisReqRNDIS_REQUEST *request;RNDIS_MESSAGE *rndisMessage;RNDIS_SET_REQUEST *set; +unsigned long flags; request =kzalloc (sizeof (RNDIS_REQUEST ),GFP_KERNEL );if (!request)
@@ -265,18 +260,20 @@ static inline RNDIS_REQUEST* GetRndisReq set->RequestId =InterlockedIncrement ((int *)&Device->NewRequestId);// Add to the request list -SpinlockAcquire (Device->RequestLock); +spin_lock_irqsave (&Device->request_lock, flags);INSERT_TAIL_LIST (&Device->RequestList, &request->ListEntry); -SpinlockRelease (Device->RequestLock); +spin_unlock_irqrestore (&Device->request_lock, flags);return request; }static inline void PutRndisRequest (RNDIS_DEVICE *Device,RNDIS_REQUEST *Request) { -SpinlockAcquire (Device->RequestLock); +unsigned long flags; + +spin_lock_irqsave (&Device->request_lock, flags);REMOVE_ENTRY_LIST (&Request->ListEntry); -SpinlockRelease (Device->RequestLock); +spin_unlock_irqrestore (&Device->request_lock, flags);WaitEventClose (Request->WaitEvent);kfree (Request);
@@ -385,10 +382,11 @@ RndisFilterReceiveResponse(LIST_ENTRY *curr;RNDIS_REQUEST *request=NULL ;bool found = false; +unsigned long flags;DPRINT_ENTER (NETVSC ); -SpinlockAcquire (Device->RequestLock); +spin_lock_irqsave (&Device->request_lock, flags); ITERATE_LIST_ENTRIES(anchor, curr, &Device->RequestList) { request =CONTAINING_RECORD (curr,RNDIS_REQUEST , ListEntry);
@@ -403,7 +401,7 @@ RndisFilterReceiveResponse(break ; } } -SpinlockRelease (Device->RequestLock); +spin_unlock_irqrestore (&Device->request_lock, flags);if (found) {
PATCH 45/54 Staging: hv: make netDevice->ReceivePacketListLock a real spinlock
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
Don't use the wrapper functions for this lock, make it a real lock so that we know what is going on.
I don't think we really want to be doing a irqsave for this code, but I left it alone to preserve the original codepath. It should be reviewed later.
--- drivers/staging/hv/NetVsc.c | 19 +++++++++---------- drivers/staging/hv/NetVsc.h | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-)
drivers/staging/hv/NetVsc.c +9 -10
@@ -807,7 +807,7 @@ NetVscOnDeviceAdd(// Initialize the NetVSC channel extension netDevice->ReceiveBufferSize =NETVSC_RECEIVE_BUFFER_SIZE ; - netDevice->ReceivePacketListLock =SpinlockCreate (); +spin_lock_init (&netDevice->receive_packet_list_lock); netDevice->SendBufferSize =NETVSC_SEND_BUFFER_SIZE ;
@@ -876,8 +876,6 @@ Cleanup:kfree (packet); } -SpinlockClose (netDevice->ReceivePacketListLock); -ReleaseOutboundNetDevice (Device);ReleaseInboundNetDevice (Device);
@@ -952,7 +950,6 @@ NetVscOnDeviceRemove(kfree (netvscPacket); } -SpinlockClose (netDevice->ReceivePacketListLock);WaitEventClose (netDevice->ChannelInitEvent);FreeNetDevice (netDevice);
@@ -1118,6 +1115,7 @@ NetVscOnReceive(int i=0 , j=0 ;int count=0 , bytesRemain=0 ; +unsigned long flags;DPRINT_ENTER (NETVSC );
@@ -1164,7 +1162,7 @@ NetVscOnReceive(// Grab free packets (range count + 1) to represent this xfer page packet. +1 to represent // the xfer page packet itself. We grab it here so that we know exactly how many we can fulfil -SpinlockAcquire (netDevice->ReceivePacketListLock); +spin_lock_irqsave (&netDevice->receive_packet_list_lock, flags);while (!IsListEmpty (&netDevice->ReceivePacketList)) { entry =REMOVE_HEAD_LIST (&netDevice->ReceivePacketList);
@@ -1175,7 +1173,7 @@ NetVscOnReceive(if (++count == vmxferpagePacket->RangeCount +1 )break ; } -SpinlockRelease (netDevice->ReceivePacketListLock); +spin_unlock_irqrestore (&netDevice->receive_packet_list_lock, flags);// We need at least 2 netvsc pkts (1 to represent the xfer page and at least 1 for the range) // i.e. we can handled some of the xfer page packet ranges...
@@ -1184,7 +1182,7 @@ NetVscOnReceive(DPRINT_ERR (NETVSC ,"Got only %d netvsc pkt...needed %d pkts. Dropping this xfer page packet completely!" , count, vmxferpagePacket->RangeCount+1 );// Return it to the freelist -SpinlockAcquire (netDevice->ReceivePacketListLock); +spin_lock_irqsave (&netDevice->receive_packet_list_lock, flags);for (i=count; i !=0 ; i--) { entry =REMOVE_HEAD_LIST (&listHead);
@@ -1192,7 +1190,7 @@ NetVscOnReceive(INSERT_TAIL_LIST (&netDevice->ReceivePacketList, &netvscPacket->ListEntry); } -SpinlockRelease (netDevice->ReceivePacketListLock); +spin_unlock_irqrestore (&netDevice->receive_packet_list_lock, flags);NetVscSendReceiveCompletion (Device, vmxferpagePacket->d.TransactionId);
@@ -1346,6 +1344,7 @@ NetVscOnReceiveCompletion(NETVSC_DEVICE * netDevice;u64 transactionId=0 ;bool fSendReceiveComp = false; +unsigned long flags;DPRINT_ENTER (NETVSC );
@@ -1362,7 +1361,7 @@ NetVscOnReceiveCompletion( }// Overloading use of the lock. -SpinlockAcquire (netDevice->ReceivePacketListLock); +spin_lock_irqsave (&netDevice->receive_packet_list_lock, flags);ASSERT (packet->XferPagePacket->Count >0 ); packet->XferPagePacket->Count--;
@@ -1379,7 +1378,7 @@ NetVscOnReceiveCompletion(// Put the packet back INSERT_TAIL_LIST (&netDevice->ReceivePacketList, &packet->ListEntry); -SpinlockRelease (netDevice->ReceivePacketListLock); +spin_unlock_irqrestore (&netDevice->receive_packet_list_lock, flags);// Send a receive completion for the xfer page packet if (fSendReceiveComp)
drivers/staging/hv/NetVsc.h +1 -1
@@ -62,7 +62,7 @@ typedef struct _NETVSC_DEVICE {int NumOutstandingSends;// List of free preallocated NETVSC_PACKET to represent receive packet LIST_ENTRY ReceivePacketList; -HANDLE ReceivePacketListLock; +spinlock_t receive_packet_list_lock;// Send buffer allocated by us but manages by NetVSP void * SendBuffer;
PATCH 46/54 Staging: hv: make gVmbusConnection.ChannelMsgLock a real spinlock
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
Don't use the wrapper functions for this lock, make it a real lock so that we know what is going on.
I don't think we really want to be doing a irqsave for this code, but I left it alone to preserve the original codepath. It should be reviewed later.
--- drivers/staging/hv/Channel.c | 27 +++++++++++++++------------ drivers/staging/hv/ChannelMgmt.c | 20 ++++++++++++-------- drivers/staging/hv/Connection.c | 10 ++++------ drivers/staging/hv/VmbusPrivate.h | 2 +- 4 files changed, 32 insertions(+), 27 deletions(-)
drivers/staging/hv/Channel.c +15 -12
@@ -214,6 +214,7 @@ VmbusChannelOpen(VMBUS_CHANNEL_OPEN_CHANNEL * openMsg;VMBUS_CHANNEL_MSGINFO * openInfo;void *in, *out; +unsigned long flags;DPRINT_ENTER (VMBUS );
@@ -280,9 +281,9 @@ VmbusChannelOpen(memcpy (openMsg->UserData, UserData, UserDataLen); } -SpinlockAcquire (gVmbusConnection.ChannelMsgLock); +spin_lock_irqsave (&gVmbusConnection.channelmsg_lock, flags);INSERT_TAIL_LIST (&gVmbusConnection.ChannelMsgList, &openInfo->MsgListEntry); -SpinlockRelease (gVmbusConnection.ChannelMsgLock); +spin_unlock_irqrestore (&gVmbusConnection.channelmsg_lock, flags);DPRINT_DBG (VMBUS ,"Sending channel open msg..." );
@@ -306,9 +307,9 @@ VmbusChannelOpen( } Cleanup: -SpinlockAcquire (gVmbusConnection.ChannelMsgLock); +spin_lock_irqsave (&gVmbusConnection.channelmsg_lock, flags);REMOVE_ENTRY_LIST (&openInfo->MsgListEntry); -SpinlockRelease (gVmbusConnection.ChannelMsgLock); +spin_unlock_irqrestore (&gVmbusConnection.channelmsg_lock, flags);WaitEventClose (openInfo->WaitEvent);kfree (openInfo);
@@ -531,6 +532,7 @@ VmbusChannelEstablishGpadl(LIST_ENTRY * anchor;LIST_ENTRY * curr;u32 nextGpadlHandle; +unsigned long flags;DPRINT_ENTER (VMBUS );
@@ -549,9 +551,9 @@ VmbusChannelEstablishGpadl(DumpGpadlHeader (gpadlMsg); -SpinlockAcquire (gVmbusConnection.ChannelMsgLock); +spin_lock_irqsave (&gVmbusConnection.channelmsg_lock, flags);INSERT_TAIL_LIST (&gVmbusConnection.ChannelMsgList, &msgInfo->MsgListEntry); -SpinlockRelease (gVmbusConnection.ChannelMsgLock); +spin_unlock_irqrestore (&gVmbusConnection.channelmsg_lock, flags);DPRINT_DBG (VMBUS ,"buffer %p, size %d msg cnt %d" , Kbuffer, Size, msgCount);
@@ -592,9 +594,9 @@ VmbusChannelEstablishGpadl( *GpadlHandle = gpadlMsg->Gpadl; Cleanup: -SpinlockAcquire (gVmbusConnection.ChannelMsgLock); +spin_lock_irqsave (&gVmbusConnection.channelmsg_lock, flags);REMOVE_ENTRY_LIST (&msgInfo->MsgListEntry); -SpinlockRelease (gVmbusConnection.ChannelMsgLock); +spin_unlock_irqrestore (&gVmbusConnection.channelmsg_lock, flags);WaitEventClose (msgInfo->WaitEvent);kfree (msgInfo);
@@ -624,6 +626,7 @@ VmbusChannelTeardownGpadl(int ret=0 ;VMBUS_CHANNEL_GPADL_TEARDOWN *msg;VMBUS_CHANNEL_MSGINFO * info; +unsigned long flags;DPRINT_ENTER (VMBUS );
@@ -640,9 +643,9 @@ VmbusChannelTeardownGpadl( msg->ChildRelId = Channel->OfferMsg.ChildRelId; msg->Gpadl = GpadlHandle; -SpinlockAcquire (gVmbusConnection.ChannelMsgLock); +spin_lock_irqsave (&gVmbusConnection.channelmsg_lock, flags);INSERT_TAIL_LIST (&gVmbusConnection.ChannelMsgList, &info->MsgListEntry); -SpinlockRelease (gVmbusConnection.ChannelMsgLock); +spin_unlock_irqrestore (&gVmbusConnection.channelmsg_lock, flags); ret =VmbusPostMessage (msg,sizeof (VMBUS_CHANNEL_GPADL_TEARDOWN ));if (ret !=0 )
@@ -653,9 +656,9 @@ VmbusChannelTeardownGpadl(WaitEventWait (info->WaitEvent);// Received a torndown response -SpinlockAcquire (gVmbusConnection.ChannelMsgLock); +spin_lock_irqsave (&gVmbusConnection.channelmsg_lock, flags);REMOVE_ENTRY_LIST (&info->MsgListEntry); -SpinlockRelease (gVmbusConnection.ChannelMsgLock); +spin_unlock_irqrestore (&gVmbusConnection.channelmsg_lock, flags);WaitEventClose (info->WaitEvent);kfree (info);
drivers/staging/hv/ChannelMgmt.c +12 -8
@@ -472,13 +472,14 @@ VmbusChannelOnOpenResult(VMBUS_CHANNEL_MSGINFO * msgInfo;VMBUS_CHANNEL_MESSAGE_HEADER * requestHeader;VMBUS_CHANNEL_OPEN_CHANNEL * openMsg; +unsigned long flags;DPRINT_ENTER (VMBUS );DPRINT_DBG (VMBUS ,"vmbus open result - %d" , result->Status);// Find the open msg, copy the result and signal/unblock the wait event -SpinlockAcquire (gVmbusConnection.ChannelMsgLock); +spin_lock_irqsave (&gVmbusConnection.channelmsg_lock, flags); ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelMsgList) {
@@ -497,7 +498,7 @@ VmbusChannelOnOpenResult( } } } -SpinlockRelease (gVmbusConnection.ChannelMsgLock); +spin_unlock_irqrestore (&gVmbusConnection.channelmsg_lock, flags);DPRINT_EXIT (VMBUS ); }
@@ -525,13 +526,14 @@ VmbusChannelOnGpadlCreated(VMBUS_CHANNEL_MSGINFO *msgInfo;VMBUS_CHANNEL_MESSAGE_HEADER *requestHeader;VMBUS_CHANNEL_GPADL_HEADER *gpadlHeader; +unsigned long flags;DPRINT_ENTER (VMBUS );DPRINT_DBG (VMBUS ,"vmbus gpadl created result - %d" , gpadlCreated->CreationStatus);// Find the establish msg, copy the result and signal/unblock the wait event -SpinlockAcquire (gVmbusConnection.ChannelMsgLock); +spin_lock_irqsave (&gVmbusConnection.channelmsg_lock, flags); ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelMsgList) {
@@ -551,7 +553,7 @@ VmbusChannelOnGpadlCreated( } } } -SpinlockRelease (gVmbusConnection.ChannelMsgLock); +spin_unlock_irqrestore (&gVmbusConnection.channelmsg_lock, flags);DPRINT_EXIT (VMBUS ); }
@@ -579,11 +581,12 @@ VmbusChannelOnGpadlTorndown(VMBUS_CHANNEL_MSGINFO * msgInfo;VMBUS_CHANNEL_MESSAGE_HEADER *requestHeader;VMBUS_CHANNEL_GPADL_TEARDOWN *gpadlTeardown; +unsigned long flags;DPRINT_ENTER (VMBUS );// Find the open msg, copy the result and signal/unblock the wait event -SpinlockAcquire (gVmbusConnection.ChannelMsgLock); +spin_lock_irqsave (&gVmbusConnection.channelmsg_lock, flags); ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelMsgList) {
@@ -602,7 +605,7 @@ VmbusChannelOnGpadlTorndown( } } } -SpinlockRelease (gVmbusConnection.ChannelMsgLock); +spin_unlock_irqrestore (&gVmbusConnection.channelmsg_lock, flags);DPRINT_EXIT (VMBUS ); }
@@ -630,10 +633,11 @@ VmbusChannelOnVersionResponse(VMBUS_CHANNEL_MESSAGE_HEADER *requestHeader;VMBUS_CHANNEL_INITIATE_CONTACT *initiate;VMBUS_CHANNEL_VERSION_RESPONSE *versionResponse = (VMBUS_CHANNEL_VERSION_RESPONSE *)hdr; +unsigned long flags;DPRINT_ENTER (VMBUS ); -SpinlockAcquire (gVmbusConnection.ChannelMsgLock); +spin_lock_irqsave (&gVmbusConnection.channelmsg_lock, flags); ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelMsgList) {
@@ -647,7 +651,7 @@ VmbusChannelOnVersionResponse(WaitEventSet (msgInfo->WaitEvent); } } -SpinlockRelease (gVmbusConnection.ChannelMsgLock); +spin_unlock_irqrestore (&gVmbusConnection.channelmsg_lock, flags);DPRINT_EXIT (VMBUS ); }
drivers/staging/hv/Connection.c +4 -6
@@ -53,6 +53,7 @@ VmbusConnect(int ret=0 ;VMBUS_CHANNEL_MSGINFO *msgInfo=NULL ;VMBUS_CHANNEL_INITIATE_CONTACT *msg; +unsigned long flags;DPRINT_ENTER (VMBUS );
@@ -65,7 +66,7 @@ VmbusConnect( gVmbusConnection.WorkQueue =WorkQueueCreate ("vmbusQ" );INITIALIZE_LIST_HEAD (&gVmbusConnection.ChannelMsgList); - gVmbusConnection.ChannelMsgLock =SpinlockCreate (); +spin_lock_init (&gVmbusConnection.channelmsg_lock);INITIALIZE_LIST_HEAD (&gVmbusConnection.ChannelList); gVmbusConnection.ChannelLock =SpinlockCreate ();
@@ -107,9 +108,9 @@ VmbusConnect(// Add to list before we send the request since we may receive the response // before returning from this routine -SpinlockAcquire (gVmbusConnection.ChannelMsgLock); +spin_lock_irqsave (&gVmbusConnection.channelmsg_lock, flags);INSERT_TAIL_LIST (&gVmbusConnection.ChannelMsgList, &msgInfo->MsgListEntry); -SpinlockRelease (gVmbusConnection.ChannelMsgLock); +spin_unlock_irqrestore (&gVmbusConnection.channelmsg_lock, flags);DPRINT_DBG (VMBUS ,"Vmbus connection - interrupt pfn %llx, monitor1 pfn %llx,, monitor2 pfn %llx" , msg->InterruptPage, msg->MonitorPage1, msg->MonitorPage2);
@@ -156,7 +157,6 @@ Cleanup:WorkQueueClose (gVmbusConnection.WorkQueue);SpinlockClose (gVmbusConnection.ChannelLock); -SpinlockClose (gVmbusConnection.ChannelMsgLock);if (gVmbusConnection.InterruptPage) {
@@ -222,8 +222,6 @@ VmbusDisconnect(// TODO: iterate thru the msg list and free up -SpinlockClose (gVmbusConnection.ChannelMsgLock); -WorkQueueClose (gVmbusConnection.WorkQueue); gVmbusConnection.ConnectState = Disconnected;
drivers/staging/hv/VmbusPrivate.h +1 -1
@@ -80,7 +80,7 @@ typedef struct _VMBUS_CONNECTION {// 2 pages - 1st page for parent->child notification and 2nd is child->parent notification void * MonitorPages;LIST_ENTRY ChannelMsgList; -HANDLE ChannelMsgLock; +spinlock_t channelmsg_lock;// List of channels LIST_ENTRY ChannelList;
PATCH 47/54 Staging: hv: make gVmbusConnection.ChannelLock a real spinlock
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
Don't use the wrapper functions for this lock, make it a real lock so that we know what is going on.
I don't think we really want to be doing a irqsave for this code, but I left it alone to preserve the original codepath. It should be reviewed later.
--- drivers/staging/hv/Channel.c | 5 +++-- drivers/staging/hv/ChannelMgmt.c | 14 ++++++++------ drivers/staging/hv/Connection.c | 8 ++++---- drivers/staging/hv/VmbusPrivate.h | 2 +- 4 files changed, 16 insertions(+), 13 deletions(-)
drivers/staging/hv/Channel.c +3 -2
@@ -686,6 +686,7 @@ VmbusChannelClose(int ret=0 ;VMBUS_CHANNEL_CLOSE_CHANNEL * msg;VMBUS_CHANNEL_MSGINFO * info; +unsigned long flags;DPRINT_ENTER (VMBUS );
@@ -729,9 +730,9 @@ VmbusChannelClose(// since the caller will free the channel if (Channel->State ==CHANNEL_OPEN_STATE ) { -SpinlockAcquire (gVmbusConnection.ChannelLock); +spin_lock_irqsave (&gVmbusConnection.channel_lock, flags);REMOVE_ENTRY_LIST (&Channel->ListEntry); -SpinlockRelease (gVmbusConnection.ChannelLock); +spin_unlock_irqrestore (&gVmbusConnection.channel_lock, flags);FreeVmbusChannel (Channel); }
drivers/staging/hv/ChannelMgmt.c +8 -6
@@ -233,11 +233,12 @@ VmbusChannelProcessOffer(LIST_ENTRY * curr;bool fNew = true;VMBUS_CHANNEL * channel; +unsigned long flags;DPRINT_ENTER (VMBUS );// Make sure this is a new offer -SpinlockAcquire (gVmbusConnection.ChannelLock); +spin_lock_irqsave (&gVmbusConnection.channel_lock, flags); ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelList) {
@@ -255,7 +256,7 @@ VmbusChannelProcessOffer( {INSERT_TAIL_LIST (&gVmbusConnection.ChannelList, &newChannel->ListEntry); } -SpinlockRelease (gVmbusConnection.ChannelLock); +spin_unlock_irqrestore (&gVmbusConnection.channel_lock, flags);if (!fNew) {
@@ -282,9 +283,9 @@ VmbusChannelProcessOffer(DPRINT_ERR (VMBUS ,"unable to add child device object (relid %d)" , newChannel->OfferMsg.ChildRelId); -SpinlockAcquire (gVmbusConnection.ChannelLock); +spin_lock_irqsave (&gVmbusConnection.channel_lock, flags);REMOVE_ENTRY_LIST (&newChannel->ListEntry); -SpinlockRelease (gVmbusConnection.ChannelLock); +spin_unlock_irqrestore (&gVmbusConnection.channel_lock, flags);FreeVmbusChannel (newChannel); }
@@ -785,8 +786,9 @@ VmbusChannelReleaseUnattachedChannels(LIST_ENTRY *entry;VMBUS_CHANNEL *channel;VMBUS_CHANNEL *start=NULL ; +unsigned long flags; -SpinlockAcquire (gVmbusConnection.ChannelLock); +spin_lock_irqsave (&gVmbusConnection.channel_lock, flags);while (!IsListEmpty (&gVmbusConnection.ChannelList)) {
@@ -813,7 +815,7 @@ VmbusChannelReleaseUnattachedChannels( } } -SpinlockRelease (gVmbusConnection.ChannelLock); +spin_unlock_irqrestore (&gVmbusConnection.channel_lock, flags); }// eof
drivers/staging/hv/Connection.c +4 -4
@@ -69,7 +69,7 @@ VmbusConnect(spin_lock_init (&gVmbusConnection.channelmsg_lock);INITIALIZE_LIST_HEAD (&gVmbusConnection.ChannelList); - gVmbusConnection.ChannelLock =SpinlockCreate (); +spin_lock_init (&gVmbusConnection.channel_lock);// Setup the vmbus event connection for channel interrupt abstraction stuff gVmbusConnection.InterruptPage =PageAlloc (1 );
@@ -156,7 +156,6 @@ Cleanup: gVmbusConnection.ConnectState = Disconnected;WorkQueueClose (gVmbusConnection.WorkQueue); -SpinlockClose (gVmbusConnection.ChannelLock);if (gVmbusConnection.InterruptPage) {
@@ -258,8 +257,9 @@ GetChannelFromRelId(VMBUS_CHANNEL * foundChannel=NULL ;LIST_ENTRY * anchor;LIST_ENTRY * curr; +unsigned long flags; -SpinlockAcquire (gVmbusConnection.ChannelLock); +spin_lock_irqsave (&gVmbusConnection.channel_lock, flags); ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelList) { channel =CONTAINING_RECORD (curr,VMBUS_CHANNEL , ListEntry);
@@ -270,7 +270,7 @@ GetChannelFromRelId(break ; } } -SpinlockRelease (gVmbusConnection.ChannelLock); +spin_unlock_irqrestore (&gVmbusConnection.channel_lock, flags);return foundChannel; }
drivers/staging/hv/VmbusPrivate.h +1 -1
@@ -84,7 +84,7 @@ typedef struct _VMBUS_CONNECTION {// List of channels LIST_ENTRY ChannelList; -HANDLE ChannelLock; +spinlock_t channel_lock;HANDLE WorkQueue; }VMBUS_CONNECTION ;
Re: [patch 47/54] Staging: hv: make gVmbusConnection.ChannelLock a real spinlock
Quoted 3 lines · Greg Kroah-Hartman
I don't think we really want to be doing a irqsave for this code, but I left it alone to preserve the original codepath. It should be reviewed later.
This patch does not preserve the original code path if any of the callers has a different irq state from the others. When flags is shared, releasing the lock actually sets the irq state to whatever another thread was using when failing to acquire the lock while it was held.
The patch of course looks good, but the comment is misleading.
Arnd <><
Re: [patch 47/54] Staging: hv: make gVmbusConnection.ChannelLock a real spinlock
Quoted 5 lines · Arnd Bergmann
Quoted 3 lines · Greg Kroah-Hartman
I don't think we really want to be doing a irqsave for this code, but I left it alone to preserve the original codepath. It should be reviewed later.
Quoted 7 lines
This patch does not preserve the original code path if any of the callers has a different irq state from the others. When flags is shared, releasing the lock actually sets the irq state to whatever another thread was using when failing to acquire the lock while it was held.
The patch of course looks good, but the comment is misleading.
Good point, sorry for the misleading comment.
I'll let Hank work out the details as to if the irqsave mode is needed or not :)
thanks,
greg k-h
PATCH 48/54 Staging: hv: osd: remove spinlock wrapper functions
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
Now that there are no users of the wrapper functions for spinlocks, remove them.
--- drivers/staging/hv/include/osd.h | 5 ----- drivers/staging/hv/osd.c | 37 ------------------------------------- 2 files changed, 42 deletions(-)
drivers/staging/hv/include/osd.h +0 -5
@@ -137,11 +137,6 @@ extern int WaitEventWait(HANDLE hWait);// If >0, hWait got signaled. If ==0, timeout. If < 0, error extern int WaitEventWaitEx (HANDLE hWait,u32 TimeoutInMs); -extern HANDLE SpinlockCreate (void ); -extern void SpinlockClose (HANDLE hSpin); -extern void SpinlockAcquire (HANDLE hSpin); -extern void SpinlockRelease (HANDLE hSpin); -#define GetVirtualAddress Physical2LogicalAddrvoid *Physical2LogicalAddr (unsigned long PhysAddr);
drivers/staging/hv/osd.c +0 -37
@@ -61,11 +61,6 @@ typedef struct _WAITEVENT {wait_queue_head_t event; }WAITEVENT ; -typedef struct _SPINLOCK { -spinlock_t lock; -unsigned long flags; -}SPINLOCK ; -typedef struct _WORKQUEUE {struct workqueue_struct *queue; }WORKQUEUE ;
@@ -323,38 +318,6 @@ int WaitEventWaitEx(HANDLE hWait, u32 Tireturn ret; } -HANDLE SpinlockCreate (void ) -{ -SPINLOCK * spin =kmalloc (sizeof (SPINLOCK ),GFP_KERNEL ); -if (!spin) - { -return NULL ; - } -spin_lock_init (&spin->lock); - -return spin; -} - -void SpinlockAcquire (HANDLE hSpin) -{ -SPINLOCK * spin = (SPINLOCK * )hSpin; - -spin_lock_irqsave (&spin->lock, spin->flags); -} - -void SpinlockRelease (HANDLE hSpin) -{ -SPINLOCK * spin = (SPINLOCK * )hSpin; - -spin_unlock_irqrestore (&spin->lock, spin->flags); -} - -void SpinlockClose (HANDLE hSpin) -{ -SPINLOCK * spin = (SPINLOCK * )hSpin; -kfree (spin); -} -void *Physical2LogicalAddr (unsigned long PhysAddr) {void * logicalAddr =phys_to_virt (PhysAddr);
PATCH 49/54 Staging: hv: osd: remove Sleep wrapper
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
Use the "real" udelay call instead of a wrapper function.
--- drivers/staging/hv/NetVsc.c | 9 +++++---- drivers/staging/hv/StorVsc.c | 7 ++++--- drivers/staging/hv/include/osd.h | 2 -- drivers/staging/hv/osd.c | 5 ----- 4 files changed, 9 insertions(+), 14 deletions(-)
drivers/staging/hv/include/osd.h +0 -2
@@ -110,8 +110,6 @@ extern int InterlockedIncrement(int *valextern int InterlockedDecrement (int *val);extern int InterlockedCompareExchange (int *val,int new,int curr); -extern void Sleep (unsigned long usecs); -extern void *VirtualAllocExec (unsigned int size);extern void VirtualFree (void * VirtAddr);
drivers/staging/hv/NetVsc.c +5 -4
@@ -24,6 +24,7 @@#include <linux/kernel.h> #include <linux/mm.h> +#include <linux/delay.h> #include "include/logging.h" #include "NetVsc.h" #include "RndisFilter.h"
@@ -200,7 +201,7 @@ static inline NETVSC_DEVICE* ReleaseOutb// Busy wait until the ref drop to 2, then set it to 1 while (InterlockedCompareExchange (&netDevice->RefCount,1 ,2 ) !=2 ) { -Sleep (100 ); +udelay (100 ); }return netDevice;
@@ -217,7 +218,7 @@ static inline NETVSC_DEVICE* ReleaseInbo// Busy wait until the ref drop to 1, then set it to 0 while (InterlockedCompareExchange (&netDevice->RefCount,0 ,1 ) !=1 ) { -Sleep (100 ); +udelay (100 ); } Device->Extension =NULL ;
@@ -923,7 +924,7 @@ NetVscOnDeviceRemove( {DPRINT_INFO (NETVSC ,"waiting for %d requests to complete..." , netDevice->NumOutstandingSends); -Sleep (100 ); +udelay (100 ); }DPRINT_INFO (NETVSC ,"Disconnecting from netvsp..." );
@@ -1318,7 +1319,7 @@ retry_send_cmplt:if (retries <4 ) { -Sleep (100 ); +udelay (100 ); goto retry_send_cmplt; }else
drivers/staging/hv/osd.c +0 -5
@@ -131,11 +131,6 @@ int InterlockedCompareExchange(int *val, } -void Sleep (unsigned long usecs) -{ -udelay (usecs); -} -void *VirtualAllocExec (unsigned int size) {#ifdef __x86_64__
drivers/staging/hv/StorVsc.c +4 -3
@@ -26,6 +26,7 @@#include <linux/kernel.h> #include <linux/string.h> #include <linux/mm.h> +#include <linux/delay.h> #include "include/logging.h" #include "include/StorVscApi.h"
@@ -225,7 +226,7 @@ static inline STORVSC_DEVICE* ReleaseSto// Busy wait until the ref drop to 2, then set it to 1 while (InterlockedCompareExchange (&storDevice->RefCount,1 ,2 ) !=2 ) { -Sleep (100 ); +udelay (100 ); }return storDevice;
@@ -242,7 +243,7 @@ static inline STORVSC_DEVICE* FinalRelea// Busy wait until the ref drop to 1, then set it to 0 while (InterlockedCompareExchange (&storDevice->RefCount,0 ,1 ) !=1 ) { -Sleep (100 ); +udelay (100 ); } Device->Extension =NULL ;
@@ -582,7 +583,7 @@ StorVscOnDeviceRemove( {DPRINT_INFO (STORVSC ,"waiting for %d requests to complete..." , storDevice->NumOutstandingRequests); -Sleep (100 ); +udelay (100 ); }DPRINT_INFO (STORVSC ,"removing storage device (%p)..." , Device->Extension);
PATCH 50/54 Staging: hv: osd: remove MemoryFence wrapper
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
Use the "real" mb call instead of a wrapper function.
--- drivers/staging/hv/RingBuffer.c | 4 ++-- drivers/staging/hv/Vmbus.c | 2 +- drivers/staging/hv/include/osd.h | 2 -- drivers/staging/hv/osd.c | 5 ----- 4 files changed, 3 insertions(+), 10 deletions(-)
drivers/staging/hv/include/osd.h +0 -2
@@ -119,8 +119,6 @@ extern void PageFree(void* page, unsigneextern void *MemMapIO (unsigned long phys,unsigned long size);extern void MemUnmapIO (void * virt); -extern void MemoryFence (void ); -extern HANDLE TimerCreate (PFN_TIMER_CALLBACK pfnTimerCB,void * context);extern void TimerClose (HANDLE hTimer);extern int TimerStop (HANDLE hTimer);
drivers/staging/hv/osd.c +0 -5
@@ -197,11 +197,6 @@ void MemUnmapIO(void *virt)//iounmap(virt); } -void MemoryFence () -{ -mb (); -} -void TimerCallback (unsigned long data) {TIMER * t = (TIMER *)data;
drivers/staging/hv/RingBuffer.c +2 -2
@@ -411,7 +411,7 @@ RingBufferWrite( sizeof(u64));// Make sure we flush all writes before updating the writeIndex -MemoryFence (); +mb ();// Now, update the write location SetNextWriteLocation (OutRingInfo, nextWriteLocation);
@@ -532,7 +532,7 @@ RingBufferRead(// Make sure all reads are done before we update the read index since // the writer may start writing to the read area once the read index is updated -MemoryFence (); +mb ();// Update the read index SetNextReadLocation (InRingInfo, nextReadLocation);
drivers/staging/hv/Vmbus.c +1 -1
@@ -426,7 +426,7 @@ VmbusOnMsgDPC(// Make sure the write to MessageType (ie set to HvMessageTypeNone) happens // before we read the MessagePending and EOMing. Otherwise, the EOMing will not deliver // any more messages since there is no empty slot -MemoryFence (); +mb ();if (msg->Header.MessageFlags.MessagePending) {
PATCH 51/54 Staging: hv: osd: remove LogMsg wrapper
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
Use the "real" printk call instead of a wrapper function.
--- drivers/staging/hv/include/logging.h | 54 ++++++++++++++++++++--------------- drivers/staging/hv/include/osd.h | 2 - drivers/staging/hv/osd.c | 13 -------- 3 files changed, 31 insertions(+), 38 deletions(-)
drivers/staging/hv/include/logging.h +31 -23
@@ -53,11 +53,10 @@ BLKVSC_DRV)// Logging Level -#define CRITICAL_LVL 2 -#define ERROR_LVL 3 -#define WARNING_LVL 4 -#define INFO_LVL 6 -#define DEBUG_LVL 7 +#define ERROR_LVL 3 +#define WARNING_LVL 4 +#define INFO_LVL 6 +#define DEBUG_LVL 7#define DEBUG_LVL_ENTEREXIT 8#define DEBUG_RING_LVL 9
@@ -65,44 +64,53 @@ extern unsigned int vmbus_loglevel;#define ASSERT (expr) \ if (!(expr)) { \ - LogMsg("<%d>Assertion failed! %s,%s,%s,line=%d\n", CRITICAL_LVL, #expr,__FILE__,__FUNCTION__,__LINE__); \ + printk(KERN_CRIT "Assertion failed! %s,%s,%s,line=%d\n", \ + #expr, __FILE__, __func__, __LINE__); \ __asm__ __volatile__("int3"); \ } #define DPRINT(mod, lvl, fmt, args...) do {\ - if (mod & (HIWORD(vmbus_loglevel))) \ - (lvl <= LOWORD(vmbus_loglevel))?(LogMsg("<%d>" #mod": %s() " fmt "\n", DEBUG_LVL, __FUNCTION__, ## args)):(0);\ + if ((mod & (HIWORD(vmbus_loglevel))) && \ + (lvl <= LOWORD(vmbus_loglevel))) \ + printk(KERN_DEBUG #mod": %s() " fmt "\n", __func__, ## args);\ } while (0) #define DPRINT_DBG(mod, fmt, args...) do {\ - if (mod & (HIWORD(vmbus_loglevel))) \ - (DEBUG_LVL <= LOWORD(vmbus_loglevel))?(LogMsg("<%d>" #mod": %s() " fmt "\n", DEBUG_LVL, __FUNCTION__, ## args)):(0);\ + if ((mod & (HIWORD(vmbus_loglevel))) && \ + (DEBUG_LVL <= LOWORD(vmbus_loglevel))) \ + printk(KERN_DEBUG #mod": %s() " fmt "\n", __func__, ## args);\ } while (0) #define DPRINT_INFO(mod, fmt, args...) do {\ - if (mod & (HIWORD(vmbus_loglevel))) \ - (INFO_LVL <= LOWORD(vmbus_loglevel))?(LogMsg("<%d>" #mod": " fmt "\n", INFO_LVL, ## args)):(0);\ + if ((mod & (HIWORD(vmbus_loglevel))) && \ + (INFO_LVL <= LOWORD(vmbus_loglevel))) \ + printk(KERN_INFO #mod": " fmt "\n", ## args);\ } while (0) #define DPRINT_WARN(mod, fmt, args...) do {\ - if (mod & (HIWORD(vmbus_loglevel))) \ - (WARNING_LVL <= LOWORD(vmbus_loglevel))?(LogMsg("<%d>" #mod": WARNING! " fmt "\n", WARNING_LVL, ## args)):(0);\ + if ((mod & (HIWORD(vmbus_loglevel))) && \ + (WARNING_LVL <= LOWORD(vmbus_loglevel))) \ + printk(KERN_WARNING #mod": WARNING! " fmt "\n", ## args);\ } while (0) #define DPRINT_ERR(mod, fmt, args...) do {\ - if (mod & (HIWORD(vmbus_loglevel))) \ - (ERROR_LVL <= LOWORD(vmbus_loglevel))?(LogMsg("<%d>" #mod": %s() ERROR!! " fmt "\n", ERROR_LVL, __FUNCTION__, ## args)):(0);\ + if ((mod & (HIWORD(vmbus_loglevel))) && \ + (ERROR_LVL <= LOWORD(vmbus_loglevel))) \ + printk(KERN_ERR #mod": %s() ERROR!! " fmt "\n", \ + __func__, ## args);\ } while (0)#ifdef DEBUG #define DPRINT_ENTER (mod) do {\ - if (mod & (HIWORD(vmbus_loglevel))) \ - (DEBUG_LVL_ENTEREXIT <= LOWORD(vmbus_loglevel))?(LogMsg("<%d>" "["#mod"]: %s() enter\n", DEBUG_LVL, __FUNCTION__)):(0);\ + if ((mod & (HIWORD(vmbus_loglevel))) && \ + (DEBUG_LVL_ENTEREXIT <= LOWORD(vmbus_loglevel))) \ + printk(KERN_DEBUG "["#mod"]: %s() enter\n", __func__);\ } while (0)#define DPRINT_EXIT (mod) do {\ - if (mod & (HIWORD(vmbus_loglevel))) \ - (DEBUG_LVL_ENTEREXIT <= LOWORD(vmbus_loglevel))?(LogMsg("<%d>" "["#mod"]: %s() exit\n", DEBUG_LVL, __FUNCTION__)):(0);\ + if ((mod & (HIWORD(vmbus_loglevel))) && \ + (DEBUG_LVL_ENTEREXIT <= LOWORD(vmbus_loglevel))) \ + printk(KERN_DEBUG "["#mod"]: %s() exit\n", __func__);\ } while (0)#else #define DPRINT_ENTER (mod)
@@ -113,12 +121,12 @@ static inline void PrintBytes(const unsi {int i=0 ; -LogMsg ("\n<< " ); +printk ("\n<< " );for (i=0 ; i< len; i++) { -LogMsg ("0x%x " , bytes[i]); +printk ("0x%x " , bytes[i]); } -LogMsg (">>\n" ); +printk (">>\n" ); }//
drivers/staging/hv/include/osd.h +0 -2
@@ -98,8 +98,6 @@ static inline void do_cpuid(unsigned int// // Osd routines // -extern void LogMsg (const char *fmt, ...); -extern void BitSet (unsigned int * addr,int value);extern void BitClear (unsigned int * addr,int value);extern int BitTest (unsigned int * addr,int value);
drivers/staging/hv/osd.c +0 -13
@@ -72,19 +72,6 @@ typedef struct _WORKITEM { }WORKITEM ; -// -// Global -// - -void LogMsg (const char *fmt, ...) -{ -va_list args; - -va_start (args, fmt); -vprintk (fmt, args); -va_end (args); -} -void BitSet (unsigned int * addr,int bit) {set_bit (bit, (unsigned long *)addr);
PATCH 52/54 Staging: hv: osd: remove PrintBytes wrapper
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
Use the "real" print_hex_dump_bytes call instead of a wrapper function.
--- drivers/staging/hv/ChannelMgmt.c | 3 ++- drivers/staging/hv/StorVsc.c | 2 +- drivers/staging/hv/blkvsc_drv.c | 5 +++-- drivers/staging/hv/include/logging.h | 22 ---------------------- 4 files changed, 6 insertions(+), 26 deletions(-)
drivers/staging/hv/blkvsc_drv.c +3 -2
@@ -578,7 +578,7 @@ static int blkvsc_do_inquiry(struct bloc buf =kmap (page_buf); -//PrintBytes(buf, 64); +/* print_hex_dump_bytes("", DUMP_PREFIX_NONE, buf, 64); */ // be to le device_type = buf[0 ] &0x1F ;
@@ -603,7 +603,8 @@ static int blkvsc_do_inquiry(struct bloc blkdev->device_id_len =64 ;memcpy (blkdev->device_id, &buf[8 ], blkdev->device_id_len); -//PrintBytes(blkdev->device_id, blkdev->device_id_len); +/* printk_hex_dump_bytes("", DUMP_PREFIX_NONE, blkdev->device_id, +* blkdev->device_id_len); */ kunmap (page_buf);
drivers/staging/hv/ChannelMgmt.c +2 -1
@@ -687,7 +687,8 @@ VmbusOnChannelMessage(if (hdr->MessageType >= ChannelMessageCount) {DPRINT_ERR (VMBUS ,"Received invalid channel message type %d size %d" , hdr->MessageType, size); -PrintBytes ((unsigned char *)msg->u.Payload, size); +print_hex_dump_bytes ("" ,DUMP_PREFIX_NONE , + (unsigned char *)msg->u.Payload, size);kfree (msg);return ; }
drivers/staging/hv/include/logging.h +0 -22
@@ -117,26 +117,4 @@ extern unsigned int vmbus_loglevel;#define DPRINT_EXIT (mod)#endif -static inline void PrintBytes (const unsigned char * bytes,int len) -{ -int i=0 ; - -printk ("\n<< " ); -for (i=0 ; i< len; i++) - { -printk ("0x%x " , bytes[i]); - } -printk (">>\n" ); -} - -// -// Inline -// -//static inline void GuidToStr(const GUID g, char *str) -//{ -// sprintf(str, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x%02x%02x}", -// g[3], g[2], g[1], g[0], g[5], g[4], g[7], g[6], g[8], g[9], g[10], g[11], g[12], g[13], g[14], g[15]); -// -//} -#endif //_LOGGING_H_
drivers/staging/hv/StorVsc.c +1 -1
@@ -713,7 +713,7 @@ StorVscOnIORequest(return -2 ; } -//PrintBytes(Request->Cdb, Request->CdbLen); +/* print_hex_dump_bytes("", DUMP_PREFIX_NONE, Request->Cdb, Request->CdbLen); */ requestExtension->Request = Request; requestExtension->Device = Device;
PATCH 53/54 Staging: hv: fix up printk warnings
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
After LogMsg was converted to printk, lots of build warnings showed up as no one was checking the arguments to LogMsg. This patch fixes them all.
--- drivers/staging/hv/Hv.c | 6 +++--- drivers/staging/hv/StorVsc.c | 16 ++++++++-------- drivers/staging/hv/blkvsc_drv.c | 12 ++++++------ drivers/staging/hv/storvsc_drv.c | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-)
drivers/staging/hv/blkvsc_drv.c +6 -6
@@ -918,7 +918,7 @@ static int blkvsc_submit_request(structSTORVSC_REQUEST *storvsc_req; - DPRINT_DBG(BLKVSC_DRV, "blkvsc_submit_request() - req %p type %s start_sector %llu count %d offset %d len %d\n", + DPRINT_DBG(BLKVSC_DRV, "blkvsc_submit_request() - req %p type %s start_sector %llu count %ld offset %d len %d\n", blkvsc_req, (blkvsc_req->write)?"WRITE":"READ", blkvsc_req->sector_start,
@@ -1087,7 +1087,7 @@ static int blkvsc_do_request(struct bloc {if (pending) { -DPRINT_DBG (BLKVSC_DRV ,"adding blkvsc_req to pending_list - blkvsc_req %p start_sect %llu sect_count %d (%llu %d)\n" , +DPRINT_DBG (BLKVSC_DRV ,"adding blkvsc_req to pending_list - blkvsc_req %p start_sect %llu sect_count %ld (%llu %ld)\n" , blkvsc_req, blkvsc_req->sector_start, blkvsc_req->sector_count, start_sector, num_sectors);list_add_tail (&blkvsc_req->pend_entry, &blkdev->pending_list);
@@ -1101,7 +1101,7 @@ static int blkvsc_do_request(struct bloclist_add_tail (&blkvsc_req->pend_entry, &blkdev->pending_list); } -DPRINT_DBG (BLKVSC_DRV ,"submitted blkvsc_req %p start_sect %llu sect_count %d (%llu %d) ret %d\n" , +DPRINT_DBG (BLKVSC_DRV ,"submitted blkvsc_req %p start_sect %llu sect_count %ld (%llu %ld) ret %d\n" , blkvsc_req, blkvsc_req->sector_start, blkvsc_req->sector_count, start_sector, num_sectors, ret); } }
@@ -1141,7 +1141,7 @@ static void blkvsc_request_completion(STASSERT (blkvsc_req->group); - DPRINT_DBG(BLKVSC_DRV, "blkdev %p blkvsc_req %p group %p type %s sect_start %llu sect_count %d len %d group outstd %d total outstd %d\n", + DPRINT_DBG(BLKVSC_DRV, "blkdev %p blkvsc_req %p group %p type %s sect_start %llu sect_count %ld len %d group outstd %d total outstd %d\n", blkdev, blkvsc_req, blkvsc_req->group,
@@ -1163,7 +1163,7 @@ static void blkvsc_request_completion(ST {list_for_each_entry_safe (comp_req, tmp, &blkvsc_req->group->blkvsc_req_list, req_entry) { -DPRINT_DBG (BLKVSC_DRV ,"completing blkvsc_req %p sect_start %llu sect_count %d \n" , +DPRINT_DBG (BLKVSC_DRV ,"completing blkvsc_req %p sect_start %llu sect_count %ld \n" , comp_req, comp_req->sector_start, comp_req->sector_count);
@@ -1222,7 +1222,7 @@ static int blkvsc_cancel_pending_reqs(st// until we hit the pend_req list_for_each_entry_safe (comp_req, tmp2, &pend_req->group->blkvsc_req_list, req_entry) { -DPRINT_DBG (BLKVSC_DRV ,"completing blkvsc_req %p sect_start %llu sect_count %d \n" , +DPRINT_DBG (BLKVSC_DRV ,"completing blkvsc_req %p sect_start %llu sect_count %ld \n" , comp_req, comp_req->sector_start, comp_req->sector_count);
drivers/staging/hv/Hv.c +3 -3
@@ -300,9 +300,9 @@ HvInit ( goto Cleanup; } -DPRINT_INFO (VMBUS ,"Hypercall page VA=0x%08x, PA=0x%08x" , - (unsigned long )gHvContext.HypercallPage, - (unsigned long )hypercallMsr.GuestPhysicalAddress <<PAGE_SHIFT ); +DPRINT_INFO (VMBUS ,"Hypercall page VA=%p, PA=0x%0llx" , + gHvContext.HypercallPage, + (u64 )hypercallMsr.GuestPhysicalAddress <<PAGE_SHIFT );// Setup the global signal event param for the signal event hypercall gHvContext.SignalEventBuffer =kmalloc (sizeof (HV_INPUT_SIGNAL_EVENT_BUFFER ),GFP_KERNEL );
drivers/staging/hv/StorVsc.c +8 -8
@@ -348,7 +348,7 @@ StorVscOnDeviceAdd( deviceInfo->PathId = storDevice->PathId; deviceInfo->TargetId = storDevice->TargetId; -DPRINT_DBG (STORVSC ,"assigned port %u, path %u target %u\n" , storDevice->PortNumber, storDevice->PathId, storDevice->TargetId); +DPRINT_DBG (STORVSC ,"assigned port %lu, path %u target %u\n" , storDevice->PortNumber, storDevice->PathId, storDevice->TargetId); Cleanup:DPRINT_EXIT (STORVSC );
@@ -404,7 +404,7 @@ static int StorVscChannelInit(DEVICE_OBJif (vstorPacket->Operation != VStorOperationCompleteIo || vstorPacket->Status !=0 ) { -DPRINT_ERR (STORVSC ,"BEGIN_INITIALIZATION_OPERATION failed (op %d status 0x%x)" , vstorPacket->Operation, vstorPacket->Status); +DPRINT_ERR (STORVSC ,"BEGIN_INITIALIZATION_OPERATION failed (op %d status 0x%lx)" , vstorPacket->Operation, vstorPacket->Status); goto Cleanup; }
@@ -435,7 +435,7 @@ static int StorVscChannelInit(DEVICE_OBJ// TODO: Check returned version if (vstorPacket->Operation != VStorOperationCompleteIo || vstorPacket->Status !=0 ) { -DPRINT_ERR (STORVSC ,"QUERY_PROTOCOL_VERSION_OPERATION failed (op %d status 0x%x)" , vstorPacket->Operation, vstorPacket->Status); +DPRINT_ERR (STORVSC ,"QUERY_PROTOCOL_VERSION_OPERATION failed (op %d status 0x%lx)" , vstorPacket->Operation, vstorPacket->Status); goto Cleanup; }
@@ -465,7 +465,7 @@ static int StorVscChannelInit(DEVICE_OBJ// TODO: Check returned version if (vstorPacket->Operation != VStorOperationCompleteIo || vstorPacket->Status !=0 ) { -DPRINT_ERR (STORVSC ,"QUERY_PROPERTIES_OPERATION failed (op %d status 0x%x)" , vstorPacket->Operation, vstorPacket->Status); +DPRINT_ERR (STORVSC ,"QUERY_PROPERTIES_OPERATION failed (op %d status 0x%lx)" , vstorPacket->Operation, vstorPacket->Status); goto Cleanup; }
@@ -473,7 +473,7 @@ static int StorVscChannelInit(DEVICE_OBJ storDevice->PathId = vstorPacket->StorageChannelProperties.PathId; storDevice->TargetId = vstorPacket->StorageChannelProperties.TargetId; -DPRINT_DBG (STORVSC ,"channel flag 0x%x, max xfer len 0x%x" , vstorPacket->StorageChannelProperties.Flags, vstorPacket->StorageChannelProperties.MaxTransferBytes); +DPRINT_DBG (STORVSC ,"channel flag 0x%lx, max xfer len 0x%lx" , vstorPacket->StorageChannelProperties.Flags, vstorPacket->StorageChannelProperties.MaxTransferBytes);DPRINT_INFO (STORVSC ,"END_INITIALIZATION_OPERATION..." );
@@ -498,7 +498,7 @@ static int StorVscChannelInit(DEVICE_OBJif (vstorPacket->Operation != VStorOperationCompleteIo || vstorPacket->Status !=0 ) { -DPRINT_ERR (STORVSC ,"END_INITIALIZATION_OPERATION failed (op %d status 0x%x)" , vstorPacket->Operation, vstorPacket->Status); +DPRINT_ERR (STORVSC ,"END_INITIALIZATION_OPERATION failed (op %d status 0x%lx)" , vstorPacket->Operation, vstorPacket->Status); goto Cleanup; }
@@ -540,7 +540,7 @@ StorVscConnectToVsp(Device ); -DPRINT_DBG (STORVSC ,"storage props: path id %d, tgt id %d, max xfer %d" , props.PathId, props.TargetId, props.MaxTransferBytes); +DPRINT_DBG (STORVSC ,"storage props: path id %d, tgt id %d, max xfer %ld" , props.PathId, props.TargetId, props.MaxTransferBytes);if (ret !=0 ) {
@@ -819,7 +819,7 @@ StorVscOnIOCompletion(return ; } -DPRINT_DBG (STORVSC ,"IO_COMPLETE_OPERATION - request extension %p completed bytes xfer %u" , +DPRINT_DBG (STORVSC ,"IO_COMPLETE_OPERATION - request extension %p completed bytes xfer %lu" , RequestExt, VStorPacket->VmSrb.DataTransferLength);ASSERT (RequestExt !=NULL );
drivers/staging/hv/storvsc_drv.c +1 -1
@@ -1054,7 +1054,7 @@ static int storvsc_device_configure(struDPRINT_INFO (STORVSC_DRV ,"sdev (%p) - setting queue depth to %d" , sdevice,STORVSC_MAX_IO_REQUESTS );scsi_adjust_queue_depth (sdevice,MSG_SIMPLE_TAG ,STORVSC_MAX_IO_REQUESTS ); -DPRINT_INFO (STORVSC_DRV ,"sdev (%p) - setting max segment size to %d" , sdevice,PAGE_SIZE ); +DPRINT_INFO (STORVSC_DRV ,"sdev (%p) - setting max segment size to %ld" , sdevice,PAGE_SIZE );blk_queue_max_segment_size (sdevice->request_queue,PAGE_SIZE );DPRINT_INFO (STORVSC_DRV ,"sdev (%p) - adding merge bio vec routine" , sdevice);
PATCH 54/54 Staging: hv: osd: remove GetTickCount and GetTimestamp wrappers
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
No one was even using them.
--- drivers/staging/hv/include/osd.h | 1 - drivers/staging/hv/osd.c | 14 -------------- 2 files changed, 15 deletions(-)
drivers/staging/hv/include/osd.h +0 -1
@@ -121,7 +121,6 @@ extern HANDLE TimerCreate(PFN_TIMER_CALLextern void TimerClose (HANDLE hTimer);extern int TimerStop (HANDLE hTimer);extern void TimerStart (HANDLE hTimer,u32 expirationInUs); -extern size_t GetTickCount (void );extern HANDLE WaitEventCreate (void );extern void WaitEventClose (HANDLE hWait);
drivers/staging/hv/osd.c +0 -14
@@ -232,20 +232,6 @@ void TimerClose(HANDLE hTimer)kfree (t); } -size_t GetTickCount (void ) -{ -return jiffies; -} - -signed long long GetTimestamp (void ) -{ -struct timeval t; - -do_gettimeofday (&t); - -return timeval_to_ns (&t); -} -HANDLE WaitEventCreate (void ) {WAITEVENT * wait =kmalloc (sizeof (WAITEVENT ),GFP_KERNEL );