1b0a2fdeeSScott Long /*-
2b0a2fdeeSScott Long * LSI MPT Host Adapter FreeBSD Wrapper Definitions (CAM version)
3b0a2fdeeSScott Long *
4*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause AND BSD-3-Clause
5718cf2ccSPedro F. Giffuni *
6b0a2fdeeSScott Long * Copyright (c) 2000, 2001 by Greg Ansley, Adam Prewett
7b0a2fdeeSScott Long *
8b0a2fdeeSScott Long * Partially derived from Matty Jacobs ISP driver.
9b0a2fdeeSScott Long *
10b0a2fdeeSScott Long * Redistribution and use in source and binary forms, with or without
11b0a2fdeeSScott Long * modification, are permitted provided that the following conditions
12b0a2fdeeSScott Long * are met:
13b0a2fdeeSScott Long * 1. Redistributions of source code must retain the above copyright
14b0a2fdeeSScott Long * notice immediately at the beginning of the file, without modification,
15b0a2fdeeSScott Long * this list of conditions, and the following disclaimer.
16b0a2fdeeSScott Long * 2. The name of the author may not be used to endorse or promote products
17b0a2fdeeSScott Long * derived from this software without specific prior written permission.
18b0a2fdeeSScott Long *
19b0a2fdeeSScott Long * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20b0a2fdeeSScott Long * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21b0a2fdeeSScott Long * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22b0a2fdeeSScott Long * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
23b0a2fdeeSScott Long * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24b0a2fdeeSScott Long * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25b0a2fdeeSScott Long * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26b0a2fdeeSScott Long * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27b0a2fdeeSScott Long * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
280b80d21bSMatt Jacob */
290b80d21bSMatt Jacob /*-
300b80d21bSMatt Jacob * Copyright (c) 2002, 2006 by Matthew Jacob
310b80d21bSMatt Jacob * All rights reserved.
32b0a2fdeeSScott Long *
330b80d21bSMatt Jacob * Redistribution and use in source and binary forms, with or without
340b80d21bSMatt Jacob * modification, are permitted provided that the following conditions are
350b80d21bSMatt Jacob * met:
360b80d21bSMatt Jacob * 1. Redistributions of source code must retain the above copyright
370b80d21bSMatt Jacob * notice, this list of conditions and the following disclaimer.
380b80d21bSMatt Jacob * 2. Redistributions in binary form must reproduce at minimum a disclaimer
390b80d21bSMatt Jacob * substantially similar to the "NO WARRANTY" disclaimer below
400b80d21bSMatt Jacob * ("Disclaimer") and any redistribution must be conditioned upon including
410b80d21bSMatt Jacob * a substantially similar Disclaimer requirement for further binary
420b80d21bSMatt Jacob * redistribution.
430b80d21bSMatt Jacob * 3. Neither the names of the above listed copyright holders nor the names
440b80d21bSMatt Jacob * of any contributors may be used to endorse or promote products derived
450b80d21bSMatt Jacob * from this software without specific prior written permission.
460b80d21bSMatt Jacob *
470b80d21bSMatt Jacob * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
480b80d21bSMatt Jacob * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
490b80d21bSMatt Jacob * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
500b80d21bSMatt Jacob * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
510b80d21bSMatt Jacob * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
520b80d21bSMatt Jacob * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
530b80d21bSMatt Jacob * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
540b80d21bSMatt Jacob * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
550b80d21bSMatt Jacob * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
560b80d21bSMatt Jacob * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT
570b80d21bSMatt Jacob * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
580b80d21bSMatt Jacob *
590b80d21bSMatt Jacob * Support from Chris Ellsworth in order to make SAS adapters work
600b80d21bSMatt Jacob * is gratefully acknowledged.
61ec5fe39dSMatt Jacob *
62ec5fe39dSMatt Jacob * Support from LSI-Logic has also gone a great deal toward making this a
63ec5fe39dSMatt Jacob * workable subsystem and is gratefully acknowledged.
64b0a2fdeeSScott Long */
65b0a2fdeeSScott Long /*-
66b0a2fdeeSScott Long * Copyright (c) 2004, Avid Technology, Inc. and its contributors.
67b0a2fdeeSScott Long * Copyright (c) 2005, WHEEL Sp. z o.o.
68b0a2fdeeSScott Long * Copyright (c) 2004, 2005 Justin T. Gibbs
69b0a2fdeeSScott Long * All rights reserved.
70b0a2fdeeSScott Long *
71b0a2fdeeSScott Long * Redistribution and use in source and binary forms, with or without
72b0a2fdeeSScott Long * modification, are permitted provided that the following conditions are
73b0a2fdeeSScott Long * met:
74b0a2fdeeSScott Long * 1. Redistributions of source code must retain the above copyright
75b0a2fdeeSScott Long * notice, this list of conditions and the following disclaimer.
76b0a2fdeeSScott Long * 2. Redistributions in binary form must reproduce at minimum a disclaimer
77b0a2fdeeSScott Long * substantially similar to the "NO WARRANTY" disclaimer below
78b0a2fdeeSScott Long * ("Disclaimer") and any redistribution must be conditioned upon including
79b0a2fdeeSScott Long * a substantially similar Disclaimer requirement for further binary
80b0a2fdeeSScott Long * redistribution.
81286e947fSJustin T. Gibbs * 3. Neither the names of the above listed copyright holders nor the names
82286e947fSJustin T. Gibbs * of any contributors may be used to endorse or promote products derived
83286e947fSJustin T. Gibbs * from this software without specific prior written permission.
84b0a2fdeeSScott Long *
85b0a2fdeeSScott Long * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
86b0a2fdeeSScott Long * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
87b0a2fdeeSScott Long * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
88b0a2fdeeSScott Long * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
89b0a2fdeeSScott Long * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
90b0a2fdeeSScott Long * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
91b0a2fdeeSScott Long * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
92b0a2fdeeSScott Long * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
93b0a2fdeeSScott Long * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
94b0a2fdeeSScott Long * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT
95b0a2fdeeSScott Long * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
96b0a2fdeeSScott Long */
97b0a2fdeeSScott Long #ifndef _MPT_CAM_H_
98b0a2fdeeSScott Long #define _MPT_CAM_H_
99b0a2fdeeSScott Long
100b0a2fdeeSScott Long #include <cam/cam.h>
101b0a2fdeeSScott Long #include <cam/cam_debug.h>
102b0a2fdeeSScott Long #include <cam/cam_ccb.h>
103b0a2fdeeSScott Long #include <cam/cam_sim.h>
104b0a2fdeeSScott Long #include <cam/cam_xpt.h>
105ffcf6651SMatt Jacob #include <cam/cam_periph.h>
106b0a2fdeeSScott Long #include <cam/cam_xpt_sim.h>
107b0a2fdeeSScott Long #include <cam/cam_debug.h>
108b0a2fdeeSScott Long #include <cam/scsi/scsi_all.h>
109b0a2fdeeSScott Long #include <cam/scsi/scsi_message.h>
110b0a2fdeeSScott Long
111b0a2fdeeSScott Long #define ccb_mpt_ptr sim_priv.entries[0].ptr
112b0a2fdeeSScott Long #define ccb_req_ptr sim_priv.entries[1].ptr
113b0a2fdeeSScott Long
114b0a2fdeeSScott Long /************************** CCB Manipulation Routines *************************/
115b0a2fdeeSScott Long static __inline void mpt_freeze_ccb(union ccb *ccb);
116b0a2fdeeSScott Long static __inline void mpt_set_ccb_status(union ccb *ccb, cam_status status);
117b0a2fdeeSScott Long
118b0a2fdeeSScott Long static __inline void
mpt_freeze_ccb(union ccb * ccb)119b0a2fdeeSScott Long mpt_freeze_ccb(union ccb *ccb)
120b0a2fdeeSScott Long {
121b0a2fdeeSScott Long if ((ccb->ccb_h.status & CAM_DEV_QFRZN) == 0) {
122b0a2fdeeSScott Long ccb->ccb_h.status |= CAM_DEV_QFRZN;
123b0a2fdeeSScott Long xpt_freeze_devq(ccb->ccb_h.path, /*count*/1);
124b0a2fdeeSScott Long }
125b0a2fdeeSScott Long }
126b0a2fdeeSScott Long
127b0a2fdeeSScott Long static __inline void
mpt_set_ccb_status(union ccb * ccb,cam_status status)128b0a2fdeeSScott Long mpt_set_ccb_status(union ccb *ccb, cam_status status)
129b0a2fdeeSScott Long {
130b0a2fdeeSScott Long ccb->ccb_h.status &= ~CAM_STATUS_MASK;
131b0a2fdeeSScott Long ccb->ccb_h.status |= status;
132b0a2fdeeSScott Long }
133b0a2fdeeSScott Long
134b0a2fdeeSScott Long /****************************** Timeout Recovery ******************************/
135b0a2fdeeSScott Long /*
136b0a2fdeeSScott Long * The longest timeout specified for a Task Managent command.
137b0a2fdeeSScott Long */
138b0a2fdeeSScott Long #define MPT_TMF_MAX_TIMEOUT (20000)
139b0a2fdeeSScott Long
140b0a2fdeeSScott Long static __inline void
mpt_wakeup_recovery_thread(struct mpt_softc * mpt)141b0a2fdeeSScott Long mpt_wakeup_recovery_thread(struct mpt_softc *mpt)
142b0a2fdeeSScott Long {
143b0a2fdeeSScott Long wakeup(mpt);
144b0a2fdeeSScott Long }
145b0a2fdeeSScott Long
146d0a68c27SMatt Jacob /************************** Version Compatibility *************************/
147d0a68c27SMatt Jacob #define mpt_sim_alloc(a, b, c, mpt, e, f, g) \
148d0a68c27SMatt Jacob cam_sim_alloc(a, b, c, mpt, (mpt)->unit, &(mpt)->mpt_lock, e, f, g)
149b0a2fdeeSScott Long #endif /*_MPT_CAM_H_ */
150