Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Jul 2016 06:16:40 +0000 (UTC)
From:      Sepherosa Ziehau <sephe@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r302875 - head/sys/dev/hyperv/vmbus
Message-ID:  <201607150616.u6F6GeRL094391@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sephe
Date: Fri Jul 15 06:16:39 2016
New Revision: 302875
URL: https://svnweb.freebsd.org/changeset/base/302875

Log:
  hyperv/vmbus: Redefine channel packet.
  
  The channel packet header will be shared w/ PRP (physical region page)
  list channel packet and SG (scatter gather) list channel packet.
  
  MFC after:	1 week
  Sponsored by:	Microsoft OSTC
  Differential Revision:	https://reviews.freebsd.org/D7155

Modified:
  head/sys/dev/hyperv/vmbus/hv_channel.c
  head/sys/dev/hyperv/vmbus/vmbus_reg.h

Modified: head/sys/dev/hyperv/vmbus/hv_channel.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_channel.c	Fri Jul 15 06:08:48 2016	(r302874)
+++ head/sys/dev/hyperv/vmbus/hv_channel.c	Fri Jul 15 06:16:39 2016	(r302875)
@@ -634,27 +634,28 @@ hv_vmbus_channel_send_packet(
 	uint32_t		flags)
 {
 	int			ret = 0;
-	hv_vm_packet_descriptor	desc;
+	struct vmbus_chanpkt pkt;
 	uint32_t		packet_len;
 	uint64_t		aligned_data;
 	uint32_t		packet_len_aligned;
 	boolean_t		need_sig;
 	struct iovec		iov[3];
 
-	packet_len = sizeof(hv_vm_packet_descriptor) + buffer_len;
-	packet_len_aligned = HV_ALIGN_UP(packet_len, sizeof(uint64_t));
+	packet_len = sizeof(pkt) + buffer_len;
+	packet_len_aligned = roundup2(packet_len, VMBUS_CHANPKT_SIZE_ALIGN);
 	aligned_data = 0;
 
-	/* Setup the descriptor */
-	desc.type = type;   /* HV_VMBUS_PACKET_TYPE_DATA_IN_BAND;             */
-	desc.flags = flags; /* HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED */
-			    /* in 8-bytes granularity */
-	desc.data_offset8 = sizeof(hv_vm_packet_descriptor) >> 3;
-	desc.length8 = (uint16_t) (packet_len_aligned >> 3);
-	desc.transaction_id = request_id;
+	/*
+	 * Setup channel packet.
+	 */
+	pkt.cp_hdr.cph_type = type;
+	pkt.cp_hdr.cph_flags = flags;
+	pkt.cp_hdr.cph_data_ofs = sizeof(pkt) >> VMBUS_CHANPKT_SIZE_SHIFT;
+	pkt.cp_hdr.cph_len = packet_len_aligned >> VMBUS_CHANPKT_SIZE_SHIFT;
+	pkt.cp_hdr.cph_xactid = request_id;
 
-	iov[0].iov_base = &desc;
-	iov[0].iov_len = sizeof(hv_vm_packet_descriptor);
+	iov[0].iov_base = &pkt;
+	iov[0].iov_len = sizeof(pkt);
 
 	iov[1].iov_base = buffer;
 	iov[1].iov_len = buffer_len;

Modified: head/sys/dev/hyperv/vmbus/vmbus_reg.h
==============================================================================
--- head/sys/dev/hyperv/vmbus/vmbus_reg.h	Fri Jul 15 06:08:48 2016	(r302874)
+++ head/sys/dev/hyperv/vmbus/vmbus_reg.h	Fri Jul 15 06:16:39 2016	(r302875)
@@ -117,6 +117,25 @@ struct vmbus_gpa_range {
 } __packed;
 
 /*
+ * Channel packets
+ */
+
+#define VMBUS_CHANPKT_SIZE_SHIFT	3
+#define VMBUS_CHANPKT_SIZE_ALIGN	(1 << VMBUS_CHANPKT_SIZE_SHIFT)
+
+struct vmbus_chanpkt_hdr {
+	uint16_t	cph_type;
+	uint16_t	cph_data_ofs;	/* in 8 bytes */
+	uint16_t	cph_len;	/* in 8 bytes */
+	uint16_t	cph_flags;
+	uint64_t	cph_xactid;
+} __packed;
+
+struct vmbus_chanpkt {
+	struct vmbus_chanpkt_hdr cp_hdr;
+} __packed;
+
+/*
  * Channel messages
  * - Embedded in vmbus_message.msg_data, e.g. response and notification.
  * - Embedded in hypercall_postmsg_in.hc_data, e.g. request.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201607150616.u6F6GeRL094391>