Files
@ bd21c8aa7237
Branch filter:
Location: vmkdrivers/vmkdrivers/src_9/drivers/scsi/mpt2sas/mpt2sas_compatibility.h
bd21c8aa7237
5.0 KiB
text/x-chdr
ESXi-6.0.0b
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | /*
* Compatiblity Header for compilation working across multiple kernels
*
* This code is based on drivers/scsi/mpt2sas/mpt2_base.c
* Copyright (C) 2007-2013 LSI Corporation
* (mailto:DL-MPTFusionLinux@lsi.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* NO WARRANTY
* THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
* LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
* solely responsible for determining the appropriateness of using and
* distributing the Program and assumes all risks associated with its
* exercise of rights under this Agreement, including but not limited to
* the risks and costs of program errors, damage to or loss of data,
* programs or equipment, and unavailability or interruption of operations.
* DISCLAIMER OF LIABILITY
* NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
* HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
#ifndef FUSION_LINUX_COMPAT_H
#define FUSION_LINUX_COMPAT_H
#include <linux/version.h>
extern int scsi_internal_device_block(struct scsi_device *sdev);
extern int scsi_internal_device_unblock(struct scsi_device *sdev);
#ifndef DID_TRANSPORT_DISRUPTED
#define DID_TRANSPORT_DISRUPTED DID_BUS_BUSY
#endif
#ifndef ULLONG_MAX
#define ULLONG_MAX (~0ULL)
#endif
#ifndef USHORT_MAX
#define USHORT_MAX ((u16)(~0U))
#endif
/*
* TODO Need to change 'shost_private' back to 'shost_priv' when suppying patchs
* upstream. Since Red Hat decided to backport this to rhel5.2 (2.6.18-92.el5)
* from the 2.6.23 kernel, it will make it difficult for us to add the proper
* glue in our driver.
*/
static inline void *shost_private(struct Scsi_Host *shost)
{
return (void *)shost->hostdata;
}
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27))
static inline sector_t scsi_get_lba(struct scsi_cmnd *scmd)
{
return scmd->request->sector;
}
#endif
/**
* mpt_scsi_build_sense_buffer - build sense data in a buffer
* @desc: Sense format (non zero == descriptor format,
* 0 == fixed format)
* @buf: Where to build sense data
* @key: Sense key
* @asc: Additional sense code
* @ascq: Additional sense code qualifier
*
* Note: scsi_build_sense_buffer was added in the 2.6.26 kernel
* It was backported in RHEL5.3 2.6.18-128.el5
**/
static inline void mpt_scsi_build_sense_buffer(int desc, u8 *buf, u8 key,
u8 asc, u8 ascq)
{
if (desc) {
buf[0] = 0x72; /* descriptor, current */
buf[1] = key;
buf[2] = asc;
buf[3] = ascq;
buf[7] = 0;
} else {
buf[0] = 0x70; /* fixed, current */
buf[2] = key;
buf[7] = 0xa;
buf[12] = asc;
buf[13] = ascq;
}
}
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23))
/**
* mpt_scsilun_to_int: convert a scsi_lun to an int
* @scsilun: struct scsi_lun to be converted.
*
* Description:
* Convert @scsilun from a struct scsi_lun to a four byte host byte-ordered
* integer, and return the result. The caller must check for
* truncation before using this function.
*
* Notes:
* The struct scsi_lun is assumed to be four levels, with each level
* effectively containing a SCSI byte-ordered (big endian) short; the
* addressing bits of each level are ignored (the highest two bits).
* For a description of the LUN format, post SCSI-3 see the SCSI
* Architecture Model, for SCSI-3 see the SCSI Controller Commands.
*
* Given a struct scsi_lun of: 0a 04 0b 03 00 00 00 00, this function
* returns the integer: 0x0b030a04
**/
static inline int mpt_scsilun_to_int(struct scsi_lun *scsilun)
{
int i;
unsigned int lun;
lun = 0;
for (i = 0; i < sizeof(lun); i += 2)
lun = lun | (((scsilun->scsi_lun[i] << 8) |
scsilun->scsi_lun[i + 1]) << (i * 8));
return lun;
}
#else
static inline int mpt_scsilun_to_int(struct scsi_lun *scsilun)
{
return scsilun_to_int(scsilun);
}
#endif
#endif /* FUSION_LINUX_COMPAT_H */
|