ctl.h revision 279273
190075Sobrien/*- 2169689Skan * Copyright (c) 2003 Silicon Graphics International Corp. 390075Sobrien * All rights reserved. 4132718Skan * 590075Sobrien * Redistribution and use in source and binary forms, with or without 6132718Skan * modification, are permitted provided that the following conditions 790075Sobrien * are met: 890075Sobrien * 1. Redistributions of source code must retain the above copyright 990075Sobrien * notice, this list of conditions, and the following disclaimer, 1090075Sobrien * without modification. 11132718Skan * 2. Redistributions in binary form must reproduce at minimum a disclaimer 1290075Sobrien * substantially similar to the "NO WARRANTY" disclaimer below 1390075Sobrien * ("Disclaimer") and any redistribution must be conditioned upon 1490075Sobrien * including a substantially similar Disclaimer requirement for further 1590075Sobrien * binary redistribution. 1690075Sobrien * 17132718Skan * NO WARRANTY 18169689Skan * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19169689Skan * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2090075Sobrien * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 2190075Sobrien * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2290075Sobrien * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2390075Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24117395Skan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25117395Skan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26117395Skan * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 27117395Skan * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28169689Skan * POSSIBILITY OF SUCH DAMAGES. 29169689Skan * 3090075Sobrien * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl.h#5 $ 31132718Skan * $FreeBSD: stable/10/sys/cam/ctl/ctl.h 279273 2015-02-25 09:21:04Z mav $ 3290075Sobrien */ 3390075Sobrien/* 3490075Sobrien * Function definitions used both within CTL and potentially in various CTL 3590075Sobrien * clients. 3690075Sobrien * 3790075Sobrien * Author: Ken Merry <ken@FreeBSD.org> 38132718Skan */ 39132718Skan 40169689Skan#ifndef _CTL_H_ 41132718Skan#define _CTL_H_ 42132718Skan 43132718Skan#define CTL_RETVAL_COMPLETE 0 44132718Skan#define CTL_RETVAL_QUEUED 1 45132718Skan#define CTL_RETVAL_ALLOCATED 2 46169689Skan#define CTL_RETVAL_ERROR 3 47132718Skan 48132718Skantypedef enum { 49132718Skan CTL_PORT_NONE = 0x00, 5090075Sobrien CTL_PORT_FC = 0x01, 5190075Sobrien CTL_PORT_SCSI = 0x02, 52132718Skan CTL_PORT_IOCTL = 0x04, 53132718Skan CTL_PORT_INTERNAL = 0x08, 54132718Skan CTL_PORT_ISCSI = 0x10, 55132718Skan CTL_PORT_SAS = 0x20, 56132718Skan CTL_PORT_ALL = 0xff, 57132718Skan CTL_PORT_ISC = 0x100 // FC port for inter-shelf communication 58132718Skan} ctl_port_type; 59132718Skan 60132718Skanstruct ctl_port_entry { 61132718Skan ctl_port_type port_type; 62117395Skan char port_name[64]; 63117395Skan int32_t targ_port; 64117395Skan int physical_port; 65117395Skan int virtual_port; 66117395Skan u_int flags; 67132718Skan#define CTL_PORT_WWNN_VALID 0x01 68117395Skan#define CTL_PORT_WWPN_VALID 0x02 69117395Skan uint64_t wwnn; 70132718Skan uint64_t wwpn; 71117395Skan int online; 72117395Skan}; 73132718Skan 74117395Skanstruct ctl_modepage_header { 75117395Skan uint8_t page_code; 76132718Skan uint8_t subpage; 77117395Skan int32_t len_used; 78169689Skan int32_t len_left; 79169689Skan}; 80132718Skan 81132718Skanstruct ctl_modepage_aps { 8290075Sobrien struct ctl_modepage_header header; 8390075Sobrien uint8_t lock_active; 8490075Sobrien}; 8590075Sobrien 86117395Skanunion ctl_modepage_info { 8790075Sobrien struct ctl_modepage_header header; 88132718Skan struct ctl_modepage_aps aps; 8990075Sobrien}; 9090075Sobrien 91132718Skan/* 9290075Sobrien * Serial number length, for VPD page 0x80. 9390075Sobrien */ 94117395Skan#define CTL_SN_LEN 16 95117395Skan 96117395Skan/* 97117395Skan * Device ID length, for VPD page 0x83. 98117395Skan */ 99117395Skan#define CTL_DEVID_LEN 64 100132718Skan#define CTL_DEVID_MIN_LEN 16 101117395Skan/* 102117395Skan * WWPN length, for VPD page 0x83. 103117395Skan */ 104132718Skan#define CTL_WWPN_LEN 8 105117395Skan 106117395Skan#define CTL_DRIVER_NAME_LEN 32 107117395Skan 108132718Skan/* 109117395Skan * Unit attention types. ASC/ASCQ values for these should be placed in 110117395Skan * ctl_build_ua. These are also listed in order of reporting priority. 111117395Skan * i.e. a poweron UA is reported first, bus reset second, etc. 112132718Skan */ 113117395Skantypedef enum { 114117395Skan CTL_UA_NONE = 0x0000, 115117395Skan CTL_UA_POWERON = 0x0001, 116132718Skan CTL_UA_BUS_RESET = 0x0002, 117117395Skan CTL_UA_TARG_RESET = 0x0004, 118117395Skan CTL_UA_I_T_NEXUS_LOSS = 0x0008, 119117395Skan CTL_UA_LUN_RESET = 0x0010, 120132718Skan CTL_UA_LUN_CHANGE = 0x0020, 121117395Skan CTL_UA_MODE_CHANGE = 0x0040, 122259268Spfg CTL_UA_LOG_CHANGE = 0x0080, 123259268Spfg CTL_UA_LVD = 0x0100, 124259268Spfg CTL_UA_SE = 0x0200, 125259268Spfg CTL_UA_RES_PREEMPT = 0x0400, 126117395Skan CTL_UA_RES_RELEASE = 0x0800, 127117395Skan CTL_UA_REG_PREEMPT = 0x1000, 128117395Skan CTL_UA_ASYM_ACC_CHANGE = 0x2000, 129169689Skan CTL_UA_CAPACITY_CHANGED = 0x4000, 130132718Skan CTL_UA_THIN_PROV_THRES = 0x8000 131117395Skan} ctl_ua_type; 132132718Skan 133132718Skan#ifdef _KERNEL 134132718Skan 135132718SkanMALLOC_DECLARE(M_CTL); 136132718Skan 137132718Skanstruct ctl_page_index; 138132718Skan 139132718Skan#ifdef SYSCTL_DECL /* from sysctl.h */ 140132718SkanSYSCTL_DECL(_kern_cam_ctl); 141117395Skan#endif 142117395Skan 143117395Skan/* 144117395Skan * Call these routines to enable or disable front end ports. 145132718Skan */ 146169689Skanint ctl_port_enable(ctl_port_type port_type); 147169689Skanint ctl_port_disable(ctl_port_type port_type); 148169689Skan/* 149169689Skan * This routine grabs a list of frontend ports. 150169689Skan */ 151169689Skanint ctl_port_list(struct ctl_port_entry *entries, int num_entries_alloced, 152169689Skan int *num_entries_filled, int *num_entries_dropped, 153169689Skan ctl_port_type port_type, int no_virtual); 154169689Skan 155261188Spfg/* 156261188Spfg * Put a string into an sbuf, escaping characters that are illegal or not 157261188Spfg * recommended in XML. Note this doesn't escape everything, just > < and &. 158261188Spfg */ 159261188Spfgint ctl_sbuf_printf_esc(struct sbuf *sb, char *str, int size); 160261188Spfg 161169689Skanint ctl_ffz(uint32_t *mask, uint32_t size); 162169689Skanint ctl_set_mask(uint32_t *mask, uint32_t bit); 163169689Skanint ctl_clear_mask(uint32_t *mask, uint32_t bit); 164169689Skanint ctl_is_set(uint32_t *mask, uint32_t bit); 165117395Skanint ctl_caching_sp_handler(struct ctl_scsiio *ctsio, 166117395Skan struct ctl_page_index *page_index, uint8_t *page_ptr); 167117395Skanint ctl_control_page_handler(struct ctl_scsiio *ctsio, 168117395Skan struct ctl_page_index *page_index, 169117395Skan uint8_t *page_ptr); 170117395Skan/** 171117395Skanint ctl_failover_sp_handler(struct ctl_scsiio *ctsio, 172117395Skan struct ctl_page_index *page_index, 173132718Skan uint8_t *page_ptr); 174117395Skan**/ 175117395Skanint ctl_debugconf_sp_sense_handler(struct ctl_scsiio *ctsio, 176117395Skan struct ctl_page_index *page_index, 177117395Skan int pc); 178132718Skanint ctl_debugconf_sp_select_handler(struct ctl_scsiio *ctsio, 179117395Skan struct ctl_page_index *page_index, 180117395Skan uint8_t *page_ptr); 181117395Skanint ctl_lbp_log_sense_handler(struct ctl_scsiio *ctsio, 182117395Skan struct ctl_page_index *page_index, 183117395Skan int pc); 184132718Skanint ctl_sap_log_sense_handler(struct ctl_scsiio *ctsio, 185117395Skan struct ctl_page_index *page_index, 186117395Skan int pc); 187132718Skanint ctl_config_move_done(union ctl_io *io); 188117395Skanvoid ctl_datamove(union ctl_io *io); 189117395Skanvoid ctl_done(union ctl_io *io); 190117395Skanvoid ctl_data_submit_done(union ctl_io *io); 191132718Skanvoid ctl_config_read_done(union ctl_io *io); 192117395Skanvoid ctl_config_write_done(union ctl_io *io); 193117395Skanvoid ctl_portDB_changed(int portnum); 194117395Skanvoid ctl_init_isc_msg(void); 195132718Skan 196117395Skan/* 197132718Skan * KPI to manipulate LUN/port options 198132718Skan */ 199132718Skan 200117395Skanstruct ctl_option { 201132718Skan STAILQ_ENTRY(ctl_option) links; 202169689Skan char *name; 203169689Skan char *value; 204169689Skan}; 205169689Skantypedef STAILQ_HEAD(ctl_options, ctl_option) ctl_options_t; 206169689Skan 207169689Skanstruct ctl_be_arg; 208169689Skanvoid ctl_init_opts(ctl_options_t *opts, int num_args, struct ctl_be_arg *args); 209169689Skanvoid ctl_free_opts(ctl_options_t *opts); 210169689Skanchar * ctl_get_opt(ctl_options_t *opts, const char *name); 211169689Skanint ctl_expand_number(const char *buf, uint64_t *num); 212169689Skan 213169689Skan#endif /* _KERNEL */ 214169689Skan 215169689Skan#endif /* _CTL_H_ */ 216169689Skan 217169689Skan/* 218169689Skan * vim: ts=8 219169689Skan */ 220169689Skan