Files
scst/qla_isp/linux/isp_linux.h
Yan Burman e4c7d430c1 Merged revisions 5536-5539,5543,5545,5547,5555,5557-5558,5560-5563,5566-5575,5577-5579,5581-5590,5592-5598,5600-5603,5605-5622,5624-5631,5647-5651,5654,5657-5659,5661-5662 via svnmerge from
svn+ssh://yanb123@svn.code.sf.net/p/scst/svn/trunk

........
  r5536 | vlnb | 2014-05-22 06:06:46 +0300 (Thu, 22 May 2014) | 3 lines
  
  Version changed to 3.1.0-pre1
........
  r5537 | vlnb | 2014-05-22 06:18:27 +0300 (Thu, 22 May 2014) | 3 lines
  
  Web updates
........
  r5538 | bvassche | 2014-05-22 10:16:04 +0300 (Thu, 22 May 2014) | 1 line
  
  nightly build: Update kernel versions
........
  r5539 | vlnb | 2014-05-23 05:20:35 +0300 (Fri, 23 May 2014) | 9 lines
  
  vdisk_nullio: Add "read_zero" attribute
  
  Add an attribute called "read_zero" to vdisk_nullio devices that
  controls whether or not READs from a vdisk_nullio device return
  zeroed data buffers.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5543 | bvassche | 2014-05-23 10:33:53 +0300 (Fri, 23 May 2014) | 1 line
  
  RHEL 7 build fixes
........
  r5545 | bvassche | 2014-05-23 11:36:36 +0300 (Fri, 23 May 2014) | 1 line
  
  scripts/rebuild-rhel-kernel-rpm: Add RHEL 7 RC support
........
  r5547 | vlnb | 2014-05-24 06:10:34 +0300 (Sat, 24 May 2014) | 3 lines
  
  Optimize read_zero functionality
........
  r5555 | bvassche | 2014-05-27 14:59:11 +0300 (Tue, 27 May 2014) | 5 lines
  
  qla2x00t: Documentation / source code comment / log messages spelling fix
  
  Change a few occurrences of "conformation" into "confirmation". See also the
  QLogic 2500 Series Firmware Interface Specification.
........
  r5557 | vlnb | 2014-05-30 03:42:34 +0300 (Fri, 30 May 2014) | 5 lines
  
  Small code reorganization.
  
  No functionality changed
........
  r5558 | vlnb | 2014-05-30 06:00:07 +0300 (Fri, 30 May 2014) | 3 lines
  
  Logging fixes
........
  r5560 | bvassche | 2014-06-02 18:31:50 +0300 (Mon, 02 Jun 2014) | 1 line
  
  Makefile: Only report which RPMs have been built if "make rpm" is run as a non-privileged user
........
  r5561 | bvassche | 2014-06-03 09:04:47 +0300 (Tue, 03 Jun 2014) | 1 line
  
  nightly build: Update kernel versions
........
  r5562 | vlnb | 2014-06-04 04:54:21 +0300 (Wed, 04 Jun 2014) | 3 lines
  
  Decrease max WRITE SAME length for better latencies
........
  r5563 | vlnb | 2014-06-04 05:16:51 +0300 (Wed, 04 Jun 2014) | 3 lines
  
  Enforce limit on max unmap LBAs
........
  r5566 | bvassche | 2014-06-04 18:14:22 +0300 (Wed, 04 Jun 2014) | 1 line
  
  ib_srpt: Fix an error message
........
  r5567 | bvassche | 2014-06-04 18:17:59 +0300 (Wed, 04 Jun 2014) | 1 line
  
  ib_srpt: Avoid triggering a SCSI command timeout after login
........
  r5568 | bvassche | 2014-06-05 09:34:19 +0300 (Thu, 05 Jun 2014) | 1 line
  
  scst_vdisk: Build fix for kernel versions <= 2.6.32
........
  r5569 | bvassche | 2014-06-05 09:46:57 +0300 (Thu, 05 Jun 2014) | 1 line
  
  scst_vdisk: Fix a kernel version < 2.6.38 compiler warning
........
  r5570 | vlnb | 2014-06-06 06:20:26 +0300 (Fri, 06 Jun 2014) | 8 lines
  
  scst_lib: Fix a compiler warning triggered by the WRITE SAME implementation
  
  Avoid for release builds that the compiler reports that the variable
  'ws_sg_cnt' is not used.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5571 | vlnb | 2014-06-06 06:22:14 +0300 (Fri, 06 Jun 2014) | 7 lines
  
  nullio_exec_read(): Fix kunmap() argument
  
  The argument of kunmap() is of type struct page *. Detected by smatch.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5572 | vlnb | 2014-06-06 06:24:03 +0300 (Fri, 06 Jun 2014) | 11 lines
  
  scst: Leave out FSF mail address
  
  This avoids that the following checkpatch complaint is triggered:
  
  Do not include the paragraph about writing to the Free Software Foundation's
  mailing address from the sample GPL notice. The FSF has changed addresses in
  the past, and may do so again. Linux already includes a copy of the GPL.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5573 | vlnb | 2014-06-06 06:26:55 +0300 (Fri, 06 Jun 2014) | 10 lines
  
  scst: Make lockdep_assert_held() easier to use
  
  The lockdep_assert_held() macro is a convenient debugging tool.
  However, it is inconvenient to surround each invocation of that
  macro by an #ifdef/#endif pair. Hence make it easier to use this
  macro with older kernel versions.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5574 | vlnb | 2014-06-07 00:59:24 +0300 (Sat, 07 Jun 2014) | 3 lines
  
  Use limits.discard_zeroes_data to set LBPRZ
........
  r5575 | bvassche | 2014-06-07 13:46:49 +0300 (Sat, 07 Jun 2014) | 1 line
  
  nightly build: Update kernel versions
........
  r5577 | bvassche | 2014-06-10 17:16:14 +0300 (Tue, 10 Jun 2014) | 1 line
  
  ib_srpt: Make the test for IB_EVENT_GID_CHANGE support more robust
........
  r5578 | bvassche | 2014-06-10 17:49:59 +0300 (Tue, 10 Jun 2014) | 1 line
  
  ib_srpt: Make IB_EVENT_GID_CHANGE test independent of the OFED detection code
........
  r5579 | bvassche | 2014-06-11 13:02:15 +0300 (Wed, 11 Jun 2014) | 1 line
  
  ib_srpt: RHEL 5 build fix
........
  r5581 | bvassche | 2014-06-11 18:27:06 +0300 (Wed, 11 Jun 2014) | 1 line
  
  regression tests: Sync with a recent sysfs change
........
  r5582 | bvassche | 2014-06-11 18:27:48 +0300 (Wed, 11 Jun 2014) | 1 line
  
  regression tests: Sort hash keys before comparing
