svn commit: r307458 - in stable/11/sys/dev/hyperv: include netvsc vmbus
Sepherosa Ziehau
sephe at FreeBSD.org
Mon Oct 17 02:38:45 UTC 2016
Author: sephe
Date: Mon Oct 17 02:38:44 2016
New Revision: 307458
URL: https://svnweb.freebsd.org/changeset/base/307458
Log:
MFC 302887
hyperv/hn: Busdma-fy rxbuf and chimney sending buffer
Nuke unused channel GPADL API.
Sponsored by: Microsoft OSTC
Differential Revision: https://reviews.freebsd.org/D7211
Modified:
stable/11/sys/dev/hyperv/include/hyperv.h
stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c
stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h
stable/11/sys/dev/hyperv/vmbus/hv_channel.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/dev/hyperv/include/hyperv.h
==============================================================================
--- stable/11/sys/dev/hyperv/include/hyperv.h Mon Oct 17 02:36:49 2016 (r307457)
+++ stable/11/sys/dev/hyperv/include/hyperv.h Mon Oct 17 02:38:44 2016 (r307458)
@@ -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: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c
==============================================================================
--- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 02:36:49 2016 (r307457)
+++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Mon Oct 17 02:38:44 2016 (r307458)
@@ -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: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h
==============================================================================
--- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 02:36:49 2016 (r307457)
+++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 17 02:38:44 2016 (r307458)
@@ -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: stable/11/sys/dev/hyperv/vmbus/hv_channel.c
==============================================================================
--- stable/11/sys/dev/hyperv/vmbus/hv_channel.c Mon Oct 17 02:36:49 2016 (r307457)
+++ stable/11/sys/dev/hyperv/vmbus/hv_channel.c Mon Oct 17 02:38:44 2016 (r307458)
@@ -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-stable
mailing list