Add more startup delay for 24XX cards when execing f/w (temp soln)

Add support for up through 2.6.25 (might even be good for 2.6.26)
Remove HBAAPI support. This never has worked well and I doubt anyone will miss it.
Remove files not pertinent SCST build.


git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@493 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Dotan Barak
2008-09-12 22:30:21 +00:00
parent 2072470745
commit 508b07dbb0
13 changed files with 402 additions and 5843 deletions

View File

@@ -1,4 +1,4 @@
/* $Id: isp.c,v 1.204 2008/04/15 22:40:52 mjacob Exp $ */
/* $Id: isp.c,v 1.209 2008/09/12 16:01:52 mjacob Exp $ */
/*-
* Copyright (c) 1997-2008 by Matthew Jacob
* All rights reserved.
@@ -116,7 +116,7 @@ static const char pskip[] =
static const char topology[] =
"Chan %d WWPN 0x%08x%08x PortID 0x%06x N-Port Handle %d, Connection '%s'";
static const char finmsg[] =
"%d.%d.%d: FIN dl%d resid %d STS 0x%x SKEY %c XS_ERR=0x%x";
"%d.%d.%d: FIN dl%d resid %ld STS 0x%x SKEY %c XS_ERR=0x%x";
static const char sc4[] = "NVRAM";
static const char bun[] =
"bad underrun for %d.%d (count %d, resid %d, status %s)";
@@ -500,7 +500,7 @@ isp_reset(ispsoftc_t *isp)
/*
* Hit the chip over the head with hammer,
* and give the ISP a chance to recover.
* and give it a chance to recover.
*/
if (IS_SCSI(isp)) {
@@ -624,7 +624,6 @@ isp_reset(ispsoftc_t *isp)
ISP_WRITE(isp, BIU_SEMA, 0);
}
/*
* Post-RISC Reset stuff.
*/
@@ -723,17 +722,24 @@ isp_reset(ispsoftc_t *isp)
*/
/*
* Do some sanity checking.
* Do some sanity checking by running a NOP command.
* If it succeeds, the ROM firmware is now running.
*/
MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_NO_OP;
mbs.logval = MBLOGALL;
isp_mboxcmd(isp, &mbs);
if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
isp_prt(isp, ISP_LOGERR, "NOP ommand failed (%x)",
mbs.param[0]);
ISP_RESET0(isp);
return;
}
/*
* Do some operational tests
*/
if (IS_SCSI(isp) || IS_24XX(isp)) {
MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_MAILBOX_REG_TEST;
@@ -788,13 +794,6 @@ isp_reset(ispsoftc_t *isp)
if (dodnld && IS_24XX(isp)) {
const uint32_t *ptr = isp->isp_mdvec->dv_ispfw;
/*
* NB: Whatever you do do, do *not* issue the VERIFY FIRMWARE
* NB: command to the 2400 while loading new firmware. This
* NB: causes the new f/w to start and immediately crash back
* NB: to the ROM.
*/
/*
* Keep loading until we run out of f/w.
*/
@@ -909,23 +908,6 @@ isp_reset(ispsoftc_t *isp)
la += nw;
}
if (!IS_2322(isp)) {
/*
* Verify that it downloaded correctly.
*/
MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_VERIFY_CHECKSUM;
mbs.param[1] = code_org;
mbs.logval = MBLOGNONE;
isp_mboxcmd(isp, &mbs);
if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
isp_prt(isp, ISP_LOGERR, dcrc);
ISP_RESET0(isp);
return;
}
break;
}
if (++segno == 3) {
break;
}
@@ -965,23 +947,29 @@ isp_reset(ispsoftc_t *isp)
ISP_RESET0(isp);
return;
}
/*
* Verify that it downloaded correctly.
*/
} else {
isp->isp_loaded_fw = 0;
isp_prt(isp, ISP_LOGDEBUG2, "skipping f/w download");
}
/*
* If we loaded firmware, verify its checksum
*/
if (isp->isp_loaded_fw) {
MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_VERIFY_CHECKSUM;
mbs.param[1] = code_org;
mbs.logval = MBLOGNONE;
if (IS_24XX(isp)) {
mbs.param[1] = code_org >> 16;
mbs.param[2] = code_org;
} else {
mbs.param[1] = code_org;
}
isp_mboxcmd(isp, &mbs);
if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
isp_prt(isp, ISP_LOGERR, dcrc);
ISP_RESET0(isp);
return;
}
isp->isp_loaded_fw = 1;
} else {
isp->isp_loaded_fw = 0;
isp_prt(isp, ISP_LOGDEBUG2, "skipping f/w download");
}
/*
@@ -1025,22 +1013,38 @@ isp_reset(ispsoftc_t *isp)
/*
* Give it a chance to finish starting up.
* Give the 24XX more time.
*/
USEC_DELAY(250000);
if (IS_SCSI(isp)) {
if (IS_24XX(isp)) {
USEC_DELAY(500000);
/*
* Set CLOCK RATE, but only if asked to.
* Check to see if the 24XX firmware really started.
*/
if (isp->isp_clock) {
mbs.param[0] = MBOX_SET_CLOCK_RATE;
mbs.param[1] = isp->isp_clock;
mbs.logval = MBLOGNONE;
isp_mboxcmd(isp, &mbs);
/* we will try not to care if this fails */
if (mbs.param[1] == 0xdead) {
isp_prt(isp, ISP_LOGERR, "f/w didn't *really* start");
ISP_RESET0(isp);
return;
}
} else {
USEC_DELAY(250000);
if (IS_SCSI(isp)) {
/*
* Set CLOCK RATE, but only if asked to.
*/
if (isp->isp_clock) {
mbs.param[0] = MBOX_SET_CLOCK_RATE;
mbs.param[1] = isp->isp_clock;
mbs.logval = MBLOGNONE;
isp_mboxcmd(isp, &mbs);
/* we will try not to care if this fails */
}
}
}
/*
* Ask the chip for the current firmware version.
* This should prove that the new firmware is working.
*/
MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_ABOUT_FIRMWARE;
mbs.logval = MBLOGALL;
@@ -1050,12 +1054,6 @@ isp_reset(ispsoftc_t *isp)
return;
}
if (IS_24XX(isp) && mbs.param[1] == 0xdead) {
isp_prt(isp, ISP_LOGERR, "f/w didn't *really* start");
ISP_RESET0(isp);
return;
}
/*
* The SBus firmware that we are using apparently does not return
* major, minor, micro revisions in the mailbox registers, which
@@ -2390,13 +2388,13 @@ isp_port_login(ispsoftc_t *isp, uint16_t handle, uint32_t portid)
switch (mbs.param[0]) {
case MBOX_PORT_ID_USED:
isp_prt(isp, ISP_LOGDEBUG0,
"isp_plogi_old: portid 0x%06x already logged in as %u",
"isp_port_login: portid 0x%06x already logged in as %u",
portid, mbs.param[1]);
return (MBOX_PORT_ID_USED | (mbs.param[1] << 16));
case MBOX_LOOP_ID_USED:
isp_prt(isp, ISP_LOGDEBUG0,
"isp_plogi_old: handle %u in use for port id 0x%02xXXXX",
"isp_port_login: handle %u in use for port id 0x%02xXXXX",
handle, mbs.param[1] & 0xff);
return (MBOX_LOOP_ID_USED);
@@ -2405,18 +2403,18 @@ isp_port_login(ispsoftc_t *isp, uint16_t handle, uint32_t portid)
case MBOX_COMMAND_ERROR:
isp_prt(isp, ISP_LOGINFO,
"isp_plogi_old: error 0x%x in PLOGI to port 0x%06x",
"isp_port_login: error 0x%x in PLOGI to port 0x%06x",
mbs.param[1], portid);
return (MBOX_COMMAND_ERROR);
case MBOX_ALL_IDS_USED:
isp_prt(isp, ISP_LOGINFO,
"isp_plogi_old: all IDs used for fabric login");
"isp_port_login: all IDs used for fabric login");
return (MBOX_ALL_IDS_USED);
default:
isp_prt(isp, ISP_LOGINFO,
"isp_plogi_old: error 0x%x on port login of 0x%06x@0x%0x",
"isp_port_login: error 0x%x on port login of 0x%06x@0x%0x",
mbs.param[0], portid, handle);
return (mbs.param[0]);
}
@@ -4137,6 +4135,8 @@ isp_login_device(ispsoftc_t *isp, int chan, uint32_t portid, isp_pdb_t *p,
} else if (r != MBOX_LOOP_ID_USED) {
i = lim;
break;
} else if (r == MBOX_TIMEOUT) {
return (-1);
} else {
*ohp = handle;
handle = isp_nxt_handle(isp, chan, *ohp);
@@ -4326,7 +4326,7 @@ isp_register_fc4_type_24xx(ispsoftc_t *isp, int chan)
} else if (ct->ct_cmd_resp == LS_ACC) {
isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
"Chan %d Register FC4 Type accepted", chan);
return(0);
return (0);
} else {
isp_prt(isp, ISP_LOGWARN,
"Chan %d Register FC4 Type: 0x%x",
@@ -4546,7 +4546,7 @@ isp_start(XS_T *xs)
/*
* See comment in isp_intr
*/
/* XS_RESID(xs) = 0; */
/* XS_SET_RESID(xs, 0); */
/*
* Fibre Channel always requires some kind of tag.
@@ -5010,7 +5010,7 @@ isp_control(ispsoftc_t *isp, ispctl_t ctl, ...)
mbr = va_arg(ap, mbreg_t *);
va_end(ap);
isp_mboxcmd(isp, mbr);
return(0);
return (0);
}
case ISPCTL_PLOGX:
{
@@ -5489,7 +5489,7 @@ again:
XS_SETERR(xs, HBA_TGTBSY);
}
if (IS_SCSI(isp)) {
XS_RESID(xs) = resid;
XS_SET_RESID(xs, resid);
/*
* A new synchronous rate was negotiated for
* this target. Mark state such that we'll go
@@ -5504,11 +5504,11 @@ again:
}
} else {
if (req_status_flags & RQSF_XFER_COMPLETE) {
XS_RESID(xs) = 0;
XS_SET_RESID(xs, 0);
} else if (scsi_status & RQCS_RESID) {
XS_RESID(xs) = resid;
XS_SET_RESID(xs, resid);
} else {
XS_RESID(xs) = 0;
XS_SET_RESID(xs, 0);
}
}
if (snsp && slen) {
@@ -5516,7 +5516,7 @@ again:
}
isp_prt(isp, ISP_LOGDEBUG2,
"asked for %ld got raw resid %ld settled for %ld",
(long) XS_XFRLEN(xs), resid, (long) XS_RESID(xs));
(long) XS_XFRLEN(xs), resid, (long) XS_GET_RESID(xs));
break;
case RQSTYPE_REQUEST:
case RQSTYPE_A64:
@@ -5541,7 +5541,7 @@ again:
QENTRY_LEN, qe);
}
}
XS_RESID(xs) = XS_XFRLEN(xs);
XS_SET_RESID(xs, XS_XFRLEN(xs));
break;
default:
isp_print_bytes(isp, "Unhandled Response Type",
@@ -5576,7 +5576,7 @@ again:
skey = '.';
}
isp_prt(isp, ISP_LOGALL, finmsg, XS_CHANNEL(xs),
XS_TGT(xs), XS_LUN(xs), XS_XFRLEN(xs), XS_RESID(xs),
XS_TGT(xs), XS_LUN(xs), XS_XFRLEN(xs), (long) XS_GET_RESID(xs),
*XS_STSP(xs), skey, XS_ERR(xs));
}
@@ -6392,9 +6392,9 @@ isp_parse_status(ispsoftc_t *isp, ispstatusreq_t *sp, XS_T *xs, long *rp)
return;
case RQCS_DATA_OVERRUN:
XS_RESID(xs) = sp->req_resid;
isp_prt(isp, ISP_LOGERR, "data overrun for command on %d.%d.%d",
XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
XS_SET_RESID(xs, sp->req_resid);
isp_prt(isp, ISP_LOGERR, "data overrun (%ld) for command on %d.%d.%d",
(long) XS_GET_RESID(xs), XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
if (XS_NOERR(xs)) {
XS_SETERR(xs, HBA_DATAOVR);
}
@@ -6486,7 +6486,7 @@ isp_parse_status(ispsoftc_t *isp, ispstatusreq_t *sp, XS_T *xs, long *rp)
return;
}
}
XS_RESID(xs) = sp->req_resid;
XS_SET_RESID(xs, sp->req_resid);
if (XS_NOERR(xs)) {
XS_SETERR(xs, HBA_NOERROR);
}
@@ -6706,7 +6706,7 @@ isp_parse_status_24xx(ispsoftc_t *isp, isp24xx_statusreq_t *sp,
return;
case RQCS_DATA_OVERRUN:
XS_RESID(xs) = sp->req_resid;
XS_SET_RESID(xs, sp->req_resid);
isp_prt(isp, ISP_LOGERR,
"data overrun for command on %d.%d.%d",
XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
@@ -6750,7 +6750,7 @@ isp_parse_status_24xx(ispsoftc_t *isp, isp24xx_statusreq_t *sp,
}
return;
}
XS_RESID(xs) = sp->req_resid;
XS_SET_RESID(xs, sp->req_resid);
isp_prt(isp, ISP_LOGDEBUG0,
"%d.%d.%d data underrun (%d) for command 0x%x",
XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs),
@@ -6850,7 +6850,7 @@ isp_fastpost_complete(ispsoftc_t *isp, uint16_t fph)
* we must believe that SCSI status is zero and
* that all data transferred.
*/
XS_RESID(xs) = 0;
XS_SET_RESID(xs, 0);
*XS_STSP(xs) = SCSI_GOOD;
if (XS_XFRLEN(xs)) {
ISP_DMAFREE(isp, xs, fph);
@@ -7141,7 +7141,7 @@ static const uint32_t mbpfc[] = {
ISPOPMAP(0x07, 0x07), /* 0x04: MBOX_WRITE_RAM_WORD */
ISPOPMAP(0x03, 0x07), /* 0x05: MBOX_READ_RAM_WORD */
ISPOPMAP(0xff, 0xff), /* 0x06: MBOX_MAILBOX_REG_TEST */
ISPOPMAP(0x03, 0x07), /* 0x07: MBOX_VERIFY_CHECKSUM */
ISPOPMAP(0x07, 0x07), /* 0x07: MBOX_VERIFY_CHECKSUM */
ISPOPMAP(0x01, 0x4f), /* 0x08: MBOX_ABOUT_FIRMWARE */
ISPOPMAP(0xdf, 0x01), /* 0x09: MBOX_LOAD_RISC_RAM_2100 */
ISPOPMAP(0xdf, 0x01), /* 0x0a: DUMP RAM */
@@ -7866,7 +7866,6 @@ isp_setdfltsdparm(ispsoftc_t *isp)
return;
}
}
}
MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_GET_ACT_NEG_STATE;
@@ -8033,9 +8032,9 @@ isp_reinit(ispsoftc_t *isp)
isp_destroy_handle(isp, handle);
if (XS_XFRLEN(xs)) {
ISP_DMAFREE(isp, xs, handle);
XS_RESID(xs) = XS_XFRLEN(xs);
XS_SET_RESID(xs, XS_XFRLEN(xs));
} else {
XS_RESID(xs) = 0;
XS_SET_RESID(xs, 0);
}
XS_SETERR(xs, HBA_BUSRESET);
isp_done(xs);

View File

@@ -1,4 +1,4 @@
/* $Id: ispvar.h,v 1.97 2008/03/23 04:56:30 mjacob Exp $ */
/* $Id: ispvar.h,v 1.99 2008/06/16 23:53:18 mjacob Exp $ */
/*-
* Copyright (c) 1997-2008 by Matthew Jacob
* All rights reserved.
@@ -104,7 +104,9 @@ struct ispmdvec {
* Overall parameters
*/
#define MAX_TARGETS 16
#ifndef MAX_FC_TARG
#define MAX_FC_TARG 512
#endif
#define ISP_MAX_TARGETS(isp) (IS_FC(isp)? MAX_FC_TARG : MAX_TARGETS)
#define ISP_MAX_LUNS(isp) (isp)->isp_maxluns
@@ -983,7 +985,8 @@ void isp_async(ispsoftc_t *, ispasync_t, ...);
* XS_CDBLEN(xs) gets the CDB's length ""
* XS_XFRLEN(xs) gets the associated data transfer length ""
* XS_TIME(xs) gets the time (in milliseconds) for this command
* XS_RESID(xs) gets the current residual count
* XS_GET_RESID(xs) gets the current residual count
* XS_GET_RESID(xs, resid) sets the current residual count
* XS_STSP(xs) gets a pointer to the SCSI status byte ""
* XS_SNSP(xs) gets a pointer to the associate sense data
* XS_SNSLEN(xs) gets the length of sense data storage

File diff suppressed because it is too large Load Diff

View File

