Skip to contentSkip to conversation

Drivers: hv: vmbus: add APIs to register callbacks to process hvsock connection

PATCH Superseded Dexuan Cui 1 participant 1 message Jul 21, 2015

Subsystems (3)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Dexuan Cui

author maintainer
#0 lore raw

PATCH v3 4/7 Drivers: hv: vmbus: add APIs to register callbacks to process hvsock connection

With the 2 APIs supplied by the VMBus driver, the coming net/hvsock driver can register 2 callbacks and can know when a new hvsock connection is offered by the host, and when a hvsock connection is being closed by the host.

---
 drivers/hv/Makefile           |  4 ++-
 drivers/hv/channel_mgmt.c     |  9 ++++++
 drivers/hv/hvsock_callbacks.c | 71 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/hyperv.h        | 10 ++++++
 4 files changed, 93 insertions(+), 1 deletion(-)
 create mode 100644 drivers/hv/hvsock_callbacks.c
drivers/hv/Makefile +3 -1
index 39c9b2c..ef6f8a8 100644
@@ -4,5 +4,7 @@ obj-$(CONFIG_HYPERV_BALLOON)	+= hv_balloon.o
 
 hv_vmbus-y := vmbus_drv.o \
 		 hv.o connection.o channel.o \
-		 channel_mgmt.o ring_buffer.o
+		 channel_mgmt.o ring_buffer.o \
+		 hvsock_callbacks.o
+
 hv_utils-y := hv_util.o hv_kvp.o hv_snapshot.o hv_fcopy.o hv_utils_transport.o
drivers/hv/channel_mgmt.c +9 -0
index 7018c53..a8b1e61 100644
@@ -300,6 +300,12 @@ static void vmbus_process_offer(struct vmbus_channel *newchannel)
 		return;
 	}
 
+	if (is_hvsock_channel(newchannel)) {
+		if (hvsock_process_offer(newchannel) != 0)
+			goto err_deq_chan;
+		return;
+	}
+
 	/*
 	 * Start the process of binding this offer to the driver
 	 * We need to set the DeviceObject field before calling
@@ -564,7 +570,10 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr)
 			vmbus_device_unregister(channel->device_obj);
 			put_device(dev);
 		}
+	} else if (is_hvsock_channel(channel)) {
+		hvsock_process_offer_rescind(channel);
 	} else {
+		/* it is a sub-channel. */
 		hv_process_channel_removal(channel,
 			channel->offermsg.child_relid);
 	}
drivers/hv/hvsock_callbacks.c new file +71 -0

71 lines not on this page · raw message

include/linux/hyperv.h +10 -0
index c8e27da..fda9790 100644
@@ -1269,6 +1269,16 @@ extern __u32 vmbus_proto_version;
 
 int vmbus_send_tl_connect_request(const uuid_le *shv_guest_servie_id,
 				  const uuid_le *shv_host_servie_id);
+
+extern int hvsock_process_offer(struct vmbus_channel *channel);
+extern void hvsock_process_offer_rescind(struct vmbus_channel *channel);
+
+extern void vmbus_register_hvsock_callbacks(
+	int (*process_offer)(struct vmbus_channel *),
+	void (*process_offer_rescind)(struct vmbus_channel *));
+
+void vmbus_unregister_hvsock_callbacks(void);
+
 struct vmpipe_proto_header {
 	u32 pkt_type;
 
Signature · 1 line
2.1.0