74e20cfe817b82802b16fac8690dadcda76f54f5nh/*
74e20cfe817b82802b16fac8690dadcda76f54f5nh * CDDL HEADER START
74e20cfe817b82802b16fac8690dadcda76f54f5nh *
74e20cfe817b82802b16fac8690dadcda76f54f5nh * The contents of this file are subject to the terms of the
74e20cfe817b82802b16fac8690dadcda76f54f5nh * Common Development and Distribution License (the "License").
74e20cfe817b82802b16fac8690dadcda76f54f5nh * You may not use this file except in compliance with the License.
74e20cfe817b82802b16fac8690dadcda76f54f5nh *
74e20cfe817b82802b16fac8690dadcda76f54f5nh * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
74e20cfe817b82802b16fac8690dadcda76f54f5nh * or http://www.opensolaris.org/os/licensing.
74e20cfe817b82802b16fac8690dadcda76f54f5nh * See the License for the specific language governing permissions
74e20cfe817b82802b16fac8690dadcda76f54f5nh * and limitations under the License.
74e20cfe817b82802b16fac8690dadcda76f54f5nh *
74e20cfe817b82802b16fac8690dadcda76f54f5nh * When distributing Covered Code, include this CDDL HEADER in each
74e20cfe817b82802b16fac8690dadcda76f54f5nh * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
74e20cfe817b82802b16fac8690dadcda76f54f5nh * If applicable, add the following below this CDDL HEADER, with the
74e20cfe817b82802b16fac8690dadcda76f54f5nh * fields enclosed by brackets "[]" replaced with your own identifying
74e20cfe817b82802b16fac8690dadcda76f54f5nh * information: Portions Copyright [yyyy] [name of copyright owner]
74e20cfe817b82802b16fac8690dadcda76f54f5nh *
74e20cfe817b82802b16fac8690dadcda76f54f5nh * CDDL HEADER END
74e20cfe817b82802b16fac8690dadcda76f54f5nh */
74e20cfe817b82802b16fac8690dadcda76f54f5nh/*
d2b5b2d357ee3172eacb6860be1891259902203dAnders Persson * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
74e20cfe817b82802b16fac8690dadcda76f54f5nh */
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nh#include <sys/types.h>
74e20cfe817b82802b16fac8690dadcda76f54f5nh#include <sys/conf.h>
74e20cfe817b82802b16fac8690dadcda76f54f5nh#include <sys/modctl.h>
74e20cfe817b82802b16fac8690dadcda76f54f5nh#include <sys/stat.h>
74e20cfe817b82802b16fac8690dadcda76f54f5nh#include <sys/stream.h>
74e20cfe817b82802b16fac8690dadcda76f54f5nh#include <sys/strsun.h>
09cb82ca24006b806e9f17e2135eef96364facfenh#include <sys/stropts.h>
74e20cfe817b82802b16fac8690dadcda76f54f5nh#include <sys/ddi.h>
74e20cfe817b82802b16fac8690dadcda76f54f5nh#include <sys/sunddi.h>
74e20cfe817b82802b16fac8690dadcda76f54f5nh#include <sys/sunldi.h>
74e20cfe817b82802b16fac8690dadcda76f54f5nh#include <sys/file.h>
74e20cfe817b82802b16fac8690dadcda76f54f5nh#include <sys/priv_names.h>
74e20cfe817b82802b16fac8690dadcda76f54f5nh#include <inet/common.h>
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nh#define _SUN_TPI_VERSION 2
74e20cfe817b82802b16fac8690dadcda76f54f5nh#include <sys/tihdr.h>
74e20cfe817b82802b16fac8690dadcda76f54f5nh#include <sys/timod.h>
74e20cfe817b82802b16fac8690dadcda76f54f5nh#include <sys/tiuser.h>
74e20cfe817b82802b16fac8690dadcda76f54f5nh#include <sys/suntpi.h>
74e20cfe817b82802b16fac8690dadcda76f54f5nh#include <sys/socket.h>
74e20cfe817b82802b16fac8690dadcda76f54f5nh#include <sys/sockio.h>
74e20cfe817b82802b16fac8690dadcda76f54f5nh#include <inet/common.h>
74e20cfe817b82802b16fac8690dadcda76f54f5nh#include <inet/ip.h>
74e20cfe817b82802b16fac8690dadcda76f54f5nh#include <inet/mi.h>
74e20cfe817b82802b16fac8690dadcda76f54f5nh#include <sys/policy.h>
74e20cfe817b82802b16fac8690dadcda76f54f5nh#include "sys/random.h"
74e20cfe817b82802b16fac8690dadcda76f54f5nh#include <inet/sdp_itf.h>
74e20cfe817b82802b16fac8690dadcda76f54f5nh#include <sys/ib/ibtl/ibti.h>
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nh/*
74e20cfe817b82802b16fac8690dadcda76f54f5nh * This is a pseudo driver which creates an entry for /dev/sdp in the device
d2b5b2d357ee3172eacb6860be1891259902203dAnders Persson * tree. A regular installation will end up adding a file to sock2path.d
d2b5b2d357ee3172eacb6860be1891259902203dAnders Persson * announcing support for sdp using AF_INET/SOCK_STREAM/PROTO_SDP parameters in
d2b5b2d357ee3172eacb6860be1891259902203dAnders Persson * socket call. On a non IB hardware, following are the constraints within
d2b5b2d357ee3172eacb6860be1891259902203dAnders Persson * which the sdp project operates. The sdpib driver which is the real driver
74e20cfe817b82802b16fac8690dadcda76f54f5nh * (in terms of moving data) should not be loaded since it has dependency on
74e20cfe817b82802b16fac8690dadcda76f54f5nh * ibcm and ibtl modules which will be loaded in the memory. This will consume
74e20cfe817b82802b16fac8690dadcda76f54f5nh * precious memory and needs to be avoided. As a result the sdpib driver
74e20cfe817b82802b16fac8690dadcda76f54f5nh * should fail its init() call to disallow loading on other modules. Due to
74e20cfe817b82802b16fac8690dadcda76f54f5nh * this we do not get a chance to create a /dev/sdp entry in the device tree
74e20cfe817b82802b16fac8690dadcda76f54f5nh * in the regular sdpib driver. During the boottime, this will cause a warning
74e20cfe817b82802b16fac8690dadcda76f54f5nh * message when soconfig processes the entry for sdp in sock2path file . In
74e20cfe817b82802b16fac8690dadcda76f54f5nh * order to avoid this a pseudo driver is introduced which creates an entry
74e20cfe817b82802b16fac8690dadcda76f54f5nh * for /dev/sdp regardless of the hardware. When a socket call is made on the
74e20cfe817b82802b16fac8690dadcda76f54f5nh * sdp subsystem, the call will end up in this driver, which then forwards
74e20cfe817b82802b16fac8690dadcda76f54f5nh * this call to the real sdp driver. On a non-ib hardware system the call
74e20cfe817b82802b16fac8690dadcda76f54f5nh * will fail
74e20cfe817b82802b16fac8690dadcda76f54f5nh */
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nh#define SDP_NAME "sdp"
193974072f41a843678abf5f61979c748687e66bSherry Moore#define SDP_DEVDESC "SDP STREAMS driver"
74e20cfe817b82802b16fac8690dadcda76f54f5nh#define SDP_DEVMINOR 0
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nhstatic dev_info_t *sdp_dev_info;
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nhldi_ident_t sdp_li;
74e20cfe817b82802b16fac8690dadcda76f54f5nhkrwlock_t sdp_transport_lock;
74e20cfe817b82802b16fac8690dadcda76f54f5nhldi_handle_t sdp_transport_handle = NULL;
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nhstatic int
74e20cfe817b82802b16fac8690dadcda76f54f5nhsdp_gen_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
74e20cfe817b82802b16fac8690dadcda76f54f5nh{
74e20cfe817b82802b16fac8690dadcda76f54f5nh int ret;
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nh if (cmd != DDI_ATTACH)
74e20cfe817b82802b16fac8690dadcda76f54f5nh return (DDI_FAILURE);
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nh sdp_dev_info = devi;
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nh ret = ddi_create_minor_node(devi, SDP_NAME, S_IFCHR,
74e20cfe817b82802b16fac8690dadcda76f54f5nh SDP_DEVMINOR, DDI_PSEUDO, 0);
74e20cfe817b82802b16fac8690dadcda76f54f5nh if (ret != DDI_SUCCESS) {
74e20cfe817b82802b16fac8690dadcda76f54f5nh return (ret);
74e20cfe817b82802b16fac8690dadcda76f54f5nh }
74e20cfe817b82802b16fac8690dadcda76f54f5nh return (DDI_SUCCESS);
74e20cfe817b82802b16fac8690dadcda76f54f5nh}
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nhstatic int
74e20cfe817b82802b16fac8690dadcda76f54f5nhsdp_gen_detach(dev_info_t *devi, ddi_detach_cmd_t cmd)
74e20cfe817b82802b16fac8690dadcda76f54f5nh{
74e20cfe817b82802b16fac8690dadcda76f54f5nh if (cmd != DDI_DETACH)
74e20cfe817b82802b16fac8690dadcda76f54f5nh return (DDI_FAILURE);
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nh ASSERT(devi == sdp_dev_info);
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nh ddi_remove_minor_node(devi, NULL);
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nh return (DDI_SUCCESS);
74e20cfe817b82802b16fac8690dadcda76f54f5nh}
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nh/* open routine. */
74e20cfe817b82802b16fac8690dadcda76f54f5nh/*ARGSUSED*/
74e20cfe817b82802b16fac8690dadcda76f54f5nhstatic int
74e20cfe817b82802b16fac8690dadcda76f54f5nhsdp_gen_open(queue_t *q, dev_t *devp, int flag, int sflag, cred_t *credp)
74e20cfe817b82802b16fac8690dadcda76f54f5nh{
74e20cfe817b82802b16fac8690dadcda76f54f5nh qprocson(q);
74e20cfe817b82802b16fac8690dadcda76f54f5nh qenable(q);
74e20cfe817b82802b16fac8690dadcda76f54f5nh return (0);
74e20cfe817b82802b16fac8690dadcda76f54f5nh}
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nh/* open routine. */
74e20cfe817b82802b16fac8690dadcda76f54f5nh/*ARGSUSED*/
74e20cfe817b82802b16fac8690dadcda76f54f5nhstatic int
74e20cfe817b82802b16fac8690dadcda76f54f5nhsdp_gen_close(queue_t *q, dev_t *devp, int flag, int sflag, cred_t *credp)
74e20cfe817b82802b16fac8690dadcda76f54f5nh{
74e20cfe817b82802b16fac8690dadcda76f54f5nh qprocsoff(q);
74e20cfe817b82802b16fac8690dadcda76f54f5nh return (0);
74e20cfe817b82802b16fac8690dadcda76f54f5nh}
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nhstatic int
74e20cfe817b82802b16fac8690dadcda76f54f5nhsdp_open_sdpib_driver()
74e20cfe817b82802b16fac8690dadcda76f54f5nh{
74e20cfe817b82802b16fac8690dadcda76f54f5nh int ret = 0;
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nh rw_enter(&sdp_transport_lock, RW_WRITER);
74e20cfe817b82802b16fac8690dadcda76f54f5nh if (sdp_transport_handle != 0) {
74e20cfe817b82802b16fac8690dadcda76f54f5nh /*
74e20cfe817b82802b16fac8690dadcda76f54f5nh * Someone beat us to it.
74e20cfe817b82802b16fac8690dadcda76f54f5nh */
74e20cfe817b82802b16fac8690dadcda76f54f5nh goto done;
74e20cfe817b82802b16fac8690dadcda76f54f5nh }
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nh if (ibt_hw_is_present() == 0) {
74e20cfe817b82802b16fac8690dadcda76f54f5nh ret = ENODEV;
74e20cfe817b82802b16fac8690dadcda76f54f5nh goto done;
74e20cfe817b82802b16fac8690dadcda76f54f5nh }
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nh if (sdp_li == NULL) {
74e20cfe817b82802b16fac8690dadcda76f54f5nh ret = EPROTONOSUPPORT;
74e20cfe817b82802b16fac8690dadcda76f54f5nh goto done;
74e20cfe817b82802b16fac8690dadcda76f54f5nh }
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nh ret = ldi_open_by_name("/devices/ib/sdpib@0:sdpib",
74e20cfe817b82802b16fac8690dadcda76f54f5nh FREAD | FWRITE, kcred, &sdp_transport_handle, sdp_li);
74e20cfe817b82802b16fac8690dadcda76f54f5nh if (ret != 0) {
74e20cfe817b82802b16fac8690dadcda76f54f5nh ret = EPROTONOSUPPORT;
74e20cfe817b82802b16fac8690dadcda76f54f5nh sdp_transport_handle = NULL;
74e20cfe817b82802b16fac8690dadcda76f54f5nh goto done;
74e20cfe817b82802b16fac8690dadcda76f54f5nh }
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nhdone:
74e20cfe817b82802b16fac8690dadcda76f54f5nh rw_exit(&sdp_transport_lock);
74e20cfe817b82802b16fac8690dadcda76f54f5nh return (ret);
74e20cfe817b82802b16fac8690dadcda76f54f5nh}
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nhstatic void
74e20cfe817b82802b16fac8690dadcda76f54f5nhsdp_gen_ioctl(queue_t *q, mblk_t *mp)
74e20cfe817b82802b16fac8690dadcda76f54f5nh{
74e20cfe817b82802b16fac8690dadcda76f54f5nh struct iocblk *iocp;
74e20cfe817b82802b16fac8690dadcda76f54f5nh int32_t enable = 0;
74e20cfe817b82802b16fac8690dadcda76f54f5nh int ret;
74e20cfe817b82802b16fac8690dadcda76f54f5nh boolean_t priv = B_TRUE;
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nh /* LINTED */
74e20cfe817b82802b16fac8690dadcda76f54f5nh iocp = (struct iocblk *)mp->b_rptr;
74e20cfe817b82802b16fac8690dadcda76f54f5nh switch (iocp->ioc_cmd) {
2876fe8aae833926eecc6a2388b29b674c5cee5cLida.Horn int32_t send_enable;
bbfe764ef179c2f606b093b6ec6bb149cde0e31bse case SIOCSENABLESDP:
74e20cfe817b82802b16fac8690dadcda76f54f5nh bcopy(mp->b_cont->b_rptr, &enable, sizeof (int));
74e20cfe817b82802b16fac8690dadcda76f54f5nh
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning send_enable = enable;
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning
74e20cfe817b82802b16fac8690dadcda76f54f5nh /*
74e20cfe817b82802b16fac8690dadcda76f54f5nh * Check for root privs.
74e20cfe817b82802b16fac8690dadcda76f54f5nh * if not net config privs - return state of system SDP
74e20cfe817b82802b16fac8690dadcda76f54f5nh */
74e20cfe817b82802b16fac8690dadcda76f54f5nh if (secpolicy_net_config(CRED(), B_FALSE) != 0) {
74e20cfe817b82802b16fac8690dadcda76f54f5nh priv = B_FALSE;
74e20cfe817b82802b16fac8690dadcda76f54f5nh }
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nh /*
74e20cfe817b82802b16fac8690dadcda76f54f5nh * The sdpib driver is loaded if root enables sdp the
74e20cfe817b82802b16fac8690dadcda76f54f5nh * first time (sdp_transport_handle is NULL). It is
74e20cfe817b82802b16fac8690dadcda76f54f5nh * unloaded during the following first disable. At all
74e20cfe817b82802b16fac8690dadcda76f54f5nh * other times for root as well as non-root users, the
74e20cfe817b82802b16fac8690dadcda76f54f5nh * action of enabling/disabling sdp is simply acked.
74e20cfe817b82802b16fac8690dadcda76f54f5nh */
74e20cfe817b82802b16fac8690dadcda76f54f5nh rw_enter(&sdp_transport_lock, RW_READER);
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning if ((send_enable == 1) &&
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning (sdp_transport_handle == NULL) &&
09cb82ca24006b806e9f17e2135eef96364facfenh (priv == B_TRUE)) {
74e20cfe817b82802b16fac8690dadcda76f54f5nh /* Initialize sdpib transport driver */
74e20cfe817b82802b16fac8690dadcda76f54f5nh rw_exit(&sdp_transport_lock);
74e20cfe817b82802b16fac8690dadcda76f54f5nh ret = sdp_open_sdpib_driver();
74e20cfe817b82802b16fac8690dadcda76f54f5nh rw_enter(&sdp_transport_lock,
74e20cfe817b82802b16fac8690dadcda76f54f5nh RW_READER);
74e20cfe817b82802b16fac8690dadcda76f54f5nh if (ret != 0) {
74e20cfe817b82802b16fac8690dadcda76f54f5nh /* Transport failed to load */
74e20cfe817b82802b16fac8690dadcda76f54f5nh rw_exit(&sdp_transport_lock);
74e20cfe817b82802b16fac8690dadcda76f54f5nh enable = 0;
74e20cfe817b82802b16fac8690dadcda76f54f5nh goto done;
74e20cfe817b82802b16fac8690dadcda76f54f5nh }
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning (void) ldi_ioctl(sdp_transport_handle,
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning iocp->ioc_cmd, (intptr_t)&send_enable,
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning FKIOCTL, CRED(), (int *)&enable);
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning } else if (sdp_transport_handle != NULL) {
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning (void) ldi_ioctl(sdp_transport_handle,
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning iocp->ioc_cmd, (intptr_t)&send_enable,
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning FKIOCTL, CRED(), (int *)&enable);
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning if (send_enable == 0 && priv == B_TRUE) {
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning (void) ldi_close(sdp_transport_handle,
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning FNDELAY, kcred);
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning sdp_transport_handle = NULL;
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning }
74e20cfe817b82802b16fac8690dadcda76f54f5nh } else {
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning enable = 0;
74e20cfe817b82802b16fac8690dadcda76f54f5nh }
74e20cfe817b82802b16fac8690dadcda76f54f5nh rw_exit(&sdp_transport_lock);
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nhdone:
74e20cfe817b82802b16fac8690dadcda76f54f5nh bcopy(&enable, mp->b_cont->b_rptr, sizeof (int));
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nh /* ACK the ioctl */
74e20cfe817b82802b16fac8690dadcda76f54f5nh mp->b_datap->db_type = M_IOCACK;
74e20cfe817b82802b16fac8690dadcda76f54f5nh iocp->ioc_count = sizeof (int);
74e20cfe817b82802b16fac8690dadcda76f54f5nh qreply(q, mp);
74e20cfe817b82802b16fac8690dadcda76f54f5nh break;
74e20cfe817b82802b16fac8690dadcda76f54f5nh default:
74e20cfe817b82802b16fac8690dadcda76f54f5nh miocnak(q, mp, 0, ENOTSUP);
74e20cfe817b82802b16fac8690dadcda76f54f5nh }
74e20cfe817b82802b16fac8690dadcda76f54f5nh}
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nh/*
74e20cfe817b82802b16fac8690dadcda76f54f5nh * Received a put from sockfs. We only support ndd get/set
74e20cfe817b82802b16fac8690dadcda76f54f5nh */
74e20cfe817b82802b16fac8690dadcda76f54f5nhstatic void
74e20cfe817b82802b16fac8690dadcda76f54f5nhsdp_gen_wput(queue_t *q, mblk_t *mp)
74e20cfe817b82802b16fac8690dadcda76f54f5nh{
74e20cfe817b82802b16fac8690dadcda76f54f5nh switch (mp->b_datap->db_type) {
09cb82ca24006b806e9f17e2135eef96364facfenh case M_IOCTL:
09cb82ca24006b806e9f17e2135eef96364facfenh sdp_gen_ioctl(q, mp);
09cb82ca24006b806e9f17e2135eef96364facfenh break;
09cb82ca24006b806e9f17e2135eef96364facfenh case M_FLUSH:
09cb82ca24006b806e9f17e2135eef96364facfenh *mp->b_rptr &= ~FLUSHW;
09cb82ca24006b806e9f17e2135eef96364facfenh if (*mp->b_rptr & FLUSHR)
09cb82ca24006b806e9f17e2135eef96364facfenh qreply(q, mp);
09cb82ca24006b806e9f17e2135eef96364facfenh else
09cb82ca24006b806e9f17e2135eef96364facfenh freemsg(mp);
09cb82ca24006b806e9f17e2135eef96364facfenh break;
09cb82ca24006b806e9f17e2135eef96364facfenh default:
09cb82ca24006b806e9f17e2135eef96364facfenh freemsg(mp);
09cb82ca24006b806e9f17e2135eef96364facfenh return;
74e20cfe817b82802b16fac8690dadcda76f54f5nh }
74e20cfe817b82802b16fac8690dadcda76f54f5nh}
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nhstatic struct module_info info = {
74e20cfe817b82802b16fac8690dadcda76f54f5nh 0, "sdp", 1, INFPSZ, 65536, 1024
74e20cfe817b82802b16fac8690dadcda76f54f5nh};
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nhstatic struct qinit rinit = {
74e20cfe817b82802b16fac8690dadcda76f54f5nh NULL, (pfi_t)NULL, (pfi_t)sdp_gen_open, (pfi_t)sdp_gen_close, NULL,
74e20cfe817b82802b16fac8690dadcda76f54f5nh &info, NULL, NULL, NULL, STRUIOT_NONE
74e20cfe817b82802b16fac8690dadcda76f54f5nh};
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nhstatic struct qinit winit = {
74e20cfe817b82802b16fac8690dadcda76f54f5nh (pfi_t)sdp_gen_wput, NULL, (pfi_t)sdp_gen_open, (pfi_t)sdp_gen_close,
74e20cfe817b82802b16fac8690dadcda76f54f5nh NULL, &info, NULL, NULL, NULL, STRUIOT_NONE
74e20cfe817b82802b16fac8690dadcda76f54f5nh};
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nhstruct streamtab sdpinfo = {
74e20cfe817b82802b16fac8690dadcda76f54f5nh &rinit, &winit, NULL, NULL
74e20cfe817b82802b16fac8690dadcda76f54f5nh};
74e20cfe817b82802b16fac8690dadcda76f54f5nh
09cb82ca24006b806e9f17e2135eef96364facfenhDDI_DEFINE_STREAM_OPS(sdp_devops, nulldev, nulldev, sdp_gen_attach,
193974072f41a843678abf5f61979c748687e66bSherry Moore sdp_gen_detach, nodev, NULL, D_MP, &sdpinfo, ddi_quiesce_not_needed);
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nh/*
74e20cfe817b82802b16fac8690dadcda76f54f5nh * Module linkage information for the kernel.
74e20cfe817b82802b16fac8690dadcda76f54f5nh */
74e20cfe817b82802b16fac8690dadcda76f54f5nhstatic struct modldrv modldrv = {
74e20cfe817b82802b16fac8690dadcda76f54f5nh &mod_driverops,
74e20cfe817b82802b16fac8690dadcda76f54f5nh SDP_DEVDESC,
74e20cfe817b82802b16fac8690dadcda76f54f5nh &sdp_devops
74e20cfe817b82802b16fac8690dadcda76f54f5nh};
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nhstatic struct modlinkage modlinkage = {
74e20cfe817b82802b16fac8690dadcda76f54f5nh MODREV_1,
74e20cfe817b82802b16fac8690dadcda76f54f5nh &modldrv,
74e20cfe817b82802b16fac8690dadcda76f54f5nh NULL
74e20cfe817b82802b16fac8690dadcda76f54f5nh};
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nhint
74e20cfe817b82802b16fac8690dadcda76f54f5nh_init(void)
74e20cfe817b82802b16fac8690dadcda76f54f5nh{
74e20cfe817b82802b16fac8690dadcda76f54f5nh int ret;
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nh ret = mod_install(&modlinkage);
74e20cfe817b82802b16fac8690dadcda76f54f5nh if (ret != 0)
74e20cfe817b82802b16fac8690dadcda76f54f5nh goto done;
74e20cfe817b82802b16fac8690dadcda76f54f5nh ret = ldi_ident_from_mod(&modlinkage, &sdp_li);
74e20cfe817b82802b16fac8690dadcda76f54f5nh if (ret != 0)
74e20cfe817b82802b16fac8690dadcda76f54f5nh sdp_li = NULL;
74e20cfe817b82802b16fac8690dadcda76f54f5nhdone:
74e20cfe817b82802b16fac8690dadcda76f54f5nh return (ret);
74e20cfe817b82802b16fac8690dadcda76f54f5nh}
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nhint
74e20cfe817b82802b16fac8690dadcda76f54f5nh_fini(void)
74e20cfe817b82802b16fac8690dadcda76f54f5nh{
74e20cfe817b82802b16fac8690dadcda76f54f5nh int ret;
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nh ret = mod_remove(&modlinkage);
74e20cfe817b82802b16fac8690dadcda76f54f5nh if (ret != 0) {
74e20cfe817b82802b16fac8690dadcda76f54f5nh return (ret);
74e20cfe817b82802b16fac8690dadcda76f54f5nh }
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nh ldi_ident_release(sdp_li);
74e20cfe817b82802b16fac8690dadcda76f54f5nh return (0);
74e20cfe817b82802b16fac8690dadcda76f54f5nh}
74e20cfe817b82802b16fac8690dadcda76f54f5nh
74e20cfe817b82802b16fac8690dadcda76f54f5nhint
74e20cfe817b82802b16fac8690dadcda76f54f5nh_info(struct modinfo *modinfop)
74e20cfe817b82802b16fac8690dadcda76f54f5nh{
74e20cfe817b82802b16fac8690dadcda76f54f5nh return (mod_info(&modlinkage, modinfop));
74e20cfe817b82802b16fac8690dadcda76f54f5nh}