@@ -1,373 +0,0 @@
/*****************************************************************************
* QLOGIC LINUX SOFTWARE
*
* QLogic ISP2x00 device driver ioctl definition file
* Copyright (C) 2005 QLogic Corporation
* (www.qlogic.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, 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.
****************************************************************************/
/*
* File Name: exioctln.h
Rev 24 October 06, 2005 RL
- Added reserve internal ioctl command code for future use.
Rev 23 June 22, 2005 RL
- Corrected assignment condition of EXT_ADDR_MODE_OS value.
Rev 22 February 25, 2005 RL
- Added reserve internal ioctl command codes.
Rev 21 February 1, 2005 RL
- Deleted AdapterModel field and bit definition for
EXT_LN_DRIVER_DATA.
Rev 20 December 20, 2004 RL
- Decreased MAX_HBA_OS value again.
Rev 19 September 9, 2004 RL
- Added AdapterModel field and bit definition for
EXT_LN_DRIVER_DATA.
Rev 18 August 6, 2004 RL
- Added 'Flags' field and bit defines for EXT_LN_DRIVER_DATA.
- Corrected UINT64 define to real 64 bit.
- Corrected ioctl command value definition so it is
the same value in both 32bit and 64bit environments.
- Added NFO command values.
- Changed EXT_CC_STARTIOCTL to EXT_CC_GET_HBA_CNT.
Rev 17 August 08, 2003 RL
- Decreased MAX_HBA_OS value to both decrease wasted space
in shared mem so it can be used to store other data, and
to decrease unnecesary loops checking through all adapters.
Rev 16 July 31, 2003 RL
- Added definitions for Status field in discovered target
structure.
- Updated ioctl command value assignment on PPC64 so this
file can be shared with API lib.
Rev 15 June 03, 2003 RL
- Modified ioctl command code value assignment so it also
works on PPC64.
Rev 14 February 25, 2003 RL
- Added EXT_CC_DRIVER_SPECIFIC ioctl command to return
some driver specific data that can be used by API library
to determine how to maintain backward compatibility
of certain features.
Rev 13 January 31, 2003 RL
- Changed the value of EXT_DEF_USE_HBASELECT to avoid
conflicting with older implementation of FO API lib.
Rev 12 January 20, 2003 RL
- Added EXT_DEF_USE_HBASELECT definition for use by
the SETINSTANCE command.
Rev 11 December 10, 2002 RL
- Added EXT_CC_SEND_ELS_PASSTHRU_OS definition.
Rev 10 October 26, 2001 RL
- Corrected MAX_HBA, MAX_TARGET and MAX_LUN values to 255.
Rev 9 July 26, 2001 RL
- Added definition of signed types.
Rev 8 July 05, 2001 RL
- Redefined ioctl command values.
Rev 7 Nov 06, 2000 BN
- Added EXT_DEF_MAX_AEN_QUEUE_OS define
- Added define for handle_hba_t
Rev 6 Oct 25, 2000 BN
- Added EXT_CC_DRIVER_PROP_OS define
Rev 5 Oct 25, 2000 BN
- Redo the copyright header and add AEN details
Rev 4 Oct 23, 2000 BN
- Added definition for BOOLEAN
Rev 3 Oct 23, 2000 BN
- Added definitions for EXT_ADDR_MODE_OS
and also include of <linux/ioctl.h>
Rev 2 Oct 18, 2000 BN
- Enable API Exention support
Rev 1 Original version Sep 7, 2000 BN
*/
#ifndef _EXIOCT_LN_H_
#define _EXIOCT_LN_H_
#include <linux/ioctl.h>
#ifdef APILIB
#include <stdint.h>
#include <linux/types.h>
#include <bits/wordsize.h>
#endif
#ifndef INT8
#define INT8 int8_t
#endif
#ifndef INT16
#define INT16 int16_t
#endif
#ifndef INT32
#define INT32 int32_t
#endif
#ifndef UINT8
#define UINT8 uint8_t
#endif
#ifndef UINT16
#define UINT16 uint16_t
#endif
#ifndef UINT32
#define UINT32 uint32_t
#endif
#ifndef UINT64
#define UINT64 uint64_t
#endif
#ifndef UINT64_O
#define UINT64_O void * /* old define for FC drivers */
#endif
#ifndef BOOLEAN
#define BOOLEAN uint8_t
#endif
#ifndef HANDLE
#define HANDLE int
#endif
#if __WORDSIZE == 64
#define EXT_ADDR_MODE_OS EXT_DEF_ADDR_MODE_64
#else
#define EXT_ADDR_MODE_OS EXT_DEF_ADDR_MODE_32
#endif
#define QLMULTIPATH_MAGIC 'y'
#define _QLBUILD /* for exioct.h to enable include of qinsdmgt.h */
#define EXT_DEF_MAX_HBA_OS 31 /* 0x1F */
#define EXT_DEF_MAX_HBAS 32 /* 0 - 0x1F */
#define EXT_DEF_MAX_BUS_OS 1
#define EXT_DEF_MAX_TARGET_OS 255 /* 0xFE */
#define EXT_DEF_MAX_TARGETS 256 /* 0 - 0xFE */
#define EXT_DEF_MAX_LUN_OS 255 /* 0xFE */
#define EXT_DEF_MAX_LUNS 256 /* 0 - 0xFE */
#define EXT_DEF_MAX_AEN_QUEUE_OS 64
#define EXT_DEF_MAX_TGTEV_QUEUE_OS 256 /* max tgts in driver */
#define EXT_DEF_MAX_NFOEV_QUEUE_OS 256
#define EXT_DEF_FC_HEADER_LEN 24
#define EXT_DEF_ELS_RJT_LENGTH 0x08 /* 8 */
#define EXT_DEF_ELS_RPS_ACC_LENGTH 0x40 /* 64 */
#define EXT_DEF_ELS_RLS_ACC_LENGTH 0x1C /* 28 */
#define EXT_DEF_USE_HBASELECT 0x02 /* bit 1: HbaSelect field now
* used to specify destination
* HBA of each command.
* SetInstance cmd is now
* issued only once during
* API initialization.
*/
/* target status flags */
#define EXT_DEF_TGTSTAT_OFFLINE 0x01
#define EXT_DEF_TGTSTAT_IN_CFG 0x02
#define EXT_DEF_REGULAR_SIGNATURE "QLOGIC"
/*****************/
/* Command codes */
/*****************/
#define QL_IOCTL_BASE(idx) \
_IOWR(QLMULTIPATH_MAGIC, idx, EXT_IOCTL)
#define QL_IOCTL_CMD(idx) QL_IOCTL_BASE(idx)
/***************************************************************
* These are regular/external command codes, starting from 0.
* The regular command code end index must be updated whenever
* adding new commands.
***************************************************************/
#define EXT_DEF_LN_REG_CC_START_IDX 0x00 /* reg cmd start index */
#define EXT_CC_QUERY_OS /* QUERY */ \
QL_IOCTL_CMD(0x00)
#define EXT_CC_SEND_FCCT_PASSTHRU_OS /* FCCT_PASSTHRU */ \
QL_IOCTL_CMD(0x01)
#define EXT_CC_REG_AEN_OS /* REG_AEN */ \
QL_IOCTL_CMD(0x02)
#define EXT_CC_GET_AEN_OS /* GET_AEN */ \
QL_IOCTL_CMD(0x03)
#define EXT_CC_SEND_ELS_RNID_OS /* SEND_ELS_RNID */ \
QL_IOCTL_CMD(0x04)
#define EXT_CC_SCSI_PASSTHRU_OS /* SCSI_PASSTHRU */ \
QL_IOCTL_CMD(0x05)
#define EXT_CC_GET_DATA_OS /* GET_DATA */ \
QL_IOCTL_CMD(0x06)
#define EXT_CC_SET_DATA_OS /* SET_DATA */ \
QL_IOCTL_CMD(0x07)
#define EXT_DEF_LN_REG_CC_END_IDX 0x07 /* reg cmd end index */
/*****************************************
* Following are internal command codes.
* See inioct.h.
*****************************************/
#define EXT_DEF_LN_INT_CC_START_IDX 0x08 /* int cmd start index */
#define EXT_CC_RESERVED0A_OS \
QL_IOCTL_CMD(0x08)
#define EXT_CC_RESERVED0B_OS \
QL_IOCTL_CMD(0x09)
#define EXT_CC_RESERVED0C_OS \
QL_IOCTL_CMD(0x0a)
#define EXT_CC_RESERVED0D_OS \
QL_IOCTL_CMD(0x0b)
#define EXT_CC_RESERVED0E_OS \
QL_IOCTL_CMD(0x0c)
#define EXT_CC_RESERVED0F_OS \
QL_IOCTL_CMD(0x0d)
#define EXT_CC_RESERVED0G_OS \
QL_IOCTL_CMD(0x0e)
#define EXT_CC_RESERVED0H_OS \
QL_IOCTL_CMD(0x0f)
#define EXT_CC_RESERVED0I_OS \
QL_IOCTL_CMD(0x10)
#define EXT_CC_RESERVED0J_OS \
QL_IOCTL_CMD(0x11)
#define EXT_CC_RESERVED0K_OS \
QL_IOCTL_CMD(0x12)
#define EXT_CC_RESERVED0L_OS \
QL_IOCTL_CMD(0x13)
#define EXT_CC_RESERVED0Z_OS \
QL_IOCTL_CMD(0x21)
#define EXT_DEF_LN_INT_CC_END_IDX 0x21 /* supported int cmd end idx */
/********************************************************/
/* These are additional regular/external command codes. */
/********************************************************/
#define EXT_DEF_LN_ADD_CC_START_IDX 0x30 /* additional cmd start index */
#define EXT_CC_SEND_ELS_PASSTHRU_OS \
QL_IOCTL_CMD(0x30)
#define EXT_DEF_LN_ADD_CC_END_IDX 0x30 /* additional cmd end index */
/********************************************************
* NextGen Failover (NFO) ioctl command codes range from
* 0x37 to 0x4f. See qlnfoln.h
********************************************************/
/********************************************************
* Failover ioctl command codes range from 0xc0 to 0xdf.
* See definition in qlfoln.h.
********************************************************/
/*******************************************************************/
/* These are Linux driver implementation specific commands. Values */
/* start from highest possible value and in decreasing order. */
/*******************************************************************/
#define EXT_DEF_LN_SPC_CC_START_IDX 0xff /* LN specific cmd start idx */
#define EXT_CC_GET_HBA_CNT /* GET_HBA_CNT */ \
QL_IOCTL_CMD(0xff)
#define EXT_CC_SETINSTANCE /* SETINSTANCE */ \
QL_IOCTL_CMD(0xfe)
#define EXT_CC_WWPN_TO_SCSIADDR /* WWPN_TO_SCSIADDR */ \
QL_IOCTL_CMD(0xfd)
#define EXT_CC_DRIVER_SPECIFIC /* DRIVER_SPECIFIC */ \
QL_IOCTL_CMD(0xfc)
#define EXT_DEF_LN_SPC_CC_END_IDX 0xfc /* LN specific cmd end idx */
/*
* Response struct definition
*/
typedef struct _EXT_LN_DRV_VERSION {
UINT8 Major;
UINT8 Minor;
UINT8 Patch;
UINT8 Beta;
UINT8 Reserved[4];
} EXT_LN_DRV_VERSION; /* 8 */
typedef struct _EXT_LN_DRIVER_DATA {
EXT_LN_DRV_VERSION DrvVer; /* 8 */
UINT32 Flags; /* 4 */
UINT32 Reserved[13]; /* 52 */
} EXT_LN_DRIVER_DATA, *PEXT_LN_DRIVER_DATA; /* 64 */
/* Bit defines for the Flags field */
#define EXT_DEF_NGFO_CAPABLE 0x0001 /* bit 0: failover capable */
#define EXT_DEF_NGFO_ENABLED 0x0002 /* bit 1: failover enabled */
/*
* Overrides for Emacs so that we almost follow Linus's tabbing style.
* Emacs will notice this stuff at the end of the file and automatically
* adjust the settings for this buffer only. This must remain at the end
* of the file.
* ---------------------------------------------------------------------------
* Local variables:
* c-indent-level: 2
* c-brace-imaginary-offset: 0
* c-brace-offset: -2
* c-argdecl-indent: 2
* c-label-offset: -2
* c-continued-statement-offset: 4
* c-continued-brace-offset: 0
* indent-tabs-mode: nil
* tab-width: 8
* End:
*/
#endif /* _EXIOCT_LN_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -232,14 +232,6 @@ typedef struct {
/* do not recycle 22 */
#define ISP_FC_GETDLIST (ISP_IOC | 23)
/*
* This is a trigger for a performance test.
*/
#define ISP_FC_PERFTST (ISP_IOC | 44)
typedef struct {
uint32_t channel, target, lun, count;
int32_t ioszdir;
} isp_perftst_t;
/*
* vim:ts=4:sw=4:expandtab
*/

View File

