hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/include/linux/hyperv.h
....@@ -1,25 +1,12 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 *
34 * 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.
175 *
186 * Authors:
197 * Haiyang Zhang <haiyangz@microsoft.com>
208 * Hank Janssen <hjanssen@microsoft.com>
219 * K. Y. Srinivasan <kys@microsoft.com>
22
- *
2310 */
2411
2512 #ifndef _HYPERV_H
....@@ -27,6 +14,7 @@
2714
2815 #include <uapi/linux/hyperv.h>
2916
17
+#include <linux/mm.h>
3018 #include <linux/types.h>
3119 #include <linux/scatterlist.h>
3220 #include <linux/list.h>
....@@ -36,11 +24,54 @@
3624 #include <linux/mod_devicetable.h>
3725 #include <linux/interrupt.h>
3826 #include <linux/reciprocal_div.h>
27
+#include <asm/hyperv-tlfs.h>
3928
4029 #define MAX_PAGE_BUFFER_COUNT 32
4130 #define MAX_MULTIPAGE_BUFFER_COUNT 32 /* 128K */
4231
4332 #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
+};
4475
4576 /* Single-page buffer */
4677 struct hv_page_buffer {
....@@ -124,14 +155,18 @@
124155 } feature_bits;
125156
126157 /* Pad it to PAGE_SIZE so that data starts on page boundary */
127
- u8 reserved2[4028];
158
+ u8 reserved2[PAGE_SIZE - 68];
128159
129160 /*
130161 * Ring data starts here + RingDataStartOffset
131162 * !!! DO NOT place any fields below this !!!
132163 */
133
- u8 buffer[0];
164
+ u8 buffer[];
134165 } __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))
135170
136171 struct hv_ring_buffer_info {
137172 struct hv_ring_buffer *ring_buffer;
....@@ -141,6 +176,11 @@
141176
142177 u32 ring_datasize; /* < ring_size */
143178 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;
144184 };
145185
146186
....@@ -190,19 +230,21 @@
190230 * 2 . 4 (Windows 8)
191231 * 3 . 0 (Windows 8 R2)
192232 * 4 . 0 (Windows 10)
233
+ * 4 . 1 (Windows 10 RS3)
193234 * 5 . 0 (Newer Windows 10)
235
+ * 5 . 1 (Windows 10 RS4)
236
+ * 5 . 2 (Windows Server 2019, RS5)
194237 */
195238
196239 #define VERSION_WS2008 ((0 << 16) | (13))
197240 #define VERSION_WIN7 ((1 << 16) | (1))
198241 #define VERSION_WIN8 ((2 << 16) | (4))
199242 #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))
201245 #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))
206248
207249 /* Make maximum size of pipe payload of 16K */
208250 #define MAX_PIPE_DATA_PAYLOAD (sizeof(u8) * 16384)
....@@ -222,8 +264,8 @@
222264 * struct contains the fundamental information about an offer.
223265 */
224266 struct vmbus_channel_offer {
225
- uuid_le if_type;
226
- uuid_le if_instance;
267
+ guid_t if_type;
268
+ guid_t if_instance;
227269
228270 /*
229271 * These two fields are not currently used.
....@@ -253,7 +295,10 @@
253295 } pipe;
254296 } u;
255297 /*
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.
257302 */
258303 u16 sub_channel_index;
259304 u16 reserved3;
....@@ -316,7 +361,7 @@
316361 struct gpa_range {
317362 u32 byte_count;
318363 u32 byte_offset;
319
- u64 pfn_array[0];
364
+ u64 pfn_array[];
320365 };
321366
322367 /*
....@@ -428,10 +473,13 @@
428473 CHANNELMSG_19 = 19,
429474 CHANNELMSG_20 = 20,
430475 CHANNELMSG_TL_CONNECT_REQUEST = 21,
431
- CHANNELMSG_22 = 22,
476
+ CHANNELMSG_MODIFYCHANNEL = 22,
432477 CHANNELMSG_TL_CONNECT_RESULT = 23,
433478 CHANNELMSG_COUNT
434479 };
480
+
481
+/* Hyper-V supports about 2048 channels, and the RELIDs start with 1. */
482
+#define INVALID_RELID U32_MAX
435483
436484 struct vmbus_channel_message_header {
437485 enum vmbus_channel_message_type msgtype;
....@@ -563,7 +611,7 @@
563611 u32 gpadl;
564612 u16 range_buflen;
565613 u16 rangecount;
566
- struct gpa_range range[0];
614
+ struct gpa_range range[];
567615 } __packed;
568616
569617 /* This is the followup packet that contains more PFNs. */
....@@ -571,7 +619,7 @@
571619 struct vmbus_channel_message_header header;
572620 u32 msgnumber;
573621 u32 gpadl;
574
- u64 pfn[0];
622
+ u64 pfn[];
575623 } __packed;
576624
577625 struct vmbus_channel_gpadl_created {
....@@ -616,8 +664,15 @@
616664 /* Hyper-V socket: guest's connect()-ing to host */
617665 struct vmbus_channel_tl_connect_request {
618666 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;
621676 } __packed;
622677
623678 struct vmbus_channel_version_response {
....@@ -672,7 +727,7 @@
672727 * The channel message that goes out on the "wire".
673728 * It will contain at minimum the VMBUS_CHANNEL_MESSAGE_HEADER header
674729 */
675
- unsigned char msg[0];
730
+ unsigned char msg[];
676731 };
677732
678733 struct vmbus_close_msg {
....@@ -687,11 +742,6 @@
687742 u32 id:24;
688743 u32 reserved:8;
689744 } u;
690
-};
691
-
692
-enum hv_numa_policy {
693
- HV_BALANCED = 0,
694
- HV_LOCALIZED,
695745 };
696746
697747 enum vmbus_device_type {
....@@ -716,7 +766,7 @@
716766
717767 struct vmbus_device {
718768 u16 dev_type;
719
- uuid_le guid;
769
+ guid_t guid;
720770 bool perf_device;
721771 };
722772
....@@ -743,6 +793,7 @@
743793 /* Allocated memory for ring buffer */
744794 struct page *ringbuffer_page;
745795 u32 ringbuffer_pagecount;
796
+ u32 ringbuffer_send_offset;
746797 struct hv_ring_buffer_info outbound; /* send to parent */
747798 struct hv_ring_buffer_info inbound; /* receive from parent */
748799
....@@ -752,10 +803,32 @@
752803 u64 interrupts; /* Host to Guest interrupts */
753804 u64 sig_events; /* Guest to Host events */
754805
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
+
755819 /* Channel callback's invoked in softirq context */
756820 struct tasklet_struct callback_event;
757821 void (*onchannel_callback)(void *context);
758822 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;
759832
760833 /*
761834 * A channel can be marked for one of three modes of reading:
....@@ -778,21 +851,15 @@
778851 u64 sig_event;
779852
780853 /*
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.
787861 */
788
- u32 target_vp;
789
- /* The corresponding CPUID in the guest */
790862 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;
796863 /*
797864 * Support for sub-channels. For high performance devices,
798865 * it will be useful to have multiple sub-channels to support
....@@ -822,24 +889,9 @@
822889 void (*chn_rescind_callback)(struct vmbus_channel *channel);
823890
824891 /*
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
- /*
831892 * All Sub-channels of a primary channel are linked here.
832893 */
833894 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;
843895 /*
844896 * The primary channel this sub-channel belongs to.
845897 * This will be NULL for the primary channel.
....@@ -849,11 +901,6 @@
849901 * Support per-channel state for use by vmbus drivers.
850902 */
851903 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;
857904
858905 /*
859906 * Defer freeing channel until after all cpu's have
....@@ -892,19 +939,14 @@
892939 */
893940 bool low_latency;
894941
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
-
907942 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;
908950
909951 /*
910952 * We must offload the handling of the primary/sub channels
....@@ -913,6 +955,39 @@
913955 * vmbus_connection.work_queue and hang: see vmbus_process_offer().
914956 */
915957 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
+
916991 };
917992
918993 static inline bool is_hvsock_channel(const struct vmbus_channel *c)
....@@ -921,10 +996,9 @@
921996 VMBUS_CHANNEL_TLNPI_PROVIDER_OFFER);
922997 }
923998
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)
9261000 {
927
- c->affinity_policy = policy;
1001
+ return c->offermsg.offer.sub_channel_index != 0;
9281002 }
9291003
9301004 static inline void set_channel_read_mode(struct vmbus_channel *c,
....@@ -946,6 +1020,21 @@
9461020 static inline void set_channel_pending_send_size(struct vmbus_channel *c,
9471021 u32 size)
9481022 {
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
+
9491038 c->outbound.ring_buffer->pending_send_sz = size;
9501039 }
9511040
....@@ -959,7 +1048,7 @@
9591048 c->low_latency = false;
9601049 }
9611050
962
-void vmbus_onmessage(void *context);
1051
+void vmbus_onmessage(struct vmbus_channel_message_header *hdr);
9631052
9641053 int vmbus_request_offers(void);
9651054
....@@ -972,14 +1061,6 @@
9721061
9731062 void vmbus_set_chn_rescind_callback(struct vmbus_channel *channel,
9741063 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);
9831064
9841065 /*
9851066 * Check if sub-channels have already been offerred. This API will be useful
....@@ -1030,6 +1111,14 @@
10301111 struct hv_mpb_array range;
10311112 } __packed;
10321113
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);
10331122
10341123 extern int vmbus_open(struct vmbus_channel *channel,
10351124 u32 send_ringbuffersize,
....@@ -1106,7 +1195,7 @@
11061195 bool hvsock;
11071196
11081197 /* the device type supported by this driver */
1109
- uuid_le dev_type;
1198
+ guid_t dev_type;
11101199 const struct hv_vmbus_device_id *id_table;
11111200
11121201 struct device_driver driver;
....@@ -1121,22 +1210,30 @@
11211210 int (*remove)(struct hv_device *);
11221211 void (*shutdown)(struct hv_device *);
11231212
1213
+ int (*suspend)(struct hv_device *);
1214
+ int (*resume)(struct hv_device *);
1215
+
11241216 };
11251217
11261218 /* Base device object */
11271219 struct hv_device {
11281220 /* the device type id of this device */
1129
- uuid_le dev_type;
1221
+ guid_t dev_type;
11301222
11311223 /* the device instance id of this device */
1132
- uuid_le dev_instance;
1224
+ guid_t dev_instance;
11331225 u16 vendor_id;
11341226 u16 device_id;
11351227
11361228 struct device device;
1229
+ char *driver_override; /* Driver name to force a match */
11371230
11381231 struct vmbus_channel *channel;
11391232 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
+
11401237 };
11411238
11421239
....@@ -1169,8 +1266,10 @@
11691266 };
11701267
11711268
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,
11731270 struct hv_ring_buffer_debug_info *debug_info);
1271
+
1272
+bool hv_ringbuffer_spinlock_busy(struct vmbus_channel *channel);
11741273
11751274 /* Vmbus interface */
11761275 #define vmbus_driver_register(driver) \
....@@ -1197,102 +1296,102 @@
11971296 * {f8615163-df3e-46c5-913f-f2d2f965ed0e}
11981297 */
11991298 #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)
12021301
12031302 /*
12041303 * IDE GUID
12051304 * {32412632-86cb-44a2-9b5c-50d1417354f5}
12061305 */
12071306 #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)
12101309
12111310 /*
12121311 * SCSI GUID
12131312 * {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f}
12141313 */
12151314 #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)
12181317
12191318 /*
12201319 * Shutdown GUID
12211320 * {0e0b6031-5213-4934-818b-38d90ced39db}
12221321 */
12231322 #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)
12261325
12271326 /*
12281327 * Time Synch GUID
12291328 * {9527E630-D0AE-497b-ADCE-E80AB0175CAF}
12301329 */
12311330 #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)
12341333
12351334 /*
12361335 * Heartbeat GUID
12371336 * {57164f39-9115-4e78-ab55-382f3bd5422d}
12381337 */
12391338 #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)
12421341
12431342 /*
12441343 * KVP GUID
12451344 * {a9a0f4e7-5a45-4d96-b827-8a841e8c03e6}
12461345 */
12471346 #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)
12501349
12511350 /*
12521351 * Dynamic memory GUID
12531352 * {525074dc-8985-46e2-8057-a307dc18a502}
12541353 */
12551354 #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)
12581357
12591358 /*
12601359 * Mouse GUID
12611360 * {cfa8b69e-5b4a-4cc0-b98b-8ba1a1f3f95a}
12621361 */
12631362 #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)
12661365
12671366 /*
12681367 * Keyboard GUID
12691368 * {f912ad6d-2b17-48ea-bd65-f927a61c7684}
12701369 */
12711370 #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)
12741373
12751374 /*
12761375 * VSS (Backup/Restore) GUID
12771376 */
12781377 #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)
12811380 /*
12821381 * Synthetic Video GUID
12831382 * {DA0A7802-E377-4aac-8E77-0558EB1073F8}
12841383 */
12851384 #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)
12881387
12891388 /*
12901389 * Synthetic FC GUID
12911390 * {2f9bcc4a-0069-4af3-b76b-6fd0be528cda}
12921391 */
12931392 #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)
12961395
12971396 /*
12981397 * Guest File Copy Service
....@@ -1300,16 +1399,16 @@
13001399 */
13011400
13021401 #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)
13051404
13061405 /*
13071406 * NetworkDirect. This is the guest RDMA service.
13081407 * {8c2eaf3d-32a7-4b09-ab99-bd1f1c86b501}
13091408 */
13101409 #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)
13131412
13141413 /*
13151414 * PCI Express Pass Through
....@@ -1317,8 +1416,8 @@
13171416 */
13181417
13191418 #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)
13221421
13231422 /*
13241423 * Linux doesn't support the 3 devices: the first two are for
....@@ -1330,16 +1429,16 @@
13301429 */
13311430
13321431 #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)
13351434
13361435 #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)
13391438
13401439 #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)
13431442
13441443 /*
13451444 * Common header for Hyper-V ICs
....@@ -1369,6 +1468,8 @@
13691468 void (*util_cb)(void *);
13701469 int (*util_init)(struct hv_util_service *);
13711470 void (*util_deinit)(void);
1471
+ int (*util_pre_suspend)(void);
1472
+ int (*util_pre_resume)(void);
13721473 };
13731474
13741475 struct vmbuspipe_hdr {
....@@ -1441,7 +1542,7 @@
14411542 struct hyperv_service_callback {
14421543 u8 msg_type;
14431544 char *log_msg;
1444
- uuid_le data;
1545
+ guid_t data;
14451546 struct vmbus_channel *channel;
14461547 void (*callback)(void *context);
14471548 };
....@@ -1452,7 +1553,7 @@
14521553 const int *srv_version, int srv_vercnt,
14531554 int *nego_fw_version, int *nego_srv_version);
14541555
1455
-void hv_process_channel_removal(u32 relid);
1556
+void hv_process_channel_removal(struct vmbus_channel *channel);
14561557
14571558 void vmbus_setevent(struct vmbus_channel *channel);
14581559 /*
....@@ -1461,8 +1562,9 @@
14611562
14621563 extern __u32 vmbus_proto_version;
14631564
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);
14661568 void vmbus_set_event(struct vmbus_channel *channel);
14671569
14681570 /* Get the start of the ring buffer. */
....@@ -1549,4 +1651,51 @@
15491651 for (pkt = hv_pkt_iter_first(channel); pkt; \
15501652 pkt = hv_pkt_iter_next(channel, pkt))
15511653
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
+
15521701 #endif /* _HYPERV_H */