aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/hyperv.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/hyperv.h')
-rw-r--r--include/linux/hyperv.h96
1 files changed, 96 insertions, 0 deletions
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 753dbad0bf94..aa0fadce9308 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -235,6 +235,7 @@ struct vmbus_channel_offer {
235#define VMBUS_CHANNEL_LOOPBACK_OFFER 0x100 235#define VMBUS_CHANNEL_LOOPBACK_OFFER 0x100
236#define VMBUS_CHANNEL_PARENT_OFFER 0x200 236#define VMBUS_CHANNEL_PARENT_OFFER 0x200
237#define VMBUS_CHANNEL_REQUEST_MONITORED_NOTIFICATION 0x400 237#define VMBUS_CHANNEL_REQUEST_MONITORED_NOTIFICATION 0x400
238#define VMBUS_CHANNEL_TLNPI_PROVIDER_OFFER 0x2000
238 239
239struct vmpacket_descriptor { 240struct vmpacket_descriptor {
240 u16 type; 241 u16 type;
@@ -391,6 +392,10 @@ enum vmbus_channel_message_type {
391 CHANNELMSG_VERSION_RESPONSE = 15, 392 CHANNELMSG_VERSION_RESPONSE = 15,
392 CHANNELMSG_UNLOAD = 16, 393 CHANNELMSG_UNLOAD = 16,
393 CHANNELMSG_UNLOAD_RESPONSE = 17, 394 CHANNELMSG_UNLOAD_RESPONSE = 17,
395 CHANNELMSG_18 = 18,
396 CHANNELMSG_19 = 19,
397 CHANNELMSG_20 = 20,
398 CHANNELMSG_TL_CONNECT_REQUEST = 21,
394 CHANNELMSG_COUNT 399 CHANNELMSG_COUNT
395}; 400};
396 401
@@ -561,6 +566,13 @@ struct vmbus_channel_initiate_contact {
561 u64 monitor_page2; 566 u64 monitor_page2;
562} __packed; 567} __packed;
563 568
569/* Hyper-V socket: guest's connect()-ing to host */
570struct vmbus_channel_tl_connect_request {
571 struct vmbus_channel_message_header header;
572 uuid_le guest_endpoint_id;
573 uuid_le host_service_id;
574} __packed;
575
564struct vmbus_channel_version_response { 576struct vmbus_channel_version_response {
565 struct vmbus_channel_message_header header; 577 struct vmbus_channel_message_header header;
566 u8 version_supported; 578 u8 version_supported;
@@ -633,6 +645,32 @@ enum hv_signal_policy {
633 HV_SIGNAL_POLICY_EXPLICIT, 645 HV_SIGNAL_POLICY_EXPLICIT,
634}; 646};
635 647
648enum vmbus_device_type {
649 HV_IDE = 0,
650 HV_SCSI,
651 HV_FC,
652 HV_NIC,
653 HV_ND,
654 HV_PCIE,
655 HV_FB,
656 HV_KBD,
657 HV_MOUSE,
658 HV_KVP,
659 HV_TS,
660 HV_HB,
661 HV_SHUTDOWN,
662 HV_FCOPY,
663 HV_BACKUP,
664 HV_DM,
665 HV_UNKOWN,
666};
667
668struct vmbus_device {
669 u16 dev_type;
670 uuid_le guid;
671 bool perf_device;
672};
673
636struct vmbus_channel { 674struct vmbus_channel {
637 /* Unique channel id */ 675 /* Unique channel id */
638 int id; 676 int id;
@@ -728,6 +766,12 @@ struct vmbus_channel {
728 void (*sc_creation_callback)(struct vmbus_channel *new_sc); 766 void (*sc_creation_callback)(struct vmbus_channel *new_sc);
729 767
730 /* 768 /*
769 * Channel rescind callback. Some channels (the hvsock ones), need to
770 * register a callback which is invoked in vmbus_onoffer_rescind().
771 */
772 void (*chn_rescind_callback)(struct vmbus_channel *channel);
773
774 /*
731 * The spinlock to protect the structure. It is being used to protect 775 * The spinlock to protect the structure. It is being used to protect
732 * test-and-set access to various attributes of the structure as well 776 * test-and-set access to various attributes of the structure as well
733 * as all sc_list operations. 777 * as all sc_list operations.
@@ -767,8 +811,30 @@ struct vmbus_channel {
767 * signaling control. 811 * signaling control.
768 */ 812 */
769 enum hv_signal_policy signal_policy; 813 enum hv_signal_policy signal_policy;
814 /*
815 * On the channel send side, many of the VMBUS
816 * device drivers explicity serialize access to the
817 * outgoing ring buffer. Give more control to the
818 * VMBUS device drivers in terms how to serialize
819 * accesss to the outgoing ring buffer.
820 * The default behavior will be to aquire the
821 * ring lock to preserve the current behavior.
822 */
823 bool acquire_ring_lock;
824
770}; 825};
771 826
827static inline void set_channel_lock_state(struct vmbus_channel *c, bool state)
828{
829 c->acquire_ring_lock = state;
830}
831
832static inline bool is_hvsock_channel(const struct vmbus_channel *c)
833{
834 return !!(c->offermsg.offer.chn_flags &
835 VMBUS_CHANNEL_TLNPI_PROVIDER_OFFER);
836}
837
772static inline void set_channel_signal_state(struct vmbus_channel *c, 838static inline void set_channel_signal_state(struct vmbus_channel *c,
773 enum hv_signal_policy policy) 839 enum hv_signal_policy policy)
774{ 840{
@@ -790,6 +856,12 @@ static inline void *get_per_channel_state(struct vmbus_channel *c)
790 return c->per_channel_state; 856 return c->per_channel_state;
791} 857}
792 858
859static inline void set_channel_pending_send_size(struct vmbus_channel *c,
860 u32 size)
861{
862 c->outbound.ring_buffer->pending_send_sz = size;
863}
864
793void vmbus_onmessage(void *context); 865void vmbus_onmessage(void *context);
794 866
795int vmbus_request_offers(void); 867int vmbus_request_offers(void);
@@ -801,6 +873,9 @@ int vmbus_request_offers(void);
801void vmbus_set_sc_create_callback(struct vmbus_channel *primary_channel, 873void vmbus_set_sc_create_callback(struct vmbus_channel *primary_channel,
802 void (*sc_cr_cb)(struct vmbus_channel *new_sc)); 874 void (*sc_cr_cb)(struct vmbus_channel *new_sc));
803 875
876void vmbus_set_chn_rescind_callback(struct vmbus_channel *channel,
877 void (*chn_rescind_cb)(struct vmbus_channel *));
878
804/* 879/*
805 * Retrieve the (sub) channel on which to send an outgoing request. 880 * Retrieve the (sub) channel on which to send an outgoing request.
806 * When a primary channel has multiple sub-channels, we choose a 881 * When a primary channel has multiple sub-channels, we choose a
@@ -940,6 +1015,20 @@ extern void vmbus_ontimer(unsigned long data);
940struct hv_driver { 1015struct hv_driver {
941 const char *name; 1016 const char *name;
942 1017
1018 /*
1019 * A hvsock offer, which has a VMBUS_CHANNEL_TLNPI_PROVIDER_OFFER
1020 * channel flag, actually doesn't mean a synthetic device because the
1021 * offer's if_type/if_instance can change for every new hvsock
1022 * connection.
1023 *
1024 * However, to facilitate the notification of new-offer/rescind-offer
1025 * from vmbus driver to hvsock driver, we can handle hvsock offer as
1026 * a special vmbus device, and hence we need the below flag to
1027 * indicate if the driver is the hvsock driver or not: we need to
1028 * specially treat the hvosck offer & driver in vmbus_match().
1029 */
1030 bool hvsock;
1031
943 /* the device type supported by this driver */ 1032 /* the device type supported by this driver */
944 uuid_le dev_type; 1033 uuid_le dev_type;
945 const struct hv_vmbus_device_id *id_table; 1034 const struct hv_vmbus_device_id *id_table;
@@ -959,6 +1048,8 @@ struct hv_device {
959 1048
960 /* the device instance id of this device */ 1049 /* the device instance id of this device */
961 uuid_le dev_instance; 1050 uuid_le dev_instance;
1051 u16 vendor_id;
1052 u16 device_id;
962 1053
963 struct device device; 1054 struct device device;
964 1055
@@ -994,6 +1085,8 @@ int __must_check __vmbus_driver_register(struct hv_driver *hv_driver,
994 const char *mod_name); 1085 const char *mod_name);
995void vmbus_driver_unregister(struct hv_driver *hv_driver); 1086void vmbus_driver_unregister(struct hv_driver *hv_driver);
996 1087
1088void vmbus_hvsock_device_unregister(struct vmbus_channel *channel);
1089
997int vmbus_allocate_mmio(struct resource **new, struct hv_device *device_obj, 1090int vmbus_allocate_mmio(struct resource **new, struct hv_device *device_obj,
998 resource_size_t min, resource_size_t max, 1091 resource_size_t min, resource_size_t max,
999 resource_size_t size, resource_size_t align, 1092 resource_size_t size, resource_size_t align,
@@ -1158,6 +1251,7 @@ u64 hv_do_hypercall(u64 control, void *input, void *output);
1158 1251
1159struct hv_util_service { 1252struct hv_util_service {
1160 u8 *recv_buffer; 1253 u8 *recv_buffer;
1254 void *channel;
1161 void (*util_cb)(void *); 1255 void (*util_cb)(void *);
1162 int (*util_init)(struct hv_util_service *); 1256 int (*util_init)(struct hv_util_service *);
1163 void (*util_deinit)(void); 1257 void (*util_deinit)(void);
@@ -1242,4 +1336,6 @@ void hv_process_channel_removal(struct vmbus_channel *channel, u32 relid);
1242 1336
1243extern __u32 vmbus_proto_version; 1337extern __u32 vmbus_proto_version;
1244 1338
1339int vmbus_send_tl_connect_request(const uuid_le *shv_guest_servie_id,
1340 const uuid_le *shv_host_servie_id);
1245#endif /* _HYPERV_H */ 1341#endif /* _HYPERV_H */