........
  r5583 | bvassche | 2014-06-11 18:41:01 +0300 (Wed, 11 Jun 2014) | 1 line
  
  nightly build: Update kernel versions
........
  r5584 | vlnb | 2014-06-11 22:33:18 +0300 (Wed, 11 Jun 2014) | 8 lines
  
  scst: RHEL 5 build fix
  
  Avoid that building the scst kernel module fails on RHEL 5 due to
  a missing kvasprintf() implementation.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5585 | vlnb | 2014-06-11 22:38:10 +0300 (Wed, 11 Jun 2014) | 11 lines
  
  scst: Remove unused variables
  
  Avoid that building scst with W=1 triggers compiler warnings about
  variables that are set but not used. See also the documentation of
  the gcc compiler flag -Wunused-but-set-variable.
  
  This patch does not change any functionality.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5586 | vlnb | 2014-06-11 22:39:51 +0300 (Wed, 11 Jun 2014) | 9 lines
  
  scst_lib: Introduce additional temporary variables
  
  Make the code slightly easier to read by introducing temporary
  variables for the expressions 'tgt_dev->sess' and 'sess->tgt->tgtt'.
  This patch does not change any functionality.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5587 | vlnb | 2014-06-11 23:57:03 +0300 (Wed, 11 Jun 2014) | 10 lines
  
  scst: Add support for 64-bit LUNs
  
  The datatype of scsi_device.lun will be changed from u32 into u64
  in the near future. Update SCST accordingly. These changes have
  been implemented such that these are compatible with 32-bit and
  64-bit LUNs.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5588 | vlnb | 2014-06-12 00:00:16 +0300 (Thu, 12 Jun 2014) | 9 lines
  
  scst_local: Support LUN numbers >= 16384
  
  Add support for 32-bit LUN numbers. As soon as the patches that add
  64-bit LUN support are upstream this patch will also make 64-bit
  LUN support available in scst_local.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5589 | vlnb | 2014-06-12 00:42:08 +0300 (Thu, 12 Jun 2014) | 8 lines
  
  scst: Clean up __scst_resume_activity()
  
  Move all management commands from scst_delayed_mgmt_cmd_list to the
  active command list during resume instead of only the first one.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5590 | vlnb | 2014-06-12 01:07:00 +0300 (Thu, 12 Jun 2014) | 9 lines
  
  scst: Introduce scst_lookup_tgt_dev()
  
  This patch does not change any functionality.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
  
  with some improvements
........
  r5592 | bvassche | 2014-06-12 11:38:45 +0300 (Thu, 12 Jun 2014) | 7 lines
  
  scst.h: Move definition of swap()
  
  Make sure that the definition of swap() is guarded by
  "#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)" only instead
  of "#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28)" and
  "#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)".
........
  r5593 | bvassche | 2014-06-12 12:15:50 +0300 (Thu, 12 Jun 2014) | 1 line
  
  nightly build: Update kernel versions
........
  r5594 | bvassche | 2014-06-12 14:33:00 +0300 (Thu, 12 Jun 2014) | 1 line
  
  ib_srpt: Set MOFED include path correctly if MOFED has been installed with --add-kernel-support
........
  r5595 | bvassche | 2014-06-12 16:38:38 +0300 (Thu, 12 Jun 2014) | 1 line
  
  ib_srpt: Make non-OFED build work again
........
  r5596 | vlnb | 2014-06-13 07:52:18 +0300 (Fri, 13 Jun 2014) | 16 lines
  
  scst: Switch from the cpu_*() to the cpumask_*() API
  
  The cpus_*() functions were deprecated via patch "cpumask:
  introduce new API, without changing anything" (November 2008,
  commit ID 2d3854a37e8b). Hence switch from the cpus_*() API to
  the cpumask_*() API.
  
  This patch has the intended side effect of not adding the "[key]"
  property to cpumask sysfs attributes that contain the default
  cpumask. The current code namely reads uninitialized bits on
  systems where nr_cpu_ids < NR_CPUS because cpus_equal() compares
  more bits than those that were set by cpumask_copy().
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5597 | vlnb | 2014-06-13 08:03:17 +0300 (Fri, 13 Jun 2014) | 3 lines
  
  Forgotten versions updated
........
  r5598 | bvassche | 2014-06-13 09:55:23 +0300 (Fri, 13 Jun 2014) | 1 line
  
  ib_srpt: Make one_target_per_port the default mode
........
  r5600 | vlnb | 2014-06-14 01:24:06 +0300 (Sat, 14 Jun 2014) | 9 lines
  
  scst: Avoid that W=1 triggers complaints about unused variables
  
  Avoid that building scst with W=1 triggers compiler warnings about
  variables that are set but not used. See also the documentation of
  the gcc compiler flag -Wunused-but-set-variable.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5601 | vlnb | 2014-06-14 01:31:42 +0300 (Sat, 14 Jun 2014) | 8 lines
  
  scst_local: Add close_session() callback function
  
  This is useful for triggering the session reassignment code via
  the scst_local driver.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5602 | vlnb | 2014-06-14 02:57:26 +0300 (Sat, 14 Jun 2014) | 8 lines
  
  scst_pr_read_reservation(): Initialize returned buffer
  
  Avoid that this function returns an uninitialized buffer to the
  initiator if buffer_size < 8. Detected by Coverity.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5603 | vlnb | 2014-06-14 02:58:28 +0300 (Sat, 14 Jun 2014) | 5 lines
  
  scst: Help Coverity recognize that vmalloc(0) returns NULL
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5605 | bvassche | 2014-06-14 20:10:58 +0300 (Sat, 14 Jun 2014) | 1 line
  
  fcst: Remove an unused variable
........
  r5606 | bvassche | 2014-06-14 20:17:56 +0300 (Sat, 14 Jun 2014) | 5 lines
  
  fcst: Move exch_done() calls into ft_cmd_done()
  
  This patch ensures that exch_done() gets called if an fcst
  callback returns SCST_TGT_RES_FATAL_ERROR.
........
  r5607 | bvassche | 2014-06-14 20:18:34 +0300 (Sat, 14 Jun 2014) | 10 lines
  
  fcst: Handle frame send failures properly
  
  Retry sending XFER_RDY, data and response frames if the network
  driver reports that sending failed (-ENOMEM) instead of reporting
  a kernel warning (WARN_ON(1)). If sending XFER_RDY or data frames
  failed for another reason, report this to the initiator as a
  write error (ASC = 03; ASCQ = 00 which stands for PERIPHERAL
  DEVICE WRITE FAULT). If sending a response frame failed with
  another error code than -ENOMEM, do not send a response.
