2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#ifndef _SES_IMPL_H
2N/A#define _SES_IMPL_H
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A#include <alloca.h>
2N/A#include <errno.h>
2N/A#include <assert.h>
2N/A#include <dirent.h>
2N/A#include <dlfcn.h>
2N/A#include <limits.h>
2N/A#include <pthread.h>
2N/A#include <stdarg.h>
2N/A#include <stddef.h>
2N/A#include <stdio.h>
2N/A#include <stdlib.h>
2N/A#include <string.h>
2N/A#include <strings.h>
2N/A#include <libnvpair.h>
2N/A#include <unistd.h>
2N/A#include <sys/mman.h>
2N/A#include <sys/types.h>
2N/A#include <sys/sysmacros.h>
2N/A#include <sys/systeminfo.h>
2N/A
2N/A#include <scsi/libscsi.h>
2N/A#include <scsi/libses_plugin.h>
2N/A#include <scsi/plugins/ses/framework/ses2_impl.h>
2N/A
2N/A#define LIBSES_ERRMSGLEN 512
2N/A
2N/A#define LIBSES_DEFAULT_PLUGINDIR "/usr/lib/scsi/plugins/ses"
2N/A#define LIBSES_PLUGIN_FRAMEWORK "framework"
2N/A#define LIBSES_PLUGIN_VENDOR "vendor"
2N/A
2N/A#define LIBSES_PLUGIN_EXT ".so"
2N/A
2N/Astruct ses_plugin {
2N/A struct ses_plugin *sp_next; /* next plugin in list */
2N/A struct ses_plugin *sp_prev; /* previous plugin in list */
2N/A uint64_t sp_priority; /* plugin priority */
2N/A struct ses_target *sp_target; /* corresponding target */
2N/A void *sp_object; /* shared object */
2N/A void *sp_data; /* module-specific data */
2N/A boolean_t sp_initialized; /* successfully initialized */
2N/A ses_pagedesc_t *sp_pages; /* pages */
2N/A int (*sp_init)(ses_plugin_t *); /* plugin init */
2N/A void (*sp_fini)(ses_plugin_t *); /* plugin fini */
2N/A int (*sp_node_parse)(ses_plugin_t *, ses_node_t *); /* parse node */
2N/A int (*sp_node_ctl)(ses_plugin_t *, ses_node_t *, const char *,
2N/A nvlist_t *); /* node control */
2N/A int (*sp_node_type_known)(ses_plugin_t *, ses_node_t *);
2N/A /* check if the type of a node is known to the plugin */
2N/A};
2N/A
2N/Astruct ses_target {
2N/A libscsi_hdl_t *st_scsi_hdl;
2N/A libscsi_target_t *st_target;
2N/A struct ses_plugin *st_plugin_first;
2N/A struct ses_plugin *st_plugin_last;
2N/A struct ses_snap *st_snapshots;
2N/A boolean_t st_closescsi;
2N/A boolean_t st_truncate;
2N/A pthread_mutex_t st_lock;
2N/A};
2N/A
2N/A/*
2N/A * Maximum number of snapshot retries triggered by generation count changes
2N/A */
2N/A#define LIBSES_MAX_GC_RETRIES 10
2N/A
2N/A/*
2N/A * Maximum number of Enclosure Busy retries
2N/A */
2N/A#define LIBSES_MAX_BUSY_RETRIES 3
2N/A
2N/Atypedef struct ses_snap_page {
2N/A ses2_diag_page_t ssp_num;
2N/A boolean_t ssp_control;
2N/A boolean_t ssp_initialized;
2N/A size_t ssp_alloc;
2N/A size_t ssp_len;
2N/A void *ssp_page;
2N/A char *ssp_mmap_base;
2N/A size_t ssp_mmap_len;
2N/A struct ses_snap_page *ssp_next;
2N/A struct ses_snap_page *ssp_unique;
2N/A} ses_snap_page_t;
2N/A
2N/Astruct ses_snap {
2N/A struct ses_target *ss_target;
2N/A uint32_t ss_generation;
2N/A hrtime_t ss_time;
2N/A struct ses_node *ss_root;
2N/A size_t ss_n_elem;
2N/A ses_snap_page_t *ss_pages;
2N/A size_t ss_n_nodes;
2N/A struct ses_node **ss_nodes;
2N/A struct ses_snap *ss_next;
2N/A struct ses_snap *ss_prev;
2N/A uint32_t ss_refcnt;
2N/A};
2N/A
2N/Astruct ses_node {
2N/A ses_node_type_t sn_type;
2N/A uint64_t sn_rootidx; /* Relative index for enclosure/aggregate */
2N/A size_t sn_id; /* Unique global ID */
2N/A uint64_t sn_enc_num;
2N/A struct ses_snap *sn_snapshot;
2N/A struct ses_node *sn_parent;
2N/A struct ses_node *sn_next_sibling;
2N/A struct ses_node *sn_prev_sibling;
2N/A struct ses_node *sn_first_child;
2N/A struct ses_node *sn_last_child;
2N/A nvlist_t *sn_props;
2N/A};
2N/A
2N/Aextern int ses_fill_snap(ses_snap_t *);
2N/Aextern void ses_node_teardown(ses_node_t *);
2N/Aextern ses_snap_page_t *ses_snap_find_page(ses_snap_t *, ses2_diag_page_t,
2N/A boolean_t);
2N/Aextern ses_snap_page_t *ses_snap_ctl_page(ses_snap_t *,
2N/A ses2_diag_page_t, size_t, boolean_t);
2N/Aextern int ses_snap_do_ctl(ses_snap_t *);
2N/A
2N/Aextern int ses_libscsi_error(libscsi_hdl_t *, const char *, ...);
2N/Aextern int ses_scsi_error(libscsi_action_t *, const char *, ...);
2N/A
2N/Aextern int ses_plugin_load(ses_target_t *);
2N/Aextern void ses_plugin_unload(ses_target_t *);
2N/A
2N/Aextern ses_pagedesc_t *ses_get_pagedesc(ses_target_t *, int, ses_pagetype_t,
2N/A ses_node_t *);
2N/Aextern int ses_fill_node(ses_node_t *);
2N/A
2N/Aextern int enc_parse_ed(ses2_ed_impl_t *, nvlist_t *);
2N/Aextern int enc_parse_td(ses2_td_hdr_impl_t *, const char *, nvlist_t *);
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _SES_IMPL_H */