ctl.h revision 273075
10SN/A/*-
22362SN/A * Copyright (c) 2003 Silicon Graphics International Corp.
30SN/A * All rights reserved.
40SN/A *
50SN/A * Redistribution and use in source and binary forms, with or without
60SN/A * modification, are permitted provided that the following conditions
72362SN/A * are met:
80SN/A * 1. Redistributions of source code must retain the above copyright
92362SN/A *    notice, this list of conditions, and the following disclaimer,
100SN/A *    without modification.
110SN/A * 2. Redistributions in binary form must reproduce at minimum a disclaimer
120SN/A *    substantially similar to the "NO WARRANTY" disclaimer below
130SN/A *    ("Disclaimer") and any redistribution must be conditioned upon
140SN/A *    including a substantially similar Disclaimer requirement for further
150SN/A *    binary redistribution.
160SN/A *
170SN/A * NO WARRANTY
180SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
190SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
200SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
212362SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
222362SN/A * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
232362SN/A * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
240SN/A * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
250SN/A * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
260SN/A * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
270SN/A * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
280SN/A * POSSIBILITY OF SUCH DAMAGES.
290SN/A *
300SN/A * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl.h#5 $
310SN/A * $FreeBSD: head/sys/cam/ctl/ctl.h 273075 2014-10-14 11:28:25Z mav $
320SN/A */
330SN/A/*
340SN/A * Function definitions used both within CTL and potentially in various CTL
350SN/A * clients.
360SN/A *
370SN/A * Author: Ken Merry <ken@FreeBSD.org>
380SN/A */
390SN/A
400SN/A#ifndef	_CTL_H_
410SN/A#define	_CTL_H_
420SN/A
430SN/A#define	ctl_min(x,y)	(((x) < (y)) ? (x) : (y))
440SN/A#define	CTL_RETVAL_COMPLETE	0
450SN/A#define	CTL_RETVAL_QUEUED	1
460SN/A#define	CTL_RETVAL_ALLOCATED	2
470SN/A#define	CTL_RETVAL_ERROR	3
480SN/A
490SN/Atypedef enum {
500SN/A	CTL_PORT_NONE		= 0x00,
510SN/A	CTL_PORT_FC		= 0x01,
520SN/A	CTL_PORT_SCSI		= 0x02,
530SN/A	CTL_PORT_IOCTL		= 0x04,
540SN/A	CTL_PORT_INTERNAL	= 0x08,
550SN/A	CTL_PORT_ISCSI		= 0x10,
560SN/A	CTL_PORT_SAS		= 0x20,
570SN/A	CTL_PORT_ALL		= 0xff,
580SN/A	CTL_PORT_ISC		= 0x100 // FC port for inter-shelf communication
5910211SN/A} ctl_port_type;
6010211SN/A
6110211SN/Astruct ctl_port_entry {
6210211SN/A	ctl_port_type		port_type;
630SN/A	char			port_name[64];
640SN/A	int32_t			targ_port;
650SN/A	int			physical_port;
660SN/A	int			virtual_port;
670SN/A	u_int			flags;
680SN/A#define	CTL_PORT_WWNN_VALID	0x01
690SN/A#define	CTL_PORT_WWPN_VALID	0x02
700SN/A	uint64_t		wwnn;
71178SN/A	uint64_t		wwpn;
720SN/A	int			online;
730SN/A};
740SN/A
750SN/Astruct ctl_modepage_header {
760SN/A	uint8_t page_code;
770SN/A	uint8_t subpage;
780SN/A	int32_t len_used;
790SN/A	int32_t len_left;
800SN/A};
810SN/A
82178SN/Astruct ctl_modepage_aps {
830SN/A	struct ctl_modepage_header header;
840SN/A	uint8_t lock_active;
850SN/A};
860SN/A
870SN/Aunion ctl_modepage_info {
880SN/A	struct ctl_modepage_header header;
890SN/A	struct ctl_modepage_aps aps;
900SN/A};
910SN/A
920SN/A/*
930SN/A * Serial number length, for VPD page 0x80.
940SN/A */
950SN/A#define	CTL_SN_LEN	16
960SN/A
970SN/A/*
980SN/A * Device ID length, for VPD page 0x83.
990SN/A */
1000SN/A#define	CTL_DEVID_LEN	64
1010SN/A#define	CTL_DEVID_MIN_LEN	16
1020SN/A/*
1030SN/A * WWPN length, for VPD page 0x83.
1040SN/A */
1050SN/A#define CTL_WWPN_LEN   8
1060SN/A
1070SN/A#define	CTL_DRIVER_NAME_LEN	32
1080SN/A
1090SN/A/*
1100SN/A * Unit attention types. ASC/ASCQ values for these should be placed in
1110SN/A * ctl_build_ua.  These are also listed in order of reporting priority.
1120SN/A * i.e. a poweron UA is reported first, bus reset second, etc.
1130SN/A */
1140SN/Atypedef enum {
1150SN/A	CTL_UA_NONE		= 0x0000,
1160SN/A	CTL_UA_POWERON		= 0x0001,
1170SN/A	CTL_UA_BUS_RESET	= 0x0002,
1180SN/A	CTL_UA_TARG_RESET	= 0x0004,
1190SN/A	CTL_UA_I_T_NEXUS_LOSS	= 0x0008,
1200SN/A	CTL_UA_LUN_RESET	= 0x0010,
1210SN/A	CTL_UA_LUN_CHANGE	= 0x0020,
1220SN/A	CTL_UA_MODE_CHANGE	= 0x0040,
1230SN/A	CTL_UA_LOG_CHANGE	= 0x0080,
1240SN/A	CTL_UA_LVD		= 0x0100,
1250SN/A	CTL_UA_SE		= 0x0200,
1260SN/A	CTL_UA_RES_PREEMPT	= 0x0400,
1270SN/A	CTL_UA_RES_RELEASE	= 0x0800,
1280SN/A	CTL_UA_REG_PREEMPT  	= 0x1000,
1291807SN/A	CTL_UA_ASYM_ACC_CHANGE  = 0x2000,
1301807SN/A	CTL_UA_CAPACITY_CHANGED = 0x4000
1310SN/A} ctl_ua_type;
132
133#ifdef	_KERNEL
134
135MALLOC_DECLARE(M_CTL);
136
137struct ctl_page_index;
138
139#ifdef SYSCTL_DECL	/* from sysctl.h */
140SYSCTL_DECL(_kern_cam_ctl);
141#endif
142
143/*
144 * Call these routines to enable or disable front end ports.
145 */
146int ctl_port_enable(ctl_port_type port_type);
147int ctl_port_disable(ctl_port_type port_type);
148/*
149 * This routine grabs a list of frontend ports.
150 */
151int ctl_port_list(struct ctl_port_entry *entries, int num_entries_alloced,
152		  int *num_entries_filled, int *num_entries_dropped,
153		  ctl_port_type port_type, int no_virtual);
154
155/*
156 * Put a string into an sbuf, escaping characters that are illegal or not
157 * recommended in XML.  Note this doesn't escape everything, just > < and &.
158 */
159int ctl_sbuf_printf_esc(struct sbuf *sb, char *str);
160
161int ctl_ffz(uint32_t *mask, uint32_t size);
162int ctl_set_mask(uint32_t *mask, uint32_t bit);
163int ctl_clear_mask(uint32_t *mask, uint32_t bit);
164int ctl_is_set(uint32_t *mask, uint32_t bit);
165int ctl_caching_sp_handler(struct ctl_scsiio *ctsio,
166			 struct ctl_page_index *page_index, uint8_t *page_ptr);
167int ctl_control_page_handler(struct ctl_scsiio *ctsio,
168			     struct ctl_page_index *page_index,
169			     uint8_t *page_ptr);
170/**
171int ctl_failover_sp_handler(struct ctl_scsiio *ctsio,
172			    struct ctl_page_index *page_index,
173			    uint8_t *page_ptr);
174**/
175int ctl_debugconf_sp_sense_handler(struct ctl_scsiio *ctsio,
176				   struct ctl_page_index *page_index,
177				   int pc);
178int ctl_debugconf_sp_select_handler(struct ctl_scsiio *ctsio,
179				    struct ctl_page_index *page_index,
180				    uint8_t *page_ptr);
181int ctl_config_move_done(union ctl_io *io);
182void ctl_datamove(union ctl_io *io);
183void ctl_done(union ctl_io *io);
184void ctl_data_submit_done(union ctl_io *io);
185void ctl_config_write_done(union ctl_io *io);
186void ctl_portDB_changed(int portnum);
187void ctl_init_isc_msg(void);
188
189/*
190 * KPI to manipulate LUN/port options
191 */
192
193struct ctl_option {
194	STAILQ_ENTRY(ctl_option)	links;
195	char			*name;
196	char			*value;
197};
198typedef STAILQ_HEAD(ctl_options, ctl_option) ctl_options_t;
199
200struct ctl_be_arg;
201void ctl_init_opts(ctl_options_t *opts, int num_args, struct ctl_be_arg *args);
202void ctl_free_opts(ctl_options_t *opts);
203char * ctl_get_opt(ctl_options_t *opts, const char *name);
204
205#endif	/* _KERNEL */
206
207#endif	/* _CTL_H_ */
208
209/*
210 * vim: ts=8
211 */
212