fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _DSW_
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/types.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/ksynch.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/kmem.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/errno.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/conf.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/cmn_err.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/modctl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/cred.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/file.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/ddi.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/unistat/spcs_s.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/dkio.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DS_DDICT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "../contract.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/nsctl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/nsvers.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/sdt.h> /* dtrace is S10 or later */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "dsw.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "dsw_dev.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DIDINIT 0x01
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DIDNODES 0x02
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int iiopen(dev_t *devp, int flag, int otyp, cred_t *crp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int iiclose(dev_t dev, int flag, int otyp, cred_t *crp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int iiprint(dev_t dev, char *str);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int iiioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *crp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int *rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int iiprobe(dev_info_t *dip);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int iiattach(dev_info_t *dip, ddi_attach_cmd_t cmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int iidetach(dev_info_t *dip, ddi_detach_cmd_t cmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int iistrat(struct buf *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int iiread();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic kstat_t *ii_gkstat = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiigkstat_t iigkstat = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "ii_debug", KSTAT_DATA_ULONG },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "ii_bitmap", KSTAT_DATA_ULONG },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "ii_throttle_unit", KSTAT_DATA_ULONG },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "ii_throttle_delay", KSTAT_DATA_ULONG },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "ii_copy_direct", KSTAT_DATA_ULONG },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "num-sets", KSTAT_DATA_ULONG },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "assoc-over", KSTAT_DATA_ULONG },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "spilled-over", KSTAT_DATA_ULONG },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic struct cb_ops ii_cb_ops = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iiopen,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iiclose,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iistrat, /* dummy strategy */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iiprint,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nodev, /* no dump */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iiread, /* dummy read */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nodev, /* no write */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iiioctl,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nodev, /* no devmap */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nodev, /* no mmap */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nodev, /* no segmap */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nochpoll,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_prop_op,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, /* not STREAMS */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte D_NEW | D_MP
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic struct dev_ops ii_ops = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEVO_REV,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nodev, /* no getinfo */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nulldev,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iiprobe,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iiattach,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iidetach,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nodev, /* no reset */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &ii_cb_ops,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (struct bus_ops *)NULL
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic struct modldrv ii_ldrv = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &mod_driverops,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "nws:Point-in-Time:" ISS_VERSION_STR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &ii_ops
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic struct modlinkage ii_modlinkage = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MODREV_1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &ii_ldrv,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct ii_state {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev_info_t *dip;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int instance;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* used for logging sysevent, gets set in _ii_attach */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedev_info_t *ii_dip = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern _ii_info_t *_ii_info_top;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern _ii_lsthead_t *_ii_cluster_top;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern _ii_lsthead_t *_ii_group_top;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern kmutex_t _ii_cluster_mutex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern kmutex_t _ii_group_mutex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int dsw_major_rev = ISS_VERSION_MAJ; /* Major release number */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int dsw_minor_rev = ISS_VERSION_MIN; /* Minor release number */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int dsw_micro_rev = ISS_VERSION_MIC; /* Micro release number */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int dsw_baseline_rev = ISS_VERSION_NUM; /* Baseline revision */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void *ii_statep;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_init_dev();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void _ii_deinit_dev();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_config(intptr_t arg, int ilp32, int *rvp, int iflags);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_disable(intptr_t arg, int ilp32, int *rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_suspend(intptr_t arg, int ilp32, int *rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_bitmap(intptr_t arg, int ilp32, int *rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_segment(intptr_t arg, int ilp32, int *rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_abort(intptr_t arg, int ilp32, int *rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_acopy(intptr_t arg, int ilp32, int *rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_copy(intptr_t arg, int ilp32, int *rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_shutdown(intptr_t arg, int *rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_stat(intptr_t arg, int ilp32, int *rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_version(intptr_t arg, int ilp32, int *rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_wait(intptr_t arg, int ilp32, int *rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_reset(intptr_t arg, int ilp32, int *rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_offline(intptr_t arg, int ilp32, int *rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_list(intptr_t arg, int ilp32, int *rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_listlen(int cmd, int ilp32, int *rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_export(intptr_t arg, int ilp32, int *rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_join(intptr_t arg, int ilp32, int *rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_copyparm(intptr_t arg, int ilp32, int *rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_ocreate(intptr_t arg, int ilp32, int *rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_oattach(intptr_t arg, int ilp32, int *rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_odetach(intptr_t arg, int ilp32, int *rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_olist(intptr_t arg, int ilp32, int *rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_ostat(intptr_t arg, int ilp32, int *rvp, int is_iost_2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_bitsset(intptr_t arg, int ilp32, int cmd, int *rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_gc_list(intptr_t, int, int *, kmutex_t *, _ii_lsthead_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_clist(intptr_t arg, int ilp32, int *rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_move_grp(intptr_t arg, int ilp32, int *rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _ii_change_tag(intptr_t arg, int ilp32, int *rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int ii_debug;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int ii_throttle_unit;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int ii_throttle_delay;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int ii_copy_direct;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int ii_bitmap;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_init(void)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int error;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error = ddi_soft_state_init(&ii_statep, sizeof (struct ii_state), 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!error) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error = mod_install(&ii_modlinkage);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (error)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_soft_state_fini(&ii_statep);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (error);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_fini(void)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int error;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error = mod_remove(&ii_modlinkage);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!error)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_soft_state_fini(&ii_statep);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (error);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_info(struct modinfo *modinfop)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = mod_info(&ii_modlinkage, modinfop);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiiprobe(dev_info_t *dip)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DDI_PROBE_SUCCESS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteii_stats_update(kstat_t *ksp, int rw)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (KSTAT_WRITE == rw) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EACCES);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We do nothing here for now -- the kstat structure is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * updated in-place
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteii_create_kstats()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* create global info structure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!ii_gkstat) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ii_gkstat = kstat_create("ii", 0, "global", "StorEdge",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KSTAT_TYPE_NAMED,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (iigkstat) / sizeof (kstat_named_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KSTAT_FLAG_VIRTUAL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ii_gkstat) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ii_gkstat->ks_data = &iigkstat;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ii_gkstat->ks_update = ii_stats_update;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ii_gkstat->ks_private = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_install(ii_gkstat);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* fill in immutable values */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iigkstat.ii_debug.value.ul = ii_debug;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iigkstat.ii_bitmap.value.ul = ii_bitmap;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iigkstat.ii_throttle_unit.value.ul = ii_throttle_unit;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iigkstat.ii_throttle_delay.value.ul =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ii_throttle_delay;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iigkstat.ii_copy_direct.value.ul = ii_copy_direct;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!Unable to create II global stats");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiiattach(dev_info_t *dip, ddi_attach_cmd_t cmd)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct ii_state *xsp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int instance;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte intptr_t flags;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd != DDI_ATTACH) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DDI_FAILURE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save the dev_info_t to be used in logging using ddi_log_sysevent */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ii_dip = dip;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte instance = ddi_get_instance(dip);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_soft_state_zalloc(ii_statep, instance) != 0) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!ii: no memory for instance %d state.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DDI_FAILURE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte flags = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xsp = ddi_get_soft_state(ii_statep, instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xsp == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_WARN,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!ii: attach: could not get state for instance %d.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto out;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ii_debug = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "ii_debug", 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ii_debug != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!ii: initializing ii version %d.%d.%d.%d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dsw_major_rev, dsw_minor_rev,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dsw_micro_rev, dsw_baseline_rev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dsw_micro_rev) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!ii: initializing ii vers %d.%d.%d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dsw_major_rev, dsw_minor_rev, dsw_micro_rev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!ii: initializing ii version %d.%d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dsw_major_rev, dsw_minor_rev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (ii_debug) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 1:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 2: cmn_err(CE_NOTE,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!ii: ii_debug=%d is enabled.", ii_debug);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_WARN,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!ii: Value of ii_debug=%d is not 0,1 or 2.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ii_debug);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ii_bitmap = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "ii_bitmap", II_WTHRU);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (ii_bitmap) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case II_KMEM:
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana if (ii_debug > 0)
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!ii: ii_bitmap is in memory");
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case II_FWC:
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana if (ii_debug > 0)
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!ii: ii_bitmap is on disk,"
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana " no FWC");
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case II_WTHRU:
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana if (ii_debug > 0)
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!ii: ii_bitmap is on disk");
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!ii: ii_bitmap=%d out of range; "
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "defaulting WTHRU(%d)", ii_bitmap, II_WTHRU);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana ii_bitmap = II_WTHRU;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* pick up these values if in ii.conf, otherwise leave alone */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "ii_throttle_unit", 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ii_throttle_unit = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ii_throttle_unit < MIN_THROTTLE_UNIT) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ii_throttle_unit > MAX_THROTTLE_UNIT) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ii_debug > 0))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_NOTE,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!ii: ii_throttle_unit=%d", ii_throttle_unit);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "ii_throttle_delay", 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ii_throttle_delay = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ii_throttle_delay < MIN_THROTTLE_DELAY) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ii_throttle_delay > MIN_THROTTLE_DELAY) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ii_debug > 0))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_NOTE,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!ii: ii_throttle_delay=%d", ii_throttle_delay);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ii_copy_direct = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "ii_copy_direct", 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ii_copy_direct = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ii_copy_direct < 0) || (ii_copy_direct > 1))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_NOTE,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!ii: ii_copy_direct=%d", ii_copy_direct);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (_ii_init_dev()) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!ii: _ii_init_dev failed");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto out;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte flags |= DIDINIT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xsp->dip = dip;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xsp->instance = instance;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_create_minor_node(dip, "ii", S_IFCHR, instance, DDI_PSEUDO, 0)
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana != DDI_SUCCESS) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!ii: could not create node.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto out;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte flags |= DIDNODES;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_set_driver_private(dip, (caddr_t)flags);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_report_dev(dip);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ii_create_kstats();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DDI_SUCCESS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteout:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_set_driver_private(dip, (caddr_t)flags);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) iidetach(dip, DDI_DETACH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DDI_FAILURE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiidetach(dev_info_t *dip, ddi_detach_cmd_t cmd)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct ii_state *xsp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int instance;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte intptr_t flags;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd != DDI_DETACH) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DDI_FAILURE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (_ii_info_top) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DDI_FAILURE); /* busy */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte instance = ddi_get_instance(dip);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xsp = ddi_get_soft_state(ii_statep, instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xsp == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_WARN,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!ii: detach: could not get state for instance %d.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DDI_FAILURE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte flags = (intptr_t)ddi_get_driver_private(dip);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (flags & DIDNODES)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_remove_minor_node(dip, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (flags & DIDINIT)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _ii_deinit_dev();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_soft_state_free(ii_statep, instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ii_gkstat) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_delete(ii_gkstat);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ii_gkstat = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DDI_SUCCESS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiiopen(dev_t *devp, int flag, int otyp, cred_t *crp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int error;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error = drv_priv(crp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (error);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiiclose(dev_t dev, int flag, int otyp, cred_t *crp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiiprint(dev_t dev, char *str)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int instance = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!ii%d: %s", instance, str);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiiioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *crp, int *rvp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ilp32;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ilp32 = (ddi_model_convert_from(mode & FMODELS) == DDI_MODEL_ILP32);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (cmd) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_WAIT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_wait(arg, ilp32, rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_RESET:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_reset(arg, ilp32, rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_VERSION:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_version(arg, ilp32, rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_ENABLE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_config(arg, ilp32, rvp, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_RESUME:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_config(arg, ilp32, rvp, II_EXISTING);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_DISABLE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_disable(arg, ilp32, rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_SUSPEND:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_suspend(arg, ilp32, rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_ACOPY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_acopy(arg, ilp32, rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_COPY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_copy(arg, ilp32, rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_SHUTDOWN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_shutdown(arg, rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_STAT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_stat(arg, ilp32, rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_BITMAP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_bitmap(arg, ilp32, rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_SEGMENT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_segment(arg, ilp32, rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_ABORT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_abort(arg, ilp32, rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_OFFLINE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_offline(arg, ilp32, rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_LIST:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_list(arg, ilp32, rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_LISTLEN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_OLISTLEN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_listlen(cmd, ilp32, rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_EXPORT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_export(arg, ilp32, rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_IMPORT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_config(arg, ilp32, rvp, II_IMPORT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_JOIN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_join(arg, ilp32, rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_COPYP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_copyparm(arg, ilp32, rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_OCREAT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_ocreate(arg, ilp32, rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_OATTACH:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_oattach(arg, ilp32, rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_ODETACH:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_odetach(arg, ilp32, rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_OLIST:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_olist(arg, ilp32, rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_OSTAT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_ostat(arg, ilp32, rvp, FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_OSTAT2:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_ostat(arg, ilp32, rvp, TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_SBITSSET:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_CBITSSET:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_bitsset(arg, ilp32, cmd, rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_CLIST:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_gc_list(arg, ilp32, rvp, &_ii_cluster_mutex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _ii_cluster_top);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_GLIST:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_gc_list(arg, ilp32, rvp, &_ii_group_mutex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _ii_group_top);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_MOVEGRP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_move_grp(arg, ilp32, rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DSWIOC_CHANGETAG:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _ii_change_tag(arg, ilp32, rvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = EINVAL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * dummy function
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiistrat(struct buf *bp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bp->b_error = EIO;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte biodone(bp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiiread()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EIO);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}