fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
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 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
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 * CDDL HEADER END
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A global variable to set the threshold for large writes to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * be in write through mode when NVRAM is present. This should
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * solve the NVRAM bandwidth problem.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define REGISTER_SVC(X, Y) (ncall_register_svc(X, Y))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define UNREGISTER_SVC(X) (ncall_unregister_svc(X))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int sdbcunload(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int sdbcload(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int sdbcopen(dev_t *devp, int flag, int otyp, cred_t *crp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int sdbcclose(dev_t dev, int flag, int otyp, cred_t *crp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int sdbcioctl(dev_t dev, int cmd, void *arg, int mode, cred_t *crp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int _sdbc_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int _sdbc_attach(dev_info_t *, ddi_attach_cmd_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int _sdbc_detach(dev_info_t *, ddi_detach_cmd_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int _sdbc_reset(dev_info_t *, ddi_reset_cmd_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Solaris specific driver module interface code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev_info_t *dip; /* everyone would need a devinfo */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void *sdbc_statep; /* for soft state routines */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* USES_SOFT_STATE */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nodev, /* not a block driver, strategy not an entry point */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* not a STREAMS driver, no cb_str routine */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte D_NEW | D_MP, /* safe for multi-thread/multi-processor */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* device reference count */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * dynmem interface
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Solaris module load time code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_soft_state_init(&sdbc_statep, sizeof (struct sdbc_state),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* USES_SOFT_STATE */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * It is "load" time, call the unixware equivalent.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* USES_SOFT_STATE */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&dynmem_processing_dm.thread_dm_lock, "dynmem",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cv_init(&dynmem_processing_dm.thread_dm_cv, "dynmem",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Solaris module unload time code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (_sd_ioset &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (_sd_ioset->set_nlive || _sd_ioset->set_nthread)) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!sdbc:_fini() %d threads still "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "active; %d threads in set\n", _sd_ioset->set_nlive,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* USES_SOFT_STATE */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_destroy(&dynmem_processing_dm.thread_dm_lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Solaris module info code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Attach an instance of the device. This happens before an open
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * can succeed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_sdbc_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the threshold value for setting large writes in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * write through mode(when NVRAM is present)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_wrthru_len = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "sdbc_wrthru_thresh", 64);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get sdbc_max_fbas from sdbc.conf */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_max_fbas = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "sdbc_max_fbas",
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!_sdbc_attach: sdbc_max_fbas set to %d", _SD_MAX_FBAS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * -get the maximum list length for multipage dynmem
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * -time between aging
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * -number of agings before dealloc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * -what to report D0=shutdown, D1=thread variables
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.max_dyn_list = MAX_DYN_LIST_DEFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.cache_aging_ct1 = CACHE_AGING_CT_DEFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.cache_aging_ct2 = CACHE_AGING_CT_DEFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.cache_aging_ct3 = CACHE_AGING_CT_DEFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.cache_aging_sec1 = CACHE_AGING_SEC1_DEFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.cache_aging_sec2 = CACHE_AGING_SEC2_DEFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.cache_aging_sec3 = CACHE_AGING_SEC3_DEFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.cache_aging_pcnt1 = CACHE_AGING_PCNT1_DEFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.cache_aging_pcnt2 = CACHE_AGING_PCNT2_DEFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.max_holds_pcnt = MAX_HOLDS_PCNT_DEFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.process_directive = PROCESS_DIRECTIVE_DEFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_dm_process_vars.max_dyn_list = ddi_prop_get_int(DDI_DEV_T_ANY,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dip, DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "sdbc_max_dyn_list",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "sdbc_monitor_dynmem",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_dm_process_vars.cache_aging_ct1 = ddi_prop_get_int(DDI_DEV_T_ANY,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dip, DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "sdbc_cache_aging_ct1",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_dm_process_vars.cache_aging_ct2 = ddi_prop_get_int(DDI_DEV_T_ANY,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dip, DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "sdbc_cache_aging_ct2",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_dm_process_vars.cache_aging_ct3 = ddi_prop_get_int(DDI_DEV_T_ANY,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dip, DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "sdbc_cache_aging_ct3",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_dm_process_vars.cache_aging_sec1 = ddi_prop_get_int(DDI_DEV_T_ANY,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dip, DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "sdbc_cache_aging_sec1",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_dm_process_vars.cache_aging_sec2 = ddi_prop_get_int(DDI_DEV_T_ANY,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dip, DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "sdbc_cache_aging_sec2",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_dm_process_vars.cache_aging_sec3 = ddi_prop_get_int(DDI_DEV_T_ANY,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dip, DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "sdbc_cache_aging_sec3",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "sdbc_cache_aging_pcnt1",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "sdbc_cache_aging_pcnt2",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "sdbc_process_directive",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_dm_process_vars.max_holds_pcnt = ddi_prop_get_int(DDI_DEV_T_ANY,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dip, DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "sdbc_max_holds_pcnt",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sdbc_edit_xfer_process_vars_dm(&local_dm_process_vars);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MINOR_NAME "c,sdbc" /* character device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_create_minor_node(dip, MINOR_NAME, S_IFCHR,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana MINOR_NUMBER, DDI_PSEUDO, 0) != DDI_SUCCESS) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana /* free anything we allocated here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* MINOR_NAME */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Announce presence of the device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* mark the device as attached, opens may proceed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rw_init(&sdbc_queue_lock, NULL, RW_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_sdbc_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check first if the cache is still in use
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and if it is, prevent the detach.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_sdbc_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, void **result)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* USES_SOFT_STATE */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* The "instance" number is the minor number */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the instance number is the minor number */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* USES_SOFT_STATE */
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!sdbc(_sdbc_print) %s", s);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMOD_DRV_WRAPPER(sdbc, sdbcload, sdbcunload, NULL, "Storage Device Block Cache");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* sun */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(sdbc_version, _VERSION_, sizeof (sdbc_version));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&_sd_cache_lock, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&_sdbc_config_lock, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REGISTER_SVC(SD_REMOTE_FLUSH, r_sd_remote_flush);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REGISTER_SVC(SD_SGREMOTE_FLUSH, r_sd_sgremote_flush);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rc = hpf_register_module("SDBC", _sd_hpf_stats)) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REGISTER_SVC(SD_DISABLE, r_sd_ifs_cache_disable);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&_sd_block_lk, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Initialize the bitmap array that would be useful in determining
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if the mask is not fragmented, instead of determinig this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * at run time. Also initialize a lookup array for each mask, with
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the starting position, the length, and the mask subset
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!sdbc(sdbcunload) cannot unload module - cache in use!");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Normally we would unregister memory at deconfig time.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * However when chasing things like memory leaks it is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * useful to defer until unload time.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbcopen(dev_t *devp, int flag, int otyp, cred_t *crp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we were statically linked in then returning an error out
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of sdbcinit won't prevent someone from coming thru here.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We must prevent them from getting any further.
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!sdbc(sdbcopen) open failed, systemid (%d) must be >= %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbcclose(dev_t dev, int flag, int otyp, cred_t *crp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconvert_ioctl_args(int cmd, void *arg, int mode, _sdbc_ioctl_t *args)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * convert_ioctl-args - Do a case by case conversion of a ILP32 ioctl
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * structure to an LP64 structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The main concern here is whether to sign-extend or not. The rule
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is that pointers are not sign extended, the rest are obvious.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Since most everything is sign-extended the definition of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _sdbc_ioctl32_t uses signed fields.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyin(arg, &args32, sizeof (_sdbc_ioctl32_t), mode))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!sdbc(convert_ioctl_args) obsolete sdbc ioctl used");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg2 = (uint32_t)args32.arg2; /* NULL (buf) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg0 = (uint32_t)args32.arg0; /* fname (char *) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg0 = (uint32_t)args32.arg0; /* pointer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg0 = (uint32_t)args32.arg0; /* (int * ) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the gl_file data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* pointer to array[2*cluster_size] */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the size of the global info pages for each board */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg0 = (uint32_t)args32.arg0; /* int[CACHE_MEM_PAD] * */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the global info about write blocks */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* pointer to array[2*(sum of GLMUL_SIZES)] */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg0 = (uint32_t)args32.arg0; /* (_sd_stats_t *) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg2 = (uint32_t)args32.arg2; /* (addr[5] *) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg0 = (uint32_t)args32.arg0; /* (_sdbc_config_t *) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg0 = (uint32_t)args32.arg0; /* (_sdbc_config_t *) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg0 = (uint32_t)args32.arg0; /* (int * ) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* toggle flusher flag for testing */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->sdbc_ustatus = (spcs_s_info_t)args32.sdbc_ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte args->arg2 = args32.arg2; /* countdown to issuing error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* clear injected i/o errors */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* DEBUG */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _MULTI_DATAMODEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _MULTI_DATAMODEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* copyin the block number */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyin((void *)args->arg1, &fba_pos, sizeof (nsc_off_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_model_convert_from(mode & FMODELS) == DDI_MODEL_ILP32) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyin((void *)args->arg2, addr_32, sizeof (addr_32),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyin((void *)args->arg2, addr, sizeof (addr), mode)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else /* _MULTI_DATAMODEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyin((void *)args->arg2, addr, sizeof (addr), mode)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _MULTI_DATAMODEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) copyout(&CACHE_BLOCK_SIZE, (void *)addr[2], sizeof (int));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (_sd_get_cd_blk((int)args->arg0, FBA_TO_BLK_NUM(fba_pos),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte info.ci_dblk = BLK_TO_FBA_NUM(CENTRY_BLK(cc_ent));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) copyout(lookup_file, (void *)addr[3], NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) copyout(&info, (void *)addr[0], sizeof (sdbc_info_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) copyout(data, (void *)addr[1], CACHE_BLOCK_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the write data if any */
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!sdbc(sdbc_get_cd_blk) cc_write 0x%p sc-res 0x%p",
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!sdbc(sdbc_get_cd_blk) kmem_alloc failed."
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " cannot get write data");
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!safestore read failed");
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana "!sdbc(sdbc_get_cd_blk) copyout failed."
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " cannot get write data");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbcioctl(dev_t dev, int cmd, void *arg, int mode, cred_t *crp, int *rvp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_model_convert_from(mode & FMODELS) == DDI_MODEL_ILP32) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rc = convert_ioctl_args(cmd, arg, mode, &args)) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyin(arg, &args, sizeof (_sdbc_ioctl_t), mode)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else /* _MULTI_DATAMODEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyin(arg, &args, sizeof (_sdbc_ioctl_t), mode)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _MULTI_DATAMODEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _sdbc_configure((_sd_cache_param_t *)args.arg0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc && rc != EALREADY && rc != SDBC_ENONETMEM) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus, rc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus, rc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the gl_file data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the size of the global info pages for each board */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the global info about write blocks */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_set_hint((int)args.arg0, (uint_t)args.arg1) :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_clear_hint((int)args.arg0, (uint_t)args.arg1));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus, rc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rc = _sd_get_cd_hint((int)args.arg0, &hint)) == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = ((args.arg1) ? _sd_set_node_hint((uint_t)args.arg0) :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* FALLTHRU */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _sd_get_stats((void *)args.arg0, convert_32);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus, rc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus, 0));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus, rc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _sdbc_configure(NULL, &mgmt_config_info, kstatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus, rc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyout(&cache_version, (void *)args.arg0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* toggle flusher flag for testing */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (spcs_s_ocopyoutf(&kstatus, args.sdbc_ustatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SDBC_ETOGGLE_FLUSH, _sdbc_flush_flag ? "on" : "off"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* inject i/o errors */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = _sdbc_inject_ioerr(args.arg0, args.arg1, args.arg2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* clear injected i/o errors */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* DEBUG */
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana _sd_print(3, "!SDBC unknown ioctl: 0x%x unsupported", cmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _sd_timed_block - sleep waiting for ticks time delay.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ticks - # of ticks to sleep
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cvp - pointer to the cv we wait on while we delay.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NO spin locks can be held at entry!
d3d50737e566cade9a08d73d2af95105ac7cd960Rafael Vanoni (void) cv_reltimedwait(cvp, &_sd_block_lk, ticks, TR_CLOCK_TICK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _sd_unblock - awake a sleeper waiting on cv pointed to by cvp.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NO spin locks can be held at entry as we may sleep.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_sd_data_log(int num, _sd_cctl_t *centry, nsc_off_t st, nsc_size_t len)
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana *(int *)(centry->cc_data + FBA_SIZE(i) + 4));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _SD_FBA_DATA_LOG */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_sd_data_log_chain(int num, _sd_cctl_t *centry, nsc_off_t fba_pos,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_cblk_fba_t st_cblk_len; /* FBA len of starting cache block */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_cblk_fba_t end_cblk_len; /* FBA len of ending cache block */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_cblk_fba_t st_cblk_off; /* FBA offset into starting cblock */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (CENTRY_BLK(centry) != FBA_TO_BLK_NUM(fba_pos))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (end_cblk_len) DATA_LOG(num, centry, 0, end_cblk_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _SD_FBA_DATA_LOG */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < sdbc_max_devs; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sd_cache_stats->st_shared[i].sh_cache_write = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return the cache sizes used by the Sense Subsystem Status CCW
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * add in the total cache size and the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-volatile (battery-backed) cache size.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*PRINTFLIKE2*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_sd_get_cd_blk(int cd, nsc_off_t cblk, _sd_cctl_t **cc, caddr_t *data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *filename = _sd_cache_files[cd].cd_info->sh_filename;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * central dyn mem processing vars edit rtn.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * input a local copy and xfer to global
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sec0,sec1,sec2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * range check 1 to 255 (arbitrary but in any case must be <= 2000 due to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 32bit signed int limits in later calc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * range check 1 to 255 (only 8 bits reserved for aging ctr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_edit_xfer_process_vars_dm(_dm_process_vars_t *process_vars)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dynmem_processing_dm.max_dyn_list = process_vars->max_dyn_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no edit on monitor_dynmem_process */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no edit on process_directive */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte process_vars->cache_aging_ct1 <= CACHE_AGING_CT_MAX)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte process_vars->cache_aging_ct2 <= CACHE_AGING_CT_MAX)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte process_vars->cache_aging_ct3 <= CACHE_AGING_CT_MAX)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte process_vars->cache_aging_sec1 <= CACHE_AGING_SEC1_MAX)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte process_vars->cache_aging_sec2 <= CACHE_AGING_SEC2_MAX)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte process_vars->cache_aging_sec3 <= CACHE_AGING_SEC3_MAX)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte process_vars->cache_aging_pcnt1 <= CACHE_AGING_PCNT1_MAX)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte process_vars->cache_aging_pcnt2 <= CACHE_AGING_PCNT2_MAX)