1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 #ifndef _DS_IMPL_H
  27 #define _DS_IMPL_H
  28 
  29 #pragma ident   "%Z%%M% %I%     %E% SMI"
  30 
  31 #include <dlfcn.h>
  32 #include <libnvpair.h>
  33 #include <sys/types.h>
  34 
  35 #ifdef  __cplusplus
  36 extern "C" {
  37 #endif
  38 
  39 struct disk_status;
  40 
  41 typedef struct ds_transport {
  42         void            *(*dt_open)(struct disk_status *);
  43         void            (*dt_close)(void *);
  44         int             (*dt_scan)(void *);
  45 } ds_transport_t;
  46 
  47 struct disk_status {
  48         char                    *ds_path;       /* path to device */
  49         int                     ds_fd;          /* device file descriptor */
  50         ds_transport_t          *ds_transport;  /* associated transport */
  51         void                    *ds_data;       /* transport-specific data */
  52         int                     ds_faults;      /* mask of current faults */
  53         nvlist_t                *ds_overtemp;   /* overtemp */
  54         nvlist_t                *ds_predfail;   /* predict fail */
  55         nvlist_t                *ds_testfail;   /* self test fail */
  56         int                     ds_error;       /* last error */
  57         nvlist_t                *ds_state;      /* protocol state */
  58 };
  59 
  60 #define DS_FAULT_OVERTEMP       0x1
  61 #define DS_FAULT_PREDFAIL       0x2
  62 #define DS_FAULT_TESTFAIL       0x4
  63 
  64 extern void dprintf(const char *, ...);
  65 extern void ddump(const char *, const void *, size_t);
  66 extern boolean_t ds_debug;
  67 
  68 extern int ds_set_errno(struct disk_status *, int);
  69 
  70 #ifdef  __cplusplus
  71 }
  72 #endif
  73 
  74 #endif  /* _DS_IMPL_H */