........
  r5608 | vlnb | 2014-06-17 03:50:46 +0300 (Tue, 17 Jun 2014) | 10 lines
  
  scst: Make access control group removal behavior configurable
  
  SCST rejects removal of an access control group with one or more
  sessions with error code -EBUSY. Make it easy to change this
  behavior into forcibly closing sessions when an access control
  group is removed.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5609 | bvassche | 2014-06-17 09:37:08 +0300 (Tue, 17 Jun 2014) | 1 line
  
  nightly build: Update kernel versions
........
  r5610 | vlnb | 2014-06-19 06:51:48 +0300 (Thu, 19 Jun 2014) | 3 lines
  
  Update for 3.15 kernels
........
  r5611 | bvassche | 2014-06-19 10:09:53 +0300 (Thu, 19 Jun 2014) | 1 line
  
  nightly build: Add kernel 3.15 build infrastructure
........
  r5612 | bvassche | 2014-06-19 15:48:25 +0300 (Thu, 19 Jun 2014) | 1 line
  
  kernel module installation: Skip "depmod" when building an RPM
........
  r5613 | vlnb | 2014-06-20 07:00:41 +0300 (Fri, 20 Jun 2014) | 8 lines
  
  scst: Convert a loop to keep smatch happy
  
  Avoid that smatch reports the following warning:
  scst_init_session() info: loop could be replaced with if statement.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5614 | vlnb | 2014-06-20 07:02:00 +0300 (Fri, 20 Jun 2014) | 13 lines
  
  iscsi-scst: Suppress a compiler warning
  
  Avoid that the following compiler warning is reported when compiling
  iscsi-scst:
  
  chap.c: In function 'chap_rand':
  chap.c:348:5: warning: ignoring return value of 'read', declared with attribute warn_unused_result [-Wunused-result]
       (void)read(fd, &r, sizeof(r));
       ^
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5615 | vlnb | 2014-06-20 07:03:40 +0300 (Fri, 20 Jun 2014) | 5 lines
  
  scst, iscsi-scst: Fix RHEL 5 compilation warnings
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5616 | vlnb | 2014-06-20 07:05:11 +0300 (Fri, 20 Jun 2014) | 10 lines
  
  scst: Exclude certain locking code from static analysis
  
  Loops with locking statements and also lock and unlock
  statements guarded by an if-statement trigger false positive
  warnings when analyzing the SCST code with smatch and/or sparse.
  Hence exclude such code from static analysis.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5617 | vlnb | 2014-06-20 07:09:11 +0300 (Fri, 20 Jun 2014) | 10 lines
  
  scst: Avoid that sparse complains about unreachable code
  
  Remove the code after BUG() statements to avoid that smatch
  complains about unreachable code. Hide the spin_unlock() statements
  before BUG() statements for static analysis tools to avoid that
  sparse complains about locking imbalances.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5618 | vlnb | 2014-06-20 07:10:40 +0300 (Fri, 20 Jun 2014) | 12 lines
  
  Change BUG_ON(1) into BUG()
  
  With CONFIG_BUG=y both BUG() and BUG_ON(1) halt the system. However,
  with CONFIG_BUG=n BUG() halts the system but BUG_ON(1) not. To avoid
  such subtleties, change BUG_ON(1) into BUG().
  
  See also patch Josh Triplett, "bug: Make BUG() always stop the machine",
  7 April 2014 (commit ID a4b5d580e07875f9be29f62a57c67fbbdbb40ba2).
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5619 | bvassche | 2014-06-20 08:56:36 +0300 (Fri, 20 Jun 2014) | 1 line
  
  nightly build: Add kernel version 3.15.1
........
  r5620 | vlnb | 2014-06-24 07:45:08 +0300 (Tue, 24 Jun 2014) | 9 lines
  
  scst_vdisk: Split vdisk_exec_inquiry()
  
  Make vdisk_exec_inquiry() easier to read by moving the code
  for the implementation of each VPD page into a separate function.
  This patch does not change any functionality.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5621 | bvassche | 2014-06-24 16:32:18 +0300 (Tue, 24 Jun 2014) | 1 line
  
  ib_srpt: Complain if another ib_srpt.ko kernel module already exists
........
  r5622 | bvassche | 2014-06-24 16:33:23 +0300 (Tue, 24 Jun 2014) | 2 lines
  
  ib_srpt: Set SCSI residual fields in SRP_CMD reply
........
  r5624 | bvassche | 2014-06-25 14:50:40 +0300 (Wed, 25 Jun 2014) | 1 line
  
  nightly build: Use http instead of ftp for downloading kernel source code
........
  r5625 | vlnb | 2014-06-26 00:38:19 +0300 (Thu, 26 Jun 2014) | 5 lines
  
  scst_debug.h: Make EXTRACHECKS_*_ON() statements visible to Coverity
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5626 | vlnb | 2014-06-27 02:26:25 +0300 (Fri, 27 Jun 2014) | 10 lines
  
  scst_vdisk: Three more put_unaligned_*() conversions
  
  Convert three more *(__be16 *)p = cpu_to_be16(v) statements into
  put_unaligned_be16(v, p) since the latter is easier to read. Also
  convert one "cmd->dev" into "dev" expression. This patch does not
  change any functionality.
  
  Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
  r5627 | bvassche | 2014-06-27 13:32:02 +0300 (Fri, 27 Jun 2014) | 1 line
  
  nightly build: Update kernel versions
........
  r5628 | bvassche | 2014-06-28 22:56:36 +0300 (Sat, 28 Jun 2014) | 1 line
  
  ib_srpt: Remove existing ib_srpt.ko kernel modules before installation
........
  r5629 | bvassche | 2014-06-28 22:58:44 +0300 (Sat, 28 Jun 2014) | 6 lines
  
  scst_vdisk: Fix 32-bit build
  
  Avoid 64-bit modulo computations since these result in undefined symbol
  errors on 32-bit systems (__moddi3 / __umoddi3). Support sizes >= 2**32
  bytes on 32-bit systems.
........
  r5630 | bvassche | 2014-06-28 23:00:22 +0300 (Sat, 28 Jun 2014) | 1 line
  
  scst.spec.in: Follow-up for r5628
........
  r5631 | bvassche | 2014-06-28 23:15:45 +0300 (Sat, 28 Jun 2014) | 1 line
  
  scst_local: Avoid that session deletion triggers a kernel warning
........
  r5647 | bvassche | 2014-06-30 10:18:53 +0300 (Mon, 30 Jun 2014) | 1 line
  
  scst: Build fix for Linux kernel versions 2.6.33 and 2.6.34
........
  r5648 | bvassche | 2014-06-30 10:28:18 +0300 (Mon, 30 Jun 2014) | 1 line
  
  scst: Build fix for kernel versions <= 2.6.31