@@ -1,4 +1,4 @@
/* $Id: isp_linux.c,v 1.230 2008/04/15 22:41:03 mjacob Exp $ */
/* $Id: isp_linux.c,v 1.234 2008/08/20 15:50:56 mjacob Exp $ */
/*
* Copyright (c) 1997-2008 by Matthew Jacob
* All rights reserved.
@@ -313,7 +313,7 @@ isplinux_runwaitq(ispsoftc_t *isp)
*/
if (IS_FC(isp)) {
if (result == CMD_RQLATER && ISP_DATA(isp, XS_CHANNEL(f))->deadloop == 0) {
isp_thread_event(isp, ISP_THREAD_FC_RESCAN, FCPARAM(isp, chan), 0, __FUNCTION__, __LINE__);
isp_thread_event(isp, ISP_THREAD_FC_RESCAN, FCPARAM(isp, chan), 0, __func__, __LINE__);
}
}
@@ -412,7 +412,6 @@ isplinux_queuecommand(Scsi_Cmnd *Cmnd, void (*donecmd)(Scsi_Cmnd *))
chan = XS_CHANNEL(Cmnd);
Cmnd->scsi_done = donecmd;
Cmnd->sense_buffer[0] = 0;
ISP_DRIVER_ENTRY_LOCK(isp);
ISP_LOCK_SOFTC(isp);
@@ -485,7 +484,7 @@ isplinux_queuecommand(Scsi_Cmnd *Cmnd, void (*donecmd)(Scsi_Cmnd *))
*/
isplinux_append_to_waitq(isp, Cmnd);
if (IS_FC(isp) && ISP_DATA(isp, XS_CHANNEL(Cmnd))->deadloop == 0) {
isp_thread_event(isp, ISP_THREAD_FC_RESCAN, FCPARAM(isp, XS_CHANNEL(Cmnd)), 0, __FUNCTION__, __LINE__);
isp_thread_event(isp, ISP_THREAD_FC_RESCAN, FCPARAM(isp, XS_CHANNEL(Cmnd)), 0, __func__, __LINE__);
}
result = 0;
} else if (result == CMD_COMPLETE) {
@@ -539,13 +538,19 @@ isplinux_scsi_probe_done(Scsi_Cmnd *Cmnd)
sdp = SDPARAM(isp, XS_CHANNEL(Cmnd));
if (Cmnd->cmnd[0] == 0x12 && host_byte(Cmnd->result) == DID_OK) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
if (Cmnd->use_sg == 0) {
iqd = (caddr_t) Cmnd->request_buffer;
} else {
struct scatterlist *sg;
sg = (struct scatterlist *) Cmnd->request_buffer;
struct scatterlist *sg = (struct scatterlist *) Cmnd->request_buffer;
iqd = page_address(sg_page(sg)) + sg->offset;
}
#else
{
struct scatterlist *sg = scsi_sglist(Cmnd);
iqd = page_address(sg_page(sg)) + sg->offset;
}
#endif
sdp->isp_devparam[XS_TGT(Cmnd)].goal_flags &= ~(DPARM_TQING|DPARM_SYNC|DPARM_WIDE);
if (iqd[7] & 0x2) {
sdp->isp_devparam[XS_TGT(Cmnd)].goal_flags |= DPARM_TQING;
@@ -592,8 +597,7 @@ isp_done(Scsi_Cmnd *Cmnd)
}
}
Cmnd->resid = XS_RESID(Cmnd);
if (Cmnd->underflow > (Cmnd->request_bufflen - Cmnd->resid)) {
if (Cmnd->underflow > (XS_XFRLEN(Cmnd) - XS_GET_RESID(Cmnd))) {
XS_SETERR(Cmnd, DID_ERROR);
}
@@ -956,7 +960,7 @@ isp_tgt_tq(ispsoftc_t *isp)
while (tmd != NULL) {
tmd_cmd_t *next = tmd->cd_next;
tmd->cd_next = NULL;
isp_prt(isp, ISP_LOGTDEBUG2, "isp_tgt_tq[%llx] -> code 0x%x", tmd->cd_tagval, tmd->cd_action);
isp_prt(isp, ISP_LOGTDEBUG2, "isp_tgt_tq[%llx] -> code 0x%x", (ull) tmd->cd_tagval, tmd->cd_action);
ISP_PARENT_TARGET(tmd->cd_action, tmd);
tmd = next;
}
@@ -1022,11 +1026,11 @@ isp_add_wwn_entry(ispsoftc_t *isp, int chan, uint64_t ini, uint16_t nphdl, uint3
i = ISP_LOGTINFO;
}
if (lp->portid == s_id && VALID_INI(lp->port_wwn) && (lp->port_wwn == ini || ini == INI_NONE) && lp->handle == nphdl) {
isp_prt(isp, i, "%s: Chan %d IID 0x%016llx N-Port Handle 0x%02x Port ID 0x%06x reentered", __FUNCTION__, chan,
(unsigned long long) lp->port_wwn, lp->handle, lp->portid);
isp_prt(isp, i, "%s: Chan %d IID 0x%016llx N-Port Handle 0x%02x Port ID 0x%06x reentered", __func__, chan,
(ull) lp->port_wwn, lp->handle, lp->portid);
} else {
isp_prt(isp, i, "%s: Chan %d IID 0x%016llx N-Port Handle 0x%02x Port ID 0x%06x overwrites IID 0x%016llx N-Port Handle 0x%02x Port Id 0x%06x",
__FUNCTION__, chan, (unsigned long long) ini, nphdl, s_id, (unsigned long long) lp->port_wwn, lp->handle, lp->portid);
__func__, chan, (ull) ini, nphdl, s_id, (ull) lp->port_wwn, lp->handle, lp->portid);
}
lp->portid = s_id;
if (VALID_INI(ini)) {
@@ -1048,7 +1052,7 @@ isp_add_wwn_entry(ispsoftc_t *isp, int chan, uint64_t ini, uint16_t nphdl, uint3
}
if (i < 0) {
isp_prt(isp, ISP_LOGWARN, "%s: Chan %d IID 0x%016llx N-Port Handle 0x%02x Port ID 0x%06x- no room in port database",
__FUNCTION__, chan, ini, nphdl, s_id);
__func__, chan, (ull) ini, nphdl, s_id);
return;
}
lp = &fcp->portdb[i];
@@ -1058,7 +1062,7 @@ isp_add_wwn_entry(ispsoftc_t *isp, int chan, uint64_t ini, uint16_t nphdl, uint3
lp->portid = s_id;
lp->port_wwn = ini;
isp_prt(isp, ISP_LOGTINFO, "%s: Chan %d IID 0x%016llx N-Port Handle 0x%02x Port ID 0x%06x added",
__FUNCTION__, chan, (unsigned long long) ini, nphdl, s_id);
__func__, chan, (ull) ini, nphdl, s_id);
}
static void
@@ -1075,7 +1079,7 @@ isp_del_wwn_entry(ispsoftc_t *isp, int chan, uint64_t ini, uint16_t nphdl, uint3
}
if (ini == INI_ANY && nphdl == NIL_HANDLE && s_id == PORT_ANY) {
isp_prt(isp, ISP_LOGTINFO, "%s: Chan %d IID 0x%016llx N-Port Handle 0x%x Port ID 0x%06x cleared due to wildcard call",
__FUNCTION__, chan, (unsigned long long) lp->port_wwn, lp->handle, lp->portid);
__func__, chan, (ull) lp->port_wwn, lp->handle, lp->portid);
MEMZERO(&fcp->portdb[i], sizeof (fcportdb_t));
continue;
}
@@ -1088,10 +1092,10 @@ isp_del_wwn_entry(ispsoftc_t *isp, int chan, uint64_t ini, uint16_t nphdl, uint3
}
if (i == MAX_FC_TARG) {
isp_prt(isp, ISP_LOGTINFO, "%s: Chan %d IID 0x%016llx N-Port Handle 0x%x Port ID 0x%06x cannot be found to be cleared",
__FUNCTION__, chan, (unsigned long long) lp->port_wwn, nphdl, lp->portid);
__func__, chan, (ull) lp->port_wwn, nphdl, lp->portid);
} else {
isp_prt(isp, ISP_LOGTINFO, "%s: Chan %d IID 0x%016llx N-Port Handle 0x%x Port ID 0x%06x cleared",
__FUNCTION__, chan, (unsigned long long) lp->port_wwn, nphdl, lp->portid);
__func__, chan, (ull) lp->port_wwn, nphdl, lp->portid);
MEMZERO(&fcp->portdb[i], sizeof (fcportdb_t));
}
}
@@ -1159,7 +1163,7 @@ isp_tgt_dump_pdb(ispsoftc_t *isp, int chan)
if (lp->target_mode == 0) {
continue;
}
isp_prt(isp, ISP_LOGTINFO, "PDB[%d]: Chan %d 0x%016llx Port-ID 0x%06x N-Port Handle 0x%04x", i, chan, (unsigned long long) lp->port_wwn, lp->portid, lp->handle);
isp_prt(isp, ISP_LOGTINFO, "PDB[%d]: Chan %d 0x%016llx Port-ID 0x%06x N-Port Handle 0x%04x", i, chan, (ull) lp->port_wwn, lp->portid, lp->handle);
}
}
@@ -1177,7 +1181,7 @@ isp_taction(qact_e action, void *arg)
hp = (hba_register_t *) arg;
isp = hp->r_identity;
if (isp == NULL) {
printk(KERN_ERR "null isp @ %s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__);
printk(KERN_ERR "null isp @ %s:%s:%d\n", __FILE__, __func__, __LINE__);
break;
}
isp_prt(isp, ISP_LOGINFO, "completed target registration");
@@ -1257,7 +1261,7 @@ isp_taction(qact_e action, void *arg)
ep = arg;
isp = ep->en_hba;
if (isp == NULL) {
printk(KERN_ERR "null isp @ %s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__);
printk(KERN_ERR "null isp @ %s:%s:%d\n", __FILE__, __func__, __LINE__);
break;
}
ep->en_error = isp_enable_lun(isp, ep->en_chan, ep->en_lun);
@@ -1268,7 +1272,7 @@ isp_taction(qact_e action, void *arg)
ep = arg;
isp = ep->en_hba;
if (isp == NULL) {
printk(KERN_ERR "null isp @ %s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__);
printk(KERN_ERR "null isp @ %s:%s:%d\n", __FILE__, __func__, __LINE__);
break;
}
ep->en_error = isp_disable_lun(isp, ep->en_chan, ep->en_lun);
@@ -1292,21 +1296,21 @@ isp_taction(qact_e action, void *arg)
tmd = (tmd_cmd_t *) arg;
isp = tmd->cd_hba;
if (isp == NULL) {
printk(KERN_ERR "null isp @ %s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__);
printk(KERN_ERR "null isp @ %s:%s:%d\n", __FILE__, __func__, __LINE__);
break;
}
ISP_LOCK_SOFTC(isp);
isp_prt(isp, ISP_LOGTDEBUG1, "freeing tmd %p [%llx]", tmd, tmd->cd_tagval);
isp_prt(isp, ISP_LOGTDEBUG1, "freeing tmd %p [%llx]", tmd, (ull) tmd->cd_tagval);
if (tmd->cd_lflags & CDFL_RESRC_FILL) {
if (isp_target_putback_atio(isp, tmd)) {
isp_thread_event(isp, ISP_THREAD_FC_PUTBACK, tmd, 0, __FUNCTION__, __LINE__);
isp_thread_event(isp, ISP_THREAD_FC_PUTBACK, tmd, 0, __func__, __LINE__);
ISP_UNLK_SOFTC(isp);
break;
}
}
if (tmd->cd_lflags & CDFL_NEED_CLNUP) {
tmd->cd_lflags &= ~CDFL_NEED_CLNUP;
isp_prt(isp, ISP_LOGTINFO, "Terminating [%llx] on FIN", (unsigned long long) tmd->cd_tagval);
isp_prt(isp, ISP_LOGTINFO, "Terminating [%llx] on FIN", (ull) tmd->cd_tagval);
(void) isp_terminate_cmd(isp, tmd);
}
tmd->cd_next = NULL;
@@ -1316,7 +1320,7 @@ isp_taction(qact_e action, void *arg)
isp->isp_osinfo.tfreelist = tmd;
}
isp->isp_osinfo.bfreelist = tmd; /* remember to move the list tail pointer */
isp_prt(isp, ISP_LOGTDEBUG1, "DONE freeing tmd %p [%llx]", tmd, tmd->cd_tagval);
isp_prt(isp, ISP_LOGTDEBUG1, "DONE freeing tmd %p [%llx]", tmd, (ull) tmd->cd_tagval);
ISP_UNLK_SOFTC(isp);
break;
@@ -1326,7 +1330,7 @@ isp_taction(qact_e action, void *arg)
isp = ins->notify.nt_hba;
if (isp == NULL) {
printk(KERN_ERR "null isp @ %s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__);
printk(KERN_ERR "null isp @ %s:%s:%d\n", __FILE__, __func__, __LINE__);
break;
}
ISP_LOCK_SOFTC(isp);
@@ -1339,7 +1343,7 @@ isp_taction(qact_e action, void *arg)
default:
if (isp->isp_state != ISP_RUNSTATE) {
isp_prt(isp, ISP_LOGINFO, "[%llx] Notify Code 0x%x (qevalid=%d) acked- h/w not ready (dropping)",
ins->notify.nt_tagval, ins->notify.nt_ncode, ins->qevalid);
(ull) ins->notify.nt_tagval, ins->notify.nt_ncode, ins->qevalid);
} else if (IS_24XX(isp) && ins->qevalid && ((isphdr_t *)ins->qentry)->rqs_entry_type == RQSTYPE_ATIO) {
ct7_entry_t local, *cto = &local;
at7_entry_t *aep = (at7_entry_t *)ins->qentry;
@@ -1381,7 +1385,7 @@ isp_taction(qact_e action, void *arg)
rsp->abts_rsp_payload.ba_acc.high_seq_cnt = 0xffff;
isp_notify_ack(isp, ins->qentry);
} else if (ins->notify.nt_need_ack) {
isp_prt(isp, ISP_LOGINFO, "[%llx] Notify Code 0x%x (qevalid=%d) being acked", ins->notify.nt_tagval, ins->notify.nt_ncode, ins->qevalid);
isp_prt(isp, ISP_LOGINFO, "[%llx] Notify Code 0x%x (qevalid=%d) being acked", (ull) ins->notify.nt_tagval, ins->notify.nt_ncode, ins->qevalid);
if (ins->qevalid) {
isp_notify_ack(isp, ins->qentry);
} else {
@@ -1399,7 +1403,7 @@ isp_taction(qact_e action, void *arg)
hp = (hba_register_t *) arg;
isp = hp->r_identity;
if (isp == NULL) {
printk(KERN_ERR "null isp @ %s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__);
printk(KERN_ERR "null isp @ %s:%s:%d\n", __FILE__, __func__, __LINE__);
break;
}
isp_prt(isp, ISP_LOGINFO, "completed target unregistration");
@@ -1499,7 +1503,7 @@ isp_target_start_ctio(ispsoftc_t *isp, tmd_xact_t *xact)
* Check for commands that are already dead
*/
if (tmd->cd_lflags & CDFL_ABORTED) {
isp_prt(isp, ISP_LOGINFO, "[%llx] already ABORTED- not sending a CTIO", tmd->cd_tagval);
isp_prt(isp, ISP_LOGINFO, "[%llx] already ABORTED- not sending a CTIO", (ull) tmd->cd_tagval);
xact->td_error = -ENXIO;
goto out;
}
@@ -1532,7 +1536,7 @@ isp_target_start_ctio(ispsoftc_t *isp, tmd_xact_t *xact)
}
if ((xact->td_hflags & TDFH_STSVALID) && tmd->cd_scsi_status == SCSI_CHECK && (xact->td_hflags & TDFH_SNSVALID) && tmd->cd_sense[0] == 0) {
isp_prt(isp, ISP_LOGWARN, "[%llx] cdb0 0x%02x CHECK CONDITION but bogus sense 0x%x/0x%x/0x%x", tmd->cd_tagval, tmd->cd_cdb[0], tmd->cd_sense[0], tmd->cd_sense[12], tmd->cd_sense[13]);
isp_prt(isp, ISP_LOGWARN, "[%llx] cdb0 0x%02x CHECK CONDITION but bogus sense 0x%x/0x%x/0x%x", (ull) tmd->cd_tagval, tmd->cd_cdb[0], tmd->cd_sense[0], tmd->cd_sense[12], tmd->cd_sense[13]);
}
MEMZERO(local, QENTRY_LEN);
@@ -1617,7 +1621,7 @@ isp_target_start_ctio(ispsoftc_t *isp, tmd_xact_t *xact)
cto->ct_scsi_status |= (FCP_RESID_UNDERFLOW << 8);
}
}
isp_prt(isp, ISP_LOGTDEBUG0, "CTIO7[%llx] scsi sts %x flags %x resid %d offset %u", tmd->cd_tagval, tmd->cd_scsi_status, cto->ct_flags, resid, xact->td_offset);
isp_prt(isp, ISP_LOGTDEBUG0, "CTIO7[%llx] scsi sts %x flags %x resid %d offset %u", (ull) tmd->cd_tagval, tmd->cd_scsi_status, cto->ct_flags, resid, xact->td_offset);
} else if (IS_FC(isp)) {
ct2_entry_t *cto = (ct2_entry_t *) local;
uint16_t *ssptr = NULL;
@@ -1685,7 +1689,7 @@ isp_target_start_ctio(ispsoftc_t *isp, tmd_xact_t *xact)
if (cto->ct_flags & CT2_SENDSTATUS) {
cto->ct_flags |= CT2_CCINCR;
}
isp_prt(isp, ISP_LOGTDEBUG0, "CTIO2[%llx] scsi sts %x flags %x resid %d", tmd->cd_tagval, tmd->cd_scsi_status, cto->ct_flags, resid);
isp_prt(isp, ISP_LOGTDEBUG0, "CTIO2[%llx] scsi sts %x flags %x resid %d", (ull) tmd->cd_tagval, tmd->cd_scsi_status, cto->ct_flags, resid);
} else {
ct_entry_t *cto = (ct_entry_t *) local;
@@ -1726,11 +1730,11 @@ isp_target_start_ctio(ispsoftc_t *isp, tmd_xact_t *xact)
if (cto->ct_flags & CT_SENDSTATUS) {
cto->ct_flags |= CT_CCINCR;
}
isp_prt(isp, ISP_LOGTDEBUG0, "CTIO[%llx] scsi sts %x resid %d cd_lflags %x", tmd->cd_tagval, tmd->cd_scsi_status, resid, xact->td_hflags);
isp_prt(isp, ISP_LOGTDEBUG0, "CTIO[%llx] scsi sts %x resid %d cd_lflags %x", (ull) tmd->cd_tagval, tmd->cd_scsi_status, resid, xact->td_hflags);
}
if (isp_getrqentry(isp, &nxti, &optr, &qe)) {
isp_prt(isp, ISP_LOGWARN, "%s: request queue overflow", __FUNCTION__);
isp_prt(isp, ISP_LOGWARN, "%s: request queue overflow", __func__);
xact->td_error = -ENOMEM;
ISP_UNLK_SOFTC(isp);
goto out;
@@ -1935,7 +1939,7 @@ isp_handle_platform_atio(ispsoftc_t *isp, at_entry_t *aep)
isp_endcmd(isp, aep, SCSI_BUSY, 0);
if (jiffies - isp->isp_osinfo.out_of_tmds > 30 * HZ) {
isp_prt(isp, ISP_LOGERR, "out of TMDs too long: disabling port");
isp_thread_event(isp, ISP_THREAD_REINIT, NULL, 0, __FUNCTION__, __LINE__);
isp_thread_event(isp, ISP_THREAD_REINIT, NULL, 0, __func__, __LINE__);
}
return;
}
@@ -1966,7 +1970,7 @@ isp_handle_platform_atio(ispsoftc_t *isp, at_entry_t *aep)
AT_MAKE_TAGID(tmd->cd_tagval, tmd->cd_channel, isp->isp_unit, aep);
tmd->cd_tagtype = aep->at_tag_type;
tmd->cd_hba = isp;
isp_prt(isp, ISP_LOGTDEBUG0, "ATIO[%llx] CDB=0x%x bus %d iid%d->lun%d ttype 0x%x %s", tmd->cd_tagval, aep->at_cdb[0] & 0xff,
isp_prt(isp, ISP_LOGTDEBUG0, "ATIO[%llx] CDB=0x%x bus %d iid%d->lun%d ttype 0x%x %s", (ull) tmd->cd_tagval, aep->at_cdb[0] & 0xff,
GET_BUS_VAL(aep->at_iid), GET_IID_VAL(aep->at_iid), aep->at_lun, aep->at_tag_type,
(aep->at_flags & AT_NODISC)? "nondisc" : "disconnecting");
if (isp->isp_osinfo.hcb == 0) {
@@ -2026,7 +2030,7 @@ isp_handle_platform_atio2(ispsoftc_t *isp, at2_entry_t *aep)
isp_endcmd(isp, aep, SCSI_BUSY, 0);
if (jiffies - isp->isp_osinfo.out_of_tmds > 30 * HZ) {
isp_prt(isp, ISP_LOGERR, "out of TMDs too long: disabling port");
isp_thread_event(isp, ISP_THREAD_REINIT, NULL, 0, __FUNCTION__, __LINE__);
isp_thread_event(isp, ISP_THREAD_REINIT, NULL, 0, __func__, __LINE__);
}
return;
}
@@ -2107,7 +2111,7 @@ isp_handle_platform_atio2(ispsoftc_t *isp, at2_entry_t *aep)
sstr = "BIDIR";
break;
}
isp_prt(isp, ISP_LOGALL, "ATIO2[%llx] CDB=0x%x 0x%016llx for lun %d tcode 0x%x dlen %d %s", tmd->cd_tagval,
isp_prt(isp, ISP_LOGALL, "ATIO2[%llx] CDB=0x%x 0x%016llx for lun %d tcode 0x%x dlen %d %s", (ull) tmd->cd_tagval,
aep->at_cdb[0] & 0xff, tmd->cd_iid, lun, aep->at_taskcodes, aep->at_datalen, sstr);
}
@@ -2121,7 +2125,7 @@ isp_handle_platform_atio2(ispsoftc_t *isp, at2_entry_t *aep)
} else {
tmd->cd_portid = PORT_NONE;
isp_add_wwn_entry(isp, 0, tmd->cd_iid, tmd->cd_nphdl, PORT_NONE);
(void) isp_thread_event(isp, ISP_THREAD_FINDPORTID, tmd, 0, __FUNCTION__, __LINE__);
(void) isp_thread_event(isp, ISP_THREAD_FINDPORTID, tmd, 0, __func__, __LINE__);
}
}
}
@@ -2175,7 +2179,7 @@ isp_handle_platform_atio7(ispsoftc_t *isp, at7_entry_t *aep)
* It's Hackaroni time...
*/
if ((tmd = isp->isp_osinfo.tfreelist) == NULL || ++aep->at_count == 250) {
isp_prt(isp, ISP_LOGWARN, "%s: [RX_ID 0x%x] D_ID %x not found on any channel- dropping", __FUNCTION__, aep->at_rxid, did);
isp_prt(isp, ISP_LOGWARN, "%s: [RX_ID 0x%x] D_ID %x not found on any channel- dropping", __func__, aep->at_rxid, did);
return;
}
if ((isp->isp_osinfo.tfreelist = tmd->cd_next) == NULL) {
@@ -2189,7 +2193,7 @@ isp_handle_platform_atio7(ispsoftc_t *isp, at7_entry_t *aep)
tmd->cd_lastoff = 1;
return;
}
isp_prt(isp, ISP_LOGTDEBUG0, "%s: [RX_ID 0x%x] D_ID 0x%06x found on Chan %d for S_ID 0x%06x", __FUNCTION__, aep->at_rxid, did, chan, sid);
isp_prt(isp, ISP_LOGTDEBUG0, "%s: [RX_ID 0x%x] D_ID 0x%06x found on Chan %d for S_ID 0x%06x", __func__, aep->at_rxid, did, chan, sid);
if (isp_find_pdb_by_sid(isp, chan, sid, &lp)) {
nphdl = lp->handle;
@@ -2198,7 +2202,7 @@ isp_handle_platform_atio7(ispsoftc_t *isp, at7_entry_t *aep)
/*
* If we're not in the port database, do a tentative entry.
*/
isp_prt(isp, ISP_LOGTINFO, "%s: [RX_ID 0x%x] D_ID 0x%06x found on Chan %d for S_ID 0x%06x wasn't in PDB already", __FUNCTION__, aep->at_rxid, did, chan, sid);
isp_prt(isp, ISP_LOGTINFO, "%s: [RX_ID 0x%x] D_ID 0x%06x found on Chan %d for S_ID 0x%06x wasn't in PDB already", __func__, aep->at_rxid, did, chan, sid);
isp_add_wwn_entry(isp, chan, INI_NONE, NIL_HANDLE, sid);
}
@@ -2221,7 +2225,7 @@ isp_handle_platform_atio7(ispsoftc_t *isp, at7_entry_t *aep)
isp_endcmd(isp, aep, chan, SCSI_BUSY, 0);
if (jiffies - isp->isp_osinfo.out_of_tmds > 30 * HZ) {
isp_prt(isp, ISP_LOGERR, "out of TMDs too long: disabling port");
isp_thread_event(isp, ISP_THREAD_REINIT, NULL, 0, __FUNCTION__, __LINE__);
isp_thread_event(isp, ISP_THREAD_REINIT, NULL, 0, __func__, __LINE__);
}
return;
}
@@ -2306,8 +2310,8 @@ isp_handle_platform_atio7(ispsoftc_t *isp, at7_entry_t *aep)
sstr = "BIDIR";
break;
}
isp_prt(isp, ISP_LOGALL, "ATIO7[%llx] cdb0=0x%x from 0x%016llx/0x%06x ox_id 0x%x N-Port Handle 0x%02x for lun %u dlen %d %s", tmd->cd_tagval,
tmd->cd_cdb[0] & 0xff, (unsigned long long) tmd->cd_iid, tmd->cd_portid, tmd->cd_oxid, tmd->cd_nphdl, lun, tmd->cd_totlen, sstr);
isp_prt(isp, ISP_LOGALL, "ATIO7[%llx] cdb0=0x%x from 0x%016llx/0x%06x ox_id 0x%x N-Port Handle 0x%02x for lun %u dlen %d %s", (ull) tmd->cd_tagval,
tmd->cd_cdb[0] & 0xff, (ull) tmd->cd_iid, tmd->cd_portid, tmd->cd_oxid, tmd->cd_nphdl, lun, tmd->cd_totlen, sstr);
}
if (isp->isp_osinfo.hcb == 0) {
@@ -2317,8 +2321,8 @@ isp_handle_platform_atio7(ispsoftc_t *isp, at7_entry_t *aep)
if (VALID_INI(tmd->cd_iid)) {
CALL_PARENT_TMD(isp, tmd, QOUT_TMD_START);
} else {
isp_prt(isp, ISP_LOGTDEBUG0, "[0x%llx] asking taskthread to find iid of initiator", (unsigned long long) tmd->cd_tagval);
if (isp_thread_event(isp, ISP_THREAD_FINDIID, tmd, 0, __FUNCTION__, __LINE__)) {
isp_prt(isp, ISP_LOGTDEBUG0, "[0x%llx] asking taskthread to find iid of initiator", (ull) tmd->cd_tagval);
if (isp_thread_event(isp, ISP_THREAD_FINDIID, tmd, 0, __func__, __LINE__)) {
isp_endcmd(isp, aep, nphdl, chan, SCSI_BUSY, 0);
MEMZERO(tmd, TMD_SIZE);
if (isp->isp_osinfo.tfreelist) {
@@ -2340,7 +2344,7 @@ isp_terminate_cmd(ispsoftc_t *isp, tmd_cmd_t *tmd)
ct7_entry_t local, *cto = &local;
if (IS_24XX(isp)) {
isp_prt(isp, ISP_LOGTINFO, "isp_terminate_cmd: [%llx] is being terminated", (unsigned long long) tmd->cd_tagval);
isp_prt(isp, ISP_LOGTINFO, "isp_terminate_cmd: [%llx] is being terminated", (ull) tmd->cd_tagval);
MEMZERO(&local, sizeof (local));
cto->ct_header.rqs_entry_type = RQSTYPE_CTIO7;
cto->ct_header.rqs_entry_count = 1;
@@ -2440,7 +2444,7 @@ isp_handle_platform_ctio(ispsoftc_t *isp, void *arg)
tmd->cd_moved -= resid;
isp_prt(isp, ISP_LOGTDEBUG0, "%s[%llx] status 0x%x flg 0x%x %s", ctstr, tmd->cd_tagval, status, flags, sentstatus? "FIN" : "MID");
isp_prt(isp, ISP_LOGTDEBUG0, "%s[%llx] status 0x%x flg 0x%x %s", ctstr, (ull) tmd->cd_tagval, status, flags, sentstatus? "FIN" : "MID");
/*
* We're here either because intermediate data transfers are done
@@ -2463,14 +2467,15 @@ isp_handle_platform_ctio(ispsoftc_t *isp, void *arg)
cx = "O";
}
if ((status & ~QLTM_SVALID) == CT_ABORTED) {
isp_prt(isp, ISP_LOGINFO, "[%llx] CTI%s aborted", tmd->cd_tagval, cx);
isp_prt(isp, ISP_LOGINFO, "[%llx] CTI%s aborted", (ull) tmd->cd_tagval, cx);
tmd->cd_lflags |= CDFL_ABORTED;
} else if ((status & QLTM_SVALID) == CT_LOGOUT) {
isp_prt(isp, ISP_LOGINFO, "[%llx] CTI%s killed by Port Logout", tmd->cd_tagval, cx);
isp_prt(isp, ISP_LOGINFO, "[%llx] CTI%s killed by Port Logout", (ull) tmd->cd_tagval, cx);
} else {
isp_prt(isp, ISP_LOGINFO, "[%llx] CTI%s ended with badstate (0x%x)", tmd->cd_tagval, cx, status);
isp_prt(isp, ISP_LOGINFO, "[%llx] CTI%s ended with badstate (0x%x)", (ull) tmd->cd_tagval, cx, status);
}
xact->td_error = -EIO;
xact->td_lflags |= TDFL_ERROR;
if (isp_target_putback_atio(isp, tmd)) {
tmd->cd_lflags |= CDFL_RESRC_FILL;
}
@@ -2489,7 +2494,7 @@ isp_handle_platform_ctio(ispsoftc_t *isp, void *arg)
continue;
}
}
isp_thread_event(isp, ISP_THREAD_LOGOUT, &FCPARAM(isp, tmd->cd_channel)->portdb[i], 0, __FUNCTION__, __LINE__);
isp_thread_event(isp, ISP_THREAD_LOGOUT, &FCPARAM(isp, tmd->cd_channel)->portdb[i], 0, __func__, __LINE__);
break;
}
}
@@ -2509,10 +2514,10 @@ isp_target_putback_atio(ispsoftc_t *isp, tmd_cmd_t *tmd)
return (0);
}
if (isp_getrqentry(isp, &nxti, NULL, &qe)) {
isp_prt(isp, ISP_LOGWARN, "%s: Request Queue Overflow", __FUNCTION__);
isp_prt(isp, ISP_LOGWARN, "%s: Request Queue Overflow", __func__);
return (-ENOMEM);
}
isp_prt(isp, ISP_LOGTDEBUG0, "[%llx] resource putback being sent", tmd->cd_tagval);
isp_prt(isp, ISP_LOGTDEBUG0, "[%llx] resource putback being sent", (ull) tmd->cd_tagval);
MEMZERO(local, sizeof (local));
if (IS_FC(isp)) {
at2_entry_t *at = (at2_entry_t *) local;
@@ -2579,7 +2584,7 @@ isp_fc_change_role(ispsoftc_t *isp, int chan, int new_role)
return (0);
}
if (chan >= isp->isp_nchan) {
isp_prt(isp, ISP_LOGWARN, "%s: bad channel %d", __FUNCTION__, chan);
isp_prt(isp, ISP_LOGWARN, "%s: bad channel %d", __func__, chan);
return (-ENXIO);
}
fcp = FCPARAM(isp, chan);
@@ -2648,7 +2653,7 @@ isp_fc_change_role(ispsoftc_t *isp, int chan, int new_role)
FC_SCRATCH_RELEASE(isp, chan);
if (vp->vp_mod_status != VP_STS_OK) {
isp_prt(isp, ISP_LOGERR, "%s: VP_MODIFY of Chan %d failed with status %d", __FUNCTION__, chan, vp->vp_mod_status);
isp_prt(isp, ISP_LOGERR, "%s: VP_MODIFY of Chan %d failed with status %d", __func__, chan, vp->vp_mod_status);
ISP_DATA(isp, chan)->blocked = 0;
return (-EIO);
}
@@ -2707,7 +2712,7 @@ isp_enable_lun(ispsoftc_t *isp, uint16_t bus, uint16_t lun)
* first in some kind of role.
*/
if (IS_FC(isp) && bus != 0 && (((FCPARAM(isp, 0)->role & ISP_ROLE_TARGET) && nolunsenabled(isp, 0)) || (FCPARAM(isp, 0)->role == ISP_ROLE_NONE))) {
isp_prt(isp, ISP_LOGWARN, "%s: must enable Chan 0 before Chan %u", __FUNCTION__, bus);
isp_prt(isp, ISP_LOGWARN, "%s: must enable Chan 0 before Chan %u", __func__, bus);
up(&isp->isp_osinfo.tgt_inisem);
isp_kfree(axl, sizeof (tgt_enalun_t));
return (-EINVAL);
@@ -2871,7 +2876,7 @@ isp_disable_lun(ispsoftc_t *isp, uint16_t bus, uint16_t lun)
}
}
if (rstat > 0) {
isp_prt(isp, ISP_LOGERR, "%s: must disable Chan %u before Chan 0\n", __FUNCTION__, rstat);
isp_prt(isp, ISP_LOGERR, "%s: must disable Chan %u before Chan 0\n", __func__, rstat);
ISP_UNLK_SOFTC(isp);
up(&isp->isp_osinfo.tgt_inisem);
return (-EINVAL);
@@ -2941,7 +2946,7 @@ out:
if (axl) {
isp_kfree(axl, sizeof (tgt_enalun_t));
} else {
isp_prt(isp, ISP_LOGWARN, "%s: Chan %d lun %u unable to find axl to delete", __FUNCTION__, bus, lun);
isp_prt(isp, ISP_LOGWARN, "%s: Chan %d lun %u unable to find axl to delete", __func__, bus, lun);
}
if (rstat != LUN_OK) {
isp_prt(isp, ISP_LOGERR, "lun %u disable failed", lun);
@@ -3119,11 +3124,11 @@ isp_async(ispsoftc_t *isp, ispasync_t cmd, ...)
if (lp->ini_map_idx) {
unsigned long arg;
tgt = lp->ini_map_idx - 1;
isp_prt(isp, ISP_LOGCONFIG, prom2, bus, lp->portid, lp->handle, isp_class3_roles[lp->roles], "arrived at", tgt, lp->node_wwn, lp->port_wwn);
isp_prt(isp, ISP_LOGCONFIG, prom2, bus, lp->portid, lp->handle, isp_class3_roles[lp->roles], "arrived at", tgt, (ull) lp->node_wwn, (ull) lp->port_wwn);
arg = tgt | (bus << 16);
isp_thread_event(isp, ISP_THREAD_SCSI_SCAN, (void *)arg, 0, __FUNCTION__, __LINE__);
isp_thread_event(isp, ISP_THREAD_SCSI_SCAN, (void *)arg, 0, __func__, __LINE__);
} else {
isp_prt(isp, ISP_LOGCONFIG, prom0, bus, lp->portid, lp->handle, isp_class3_roles[lp->roles], "arrived", lp->node_wwn, lp->port_wwn);
isp_prt(isp, ISP_LOGCONFIG, prom0, bus, lp->portid, lp->handle, isp_class3_roles[lp->roles], "arrived", (ull) lp->node_wwn, (ull) lp->port_wwn);
}
break;
case ISPASYNC_DEV_CHANGED:
@@ -3138,9 +3143,9 @@ isp_async(ispsoftc_t *isp, ispasync_t cmd, ...)
int t = lp->ini_map_idx - 1;
fcp->isp_ini_map[t] = (lp - fcp->portdb) + 1;
tgt = lp->ini_map_idx - 1;
isp_prt(isp, ISP_LOGCONFIG, prom2, bus, lp->portid, lp->handle, isp_class3_roles[lp->roles], "changed at", tgt, lp->node_wwn, lp->port_wwn);
isp_prt(isp, ISP_LOGCONFIG, prom2, bus, lp->portid, lp->handle, isp_class3_roles[lp->roles], "changed at", tgt, (ull) lp->node_wwn, (ull) lp->port_wwn);
} else {
isp_prt(isp, ISP_LOGCONFIG, prom0, bus, lp->portid, lp->handle, isp_class3_roles[lp->roles], "changed", lp->node_wwn, lp->port_wwn);
isp_prt(isp, ISP_LOGCONFIG, prom0, bus, lp->portid, lp->handle, isp_class3_roles[lp->roles], "changed", (ull) lp->node_wwn, (ull) lp->port_wwn);
}
break;
case ISPASYNC_DEV_STAYED:
@@ -3150,9 +3155,9 @@ isp_async(ispsoftc_t *isp, ispasync_t cmd, ...)
va_end(ap);
if (lp->ini_map_idx) {
tgt = lp->ini_map_idx - 1;
isp_prt(isp, ISP_LOGCONFIG, prom2, bus, lp->portid, lp->handle, isp_class3_roles[lp->roles], "stayed at", tgt, lp->node_wwn, lp->port_wwn);
isp_prt(isp, ISP_LOGCONFIG, prom2, bus, lp->portid, lp->handle, isp_class3_roles[lp->roles], "stayed at", tgt, (ull) lp->node_wwn, (ull) lp->port_wwn);
} else {
isp_prt(isp, ISP_LOGCONFIG, prom0, bus, lp->portid, lp->handle, isp_class3_roles[lp->roles], "stayed", lp->node_wwn, lp->port_wwn);
isp_prt(isp, ISP_LOGCONFIG, prom0, bus, lp->portid, lp->handle, isp_class3_roles[lp->roles], "stayed", (ull) lp->node_wwn, (ull) lp->port_wwn);
}
break;
case ISPASYNC_DEV_GONE:
@@ -3167,11 +3172,11 @@ isp_async(ispsoftc_t *isp, ispasync_t cmd, ...)
fcp->isp_ini_map[tgt] = 0;
lp->state = FC_PORTDB_STATE_NIL;
lp->ini_map_idx = 0;
isp_prt(isp, ISP_LOGCONFIG, prom2, bus, lp->portid, lp->handle, isp_class3_roles[lp->roles], "departed", tgt, lp->node_wwn, lp->port_wwn);
isp_prt(isp, ISP_LOGCONFIG, prom2, bus, lp->portid, lp->handle, isp_class3_roles[lp->roles], "departed", tgt, (ull) lp->node_wwn, (ull) lp->port_wwn);
arg = tgt | (bus << 16) | (1 << 31);
isp_thread_event(isp, ISP_THREAD_SCSI_SCAN, (void *)arg, 0, __FUNCTION__, __LINE__);
isp_thread_event(isp, ISP_THREAD_SCSI_SCAN, (void *)arg, 0, __func__, __LINE__);
} else if (lp->reserved == 0) {
isp_prt(isp, ISP_LOGCONFIG, prom0, bus, lp->portid, lp->handle, isp_class3_roles[lp->roles], "departed", lp->node_wwn, lp->port_wwn);
isp_prt(isp, ISP_LOGCONFIG, prom0, bus, lp->portid, lp->handle, isp_class3_roles[lp->roles], "departed", (ull) lp->node_wwn, (ull) lp->port_wwn);
}
break;
case ISPASYNC_CHANGE_NOTIFY:
@@ -3203,7 +3208,7 @@ isp_async(ispsoftc_t *isp, ispasync_t cmd, ...)
isp_prt(isp, ISP_LOGINFO, "Chan %d Other Change Notify occurred", bus);
}
if (isp->isp_state >= ISP_INITSTATE) {
isp_thread_event(isp, ISP_THREAD_FC_RESCAN, fcp, 0, __FUNCTION__, __LINE__);
isp_thread_event(isp, ISP_THREAD_FC_RESCAN, fcp, 0, __func__, __LINE__);
}
break;
}
@@ -3311,8 +3316,7 @@ isp_async(ispsoftc_t *isp, ispasync_t cmd, ...)
TAG_INSERT_INST(mp->nt_tagval, isp->isp_unit);
}
isp_prt(isp, ISP_LOGTINFO, "Notify Code 0x%x iid 0x%016llx tgt 0x%016llx lun %u tag %llx",
mp->nt_ncode, (unsigned long long) mp->nt_iid, (unsigned long long) mp->nt_tgt,
mp->nt_lun, mp->nt_tagval);
mp->nt_ncode, (ull) mp->nt_iid, (ull) mp->nt_tgt, mp->nt_lun, mp->nt_tagval);
CALL_PARENT_NOTIFY(isp, ins);
break;
}
@@ -3421,14 +3425,14 @@ isp_async(ispsoftc_t *isp, ispasync_t cmd, ...)
tmd_cmd_t *tmd = &isp->isp_osinfo.pool[i];
if (tmd->cd_lflags & CDFL_BUSY) {
if (ins->notify.nt_tagval == tmd->cd_tagval && ins->notify.nt_channel == tmd->cd_channel) {
isp_prt(isp, ISP_LOGTINFO, "[0x%llx] marked as aborted", (unsigned long long) tmd->cd_tagval);
isp_prt(isp, ISP_LOGTINFO, "[0x%llx] marked as aborted", (ull) tmd->cd_tagval);
tmd->cd_lflags |= CDFL_ABORTED|CDFL_NEED_CLNUP;
ins->notify.nt_tmd = tmd;
break;
}
}
}
isp_prt(isp, ISP_LOGTINFO, "ABTS [%llx] from 0x%016llx", ins->notify.nt_tagval, ins->notify.nt_iid);
isp_prt(isp, ISP_LOGTINFO, "ABTS [%llx] from 0x%016llx", (ull) ins->notify.nt_tagval, (ull) ins->notify.nt_iid);
CALL_PARENT_NOTIFY(isp, ins);
break;
}
@@ -3471,7 +3475,7 @@ isp_async(ispsoftc_t *isp, ispasync_t cmd, ...)
IN_MAKE_TAGID(ins->notify.nt_tagval, GET_BUS_VAL(inot->in_iid), isp->isp_unit, inot);
ins->notify.nt_ncode = NT_ABORT_TASK;
ins->notify.nt_need_ack = 1;
isp_prt(isp, ISP_LOGINFO, "ABORT TASK [%llx] from iid %u to lun %u", ins->notify.nt_tagval,
isp_prt(isp, ISP_LOGINFO, "ABORT TASK [%llx] from iid %u to lun %u", (ull) ins->notify.nt_tagval,
(uint32_t) ins->notify.nt_iid, inot->in_lun);
CALL_PARENT_NOTIFY(isp, ins);
break;
@@ -3543,7 +3547,7 @@ isp_async(ispsoftc_t *isp, ispasync_t cmd, ...)
break;
case PDISC:
isp_prt(isp, ISP_LOGTINFO, "%s: Chan %d IID N-Port Handle 0x%x Port ID 0x%06x PDISC",
__FUNCTION__, inot->in_vpindex, nphdl, portid);
__func__, inot->in_vpindex, nphdl, portid);
break;
default:
isp_prt(isp, ISP_LOGTINFO, "ELS CODE 0x%x Received from 0x%06x", inot->in_status_subcode, portid);
@@ -3581,11 +3585,11 @@ isp_async(ispsoftc_t *isp, ispasync_t cmd, ...)
ins->notify.nt_hba = isp;
ins->notify.nt_ncode = NT_LOGOUT;
isp_prt(isp, ISP_LOGTINFO, "%s: isp_del_wwn being called on Chan %d because of PC/PL(0x%x) for 0x%016llx loopid 0x%02x",
__FUNCTION__, inot->in_vpindex, status, (unsigned long long) ins->notify.nt_iid, nphdl);
__func__, inot->in_vpindex, status, (ull) ins->notify.nt_iid, nphdl);
isp_del_wwn_entry(isp, inot->in_vpindex, ins->notify.nt_iid, nphdl, portid);
ins->notify.nt_tagval = seqid;
isp_prt(isp, ISP_LOGINFO, "PORT %s [%llx] from 0x%016llx", status == IN24XX_PORT_CHANGED? "CHANGED" : "LOGOUT",
ins->notify.nt_tagval, ins->notify.nt_iid);
(ull) ins->notify.nt_tagval, (ull) ins->notify.nt_iid);
CALL_PARENT_NOTIFY(isp, ins);
break;
@@ -3647,8 +3651,8 @@ isp_async(ispsoftc_t *isp, ispasync_t cmd, ...)
ins->notify.nt_need_ack = 1;
IN_FC_MAKE_TAGID(ins->notify.nt_tagval, 0, isp->isp_unit, seqid);
ins->notify.nt_ncode = NT_ABORT_TASK;
isp_prt(isp, ISP_LOGINFO, "ABORT TASK [%llx] from 0x%016llx to lun %u", ins->notify.nt_tagval,
(unsigned long long) ins->notify.nt_iid, lun);
isp_prt(isp, ISP_LOGINFO, "ABORT TASK [%llx] from 0x%016llx to lun %u", (ull) ins->notify.nt_tagval,
(ull) ins->notify.nt_iid, lun);
CALL_PARENT_NOTIFY(isp, ins);
break;
} else if (status == IN_PORT_LOGOUT) {
@@ -3658,10 +3662,10 @@ isp_async(ispsoftc_t *isp, ispasync_t cmd, ...)
if (isp_find_pdb_by_loopid(isp, 0, nphdl, &lp)) {
ins->notify.nt_iid = lp->port_wwn;
ins->notify.nt_ncode = NT_LOGOUT;
isp_prt(isp, ISP_LOGTINFO, "%s: isp_del_wwn called for 0x%016llx due to PORT_LOGOUT", __FUNCTION__, (unsigned long long)ins->notify.nt_iid);
isp_prt(isp, ISP_LOGTINFO, "%s: isp_del_wwn called for 0x%016llx due to PORT_LOGOUT", __func__, (ull) ins->notify.nt_iid);
isp_del_wwn_entry(isp, 0, ins->notify.nt_iid, nphdl, PORT_ANY);
IN_FC_MAKE_TAGID(ins->notify.nt_tagval, 0, isp->isp_unit, seqid);
isp_prt(isp, ISP_LOGINFO, "PORT LOGOUT [%llx] from 0x%016llx", ins->notify.nt_tagval, (unsigned long long) ins->notify.nt_iid);
isp_prt(isp, ISP_LOGINFO, "PORT LOGOUT [%llx] from 0x%016llx", (ull) ins->notify.nt_tagval, (ull) ins->notify.nt_iid);
ins->notify.nt_need_ack = 1;
CALL_PARENT_NOTIFY(isp, ins);
break;
@@ -3688,14 +3692,14 @@ isp_async(ispsoftc_t *isp, ispasync_t cmd, ...)
/*
* Everyone Logged Out
*/
isp_prt(isp, ISP_LOGTINFO, "%s: isp_del_wwn called for everyone due to GLOBAL PORT_LOGOUT", __FUNCTION__);
isp_prt(isp, ISP_LOGTINFO, "%s: isp_del_wwn called for everyone due to GLOBAL PORT_LOGOUT", __func__);
isp_del_wwn_entry(isp, 0, INI_ANY, NIL_HANDLE, PORT_ANY);
ins->notify.nt_iid = INI_ANY;
ins->notify.nt_ncode = NT_LOGOUT;
ins->notify.nt_need_ack = 1;
CALL_PARENT_NOTIFY(isp, ins);
} else {
isp_prt(isp, ISP_LOGINFO, "%s: ACKing unknown status 0x%x", __FUNCTION__, status);
isp_prt(isp, ISP_LOGINFO, "%s: ACKing unknown status 0x%x", __func__, status);
isp_notify_ack(isp, qe);
}
}
@@ -3721,7 +3725,7 @@ isp_async(ispsoftc_t *isp, ispasync_t cmd, ...)
ISP_DATA(isp, mbox6)->blocked = 1;
ISP_RESET0(isp);
isp_shutdown(isp);
isp_thread_event(isp, ISP_THREAD_REINIT, NULL, 0, __FUNCTION__, __LINE__);
isp_thread_event(isp, ISP_THREAD_REINIT, NULL, 0, __func__, __LINE__);
break;
}
case ISPASYNC_FW_RESTARTED:
@@ -3729,7 +3733,7 @@ isp_async(ispsoftc_t *isp, ispasync_t cmd, ...)
if (IS_FC(isp)) {
int i;
for (i = 0; i < isp->isp_nchan; i++) {
isp_thread_event(isp, ISP_THREAD_FC_RESCAN, FCPARAM(isp, i), 0, __FUNCTION__, __LINE__);
isp_thread_event(isp, ISP_THREAD_FC_RESCAN, FCPARAM(isp, i), 0, __func__, __LINE__);
}
}
break;
@@ -3917,7 +3921,7 @@ isplinux_timer(unsigned long arg)
fcparam *fcp = FCPARAM(isp, i);
if (fcp->role != ISP_ROLE_NONE && ISP_DATA(isp, i)->fcrswdog && ISP_DATA(isp, i)->deadloop == 0) {
ISP_DATA(isp, i)->fcrswdog = 1;
isp_thread_event(isp, ISP_THREAD_FC_RESCAN, fcp, 0, __FUNCTION__, __LINE__);
isp_thread_event(isp, ISP_THREAD_FC_RESCAN, fcp, 0, __func__, __LINE__);
}
}
}
@@ -3935,9 +3939,9 @@ isplinux_timer(unsigned long arg)
isp->isp_osinfo.waiting_t = wt->cd_next;
wt->cd_next = NULL;
if (wt->cd_lastoff == 0) {
isp_thread_event(isp, ISP_THREAD_FINDIID, wt, 0, __FUNCTION__, __LINE__);
isp_thread_event(isp, ISP_THREAD_FINDIID, wt, 0, __func__, __LINE__);
} else {
isp_thread_event(isp, ISP_THREAD_RESTART_AT7, wt, 0, __FUNCTION__, __LINE__);
isp_thread_event(isp, ISP_THREAD_RESTART_AT7, wt, 0, __func__, __LINE__);
}
}
}
@@ -3973,7 +3977,7 @@ isplinux_mbtimer(unsigned long arg)
ISP_IUNLK_SOFTC(isp);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
#define PTARG , struct pt_regs *pt
#else
#define PTARG
@@ -4509,15 +4513,21 @@ isp_task_thread(void *arg)
break;
case ISP_THREAD_SCSI_SCAN:
{
/* this gets pegged in isplinux_queuecommand, even for async scanning */
#if 0
unsigned long arg = (unsigned long) tap->arg;
int tgt, chan, rescan;
tgt = arg & 0xffff;
chan = (arg >> 16) & 0xff;
rescan = (arg >> 31) & 1;
scsi_scan_target(&isp->isp_osinfo.host->shost_gendev, chan, tgt, SCAN_WILD_CARD, rescan);
#endif
if (rescan == 0) {
scsi_scan_target(&isp->isp_osinfo.host->shost_gendev, chan, tgt, 0, rescan);
} else {
struct scsi_device *sdev;
sdev = scsi_device_lookup(isp->isp_osinfo.host, 0, tgt, 0);
if (sdev) {
scsi_remove_device(sdev);
scsi_device_put(sdev);
}
}
break;
}
case ISP_THREAD_REINIT:
@@ -4593,7 +4603,7 @@ isp_task_thread(void *arg)
MEMZERO(&u, sizeof (u));
u.id = lp->handle;
isp_prt(isp, ISP_LOGTINFO, "Doing Port Logout repair for 0x%016llx@0x%x (loop id) %u",
lp->port_wwn, lp->portid, lp->handle);
(ull) lp->port_wwn, lp->portid, lp->handle);
MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_FABRIC_LOGOUT;
if (ISP_CAP_2KLOGIN(isp)) {
@@ -4639,8 +4649,8 @@ isp_task_thread(void *arg)
uint16_t nphdl = NIL_HANDLE;
if (tmd->cd_lflags & CDFL_ABORTED) {
isp_prt(isp, ISP_LOGTINFO, "[%llx] asking thread to terminate because it was marked aborted", (unsigned long long) tmd->cd_tagval);
isp_thread_event(isp, ISP_THREAD_TERMINATE, tmd, 0, __FUNCTION__, __LINE__);
isp_prt(isp, ISP_LOGTINFO, "[%llx] asking thread to terminate because it was marked aborted", (ull) tmd->cd_tagval);
isp_thread_event(isp, ISP_THREAD_TERMINATE, tmd, 0, __func__, __LINE__);
break;
}
ISP_LOCKU_SOFTC(isp);
@@ -4662,7 +4672,7 @@ isp_task_thread(void *arg)
if (isp_control(isp, ISPCTL_GET_PDB, tmd->cd_channel, nphdl, &pdb)) {
continue;
}
isp_prt(isp, ISP_LOGTINFO, "%s: nphdl 0x%04x has portid 0x%06x", __FUNCTION__, nphdl, pdb.portid);
isp_prt(isp, ISP_LOGTINFO, "%s: nphdl 0x%04x has portid 0x%06x", __func__, nphdl, pdb.portid);
if (pdb.portid == tmd->cd_portid) {
lp->handle = nphdl;
break;
@@ -4670,9 +4680,9 @@ isp_task_thread(void *arg)
}
if (nphdl == max) {
ISP_UNLKU_SOFTC(isp);
isp_prt(isp, ISP_LOGTINFO, "[0x%llx] asking thread to terminate cmd [0x%02x] because because we can't find the N-Port handle", tmd->cd_tagval, tmd->cd_cdb[0] & 0xff);
isp_prt(isp, ISP_LOGTINFO, "[0x%llx] asking thread to terminate cmd [0x%02x] because because we can't find the N-Port handle", (ull) tmd->cd_tagval, tmd->cd_cdb[0] & 0xff);
isp_tgt_dump_pdb(isp, tmd->cd_channel);
isp_thread_event(isp, ISP_THREAD_TERMINATE, tmd, 0, __FUNCTION__, __LINE__);
isp_thread_event(isp, ISP_THREAD_TERMINATE, tmd, 0, __func__, __LINE__);
break;
}
}
@@ -4680,7 +4690,7 @@ isp_task_thread(void *arg)
nphdl = lp->handle;
iid = lp->port_wwn;
} else {
isp_prt(isp, ISP_LOGALL, "%s: Chan %d [0x%llx] failed to get name for handle 0x%02x for portid 0x%06x", __FUNCTION__, tmd->cd_channel, tmd->cd_tagval, lp->handle, tmd->cd_portid);
isp_prt(isp, ISP_LOGALL, "%s: Chan %d [0x%llx] failed to get name for handle 0x%02x for portid 0x%06x", __func__, tmd->cd_channel, (ull) tmd->cd_tagval, lp->handle, tmd->cd_portid);
}
} else {
nphdl = lp->handle;
@@ -4692,13 +4702,13 @@ isp_task_thread(void *arg)
* has cleared it out. The command is probably already dead due to initiator port logout.
*/
ISP_UNLKU_SOFTC(isp);
isp_prt(isp, ISP_LOGTINFO, "[0x%llx] asking thread to terminate cmd [0x%02x] because PortID 0x%06x no longer in port database", tmd->cd_tagval, tmd->cd_cdb[0] & 0xff, tmd->cd_portid);
isp_prt(isp, ISP_LOGTINFO, "[0x%llx] asking thread to terminate cmd [0x%02x] because PortID 0x%06x no longer in port database", (ull) tmd->cd_tagval, tmd->cd_cdb[0] & 0xff, tmd->cd_portid);
isp_tgt_dump_pdb(isp, tmd->cd_channel);
isp_thread_event(isp, ISP_THREAD_TERMINATE, tmd, 0, __FUNCTION__, __LINE__);
isp_thread_event(isp, ISP_THREAD_TERMINATE, tmd, 0, __func__, __LINE__);
break;
}
if (iid == INI_NONE) {
isp_prt(isp, ISP_LOGTDEBUG0, "%s: [0x%llx] trying to find IID again...", __FUNCTION__, tmd->cd_tagval);
isp_prt(isp, ISP_LOGTDEBUG0, "%s: [0x%llx] trying to find IID again...", __func__, (ull) tmd->cd_tagval);
tmd->cd_next = isp->isp_osinfo.waiting_t;
isp->isp_osinfo.waiting_t = tmd;
tmd->cd_lastoff = 0;
@@ -4708,8 +4718,8 @@ isp_task_thread(void *arg)
tmd->cd_tgt = FCPARAM(isp, tmd->cd_channel)->isp_wwpn;
tmd->cd_nphdl = nphdl;
tmd->cd_iid = iid;
isp_prt(isp, ISP_LOGTINFO, "%s: [0x%llx] Chan %d found initiator @ IID 0x%016llx N-Port Handle 0x%02x Port ID 0x%06x", __FUNCTION__,
tmd->cd_tagval, tmd->cd_channel, (unsigned long long)tmd->cd_iid, tmd->cd_nphdl, tmd->cd_portid);
isp_prt(isp, ISP_LOGTINFO, "%s: [0x%llx] Chan %d found initiator @ IID 0x%016llx N-Port Handle 0x%02x Port ID 0x%06x", __func__,
(ull) tmd->cd_tagval, tmd->cd_channel, (ull)tmd->cd_iid, tmd->cd_nphdl, tmd->cd_portid);
CALL_PARENT_TMD(isp, tmd, QOUT_TMD_START);
ISP_UNLKU_SOFTC(isp);
isp_tgt_tq(isp);
@@ -4731,11 +4741,11 @@ isp_task_thread(void *arg)
tmd->cd_portid = lp->portid;
}
} else {
isp_prt(isp, ISP_LOGTINFO, "[0x%llx] not in port database at all any more", tmd->cd_tagval);
isp_prt(isp, ISP_LOGTINFO, "[0x%llx] not in port database at all any more", (ull) tmd->cd_tagval);
}
if (tmd->cd_portid != PORT_NONE) {
isp_prt(isp, ISP_LOGTINFO, "%s: [0x%llx] Chan %d found initiator @ IID 0x%016llx N-Port Handle 0x%02x Port ID 0x%06x", __FUNCTION__,
tmd->cd_tagval, tmd->cd_channel, (unsigned long long)tmd->cd_iid, tmd->cd_nphdl, tmd->cd_portid);
isp_prt(isp, ISP_LOGTINFO, "%s: [0x%llx] Chan %d found initiator @ IID 0x%016llx N-Port Handle 0x%02x Port ID 0x%06x", __func__,
(ull) tmd->cd_tagval, tmd->cd_channel, (ull)tmd->cd_iid, tmd->cd_nphdl, tmd->cd_portid);
}
CALL_PARENT_TMD(isp, tmd, QOUT_TMD_START);
ISP_UNLKU_SOFTC(isp);
@@ -4754,14 +4764,14 @@ isp_task_thread(void *arg)
CALL_PARENT_TMD(isp, tmd, QOUT_TMD_START);
ISP_UNLKU_SOFTC(isp);
isp_tgt_tq(isp);
isp_prt(isp, ISP_LOGINFO, "Chan %d [%llx] reprieved", (int) AT2_GET_BUS(tmd->cd_tagval), (unsigned long long) tmd->cd_tagval);
isp_prt(isp, ISP_LOGINFO, "Chan %d [%llx] reprieved", (int) AT2_GET_BUS(tmd->cd_tagval), (ull) tmd->cd_tagval);
break;
}
isp_prt(isp, ISP_LOGTINFO, "%s now terminating [%llx] from 0x%06x", __FUNCTION__, (unsigned long long) tmd->cd_tagval, tmd->cd_portid);
isp_prt(isp, ISP_LOGTINFO, "%s now terminating [%llx] from 0x%06x", __func__, (ull) tmd->cd_tagval, tmd->cd_portid);
if (isp_terminate_cmd(isp, tmd)) {
ISP_UNLKU_SOFTC(isp);
isp_thread_event(isp, ISP_THREAD_TERMINATE, tmd, 0, __FUNCTION__, __LINE__);
isp_thread_event(isp, ISP_THREAD_TERMINATE, tmd, 0, __func__, __LINE__);
break;
}
tmd->cd_next = NULL;
@@ -4795,15 +4805,15 @@ isp_task_thread(void *arg)
{
tmd_cmd_t *tmd = tap->arg;
ISP_LOCKU_SOFTC(isp);
isp_prt(isp, ISP_LOGTINFO, "%s: [%llx] calling putback", __FUNCTION__, tmd->cd_tagval);
isp_prt(isp, ISP_LOGTINFO, "%s: [%llx] calling putback", __func__, (ull) tmd->cd_tagval);
if (isp_target_putback_atio(isp, tmd)) {
ISP_UNLKU_SOFTC(isp);
isp_thread_event(isp, ISP_THREAD_FC_PUTBACK, tmd, 0, __FUNCTION__, __LINE__);
isp_thread_event(isp, ISP_THREAD_FC_PUTBACK, tmd, 0, __func__, __LINE__);
break;
}
if (tmd->cd_lflags & CDFL_NEED_CLNUP) {
tmd->cd_lflags ^= CDFL_NEED_CLNUP;
isp_prt(isp, ISP_LOGTINFO, "Terminating %llx too", (unsigned long long) tmd->cd_tagval);
isp_prt(isp, ISP_LOGTINFO, "Terminating %llx too", (ull) tmd->cd_tagval);
(void) isp_terminate_cmd(isp, tmd);
}
MEMZERO(tmd, sizeof (tmd_cmd_t));
@@ -4813,7 +4823,7 @@ isp_task_thread(void *arg)
isp->isp_osinfo.tfreelist = tmd;
}
isp->isp_osinfo.bfreelist = tmd; /* remember to move the list tail pointer */
isp_prt(isp, ISP_LOGTDEBUG0, "DONE freeing tmd %p [%llx] after retry", tmd, tmd->cd_tagval);
isp_prt(isp, ISP_LOGTDEBUG0, "DONE freeing tmd %p [%llx] after retry", tmd, (ull) tmd->cd_tagval);
ISP_UNLKU_SOFTC(isp);
break;
}

