xref: /titanic_52/usr/src/uts/common/io/scsi/adapters/smartpqi/smartpqi.h (revision 58f4054fce841e31413b3ec9f94e78e911e83772)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2019 Nexenta Systems, Inc.
14  * Copyright 2021 RackTop Systems, Inc.
15  */
16 
17 #ifndef _SMARTPQI_H
18 #define	_SMARTPQI_H
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 /* ---- Standard header files. ---- */
25 #include <sys/note.h>
26 #include <sys/byteorder.h>
27 #include <sys/scsi/scsi.h>
28 #include <sys/pci.h>
29 #include <sys/file.h>
30 #include <sys/policy.h>
31 #include <sys/model.h>
32 #include <sys/sysevent.h>
33 #include <sys/sysevent/eventdefs.h>
34 #include <sys/sysevent/dr.h>
35 #include <sys/sata/sata_defs.h>
36 #include <sys/sata/sata_hba.h>
37 #include <sys/scsi/generic/sas.h>
38 #include <sys/scsi/impl/scsi_sas.h>
39 #include <sys/scsi/impl/scsi_reset_notify.h>
40 #include <sys/sdt.h>
41 #include <sys/mdi_impldefs.h>
42 #include <sys/fs/dv_node.h>
43 #include <sys/sysmacros.h>
44 #include <sys/systm.h>
45 #include <smartpqi_hw.h>
46 
47 /* ---- Hint for ddi_soft_state_init() on amount of structs to alloc ---- */
48 #define	SMARTPQI_INITIAL_SOFT_SPACE	1
49 
50 #define	SMARTPQI_MOD_STRING	"smartpqi RT-20210716"
51 
52 /* ---- Handy constants ---- */
53 #define	UNDEFINED				-1
54 #define	MAX_NAME_PROP_SIZE			256
55 #define	LUN_PROP				"lun"
56 #define	LUN64_PROP				"lun64"
57 #define	MDI_GUID				"wwn"
58 #define	NDI_GUID				"guid"
59 #define	TARGET_PROP				"target"
60 #define	LUN_PROP				"lun"
61 #define	COMPAT_PROP				"compatible"
62 #define	NAME_DISK				"disk"
63 #define	NAME_ENCLOSURE				"enclosure"
64 
65 #define	CMD_TIMEOUT_SCAN_SECS			10
66 #define	SYNC_CMDS_TIMEOUT_SECS			5
67 #define	IO_SPACE				1
68 #define	PQI_MAXTGTS				256
69 
70 #define	PQI_MIN_MSIX_VECTORS			1
71 #define	PQI_MAX_MSIX_VECTORS			16
72 #define	PQI_DEFAULT_QUEUE_GROUP			0
73 #define	PQI_MAX_QUEUE_GROUPS			PQI_MAX_MSIX_VECTORS
74 #define	PQI_MIN_OPERATIONAL_QUEUE_ID		1
75 /* ---- Size of structure scsi_arq_status without sense data. ---- */
76 #define	PQI_ARQ_STATUS_NOSENSE_LEN	(sizeof (struct scsi_arq_status) - \
77     sizeof (struct scsi_extended_sense))
78 
79 /* ---- macros to return various addresses ---- */
80 #define	ADDR2TRAN(ap)	((ap)->a_hba_tran)
81 #define	TRAN2PQI(hba)	((pqi_state_t)(hba)->tran_hba_private)
82 #define	ADDR2PQI(ap)	(TRAN2PQI(ADDR2TRAN(ap)))
83 #define	PKT2CMD(pkt)	((pqi_cmd_t)(pkt)->pkt_ha_private)
84 #define	CMD2PKT(cmd)	((struct scsi_pkt *)(cmd)->pc_pkt)
85 
86 /* ---- PQI configuration ---- */
87 #define	PQI_MAX_OUTSTANDING_REQUESTS		32
88 #define	PQI_ERROR_BUFFER_ELEMENT_LENGTH sizeof (struct pqi_raid_error_info)
89 #define	PQI_CREATE_ADMIN_QUEUE_PAIR		1
90 #define	PQI_DELETE_ADMIN_QUEUE_PAIR		2
91 #define	PQI_MAX_TRANSFER_SIZE			(4 * 1024U * 1024U)
92 #define	PQI_MAX_RESET_XFER_SIZE			(512 * 1024)
93 #define	PQI_NUM_SUPPORTED_EVENTS		7
94 #define	PQI_RESERVED_IO_SLOTS_LUN_RESET		1
95 #define	PQI_RESERVED_IO_SLOTS_EVENT_ACK	PQI_NUM_SUPPORTED_EVENTS
96 #define	PQI_RESERVED_IO_SLOTS_SYNCHRONOUS_REQUESTS	3
97 #define	PQI_RESERVED_IO_SLOTS \
98 	(PQI_RESERVED_IO_SLOTS_LUN_RESET + PQI_RESERVED_IO_SLOTS_EVENT_ACK + \
99 	PQI_RESERVED_IO_SLOTS_SYNCHRONOUS_REQUESTS)
100 #define	PQI_MAX_SCATTER_GATHER			0x200
101 
102 /* ---- SIS constants ---- */
103 #define	SIS_BASE_STRUCT_ALIGNMENT		16
104 
105 /* ---- Once every 10 seconds ---- */
106 #define	WATCHDOG (10 * MICROSEC)
107 
108 /* ---- Update HBA time of day clock once a day ---- */
109 #define	MINUTE		60
110 #define	HOUR		(60 * MINUTE)
111 #define	DAY		(24 * HOUR)
112 
113 #define	HBA_IS_QUIESCED(s)	(((s)->s_flags & PQI_HBA_QUIESCED) != 0)
114 #define	HBA_QUIESCED_PENDING(s)	\
115 	(((s)->s_flags & PQI_HBA_QUIESCED_PENDING) != 0 && \
116 	((s)->s_cmd_queue_len == 0))
117 #define	PQIALIGN_TYPED(addr, align, type) \
118 	(type)(((uintptr_t)(addr) + align - 1) & ~(align - 1))
119 
120 /* ---- Handy macros to get/set device registers ---- */
121 #define	G8(state, __reg__) \
122     ddi_get8(state->s_datap, &state->s_reg->__reg__)
123 #define	G16(state, __reg__) \
124     ddi_get16(state->s_datap, &state->s_reg->__reg__)
125 #define	G32(state, __reg__) \
126     ddi_get32(state->s_datap, &state->s_reg->__reg__)
127 #define	S8(state, __reg__, val) \
128     ddi_put8(state->s_datap, &state->s_reg->__reg__, val)
129 #define	S32(state, __reg__, val) \
130     ddi_put32(state->s_datap, &state->s_reg->__reg__, val)
131 #define	S64(state, __reg__, val) \
132     ddi_put64(state->s_datap, &state->s_reg->__reg__, val)
133 #define	G64(state, __reg__) \
134     ddi_get64(state->s_datap, &state->s_reg->__reg__)
135 
136 /*
137  * Yuck! Internal knowledge of MPxIO, but since this variable is required
138  * to use MPxIO and there's no public API it must be declared here. Both
139  * the iSCSI Initiator and MPT SAS drivers do the same thing.
140  */
141 extern dev_info_t *scsi_vhci_dip;
142 
143 typedef enum pqi_io_path {
144 	RAID_PATH = 0,
145 	AIO_PATH = 1
146 } pqi_path_t;
147 
148 typedef struct dma_overhead {
149 	ddi_dma_handle_t	handle;
150 	ddi_acc_handle_t	acc;
151 	caddr_t			alloc_memory;
152 	size_t			len_to_alloc;
153 	size_t			allocated_len;
154 	uint64_t		dma_addr;
155 	uint_t			cookie_count;
156 	ddi_dma_cookie_t	second;
157 } pqi_dma_overhead_t;
158 
159 typedef struct pqi_admin_queues {
160 	caddr_t			iq_element_array;
161 	caddr_t			oq_element_array;
162 	volatile pqi_index_t	*iq_ci;
163 	pqi_index_t		*oq_pi;
164 	uint64_t		iq_element_array_bus_addr;
165 	uint64_t		oq_element_array_bus_addr;
166 	uint64_t		iq_ci_bus_addr;
167 	uint64_t		oq_pi_bus_addr;
168 	uint32_t		*iq_pi;
169 	pqi_index_t		iq_pi_copy;
170 	uint32_t		*oq_ci;
171 	pqi_index_t		oq_ci_copy;
172 	struct task_struct	*task;
173 	uint16_t		int_msg_num;
174 } pqi_admin_queues_t;
175 
176 typedef struct pqi_event_queue {
177 	uint16_t		oq_id;
178 	uint16_t		int_msg_num;
179 	void			*oq_element_array;
180 	pqi_index_t		*oq_pi;		/* In s_queue_dma space */
181 	uint64_t		oq_element_array_bus_addr;
182 	uint64_t		oq_pi_bus_addr;
183 	uint32_t		*oq_ci;		/* In s_reg space */
184 	pqi_index_t		oq_ci_copy;
185 } pqi_event_queue_t;
186 
187 typedef struct pqi_queue_group {
188 	struct pqi_state	*qg_softc;	/* backpointer */
189 	uint16_t		iq_id[2];
190 	uint16_t		oq_id;
191 	uint16_t		int_msg_num;
192 	caddr_t			iq_element_array[2];
193 	caddr_t			oq_element_array;
194 	uint64_t		iq_element_array_bus_addr[2];
195 	uint64_t		oq_element_array_bus_addr;
196 	pqi_index_t		iq_pi_copy[2];
197 	pqi_index_t		oq_ci_copy;
198 	/* ---- In s_reg space ---- */
199 	uint32_t		*iq_pi[2];
200 	uint32_t		*oq_ci;
201 
202 	/* ---- In s_queue_dma space ---- */
203 	pqi_index_t		*iq_ci[2];
204 	pqi_index_t		*oq_pi;
205 
206 	uint64_t		iq_ci_bus_addr[2];
207 	uint64_t		oq_pi_bus_addr;
208 
209 	kmutex_t		submit_lock[2]; /* protect submission queue */
210 	list_t			request_list[2];
211 	int			submit_count;
212 	int			cmplt_count;
213 	boolean_t		qg_active;
214 } pqi_queue_group_t;
215 
216 typedef struct pqi_io_request {
217 	uint32_t		io_refcount;
218 	uint16_t		io_index;
219 	void			(*io_cb)(struct pqi_io_request *, void *);
220 	void			*io_context;
221 	uint8_t			io_raid_bypass : 1;
222 	int			io_status;
223 	pqi_queue_group_t	*io_queue_group;
224 	struct pqi_cmd		*io_cmd;
225 	void			*io_error_info;
226 	pqi_dma_overhead_t	*io_sg_chain_dma;
227 	void			*io_iu;
228 	list_node_t		io_list_node;
229 
230 	/* ---- Debug aids ---- */
231 	pqi_index_t		io_pi;
232 	int			io_iu_type;
233 
234 	struct pqi_state	*io_softc;
235 } pqi_io_request_t;
236 
237 typedef struct pqi_event {
238 	boolean_t		ev_pending;
239 	uint8_t			ev_type;
240 	uint16_t		ev_id;
241 	uint32_t		ev_additional;
242 } *pqi_event_t;
243 
244 /* ---- Flags used in pqi_state ---- */
245 #define	PQI_HBA_DRIVER_SHUTDOWN			0x0001
246 #define	PQI_HBA_QUIESCED			0x0002
247 #define	PQI_HBA_QUIESCED_PENDING		0x0004
248 #define	PQI_HBA_AUTO_REQUEST_SENSE		0x0008
249 #define	PQI_HBA_LUN_RESET_CAP			0x0010
250 
251 /* ---- Debug flags, example debug=0x10; in .conf file ---- */
252 #define	DBG_LVL_CDB				0x0001
253 #define	DBG_LVL_RQST				0x0002
254 #define	DBG_LVL_STATE				0x0004
255 #define	DBG_LVL_RAW_RQST			0x0008
256 
257 typedef struct pqi_state {
258 	int			s_instance;
259 	dev_info_t		*s_dip;
260 	int			s_flags;
261 	kmutex_t		s_mutex;
262 	kmutex_t		s_intr_mutex;
263 	kcondvar_t		s_quiescedvar;
264 
265 	/* ---- Used for serialized commands through driver ---- */
266 	ksema_t			s_sync_rqst;
267 	hrtime_t		s_sync_expire;
268 	pqi_io_request_t	*s_sync_io;
269 
270 	int			s_intr_ready : 1,
271 				s_offline : 1,
272 				s_disable_mpxio : 1;
273 	kmem_cache_t		*s_cmd_cache;
274 	ddi_taskq_t		*s_events_taskq;
275 	ddi_taskq_t		*s_complete_taskq;
276 	timeout_id_t		s_time_of_day;
277 	timeout_id_t		s_cmd_timeout;
278 
279 	/* ---- Debug related state ---- */
280 	int			s_debug_level;
281 
282 	/* ---- State for watchdog ---- */
283 	timeout_id_t		s_watchdog;
284 	uint32_t		s_last_intr_count;
285 	uint32_t		s_last_heartbeat_count;
286 	uint32_t		s_intr_count;
287 
288 	/* ---- Interrupt related fields ---- */
289 	int			s_intr_type;	/* Type of interrupt used */
290 	int			s_intr_cnt;	/* # of interrupts */
291 	uint_t			s_intr_pri;	/* Interrupt priority */
292 	int			s_intr_cap;	/* Interrupt capabilities */
293 	int			s_intr_size;	/* Size of s_htable */
294 	ddi_intr_handle_t	*s_itable;	/* Interrupt table */
295 
296 	scsi_hba_tran_t		*s_tran;
297 	ddi_dma_attr_t		s_msg_dma_attr;	/* Used for message frames */
298 
299 	/* ---- list of reset notification requests ---- */
300 	struct scsi_reset_notify_entry	*s_reset_notify_listf;
301 
302 	pqi_ctrl_regs_t		*s_reg;
303 	ddi_device_acc_attr_t	s_reg_acc_attr;
304 	/* ---- operating regs data access handle ---- */
305 	ddi_acc_handle_t	s_datap;
306 
307 	list_t			s_devnodes;
308 	volatile uint32_t	s_cmd_queue_len;
309 
310 	/* ---- SIS capabilities from controller ---- */
311 	uint32_t		s_max_sg_entries;
312 	uint32_t		s_max_xfer_size;
313 	uint32_t		s_max_outstanding_requests;
314 	uint32_t		s_config_table_offset;
315 	uint32_t		s_config_table_len;
316 
317 	/* ---- PQI capabilities from controller ---- */
318 	uint32_t		*s_heartbeat_counter;
319 	uint16_t		s_max_inbound_queues;
320 	uint16_t		s_max_elements_per_iq;
321 	uint16_t		s_max_iq_element_length;
322 	uint16_t		s_max_outbound_queues;
323 	uint16_t		s_max_elements_per_oq;
324 	uint16_t		s_max_oq_element_length;
325 	uint16_t		s_max_inbound_iu_length_per_firmware;
326 	uint8_t			s_inbound_spanning_supported : 1,
327 				s_outbound_spanning_supported:1,
328 				s_pqi_mode_enabled : 1;
329 	char			s_firmware_version[11];
330 
331 	/* ---- Computed values from config ---- */
332 	uint32_t		s_max_sg_per_iu;
333 	uint32_t		s_num_elements_per_iq;
334 	uint32_t		s_num_elements_per_oq;
335 	uint32_t		s_max_inbound_iu_length;
336 	uint32_t		s_num_queue_groups;
337 	uint32_t		s_max_io_slots;
338 	uint32_t		s_sg_chain_buf_length;
339 	uint32_t		s_max_sectors;
340 
341 	/* ---- allocation/free is protected by s_io_mutex ---- */
342 	kmutex_t		s_io_mutex;
343 	kcondvar_t		s_io_condvar;
344 	pqi_io_request_t	*s_io_rqst_pool;
345 	int			s_io_wait_cnt;
346 	int			s_next_io_slot;
347 	uint32_t		s_io_need;
348 	uint32_t		s_io_had2wait;
349 	uint32_t		s_io_sig;
350 
351 	pqi_dma_overhead_t	*s_error_dma;
352 	pqi_dma_overhead_t	*s_adminq_dma;
353 	pqi_admin_queues_t	s_admin_queues;
354 	pqi_dma_overhead_t	*s_queue_dma;
355 	pqi_queue_group_t	s_queue_groups[PQI_MAX_QUEUE_GROUPS];
356 	pqi_event_queue_t	s_event_queue;
357 	struct pqi_event	s_events[PQI_NUM_SUPPORTED_EVENTS];
358 } *pqi_state_t;
359 
360 typedef struct pqi_device {
361 	list_node_t		pd_list;
362 	kmutex_t		pd_mutex;
363 
364 	/* ---- Protected by pd_mutex ---- */
365 	list_t			pd_cmd_list;
366 	int			pd_flags;
367 
368 	int			pd_active_cmds;
369 	int			pd_target;
370 	int 			pd_lun;
371 
372 	/* ---- Only one will be valid, MPxIO uses s_pip ---- */
373 	dev_info_t		*pd_dip;
374 	mdi_pathinfo_t		*pd_pip;
375 	mdi_pathinfo_t		*pd_pip_offlined;
376 
377 	dev_info_t		*pd_parent;
378 	int			pd_devtype;
379 	int			pd_online : 1;
380 	int			pd_scanned : 1;
381 	int			pd_phys_dev : 1;
382 	int			pd_external_raid : 1;
383 	int			pd_aio_enabled : 1;
384 	uint32_t		pd_aio_handle;
385 	char			pd_scsi3addr[8];
386 	uint64_t		pd_wwid;
387 	char			*pd_guid;
388 	uint8_t			pd_volume_id[16];
389 	char			pd_vendor[8];	/* From INQUIRY */
390 	char			pd_model[16];	/* From INQUIRY */
391 	char			pd_unit_address[32];
392 } *pqi_device_t;
393 
394 /* ---- Flags used in pqi_cmd_t ---- */
395 #define	PQI_FLAG_ABORTED	0x0001
396 #define	PQI_FLAG_TIMED_OUT	0x0002
397 #define	PQI_FLAG_RESET		0x0004
398 #define	PQI_FLAG_IO_IOPB	0x0040
399 #define	PQI_FLAG_DMA_VALID	0x0100
400 #define	PQI_FLAG_CDB_EXT	0x0200
401 #define	PQI_FLAG_SCB_EXT	0x0400
402 #define	PQI_FLAG_PRIV_EXT	0x0800
403 #define	PQI_FLAG_IO_READ	0x1000
404 #define	PQI_FLAG_IO_BOUNCE	0x2000
405 #define	PQI_FLAG_FINISHING	0x4000
406 
407 typedef enum pqi_cmd_state {
408 	PQI_CMD_UNINIT		= 0,
409 	PQI_CMD_CONSTRUCT,
410 	PQI_CMD_INIT,
411 	PQI_CMD_QUEUED,
412 	PQI_CMD_STARTED,
413 	PQI_CMD_CMPLT,
414 	PQI_CMD_FATAL,
415 	PQI_CMD_DESTRUCT
416 } pqi_cmd_state_t;
417 
418 #define	PQI_FLAGS_PERSISTENT	\
419 	(PQI_FLAG_DMA_VALID	|\
420 	PQI_FLAG_IO_IOPB)
421 
422 #define	PQI_FLAGS_NON_HW_COMPLETION \
423 	(PQI_FLAG_ABORTED	|\
424 	PQI_FLAG_TIMED_OUT	|\
425 	PQI_FLAG_RESET)
426 
427 typedef struct pqi_cmd {
428 	list_node_t		pc_list;
429 	pqi_cmd_state_t		pc_cmd_state;
430 	pqi_cmd_state_t		pc_last_state;
431 	struct scsi_pkt		*pc_pkt;
432 	pqi_state_t		pc_softc;
433 	pqi_device_t		pc_device;
434 	ksema_t			*pc_poll;
435 	uint8_t			pc_cdb[SCSI_CDB_SIZE];
436 	struct scsi_arq_status	pc_cmd_scb;
437 
438 	uint64_t		pc_tgt_priv[2];
439 	int			pc_dma_count;	/* bytes to transfer */
440 
441 	/*
442 	 * Setting/clearing/testing of ABORT and FINISHING are
443 	 * protected by pqi_device->pd_mutex. The other bits in
444 	 * this flag are set during init_pkt and read only during
445 	 * cleanup.
446 	 */
447 	int			pc_flags;
448 
449 	int			pc_tgtlen;
450 	int			pc_statuslen;
451 	int			pc_cmdlen;
452 	hrtime_t		pc_expiration;
453 	hrtime_t		pc_start_time;
454 
455 	/* ---- For partial DMA transfers ---- */
456 	uint_t			pc_nwin;
457 	uint_t			pc_winidx;
458 	off_t			pc_dma_offset;
459 	size_t			pc_dma_len;
460 
461 	/* ---- Valid after call to pqi_transport_command ---- */
462 	pqi_io_request_t	*pc_io_rqst;
463 
464 	ddi_dma_handle_t	pc_dmahdl;
465 	ddi_dma_cookie_t	pc_dmac;
466 	uint_t			pc_dmaccount;	/* cookie count */
467 	struct scsi_pkt		pc_cached_pkt;
468 	ddi_dma_cookie_t	pc_cached_cookies[PQI_MAX_SCATTER_GATHER];
469 } *pqi_cmd_t;
470 
471 /* ---- configuration table section IDs ---- */
472 #define	PQI_CONFIG_TABLE_SECTION_GENERAL_INFO		0
473 #define	PQI_CONFIG_TABLE_SECTION_FIRMWARE_FEATURES	1
474 #define	PQI_CONFIG_TABLE_SECTION_FIRMWARE_ERRATA	2
475 #define	PQI_CONFIG_TABLE_SECTION_DEBUG			3
476 #define	PQI_CONFIG_TABLE_SECTION_HEARTBEAT		4
477 
478 /* ---- manifest constants for the flags field of pqi_sg_descriptor ---- */
479 #define	CISS_SG_NORMAL				0x00000000
480 #define	CISS_SG_LAST				0x40000000
481 #define	CISS_SG_CHAIN				0x80000000
482 
483 /*
484  * According to the PQI spec, the IU header is only the first 4 bytes of our
485  * pqi_iu_header structure.
486  */
487 #define	PQI_REQUEST_HEADER_LENGTH			4
488 #define	PQI_REQUEST_IU_TASK_MANAGEMENT			0x13
489 #define	PQI_REQUEST_IU_RAID_PATH_IO			0x14
490 #define	PQI_REQUEST_IU_AIO_PATH_IO			0x15
491 #define	PQI_REQUEST_IU_GENERAL_ADMIN			0x60
492 #define	PQI_REQUEST_IU_REPORT_VENDOR_EVENT_CONFIG	0x72
493 #define	PQI_REQUEST_IU_SET_VENDOR_EVENT_CONFIG		0x73
494 #define	PQI_REQUEST_IU_ACKNOWLEDGE_VENDOR_EVENT		0xf6
495 
496 #define	MASKED_DEVICE(lunid)				((lunid)[3] & 0xc0)
497 
498 /* ---- Defines for PQI mode ---- */
499 #define	IRQ_MODE_NONE			0x00
500 #define	VPD_PAGE			(1 << 8)
501 
502 /* ---- Defines for use in Legacy mode ---- */
503 #define	SIS_CTRL_KERNEL_UP		0x080
504 #define	SIS_CTRL_KERNEL_PANIC		0x100
505 #define	SIS_MODE			0x0
506 #define	PQI_MODE			0x1
507 
508 /* ---- smartpqi_main.c ---- */
509 void *pqi_state;
510 extern int pqi_do_scan;
511 extern int pqi_do_ctrl;
512 
513 /* ---- smartpqi_intr.c ---- */
514 int smartpqi_register_intrs(pqi_state_t);
515 void smartpqi_unregister_intrs(pqi_state_t);
516 void pqi_process_io_intr(pqi_state_t s, pqi_queue_group_t *qg);
517 
518 /* ---- smartpqi_sis.c ---- */
519 boolean_t sis_reenable_mode(pqi_state_t s);
520 void sis_write_scratch(pqi_state_t s, int mode);
521 uint32_t sis_read_scratch(pqi_state_t s);
522 boolean_t sis_wait_for_ctrl_ready(pqi_state_t s);
523 boolean_t sis_get_ctrl_props(pqi_state_t s);
524 boolean_t sis_init_base_struct_addr(pqi_state_t s);
525 boolean_t sis_get_pqi_capabilities(pqi_state_t s);
526 
527 /* ---- smartpqi_init.c ---- */
528 void pqi_free_io_resource(pqi_state_t s);
529 boolean_t pqi_scsi_inquiry(pqi_state_t s, pqi_device_t dev, int vpd,
530     struct scsi_inquiry *inq, int len);
531 void pqi_rescan_devices(pqi_state_t s);
532 boolean_t pqi_check_firmware(pqi_state_t s);
533 boolean_t pqi_prep_full(pqi_state_t s);
534 boolean_t pqi_hba_reset(pqi_state_t s);
535 
536 /* ---- smartpqi_hba.c ---- */
537 int smartpqi_register_hba(pqi_state_t);
538 void smartpqi_unregister_hba(pqi_state_t);
539 pqi_device_t pqi_find_target_ua(pqi_state_t s, char *);
540 int pqi_cache_constructor(void *buf, void *un, int flags);
541 void pqi_cache_destructor(void *buf, void *un);
542 int pqi_config_all(dev_info_t *pdip, pqi_state_t s);
543 void pqi_quiesced_notify(pqi_state_t s);
544 
545 /* ---- smartpqi_hw.c ---- */
546 void pqi_start_io(pqi_state_t s, pqi_queue_group_t *qg, pqi_path_t path,
547     pqi_io_request_t *io);
548 int pqi_transport_command(pqi_state_t s, pqi_cmd_t cmd);
549 void pqi_fail_cmd(pqi_cmd_t cmd, uchar_t reason, uint_t stats);
550 void pqi_fail_drive_cmds(pqi_device_t devp);
551 void pqi_watchdog(void *v);
552 void pqi_do_rescan(void *v);
553 void pqi_event_worker(void *v);
554 uint32_t pqi_disable_intr(pqi_state_t s);
555 void pqi_enable_intr(pqi_state_t s, uint32_t old_state);
556 boolean_t pqi_lun_reset(pqi_state_t s, pqi_device_t d);
557 
558 /* ---- smartpqi_util.c ---- */
559 pqi_dma_overhead_t *pqi_alloc_single(pqi_state_t s, size_t len);
560 void pqi_free_single(pqi_state_t s, pqi_dma_overhead_t *d);
561 pqi_io_request_t *pqi_alloc_io(pqi_state_t s);
562 void pqi_free_io(pqi_io_request_t *io);
563 void pqi_dump_io(pqi_io_request_t *io);
564 void pqi_cmd_sm(pqi_cmd_t cmd, pqi_cmd_state_t new_state, boolean_t grab_lock);
565 char *pqi_event_to_str(uint8_t event);
566 int pqi_map_event(uint8_t event);
567 boolean_t pqi_supported_event(uint8_t event_type);
568 char *bool_to_str(int v);
569 char *dtype_to_str(int t);
570 int pqi_is_offline(pqi_state_t s);
571 void pqi_show_dev_state(pqi_state_t s);
572 void pqi_mem_check(void *v);
573 char *cdb_to_str(uint8_t scsi_cmd);
574 char *io_status_to_str(int val);
575 char *scsi_status_to_str(uint8_t val);
576 char *iu_type_to_str(int val);
577 
578 #ifdef __cplusplus
579 }
580 #endif
581 
582 #endif /* _SMARTPQI_H */
583