........
  r5649 | bvassche | 2014-06-30 11:40:23 +0300 (Mon, 30 Jun 2014) | 6 lines
  
  scst_vdisk: Fix a checkpatch warning
  
  Address the following checkpatch warning:
  
  char * array declaration might be better as static const
........
  r5650 | bvassche | 2014-06-30 11:52:06 +0300 (Mon, 30 Jun 2014) | 1 line
  
  nightly build: Correct a kernel version
........
  r5651 | bvassche | 2014-06-30 12:18:41 +0300 (Mon, 30 Jun 2014) | 1 line
  
  nightly build: Correct a kernel version
........
  r5654 | bvassche | 2014-07-01 09:38:13 +0300 (Tue, 01 Jul 2014) | 6 lines
  
  scst_vdisk: Fix a checkpatch warning
  
  Avoid that checkpatch reports the following warning:
  
  WARNING: static const char * array should probably be static const char * const
........
  r5657 | bvassche | 2014-07-01 19:46:12 +0300 (Tue, 01 Jul 2014) | 1 line
  
  nightly build: Update kernel versions
........
  r5658 | bvassche | 2014-07-03 11:36:48 +0300 (Thu, 03 Jul 2014) | 1 line
  
  scripts/kernel-functions: Handle 3.x.0 kernel versions correctly
........
  r5659 | bvassche | 2014-07-03 11:42:08 +0300 (Thu, 03 Jul 2014) | 1 line
  
  scripts/generate-patched-kernel: Clean up
........
  r5661 | bvassche | 2014-07-04 08:39:28 +0300 (Fri, 04 Jul 2014) | 1 line
  
  Make scripts/kernel-functions again compatible with 2.6.x kernels
........
  r5662 | bvassche | 2014-07-06 11:02:28 +0300 (Sun, 06 Jul 2014) | 1 line
  
  scripts/run-regression-tests: Add command-line option -4 (disable IPv6)
........


git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/iser@5666 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2014-07-07 10:36:05 +00:00

978 lines
30 KiB
C

