| .. | .. | 
|---|
|  | 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ | 
|---|
| 1 | 2 | /* | 
|---|
| 2 | 3 | * | 
|---|
| 3 | 4 | * Copyright (c) 2011, Microsoft Corporation. | 
|---|
| 4 |  | - * | 
|---|
| 5 |  | - * This program is free software; you can redistribute it and/or modify it | 
|---|
| 6 |  | - * under the terms and conditions of the GNU General Public License, | 
|---|
| 7 |  | - * version 2, as published by the Free Software Foundation. | 
|---|
| 8 |  | - * | 
|---|
| 9 |  | - * This program is distributed in the hope it will be useful, but WITHOUT | 
|---|
| 10 |  | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | 
|---|
| 11 |  | - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for | 
|---|
| 12 |  | - * more details. | 
|---|
| 13 |  | - * | 
|---|
| 14 |  | - * You should have received a copy of the GNU General Public License along with | 
|---|
| 15 |  | - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple | 
|---|
| 16 |  | - * Place - Suite 330, Boston, MA 02111-1307 USA. | 
|---|
| 17 | 5 | * | 
|---|
| 18 | 6 | * Authors: | 
|---|
| 19 | 7 | *   Haiyang Zhang <haiyangz@microsoft.com> | 
|---|
| 20 | 8 | *   Hank Janssen  <hjanssen@microsoft.com> | 
|---|
| 21 | 9 | *   K. Y. Srinivasan <kys@microsoft.com> | 
|---|
| 22 |  | - * | 
|---|
| 23 | 10 | */ | 
|---|
| 24 | 11 |  | 
|---|
| 25 | 12 | #ifndef _HYPERV_H | 
|---|
| .. | .. | 
|---|
| 27 | 14 |  | 
|---|
| 28 | 15 | #include <uapi/linux/hyperv.h> | 
|---|
| 29 | 16 |  | 
|---|
|  | 17 | +#include <linux/mm.h> | 
|---|
| 30 | 18 | #include <linux/types.h> | 
|---|
| 31 | 19 | #include <linux/scatterlist.h> | 
|---|
| 32 | 20 | #include <linux/list.h> | 
|---|
| .. | .. | 
|---|
| 36 | 24 | #include <linux/mod_devicetable.h> | 
|---|
| 37 | 25 | #include <linux/interrupt.h> | 
|---|
| 38 | 26 | #include <linux/reciprocal_div.h> | 
|---|
|  | 27 | +#include <asm/hyperv-tlfs.h> | 
|---|
| 39 | 28 |  | 
|---|
| 40 | 29 | #define MAX_PAGE_BUFFER_COUNT				32 | 
|---|
| 41 | 30 | #define MAX_MULTIPAGE_BUFFER_COUNT			32 /* 128K */ | 
|---|
| 42 | 31 |  | 
|---|
| 43 | 32 | #pragma pack(push, 1) | 
|---|
|  | 33 | + | 
|---|
|  | 34 | +/* | 
|---|
|  | 35 | + * Types for GPADL, decides is how GPADL header is created. | 
|---|
|  | 36 | + * | 
|---|
|  | 37 | + * It doesn't make much difference between BUFFER and RING if PAGE_SIZE is the | 
|---|
|  | 38 | + * same as HV_HYP_PAGE_SIZE. | 
|---|
|  | 39 | + * | 
|---|
|  | 40 | + * If PAGE_SIZE is bigger than HV_HYP_PAGE_SIZE, the headers of ring buffers | 
|---|
|  | 41 | + * will be of PAGE_SIZE, however, only the first HV_HYP_PAGE will be put | 
|---|
|  | 42 | + * into gpadl, therefore the number for HV_HYP_PAGE and the indexes of each | 
|---|
|  | 43 | + * HV_HYP_PAGE will be different between different types of GPADL, for example | 
|---|
|  | 44 | + * if PAGE_SIZE is 64K: | 
|---|
|  | 45 | + * | 
|---|
|  | 46 | + * BUFFER: | 
|---|
|  | 47 | + * | 
|---|
|  | 48 | + * gva:    |--       64k      --|--       64k      --| ... | | 
|---|
|  | 49 | + * gpa:    | 4k | 4k | ... | 4k | 4k | 4k | ... | 4k | | 
|---|
|  | 50 | + * index:  0    1    2     15   16   17   18 .. 31   32 ... | 
|---|
|  | 51 | + *         |    |    ...   |    |    |   ...    |   ... | 
|---|
|  | 52 | + *         v    V          V    V    V          V | 
|---|
|  | 53 | + * gpadl:  | 4k | 4k | ... | 4k | 4k | 4k | ... | 4k | ... | | 
|---|
|  | 54 | + * index:  0    1    2 ... 15   16   17   18 .. 31   32 ... | 
|---|
|  | 55 | + * | 
|---|
|  | 56 | + * RING: | 
|---|
|  | 57 | + * | 
|---|
|  | 58 | + *         | header  |           data           | header  |     data      | | 
|---|
|  | 59 | + * gva:    |-- 64k --|--       64k      --| ... |-- 64k --|-- 64k --| ... | | 
|---|
|  | 60 | + * gpa:    | 4k | .. | 4k | 4k | ... | 4k | ... | 4k | .. | 4k | .. | ... | | 
|---|
|  | 61 | + * index:  0    1    16   17   18    31   ...   n   n+1  n+16 ...         2n | 
|---|
|  | 62 | + *         |         /    /          /          |         /               / | 
|---|
|  | 63 | + *         |        /    /          /           |        /               / | 
|---|
|  | 64 | + *         |       /    /   ...    /    ...     |       /      ...      / | 
|---|
|  | 65 | + *         |      /    /          /             |      /               / | 
|---|
|  | 66 | + *         |     /    /          /              |     /               / | 
|---|
|  | 67 | + *         V    V    V          V               V    V               v | 
|---|
|  | 68 | + * gpadl:  | 4k | 4k |   ...    |    ...        | 4k | 4k |  ...     | | 
|---|
|  | 69 | + * index:  0    1    2   ...    16   ...       n-15 n-14 n-13  ...  2n-30 | 
|---|
|  | 70 | + */ | 
|---|
|  | 71 | +enum hv_gpadl_type { | 
|---|
|  | 72 | +	HV_GPADL_BUFFER, | 
|---|
|  | 73 | +	HV_GPADL_RING | 
|---|
|  | 74 | +}; | 
|---|
| 44 | 75 |  | 
|---|
| 45 | 76 | /* Single-page buffer */ | 
|---|
| 46 | 77 | struct hv_page_buffer { | 
|---|
| .. | .. | 
|---|
| 124 | 155 | } feature_bits; | 
|---|
| 125 | 156 |  | 
|---|
| 126 | 157 | /* Pad it to PAGE_SIZE so that data starts on page boundary */ | 
|---|
| 127 |  | -	u8	reserved2[4028]; | 
|---|
|  | 158 | +	u8	reserved2[PAGE_SIZE - 68]; | 
|---|
| 128 | 159 |  | 
|---|
| 129 | 160 | /* | 
|---|
| 130 | 161 | * Ring data starts here + RingDataStartOffset | 
|---|
| 131 | 162 | * !!! DO NOT place any fields below this !!! | 
|---|
| 132 | 163 | */ | 
|---|
| 133 |  | -	u8 buffer[0]; | 
|---|
|  | 164 | +	u8 buffer[]; | 
|---|
| 134 | 165 | } __packed; | 
|---|
|  | 166 | + | 
|---|
|  | 167 | +/* Calculate the proper size of a ringbuffer, it must be page-aligned */ | 
|---|
|  | 168 | +#define VMBUS_RING_SIZE(payload_sz) PAGE_ALIGN(sizeof(struct hv_ring_buffer) + \ | 
|---|
|  | 169 | +					       (payload_sz)) | 
|---|
| 135 | 170 |  | 
|---|
| 136 | 171 | struct hv_ring_buffer_info { | 
|---|
| 137 | 172 | struct hv_ring_buffer *ring_buffer; | 
|---|
| .. | .. | 
|---|
| 141 | 176 |  | 
|---|
| 142 | 177 | u32 ring_datasize;		/* < ring_size */ | 
|---|
| 143 | 178 | u32 priv_read_index; | 
|---|
|  | 179 | +	/* | 
|---|
|  | 180 | +	 * The ring buffer mutex lock. This lock prevents the ring buffer from | 
|---|
|  | 181 | +	 * being freed while the ring buffer is being accessed. | 
|---|
|  | 182 | +	 */ | 
|---|
|  | 183 | +	struct mutex ring_buffer_mutex; | 
|---|
| 144 | 184 | }; | 
|---|
| 145 | 185 |  | 
|---|
| 146 | 186 |  | 
|---|
| .. | .. | 
|---|
| 190 | 230 | * 2 . 4  (Windows 8) | 
|---|
| 191 | 231 | * 3 . 0  (Windows 8 R2) | 
|---|
| 192 | 232 | * 4 . 0  (Windows 10) | 
|---|
|  | 233 | + * 4 . 1  (Windows 10 RS3) | 
|---|
| 193 | 234 | * 5 . 0  (Newer Windows 10) | 
|---|
|  | 235 | + * 5 . 1  (Windows 10 RS4) | 
|---|
|  | 236 | + * 5 . 2  (Windows Server 2019, RS5) | 
|---|
| 194 | 237 | */ | 
|---|
| 195 | 238 |  | 
|---|
| 196 | 239 | #define VERSION_WS2008  ((0 << 16) | (13)) | 
|---|
| 197 | 240 | #define VERSION_WIN7    ((1 << 16) | (1)) | 
|---|
| 198 | 241 | #define VERSION_WIN8    ((2 << 16) | (4)) | 
|---|
| 199 | 242 | #define VERSION_WIN8_1    ((3 << 16) | (0)) | 
|---|
| 200 |  | -#define VERSION_WIN10	((4 << 16) | (0)) | 
|---|
|  | 243 | +#define VERSION_WIN10 ((4 << 16) | (0)) | 
|---|
|  | 244 | +#define VERSION_WIN10_V4_1 ((4 << 16) | (1)) | 
|---|
| 201 | 245 | #define VERSION_WIN10_V5 ((5 << 16) | (0)) | 
|---|
| 202 |  | - | 
|---|
| 203 |  | -#define VERSION_INVAL -1 | 
|---|
| 204 |  | - | 
|---|
| 205 |  | -#define VERSION_CURRENT VERSION_WIN10_V5 | 
|---|
|  | 246 | +#define VERSION_WIN10_V5_1 ((5 << 16) | (1)) | 
|---|
|  | 247 | +#define VERSION_WIN10_V5_2 ((5 << 16) | (2)) | 
|---|
| 206 | 248 |  | 
|---|
| 207 | 249 | /* Make maximum size of pipe payload of 16K */ | 
|---|
| 208 | 250 | #define MAX_PIPE_DATA_PAYLOAD		(sizeof(u8) * 16384) | 
|---|
| .. | .. | 
|---|
| 222 | 264 | * struct contains the fundamental information about an offer. | 
|---|
| 223 | 265 | */ | 
|---|
| 224 | 266 | struct vmbus_channel_offer { | 
|---|
| 225 |  | -	uuid_le if_type; | 
|---|
| 226 |  | -	uuid_le if_instance; | 
|---|
|  | 267 | +	guid_t if_type; | 
|---|
|  | 268 | +	guid_t if_instance; | 
|---|
| 227 | 269 |  | 
|---|
| 228 | 270 | /* | 
|---|
| 229 | 271 | * These two fields are not currently used. | 
|---|
| .. | .. | 
|---|
| 253 | 295 | } pipe; | 
|---|
| 254 | 296 | } u; | 
|---|
| 255 | 297 | /* | 
|---|
| 256 |  | -	 * The sub_channel_index is defined in win8. | 
|---|
|  | 298 | +	 * The sub_channel_index is defined in Win8: a value of zero means a | 
|---|
|  | 299 | +	 * primary channel and a value of non-zero means a sub-channel. | 
|---|
|  | 300 | +	 * | 
|---|
|  | 301 | +	 * Before Win8, the field is reserved, meaning it's always zero. | 
|---|
| 257 | 302 | */ | 
|---|
| 258 | 303 | u16 sub_channel_index; | 
|---|
| 259 | 304 | u16 reserved3; | 
|---|
| .. | .. | 
|---|
| 316 | 361 | struct gpa_range { | 
|---|
| 317 | 362 | u32 byte_count; | 
|---|
| 318 | 363 | u32 byte_offset; | 
|---|
| 319 |  | -	u64 pfn_array[0]; | 
|---|
|  | 364 | +	u64 pfn_array[]; | 
|---|
| 320 | 365 | }; | 
|---|
| 321 | 366 |  | 
|---|
| 322 | 367 | /* | 
|---|
| .. | .. | 
|---|
| 428 | 473 | CHANNELMSG_19				= 19, | 
|---|
| 429 | 474 | CHANNELMSG_20				= 20, | 
|---|
| 430 | 475 | CHANNELMSG_TL_CONNECT_REQUEST		= 21, | 
|---|
| 431 |  | -	CHANNELMSG_22				= 22, | 
|---|
|  | 476 | +	CHANNELMSG_MODIFYCHANNEL		= 22, | 
|---|
| 432 | 477 | CHANNELMSG_TL_CONNECT_RESULT		= 23, | 
|---|
| 433 | 478 | CHANNELMSG_COUNT | 
|---|
| 434 | 479 | }; | 
|---|
|  | 480 | + | 
|---|
|  | 481 | +/* Hyper-V supports about 2048 channels, and the RELIDs start with 1. */ | 
|---|
|  | 482 | +#define INVALID_RELID	U32_MAX | 
|---|
| 435 | 483 |  | 
|---|
| 436 | 484 | struct vmbus_channel_message_header { | 
|---|
| 437 | 485 | enum vmbus_channel_message_type msgtype; | 
|---|
| .. | .. | 
|---|
| 563 | 611 | u32 gpadl; | 
|---|
| 564 | 612 | u16 range_buflen; | 
|---|
| 565 | 613 | u16 rangecount; | 
|---|
| 566 |  | -	struct gpa_range range[0]; | 
|---|
|  | 614 | +	struct gpa_range range[]; | 
|---|
| 567 | 615 | } __packed; | 
|---|
| 568 | 616 |  | 
|---|
| 569 | 617 | /* This is the followup packet that contains more PFNs. */ | 
|---|
| .. | .. | 
|---|
| 571 | 619 | struct vmbus_channel_message_header header; | 
|---|
| 572 | 620 | u32 msgnumber; | 
|---|
| 573 | 621 | u32 gpadl; | 
|---|
| 574 |  | -	u64 pfn[0]; | 
|---|
|  | 622 | +	u64 pfn[]; | 
|---|
| 575 | 623 | } __packed; | 
|---|
| 576 | 624 |  | 
|---|
| 577 | 625 | struct vmbus_channel_gpadl_created { | 
|---|
| .. | .. | 
|---|
| 616 | 664 | /* Hyper-V socket: guest's connect()-ing to host */ | 
|---|
| 617 | 665 | struct vmbus_channel_tl_connect_request { | 
|---|
| 618 | 666 | struct vmbus_channel_message_header header; | 
|---|
| 619 |  | -	uuid_le guest_endpoint_id; | 
|---|
| 620 |  | -	uuid_le host_service_id; | 
|---|
|  | 667 | +	guid_t guest_endpoint_id; | 
|---|
|  | 668 | +	guid_t host_service_id; | 
|---|
|  | 669 | +} __packed; | 
|---|
|  | 670 | + | 
|---|
|  | 671 | +/* Modify Channel parameters, cf. vmbus_send_modifychannel() */ | 
|---|
|  | 672 | +struct vmbus_channel_modifychannel { | 
|---|
|  | 673 | +	struct vmbus_channel_message_header header; | 
|---|
|  | 674 | +	u32 child_relid; | 
|---|
|  | 675 | +	u32 target_vp; | 
|---|
| 621 | 676 | } __packed; | 
|---|
| 622 | 677 |  | 
|---|
| 623 | 678 | struct vmbus_channel_version_response { | 
|---|
| .. | .. | 
|---|
| 672 | 727 | * The channel message that goes out on the "wire". | 
|---|
| 673 | 728 | * It will contain at minimum the VMBUS_CHANNEL_MESSAGE_HEADER header | 
|---|
| 674 | 729 | */ | 
|---|
| 675 |  | -	unsigned char msg[0]; | 
|---|
|  | 730 | +	unsigned char msg[]; | 
|---|
| 676 | 731 | }; | 
|---|
| 677 | 732 |  | 
|---|
| 678 | 733 | struct vmbus_close_msg { | 
|---|
| .. | .. | 
|---|
| 687 | 742 | u32 id:24; | 
|---|
| 688 | 743 | u32 reserved:8; | 
|---|
| 689 | 744 | } u; | 
|---|
| 690 |  | -}; | 
|---|
| 691 |  | - | 
|---|
| 692 |  | -enum hv_numa_policy { | 
|---|
| 693 |  | -	HV_BALANCED = 0, | 
|---|
| 694 |  | -	HV_LOCALIZED, | 
|---|
| 695 | 745 | }; | 
|---|
| 696 | 746 |  | 
|---|
| 697 | 747 | enum vmbus_device_type { | 
|---|
| .. | .. | 
|---|
| 716 | 766 |  | 
|---|
| 717 | 767 | struct vmbus_device { | 
|---|
| 718 | 768 | u16  dev_type; | 
|---|
| 719 |  | -	uuid_le guid; | 
|---|
|  | 769 | +	guid_t guid; | 
|---|
| 720 | 770 | bool perf_device; | 
|---|
| 721 | 771 | }; | 
|---|
| 722 | 772 |  | 
|---|
| .. | .. | 
|---|
| 743 | 793 | /* Allocated memory for ring buffer */ | 
|---|
| 744 | 794 | struct page *ringbuffer_page; | 
|---|
| 745 | 795 | u32 ringbuffer_pagecount; | 
|---|
|  | 796 | +	u32 ringbuffer_send_offset; | 
|---|
| 746 | 797 | struct hv_ring_buffer_info outbound;	/* send to parent */ | 
|---|
| 747 | 798 | struct hv_ring_buffer_info inbound;	/* receive from parent */ | 
|---|
| 748 | 799 |  | 
|---|
| .. | .. | 
|---|
| 752 | 803 | u64	interrupts;	/* Host to Guest interrupts */ | 
|---|
| 753 | 804 | u64	sig_events;	/* Guest to Host events */ | 
|---|
| 754 | 805 |  | 
|---|
|  | 806 | +	/* | 
|---|
|  | 807 | +	 * Guest to host interrupts caused by the outbound ring buffer changing | 
|---|
|  | 808 | +	 * from empty to not empty. | 
|---|
|  | 809 | +	 */ | 
|---|
|  | 810 | +	u64 intr_out_empty; | 
|---|
|  | 811 | + | 
|---|
|  | 812 | +	/* | 
|---|
|  | 813 | +	 * Indicates that a full outbound ring buffer was encountered. The flag | 
|---|
|  | 814 | +	 * is set to true when a full outbound ring buffer is encountered and | 
|---|
|  | 815 | +	 * set to false when a write to the outbound ring buffer is completed. | 
|---|
|  | 816 | +	 */ | 
|---|
|  | 817 | +	bool out_full_flag; | 
|---|
|  | 818 | + | 
|---|
| 755 | 819 | /* Channel callback's invoked in softirq context */ | 
|---|
| 756 | 820 | struct tasklet_struct callback_event; | 
|---|
| 757 | 821 | void (*onchannel_callback)(void *context); | 
|---|
| 758 | 822 | void *channel_callback_context; | 
|---|
|  | 823 | + | 
|---|
|  | 824 | +	void (*change_target_cpu_callback)(struct vmbus_channel *channel, | 
|---|
|  | 825 | +			u32 old, u32 new); | 
|---|
|  | 826 | + | 
|---|
|  | 827 | +	/* | 
|---|
|  | 828 | +	 * Synchronize channel scheduling and channel removal; see the inline | 
|---|
|  | 829 | +	 * comments in vmbus_chan_sched() and vmbus_reset_channel_cb(). | 
|---|
|  | 830 | +	 */ | 
|---|
|  | 831 | +	spinlock_t sched_lock; | 
|---|
| 759 | 832 |  | 
|---|
| 760 | 833 | /* | 
|---|
| 761 | 834 | * A channel can be marked for one of three modes of reading: | 
|---|
| .. | .. | 
|---|
| 778 | 851 | u64 sig_event; | 
|---|
| 779 | 852 |  | 
|---|
| 780 | 853 | /* | 
|---|
| 781 |  | -	 * Starting with win8, this field will be used to specify | 
|---|
| 782 |  | -	 * the target virtual processor on which to deliver the interrupt for | 
|---|
| 783 |  | -	 * the host to guest communication. | 
|---|
| 784 |  | -	 * Prior to win8, incoming channel interrupts would only | 
|---|
| 785 |  | -	 * be delivered on cpu 0. Setting this value to 0 would | 
|---|
| 786 |  | -	 * preserve the earlier behavior. | 
|---|
|  | 854 | +	 * Starting with win8, this field will be used to specify the | 
|---|
|  | 855 | +	 * target CPU on which to deliver the interrupt for the host | 
|---|
|  | 856 | +	 * to guest communication. | 
|---|
|  | 857 | +	 * | 
|---|
|  | 858 | +	 * Prior to win8, incoming channel interrupts would only be | 
|---|
|  | 859 | +	 * delivered on CPU 0. Setting this value to 0 would preserve | 
|---|
|  | 860 | +	 * the earlier behavior. | 
|---|
| 787 | 861 | */ | 
|---|
| 788 |  | -	u32 target_vp; | 
|---|
| 789 |  | -	/* The corresponding CPUID in the guest */ | 
|---|
| 790 | 862 | u32 target_cpu; | 
|---|
| 791 |  | -	/* | 
|---|
| 792 |  | -	 * State to manage the CPU affiliation of channels. | 
|---|
| 793 |  | -	 */ | 
|---|
| 794 |  | -	struct cpumask alloced_cpus_in_node; | 
|---|
| 795 |  | -	int numa_node; | 
|---|
| 796 | 863 | /* | 
|---|
| 797 | 864 | * Support for sub-channels. For high performance devices, | 
|---|
| 798 | 865 | * it will be useful to have multiple sub-channels to support | 
|---|
| .. | .. | 
|---|
| 822 | 889 | void (*chn_rescind_callback)(struct vmbus_channel *channel); | 
|---|
| 823 | 890 |  | 
|---|
| 824 | 891 | /* | 
|---|
| 825 |  | -	 * The spinlock to protect the structure. It is being used to protect | 
|---|
| 826 |  | -	 * test-and-set access to various attributes of the structure as well | 
|---|
| 827 |  | -	 * as all sc_list operations. | 
|---|
| 828 |  | -	 */ | 
|---|
| 829 |  | -	spinlock_t lock; | 
|---|
| 830 |  | -	/* | 
|---|
| 831 | 892 | * All Sub-channels of a primary channel are linked here. | 
|---|
| 832 | 893 | */ | 
|---|
| 833 | 894 | struct list_head sc_list; | 
|---|
| 834 |  | -	/* | 
|---|
| 835 |  | -	 * Current number of sub-channels. | 
|---|
| 836 |  | -	 */ | 
|---|
| 837 |  | -	int num_sc; | 
|---|
| 838 |  | -	/* | 
|---|
| 839 |  | -	 * Number of a sub-channel (position within sc_list) which is supposed | 
|---|
| 840 |  | -	 * to be used as the next outgoing channel. | 
|---|
| 841 |  | -	 */ | 
|---|
| 842 |  | -	int next_oc; | 
|---|
| 843 | 895 | /* | 
|---|
| 844 | 896 | * The primary channel this sub-channel belongs to. | 
|---|
| 845 | 897 | * This will be NULL for the primary channel. | 
|---|
| .. | .. | 
|---|
| 849 | 901 | * Support per-channel state for use by vmbus drivers. | 
|---|
| 850 | 902 | */ | 
|---|
| 851 | 903 | void *per_channel_state; | 
|---|
| 852 |  | -	/* | 
|---|
| 853 |  | -	 * To support per-cpu lookup mapping of relid to channel, | 
|---|
| 854 |  | -	 * link up channels based on their CPU affinity. | 
|---|
| 855 |  | -	 */ | 
|---|
| 856 |  | -	struct list_head percpu_list; | 
|---|
| 857 | 904 |  | 
|---|
| 858 | 905 | /* | 
|---|
| 859 | 906 | * Defer freeing channel until after all cpu's have | 
|---|
| .. | .. | 
|---|
| 892 | 939 | */ | 
|---|
| 893 | 940 | bool low_latency; | 
|---|
| 894 | 941 |  | 
|---|
| 895 |  | -	/* | 
|---|
| 896 |  | -	 * NUMA distribution policy: | 
|---|
| 897 |  | -	 * We support two policies: | 
|---|
| 898 |  | -	 * 1) Balanced: Here all performance critical channels are | 
|---|
| 899 |  | -	 *    distributed evenly amongst all the NUMA nodes. | 
|---|
| 900 |  | -	 *    This policy will be the default policy. | 
|---|
| 901 |  | -	 * 2) Localized: All channels of a given instance of a | 
|---|
| 902 |  | -	 *    performance critical service will be assigned CPUs | 
|---|
| 903 |  | -	 *    within a selected NUMA node. | 
|---|
| 904 |  | -	 */ | 
|---|
| 905 |  | -	enum hv_numa_policy affinity_policy; | 
|---|
| 906 |  | - | 
|---|
| 907 | 942 | bool probe_done; | 
|---|
|  | 943 | + | 
|---|
|  | 944 | +	/* | 
|---|
|  | 945 | +	 * Cache the device ID here for easy access; this is useful, in | 
|---|
|  | 946 | +	 * particular, in situations where the channel's device_obj has | 
|---|
|  | 947 | +	 * not been allocated/initialized yet. | 
|---|
|  | 948 | +	 */ | 
|---|
|  | 949 | +	u16 device_id; | 
|---|
| 908 | 950 |  | 
|---|
| 909 | 951 | /* | 
|---|
| 910 | 952 | * We must offload the handling of the primary/sub channels | 
|---|
| .. | .. | 
|---|
| 913 | 955 | * vmbus_connection.work_queue and hang: see vmbus_process_offer(). | 
|---|
| 914 | 956 | */ | 
|---|
| 915 | 957 | struct work_struct add_channel_work; | 
|---|
|  | 958 | + | 
|---|
|  | 959 | +	/* | 
|---|
|  | 960 | +	 * Guest to host interrupts caused by the inbound ring buffer changing | 
|---|
|  | 961 | +	 * from full to not full while a packet is waiting. | 
|---|
|  | 962 | +	 */ | 
|---|
|  | 963 | +	u64 intr_in_full; | 
|---|
|  | 964 | + | 
|---|
|  | 965 | +	/* | 
|---|
|  | 966 | +	 * The total number of write operations that encountered a full | 
|---|
|  | 967 | +	 * outbound ring buffer. | 
|---|
|  | 968 | +	 */ | 
|---|
|  | 969 | +	u64 out_full_total; | 
|---|
|  | 970 | + | 
|---|
|  | 971 | +	/* | 
|---|
|  | 972 | +	 * The number of write operations that were the first to encounter a | 
|---|
|  | 973 | +	 * full outbound ring buffer. | 
|---|
|  | 974 | +	 */ | 
|---|
|  | 975 | +	u64 out_full_first; | 
|---|
|  | 976 | + | 
|---|
|  | 977 | +	/* enabling/disabling fuzz testing on the channel (default is false)*/ | 
|---|
|  | 978 | +	bool fuzz_testing_state; | 
|---|
|  | 979 | + | 
|---|
|  | 980 | +	/* | 
|---|
|  | 981 | +	 * Interrupt delay will delay the guest from emptying the ring buffer | 
|---|
|  | 982 | +	 * for a specific amount of time. The delay is in microseconds and will | 
|---|
|  | 983 | +	 * be between 1 to a maximum of 1000, its default is 0 (no delay). | 
|---|
|  | 984 | +	 * The  Message delay will delay guest reading on a per message basis | 
|---|
|  | 985 | +	 * in microseconds between 1 to 1000 with the default being 0 | 
|---|
|  | 986 | +	 * (no delay). | 
|---|
|  | 987 | +	 */ | 
|---|
|  | 988 | +	u32 fuzz_testing_interrupt_delay; | 
|---|
|  | 989 | +	u32 fuzz_testing_message_delay; | 
|---|
|  | 990 | + | 
|---|
| 916 | 991 | }; | 
|---|
| 917 | 992 |  | 
|---|
| 918 | 993 | static inline bool is_hvsock_channel(const struct vmbus_channel *c) | 
|---|
| .. | .. | 
|---|
| 921 | 996 | VMBUS_CHANNEL_TLNPI_PROVIDER_OFFER); | 
|---|
| 922 | 997 | } | 
|---|
| 923 | 998 |  | 
|---|
| 924 |  | -static inline void set_channel_affinity_state(struct vmbus_channel *c, | 
|---|
| 925 |  | -					      enum hv_numa_policy policy) | 
|---|
|  | 999 | +static inline bool is_sub_channel(const struct vmbus_channel *c) | 
|---|
| 926 | 1000 | { | 
|---|
| 927 |  | -	c->affinity_policy = policy; | 
|---|
|  | 1001 | +	return c->offermsg.offer.sub_channel_index != 0; | 
|---|
| 928 | 1002 | } | 
|---|
| 929 | 1003 |  | 
|---|
| 930 | 1004 | static inline void set_channel_read_mode(struct vmbus_channel *c, | 
|---|
| .. | .. | 
|---|
| 946 | 1020 | static inline void set_channel_pending_send_size(struct vmbus_channel *c, | 
|---|
| 947 | 1021 | u32 size) | 
|---|
| 948 | 1022 | { | 
|---|
|  | 1023 | +	unsigned long flags; | 
|---|
|  | 1024 | + | 
|---|
|  | 1025 | +	if (size) { | 
|---|
|  | 1026 | +		spin_lock_irqsave(&c->outbound.ring_lock, flags); | 
|---|
|  | 1027 | +		++c->out_full_total; | 
|---|
|  | 1028 | + | 
|---|
|  | 1029 | +		if (!c->out_full_flag) { | 
|---|
|  | 1030 | +			++c->out_full_first; | 
|---|
|  | 1031 | +			c->out_full_flag = true; | 
|---|
|  | 1032 | +		} | 
|---|
|  | 1033 | +		spin_unlock_irqrestore(&c->outbound.ring_lock, flags); | 
|---|
|  | 1034 | +	} else { | 
|---|
|  | 1035 | +		c->out_full_flag = false; | 
|---|
|  | 1036 | +	} | 
|---|
|  | 1037 | + | 
|---|
| 949 | 1038 | c->outbound.ring_buffer->pending_send_sz = size; | 
|---|
| 950 | 1039 | } | 
|---|
| 951 | 1040 |  | 
|---|
| .. | .. | 
|---|
| 959 | 1048 | c->low_latency = false; | 
|---|
| 960 | 1049 | } | 
|---|
| 961 | 1050 |  | 
|---|
| 962 |  | -void vmbus_onmessage(void *context); | 
|---|
|  | 1051 | +void vmbus_onmessage(struct vmbus_channel_message_header *hdr); | 
|---|
| 963 | 1052 |  | 
|---|
| 964 | 1053 | int vmbus_request_offers(void); | 
|---|
| 965 | 1054 |  | 
|---|
| .. | .. | 
|---|
| 972 | 1061 |  | 
|---|
| 973 | 1062 | void vmbus_set_chn_rescind_callback(struct vmbus_channel *channel, | 
|---|
| 974 | 1063 | void (*chn_rescind_cb)(struct vmbus_channel *)); | 
|---|
| 975 |  | - | 
|---|
| 976 |  | -/* | 
|---|
| 977 |  | - * Retrieve the (sub) channel on which to send an outgoing request. | 
|---|
| 978 |  | - * When a primary channel has multiple sub-channels, we choose a | 
|---|
| 979 |  | - * channel whose VCPU binding is closest to the VCPU on which | 
|---|
| 980 |  | - * this call is being made. | 
|---|
| 981 |  | - */ | 
|---|
| 982 |  | -struct vmbus_channel *vmbus_get_outgoing_channel(struct vmbus_channel *primary); | 
|---|
| 983 | 1064 |  | 
|---|
| 984 | 1065 | /* | 
|---|
| 985 | 1066 | * Check if sub-channels have already been offerred. This API will be useful | 
|---|
| .. | .. | 
|---|
| 1030 | 1111 | struct hv_mpb_array range; | 
|---|
| 1031 | 1112 | } __packed; | 
|---|
| 1032 | 1113 |  | 
|---|
|  | 1114 | +int vmbus_alloc_ring(struct vmbus_channel *channel, | 
|---|
|  | 1115 | +		     u32 send_size, u32 recv_size); | 
|---|
|  | 1116 | +void vmbus_free_ring(struct vmbus_channel *channel); | 
|---|
|  | 1117 | + | 
|---|
|  | 1118 | +int vmbus_connect_ring(struct vmbus_channel *channel, | 
|---|
|  | 1119 | +		       void (*onchannel_callback)(void *context), | 
|---|
|  | 1120 | +		       void *context); | 
|---|
|  | 1121 | +int vmbus_disconnect_ring(struct vmbus_channel *channel); | 
|---|
| 1033 | 1122 |  | 
|---|
| 1034 | 1123 | extern int vmbus_open(struct vmbus_channel *channel, | 
|---|
| 1035 | 1124 | u32 send_ringbuffersize, | 
|---|
| .. | .. | 
|---|
| 1106 | 1195 | bool hvsock; | 
|---|
| 1107 | 1196 |  | 
|---|
| 1108 | 1197 | /* the device type supported by this driver */ | 
|---|
| 1109 |  | -	uuid_le dev_type; | 
|---|
|  | 1198 | +	guid_t dev_type; | 
|---|
| 1110 | 1199 | const struct hv_vmbus_device_id *id_table; | 
|---|
| 1111 | 1200 |  | 
|---|
| 1112 | 1201 | struct device_driver driver; | 
|---|
| .. | .. | 
|---|
| 1121 | 1210 | int (*remove)(struct hv_device *); | 
|---|
| 1122 | 1211 | void (*shutdown)(struct hv_device *); | 
|---|
| 1123 | 1212 |  | 
|---|
|  | 1213 | +	int (*suspend)(struct hv_device *); | 
|---|
|  | 1214 | +	int (*resume)(struct hv_device *); | 
|---|
|  | 1215 | + | 
|---|
| 1124 | 1216 | }; | 
|---|
| 1125 | 1217 |  | 
|---|
| 1126 | 1218 | /* Base device object */ | 
|---|
| 1127 | 1219 | struct hv_device { | 
|---|
| 1128 | 1220 | /* the device type id of this device */ | 
|---|
| 1129 |  | -	uuid_le dev_type; | 
|---|
|  | 1221 | +	guid_t dev_type; | 
|---|
| 1130 | 1222 |  | 
|---|
| 1131 | 1223 | /* the device instance id of this device */ | 
|---|
| 1132 |  | -	uuid_le dev_instance; | 
|---|
|  | 1224 | +	guid_t dev_instance; | 
|---|
| 1133 | 1225 | u16 vendor_id; | 
|---|
| 1134 | 1226 | u16 device_id; | 
|---|
| 1135 | 1227 |  | 
|---|
| 1136 | 1228 | struct device device; | 
|---|
|  | 1229 | +	char *driver_override; /* Driver name to force a match */ | 
|---|
| 1137 | 1230 |  | 
|---|
| 1138 | 1231 | struct vmbus_channel *channel; | 
|---|
| 1139 | 1232 | struct kset	     *channels_kset; | 
|---|
|  | 1233 | + | 
|---|
|  | 1234 | +	/* place holder to keep track of the dir for hv device in debugfs */ | 
|---|
|  | 1235 | +	struct dentry *debug_dir; | 
|---|
|  | 1236 | + | 
|---|
| 1140 | 1237 | }; | 
|---|
| 1141 | 1238 |  | 
|---|
| 1142 | 1239 |  | 
|---|
| .. | .. | 
|---|
| 1169 | 1266 | }; | 
|---|
| 1170 | 1267 |  | 
|---|
| 1171 | 1268 |  | 
|---|
| 1172 |  | -int hv_ringbuffer_get_debuginfo(const struct hv_ring_buffer_info *ring_info, | 
|---|
|  | 1269 | +int hv_ringbuffer_get_debuginfo(struct hv_ring_buffer_info *ring_info, | 
|---|
| 1173 | 1270 | struct hv_ring_buffer_debug_info *debug_info); | 
|---|
|  | 1271 | + | 
|---|
|  | 1272 | +bool hv_ringbuffer_spinlock_busy(struct vmbus_channel *channel); | 
|---|
| 1174 | 1273 |  | 
|---|
| 1175 | 1274 | /* Vmbus interface */ | 
|---|
| 1176 | 1275 | #define vmbus_driver_register(driver)	\ | 
|---|
| .. | .. | 
|---|
| 1197 | 1296 | * {f8615163-df3e-46c5-913f-f2d2f965ed0e} | 
|---|
| 1198 | 1297 | */ | 
|---|
| 1199 | 1298 | #define HV_NIC_GUID \ | 
|---|
| 1200 |  | -	.guid = UUID_LE(0xf8615163, 0xdf3e, 0x46c5, 0x91, 0x3f, \ | 
|---|
| 1201 |  | -			0xf2, 0xd2, 0xf9, 0x65, 0xed, 0x0e) | 
|---|
|  | 1299 | +	.guid = GUID_INIT(0xf8615163, 0xdf3e, 0x46c5, 0x91, 0x3f, \ | 
|---|
|  | 1300 | +			  0xf2, 0xd2, 0xf9, 0x65, 0xed, 0x0e) | 
|---|
| 1202 | 1301 |  | 
|---|
| 1203 | 1302 | /* | 
|---|
| 1204 | 1303 | * IDE GUID | 
|---|
| 1205 | 1304 | * {32412632-86cb-44a2-9b5c-50d1417354f5} | 
|---|
| 1206 | 1305 | */ | 
|---|
| 1207 | 1306 | #define HV_IDE_GUID \ | 
|---|
| 1208 |  | -	.guid = UUID_LE(0x32412632, 0x86cb, 0x44a2, 0x9b, 0x5c, \ | 
|---|
| 1209 |  | -			0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5) | 
|---|
|  | 1307 | +	.guid = GUID_INIT(0x32412632, 0x86cb, 0x44a2, 0x9b, 0x5c, \ | 
|---|
|  | 1308 | +			  0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5) | 
|---|
| 1210 | 1309 |  | 
|---|
| 1211 | 1310 | /* | 
|---|
| 1212 | 1311 | * SCSI GUID | 
|---|
| 1213 | 1312 | * {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} | 
|---|
| 1214 | 1313 | */ | 
|---|
| 1215 | 1314 | #define HV_SCSI_GUID \ | 
|---|
| 1216 |  | -	.guid = UUID_LE(0xba6163d9, 0x04a1, 0x4d29, 0xb6, 0x05, \ | 
|---|
| 1217 |  | -			0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f) | 
|---|
|  | 1315 | +	.guid = GUID_INIT(0xba6163d9, 0x04a1, 0x4d29, 0xb6, 0x05, \ | 
|---|
|  | 1316 | +			  0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f) | 
|---|
| 1218 | 1317 |  | 
|---|
| 1219 | 1318 | /* | 
|---|
| 1220 | 1319 | * Shutdown GUID | 
|---|
| 1221 | 1320 | * {0e0b6031-5213-4934-818b-38d90ced39db} | 
|---|
| 1222 | 1321 | */ | 
|---|
| 1223 | 1322 | #define HV_SHUTDOWN_GUID \ | 
|---|
| 1224 |  | -	.guid = UUID_LE(0x0e0b6031, 0x5213, 0x4934, 0x81, 0x8b, \ | 
|---|
| 1225 |  | -			0x38, 0xd9, 0x0c, 0xed, 0x39, 0xdb) | 
|---|
|  | 1323 | +	.guid = GUID_INIT(0x0e0b6031, 0x5213, 0x4934, 0x81, 0x8b, \ | 
|---|
|  | 1324 | +			  0x38, 0xd9, 0x0c, 0xed, 0x39, 0xdb) | 
|---|
| 1226 | 1325 |  | 
|---|
| 1227 | 1326 | /* | 
|---|
| 1228 | 1327 | * Time Synch GUID | 
|---|
| 1229 | 1328 | * {9527E630-D0AE-497b-ADCE-E80AB0175CAF} | 
|---|
| 1230 | 1329 | */ | 
|---|
| 1231 | 1330 | #define HV_TS_GUID \ | 
|---|
| 1232 |  | -	.guid = UUID_LE(0x9527e630, 0xd0ae, 0x497b, 0xad, 0xce, \ | 
|---|
| 1233 |  | -			0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf) | 
|---|
|  | 1331 | +	.guid = GUID_INIT(0x9527e630, 0xd0ae, 0x497b, 0xad, 0xce, \ | 
|---|
|  | 1332 | +			  0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf) | 
|---|
| 1234 | 1333 |  | 
|---|
| 1235 | 1334 | /* | 
|---|
| 1236 | 1335 | * Heartbeat GUID | 
|---|
| 1237 | 1336 | * {57164f39-9115-4e78-ab55-382f3bd5422d} | 
|---|
| 1238 | 1337 | */ | 
|---|
| 1239 | 1338 | #define HV_HEART_BEAT_GUID \ | 
|---|
| 1240 |  | -	.guid = UUID_LE(0x57164f39, 0x9115, 0x4e78, 0xab, 0x55, \ | 
|---|
| 1241 |  | -			0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d) | 
|---|
|  | 1339 | +	.guid = GUID_INIT(0x57164f39, 0x9115, 0x4e78, 0xab, 0x55, \ | 
|---|
|  | 1340 | +			  0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d) | 
|---|
| 1242 | 1341 |  | 
|---|
| 1243 | 1342 | /* | 
|---|
| 1244 | 1343 | * KVP GUID | 
|---|
| 1245 | 1344 | * {a9a0f4e7-5a45-4d96-b827-8a841e8c03e6} | 
|---|
| 1246 | 1345 | */ | 
|---|
| 1247 | 1346 | #define HV_KVP_GUID \ | 
|---|
| 1248 |  | -	.guid = UUID_LE(0xa9a0f4e7, 0x5a45, 0x4d96, 0xb8, 0x27, \ | 
|---|
| 1249 |  | -			0x8a, 0x84, 0x1e, 0x8c, 0x03, 0xe6) | 
|---|
|  | 1347 | +	.guid = GUID_INIT(0xa9a0f4e7, 0x5a45, 0x4d96, 0xb8, 0x27, \ | 
|---|
|  | 1348 | +			  0x8a, 0x84, 0x1e, 0x8c, 0x03, 0xe6) | 
|---|
| 1250 | 1349 |  | 
|---|
| 1251 | 1350 | /* | 
|---|
| 1252 | 1351 | * Dynamic memory GUID | 
|---|
| 1253 | 1352 | * {525074dc-8985-46e2-8057-a307dc18a502} | 
|---|
| 1254 | 1353 | */ | 
|---|
| 1255 | 1354 | #define HV_DM_GUID \ | 
|---|
| 1256 |  | -	.guid = UUID_LE(0x525074dc, 0x8985, 0x46e2, 0x80, 0x57, \ | 
|---|
| 1257 |  | -			0xa3, 0x07, 0xdc, 0x18, 0xa5, 0x02) | 
|---|
|  | 1355 | +	.guid = GUID_INIT(0x525074dc, 0x8985, 0x46e2, 0x80, 0x57, \ | 
|---|
|  | 1356 | +			  0xa3, 0x07, 0xdc, 0x18, 0xa5, 0x02) | 
|---|
| 1258 | 1357 |  | 
|---|
| 1259 | 1358 | /* | 
|---|
| 1260 | 1359 | * Mouse GUID | 
|---|
| 1261 | 1360 | * {cfa8b69e-5b4a-4cc0-b98b-8ba1a1f3f95a} | 
|---|
| 1262 | 1361 | */ | 
|---|
| 1263 | 1362 | #define HV_MOUSE_GUID \ | 
|---|
| 1264 |  | -	.guid = UUID_LE(0xcfa8b69e, 0x5b4a, 0x4cc0, 0xb9, 0x8b, \ | 
|---|
| 1265 |  | -			0x8b, 0xa1, 0xa1, 0xf3, 0xf9, 0x5a) | 
|---|
|  | 1363 | +	.guid = GUID_INIT(0xcfa8b69e, 0x5b4a, 0x4cc0, 0xb9, 0x8b, \ | 
|---|
|  | 1364 | +			  0x8b, 0xa1, 0xa1, 0xf3, 0xf9, 0x5a) | 
|---|
| 1266 | 1365 |  | 
|---|
| 1267 | 1366 | /* | 
|---|
| 1268 | 1367 | * Keyboard GUID | 
|---|
| 1269 | 1368 | * {f912ad6d-2b17-48ea-bd65-f927a61c7684} | 
|---|
| 1270 | 1369 | */ | 
|---|
| 1271 | 1370 | #define HV_KBD_GUID \ | 
|---|
| 1272 |  | -	.guid = UUID_LE(0xf912ad6d, 0x2b17, 0x48ea, 0xbd, 0x65, \ | 
|---|
| 1273 |  | -			0xf9, 0x27, 0xa6, 0x1c, 0x76, 0x84) | 
|---|
|  | 1371 | +	.guid = GUID_INIT(0xf912ad6d, 0x2b17, 0x48ea, 0xbd, 0x65, \ | 
|---|
|  | 1372 | +			  0xf9, 0x27, 0xa6, 0x1c, 0x76, 0x84) | 
|---|
| 1274 | 1373 |  | 
|---|
| 1275 | 1374 | /* | 
|---|
| 1276 | 1375 | * VSS (Backup/Restore) GUID | 
|---|
| 1277 | 1376 | */ | 
|---|
| 1278 | 1377 | #define HV_VSS_GUID \ | 
|---|
| 1279 |  | -	.guid = UUID_LE(0x35fa2e29, 0xea23, 0x4236, 0x96, 0xae, \ | 
|---|
| 1280 |  | -			0x3a, 0x6e, 0xba, 0xcb, 0xa4, 0x40) | 
|---|
|  | 1378 | +	.guid = GUID_INIT(0x35fa2e29, 0xea23, 0x4236, 0x96, 0xae, \ | 
|---|
|  | 1379 | +			  0x3a, 0x6e, 0xba, 0xcb, 0xa4, 0x40) | 
|---|
| 1281 | 1380 | /* | 
|---|
| 1282 | 1381 | * Synthetic Video GUID | 
|---|
| 1283 | 1382 | * {DA0A7802-E377-4aac-8E77-0558EB1073F8} | 
|---|
| 1284 | 1383 | */ | 
|---|
| 1285 | 1384 | #define HV_SYNTHVID_GUID \ | 
|---|
| 1286 |  | -	.guid = UUID_LE(0xda0a7802, 0xe377, 0x4aac, 0x8e, 0x77, \ | 
|---|
| 1287 |  | -			0x05, 0x58, 0xeb, 0x10, 0x73, 0xf8) | 
|---|
|  | 1385 | +	.guid = GUID_INIT(0xda0a7802, 0xe377, 0x4aac, 0x8e, 0x77, \ | 
|---|
|  | 1386 | +			  0x05, 0x58, 0xeb, 0x10, 0x73, 0xf8) | 
|---|
| 1288 | 1387 |  | 
|---|
| 1289 | 1388 | /* | 
|---|
| 1290 | 1389 | * Synthetic FC GUID | 
|---|
| 1291 | 1390 | * {2f9bcc4a-0069-4af3-b76b-6fd0be528cda} | 
|---|
| 1292 | 1391 | */ | 
|---|
| 1293 | 1392 | #define HV_SYNTHFC_GUID \ | 
|---|
| 1294 |  | -	.guid = UUID_LE(0x2f9bcc4a, 0x0069, 0x4af3, 0xb7, 0x6b, \ | 
|---|
| 1295 |  | -			0x6f, 0xd0, 0xbe, 0x52, 0x8c, 0xda) | 
|---|
|  | 1393 | +	.guid = GUID_INIT(0x2f9bcc4a, 0x0069, 0x4af3, 0xb7, 0x6b, \ | 
|---|
|  | 1394 | +			  0x6f, 0xd0, 0xbe, 0x52, 0x8c, 0xda) | 
|---|
| 1296 | 1395 |  | 
|---|
| 1297 | 1396 | /* | 
|---|
| 1298 | 1397 | * Guest File Copy Service | 
|---|
| .. | .. | 
|---|
| 1300 | 1399 | */ | 
|---|
| 1301 | 1400 |  | 
|---|
| 1302 | 1401 | #define HV_FCOPY_GUID \ | 
|---|
| 1303 |  | -	.guid = UUID_LE(0x34d14be3, 0xdee4, 0x41c8, 0x9a, 0xe7, \ | 
|---|
| 1304 |  | -			0x6b, 0x17, 0x49, 0x77, 0xc1, 0x92) | 
|---|
|  | 1402 | +	.guid = GUID_INIT(0x34d14be3, 0xdee4, 0x41c8, 0x9a, 0xe7, \ | 
|---|
|  | 1403 | +			  0x6b, 0x17, 0x49, 0x77, 0xc1, 0x92) | 
|---|
| 1305 | 1404 |  | 
|---|
| 1306 | 1405 | /* | 
|---|
| 1307 | 1406 | * NetworkDirect. This is the guest RDMA service. | 
|---|
| 1308 | 1407 | * {8c2eaf3d-32a7-4b09-ab99-bd1f1c86b501} | 
|---|
| 1309 | 1408 | */ | 
|---|
| 1310 | 1409 | #define HV_ND_GUID \ | 
|---|
| 1311 |  | -	.guid = UUID_LE(0x8c2eaf3d, 0x32a7, 0x4b09, 0xab, 0x99, \ | 
|---|
| 1312 |  | -			0xbd, 0x1f, 0x1c, 0x86, 0xb5, 0x01) | 
|---|
|  | 1410 | +	.guid = GUID_INIT(0x8c2eaf3d, 0x32a7, 0x4b09, 0xab, 0x99, \ | 
|---|
|  | 1411 | +			  0xbd, 0x1f, 0x1c, 0x86, 0xb5, 0x01) | 
|---|
| 1313 | 1412 |  | 
|---|
| 1314 | 1413 | /* | 
|---|
| 1315 | 1414 | * PCI Express Pass Through | 
|---|
| .. | .. | 
|---|
| 1317 | 1416 | */ | 
|---|
| 1318 | 1417 |  | 
|---|
| 1319 | 1418 | #define HV_PCIE_GUID \ | 
|---|
| 1320 |  | -	.guid = UUID_LE(0x44c4f61d, 0x4444, 0x4400, 0x9d, 0x52, \ | 
|---|
| 1321 |  | -			0x80, 0x2e, 0x27, 0xed, 0xe1, 0x9f) | 
|---|
|  | 1419 | +	.guid = GUID_INIT(0x44c4f61d, 0x4444, 0x4400, 0x9d, 0x52, \ | 
|---|
|  | 1420 | +			  0x80, 0x2e, 0x27, 0xed, 0xe1, 0x9f) | 
|---|
| 1322 | 1421 |  | 
|---|
| 1323 | 1422 | /* | 
|---|
| 1324 | 1423 | * Linux doesn't support the 3 devices: the first two are for | 
|---|
| .. | .. | 
|---|
| 1330 | 1429 | */ | 
|---|
| 1331 | 1430 |  | 
|---|
| 1332 | 1431 | #define HV_AVMA1_GUID \ | 
|---|
| 1333 |  | -	.guid = UUID_LE(0xf8e65716, 0x3cb3, 0x4a06, 0x9a, 0x60, \ | 
|---|
| 1334 |  | -			0x18, 0x89, 0xc5, 0xcc, 0xca, 0xb5) | 
|---|
|  | 1432 | +	.guid = GUID_INIT(0xf8e65716, 0x3cb3, 0x4a06, 0x9a, 0x60, \ | 
|---|
|  | 1433 | +			  0x18, 0x89, 0xc5, 0xcc, 0xca, 0xb5) | 
|---|
| 1335 | 1434 |  | 
|---|
| 1336 | 1435 | #define HV_AVMA2_GUID \ | 
|---|
| 1337 |  | -	.guid = UUID_LE(0x3375baf4, 0x9e15, 0x4b30, 0xb7, 0x65, \ | 
|---|
| 1338 |  | -			0x67, 0xac, 0xb1, 0x0d, 0x60, 0x7b) | 
|---|
|  | 1436 | +	.guid = GUID_INIT(0x3375baf4, 0x9e15, 0x4b30, 0xb7, 0x65, \ | 
|---|
|  | 1437 | +			  0x67, 0xac, 0xb1, 0x0d, 0x60, 0x7b) | 
|---|
| 1339 | 1438 |  | 
|---|
| 1340 | 1439 | #define HV_RDV_GUID \ | 
|---|
| 1341 |  | -	.guid = UUID_LE(0x276aacf4, 0xac15, 0x426c, 0x98, 0xdd, \ | 
|---|
| 1342 |  | -			0x75, 0x21, 0xad, 0x3f, 0x01, 0xfe) | 
|---|
|  | 1440 | +	.guid = GUID_INIT(0x276aacf4, 0xac15, 0x426c, 0x98, 0xdd, \ | 
|---|
|  | 1441 | +			  0x75, 0x21, 0xad, 0x3f, 0x01, 0xfe) | 
|---|
| 1343 | 1442 |  | 
|---|
| 1344 | 1443 | /* | 
|---|
| 1345 | 1444 | * Common header for Hyper-V ICs | 
|---|
| .. | .. | 
|---|
| 1369 | 1468 | void (*util_cb)(void *); | 
|---|
| 1370 | 1469 | int (*util_init)(struct hv_util_service *); | 
|---|
| 1371 | 1470 | void (*util_deinit)(void); | 
|---|
|  | 1471 | +	int (*util_pre_suspend)(void); | 
|---|
|  | 1472 | +	int (*util_pre_resume)(void); | 
|---|
| 1372 | 1473 | }; | 
|---|
| 1373 | 1474 |  | 
|---|
| 1374 | 1475 | struct vmbuspipe_hdr { | 
|---|
| .. | .. | 
|---|
| 1441 | 1542 | struct hyperv_service_callback { | 
|---|
| 1442 | 1543 | u8 msg_type; | 
|---|
| 1443 | 1544 | char *log_msg; | 
|---|
| 1444 |  | -	uuid_le data; | 
|---|
|  | 1545 | +	guid_t data; | 
|---|
| 1445 | 1546 | struct vmbus_channel *channel; | 
|---|
| 1446 | 1547 | void (*callback)(void *context); | 
|---|
| 1447 | 1548 | }; | 
|---|
| .. | .. | 
|---|
| 1452 | 1553 | const int *srv_version, int srv_vercnt, | 
|---|
| 1453 | 1554 | int *nego_fw_version, int *nego_srv_version); | 
|---|
| 1454 | 1555 |  | 
|---|
| 1455 |  | -void hv_process_channel_removal(u32 relid); | 
|---|
|  | 1556 | +void hv_process_channel_removal(struct vmbus_channel *channel); | 
|---|
| 1456 | 1557 |  | 
|---|
| 1457 | 1558 | void vmbus_setevent(struct vmbus_channel *channel); | 
|---|
| 1458 | 1559 | /* | 
|---|
| .. | .. | 
|---|
| 1461 | 1562 |  | 
|---|
| 1462 | 1563 | extern __u32 vmbus_proto_version; | 
|---|
| 1463 | 1564 |  | 
|---|
| 1464 |  | -int vmbus_send_tl_connect_request(const uuid_le *shv_guest_servie_id, | 
|---|
| 1465 |  | -				  const uuid_le *shv_host_servie_id); | 
|---|
|  | 1565 | +int vmbus_send_tl_connect_request(const guid_t *shv_guest_servie_id, | 
|---|
|  | 1566 | +				  const guid_t *shv_host_servie_id); | 
|---|
|  | 1567 | +int vmbus_send_modifychannel(u32 child_relid, u32 target_vp); | 
|---|
| 1466 | 1568 | void vmbus_set_event(struct vmbus_channel *channel); | 
|---|
| 1467 | 1569 |  | 
|---|
| 1468 | 1570 | /* Get the start of the ring buffer. */ | 
|---|
| .. | .. | 
|---|
| 1549 | 1651 | for (pkt = hv_pkt_iter_first(channel); pkt; \ | 
|---|
| 1550 | 1652 | pkt = hv_pkt_iter_next(channel, pkt)) | 
|---|
| 1551 | 1653 |  | 
|---|
|  | 1654 | +/* | 
|---|
|  | 1655 | + * Interface for passing data between SR-IOV PF and VF drivers. The VF driver | 
|---|
|  | 1656 | + * sends requests to read and write blocks. Each block must be 128 bytes or | 
|---|
|  | 1657 | + * smaller. Optionally, the VF driver can register a callback function which | 
|---|
|  | 1658 | + * will be invoked when the host says that one or more of the first 64 block | 
|---|
|  | 1659 | + * IDs is "invalid" which means that the VF driver should reread them. | 
|---|
|  | 1660 | + */ | 
|---|
|  | 1661 | +#define HV_CONFIG_BLOCK_SIZE_MAX 128 | 
|---|
|  | 1662 | + | 
|---|
|  | 1663 | +int hyperv_read_cfg_blk(struct pci_dev *dev, void *buf, unsigned int buf_len, | 
|---|
|  | 1664 | +			unsigned int block_id, unsigned int *bytes_returned); | 
|---|
|  | 1665 | +int hyperv_write_cfg_blk(struct pci_dev *dev, void *buf, unsigned int len, | 
|---|
|  | 1666 | +			 unsigned int block_id); | 
|---|
|  | 1667 | +int hyperv_reg_block_invalidate(struct pci_dev *dev, void *context, | 
|---|
|  | 1668 | +				void (*block_invalidate)(void *context, | 
|---|
|  | 1669 | +							 u64 block_mask)); | 
|---|
|  | 1670 | + | 
|---|
|  | 1671 | +struct hyperv_pci_block_ops { | 
|---|
|  | 1672 | +	int (*read_block)(struct pci_dev *dev, void *buf, unsigned int buf_len, | 
|---|
|  | 1673 | +			  unsigned int block_id, unsigned int *bytes_returned); | 
|---|
|  | 1674 | +	int (*write_block)(struct pci_dev *dev, void *buf, unsigned int len, | 
|---|
|  | 1675 | +			   unsigned int block_id); | 
|---|
|  | 1676 | +	int (*reg_blk_invalidate)(struct pci_dev *dev, void *context, | 
|---|
|  | 1677 | +				  void (*block_invalidate)(void *context, | 
|---|
|  | 1678 | +							   u64 block_mask)); | 
|---|
|  | 1679 | +}; | 
|---|
|  | 1680 | + | 
|---|
|  | 1681 | +extern struct hyperv_pci_block_ops hvpci_block_ops; | 
|---|
|  | 1682 | + | 
|---|
|  | 1683 | +static inline unsigned long virt_to_hvpfn(void *addr) | 
|---|
|  | 1684 | +{ | 
|---|
|  | 1685 | +	phys_addr_t paddr; | 
|---|
|  | 1686 | + | 
|---|
|  | 1687 | +	if (is_vmalloc_addr(addr)) | 
|---|
|  | 1688 | +		paddr = page_to_phys(vmalloc_to_page(addr)) + | 
|---|
|  | 1689 | +				     offset_in_page(addr); | 
|---|
|  | 1690 | +	else | 
|---|
|  | 1691 | +		paddr = __pa(addr); | 
|---|
|  | 1692 | + | 
|---|
|  | 1693 | +	return  paddr >> HV_HYP_PAGE_SHIFT; | 
|---|
|  | 1694 | +} | 
|---|
|  | 1695 | + | 
|---|
|  | 1696 | +#define NR_HV_HYP_PAGES_IN_PAGE	(PAGE_SIZE / HV_HYP_PAGE_SIZE) | 
|---|
|  | 1697 | +#define offset_in_hvpage(ptr)	((unsigned long)(ptr) & ~HV_HYP_PAGE_MASK) | 
|---|
|  | 1698 | +#define HVPFN_UP(x)	(((x) + HV_HYP_PAGE_SIZE-1) >> HV_HYP_PAGE_SHIFT) | 
|---|
|  | 1699 | +#define page_to_hvpfn(page)	(page_to_pfn(page) * NR_HV_HYP_PAGES_IN_PAGE) | 
|---|
|  | 1700 | + | 
|---|
| 1552 | 1701 | #endif /* _HYPERV_H */ | 
|---|