mpt_cam.h revision 148679
1147883Sscottl/* $FreeBSD: head/sys/dev/mpt/mpt_cam.h 148679 2005-08-03 14:08:41Z gibbs $ */ 2147883Sscottl/*- 3147883Sscottl * LSI MPT Host Adapter FreeBSD Wrapper Definitions (CAM version) 4147883Sscottl * 5147883Sscottl * Copyright (c) 2000, 2001 by Greg Ansley, Adam Prewett 6147883Sscottl * 7147883Sscottl * Partially derived from Matty Jacobs ISP driver. 8147883Sscottl * 9147883Sscottl * Redistribution and use in source and binary forms, with or without 10147883Sscottl * modification, are permitted provided that the following conditions 11147883Sscottl * are met: 12147883Sscottl * 1. Redistributions of source code must retain the above copyright 13147883Sscottl * notice immediately at the beginning of the file, without modification, 14147883Sscottl * this list of conditions, and the following disclaimer. 15147883Sscottl * 2. The name of the author may not be used to endorse or promote products 16147883Sscottl * derived from this software without specific prior written permission. 17147883Sscottl * 18147883Sscottl * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19147883Sscottl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20147883Sscottl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21147883Sscottl * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 22147883Sscottl * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23147883Sscottl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24147883Sscottl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25147883Sscottl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26147883Sscottl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27147883Sscottl * 28147883Sscottl * Additional Copyright (c) 2002 by Matthew Jacob under same license. 29147883Sscottl */ 30147883Sscottl/*- 31147883Sscottl * Copyright (c) 2004, Avid Technology, Inc. and its contributors. 32147883Sscottl * Copyright (c) 2005, WHEEL Sp. z o.o. 33147883Sscottl * Copyright (c) 2004, 2005 Justin T. Gibbs 34147883Sscottl * All rights reserved. 35147883Sscottl * 36147883Sscottl * Redistribution and use in source and binary forms, with or without 37147883Sscottl * modification, are permitted provided that the following conditions are 38147883Sscottl * met: 39147883Sscottl * 1. Redistributions of source code must retain the above copyright 40147883Sscottl * notice, this list of conditions and the following disclaimer. 41147883Sscottl * 2. Redistributions in binary form must reproduce at minimum a disclaimer 42147883Sscottl * substantially similar to the "NO WARRANTY" disclaimer below 43147883Sscottl * ("Disclaimer") and any redistribution must be conditioned upon including 44147883Sscottl * a substantially similar Disclaimer requirement for further binary 45147883Sscottl * redistribution. 46148679Sgibbs * 3. Neither the names of the above listed copyright holders nor the names 47148679Sgibbs * of any contributors may be used to endorse or promote products derived 48148679Sgibbs * from this software without specific prior written permission. 49147883Sscottl * 50147883Sscottl * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 51147883Sscottl * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 52147883Sscottl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 53147883Sscottl * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 54147883Sscottl * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 55147883Sscottl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 56147883Sscottl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 57147883Sscottl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 58147883Sscottl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 59147883Sscottl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT 60147883Sscottl * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 61147883Sscottl */ 62147883Sscottl#ifndef _MPT_CAM_H_ 63147883Sscottl#define _MPT_CAM_H_ 64147883Sscottl 65147883Sscottl#include <cam/cam.h> 66147883Sscottl#include <cam/cam_debug.h> 67147883Sscottl#include <cam/cam_ccb.h> 68147883Sscottl#include <cam/cam_sim.h> 69147883Sscottl#include <cam/cam_xpt.h> 70147883Sscottl#include <cam/cam_xpt_sim.h> 71147883Sscottl#include <cam/cam_debug.h> 72147883Sscottl#include <cam/scsi/scsi_all.h> 73147883Sscottl#include <cam/scsi/scsi_message.h> 74147883Sscottl 75147883Sscottl#define ccb_mpt_ptr sim_priv.entries[0].ptr 76147883Sscottl#define ccb_req_ptr sim_priv.entries[1].ptr 77147883Sscottl 78147883Sscottl/************************** CCB Manipulation Routines *************************/ 79147883Sscottlstatic __inline void mpt_freeze_ccb(union ccb *ccb); 80147883Sscottlstatic __inline void mpt_set_ccb_status(union ccb *ccb, cam_status status); 81147883Sscottl 82147883Sscottlstatic __inline void 83147883Sscottlmpt_freeze_ccb(union ccb *ccb) 84147883Sscottl{ 85147883Sscottl if ((ccb->ccb_h.status & CAM_DEV_QFRZN) == 0) { 86147883Sscottl ccb->ccb_h.status |= CAM_DEV_QFRZN; 87147883Sscottl xpt_freeze_devq(ccb->ccb_h.path, /*count*/1); 88147883Sscottl } 89147883Sscottl} 90147883Sscottl 91147883Sscottlstatic __inline void 92147883Sscottlmpt_set_ccb_status(union ccb *ccb, cam_status status) 93147883Sscottl{ 94147883Sscottl ccb->ccb_h.status &= ~CAM_STATUS_MASK; 95147883Sscottl ccb->ccb_h.status |= status; 96147883Sscottl} 97147883Sscottl 98147883Sscottl/****************************** Timeout Recovery ******************************/ 99147883Sscottl/* 100147883Sscottl * The longest timeout specified for a Task Managent command. 101147883Sscottl */ 102147883Sscottl#define MPT_TMF_MAX_TIMEOUT (20000) 103147883Sscottl 104147883Sscottlstatic __inline void 105147883Sscottlmpt_wakeup_recovery_thread(struct mpt_softc *mpt) 106147883Sscottl{ 107147883Sscottl wakeup(mpt); 108147883Sscottl} 109147883Sscottl 110147883Sscottl#endif /*_MPT_CAM_H_ */ 111