vlds.c revision 30588217a56ff2c9137248fb2e5065c4f0101459
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * CDDL HEADER START
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * The contents of this file are subject to the terms of the
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * Common Development and Distribution License (the "License").
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * You may not use this file except in compliance with the License.
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * or http://www.opensolaris.org/os/licensing.
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * See the License for the specific language governing permissions
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * and limitations under the License.
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * When distributing Covered Code, include this CDDL HEADER in each
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * If applicable, add the following below this CDDL HEADER, with the
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * fields enclosed by brackets "[]" replaced with your own identifying
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * information: Portions Copyright [yyyy] [name of copyright owner]
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * CDDL HEADER END
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * Use is subject to license terms.
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * LDOMs Domain Services Device Driver
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensentypedef struct vlds_state {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen struct vlds_recv_hdr *next; /* next in recv list */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen int state; /* driver svc info state VLDS_RECV* */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen vlds_recv_hdr_t *recv_headp; /* ptr to head of recv queue */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen vlds_recv_hdr_t *recv_tailp; /* ptr to tail of recv queue */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen size_t recv_size; /* no. of bytes in recv queue */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen kmutex_t recv_lock; /* lock for recv queue */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen kcondvar_t recv_cv; /* condition variable for recv queue */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen int recv_nreaders; /* no of currently waiting readers */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenstatic uint_t vlds_flags_to_svc(uint64_t flags);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenstatic int vlds_open(dev_t *devp, int flag, int otyp, cred_t *credp);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenstatic int vlds_close(dev_t dev, int flag, int otyp, cred_t *credp);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenstatic int vlds_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *credp,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenstatic int vlds_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenstatic int vlds_attach(dev_info_t *dip, ddi_attach_cmd_t cmd);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenstatic int vlds_detach(dev_info_t *dip, ddi_detach_cmd_t cmd);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen/* mdeg register functions */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenstatic int ds_mdeg_cb(void *cb_argp, mdeg_result_t *resp);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenstatic int ds_mdeg_register(void);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenstatic int ds_add_mdeg_port(md_t *mdp, mde_cookie_t node);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen/* driver utilities */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenstatic void vlds_user_reg_cb(ds_cb_arg_t arg, ds_ver_t *ver, ds_svc_hdl_t hdl);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenstatic void vlds_user_unreg_cb(ds_cb_arg_t arg);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenstatic void vlds_user_data_cb(ds_cb_arg_t arg, void *buf, size_t buflen);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenstatic void vlds_recvq_init(vlds_svc_info_t *dpsp);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenstatic void vlds_recvq_destroy(vlds_svc_info_t *dpsp);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenstatic int vlds_recvq_get_data(vlds_svc_info_t *dpsp, void *buf, size_t buflen,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenstatic void vlds_recvq_drain(vlds_svc_info_t *dpsp);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenstatic int vlds_recvq_put_data(vlds_svc_info_t *dpsp, void *buf, size_t buflen);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenstatic int vlds_recv_msg(ds_svc_hdl_t hdl, void *buf, size_t buflen,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * DS driver Ops Vector
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen 0, /* devo_refcnt */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen "Domain Services Driver 1.0",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * Callback ops for user-land services.
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen/* Definitions for binding handle array */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenstatic ulong_t vlds_bitmap_initial = 1; /* index 0 indicates error */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenstatic ulong_t *vlds_minor_bitmap = &vlds_bitmap_initial;
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * Following vlds_minor_* routines map a binding handle to a minor number.
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * Has to be called w/ locks held.
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen /* Increase bitmap by one BT_NBIPUL */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (vlds_minor_bits + BT_NBIPUL > VLDS_MINOR_MAX) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen BT_SIZEOFMAP(vlds_minor_bits + BT_NBIPUL), KM_SLEEP);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen bcopy(bhst, vlds_minor_bitmap, BT_SIZEOFMAP(vlds_minor_bits));
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen kmem_free(bhst, BT_SIZEOFMAP(vlds_minor_bits));
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen kmem_free(bitmap, BT_SIZEOFMAP(vlds_minor_bits));
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen /* Search for an available index */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen /* All busy - allocate additional binding handle bitmap space */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen /* Reached our maximum of id's == SHRT_MAX */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen idx = bt_availbit(vlds_minor_bitmap, vlds_minor_bits);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen ASSERT(BT_TEST(vlds_minor_bitmap, idx) == 1);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen mutex_init(&vlds_minor_mutex, NULL, MUTEX_DEFAULT, NULL);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if ((s = ddi_soft_state_init(&vlds_statep, sizeof (vlds_state_t), 0))
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenvlds_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, void **resultp)
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenvlds_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (ddi_create_minor_node(devi, VLDS_NAME, S_IFCHR,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenvlds_detach(dev_info_t *devi, ddi_detach_cmd_t cmd)
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenvlds_open(dev_t *devp, int flag, int otyp, cred_t *credp)
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen /* All minors are busy */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (ddi_soft_state_zalloc(vlds_statep, minor) != DDI_SUCCESS) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen *devp = makedevice(getmajor(*devp), minor);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenvlds_close(dev_t dev, int flag, int otyp, cred_t *credp)
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * Unregister all handles associated with this process.
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen sp = ddi_get_soft_state(vlds_statep, minor);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenvlds_init_sysevent(vlds_state_t *sp, uint32_t flags)
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: sysevent already bound",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen (void) sprintf(evchan_name, VLDS_SYSEV_CHAN_FMT, ddi_get_pid());
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if ((rv = sysevent_evc_bind(evchan_name, &sp->evchan,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen cmn_err(CE_WARN, "%s: can't bind to '%s' (%d)",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: sysevent bind to '%s' successful",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen#define ARGTOPTR(x) ((void *)((uintptr_t)(x)))
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen#define ARGTOINT(x) ((int)(x))
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenvlds_get_string(vlds_string_t *strp, char **rstrp, int mode)
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: invalid string length: %d", __func__,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (ddi_copyin(ARGTOPTR(strp->vlds_strp), str, len, mode) != 0) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: ddi copyin failed (%p)", __func__,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: invalid string len: %d != len: %d",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenvlds_put_string(char *str, vlds_string_t *strp, int mode)
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * If string is longer than user buffer, return a
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * truncated, null-terminated string.
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen rv = ddi_copyout(str, ARGTOPTR(strp->vlds_strp), len, mode);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: copyout (%p) failed", __func__,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenvlds_get_ucap(vlds_cap_t *capp, ds_capability_t *ucap, int mode)
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (ddi_copyin(capp, &vlds_cap, sizeof (vlds_cap), mode) != 0) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: cap copyin failed (%p)", __func__,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: vlds_nver (%d) invalid", __func__,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if ((rv = vlds_get_string(&vlds_cap.vlds_service, &servp, mode)) != 0) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: vlds_get_string vlds_service failed "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: vlds_get_string vlds_service is NULL",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (ddi_copyin(ARGTOPTR(vlds_cap.vlds_versp), dsvp, n, mode) != 0) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: copyin of vers (%p, %d) failed",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen __func__, ARGTOPTR(vlds_cap.vlds_versp), n);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen ucap->vers = DS_MALLOC(nver * sizeof (ds_ver_t));
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen for (i = 0; i < nver; i++) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen kmem_free(ucap->svc_id, strlen(ucap->svc_id) + 1);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen kmem_free(ucap->vers, ucap->nvers * sizeof (ds_ver_t));
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenvlds_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *credp,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if ((sp = ddi_get_soft_state(vlds_statep, minor)) == NULL)
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (ddi_copyin((void *)arg, &vlds_arg, sizeof (vlds_arg),
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: SVC REG arg copyin failed",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if ((rv = vlds_get_ucap(ARGTOPTR(vlds_arg.vlds_capp), &ucap,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: SVC REG get_ucap failed (%d)",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen flags = vlds_flags_to_svc(vlds_arg.vlds_reg_flags);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if ((rv = vlds_init_sysevent(sp, flags)) != 0) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen vlds_flags_to_svc(vlds_arg.vlds_reg_flags) | DSSF_ISUSER,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: SVC REG ds_ucap_init failed "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (ddi_copyout(&hdl_arg, ARGTOPTR(vlds_arg.vlds_hdlp),
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: SVC REG copyout failed",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: SVC REG succeeded: hdl: %lx",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (ddi_copyin((void *)arg, &vlds_arg, sizeof (vlds_arg),
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: UNREG_HDL arg copyin failed",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if ((rv = ds_is_my_hdl(hdl, minor)) != 0) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: UNREG_HDL ds_is_my_hdl "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen " hdl: %lx inst: %d failed (%d)", __func__,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: UNREG_HDL ds_cap_unreg "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen " hdl: %lx failed (%d)", __func__, hdl, rv);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: UNREG_HDL hdl: %lx succeeded",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (ddi_copyin((void *)arg, &vlds_arg, sizeof (vlds_arg),
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: HDL_LOOKUP arg copyin failed",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen is_client = ARGTOUINT(vlds_arg.vlds_isclient);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen maxhdls = ARGTOUINT(vlds_arg.vlds_maxhdls);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: HDL_LOOKUP invalid maxhdls "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if ((rv = vlds_get_string(&vlds_arg.vlds_service, &servicep,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: HDL_LOOKUP vlds_get_string "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: HDL_LOOKUP vlds_get_string "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen hdlsp = DS_MALLOC(maxhdls * sizeof (*hdlsp));
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: HDL_LOOKUP (%s, %d) entered",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen rv = ds_hdl_lookup(servicep, is_client, hdlsp, maxhdls, &nhdls);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: HDL_LOOKUP failed: (%d)",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen ddi_copyout(hdlsp, ARGTOPTR(vlds_arg.vlds_hdlsp),
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen nhdls * sizeof (ds_svc_hdl_t), mode) != 0) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: HDL_LOOKUP copyout of hdls "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (ddi_copyout(&nhdls_arg, ARGTOPTR(vlds_arg.vlds_nhdlsp),
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: HDL_LOOKUP copyout of nhdls "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: HDL_LOOKUP succeeded: nhdls: %d",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (ddi_copyin((void *)arg, &vlds_arg, sizeof (vlds_arg),
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: DMN_LOOKUP arg copyin failed",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if ((rv = ds_domain_lookup(hdl, &dhdl)) != 0) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: DMN_LOOKUP lookup hdl: 0x%lx "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (ddi_copyout(&dhdl_arg, ARGTOPTR(vlds_arg.vlds_dhdlp),
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: DMN_LOOKUP copyout "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: DMN_LOOKUP hdl: 0x%lx, dhdl: 0x%lx "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (ddi_copyin((void *)arg, &vlds_arg, sizeof (vlds_arg),
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: SEND_MSG arg copyin failed",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if ((rv = ds_is_my_hdl(hdl, minor)) != 0) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: SEND_MSG ds_is_my_hdl "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen " hdl: %lx inst: %d failed (%d)", __func__,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: SEND_MSG (hdl: %lx, bufp: %p, "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen "buflen: %ld", __func__, hdl, ARGTOPTR(vlds_arg.vlds_bufp),
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (ddi_copyin(ARGTOPTR(vlds_arg.vlds_bufp), bufp, buflen,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: SEND_MSG buf (%p, %ld) "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if ((rv = ds_cap_send(hdl, bufp, buflen)) != 0) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: SEND_MSG ds_cap_send failed "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: SEND_MSG hdl: %lx, bufp: %p, "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen "buflen: %ld succeeded", __func__, hdl, (void *)bufp,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DUMP_MSG(DS_DBG_FLAG_VLDS, bufp, buflen);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (ddi_copyin((void *)arg, &vlds_arg, sizeof (vlds_arg),
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: RECV_MSG arg copyin failed",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if ((rv = ds_is_my_hdl(hdl, minor)) != 0) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: RECV_MSG ds_is_my_hdl "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen " hdl: %lx inst: %d failed (%d)", __func__,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if ((rv = vlds_recv_msg(hdl, ARGTOPTR(vlds_arg.vlds_bufp),
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen buflen, &msglen, mode)) != 0 && rv != EFBIG) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: RECV_MSG vlds_recv_msg "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (ddi_copyout(&msglen_arg, ARGTOPTR(vlds_arg.vlds_msglenp),
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: RECV_MSG copyout of msglen "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: RECV_MSG hdl: %lx, "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen "msglen: %ld succeeded", __func__, hdl, buflen);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (ddi_copyin((void *)arg, &vlds_arg, sizeof (vlds_arg),
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: HDL_ISREADY arg copyin "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if ((rv = ds_hdl_isready(hdl, &is_ready)) != 0) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: HDL_ISREADY ds_hdl_isready "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (ddi_copyout(&is_ready_arg, ARGTOPTR(vlds_arg.vlds_isreadyp),
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: HDL_ISREADY copyout of "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: HDL_ISREADY succeeded hdl: %lx, "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (ddi_copyin((void *)arg, &vlds_arg, sizeof (vlds_arg),
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: DOM_NAM2HDL arg copyin "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if ((rv = vlds_get_string(&vlds_arg.vlds_domain_name,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: DOM_NAM2HDL vlds_get_string "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: DOM_NAM2HDL vlds_get_string "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: DOM_NAM2HDL (%s) entered", __func__,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if ((rv = ds_dom_name_to_hdl(domain_name, &dhdl)) != 0) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: DOM_NAM2HDL name: '%s' "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen "failed: (%d)", __func__, domain_name, rv);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_FREE(domain_name, strlen(domain_name) + 1);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (ddi_copyout(&dhdl_arg, ARGTOPTR(vlds_arg.vlds_dhdlp),
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_FREE(domain_name, strlen(domain_name) + 1);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: DOM_NAM2HDL copyout of dhdl "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: DOM_NAM2HDL succeeded: name: '%s', "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen "dhdl: 0x%lx", __func__, domain_name, dhdl);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_FREE(domain_name, strlen(domain_name) + 1);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (ddi_copyin((void *)arg, &vlds_arg, sizeof (vlds_arg),
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: DOM_HDL2NAM arg copyin "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if ((rv = ds_dom_hdl_to_name(hdl, &domain_name)) != 0) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: DOM_HDL2NAM lookup dhdl: %lx "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: DOM_HDL2NAM vlds_put_string "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen "'%s' failed (%d)", __func__, domain_name, rv);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: DOM_HDL2NAM dhdl: 0x%lx name: '%s'",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * MD registration code.
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * Placed in vlds rather than ds module due to cirular dependency of
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * platsvc module which contains the mdeg code.
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * There's only one domain services node, so we don't
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * need to specify any match conditions. However, we
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * have to supply a non-NULL property spec.
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenstatic mdeg_prop_spec_t ds_prop_template[] = {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen { VLDS_MD_ROOT_NODE_NAME, ds_prop_template };
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * Matching criteria passed to the MDEG to register interest
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * in changes to domain services port nodes identified by their
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * 'id' property.
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenstatic md_prop_match_t ds_port_prop_match[] = {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenstatic mdeg_node_match_t ds_port_match = { VLDS_MD_PORT_NODE_NAME,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen/* mdeg callback */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensends_mdeg_cb(void *cb_argp, mdeg_result_t *resp)
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "ds_mdeg_cb: no result returned");
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: added=%d, removed=%d, matched=%d", __func__,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen resp->added.nelem, resp->removed.nelem, resp->match_prev.nelem);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen /* process added ports */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen for (idx = 0; idx < resp->added.nelem; idx++) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: processing added node 0x%lx",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen /* attempt to add a port */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if ((rv = ds_add_mdeg_port(mdp, node)) != MDEG_SUCCESS) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen cmn_err(CE_NOTE, "%s: unable to add port, "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen /* process removed ports */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen for (idx = 0; idx < resp->removed.nelem; idx++) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: processing removed node 0x%lx",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen /* read in the port's id property */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (md_get_prop_val(mdp, node, "id", &portno)) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen cmn_err(CE_NOTE, "%s: node 0x%lx of removed list "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen /* attempt to remove a port */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if ((rv = ds_remove_port(portno, 0)) != 0) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen cmn_err(CE_NOTE, "%s: unable to remove port %lu, "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen/* register callback to mdeg */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "ds_mdeg_register: entered");
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen /* perform the registration */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen rv = mdeg_register(&ds_node_template, &ds_port_match, ds_mdeg_cb,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen cmn_err(CE_NOTE, "ds_mdeg_register: mdeg_register "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen/* unregister callback from mdeg */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "ds_mdeg_unregister: hdl=0x%lx", ds_mdeg_hdl);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensends_get_port_channel(md_t *mdp, mde_cookie_t node, uint64_t *ldc_id)
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * Find the channel-endpoint node(s) (which should be under this
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * port node) which contain the channel id(s).
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if ((num_nodes = md_node_count(mdp)) <= 0) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen cmn_err(CE_NOTE, "%s: invalid number of channel-endpoint nodes "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen /* allocate space for node list */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen listsz = num_nodes * sizeof (mde_cookie_t);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen nchan = md_scan_dag(mdp, node, md_find_name(mdp, "channel-endpoint"),
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen cmn_err(CE_NOTE, "%s: no channel-endpoint nodes found",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: %d channel-endpoint nodes found", __func__,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen /* use property from first node found */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (md_get_prop_val(mdp, listp[0], "id", ldc_id)) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen cmn_err(CE_NOTE, "%s: channel-endpoint has no 'id' property",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen/* add a DS services port */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensends_add_mdeg_port(md_t *mdp, mde_cookie_t node)
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen /* read in the port's id property */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (md_get_prop_val(mdp, node, "id", &portno)) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen cmn_err(CE_NOTE, "%s: node 0x%lx of added list has no "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen cmn_err(CE_NOTE, "%s: found port number (%lu) "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen "larger than maximum supported number of ports", __func__,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen /* get all channels for this device (currently only one) */
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (ds_get_port_channel(mdp, node, &ldc_id) == -1) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (md_get_prop_val(mdp, node, "remote-domain-id", &dhdl) != 0) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (md_get_prop_str(mdp, node, "remote-domain-name", &dom_name) != 0) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen rv = ds_add_port(portno, ldc_id, dhdl, dom_name, vlds_ports_inited);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "ds%lx: %s LDC chan: %lx "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen "failed err = %d", portno, __func__, ldc_id, rv);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "ds%lx: %s LDC chan: %lx inited", portno,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenvlds_user_reg_cb(ds_cb_arg_t arg, ds_ver_t *ver, ds_svc_hdl_t hdl)
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * must allocate and init the svc read queue.
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: hdl: 0x%lx initing recvq", __func__,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen dpsp = DS_MALLOC(sizeof (vlds_svc_info_t));
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen sp = ddi_get_soft_state(vlds_statep, minor);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: regcb: hdl: 0x%lx, ver%d.%d, "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (nvlist_alloc(&nvl, NV_UNIQUE_NAME, KM_SLEEP) ||
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen nvlist_add_uint16(nvl, VLDS_VER_MAJOR, ver->major) ||
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen nvlist_add_uint16(nvl, VLDS_VER_MINOR, ver->minor) ||
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen nvlist_add_uint64(nvl, VLDS_DOMAIN_HDL, dhdl) ||
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen nvlist_add_string(nvl, VLDS_SERVICE_ID, servicep) ||
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen nvlist_add_boolean_value(nvl, VLDS_ISCLIENT,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen ESC_VLDS_REGISTER, "sun.com", "kernel", nvl, EVCH_SLEEP)) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen cmn_err(CE_WARN, "Failed to send REG Callback");
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: sysevent_evc_publish "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: unregcb draining recvq",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: unregcb hdl: 0x%lx", __func__,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen sp = ddi_get_soft_state(vlds_statep, minor);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (nvlist_alloc(&nvl, NV_UNIQUE_NAME, KM_SLEEP) ||
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen ESC_VLDS_UNREGISTER, "sun.com", "kernel", nvl,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen cmn_err(CE_WARN, "Failed to send UNREG Callback");
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenvlds_user_data_cb(ds_cb_arg_t arg, void *buf, size_t buflen)
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: datacb: to recvq: buflen: %ld",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen (void) vlds_recvq_put_data(dpsp, buf, buflen);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: datacb: usercb: hdl: 0x%lx, "
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen sp = ddi_get_soft_state(vlds_statep, minor);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (nvlist_alloc(&nvl, NV_UNIQUE_NAME, KM_SLEEP) ||
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen nvlist_add_byte_array(nvl, VLDS_DATA, buf, buflen) ||
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen ESC_VLDS_DATA, "sun.com", "kernel", nvl, EVCH_SLEEP)) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen cmn_err(CE_WARN, "Failed to send DATA Callback");
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * Initialize receive queue if request is from user land but
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * data callback is null (implying user will be using ds_recv_msg).
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen mutex_init(&dpsp->recv_lock, NULL, MUTEX_DRIVER, NULL);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen cv_init(&dpsp->recv_cv, NULL, CV_DRIVER, NULL);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen ASSERT(dpsp->state == VLDS_RECV_UNREG_PENDING);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenvlds_recvq_get_data(vlds_svc_info_t *dpsp, void *buf, size_t buflen,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (dpsp->state == VLDS_RECV_UNREG_PENDING)
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * Passing in a buflen of 0 allows user to poll for msgs.
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen rv = cv_wait_sig(&dpsp->recv_cv, &dpsp->recv_lock);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_RCVQ(CE_NOTE, "%s: signal EINTR", __func__);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (dpsp->state == VLDS_RECV_UNREG_PENDING) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_RCVQ(CE_NOTE, "%s: unreg pending", __func__);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * Don't transfer truncated data, return EFBIG error if user-supplied
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * buffer is too small.
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen rv = ddi_copyout(rhp->data, buf, msglen, mode);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: user data dequeued msglen: %ld",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DUMP_MSG(DS_DBG_FLAG_VLDS, rhp->data, rhp->datasz);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: copyout failed", __func__);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenuint64_t vlds_recv_drain_delay_time = 1 * MILLISEC;
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen for (rhp = dpsp->recv_tailp; rhp != NULL; rhp = nextp) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen * Make sure other readers have exited.
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenvlds_recvq_put_data(vlds_svc_info_t *dpsp, void *buf, size_t buflen)
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if (dpsp->state != VLDS_RECV_UNREG_PENDING) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_RCVQ(CE_NOTE, "%s: user data enqueued msglen: %ld",
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DUMP_MSG(DS_DBG_FLAG_RCVQ, buf, buflen);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensenvlds_recv_msg(ds_svc_hdl_t hdl, void *buf, size_t buflen, size_t *msglenp,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if ((rv = ds_hdl_get_cbarg(hdl, &cbarg)) != 0) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: handle %lx not found (%d)", __func__,
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen if ((flags & DSSF_ISUSER) == 0 || (flags & DSSF_DATACB_VALID) != 0) {
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: invalid flags: %x", __func__, flags);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen ds_cbarg_get_drv_per_svc_ptr(cbarg, &dpsp);
30588217a56ff2c9137248fb2e5065c4f0101459Mike Christensen DS_DBG_VLDS(CE_NOTE, "%s: recv on non-ready handle: %x",