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
This commit is contained in:
Sepherosa Ziehau 2016-07-15 08:06:48 +00:00
parent 43bbe6b27f
commit 8c209c9206
4 changed files with 36 additions and 39 deletions

View File

@ -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);

View File

@ -152,19 +152,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;
}
@ -243,22 +251,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;
}
@ -364,7 +377,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;
}
@ -432,7 +445,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;
}

View File

@ -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;

View File

@ -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)