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:
parent
6d3cd9ab4a
commit
e7d187d843
@ -287,22 +287,8 @@ int hv_vmbus_channel_open(
|
||||
|
||||
void hv_vmbus_channel_close(hv_vmbus_channel *channel);
|
||||
|
||||
int hv_vmbus_channel_teardown_gpdal(
|
||||
hv_vmbus_channel* channel,
|
||||
uint32_t gpadl_handle);
|
||||
|
||||
int vmbus_chan_gpadl_connect(struct hv_vmbus_channel *chan,
|
||||
bus_addr_t paddr, int size, uint32_t *gpadl);
|
||||
|
||||
struct hv_vmbus_channel* vmbus_select_outgoing_channel(struct hv_vmbus_channel *promary);
|
||||
|
||||
void vmbus_channel_cpu_set(struct hv_vmbus_channel *chan, int cpu);
|
||||
void vmbus_channel_cpu_rr(struct hv_vmbus_channel *chan);
|
||||
struct hv_vmbus_channel **
|
||||
vmbus_get_subchan(struct hv_vmbus_channel *pri_chan, int subchan_cnt);
|
||||
void vmbus_rel_subchan(struct hv_vmbus_channel **subchan, int subchan_cnt);
|
||||
void vmbus_drain_subchan(struct hv_vmbus_channel *pri_chan);
|
||||
|
||||
/**
|
||||
* @brief Get physical address from virtual
|
||||
*/
|
||||
|
@ -89,6 +89,20 @@ struct vmbus_chanpkt_rxbuf {
|
||||
|
||||
struct hv_vmbus_channel;
|
||||
|
||||
int vmbus_chan_gpadl_connect(struct hv_vmbus_channel *chan,
|
||||
bus_addr_t paddr, int size, uint32_t *gpadl);
|
||||
int vmbus_chan_gpadl_disconnect(struct hv_vmbus_channel *chan,
|
||||
uint32_t gpadl);
|
||||
|
||||
void vmbus_chan_cpu_set(struct hv_vmbus_channel *chan, int cpu);
|
||||
void vmbus_chan_cpu_rr(struct hv_vmbus_channel *chan);
|
||||
|
||||
struct hv_vmbus_channel **
|
||||
vmbus_subchan_get(struct hv_vmbus_channel *pri_chan, int subchan_cnt);
|
||||
void vmbus_subchan_rel(struct hv_vmbus_channel **subchan, int subchan_cnt);
|
||||
void vmbus_subchan_drain(struct hv_vmbus_channel *pri_chan);
|
||||
|
||||
|
||||
int vmbus_chan_recv(struct hv_vmbus_channel *chan, void *data, int *dlen,
|
||||
uint64_t *xactid);
|
||||
int vmbus_chan_recv_pkt(struct hv_vmbus_channel *chan,
|
||||
|
@ -363,7 +363,7 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_dev)
|
||||
|
||||
/* Tear down the gpadl on the vsp end */
|
||||
if (net_dev->rx_buf_gpadl_handle) {
|
||||
ret = hv_vmbus_channel_teardown_gpdal(net_dev->sc->hn_prichan,
|
||||
ret = vmbus_chan_gpadl_disconnect(net_dev->sc->hn_prichan,
|
||||
net_dev->rx_buf_gpadl_handle);
|
||||
/*
|
||||
* If we failed here, we might as well return and have a leak
|
||||
@ -430,7 +430,7 @@ hv_nv_destroy_send_buffer(netvsc_dev *net_dev)
|
||||
|
||||
/* Tear down the gpadl on the vsp end */
|
||||
if (net_dev->send_buf_gpadl_handle) {
|
||||
ret = hv_vmbus_channel_teardown_gpdal(net_dev->sc->hn_prichan,
|
||||
ret = vmbus_chan_gpadl_disconnect(net_dev->sc->hn_prichan,
|
||||
net_dev->send_buf_gpadl_handle);
|
||||
|
||||
/*
|
||||
|
@ -1586,7 +1586,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
}
|
||||
|
||||
/* Wait for subchannels to be destroyed */
|
||||
vmbus_drain_subchan(sc->hn_prichan);
|
||||
vmbus_subchan_drain(sc->hn_prichan);
|
||||
|
||||
error = hv_rf_on_device_add(sc, &device_info,
|
||||
sc->hn_rx_ring_inuse);
|
||||
@ -2950,7 +2950,7 @@ hn_channel_attach(struct hn_softc *sc, struct hv_vmbus_channel *chan)
|
||||
}
|
||||
|
||||
/* Bind channel to a proper CPU */
|
||||
vmbus_channel_cpu_set(chan, (sc->hn_cpu + idx) % mp_ncpus);
|
||||
vmbus_chan_cpu_set(chan, (sc->hn_cpu + idx) % mp_ncpus);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2973,7 +2973,7 @@ hn_subchan_setup(struct hn_softc *sc)
|
||||
int i;
|
||||
|
||||
/* Wait for sub-channels setup to complete. */
|
||||
subchan = vmbus_get_subchan(sc->hn_prichan, subchan_cnt);
|
||||
subchan = vmbus_subchan_get(sc->hn_prichan, subchan_cnt);
|
||||
|
||||
/* Attach the sub-channels. */
|
||||
for (i = 0; i < subchan_cnt; ++i) {
|
||||
@ -2983,7 +2983,7 @@ hn_subchan_setup(struct hn_softc *sc)
|
||||
}
|
||||
|
||||
/* Release the sub-channels */
|
||||
vmbus_rel_subchan(subchan, subchan_cnt);
|
||||
vmbus_subchan_rel(subchan, subchan_cnt);
|
||||
if_printf(sc->hn_ifp, "%d sub-channels setup done\n", subchan_cnt);
|
||||
}
|
||||
|
||||
|
@ -315,7 +315,7 @@ storvsc_subchan_attach(struct storvsc_softc *sc,
|
||||
memset(&props, 0, sizeof(props));
|
||||
|
||||
new_channel->hv_chan_priv1 = sc;
|
||||
vmbus_channel_cpu_rr(new_channel);
|
||||
vmbus_chan_cpu_rr(new_channel);
|
||||
ret = hv_vmbus_channel_open(new_channel,
|
||||
sc->hs_drv_props->drv_ringbuffer_size,
|
||||
sc->hs_drv_props->drv_ringbuffer_size,
|
||||
@ -377,14 +377,14 @@ storvsc_send_multichannel_request(struct storvsc_softc *sc, int max_chans)
|
||||
}
|
||||
|
||||
/* Wait for sub-channels setup to complete. */
|
||||
subchan = vmbus_get_subchan(sc->hs_chan, request_channels_cnt);
|
||||
subchan = vmbus_subchan_get(sc->hs_chan, request_channels_cnt);
|
||||
|
||||
/* Attach the sub-channels. */
|
||||
for (i = 0; i < request_channels_cnt; ++i)
|
||||
storvsc_subchan_attach(sc, subchan[i]);
|
||||
|
||||
/* Release the sub-channels. */
|
||||
vmbus_rel_subchan(subchan, request_channels_cnt);
|
||||
vmbus_subchan_rel(subchan, request_channels_cnt);
|
||||
|
||||
if (bootverbose)
|
||||
printf("Storvsc create multi-channel success!\n");
|
||||
@ -574,7 +574,7 @@ hv_storvsc_connect_vsp(struct storvsc_softc *sc)
|
||||
* Open the channel
|
||||
*/
|
||||
KASSERT(sc->hs_chan->hv_chan_priv1 == sc, ("invalid chan priv1"));
|
||||
vmbus_channel_cpu_rr(sc->hs_chan);
|
||||
vmbus_chan_cpu_rr(sc->hs_chan);
|
||||
ret = hv_vmbus_channel_open(
|
||||
sc->hs_chan,
|
||||
sc->hs_drv_props->drv_ringbuffer_size,
|
||||
|
@ -324,7 +324,7 @@ hv_vmbus_channel_open(
|
||||
|
||||
failed:
|
||||
if (new_channel->ch_bufring_gpadl) {
|
||||
hv_vmbus_channel_teardown_gpdal(new_channel,
|
||||
vmbus_chan_gpadl_disconnect(new_channel,
|
||||
new_channel->ch_bufring_gpadl);
|
||||
new_channel->ch_bufring_gpadl = 0;
|
||||
}
|
||||
@ -468,7 +468,7 @@ vmbus_chan_gpadl_connect(struct hv_vmbus_channel *chan, bus_addr_t paddr,
|
||||
* Disconnect the GPA from the target channel
|
||||
*/
|
||||
int
|
||||
hv_vmbus_channel_teardown_gpdal(struct hv_vmbus_channel *chan, uint32_t gpadl)
|
||||
vmbus_chan_gpadl_disconnect(struct hv_vmbus_channel *chan, uint32_t gpadl)
|
||||
{
|
||||
struct vmbus_softc *sc = chan->vmbus_sc;
|
||||
struct vmbus_msghc *mh;
|
||||
@ -556,8 +556,7 @@ hv_vmbus_channel_close_internal(hv_vmbus_channel *channel)
|
||||
|
||||
/* Tear down the gpadl for the channel's ring buffer */
|
||||
if (channel->ch_bufring_gpadl) {
|
||||
hv_vmbus_channel_teardown_gpdal(channel,
|
||||
channel->ch_bufring_gpadl);
|
||||
vmbus_chan_gpadl_disconnect(channel, channel->ch_bufring_gpadl);
|
||||
channel->ch_bufring_gpadl = 0;
|
||||
}
|
||||
|
||||
@ -600,10 +599,10 @@ hv_vmbus_channel_close(struct hv_vmbus_channel *chan)
|
||||
struct hv_vmbus_channel **subchan;
|
||||
int i;
|
||||
|
||||
subchan = vmbus_get_subchan(chan, subchan_cnt);
|
||||
subchan = vmbus_subchan_get(chan, subchan_cnt);
|
||||
for (i = 0; i < subchan_cnt; ++i)
|
||||
hv_vmbus_channel_close_internal(subchan[i]);
|
||||
vmbus_rel_subchan(subchan, subchan_cnt);
|
||||
vmbus_subchan_rel(subchan, subchan_cnt);
|
||||
}
|
||||
|
||||
/* Then close the primary channel. */
|
||||
@ -1038,7 +1037,7 @@ vmbus_chan_add(struct hv_vmbus_channel *newchan)
|
||||
}
|
||||
|
||||
void
|
||||
vmbus_channel_cpu_set(struct hv_vmbus_channel *chan, int cpu)
|
||||
vmbus_chan_cpu_set(struct hv_vmbus_channel *chan, int cpu)
|
||||
{
|
||||
KASSERT(cpu >= 0 && cpu < mp_ncpus, ("invalid cpu %d", cpu));
|
||||
|
||||
@ -1058,13 +1057,13 @@ vmbus_channel_cpu_set(struct hv_vmbus_channel *chan, int cpu)
|
||||
}
|
||||
|
||||
void
|
||||
vmbus_channel_cpu_rr(struct hv_vmbus_channel *chan)
|
||||
vmbus_chan_cpu_rr(struct hv_vmbus_channel *chan)
|
||||
{
|
||||
static uint32_t vmbus_chan_nextcpu;
|
||||
int cpu;
|
||||
|
||||
cpu = atomic_fetchadd_int(&vmbus_chan_nextcpu, 1) % mp_ncpus;
|
||||
vmbus_channel_cpu_set(chan, cpu);
|
||||
vmbus_chan_cpu_set(chan, cpu);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1073,9 +1072,9 @@ vmbus_chan_cpu_default(struct hv_vmbus_channel *chan)
|
||||
/*
|
||||
* By default, pin the channel to cpu0. Devices having
|
||||
* special channel-cpu mapping requirement should call
|
||||
* vmbus_channel_cpu_{set,rr}().
|
||||
* vmbus_chan_cpu_{set,rr}().
|
||||
*/
|
||||
vmbus_channel_cpu_set(chan, 0);
|
||||
vmbus_chan_cpu_set(chan, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1309,7 +1308,7 @@ vmbus_select_outgoing_channel(struct hv_vmbus_channel *primary)
|
||||
}
|
||||
|
||||
struct hv_vmbus_channel **
|
||||
vmbus_get_subchan(struct hv_vmbus_channel *pri_chan, int subchan_cnt)
|
||||
vmbus_subchan_get(struct hv_vmbus_channel *pri_chan, int subchan_cnt)
|
||||
{
|
||||
struct hv_vmbus_channel **ret, *chan;
|
||||
int i;
|
||||
@ -1340,14 +1339,14 @@ vmbus_get_subchan(struct hv_vmbus_channel *pri_chan, int subchan_cnt)
|
||||
}
|
||||
|
||||
void
|
||||
vmbus_rel_subchan(struct hv_vmbus_channel **subchan, int subchan_cnt __unused)
|
||||
vmbus_subchan_rel(struct hv_vmbus_channel **subchan, int subchan_cnt __unused)
|
||||
{
|
||||
|
||||
free(subchan, M_TEMP);
|
||||
}
|
||||
|
||||
void
|
||||
vmbus_drain_subchan(struct hv_vmbus_channel *pri_chan)
|
||||
vmbus_subchan_drain(struct hv_vmbus_channel *pri_chan)
|
||||
{
|
||||
mtx_lock(&pri_chan->ch_subchan_lock);
|
||||
while (pri_chan->ch_subchan_cnt > 0)
|
||||
|
Loading…
Reference in New Issue
Block a user