summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorwh94709 <none@none>2006-04-19 16:08:32 -0700
committerwh94709 <none@none>2006-04-19 16:08:32 -0700
commit4ab777b1b0f310e59b52a57c79efa0571506942a (patch)
tree8d0f40f05b1ac9dedeba76bdd3e36493b59e03ac /usr/src
parente82f9ced0e2d2001a6e6c1c684f43a3faef8c7c7 (diff)
downloadillumos-joyent-4ab777b1b0f310e59b52a57c79efa0571506942a.tar.gz
6391344 Move virutal channels API versioning negotiation to the glvc driver
--HG-- rename : usr/src/uts/sun4v/io/glvc.c => usr/src/uts/sun4v/io/glvc/glvc.c
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/uts/sun4v/Makefile.files2
-rw-r--r--usr/src/uts/sun4v/Makefile.rules13
-rw-r--r--usr/src/uts/sun4v/io/glvc/glvc.c (renamed from usr/src/uts/sun4v/io/glvc.c)77
-rw-r--r--usr/src/uts/sun4v/io/glvc/glvc_hcall.s141
-rw-r--r--usr/src/uts/sun4v/ml/hcall.s101
-rw-r--r--usr/src/uts/sun4v/os/hsvc.c7
-rw-r--r--usr/src/uts/sun4v/sys/glvc.h31
-rw-r--r--usr/src/uts/sun4v/sys/hypervisor_api.h6
8 files changed, 251 insertions, 127 deletions
diff --git a/usr/src/uts/sun4v/Makefile.files b/usr/src/uts/sun4v/Makefile.files
index 8b6b89aca1..8fd0f3f1af 100644
--- a/usr/src/uts/sun4v/Makefile.files
+++ b/usr/src/uts/sun4v/Makefile.files
@@ -109,7 +109,7 @@ MEMTEST_OBJS += memtest.o memtest_asm.o \
#
QCN_OBJS = qcn.o
VNEX_OBJS = vnex.o
-GLVC_OBJS = glvc.o
+GLVC_OBJS = glvc.o glvc_hcall.o
MDESC_OBJS = mdesc.o
#
diff --git a/usr/src/uts/sun4v/Makefile.rules b/usr/src/uts/sun4v/Makefile.rules
index d97c91bc9e..8b49649880 100644
--- a/usr/src/uts/sun4v/Makefile.rules
+++ b/usr/src/uts/sun4v/Makefile.rules
@@ -76,6 +76,13 @@ $(OBJS_DIR)/%.o: $(UTSBASE)/sun4v/io/fpc/%.c
$(OBJS_DIR)/%.o: $(UTSBASE)/sun4v/io/fpc/%.s
$(COMPILE.s) -o $@ $<
+$(OBJS_DIR)/%.o: $(UTSBASE)/sun4v/io/glvc/%.c
+ $(COMPILE.c) -o $@ $<
+ $(CTFCONVERT_O)
+
+$(OBJS_DIR)/%.o: $(UTSBASE)/sun4v/io/glvc/%.s
+ $(COMPILE.s) -o $@ $<
+
$(OBJS_DIR)/%.o: $(UTSBASE)/sun4v/vm/%.c
$(COMPILE.c) -o $@ $<
$(CTFCONVERT_O)
@@ -141,6 +148,12 @@ $(LINTS_DIR)/%.ln: $(UTSBASE)/sun4v/io/fpc/%.c
$(LINTS_DIR)/%.ln: $(UTSBASE)/sun4v/io/fpc/%.s
@($(LHEAD) $(LINT.s) $< $(LTAIL))
+$(LINTS_DIR)/%.ln: $(UTSBASE)/sun4v/io/glvc/%.c
+ @($(LHEAD) $(LINT.c) $< $(LTAIL))
+
+$(LINTS_DIR)/%.ln: $(UTSBASE)/sun4v/io/glvc/%.s
+ @($(LHEAD) $(LINT.s) $< $(LTAIL))
+
$(LINTS_DIR)/%.ln: $(UTSBASE)/sun4v/ml/%.s
@($(LHEAD) $(LINT.s) $< $(LTAIL))
diff --git a/usr/src/uts/sun4v/io/glvc.c b/usr/src/uts/sun4v/io/glvc/glvc.c
index 0743b9d329..2b3b9e24a8 100644
--- a/usr/src/uts/sun4v/io/glvc.c
+++ b/usr/src/uts/sun4v/io/glvc/glvc.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -45,6 +44,7 @@
#include <sys/uadmin.h>
#include <sys/machsystm.h>
#include <sys/hypervisor_api.h>
+#include <sys/hsvc.h>
#include <sys/glvc.h>
/*
@@ -137,7 +137,7 @@ extern struct mod_ops mod_driverops;
static struct modldrv modldrv = {
&mod_driverops, /* Type of module. This is a driver */
- "Sun4v virtual channel driver", /* Name of the module */
+ "Sun4v virtual channel driver 2.0", /* Name of the module */
&glvc_ops /* pointer to the dev_ops structure */
};
@@ -170,6 +170,18 @@ typedef struct glvc_soft_state {
} glvc_soft_state_t;
/*
+ * Hypervisor VSC api versioning information for glvc driver.
+ */
+static uint64_t glvc_vsc_min_ver; /* Negotiated VSC API minor version */
+static uint_t glvc_vsc_users = 0; /* VSC API users */
+static kmutex_t glvc_vsc_users_mutex; /* Mutex to protect user count */
+
+static hsvc_info_t glvc_hsvc = {
+ HSVC_REV_1, NULL, HSVC_GROUP_VSC, GLVC_VSC_MAJOR_VER,
+ GLVC_VSC_MINOR_VER, "glvc"
+};
+
+/*
* Module Variables
* ================
*/
@@ -203,6 +215,11 @@ _init(void)
sizeof (glvc_soft_state_t), 1)) != 0)
return (error);
+ /*
+ * Initialize the mutex for global data structure
+ */
+ mutex_init(&glvc_vsc_users_mutex, NULL, MUTEX_DRIVER, NULL);
+
error = mod_install(&modlinkage);
return (error);
@@ -225,6 +242,8 @@ _fini(void)
if (error)
return (error);
+ mutex_destroy(&glvc_vsc_users_mutex);
+
ddi_soft_state_fini(&glvc_ssp);
return (0);
}
@@ -241,9 +260,38 @@ glvc_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
case DDI_ATTACH:
instance = ddi_get_instance(dip);
+ /*
+ * Negotiate the API version for VSC hypervisor services.
+ */
+ mutex_enter(&glvc_vsc_users_mutex);
+ if (glvc_vsc_users == 0 &&
+ (err = hsvc_register(&glvc_hsvc, &glvc_vsc_min_ver))
+ != 0) {
+ cmn_err(CE_WARN, "%s: cannot negotiate hypervisor "
+ "services group: 0x%lx major: 0x%lx minor: 0x%lx "
+ "errno: %d\n", glvc_hsvc.hsvc_modname,
+ glvc_hsvc.hsvc_group, glvc_hsvc.hsvc_major,
+ glvc_hsvc.hsvc_minor, err);
+
+ mutex_exit(&glvc_vsc_users_mutex);
+ return (DDI_FAILURE);
+ } else {
+ glvc_vsc_users++;
+ mutex_exit(&glvc_vsc_users_mutex);
+ }
+
+ DPRINTF(("Glvc instance %d negotiated VSC API version, "
+ " major 0x%lx minor 0x%lx\n",
+ instance, glvc_hsvc.hsvc_major, glvc_vsc_min_ver));
+
if (ddi_soft_state_zalloc(glvc_ssp, instance)
- != DDI_SUCCESS)
+ != DDI_SUCCESS) {
+ mutex_enter(&glvc_vsc_users_mutex);
+ if (--glvc_vsc_users == 0)
+ (void) hsvc_unregister(&glvc_hsvc);
+ mutex_exit(&glvc_vsc_users_mutex);
return (DDI_FAILURE);
+ }
softsp = ddi_get_soft_state(glvc_ssp, instance);
@@ -330,7 +378,7 @@ glvc_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
ddi_report_dev(dip);
DPRINTF(("glvc instance %d, s_id %lu,"
- "mtu %lu attached", instance, softsp->s_id,
+ "mtu %lu attached\n", instance, softsp->s_id,
softsp->mtu));
return (DDI_SUCCESS);
@@ -349,6 +397,10 @@ bad1:
mutex_destroy(&(softsp->statusreg_mutex));
bad:
+ mutex_enter(&glvc_vsc_users_mutex);
+ if (--glvc_vsc_users == 0)
+ (void) hsvc_unregister(&glvc_hsvc);
+ mutex_exit(&glvc_vsc_users_mutex);
cmn_err(CE_WARN, "glvc: attach failed for instance %d\n", instance);
ddi_soft_state_free(glvc_ssp, instance);
return (DDI_FAILURE);
@@ -390,6 +442,11 @@ glvc_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
ddi_soft_state_free(glvc_ssp, instance);
+ mutex_enter(&glvc_vsc_users_mutex);
+ if (--glvc_vsc_users == 0)
+ (void) hsvc_unregister(&glvc_hsvc);
+ mutex_exit(&glvc_vsc_users_mutex);
+
return (DDI_SUCCESS);
case DDI_SUSPEND:
return (DDI_SUCCESS);
@@ -424,7 +481,7 @@ glvc_add_intr_handlers(dev_info_t *dip)
polling_interval = (uint64_t)ddi_getprop(DDI_DEV_T_ANY,
softsp->dip, DDI_PROP_DONTPASS, "intrmode_poll",
GLVC_TIMEOUT_POLL);
- DPRINTF(("glvc instance %d polling_interval = %lu",
+ DPRINTF(("glvc instance %d polling_interval = %lu\n",
instance, polling_interval));
softsp->polling_interval = drv_usectohz(polling_interval);
} else {
@@ -435,7 +492,7 @@ glvc_add_intr_handlers(dev_info_t *dip)
(uint64_t)ddi_getprop(DDI_DEV_T_ANY,
softsp->dip, DDI_PROP_DONTPASS, "pollmode_poll",
GLVC_POLLMODE_POLL);
- DPRINTF(("glvc instance %d polling_interval = %lu",
+ DPRINTF(("glvc instance %d polling_interval = %lu\n",
instance, polling_interval));
softsp->polling_interval =
drv_usectohz(polling_interval);
@@ -447,7 +504,7 @@ glvc_add_intr_handlers(dev_info_t *dip)
GLVC_REG_RECV_ENA|GLVC_REG_SEND_ENA);
if (err != H_EOK) {
cmn_err(CE_NOTE, "glvc instance %d"
- " cannot enable receive interrupt",
+ " cannot enable receive interrupt\n",
instance);
return (DDI_FAILURE);
}
diff --git a/usr/src/uts/sun4v/io/glvc/glvc_hcall.s b/usr/src/uts/sun4v/io/glvc/glvc_hcall.s
new file mode 100644
index 0000000000..e3717f245c
--- /dev/null
+++ b/usr/src/uts/sun4v/io/glvc/glvc_hcall.s
@@ -0,0 +1,141 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * Hypervisor calls called by glvc driver.
+*/
+
+#include <sys/asm_linkage.h>
+#include <sys/hypervisor_api.h>
+#include <sys/glvc.h>
+
+#if defined(lint) || defined(__lint)
+
+/*ARGSUSED*/
+uint64_t
+hv_service_recv(uint64_t s_id, uint64_t buf_pa, uint64_t size,
+ uint64_t *recv_bytes)
+{ return (0); }
+
+/*ARGSUSED*/
+uint64_t
+hv_service_send(uint64_t s_id, uint64_t buf_pa, uint64_t size,
+ uint64_t *send_bytes)
+{ return (0); }
+
+/*ARGSUSED*/
+uint64_t
+hv_service_getstatus(uint64_t s_id, uint64_t *vreg)
+{ return (0); }
+
+/*ARGSUSED*/
+uint64_t
+hv_service_setstatus(uint64_t s_id, uint64_t bits)
+{ return (0); }
+
+/*ARGSUSED*/
+uint64_t
+hv_service_clrstatus(uint64_t s_id, uint64_t bits)
+{ return (0); }
+
+#else /* lint || __lint */
+
+ /*
+ * hv_service_recv(uint64_t s_id, uint64_t buf_pa,
+ * uint64_t size, uint64_t *recv_bytes);
+ */
+ ENTRY(hv_service_recv)
+ save %sp, -SA(MINFRAME), %sp
+ mov %i0, %o0
+ mov %i1, %o1
+ mov %i2, %o2
+ mov %i3, %o3
+ mov SVC_RECV, %o5
+ ta FAST_TRAP
+ brnz %o0, 1f
+ mov %o0, %i0
+ stx %o1, [%i3]
+1:
+ ret
+ restore
+ SET_SIZE(hv_service_recv)
+
+ /*
+ * hv_service_send(uint64_t s_id, uint64_t buf_pa,
+ * uint64_t size, uint64_t *recv_bytes);
+ */
+ ENTRY(hv_service_send)
+ save %sp, -SA(MINFRAME), %sp
+ mov %i0, %o0
+ mov %i1, %o1
+ mov %i2, %o2
+ mov %i3, %o3
+ mov SVC_SEND, %o5
+ ta FAST_TRAP
+ brnz %o0, 1f
+ mov %o0, %i0
+ stx %o1, [%i3]
+1:
+ ret
+ restore
+ SET_SIZE(hv_service_send)
+
+ /*
+ * hv_service_getstatus(uint64_t s_id, uint64_t *vreg);
+ */
+ ENTRY(hv_service_getstatus)
+ mov %o1, %o4 ! save datap
+ mov SVC_GETSTATUS, %o5
+ ta FAST_TRAP
+ brz,a %o0, 1f
+ stx %o1, [%o4]
+1:
+ retl
+ nop
+ SET_SIZE(hv_service_getstatus)
+
+ /*
+ * hv_service_setstatus(uint64_t s_id, uint64_t bits);
+ */
+ ENTRY(hv_service_setstatus)
+ mov SVC_SETSTATUS, %o5
+ ta FAST_TRAP
+ retl
+ nop
+ SET_SIZE(hv_service_setstatus)
+
+ /*
+ * hv_service_clrstatus(uint64_t s_id, uint64_t bits);
+ */
+ ENTRY(hv_service_clrstatus)
+ mov SVC_CLRSTATUS, %o5
+ ta FAST_TRAP
+ retl
+ nop
+ SET_SIZE(hv_service_clrstatus)
+
+#endif /* lint || __lint */
diff --git a/usr/src/uts/sun4v/ml/hcall.s b/usr/src/uts/sun4v/ml/hcall.s
index b216f0448e..d445127644 100644
--- a/usr/src/uts/sun4v/ml/hcall.s
+++ b/usr/src/uts/sun4v/ml/hcall.s
@@ -129,33 +129,6 @@ hv_cpu_yield(void)
/*ARGSUSED*/
uint64_t
-hv_service_recv(uint64_t s_id, uint64_t buf_pa, uint64_t size,
- uint64_t *recv_bytes)
-{ return (0); }
-
-/*ARGSUSED*/
-uint64_t
-hv_service_send(uint64_t s_id, uint64_t buf_pa, uint64_t size,
- uint64_t *send_bytes)
-{ return (0); }
-
-/*ARGSUSED*/
-uint64_t
-hv_service_getstatus(uint64_t s_id, uint64_t *vreg)
-{ return (0); }
-
-/*ARGSUSED*/
-uint64_t
-hv_service_setstatus(uint64_t s_id, uint64_t bits)
-{ return (0); }
-
-/*ARGSUSED*/
-uint64_t
-hv_service_clrstatus(uint64_t s_id, uint64_t bits)
-{ return (0); }
-
-/*ARGSUSED*/
-uint64_t
hv_cpu_state(uint64_t cpuid, uint64_t *cpu_state)
{ return (0); }
@@ -455,80 +428,6 @@ hv_hpriv(void *func, uint64_t arg1, uint64_t arg2, uint64_t arg3)
SET_SIZE(hv_cpu_yield)
/*
- * hv_service_recv(uint64_t s_id, uint64_t buf_pa,
- * uint64_t size, uint64_t *recv_bytes);
- */
- ENTRY(hv_service_recv)
- save %sp, -SA(MINFRAME), %sp
- mov %i0, %o0
- mov %i1, %o1
- mov %i2, %o2
- mov %i3, %o3
- mov SVC_RECV, %o5
- ta FAST_TRAP
- brnz %o0, 1f
- mov %o0, %i0
- stx %o1, [%i3]
-1:
- ret
- restore
- SET_SIZE(hv_service_recv)
-
- /*
- * hv_service_send(uint64_t s_id, uint64_t buf_pa,
- * uint64_t size, uint64_t *recv_bytes);
- */
- ENTRY(hv_service_send)
- save %sp, -SA(MINFRAME), %sp
- mov %i0, %o0
- mov %i1, %o1
- mov %i2, %o2
- mov %i3, %o3
- mov SVC_SEND, %o5
- ta FAST_TRAP
- brnz %o0, 1f
- mov %o0, %i0
- stx %o1, [%i3]
-1:
- ret
- restore
- SET_SIZE(hv_service_send)
-
- /*
- * hv_service_getstatus(uint64_t s_id, uint64_t *vreg);
- */
- ENTRY(hv_service_getstatus)
- mov %o1, %o4 ! save datap
- mov SVC_GETSTATUS, %o5
- ta FAST_TRAP
- brz,a %o0, 1f
- stx %o1, [%o4]
-1:
- retl
- nop
- SET_SIZE(hv_service_getstatus)
-
- /*
- * hv_service_setstatus(uint64_t s_id, uint64_t bits);
- */
- ENTRY(hv_service_setstatus)
- mov SVC_SETSTATUS, %o5
- ta FAST_TRAP
- retl
- nop
- SET_SIZE(hv_service_setstatus)
-
- /*
- * hv_service_clrstatus(uint64_t s_id, uint64_t bits);
- */
- ENTRY(hv_service_clrstatus)
- mov SVC_CLRSTATUS, %o5
- ta FAST_TRAP
- retl
- nop
- SET_SIZE(hv_service_clrstatus)
-
- /*
* int hv_cpu_state(uint64_t cpuid, uint64_t *cpu_state);
*/
ENTRY(hv_cpu_state)
diff --git a/usr/src/uts/sun4v/os/hsvc.c b/usr/src/uts/sun4v/os/hsvc.c
index 689c1cc8c5..4b88b60222 100644
--- a/usr/src/uts/sun4v/os/hsvc.c
+++ b/usr/src/uts/sun4v/os/hsvc.c
@@ -653,15 +653,12 @@ hsvc_init(void)
* uses hypervisor services belonging to the HSVC_GROUP_CORE API
* group only for itself.
*
- * Rest of the API groups are currently negotiated on behalf
- * of the pcitool and glvc support. In future, when these drivers
- * are modified to do the negotiation themselves, corresponding
- * entry should be removed from the table below.
+ * Note that the HSVC_GROUP_DIAG is negotiated on behalf of
+ * any driver/module using DIAG services.
*/
static hsvc_info_t hsvcinfo_unix[] = {
{HSVC_REV_1, NULL, HSVC_GROUP_SUN4V, 1, 0, NULL},
{HSVC_REV_1, NULL, HSVC_GROUP_CORE, 1, 0, NULL},
- {HSVC_REV_1, NULL, HSVC_GROUP_VSC, 1, 0, NULL},
{HSVC_REV_1, NULL, HSVC_GROUP_DIAG, 1, 0, NULL}
};
diff --git a/usr/src/uts/sun4v/sys/glvc.h b/usr/src/uts/sun4v/sys/glvc.h
index 993aefaa6d..13f27e3158 100644
--- a/usr/src/uts/sun4v/sys/glvc.h
+++ b/usr/src/uts/sun4v/sys/glvc.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -33,6 +32,28 @@
extern "C" {
#endif
+/*
+ * Service channel related Hypervisor function numbers.
+ */
+#define SVC_SEND 0x80
+#define SVC_RECV 0x81
+#define SVC_GETSTATUS 0x82
+#define SVC_SETSTATUS 0x83
+#define SVC_CLRSTATUS 0x84
+
+#ifndef _ASM
+
+/*
+ * VSC API versioning.
+ *
+ * Current glvc driver supports VSC API version 1.0.
+ */
+#define GLVC_VSC_MAJOR_VER_1 0x1ull
+#define GLVC_VSC_MAJOR_VER GLVC_VSC_MAJOR_VER_1
+
+#define GLVC_VSC_MINOR_VER_0 0x0ull
+#define GLVC_VSC_MINOR_VER GLVC_VSC_MINOR_VER_0
+
/* for ioctl */
#define GLVC_XPORT_IOCTL_DATA_PEEK 1
#define GLVC_XPORT_IOCTL_OPT_OP 2
@@ -62,6 +83,8 @@ typedef struct glvc_xport_opt_op {
uint32_t opt_val; /* option value to use */
} glvc_xport_opt_op_t;
+#endif /* _ASM */
+
#ifdef __cplusplus
}
#endif
diff --git a/usr/src/uts/sun4v/sys/hypervisor_api.h b/usr/src/uts/sun4v/sys/hypervisor_api.h
index 3b4aad6910..57e4808a75 100644
--- a/usr/src/uts/sun4v/sys/hypervisor_api.h
+++ b/usr/src/uts/sun4v/sys/hypervisor_api.h
@@ -104,12 +104,6 @@ extern "C" {
#define CONS_READ 0x60
#define CONS_WRITE 0x61
-#define SVC_SEND 0x80
-#define SVC_RECV 0x81
-#define SVC_GETSTATUS 0x82
-#define SVC_SETSTATUS 0x83
-#define SVC_CLRSTATUS 0x84
-
#define TTRACE_BUF_CONF 0x90
#define TTRACE_BUF_INFO 0x91
#define TTRACE_ENABLE 0x92