The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/cam/scsi/scsi_enc_internal.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 2000 Matthew Jacob
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions, and the following disclaimer,
   10  *    without modification, immediately at the beginning of the file.
   11  * 2. The name of the author may not be used to endorse or promote products
   12  *    derived from this software without specific prior written permission.
   13  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   17  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
   18  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   24  * SUCH DAMAGE.
   25  *
   26  * $FreeBSD: releng/10.4/sys/cam/scsi/scsi_enc_internal.h 260387 2014-01-07 01:51:48Z scottl $
   27  */
   28 
   29 /*
   30  * This file contains definitions only intended for use within
   31  * sys/cam/scsi/scsi_enc*.c, and not in other kernel components.
   32  */
   33 
   34 #ifndef __SCSI_ENC_INTERNAL_H__
   35 #define __SCSI_ENC_INTERNAL_H__
   36 
   37 typedef struct enc_element {
   38         uint32_t
   39                  enctype        : 8,    /* enclosure type */
   40                  subenclosure : 8,      /* subenclosure id */
   41                  svalid : 1,            /* enclosure information valid */
   42                  overall_status_elem: 1,/*
   43                                          * This object represents generic
   44                                          * status about all objects of this
   45                                          * type.
   46                                          */
   47                  priv   : 14;           /* private data, per object */
   48         uint8_t  encstat[4];            /* state && stats */
   49         uint8_t *physical_path;         /* Device physical path data. */
   50         u_int    physical_path_len;     /* Length of device path data. */
   51         void    *elm_private;           /* per-type object data */
   52 } enc_element_t;
   53 
   54 typedef enum {
   55         ENC_NONE,
   56         ENC_SES_SCSI2,
   57         ENC_SES,
   58         ENC_SES_PASSTHROUGH,
   59         ENC_SEN,
   60         ENC_SAFT,
   61         ENC_SEMB_SES,
   62         ENC_SEMB_SAFT
   63 } enctyp;
   64 
   65 /* Platform Independent Driver Internal Definitions for enclosure devices. */
   66 typedef struct enc_softc enc_softc_t;
   67 
   68 struct enc_fsm_state;
   69 typedef int fsm_fill_handler_t(enc_softc_t *ssc,
   70                                 struct enc_fsm_state *state,
   71                                 union ccb *ccb,
   72                                 uint8_t *buf);
   73 typedef int fsm_error_handler_t(union ccb *ccb, uint32_t cflags,
   74                                 uint32_t sflags);
   75 typedef int fsm_done_handler_t(enc_softc_t *ssc,
   76                                struct enc_fsm_state *state, union ccb *ccb,
   77                                uint8_t **bufp, int error, int xfer_len);
   78 
   79 struct enc_fsm_state {
   80         const char          *name;
   81         int                  page_code;
   82         size_t               buf_size;
   83         uint32_t             timeout;
   84         fsm_fill_handler_t  *fill;
   85         fsm_done_handler_t  *done;
   86         fsm_error_handler_t *error;
   87 };
   88 
   89 typedef int (enc_softc_init_t)(enc_softc_t *);
   90 typedef void (enc_softc_invalidate_t)(enc_softc_t *);
   91 typedef void (enc_softc_cleanup_t)(enc_softc_t *);
   92 typedef int (enc_init_enc_t)(enc_softc_t *); 
   93 typedef int (enc_get_enc_status_t)(enc_softc_t *, int);
   94 typedef int (enc_set_enc_status_t)(enc_softc_t *, encioc_enc_status_t, int);
   95 typedef int (enc_get_elm_status_t)(enc_softc_t *, encioc_elm_status_t *, int);
   96 typedef int (enc_set_elm_status_t)(enc_softc_t *, encioc_elm_status_t *, int);
   97 typedef int (enc_get_elm_desc_t)(enc_softc_t *, encioc_elm_desc_t *); 
   98 typedef int (enc_get_elm_devnames_t)(enc_softc_t *, encioc_elm_devnames_t *); 
   99 typedef int (enc_handle_string_t)(enc_softc_t *, encioc_string_t *, int);
  100 typedef void (enc_device_found_t)(enc_softc_t *);
  101 typedef void (enc_poll_status_t)(enc_softc_t *);
  102 
  103 struct enc_vec {
  104         enc_softc_invalidate_t  *softc_invalidate;
  105         enc_softc_cleanup_t     *softc_cleanup;
  106         enc_init_enc_t          *init_enc;
  107         enc_get_enc_status_t    *get_enc_status;
  108         enc_set_enc_status_t    *set_enc_status;
  109         enc_get_elm_status_t    *get_elm_status;
  110         enc_set_elm_status_t    *set_elm_status;
  111         enc_get_elm_desc_t      *get_elm_desc;
  112         enc_get_elm_devnames_t  *get_elm_devnames;
  113         enc_handle_string_t     *handle_string;
  114         enc_device_found_t      *device_found;
  115         enc_poll_status_t       *poll_status;
  116 };
  117 
  118 typedef struct enc_cache {
  119         enc_element_t           *elm_map;       /* objects */
  120         int                      nelms;         /* number of objects */
  121         encioc_enc_status_t      enc_status;    /* overall status */
  122         void                    *private;       /* per-type private data */
  123 } enc_cache_t;
  124 
  125 /* Enclosure instance toplevel structure */
  126 struct enc_softc {
  127         enctyp                   enc_type;      /* type of enclosure */
  128         struct enc_vec           enc_vec;       /* vector to handlers */
  129         void                    *enc_private;   /* per-type private data */
  130 
  131         /**
  132          * "Published" configuration and state data available to
  133          * external consumers.
  134          */
  135         enc_cache_t              enc_cache;
  136 
  137         /**
  138          * Configuration and state data being actively updated
  139          * by the enclosure daemon.
  140          */
  141         enc_cache_t              enc_daemon_cache;
  142 
  143         struct sx                enc_cache_lock;
  144         uint8_t                  enc_flags;
  145 #define ENC_FLAG_INVALID        0x01
  146 #define ENC_FLAG_INITIALIZED    0x02
  147 #define ENC_FLAG_SHUTDOWN       0x04
  148         union ccb                saved_ccb;
  149         struct cdev             *enc_dev;
  150         struct cam_periph       *periph;
  151         int                      open_count;
  152 
  153         /* Bitmap of pending operations. */
  154         uint32_t                 pending_actions;
  155 
  156         /* The action on which the state machine is currently working. */
  157         uint32_t                 current_action;
  158 #define ENC_UPDATE_NONE         0x00
  159 #define ENC_UPDATE_INVALID      0xff
  160 
  161         /* Callout for auto-updating enclosure status */
  162         struct callout           status_updater;
  163 
  164         struct proc             *enc_daemon;
  165 
  166         struct enc_fsm_state    *enc_fsm_states;
  167 
  168         struct intr_config_hook  enc_boot_hold_ch;
  169 };
  170 
  171 static inline enc_cache_t *
  172 enc_other_cache(enc_softc_t *enc, enc_cache_t *primary)
  173 {
  174         return (primary == &enc->enc_cache
  175               ? &enc->enc_daemon_cache : &enc->enc_cache);
  176 }
  177 
  178 /* SES Management mode page - SES2r20 Table 59 */
  179 struct ses_mgmt_mode_page {
  180         struct scsi_mode_header_6 header;
  181         struct scsi_mode_blk_desc blk_desc;
  182         uint8_t byte0;  /* ps : 1, spf : 1, page_code : 6 */
  183 #define SES_MGMT_MODE_PAGE_CODE 0x14
  184         uint8_t length;
  185 #define SES_MGMT_MODE_PAGE_LEN  6
  186         uint8_t reserved[3];
  187         uint8_t byte5;  /* reserved : 7, enbltc : 1 */
  188 #define SES_MGMT_TIMED_COMP_EN  0x1
  189         uint8_t max_comp_time[2];
  190 };
  191 
  192 /* Enclosure core interface for sub-drivers */
  193 int  enc_runcmd(struct enc_softc *, char *, int, char *, int *);
  194 void enc_log(struct enc_softc *, const char *, ...);
  195 int  enc_error(union ccb *, uint32_t, uint32_t);
  196 void enc_update_request(enc_softc_t *, uint32_t);
  197 
  198 /* SES Native interface */
  199 enc_softc_init_t        ses_softc_init;
  200 
  201 /* SAF-TE interface */
  202 enc_softc_init_t        safte_softc_init;
  203 
  204 /* Helper macros */
  205 MALLOC_DECLARE(M_SCSIENC);
  206 #define ENC_CFLAGS              CAM_RETRY_SELTO
  207 #define ENC_FLAGS               SF_NO_PRINT | SF_RETRY_UA
  208 #define STRNCMP                 strncmp
  209 #define PRINTF                  printf
  210 #define ENC_LOG                 enc_log
  211 #if defined(DEBUG) || defined(ENC_DEBUG)
  212 #define ENC_DLOG                enc_log
  213 #else
  214 #define ENC_DLOG                if (0) enc_log
  215 #endif
  216 #define ENC_VLOG                if (bootverbose) enc_log
  217 #define ENC_MALLOC(amt)         malloc(amt, M_SCSIENC, M_NOWAIT)
  218 #define ENC_MALLOCZ(amt)        malloc(amt, M_SCSIENC, M_ZERO|M_NOWAIT)
  219 /* Cast away const avoiding GCC warnings. */
  220 #define ENC_FREE(ptr)           free((void *)((uintptr_t)ptr), M_SCSIENC)
  221 #define ENC_FREE_AND_NULL(ptr)  do {    \
  222         if (ptr != NULL) {              \
  223                 ENC_FREE(ptr);          \
  224                 ptr = NULL;             \
  225         }                               \
  226 } while(0)
  227 #define MEMZERO                 bzero
  228 #define MEMCPY(dest, src, amt)  bcopy(src, dest, amt)
  229 
  230 #endif  /* __SCSI_ENC_INTERNAL_H__ */

Cache object: ee0d50780b9bc9d18ac83c1ac4b5a397


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.