/* $Id: isp_linux.h,v 1.176 2009/09/06 00:37:07 mjacob Exp $ */
/*
* Copyright (c) 1997-2009 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.
*
*
* Matthew Jacob
* Feral Software
* 421 Laurel Avenue
* Menlo Park, CA 94025
* USA
*
* gplbsd at feral com
*/
/*
* Qlogic ISP SCSI Host Adapter Linux Wrapper Definitions
*/
#ifndef _ISP_LINUX_H
#define _ISP_LINUX_H
#ifndef ISP_MODULE
#define __NO_VERSION__
#endif
#ifdef MODULE
#define EXPORT_SYMTAB 1
#endif
#include <linux/version.h>
#ifndef KERNEL_VERSION
#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)
#error "Only Linux 2.5/2.6 kernels are supported with this driver"
#endif
#ifndef UNUSED_PARAMETER
#define UNUSED_PARAMETER(x) (void) x
#endif
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 32)
#include <linux/autoconf.h>
#else
#include <generated/autoconf.h>
#endif
#ifdef CONFIG_SMP
#define __SMP__ 1
#endif
#include <linux/module.h>
#include <linux/init.h>
#include <linux/types.h>
#include <linux/blkdev.h>
#include <linux/delay.h>
#include <linux/ioport.h>
#include <linux/mm.h>
#include <linux/vmalloc.h>
#include <linux/sched.h>
#include <linux/kthread.h>
#include <linux/stat.h>
#include <linux/pci.h>
#include <asm/dma.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <linux/smp.h>
#include <linux/spinlock.h>
#include <asm/system.h>
#include <asm/uaccess.h>
#include <asm/byteorder.h>
#include <linux/interrupt.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_tcq.h>
#include <scsi/scsi_device.h>
#include <linux/cdev.h>
#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))
#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));
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
#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));
#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), NULL, "%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;
typedef struct scsi_request Scsi_Request;
typedef struct scsi_host_template Scsi_Host_Template;
#ifdef CONFIG_PROC_FS
#include <linux/proc_fs.h>
#endif
/*
* Efficiency- get rid of SBus code && tests unless we need them.
*/
#if defined(__sparcv9__ ) || defined(__sparc__)
#define ISP_SBUS_SUPPORTED 1
#else
#define ISP_SBUS_SUPPORTED 0
#endif
#define ISP_PLATFORM_VERSION_MAJOR 6
#define ISP_PLATFORM_VERSION_MINOR 1
#ifndef ISP_NAME
#define ISP_NAME "isp"
#endif
#ifndef BIG_ENDIAN
#define BIG_ENDIAN 4321
#endif
#ifndef LITTLE_ENDIAN
#define LITTLE_ENDIAN 1234
#endif
#ifdef __BIG_ENDIAN
#define BYTE_ORDER BIG_ENDIAN
#endif
#ifdef __LITTLE_ENDIAN
#define BYTE_ORDER LITTLE_ENDIAN
#endif
#ifndef __WORDSIZE
#define __WORDSIZE BITS_PER_LONG
#endif
#define DMA_HTYPE_T dma_addr_t
#define QLA_HANDLE(cmd) (cmd)->SCp.dma_handle
#ifdef min
#undef min
#endif
#ifdef max
#undef max
#endif
#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
/*
* Normally this should be taken care of by typedefs,
* but linux includes are a complete dog's breakfast.
*/
#define uint8_t u8
#define uint16_t u16
#define uint32_t u32
#define uint64_t u64
#define int8_t char
#define int16_t short
#define int32_t int
#define u_long unsigned long
#define uint unsigned int
#define u_char unsigned char
typedef u_long vm_offset_t;
/* bit map using 8 bit arrays */
typedef uint8_t isp_bmap_t;
#define _ISP_WIX(isp, ix) (ix >> 3)
#define _ISP_BIX(isp, ix) (1 << (ix & 0x7))
#define ISP_NBPIDX(x) ((x + 7) / 8) /* index width from bits */
#define ISP_BTST(map, ix) (((map)[_ISP_WIX(isp, ix)] & _ISP_BIX(isp, ix)) != 0)
#define ISP_BSET(map, ix) (map)[_ISP_WIX(isp, ix)] |= _ISP_BIX(isp, ix)
#define ISP_BCLR(map, ix) (map)[_ISP_WIX(isp, ix)] &= ~_ISP_BIX(isp, ix)
#ifdef ISP_TARGET_MODE
#include "isp_tpublic.h"
#ifndef DEFAULT_DEVICE_TYPE
#define DEFAULT_DEVICE_TYPE 0
#endif
#define NTGT_CMDS 1024
#define N_NOTIFIES 256
#define DEFAULT_INQSIZE 32
typedef struct notify notify_t;
#define cd_action cd_lreserved[0].shorts[0]
#define cd_oxid cd_lreserved[0].shorts[1]
#define cd_lflags cd_lreserved[0].shorts[2]
#define cd_nphdl cd_lreserved[0].shorts[3]
#define cd_nseg cd_lreserved[1].longs[0]
#define cd_portid cd_lreserved[1].longs[1]
#define cd_next cd_lreserved[2].ptrs[0]
#define cd_lastoff cd_lreserved[3].longs[0]
#define cd_lastsize cd_lreserved[3].longs[1]
#define CDFL_LCL 0x8000
#define CDFL_RESRC_FILL 0x4000
#define CDFL_ABORTED 0x2000
#define CDFL_NEED_CLNUP 0x1000
#define CDFL_BUSY 0x0800
typedef struct enalun tgt_enalun_t;
struct enalun {
tgt_enalun_t * next;
uint16_t lun;
uint16_t bus;
};
typedef struct {
struct scatterlist sg;
tmd_xact_t xact;
} tgt_auxcmd_t;
#define N_TGT_AUX 32
#define ISP_CT_TIMEOUT 120
#endif /* ISP_TARGET_MODE */
typedef struct isp_thread_action isp_thread_action_t;
struct isp_thread_action {
isp_thread_action_t *next;
enum {
ISP_THREAD_NIL=1,
ISP_THREAD_FC_RESCAN,
ISP_THREAD_REINIT,
ISP_THREAD_FW_CRASH_DUMP,
ISP_THREAD_LOGOUT,
ISP_THREAD_FINDIID,
ISP_THREAD_FINDPORTID,
ISP_THREAD_TERMINATE,
ISP_THREAD_RESTART_AT7,
ISP_THREAD_FC_PUTBACK,
ISP_THREAD_SCSI_SCAN,
} thread_action;
void * arg;
wait_queue_head_t thread_waiter;
uint32_t
waiting : 1,
done : 1,
count : 30;
};
#define MAX_THREAD_ACTION 128
#define MAX_FC_CHAN 128
#define ISP_HOST2ISP(host) (ispsoftc_t *) host->hostdata
struct isposinfo {
struct Scsi_Host * host;
unsigned int device_id;
u32 mcorig; /* original maxcmds */
void *device; /* hardware device structure */
Scsi_Cmnd *wqnext, *wqtail;
Scsi_Cmnd *dqnext, *dqtail;
void * storep;
size_t storep_amt;
size_t param_amt;
const struct firmware *fwp;
#ifdef CONFIG_PROC_FS
struct proc_dir_entry *pdp;
#endif
char hbaname[16];
long bins[8];
u16 wqcnt;
u16 wqhiwater;
u16 hiwater;
struct timer_list timer;
struct semaphore mbox_sem;
wait_queue_head_t mboxwq;
struct semaphore mbox_c_sem;
spinlock_t slock;
uint32_t
dogcnt : 5,
isopen : 1,
is_64bit_dma : 1,
dogactive : 1,
mboxcmd_done : 1,
mbintsok : 1,
intsok : 1;
u16 scan_timeout;
u16 rescan_timeout;
u16 frame_size;
u16 exec_throttle;
struct task_struct *thread_task;
wait_queue_head_t trq;
spinlock_t tlock;
isp_thread_action_t t_actions[MAX_THREAD_ACTION];
isp_thread_action_t *t_free;
isp_thread_action_t *t_busy, *t_busy_t;
#ifdef ISP_TARGET_MODE
u32 isget : 16,
rstatus : 8,
: 7,
hcb : 1;
struct semaphore tgt_inisem;
struct semaphore * rsemap;
tgt_enalun_t * luns; /* enabled { lun, port } tuples */
struct tmd_cmd * pending_t; /* pending list of commands going upstream */
struct tmd_cmd * waiting_t; /* pending list of commands waiting to be fleshed out */
struct tmd_cmd * tfreelist; /* freelist head */
struct tmd_cmd * bfreelist; /* freelist tail */
struct tmd_cmd * pool; /* pool itself */
notify_t * pending_n; /* pending list of notifies going upstream */
notify_t * nfreelist; /* freelist */
notify_t * npool; /* pool itself */
struct tmd_xact * pending_x; /* pending list of xacts going upstream */
/*
* When we have inquiry commands that we have to xfer data with
* locally we have to have some aux info (scatterlist, tmd_xact_t)
* to manage those commands.
*/
tgt_auxcmd_t auxinfo[N_TGT_AUX];
isp_bmap_t auxbmap[ISP_NBPIDX(N_TGT_AUX)];
u8 inqdata[DEFAULT_INQSIZE];
u64 cmds_started;
u64 cmds_completed;
unsigned long out_of_tmds;
#endif
};
#define mbtimer isp_osinfo.mbtimer
#define dogactive isp_osinfo.dogactive
#define mbintsok isp_osinfo.mbintsok
#define intsok isp_osinfo.intsok
#define mbox_waiting isp_osinfo.mbox_waiting
#define mboxcmd_done isp_osinfo.mboxcmd_done
#define isp_isopen isp_osinfo.isopen
/*
* Locking macros...
*/
#define ISP_LOCK_INIT(isp) spin_lock_init(&isp->isp_osinfo.slock)
#define ISP_LOCK_SOFTC(isp) spin_lock_irqsave(&isp->isp_osinfo.slock, flags)
#define ISP_UNLK_SOFTC(isp) spin_unlock_irqrestore(&isp->isp_osinfo.slock, flags)
#define ISP_ILOCK_SOFTC ISP_LOCK_SOFTC
#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_LOCKU_SOFTC ISP_ILOCK_SOFTC
#define ISP_UNLKU_SOFTC ISP_IUNLK_SOFTC
#define ISP_TLOCK_INIT(isp) spin_lock_init(&isp->isp_osinfo.tlock)
#define ISP_DRIVER_ENTRY_LOCK(isp) spin_unlock_irq(isp->isp_osinfo.host->host_lock)
#define ISP_DRIVER_EXIT_LOCK(isp) spin_lock_irq(isp->isp_osinfo.host->host_lock)
#define ISP_DRIVER_CTL_ENTRY_LOCK(isp) do { } while (0)
#define ISP_DRIVER_CTL_EXIT_LOCK(isp) do { } while (0)
#define ISP_MUST_POLL(isp) (in_interrupt() || isp->mbintsok == 0)
/*
* Required Macros/Defines
*/
#define ISP_FC_SCRLEN 0x1000
#define ISP_MEMZERO(b, a) memset(b, 0, a)
#define ISP_MEMCPY memcpy
#define ISP_SNPRINTF snprintf
#define ISP_DELAY _isp_usec_delay
#define ISP_SLEEP(isp, x) \
ISP_DROP_LK_SOFTC(isp); \
__set_current_state(TASK_UNINTERRUPTIBLE); \
(void) schedule_timeout(_usec_to_jiffies(x)); \
ISP_IGET_LK_SOFTC(isp)
#define ISP_INLINE inline
#define NANOTIME_T struct timeval
/* for prior to 2.2.19, use do_gettimeofday, and, well, it'll be inaccurate */
#define GET_NANOTIME(ptr) (ptr)->tv_sec = 0, (ptr)->tv_usec = 0, do_gettimeofday(ptr)
#define GET_NANOSEC(x) ((uint64_t) ((((uint64_t)(x)->tv_sec) * 1000000 + (x)->tv_usec)))
#define NANOTIME_SUB _isp_microtime_sub
#define MAXISPREQUEST(isp) (IS_24XX(isp)? 2048 : ((IS_FC(isp) || IS_ULTRA2(isp))? 1024 : 256))
#if defined(__powerpc__)
#define MEMORYBARRIER(isp, type, offset, size) __asm__ __volatile__("eieio" ::: "memory")
#else
# ifdef mb
# define MEMORYBARRIER(isp, type, offset, size) mb()
# else
# define MEMORYBARRIER(isp, type, offset, size) barrier()
# endif
#endif
#define MBOX_ACQUIRE(isp) down_trylock(&isp->isp_osinfo.mbox_sem)
#define MBOX_WAIT_COMPLETE mbox_wait_complete
#define MBOX_NOTIFY_COMPLETE(isp) \
wake_up(&isp->isp_osinfo.mboxwq); \
isp->mboxcmd_done = 1
#define MBOX_RELEASE(isp) up(&isp->isp_osinfo.mbox_sem)
#define FC_SCRATCH_ACQUIRE fc_scratch_acquire
#define FC_SCRATCH_RELEASE(isp, chan) ISP_DATA(isp, chan)->scratch_busy = 0
#ifndef SCSI_GOOD
#define SCSI_GOOD 0x0
#endif
#ifndef SCSI_CHECK
#define SCSI_CHECK 0x2
#endif
#ifndef SCSI_BUSY
#define SCSI_BUSY 0x8
#endif
#ifndef SCSI_QFULL
#define SCSI_QFULL 0x28
#endif
#ifndef REPORT_LUNS
#define REPORT_LUNS 0xa0
#endif
#define XS_T Scsi_Cmnd
#define XS_DMA_ADDR_T dma_addr_t
#define XS_GET_DMA64_SEG isp_get_dma64_seg
#define XS_GET_DMA_SEG isp_get_dma_seg
#define XS_HOST(Cmnd) Cmnd->device->host
#define XS_CHANNEL(Cmnd) (Cmnd)->device->channel
#define XS_TGT(Cmnd) (Cmnd)->device->id
#define XS_LUN(Cmnd) (Cmnd)->device->lun
#define SCSI_DATA_NONE DMA_NONE
#define SCSI_DATA_READ DMA_FROM_DEVICE
#define SCSI_DATA_WRITE DMA_TO_DEVICE
#define scsi_to_pci_dma_dir(x) x
#define XS_ISP(Cmnd) ((ispsoftc_t *)XS_HOST(Cmnd)->hostdata)
#define XS_CDBP(Cmnd) (Cmnd)->cmnd
#define XS_CDBLEN(Cmnd) (Cmnd)->cmd_len
#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
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
#define XS_TIME(Cmnd) ((((Cmnd)->timeout_per_command) * HZ)*1000)
#else
#define XS_TIME(Cmnd) ((((Cmnd)->request->timeout) * HZ)*1000)
#endif
#define XS_STSP(Cmnd) (&(Cmnd)->SCp.Status)
#define XS_SNSP(Cmnd) (Cmnd)->sense_buffer
#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
#define XS_SETERR(xs, v) \
if ((v) == HBA_TGTBSY) { \
(xs)->SCp.Status = SCSI_BUSY; \
} else { \
(xs)->result &= ~0xff0000; \
(xs)->result |= ((v) << 16); \
}
#define HBA_NOERROR DID_OK
#define HBA_BOTCH DID_ERROR
#define HBA_CMDTIMEOUT DID_TIME_OUT
#define HBA_SELTIMEOUT DID_NO_CONNECT
#define HBA_TGTBSY 123456 /* special handling */
#define HBA_BUSRESET DID_RESET
#define HBA_ABORTED DID_ABORT
#define HBA_DATAOVR DID_ERROR
#define HBA_ARQFAIL DID_ERROR
#define XS_ERR(xs) host_byte((xs)->result)
#define XS_NOERR(xs) host_byte((xs)->result) == DID_OK
#define XS_INITERR(xs) (xs)->result = 0, (xs)->SCp.Status = 0
#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)
#define GET_DEFAULT_ROLE isplinux_get_default_role
#define SET_DEFAULT_ROLE isplinux_set_default_role
#define DEFAULT_IID isplinux_get_default_id
#define DEFAULT_LOOPID isplinux_get_default_id
#define DEFAULT_FRAMESIZE(isp) isp->isp_osinfo.frame_size
#define DEFAULT_EXEC_THROTTLE(isp) isp->isp_osinfo.exec_throttle
#define DEFAULT_NODEWWN(isp, chan) isplinux_default_wwn(isp, chan, 0, 1)
#define DEFAULT_PORTWWN(isp, chan) isplinux_default_wwn(isp, chan, 0, 0)
#define ACTIVE_NODEWWN(isp, chan) isplinux_default_wwn(isp, chan, 1, 1)
#define ACTIVE_PORTWWN(isp, chan) isplinux_default_wwn(isp, chan, 1, 0)
#define ISP_IOXPUT_8(isp, s, d) *(d) = s
#define ISP_IOXPUT_16(isp, s, d) *(d) = cpu_to_le16(s)
#define ISP_IOXPUT_32(isp, s, d) *(d) = cpu_to_le32(s)
#define ISP_IOXGET_8(isp, s, d) d = *(s)
#define ISP_IOXGET_16(isp, s, d) d = le16_to_cpu(*((uint16_t *)s))
#define ISP_IOXGET_32(isp, s, d) d = le32_to_cpu(*((uint32_t *)s))
#if BYTE_ORDER == BIG_ENDIAN
#define ISP_IOX_8X2(isp, sptr, dptr, tag1, tag2) \
dptr ## -> ## tag1 = sptr ## -> ## tag2; \
dptr ## -> ## tag2 = sptr ## -> ## tag1
#define ISP_IOZ_8X2(isp, sptr, dptr, tag1, tag2) \
dptr ## -> ## tag1 = sptr ## -> ## tag1; \
dptr ## -> ## tag2 = sptr ## -> ## tag2
#else
#define ISP_IOX_8X2(isp, sptr, dptr, tag1, tag2) \
dptr ## -> ## tag1 = sptr ## -> ## tag1; \
dptr ## -> ## tag2 = sptr ## -> ## tag2
#define ISP_IOZ_8X2(isp, sptr, dptr, tag1, tag2) \
dptr ## -> ## tag1 = sptr ## -> ## tag2; \
dptr ## -> ## tag2 = sptr ## -> ## tag1
#endif
#define ISP_IOZPUT_8 ISP_IOXPUT_8
#define ISP_IOZPUT_16(isp, s, d) *(d) = cpu_to_be16(s)
#define ISP_IOZPUT_32(isp, s, d) *(d) = cpu_to_be32(s)
#define ISP_IOZGET_8 ISP_IOXGET_8
#define ISP_IOZGET_16(isp, s, d) d = be16_to_cpu(*((uint16_t *)s))
#define ISP_IOZGET_32(isp, s, d) d = be32_to_cpu(*((uint32_t *)s))
#define ISP_SWIZZLE_NVRAM_WORD(isp, rp) *rp = le16_to_cpu(*rp)
#define ISP_SWIZZLE_NVRAM_LONG(isp, rp) *rp = le32_to_cpu(*rp)
#define ISP_SWAP16(isp, x) swab16(x)
#define ISP_SWAP32(isp, x) swab32(x)
/*
* Includes of common header files
*/
#include "ispreg.h"
#include "ispvar.h"
#if defined(__GNUC__) || defined(__INTEL_COMPILER)
void isp_prt(ispsoftc_t *, int level, const char *, ...) __attribute__((__format__(__printf__, 3, 4)));
#else
void isp_prt(ispsoftc_t *, int level, const char *, ...);
#endif
/*
* isp_osinfo definitions, extensions and shorthand.
*/
/*
* Parameter and platform per-channel storage.
*/
typedef struct {
uint64_t def_wwnn;
uint64_t def_wwpn;
uint32_t
tgts_tested : 16,
: 11,
scratch_busy : 1,
blocked : 1,
deadloop : 1,
role : 2;
unsigned long downcount, nextscan;
unsigned int qfdelay;
} isp_data;
#define ISP_DATA(isp, chan) (&((isp_data *)((isp)->isp_osinfo.storep))[chan])
#define isp_name isp_osinfo.hbaname
#define isp_host isp_osinfo.host
#define isp_unit isp_osinfo.host->unique_id
/*
* Driver prototypes..
*/
void isplinux_timer(unsigned long);
void isplinux_mbtimer(unsigned long);
#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 *);
#endif
int isplinux_common_init(ispsoftc_t *);
#ifdef CONFIG_PROC_FS
void isplinux_init_proc(ispsoftc_t *);
void isplinux_undo_proc(ispsoftc_t *);
#endif
int isplinux_reinit(ispsoftc_t *, int);
void isplinux_sqd(struct Scsi_Host *, struct scsi_device *);
int isp_thread_event(ispsoftc_t *, int, void *, int, const char *, const int line);
static ISP_INLINE uint64_t _isp_microtime_sub(struct timeval *, struct timeval *);
static ISP_INLINE void _isp_usec_delay(unsigned int);
static ISP_INLINE unsigned long _usec_to_jiffies(unsigned int);
static ISP_INLINE unsigned long _jiffies_to_usec(unsigned long);
static ISP_INLINE int isplinux_tagtype(Scsi_Cmnd *);
static ISP_INLINE void mbox_wait_complete(ispsoftc_t *, mbreg_t *);
int isplinux_proc_info(struct Scsi_Host *, char *, char **, off_t, int, int);
const char *isplinux_info(struct Scsi_Host *);
int isplinux_queuecommand(Scsi_Cmnd *, void (* done)(Scsi_Cmnd *));
int isplinux_biosparam(struct scsi_device *, struct block_device *, sector_t, int[]);
int isplinux_get_default_id(ispsoftc_t *, int);
int isplinux_get_default_role(ispsoftc_t *, int);
void isplinux_set_default_role(ispsoftc_t *, int, int);
uint64_t isplinux_default_wwn(ispsoftc_t *, int, int, int);
/*
* Driver wide data...
*/
extern int isp_debug;
extern int isp_unit_seed;
extern int isp_disable;
extern int isp_nofwreload;
extern int isp_nonvram;
extern int isp_fcduplex;
extern int isp_maxsectors;
extern struct scsi_host_template *isp_template;
extern const char *class3_roles[4];
extern int isp_vports;
extern dev_t isp_dev;
extern struct cdev isp_cdev;
extern struct file_operations isp_ioctl_operations;
extern ISP_CLASS *isp_class;
/*
* This used to be considered bad form, but locking crap made it more attractive.
*/
#define MAX_ISP 32
extern ispsoftc_t *isplist[MAX_ISP];
extern ispsoftc_t *api_isp;
extern int api_channel;
/*
* Platform private flags
*/
#ifndef NULL
#define NULL ((void *) 0)
#endif
#define ISP_WATCH_TPS 10
#define ISP_WATCH_TIME (HZ / ISP_WATCH_TPS)
#define ISP_SCAN_TIMEOUT (2 * ISP_WATCH_TPS)
#define ISP_RESCAN_TIMEOUT ISP_WATCH_TPS
#ifndef min
#define min(a,b) (((a)<(b))?(a):(b))
#endif
#ifndef max
#define max(a, b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef roundup
#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
#endif
/*
* Platform specific 'inline' or support functions
*/
#ifdef __sparc__
#define _SBSWAP(isp, b, c) \
if (isp->isp_bustype == ISP_BT_SBUS) { \
uint8_t tmp = b; \
b = c; \
c = tmp; \
}
#else
#define _SBSWAP(a, b, c)
#endif
static ISP_INLINE uint64_t
_isp_microtime_sub(struct timeval *b, struct timeval *a)
{
uint64_t elapsed;
struct timeval x = *b;
x.tv_sec -= a->tv_sec;
x.tv_usec -= a->tv_usec;
if (x.tv_usec < 0) {
x.tv_sec--;
x.tv_usec += 1000000;
}
if (x.tv_usec >= 1000000) {
x.tv_sec++;
x.tv_usec -= 1000000;
}
elapsed = GET_NANOSEC(&x);
if (elapsed == 0)
elapsed++;
if ((int64_t) elapsed < 0) /* !!!! */
return (1000);
return (elapsed * 1000);
}
static ISP_INLINE void
_isp_usec_delay(unsigned int usecs)
{
while (usecs > 1000) {
mdelay(1);
usecs -= 1000;
}
if (usecs)
udelay(usecs);
}
static ISP_INLINE unsigned long
_usec_to_jiffies(unsigned int usecs)
{
struct timespec lt;
if (usecs == 0)
usecs++;
lt.tv_sec = 0;
lt.tv_nsec = usecs * 1000;
return (timespec_to_jiffies(&lt));
}
static ISP_INLINE unsigned long
_jiffies_to_usec(unsigned long jiffies)
{
unsigned long usecs;
struct timespec lt;
jiffies++;
jiffies_to_timespec((unsigned long) jiffies, &lt);
usecs = (lt.tv_sec * 1000000L);
usecs += (lt.tv_nsec * 1000);
return (usecs);
}
#ifndef MSG_SIMPLE_TAG
#define MSG_SIMPLE_TAG 0x20
#endif
#ifndef MSG_HEAD_TAG
#define MSG_HEAD_TAG 0x21
#endif
#ifndef MSG_ORDERED_TAG
#define MSG_ORDERED_TAG 0x22
#endif
static ISP_INLINE int
isplinux_tagtype(Scsi_Cmnd *Cmnd)
{
switch (Cmnd->tag) {
case MSG_ORDERED_TAG:
return (REQFLAG_OTAG);
case MSG_SIMPLE_TAG:
return (REQFLAG_STAG);
case MSG_HEAD_TAG:
return (REQFLAG_HTAG);
default:
return (REQFLAG_STAG);
}
}
static ISP_INLINE void
mbox_wait_complete(ispsoftc_t *isp, mbreg_t *mbp)
{
uint32_t lim = mbp->timeout;
unsigned long et, tt = jiffies;
if (lim == 0) {
lim = MBCMD_DEFAULT_TIMEOUT;
}
if (isp->isp_mbxwrk0) {
lim *= isp->isp_mbxwrk0;
}
isp->mboxcmd_done = 0;
if (ISP_MUST_POLL(isp)) {
int j;
for (j = 0; j < lim; j += 100) {
uint32_t isr;
uint16_t sema, mbox;
if (isp->mboxcmd_done) {
break;
}
if (ISP_READ_ISR(isp, &isr, &sema, &mbox)) {
isp_intr(isp, isr, sema, mbox);
if (isp->mboxcmd_done) {
break;
}
}
ISP_ENABLE_INTS(isp);
ISP_DROP_LK_SOFTC(isp);
udelay(100);
ISP_IGET_LK_SOFTC(isp);
if (isp->mboxcmd_done) {
break;
}
}
if (isp->mboxcmd_done == 0) {
isp_prt(isp, ISP_LOGWARN, "Polled Mailbox Command (0x%x) Timeout (%lu elapsed usec)", isp->isp_lastmbxcmd, _jiffies_to_usec(jiffies - tt));
mbp->param[0] = MBOX_TIMEOUT;
}
} else {
isp_prt(isp, ISP_LOGDEBUG1, "Start Interrupting Mailbox Command (%x)", isp->isp_lastmbxcmd);
ISP_ENABLE_INTS(isp);
ISP_DROP_LK_SOFTC(isp);
et = wait_event_timeout(isp->isp_osinfo.mboxwq, isp->mboxcmd_done, usecs_to_jiffies(lim));
ISP_IGET_LK_SOFTC(isp);
if (et == 0) {
isp_prt(isp, ISP_LOGWARN, "Interrupting Mailbox Command (0x%x) Timeout (elapsed time %lu usec)", isp->isp_lastmbxcmd, _jiffies_to_usec(jiffies - tt));
mbp->param[0] = MBOX_TIMEOUT;
} else {
isp_prt(isp, ISP_LOGDEBUG1, "Interrupting Mailbox Command (0x%x) done (%lu usec)", isp->isp_lastmbxcmd, _jiffies_to_usec(et));
}
}
}
static ISP_INLINE int
fc_scratch_acquire(ispsoftc_t *isp, int chan)
{
if (ISP_DATA(isp, chan)->scratch_busy) {
return (-1);
}
ISP_DATA(isp, chan)->scratch_busy = 1;
return (0);
}
/*
* Note that these allocators aren't interrupt safe
*/
static ISP_INLINE void * isp_kalloc(size_t, int);
static ISP_INLINE void isp_kfree(void *, size_t);
static ISP_INLINE void * isp_kzalloc(size_t, int);
static ISP_INLINE void *
isp_kalloc(size_t size, int flags)
{
void *ptr;
if (size >= PAGE_SIZE) {
ptr = vmalloc(size);
} else {
ptr = kmalloc(size, flags);
}
return (ptr);
}
static ISP_INLINE void
isp_kfree(void *ptr, size_t size)
{
if (size >= PAGE_SIZE) {
vfree(ptr);
} else {
kfree(ptr);
}
}
static ISP_INLINE void *
isp_kzalloc(size_t size, int flags)
{
void *ptr = isp_kalloc(size, flags);
if (ptr != NULL){
memset(ptr, 0, size);
}
return (ptr);
}
#define COPYIN(uarg, karg, amt) copy_from_user(karg, uarg, amt)
#define COPYOUT(karg, uarg, amt) copy_to_user(uarg, karg, amt)
static ISP_INLINE void
isp_get_dma64_seg(ispds64_t *dsp, struct scatterlist *sg, uint32_t sgidx)
{
sg += sgidx;
dsp->ds_base = DMA_LO32(sg_dma_address(sg));
dsp->ds_basehi = DMA_HI32(sg_dma_address(sg));
dsp->ds_count = sg_dma_len(sg);
}
static ISP_INLINE void
isp_get_dma_seg(ispds_t *dsp, struct scatterlist *sg, uint32_t sgidx)
{
sg += sgidx;
dsp->ds_base = sg_dma_address(sg);
dsp->ds_count = sg_dma_len(sg);
}
/*
* Common inline functions
*/
#include "isp_library.h"
#ifdef ISP_TARGET_MODE
#include "isp_tpublic.h"
int isp_init_target(ispsoftc_t *);
void isp_attach_target(ispsoftc_t *);
void isp_deinit_target(ispsoftc_t *);
void isp_detach_target(ispsoftc_t *);
int isp_target_async(ispsoftc_t *, int, int);
int isp_target_notify(ispsoftc_t *, void *, uint32_t *);
int isp_enable_lun(ispsoftc_t *, uint16_t, uint16_t);
int isp_disable_lun(ispsoftc_t *, uint16_t, uint16_t);
struct notify {
isp_notify_t notify;
uint8_t qentry[QENTRY_LEN]; /* original immediate notify entry */
uint8_t qevalid;
uint8_t tmf_resp;
};
#endif
/*
* Config data
*/
int isplinux_abort(Scsi_Cmnd *);
int isplinux_bdr(Scsi_Cmnd *);
int isplinux_sreset(Scsi_Cmnd *);
int isplinux_hreset(Scsi_Cmnd *);
#endif /* _ISP_LINUX_H */
/*
* vim:ts=4:sw=4:expandtab
*/