View File

@@ -1,4 +1,4 @@
/* $Id: isp_linux.h,v 1.161 2008/04/15 22:41:03 mjacob Exp $ */
/* $Id: isp_linux.h,v 1.164 2008/08/20 15:50:56 mjacob Exp $ */
/*
* Copyright (c) 1997-2008 by Matthew Jacob
* All rights reserved.
@@ -59,15 +59,6 @@
#ifndef _ISP_LINUX_H
#define _ISP_LINUX_H
//#define DISABLE_FW_LOADER 1
//#define ISP_DISABLE_1080_SUPPORT 1
//#define ISP_DISABLE_12160_SUPPORT 1
//#define ISP_DISABLE_2100_SUPPORT 1
//#define ISP_DISABLE_2200_SUPPORT 1
//#define ISP_DISABLE_2300_SUPPORT 1
//#define ISP_DISABLE_2322_SUPPORT 1
//#define ISP_DISABLE_2400_SUPPORT 1
#ifndef ISP_MODULE
#define __NO_VERSION__
#endif
@@ -80,14 +71,10 @@
#define KERNEL_VERSION(v,p,s) (((v)<<16)+(p<<8)+s)
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) || LINUX_VERSION_CODE >= KERNEL_VERSION(2, 7, 0)
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) || LINUX_VERSION_CODE >= KERNEL_VERSION(2,7,0)
#error "Only Linux 2.5/2.6 kernels are supported with this driver"
#endif
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 24)
#error "Linux kernels newer than 2.6.24 are not supported with this driver"
#endif
#ifndef UNUSED_PARAMETER
#define UNUSED_PARAMETER(x) (void) x
#endif
@@ -126,24 +113,34 @@
#include <scsi/scsi_device.h>
#include <linux/cdev.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 13)
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
#include <linux/devfs_fs_kernel.h>
#define ISP_CLASS struct class_simple
#define CREATE_ISP_CLASS class_simple_create
#define DESTROY_ISP_CLASS class_simple_destroy
#define CREATE_ISP_DEV(isp, class) \
class_simple_device_add(class, MKDEV(MAJOR(isp_dev), isp->isp_unit), NULL, "%s%d", ISP_NAME, isp->isp_unit), \
devfs_mk_cdev(MKDEV(MAJOR(isp_dev), isp->isp_unit), S_IFCHR | S_IRUGO | S_IWUGO, "%s%d", ISP_NAME, isp->isp_unit)
#define DESTROY_ISP_DEV(isp) \
devfs_remove("%s%d", ISP_NAME, isp->isp_unit), class_simple_device_remove(MKDEV(MAJOR(isp_dev), isp->isp_unit))
#else
#define ISP_CLASS struct class
#define CREATE_ISP_CLASS class_create
#define DESTROY_ISP_CLASS class_destroy
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
#define ISP_CLASS struct class
#define CREATE_ISP_CLASS class_create
#define DESTROY_ISP_CLASS class_destroy
#define CREATE_ISP_DEV(isp, class) \
class_device_create(class, NULL, MKDEV(MAJOR(isp_dev), isp->isp_unit), NULL, "%s%d", ISP_NAME, isp->isp_unit)
#define DESTROY_ISP_DEV(isp) \
class_device_destroy(isp_class, MKDEV(MAJOR(isp_dev), (isp)->isp_unit));
#else
#define ISP_CLASS struct class
#define CREATE_ISP_CLASS class_create
#define DESTROY_ISP_CLASS class_destroy
#define CREATE_ISP_DEV(i, c) (void) device_create(c, NULL, MKDEV(MAJOR(isp_dev), (i)->isp_unit), "%s%d", ISP_NAME, (i)->isp_unit);
#define DESTROY_ISP_DEV(i) device_destroy(isp_class, MKDEV(MAJOR(isp_dev), (i)->isp_unit));
#endif
typedef struct scsi_cmnd Scsi_Cmnd;
@@ -163,7 +160,7 @@ typedef struct scsi_host_template Scsi_Host_Template;
#endif
#define ISP_PLATFORM_VERSION_MAJOR 6
#define ISP_PLATFORM_VERSION_MINOR 0
#define ISP_PLATFORM_VERSION_MINOR 1
#ifndef ISP_NAME
#define ISP_NAME "isp"
@@ -201,9 +198,11 @@ typedef struct scsi_host_template Scsi_Host_Template;
#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
#define sg_page(_sg) ((_sg)->page)
#define sg_assign_page(_sg, _pg) ((_sg)->page = (_pg))
#define ull unsigned long long
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
#define sg_page(_sg) ((_sg)->page)
#define sg_assign_page(_sg, _pg) ((_sg)->page = (_pg))
#endif
/*
@@ -399,8 +398,8 @@ struct isposinfo {
#define ISP_IUNLK_SOFTC ISP_UNLK_SOFTC
#define ISP_IGET_LK_SOFTC(isp) spin_lock_irq(&isp->isp_osinfo.slock)
#define ISP_DROP_LK_SOFTC(isp) spin_unlock_irq(&isp->isp_osinfo.slock)
#define ISP_LOCK_SCSI_DONE(isp) do { } while (0)
#define ISP_UNLK_SCSI_DONE(isp) do { } while (0)
#define ISP_LOCK_SCSI_DONE(isp) do { } while(0)
#define ISP_UNLK_SCSI_DONE(isp) do { } while(0)
#define ISP_LOCKU_SOFTC ISP_ILOCK_SOFTC
#define ISP_UNLKU_SOFTC ISP_IUNLK_SOFTC
#define ISP_TLOCK_INIT(isp) spin_lock_init(&isp->isp_osinfo.tlock)
@@ -498,13 +497,20 @@ struct isposinfo {
#define XS_ISP(Cmnd) ((ispsoftc_t *)XS_HOST(Cmnd)->hostdata)
#define XS_CDBP(Cmnd) (Cmnd)->cmnd
#define XS_CDBLEN(Cmnd) (Cmnd)->cmd_len
#define XS_XFRLEN(Cmnd) (Cmnd)->request_bufflen
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
#define XS_GET_RESID(Cmnd) (Cmnd)->SCp.this_residual
#define XS_SET_RESID(Cmnd, resid) (Cmnd)->SCp.this_residual = resid
#define XS_XFRLEN(Cmnd) (Cmnd)->request_bufflen
#else
#define XS_GET_RESID scsi_get_resid
#define XS_SET_RESID scsi_set_resid
#define XS_XFRLEN scsi_bufflen
#endif
#define XS_TIME(Cmnd) ((((Cmnd)->timeout_per_command) * HZ)*1000)
#define XS_RESID(Cmnd) (Cmnd)->SCp.this_residual
#define XS_STSP(Cmnd) (&(Cmnd)->SCp.Status)
#define XS_SNSP(Cmnd) (Cmnd)->sense_buffer
#define XS_SNSLEN(Cmnd) (sizeof (Cmnd)->sense_buffer)
#define XS_SNSKEY(Cmnd) ((Cmnd)->sense_buffer[2] & 0xf)
#define XS_SNSLEN(Cmnd) SCSI_SENSE_BUFFERSIZE
#define XS_SNSKEY(Cmnd) (XS_SNSP(Cmnd)[2] & 0xf)
#define XS_TAG_P(Cmnd) (Cmnd->device->tagged_supported != 0)
#define XS_TAG_TYPE isplinux_tagtype
@@ -532,8 +538,7 @@ struct isposinfo {
#define XS_INITERR(xs) (xs)->result = 0, (xs)->SCp.Status = 0
#define XS_SAVE_SENSE(Cmnd, s, l) \
MEMCPY(&Cmnd->sense_buffer, s, min(sizeof Cmnd->sense_buffer, l))
#define XS_SAVE_SENSE(Cmnd, s, l) MEMCPY(XS_SNSP(Cmnd), s, min(XS_SNSLEN(Cmnd), l))
#define XS_SET_STATE_STAT(a, b, c)
@@ -632,7 +637,7 @@ typedef struct {
*/
void isplinux_timer(unsigned long);
void isplinux_mbtimer(unsigned long);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
irqreturn_t isplinux_intr(int, void *, struct pt_regs *);
#else
irqreturn_t isplinux_intr(int, void *);

