mpt_cam.h revision 169293
1178476Sjb/* $FreeBSD: head/sys/dev/mpt/mpt_cam.h 169293 2007-05-05 20:18:24Z mjacob $ */ 2178476Sjb/*- 3178476Sjb * LSI MPT Host Adapter FreeBSD Wrapper Definitions (CAM version) 4178476Sjb * 5178476Sjb * Copyright (c) 2000, 2001 by Greg Ansley, Adam Prewett 6178476Sjb * 7178476Sjb * Partially derived from Matty Jacobs ISP driver. 8178476Sjb * 9178476Sjb * Redistribution and use in source and binary forms, with or without 10178476Sjb * modification, are permitted provided that the following conditions 11178476Sjb * are met: 12178476Sjb * 1. Redistributions of source code must retain the above copyright 13178476Sjb * notice immediately at the beginning of the file, without modification, 14178476Sjb * this list of conditions, and the following disclaimer. 15178476Sjb * 2. The name of the author may not be used to endorse or promote products 16178476Sjb * derived from this software without specific prior written permission. 17178476Sjb * 18178476Sjb * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19178476Sjb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20178476Sjb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21178476Sjb * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 22178476Sjb * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23178476Sjb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24178476Sjb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25178476Sjb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26178476Sjb * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27178476Sjb */ 28178476Sjb/*- 29178476Sjb * Copyright (c) 2002, 2006 by Matthew Jacob 30178476Sjb * All rights reserved. 31178476Sjb * 32178476Sjb * Redistribution and use in source and binary forms, with or without 33178476Sjb * modification, are permitted provided that the following conditions are 34178476Sjb * met: 35178476Sjb * 1. Redistributions of source code must retain the above copyright 36178476Sjb * notice, this list of conditions and the following disclaimer. 37178476Sjb * 2. Redistributions in binary form must reproduce at minimum a disclaimer 38178476Sjb * substantially similar to the "NO WARRANTY" disclaimer below 39178476Sjb * ("Disclaimer") and any redistribution must be conditioned upon including 40178476Sjb * a substantially similar Disclaimer requirement for further binary 41178476Sjb * redistribution. 42178476Sjb * 3. Neither the names of the above listed copyright holders nor the names 43178476Sjb * of any contributors may be used to endorse or promote products derived 44178476Sjb * from this software without specific prior written permission. 45178476Sjb * 46178476Sjb * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 47178476Sjb * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 48178476Sjb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 49178476Sjb * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 50178476Sjb * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 51178476Sjb * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 52178476Sjb * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 53178476Sjb * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 54178476Sjb * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 55178476Sjb * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT 56178476Sjb * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 57178476Sjb * 58178476Sjb * Support from Chris Ellsworth in order to make SAS adapters work 59178476Sjb * is gratefully acknowledged. 60178476Sjb * 61178476Sjb * Support from LSI-Logic has also gone a great deal toward making this a 62178476Sjb * workable subsystem and is gratefully acknowledged. 63178476Sjb */ 64178476Sjb/*- 65178476Sjb * Copyright (c) 2004, Avid Technology, Inc. and its contributors. 66178476Sjb * Copyright (c) 2005, WHEEL Sp. z o.o. 67178476Sjb * Copyright (c) 2004, 2005 Justin T. Gibbs 68178476Sjb * All rights reserved. 69178476Sjb * 70178476Sjb * Redistribution and use in source and binary forms, with or without 71178476Sjb * modification, are permitted provided that the following conditions are 72178476Sjb * met: 73178476Sjb * 1. Redistributions of source code must retain the above copyright 74178476Sjb * notice, this list of conditions and the following disclaimer. 75178476Sjb * 2. Redistributions in binary form must reproduce at minimum a disclaimer 76178476Sjb * substantially similar to the "NO WARRANTY" disclaimer below 77178476Sjb * ("Disclaimer") and any redistribution must be conditioned upon including 78178476Sjb * a substantially similar Disclaimer requirement for further binary 79178476Sjb * redistribution. 80178476Sjb * 3. Neither the names of the above listed copyright holders nor the names 81178476Sjb * of any contributors may be used to endorse or promote products derived 82178476Sjb * from this software without specific prior written permission. 83178476Sjb * 84178476Sjb * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 85178476Sjb * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 86178476Sjb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 87178476Sjb * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 88 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 89 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 90 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 91 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 92 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 93 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT 94 * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 95 */ 96#ifndef _MPT_CAM_H_ 97#define _MPT_CAM_H_ 98 99#include <cam/cam.h> 100#include <cam/cam_debug.h> 101#include <cam/cam_ccb.h> 102#include <cam/cam_sim.h> 103#include <cam/cam_xpt.h> 104#include <cam/cam_periph.h> 105#include <cam/cam_xpt_periph.h> 106#include <cam/cam_xpt_sim.h> 107#include <cam/cam_debug.h> 108#include <cam/scsi/scsi_all.h> 109#include <cam/scsi/scsi_message.h> 110 111#define ccb_mpt_ptr sim_priv.entries[0].ptr 112#define ccb_req_ptr sim_priv.entries[1].ptr 113 114/************************** CCB Manipulation Routines *************************/ 115static __inline void mpt_freeze_ccb(union ccb *ccb); 116static __inline void mpt_set_ccb_status(union ccb *ccb, cam_status status); 117 118static __inline void 119mpt_freeze_ccb(union ccb *ccb) 120{ 121 if ((ccb->ccb_h.status & CAM_DEV_QFRZN) == 0) { 122 ccb->ccb_h.status |= CAM_DEV_QFRZN; 123 xpt_freeze_devq(ccb->ccb_h.path, /*count*/1); 124 } 125} 126 127static __inline void 128mpt_set_ccb_status(union ccb *ccb, cam_status status) 129{ 130 ccb->ccb_h.status &= ~CAM_STATUS_MASK; 131 ccb->ccb_h.status |= status; 132} 133 134/****************************** Timeout Recovery ******************************/ 135/* 136 * The longest timeout specified for a Task Managent command. 137 */ 138#define MPT_TMF_MAX_TIMEOUT (20000) 139 140static __inline void 141mpt_wakeup_recovery_thread(struct mpt_softc *mpt) 142{ 143 wakeup(mpt); 144} 145 146/************************** Version Compatibility *************************/ 147#if __FreeBSD_version < 700031 148#define mpt_sim_alloc(a, b, c, mpt, e, f, g) \ 149 cam_sim_alloc(a, b, c, mpt, (mpt)->unit, e, f, g) 150#else 151#define mpt_sim_alloc(a, b, c, mpt, e, f, g) \ 152 cam_sim_alloc(a, b, c, mpt, (mpt)->unit, &(mpt)->mpt_lock, e, f, g) 153#endif 154#endif /*_MPT_CAM_H_ */ 155