summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/dev/hyperv/include/hyperv.h8
-rw-r--r--sys/dev/hyperv/netvsc/hv_net_vsc.c53
-rw-r--r--sys/dev/hyperv/netvsc/hv_net_vsc.h3
-rw-r--r--sys/dev/hyperv/vmbus/hv_channel.c11
4 files changed, 36 insertions, 39 deletions
diff --git a/sys/dev/hyperv/include/hyperv.h b/sys/dev/hyperv/include/hyperv.h
index a987b09..7808e7b 100644
--- a/sys/dev/hyperv/include/hyperv.h
+++ b/sys/dev/hyperv/include/hyperv.h
@@ -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);
diff --git a/sys/dev/hyperv/netvsc/hv_net_vsc.c b/sys/dev/hyperv/netvsc/hv_net_vsc.c
index 81cb714..704a568 100644
--- a/sys/dev/hyperv/netvsc/hv_net_vsc.c
+++ b/sys/dev/hyperv/netvsc/hv_net_vsc.c
@@ -151,19 +151,27 @@ hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *sc)
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.
+ * Connect the RXBUF GPADL to the primary channel.
+ *
+ * NOTE:
+ * Only primary channel has RXBUF connected to it. Sub-channels
+ * just share this RXBUF.
*/
- ret = hv_vmbus_channel_establish_gpadl(
- sc->hn_prichan, net_dev->rx_buf,
- net_dev->rx_buf_size, &net_dev->rx_buf_gpadl_handle);
+ 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;
}
@@ -242,22 +250,27 @@ hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc)
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;
}
@@ -363,7 +376,7 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_dev)
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;
}
@@ -431,7 +444,7 @@ hv_nv_destroy_send_buffer(netvsc_dev *net_dev)
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;
}
diff --git a/sys/dev/hyperv/netvsc/hv_net_vsc.h b/sys/dev/hyperv/netvsc/hv_net_vsc.h
index 67ef86a..d00c186 100644
--- a/sys/dev/hyperv/netvsc/hv_net_vsc.h
+++ b/sys/dev/hyperv/netvsc/hv_net_vsc.h
@@ -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;
diff --git a/sys/dev/hyperv/vmbus/hv_channel.c b/sys/dev/hyperv/vmbus/hv_channel.c
index 8397f22..93fcf80 100644
--- a/sys/dev/hyperv/vmbus/hv_channel.c
+++ b/sys/dev/hyperv/vmbus/hv_channel.c
@@ -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)
OpenPOWER on IntegriCloud