View File

@@ -1,4 +1,4 @@
/* $Id: isp_pci.c,v 1.168 2008/04/15 22:41:03 mjacob Exp $ */
/* $Id: isp_pci.c,v 1.172 2008/08/20 15:50:56 mjacob Exp $ */
/*
* Copyright (c) 1997-2008 by Matthew Jacob
* All rights reserved.
@@ -87,7 +87,7 @@ static int isp_pci_mbxdma(ispsoftc_t *);
static int isp_pci_dmasetup(ispsoftc_t *, XS_T *, ispreq_t *, uint32_t *, uint32_t);
static void isp_pci_dmateardown(ispsoftc_t *, XS_T *, uint32_t);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 6)
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6)
#define DMA_64BIT_MASK 0xffffffffffffffffULL
#define DMA_32BIT_MASK 0x00000000ffffffffULL
#endif
@@ -99,7 +99,7 @@ static void isp_pci_dmateardown(ispsoftc_t *, XS_T *, uint32_t);
#define SAME_4G(addr, cnt) (FOURG_SEG(addr) == FOURG_SEG(addr + cnt - 1))
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
#define ISP_IRQ_FLAGS SA_INTERRUPT | SA_SHIRQ
#else
#define ISP_IRQ_FLAGS IRQF_SHARED
@@ -365,11 +365,11 @@ struct isp_pcisoftc {
msix_enabled : 2,
msi_enabled : 1;
};
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 8)
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8)
#define pci_enable_msi(x) -ENXIO
#define pci_enable_msix(x) -ENXIO
#define pci_disable_msi(x) do { ; } while (0)
#define pci_disable_msix(x) do { ; } while (0)
#define pci_disable_msi(x) do { ; } while(0)
#define pci_disable_msix(x) do { ; } while(0)
#endif
/*
@@ -506,7 +506,7 @@ isplinux_pci_release(struct Scsi_Host *host)
}
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 7) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 14)
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,7) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
/**
* pci_intx - enables/disables PCI INTx for device dev
* @pdev: the PCI device to operate on
@@ -619,7 +619,7 @@ isplinux_pci_init_one(struct Scsi_Host *host)
return (1);
}
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 7)
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,7)
if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 || pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432) {
struct msix_entry isp_msix[3];
int reg;
@@ -669,7 +669,7 @@ isplinux_pci_init_one(struct Scsi_Host *host)
pci_write_config_word(pdev, reg + PCI_EXP_DEVCTL, pectl);
}
} else
#elif LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 0)
#elif LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
if (pci_enable_msi(pdev) == 0) {
isp_pci->msi_enabled = 1;
}
@@ -945,7 +945,7 @@ bad:
isp_kfree(isp->isp_osinfo.storep, isp->isp_osinfo.storep_amt);
isp->isp_osinfo.storep = NULL;
}
#if !defined(DISABLE_FW_LOADER) && (defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE))
#ifdef CONFIG_FW_LOADER
if (isp->isp_osinfo.fwp) {
release_firmware(isp->isp_osinfo.fwp);
isp->isp_osinfo.fwp = NULL;
@@ -1677,7 +1677,7 @@ tdma_mk(ispsoftc_t *isp, tmd_xact_t *xact, ct_entry_t *cto, uint32_t *nxtip, uin
resid = (int32_t) xact->td_xfrlen;
while (resid > 0) {
if (sg->length == 0) {
isp_prt(isp, ISP_LOGWARN, "%s: zero length segment #%d for tag %llx\n", __FUNCTION__, nseg, tmd->cd_tagval);
isp_prt(isp, ISP_LOGWARN, "%s: zero length segment #%d for tag %llx\n", __func__, nseg, tmd->cd_tagval);
cto->ct_resid = -EINVAL;
return (CMD_COMPLETE);
}
@@ -1690,7 +1690,7 @@ tdma_mk(ispsoftc_t *isp, tmd_xact_t *xact, ct_entry_t *cto, uint32_t *nxtip, uin
new_seg_cnt = pci_map_sg(pcs->pci_dev, sg, nseg, (cto->ct_flags & CT_DATA_IN)? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE);
if (new_seg_cnt == 0) {
isp_prt(isp, ISP_LOGWARN, "%s: unable to dma map request", __FUNCTION__);
isp_prt(isp, ISP_LOGWARN, "%s: unable to dma map request", __func__);
cto->ct_resid = -ENOMEM;
return (CMD_COMPLETE);
}
@@ -1759,7 +1759,7 @@ tdma_mk(ispsoftc_t *isp, tmd_xact_t *xact, ct_entry_t *cto, uint32_t *nxtip, uin
* pretty unlikely to ever be used.
*/
if (ISP_A64 && IS_HIGH_ISP_ADDR(addr)) {
isp_prt(isp, ISP_LOGERR, "%s: 64 bit tgt mode not supported", __FUNCTION__);
isp_prt(isp, ISP_LOGERR, "%s: 64 bit tgt mode not supported", __func__);
cto->ct_resid = -EFAULT;
pci_unmap_sg(pcs->pci_dev, xact->td_data, nseg, (cto->ct_flags & CT_DATA_IN)? PCI_DMA_TODEVICE: PCI_DMA_FROMDEVICE);
return (CMD_COMPLETE);
@@ -1779,7 +1779,7 @@ tdma_mk(ispsoftc_t *isp, tmd_xact_t *xact, ct_entry_t *cto, uint32_t *nxtip, uin
* sending an extra CTIO with final status.
*/
if (send_status == 0) {
isp_prt(isp, ISP_LOGERR, "%s: ran out of segments, no status to send", __FUNCTION__);
isp_prt(isp, ISP_LOGERR, "%s: ran out of segments, no status to send", __func__);
return (CMD_EAGAIN);
}
}
@@ -1831,7 +1831,7 @@ tdma_mk(ispsoftc_t *isp, tmd_xact_t *xact, ct_entry_t *cto, uint32_t *nxtip, uin
qe = (ct_entry_t *) ISP_QUEUE_ENTRY(isp->isp_rquest, nxti);
nxti = ISP_NXT_QENTRY(nxti, RQUEST_QUEUE_LEN(isp));
if (nxti == optr) {
isp_prt(isp, ISP_LOGERR, "%s: request queue overflow", __FUNCTION__);
isp_prt(isp, ISP_LOGERR, "%s: request queue overflow", __func__);
return (CMD_EAGAIN);
}
@@ -1979,7 +1979,7 @@ tdma_mk_2400(ispsoftc_t *isp, tmd_xact_t *xact, ct7_entry_t *cto, uint32_t *nxti
xfcnt = xact->td_xfrlen;
while (xfcnt > 0) {
if (sg->length == 0) {
isp_prt(isp, ISP_LOGWARN, "%s: zero length segment #%d for tag %llx\n", __FUNCTION__, nseg, tmd->cd_tagval);
isp_prt(isp, ISP_LOGWARN, "%s: zero length segment #%d for tag %llx\n", __func__, nseg, tmd->cd_tagval);
cto->ct_resid = -EINVAL;
return (CMD_COMPLETE);
}
@@ -1990,7 +1990,7 @@ tdma_mk_2400(ispsoftc_t *isp, tmd_xact_t *xact, ct7_entry_t *cto, uint32_t *nxti
sg = xact->td_data;
new_seg_cnt = pci_map_sg(pcs->pci_dev, sg, nseg, (cto->ct_flags & CT2_DATA_IN)? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE);
if (new_seg_cnt == 0) {
isp_prt(isp, ISP_LOGWARN, "%s: unable to dma map request", __FUNCTION__);
isp_prt(isp, ISP_LOGWARN, "%s: unable to dma map request", __func__);
cto->ct_resid = -ENOMEM;
return (CMD_COMPLETE);
}
@@ -2000,7 +2000,7 @@ tdma_mk_2400(ispsoftc_t *isp, tmd_xact_t *xact, ct7_entry_t *cto, uint32_t *nxti
* Check for sequential ordering of data frames
*/
if (tmd->cd_lastoff + tmd->cd_lastsize != xact->td_offset) {
isp_prt(isp, ISP_LOGWARN, "%s: [0x%llx] lastoff %u lastsize %u but curoff %u (totlen %u)", __FUNCTION__, (unsigned long long) tmd->cd_tagval, tmd->cd_lastoff, tmd->cd_lastsize, xact->td_offset, tmd->cd_totlen);
isp_prt(isp, ISP_LOGWARN, "%s: [0x%llx] lastoff %u lastsize %u but curoff %u (totlen %u)", __func__, (unsigned long long) tmd->cd_tagval, tmd->cd_lastoff, tmd->cd_lastsize, xact->td_offset, tmd->cd_totlen);
}
tmd->cd_lastsize = xact->td_xfrlen;
tmd->cd_lastoff = xact->td_offset;
@@ -2074,7 +2074,7 @@ tdma_mk_2400(ispsoftc_t *isp, tmd_xact_t *xact, ct7_entry_t *cto, uint32_t *nxti
last_synthetic_addr = addr;
} else {
cto->rsp.m0.ds.ds_count = bc;
isp_prt(isp, ISP_LOGTDEBUG1, "%s: seg0[%d]%lx%08lx:%u", __FUNCTION__, seg,
isp_prt(isp, ISP_LOGTDEBUG1, "%s: seg0[%d]%lx%08lx:%u", __func__, seg,
(unsigned long)cto->rsp.m0.ds.ds_basehi, (unsigned long)cto->rsp.m0.ds.ds_base, bc);
}
cto->rsp.m0.ct_xfrlen += bc;
@@ -2099,7 +2099,7 @@ tdma_mk_2400(ispsoftc_t *isp, tmd_xact_t *xact, ct7_entry_t *cto, uint32_t *nxti
nxti = ISP_NXT_QENTRY((curip), RQUEST_QUEUE_LEN(isp));
if (nxti == optr) {
pci_unmap_sg(pcs->pci_dev, xact->td_data, nseg, (cto->ct_flags & CT2_DATA_IN)? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE);
isp_prt(isp, ISP_LOGTDEBUG0, "%s: out of space for continuations (%d of %d segs done)", __FUNCTION__, cto->ct_seg_count, nseg);
isp_prt(isp, ISP_LOGTDEBUG0, "%s: out of space for continuations (%d of %d segs done)", __func__, cto->ct_seg_count, nseg);
return (CMD_EAGAIN);
}
cto->ct_header.rqs_entry_count++;
@@ -2120,7 +2120,7 @@ tdma_mk_2400(ispsoftc_t *isp, tmd_xact_t *xact, ct7_entry_t *cto, uint32_t *nxti
addr = sg_dma_address(sg);
bc = min(sg_dma_len(sg), xfcnt);
}
isp_prt(isp, ISP_LOGTDEBUG1, "%s: seg%d[%d]%llx:%u", __FUNCTION__, cto->ct_header.rqs_entry_count-1, ovseg, (unsigned long long) addr, bc);
isp_prt(isp, ISP_LOGTDEBUG1, "%s: seg%d[%d]%llx:%u", __func__, cto->ct_header.rqs_entry_count-1, ovseg, (unsigned long long) addr, bc);
cto->ct_seg_count++;
cto->rsp.m0.ct_xfrlen += bc;
@@ -2177,7 +2177,7 @@ mbxsync:
nxti = ISP_NXT_QENTRY(curi, RQUEST_QUEUE_LEN(isp));
if (nxti == optr) {
pci_unmap_sg(pcs->pci_dev, xact->td_data, nseg, (cto->ct_flags & CT7_DATA_IN)? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE);
isp_prt(isp, ISP_LOGTDEBUG0, "%s: request queue overflow", __FUNCTION__);
isp_prt(isp, ISP_LOGTDEBUG0, "%s: request queue overflow", __func__);
cto->ct_resid = -EAGAIN;
return (CMD_COMPLETE);
}
@@ -2300,7 +2300,7 @@ tdma_mkfc(ispsoftc_t *isp, tmd_xact_t *xact, ct2_entry_t *cto, uint32_t *nxtip,
xfcnt = xact->td_xfrlen;
while (xfcnt > 0) {
if (sg->length == 0) {
isp_prt(isp, ISP_LOGWARN, "%s: zero length segment #%d for tag %llx\n", __FUNCTION__, nseg, tmd->cd_tagval);
isp_prt(isp, ISP_LOGWARN, "%s: zero length segment #%d for tag %llx\n", __func__, nseg, tmd->cd_tagval);
cto->ct_resid = -EINVAL;
return (CMD_COMPLETE);
}
@@ -2311,7 +2311,7 @@ tdma_mkfc(ispsoftc_t *isp, tmd_xact_t *xact, ct2_entry_t *cto, uint32_t *nxtip,
sg = xact->td_data;
new_seg_cnt = pci_map_sg(pcs->pci_dev, sg, nseg, (cto->ct_flags & CT2_DATA_IN)? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE);
if (new_seg_cnt == 0) {
isp_prt(isp, ISP_LOGWARN, "%s: unable to dma map request", __FUNCTION__);
isp_prt(isp, ISP_LOGWARN, "%s: unable to dma map request", __func__);
cto->ct_resid = -ENOMEM;
return (CMD_COMPLETE);
}
@@ -2413,12 +2413,12 @@ again:
cto->rsp.m0.ct_xfrlen = 0;
sg = xact->td_data;
seglim = ISP_RQDSEG_T3;
isp_prt(isp, ISP_LOGTDEBUG2, "%s: found hi page", __FUNCTION__);
isp_prt(isp, ISP_LOGTDEBUG2, "%s: found hi page", __func__);
goto again;
}
cto->rsp.m0.u.ct_dataseg[seg].ds_base = LOWD(addr);
cto->rsp.m0.u.ct_dataseg[seg].ds_count = bc;
isp_prt(isp, ISP_LOGTDEBUG1, "%s: seg0[%d]%x:%u", __FUNCTION__, seg, cto->rsp.m0.u.ct_dataseg[seg].ds_base, bc);
isp_prt(isp, ISP_LOGTDEBUG1, "%s: seg0[%d]%x:%u", __func__, seg, cto->rsp.m0.u.ct_dataseg[seg].ds_base, bc);
} else {
cto->rsp.m0.u.ct_dataseg64[seg].ds_base = LOWD(addr);
cto->rsp.m0.u.ct_dataseg64[seg].ds_basehi = HIWD(addr);
@@ -2439,12 +2439,12 @@ again:
cto->rsp.m0.u.ct_dataseg64[seg].ds_count = bc;
cto->rsp.m0.u.ct_dataseg64[seg].ds_base = LOWD(addr);
cto->rsp.m0.u.ct_dataseg64[seg].ds_basehi = HIWD(addr);
isp_prt(isp, ISP_LOGALL, "%s: seg0[%d]%lx%08lx:%u", __FUNCTION__, seg,
isp_prt(isp, ISP_LOGALL, "%s: seg0[%d]%lx%08lx:%u", __func__, seg,
(unsigned long)cto->rsp.m0.u.ct_dataseg64[seg].ds_basehi, (unsigned long)cto->rsp.m0.u.ct_dataseg64[seg].ds_base, bc);
}
} else {
cto->rsp.m0.u.ct_dataseg64[seg].ds_count = bc;
isp_prt(isp, ISP_LOGTDEBUG1, "%s: seg0[%d]%lx%08lx:%u", __FUNCTION__, seg,
isp_prt(isp, ISP_LOGTDEBUG1, "%s: seg0[%d]%lx%08lx:%u", __func__, seg,
(unsigned long)cto->rsp.m0.u.ct_dataseg64[seg].ds_basehi, (unsigned long)cto->rsp.m0.u.ct_dataseg64[seg].ds_base, bc);
}
}
@@ -2452,12 +2452,12 @@ again:
if (seglim == ISP_RQDSEG_T2) {
cto->rsp.m0.u.ct_dataseg[seg].ds_base = addr;
cto->rsp.m0.u.ct_dataseg[seg].ds_count = bc;
isp_prt(isp, ISP_LOGTDEBUG1, "%s: seg0[%d]%x:%u", __FUNCTION__, seg, cto->rsp.m0.u.ct_dataseg[seg].ds_base, bc);
isp_prt(isp, ISP_LOGTDEBUG1, "%s: seg0[%d]%x:%u", __func__, seg, cto->rsp.m0.u.ct_dataseg[seg].ds_base, bc);
} else {
cto->rsp.m0.u.ct_dataseg64[seg].ds_base = addr;
cto->rsp.m0.u.ct_dataseg64[seg].ds_basehi = 0;
cto->rsp.m0.u.ct_dataseg64[seg].ds_count = bc;
isp_prt(isp, ISP_LOGTDEBUG1, "%s: seg0[%d]%lx:%u", __FUNCTION__, seg, (unsigned long) cto->rsp.m0.u.ct_dataseg64[seg].ds_base, bc);
isp_prt(isp, ISP_LOGTDEBUG1, "%s: seg0[%d]%lx:%u", __func__, seg, (unsigned long) cto->rsp.m0.u.ct_dataseg64[seg].ds_base, bc);
}
#endif
cto->rsp.m0.ct_xfrlen += bc;
@@ -2483,7 +2483,7 @@ again:
nxti = ISP_NXT_QENTRY((curip), RQUEST_QUEUE_LEN(isp));
if (nxti == optr) {
pci_unmap_sg(pcs->pci_dev, xact->td_data, nseg, (cto->ct_flags & CT2_DATA_IN)? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE);
isp_prt(isp, ISP_LOGTDEBUG0, "%s: out of space for continuations (%d of %d segs done)", __FUNCTION__, cto->ct_seg_count, nseg);
isp_prt(isp, ISP_LOGTDEBUG0, "%s: out of space for continuations (%d of %d segs done)", __func__, cto->ct_seg_count, nseg);
return (CMD_EAGAIN);
}
cto->ct_header.rqs_entry_count++;
@@ -2508,7 +2508,7 @@ again:
addr = sg_dma_address(sg);
bc = min(sg_dma_len(sg), xfcnt);
}
isp_prt(isp, ISP_LOGTDEBUG1, "%s: seg%d[%d]%llx:%u", __FUNCTION__, cto->ct_header.rqs_entry_count-1, ovseg, (unsigned long long) addr, bc);
isp_prt(isp, ISP_LOGTDEBUG1, "%s: seg%d[%d]%llx:%u", __func__, cto->ct_header.rqs_entry_count-1, ovseg, (unsigned long long) addr, bc);
cto->ct_seg_count++;
cto->rsp.m0.ct_xfrlen += bc;
@@ -2561,7 +2561,7 @@ again:
cto->rsp.m0.ct_xfrlen = 0;
sg = xact->td_data;
seglim = ISP_RQDSEG_T3;
isp_prt(isp, ISP_LOGTDEBUG1, "%s: found hi page in continuation, restarting", __FUNCTION__);
isp_prt(isp, ISP_LOGTDEBUG1, "%s: found hi page in continuation, restarting", __func__);
goto again;
}
crq->req_dataseg[ovseg].ds_count = bc;
@@ -2593,7 +2593,7 @@ mbxsync:
nxti = ISP_NXT_QENTRY(curi, RQUEST_QUEUE_LEN(isp));
if (nxti == optr) {
pci_unmap_sg(pcs->pci_dev, xact->td_data, nseg, (cto->ct_flags & CT2_DATA_IN)? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE);
isp_prt(isp, ISP_LOGTDEBUG0, "%s: request queue overflow", __FUNCTION__);
isp_prt(isp, ISP_LOGTDEBUG0, "%s: request queue overflow", __func__);
cto->ct_resid = -EAGAIN;
return (CMD_COMPLETE);
}
@@ -2617,8 +2617,13 @@ static int
isp_pci_dmasetup(ispsoftc_t *isp, Scsi_Cmnd *Cmnd, ispreq_t *rq, uint32_t *nxi, uint32_t optr)
{
struct scatterlist *sg, *savesg;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
XS_DMA_ADDR_T one_shot_addr, last_synthetic_addr;
unsigned int one_shot_length, last_synthetic_count;
#else
XS_DMA_ADDR_T last_synthetic_addr;
unsigned int last_synthetic_count;
#endif
int segcnt, seg, ovseg, seglim;
void *h;
uint32_t nxti;
@@ -2638,24 +2643,24 @@ isp_pci_dmasetup(ispsoftc_t *isp, Scsi_Cmnd *Cmnd, ispreq_t *rq, uint32_t *nxi,
nxti = *nxi;
h = (void *) ISP_QUEUE_ENTRY(isp->isp_rquest, isp->isp_reqidx);
if (Cmnd->sc_data_direction == SCSI_DATA_NONE || Cmnd->request_bufflen == 0) {
if (Cmnd->sc_data_direction == SCSI_DATA_NONE || XS_XFRLEN(Cmnd) == 0) {
rq->req_seg_count = 1;
goto mbxsync;
}
if (Cmnd->request_bufflen <= 1024) {
if (XS_XFRLEN(Cmnd) <= 1024) {
seg = 0;
} else if (Cmnd->request_bufflen <= 4096) {
} else if (XS_XFRLEN(Cmnd) <= 4096) {
seg = 1;
} else if (Cmnd->request_bufflen <= 32768) {
} else if (XS_XFRLEN(Cmnd) <= 32768) {
seg = 2;
} else if (Cmnd->request_bufflen <= 65536) {
} else if (XS_XFRLEN(Cmnd) <= 65536) {
seg = 3;
} else if (Cmnd->request_bufflen <= 131372) {
} else if (XS_XFRLEN(Cmnd) <= 131372) {
seg = 4;
} else if (Cmnd->request_bufflen <= 262144) {
} else if (XS_XFRLEN(Cmnd) <= 262144) {
seg = 5;
} else if (Cmnd->request_bufflen <= 524288) {
} else if (XS_XFRLEN(Cmnd) <= 524288) {
seg = 6;
} else {
seg = 7;
@@ -2664,14 +2669,14 @@ isp_pci_dmasetup(ispsoftc_t *isp, Scsi_Cmnd *Cmnd, ispreq_t *rq, uint32_t *nxi,
if (IS_FC(isp)) {
seglim = ISP_RQDSEG_T2;
((ispreqt2_t *)rq)->req_totalcnt = Cmnd->request_bufflen;
((ispreqt2_t *)rq)->req_totalcnt = XS_XFRLEN(Cmnd);
if (Cmnd->sc_data_direction == SCSI_DATA_WRITE) {
((ispreqt2_t *)rq)->req_flags |= REQFLAG_DATA_OUT;
} else if (Cmnd->sc_data_direction == SCSI_DATA_READ) {
((ispreqt2_t *)rq)->req_flags |= REQFLAG_DATA_IN;
} else {
isp_prt(isp, ISP_LOGERR, "%s: unkown data direction (%x) for %d byte request (opcode 0x%x)", __FUNCTION__,
Cmnd->sc_data_direction, Cmnd->request_bufflen, Cmnd->cmnd[0]);
isp_prt(isp, ISP_LOGERR, "%s: unkown data direction (%x) for %d byte request (opcode 0x%x)", __func__,
Cmnd->sc_data_direction, XS_XFRLEN(Cmnd), Cmnd->cmnd[0]);
XS_SETERR(Cmnd, HBA_BOTCH);
return (CMD_COMPLETE);
}
@@ -2686,21 +2691,22 @@ isp_pci_dmasetup(ispsoftc_t *isp, Scsi_Cmnd *Cmnd, ispreq_t *rq, uint32_t *nxi,
} else if (Cmnd->sc_data_direction == SCSI_DATA_READ) {
rq->req_flags |= REQFLAG_DATA_IN;
} else {
isp_prt(isp, ISP_LOGERR, "%s: unkown data direction (%x) for %d byte request (opcode 0x%x)", __FUNCTION__,
Cmnd->sc_data_direction, Cmnd->request_bufflen, Cmnd->cmnd[0]);
isp_prt(isp, ISP_LOGERR, "%s: unkown data direction (%x) for %d byte request (opcode 0x%x)", __func__,
Cmnd->sc_data_direction, XS_XFRLEN(Cmnd), Cmnd->cmnd[0]);
XS_SETERR(Cmnd, HBA_BOTCH);
return (CMD_COMPLETE);
}
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
one_shot_addr = (XS_DMA_ADDR_T) 0;
one_shot_length = 0;
if ((segcnt = Cmnd->use_sg) == 0) {
struct isp_pcisoftc *pcs = (struct isp_pcisoftc *) isp;
segcnt = 1;
sg = NULL;
one_shot_length = Cmnd->request_bufflen;
one_shot_addr = pci_map_single(pcs->pci_dev, Cmnd->request_buffer, Cmnd->request_bufflen, scsi_to_pci_dma_dir(Cmnd->sc_data_direction));
one_shot_length = XS_XFRLEN(Cmnd);
one_shot_addr = pci_map_single(pcs->pci_dev, Cmnd->request_buffer, XS_XFRLEN(Cmnd), scsi_to_pci_dma_dir(Cmnd->sc_data_direction));
QLA_HANDLE(Cmnd) = (DMA_HTYPE_T) one_shot_addr;
} else {
struct isp_pcisoftc *pcs = (struct isp_pcisoftc *) isp;
@@ -2708,10 +2714,19 @@ isp_pci_dmasetup(ispsoftc_t *isp, Scsi_Cmnd *Cmnd, ispreq_t *rq, uint32_t *nxi,
segcnt = pci_map_sg(pcs->pci_dev, sg, Cmnd->use_sg, scsi_to_pci_dma_dir(Cmnd->sc_data_direction));
}
if (segcnt == 0) {
isp_prt(isp, ISP_LOGWARN, "%s: unable to dma map request", __FUNCTION__);
isp_prt(isp, ISP_LOGWARN, "%s: unable to dma map request", __func__);
XS_SETERR(Cmnd, HBA_BOTCH);
return (CMD_COMPLETE);
}
#else
segcnt = scsi_dma_map(Cmnd);
if (segcnt <= 0) {
isp_prt(isp, ISP_LOGWARN, "%s: unable to dma map request", __func__);
XS_SETERR(Cmnd, HBA_BOTCH);
return (CMD_COMPLETE);
}
sg = scsi_sglist(Cmnd);
#endif
savesg = sg;
again:
@@ -2721,6 +2736,7 @@ again:
XS_DMA_ADDR_T addr;
unsigned int length;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
if (sg) {
length = sg_dma_len(sg);
addr = sg_dma_address(sg);
@@ -2729,6 +2745,11 @@ again:
length = one_shot_length;
addr = one_shot_addr;
}
#else
length = sg_dma_len(sg);
addr = sg_dma_address(sg);
sg++;
#endif
if (ISP_A64 && IS_HIGH_ISP_ADDR(addr)) {
if (IS_FC(isp)) {
@@ -2845,7 +2866,7 @@ again:
nxti = ISP_NXT_QENTRY((curip), RQUEST_QUEUE_LEN(isp));
if (nxti == optr) {
isp_pci_dmateardown(isp, Cmnd, 0);
isp_prt(isp, ISP_LOGDEBUG0, "%s: Chan %d out of space for continuations (did %d of %d segments)", __FUNCTION__, XS_CHANNEL(Cmnd), seg, segcnt);
isp_prt(isp, ISP_LOGDEBUG0, "%s: Chan %d out of space for continuations (did %d of %d segments)", __func__, XS_CHANNEL(Cmnd), seg, segcnt);
XS_SETERR(Cmnd, HBA_BOTCH);
return (CMD_EAGAIN);
}
@@ -2969,8 +2990,13 @@ isp_pci_2400_dmasetup(ispsoftc_t *isp, Scsi_Cmnd *Cmnd, ispreq_t *orig_rq, uint3
{
struct scatterlist *sg, *savesg;
ispreqt7_t *rq;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
XS_DMA_ADDR_T addr, one_shot_addr, last_synthetic_addr;
unsigned int one_shot_length, last_synthetic_count, length;
#else
XS_DMA_ADDR_T addr, last_synthetic_addr;
unsigned int last_synthetic_count, length;
#endif
int segcnt, seg, ovseg;
void *h;
uint32_t nxti;
@@ -2984,31 +3010,31 @@ isp_pci_2400_dmasetup(ispsoftc_t *isp, Scsi_Cmnd *Cmnd, ispreq_t *orig_rq, uint3
nxti = *nxi;
h = (void *) ISP_QUEUE_ENTRY(isp->isp_rquest, isp->isp_reqidx);
if (Cmnd->sc_data_direction == SCSI_DATA_NONE || Cmnd->request_bufflen == 0) {
if (Cmnd->sc_data_direction == SCSI_DATA_NONE || XS_XFRLEN(Cmnd) == 0) {
rq->req_seg_count = 0;
goto mbxsync;
}
if (Cmnd->request_bufflen <= 1024) {
if (XS_XFRLEN(Cmnd) <= 1024) {
seg = 0;
} else if (Cmnd->request_bufflen <= 4096) {
} else if (XS_XFRLEN(Cmnd) <= 4096) {
seg = 1;
} else if (Cmnd->request_bufflen <= 32768) {
} else if (XS_XFRLEN(Cmnd) <= 32768) {
seg = 2;
} else if (Cmnd->request_bufflen <= 65536) {
} else if (XS_XFRLEN(Cmnd) <= 65536) {
seg = 3;
} else if (Cmnd->request_bufflen <= 131372) {
} else if (XS_XFRLEN(Cmnd) <= 131372) {
seg = 4;
} else if (Cmnd->request_bufflen <= 262144) {
} else if (XS_XFRLEN(Cmnd) <= 262144) {
seg = 5;
} else if (Cmnd->request_bufflen <= 524288) {
} else if (XS_XFRLEN(Cmnd) <= 524288) {
seg = 6;
} else {
seg = 7;
}
isp->isp_osinfo.bins[seg]++;
rq->req_dl = Cmnd->request_bufflen;
rq->req_dl = XS_XFRLEN(Cmnd);
rq->req_seg_count = 1;
if (Cmnd->sc_data_direction == SCSI_DATA_WRITE) {
rq->req_alen_datadir = FCP_CMND_DATA_WRITE;
@@ -3016,19 +3042,20 @@ isp_pci_2400_dmasetup(ispsoftc_t *isp, Scsi_Cmnd *Cmnd, ispreq_t *orig_rq, uint3
rq->req_alen_datadir = FCP_CMND_DATA_READ;
} else {
isp_prt(isp, ISP_LOGERR, "unknown data direction (%x) for %d byte request (opcode 0x%x)",
Cmnd->sc_data_direction, Cmnd->request_bufflen, Cmnd->cmnd[0]);
Cmnd->sc_data_direction, XS_XFRLEN(Cmnd), Cmnd->cmnd[0]);
XS_SETERR(Cmnd, HBA_BOTCH);
return (CMD_COMPLETE);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
one_shot_addr = (XS_DMA_ADDR_T) 0;
one_shot_length = 0;
if ((segcnt = Cmnd->use_sg) == 0) {
struct isp_pcisoftc *pcs = (struct isp_pcisoftc *) isp;
segcnt = 1;
sg = NULL;
one_shot_length = Cmnd->request_bufflen;
one_shot_addr = pci_map_single(pcs->pci_dev, Cmnd->request_buffer, Cmnd->request_bufflen, scsi_to_pci_dma_dir(Cmnd->sc_data_direction));
one_shot_length = XS_XFRLEN(Cmnd);
one_shot_addr = pci_map_single(pcs->pci_dev, Cmnd->request_buffer, XS_XFRLEN(Cmnd), scsi_to_pci_dma_dir(Cmnd->sc_data_direction));
QLA_HANDLE(Cmnd) = (DMA_HTYPE_T) one_shot_addr;
} else {
struct isp_pcisoftc *pcs = (struct isp_pcisoftc *) isp;
@@ -3041,12 +3068,22 @@ isp_pci_2400_dmasetup(ispsoftc_t *isp, Scsi_Cmnd *Cmnd, ispreq_t *orig_rq, uint3
XS_SETERR(Cmnd, HBA_BOTCH);
return (CMD_EAGAIN);
}
#else
segcnt = scsi_dma_map(Cmnd);
if (segcnt <= 0) {
isp_prt(isp, ISP_LOGWARN, "unable to dma map request");
XS_SETERR(Cmnd, HBA_BOTCH);
return (CMD_EAGAIN);
}
sg = scsi_sglist(Cmnd);
#endif
savesg = sg;
last_synthetic_count = 0;
last_synthetic_addr = 0;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
if (sg) {
length = sg_dma_len(sg);
addr = sg_dma_address(sg);
@@ -3055,6 +3092,11 @@ isp_pci_2400_dmasetup(ispsoftc_t *isp, Scsi_Cmnd *Cmnd, ispreq_t *orig_rq, uint3
length = one_shot_length;
addr = one_shot_addr;
}
#else
length = sg_dma_len(sg);
addr = sg_dma_address(sg);
sg++;
#endif
seg = 1;
rq->req_dataseg.ds_base = LOWD(addr);
@@ -3088,7 +3130,7 @@ isp_pci_2400_dmasetup(ispsoftc_t *isp, Scsi_Cmnd *Cmnd, ispreq_t *orig_rq, uint3
nxti = ISP_NXT_QENTRY((curip), RQUEST_QUEUE_LEN(isp));
if (nxti == optr) {
isp_pci_dmateardown(isp, Cmnd, 0);
isp_prt(isp, ISP_LOGDEBUG0, "%s: Chan %d out of space for continuations (did %d of %d segments)", __FUNCTION__, XS_CHANNEL(Cmnd), seg, segcnt);
isp_prt(isp, ISP_LOGDEBUG0, "%s: Chan %d out of space for continuations (did %d of %d segments)", __func__, XS_CHANNEL(Cmnd), seg, segcnt);
XS_SETERR(Cmnd, HBA_BOTCH);
return (CMD_EAGAIN);
}
@@ -3162,13 +3204,13 @@ mbxsync:
static void
isp_pci_dmateardown(ispsoftc_t *isp, Scsi_Cmnd *Cmnd, uint32_t handle)
{
struct isp_pcisoftc *pcs = (struct isp_pcisoftc *)isp;
#ifdef ISP_TARGET_MODE
/*
* The argument passed may not be a Cmnd pointer- this is the
* safest way to keep the two w/o redoing our internal apis.
*/
if (IS_TARGET_HANDLE(handle)) {
struct isp_pcisoftc *pcs = (struct isp_pcisoftc *)isp;
tmd_xact_t *xact = (tmd_xact_t *) Cmnd;
tmd_cmd_t *tmd = xact? xact->td_cmd : NULL;
int nseg = tmd? tmd->cd_nseg : 0;
@@ -3179,12 +3221,17 @@ isp_pci_dmateardown(ispsoftc_t *isp, Scsi_Cmnd *Cmnd, uint32_t handle)
} else
#endif
if (Cmnd->sc_data_direction != SCSI_DATA_NONE) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
struct isp_pcisoftc *pcs = (struct isp_pcisoftc *)isp;
if (Cmnd->use_sg) {
pci_unmap_sg(pcs->pci_dev, (struct scatterlist *)Cmnd->request_buffer, Cmnd->use_sg, scsi_to_pci_dma_dir(Cmnd->sc_data_direction));
} else if (Cmnd->request_bufflen) {
} else if (XS_XFRLEN(Cmnd)) {
XS_DMA_ADDR_T dhandle = (XS_DMA_ADDR_T) QLA_HANDLE(Cmnd);
pci_unmap_single(pcs->pci_dev, dhandle, Cmnd->request_bufflen, scsi_to_pci_dma_dir(Cmnd->sc_data_direction));
pci_unmap_single(pcs->pci_dev, dhandle, XS_XFRLEN(Cmnd), scsi_to_pci_dma_dir(Cmnd->sc_data_direction));
}
#else
scsi_dma_unmap(Cmnd);
#endif
}
}
@@ -3468,7 +3515,7 @@ isplinux_pci_remove(struct pci_dev *pdev)
isp_deinit_target(isp);
#endif
scsi_host_put(host);
#if !defined(DISABLE_FW_LOADER) && (defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE))
#ifdef CONFIG_FW_LOADER
if (isp->isp_osinfo.fwp) {
release_firmware(isp->isp_osinfo.fwp);
isp->isp_osinfo.fwp = NULL;
@@ -3479,7 +3526,7 @@ isplinux_pci_remove(struct pci_dev *pdev)
static struct pci_driver isplinux_pci_driver = {
.name = ISP_NAME,
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 9)
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)
.driver = {
.owner = THIS_MODULE,
},
@@ -3497,12 +3544,12 @@ isplinux_pci_init(void)
printk(KERN_INFO "Feral Software QLogic SCSI/FC Driver built on %s %s\n", __DATE__, __TIME__);
ret = alloc_chrdev_region(&isp_dev, 0, MAX_ISP, ISP_NAME);
if (ret) {
printk(KERN_ERR "%s: cannot allocate chrdev region\n", __FUNCTION__);
printk(KERN_ERR "%s: cannot allocate chrdev region\n", __func__);
return (ret);
}
cdev_init(&isp_cdev, &isp_ioctl_operations);
if (cdev_add(&isp_cdev, isp_dev, MAX_ISP)) {
printk(KERN_ERR "%s: cannot add cdev\n", __FUNCTION__);
printk(KERN_ERR "%s: cannot add cdev\n", __func__);
kobject_put(&isp_cdev.kobj);
unregister_chrdev_region(isp_dev, MAX_ISP);
return (-EIO);
@@ -3516,7 +3563,7 @@ isplinux_pci_init(void)
}
ret = pci_register_driver(&isplinux_pci_driver);
if (ret < 0) {
printk(KERN_ERR "%s: unable to register driver (return value %d)", __FUNCTION__, ret);
printk(KERN_ERR "%s: unable to register driver (return value %d)", __func__, ret);
unregister_chrdev_region(isp_dev, MAX_ISP);
return (ret);
}

View File

@@ -1295,7 +1295,7 @@ isp_write_proc(struct file *file, const char __user *buf, size_t len, loff_t *of
enum { DISABLE = 0, ENABLE = 1, TEST } action;
int en = -1, res = -EINVAL;
int all_channels = 0, all_luns = 0;
int lun, chan;
int lun = 0, chan = 0;
bus_t *bp = PDE(file->f_dentry->d_inode)->data;
if (bp == NULL || bp->bchan == NULL) {

File diff suppressed because it is too large Load Diff

View File

@@ -1,119 +0,0 @@
/* $Id: scsi_target.h,v 1.30 2008/02/11 23:59:06 mjacob Exp $ */
/*
* Copyright (c) 1997-2008 by Matthew Jacob
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*
* Alternatively, this software may be distributed under the terms of the
* the GNU Public License ("GPL") with platforms where the prevalant license
* is the GNU Public License:
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of The Version 2 GNU General Public License as published
* by the Free Software Foundation.
*
* 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.
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*
* Matthew Jacob
* Feral Software
* 421 Laurel Avenue
* Menlo Park, CA 94025
* USA
*
* gplbsd at feral com
*/
/*
* SCSI Target Control Port
*/
#define SCSI_TARGET "scsi_target"
#define SCSI_TARGET_DEV "/proc/" SCSI_TARGET
/*
* SCSI Target Stub Driver for Linux for a memory or user agent disk device.
* Ioctl Definitions File.
*/
#define _SI ('j' << 8)
/*
* Set new debugging level (get previous) (int argument).
*/
#define SC_DEBUG (_SI | 0)
/*
* Enable/Disable lun
*/
typedef struct {
char hba_name_unit[16]; /* e.g., "isp0" */
uint64_t nbytes; /* disk size, in bytes */
uint16_t lun; /* lun to map it to */
uint8_t channel; /* channel */
uint8_t flags;
} sc_enable_t;
#define SC_EF_OVERCOMMIT 0x01 /* allow overcommit */
#define SC_ENABLE_LUN (_SI | 1)
#define SC_DISABLE_LUN (_SI | 2)
/*
* Overcommit disks have to have data written to backing store
* and read from it.
*/
typedef struct {
char hba_name_unit[16]; /* e.g., "isp0" */
uint16_t lun; /* lun */
uint8_t channel;
uint8_t : 6,
sync : 1, /* (implied) sync after write */
read : 1; /* read (from target to initiator) flag */
void * tag; /* id tag for this command */
void * addr; /* user buffer address */
uint32_t len; /* user buffer length */
uint64_t off; /* disk offset */
uint32_t amt; /* this command's actual data length */
int err; /* from user app */
} sc_io_t;
#define SC_GET_IO (_SI | 3)
#define SC_PUT_IO (_SI | 4)
/*
* Inject a UNIT ATTENTION error on the next command for this device
*/
typedef struct {
char hba_name_unit[16];
} sc_inject_ua_t;
#define SC_INJECT_UA (_SI | 21)
/*
* vim:ts=4:sw=4:expandtab
*/

View File

@@ -1,286 +0,0 @@
/* $Id: scsi_target_ctl.c,v 1.22 2008/02/11 23:59:06 mjacob Exp $ */
/*
* Copyright (c) 1997-2008 by Matthew Jacob
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*
* Alternatively, this software may be distributed under the terms of the
* the GNU Public License ("GPL") with platforms where the prevalant license
* is the GNU Public License:
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of The Version 2 GNU General Public License as published
* by the Free Software Foundation.
*
* 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.
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*
* Matthew Jacob
* Feral Software
* 421 Laurel Avenue
* Menlo Park, CA 94025
* USA
*
* gplbsd at feral com
*/
/*
* SCSI Target Mode "stub" control program for Linux.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdint.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <syslog.h>
#include <sys/ioctl.h>
#include "scsi_target.h"
#define dprintf if (debug) printf
const char usage[] = "usage: %s\n\
scsi_target_ctl debug level\n\
scsi_target_ctl enable hba-name-unit channel lun nbytes [ overcommit-file ]\n\
scsi_target_ctl disable hba-name-unit channel lun\n\
scsi_target_ctl ua hba-name-unit\n";
static uint64_t szarg(char *);
static void ioloop(int, int, char *, uint16_t);
static int debug;
int
main(int a, char **v)
{
union {
sc_enable_t _x;
int _y;
sc_inject_ua_t _u;
} x;
int iofd = -1, fd, action, dd = 0;
char *progname;
if (v) {
progname = v[0];
if (progname == NULL) {
return (1);
}
} else {
return (1);
}
debug = getenv("DEBUG") != NULL;
if (a < 3 || a > 7) {
usage:
fprintf(stderr, usage, progname);
return (1);
}
memset(&x, 0, sizeof (x));
if (strcmp(v[1], "enable") == 0) {
if (a < 6) {
goto usage;
}
action = SC_ENABLE_LUN;
strncpy(x._x.hba_name_unit, v[2], sizeof (x._x.hba_name_unit));
x._x.channel = atoi(v[3]);
x._x.lun = atoi(v[4]);
x._x.nbytes = szarg(v[5]);
if (a == 7) {
iofd = open(v[6], O_RDWR);
if (iofd < 0) {
perror(v[6]);
return (1);
}
dprintf("opened %s to back size 0x%016llx bytes\n", v[6], (unsigned long long) x._x.nbytes);
x._x.flags = SC_EF_OVERCOMMIT;
}
} else if (strcmp(v[1], "disable") == 0) {
if (a != 5) {
goto usage;
}
action = SC_DISABLE_LUN;
strncpy(x._x.hba_name_unit, v[2], sizeof (x._x.hba_name_unit));
x._x.channel = atoi(v[3]);
x._x.lun = atoi(v[4]);
} else if (strcmp(v[1], "debug") == 0) {
if (a != 3) {
goto usage;
}
action = SC_DEBUG;
dd = x._y = atoi(v[2]);
} else if (strcmp(v[1], "ua") == 0) {
if (a != 3) {
goto usage;
}
strncpy(x._u.hba_name_unit, v[2], sizeof (x._u.hba_name_unit));
action = SC_INJECT_UA;
} else {
goto usage;
}
if ((fd = open(SCSI_TARGET_DEV, O_RDWR)) < 0) {
perror(SCSI_TARGET_DEV);
return (1);
}
if (ioctl(fd, action, &x) < 0) {
perror(v[1]);
return (2);
}
if (action == SC_ENABLE_LUN && iofd != -1) {
pid_t p = fork();
if (p == 0) {
(void) close(0);
(void) close(1);
(void) close(2);
ioloop(fd, iofd, x._x.hba_name_unit, x._x.lun);
} else if (p < 0) {
perror("fork");
}
} else if (action == SC_DEBUG) {
printf("old debug level: %d; new debug level %d\n", x._y, dd);
}
return (0);
}
static uint64_t
szarg(char *n)
{
uint64_t result;
char *q = n;
while (isxdigit(*q)) {
q++;
}
result = (uint64_t) strtoull(n, NULL, 0);
if (*q == '\0') {
return (result);
}
if (strcasecmp(q, "kib") == 0) {
result <<= 10;
} else if (strcasecmp(q, "mib") == 0) {
result <<= 20;
} else if (strcasecmp(q, "gib") == 0) {
result <<= 30;
} else if (strcasecmp(q, "tib") == 0) {
result <<= 40;
} else if (strcasecmp(q, "pib") == 0) {
result <<= 50;
} else if (strcasecmp(q, "k") == 0) {
result <<= 10;
} else if (strcasecmp(q, "m") == 0) {
result <<= 20;
} else if (strcasecmp(q, "g") == 0) {
result <<= 30;
} else if (strcasecmp(q, "t") == 0) {
result <<= 40;
} else if (strcasecmp(q, "p") == 0) {
result <<= 50;
} else if (strcasecmp(q, "kb") == 0) {
result *= 1000;
} else if (strcasecmp(q, "mb") == 0) {
result *= 1000000;
} else if (strcasecmp(q, "gb") == 0) {
result *= 1000000000ULL;
} else if (strcasecmp(q, "tb") == 0) {
result *= 1000000000000ULL;
} else if (strcasecmp(q, "pb") == 0) {
result *= 1000000000000000ULL;
}
return (result);
}
static void
ioloop(int fd, int iofd, char *hba, uint16_t lun)
{
sc_io_t sc;
off_t off;
int amt;
void *buffer = valloc(4 << 20);
openlog("scsi_target_ctl", LOG_NDELAY|LOG_PID, LOG_DAEMON);
for (;;) {
memset(&sc, 0, sizeof (sc));
strcpy(sc.hba_name_unit, hba);
sc.lun = lun;
sc.addr = buffer;
sc.len = 4 << 20;
if (ioctl(fd, SC_GET_IO, &sc) < 0) {
if (errno == EINTR || errno == ENOENT) {
continue;
}
syslog(LOG_ERR, "SC_GET_IO returned %s", strerror(errno));
break;
}
off = (off_t) sc.off;
if (lseek(iofd, off, SEEK_SET) != off) {
syslog(LOG_ERR, "lseek error: %s", strerror(errno));
break;
}
if (sc.read) {
amt = read(iofd, sc.addr, sc.amt);
syslog(LOG_DEBUG, "read %8u @ offset 0x%016llx returns %d\n", sc.amt, (unsigned long long)sc.off, amt);
} else {
amt = write(iofd, sc.addr, sc.amt);
syslog(LOG_DEBUG, "write %8u @ offset 0x%016llx returns %d\n", sc.amt, (unsigned long long)sc.off, amt);
if (sc.sync) {
if (fdatasync(iofd) < 0) {
sc.err = errno;
syslog(LOG_ERR, "FDATASYNC: %s", strerror(errno));
}
}
}
if (amt < 0) {
perror(sc.read? "read" : "write");
sc.err = errno;
sc.len = 0;
} else {
sc.len = amt;
}
if (ioctl(fd, SC_PUT_IO, &sc) < 0) {
syslog(LOG_ERR, "SC_PUT_IO: %s", strerror(errno));
break;
}
}
}
/*
* vim:ts=4:sw=4:expandtab
*/