aboutsummaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorSepherosa Ziehau <sephe@FreeBSD.org>2016-07-12 07:33:39 +0000
committerSepherosa Ziehau <sephe@FreeBSD.org>2016-07-12 07:33:39 +0000
commit38d19df6ff3135367223b2e513ef46b99bacf543 (patch)
treea7d930126d009d04dc4f5c97d8bbde2bd9036013 /sys/dev
parentcbf4af1f7e7f1d712a4210732e670c39c59eb75c (diff)
Notes
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/hyperv/include/hyperv.h12
-rw-r--r--sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c30
-rw-r--r--sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c8
-rw-r--r--sys/dev/hyperv/vmbus/hv_channel_mgmt.c6
-rw-r--r--sys/dev/hyperv/vmbus/hv_connection.c2
-rw-r--r--sys/dev/hyperv/vmbus/vmbus.c37
-rw-r--r--sys/dev/hyperv/vmbus/vmbus_if.m37
-rw-r--r--sys/dev/hyperv/vmbus/vmbus_var.h6
8 files changed, 104 insertions, 34 deletions
diff --git a/sys/dev/hyperv/include/hyperv.h b/sys/dev/hyperv/include/hyperv.h
index 7081018e67aa..87f93a9cd50b 100644
--- a/sys/dev/hyperv/include/hyperv.h
+++ b/sys/dev/hyperv/include/hyperv.h
@@ -73,10 +73,13 @@ typedef uint8_t hv_bool_uint8_t;
* 2.4 -- Windows 8
* 3.0 -- Windows 8.1
*/
-#define HV_VMBUS_VERSION_WS2008 ((0 << 16) | (13))
-#define HV_VMBUS_VERSION_WIN7 ((1 << 16) | (1))
-#define HV_VMBUS_VERSION_WIN8 ((2 << 16) | (4))
-#define HV_VMBUS_VERSION_WIN8_1 ((3 << 16) | (0))
+#define VMBUS_VERSION_WS2008 ((0 << 16) | (13))
+#define VMBUS_VERSION_WIN7 ((1 << 16) | (1))
+#define VMBUS_VERSION_WIN8 ((2 << 16) | (4))
+#define VMBUS_VERSION_WIN8_1 ((3 << 16) | (0))
+
+#define VMBUS_VERSION_MAJOR(ver) (((uint32_t)(ver)) >> 16)
+#define VMBUS_VERSION_MINOR(ver) (((uint32_t)(ver)) & 0xffff)
/*
* Make maximum size of pipe payload of 16K
@@ -723,5 +726,4 @@ hv_get_phys_addr(void *virt)
return (ret);
}
-extern uint32_t hv_vmbus_protocal_version;
#endif /* __HYPERV_H__ */
diff --git a/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c b/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
index 5afb7510bfe3..7bec32eeed6b 100644
--- a/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
+++ b/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
@@ -114,9 +114,11 @@ __FBSDID("$FreeBSD$");
#include <dev/hyperv/include/hyperv.h>
#include <dev/hyperv/include/hyperv_busdma.h>
+
#include "hv_net_vsc.h"
#include "hv_rndis.h"
#include "hv_rndis_filter.h"
+#include "vmbus_if.h"
#define hv_chan_rxr hv_chan_priv1
#define hv_chan_txr hv_chan_priv2
@@ -2369,8 +2371,10 @@ static int
hn_create_tx_ring(struct hn_softc *sc, int id)
{
struct hn_tx_ring *txr = &sc->hn_tx_ring[id];
+ device_t dev = sc->hn_dev;
bus_dma_tag_t parent_dtag;
int error, i;
+ uint32_t version;
txr->hn_sc = sc;
txr->hn_tx_idx = id;
@@ -2409,10 +2413,18 @@ hn_create_tx_ring(struct hn_softc *sc, int id)
}
txr->hn_direct_tx_size = hn_direct_tx_size;
- if (hv_vmbus_protocal_version >= HV_VMBUS_VERSION_WIN8_1)
+ version = VMBUS_GET_VERSION(device_get_parent(dev), dev);
+ if (version >= VMBUS_VERSION_WIN8_1) {
txr->hn_csum_assist = HN_CSUM_ASSIST;
- else
+ } else {
txr->hn_csum_assist = HN_CSUM_ASSIST_WIN8;
+ if (id == 0) {
+ device_printf(dev, "bus version %u.%u, "
+ "no UDP checksum offloading\n",
+ VMBUS_VERSION_MAJOR(version),
+ VMBUS_VERSION_MINOR(version));
+ }
+ }
/*
* Always schedule transmission instead of trying to do direct
@@ -2420,7 +2432,7 @@ hn_create_tx_ring(struct hn_softc *sc, int id)
*/
txr->hn_sched_tx = 1;
- parent_dtag = bus_get_dma_tag(sc->hn_dev);
+ parent_dtag = bus_get_dma_tag(dev);
/* DMA tag for RNDIS messages. */
error = bus_dma_tag_create(parent_dtag, /* parent */
@@ -2437,7 +2449,7 @@ hn_create_tx_ring(struct hn_softc *sc, int id)
NULL, /* lockfuncarg */
&txr->hn_tx_rndis_dtag);
if (error) {
- device_printf(sc->hn_dev, "failed to create rndis dmatag\n");
+ device_printf(dev, "failed to create rndis dmatag\n");
return error;
}
@@ -2456,7 +2468,7 @@ hn_create_tx_ring(struct hn_softc *sc, int id)
NULL, /* lockfuncarg */
&txr->hn_tx_data_dtag);
if (error) {
- device_printf(sc->hn_dev, "failed to create data dmatag\n");
+ device_printf(dev, "failed to create data dmatag\n");
return error;
}
@@ -2473,7 +2485,7 @@ hn_create_tx_ring(struct hn_softc *sc, int id)
BUS_DMA_WAITOK | BUS_DMA_COHERENT,
&txd->rndis_msg_dmap);
if (error) {
- device_printf(sc->hn_dev,
+ device_printf(dev,
"failed to allocate rndis_msg, %d\n", i);
return error;
}
@@ -2484,7 +2496,7 @@ hn_create_tx_ring(struct hn_softc *sc, int id)
hyperv_dma_map_paddr, &txd->rndis_msg_paddr,
BUS_DMA_NOWAIT);
if (error) {
- device_printf(sc->hn_dev,
+ device_printf(dev,
"failed to load rndis_msg, %d\n", i);
bus_dmamem_free(txr->hn_tx_rndis_dtag,
txd->rndis_msg, txd->rndis_msg_dmap);
@@ -2495,7 +2507,7 @@ hn_create_tx_ring(struct hn_softc *sc, int id)
error = bus_dmamap_create(txr->hn_tx_data_dtag, 0,
&txd->data_dmap);
if (error) {
- device_printf(sc->hn_dev,
+ device_printf(dev,
"failed to allocate tx data dmamap\n");
bus_dmamap_unload(txr->hn_tx_rndis_dtag,
txd->rndis_msg_dmap);
@@ -2523,7 +2535,7 @@ hn_create_tx_ring(struct hn_softc *sc, int id)
* Create per TX ring sysctl tree:
* dev.hn.UNIT.tx.RINGID
*/
- ctx = device_get_sysctl_ctx(sc->hn_dev);
+ ctx = device_get_sysctl_ctx(dev);
child = SYSCTL_CHILDREN(sc->hn_tx_sysctl_tree);
snprintf(name, sizeof(name), "%d", id);
diff --git a/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c b/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
index 759c7117ab3b..fb1092462516 100644
--- a/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
+++ b/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
@@ -72,7 +72,9 @@ __FBSDID("$FreeBSD$");
#include <cam/scsi/scsi_message.h>
#include <dev/hyperv/include/hyperv.h>
+
#include "hv_vstorage.h"
+#include "vmbus_if.h"
#define STORVSC_RINGBUFFER_SIZE (20*PAGE_SIZE)
#define STORVSC_MAX_LUNS_PER_TARGET (64)
@@ -465,6 +467,7 @@ hv_storvsc_channel_init(struct hv_device *dev)
struct storvsc_softc *sc;
uint16_t max_chans = 0;
boolean_t support_multichannel = FALSE;
+ uint32_t version;
max_chans = 0;
support_multichannel = FALSE;
@@ -589,8 +592,9 @@ hv_storvsc_channel_init(struct hv_device *dev)
/* multi-channels feature is supported by WIN8 and above version */
max_chans = vstor_packet->u.chan_props.max_channel_cnt;
- if ((hv_vmbus_protocal_version != HV_VMBUS_VERSION_WIN7) &&
- (hv_vmbus_protocal_version != HV_VMBUS_VERSION_WS2008) &&
+ version = VMBUS_GET_VERSION(device_get_parent(dev->device),
+ dev->device);
+ if (version != VMBUS_VERSION_WIN7 && version != VMBUS_VERSION_WS2008 &&
(vstor_packet->u.chan_props.flags &
HV_STORAGE_SUPPORTS_MULTI_CHANNEL)) {
support_multichannel = TRUE;
diff --git a/sys/dev/hyperv/vmbus/hv_channel_mgmt.c b/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
index 9b0cfd1d3fce..b7d2ccfa610b 100644
--- a/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
+++ b/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
@@ -222,8 +222,8 @@ vmbus_channel_cpu_set(struct hv_vmbus_channel *chan, int cpu)
{
KASSERT(cpu >= 0 && cpu < mp_ncpus, ("invalid cpu %d", cpu));
- if (hv_vmbus_protocal_version == HV_VMBUS_VERSION_WS2008 ||
- hv_vmbus_protocal_version == HV_VMBUS_VERSION_WIN7) {
+ if (chan->vmbus_sc->vmbus_version == VMBUS_VERSION_WS2008 ||
+ chan->vmbus_sc->vmbus_version == VMBUS_VERSION_WIN7) {
/* Only cpu0 is supported */
cpu = 0;
}
@@ -305,7 +305,7 @@ vmbus_channel_on_offer_internal(struct vmbus_softc *sc,
}
new_channel->ch_sigevt->hc_connid = VMBUS_CONNID_EVENT;
- if (hv_vmbus_protocal_version != HV_VMBUS_VERSION_WS2008) {
+ if (sc->vmbus_version != VMBUS_VERSION_WS2008) {
new_channel->is_dedicated_interrupt =
(offer->is_dedicated_interrupt != 0);
new_channel->ch_sigevt->hc_connid = offer->connection_id;
diff --git a/sys/dev/hyperv/vmbus/hv_connection.c b/sys/dev/hyperv/vmbus/hv_connection.c
index 580d801930f8..c909ef46f8ad 100644
--- a/sys/dev/hyperv/vmbus/hv_connection.c
+++ b/sys/dev/hyperv/vmbus/hv_connection.c
@@ -50,8 +50,6 @@ hv_vmbus_connection hv_vmbus_g_connection =
{ .connect_state = HV_DISCONNECTED,
.next_gpadl_handle = 0xE1E10, };
-uint32_t hv_vmbus_protocal_version;
-
/**
* Send a connect request on the partition service connection
*/
diff --git a/sys/dev/hyperv/vmbus/vmbus.c b/sys/dev/hyperv/vmbus/vmbus.c
index 858f756804c6..582a187e6e20 100644
--- a/sys/dev/hyperv/vmbus/vmbus.c
+++ b/sys/dev/hyperv/vmbus/vmbus.c
@@ -68,6 +68,7 @@ __FBSDID("$FreeBSD$");
#include <contrib/dev/acpica/include/acpi.h>
#include "acpi_if.h"
+#include "vmbus_if.h"
struct vmbus_msghc {
struct hypercall_postmsg_in *mh_inprm;
@@ -113,10 +114,10 @@ struct vmbus_softc *vmbus_sc;
extern inthand_t IDTVEC(vmbus_isr);
static const uint32_t vmbus_version[] = {
- HV_VMBUS_VERSION_WIN8_1,
- HV_VMBUS_VERSION_WIN8,
- HV_VMBUS_VERSION_WIN7,
- HV_VMBUS_VERSION_WS2008
+ VMBUS_VERSION_WIN8_1,
+ VMBUS_VERSION_WIN8,
+ VMBUS_VERSION_WIN7,
+ VMBUS_VERSION_WS2008
};
static struct vmbus_msghc *
@@ -415,10 +416,10 @@ vmbus_init(struct vmbus_softc *sc)
error = vmbus_connect(sc, vmbus_version[i]);
if (!error) {
- hv_vmbus_protocal_version = vmbus_version[i];
+ sc->vmbus_version = vmbus_version[i];
device_printf(sc->vmbus_dev, "version %u.%u\n",
- (hv_vmbus_protocal_version >> 16),
- (hv_vmbus_protocal_version & 0xffff));
+ VMBUS_VERSION_MAJOR(sc->vmbus_version),
+ VMBUS_VERSION_MINOR(sc->vmbus_version));
return 0;
}
}
@@ -1064,14 +1065,23 @@ hv_vmbus_child_device_unregister(struct hv_device *child_dev)
static int
vmbus_sysctl_version(SYSCTL_HANDLER_ARGS)
{
+ struct vmbus_softc *sc = arg1;
char verstr[16];
snprintf(verstr, sizeof(verstr), "%u.%u",
- hv_vmbus_protocal_version >> 16,
- hv_vmbus_protocal_version & 0xffff);
+ VMBUS_VERSION_MAJOR(sc->vmbus_version),
+ VMBUS_VERSION_MINOR(sc->vmbus_version));
return sysctl_handle_string(oidp, verstr, sizeof(verstr), req);
}
+static uint32_t
+vmbus_get_version_method(device_t bus, device_t dev)
+{
+ struct vmbus_softc *sc = device_get_softc(bus);
+
+ return sc->vmbus_version;
+}
+
static int
vmbus_probe(device_t dev)
{
@@ -1155,8 +1165,8 @@ vmbus_doattach(struct vmbus_softc *sc)
if (ret != 0)
goto cleanup;
- if (hv_vmbus_protocal_version == HV_VMBUS_VERSION_WS2008 ||
- hv_vmbus_protocal_version == HV_VMBUS_VERSION_WIN7)
+ if (sc->vmbus_version == VMBUS_VERSION_WS2008 ||
+ sc->vmbus_version == VMBUS_VERSION_WIN7)
sc->vmbus_event_proc = vmbus_event_proc_compat;
else
sc->vmbus_event_proc = vmbus_event_proc;
@@ -1168,7 +1178,7 @@ vmbus_doattach(struct vmbus_softc *sc)
ctx = device_get_sysctl_ctx(sc->vmbus_dev);
child = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->vmbus_dev));
SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "version",
- CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0,
+ CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0,
vmbus_sysctl_version, "A", "vmbus version");
return (ret);
@@ -1281,6 +1291,9 @@ static device_method_t vmbus_methods[] = {
DEVMETHOD(bus_write_ivar, vmbus_write_ivar),
DEVMETHOD(bus_child_pnpinfo_str, vmbus_child_pnpinfo_str),
+ /* Vmbus interface */
+ DEVMETHOD(vmbus_get_version, vmbus_get_version_method),
+
DEVMETHOD_END
};
diff --git a/sys/dev/hyperv/vmbus/vmbus_if.m b/sys/dev/hyperv/vmbus/vmbus_if.m
new file mode 100644
index 000000000000..0782d00bbdfa
--- /dev/null
+++ b/sys/dev/hyperv/vmbus/vmbus_if.m
@@ -0,0 +1,37 @@
+#-
+# Copyright (c) 2016 Microsoft Corp.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice unmodified, this list of conditions, and the following
+# disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+
+#include <sys/param.h>
+#include <sys/bus.h>
+
+INTERFACE vmbus;
+
+METHOD uint32_t get_version {
+ device_t bus;
+ device_t dev;
+};
diff --git a/sys/dev/hyperv/vmbus/vmbus_var.h b/sys/dev/hyperv/vmbus/vmbus_var.h
index 82cfe7efbbf1..85436197f6ad 100644
--- a/sys/dev/hyperv/vmbus/vmbus_var.h
+++ b/sys/dev/hyperv/vmbus/vmbus_var.h
@@ -78,10 +78,14 @@ struct vmbus_softc {
struct vmbus_msghc_ctx *vmbus_msg_hc;
struct vmbus_pcpu_data vmbus_pcpu[MAXCPU];
- /* Rarely used fields */
+ /*
+ * Rarely used fields
+ */
+
device_t vmbus_dev;
int vmbus_idtvec;
uint32_t vmbus_flags; /* see VMBUS_FLAG_ */
+ uint32_t vmbus_version;
/* Shared memory for vmbus_{rx,tx}_evtflags */
void *vmbus_evtflags;