ctl.h revision 232604
1113277Smike/*- 2113277Smike * Copyright (c) 2003 Silicon Graphics International Corp. 3185435Sbz * All rights reserved. 4113277Smike * 5113277Smike * Redistribution and use in source and binary forms, with or without 6113277Smike * modification, are permitted provided that the following conditions 7113277Smike * are met: 8113277Smike * 1. Redistributions of source code must retain the above copyright 9113277Smike * notice, this list of conditions, and the following disclaimer, 10113277Smike * without modification. 11113277Smike * 2. Redistributions in binary form must reproduce at minimum a disclaimer 12113277Smike * substantially similar to the "NO WARRANTY" disclaimer below 13113277Smike * ("Disclaimer") and any redistribution must be conditioned upon 14113277Smike * including a substantially similar Disclaimer requirement for further 15113277Smike * binary redistribution. 16113277Smike * 17113277Smike * NO WARRANTY 18113277Smike * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19113277Smike * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20113277Smike * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 21113277Smike * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22113277Smike * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23113277Smike * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24113277Smike * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25113277Smike * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26113277Smike * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 27113277Smike * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28113277Smike * POSSIBILITY OF SUCH DAMAGES. 29113277Smike * 30113277Smike * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl.h#5 $ 31113277Smike * $FreeBSD: head/sys/cam/ctl/ctl.h 232604 2012-03-06 13:43:57Z trasz $ 32192896Sjamie */ 33179319Smr/* 34113277Smike * Function definitions used both within CTL and potentially in various CTL 35192896Sjamie * clients. 36185435Sbz * 37179319Smr * Author: Ken Merry <ken@FreeBSD.org> 38113277Smike */ 39157864Sdelphij 40194869Sjamie#ifndef _CTL_H_ 41192896Sjamie#define _CTL_H_ 42157864Sdelphij 43285420Sjamie#define ctl_min(x,y) (((x) < (y)) ? (x) : (y)) 44285420Sjamie#define CTL_RETVAL_COMPLETE 0 45113277Smike#define CTL_RETVAL_QUEUED 1 46113277Smike#define CTL_RETVAL_ALLOCATED 2 47185435Sbz#define CTL_RETVAL_ERROR 3 48113277Smike 49113277Smiketypedef enum { 50285420Sjamie CTL_PORT_NONE = 0x00, 51285420Sjamie CTL_PORT_FC = 0x01, 52285420Sjamie CTL_PORT_SCSI = 0x02, 53285420Sjamie CTL_PORT_IOCTL = 0x04, 54113277Smike CTL_PORT_INTERNAL = 0x08, 55113277Smike CTL_PORT_ALL = 0xff, 56113277Smike CTL_PORT_ISC = 0x100 // FC port for inter-shelf communication 57113277Smike} ctl_port_type; 58113277Smike 59113277Smikestruct ctl_port_entry { 60157864Sdelphij ctl_port_type port_type; 61285420Sjamie char port_name[64]; 62285420Sjamie int32_t targ_port; 63285420Sjamie int physical_port; 64285420Sjamie int virtual_port; 65194709Sjamie u_int flags; 66285420Sjamie#define CTL_PORT_WWNN_VALID 0x01 67192896Sjamie#define CTL_PORT_WWPN_VALID 0x02 68194494Sbrooks uint64_t wwnn; 69285420Sjamie uint64_t wwpn; 70157864Sdelphij int online; 71285420Sjamie}; 72285420Sjamie 73285420Sjamiestruct ctl_modepage_header { 74185435Sbz uint8_t page_code; 75192896Sjamie uint8_t subpage; 76185435Sbz int32_t len_used; 77157864Sdelphij int32_t len_left; 78157864Sdelphij}; 79157864Sdelphij 80157864Sdelphijstruct ctl_modepage_aps { 81157864Sdelphij struct ctl_modepage_header header; 82157864Sdelphij uint8_t lock_active; 83157864Sdelphij}; 84157864Sdelphij 85157864Sdelphijunion ctl_modepage_info { 86157864Sdelphij struct ctl_modepage_header header; 87157864Sdelphij struct ctl_modepage_aps aps; 88157864Sdelphij}; 89157864Sdelphij 90157864Sdelphij/* 91285420Sjamie * Serial number length, for VPD page 0x80. 92113277Smike */ 93157864Sdelphij#define CTL_SN_LEN 16 94157864Sdelphij 95285420Sjamie/* 96285420Sjamie * Device ID length, for VPD page 0x83. 97285420Sjamie */ 98285420Sjamie#define CTL_DEVID_LEN 16 99285420Sjamie/* 100194869Sjamie * WWPN length, for VPD page 0x83. 101194869Sjamie */ 102194869Sjamie#define CTL_WWPN_LEN 8 103113277Smike 104194869Sjamie/* 105113277Smike * Unit attention types. ASC/ASCQ values for these should be placed in 106113277Smike * ctl_build_ua. These are also listed in order of reporting priority. 107285420Sjamie * i.e. a poweron UA is reported first, bus reset second, etc. 108285420Sjamie */ 109285420Sjamietypedef enum { 110157864Sdelphij CTL_UA_NONE = 0x0000, 111285420Sjamie CTL_UA_POWERON = 0x0001, 112285420Sjamie CTL_UA_BUS_RESET = 0x0002, 113285420Sjamie CTL_UA_TARG_RESET = 0x0004, 114285420Sjamie CTL_UA_LUN_RESET = 0x0008, 115285420Sjamie CTL_UA_LUN_CHANGE = 0x0010, 116285420Sjamie CTL_UA_MODE_CHANGE = 0x0020, 117285420Sjamie CTL_UA_LOG_CHANGE = 0x0040, 118285420Sjamie CTL_UA_LVD = 0x0080, 119285420Sjamie CTL_UA_SE = 0x0100, 120285420Sjamie CTL_UA_RES_PREEMPT = 0x0200, 121157864Sdelphij CTL_UA_RES_RELEASE = 0x0400, 122157864Sdelphij CTL_UA_REG_PREEMPT = 0x0800, 123285420Sjamie CTL_UA_ASYM_ACC_CHANGE = 0x1000, 124285420Sjamie CTL_UA_CAPACITY_CHANGED = 0x2000 125285420Sjamie} ctl_ua_type; 126157864Sdelphij 127157864Sdelphij#ifdef _KERNEL 128285420Sjamie 129285420SjamieMALLOC_DECLARE(M_CTL); 130285420Sjamie 131285420Sjamietypedef enum { 132285420Sjamie CTL_THREAD_NONE = 0x00, 133285420Sjamie CTL_THREAD_WAKEUP = 0x01 134285420Sjamie} ctl_thread_flags; 135157864Sdelphij 136285420Sjamiestruct ctl_thread { 137285420Sjamie void (*thread_func)(void *arg); 138285420Sjamie void *arg; 139285420Sjamie struct cv wait_queue; 140285420Sjamie const char *thread_name; 141285420Sjamie ctl_thread_flags thread_flags; 142285420Sjamie struct completion *thread_event; 143285420Sjamie struct task_struct *task; 144285420Sjamie}; 145285420Sjamie 146285420Sjamiestruct ctl_page_index; 147113277Smike 148113277Smike#ifdef SYSCTL_DECL /* from sysctl.h */ 149113277SmikeSYSCTL_DECL(_kern_cam_ctl); 150113277Smike#endif 151285420Sjamie 152285420Sjamie/* 153285420Sjamie * Call these routines to enable or disable front end ports. 154285420Sjamie */ 155285420Sjamieint ctl_port_enable(ctl_port_type port_type); 156285420Sjamieint ctl_port_disable(ctl_port_type port_type); 157285420Sjamie/* 158285420Sjamie * This routine grabs a list of frontend ports. 159285420Sjamie */ 160285420Sjamieint ctl_port_list(struct ctl_port_entry *entries, int num_entries_alloced, 161285420Sjamie int *num_entries_filled, int *num_entries_dropped, 162285420Sjamie ctl_port_type port_type, int no_virtual); 163285420Sjamie 164285420Sjamie/* 165285420Sjamie * Put a string into an sbuf, escaping characters that are illegal or not 166285420Sjamie * recommended in XML. Note this doesn't escape everything, just > < and &. 167285420Sjamie */ 168285420Sjamieint ctl_sbuf_printf_esc(struct sbuf *sb, char *str); 169285420Sjamie 170285420Sjamieint ctl_ffz(uint32_t *mask, uint32_t size); 171285420Sjamieint ctl_set_mask(uint32_t *mask, uint32_t bit); 172285420Sjamieint ctl_clear_mask(uint32_t *mask, uint32_t bit); 173285420Sjamieint ctl_is_set(uint32_t *mask, uint32_t bit); 174285420Sjamieint ctl_control_page_handler(struct ctl_scsiio *ctsio, 175285420Sjamie struct ctl_page_index *page_index, 176285420Sjamie uint8_t *page_ptr); 177285420Sjamie/** 178285420Sjamieint ctl_failover_sp_handler(struct ctl_scsiio *ctsio, 179285420Sjamie struct ctl_page_index *page_index, 180285420Sjamie uint8_t *page_ptr); 181285420Sjamie**/ 182285420Sjamieint ctl_power_sp_handler(struct ctl_scsiio *ctsio, 183285420Sjamie struct ctl_page_index *page_index, uint8_t *page_ptr); 184285420Sjamieint ctl_power_sp_sense_handler(struct ctl_scsiio *ctsio, 185113277Smike struct ctl_page_index *page_index, int pc); 186113277Smikeint ctl_aps_sp_handler(struct ctl_scsiio *ctsio, 187113277Smike struct ctl_page_index *page_index, uint8_t *page_ptr); 188192896Sjamieint ctl_debugconf_sp_sense_handler(struct ctl_scsiio *ctsio, 189285420Sjamie struct ctl_page_index *page_index, 190113277Smike int pc); 191113277Smikeint ctl_debugconf_sp_select_handler(struct ctl_scsiio *ctsio, 192 struct ctl_page_index *page_index, 193 uint8_t *page_ptr); 194int ctl_config_move_done(union ctl_io *io); 195void ctl_datamove(union ctl_io *io); 196void ctl_done(union ctl_io *io); 197void ctl_config_write_done(union ctl_io *io); 198#if 0 199int ctl_thread(void *arg); 200#endif 201void ctl_wakeup_thread(void); 202#if 0 203struct ctl_thread *ctl_create_thread(void (*thread_func) 204 (void *thread_arg), void *thread_arg, const char *thread_name); 205void ctl_signal_thread(struct ctl_thread *thread); 206void ctl_shutdown_thread(struct ctl_thread *thread); 207#endif 208void ctl_portDB_changed(int portnum); 209void ctl_init_isc_msg(void); 210 211#endif /* _KERNEL */ 212 213#endif /* _CTL_H_ */ 214 215/* 216 * vim: ts=8 217 */ 218