1 /* $FreeBSD: src/sys/dev/mpt/mpt.h,v 1.48 2009/07/10 08:18:08 scottl Exp $ */
3 * Generic defines for LSI '909 FC adapters.
6 * Copyright (c) 2000, 2001 by Greg Ansley
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice immediately at the beginning of the file, without modification,
13 * this list of conditions, and the following disclaimer.
14 * 2. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * Copyright (c) 2002, 2006 by Matthew Jacob
31 * All rights reserved.
33 * Redistribution and use in source and binary forms, with or without
34 * modification, are permitted provided that the following conditions are
36 * 1. Redistributions of source code must retain the above copyright
37 * notice, this list of conditions and the following disclaimer.
38 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
39 * substantially similar to the "NO WARRANTY" disclaimer below
40 * ("Disclaimer") and any redistribution must be conditioned upon including
41 * a substantially similar Disclaimer requirement for further binary
43 * 3. Neither the names of the above listed copyright holders nor the names
44 * of any contributors may be used to endorse or promote products derived
45 * from this software without specific prior written permission.
47 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
48 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
50 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
51 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
52 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
53 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
54 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
55 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
56 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT
57 * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
59 * Support from Chris Ellsworth in order to make SAS adapters work
60 * is gratefully acknowledged.
63 * Support from LSI-Logic has also gone a great deal toward making this a
64 * workable subsystem and is gratefully acknowledged.
67 * Copyright (c) 2004, Avid Technology, Inc. and its contributors.
68 * Copyright (c) 2004, 2005 Justin T. Gibbs
69 * Copyright (c) 2005, WHEEL Sp. z o.o.
70 * All rights reserved.
72 * Redistribution and use in source and binary forms, with or without
73 * modification, are permitted provided that the following conditions are
75 * 1. Redistributions of source code must retain the above copyright
76 * notice, this list of conditions and the following disclaimer.
77 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
78 * substantially similar to the "NO WARRANTY" disclaimer below
79 * ("Disclaimer") and any redistribution must be conditioned upon including
80 * a substantially similar Disclaimer requirement for further binary
82 * 3. Neither the names of the above listed copyright holders nor the names
83 * of any contributors may be used to endorse or promote products derived
84 * from this software without specific prior written permission.
86 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
87 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
88 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
89 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
90 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
91 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
92 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
93 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
94 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
95 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT
96 * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
102 /********************************* OS Includes ********************************/
103 #include <sys/types.h>
104 #include <sys/param.h>
105 #include <sys/systm.h>
106 #include <sys/endian.h>
107 #include <sys/eventhandler.h>
108 #if __FreeBSD_version < 500000
109 #include <sys/kernel.h>
110 #include <sys/queue.h>
111 #include <sys/malloc.h>
112 #include <sys/devicestat.h>
113 #include <sys/thread2.h>
115 #include <sys/lock.h>
116 #include <sys/kernel.h>
117 #include <sys/queue.h>
118 #include <sys/malloc.h>
119 #include <sys/mutex.h>
120 #include <sys/condvar.h>
122 #include <sys/proc.h>
124 #include <sys/module.h>
126 #include <sys/rman.h>
128 #if __FreeBSD_version < 500000
129 #include <bus/pci/pcireg.h>
130 #include <bus/pci/pcivar.h>
132 #include <dev/pci/pcireg.h>
133 #include <dev/pci/pcivar.h>
138 /**************************** Register Definitions ****************************/
139 #include <dev/disk/mpt/mpt_reg.h>
141 /******************************* MPI Definitions ******************************/
142 #include <dev/disk/mpt/mpilib/mpi_type.h>
143 #include <dev/disk/mpt/mpilib/mpi.h>
144 #include <dev/disk/mpt/mpilib/mpi_cnfg.h>
145 #include <dev/disk/mpt/mpilib/mpi_ioc.h>
146 #include <dev/disk/mpt/mpilib/mpi_raid.h>
148 /* XXX For mpt_debug.c */
149 #include <dev/disk/mpt/mpilib/mpi_init.h>
151 #define MPT_S64_2_SCALAR(y) ((((int64_t)y.High) << 32) | (y.Low))
152 #define MPT_U64_2_SCALAR(y) ((((uint64_t)y.High) << 32) | (y.Low))
154 /****************************** Misc Definitions ******************************/
155 /* #define MPT_TEST_MULTIPATH 1 */
157 #define MPT_FAIL (0x10000)
159 #define NUM_ELEMENTS(array) (sizeof(array) / sizeof(*array))
161 #define MPT_ROLE_NONE 0
162 #define MPT_ROLE_INITIATOR 1
163 #define MPT_ROLE_TARGET 2
164 #define MPT_ROLE_BOTH 3
165 #define MPT_ROLE_DEFAULT MPT_ROLE_INITIATOR
167 /**************************** Forward Declarations ****************************/
169 struct mpt_personality
;
170 typedef struct req_entry request_t
;
172 /************************* Personality Module Support *************************/
173 typedef int mpt_load_handler_t(struct mpt_personality
*);
174 typedef int mpt_probe_handler_t(struct mpt_softc
*);
175 typedef int mpt_attach_handler_t(struct mpt_softc
*);
176 typedef int mpt_enable_handler_t(struct mpt_softc
*);
177 typedef void mpt_ready_handler_t(struct mpt_softc
*);
178 typedef int mpt_event_handler_t(struct mpt_softc
*, request_t
*,
179 MSG_EVENT_NOTIFY_REPLY
*);
180 typedef void mpt_reset_handler_t(struct mpt_softc
*, int /*type*/);
181 /* XXX Add return value and use for veto? */
182 typedef void mpt_shutdown_handler_t(struct mpt_softc
*);
183 typedef void mpt_detach_handler_t(struct mpt_softc
*);
184 typedef int mpt_unload_handler_t(struct mpt_personality
*);
186 struct mpt_personality
189 uint32_t id
; /* Assigned identifier. */
190 u_int use_count
; /* Instances using personality*/
191 mpt_load_handler_t
*load
; /* configure personailty */
192 #define MPT_PERS_FIRST_HANDLER(pers) (&(pers)->load)
193 mpt_probe_handler_t
*probe
; /* configure personailty */
194 mpt_attach_handler_t
*attach
; /* initialize device instance */
195 mpt_enable_handler_t
*enable
; /* enable device */
196 mpt_ready_handler_t
*ready
; /* final open for business */
197 mpt_event_handler_t
*event
; /* Handle MPI event. */
198 mpt_reset_handler_t
*reset
; /* Re-init after reset. */
199 mpt_shutdown_handler_t
*shutdown
; /* Shutdown instance. */
200 mpt_detach_handler_t
*detach
; /* release device instance */
201 mpt_unload_handler_t
*unload
; /* Shutdown personality */
202 #define MPT_PERS_LAST_HANDLER(pers) (&(pers)->unload)
205 int mpt_modevent(module_t
, int, void *);
207 /* Maximum supported number of personalities. */
208 #define MPT_MAX_PERSONALITIES (15)
210 #define MPT_PERSONALITY_DEPEND(name, dep, vmin, vpref, vmax) \
211 MODULE_DEPEND(name, dep, vmin, vpref, vmax)
213 #define DECLARE_MPT_PERSONALITY(name, order) \
214 static moduledata_t name##_mod = { \
215 #name, mpt_modevent, &name##_personality \
217 DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, order); \
218 MODULE_VERSION(name, 1); \
219 MPT_PERSONALITY_DEPEND(name, mpt_core, 1, 1, 1)
221 /******************************* Bus DMA Support ******************************/
222 /* XXX Need to update bus_dmamap_sync to take a range argument. */
223 #define bus_dmamap_sync_range(dma_tag, dmamap, offset, len, op) \
224 bus_dmamap_sync(dma_tag, dmamap, op)
226 #if __FreeBSD_version < 600000
227 #define bus_get_dma_tag(x) NULL
229 #if __FreeBSD_version >= 501102
230 #define mpt_dma_tag_create(mpt, parent_tag, alignment, boundary, \
231 lowaddr, highaddr, filter, filterarg, \
232 maxsize, nsegments, maxsegsz, flags, \
234 bus_dma_tag_create(parent_tag, alignment, boundary, \
235 lowaddr, highaddr, filter, filterarg, \
236 maxsize, nsegments, maxsegsz, flags, \
237 busdma_lock_mutex, &(mpt)->mpt_lock, \
240 #define mpt_dma_tag_create(mpt, parent_tag, alignment, boundary, \
241 lowaddr, highaddr, filter, filterarg, \
242 maxsize, nsegments, maxsegsz, flags, \
244 bus_dma_tag_create(parent_tag, alignment, boundary, \
245 lowaddr, highaddr, filter, filterarg, \
246 maxsize, nsegments, maxsegsz, flags, \
250 struct mpt_map_info
{
251 struct mpt_softc
*mpt
;
256 void mpt_map_rquest(void *, bus_dma_segment_t
*, int, int);
257 /* **************************** NewBUS interrupt Crock ************************/
259 #define mpt_setup_intr(d, i, f, U, if, ifa, hp) \
260 bus_setup_intr(d, i, f, if, ifa, hp, NULL)
262 #if __FreeBSD_version < 700031
263 #define mpt_setup_intr(d, i, f, U, if, ifa, hp) \
264 bus_setup_intr(d, i, f, if, ifa, hp)
266 #define mpt_setup_intr bus_setup_intr
270 /* **************************** NewBUS CAM Support ****************************/
271 #if __FreeBSD_version < 700049
272 #define mpt_xpt_bus_register(sim, parent, bus) \
273 xpt_bus_register(sim, bus)
275 #define mpt_xpt_bus_register xpt_bus_register
278 /**************************** Kernel Thread Support ***************************/
279 #if __FreeBSD_version > 800001
280 #define mpt_kthread_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg) \
281 kproc_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg)
282 #define mpt_kthread_exit(status) \
284 #elif __FreeBSD_version > 500005
285 #define mpt_kthread_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg) \
286 kthread_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg)
287 #define mpt_kthread_exit(status) \
290 #define mpt_kthread_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg) \
291 kthread_create(func, farg, proc_ptr, fmtstr, arg)
292 #define mpt_kthread_exit(status) \
296 /****************************** Timer Facilities ******************************/
297 #if __FreeBSD_version > 500000
298 #define mpt_callout_init(c) callout_init(c, /*mpsafe*/1);
300 #define mpt_callout_init(c) callout_init(c);
303 /********************************** Endianess *********************************/
304 #define MPT_2_HOST64(ptr, tag) ptr->tag = le64toh(ptr->tag)
305 #define MPT_2_HOST32(ptr, tag) ptr->tag = le32toh(ptr->tag)
306 #define MPT_2_HOST16(ptr, tag) ptr->tag = le16toh(ptr->tag)
308 #define HOST_2_MPT64(ptr, tag) ptr->tag = htole64(ptr->tag)
309 #define HOST_2_MPT32(ptr, tag) ptr->tag = htole32(ptr->tag)
310 #define HOST_2_MPT16(ptr, tag) ptr->tag = htole16(ptr->tag)
312 #if _BYTE_ORDER == _BIG_ENDIAN
313 void mpt2host_sge_simple_union(SGE_SIMPLE_UNION
*);
314 void mpt2host_iocfacts_reply(MSG_IOC_FACTS_REPLY
*);
315 void mpt2host_portfacts_reply(MSG_PORT_FACTS_REPLY
*);
316 void mpt2host_config_page_ioc2(CONFIG_PAGE_IOC_2
*);
317 void mpt2host_config_page_ioc3(CONFIG_PAGE_IOC_3
*);
318 void mpt2host_config_page_scsi_port_0(CONFIG_PAGE_SCSI_PORT_0
*);
319 void mpt2host_config_page_scsi_port_1(CONFIG_PAGE_SCSI_PORT_1
*);
320 void host2mpt_config_page_scsi_port_1(CONFIG_PAGE_SCSI_PORT_1
*);
321 void mpt2host_config_page_scsi_port_2(CONFIG_PAGE_SCSI_PORT_2
*);
322 void mpt2host_config_page_scsi_device_0(CONFIG_PAGE_SCSI_DEVICE_0
*);
323 void mpt2host_config_page_scsi_device_1(CONFIG_PAGE_SCSI_DEVICE_1
*);
324 void host2mpt_config_page_scsi_device_1(CONFIG_PAGE_SCSI_DEVICE_1
*);
325 void mpt2host_config_page_fc_port_0(CONFIG_PAGE_FC_PORT_0
*);
326 void mpt2host_config_page_fc_port_1(CONFIG_PAGE_FC_PORT_1
*);
327 void host2mpt_config_page_fc_port_1(CONFIG_PAGE_FC_PORT_1
*);
328 void mpt2host_config_page_raid_vol_0(CONFIG_PAGE_RAID_VOL_0
*);
329 void mpt2host_config_page_raid_phys_disk_0(CONFIG_PAGE_RAID_PHYS_DISK_0
*);
330 void mpt2host_mpi_raid_vol_indicator(MPI_RAID_VOL_INDICATOR
*);
332 #define mpt2host_sge_simple_union(x) do { ; } while (0)
333 #define mpt2host_iocfacts_reply(x) do { ; } while (0)
334 #define mpt2host_portfacts_reply(x) do { ; } while (0)
335 #define mpt2host_config_page_ioc2(x) do { ; } while (0)
336 #define mpt2host_config_page_ioc3(x) do { ; } while (0)
337 #define mpt2host_config_page_scsi_port_0(x) do { ; } while (0)
338 #define mpt2host_config_page_scsi_port_1(x) do { ; } while (0)
339 #define host2mpt_config_page_scsi_port_1(x) do { ; } while (0)
340 #define mpt2host_config_page_scsi_port_2(x) do { ; } while (0)
341 #define mpt2host_config_page_scsi_device_0(x) do { ; } while (0)
342 #define mpt2host_config_page_scsi_device_1(x) do { ; } while (0)
343 #define host2mpt_config_page_scsi_device_1(x) do { ; } while (0)
344 #define mpt2host_config_page_fc_port_0(x) do { ; } while (0)
345 #define mpt2host_config_page_fc_port_1(x) do { ; } while (0)
346 #define host2mpt_config_page_fc_port_1(x) do { ; } while (0)
347 #define mpt2host_config_page_raid_vol_0(x) do { ; } while (0)
348 #define mpt2host_config_page_raid_phys_disk_0(x) \
350 #define mpt2host_mpi_raid_vol_indicator(x) do { ; } while (0)
353 /**************************** MPI Transaction State ***************************/
355 REQ_STATE_NIL
= 0x00,
356 REQ_STATE_FREE
= 0x01,
357 REQ_STATE_ALLOCATED
= 0x02,
358 REQ_STATE_QUEUED
= 0x04,
359 REQ_STATE_DONE
= 0x08,
360 REQ_STATE_TIMEDOUT
= 0x10,
361 REQ_STATE_NEED_WAKEUP
= 0x20,
362 REQ_STATE_LOCKED
= 0x80, /* can't be freed */
363 REQ_STATE_MASK
= 0xFF
367 TAILQ_ENTRY(req_entry
) links
; /* Pointer to next in list */
368 mpt_req_state_t state
; /* Request State Information */
369 uint16_t index
; /* Index of this entry */
370 uint16_t IOCStatus
; /* Completion status */
371 uint16_t ResponseCode
; /* TMF Reponse Code */
372 uint16_t serno
; /* serial number */
373 union ccb
*ccb
; /* CAM request */
374 void *req_vbuf
; /* Virtual Address of Entry */
375 void *sense_vbuf
; /* Virtual Address of sense data */
376 bus_addr_t req_pbuf
; /* Physical Address of Entry */
377 bus_addr_t sense_pbuf
; /* Physical Address of sense data */
378 bus_dmamap_t dmap
; /* DMA map for data buffers */
379 struct req_entry
*chain
; /* for SGE overallocations */
380 struct callout callout
; /* Timeout for the request */
383 typedef struct mpt_config_params
{
394 /**************************** MPI Target State Info ***************************/
397 uint32_t reply_desc
; /* current reply descriptor */
398 uint32_t resid
; /* current data residual */
399 uint32_t bytes_xfered
; /* current relative offset */
400 union ccb
*ccb
; /* pointer to currently active ccb */
401 request_t
*req
; /* pointer to currently active assist request */
411 TGT_STATE_SETTING_UP_FOR_DATA
,
412 TGT_STATE_MOVING_DATA
,
413 TGT_STATE_MOVING_DATA_AND_STATUS
,
414 TGT_STATE_SENDING_STATUS
419 * When we get an incoming command it has its own tag which is called the
420 * IoIndex. This is the value we gave that particular command buffer when
421 * we originally assigned it. It's just a number, really. The FC card uses
422 * it as an RX_ID. We can use it to index into mpt->tgt_cmd_ptrs, which
423 * contains pointers the request_t structures related to that IoIndex.
425 * What *we* do is construct a tag out of the index for the target command
426 * which owns the incoming ATIO plus a rolling sequence number.
428 #define MPT_MAKE_TAGID(mpt, req, ioindex) \
429 ((ioindex << 18) | (((mpt->sequence++) & 0x3f) << 12) | (req->index & 0xfff))
432 #define MPT_TAG_2_REQ(a, b) mpt_tag_2_req(a, (uint32_t) b)
434 #define MPT_TAG_2_REQ(mpt, tag) mpt->tgt_cmd_ptrs[tag >> 18]
437 #define MPT_TGT_STATE(mpt, req) ((mpt_tgt_state_t *) \
438 (&((uint8_t *)req->req_vbuf)[MPT_RQSL(mpt) - sizeof (mpt_tgt_state_t)]))
440 STAILQ_HEAD(mpt_hdr_stailq
, ccb_hdr
);
441 #define MPT_MAX_LUNS 256
443 struct mpt_hdr_stailq atios
;
444 struct mpt_hdr_stailq inots
;
447 #define MPT_MAX_ELS 64
449 /**************************** Handler Registration ****************************/
451 * Global table of registered reply handlers. The
452 * handler is indicated by byte 3 of the request
453 * index submitted to the IOC. This allows the
454 * driver core to perform generic processing without
455 * any knowledge of per-personality behavior.
457 * MPT_NUM_REPLY_HANDLERS must be a power of 2
458 * to allow the easy generation of a mask.
460 * The handler offsets used by the core are hard coded
461 * allowing faster code generation when assigning a handler
462 * to a request. All "personalities" must use the
463 * the handler registration mechanism.
465 * The IOC handlers that are rarely executed are placed
466 * at the tail of the table to make it more likely that
467 * all commonly executed handlers fit in a single cache
470 #define MPT_NUM_REPLY_HANDLERS (32)
471 #define MPT_REPLY_HANDLER_EVENTS MPT_CBI_TO_HID(0)
472 #define MPT_REPLY_HANDLER_CONFIG MPT_CBI_TO_HID(MPT_NUM_REPLY_HANDLERS-1)
473 #define MPT_REPLY_HANDLER_HANDSHAKE MPT_CBI_TO_HID(MPT_NUM_REPLY_HANDLERS-2)
474 typedef int mpt_reply_handler_t(struct mpt_softc
*mpt
, request_t
*request
,
475 uint32_t reply_desc
, MSG_DEFAULT_REPLY
*reply_frame
);
477 mpt_reply_handler_t
*reply_handler
;
487 struct mpt_handler_record
489 LIST_ENTRY(mpt_handler_record
) links
;
490 mpt_handler_t handler
;
493 LIST_HEAD(mpt_handler_list
, mpt_handler_record
);
496 * The handler_id is currently unused but would contain the
497 * handler ID used in the MsgContext field to allow direction
498 * of replies to the handler. Registrations that don't require
499 * a handler id can pass in NULL for the handler_id.
501 * Deregistrations for handlers without a handler id should
502 * pass in MPT_HANDLER_ID_NONE.
504 #define MPT_HANDLER_ID_NONE (0xFFFFFFFF)
505 int mpt_register_handler(struct mpt_softc
*, mpt_handler_type
,
506 mpt_handler_t
, uint32_t *);
507 int mpt_deregister_handler(struct mpt_softc
*, mpt_handler_type
,
508 mpt_handler_t
, uint32_t);
510 /******************* Per-Controller Instance Data Structures ******************/
511 TAILQ_HEAD(req_queue
, req_entry
);
513 /* Structure for saving proper values for modifyable PCI config registers */
516 uint16_t LatencyTimer_LineSize
;
518 uint32_t Mem0_BAR
[2];
519 uint32_t Mem1_BAR
[2];
527 MPT_RVF_ACTIVE
= 0x1,
528 MPT_RVF_ANNOUNCED
= 0x2,
529 MPT_RVF_UP2DATE
= 0x4,
530 MPT_RVF_REFERENCED
= 0x8,
531 MPT_RVF_WCE_CHANGED
= 0x10
532 } mpt_raid_volume_flags
;
534 struct mpt_raid_volume
{
535 CONFIG_PAGE_RAID_VOL_0
*config_page
;
536 MPI_RAID_VOL_INDICATOR sync_progress
;
537 mpt_raid_volume_flags flags
;
538 u_int quiesced_disks
;
543 MPT_RDF_ACTIVE
= 0x01,
544 MPT_RDF_ANNOUNCED
= 0x02,
545 MPT_RDF_UP2DATE
= 0x04,
546 MPT_RDF_REFERENCED
= 0x08,
547 MPT_RDF_QUIESCING
= 0x10,
548 MPT_RDF_QUIESCED
= 0x20
549 } mpt_raid_disk_flags
;
551 struct mpt_raid_disk
{
552 CONFIG_PAGE_RAID_PHYS_DISK_0 config_page
;
553 struct mpt_raid_volume
*volume
;
555 u_int pass_thru_active
;
556 mpt_raid_disk_flags flags
;
559 struct mpt_evtf_record
{
560 MSG_EVENT_NOTIFY_REPLY reply
;
562 LIST_ENTRY(mpt_evtf_record
) links
;
565 LIST_HEAD(mpt_evtf_list
, mpt_evtf_record
);
567 struct mptsas_devinfo
{
569 uint16_t parent_dev_handle
;
570 uint16_t enclosure_handle
;
573 uint8_t physical_port
;
576 uint64_t sas_address
;
577 uint32_t device_info
;
580 struct mptsas_phyinfo
{
584 uint8_t negotiated_link_rate
;
585 uint8_t hw_link_rate
;
586 uint8_t programmed_link_rate
;
587 uint8_t sas_port_add_phy
;
588 struct mptsas_devinfo identify
;
589 struct mptsas_devinfo attached
;
592 struct mptsas_portinfo
{
594 struct mptsas_phyinfo
*phy_info
;
599 #if __FreeBSD_version < 500000
600 uint32_t mpt_islocked
;
606 uint32_t mpt_pers_mask
;
628 u_int role
; /* role: none, ini, target, both */
631 #ifdef MPT_TEST_MULTIPATH
638 MSG_IOC_FACTS_REPLY ioc_facts
;
643 MSG_PORT_FACTS_REPLY
* port_facts
;
644 #define mpt_ini_id port_facts[0].PortSCSIID
645 #define mpt_max_tgtcmds port_facts[0].MaxPostedCmdBuffers
648 * Device Configuration Information
652 CONFIG_PAGE_SCSI_PORT_0 _port_page0
;
653 CONFIG_PAGE_SCSI_PORT_1 _port_page1
;
654 CONFIG_PAGE_SCSI_PORT_2 _port_page2
;
655 CONFIG_PAGE_SCSI_DEVICE_0 _dev_page0
[16];
656 CONFIG_PAGE_SCSI_DEVICE_1 _dev_page1
[16];
657 uint16_t _tag_enable
;
658 uint16_t _disc_enable
;
660 #define mpt_port_page0 cfg.spi._port_page0
661 #define mpt_port_page1 cfg.spi._port_page1
662 #define mpt_port_page2 cfg.spi._port_page2
663 #define mpt_dev_page0 cfg.spi._dev_page0
664 #define mpt_dev_page1 cfg.spi._dev_page1
665 #define mpt_tag_enable cfg.spi._tag_enable
666 #define mpt_disc_enable cfg.spi._disc_enable
668 CONFIG_PAGE_FC_PORT_0 _port_page0
;
669 uint32_t _port_speed
;
670 #define mpt_fcport_page0 cfg.fc._port_page0
671 #define mpt_fcport_speed cfg.fc._port_speed
674 #if __FreeBSD_version >= 500000
676 * Device config information stored up for sysctl to access
680 unsigned int initiator_id
;
689 /* Controller Info for RAID information */
690 CONFIG_PAGE_IOC_2
* ioc_page2
;
691 CONFIG_PAGE_IOC_3
* ioc_page3
;
694 struct mpt_raid_volume
* raid_volumes
;
695 struct mpt_raid_disk
* raid_disks
;
696 u_int raid_max_volumes
;
697 u_int raid_max_disks
;
698 u_int raid_page0_len
;
701 u_int raid_resync_rate
;
702 u_int raid_mwce_setting
;
703 u_int raid_queue_depth
;
704 u_int raid_nonopt_volumes
;
705 thread_t raid_thread
;
706 struct callout raid_timer
;
712 struct resource
* pci_irq
; /* Interrupt map for chip */
713 void * ih
; /* Interupt handle */
714 struct mpt_pci_cfg pci_cfg
; /* saved PCI conf registers */
719 struct resource
* pci_reg
; /* Register map for chip */
720 int pci_mem_rid
; /* Resource ID */
721 bus_space_tag_t pci_st
; /* Bus tag for registers */
722 bus_space_handle_t pci_sh
; /* Bus handle for registers */
723 /* PIO versions of above. */
725 struct resource
* pci_pio_reg
;
726 bus_space_tag_t pci_pio_st
;
727 bus_space_handle_t pci_pio_sh
;
729 bus_dma_tag_t parent_dmat
; /* DMA tag for parent PCI bus */
730 bus_dma_tag_t reply_dmat
; /* DMA tag for reply memory */
731 bus_dmamap_t reply_dmap
; /* DMA map for reply memory */
732 uint8_t *reply
; /* KVA of reply memory */
733 bus_addr_t reply_phys
; /* BusAddr of reply memory */
735 bus_dma_tag_t buffer_dmat
; /* DMA tag for buffers */
736 bus_dma_tag_t request_dmat
; /* DMA tag for request memroy */
737 bus_dmamap_t request_dmap
; /* DMA map for request memroy */
738 uint8_t *request
; /* KVA of Request memory */
739 bus_addr_t request_phys
; /* BusAddr of request memory */
741 uint32_t max_seg_cnt
; /* calculated after IOC facts */
744 * Hardware management
749 * CAM && Software Management
751 request_t
*request_pool
;
752 struct req_queue request_free_list
;
753 struct req_queue request_pending_list
;
754 struct req_queue request_timeout_list
;
758 struct cam_path
*path
;
760 struct cam_sim
*phydisk_sim
;
761 struct cam_path
*phydisk_path
;
763 thread_t recovery_thread
;
767 * Deferred frame acks due to resource shortage.
769 struct mpt_evtf_list ack_frames
;
772 * Target Mode Support
774 uint32_t scsi_tgt_handler_id
;
775 request_t
** tgt_cmd_ptrs
;
776 request_t
** els_cmd_ptrs
; /* FC only */
779 * *snork*- this is chosen to be here *just in case* somebody
780 * forgets to point to it exactly and we index off of trt with
783 tgt_resource_t trt_wildcard
; /* wildcard luns */
784 tgt_resource_t trt
[MPT_MAX_LUNS
];
785 uint16_t tgt_cmds_allocated
;
786 uint16_t els_cmds_allocated
; /* FC only */
788 uint16_t timeouts
; /* timeout count */
789 uint16_t success
; /* successes afer timeout */
790 uint16_t sequence
; /* Sequence Number */
794 /* Paired port in some dual adapters configurations */
795 struct mpt_softc
* mpt2
;
797 /* FW Image management */
798 uint32_t fw_image_size
;
800 bus_dma_tag_t fw_dmat
; /* DMA tag for firmware image */
801 bus_dmamap_t fw_dmap
; /* DMA map for firmware image */
802 bus_addr_t fw_phys
; /* BusAddr of firmware image */
805 struct mptsas_portinfo
*sas_portinfo
;
807 /* Shutdown Event Handler. */
810 /* Userland management interface. */
813 TAILQ_ENTRY(mpt_softc
) links
;
816 static __inline
void mpt_assign_serno(struct mpt_softc
*, request_t
*);
819 mpt_assign_serno(struct mpt_softc
*mpt
, request_t
*req
)
821 if ((req
->serno
= mpt
->sequence
++) == 0) {
822 req
->serno
= mpt
->sequence
++;
826 /***************************** Locking Primitives *****************************/
830 #define MPT_LOCK(mpt) crit_enter()
831 #define MPT_UNLOCK(mpt) crit_exit()
832 #define MPT_LOCK_SETUP(mpt) do { } while(0)
833 #define MPT_LOCK_DESTROY(mpt) do { } while(0)
834 #define MPT_LOCK_ASSERT(mpt) do { } while(0)
835 #define MPTLOCK_2_CAMLOCK MPT_UNLOCK
836 #define CAMLOCK_2_MPTLOCK MPT_LOCK
838 #define splsoftvm() 0
840 mpt_sleep(struct mpt_softc
*mpt
, void *ident
, int priority
,
841 const char *wmesg
, int timo
) {
843 error
= tsleep(ident
, 0, wmesg
, timo
);
847 #define mpt_req_timeout(req, ticks, func, arg) \
848 callout_reset(&(req)->callout, (ticks), (func), (arg));
849 #define mpt_req_untimeout(req, func, arg) \
850 callout_stop(&(req)->callout)
852 #if __FreeBSD_version < 500000
853 #define MPT_IFLAGS INTR_TYPE_CAM
854 #define MPT_LOCK(mpt) mpt_lockspl(mpt)
855 #define MPT_UNLOCK(mpt) mpt_unlockspl(mpt)
856 #define MPT_OWNED(mpt) mpt->mpt_islocked
857 #define MPT_LOCK_ASSERT(mpt)
858 #define MPTLOCK_2_CAMLOCK MPT_UNLOCK
859 #define CAMLOCK_2_MPTLOCK MPT_LOCK
860 #define MPT_LOCK_SETUP(mpt)
861 #define MPT_LOCK_DESTROY(mpt)
863 static __inline
void mpt_lockspl(struct mpt_softc
*mpt
);
864 static __inline
void mpt_unlockspl(struct mpt_softc
*mpt
);
867 mpt_lockspl(struct mpt_softc
*mpt
)
872 if (mpt
->mpt_islocked
++ == 0) {
873 mpt
->mpt_splsaved
= s
;
876 panic("Recursed lock with mask: 0x%x\n", s
);
881 mpt_unlockspl(struct mpt_softc
*mpt
)
883 if (mpt
->mpt_islocked
) {
884 if (--mpt
->mpt_islocked
== 0) {
885 splx(mpt
->mpt_splsaved
);
888 panic("Negative lock count\n");
892 mpt_sleep(struct mpt_softc
*mpt
, void *ident
, int priority
,
893 const char *wmesg
, int timo
)
899 KASSERT(mpt
->mpt_islocked
<= 1, ("Invalid lock count on tsleep"));
900 saved_cnt
= mpt
->mpt_islocked
;
901 saved_spl
= mpt
->mpt_splsaved
;
902 mpt
->mpt_islocked
= 0;
903 error
= tsleep(ident
, priority
, wmesg
, timo
);
904 KASSERT(mpt
->mpt_islocked
== 0, ("Invalid lock count on wakeup"));
905 mpt
->mpt_islocked
= saved_cnt
;
906 mpt
->mpt_splsaved
= saved_spl
;
910 #define mpt_req_timeout(req, ticks, func, arg) \
911 callout_reset(&(req)->callout, (ticks), (func), (arg));
912 #define mpt_req_untimeout(req, func, arg) \
913 callout_stop(&(req)->callout)
916 #define MPT_IFLAGS INTR_TYPE_CAM | INTR_ENTROPY | INTR_MPSAFE
917 #define MPT_LOCK_SETUP(mpt) \
918 mtx_init(&mpt->mpt_lock, "mpt", NULL, MTX_DEF); \
919 mpt->mpt_locksetup = 1
920 #define MPT_LOCK_DESTROY(mpt) \
921 if (mpt->mpt_locksetup) { \
922 mtx_destroy(&mpt->mpt_lock); \
923 mpt->mpt_locksetup = 0; \
926 #define MPT_LOCK(mpt) mtx_lock(&(mpt)->mpt_lock)
927 #define MPT_UNLOCK(mpt) mtx_unlock(&(mpt)->mpt_lock)
928 #define MPT_OWNED(mpt) mtx_owned(&(mpt)->mpt_lock)
929 #define MPT_LOCK_ASSERT(mpt) mtx_assert(&(mpt)->mpt_lock, MA_OWNED)
930 #define MPTLOCK_2_CAMLOCK(mpt)
931 #define CAMLOCK_2_MPTLOCK(mpt)
932 #define mpt_sleep(mpt, ident, priority, wmesg, timo) \
933 msleep(ident, &(mpt)->mpt_lock, priority, wmesg, timo)
934 #define mpt_req_timeout(req, ticks, func, arg) \
935 callout_reset(&(req)->callout, (ticks), (func), (arg));
936 #define mpt_req_untimeout(req, func, arg) \
937 callout_stop(&(req)->callout)
940 #define MPT_IFLAGS INTR_TYPE_CAM | INTR_ENTROPY
941 #define MPT_LOCK_SETUP(mpt) do { } while (0)
942 #define MPT_LOCK_DESTROY(mpt) do { } while (0)
943 #define MPT_LOCK_ASSERT(mpt) mtx_assert(&Giant, MA_OWNED)
944 #define MPT_LOCK(mpt) mtx_lock(&Giant)
945 #define MPT_UNLOCK(mpt) mtx_unlock(&Giant)
946 #define MPTLOCK_2_CAMLOCK(mpt)
947 #define CAMLOCK_2_MPTLOCK(mpt)
950 mpt_sleep(struct mpt_softc
*, void *, int, const char *, int);
952 #define mpt_ccb_timeout(ccb, ticks, func, arg) \
954 (ccb)->ccb_h.timeout_ch = timeout((func), (arg), (ticks)); \
956 #define mpt_ccb_untimeout(ccb, func, arg) \
957 untimeout((func), (arg), (ccb)->ccb_h.timeout_ch)
958 #define mpt_ccb_timeout_init(ccb) \
959 callout_handle_init(&(ccb)->ccb_h.timeout_ch)
962 mpt_sleep(struct mpt_softc
*mpt
, void *i
, int p
, const char *w
, int t
)
965 r
= tsleep(i
, p
, w
, t
);
972 /******************************* Register Access ******************************/
973 static __inline
void mpt_write(struct mpt_softc
*, size_t, uint32_t);
974 static __inline
uint32_t mpt_read(struct mpt_softc
*, int);
975 static __inline
void mpt_pio_write(struct mpt_softc
*, size_t, uint32_t);
976 static __inline
uint32_t mpt_pio_read(struct mpt_softc
*, int);
979 mpt_write(struct mpt_softc
*mpt
, size_t offset
, uint32_t val
)
981 bus_space_write_4(mpt
->pci_st
, mpt
->pci_sh
, offset
, val
);
984 static __inline
uint32_t
985 mpt_read(struct mpt_softc
*mpt
, int offset
)
987 return (bus_space_read_4(mpt
->pci_st
, mpt
->pci_sh
, offset
));
991 * Some operations (e.g. diagnostic register writes while the ARM proccessor
992 * is disabled), must be performed using "PCI pio" operations. On non-PCI
993 * busses, these operations likely map to normal register accesses.
996 mpt_pio_write(struct mpt_softc
*mpt
, size_t offset
, uint32_t val
)
998 bus_space_write_4(mpt
->pci_pio_st
, mpt
->pci_pio_sh
, offset
, val
);
1001 static __inline
uint32_t
1002 mpt_pio_read(struct mpt_softc
*mpt
, int offset
)
1004 return (bus_space_read_4(mpt
->pci_pio_st
, mpt
->pci_pio_sh
, offset
));
1006 /*********************** Reply Frame/Request Management ***********************/
1007 /* Max MPT Reply we are willing to accept (must be power of 2) */
1008 #define MPT_REPLY_SIZE 256
1010 /* Max i/o size, based on legacy MAXPHYS. Can be increased. */
1011 #define MPT_MAXPHYS (128 * 1024)
1014 * Must be less than 16384 in order for target mode to work
1016 #define MPT_MAX_REQUESTS(mpt) 512
1017 #define MPT_REQUEST_AREA 512
1018 #define MPT_SENSE_SIZE 32 /* included in MPT_REQUEST_AREA */
1019 #define MPT_REQ_MEM_SIZE(mpt) (MPT_MAX_REQUESTS(mpt) * MPT_REQUEST_AREA)
1021 #define MPT_CONTEXT_CB_SHIFT (16)
1022 #define MPT_CBI(handle) (handle >> MPT_CONTEXT_CB_SHIFT)
1023 #define MPT_CBI_TO_HID(cbi) ((cbi) << MPT_CONTEXT_CB_SHIFT)
1024 #define MPT_CONTEXT_TO_CBI(x) \
1025 (((x) >> MPT_CONTEXT_CB_SHIFT) & (MPT_NUM_REPLY_HANDLERS - 1))
1026 #define MPT_CONTEXT_REQI_MASK 0xFFFF
1027 #define MPT_CONTEXT_TO_REQI(x) ((x) & MPT_CONTEXT_REQI_MASK)
1030 * Convert a 32bit physical address returned from IOC to an
1031 * offset into our reply frame memory or the kvm address needed
1032 * to access the data. The returned address is only the low
1033 * 32 bits, so mask our base physical address accordingly.
1035 #define MPT_REPLY_BADDR(x) \
1037 #define MPT_REPLY_OTOV(m, i) \
1038 ((void *)(&m->reply[i]))
1040 #define MPT_DUMP_REPLY_FRAME(mpt, reply_frame) \
1042 if (mpt->verbose > MPT_PRT_DEBUG) \
1043 mpt_dump_reply_frame(mpt, reply_frame); \
1046 static __inline
uint32_t mpt_pop_reply_queue(struct mpt_softc
*mpt
);
1047 static __inline
void mpt_free_reply(struct mpt_softc
*mpt
, uint32_t ptr
);
1050 * Give the reply buffer back to the IOC after we have
1051 * finished processing it.
1053 static __inline
void
1054 mpt_free_reply(struct mpt_softc
*mpt
, uint32_t ptr
)
1056 mpt_write(mpt
, MPT_OFFSET_REPLY_Q
, ptr
);
1059 /* Get a reply from the IOC */
1060 static __inline
uint32_t
1061 mpt_pop_reply_queue(struct mpt_softc
*mpt
)
1063 return mpt_read(mpt
, MPT_OFFSET_REPLY_Q
);
1067 mpt_complete_request_chain(struct mpt_softc
*, struct req_queue
*, u_int
);
1069 /************************** Scatter Gather Managment **************************/
1070 /* MPT_RQSL- size of request frame, in bytes */
1071 #define MPT_RQSL(mpt) (mpt->ioc_facts.RequestFrameSize << 2)
1073 /* MPT_NSGL- how many SG entries can fit in a request frame size */
1074 #define MPT_NSGL(mpt) (MPT_RQSL(mpt) / sizeof (SGE_IO_UNION))
1076 /* MPT_NRFM- how many request frames can fit in each request alloc we make */
1077 #define MPT_NRFM(mpt) (MPT_REQUEST_AREA / MPT_RQSL(mpt))
1080 * MPT_NSGL_FIRST- # of SG elements that can fit after
1081 * an I/O request but still within the request frame.
1082 * Do this safely based upon SGE_IO_UNION.
1084 * Note that the first element is *within* the SCSI request.
1086 #define MPT_NSGL_FIRST(mpt) \
1087 ((MPT_RQSL(mpt) - sizeof (MSG_SCSI_IO_REQUEST) + sizeof (SGE_IO_UNION)) / \
1088 sizeof (SGE_IO_UNION))
1090 /***************************** IOC Initialization *****************************/
1091 int mpt_reset(struct mpt_softc
*, int /*reinit*/);
1093 /****************************** Debugging ************************************/
1094 typedef struct mpt_decode_entry
{
1098 } mpt_decode_entry_t
;
1100 int mpt_decode_value(mpt_decode_entry_t
*table
, u_int num_entries
,
1101 const char *name
, u_int value
, u_int
*cur_column
,
1104 void mpt_dump_data(struct mpt_softc
*, const char *, void *, int);
1105 void mpt_dump_request(struct mpt_softc
*, request_t
*);
1113 MPT_PRT_NEGOTIATION
,
1122 #if __FreeBSD_version > 500000
1123 #define mpt_lprt(mpt, level, ...) \
1125 if (level <= (mpt)->verbose) \
1126 mpt_prt(mpt, __VA_ARGS__); \
1129 #define mpt_lprtc(mpt, level, ...) \
1131 if (level <= (mpt)->debug_level) \
1132 mpt_prtc(mpt, __VA_ARGS__); \
1135 void mpt_lprt(struct mpt_softc
*, int, const char *, ...)
1137 void mpt_lprtc(struct mpt_softc
*, int, const char *, ...)
1140 void mpt_prt(struct mpt_softc
*, const char *, ...)
1142 void mpt_prtc(struct mpt_softc
*, const char *, ...)
1145 /**************************** Target Mode Related ***************************/
1146 static __inline
int mpt_cdblen(uint8_t, int);
1148 mpt_cdblen(uint8_t cdb0
, int maxlen
)
1150 int group
= cdb0
>> 5;
1164 static __inline request_t
* mpt_tag_2_req(struct mpt_softc
*, uint32_t);
1165 static __inline request_t
*
1166 mpt_tag_2_req(struct mpt_softc
*mpt
, uint32_t tag
)
1168 uint16_t rtg
= (tag
>> 18);
1169 KASSERT(rtg
< mpt
->tgt_cmds_allocated
, ("bad tag %d\n", tag
));
1170 KASSERT(mpt
->tgt_cmd_ptrs
, ("no cmd backpointer array"));
1171 KASSERT(mpt
->tgt_cmd_ptrs
[rtg
], ("no cmd backpointer"));
1172 return (mpt
->tgt_cmd_ptrs
[rtg
]);
1177 mpt_req_on_free_list(struct mpt_softc
*, request_t
*);
1179 mpt_req_on_pending_list(struct mpt_softc
*, request_t
*);
1181 static __inline
void
1182 mpt_req_spcl(struct mpt_softc
*, request_t
*, const char *, int);
1183 static __inline
void
1184 mpt_req_not_spcl(struct mpt_softc
*, request_t
*, const char *, int);
1188 * Is request on freelist?
1191 mpt_req_on_free_list(struct mpt_softc
*mpt
, request_t
*req
)
1195 TAILQ_FOREACH(lrq
, &mpt
->request_free_list
, links
) {
1204 * Is request on pending list?
1207 mpt_req_on_pending_list(struct mpt_softc
*mpt
, request_t
*req
)
1211 TAILQ_FOREACH(lrq
, &mpt
->request_pending_list
, links
) {
1220 * Make sure that req *is* part of one of the special lists
1222 static __inline
void
1223 mpt_req_spcl(struct mpt_softc
*mpt
, request_t
*req
, const char *s
, int line
)
1226 for (i
= 0; i
< mpt
->els_cmds_allocated
; i
++) {
1227 if (req
== mpt
->els_cmd_ptrs
[i
]) {
1231 for (i
= 0; i
< mpt
->tgt_cmds_allocated
; i
++) {
1232 if (req
== mpt
->tgt_cmd_ptrs
[i
]) {
1236 panic("%s(%d): req %p:%u function %x not in els or tgt ptrs\n",
1237 s
, line
, req
, req
->serno
,
1238 ((PTR_MSG_REQUEST_HEADER
)req
->req_vbuf
)->Function
);
1242 * Make sure that req is *not* part of one of the special lists.
1244 static __inline
void
1245 mpt_req_not_spcl(struct mpt_softc
*mpt
, request_t
*req
, const char *s
, int line
)
1248 for (i
= 0; i
< mpt
->els_cmds_allocated
; i
++) {
1249 KASSERT(req
!= mpt
->els_cmd_ptrs
[i
],
1250 ("%s(%d): req %p:%u func %x in els ptrs at ioindex %d\n",
1251 s
, line
, req
, req
->serno
,
1252 ((PTR_MSG_REQUEST_HEADER
)req
->req_vbuf
)->Function
, i
));
1254 for (i
= 0; i
< mpt
->tgt_cmds_allocated
; i
++) {
1255 KASSERT(req
!= mpt
->tgt_cmd_ptrs
[i
],
1256 ("%s(%d): req %p:%u func %x in tgt ptrs at ioindex %d\n",
1257 s
, line
, req
, req
->serno
,
1258 ((PTR_MSG_REQUEST_HEADER
)req
->req_vbuf
)->Function
, i
));
1264 * Task Management Types, purely for internal consumption
1267 MPT_ABORT_TASK_SET
=1234,
1272 MPT_NIL_TMT_VALUE
=5678
1275 /**************************** Unclassified Routines ***************************/
1276 void mpt_send_cmd(struct mpt_softc
*mpt
, request_t
*req
);
1277 int mpt_recv_handshake_reply(struct mpt_softc
*mpt
,
1278 size_t reply_len
, void *reply
);
1279 int mpt_wait_req(struct mpt_softc
*mpt
, request_t
*req
,
1280 mpt_req_state_t state
, mpt_req_state_t mask
,
1281 int sleep_ok
, int time_ms
);
1282 void mpt_enable_ints(struct mpt_softc
*mpt
);
1283 void mpt_disable_ints(struct mpt_softc
*mpt
);
1284 int mpt_attach(struct mpt_softc
*mpt
);
1285 int mpt_shutdown(struct mpt_softc
*mpt
);
1286 int mpt_detach(struct mpt_softc
*mpt
);
1287 int mpt_send_handshake_cmd(struct mpt_softc
*mpt
,
1288 size_t len
, void *cmd
);
1289 request_t
* mpt_get_request(struct mpt_softc
*mpt
, int sleep_ok
);
1290 void mpt_free_request(struct mpt_softc
*mpt
, request_t
*req
);
1291 void mpt_intr(void *arg
);
1292 void mpt_check_doorbell(struct mpt_softc
*mpt
);
1293 void mpt_dump_reply_frame(struct mpt_softc
*mpt
,
1294 MSG_DEFAULT_REPLY
*reply_frame
);
1296 void mpt_set_config_regs(struct mpt_softc
*);
1297 int mpt_issue_cfg_req(struct mpt_softc */
*mpt*/
, request_t */
*req*/
,
1299 bus_addr_t
/*addr*/, bus_size_t
/*len*/,
1300 int /*sleep_ok*/, int /*timeout_ms*/);
1301 int mpt_read_extcfg_header(struct mpt_softc
*mpt
, int PageVersion
,
1302 int PageNumber
, uint32_t PageAddress
,
1304 CONFIG_EXTENDED_PAGE_HEADER
*rslt
,
1305 int sleep_ok
, int timeout_ms
);
1306 int mpt_read_extcfg_page(struct mpt_softc
*mpt
, int Action
,
1307 uint32_t PageAddress
,
1308 CONFIG_EXTENDED_PAGE_HEADER
*hdr
,
1309 void *buf
, size_t len
, int sleep_ok
,
1311 int mpt_read_cfg_header(struct mpt_softc
*, int /*PageType*/,
1313 uint32_t /*PageAddress*/,
1314 CONFIG_PAGE_HEADER
*,
1315 int /*sleep_ok*/, int /*timeout_ms*/);
1316 int mpt_read_cfg_page(struct mpt_softc
*t
, int /*Action*/,
1317 uint32_t /*PageAddress*/,
1318 CONFIG_PAGE_HEADER
*, size_t /*len*/,
1319 int /*sleep_ok*/, int /*timeout_ms*/);
1320 int mpt_write_cfg_page(struct mpt_softc
*, int /*Action*/,
1321 uint32_t /*PageAddress*/,
1322 CONFIG_PAGE_HEADER
*, size_t /*len*/,
1323 int /*sleep_ok*/, int /*timeout_ms*/);
1325 mpt_read_cur_cfg_page(struct mpt_softc
*mpt
, uint32_t PageAddress
,
1326 CONFIG_PAGE_HEADER
*hdr
, size_t len
,
1327 int sleep_ok
, int timeout_ms
)
1329 return (mpt_read_cfg_page(mpt
, MPI_CONFIG_ACTION_PAGE_READ_CURRENT
,
1330 PageAddress
, hdr
, len
, sleep_ok
, timeout_ms
));
1334 mpt_write_cur_cfg_page(struct mpt_softc
*mpt
, uint32_t PageAddress
,
1335 CONFIG_PAGE_HEADER
*hdr
, size_t len
, int sleep_ok
,
1338 return (mpt_write_cfg_page(mpt
, MPI_CONFIG_ACTION_PAGE_WRITE_CURRENT
,
1339 PageAddress
, hdr
, len
, sleep_ok
,
1342 /* mpt_debug.c functions */
1343 void mpt_print_reply(void *vmsg
);
1344 void mpt_print_db(uint32_t mb
);
1345 void mpt_print_config_reply(void *vmsg
);
1346 char *mpt_ioc_diag(uint32_t diag
);
1347 void mpt_req_state(mpt_req_state_t state
);
1348 void mpt_print_config_request(void *vmsg
);
1349 void mpt_print_request(void *vmsg
);
1350 void mpt_print_scsi_io_request(MSG_SCSI_IO_REQUEST
*msg
);
1351 void mpt_dump_sgl(SGE_IO_UNION
*se
, int offset
);
1352 #endif /* _MPT_H_ */