mpt.h revision 147883
1101704Smjacob/* $FreeBSD: head/sys/dev/mpt/mpt.h 147883 2005-07-10 15:05:39Z scottl $ */
2139749Simp/*-
3101704Smjacob * Generic defines for LSI '909 FC  adapters.
4101704Smjacob * FreeBSD Version.
5101704Smjacob *
6101704Smjacob * Copyright (c)  2000, 2001 by Greg Ansley
7101704Smjacob *
8101704Smjacob * Redistribution and use in source and binary forms, with or without
9101704Smjacob * modification, are permitted provided that the following conditions
10101704Smjacob * are met:
11101704Smjacob * 1. Redistributions of source code must retain the above copyright
12101704Smjacob *    notice immediately at the beginning of the file, without modification,
13101704Smjacob *    this list of conditions, and the following disclaimer.
14101704Smjacob * 2. The name of the author may not be used to endorse or promote products
15101704Smjacob *    derived from this software without specific prior written permission.
16101704Smjacob *
17101704Smjacob * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18101704Smjacob * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19101704Smjacob * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20101704Smjacob * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
21101704Smjacob * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22101704Smjacob * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23101704Smjacob * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24101704Smjacob * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25101704Smjacob * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26101704Smjacob * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27101704Smjacob * SUCH DAMAGE.
28147883Sscottl *
29147883Sscottl * Additional Copyright (c) 2002 by Matthew Jacob under same license.
30101704Smjacob */
31101704Smjacob/*
32147883Sscottl * Copyright (c) 2004, Avid Technology, Inc. and its contributors.
33147883Sscottl * Copyright (c) 2004, 2005 Justin T. Gibbs
34147883Sscottl * Copyright (c) 2005, WHEEL Sp. z o.o.
35147883Sscottl * All rights reserved.
36147883Sscottl *
37147883Sscottl * Redistribution and use in source and binary forms, with or without
38147883Sscottl * modification, are permitted provided that the following conditions are
39147883Sscottl * met:
40147883Sscottl * 1. Redistributions of source code must retain the above copyright
41147883Sscottl *    notice, this list of conditions and the following disclaimer.
42147883Sscottl * 2. Redistributions in binary form must reproduce at minimum a disclaimer
43147883Sscottl *    substantially similar to the "NO WARRANTY" disclaimer below
44147883Sscottl *    ("Disclaimer") and any redistribution must be conditioned upon including
45147883Sscottl *    a substantially similar Disclaimer requirement for further binary
46147883Sscottl *    redistribution.
47147883Sscottl * 3. Neither the name of the LSI Logic Corporation nor the names of its
48147883Sscottl *    contributors may be used to endorse or promote products derived from
49147883Sscottl *    this software without specific prior written permission.
50147883Sscottl *
51147883Sscottl * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
52147883Sscottl * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
53147883Sscottl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
54147883Sscottl * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
55147883Sscottl * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
56147883Sscottl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
57147883Sscottl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
58147883Sscottl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
59147883Sscottl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
60147883Sscottl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT
61147883Sscottl * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62101704Smjacob */
63101704Smjacob
64101704Smjacob#ifndef _MPT_H_
65101704Smjacob#define _MPT_H_
66147883Sscottl
67147883Sscottl/********************************* OS Includes ********************************/
68147883Sscottl#include <sys/types.h>
69147883Sscottl#include <sys/param.h>
70147883Sscottl#include <sys/systm.h>
71147883Sscottl#include <sys/endian.h>
72147883Sscottl#include <sys/eventhandler.h>
73147883Sscottl#if __FreeBSD_version < 500000
74147883Sscottl#include <sys/kernel.h>
75147883Sscottl#include <sys/queue.h>
76147883Sscottl#include <sys/malloc.h>
77147883Sscottl#else
78147883Sscottl#include <sys/lock.h>
79147883Sscottl#include <sys/kernel.h>
80147883Sscottl#include <sys/queue.h>
81147883Sscottl#include <sys/malloc.h>
82147883Sscottl#include <sys/mutex.h>
83147883Sscottl#include <sys/condvar.h>
84147883Sscottl#endif
85147883Sscottl#include <sys/proc.h>
86147883Sscottl#include <sys/bus.h>
87147883Sscottl#include <sys/module.h>
88147883Sscottl
89147883Sscottl#include <machine/bus.h>
90147883Sscottl#include <machine/clock.h>
91147883Sscottl#include <machine/cpu.h>
92147883Sscottl#include <machine/resource.h>
93147883Sscottl
94147883Sscottl#include <sys/rman.h>
95147883Sscottl
96147883Sscottl#include "opt_ddb.h"
97147883Sscottl
98147883Sscottl/**************************** Register Definitions ****************************/
99147883Sscottl#include <dev/mpt/mpt_reg.h>
100147883Sscottl
101147883Sscottl/******************************* MPI Definitions ******************************/
102147883Sscottl#include <dev/mpt/mpilib/mpi_type.h>
103147883Sscottl#include <dev/mpt/mpilib/mpi.h>
104147883Sscottl#include <dev/mpt/mpilib/mpi_cnfg.h>
105147883Sscottl#include <dev/mpt/mpilib/mpi_ioc.h>
106147883Sscottl#include <dev/mpt/mpilib/mpi_raid.h>
107147883Sscottl
108147883Sscottl/* XXX For mpt_debug.c */
109147883Sscottl#include <dev/mpt/mpilib/mpi_init.h>
110147883Sscottl
111147883Sscottl/****************************** Misc Definitions ******************************/
112101704Smjacob#define MPT_OK (0)
113101704Smjacob#define MPT_FAIL (0x10000)
114101704Smjacob
115147883Sscottl#define NUM_ELEMENTS(array) (sizeof(array) / sizeof(*array))
116101704Smjacob
117147883Sscottl/**************************** Forward Declarations ****************************/
118147883Sscottlstruct mpt_softc;
119147883Sscottlstruct mpt_personality;
120147883Sscottltypedef struct req_entry request_t;
121101704Smjacob
122147883Sscottl/************************* Personality Module Support *************************/
123147883Sscottltypedef int mpt_load_handler_t(struct mpt_personality *);
124147883Sscottltypedef int mpt_probe_handler_t(struct mpt_softc *);
125147883Sscottltypedef int mpt_attach_handler_t(struct mpt_softc *);
126147883Sscottltypedef int mpt_event_handler_t(struct mpt_softc *, request_t *,
127147883Sscottl				MSG_EVENT_NOTIFY_REPLY *);
128147883Sscottltypedef void mpt_reset_handler_t(struct mpt_softc *, int /*type*/);
129147883Sscottl/* XXX Add return value and use for veto? */
130147883Sscottltypedef void mpt_shutdown_handler_t(struct mpt_softc *);
131147883Sscottltypedef void mpt_detach_handler_t(struct mpt_softc *);
132147883Sscottltypedef int mpt_unload_handler_t(struct mpt_personality *);
133147883Sscottl
134147883Sscottlstruct mpt_personality
135147883Sscottl{
136147883Sscottl	const char		*name;
137147883Sscottl	uint32_t		 id;		/* Assigned identifier. */
138147883Sscottl	u_int			 use_count;	/* Instances using personality*/
139147883Sscottl	mpt_load_handler_t	*load;		/* configure personailty */
140147883Sscottl#define MPT_PERS_FIRST_HANDLER(pers) (&(pers)->load)
141147883Sscottl	mpt_probe_handler_t	*probe;		/* configure personailty */
142147883Sscottl	mpt_attach_handler_t	*attach;	/* initialize device instance */
143147883Sscottl	mpt_event_handler_t	*event;		/* Handle MPI event. */
144147883Sscottl	mpt_reset_handler_t	*reset;		/* Re-init after reset. */
145147883Sscottl	mpt_shutdown_handler_t	*shutdown;	/* Shutdown instance. */
146147883Sscottl	mpt_detach_handler_t	*detach;	/* release device instance */
147147883Sscottl	mpt_unload_handler_t	*unload;	/* Shutdown personality */
148147883Sscottl#define MPT_PERS_LAST_HANDLER(pers) (&(pers)->unload)
149101704Smjacob};
150101704Smjacob
151147883Sscottlint mpt_modevent(module_t, int, void *);
152101704Smjacob
153147883Sscottl/* Maximum supported number of personalities. */
154147883Sscottl#define MPT_MAX_PERSONALITIES	(15)
155101704Smjacob
156147883Sscottl#define MPT_PERSONALITY_DEPEND(name, dep, vmin, vpref, vmax) \
157147883Sscottl	MODULE_DEPEND(name, dep, vmin, vpref, vmax)
158101704Smjacob
159147883Sscottl#define DECLARE_MPT_PERSONALITY(name, order)				  \
160147883Sscottl	static moduledata_t name##_mod = {				  \
161147883Sscottl		#name, mpt_modevent, &name##_personality		  \
162147883Sscottl	};								  \
163147883Sscottl	DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, order);	  \
164147883Sscottl	MODULE_VERSION(name, 1);					  \
165147883Sscottl	MPT_PERSONALITY_DEPEND(name, mpt_core, 1, 1, 1)
166147883Sscottl
167147883Sscottl/******************************* Bus DMA Support ******************************/
168147883Sscottl/* XXX Need to update bus_dmamap_sync to take a range argument. */
169147883Sscottl#define bus_dmamap_sync_range(dma_tag, dmamap, offset, len, op)	\
170147883Sscottl	bus_dmamap_sync(dma_tag, dmamap, op)
171147883Sscottl
172147883Sscottl#if __FreeBSD_version >= 501102
173147883Sscottl#define mpt_dma_tag_create(mpt, parent_tag, alignment, boundary,	\
174147883Sscottl			   lowaddr, highaddr, filter, filterarg,	\
175147883Sscottl			   maxsize, nsegments, maxsegsz, flags,		\
176147883Sscottl			   dma_tagp)					\
177147883Sscottl	bus_dma_tag_create(parent_tag, alignment, boundary,		\
178147883Sscottl			   lowaddr, highaddr, filter, filterarg,	\
179147883Sscottl			   maxsize, nsegments, maxsegsz, flags,		\
180147883Sscottl			   busdma_lock_mutex, &Giant,			\
181147883Sscottl			   dma_tagp)
182147883Sscottl#else
183147883Sscottl#define mpt_dma_tag_create(mpt, parent_tag, alignment, boundary,	\
184147883Sscottl			   lowaddr, highaddr, filter, filterarg,	\
185147883Sscottl			   maxsize, nsegments, maxsegsz, flags,		\
186147883Sscottl			   dma_tagp)					\
187147883Sscottl	bus_dma_tag_create(parent_tag, alignment, boundary,		\
188147883Sscottl			   lowaddr, highaddr, filter, filterarg,	\
189147883Sscottl			   maxsize, nsegments, maxsegsz, flags,		\
190147883Sscottl			   dma_tagp)
191147883Sscottl#endif
192147883Sscottl
193147883Sscottlstruct mpt_map_info {
194147883Sscottl	struct mpt_softc *mpt;
195147883Sscottl	int		  error;
196147883Sscottl	uint32_t	  phys;
197147883Sscottl};
198147883Sscottl
199147883Sscottlvoid mpt_map_rquest(void *, bus_dma_segment_t *, int, int);
200147883Sscottl
201147883Sscottl/**************************** Kernel Thread Support ***************************/
202147883Sscottl#if __FreeBSD_version > 500005
203147883Sscottl#define mpt_kthread_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg) \
204147883Sscottl	kthread_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg)
205147883Sscottl#else
206147883Sscottl#define mpt_kthread_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg) \
207147883Sscottl	kthread_create(func, farg, proc_ptr, fmtstr, arg)
208147883Sscottl#endif
209147883Sscottl
210147883Sscottl/****************************** Timer Facilities ******************************/
211147883Sscottl#if __FreeBSD_version > 500000
212147883Sscottl#define mpt_callout_init(c)	callout_init(c, /*mpsafe*/0);
213147883Sscottl#else
214147883Sscottl#define mpt_callout_init(c)	callout_init(c);
215147883Sscottl#endif
216147883Sscottl
217147883Sscottl/********************************** Endianess *********************************/
218147883Sscottlstatic __inline uint64_t
219147883Sscottlu64toh(U64 s)
220147883Sscottl{
221147883Sscottl	uint64_t result;
222147883Sscottl
223147883Sscottl	result = le32toh(s.Low);
224147883Sscottl	result |= ((uint64_t)le32toh(s.High)) << 32;
225147883Sscottl	return (result);
226147883Sscottl}
227147883Sscottl
228147883Sscottl/**************************** MPI Transaction State ***************************/
229147883Sscottltypedef enum {
230147883Sscottl	REQ_STATE_FREE		= 0x00,
231147883Sscottl	REQ_STATE_ALLOCATED	= 0x01,
232147883Sscottl	REQ_STATE_QUEUED	= 0x02,
233147883Sscottl	REQ_STATE_DONE		= 0x04,
234147883Sscottl	REQ_STATE_TIMEDOUT	= 0x08,
235147883Sscottl	REQ_STATE_NEED_WAKEUP	= 0x10,
236147883Sscottl	REQ_STATE_MASK		= 0xFF
237147883Sscottl} mpt_req_state_t;
238147883Sscottl
239147883Sscottlstruct req_entry {
240147883Sscottl	TAILQ_ENTRY(req_entry) links;	/* Pointer to next in list */
241147883Sscottl	mpt_req_state_t	state;		/* Request State Information */
242147883Sscottl	uint16_t	index;		/* Index of this entry */
243147883Sscottl	uint16_t	IOCStatus;	/* Completion status */
244147883Sscottl	union ccb      *ccb;		/* CAM request */
245147883Sscottl	void	       *req_vbuf;	/* Virtual Address of Entry */
246147883Sscottl	void	       *sense_vbuf;	/* Virtual Address of sense data */
247147883Sscottl	bus_addr_t	req_pbuf;	/* Physical Address of Entry */
248147883Sscottl	bus_addr_t	sense_pbuf;	/* Physical Address of sense data */
249147883Sscottl	bus_dmamap_t	dmap;		/* DMA map for data buffer */
250147883Sscottl};
251147883Sscottl
252147883Sscottl/**************************** Handler Registration ****************************/
253101704Smjacob/*
254147883Sscottl * Global table of registered reply handlers.  The
255147883Sscottl * handler is indicated by byte 3 of the request
256147883Sscottl * index submitted to the IOC.  This allows the
257147883Sscottl * driver core to perform generic processing without
258147883Sscottl * any knowledge of per-personality behavior.
259147883Sscottl *
260147883Sscottl * MPT_NUM_REPLY_HANDLERS must be a power of 2
261147883Sscottl * to allow the easy generation of a mask.
262147883Sscottl *
263147883Sscottl * The handler offsets used by the core are hard coded
264147883Sscottl * allowing faster code generation when assigning a handler
265147883Sscottl * to a request.  All "personalities" must use the
266147883Sscottl * the handler registration mechanism.
267147883Sscottl *
268147883Sscottl * The IOC handlers that are rarely executed are placed
269147883Sscottl * at the tail of the table to make it more likely that
270147883Sscottl * all commonly executed handlers fit in a single cache
271147883Sscottl * line.
272101704Smjacob */
273147883Sscottl#define MPT_NUM_REPLY_HANDLERS		(16)
274147883Sscottl#define MPT_REPLY_HANDLER_EVENTS	MPT_CBI_TO_HID(0)
275147883Sscottl#define MPT_REPLY_HANDLER_CONFIG	MPT_CBI_TO_HID(MPT_NUM_REPLY_HANDLERS-1)
276147883Sscottl#define MPT_REPLY_HANDLER_HANDSHAKE	MPT_CBI_TO_HID(MPT_NUM_REPLY_HANDLERS-2)
277147883Sscottltypedef int mpt_reply_handler_t(struct mpt_softc *mpt, request_t *request,
278147883Sscottl				 MSG_DEFAULT_REPLY *reply_frame);
279147883Sscottltypedef union {
280147883Sscottl	mpt_reply_handler_t	*reply_handler;
281147883Sscottl} mpt_handler_t;
282101704Smjacob
283147883Sscottltypedef enum {
284147883Sscottl	MPT_HANDLER_REPLY,
285147883Sscottl	MPT_HANDLER_EVENT,
286147883Sscottl	MPT_HANDLER_RESET,
287147883Sscottl	MPT_HANDLER_SHUTDOWN
288147883Sscottl} mpt_handler_type;
289101704Smjacob
290147883Sscottlstruct mpt_handler_record
291147883Sscottl{
292147883Sscottl	LIST_ENTRY(mpt_handler_record)	links;
293147883Sscottl	mpt_handler_t			handler;
294101704Smjacob};
295101704Smjacob
296147883SscottlLIST_HEAD(mpt_handler_list, mpt_handler_record);
297147883Sscottl
298147883Sscottl/*
299147883Sscottl * The handler_id is currently unused but would contain the
300147883Sscottl * handler ID used in the MsgContext field to allow direction
301147883Sscottl * of replies to the handler.  Registrations that don't require
302147883Sscottl * a handler id can pass in NULL for the handler_id.
303147883Sscottl *
304147883Sscottl * Deregistrations for handlers without a handler id should
305147883Sscottl * pass in MPT_HANDLER_ID_NONE.
306147883Sscottl */
307147883Sscottl#define MPT_HANDLER_ID_NONE		(0xFFFFFFFF)
308147883Sscottlint mpt_register_handler(struct mpt_softc *, mpt_handler_type,
309147883Sscottl			 mpt_handler_t, uint32_t *);
310147883Sscottlint mpt_deregister_handler(struct mpt_softc *, mpt_handler_type,
311147883Sscottl			   mpt_handler_t, uint32_t);
312147883Sscottl
313147883Sscottl/******************* Per-Controller Instance Data Structures ******************/
314147883SscottlTAILQ_HEAD(req_queue, req_entry);
315147883Sscottl
316147883Sscottl/* Structure for saving proper values for modifyable PCI config registers */
317147883Sscottlstruct mpt_pci_cfg {
318147883Sscottl	uint16_t Command;
319147883Sscottl	uint16_t LatencyTimer_LineSize;
320147883Sscottl	uint32_t IO_BAR;
321147883Sscottl	uint32_t Mem0_BAR[2];
322147883Sscottl	uint32_t Mem1_BAR[2];
323147883Sscottl	uint32_t ROM_BAR;
324147883Sscottl	uint8_t  IntLine;
325147883Sscottl	uint32_t PMCSR;
326101704Smjacob};
327101704Smjacob
328147883Sscottltypedef enum {
329147883Sscottl	MPT_RVF_NONE		= 0x0,
330147883Sscottl	MPT_RVF_ACTIVE		= 0x1,
331147883Sscottl	MPT_RVF_ANNOUNCED	= 0x2,
332147883Sscottl	MPT_RVF_UP2DATE		= 0x4,
333147883Sscottl	MPT_RVF_REFERENCED	= 0x8,
334147883Sscottl	MPT_RVF_WCE_CHANGED	= 0x10
335147883Sscottl} mpt_raid_volume_flags;
336101704Smjacob
337147883Sscottlstruct mpt_raid_volume {
338147883Sscottl	CONFIG_PAGE_RAID_VOL_0	       *config_page;
339147883Sscottl	MPI_RAID_VOL_INDICATOR		sync_progress;
340147883Sscottl	mpt_raid_volume_flags		flags;
341147883Sscottl	u_int				quieced_disks;
342101704Smjacob};
343101704Smjacob
344147883Sscottltypedef enum {
345147883Sscottl	MPT_RDF_NONE		= 0x00,
346147883Sscottl	MPT_RDF_ACTIVE		= 0x01,
347147883Sscottl	MPT_RDF_ANNOUNCED	= 0x02,
348147883Sscottl	MPT_RDF_UP2DATE		= 0x04,
349147883Sscottl	MPT_RDF_REFERENCED	= 0x08,
350147883Sscottl	MPT_RDF_QUIESCING	= 0x10,
351147883Sscottl	MPT_RDF_QUIESCED	= 0x20
352147883Sscottl} mpt_raid_disk_flags;
353147883Sscottl
354147883Sscottlstruct mpt_raid_disk {
355147883Sscottl	CONFIG_PAGE_RAID_PHYS_DISK_0	config_page;
356147883Sscottl	struct mpt_raid_volume	       *volume;
357147883Sscottl	u_int				member_number;
358147883Sscottl	u_int				pass_thru_active;
359147883Sscottl	mpt_raid_disk_flags		flags;
360101704Smjacob};
361101704Smjacob
362147883Sscottlstruct mpt_evtf_record {
363147883Sscottl	MSG_EVENT_NOTIFY_REPLY		reply;
364147883Sscottl	uint32_t			context;
365147883Sscottl	LIST_ENTRY(mpt_evtf_record)	links;
366147883Sscottl};
367101704Smjacob
368147883SscottlLIST_HEAD(mpt_evtf_list, mpt_evtf_record);
369101704Smjacob
370147883Sscottlstruct mpt_softc {
371147883Sscottl	device_t		dev;
372147883Sscottl#if __FreeBSD_version < 500000
373147883Sscottl	int			mpt_splsaved;
374147883Sscottl	uint32_t		mpt_islocked;
375147883Sscottl#else
376147883Sscottl	struct mtx		mpt_lock;
377147883Sscottl#endif
378147883Sscottl	uint32_t		mpt_pers_mask;
379147883Sscottl	uint32_t		: 15,
380147883Sscottl		raid_mwce_set	: 1,
381147883Sscottl		getreqwaiter	: 1,
382147883Sscottl		shutdwn_raid    : 1,
383147883Sscottl		shutdwn_recovery: 1,
384147883Sscottl		unit		: 8,
385147883Sscottl		outofbeer	: 1,
386147883Sscottl		mpt_locksetup	: 1,
387147883Sscottl		disabled	: 1,
388147883Sscottl		is_fc		: 1,
389147883Sscottl		bus		: 1;	/* FC929/1030 have two busses */
390101704Smjacob
391147883Sscottl	u_int			verbose;
392101704Smjacob
393147883Sscottl	/*
394147883Sscottl	 * IOC Facts
395147883Sscottl	 */
396147883Sscottl	uint16_t	mpt_global_credits;
397147883Sscottl	uint16_t	request_frame_size;
398147883Sscottl	uint8_t		mpt_max_devices;
399147883Sscottl	uint8_t		mpt_max_buses;
400101704Smjacob
401147883Sscottl	/*
402147883Sscottl	 * Port Facts
403147883Sscottl	 * XXX - Add multi-port support!.
404147883Sscottl	 */
405147883Sscottl	uint16_t	mpt_ini_id;
406147883Sscottl	uint16_t	mpt_port_type;
407147883Sscottl	uint16_t	mpt_proto_flags;
408102822Smjacob
409147883Sscottl	/*
410147883Sscottl	 * Device Configuration Information
411147883Sscottl	 */
412147883Sscottl	union {
413147883Sscottl		struct mpt_spi_cfg {
414147883Sscottl			CONFIG_PAGE_SCSI_PORT_0		_port_page0;
415147883Sscottl			CONFIG_PAGE_SCSI_PORT_1		_port_page1;
416147883Sscottl			CONFIG_PAGE_SCSI_PORT_2		_port_page2;
417147883Sscottl			CONFIG_PAGE_SCSI_DEVICE_0	_dev_page0[16];
418147883Sscottl			CONFIG_PAGE_SCSI_DEVICE_1	_dev_page1[16];
419147883Sscottl			uint16_t			_tag_enable;
420147883Sscottl			uint16_t			_disc_enable;
421147883Sscottl			uint16_t			_update_params0;
422147883Sscottl			uint16_t			_update_params1;
423147883Sscottl		} spi;
424147883Sscottl#define	mpt_port_page0		cfg.spi._port_page0
425147883Sscottl#define	mpt_port_page1		cfg.spi._port_page1
426147883Sscottl#define	mpt_port_page2		cfg.spi._port_page2
427147883Sscottl#define	mpt_dev_page0		cfg.spi._dev_page0
428147883Sscottl#define	mpt_dev_page1		cfg.spi._dev_page1
429147883Sscottl#define	mpt_tag_enable		cfg.spi._tag_enable
430147883Sscottl#define	mpt_disc_enable		cfg.spi._disc_enable
431147883Sscottl#define	mpt_update_params0	cfg.spi._update_params0
432147883Sscottl#define	mpt_update_params1	cfg.spi._update_params1
433147883Sscottl		struct mpi_fc_cfg {
434147883Sscottl			uint8_t	nada;
435147883Sscottl		} fc;
436147883Sscottl	} cfg;
437147883Sscottl
438147883Sscottl	/* Controller Info */
439147883Sscottl	CONFIG_PAGE_IOC_2 *	ioc_page2;
440147883Sscottl	CONFIG_PAGE_IOC_3 *	ioc_page3;
441147883Sscottl
442147883Sscottl	/* Raid Data */
443147883Sscottl	struct mpt_raid_volume* raid_volumes;
444147883Sscottl	struct mpt_raid_disk*	raid_disks;
445147883Sscottl	u_int			raid_max_volumes;
446147883Sscottl	u_int			raid_max_disks;
447147883Sscottl	u_int			raid_page0_len;
448147883Sscottl	u_int			raid_wakeup;
449147883Sscottl	u_int			raid_rescan;
450147883Sscottl	u_int			raid_resync_rate;
451147883Sscottl	u_int			raid_mwce_setting;
452147883Sscottl	u_int			raid_queue_depth;
453147883Sscottl	struct proc	       *raid_thread;
454147883Sscottl	struct callout		raid_timer;
455147883Sscottl
456147883Sscottl	/*
457147883Sscottl	 * PCI Hardware info
458147883Sscottl	 */
459147883Sscottl	struct resource *	pci_irq;	/* Interrupt map for chip */
460147883Sscottl	void *			ih;		/* Interupt handle */
461147883Sscottl	struct mpt_pci_cfg	pci_cfg;	/* saved PCI conf registers */
462147883Sscottl
463147883Sscottl	/*
464147883Sscottl	 * DMA Mapping Stuff
465147883Sscottl	 */
466147883Sscottl	struct resource *	pci_reg;	/* Register map for chip */
467147883Sscottl	int			pci_mem_rid;	/* Resource ID */
468147883Sscottl	bus_space_tag_t		pci_st;		/* Bus tag for registers */
469147883Sscottl	bus_space_handle_t	pci_sh;		/* Bus handle for registers */
470147883Sscottl	/* PIO versions of above. */
471147883Sscottl	int			pci_pio_rid;
472147883Sscottl	struct resource *	pci_pio_reg;
473147883Sscottl	bus_space_tag_t		pci_pio_st;
474147883Sscottl	bus_space_handle_t	pci_pio_sh;
475147883Sscottl
476147883Sscottl	bus_dma_tag_t		parent_dmat;	/* DMA tag for parent PCI bus */
477147883Sscottl	bus_dma_tag_t		reply_dmat;	/* DMA tag for reply memory */
478147883Sscottl	bus_dmamap_t		reply_dmap;	/* DMA map for reply memory */
479147883Sscottl	uint8_t		       *reply;		/* KVA of reply memory */
480147883Sscottl	bus_addr_t		reply_phys;	/* BusAddr of reply memory */
481147883Sscottl
482147883Sscottl	bus_dma_tag_t		buffer_dmat;	/* DMA tag for buffers */
483147883Sscottl	bus_dma_tag_t		request_dmat;	/* DMA tag for request memroy */
484147883Sscottl	bus_dmamap_t		request_dmap;	/* DMA map for request memroy */
485147883Sscottl	uint8_t		       *request;	/* KVA of Request memory */
486147883Sscottl	bus_addr_t		request_phys;	/* BusADdr of request memory */
487147883Sscottl
488147883Sscottl	u_int			reset_cnt;
489147883Sscottl
490147883Sscottl	/*
491147883Sscottl	 * CAM && Software Management
492147883Sscottl	 */
493147883Sscottl	request_t	       *request_pool;
494147883Sscottl	struct req_queue	request_free_list;
495147883Sscottl	struct req_queue	request_pending_list;
496147883Sscottl	struct req_queue	request_timeout_list;
497147883Sscottl
498147883Sscottl	/*
499147883Sscottl	 * Deferred frame acks due to resource shortage.
500147883Sscottl	 */
501147883Sscottl	struct mpt_evtf_list	ack_frames;
502147883Sscottl
503147883Sscottl
504147883Sscottl	struct cam_sim	       *sim;
505147883Sscottl	struct cam_path	       *path;
506147883Sscottl
507147883Sscottl	struct cam_sim	       *phydisk_sim;
508147883Sscottl	struct cam_path	       *phydisk_path;
509147883Sscottl
510147883Sscottl	struct proc	       *recovery_thread;
511147883Sscottl	request_t	       *tmf_req;
512147883Sscottl
513147883Sscottl	uint32_t		sequence;	/* Sequence Number */
514147883Sscottl	uint32_t		timeouts;	/* timeout count */
515147883Sscottl	uint32_t		success;	/* successes afer timeout */
516147883Sscottl
517147883Sscottl	/* Opposing port in a 929 or 1030, or NULL */
518147883Sscottl	struct mpt_softc *	mpt2;
519147883Sscottl
520147883Sscottl	/* FW Image management */
521147883Sscottl	uint32_t		fw_image_size;
522147883Sscottl	uint8_t		       *fw_image;
523147883Sscottl	bus_dma_tag_t		fw_dmat;	/* DMA tag for firmware image */
524147883Sscottl	bus_dmamap_t		fw_dmap;	/* DMA map for firmware image */
525147883Sscottl	bus_addr_t		fw_phys;	/* BusAddr of request memory */
526147883Sscottl
527147883Sscottl	/* Shutdown Event Handler. */
528147883Sscottl	eventhandler_tag         eh;
529147883Sscottl
530147883Sscottl	TAILQ_ENTRY(mpt_softc)	links;
531147883Sscottl};
532147883Sscottl
533147883Sscottl/***************************** Locking Primatives *****************************/
534147883Sscottl#if __FreeBSD_version < 500000
535147883Sscottl#define	MPT_IFLAGS		INTR_TYPE_CAM
536147883Sscottl#define	MPT_LOCK(mpt)		mpt_lockspl(mpt)
537147883Sscottl#define	MPT_UNLOCK(mpt)		mpt_unlockspl(mpt)
538147883Sscottl#define	MPTLOCK_2_CAMLOCK	MPT_UNLOCK
539147883Sscottl#define	CAMLOCK_2_MPTLOCK	MPT_LOCK
540147883Sscottl#define	MPT_LOCK_SETUP(mpt)
541147883Sscottl#define	MPT_LOCK_DESTROY(mpt)
542147883Sscottl
543147883Sscottlstatic __inline void mpt_lockspl(struct mpt_softc *mpt);
544147883Sscottlstatic __inline void mpt_unlockspl(struct mpt_softc *mpt);
545147883Sscottl
546147883Sscottlstatic __inline void
547147883Sscottlmpt_lockspl(struct mpt_softc *mpt)
548147883Sscottl{
549147883Sscottl       int s;
550147883Sscottl
551147883Sscottl       s = splcam();
552147883Sscottl       if (mpt->mpt_islocked++ == 0) {
553147883Sscottl               mpt->mpt_splsaved = s;
554147883Sscottl       } else {
555147883Sscottl               splx(s);
556147883Sscottl	       panic("Recursed lock with mask: 0x%x\n", s);
557147883Sscottl       }
558147883Sscottl}
559147883Sscottl
560147883Sscottlstatic __inline void
561147883Sscottlmpt_unlockspl(struct mpt_softc *mpt)
562147883Sscottl{
563147883Sscottl       if (mpt->mpt_islocked) {
564147883Sscottl               if (--mpt->mpt_islocked == 0) {
565147883Sscottl                       splx(mpt->mpt_splsaved);
566147883Sscottl               }
567147883Sscottl       } else
568147883Sscottl	       panic("Negative lock count\n");
569147883Sscottl}
570147883Sscottl
571147883Sscottlstatic __inline int
572147883Sscottlmpt_sleep(struct mpt_softc *mpt, void *ident, int priority,
573147883Sscottl	   const char *wmesg, int timo)
574147883Sscottl{
575147883Sscottl	int saved_cnt;
576147883Sscottl	int saved_spl;
577147883Sscottl	int error;
578147883Sscottl
579147883Sscottl	KASSERT(mpt->mpt_islocked <= 1, ("Invalid lock count on tsleep"));
580147883Sscottl	saved_cnt = mpt->mpt_islocked;
581147883Sscottl	saved_spl = mpt->mpt_splsaved;
582147883Sscottl	mpt->mpt_islocked = 0;
583147883Sscottl	error = tsleep(ident, priority, wmesg, timo);
584147883Sscottl	KASSERT(mpt->mpt_islocked = 0, ("Invalid lock count on wakeup"));
585147883Sscottl	mpt->mpt_islocked = saved_cnt;
586147883Sscottl	mpt->mpt_splsaved = saved_spl;
587147883Sscottl	return (error);
588147883Sscottl}
589147883Sscottl
590147883Sscottl#else
591147883Sscottl#if	LOCKING_WORKED_AS_IT_SHOULD
592147883Sscottl#error "Shouldn't Be Here!"
593147883Sscottl#define	MPT_IFLAGS		INTR_TYPE_CAM | INTR_ENTROPY | INTR_MPSAFE
594147883Sscottl#define	MPT_LOCK_SETUP(mpt)						\
595147883Sscottl		mtx_init(&mpt->mpt_lock, "mpt", NULL, MTX_DEF);		\
596147883Sscottl		mpt->mpt_locksetup = 1
597147883Sscottl#define	MPT_LOCK_DESTROY(mpt)						\
598147883Sscottl	if (mpt->mpt_locksetup) {					\
599147883Sscottl		mtx_destroy(&mpt->mpt_lock);				\
600147883Sscottl		mpt->mpt_locksetup = 0;					\
601147883Sscottl	}
602147883Sscottl
603147883Sscottl#define	MPT_LOCK(mpt)		mtx_lock(&(mpt)->mpt_lock)
604147883Sscottl#define	MPT_UNLOCK(mpt)		mtx_unlock(&(mpt)->mpt_lock)
605147883Sscottl#define	MPTLOCK_2_CAMLOCK(mpt)	\
606147883Sscottl	mtx_unlock(&(mpt)->mpt_lock); mtx_lock(&Giant)
607147883Sscottl#define	CAMLOCK_2_MPTLOCK(mpt)	\
608147883Sscottl	mtx_unlock(&Giant); mtx_lock(&(mpt)->mpt_lock)
609147883Sscottl#define mpt_sleep(mpt, ident, priority, wmesg, timo) \
610147883Sscottl	msleep(ident, &(mpt)->mpt_lock, priority, wmesg, timo)
611147883Sscottl#else
612147883Sscottl#define	MPT_IFLAGS		INTR_TYPE_CAM | INTR_ENTROPY
613147883Sscottl#define	MPT_LOCK_SETUP(mpt)	do { } while (0)
614147883Sscottl#define	MPT_LOCK_DESTROY(mpt)	do { } while (0)
615147883Sscottl#define	MPT_LOCK(mpt)		do { } while (0)
616147883Sscottl#define	MPT_UNLOCK(mpt)		do { } while (0)
617147883Sscottl#define	MPTLOCK_2_CAMLOCK(mpt)	do { } while (0)
618147883Sscottl#define	CAMLOCK_2_MPTLOCK(mpt)	do { } while (0)
619147883Sscottl#define mpt_sleep(mpt, ident, priority, wmesg, timo) \
620147883Sscottl	tsleep(ident, priority, wmesg, timo)
621147883Sscottl#endif
622147883Sscottl#endif
623147883Sscottl
624147883Sscottl/******************************* Register Access ******************************/
625147883Sscottlstatic __inline void mpt_write(struct mpt_softc *, size_t, uint32_t);
626147883Sscottlstatic __inline uint32_t mpt_read(struct mpt_softc *, int);
627147883Sscottlstatic __inline void mpt_pio_write(struct mpt_softc *, size_t, uint32_t);
628147883Sscottlstatic __inline uint32_t mpt_pio_read(struct mpt_softc *, int);
629147883Sscottl
630147883Sscottlstatic __inline void
631147883Sscottlmpt_write(struct mpt_softc *mpt, size_t offset, uint32_t val)
632147883Sscottl{
633147883Sscottl	bus_space_write_4(mpt->pci_st, mpt->pci_sh, offset, val);
634147883Sscottl}
635147883Sscottl
636147883Sscottlstatic __inline uint32_t
637147883Sscottlmpt_read(struct mpt_softc *mpt, int offset)
638147883Sscottl{
639147883Sscottl	return (bus_space_read_4(mpt->pci_st, mpt->pci_sh, offset));
640147883Sscottl}
641147883Sscottl
642147883Sscottl/*
643147883Sscottl * Some operations (e.g. diagnostic register writes while the ARM proccessor
644147883Sscottl * is disabled), must be performed using "PCI pio" operations.  On non-PCI
645147883Sscottl * busses, these operations likely map to normal register accesses.
646147883Sscottl */
647147883Sscottlstatic __inline void
648147883Sscottlmpt_pio_write(struct mpt_softc *mpt, size_t offset, uint32_t val)
649147883Sscottl{
650147883Sscottl	bus_space_write_4(mpt->pci_pio_st, mpt->pci_pio_sh, offset, val);
651147883Sscottl}
652147883Sscottl
653147883Sscottlstatic __inline uint32_t
654147883Sscottlmpt_pio_read(struct mpt_softc *mpt, int offset)
655147883Sscottl{
656147883Sscottl	return (bus_space_read_4(mpt->pci_pio_st, mpt->pci_pio_sh, offset));
657147883Sscottl}
658147883Sscottl/*********************** Reply Frame/Request Management ***********************/
659147883Sscottl/* Max MPT Reply we are willing to accept (must be power of 2) */
660147883Sscottl#define MPT_REPLY_SIZE   	128
661147883Sscottl
662147883Sscottl#define MPT_MAX_REQUESTS(mpt)	((mpt)->is_fc ? 1024 : 256)
663147883Sscottl#define MPT_REQUEST_AREA 512
664147883Sscottl#define MPT_SENSE_SIZE    32	/* included in MPT_REQUEST_SIZE */
665147883Sscottl#define MPT_REQ_MEM_SIZE(mpt)	(MPT_MAX_REQUESTS(mpt) * MPT_REQUEST_AREA)
666147883Sscottl
667147883Sscottl#define MPT_CONTEXT_CB_SHIFT	(16)
668147883Sscottl#define MPT_CBI(handle)	(handle >> MPT_CONTEXT_CB_SHIFT)
669147883Sscottl#define MPT_CBI_TO_HID(cbi)	((cbi) << MPT_CONTEXT_CB_SHIFT)
670147883Sscottl#define MPT_CONTEXT_TO_CBI(x)	\
671147883Sscottl    (((x) >> MPT_CONTEXT_CB_SHIFT) & (MPT_NUM_REPLY_HANDLERS - 1))
672147883Sscottl#define MPT_CONTEXT_REQI_MASK 0xFFFF
673147883Sscottl#define MPT_CONTEXT_TO_REQI(x)	\
674147883Sscottl    ((x) & MPT_CONTEXT_REQI_MASK)
675147883Sscottl
676147883Sscottl/*
677147883Sscottl * Convert a 32bit physical address returned from IOC to an
678147883Sscottl * offset into our reply frame memory or the kvm address needed
679147883Sscottl * to access the data.  The returned address is only the low
680147883Sscottl * 32 bits, so mask our base physical address accordingly.
681147883Sscottl */
682147883Sscottl#define MPT_REPLY_BADDR(x)		\
683147883Sscottl	(x << 1)
684147883Sscottl#define MPT_REPLY_OTOV(m, i) 		\
685147883Sscottl	((void *)(&m->reply[i]))
686147883Sscottl
687147883Sscottl#define	MPT_DUMP_REPLY_FRAME(mpt, reply_frame)		\
688147883Sscottldo {							\
689147883Sscottl	if (mpt->verbose >= MPT_PRT_DEBUG)		\
690147883Sscottl		mpt_dump_reply_frame(mpt, reply_frame);	\
691147883Sscottl} while(0)
692147883Sscottl
693147883Sscottlstatic __inline uint32_t mpt_pop_reply_queue(struct mpt_softc *mpt);
694147883Sscottlstatic __inline void mpt_free_reply(struct mpt_softc *mpt, uint32_t ptr);
695147883Sscottl
696147883Sscottl/*
697147883Sscottl * Give the reply buffer back to the IOC after we have
698147883Sscottl * finished processing it.
699147883Sscottl */
700147883Sscottlstatic __inline void
701147883Sscottlmpt_free_reply(struct mpt_softc *mpt, uint32_t ptr)
702147883Sscottl{
703147883Sscottl     mpt_write(mpt, MPT_OFFSET_REPLY_Q, ptr);
704147883Sscottl}
705147883Sscottl
706147883Sscottl/* Get a reply from the IOC */
707147883Sscottlstatic __inline uint32_t
708147883Sscottlmpt_pop_reply_queue(struct mpt_softc *mpt)
709147883Sscottl{
710147883Sscottl     return mpt_read(mpt, MPT_OFFSET_REPLY_Q);
711147883Sscottl}
712147883Sscottl
713147883Sscottlvoid mpt_complete_request_chain(struct mpt_softc *mpt,
714147883Sscottl				struct req_queue *chain, u_int iocstatus);
715147883Sscottl/************************** Scatter Gather Managment **************************/
716147883Sscottl/*
717147883Sscottl * We cannot tell prior to getting IOC facts how big the IOC's request
718147883Sscottl * area is. Because of this we cannot tell at compile time how many
719147883Sscottl * simple SG elements we can fit within an IOC request prior to having
720147883Sscottl * to put in a chain element.
721147883Sscottl *
722147883Sscottl * Experimentally we know that the Ultra4 parts have a 96 byte request
723147883Sscottl * element size and the Fibre Channel units have a 144 byte request
724147883Sscottl * element size. Therefore, if we have 512-32 (== 480) bytes of request
725147883Sscottl * area to play with, we have room for between 3 and 5 request sized
726147883Sscottl * regions- the first of which is the command  plus a simple SG list,
727147883Sscottl * the rest of which are chained continuation SG lists. Given that the
728147883Sscottl * normal request we use is 48 bytes w/o the first SG element, we can
729147883Sscottl * assume we have 480-48 == 432 bytes to have simple SG elements and/or
730147883Sscottl * chain elements. If we assume 32 bit addressing, this works out to
731147883Sscottl * 54 SG or chain elements. If we assume 5 chain elements, then we have
732147883Sscottl * a maximum of 49 seperate actual SG segments.
733147883Sscottl */
734147883Sscottl#define MPT_SGL_MAX		49
735147883Sscottl
736147883Sscottl#define	MPT_RQSL(mpt)		(mpt->request_frame_size << 2)
737147883Sscottl#define	MPT_NSGL(mpt)		(MPT_RQSL(mpt) / sizeof (SGE_SIMPLE32))
738147883Sscottl
739147883Sscottl#define	MPT_NSGL_FIRST(mpt)				\
740147883Sscottl	(((mpt->request_frame_size << 2) -		\
741147883Sscottl	sizeof (MSG_SCSI_IO_REQUEST) -			\
742147883Sscottl	sizeof (SGE_IO_UNION)) / sizeof (SGE_SIMPLE32))
743147883Sscottl
744147883Sscottl/***************************** IOC Initialization *****************************/
745147883Sscottlint mpt_reset(struct mpt_softc *, int /*reinit*/);
746147883Sscottl
747147883Sscottl/****************************** Debugging/Logging *****************************/
748147883Sscottltypedef struct mpt_decode_entry {
749147883Sscottl	char    *name;
750147883Sscottl	u_int	 value;
751147883Sscottl	u_int	 mask;
752147883Sscottl} mpt_decode_entry_t;
753147883Sscottl
754147883Sscottlint mpt_decode_value(mpt_decode_entry_t *table, u_int num_entries,
755147883Sscottl		     const char *name, u_int value, u_int *cur_column,
756147883Sscottl		     u_int wrap_point);
757147883Sscottl
758147883Sscottlenum {
759147883Sscottl	MPT_PRT_ALWAYS,
760147883Sscottl	MPT_PRT_FATAL,
761147883Sscottl	MPT_PRT_ERROR,
762147883Sscottl	MPT_PRT_WARN,
763147883Sscottl	MPT_PRT_INFO,
764147883Sscottl	MPT_PRT_DEBUG,
765147883Sscottl	MPT_PRT_TRACE
766147883Sscottl};
767147883Sscottl
768147883Sscottl#define mpt_lprt(mpt, level, ...)		\
769147883Sscottldo {						\
770147883Sscottl	if (level <= (mpt)->verbose)		\
771147883Sscottl		mpt_prt(mpt, __VA_ARGS__);	\
772147883Sscottl} while (0)
773147883Sscottl
774147883Sscottl#define mpt_lprtc(mpt, level, ...)		 \
775147883Sscottldo {						 \
776147883Sscottl	if (level <= (mpt)->debug_level)	 \
777147883Sscottl		mpt_prtc(mpt, __VA_ARGS__);	 \
778147883Sscottl} while (0)
779147883Sscottl
780147883Sscottlvoid mpt_prt(struct mpt_softc *, const char *, ...);
781147883Sscottlvoid mpt_prtc(struct mpt_softc *, const char *, ...);
782147883Sscottl
783147883Sscottl/**************************** Unclassified Routines ***************************/
784147883Sscottlvoid		mpt_send_cmd(struct mpt_softc *mpt, request_t *req);
785147883Sscottlint		mpt_recv_handshake_reply(struct mpt_softc *mpt,
786147883Sscottl					 size_t reply_len, void *reply);
787147883Sscottlint		mpt_wait_req(struct mpt_softc *mpt, request_t *req,
788147883Sscottl			     mpt_req_state_t state, mpt_req_state_t mask,
789147883Sscottl			     int sleep_ok, int time_ms);
790147883Sscottlvoid		mpt_enable_ints(struct mpt_softc *mpt);
791147883Sscottlvoid		mpt_disable_ints(struct mpt_softc *mpt);
792147883Sscottlint		mpt_attach(struct mpt_softc *mpt);
793147883Sscottlint		mpt_shutdown(struct mpt_softc *mpt);
794147883Sscottlint		mpt_detach(struct mpt_softc *mpt);
795147883Sscottlint		mpt_send_handshake_cmd(struct mpt_softc *mpt,
796147883Sscottl				       size_t len, void *cmd);
797147883Sscottlrequest_t *	mpt_get_request(struct mpt_softc *mpt, int sleep_ok);
798147883Sscottlvoid		mpt_free_request(struct mpt_softc *mpt, request_t *req);
799147883Sscottlvoid		mpt_intr(void *arg);
800147883Sscottlvoid		mpt_check_doorbell(struct mpt_softc *mpt);
801147883Sscottlvoid		mpt_dump_reply_frame(struct mpt_softc *mpt,
802147883Sscottl				     MSG_DEFAULT_REPLY *reply_frame);
803147883Sscottl
804147883Sscottlvoid		mpt_set_config_regs(struct mpt_softc *);
805147883Sscottlint		mpt_issue_cfg_req(struct mpt_softc */*mpt*/, request_t */*req*/,
806147883Sscottl				  u_int /*Action*/, u_int /*PageVersion*/,
807147883Sscottl				  u_int /*PageLength*/, u_int /*PageNumber*/,
808147883Sscottl				  u_int /*PageType*/, uint32_t /*PageAddress*/,
809147883Sscottl				  bus_addr_t /*addr*/, bus_size_t/*len*/,
810147883Sscottl				  int /*sleep_ok*/, int /*timeout_ms*/);
811147883Sscottlint		mpt_read_cfg_header(struct mpt_softc *, int /*PageType*/,
812147883Sscottl				    int /*PageNumber*/,
813147883Sscottl				    uint32_t /*PageAddress*/,
814147883Sscottl				    CONFIG_PAGE_HEADER *,
815147883Sscottl				    int /*sleep_ok*/, int /*timeout_ms*/);
816147883Sscottlint		mpt_read_cfg_page(struct mpt_softc *t, int /*Action*/,
817147883Sscottl				  uint32_t /*PageAddress*/,
818147883Sscottl				  CONFIG_PAGE_HEADER *, size_t /*len*/,
819147883Sscottl				  int /*sleep_ok*/, int /*timeout_ms*/);
820147883Sscottlint		mpt_write_cfg_page(struct mpt_softc *, int /*Action*/,
821147883Sscottl				   uint32_t /*PageAddress*/,
822147883Sscottl				   CONFIG_PAGE_HEADER *, size_t /*len*/,
823147883Sscottl				   int /*sleep_ok*/, int /*timeout_ms*/);
824147883Sscottlstatic __inline int
825147883Sscottlmpt_read_cur_cfg_page(struct mpt_softc *mpt, uint32_t PageAddress,
826147883Sscottl		      CONFIG_PAGE_HEADER *hdr, size_t len,
827147883Sscottl		      int sleep_ok, int timeout_ms)
828147883Sscottl{
829147883Sscottl	return (mpt_read_cfg_page(mpt, MPI_CONFIG_ACTION_PAGE_READ_CURRENT,
830147883Sscottl				  PageAddress, hdr, len, sleep_ok, timeout_ms));
831147883Sscottl}
832147883Sscottl
833147883Sscottlstatic __inline int
834147883Sscottlmpt_write_cur_cfg_page(struct mpt_softc *mpt, uint32_t PageAddress,
835147883Sscottl		       CONFIG_PAGE_HEADER *hdr, size_t len, int sleep_ok,
836147883Sscottl		       int timeout_ms)
837147883Sscottl{
838147883Sscottl	return (mpt_write_cfg_page(mpt, MPI_CONFIG_ACTION_PAGE_WRITE_CURRENT,
839147883Sscottl				   PageAddress, hdr, len, sleep_ok,
840147883Sscottl				   timeout_ms));
841147883Sscottl}
842147883Sscottl
843101704Smjacob/* mpt_debug.c functions */
844101704Smjacobvoid mpt_print_reply(void *vmsg);
845147883Sscottlvoid mpt_print_db(uint32_t mb);
846101704Smjacobvoid mpt_print_config_reply(void *vmsg);
847147883Sscottlchar *mpt_ioc_diag(uint32_t diag);
848147883Sscottlvoid mpt_req_state(mpt_req_state_t state);
849101704Smjacobvoid mpt_print_config_request(void *vmsg);
850101704Smjacobvoid mpt_print_request(void *vmsg);
851147883Sscottlvoid mpt_print_scsi_io_request(MSG_SCSI_IO_REQUEST *msg);
852101704Smjacob#endif /* _MPT_H_ */
853