Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Jul 2016 05:29:04 +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: r302870 - head/sys/dev/hyperv/vmbus
Message-ID:  <201607150529.u6F5T4pa075956@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sephe
Date: Fri Jul 15 05:29:04 2016
New Revision: 302870
URL: https://svnweb.freebsd.org/changeset/base/302870

Log:
  hyperv/vmbus: Use iovec for bufring scatter/gather list.
  
  MFC after:	1 week
  Sponsored by:	Microsoft OSTC
  Differential Revision:	https://reviews.freebsd.org/D7134

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

Modified: head/sys/dev/hyperv/vmbus/hv_channel.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_channel.c	Fri Jul 15 05:15:21 2016	(r302869)
+++ head/sys/dev/hyperv/vmbus/hv_channel.c	Fri Jul 15 05:29:04 2016	(r302870)
@@ -616,7 +616,7 @@ hv_vmbus_channel_send_packet(
 	uint64_t		aligned_data;
 	uint32_t		packet_len_aligned;
 	boolean_t		need_sig;
-	hv_vmbus_sg_buffer_list	buffer_list[3];
+	struct iovec		iov[3];
 
 	packet_len = sizeof(hv_vm_packet_descriptor) + buffer_len;
 	packet_len_aligned = HV_ALIGN_UP(packet_len, sizeof(uint64_t));
@@ -630,17 +630,16 @@ hv_vmbus_channel_send_packet(
 	desc.length8 = (uint16_t) (packet_len_aligned >> 3);
 	desc.transaction_id = request_id;
 
-	buffer_list[0].data = &desc;
-	buffer_list[0].length = sizeof(hv_vm_packet_descriptor);
+	iov[0].iov_base = &desc;
+	iov[0].iov_len = sizeof(hv_vm_packet_descriptor);
 
-	buffer_list[1].data = buffer;
-	buffer_list[1].length = buffer_len;
+	iov[1].iov_base = buffer;
+	iov[1].iov_len = buffer_len;
 
-	buffer_list[2].data = &aligned_data;
-	buffer_list[2].length = packet_len_aligned - packet_len;
+	iov[2].iov_base = &aligned_data;
+	iov[2].iov_len = packet_len_aligned - packet_len;
 
-	ret = hv_ring_buffer_write(&channel->outbound, buffer_list, 3,
-	    &need_sig);
+	ret = hv_ring_buffer_write(&channel->outbound, iov, 3, &need_sig);
 
 	/* TODO: We should determine if this is optional */
 	if (ret == 0 && need_sig)
@@ -668,7 +667,7 @@ hv_vmbus_channel_send_packet_pagebuffer(
 	uint32_t				packet_len;
 	uint32_t				page_buflen;
 	uint32_t				packetLen_aligned;
-	hv_vmbus_sg_buffer_list			buffer_list[4];
+	struct iovec				iov[4];
 	hv_vmbus_channel_packet_page_buffer	desc;
 	uint32_t				descSize;
 	uint64_t				alignedData = 0;
@@ -694,20 +693,19 @@ hv_vmbus_channel_send_packet_pagebuffer(
 	desc.transaction_id = request_id;
 	desc.range_count = page_count;
 
-	buffer_list[0].data = &desc;
-	buffer_list[0].length = descSize;
+	iov[0].iov_base = &desc;
+	iov[0].iov_len = descSize;
 
-	buffer_list[1].data = page_buffers;
-	buffer_list[1].length = page_buflen;
+	iov[1].iov_base = page_buffers;
+	iov[1].iov_len = page_buflen;
 
-	buffer_list[2].data = buffer;
-	buffer_list[2].length = buffer_len;
+	iov[2].iov_base = buffer;
+	iov[2].iov_len = buffer_len;
 
-	buffer_list[3].data = &alignedData;
-	buffer_list[3].length = packetLen_aligned - packet_len;
+	iov[3].iov_base = &alignedData;
+	iov[3].iov_len = packetLen_aligned - packet_len;
 
-	ret = hv_ring_buffer_write(&channel->outbound, buffer_list, 4,
-	    &need_sig);
+	ret = hv_ring_buffer_write(&channel->outbound, iov, 4, &need_sig);
 
 	/* TODO: We should determine if this is optional */
 	if (ret == 0 && need_sig)
@@ -735,7 +733,7 @@ hv_vmbus_channel_send_packet_multipagebu
 	uint32_t		packet_len_aligned;
 	uint32_t		pfn_count;
 	uint64_t		aligned_data = 0;
-	hv_vmbus_sg_buffer_list	buffer_list[3];
+	struct iovec		iov[3];
 	hv_vmbus_channel_packet_multipage_buffer desc;
 
 	pfn_count =
@@ -772,17 +770,16 @@ hv_vmbus_channel_send_packet_multipagebu
 	memcpy(desc.range.pfn_array, multi_page_buffer->pfn_array,
 		pfn_count * sizeof(uint64_t));
 
-	buffer_list[0].data = &desc;
-	buffer_list[0].length = desc_size;
+	iov[0].iov_base = &desc;
+	iov[0].iov_len = desc_size;
 
-	buffer_list[1].data = buffer;
-	buffer_list[1].length = buffer_len;
+	iov[1].iov_base = buffer;
+	iov[1].iov_len = buffer_len;
 
-	buffer_list[2].data = &aligned_data;
-	buffer_list[2].length = packet_len_aligned - packet_len;
+	iov[2].iov_base = &aligned_data;
+	iov[2].iov_len = packet_len_aligned - packet_len;
 
-	ret = hv_ring_buffer_write(&channel->outbound, buffer_list, 3,
-	    &need_sig);
+	ret = hv_ring_buffer_write(&channel->outbound, iov, 3, &need_sig);
 
 	/* TODO: We should determine if this is optional */
 	if (ret == 0 && need_sig)

Modified: head/sys/dev/hyperv/vmbus/hv_ring_buffer.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_ring_buffer.c	Fri Jul 15 05:15:21 2016	(r302869)
+++ head/sys/dev/hyperv/vmbus/hv_ring_buffer.c	Fri Jul 15 05:29:04 2016	(r302870)
@@ -252,7 +252,7 @@ hv_ring_buffer_needsig_on_write(
 static uint32_t	copy_to_ring_buffer(
 			hv_vmbus_ring_buffer_info*	ring_info,
 			uint32_t			start_write_offset,
-			char*				src,
+			const uint8_t			*src,
 			uint32_t			src_len);
 
 static uint32_t copy_from_ring_buffer(
@@ -297,8 +297,8 @@ void hv_ring_buffer_cleanup(hv_vmbus_rin
 int
 hv_ring_buffer_write(
 	hv_vmbus_ring_buffer_info*	out_ring_info,
-	hv_vmbus_sg_buffer_list		sg_buffers[],
-	uint32_t			sg_buffer_count,
+	const struct iovec		iov[],
+	uint32_t			iovlen,
 	boolean_t			*need_sig)
 {
 	int i = 0;
@@ -310,8 +310,8 @@ hv_ring_buffer_write(
 	volatile uint32_t next_write_location;
 	uint64_t prev_indices = 0;
 
-	for (i = 0; i < sg_buffer_count; i++) {
-	    total_bytes_to_write += sg_buffers[i].length;
+	for (i = 0; i < iovlen; i++) {
+	    total_bytes_to_write += iov[i].iov_len;
 	}
 
 	total_bytes_to_write += sizeof(uint64_t);
@@ -340,10 +340,9 @@ hv_ring_buffer_write(
 
 	old_write_location = next_write_location;
 
-	for (i = 0; i < sg_buffer_count; i++) {
+	for (i = 0; i < iovlen; i++) {
 	    next_write_location = copy_to_ring_buffer(out_ring_info,
-		next_write_location, (char *) sg_buffers[i].data,
-		sg_buffers[i].length);
+		next_write_location, iov[i].iov_base, iov[i].iov_len);
 	}
 
 	/*
@@ -482,11 +481,11 @@ hv_ring_buffer_read(
  *
  * Assume there is enough room. Handles wrap-around in dest case only!
  */
-uint32_t
+static uint32_t
 copy_to_ring_buffer(
 	hv_vmbus_ring_buffer_info*	ring_info,
 	uint32_t 			start_write_offset,
-	char*				src,
+	const uint8_t			*src,
 	uint32_t			src_len)
 {
 	char *ring_buffer = get_ring_buffer(ring_info);

Modified: head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h	Fri Jul 15 05:15:21 2016	(r302869)
+++ head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h	Fri Jul 15 05:29:04 2016	(r302870)
@@ -35,16 +35,12 @@
 #include <sys/lock.h>
 #include <sys/mutex.h>
 #include <sys/sema.h>
+#include <sys/_iovec.h>
 
 #include <dev/hyperv/include/hyperv.h>
 
 struct vmbus_softc;
 
-typedef struct {
-	void*		data;
-	uint32_t	length;
-} hv_vmbus_sg_buffer_list;
-
 /*
  * The format must be the same as hv_vm_data_gpa_direct
  */
@@ -95,8 +91,8 @@ void			hv_ring_buffer_cleanup(
 
 int			hv_ring_buffer_write(
 				hv_vmbus_ring_buffer_info	*ring_info,
-				hv_vmbus_sg_buffer_list		sg_buffers[],
-				uint32_t			sg_buff_count,
+				const struct iovec		iov[],
+				uint32_t			iovlen,
 				boolean_t			*need_sig);
 
 int			hv_ring_buffer_peek(



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