svn commit: r302887 - in head/sys/dev/hyperv: include netvsc vmbus
Sepherosa Ziehau
sephe at FreeBSD.org
Fri Jul 15 08:06:50 UTC 2016
Author: sephe
Date: Fri Jul 15 08:06:48 2016
New Revision: 302887
URL: https://svnweb.freebsd.org/changeset/base/302887
Log:
hyperv/hn: Busdma-fy rxbuf and chimney sending buffer
Nuke unused channel GPADL API.
MFC after: 1 week
Sponsored by: Microsoft OSTC
Differential Revision: https://reviews.freebsd.org/D7211
Modified:
head/sys/dev/hyperv/include/hyperv.h
head/sys/dev/hyperv/netvsc/hv_net_vsc.c
head/sys/dev/hyperv/netvsc/hv_net_vsc.h
head/sys/dev/hyperv/vmbus/hv_channel.c
Modified: head/sys/dev/hyperv/include/hyperv.h
==============================================================================
--- head/sys/dev/hyperv/include/hyperv.h Fri Jul 15 07:53:45 2016 (r302886)
+++ head/sys/dev/hyperv/include/hyperv.h Fri Jul 15 08:06:48 2016 (r302887)
@@ -287,14 +287,6 @@ int hv_vmbus_channel_open(
void hv_vmbus_channel_close(hv_vmbus_channel *channel);
-int hv_vmbus_channel_establish_gpadl(
- hv_vmbus_channel* channel,
- /* must be phys and virt contiguous */
- void* contig_buffer,
- /* page-size multiple */
- uint32_t size,
- uint32_t* gpadl_handle);
-
int hv_vmbus_channel_teardown_gpdal(
hv_vmbus_channel* channel,
uint32_t gpadl_handle);
Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.c
==============================================================================
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.c Fri Jul 15 07:53:45 2016 (r302886)
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.c Fri Jul 15 08:06:48 2016 (r302887)
@@ -152,19 +152,27 @@ hv_nv_init_rx_buffer_with_net_vsp(struct
return (ENODEV);
}
- net_dev->rx_buf = contigmalloc(net_dev->rx_buf_size, M_NETVSC,
- M_ZERO, 0UL, BUS_SPACE_MAXADDR, PAGE_SIZE, 0);
+ net_dev->rx_buf = hyperv_dmamem_alloc(bus_get_dma_tag(sc->hn_dev),
+ PAGE_SIZE, 0, net_dev->rx_buf_size, &net_dev->rxbuf_dma,
+ BUS_DMA_WAITOK | BUS_DMA_ZERO);
+ if (net_dev->rx_buf == NULL) {
+ device_printf(sc->hn_dev, "allocate rxbuf failed\n");
+ return ENOMEM;
+ }
/*
- * Establish the GPADL handle for this buffer on this channel.
- * Note: This call uses the vmbus connection rather than the
- * channel to establish the gpadl handle.
- * GPADL: Guest physical address descriptor list.
- */
- ret = hv_vmbus_channel_establish_gpadl(
- sc->hn_prichan, net_dev->rx_buf,
- net_dev->rx_buf_size, &net_dev->rx_buf_gpadl_handle);
+ * Connect the RXBUF GPADL to the primary channel.
+ *
+ * NOTE:
+ * Only primary channel has RXBUF connected to it. Sub-channels
+ * just share this RXBUF.
+ */
+ ret = vmbus_chan_gpadl_connect(sc->hn_prichan,
+ net_dev->rxbuf_dma.hv_paddr, net_dev->rx_buf_size,
+ &net_dev->rx_buf_gpadl_handle);
if (ret != 0) {
+ device_printf(sc->hn_dev, "rxbuf gpadl connect failed: %d\n",
+ ret);
goto cleanup;
}
@@ -243,22 +251,27 @@ hv_nv_init_send_buffer_with_net_vsp(stru
return (ENODEV);
}
- net_dev->send_buf = contigmalloc(net_dev->send_buf_size, M_NETVSC,
- M_ZERO, 0UL, BUS_SPACE_MAXADDR, PAGE_SIZE, 0);
+ net_dev->send_buf = hyperv_dmamem_alloc(bus_get_dma_tag(sc->hn_dev),
+ PAGE_SIZE, 0, net_dev->send_buf_size, &net_dev->txbuf_dma,
+ BUS_DMA_WAITOK | BUS_DMA_ZERO);
if (net_dev->send_buf == NULL) {
- ret = ENOMEM;
- goto cleanup;
+ device_printf(sc->hn_dev, "allocate chimney txbuf failed\n");
+ return ENOMEM;
}
/*
- * Establish the gpadl handle for this buffer on this channel.
- * Note: This call uses the vmbus connection rather than the
- * channel to establish the gpadl handle.
+ * Connect chimney sending buffer GPADL to the primary channel.
+ *
+ * NOTE:
+ * Only primary channel has chimney sending buffer connected to it.
+ * Sub-channels just share this chimney sending buffer.
*/
- ret = hv_vmbus_channel_establish_gpadl(sc->hn_prichan,
- net_dev->send_buf, net_dev->send_buf_size,
+ ret = vmbus_chan_gpadl_connect(sc->hn_prichan,
+ net_dev->txbuf_dma.hv_paddr, net_dev->send_buf_size,
&net_dev->send_buf_gpadl_handle);
if (ret != 0) {
+ device_printf(sc->hn_dev, "chimney sending buffer gpadl "
+ "connect failed: %d\n", ret);
goto cleanup;
}
@@ -364,7 +377,7 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_
if (net_dev->rx_buf) {
/* Free up the receive buffer */
- contigfree(net_dev->rx_buf, net_dev->rx_buf_size, M_NETVSC);
+ hyperv_dmamem_free(&net_dev->rxbuf_dma, net_dev->rx_buf);
net_dev->rx_buf = NULL;
}
@@ -432,7 +445,7 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne
if (net_dev->send_buf) {
/* Free up the receive buffer */
- contigfree(net_dev->send_buf, net_dev->send_buf_size, M_NETVSC);
+ hyperv_dmamem_free(&net_dev->txbuf_dma, net_dev->send_buf);
net_dev->send_buf = NULL;
}
Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.h
==============================================================================
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.h Fri Jul 15 07:53:45 2016 (r302886)
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.h Fri Jul 15 08:06:48 2016 (r302887)
@@ -57,6 +57,7 @@
#include <net/if_media.h>
#include <dev/hyperv/include/hyperv.h>
+#include <dev/hyperv/include/hyperv_busdma.h>
#include <dev/hyperv/include/vmbus.h>
#define HN_USE_TXDESC_BUFRING
@@ -1075,6 +1076,8 @@ typedef struct netvsc_dev_ {
uint32_t num_channel;
+ struct hyperv_dma rxbuf_dma;
+ struct hyperv_dma txbuf_dma;
uint32_t vrss_send_table[VRSS_SEND_TABLE_SIZE];
} netvsc_dev;
Modified: head/sys/dev/hyperv/vmbus/hv_channel.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_channel.c Fri Jul 15 07:53:45 2016 (r302886)
+++ head/sys/dev/hyperv/vmbus/hv_channel.c Fri Jul 15 08:06:48 2016 (r302887)
@@ -337,17 +337,6 @@ failed:
return ret;
}
-/**
- * @brief Establish a GPADL for the specified buffer
- */
-int
-hv_vmbus_channel_establish_gpadl(struct hv_vmbus_channel *channel,
- void *contig_buffer, uint32_t size, uint32_t *gpadl)
-{
- return vmbus_chan_gpadl_connect(channel,
- hv_get_phys_addr(contig_buffer), size, gpadl);
-}
-
int
vmbus_chan_gpadl_connect(struct hv_vmbus_channel *chan, bus_addr_t paddr,
int size, uint32_t *gpadl0)
More information about the svn-src-all
mailing list