1 |
1275 |
phoenix |
/******************************************************************************
|
2 |
|
|
* QLOGIC LINUX SOFTWARE
|
3 |
|
|
*
|
4 |
|
|
* QLogic QLA1280 (Ultra2) and QLA12160 (Ultra3) SCSI driver
|
5 |
|
|
* Copyright (C) 2000 Qlogic Corporation (www.qlogic.com)
|
6 |
|
|
* Copyright (C) 2001-2003 Jes Sorensen, Wild Open Source Inc.
|
7 |
|
|
*
|
8 |
|
|
* This program is free software; you can redistribute it and/or modify it
|
9 |
|
|
* under the terms of the GNU General Public License as published by the
|
10 |
|
|
* Free Software Foundation; either version 2, or (at your option) any
|
11 |
|
|
* later version.
|
12 |
|
|
*
|
13 |
|
|
* This program is distributed in the hope that it will be useful, but
|
14 |
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
16 |
|
|
* General Public License for more details.
|
17 |
|
|
*
|
18 |
|
|
******************************************************************************/
|
19 |
|
|
#define QLA1280_VERSION "3.23.37"
|
20 |
|
|
/*****************************************************************************
|
21 |
|
|
Revision History:
|
22 |
|
|
Rev 3.23.37 October 1, 2003, Jes Sorensen
|
23 |
|
|
- Make MMIO depend on CONFIG_X86_VISWS instead of yet another
|
24 |
|
|
random CONFIG option
|
25 |
|
|
- Clean up locking in probe path
|
26 |
|
|
Rev 3.23.36 October 1, 2003, Christoph Hellwig
|
27 |
|
|
- queuecommand only ever receives new commands - clear flags
|
28 |
|
|
- Reintegrate lost fixes from Linux 2.5
|
29 |
|
|
Rev 3.23.35 August 14, 2003, Jes Sorensen
|
30 |
|
|
- Build against 2.6
|
31 |
|
|
Rev 3.23.34 July 23, 2003, Jes Sorensen
|
32 |
|
|
- Remove pointless TRUE/FALSE macros
|
33 |
|
|
- Clean up vchan handling
|
34 |
|
|
Rev 3.23.33 July 3, 2003, Jes Sorensen
|
35 |
|
|
- Don't define register access macros before define determining MMIO.
|
36 |
|
|
This just happend to work out on ia64 but not elsewhere.
|
37 |
|
|
- Don't try and read from the card while it is in reset as
|
38 |
|
|
it won't respond and causes an MCA
|
39 |
|
|
Rev 3.23.32 June 23, 2003, Jes Sorensen
|
40 |
|
|
- Basic support for boot time arguments
|
41 |
|
|
Rev 3.23.31 June 8, 2003, Jes Sorensen
|
42 |
|
|
- Reduce boot time messages
|
43 |
|
|
Rev 3.23.30 June 6, 2003, Jes Sorensen
|
44 |
|
|
- Do not enable sync/wide/ppr before it has been determined
|
45 |
|
|
that the target device actually supports it
|
46 |
|
|
- Enable DMA arbitration for multi channel controllers
|
47 |
|
|
Rev 3.23.29 June 3, 2003, Jes Sorensen
|
48 |
|
|
- Port to 2.5.69
|
49 |
|
|
Rev 3.23.28 June 3, 2003, Jes Sorensen
|
50 |
|
|
- Eliminate duplicate marker commands on bus resets
|
51 |
|
|
- Handle outstanding commands appropriately on bus/device resets
|
52 |
|
|
Rev 3.23.27 May 28, 2003, Jes Sorensen
|
53 |
|
|
- Remove bogus input queue code, let the Linux SCSI layer do the work
|
54 |
|
|
- Clean up NVRAM handling, only read it once from the card
|
55 |
|
|
- Add a number of missing default nvram parameters
|
56 |
|
|
Rev 3.23.26 Beta May 28, 2003, Jes Sorensen
|
57 |
|
|
- Use completion queue for mailbox commands instead of busy wait
|
58 |
|
|
Rev 3.23.25 Beta May 27, 2003, James Bottomley
|
59 |
|
|
- Migrate to use new error handling code
|
60 |
|
|
Rev 3.23.24 Beta May 21, 2003, James Bottomley
|
61 |
|
|
- Big endian support
|
62 |
|
|
- Cleanup data direction code
|
63 |
|
|
Rev 3.23.23 Beta May 12, 2003, Jes Sorensen
|
64 |
|
|
- Switch to using MMIO instead of PIO
|
65 |
|
|
Rev 3.23.22 Beta April 15, 2003, Jes Sorensen
|
66 |
|
|
- Fix PCI parity problem with 12160 during reset.
|
67 |
|
|
Rev 3.23.21 Beta April 14, 2003, Jes Sorensen
|
68 |
|
|
- Use pci_map_page()/pci_unmap_page() instead of map_single version.
|
69 |
|
|
Rev 3.23.20 Beta April 9, 2003, Jes Sorensen
|
70 |
|
|
- Remove < 2.4.x support
|
71 |
|
|
- Introduce HOST_LOCK to make the spin lock changes portable.
|
72 |
|
|
- Remove a bunch of idiotic and unnecessary typedef's
|
73 |
|
|
- Kill all leftovers of target-mode support which never worked anyway
|
74 |
|
|
Rev 3.23.19 Beta April 11, 2002, Linus Torvalds
|
75 |
|
|
- Do qla1280_pci_config() before calling request_irq() and
|
76 |
|
|
request_region()
|
77 |
|
|
- Use pci_dma_hi32() to handle upper word of DMA addresses instead
|
78 |
|
|
of large shifts
|
79 |
|
|
- Hand correct arguments to free_irq() in case of failure
|
80 |
|
|
Rev 3.23.18 Beta April 11, 2002, Jes Sorensen
|
81 |
|
|
- Run source through Lindent and clean up the output
|
82 |
|
|
Rev 3.23.17 Beta April 11, 2002, Jes Sorensen
|
83 |
|
|
- Update SCSI firmware to qla1280 v8.15.00 and qla12160 v10.04.32
|
84 |
|
|
Rev 3.23.16 Beta March 19, 2002, Jes Sorensen
|
85 |
|
|
- Rely on mailbox commands generating interrupts - do not
|
86 |
|
|
run qla1280_isr() from ql1280_mailbox_command()
|
87 |
|
|
- Remove device_reg_t
|
88 |
|
|
- Integrate ql12160_set_target_parameters() with 1280 version
|
89 |
|
|
- Make qla1280_setup() non static
|
90 |
|
|
- Do not call qla1280_check_for_dead_scsi_bus() on every I/O request
|
91 |
|
|
sent to the card - this command pauses the firmare!!!
|
92 |
|
|
Rev 3.23.15 Beta March 19, 2002, Jes Sorensen
|
93 |
|
|
- Clean up qla1280.h - remove obsolete QL_DEBUG_LEVEL_x definitions
|
94 |
|
|
- Remove a pile of pointless and confusing (srb_t **) and
|
95 |
|
|
(scsi_lu_t *) typecasts
|
96 |
|
|
- Explicit mark that we do not use the new error handling (for now)
|
97 |
|
|
- Remove scsi_qla_host_t and use 'struct' instead
|
98 |
|
|
- Remove in_abort, watchdog_enabled, dpc, dpc_sched, bios_enabled,
|
99 |
|
|
pci_64bit_slot flags which weren't used for anything anyway
|
100 |
|
|
- Grab host->host_lock while calling qla1280_isr() from abort()
|
101 |
|
|
- Use spin_lock()/spin_unlock() in qla1280_intr_handler() - we
|
102 |
|
|
do not need to save/restore flags in the interrupt handler
|
103 |
|
|
- Enable interrupts early (before any mailbox access) in preparation
|
104 |
|
|
for cleaning up the mailbox handling
|
105 |
|
|
Rev 3.23.14 Beta March 14, 2002, Jes Sorensen
|
106 |
|
|
- Further cleanups. Remove all trace of QL_DEBUG_LEVEL_x and replace
|
107 |
|
|
it with proper use of dprintk().
|
108 |
|
|
- Make qla1280_print_scsi_cmd() and qla1280_dump_buffer() both take
|
109 |
|
|
a debug level argument to determine if data is to be printed
|
110 |
|
|
- Add KERN_* info to printk()
|
111 |
|
|
Rev 3.23.13 Beta March 14, 2002, Jes Sorensen
|
112 |
|
|
- Significant cosmetic cleanups
|
113 |
|
|
- Change debug code to use dprintk() and remove #if mess
|
114 |
|
|
Rev 3.23.12 Beta March 13, 2002, Jes Sorensen
|
115 |
|
|
- More cosmetic cleanups, fix places treating return as function
|
116 |
|
|
- use cpu_relax() in qla1280_debounce_register()
|
117 |
|
|
Rev 3.23.11 Beta March 13, 2002, Jes Sorensen
|
118 |
|
|
- Make it compile under 2.5.5
|
119 |
|
|
Rev 3.23.10 Beta October 1, 2001, Jes Sorensen
|
120 |
|
|
- Do no typecast short * to long * in QL1280BoardTbl, this
|
121 |
|
|
broke miserably on big endian boxes
|
122 |
|
|
Rev 3.23.9 Beta September 30, 2001, Jes Sorensen
|
123 |
|
|
- Remove pre 2.2 hack for checking for reentrance in interrupt handler
|
124 |
|
|
- Make data types used to receive from SCSI_{BUS,TCN,LUN}_32
|
125 |
|
|
unsigned int to match the types from struct scsi_cmnd
|
126 |
|
|
Rev 3.23.8 Beta September 29, 2001, Jes Sorensen
|
127 |
|
|
- Remove bogus timer_t typedef from qla1280.h
|
128 |
|
|
- Remove obsolete pre 2.2 PCI setup code, use proper #define's
|
129 |
|
|
for PCI_ values, call pci_set_master()
|
130 |
|
|
- Fix memleak of qla1280_buffer on module unload
|
131 |
|
|
- Only compile module parsing code #ifdef MODULE - should be
|
132 |
|
|
changed to use individual MODULE_PARM's later
|
133 |
|
|
- Remove dummy_buffer that was never modified nor printed
|
134 |
|
|
- ENTER()/LEAVE() are noops unless QL_DEBUG_LEVEL_3, hence remove
|
135 |
|
|
#ifdef QL_DEBUG_LEVEL_3/#endif around ENTER()/LEAVE() calls
|
136 |
|
|
- Remove \r from print statements, this is Linux, not DOS
|
137 |
|
|
- Remove obsolete QLA1280_{SCSILU,INTR,RING}_{LOCK,UNLOCK}
|
138 |
|
|
dummy macros
|
139 |
|
|
- Remove C++ compile hack in header file as Linux driver are not
|
140 |
|
|
supposed to be compiled as C++
|
141 |
|
|
- Kill MS_64BITS macro as it makes the code more readable
|
142 |
|
|
- Remove unnecessary flags.in_interrupts bit
|
143 |
|
|
Rev 3.23.7 Beta August 20, 2001, Jes Sorensen
|
144 |
|
|
- Dont' check for set flags on q->q_flag one by one in qla1280_next()
|
145 |
|
|
- Check whether the interrupt was generated by the QLA1280 before
|
146 |
|
|
doing any processing
|
147 |
|
|
- qla1280_status_entry(): Only zero out part of sense_buffer that
|
148 |
|
|
is not being copied into
|
149 |
|
|
- Remove more superflouous typecasts
|
150 |
|
|
- qla1280_32bit_start_scsi() replace home-brew memcpy() with memcpy()
|
151 |
|
|
Rev 3.23.6 Beta August 20, 2001, Tony Luck, Intel
|
152 |
|
|
- Don't walk the entire list in qla1280_putq_t() just to directly
|
153 |
|
|
grab the pointer to the last element afterwards
|
154 |
|
|
Rev 3.23.5 Beta August 9, 2001, Jes Sorensen
|
155 |
|
|
- Don't use SA_INTERRUPT, it's use is deprecated for this kinda driver
|
156 |
|
|
Rev 3.23.4 Beta August 8, 2001, Jes Sorensen
|
157 |
|
|
- Set dev->max_sectors to 1024
|
158 |
|
|
Rev 3.23.3 Beta August 6, 2001, Jes Sorensen
|
159 |
|
|
- Provide compat macros for pci_enable_device(), pci_find_subsys()
|
160 |
|
|
and scsi_set_pci_device()
|
161 |
|
|
- Call scsi_set_pci_device() for all devices
|
162 |
|
|
- Reduce size of kernel version dependent device probe code
|
163 |
|
|
- Move duplicate probe/init code to separate function
|
164 |
|
|
- Handle error if qla1280_mem_alloc() fails
|
165 |
|
|
- Kill OFFSET() macro and use Linux's PCI definitions instead
|
166 |
|
|
- Kill private structure defining PCI config space (struct config_reg)
|
167 |
|
|
- Only allocate I/O port region if not in MMIO mode
|
168 |
|
|
- Remove duplicate (unused) sanity check of sife of srb_t
|
169 |
|
|
Rev 3.23.2 Beta August 6, 2001, Jes Sorensen
|
170 |
|
|
- Change home-brew memset() implementations to use memset()
|
171 |
|
|
- Remove all references to COMTRACE() - accessing a PC's COM2 serial
|
172 |
|
|
port directly is not legal under Linux.
|
173 |
|
|
Rev 3.23.1 Beta April 24, 2001, Jes Sorensen
|
174 |
|
|
- Remove pre 2.2 kernel support
|
175 |
|
|
- clean up 64 bit DMA setting to use 2.4 API (provide backwards compat)
|
176 |
|
|
- Fix MMIO access to use readl/writel instead of directly
|
177 |
|
|
dereferencing pointers
|
178 |
|
|
- Nuke MSDOS debugging code
|
179 |
|
|
- Change true/false data types to int from uint8_t
|
180 |
|
|
- Use int for counters instead of uint8_t etc.
|
181 |
|
|
- Clean up size & byte order conversion macro usage
|
182 |
|
|
Rev 3.23 Beta January 11, 2001 BN Qlogic
|
183 |
|
|
- Added check of device_id when handling non
|
184 |
|
|
QLA12160s during detect().
|
185 |
|
|
Rev 3.22 Beta January 5, 2001 BN Qlogic
|
186 |
|
|
- Changed queue_task() to schedule_task()
|
187 |
|
|
for kernels 2.4.0 and higher.
|
188 |
|
|
Note: 2.4.0-testxx kernels released prior to
|
189 |
|
|
the actual 2.4.0 kernel release on January 2001
|
190 |
|
|
will get compile/link errors with schedule_task().
|
191 |
|
|
Please update your kernel to released 2.4.0 level,
|
192 |
|
|
or comment lines in this file flagged with 3.22
|
193 |
|
|
to resolve compile/link error of schedule_task().
|
194 |
|
|
- Added -DCONFIG_SMP in addition to -D__SMP__
|
195 |
|
|
in Makefile for 2.4.0 builds of driver as module.
|
196 |
|
|
Rev 3.21 Beta January 4, 2001 BN Qlogic
|
197 |
|
|
- Changed criteria of 64/32 Bit mode of HBA
|
198 |
|
|
operation according to BITS_PER_LONG rather
|
199 |
|
|
than HBA's NVRAM setting of >4Gig memory bit;
|
200 |
|
|
so that the HBA auto-configures without the need
|
201 |
|
|
to setup each system individually.
|
202 |
|
|
Rev 3.20 Beta December 5, 2000 BN Qlogic
|
203 |
|
|
- Added priority handling to IA-64 onboard SCSI
|
204 |
|
|
ISP12160 chip for kernels greater than 2.3.18.
|
205 |
|
|
- Added irqrestore for qla1280_intr_handler.
|
206 |
|
|
- Enabled /proc/scsi/qla1280 interface.
|
207 |
|
|
- Clear /proc/scsi/qla1280 counters in detect().
|
208 |
|
|
Rev 3.19 Beta October 13, 2000 BN Qlogic
|
209 |
|
|
- Declare driver_template for new kernel
|
210 |
|
|
(2.4.0 and greater) scsi initialization scheme.
|
211 |
|
|
- Update /proc/scsi entry for 2.3.18 kernels and
|
212 |
|
|
above as qla1280
|
213 |
|
|
Rev 3.18 Beta October 10, 2000 BN Qlogic
|
214 |
|
|
- Changed scan order of adapters to map
|
215 |
|
|
the QLA12160 followed by the QLA1280.
|
216 |
|
|
Rev 3.17 Beta September 18, 2000 BN Qlogic
|
217 |
|
|
- Removed warnings for 32 bit 2.4.x compiles
|
218 |
|
|
- Corrected declared size for request and response
|
219 |
|
|
DMA addresses that are kept in each ha
|
220 |
|
|
Rev. 3.16 Beta August 25, 2000 BN Qlogic
|
221 |
|
|
- Corrected 64 bit addressing issue on IA-64
|
222 |
|
|
where the upper 32 bits were not properly
|
223 |
|
|
passed to the RISC engine.
|
224 |
|
|
Rev. 3.15 Beta August 22, 2000 BN Qlogic
|
225 |
|
|
- Modified qla1280_setup_chip to properly load
|
226 |
|
|
ISP firmware for greater that 4 Gig memory on IA-64
|
227 |
|
|
Rev. 3.14 Beta August 16, 2000 BN Qlogic
|
228 |
|
|
- Added setting of dma_mask to full 64 bit
|
229 |
|
|
if flags.enable_64bit_addressing is set in NVRAM
|
230 |
|
|
Rev. 3.13 Beta August 16, 2000 BN Qlogic
|
231 |
|
|
- Use new PCI DMA mapping APIs for 2.4.x kernel
|
232 |
|
|
Rev. 3.12 July 18, 2000 Redhat & BN Qlogic
|
233 |
|
|
- Added check of pci_enable_device to detect() for 2.3.x
|
234 |
|
|
- Use pci_resource_start() instead of
|
235 |
|
|
pdev->resource[0].start in detect() for 2.3.x
|
236 |
|
|
- Updated driver version
|
237 |
|
|
Rev. 3.11 July 14, 2000 BN Qlogic
|
238 |
|
|
- Updated SCSI Firmware to following versions:
|
239 |
|
|
qla1x80: 8.13.08
|
240 |
|
|
qla1x160: 10.04.08
|
241 |
|
|
- Updated driver version to 3.11
|
242 |
|
|
Rev. 3.10 June 23, 2000 BN Qlogic
|
243 |
|
|
- Added filtering of AMI SubSys Vendor ID devices
|
244 |
|
|
Rev. 3.9
|
245 |
|
|
- DEBUG_QLA1280 undefined and new version BN Qlogic
|
246 |
|
|
Rev. 3.08b May 9, 2000 MD Dell
|
247 |
|
|
- Added logic to check against AMI subsystem vendor ID
|
248 |
|
|
Rev. 3.08 May 4, 2000 DG Qlogic
|
249 |
|
|
- Added logic to check for PCI subsystem ID.
|
250 |
|
|
Rev. 3.07 Apr 24, 2000 DG & BN Qlogic
|
251 |
|
|
- Updated SCSI Firmware to following versions:
|
252 |
|
|
qla12160: 10.01.19
|
253 |
|
|
qla1280: 8.09.00
|
254 |
|
|
Rev. 3.06 Apr 12, 2000 DG & BN Qlogic
|
255 |
|
|
- Internal revision; not released
|
256 |
|
|
Rev. 3.05 Mar 28, 2000 DG & BN Qlogic
|
257 |
|
|
- Edit correction for virt_to_bus and PROC.
|
258 |
|
|
Rev. 3.04 Mar 28, 2000 DG & BN Qlogic
|
259 |
|
|
- Merge changes from ia64 port.
|
260 |
|
|
Rev. 3.03 Mar 28, 2000 BN Qlogic
|
261 |
|
|
- Increase version to reflect new code drop with compile fix
|
262 |
|
|
of issue with inclusion of linux/spinlock for 2.3 kernels
|
263 |
|
|
Rev. 3.02 Mar 15, 2000 BN Qlogic
|
264 |
|
|
- Merge qla1280_proc_info from 2.10 code base
|
265 |
|
|
Rev. 3.01 Feb 10, 2000 BN Qlogic
|
266 |
|
|
- Corrected code to compile on a 2.2.x kernel.
|
267 |
|
|
Rev. 3.00 Jan 17, 2000 DG Qlogic
|
268 |
|
|
- Added 64-bit support.
|
269 |
|
|
Rev. 2.07 Nov 9, 1999 DG Qlogic
|
270 |
|
|
- Added new routine to set target parameters for ISP12160.
|
271 |
|
|
Rev. 2.06 Sept 10, 1999 DG Qlogic
|
272 |
|
|
- Added support for ISP12160 Ultra 3 chip.
|
273 |
|
|
Rev. 2.03 August 3, 1999 Fred Lewis, Intel DuPont
|
274 |
|
|
- Modified code to remove errors generated when compiling with
|
275 |
|
|
Cygnus IA64 Compiler.
|
276 |
|
|
- Changed conversion of pointers to unsigned longs instead of integers.
|
277 |
|
|
- Changed type of I/O port variables from uint32_t to unsigned long.
|
278 |
|
|
- Modified OFFSET macro to work with 64-bit as well as 32-bit.
|
279 |
|
|
- Changed sprintf and printk format specifiers for pointers to %p.
|
280 |
|
|
- Changed some int to long type casts where needed in sprintf & printk.
|
281 |
|
|
- Added l modifiers to sprintf and printk format specifiers for longs.
|
282 |
|
|
- Removed unused local variables.
|
283 |
|
|
Rev. 1.20 June 8, 1999 DG, Qlogic
|
284 |
|
|
Changes to support RedHat release 6.0 (kernel 2.2.5).
|
285 |
|
|
- Added SCSI exclusive access lock (io_request_lock) when accessing
|
286 |
|
|
the adapter.
|
287 |
|
|
- Added changes for the new LINUX interface template. Some new error
|
288 |
|
|
handling routines have been added to the template, but for now we
|
289 |
|
|
will use the old ones.
|
290 |
|
|
- Initial Beta Release.
|
291 |
|
|
*****************************************************************************/
|
292 |
|
|
|
293 |
|
|
|
294 |
|
|
#include <linux/config.h>
|
295 |
|
|
#include <linux/module.h>
|
296 |
|
|
|
297 |
|
|
#include <linux/version.h>
|
298 |
|
|
#include <linux/types.h>
|
299 |
|
|
#include <linux/string.h>
|
300 |
|
|
#include <linux/errno.h>
|
301 |
|
|
#include <linux/kernel.h>
|
302 |
|
|
#include <linux/ioport.h>
|
303 |
|
|
#include <linux/delay.h>
|
304 |
|
|
#include <linux/timer.h>
|
305 |
|
|
#include <linux/sched.h>
|
306 |
|
|
#include <linux/pci.h>
|
307 |
|
|
#include <linux/proc_fs.h>
|
308 |
|
|
#include <linux/stat.h>
|
309 |
|
|
#include <linux/slab.h>
|
310 |
|
|
#include <linux/pci_ids.h>
|
311 |
|
|
#include <linux/interrupt.h>
|
312 |
|
|
#include <linux/init.h>
|
313 |
|
|
|
314 |
|
|
#include <asm/io.h>
|
315 |
|
|
#include <asm/irq.h>
|
316 |
|
|
#include <asm/byteorder.h>
|
317 |
|
|
#include <asm/processor.h>
|
318 |
|
|
#include <asm/types.h>
|
319 |
|
|
#include <asm/system.h>
|
320 |
|
|
|
321 |
|
|
#if LINUX_VERSION_CODE >= 0x020545
|
322 |
|
|
#include <scsi/scsi_host.h>
|
323 |
|
|
#include "scsi.h"
|
324 |
|
|
#else
|
325 |
|
|
#include <linux/blk.h>
|
326 |
|
|
#include "scsi.h"
|
327 |
|
|
#include "hosts.h"
|
328 |
|
|
#include "sd.h"
|
329 |
|
|
#endif
|
330 |
|
|
|
331 |
|
|
#if LINUX_VERSION_CODE < 0x020407
|
332 |
|
|
#error "Kernels older than 2.4.7 are no longer supported"
|
333 |
|
|
#endif
|
334 |
|
|
|
335 |
|
|
|
336 |
|
|
/*
|
337 |
|
|
* Compile time Options:
|
338 |
|
|
* 0 - Disable and 1 - Enable
|
339 |
|
|
*/
|
340 |
|
|
#define QL1280_LUN_SUPPORT 0
|
341 |
|
|
#define WATCHDOGTIMER 0
|
342 |
|
|
|
343 |
|
|
#define DEBUG_QLA1280_INTR 0
|
344 |
|
|
#define DEBUG_PRINT_NVRAM 0
|
345 |
|
|
#define DEBUG_QLA1280 0
|
346 |
|
|
|
347 |
|
|
/*
|
348 |
|
|
* The SGI VISWS is broken and doesn't support MMIO ;-(
|
349 |
|
|
*/
|
350 |
|
|
#ifdef CONFIG_X86_VISWS
|
351 |
|
|
#define MEMORY_MAPPED_IO 0
|
352 |
|
|
#else
|
353 |
|
|
#define MEMORY_MAPPED_IO 1
|
354 |
|
|
#endif
|
355 |
|
|
|
356 |
|
|
#define UNIQUE_FW_NAME
|
357 |
|
|
#include "qla1280.h"
|
358 |
|
|
#include "ql12160_fw.h" /* ISP RISC codes */
|
359 |
|
|
#include "ql1280_fw.h"
|
360 |
|
|
|
361 |
|
|
|
362 |
|
|
/*
|
363 |
|
|
* Missing PCI ID's
|
364 |
|
|
*/
|
365 |
|
|
#ifndef PCI_DEVICE_ID_QLOGIC_ISP1080
|
366 |
|
|
#define PCI_DEVICE_ID_QLOGIC_ISP1080 0x1080
|
367 |
|
|
#endif
|
368 |
|
|
#ifndef PCI_DEVICE_ID_QLOGIC_ISP1240
|
369 |
|
|
#define PCI_DEVICE_ID_QLOGIC_ISP1240 0x1240
|
370 |
|
|
#endif
|
371 |
|
|
#ifndef PCI_DEVICE_ID_QLOGIC_ISP1280
|
372 |
|
|
#define PCI_DEVICE_ID_QLOGIC_ISP1280 0x1280
|
373 |
|
|
#endif
|
374 |
|
|
#ifndef PCI_DEVICE_ID_QLOGIC_ISP10160
|
375 |
|
|
#define PCI_DEVICE_ID_QLOGIC_ISP10160 0x1016
|
376 |
|
|
#endif
|
377 |
|
|
#ifndef PCI_DEVICE_ID_QLOGIC_ISP12160
|
378 |
|
|
#define PCI_DEVICE_ID_QLOGIC_ISP12160 0x1216
|
379 |
|
|
#endif
|
380 |
|
|
|
381 |
|
|
#ifndef PCI_VENDOR_ID_AMI
|
382 |
|
|
#define PCI_VENDOR_ID_AMI 0x101e
|
383 |
|
|
#endif
|
384 |
|
|
|
385 |
|
|
#ifndef BITS_PER_LONG
|
386 |
|
|
#error "BITS_PER_LONG not defined!"
|
387 |
|
|
#endif
|
388 |
|
|
#if (BITS_PER_LONG == 64) || defined CONFIG_HIGHMEM
|
389 |
|
|
#define QLA_64BIT_PTR 1
|
390 |
|
|
#endif
|
391 |
|
|
|
392 |
|
|
#if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2)
|
393 |
|
|
#include <asm/sn/pci/pciio.h>
|
394 |
|
|
/* Ugly hack needed for the virtual channel fix on SN2 */
|
395 |
|
|
extern int snia_pcibr_rrb_alloc(struct pci_dev *pci_dev,
|
396 |
|
|
int *count_vchan0, int *count_vchan1);
|
397 |
|
|
#endif
|
398 |
|
|
|
399 |
|
|
#ifdef QLA_64BIT_PTR
|
400 |
|
|
#define pci_dma_hi32(a) ((a >> 16) >> 16)
|
401 |
|
|
#else
|
402 |
|
|
#define pci_dma_hi32(a) 0
|
403 |
|
|
#endif
|
404 |
|
|
#define pci_dma_lo32(a) (a & 0xffffffff)
|
405 |
|
|
|
406 |
|
|
#define NVRAM_DELAY() udelay(500) /* 2 microseconds */
|
407 |
|
|
|
408 |
|
|
#if LINUX_VERSION_CODE < 0x020417
|
409 |
|
|
/* Compat already available in 2.4.23 */
|
410 |
|
|
#define irqreturn_t void
|
411 |
|
|
#define IRQ_RETVAL(foo)
|
412 |
|
|
#endif
|
413 |
|
|
#if LINUX_VERSION_CODE < 0x020500
|
414 |
|
|
#define HOST_LOCK &io_request_lock
|
415 |
|
|
#define MSG_ORDERED_TAG 1
|
416 |
|
|
static inline void
|
417 |
|
|
scsi_adjust_queue_depth(Scsi_Device *device, int tag, int depth)
|
418 |
|
|
{
|
419 |
|
|
if (tag) {
|
420 |
|
|
device->tagged_queue = tag;
|
421 |
|
|
device->current_tag = 0;
|
422 |
|
|
}
|
423 |
|
|
device->queue_depth = depth;
|
424 |
|
|
}
|
425 |
|
|
#else
|
426 |
|
|
#define HOST_LOCK ha->host->host_lock
|
427 |
|
|
#endif
|
428 |
|
|
#if LINUX_VERSION_CODE < 0x020600
|
429 |
|
|
#define DEV_SIMPLE_TAGS(device) device->tagged_queue
|
430 |
|
|
#else
|
431 |
|
|
#define DEV_SIMPLE_TAGS(device) device->simple_tags
|
432 |
|
|
#endif
|
433 |
|
|
#if defined(__ia64__) && !defined(ia64_platform_is)
|
434 |
|
|
#define ia64_platform_is(foo) (!strcmp(x, platform_name))
|
435 |
|
|
#endif
|
436 |
|
|
|
437 |
|
|
/*
|
438 |
|
|
* QLogic Driver Support Function Prototypes.
|
439 |
|
|
*/
|
440 |
|
|
static void qla1280_done(struct scsi_qla_host *, struct srb **, struct srb **);
|
441 |
|
|
static void qla1280_done_q_put(struct srb *, struct srb **, struct srb **);
|
442 |
|
|
static int qla1280_slave_configure(Scsi_Device *);
|
443 |
|
|
#if LINUX_VERSION_CODE < 0x020545
|
444 |
|
|
static void qla1280_select_queue_depth(struct Scsi_Host *, Scsi_Device *);
|
445 |
|
|
static void qla1280_get_target_options(struct scsi_cmnd *, struct scsi_qla_host *);
|
446 |
|
|
#endif
|
447 |
|
|
|
448 |
|
|
static int qla1280_return_status(struct response * sts, Scsi_Cmnd * cp);
|
449 |
|
|
static void qla1280_mem_free(struct scsi_qla_host *ha);
|
450 |
|
|
static int qla1280_get_token(char *);
|
451 |
|
|
static int qla1280_setup(char *s) __init;
|
452 |
|
|
static inline void qla1280_enable_intrs(struct scsi_qla_host *);
|
453 |
|
|
static inline void qla1280_disable_intrs(struct scsi_qla_host *);
|
454 |
|
|
|
455 |
|
|
/*
|
456 |
|
|
* QLogic ISP1280 Hardware Support Function Prototypes.
|
457 |
|
|
*/
|
458 |
|
|
static int qla1280_initialize_adapter(struct scsi_qla_host *ha);
|
459 |
|
|
static int qla1280_isp_firmware(struct scsi_qla_host *);
|
460 |
|
|
static int qla1280_pci_config(struct scsi_qla_host *);
|
461 |
|
|
static int qla1280_chip_diag(struct scsi_qla_host *);
|
462 |
|
|
static int qla1280_setup_chip(struct scsi_qla_host *);
|
463 |
|
|
static int qla1280_init_rings(struct scsi_qla_host *);
|
464 |
|
|
static int qla1280_nvram_config(struct scsi_qla_host *);
|
465 |
|
|
static int qla1280_mailbox_command(struct scsi_qla_host *,
|
466 |
|
|
uint8_t, uint16_t *);
|
467 |
|
|
static int qla1280_bus_reset(struct scsi_qla_host *, int);
|
468 |
|
|
static int qla1280_device_reset(struct scsi_qla_host *, int, int);
|
469 |
|
|
static int qla1280_abort_device(struct scsi_qla_host *, int, int, int);
|
470 |
|
|
static int qla1280_abort_command(struct scsi_qla_host *, struct srb *, int);
|
471 |
|
|
static int qla1280_abort_isp(struct scsi_qla_host *);
|
472 |
|
|
static int qla1280_64bit_start_scsi(struct scsi_qla_host *, struct srb *);
|
473 |
|
|
static int qla1280_32bit_start_scsi(struct scsi_qla_host *, struct srb *);
|
474 |
|
|
static void qla1280_nv_write(struct scsi_qla_host *, uint16_t);
|
475 |
|
|
static void qla1280_poll(struct scsi_qla_host *);
|
476 |
|
|
static void qla1280_reset_adapter(struct scsi_qla_host *);
|
477 |
|
|
static void qla1280_marker(struct scsi_qla_host *, int, int, int, u8);
|
478 |
|
|
static void qla1280_isp_cmd(struct scsi_qla_host *);
|
479 |
|
|
irqreturn_t qla1280_intr_handler(int, void *, struct pt_regs *);
|
480 |
|
|
static void qla1280_isr(struct scsi_qla_host *, struct srb **, struct srb **);
|
481 |
|
|
static void qla1280_rst_aen(struct scsi_qla_host *);
|
482 |
|
|
static void qla1280_status_entry(struct scsi_qla_host *, struct response *,
|
483 |
|
|
struct srb **, struct srb **);
|
484 |
|
|
static void qla1280_error_entry(struct scsi_qla_host *, struct response *,
|
485 |
|
|
struct srb **, struct srb **);
|
486 |
|
|
static uint16_t qla1280_get_nvram_word(struct scsi_qla_host *, uint32_t);
|
487 |
|
|
static uint16_t qla1280_nvram_request(struct scsi_qla_host *, uint32_t);
|
488 |
|
|
static uint16_t qla1280_debounce_register(volatile uint16_t *);
|
489 |
|
|
static request_t *qla1280_req_pkt(struct scsi_qla_host *);
|
490 |
|
|
static int qla1280_check_for_dead_scsi_bus(struct scsi_qla_host *,
|
491 |
|
|
unsigned int);
|
492 |
|
|
static int qla1280_mem_alloc(struct scsi_qla_host *ha);
|
493 |
|
|
|
494 |
|
|
static void qla12160_get_target_parameters(struct scsi_qla_host *,
|
495 |
|
|
Scsi_Device *);
|
496 |
|
|
static int qla12160_set_target_parameters(struct scsi_qla_host *, int, int);
|
497 |
|
|
|
498 |
|
|
|
499 |
|
|
static struct qla_driver_setup driver_setup __initdata;
|
500 |
|
|
|
501 |
|
|
/*
|
502 |
|
|
* convert scsi data direction to request_t control flags
|
503 |
|
|
*/
|
504 |
|
|
static inline uint16_t
|
505 |
|
|
qla1280_data_direction(struct scsi_cmnd *cmnd)
|
506 |
|
|
{
|
507 |
|
|
uint16_t flags = 0;
|
508 |
|
|
|
509 |
|
|
switch(cmnd->sc_data_direction) {
|
510 |
|
|
|
511 |
|
|
case SCSI_DATA_NONE:
|
512 |
|
|
flags = 0;
|
513 |
|
|
break;
|
514 |
|
|
|
515 |
|
|
case SCSI_DATA_READ:
|
516 |
|
|
flags = BIT_5;
|
517 |
|
|
break;
|
518 |
|
|
|
519 |
|
|
case SCSI_DATA_WRITE:
|
520 |
|
|
flags = BIT_6;
|
521 |
|
|
break;
|
522 |
|
|
|
523 |
|
|
case SCSI_DATA_UNKNOWN:
|
524 |
|
|
default:
|
525 |
|
|
flags = BIT_5 | BIT_6;
|
526 |
|
|
break;
|
527 |
|
|
}
|
528 |
|
|
return flags;
|
529 |
|
|
}
|
530 |
|
|
|
531 |
|
|
#if QL1280_LUN_SUPPORT
|
532 |
|
|
static void qla1280_enable_lun(struct scsi_qla_host *, int, int);
|
533 |
|
|
#endif
|
534 |
|
|
|
535 |
|
|
#if DEBUG_QLA1280
|
536 |
|
|
static void __qla1280_print_scsi_cmd(Scsi_Cmnd * cmd);
|
537 |
|
|
static void __qla1280_dump_buffer(char *, int);
|
538 |
|
|
#endif
|
539 |
|
|
|
540 |
|
|
|
541 |
|
|
/*
|
542 |
|
|
* insmod needs to find the variable and make it point to something
|
543 |
|
|
*/
|
544 |
|
|
#ifdef MODULE
|
545 |
|
|
static char *qla1280;
|
546 |
|
|
|
547 |
|
|
/* insmod qla1280 options=verbose" */
|
548 |
|
|
MODULE_PARM(qla1280, "s");
|
549 |
|
|
#else
|
550 |
|
|
__setup("qla1280=", qla1280_setup);
|
551 |
|
|
#endif
|
552 |
|
|
|
553 |
|
|
MODULE_LICENSE("GPL");
|
554 |
|
|
|
555 |
|
|
|
556 |
|
|
/* We use the Scsi_Pointer structure that's included with each command
|
557 |
|
|
* SCSI_Cmnd as a scratchpad for our SRB.
|
558 |
|
|
*
|
559 |
|
|
* SCp will always point to the SRB structure (defined in qla1280.h).
|
560 |
|
|
* It is define as follows:
|
561 |
|
|
* - SCp.ptr -- > pointer back to the cmd
|
562 |
|
|
* - SCp.this_residual --> used as forward pointer to next srb
|
563 |
|
|
* - SCp.buffer --> used as backward pointer to next srb
|
564 |
|
|
* - SCp.buffers_residual --> used as flags field
|
565 |
|
|
* - SCp.have_data_in --> not used
|
566 |
|
|
* - SCp.sent_command --> not used
|
567 |
|
|
* - SCp.phase --> not used
|
568 |
|
|
*/
|
569 |
|
|
|
570 |
|
|
#define CMD_SP(Cmnd) &Cmnd->SCp
|
571 |
|
|
#define CMD_CDBLEN(Cmnd) Cmnd->cmd_len
|
572 |
|
|
#define CMD_CDBP(Cmnd) Cmnd->cmnd
|
573 |
|
|
#define CMD_SNSP(Cmnd) Cmnd->sense_buffer
|
574 |
|
|
#define CMD_SNSLEN(Cmnd) sizeof(Cmnd->sense_buffer)
|
575 |
|
|
#define CMD_RESULT(Cmnd) Cmnd->result
|
576 |
|
|
#define CMD_HANDLE(Cmnd) Cmnd->host_scribble
|
577 |
|
|
#if LINUX_VERSION_CODE < 0x020545
|
578 |
|
|
#define CMD_HOST(Cmnd) Cmnd->host
|
579 |
|
|
#define CMD_REQUEST(Cmnd) Cmnd->request.cmd
|
580 |
|
|
#define SCSI_BUS_32(Cmnd) Cmnd->channel
|
581 |
|
|
#define SCSI_TCN_32(Cmnd) Cmnd->target
|
582 |
|
|
#define SCSI_LUN_32(Cmnd) Cmnd->lun
|
583 |
|
|
#else
|
584 |
|
|
#define CMD_HOST(Cmnd) Cmnd->device->host
|
585 |
|
|
#define CMD_REQUEST(Cmnd) Cmnd->request->cmd
|
586 |
|
|
#define SCSI_BUS_32(Cmnd) Cmnd->device->channel
|
587 |
|
|
#define SCSI_TCN_32(Cmnd) Cmnd->device->id
|
588 |
|
|
#define SCSI_LUN_32(Cmnd) Cmnd->device->lun
|
589 |
|
|
#endif
|
590 |
|
|
|
591 |
|
|
/*****************************************/
|
592 |
|
|
/* ISP Boards supported by this driver */
|
593 |
|
|
/*****************************************/
|
594 |
|
|
|
595 |
|
|
#define NUM_OF_ISP_DEVICES 6
|
596 |
|
|
|
597 |
|
|
struct qla_boards {
|
598 |
|
|
unsigned char name[9]; /* Board ID String */
|
599 |
|
|
unsigned long device_id; /* Device PCI ID */
|
600 |
|
|
int numPorts; /* Number of SCSI ports */
|
601 |
|
|
unsigned short *fwcode; /* pointer to FW array */
|
602 |
|
|
unsigned short *fwlen; /* number of words in array */
|
603 |
|
|
unsigned short *fwstart; /* start address for F/W */
|
604 |
|
|
unsigned char *fwver; /* Ptr to F/W version array */
|
605 |
|
|
};
|
606 |
|
|
|
607 |
|
|
struct qla_boards ql1280_board_tbl[NUM_OF_ISP_DEVICES] = {
|
608 |
|
|
/* Name , Board PCI Device ID, Number of ports */
|
609 |
|
|
{"QLA12160", PCI_DEVICE_ID_QLOGIC_ISP12160, 2,
|
610 |
|
|
&fw12160i_code01[0], &fw12160i_length01,
|
611 |
|
|
&fw12160i_addr01, &fw12160i_version_str[0]},
|
612 |
|
|
{"QLA1080", PCI_DEVICE_ID_QLOGIC_ISP1080, 1,
|
613 |
|
|
&fw1280ei_code01[0], &fw1280ei_length01,
|
614 |
|
|
&fw1280ei_addr01, &fw1280ei_version_str[0]},
|
615 |
|
|
{"QLA1240", PCI_DEVICE_ID_QLOGIC_ISP1240, 2,
|
616 |
|
|
&fw1280ei_code01[0], &fw1280ei_length01,
|
617 |
|
|
&fw1280ei_addr01, &fw1280ei_version_str[0]},
|
618 |
|
|
{"QLA1280", PCI_DEVICE_ID_QLOGIC_ISP1280, 2,
|
619 |
|
|
&fw1280ei_code01[0], &fw1280ei_length01,
|
620 |
|
|
&fw1280ei_addr01, &fw1280ei_version_str[0]},
|
621 |
|
|
{"QLA10160", PCI_DEVICE_ID_QLOGIC_ISP10160, 1,
|
622 |
|
|
&fw12160i_code01[0], &fw12160i_length01,
|
623 |
|
|
&fw12160i_addr01, &fw12160i_version_str[0]},
|
624 |
|
|
{" ", 0, 0}
|
625 |
|
|
};
|
626 |
|
|
|
627 |
|
|
static int qla1280_verbose = 1;
|
628 |
|
|
static struct scsi_qla_host *qla1280_hostlist;
|
629 |
|
|
static int qla1280_buffer_size;
|
630 |
|
|
static char *qla1280_buffer;
|
631 |
|
|
|
632 |
|
|
#if DEBUG_QLA1280
|
633 |
|
|
static int ql_debug_level = 1;
|
634 |
|
|
#define dprintk(level, format, a...) \
|
635 |
|
|
do { if (ql_debug_level >= level) printk(KERN_ERR format, ##a); } while(0)
|
636 |
|
|
#define qla1280_dump_buffer(level, buf, size) \
|
637 |
|
|
if (ql_debug_level >= level) __qla1280_dump_buffer(buf, size)
|
638 |
|
|
#define qla1280_print_scsi_cmd(level, cmd) \
|
639 |
|
|
if (ql_debug_level >= level) __qla1280_print_scsi_cmd(cmd)
|
640 |
|
|
#else
|
641 |
|
|
#define ql_debug_level 0
|
642 |
|
|
#define dprintk(level, format, a...) do{}while(0)
|
643 |
|
|
#define qla1280_dump_buffer(a, b, c) do{}while(0)
|
644 |
|
|
#define qla1280_print_scsi_cmd(a, b) do{}while(0)
|
645 |
|
|
#endif
|
646 |
|
|
|
647 |
|
|
#define ENTER(x) dprintk(3, "qla1280 : Entering %s()\n", x);
|
648 |
|
|
#define LEAVE(x) dprintk(3, "qla1280 : Leaving %s()\n", x);
|
649 |
|
|
#define ENTER_INTR(x) dprintk(4, "qla1280 : Entering %s()\n", x);
|
650 |
|
|
#define LEAVE_INTR(x) dprintk(4, "qla1280 : Leaving %s()\n", x);
|
651 |
|
|
|
652 |
|
|
|
653 |
|
|
/*************************************************************************
|
654 |
|
|
* qla1280_proc_info
|
655 |
|
|
*
|
656 |
|
|
* Description:
|
657 |
|
|
* Return information to handle /proc support for the driver.
|
658 |
|
|
*
|
659 |
|
|
* buffer - ptrs to a page buffer
|
660 |
|
|
*
|
661 |
|
|
* Returns:
|
662 |
|
|
*************************************************************************/
|
663 |
|
|
#define PROC_BUF &qla1280_buffer[len]
|
664 |
|
|
|
665 |
|
|
#if LINUX_VERSION_CODE < 0x020600
|
666 |
|
|
static int qla1280_proc_info(char *buffer, char **start, off_t offset,
|
667 |
|
|
int length, int hostno, int inout)
|
668 |
|
|
#else
|
669 |
|
|
static int qla1280_proc_info(struct Scsi_Host *host, char *buffer,
|
670 |
|
|
char **start, off_t offset, int length, int inout)
|
671 |
|
|
#endif
|
672 |
|
|
{
|
673 |
|
|
struct scsi_qla_host *ha;
|
674 |
|
|
int size = 0;
|
675 |
|
|
int len = 0;
|
676 |
|
|
struct qla_boards *bdp;
|
677 |
|
|
#ifdef BOGUS_QUEUE
|
678 |
|
|
struct scsi_lu *up;
|
679 |
|
|
uint32_t b, t, l;
|
680 |
|
|
#endif
|
681 |
|
|
#if LINUX_VERSION_CODE >= 0x020600
|
682 |
|
|
ha = (struct scsi_qla_host *)host->hostdata;
|
683 |
|
|
#else
|
684 |
|
|
struct Scsi_Host *host;
|
685 |
|
|
/* Find the host that was specified */
|
686 |
|
|
for (ha = qla1280_hostlist; (ha != NULL)
|
687 |
|
|
&& ha->host->host_no != hostno; ha = ha->next) ;
|
688 |
|
|
|
689 |
|
|
/* if host wasn't found then exit */
|
690 |
|
|
if (!ha) {
|
691 |
|
|
size = sprintf(buffer, "Can't find adapter for host "
|
692 |
|
|
"number %d\n", hostno);
|
693 |
|
|
if (size > length) {
|
694 |
|
|
return size;
|
695 |
|
|
} else {
|
696 |
|
|
return 0;
|
697 |
|
|
}
|
698 |
|
|
}
|
699 |
|
|
|
700 |
|
|
host = ha->host;
|
701 |
|
|
#endif
|
702 |
|
|
|
703 |
|
|
if (inout)
|
704 |
|
|
return -ENOSYS;
|
705 |
|
|
|
706 |
|
|
/*
|
707 |
|
|
* if our old buffer is the right size use it otherwise
|
708 |
|
|
* allocate a new one.
|
709 |
|
|
*/
|
710 |
|
|
if (qla1280_buffer_size != PAGE_SIZE) {
|
711 |
|
|
/* deallocate this buffer and get a new one */
|
712 |
|
|
if (qla1280_buffer != NULL) {
|
713 |
|
|
free_page((unsigned long)qla1280_buffer);
|
714 |
|
|
qla1280_buffer_size = 0;
|
715 |
|
|
}
|
716 |
|
|
qla1280_buffer = (char *)get_zeroed_page(GFP_KERNEL);
|
717 |
|
|
}
|
718 |
|
|
if (qla1280_buffer == NULL) {
|
719 |
|
|
size = sprintf(buffer, "qla1280 - kmalloc error at line %d\n",
|
720 |
|
|
__LINE__);
|
721 |
|
|
return size;
|
722 |
|
|
}
|
723 |
|
|
/* save the size of our buffer */
|
724 |
|
|
qla1280_buffer_size = PAGE_SIZE;
|
725 |
|
|
|
726 |
|
|
/* 3.20 clear the buffer we use for proc display */
|
727 |
|
|
memset(qla1280_buffer, 0, PAGE_SIZE);
|
728 |
|
|
|
729 |
|
|
/* start building the print buffer */
|
730 |
|
|
bdp = &ql1280_board_tbl[ha->devnum];
|
731 |
|
|
size = sprintf(PROC_BUF,
|
732 |
|
|
"QLogic PCI to SCSI Adapter for ISP 1280/12160:\n"
|
733 |
|
|
" Firmware version: %2d.%02d.%02d, Driver version %s\n",
|
734 |
|
|
bdp->fwver[0], bdp->fwver[1], bdp->fwver[2],
|
735 |
|
|
QLA1280_VERSION);
|
736 |
|
|
|
737 |
|
|
len += size;
|
738 |
|
|
|
739 |
|
|
size = sprintf(PROC_BUF, "SCSI Host Adapter Information: %s\n",
|
740 |
|
|
bdp->name);
|
741 |
|
|
len += size;
|
742 |
|
|
size = sprintf(PROC_BUF, "Request Queue count= 0x%x, Response "
|
743 |
|
|
"Queue count= 0x%x\n",
|
744 |
|
|
REQUEST_ENTRY_CNT, RESPONSE_ENTRY_CNT);
|
745 |
|
|
len += size;
|
746 |
|
|
size = sprintf(PROC_BUF, "Number of pending commands = 0x%lx\n",
|
747 |
|
|
ha->actthreads);
|
748 |
|
|
len += size;
|
749 |
|
|
size = sprintf(PROC_BUF, "Number of free request entries = %d\n",
|
750 |
|
|
ha->req_q_cnt);
|
751 |
|
|
len += size;
|
752 |
|
|
size = sprintf(PROC_BUF, "\n"); /* 1 */
|
753 |
|
|
len += size;
|
754 |
|
|
|
755 |
|
|
size = sprintf(PROC_BUF, "SCSI device Information:\n");
|
756 |
|
|
len += size;
|
757 |
|
|
#ifdef BOGUS_QUEUE
|
758 |
|
|
/* scan for all equipment stats */
|
759 |
|
|
for (b = 0; b < MAX_BUSES; b++)
|
760 |
|
|
for (t = 0; t < MAX_TARGETS; t++) {
|
761 |
|
|
for (l = 0; l < MAX_LUNS; l++) {
|
762 |
|
|
up = LU_Q(ha, b, t, l);
|
763 |
|
|
if (up == NULL)
|
764 |
|
|
continue;
|
765 |
|
|
/* unused device/lun */
|
766 |
|
|
if (up->io_cnt == 0 || up->io_cnt < 2)
|
767 |
|
|
continue;
|
768 |
|
|
/* total reads since boot */
|
769 |
|
|
/* total writes since boot */
|
770 |
|
|
/* total requests since boot */
|
771 |
|
|
size = sprintf (PROC_BUF,
|
772 |
|
|
"(%2d:%2d:%2d): Total reqs %ld,",
|
773 |
|
|
b, t, l, up->io_cnt);
|
774 |
|
|
len += size;
|
775 |
|
|
/* current number of pending requests */
|
776 |
|
|
size = sprintf(PROC_BUF, " Pend reqs %d,",
|
777 |
|
|
up->q_outcnt);
|
778 |
|
|
len += size;
|
779 |
|
|
#if 0
|
780 |
|
|
/* avg response time */
|
781 |
|
|
size = sprintf(PROC_BUF, " Avg resp time %ld%%,",
|
782 |
|
|
(up->resp_time / up->io_cnt) *
|
783 |
|
|
100);
|
784 |
|
|
len += size;
|
785 |
|
|
|
786 |
|
|
/* avg active time */
|
787 |
|
|
size = sprintf(PROC_BUF,
|
788 |
|
|
" Avg active time %ld%%\n",
|
789 |
|
|
(up->act_time / up->io_cnt) * 100);
|
790 |
|
|
#else
|
791 |
|
|
size = sprintf(PROC_BUF, "\n");
|
792 |
|
|
#endif
|
793 |
|
|
len += size;
|
794 |
|
|
}
|
795 |
|
|
if (len >= qla1280_buffer_size)
|
796 |
|
|
break;
|
797 |
|
|
}
|
798 |
|
|
#endif
|
799 |
|
|
|
800 |
|
|
if (len >= qla1280_buffer_size) {
|
801 |
|
|
printk(KERN_WARNING
|
802 |
|
|
"qla1280: Overflow buffer in qla1280_proc.c\n");
|
803 |
|
|
}
|
804 |
|
|
|
805 |
|
|
if (offset > len - 1) {
|
806 |
|
|
free_page((unsigned long) qla1280_buffer);
|
807 |
|
|
qla1280_buffer = NULL;
|
808 |
|
|
qla1280_buffer_size = length = 0;
|
809 |
|
|
*start = NULL;
|
810 |
|
|
} else {
|
811 |
|
|
*start = &qla1280_buffer[offset]; /* Start of wanted data */
|
812 |
|
|
if (len - offset < length) {
|
813 |
|
|
length = len - offset;
|
814 |
|
|
}
|
815 |
|
|
}
|
816 |
|
|
return length;
|
817 |
|
|
}
|
818 |
|
|
|
819 |
|
|
|
820 |
|
|
static int qla1280_read_nvram(struct scsi_qla_host *ha)
|
821 |
|
|
{
|
822 |
|
|
uint16_t *wptr;
|
823 |
|
|
uint8_t chksum;
|
824 |
|
|
int cnt;
|
825 |
|
|
struct nvram *nv;
|
826 |
|
|
|
827 |
|
|
ENTER("qla1280_read_nvram");
|
828 |
|
|
|
829 |
|
|
if (driver_setup.no_nvram)
|
830 |
|
|
return 1;
|
831 |
|
|
|
832 |
|
|
printk(KERN_INFO "scsi(%ld): Reading NVRAM\n", ha->host_no);
|
833 |
|
|
|
834 |
|
|
wptr = (uint16_t *)&ha->nvram;
|
835 |
|
|
nv = &ha->nvram;
|
836 |
|
|
chksum = 0;
|
837 |
|
|
for (cnt = 0; cnt < 3; cnt++) {
|
838 |
|
|
*wptr = qla1280_get_nvram_word(ha, cnt);
|
839 |
|
|
chksum += *wptr & 0xff;
|
840 |
|
|
chksum += (*wptr >> 8) & 0xff;
|
841 |
|
|
wptr++;
|
842 |
|
|
}
|
843 |
|
|
|
844 |
|
|
if (nv->id0 != 'I' || nv->id1 != 'S' ||
|
845 |
|
|
nv->id2 != 'P' || nv->id3 != ' ' || nv->version < 1) {
|
846 |
|
|
dprintk(2, "Invalid nvram ID or version!\n");
|
847 |
|
|
chksum = 1;
|
848 |
|
|
} else {
|
849 |
|
|
for (; cnt < sizeof(struct nvram); cnt++) {
|
850 |
|
|
*wptr = qla1280_get_nvram_word(ha, cnt);
|
851 |
|
|
chksum += *wptr & 0xff;
|
852 |
|
|
chksum += (*wptr >> 8) & 0xff;
|
853 |
|
|
wptr++;
|
854 |
|
|
}
|
855 |
|
|
}
|
856 |
|
|
|
857 |
|
|
dprintk(3, "qla1280_read_nvram: NVRAM Magic ID= %c %c %c %02x"
|
858 |
|
|
" version %i\n", nv->id0, nv->id1, nv->id2, nv->id3,
|
859 |
|
|
nv->version);
|
860 |
|
|
|
861 |
|
|
|
862 |
|
|
if (chksum) {
|
863 |
|
|
if (!driver_setup.no_nvram)
|
864 |
|
|
printk(KERN_WARNING "scsi(%ld): Unable to identify or "
|
865 |
|
|
"validate NVRAM checksum, using default "
|
866 |
|
|
"settings\n", ha->host_no);
|
867 |
|
|
ha->nvram_valid = 0;
|
868 |
|
|
} else
|
869 |
|
|
ha->nvram_valid = 1;
|
870 |
|
|
|
871 |
|
|
dprintk(1, "qla1280_read_nvram: Completed Reading NVRAM\n");
|
872 |
|
|
LEAVE("qla1280_read_nvram");
|
873 |
|
|
|
874 |
|
|
return chksum;
|
875 |
|
|
}
|
876 |
|
|
|
877 |
|
|
|
878 |
|
|
/**************************************************************************
|
879 |
|
|
* qla1280_do_device_init
|
880 |
|
|
* This routine will register the device with the SCSI subsystem,
|
881 |
|
|
* initialize the host adapter structure and call the device init
|
882 |
|
|
* routines.
|
883 |
|
|
*
|
884 |
|
|
* Input:
|
885 |
|
|
* pdev - pointer to struct pci_dev for adapter
|
886 |
|
|
* template - pointer to SCSI template
|
887 |
|
|
* devnum - the device number
|
888 |
|
|
* bdp - pointer to struct _qlaboards
|
889 |
|
|
* num_hosts - the host number
|
890 |
|
|
*
|
891 |
|
|
* Returns:
|
892 |
|
|
* host - pointer to SCSI host structure
|
893 |
|
|
**************************************************************************/
|
894 |
|
|
struct Scsi_Host *
|
895 |
|
|
qla1280_do_device_init(struct pci_dev *pdev, Scsi_Host_Template * template,
|
896 |
|
|
int devnum, struct qla_boards *bdp, int num_hosts)
|
897 |
|
|
{
|
898 |
|
|
struct Scsi_Host *host;
|
899 |
|
|
struct scsi_qla_host *ha;
|
900 |
|
|
|
901 |
|
|
printk(KERN_INFO "qla1280: %s found on PCI bus %i, dev %i\n",
|
902 |
|
|
bdp->name, pdev->bus->number, PCI_SLOT(pdev->devfn));
|
903 |
|
|
|
904 |
|
|
host = scsi_register(template, sizeof(struct scsi_qla_host));
|
905 |
|
|
if (!host) {
|
906 |
|
|
printk(KERN_WARNING
|
907 |
|
|
"qla1280: Failed to register host, aborting.\n");
|
908 |
|
|
goto error;
|
909 |
|
|
}
|
910 |
|
|
|
911 |
|
|
#if LINUX_VERSION_CODE < 0x020545
|
912 |
|
|
scsi_set_pci_device(host, pdev);
|
913 |
|
|
#else
|
914 |
|
|
scsi_set_device(host, &pdev->dev);
|
915 |
|
|
#endif
|
916 |
|
|
ha = (struct scsi_qla_host *)host->hostdata;
|
917 |
|
|
/* Clear our data area */
|
918 |
|
|
memset(ha, 0, sizeof(struct scsi_qla_host));
|
919 |
|
|
/* Sanitize the information from PCI BIOS. */
|
920 |
|
|
host->irq = pdev->irq;
|
921 |
|
|
ha->pci_bus = pdev->bus->number;
|
922 |
|
|
ha->pci_device_fn = pdev->devfn;
|
923 |
|
|
ha->pdev = pdev;
|
924 |
|
|
ha->device_id = bdp->device_id;
|
925 |
|
|
ha->devnum = devnum; /* specifies microcode load address */
|
926 |
|
|
|
927 |
|
|
if (qla1280_mem_alloc(ha)) {
|
928 |
|
|
printk(KERN_INFO "qla1x160: Failed to get memory\n");
|
929 |
|
|
goto error_scsi_unregister;
|
930 |
|
|
}
|
931 |
|
|
|
932 |
|
|
ha->ports = bdp->numPorts;
|
933 |
|
|
/* following needed for all cases of OS versions */
|
934 |
|
|
ha->host = host;
|
935 |
|
|
ha->host_no = host->host_no;
|
936 |
|
|
|
937 |
|
|
host->can_queue = 0xfffff; /* unlimited */
|
938 |
|
|
host->cmd_per_lun = 1;
|
939 |
|
|
host->base = (unsigned long)ha->mmpbase;
|
940 |
|
|
host->max_channel = bdp->numPorts - 1;
|
941 |
|
|
host->max_lun = MAX_LUNS - 1;
|
942 |
|
|
host->max_id = MAX_TARGETS;
|
943 |
|
|
host->max_sectors = 1024;
|
944 |
|
|
#if LINUX_VERSION_CODE < 0x020545
|
945 |
|
|
host->select_queue_depths = qla1280_select_queue_depth;
|
946 |
|
|
#endif
|
947 |
|
|
|
948 |
|
|
ha->instance = num_hosts;
|
949 |
|
|
host->unique_id = ha->instance;
|
950 |
|
|
|
951 |
|
|
if (qla1280_pci_config(ha)) {
|
952 |
|
|
printk(KERN_INFO "qla1x160: Unable to configure PCI\n");
|
953 |
|
|
goto error_mem_alloced;
|
954 |
|
|
}
|
955 |
|
|
|
956 |
|
|
/* Disable ISP interrupts. */
|
957 |
|
|
qla1280_disable_intrs(ha);
|
958 |
|
|
|
959 |
|
|
/* Register the IRQ with Linux (sharable) */
|
960 |
|
|
if (request_irq(host->irq, qla1280_intr_handler, SA_SHIRQ,
|
961 |
|
|
"qla1280", ha)) {
|
962 |
|
|
printk("qla1280 : Failed to reserve interrupt %d already "
|
963 |
|
|
"in use\n", host->irq);
|
964 |
|
|
goto error_iounmap;
|
965 |
|
|
}
|
966 |
|
|
#if !MEMORY_MAPPED_IO
|
967 |
|
|
/* Register the I/O space with Linux */
|
968 |
|
|
if (!request_region(host->io_port, 0xff, "qla1280")) {
|
969 |
|
|
printk("qla1280: Failed to reserve i/o region 0x%04lx-0x%04lx"
|
970 |
|
|
" already in use\n",
|
971 |
|
|
host->io_port, host->io_port + 0xff);
|
972 |
|
|
goto error_free_irq;
|
973 |
|
|
}
|
974 |
|
|
#endif
|
975 |
|
|
|
976 |
|
|
/* load the F/W, read paramaters, and init the H/W */
|
977 |
|
|
if (qla1280_initialize_adapter(ha)) {
|
978 |
|
|
printk(KERN_INFO "qla1x160: Failed to initialize adapter\n");
|
979 |
|
|
goto error_release_region;
|
980 |
|
|
}
|
981 |
|
|
|
982 |
|
|
/* set our host ID (need to do something about our two IDs) */
|
983 |
|
|
host->this_id = ha->bus_settings[0].id;
|
984 |
|
|
|
985 |
|
|
return host;
|
986 |
|
|
|
987 |
|
|
error_release_region:
|
988 |
|
|
#if !MEMORY_MAPPED_IO
|
989 |
|
|
release_region(host->io_port, 0xff);
|
990 |
|
|
error_free_irq:
|
991 |
|
|
#endif
|
992 |
|
|
free_irq(host->irq, ha);
|
993 |
|
|
error_iounmap:
|
994 |
|
|
#if MEMORY_MAPPED_IO
|
995 |
|
|
if (ha->mmpbase)
|
996 |
|
|
iounmap((void *)(((unsigned long) ha->mmpbase) & PAGE_MASK));
|
997 |
|
|
#endif
|
998 |
|
|
error_mem_alloced:
|
999 |
|
|
qla1280_mem_free(ha);
|
1000 |
|
|
error_scsi_unregister:
|
1001 |
|
|
scsi_unregister(host);
|
1002 |
|
|
error:
|
1003 |
|
|
return NULL;
|
1004 |
|
|
}
|
1005 |
|
|
|
1006 |
|
|
/**************************************************************************
|
1007 |
|
|
* qla1280_detect
|
1008 |
|
|
* This routine will probe for Qlogic 1280 SCSI host adapters.
|
1009 |
|
|
* It returns the number of host adapters of a particular
|
1010 |
|
|
* type that were found. It also initialize all data necessary for
|
1011 |
|
|
* the driver. It is passed-in the host number, so that it
|
1012 |
|
|
* knows where its first entry is in the scsi_hosts[] array.
|
1013 |
|
|
*
|
1014 |
|
|
* Input:
|
1015 |
|
|
* template - pointer to SCSI template
|
1016 |
|
|
*
|
1017 |
|
|
* Returns:
|
1018 |
|
|
* num - number of host adapters found.
|
1019 |
|
|
**************************************************************************/
|
1020 |
|
|
static int
|
1021 |
|
|
qla1280_detect(Scsi_Host_Template * template)
|
1022 |
|
|
{
|
1023 |
|
|
struct pci_dev *pdev = NULL;
|
1024 |
|
|
struct Scsi_Host *host;
|
1025 |
|
|
struct scsi_qla_host *ha, *cur_ha;
|
1026 |
|
|
struct qla_boards *bdp;
|
1027 |
|
|
uint16_t subsys_vendor, subsys_device;
|
1028 |
|
|
int num_hosts = 0;
|
1029 |
|
|
int devnum = 0;
|
1030 |
|
|
|
1031 |
|
|
ENTER("qla1280_detect");
|
1032 |
|
|
|
1033 |
|
|
if (sizeof(struct srb) > sizeof(Scsi_Pointer)) {
|
1034 |
|
|
printk(KERN_WARNING
|
1035 |
|
|
"qla1280_detect: [WARNING] struct srb too big\n");
|
1036 |
|
|
return 0;
|
1037 |
|
|
}
|
1038 |
|
|
#ifdef MODULE
|
1039 |
|
|
/*
|
1040 |
|
|
* If we are called as a module, the qla1280 pointer may not be null
|
1041 |
|
|
* and it would point to our bootup string, just like on the lilo
|
1042 |
|
|
* command line. IF not NULL, then process this config string with
|
1043 |
|
|
* qla1280_setup
|
1044 |
|
|
*
|
1045 |
|
|
* Boot time Options
|
1046 |
|
|
* To add options at boot time add a line to your lilo.conf file like:
|
1047 |
|
|
* append="qla1280=verbose,max_tags:{{255,255,255,255},{255,255,255,255}}"
|
1048 |
|
|
* which will result in the first four devices on the first two
|
1049 |
|
|
* controllers being set to a tagged queue depth of 32.
|
1050 |
|
|
*/
|
1051 |
|
|
if (qla1280)
|
1052 |
|
|
qla1280_setup(qla1280);
|
1053 |
|
|
#endif
|
1054 |
|
|
|
1055 |
|
|
bdp = &ql1280_board_tbl[0];
|
1056 |
|
|
qla1280_hostlist = NULL;
|
1057 |
|
|
template->proc_name = "qla1280";
|
1058 |
|
|
|
1059 |
|
|
/* First Initialize QLA12160 on PCI Bus 1 Dev 2 */
|
1060 |
|
|
while ((pdev = pci_find_subsys(PCI_VENDOR_ID_QLOGIC, bdp->device_id,
|
1061 |
|
|
PCI_ANY_ID, PCI_ANY_ID, pdev))) {
|
1062 |
|
|
|
1063 |
|
|
/* find QLA12160 device on PCI bus=1 slot=2 */
|
1064 |
|
|
if ((pdev->bus->number != 1) || (PCI_SLOT(pdev->devfn) != 2))
|
1065 |
|
|
continue;
|
1066 |
|
|
|
1067 |
|
|
/* Bypass all AMI SUBSYS VENDOR IDs */
|
1068 |
|
|
if (pdev->subsystem_vendor == PCI_VENDOR_ID_AMI) {
|
1069 |
|
|
printk(KERN_INFO
|
1070 |
|
|
"qla1x160: Skip AMI SubSys Vendor ID Chip\n");
|
1071 |
|
|
continue;
|
1072 |
|
|
}
|
1073 |
|
|
|
1074 |
|
|
if (pci_enable_device(pdev))
|
1075 |
|
|
goto find_devices;
|
1076 |
|
|
|
1077 |
|
|
host = qla1280_do_device_init(pdev, template, devnum,
|
1078 |
|
|
bdp, num_hosts);
|
1079 |
|
|
if (!host)
|
1080 |
|
|
continue;
|
1081 |
|
|
ha = (struct scsi_qla_host *)host->hostdata;
|
1082 |
|
|
|
1083 |
|
|
/* this preferred device will always be the first one found */
|
1084 |
|
|
cur_ha = qla1280_hostlist = ha;
|
1085 |
|
|
num_hosts++;
|
1086 |
|
|
}
|
1087 |
|
|
|
1088 |
|
|
find_devices:
|
1089 |
|
|
|
1090 |
|
|
pdev = NULL;
|
1091 |
|
|
/* Try and find each different type of adapter we support */
|
1092 |
|
|
for (devnum = 0; bdp->device_id != 0 && devnum < NUM_OF_ISP_DEVICES;
|
1093 |
|
|
devnum++, bdp++) {
|
1094 |
|
|
/* PCI_SUBSYSTEM_IDS supported */
|
1095 |
|
|
while ((pdev = pci_find_subsys(PCI_VENDOR_ID_QLOGIC,
|
1096 |
|
|
bdp->device_id, PCI_ANY_ID,
|
1097 |
|
|
PCI_ANY_ID, pdev))) {
|
1098 |
|
|
if (pci_enable_device(pdev))
|
1099 |
|
|
continue;
|
1100 |
|
|
/* found an adapter */
|
1101 |
|
|
subsys_vendor = pdev->subsystem_vendor;
|
1102 |
|
|
subsys_device = pdev->subsystem_device;
|
1103 |
|
|
|
1104 |
|
|
/*
|
1105 |
|
|
* skip QLA12160 already initialized on
|
1106 |
|
|
* PCI Bus 1 Dev 2 since we already initialized
|
1107 |
|
|
* and presented it
|
1108 |
|
|
*/
|
1109 |
|
|
if ((bdp->device_id == PCI_DEVICE_ID_QLOGIC_ISP12160)&&
|
1110 |
|
|
(pdev->bus->number == 1) &&
|
1111 |
|
|
(PCI_SLOT(pdev->devfn) == 2))
|
1112 |
|
|
continue;
|
1113 |
|
|
|
1114 |
|
|
/* Bypass all AMI SUBSYS VENDOR IDs */
|
1115 |
|
|
if (subsys_vendor == PCI_VENDOR_ID_AMI) {
|
1116 |
|
|
printk(KERN_INFO
|
1117 |
|
|
"qla1x160: Skip AMI SubSys Vendor ID Chip\n");
|
1118 |
|
|
continue;
|
1119 |
|
|
}
|
1120 |
|
|
dprintk(1, "qla1x160: Supported Device Found VID=%x "
|
1121 |
|
|
"DID=%x SSVID=%x SSDID=%x\n", pdev->vendor,
|
1122 |
|
|
pdev->device, subsys_vendor, subsys_device);
|
1123 |
|
|
|
1124 |
|
|
host = qla1280_do_device_init(pdev, template,
|
1125 |
|
|
devnum, bdp, num_hosts);
|
1126 |
|
|
if (!host)
|
1127 |
|
|
continue;
|
1128 |
|
|
ha = (struct scsi_qla_host *)host->hostdata;
|
1129 |
|
|
|
1130 |
|
|
if (qla1280_hostlist == NULL) {
|
1131 |
|
|
cur_ha = qla1280_hostlist = ha;
|
1132 |
|
|
} else {
|
1133 |
|
|
cur_ha = qla1280_hostlist;
|
1134 |
|
|
while (cur_ha->next != NULL)
|
1135 |
|
|
cur_ha = cur_ha->next;
|
1136 |
|
|
cur_ha->next = ha;
|
1137 |
|
|
}
|
1138 |
|
|
num_hosts++;
|
1139 |
|
|
} /* end of WHILE */
|
1140 |
|
|
} /* end of FOR */
|
1141 |
|
|
|
1142 |
|
|
LEAVE("qla1280_detect");
|
1143 |
|
|
return num_hosts;
|
1144 |
|
|
}
|
1145 |
|
|
|
1146 |
|
|
/**************************************************************************
|
1147 |
|
|
* qla1280_release
|
1148 |
|
|
* Free the passed in Scsi_Host memory structures prior to unloading the
|
1149 |
|
|
* module.
|
1150 |
|
|
**************************************************************************/
|
1151 |
|
|
static int
|
1152 |
|
|
qla1280_release(struct Scsi_Host *host)
|
1153 |
|
|
{
|
1154 |
|
|
struct scsi_qla_host *ha = (struct scsi_qla_host *)host->hostdata;
|
1155 |
|
|
|
1156 |
|
|
ENTER("qla1280_release");
|
1157 |
|
|
|
1158 |
|
|
if (!ha->flags.online)
|
1159 |
|
|
return 0;
|
1160 |
|
|
|
1161 |
|
|
/* turn-off interrupts on the card */
|
1162 |
|
|
WRT_REG_WORD(&ha->iobase->ictrl, 0);
|
1163 |
|
|
|
1164 |
|
|
/* Detach interrupts */
|
1165 |
|
|
if (host->irq)
|
1166 |
|
|
free_irq(host->irq, ha);
|
1167 |
|
|
|
1168 |
|
|
#if MEMORY_MAPPED_IO
|
1169 |
|
|
if (ha->mmpbase)
|
1170 |
|
|
iounmap(ha->mmpbase);
|
1171 |
|
|
#else
|
1172 |
|
|
/* release io space registers */
|
1173 |
|
|
if (host->io_port)
|
1174 |
|
|
release_region(host->io_port, 0xff);
|
1175 |
|
|
#endif /* MEMORY_MAPPED_IO */
|
1176 |
|
|
|
1177 |
|
|
qla1280_mem_free(ha);
|
1178 |
|
|
|
1179 |
|
|
ENTER("qla1280_release");
|
1180 |
|
|
return 0;
|
1181 |
|
|
}
|
1182 |
|
|
|
1183 |
|
|
/**************************************************************************
|
1184 |
|
|
* qla1280_info
|
1185 |
|
|
* Return a string describing the driver.
|
1186 |
|
|
**************************************************************************/
|
1187 |
|
|
static const char *
|
1188 |
|
|
qla1280_info(struct Scsi_Host *host)
|
1189 |
|
|
{
|
1190 |
|
|
static char qla1280_scsi_name_buffer[125];
|
1191 |
|
|
char *bp;
|
1192 |
|
|
struct scsi_qla_host *ha;
|
1193 |
|
|
struct qla_boards *bdp;
|
1194 |
|
|
|
1195 |
|
|
bp = &qla1280_scsi_name_buffer[0];
|
1196 |
|
|
ha = (struct scsi_qla_host *)host->hostdata;
|
1197 |
|
|
bdp = &ql1280_board_tbl[ha->devnum];
|
1198 |
|
|
memset(bp, 0, sizeof(qla1280_scsi_name_buffer));
|
1199 |
|
|
sprintf (bp,
|
1200 |
|
|
"QLogic %s PCI to SCSI Host Adapter: bus %d device %d irq %d\n"
|
1201 |
|
|
" Firmware version: %2d.%02d.%02d, Driver version %s",
|
1202 |
|
|
&bdp->name[0], ha->pci_bus, (ha->pci_device_fn & 0xf8) >> 3,
|
1203 |
|
|
host->irq, bdp->fwver[0], bdp->fwver[1], bdp->fwver[2],
|
1204 |
|
|
QLA1280_VERSION);
|
1205 |
|
|
return bp;
|
1206 |
|
|
}
|
1207 |
|
|
|
1208 |
|
|
/**************************************************************************
|
1209 |
|
|
* qla1200_queuecommand
|
1210 |
|
|
* Queue a command to the controller.
|
1211 |
|
|
*
|
1212 |
|
|
* Note:
|
1213 |
|
|
* The mid-level driver tries to ensures that queuecommand never gets invoked
|
1214 |
|
|
* concurrently with itself or the interrupt handler (although the
|
1215 |
|
|
* interrupt handler may call this routine as part of request-completion
|
1216 |
|
|
* handling). Unfortunely, it sometimes calls the scheduler in interrupt
|
1217 |
|
|
* context which is a big NO! NO!.
|
1218 |
|
|
**************************************************************************/
|
1219 |
|
|
static int
|
1220 |
|
|
qla1280_queuecommand(Scsi_Cmnd * cmd, void (*fn) (Scsi_Cmnd *))
|
1221 |
|
|
{
|
1222 |
|
|
struct scsi_qla_host *ha;
|
1223 |
|
|
struct srb *sp;
|
1224 |
|
|
struct Scsi_Host *host;
|
1225 |
|
|
int bus, target, lun;
|
1226 |
|
|
int status;
|
1227 |
|
|
|
1228 |
|
|
/*ENTER("qla1280_queuecommand");
|
1229 |
|
|
*/
|
1230 |
|
|
dprintk(2, "qla1280_queuecommand(): jiffies %li\n", jiffies);
|
1231 |
|
|
|
1232 |
|
|
host = CMD_HOST(cmd);
|
1233 |
|
|
ha = (struct scsi_qla_host *)host->hostdata;
|
1234 |
|
|
|
1235 |
|
|
/* send command to adapter */
|
1236 |
|
|
sp = (struct srb *)CMD_SP(cmd);
|
1237 |
|
|
sp->cmd = cmd;
|
1238 |
|
|
cmd->scsi_done = fn;
|
1239 |
|
|
sp->flags = 0;
|
1240 |
|
|
|
1241 |
|
|
qla1280_print_scsi_cmd(5, cmd);
|
1242 |
|
|
|
1243 |
|
|
/* Generate LU queue on bus, target, LUN */
|
1244 |
|
|
bus = SCSI_BUS_32(cmd);
|
1245 |
|
|
target = SCSI_TCN_32(cmd);
|
1246 |
|
|
lun = SCSI_LUN_32(cmd);
|
1247 |
|
|
if (ha->flags.enable_64bit_addressing)
|
1248 |
|
|
status = qla1280_64bit_start_scsi(ha, sp);
|
1249 |
|
|
else
|
1250 |
|
|
status = qla1280_32bit_start_scsi(ha, sp);
|
1251 |
|
|
|
1252 |
|
|
/*LEAVE("qla1280_queuecommand"); */
|
1253 |
|
|
return status;
|
1254 |
|
|
}
|
1255 |
|
|
|
1256 |
|
|
enum action {
|
1257 |
|
|
ABORT_COMMAND,
|
1258 |
|
|
ABORT_DEVICE,
|
1259 |
|
|
DEVICE_RESET,
|
1260 |
|
|
BUS_RESET,
|
1261 |
|
|
ADAPTER_RESET,
|
1262 |
|
|
FAIL
|
1263 |
|
|
};
|
1264 |
|
|
|
1265 |
|
|
/* timer action for error action processor */
|
1266 |
|
|
static void qla1280_error_wait_timeout(unsigned long __data)
|
1267 |
|
|
{
|
1268 |
|
|
struct scsi_cmnd *cmd = (struct scsi_cmnd *)__data;
|
1269 |
|
|
struct srb *sp = (struct srb *)CMD_SP(cmd);
|
1270 |
|
|
|
1271 |
|
|
complete(sp->wait);
|
1272 |
|
|
}
|
1273 |
|
|
|
1274 |
|
|
static void qla1280_mailbox_timeout(unsigned long __data)
|
1275 |
|
|
{
|
1276 |
|
|
struct scsi_qla_host *ha = (struct scsi_qla_host *)__data;
|
1277 |
|
|
struct device_reg *reg;
|
1278 |
|
|
reg = ha->iobase;
|
1279 |
|
|
|
1280 |
|
|
ha->mailbox_out[0] = RD_REG_WORD(®->mailbox0);
|
1281 |
|
|
printk(KERN_ERR "scsi(%ld): mailbox timed out, mailbox0 %04x, "
|
1282 |
|
|
"ictrl %04x, istatus %04x\n", ha->host_no, ha->mailbox_out[0],
|
1283 |
|
|
RD_REG_WORD(®->ictrl), RD_REG_WORD(®->istatus));
|
1284 |
|
|
complete(ha->mailbox_wait);
|
1285 |
|
|
}
|
1286 |
|
|
|
1287 |
|
|
/**************************************************************************
|
1288 |
|
|
* qla1200_error_action
|
1289 |
|
|
* The function will attempt to perform a specified error action and
|
1290 |
|
|
* wait for the results (or time out).
|
1291 |
|
|
*
|
1292 |
|
|
* Input:
|
1293 |
|
|
* cmd = Linux SCSI command packet of the command that cause the
|
1294 |
|
|
* bus reset.
|
1295 |
|
|
* action = error action to take (see action_t)
|
1296 |
|
|
*
|
1297 |
|
|
* Returns:
|
1298 |
|
|
* SUCCESS or FAILED
|
1299 |
|
|
*
|
1300 |
|
|
* Note:
|
1301 |
|
|
* Resetting the bus always succeeds - is has to, otherwise the
|
1302 |
|
|
* kernel will panic! Try a surgical technique - sending a BUS
|
1303 |
|
|
* DEVICE RESET message - on the offending target before pulling
|
1304 |
|
|
* the SCSI bus reset line.
|
1305 |
|
|
**************************************************************************/
|
1306 |
|
|
static int
|
1307 |
|
|
qla1280_error_action(Scsi_Cmnd * cmd, enum action action)
|
1308 |
|
|
{
|
1309 |
|
|
struct scsi_qla_host *ha;
|
1310 |
|
|
int bus, target, lun;
|
1311 |
|
|
struct srb *sp;
|
1312 |
|
|
uint16_t data;
|
1313 |
|
|
unsigned char *handle;
|
1314 |
|
|
int result, i;
|
1315 |
|
|
DECLARE_COMPLETION(wait);
|
1316 |
|
|
struct timer_list timer;
|
1317 |
|
|
|
1318 |
|
|
ha = (struct scsi_qla_host *)(CMD_HOST(cmd)->hostdata);
|
1319 |
|
|
|
1320 |
|
|
dprintk(4, "error_action %i, istatus 0x%04x\n", action,
|
1321 |
|
|
RD_REG_WORD(&ha->iobase->istatus));
|
1322 |
|
|
|
1323 |
|
|
dprintk(4, "host_cmd 0x%04x, ictrl 0x%04x, jiffies %li\n",
|
1324 |
|
|
RD_REG_WORD(&ha->iobase->host_cmd),
|
1325 |
|
|
RD_REG_WORD(&ha->iobase->ictrl), jiffies);
|
1326 |
|
|
|
1327 |
|
|
ENTER("qla1280_error_action");
|
1328 |
|
|
if (qla1280_verbose)
|
1329 |
|
|
printk(KERN_INFO "scsi(%li): Resetting Cmnd=0x%p, "
|
1330 |
|
|
"Handle=0x%p, action=0x%x\n",
|
1331 |
|
|
ha->host_no, cmd, CMD_HANDLE(cmd), action);
|
1332 |
|
|
|
1333 |
|
|
if (cmd == NULL) {
|
1334 |
|
|
printk(KERN_WARNING "(scsi?:?:?:?) Reset called with NULL "
|
1335 |
|
|
"si_Cmnd pointer, failing.\n");
|
1336 |
|
|
LEAVE("qla1280_error_action");
|
1337 |
|
|
return FAILED;
|
1338 |
|
|
}
|
1339 |
|
|
|
1340 |
|
|
ha = (struct scsi_qla_host *)cmd->device->host->hostdata;
|
1341 |
|
|
sp = (struct srb *)CMD_SP(cmd);
|
1342 |
|
|
handle = CMD_HANDLE(cmd);
|
1343 |
|
|
|
1344 |
|
|
/* Check for pending interrupts. */
|
1345 |
|
|
data = qla1280_debounce_register(&ha->iobase->istatus);
|
1346 |
|
|
/*
|
1347 |
|
|
* The io_request_lock is held when the reset handler is called, hence
|
1348 |
|
|
* the interrupt handler cannot be running in parallel as it also
|
1349 |
|
|
* grabs the lock. /Jes
|
1350 |
|
|
*/
|
1351 |
|
|
if (data & RISC_INT)
|
1352 |
|
|
qla1280_isr(ha, &ha->done_q_first, &ha->done_q_last);
|
1353 |
|
|
|
1354 |
|
|
/*
|
1355 |
|
|
* Determine the suggested action that the mid-level driver wants
|
1356 |
|
|
* us to perform.
|
1357 |
|
|
*/
|
1358 |
|
|
if (handle == (unsigned char *)INVALID_HANDLE || handle == NULL) {
|
1359 |
|
|
if(action == ABORT_COMMAND) {
|
1360 |
|
|
/* we never got this command */
|
1361 |
|
|
printk(KERN_INFO "qla1280: Aborting a NULL handle\n");
|
1362 |
|
|
return SUCCESS; /* no action - we don't have command */
|
1363 |
|
|
}
|
1364 |
|
|
} else {
|
1365 |
|
|
sp->wait = &wait;
|
1366 |
|
|
}
|
1367 |
|
|
|
1368 |
|
|
bus = SCSI_BUS_32(cmd);
|
1369 |
|
|
target = SCSI_TCN_32(cmd);
|
1370 |
|
|
lun = SCSI_LUN_32(cmd);
|
1371 |
|
|
|
1372 |
|
|
/* Overloading result. Here it means the success or fail of the
|
1373 |
|
|
* *issue* of the action. When we return from the routine, it must
|
1374 |
|
|
* mean the actual success or fail of the action */
|
1375 |
|
|
result = FAILED;
|
1376 |
|
|
switch (action) {
|
1377 |
|
|
case FAIL:
|
1378 |
|
|
break;
|
1379 |
|
|
|
1380 |
|
|
case ABORT_COMMAND:
|
1381 |
|
|
if ((sp->flags & SRB_ABORT_PENDING)) {
|
1382 |
|
|
printk(KERN_WARNING
|
1383 |
|
|
"scsi(): Command has a pending abort "
|
1384 |
|
|
"message - ABORT_PENDING.\n");
|
1385 |
|
|
/* This should technically be impossible since we
|
1386 |
|
|
* now wait for abort completion */
|
1387 |
|
|
break;
|
1388 |
|
|
}
|
1389 |
|
|
|
1390 |
|
|
for (i = 0; i < MAX_OUTSTANDING_COMMANDS; i++) {
|
1391 |
|
|
if (sp == ha->outstanding_cmds[i]) {
|
1392 |
|
|
dprintk(1, "qla1280: RISC aborting command\n");
|
1393 |
|
|
if (qla1280_abort_command(ha, sp, i) == 0)
|
1394 |
|
|
result = SUCCESS;
|
1395 |
|
|
else {
|
1396 |
|
|
/*
|
1397 |
|
|
* Since we don't know what might
|
1398 |
|
|
* have happend to the command, it
|
1399 |
|
|
* is unsafe to remove it from the
|
1400 |
|
|
* device's queue at this point.
|
1401 |
|
|
* Wait and let the escalation
|
1402 |
|
|
* process take care of it.
|
1403 |
|
|
*/
|
1404 |
|
|
printk(KERN_WARNING
|
1405 |
|
|
"scsi(%li:%i:%i:%i): Unable"
|
1406 |
|
|
" to abort command!\n",
|
1407 |
|
|
ha->host_no, bus, target, lun);
|
1408 |
|
|
}
|
1409 |
|
|
}
|
1410 |
|
|
}
|
1411 |
|
|
break;
|
1412 |
|
|
|
1413 |
|
|
case ABORT_DEVICE:
|
1414 |
|
|
ha->flags.in_reset = 1;
|
1415 |
|
|
if (qla1280_verbose)
|
1416 |
|
|
printk(KERN_INFO
|
1417 |
|
|
"scsi(%ld:%d:%d:%d): Queueing abort device "
|
1418 |
|
|
"command.\n", ha->host_no, bus, target, lun);
|
1419 |
|
|
if (qla1280_abort_device(ha, bus, target, lun) == 0)
|
1420 |
|
|
result = SUCCESS;
|
1421 |
|
|
break;
|
1422 |
|
|
|
1423 |
|
|
case DEVICE_RESET:
|
1424 |
|
|
if (qla1280_verbose)
|
1425 |
|
|
printk(KERN_INFO
|
1426 |
|
|
"scsi(%ld:%d:%d:%d): Queueing device reset "
|
1427 |
|
|
"command.\n", ha->host_no, bus, target, lun);
|
1428 |
|
|
ha->flags.in_reset = 1;
|
1429 |
|
|
if (qla1280_device_reset(ha, bus, target) == 0)
|
1430 |
|
|
result = SUCCESS;
|
1431 |
|
|
break;
|
1432 |
|
|
|
1433 |
|
|
case BUS_RESET:
|
1434 |
|
|
if (qla1280_verbose)
|
1435 |
|
|
printk(KERN_INFO "qla1280(%ld:%d): Issuing BUS "
|
1436 |
|
|
"DEVICE RESET\n", ha->host_no, bus);
|
1437 |
|
|
ha->flags.in_reset = 1;
|
1438 |
|
|
if (qla1280_bus_reset(ha, bus == 0))
|
1439 |
|
|
result = SUCCESS;
|
1440 |
|
|
|
1441 |
|
|
break;
|
1442 |
|
|
|
1443 |
|
|
case ADAPTER_RESET:
|
1444 |
|
|
default:
|
1445 |
|
|
if (qla1280_verbose) {
|
1446 |
|
|
printk(KERN_INFO
|
1447 |
|
|
"scsi(%ld): Issued ADAPTER RESET\n",
|
1448 |
|
|
ha->host_no);
|
1449 |
|
|
printk(KERN_INFO "scsi(%ld): I/O processing will "
|
1450 |
|
|
"continue automatically\n", ha->host_no);
|
1451 |
|
|
}
|
1452 |
|
|
ha->flags.reset_active = 1;
|
1453 |
|
|
/*
|
1454 |
|
|
* We restarted all of the commands automatically, so the
|
1455 |
|
|
* mid-level code can expect completions momentitarily.
|
1456 |
|
|
*/
|
1457 |
|
|
if (qla1280_abort_isp(ha) == 0)
|
1458 |
|
|
result = SUCCESS;
|
1459 |
|
|
|
1460 |
|
|
ha->flags.reset_active = 0;
|
1461 |
|
|
}
|
1462 |
|
|
|
1463 |
|
|
if (ha->done_q_first)
|
1464 |
|
|
qla1280_done(ha, &ha->done_q_first, &ha->done_q_last);
|
1465 |
|
|
ha->flags.in_reset = 0;
|
1466 |
|
|
|
1467 |
|
|
/* If we didn't manage to issue the action, or we have no
|
1468 |
|
|
* command to wait for, exit here */
|
1469 |
|
|
if (result == FAILED || handle == NULL ||
|
1470 |
|
|
handle == (unsigned char *)INVALID_HANDLE)
|
1471 |
|
|
goto leave;
|
1472 |
|
|
|
1473 |
|
|
/* set up a timer just in case we're really jammed */
|
1474 |
|
|
init_timer(&timer);
|
1475 |
|
|
timer.expires = jiffies + 4*HZ;
|
1476 |
|
|
timer.data = (unsigned long)cmd;
|
1477 |
|
|
timer.function = qla1280_error_wait_timeout;
|
1478 |
|
|
add_timer(&timer);
|
1479 |
|
|
|
1480 |
|
|
/* wait for the action to complete (or the timer to expire) */
|
1481 |
|
|
spin_unlock_irq(HOST_LOCK);
|
1482 |
|
|
wait_for_completion(&wait);
|
1483 |
|
|
del_timer_sync(&timer);
|
1484 |
|
|
spin_lock_irq(HOST_LOCK);
|
1485 |
|
|
sp->wait = NULL;
|
1486 |
|
|
|
1487 |
|
|
/* the only action we might get a fail for is abort */
|
1488 |
|
|
if (action == ABORT_COMMAND) {
|
1489 |
|
|
if(sp->flags & SRB_ABORTED)
|
1490 |
|
|
result = SUCCESS;
|
1491 |
|
|
else
|
1492 |
|
|
result = FAILED;
|
1493 |
|
|
}
|
1494 |
|
|
|
1495 |
|
|
leave:
|
1496 |
|
|
dprintk(1, "RESET returning %d\n", result);
|
1497 |
|
|
|
1498 |
|
|
LEAVE("qla1280_error_action");
|
1499 |
|
|
return result;
|
1500 |
|
|
}
|
1501 |
|
|
|
1502 |
|
|
/**************************************************************************
|
1503 |
|
|
* qla1280_abort
|
1504 |
|
|
* Abort the specified SCSI command(s).
|
1505 |
|
|
**************************************************************************/
|
1506 |
|
|
static int
|
1507 |
|
|
qla1280_eh_abort(struct scsi_cmnd * cmd)
|
1508 |
|
|
{
|
1509 |
|
|
return qla1280_error_action(cmd, ABORT_COMMAND);
|
1510 |
|
|
}
|
1511 |
|
|
|
1512 |
|
|
/**************************************************************************
|
1513 |
|
|
* qla1280_device_reset
|
1514 |
|
|
* Reset the specified SCSI device
|
1515 |
|
|
**************************************************************************/
|
1516 |
|
|
static int
|
1517 |
|
|
qla1280_eh_device_reset(struct scsi_cmnd *cmd)
|
1518 |
|
|
{
|
1519 |
|
|
return qla1280_error_action(cmd, DEVICE_RESET);
|
1520 |
|
|
}
|
1521 |
|
|
|
1522 |
|
|
/**************************************************************************
|
1523 |
|
|
* qla1280_bus_reset
|
1524 |
|
|
* Reset the specified bus.
|
1525 |
|
|
**************************************************************************/
|
1526 |
|
|
static int
|
1527 |
|
|
qla1280_eh_bus_reset(struct scsi_cmnd *cmd)
|
1528 |
|
|
{
|
1529 |
|
|
return qla1280_error_action(cmd, BUS_RESET);
|
1530 |
|
|
}
|
1531 |
|
|
|
1532 |
|
|
/**************************************************************************
|
1533 |
|
|
* qla1280_adapter_reset
|
1534 |
|
|
* Reset the specified adapter (both channels)
|
1535 |
|
|
**************************************************************************/
|
1536 |
|
|
static int
|
1537 |
|
|
qla1280_eh_adapter_reset(struct scsi_cmnd *cmd)
|
1538 |
|
|
{
|
1539 |
|
|
return qla1280_error_action(cmd, ADAPTER_RESET);
|
1540 |
|
|
}
|
1541 |
|
|
|
1542 |
|
|
/**************************************************************************
|
1543 |
|
|
* qla1280_biosparam
|
1544 |
|
|
* Return the disk geometry for the given SCSI device.
|
1545 |
|
|
**************************************************************************/
|
1546 |
|
|
static int
|
1547 |
|
|
#if LINUX_VERSION_CODE < 0x020545
|
1548 |
|
|
qla1280_biosparam(Disk * disk, kdev_t dev, int geom[])
|
1549 |
|
|
#else
|
1550 |
|
|
qla1280_biosparam(struct scsi_device *sdev, struct block_device *bdev,
|
1551 |
|
|
sector_t capacity, int geom[])
|
1552 |
|
|
#endif
|
1553 |
|
|
{
|
1554 |
|
|
int heads, sectors, cylinders;
|
1555 |
|
|
#if LINUX_VERSION_CODE < 0x020545
|
1556 |
|
|
unsigned long capacity = disk->capacity;
|
1557 |
|
|
#endif
|
1558 |
|
|
|
1559 |
|
|
heads = 64;
|
1560 |
|
|
sectors = 32;
|
1561 |
|
|
cylinders = (unsigned long)capacity / (heads * sectors);
|
1562 |
|
|
if (cylinders > 1024) {
|
1563 |
|
|
heads = 255;
|
1564 |
|
|
sectors = 63;
|
1565 |
|
|
cylinders = (unsigned long)capacity / (heads * sectors);
|
1566 |
|
|
/* if (cylinders > 1023)
|
1567 |
|
|
cylinders = 1023; */
|
1568 |
|
|
}
|
1569 |
|
|
|
1570 |
|
|
geom[0] = heads;
|
1571 |
|
|
geom[1] = sectors;
|
1572 |
|
|
geom[2] = cylinders;
|
1573 |
|
|
|
1574 |
|
|
return 0;
|
1575 |
|
|
}
|
1576 |
|
|
|
1577 |
|
|
/**************************************************************************
|
1578 |
|
|
* qla1280_intr_handler
|
1579 |
|
|
* Handles the H/W interrupt
|
1580 |
|
|
**************************************************************************/
|
1581 |
|
|
irqreturn_t
|
1582 |
|
|
qla1280_intr_handler(int irq, void *dev_id, struct pt_regs *regs)
|
1583 |
|
|
{
|
1584 |
|
|
struct scsi_qla_host *ha;
|
1585 |
|
|
struct device_reg *reg;
|
1586 |
|
|
u16 data;
|
1587 |
|
|
int handled = 0;
|
1588 |
|
|
|
1589 |
|
|
ENTER_INTR ("qla1280_intr_handler");
|
1590 |
|
|
ha = (struct scsi_qla_host *)dev_id;
|
1591 |
|
|
|
1592 |
|
|
spin_lock(HOST_LOCK);
|
1593 |
|
|
|
1594 |
|
|
ha->isr_count++;
|
1595 |
|
|
reg = ha->iobase;
|
1596 |
|
|
|
1597 |
|
|
WRT_REG_WORD(®->ictrl, 0); /* disable our interrupt. */
|
1598 |
|
|
|
1599 |
|
|
data = qla1280_debounce_register(®->istatus);
|
1600 |
|
|
/* Check for pending interrupts. */
|
1601 |
|
|
if (data & RISC_INT) {
|
1602 |
|
|
qla1280_isr(ha, &ha->done_q_first, &ha->done_q_last);
|
1603 |
|
|
handled = 1;
|
1604 |
|
|
}
|
1605 |
|
|
if (ha->done_q_first)
|
1606 |
|
|
qla1280_done(ha, &ha->done_q_first, &ha->done_q_last);
|
1607 |
|
|
|
1608 |
|
|
spin_unlock(HOST_LOCK);
|
1609 |
|
|
|
1610 |
|
|
/* enable our interrupt. */
|
1611 |
|
|
WRT_REG_WORD(®->ictrl, (ISP_EN_INT | ISP_EN_RISC));
|
1612 |
|
|
|
1613 |
|
|
LEAVE_INTR("qla1280_intr_handler");
|
1614 |
|
|
return IRQ_RETVAL(handled);
|
1615 |
|
|
}
|
1616 |
|
|
|
1617 |
|
|
|
1618 |
|
|
static int
|
1619 |
|
|
qla12160_set_target_parameters(struct scsi_qla_host *ha, int bus, int target)
|
1620 |
|
|
{
|
1621 |
|
|
uint8_t mr;
|
1622 |
|
|
uint16_t mb[MAILBOX_REGISTER_COUNT];
|
1623 |
|
|
struct nvram *nv;
|
1624 |
|
|
int is1x160, status;
|
1625 |
|
|
|
1626 |
|
|
nv = &ha->nvram;
|
1627 |
|
|
|
1628 |
|
|
if (ha->device_id == PCI_DEVICE_ID_QLOGIC_ISP12160 ||
|
1629 |
|
|
ha->device_id == PCI_DEVICE_ID_QLOGIC_ISP10160)
|
1630 |
|
|
is1x160 = 1;
|
1631 |
|
|
else
|
1632 |
|
|
is1x160 = 0;
|
1633 |
|
|
|
1634 |
|
|
mr = BIT_3 | BIT_2 | BIT_1 | BIT_0;
|
1635 |
|
|
|
1636 |
|
|
/* Set Target Parameters. */
|
1637 |
|
|
mb[0] = MBC_SET_TARGET_PARAMETERS;
|
1638 |
|
|
mb[1] = (uint16_t) (bus ? target | BIT_7 : target);
|
1639 |
|
|
mb[1] <<= 8;
|
1640 |
|
|
|
1641 |
|
|
mb[2] = (nv->bus[bus].target[target].parameter.c << 8);
|
1642 |
|
|
|
1643 |
|
|
if (is1x160)
|
1644 |
|
|
mb[3] = nv->bus[bus].target[target].flags.flags1x160.sync_offset << 8;
|
1645 |
|
|
else
|
1646 |
|
|
mb[3] = nv->bus[bus].target[target].flags.flags1x80.sync_offset << 8;
|
1647 |
|
|
mb[3] |= nv->bus[bus].target[target].sync_period;
|
1648 |
|
|
|
1649 |
|
|
if (is1x160) {
|
1650 |
|
|
mb[2] |= nv->bus[bus].target[target].ppr_1x160.flags.enable_ppr << 5;
|
1651 |
|
|
mb[6] = nv->bus[bus].target[target].ppr_1x160.flags.ppr_options << 8;
|
1652 |
|
|
mb[6] |= nv->bus[bus].target[target].ppr_1x160.flags.ppr_bus_width;
|
1653 |
|
|
mr |= BIT_6;
|
1654 |
|
|
}
|
1655 |
|
|
|
1656 |
|
|
status = qla1280_mailbox_command(ha, mr, &mb[0]);
|
1657 |
|
|
|
1658 |
|
|
if (status)
|
1659 |
|
|
printk(KERN_WARNING "scsi(%ld:%i:%i): "
|
1660 |
|
|
"qla1280_set_target_parameters() failed\n",
|
1661 |
|
|
ha->host_no, bus, target);
|
1662 |
|
|
return status;
|
1663 |
|
|
}
|
1664 |
|
|
|
1665 |
|
|
|
1666 |
|
|
/**************************************************************************
|
1667 |
|
|
* qla1280_slave_configure
|
1668 |
|
|
*
|
1669 |
|
|
* Description:
|
1670 |
|
|
* Determines the queue depth for a given device. There are two ways
|
1671 |
|
|
* a queue depth can be obtained for a tagged queueing device. One
|
1672 |
|
|
* way is the default queue depth which is determined by whether
|
1673 |
|
|
* If it is defined, then it is used
|
1674 |
|
|
* as the default queue depth. Otherwise, we use either 4 or 8 as the
|
1675 |
|
|
* default queue depth (dependent on the number of hardware SCBs).
|
1676 |
|
|
**************************************************************************/
|
1677 |
|
|
static int
|
1678 |
|
|
qla1280_slave_configure(Scsi_Device *device)
|
1679 |
|
|
{
|
1680 |
|
|
struct scsi_qla_host *ha;
|
1681 |
|
|
int default_depth = 3;
|
1682 |
|
|
int bus = device->channel;
|
1683 |
|
|
int target = device->id;
|
1684 |
|
|
int status = 0;
|
1685 |
|
|
struct nvram *nv;
|
1686 |
|
|
unsigned long flags;
|
1687 |
|
|
|
1688 |
|
|
ha = (struct scsi_qla_host *)device->host->hostdata;
|
1689 |
|
|
nv = &ha->nvram;
|
1690 |
|
|
|
1691 |
|
|
if (qla1280_check_for_dead_scsi_bus(ha, bus))
|
1692 |
|
|
return 1;
|
1693 |
|
|
|
1694 |
|
|
if (device->tagged_supported &&
|
1695 |
|
|
(ha->bus_settings[bus].qtag_enables & (BIT_0 << target))) {
|
1696 |
|
|
scsi_adjust_queue_depth(device, MSG_ORDERED_TAG,
|
1697 |
|
|
ha->bus_settings[bus].hiwat);
|
1698 |
|
|
} else {
|
1699 |
|
|
scsi_adjust_queue_depth(device, 0, default_depth);
|
1700 |
|
|
}
|
1701 |
|
|
|
1702 |
|
|
#if LINUX_VERSION_CODE > 0x020500
|
1703 |
|
|
nv->bus[bus].target[target].parameter.f.enable_sync = device->sdtr;
|
1704 |
|
|
nv->bus[bus].target[target].parameter.f.enable_wide = device->wdtr;
|
1705 |
|
|
nv->bus[bus].target[target].ppr_1x160.flags.enable_ppr = device->ppr;
|
1706 |
|
|
#endif
|
1707 |
|
|
|
1708 |
|
|
if (driver_setup.no_sync ||
|
1709 |
|
|
(driver_setup.sync_mask &&
|
1710 |
|
|
(~driver_setup.sync_mask & (1 << target))))
|
1711 |
|
|
nv->bus[bus].target[target].parameter.f.enable_sync = 0;
|
1712 |
|
|
if (driver_setup.no_wide ||
|
1713 |
|
|
(driver_setup.wide_mask &&
|
1714 |
|
|
(~driver_setup.wide_mask & (1 << target))))
|
1715 |
|
|
nv->bus[bus].target[target].parameter.f.enable_wide = 0;
|
1716 |
|
|
if (ha->device_id == PCI_DEVICE_ID_QLOGIC_ISP12160 ||
|
1717 |
|
|
ha->device_id == PCI_DEVICE_ID_QLOGIC_ISP10160) {
|
1718 |
|
|
if (driver_setup.no_ppr ||
|
1719 |
|
|
(driver_setup.ppr_mask &&
|
1720 |
|
|
(~driver_setup.ppr_mask & (1 << target))))
|
1721 |
|
|
nv->bus[bus].target[target].ppr_1x160.flags.enable_ppr = 0;
|
1722 |
|
|
}
|
1723 |
|
|
|
1724 |
|
|
spin_lock_irqsave(HOST_LOCK, flags);
|
1725 |
|
|
if (nv->bus[bus].target[target].parameter.f.enable_sync) {
|
1726 |
|
|
status = qla12160_set_target_parameters(ha, bus, target);
|
1727 |
|
|
}
|
1728 |
|
|
|
1729 |
|
|
qla12160_get_target_parameters(ha, device);
|
1730 |
|
|
spin_unlock_irqrestore(HOST_LOCK, flags);
|
1731 |
|
|
return status;
|
1732 |
|
|
}
|
1733 |
|
|
|
1734 |
|
|
#if LINUX_VERSION_CODE < 0x020545
|
1735 |
|
|
/**************************************************************************
|
1736 |
|
|
* qla1280_select_queue_depth
|
1737 |
|
|
*
|
1738 |
|
|
* Sets the queue depth for each SCSI device hanging off the input
|
1739 |
|
|
* host adapter. We use a queue depth of 2 for devices that do not
|
1740 |
|
|
* support tagged queueing.
|
1741 |
|
|
**************************************************************************/
|
1742 |
|
|
static void
|
1743 |
|
|
qla1280_select_queue_depth(struct Scsi_Host *host, Scsi_Device *scsi_devs)
|
1744 |
|
|
{
|
1745 |
|
|
Scsi_Device *device;
|
1746 |
|
|
struct scsi_qla_host *ha = (struct scsi_qla_host *)host->hostdata;
|
1747 |
|
|
|
1748 |
|
|
ENTER("qla1280_select_queue_depth");
|
1749 |
|
|
for (device = scsi_devs; device != NULL; device = device->next) {
|
1750 |
|
|
if (device->host == host)
|
1751 |
|
|
qla1280_slave_configure(device);
|
1752 |
|
|
}
|
1753 |
|
|
|
1754 |
|
|
if (scsi_devs)
|
1755 |
|
|
qla1280_check_for_dead_scsi_bus(ha, scsi_devs->channel);
|
1756 |
|
|
|
1757 |
|
|
LEAVE("qla1280_select_queue_depth");
|
1758 |
|
|
}
|
1759 |
|
|
#endif
|
1760 |
|
|
|
1761 |
|
|
/*
|
1762 |
|
|
* Driver Support Routines
|
1763 |
|
|
*/
|
1764 |
|
|
|
1765 |
|
|
/*
|
1766 |
|
|
* qla1280_done
|
1767 |
|
|
* Process completed commands.
|
1768 |
|
|
*
|
1769 |
|
|
* Input:
|
1770 |
|
|
* ha = adapter block pointer.
|
1771 |
|
|
* done_q_first = done queue first pointer.
|
1772 |
|
|
* done_q_last = done queue last pointer.
|
1773 |
|
|
*/
|
1774 |
|
|
static void
|
1775 |
|
|
qla1280_done(struct scsi_qla_host *ha, struct srb ** done_q_first,
|
1776 |
|
|
struct srb ** done_q_last)
|
1777 |
|
|
{
|
1778 |
|
|
struct srb *sp;
|
1779 |
|
|
int bus, target, lun;
|
1780 |
|
|
Scsi_Cmnd *cmd;
|
1781 |
|
|
|
1782 |
|
|
ENTER("qla1280_done");
|
1783 |
|
|
|
1784 |
|
|
while (*done_q_first != NULL) {
|
1785 |
|
|
/* remove command from done list */
|
1786 |
|
|
sp = *done_q_first;
|
1787 |
|
|
if (!(*done_q_first = sp->s_next))
|
1788 |
|
|
*done_q_last = NULL;
|
1789 |
|
|
else
|
1790 |
|
|
(*done_q_first)->s_prev = NULL;
|
1791 |
|
|
|
1792 |
|
|
cmd = sp->cmd;
|
1793 |
|
|
bus = SCSI_BUS_32(cmd);
|
1794 |
|
|
target = SCSI_TCN_32(cmd);
|
1795 |
|
|
lun = SCSI_LUN_32(cmd);
|
1796 |
|
|
|
1797 |
|
|
switch ((CMD_RESULT(cmd) >> 16)) {
|
1798 |
|
|
case DID_RESET:
|
1799 |
|
|
/* Issue marker command. */
|
1800 |
|
|
qla1280_marker(ha, bus, target, 0, MK_SYNC_ID);
|
1801 |
|
|
break;
|
1802 |
|
|
case DID_ABORT:
|
1803 |
|
|
sp->flags &= ~SRB_ABORT_PENDING;
|
1804 |
|
|
sp->flags |= SRB_ABORTED;
|
1805 |
|
|
if (sp->flags & SRB_TIMEOUT)
|
1806 |
|
|
CMD_RESULT(sp->cmd) = DID_TIME_OUT << 16;
|
1807 |
|
|
break;
|
1808 |
|
|
default:
|
1809 |
|
|
break;
|
1810 |
|
|
}
|
1811 |
|
|
|
1812 |
|
|
/* Release memory used for this I/O */
|
1813 |
|
|
if (cmd->use_sg) {
|
1814 |
|
|
dprintk(3, "S/G unmap_sg cmd=%p\n", cmd);
|
1815 |
|
|
|
1816 |
|
|
pci_unmap_sg(ha->pdev, cmd->request_buffer,
|
1817 |
|
|
cmd->use_sg,
|
1818 |
|
|
scsi_to_pci_dma_dir(cmd->sc_data_direction));
|
1819 |
|
|
} else if (cmd->request_bufflen) {
|
1820 |
|
|
/*dprintk(1, "No S/G unmap_single cmd=%x saved_dma_handle=%lx\n",
|
1821 |
|
|
cmd, sp->saved_dma_handle); */
|
1822 |
|
|
|
1823 |
|
|
pci_unmap_page(ha->pdev, sp->saved_dma_handle,
|
1824 |
|
|
cmd->request_bufflen,
|
1825 |
|
|
scsi_to_pci_dma_dir(cmd->sc_data_direction));
|
1826 |
|
|
}
|
1827 |
|
|
|
1828 |
|
|
/* Call the mid-level driver interrupt handler */
|
1829 |
|
|
CMD_HANDLE(sp->cmd) = (unsigned char *)INVALID_HANDLE;
|
1830 |
|
|
ha->actthreads--;
|
1831 |
|
|
|
1832 |
|
|
#if LINUX_VERSION_CODE < 0x020500
|
1833 |
|
|
if (cmd->cmnd[0] == INQUIRY)
|
1834 |
|
|
qla1280_get_target_options(cmd, ha);
|
1835 |
|
|
#endif
|
1836 |
|
|
(*(cmd)->scsi_done)(cmd);
|
1837 |
|
|
|
1838 |
|
|
if(sp->wait != NULL)
|
1839 |
|
|
complete(sp->wait);
|
1840 |
|
|
|
1841 |
|
|
}
|
1842 |
|
|
LEAVE("qla1280_done");
|
1843 |
|
|
}
|
1844 |
|
|
|
1845 |
|
|
/*
|
1846 |
|
|
* Translates a ISP error to a Linux SCSI error
|
1847 |
|
|
*/
|
1848 |
|
|
static int
|
1849 |
|
|
qla1280_return_status(struct response * sts, Scsi_Cmnd * cp)
|
1850 |
|
|
{
|
1851 |
|
|
int host_status = DID_ERROR;
|
1852 |
|
|
#if DEBUG_QLA1280_INTR
|
1853 |
|
|
static char *reason[] = {
|
1854 |
|
|
"DID_OK",
|
1855 |
|
|
"DID_NO_CONNECT",
|
1856 |
|
|
"DID_BUS_BUSY",
|
1857 |
|
|
"DID_TIME_OUT",
|
1858 |
|
|
"DID_BAD_TARGET",
|
1859 |
|
|
"DID_ABORT",
|
1860 |
|
|
"DID_PARITY",
|
1861 |
|
|
"DID_ERROR",
|
1862 |
|
|
"DID_RESET",
|
1863 |
|
|
"DID_BAD_INTR"
|
1864 |
|
|
};
|
1865 |
|
|
#endif /* DEBUG_QLA1280_INTR */
|
1866 |
|
|
|
1867 |
|
|
ENTER("qla1280_return_status");
|
1868 |
|
|
|
1869 |
|
|
#if DEBUG_QLA1280_INTR
|
1870 |
|
|
/*
|
1871 |
|
|
dprintk(1, "qla1280_return_status: compl status = 0x%04x\n",
|
1872 |
|
|
sts->comp_status);
|
1873 |
|
|
*/
|
1874 |
|
|
#endif
|
1875 |
|
|
switch (sts->comp_status) {
|
1876 |
|
|
case CS_COMPLETE:
|
1877 |
|
|
host_status = DID_OK;
|
1878 |
|
|
break;
|
1879 |
|
|
|
1880 |
|
|
case CS_INCOMPLETE:
|
1881 |
|
|
if (!(sts->state_flags & SF_GOT_BUS))
|
1882 |
|
|
host_status = DID_NO_CONNECT;
|
1883 |
|
|
else if (!(sts->state_flags & SF_GOT_TARGET))
|
1884 |
|
|
host_status = DID_BAD_TARGET;
|
1885 |
|
|
else if (!(sts->state_flags & SF_SENT_CDB))
|
1886 |
|
|
host_status = DID_ERROR;
|
1887 |
|
|
else if (!(sts->state_flags & SF_TRANSFERRED_DATA))
|
1888 |
|
|
host_status = DID_ERROR;
|
1889 |
|
|
else if (!(sts->state_flags & SF_GOT_STATUS))
|
1890 |
|
|
host_status = DID_ERROR;
|
1891 |
|
|
else if (!(sts->state_flags & SF_GOT_SENSE))
|
1892 |
|
|
host_status = DID_ERROR;
|
1893 |
|
|
break;
|
1894 |
|
|
|
1895 |
|
|
case CS_RESET:
|
1896 |
|
|
host_status = DID_RESET;
|
1897 |
|
|
break;
|
1898 |
|
|
|
1899 |
|
|
case CS_ABORTED:
|
1900 |
|
|
host_status = DID_ABORT;
|
1901 |
|
|
break;
|
1902 |
|
|
|
1903 |
|
|
case CS_TIMEOUT:
|
1904 |
|
|
host_status = DID_TIME_OUT;
|
1905 |
|
|
break;
|
1906 |
|
|
|
1907 |
|
|
case CS_DATA_OVERRUN:
|
1908 |
|
|
dprintk(2, "Data overrun 0x%x\n", sts->residual_length);
|
1909 |
|
|
dprintk(2, "qla1280_isr: response packet data\n");
|
1910 |
|
|
qla1280_dump_buffer(2, (char *)sts, RESPONSE_ENTRY_SIZE);
|
1911 |
|
|
host_status = DID_ERROR;
|
1912 |
|
|
break;
|
1913 |
|
|
|
1914 |
|
|
case CS_DATA_UNDERRUN:
|
1915 |
|
|
if ((cp->request_bufflen - sts->residual_length) <
|
1916 |
|
|
cp->underflow) {
|
1917 |
|
|
printk(KERN_WARNING
|
1918 |
|
|
"scsi: Underflow detected - retrying "
|
1919 |
|
|
"command.\n");
|
1920 |
|
|
host_status = DID_ERROR;
|
1921 |
|
|
} else
|
1922 |
|
|
host_status = DID_OK;
|
1923 |
|
|
break;
|
1924 |
|
|
|
1925 |
|
|
default:
|
1926 |
|
|
host_status = DID_ERROR;
|
1927 |
|
|
break;
|
1928 |
|
|
}
|
1929 |
|
|
|
1930 |
|
|
#if DEBUG_QLA1280_INTR
|
1931 |
|
|
dprintk(1, "qla1280 ISP status: host status (%s) scsi status %x\n",
|
1932 |
|
|
reason[host_status], sts->scsi_status);
|
1933 |
|
|
#endif
|
1934 |
|
|
|
1935 |
|
|
LEAVE("qla1280_return_status");
|
1936 |
|
|
|
1937 |
|
|
return (sts->scsi_status & 0xff) | (host_status << 16);
|
1938 |
|
|
}
|
1939 |
|
|
|
1940 |
|
|
/*
|
1941 |
|
|
* qla1280_done_q_put
|
1942 |
|
|
* Place SRB command on done queue.
|
1943 |
|
|
*
|
1944 |
|
|
* Input:
|
1945 |
|
|
* sp = srb pointer.
|
1946 |
|
|
* done_q_first = done queue first pointer.
|
1947 |
|
|
* done_q_last = done queue last pointer.
|
1948 |
|
|
*/
|
1949 |
|
|
static void
|
1950 |
|
|
qla1280_done_q_put(struct srb * sp, struct srb ** done_q_first,
|
1951 |
|
|
struct srb ** done_q_last)
|
1952 |
|
|
{
|
1953 |
|
|
ENTER("qla1280_put_done_q");
|
1954 |
|
|
|
1955 |
|
|
/* Place block on done queue */
|
1956 |
|
|
sp->s_next = NULL;
|
1957 |
|
|
sp->s_prev = *done_q_last;
|
1958 |
|
|
if (!*done_q_first)
|
1959 |
|
|
*done_q_first = sp;
|
1960 |
|
|
else
|
1961 |
|
|
(*done_q_last)->s_next = sp;
|
1962 |
|
|
*done_q_last = sp;
|
1963 |
|
|
|
1964 |
|
|
LEAVE("qla1280_put_done_q");
|
1965 |
|
|
}
|
1966 |
|
|
|
1967 |
|
|
|
1968 |
|
|
/*
|
1969 |
|
|
* qla1280_mem_alloc
|
1970 |
|
|
* Allocates adapter memory.
|
1971 |
|
|
*
|
1972 |
|
|
* Returns:
|
1973 |
|
|
* 0 = success.
|
1974 |
|
|
* 1 = failure.
|
1975 |
|
|
*/
|
1976 |
|
|
static int
|
1977 |
|
|
qla1280_mem_alloc(struct scsi_qla_host *ha)
|
1978 |
|
|
{
|
1979 |
|
|
int status = 1;
|
1980 |
|
|
dma_addr_t dma_handle;
|
1981 |
|
|
|
1982 |
|
|
ENTER("qla1280_mem_alloc");
|
1983 |
|
|
|
1984 |
|
|
/* get consistent memory allocated for request and response rings */
|
1985 |
|
|
ha->request_ring = pci_alloc_consistent(ha->pdev,
|
1986 |
|
|
((REQUEST_ENTRY_CNT + 1) *
|
1987 |
|
|
(sizeof(request_t))),
|
1988 |
|
|
&dma_handle);
|
1989 |
|
|
if (!ha->request_ring)
|
1990 |
|
|
goto error;
|
1991 |
|
|
ha->request_dma = dma_handle;
|
1992 |
|
|
ha->response_ring = pci_alloc_consistent(ha->pdev,
|
1993 |
|
|
((RESPONSE_ENTRY_CNT + 1) *
|
1994 |
|
|
(sizeof(struct response))),
|
1995 |
|
|
&dma_handle);
|
1996 |
|
|
if (!ha->response_ring)
|
1997 |
|
|
goto error;
|
1998 |
|
|
ha->response_dma = dma_handle;
|
1999 |
|
|
status = 0;
|
2000 |
|
|
goto finish;
|
2001 |
|
|
|
2002 |
|
|
error:
|
2003 |
|
|
if (status)
|
2004 |
|
|
dprintk(2, "qla1280_mem_alloc: **** FAILED ****\n");
|
2005 |
|
|
|
2006 |
|
|
if (ha->request_ring)
|
2007 |
|
|
pci_free_consistent(ha->pdev,
|
2008 |
|
|
((REQUEST_ENTRY_CNT + 1) *
|
2009 |
|
|
(sizeof(request_t))),
|
2010 |
|
|
ha->request_ring, ha->request_dma);
|
2011 |
|
|
finish:
|
2012 |
|
|
LEAVE("qla1280_mem_alloc");
|
2013 |
|
|
return status;
|
2014 |
|
|
}
|
2015 |
|
|
|
2016 |
|
|
/*
|
2017 |
|
|
* qla1280_mem_free
|
2018 |
|
|
* Frees adapter allocated memory.
|
2019 |
|
|
*
|
2020 |
|
|
* Input:
|
2021 |
|
|
* ha = adapter block pointer.
|
2022 |
|
|
*/
|
2023 |
|
|
static void
|
2024 |
|
|
qla1280_mem_free(struct scsi_qla_host *ha)
|
2025 |
|
|
{
|
2026 |
|
|
ENTER("qlc1280_mem_free");
|
2027 |
|
|
/* free consistent memory allocated for request and response rings */
|
2028 |
|
|
if (ha->request_ring)
|
2029 |
|
|
pci_free_consistent(ha->pdev,
|
2030 |
|
|
((REQUEST_ENTRY_CNT + 1) *
|
2031 |
|
|
(sizeof(request_t))),
|
2032 |
|
|
ha->request_ring, ha->request_dma);
|
2033 |
|
|
|
2034 |
|
|
if (ha->response_ring)
|
2035 |
|
|
pci_free_consistent(ha->pdev,
|
2036 |
|
|
((RESPONSE_ENTRY_CNT + 1) *
|
2037 |
|
|
(sizeof(struct response))),
|
2038 |
|
|
ha->response_ring, ha->response_dma);
|
2039 |
|
|
|
2040 |
|
|
if (qla1280_buffer) {
|
2041 |
|
|
free_page((unsigned long) qla1280_buffer);
|
2042 |
|
|
qla1280_buffer = NULL;
|
2043 |
|
|
}
|
2044 |
|
|
|
2045 |
|
|
LEAVE("qlc1280_mem_free");
|
2046 |
|
|
}
|
2047 |
|
|
|
2048 |
|
|
/****************************************************************************/
|
2049 |
|
|
/* QLogic ISP1280 Hardware Support Functions. */
|
2050 |
|
|
/****************************************************************************/
|
2051 |
|
|
|
2052 |
|
|
/*
|
2053 |
|
|
* qla2100_enable_intrs
|
2054 |
|
|
* qla2100_disable_intrs
|
2055 |
|
|
*
|
2056 |
|
|
* Input:
|
2057 |
|
|
* ha = adapter block pointer.
|
2058 |
|
|
*
|
2059 |
|
|
* Returns:
|
2060 |
|
|
* None
|
2061 |
|
|
*/
|
2062 |
|
|
static inline void
|
2063 |
|
|
qla1280_enable_intrs(struct scsi_qla_host *ha)
|
2064 |
|
|
{
|
2065 |
|
|
struct device_reg *reg;
|
2066 |
|
|
|
2067 |
|
|
reg = ha->iobase;
|
2068 |
|
|
/* enable risc and host interrupts */
|
2069 |
|
|
WRT_REG_WORD(®->ictrl, (ISP_EN_INT | ISP_EN_RISC));
|
2070 |
|
|
RD_REG_WORD(®->ictrl); /* PCI Posted Write flush */
|
2071 |
|
|
ha->flags.ints_enabled = 1;
|
2072 |
|
|
}
|
2073 |
|
|
|
2074 |
|
|
static inline void
|
2075 |
|
|
qla1280_disable_intrs(struct scsi_qla_host *ha)
|
2076 |
|
|
{
|
2077 |
|
|
struct device_reg *reg;
|
2078 |
|
|
|
2079 |
|
|
reg = ha->iobase;
|
2080 |
|
|
/* disable risc and host interrupts */
|
2081 |
|
|
WRT_REG_WORD(®->ictrl, 0);
|
2082 |
|
|
RD_REG_WORD(®->ictrl); /* PCI Posted Write flush */
|
2083 |
|
|
ha->flags.ints_enabled = 0;
|
2084 |
|
|
}
|
2085 |
|
|
|
2086 |
|
|
/*
|
2087 |
|
|
* qla1280_initialize_adapter
|
2088 |
|
|
* Initialize board.
|
2089 |
|
|
*
|
2090 |
|
|
* Input:
|
2091 |
|
|
* ha = adapter block pointer.
|
2092 |
|
|
*
|
2093 |
|
|
* Returns:
|
2094 |
|
|
* 0 = success
|
2095 |
|
|
*/
|
2096 |
|
|
static int
|
2097 |
|
|
qla1280_initialize_adapter(struct scsi_qla_host *ha)
|
2098 |
|
|
{
|
2099 |
|
|
struct device_reg *reg;
|
2100 |
|
|
int status;
|
2101 |
|
|
int bus;
|
2102 |
|
|
#if LINUX_VERSION_CODE > 0x020500
|
2103 |
|
|
unsigned long flags;
|
2104 |
|
|
#endif
|
2105 |
|
|
|
2106 |
|
|
ENTER("qla1280_initialize_adapter");
|
2107 |
|
|
|
2108 |
|
|
/* Clear adapter flags. */
|
2109 |
|
|
ha->flags.online = 0;
|
2110 |
|
|
ha->flags.disable_host_adapter = 0;
|
2111 |
|
|
ha->flags.reset_active = 0;
|
2112 |
|
|
ha->flags.abort_isp_active = 0;
|
2113 |
|
|
|
2114 |
|
|
ha->flags.ints_enabled = 0;
|
2115 |
|
|
#if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2)
|
2116 |
|
|
if (ia64_platform_is("sn2")) {
|
2117 |
|
|
int count1, count2;
|
2118 |
|
|
int c;
|
2119 |
|
|
|
2120 |
|
|
count1 = 3;
|
2121 |
|
|
count2 = 3;
|
2122 |
|
|
printk(KERN_INFO "scsi(%li): Enabling SN2 PCI DMA "
|
2123 |
|
|
"dual channel lockup workaround\n", ha->host_no);
|
2124 |
|
|
if ((c = snia_pcibr_rrb_alloc(ha->pdev, &count1, &count2)) < 0)
|
2125 |
|
|
printk(KERN_ERR "scsi(%li): Unable to allocate SN2 "
|
2126 |
|
|
"virtual DMA channels\n", ha->host_no);
|
2127 |
|
|
ha->flags.use_pci_vchannel = 1;
|
2128 |
|
|
|
2129 |
|
|
driver_setup.no_nvram = 1;
|
2130 |
|
|
}
|
2131 |
|
|
#endif
|
2132 |
|
|
|
2133 |
|
|
dprintk(1, "Configure PCI space for adapter...\n");
|
2134 |
|
|
|
2135 |
|
|
reg = ha->iobase;
|
2136 |
|
|
|
2137 |
|
|
/* Insure mailbox registers are free. */
|
2138 |
|
|
WRT_REG_WORD(®->semaphore, 0);
|
2139 |
|
|
WRT_REG_WORD(®->host_cmd, HC_CLR_RISC_INT);
|
2140 |
|
|
WRT_REG_WORD(®->host_cmd, HC_CLR_HOST_INT);
|
2141 |
|
|
RD_REG_WORD(®->host_cmd);
|
2142 |
|
|
|
2143 |
|
|
if (qla1280_read_nvram(ha)) {
|
2144 |
|
|
dprintk(2, "qla1280_initialize_adapter: failed to read "
|
2145 |
|
|
"NVRAM\n");
|
2146 |
|
|
}
|
2147 |
|
|
|
2148 |
|
|
#if LINUX_VERSION_CODE >= 0x020500
|
2149 |
|
|
/*
|
2150 |
|
|
* It's necessary to grab the spin here as qla1280_mailbox_command
|
2151 |
|
|
* needs to be able to drop the lock unconditionally to wait
|
2152 |
|
|
* for completion.
|
2153 |
|
|
* In 2.4 ->detect is called with the io_request_lock held.
|
2154 |
|
|
*/
|
2155 |
|
|
spin_lock_irqsave(HOST_LOCK, flags);
|
2156 |
|
|
#endif
|
2157 |
|
|
/* If firmware needs to be loaded */
|
2158 |
|
|
if (qla1280_isp_firmware(ha)) {
|
2159 |
|
|
if (!(status = qla1280_chip_diag (ha))) {
|
2160 |
|
|
status = qla1280_setup_chip(ha);
|
2161 |
|
|
}
|
2162 |
|
|
} else {
|
2163 |
|
|
printk(KERN_ERR "scsi(%li): isp_firmware() failed!\n",
|
2164 |
|
|
ha->host_no);
|
2165 |
|
|
status = 1;
|
2166 |
|
|
}
|
2167 |
|
|
|
2168 |
|
|
if (status) {
|
2169 |
|
|
printk(KERN_ERR "scsi(%li): initialize: pci probe failed!\n",
|
2170 |
|
|
ha->host_no);
|
2171 |
|
|
goto out;
|
2172 |
|
|
}
|
2173 |
|
|
|
2174 |
|
|
/* Setup adapter based on NVRAM parameters. */
|
2175 |
|
|
dprintk(1, "scsi(%ld): Configure NVRAM parameters\n", ha->host_no);
|
2176 |
|
|
qla1280_nvram_config(ha);
|
2177 |
|
|
|
2178 |
|
|
if (!ha->flags.disable_host_adapter && !qla1280_init_rings(ha)) {
|
2179 |
|
|
/* Issue SCSI reset. */
|
2180 |
|
|
/* dg 03/13 if we can't reset twice then bus is dead */
|
2181 |
|
|
for (bus = 0; bus < ha->ports; bus++) {
|
2182 |
|
|
if (!ha->bus_settings[bus].disable_scsi_reset){
|
2183 |
|
|
if (qla1280_bus_reset(ha, bus)) {
|
2184 |
|
|
if (qla1280_bus_reset(ha, bus)) {
|
2185 |
|
|
ha->bus_settings[bus].scsi_bus_dead = 1;
|
2186 |
|
|
}
|
2187 |
|
|
}
|
2188 |
|
|
}
|
2189 |
|
|
}
|
2190 |
|
|
|
2191 |
|
|
/*
|
2192 |
|
|
* qla1280_bus_reset() will take care of issueing markers,
|
2193 |
|
|
* no need to do that here as well!
|
2194 |
|
|
*/
|
2195 |
|
|
#if 0
|
2196 |
|
|
/* Issue marker command. */
|
2197 |
|
|
ha->flags.reset_marker = 0;
|
2198 |
|
|
for (bus = 0; bus < ha->ports; bus++) {
|
2199 |
|
|
ha->bus_settings[bus].reset_marker = 0;
|
2200 |
|
|
qla1280_marker(ha, bus, 0, 0, MK_SYNC_ALL);
|
2201 |
|
|
}
|
2202 |
|
|
#endif
|
2203 |
|
|
|
2204 |
|
|
ha->flags.online = 1;
|
2205 |
|
|
} else
|
2206 |
|
|
status = 1;
|
2207 |
|
|
|
2208 |
|
|
out:
|
2209 |
|
|
#if LINUX_VERSION_CODE >= 0x020500
|
2210 |
|
|
spin_unlock_irqrestore(HOST_LOCK, flags);
|
2211 |
|
|
#endif
|
2212 |
|
|
if (status)
|
2213 |
|
|
dprintk(2, "qla1280_initialize_adapter: **** FAILED ****\n");
|
2214 |
|
|
|
2215 |
|
|
LEAVE("qla1280_initialize_adapter");
|
2216 |
|
|
return status;
|
2217 |
|
|
}
|
2218 |
|
|
|
2219 |
|
|
|
2220 |
|
|
/*
|
2221 |
|
|
* ISP Firmware Test
|
2222 |
|
|
* Checks if present version of RISC firmware is older than
|
2223 |
|
|
* driver firmware.
|
2224 |
|
|
*
|
2225 |
|
|
* Input:
|
2226 |
|
|
* ha = adapter block pointer.
|
2227 |
|
|
*
|
2228 |
|
|
* Returns:
|
2229 |
|
|
* 0 = firmware does not need to be loaded.
|
2230 |
|
|
*/
|
2231 |
|
|
static int
|
2232 |
|
|
qla1280_isp_firmware(struct scsi_qla_host *ha)
|
2233 |
|
|
{
|
2234 |
|
|
struct nvram *nv = (struct nvram *) ha->response_ring;
|
2235 |
|
|
int status = 0; /* dg 2/27 always loads RISC */
|
2236 |
|
|
uint16_t mb[MAILBOX_REGISTER_COUNT];
|
2237 |
|
|
|
2238 |
|
|
ENTER("qla1280_isp_firmware");
|
2239 |
|
|
|
2240 |
|
|
dprintk(1, "scsi(%li): Determining if RISC is loaded\n", ha->host_no);
|
2241 |
|
|
|
2242 |
|
|
/* Bad NVRAM data, load RISC code. */
|
2243 |
|
|
if (!ha->nvram_valid) {
|
2244 |
|
|
ha->flags.disable_risc_code_load = 0;
|
2245 |
|
|
} else
|
2246 |
|
|
ha->flags.disable_risc_code_load =
|
2247 |
|
|
nv->cntr_flags_1.disable_loading_risc_code;
|
2248 |
|
|
|
2249 |
|
|
if (ha->flags.disable_risc_code_load) {
|
2250 |
|
|
dprintk(3, "qla1280_isp_firmware: Telling RISC to verify "
|
2251 |
|
|
"checksum of loaded BIOS code.\n");
|
2252 |
|
|
|
2253 |
|
|
/* Verify checksum of loaded RISC code. */
|
2254 |
|
|
mb[0] = MBC_VERIFY_CHECKSUM;
|
2255 |
|
|
/* mb[1] = ql12_risc_code_addr01; */
|
2256 |
|
|
mb[1] = *ql1280_board_tbl[ha->devnum].fwstart;
|
2257 |
|
|
|
2258 |
|
|
if (!(status =
|
2259 |
|
|
qla1280_mailbox_command(ha, BIT_1 | BIT_0, &mb[0]))) {
|
2260 |
|
|
/* Start firmware execution. */
|
2261 |
|
|
dprintk(3, "qla1280_isp_firmware: Startng F/W "
|
2262 |
|
|
"execution.\n");
|
2263 |
|
|
|
2264 |
|
|
mb[0] = MBC_EXECUTE_FIRMWARE;
|
2265 |
|
|
/* mb[1] = ql12_risc_code_addr01; */
|
2266 |
|
|
mb[1] = *ql1280_board_tbl[ha->devnum].fwstart;
|
2267 |
|
|
qla1280_mailbox_command(ha, BIT_1 | BIT_0, &mb[0]);
|
2268 |
|
|
} else
|
2269 |
|
|
printk(KERN_INFO "qla1280: RISC checksum failed.\n");
|
2270 |
|
|
} else {
|
2271 |
|
|
dprintk(1, "qla1280: NVRAM configured to load RISC load.\n");
|
2272 |
|
|
status = 1;
|
2273 |
|
|
}
|
2274 |
|
|
|
2275 |
|
|
if (status)
|
2276 |
|
|
dprintk(2, "qla1280_isp_firmware: **** Load RISC code ****\n");
|
2277 |
|
|
|
2278 |
|
|
LEAVE("qla1280_isp_firmware");
|
2279 |
|
|
return status;
|
2280 |
|
|
}
|
2281 |
|
|
|
2282 |
|
|
/*
|
2283 |
|
|
* PCI configuration
|
2284 |
|
|
* Setup device PCI configuration registers.
|
2285 |
|
|
*
|
2286 |
|
|
* Input:
|
2287 |
|
|
* ha = adapter block pointer.
|
2288 |
|
|
*
|
2289 |
|
|
* Returns:
|
2290 |
|
|
* 0 = success.
|
2291 |
|
|
*/
|
2292 |
|
|
static int
|
2293 |
|
|
qla1280_pci_config(struct scsi_qla_host *ha)
|
2294 |
|
|
{
|
2295 |
|
|
#if MEMORY_MAPPED_IO
|
2296 |
|
|
unsigned long base;
|
2297 |
|
|
int size;
|
2298 |
|
|
#endif
|
2299 |
|
|
uint16_t buf_wd;
|
2300 |
|
|
int status = 1;
|
2301 |
|
|
|
2302 |
|
|
ENTER("qla1280_pci_config");
|
2303 |
|
|
|
2304 |
|
|
pci_set_master(ha->pdev);
|
2305 |
|
|
/*
|
2306 |
|
|
* Set Bus Master Enable, Memory Address Space Enable and
|
2307 |
|
|
* reset any error bits, in the command register.
|
2308 |
|
|
*/
|
2309 |
|
|
pci_read_config_word (ha->pdev, PCI_COMMAND, &buf_wd);
|
2310 |
|
|
#if MEMORY_MAPPED_IO
|
2311 |
|
|
buf_wd |= PCI_COMMAND_MEMORY;
|
2312 |
|
|
#endif
|
2313 |
|
|
buf_wd |= PCI_COMMAND_IO;
|
2314 |
|
|
pci_write_config_word (ha->pdev, PCI_COMMAND, buf_wd);
|
2315 |
|
|
/*
|
2316 |
|
|
* Reset expansion ROM address decode enable.
|
2317 |
|
|
*/
|
2318 |
|
|
pci_read_config_word(ha->pdev, PCI_ROM_ADDRESS, &buf_wd);
|
2319 |
|
|
buf_wd &= ~PCI_ROM_ADDRESS_ENABLE;
|
2320 |
|
|
pci_write_config_word (ha->pdev, PCI_ROM_ADDRESS, buf_wd);
|
2321 |
|
|
|
2322 |
|
|
ha->host->io_port = pci_resource_start(ha->pdev, 0);
|
2323 |
|
|
ha->host->io_port &= PCI_BASE_ADDRESS_IO_MASK;
|
2324 |
|
|
ha->iobase = (struct device_reg *) ha->host->io_port;
|
2325 |
|
|
|
2326 |
|
|
#if MEMORY_MAPPED_IO
|
2327 |
|
|
/*
|
2328 |
|
|
* Find proper memory chunk for memory map I/O reg.
|
2329 |
|
|
*/
|
2330 |
|
|
base = pci_resource_start(ha->pdev, 1);
|
2331 |
|
|
size = pci_resource_len(ha->pdev, 1);
|
2332 |
|
|
/*
|
2333 |
|
|
* Get virtual address for I/O registers.
|
2334 |
|
|
*/
|
2335 |
|
|
ha->mmpbase = ioremap(base, size);
|
2336 |
|
|
if (ha->mmpbase) {
|
2337 |
|
|
ha->iobase = (struct device_reg *)ha->mmpbase;
|
2338 |
|
|
status = 0;
|
2339 |
|
|
}
|
2340 |
|
|
#else /* MEMORY_MAPPED_IO */
|
2341 |
|
|
status = 0;
|
2342 |
|
|
#endif /* MEMORY_MAPPED_IO */
|
2343 |
|
|
|
2344 |
|
|
LEAVE("qla1280_pci_config");
|
2345 |
|
|
return status;
|
2346 |
|
|
}
|
2347 |
|
|
|
2348 |
|
|
/*
|
2349 |
|
|
* Chip diagnostics
|
2350 |
|
|
* Test chip for proper operation.
|
2351 |
|
|
*
|
2352 |
|
|
* Input:
|
2353 |
|
|
* ha = adapter block pointer.
|
2354 |
|
|
*
|
2355 |
|
|
* Returns:
|
2356 |
|
|
* 0 = success.
|
2357 |
|
|
*/
|
2358 |
|
|
static int
|
2359 |
|
|
qla1280_chip_diag(struct scsi_qla_host *ha)
|
2360 |
|
|
{
|
2361 |
|
|
uint16_t mb[MAILBOX_REGISTER_COUNT];
|
2362 |
|
|
struct device_reg *reg = ha->iobase;
|
2363 |
|
|
int status = 0;
|
2364 |
|
|
int cnt;
|
2365 |
|
|
uint16_t data;
|
2366 |
|
|
|
2367 |
|
|
dprintk(3, "qla1280_chip_diag: testing device at 0x%p \n", ®->id_l);
|
2368 |
|
|
|
2369 |
|
|
dprintk(1, "scsi(%ld): Verifying chip\n", ha->host_no);
|
2370 |
|
|
|
2371 |
|
|
/* Soft reset chip and wait for it to finish. */
|
2372 |
|
|
WRT_REG_WORD(®->ictrl, ISP_RESET);
|
2373 |
|
|
/*
|
2374 |
|
|
* We can't do a traditional PCI write flush here by reading
|
2375 |
|
|
* back the register. The card will not respond once the reset
|
2376 |
|
|
* is in action and we end up with a machine check exception
|
2377 |
|
|
* instead. Nothing to do but wait and hope for the best.
|
2378 |
|
|
* A portable pci_write_flush(pdev) call would be very useful here.
|
2379 |
|
|
*/
|
2380 |
|
|
udelay(20);
|
2381 |
|
|
data = qla1280_debounce_register(®->ictrl);
|
2382 |
|
|
/*
|
2383 |
|
|
* Yet another QLogic gem ;-(
|
2384 |
|
|
*/
|
2385 |
|
|
for (cnt = 1000000; cnt && data & ISP_RESET; cnt--) {
|
2386 |
|
|
udelay(5);
|
2387 |
|
|
data = RD_REG_WORD(®->ictrl);
|
2388 |
|
|
}
|
2389 |
|
|
|
2390 |
|
|
if (cnt) {
|
2391 |
|
|
/* Reset register cleared by chip reset. */
|
2392 |
|
|
dprintk(3, "qla1280_chip_diag: reset register cleared by "
|
2393 |
|
|
"chip reset\n");
|
2394 |
|
|
|
2395 |
|
|
WRT_REG_WORD(®->cfg_1, 0);
|
2396 |
|
|
|
2397 |
|
|
/* Reset RISC and disable BIOS which
|
2398 |
|
|
allows RISC to execute out of RAM. */
|
2399 |
|
|
#if 0
|
2400 |
|
|
WRT_REG_WORD(®->host_cmd, HC_RESET_RISC);
|
2401 |
|
|
RD_REG_WORD(®->id_l); /* Flush PCI write */
|
2402 |
|
|
WRT_REG_WORD(®->host_cmd, HC_RELEASE_RISC);
|
2403 |
|
|
RD_REG_WORD(®->id_l); /* Flush PCI write */
|
2404 |
|
|
WRT_REG_WORD(®->host_cmd, HC_DISABLE_BIOS);
|
2405 |
|
|
#else
|
2406 |
|
|
WRT_REG_WORD(®->host_cmd, HC_RESET_RISC |
|
2407 |
|
|
HC_RELEASE_RISC | HC_DISABLE_BIOS);
|
2408 |
|
|
#endif
|
2409 |
|
|
RD_REG_WORD(®->id_l); /* Flush PCI write */
|
2410 |
|
|
data = qla1280_debounce_register(®->mailbox0);
|
2411 |
|
|
/*
|
2412 |
|
|
* I *LOVE* this code!
|
2413 |
|
|
*/
|
2414 |
|
|
for (cnt = 1000000; cnt && data == MBS_BUSY; cnt--) {
|
2415 |
|
|
udelay(5);
|
2416 |
|
|
data = RD_REG_WORD(®->mailbox0);
|
2417 |
|
|
}
|
2418 |
|
|
|
2419 |
|
|
if (cnt) {
|
2420 |
|
|
/* Check product ID of chip */
|
2421 |
|
|
dprintk(3, "qla1280_chip_diag: Checking product "
|
2422 |
|
|
"ID of chip\n");
|
2423 |
|
|
|
2424 |
|
|
if (RD_REG_WORD(®->mailbox1) != PROD_ID_1 ||
|
2425 |
|
|
(RD_REG_WORD(®->mailbox2) != PROD_ID_2 &&
|
2426 |
|
|
RD_REG_WORD(®->mailbox2) != PROD_ID_2a) ||
|
2427 |
|
|
RD_REG_WORD(®->mailbox3) != PROD_ID_3 ||
|
2428 |
|
|
RD_REG_WORD(®->mailbox4) != PROD_ID_4) {
|
2429 |
|
|
printk(KERN_INFO "qla1280: Wrong product ID = "
|
2430 |
|
|
"0x%x,0x%x,0x%x,0x%x\n",
|
2431 |
|
|
RD_REG_WORD(®->mailbox1),
|
2432 |
|
|
RD_REG_WORD(®->mailbox2),
|
2433 |
|
|
RD_REG_WORD(®->mailbox3),
|
2434 |
|
|
RD_REG_WORD(®->mailbox4));
|
2435 |
|
|
status = 1;
|
2436 |
|
|
} else {
|
2437 |
|
|
/*
|
2438 |
|
|
* Enable ints early!!!
|
2439 |
|
|
*/
|
2440 |
|
|
qla1280_enable_intrs(ha);
|
2441 |
|
|
|
2442 |
|
|
dprintk(1, "qla1280_chip_diag: Checking "
|
2443 |
|
|
"mailboxes of chip\n");
|
2444 |
|
|
/* Wrap Incoming Mailboxes Test. */
|
2445 |
|
|
mb[0] = MBC_MAILBOX_REGISTER_TEST;
|
2446 |
|
|
mb[1] = 0xAAAA;
|
2447 |
|
|
mb[2] = 0x5555;
|
2448 |
|
|
mb[3] = 0xAA55;
|
2449 |
|
|
mb[4] = 0x55AA;
|
2450 |
|
|
mb[5] = 0xA5A5;
|
2451 |
|
|
mb[6] = 0x5A5A;
|
2452 |
|
|
mb[7] = 0x2525;
|
2453 |
|
|
if (!(status = qla1280_mailbox_command(ha,
|
2454 |
|
|
0xff,
|
2455 |
|
|
&mb
|
2456 |
|
|
[0]))) {
|
2457 |
|
|
if (mb[1] != 0xAAAA ||
|
2458 |
|
|
mb[2] != 0x5555 ||
|
2459 |
|
|
mb[3] != 0xAA55 ||
|
2460 |
|
|
mb[4] != 0x55AA ||
|
2461 |
|
|
mb[5] != 0xA5A5 ||
|
2462 |
|
|
mb[6] != 0x5A5A ||
|
2463 |
|
|
mb[7] != 0x2525) {
|
2464 |
|
|
status = 1;
|
2465 |
|
|
printk(KERN_INFO "qla1280: "
|
2466 |
|
|
"Failed mbox check\n");
|
2467 |
|
|
}
|
2468 |
|
|
}
|
2469 |
|
|
}
|
2470 |
|
|
} else
|
2471 |
|
|
status = 1;
|
2472 |
|
|
} else
|
2473 |
|
|
status = 1;
|
2474 |
|
|
|
2475 |
|
|
if (status)
|
2476 |
|
|
dprintk(2, "qla1280_chip_diag: **** FAILED ****\n");
|
2477 |
|
|
else
|
2478 |
|
|
dprintk(3, "qla1280_chip_diag: exiting normally\n");
|
2479 |
|
|
|
2480 |
|
|
return status;
|
2481 |
|
|
}
|
2482 |
|
|
|
2483 |
|
|
/*
|
2484 |
|
|
* Setup chip
|
2485 |
|
|
* Load and start RISC firmware.
|
2486 |
|
|
*
|
2487 |
|
|
* Input:
|
2488 |
|
|
* ha = adapter block pointer.
|
2489 |
|
|
*
|
2490 |
|
|
* Returns:
|
2491 |
|
|
* 0 = success.
|
2492 |
|
|
*/
|
2493 |
|
|
#define DUMP_IT_BACK 0 /* for debug of RISC loading */
|
2494 |
|
|
static int
|
2495 |
|
|
qla1280_setup_chip(struct scsi_qla_host *ha)
|
2496 |
|
|
{
|
2497 |
|
|
int status = 0;
|
2498 |
|
|
uint16_t risc_address;
|
2499 |
|
|
uint16_t *risc_code_address;
|
2500 |
|
|
int risc_code_size;
|
2501 |
|
|
uint16_t mb[MAILBOX_REGISTER_COUNT];
|
2502 |
|
|
uint16_t cnt;
|
2503 |
|
|
int num, i;
|
2504 |
|
|
#if DUMP_IT_BACK
|
2505 |
|
|
uint8_t *sp;
|
2506 |
|
|
uint8_t *tbuf;
|
2507 |
|
|
dma_addr_t p_tbuf;
|
2508 |
|
|
#endif
|
2509 |
|
|
|
2510 |
|
|
ENTER("qla1280_setup_chip");
|
2511 |
|
|
|
2512 |
|
|
dprintk(1, "scsi(%ld): Setup chip\n", ha->host_no);
|
2513 |
|
|
|
2514 |
|
|
#if DUMP_IT_BACK
|
2515 |
|
|
/* get consistent memory allocated for setup_chip */
|
2516 |
|
|
tbuf = pci_alloc_consistent(ha->pdev, 8000, &p_tbuf);
|
2517 |
|
|
#endif
|
2518 |
|
|
|
2519 |
|
|
/* Load RISC code. */
|
2520 |
|
|
risc_address = *ql1280_board_tbl[ha->devnum].fwstart;
|
2521 |
|
|
risc_code_address = ql1280_board_tbl[ha->devnum].fwcode;
|
2522 |
|
|
risc_code_size = (int) *ql1280_board_tbl[ha->devnum].fwlen;
|
2523 |
|
|
|
2524 |
|
|
dprintk(1, "qla1280_setup_chip: DMA RISC code (%i) words\n",
|
2525 |
|
|
risc_code_size);
|
2526 |
|
|
|
2527 |
|
|
num = 0;
|
2528 |
|
|
while (risc_code_size > 0 && !status) {
|
2529 |
|
|
int warn __attribute__((unused)) = 0;
|
2530 |
|
|
|
2531 |
|
|
cnt = 2000 >> 1;
|
2532 |
|
|
|
2533 |
|
|
if (cnt > risc_code_size)
|
2534 |
|
|
cnt = risc_code_size;
|
2535 |
|
|
|
2536 |
|
|
dprintk(2, "qla1280_setup_chip: loading risc @ =(0x%p),"
|
2537 |
|
|
"%d,%d(0x%x)\n",
|
2538 |
|
|
risc_code_address, cnt, num, risc_address);
|
2539 |
|
|
for(i = 0; i < cnt; i++)
|
2540 |
|
|
((uint16_t *)ha->request_ring)[i] =
|
2541 |
|
|
cpu_to_le16(risc_code_address[i]);
|
2542 |
|
|
|
2543 |
|
|
flush_cache_all();
|
2544 |
|
|
|
2545 |
|
|
mb[0] = MBC_LOAD_RAM;
|
2546 |
|
|
mb[1] = risc_address;
|
2547 |
|
|
mb[4] = cnt;
|
2548 |
|
|
mb[3] = ha->request_dma & 0xffff;
|
2549 |
|
|
mb[2] = (ha->request_dma >> 16) & 0xffff;
|
2550 |
|
|
mb[7] = pci_dma_hi32(ha->request_dma) & 0xffff;
|
2551 |
|
|
mb[6] = pci_dma_hi32(ha->request_dma) >> 16;
|
2552 |
|
|
dprintk(2, "qla1280_setup_chip: op=%d 0x%p = 0x%4x,0x%4x,"
|
2553 |
|
|
"0x%4x,0x%4x\n", mb[0], (void *)(long)ha->request_dma,
|
2554 |
|
|
mb[6], mb[7], mb[2], mb[3]);
|
2555 |
|
|
if ((status = qla1280_mailbox_command(ha, BIT_4 | BIT_3 |
|
2556 |
|
|
BIT_2 | BIT_1 | BIT_0,
|
2557 |
|
|
&mb[0]))) {
|
2558 |
|
|
printk(KERN_ERR "scsi(%li): Failed to load partial "
|
2559 |
|
|
"segment of f\n", ha->host_no);
|
2560 |
|
|
break;
|
2561 |
|
|
}
|
2562 |
|
|
|
2563 |
|
|
#if DUMP_IT_BACK
|
2564 |
|
|
mb[0] = MBC_DUMP_RAM;
|
2565 |
|
|
mb[1] = risc_address;
|
2566 |
|
|
mb[4] = cnt;
|
2567 |
|
|
mb[3] = p_tbuf & 0xffff;
|
2568 |
|
|
mb[2] = (p_tbuf >> 16) & 0xffff;
|
2569 |
|
|
mb[7] = pci_dma_hi32(p_tbuf) & 0xffff;
|
2570 |
|
|
mb[6] = pci_dma_hi32(p_tbuf) >> 16;
|
2571 |
|
|
|
2572 |
|
|
if ((status = qla1280_mailbox_command(ha,
|
2573 |
|
|
BIT_4 | BIT_3 | BIT_2 |
|
2574 |
|
|
BIT_1 | BIT_0,
|
2575 |
|
|
&mb[0]))) {
|
2576 |
|
|
printk(KERN_ERR
|
2577 |
|
|
"Failed to dump partial segment of f/w\n");
|
2578 |
|
|
break;
|
2579 |
|
|
}
|
2580 |
|
|
sp = (uint8_t *)ha->request_ring;
|
2581 |
|
|
for (i = 0; i < (cnt << 1); i++) {
|
2582 |
|
|
if (tbuf[i] != sp[i] && warn++ < 10) {
|
2583 |
|
|
printk(KERN_ERR "qla1280_setup_chip: FW "
|
2584 |
|
|
"compare error @ byte(0x%x) loop#=%x\n",
|
2585 |
|
|
i, num);
|
2586 |
|
|
printk(KERN_ERR "setup_chip: FWbyte=%x "
|
2587 |
|
|
"FWfromChip=%x\n", sp[i], tbuf[i]);
|
2588 |
|
|
/*break; */
|
2589 |
|
|
}
|
2590 |
|
|
}
|
2591 |
|
|
#endif
|
2592 |
|
|
risc_address += cnt;
|
2593 |
|
|
risc_code_size = risc_code_size - cnt;
|
2594 |
|
|
risc_code_address = risc_code_address + cnt;
|
2595 |
|
|
num++;
|
2596 |
|
|
}
|
2597 |
|
|
|
2598 |
|
|
/* Verify checksum of loaded RISC code. */
|
2599 |
|
|
if (!status) {
|
2600 |
|
|
dprintk(1, "qla1280_setup_chip: Verifying checksum of "
|
2601 |
|
|
"loaded RISC code.\n");
|
2602 |
|
|
mb[0] = MBC_VERIFY_CHECKSUM;
|
2603 |
|
|
/* mb[1] = ql12_risc_code_addr01; */
|
2604 |
|
|
mb[1] = *ql1280_board_tbl[ha->devnum].fwstart;
|
2605 |
|
|
|
2606 |
|
|
if (!(status =
|
2607 |
|
|
qla1280_mailbox_command(ha, BIT_1 | BIT_0, &mb[0]))) {
|
2608 |
|
|
/* Start firmware execution. */
|
2609 |
|
|
dprintk(1,
|
2610 |
|
|
"qla1280_setup_chip: start firmware running.\n");
|
2611 |
|
|
mb[0] = MBC_EXECUTE_FIRMWARE;
|
2612 |
|
|
mb[1] = *ql1280_board_tbl[ha->devnum].fwstart;
|
2613 |
|
|
qla1280_mailbox_command(ha, BIT_1 | BIT_0, &mb[0]);
|
2614 |
|
|
} else
|
2615 |
|
|
printk(KERN_ERR "scsi(%li): qla1280_setup_chip: "
|
2616 |
|
|
"Failed checksum\n", ha->host_no);
|
2617 |
|
|
}
|
2618 |
|
|
|
2619 |
|
|
#if DUMP_IT_BACK
|
2620 |
|
|
/* free consistent memory allocated for setup_chip */
|
2621 |
|
|
pci_free_consistent(ha->pdev, 8000, tbuf, p_tbuf);
|
2622 |
|
|
#endif
|
2623 |
|
|
|
2624 |
|
|
if (status)
|
2625 |
|
|
dprintk(2, "qla1280_setup_chip: **** FAILED ****\n");
|
2626 |
|
|
|
2627 |
|
|
LEAVE("qla1280_setup_chip");
|
2628 |
|
|
return status;
|
2629 |
|
|
}
|
2630 |
|
|
|
2631 |
|
|
/*
|
2632 |
|
|
* Initialize rings
|
2633 |
|
|
*
|
2634 |
|
|
* Input:
|
2635 |
|
|
* ha = adapter block pointer.
|
2636 |
|
|
* ha->request_ring = request ring virtual address
|
2637 |
|
|
* ha->response_ring = response ring virtual address
|
2638 |
|
|
* ha->request_dma = request ring physical address
|
2639 |
|
|
* ha->response_dma = response ring physical address
|
2640 |
|
|
*
|
2641 |
|
|
* Returns:
|
2642 |
|
|
* 0 = success.
|
2643 |
|
|
*/
|
2644 |
|
|
static int
|
2645 |
|
|
qla1280_init_rings(struct scsi_qla_host *ha)
|
2646 |
|
|
{
|
2647 |
|
|
uint16_t mb[MAILBOX_REGISTER_COUNT];
|
2648 |
|
|
int status = 0;
|
2649 |
|
|
|
2650 |
|
|
ENTER("qla1280_init_rings");
|
2651 |
|
|
|
2652 |
|
|
/* Clear outstanding commands array. */
|
2653 |
|
|
memset(ha->outstanding_cmds, 0,
|
2654 |
|
|
sizeof(struct srb *) * MAX_OUTSTANDING_COMMANDS);
|
2655 |
|
|
|
2656 |
|
|
/* Initialize request queue. */
|
2657 |
|
|
ha->request_ring_ptr = ha->request_ring;
|
2658 |
|
|
ha->req_ring_index = 0;
|
2659 |
|
|
ha->req_q_cnt = REQUEST_ENTRY_CNT;
|
2660 |
|
|
/* mb[0] = MBC_INIT_REQUEST_QUEUE; */
|
2661 |
|
|
mb[0] = MBC_INIT_REQUEST_QUEUE_A64;
|
2662 |
|
|
mb[1] = REQUEST_ENTRY_CNT;
|
2663 |
|
|
mb[3] = ha->request_dma & 0xffff;
|
2664 |
|
|
mb[2] = (ha->request_dma >> 16) & 0xffff;
|
2665 |
|
|
mb[4] = 0;
|
2666 |
|
|
mb[7] = pci_dma_hi32(ha->request_dma) & 0xffff;
|
2667 |
|
|
mb[6] = pci_dma_hi32(ha->request_dma) >> 16;
|
2668 |
|
|
if (!(status = qla1280_mailbox_command(ha, BIT_7 | BIT_6 | BIT_4 |
|
2669 |
|
|
BIT_3 | BIT_2 | BIT_1 | BIT_0,
|
2670 |
|
|
&mb[0]))) {
|
2671 |
|
|
/* Initialize response queue. */
|
2672 |
|
|
ha->response_ring_ptr = ha->response_ring;
|
2673 |
|
|
ha->rsp_ring_index = 0;
|
2674 |
|
|
/* mb[0] = MBC_INIT_RESPONSE_QUEUE; */
|
2675 |
|
|
mb[0] = MBC_INIT_RESPONSE_QUEUE_A64;
|
2676 |
|
|
mb[1] = RESPONSE_ENTRY_CNT;
|
2677 |
|
|
mb[3] = ha->response_dma & 0xffff;
|
2678 |
|
|
mb[2] = (ha->response_dma >> 16) & 0xffff;
|
2679 |
|
|
mb[5] = 0;
|
2680 |
|
|
mb[7] = pci_dma_hi32(ha->response_dma) & 0xffff;
|
2681 |
|
|
mb[6] = pci_dma_hi32(ha->response_dma) >> 16;
|
2682 |
|
|
status = qla1280_mailbox_command(ha, BIT_7 | BIT_6 | BIT_5 |
|
2683 |
|
|
BIT_3 | BIT_2 | BIT_1 | BIT_0,
|
2684 |
|
|
&mb[0]);
|
2685 |
|
|
}
|
2686 |
|
|
|
2687 |
|
|
if (status)
|
2688 |
|
|
dprintk(2, "qla1280_init_rings: **** FAILED ****\n");
|
2689 |
|
|
|
2690 |
|
|
LEAVE("qla1280_init_rings");
|
2691 |
|
|
return status;
|
2692 |
|
|
}
|
2693 |
|
|
|
2694 |
|
|
/*
|
2695 |
|
|
* NVRAM configuration.
|
2696 |
|
|
*
|
2697 |
|
|
* Input:
|
2698 |
|
|
* ha = adapter block pointer.
|
2699 |
|
|
* ha->request_ring = request ring virtual address
|
2700 |
|
|
*
|
2701 |
|
|
* Output:
|
2702 |
|
|
* host adapters parameters in host adapter block
|
2703 |
|
|
*
|
2704 |
|
|
* Returns:
|
2705 |
|
|
* 0 = success.
|
2706 |
|
|
*/
|
2707 |
|
|
static int
|
2708 |
|
|
qla1280_nvram_config(struct scsi_qla_host *ha)
|
2709 |
|
|
{
|
2710 |
|
|
struct device_reg *reg = ha->iobase;
|
2711 |
|
|
struct nvram *nv;
|
2712 |
|
|
int is1x160, status = 0;
|
2713 |
|
|
int bus, target, lun;
|
2714 |
|
|
uint16_t mb[MAILBOX_REGISTER_COUNT];
|
2715 |
|
|
uint16_t mask;
|
2716 |
|
|
|
2717 |
|
|
ENTER("qla1280_nvram_config");
|
2718 |
|
|
|
2719 |
|
|
if (ha->device_id == PCI_DEVICE_ID_QLOGIC_ISP12160 ||
|
2720 |
|
|
ha->device_id == PCI_DEVICE_ID_QLOGIC_ISP10160)
|
2721 |
|
|
is1x160 = 1;
|
2722 |
|
|
else
|
2723 |
|
|
is1x160 = 0;
|
2724 |
|
|
|
2725 |
|
|
nv = &ha->nvram;
|
2726 |
|
|
if (!ha->nvram_valid) {
|
2727 |
|
|
dprintk(1, "Using defaults for NVRAM: \n");
|
2728 |
|
|
memset(nv, 0, sizeof(struct nvram));
|
2729 |
|
|
|
2730 |
|
|
/* nv->cntr_flags_1.disable_loading_risc_code = 1; */
|
2731 |
|
|
nv->firmware_feature.f.enable_fast_posting = 1;
|
2732 |
|
|
nv->firmware_feature.f.disable_synchronous_backoff = 1;
|
2733 |
|
|
|
2734 |
|
|
nv->termination.f.scsi_bus_0_control = 3;
|
2735 |
|
|
nv->termination.f.scsi_bus_1_control = 3;
|
2736 |
|
|
nv->termination.f.auto_term_support = 1;
|
2737 |
|
|
|
2738 |
|
|
/*
|
2739 |
|
|
* Set default FIFO magic - What appropriate values
|
2740 |
|
|
* would be here is unknown. This is what I have found
|
2741 |
|
|
* testing with 12160s.
|
2742 |
|
|
* Now, I would love the magic decoder ring for this one,
|
2743 |
|
|
* the header file provided by QLogic seems to be bogus
|
2744 |
|
|
* or incomplete at best.
|
2745 |
|
|
*/
|
2746 |
|
|
nv->isp_config.c = 0x44;
|
2747 |
|
|
|
2748 |
|
|
if (is1x160)
|
2749 |
|
|
nv->isp_parameter = 0x01;
|
2750 |
|
|
|
2751 |
|
|
for (bus = 0; bus < MAX_BUSES; bus++) {
|
2752 |
|
|
nv->bus[bus].config_1.initiator_id = 7;
|
2753 |
|
|
nv->bus[bus].bus_reset_delay = 5;
|
2754 |
|
|
/* 8 = 5.0 clocks */
|
2755 |
|
|
nv->bus[bus].config_2.async_data_setup_time = 8;
|
2756 |
|
|
nv->bus[bus].config_2.req_ack_active_negation = 1;
|
2757 |
|
|
nv->bus[bus].config_2.data_line_active_negation = 1;
|
2758 |
|
|
nv->bus[bus].selection_timeout = 250;
|
2759 |
|
|
nv->bus[bus].max_queue_depth = 256;
|
2760 |
|
|
|
2761 |
|
|
for (target = 0; target < MAX_TARGETS; target++) {
|
2762 |
|
|
nv->bus[bus].target[target].parameter.f.
|
2763 |
|
|
renegotiate_on_error = 1;
|
2764 |
|
|
nv->bus[bus].target[target].parameter.f.
|
2765 |
|
|
auto_request_sense = 1;
|
2766 |
|
|
nv->bus[bus].target[target].parameter.f.
|
2767 |
|
|
tag_queuing = 1;
|
2768 |
|
|
nv->bus[bus].target[target].parameter.f.
|
2769 |
|
|
enable_sync = 1;
|
2770 |
|
|
#if 1 /* Some SCSI Processors do not seem to like this */
|
2771 |
|
|
nv->bus[bus].target[target].parameter.f.
|
2772 |
|
|
enable_wide = 1;
|
2773 |
|
|
#endif
|
2774 |
|
|
nv->bus[bus].target[target].parameter.f.
|
2775 |
|
|
parity_checking = 1;
|
2776 |
|
|
nv->bus[bus].target[target].parameter.f.
|
2777 |
|
|
disconnect_allowed = 1;
|
2778 |
|
|
nv->bus[bus].target[target].execution_throttle=
|
2779 |
|
|
nv->bus[bus].max_queue_depth - 1;
|
2780 |
|
|
if (is1x160) {
|
2781 |
|
|
nv->bus[bus].target[target].flags.
|
2782 |
|
|
flags1x160.device_enable = 1;
|
2783 |
|
|
nv->bus[bus].target[target].flags.
|
2784 |
|
|
flags1x160.sync_offset = 0x0e;
|
2785 |
|
|
nv->bus[bus].target[target].
|
2786 |
|
|
sync_period = 9;
|
2787 |
|
|
nv->bus[bus].target[target].
|
2788 |
|
|
ppr_1x160.flags.enable_ppr = 1;
|
2789 |
|
|
nv->bus[bus].target[target].ppr_1x160.
|
2790 |
|
|
flags.ppr_options = 2;
|
2791 |
|
|
nv->bus[bus].target[target].ppr_1x160.
|
2792 |
|
|
flags.ppr_bus_width = 1;
|
2793 |
|
|
} else {
|
2794 |
|
|
nv->bus[bus].target[target].flags.
|
2795 |
|
|
flags1x80.device_enable = 1;
|
2796 |
|
|
nv->bus[bus].target[target].flags.
|
2797 |
|
|
flags1x80.sync_offset = 0x8;
|
2798 |
|
|
nv->bus[bus].target[target].
|
2799 |
|
|
sync_period = 10;
|
2800 |
|
|
}
|
2801 |
|
|
}
|
2802 |
|
|
}
|
2803 |
|
|
} else {
|
2804 |
|
|
/* Always force AUTO sense for LINUX SCSI */
|
2805 |
|
|
for (bus = 0; bus < MAX_BUSES; bus++)
|
2806 |
|
|
for (target = 0; target < MAX_TARGETS; target++) {
|
2807 |
|
|
nv->bus[bus].target[target].parameter.f.
|
2808 |
|
|
auto_request_sense = 1;
|
2809 |
|
|
}
|
2810 |
|
|
}
|
2811 |
|
|
dprintk(1, "qla1280 : initiator scsi id bus[0]=%d\n",
|
2812 |
|
|
nv->bus[0].config_1.initiator_id);
|
2813 |
|
|
dprintk(1, "qla1280 : initiator scsi id bus[1]=%d\n",
|
2814 |
|
|
nv->bus[1].config_1.initiator_id);
|
2815 |
|
|
|
2816 |
|
|
dprintk(1, "qla1280 : bus reset delay[0]=%d\n",
|
2817 |
|
|
nv->bus[0].bus_reset_delay);
|
2818 |
|
|
dprintk(1, "qla1280 : bus reset delay[1]=%d\n",
|
2819 |
|
|
nv->bus[1].bus_reset_delay);
|
2820 |
|
|
|
2821 |
|
|
dprintk(1, "qla1280 : retry count[0]=%d\n", nv->bus[0].retry_count);
|
2822 |
|
|
dprintk(1, "qla1280 : retry delay[0]=%d\n", nv->bus[0].retry_delay);
|
2823 |
|
|
dprintk(1, "qla1280 : retry count[1]=%d\n", nv->bus[1].retry_count);
|
2824 |
|
|
dprintk(1, "qla1280 : retry delay[1]=%d\n", nv->bus[1].retry_delay);
|
2825 |
|
|
|
2826 |
|
|
dprintk(1, "qla1280 : async data setup time[0]=%d\n",
|
2827 |
|
|
nv->bus[0].config_2.async_data_setup_time);
|
2828 |
|
|
dprintk(1, "qla1280 : async data setup time[1]=%d\n",
|
2829 |
|
|
nv->bus[1].config_2.async_data_setup_time);
|
2830 |
|
|
|
2831 |
|
|
dprintk(1, "qla1280 : req/ack active negation[0]=%d\n",
|
2832 |
|
|
nv->bus[0].config_2.req_ack_active_negation);
|
2833 |
|
|
dprintk(1, "qla1280 : req/ack active negation[1]=%d\n",
|
2834 |
|
|
nv->bus[1].config_2.req_ack_active_negation);
|
2835 |
|
|
|
2836 |
|
|
dprintk(1, "qla1280 : data line active negation[0]=%d\n",
|
2837 |
|
|
nv->bus[0].config_2.data_line_active_negation);
|
2838 |
|
|
dprintk(1, "qla1280 : data line active negation[1]=%d\n",
|
2839 |
|
|
nv->bus[1].config_2.data_line_active_negation);
|
2840 |
|
|
|
2841 |
|
|
dprintk(1, "qla1280 : disable loading risc code=%d\n",
|
2842 |
|
|
nv->cntr_flags_1.disable_loading_risc_code);
|
2843 |
|
|
|
2844 |
|
|
dprintk(1, "qla1280 : enable 64bit addressing=%d\n",
|
2845 |
|
|
nv->cntr_flags_1.enable_64bit_addressing);
|
2846 |
|
|
|
2847 |
|
|
dprintk(1, "qla1280 : selection timeout limit[0]=%d\n",
|
2848 |
|
|
nv->bus[0].selection_timeout);
|
2849 |
|
|
dprintk(1, "qla1280 : selection timeout limit[1]=%d\n",
|
2850 |
|
|
nv->bus[1].selection_timeout);
|
2851 |
|
|
|
2852 |
|
|
dprintk(1, "qla1280 : max queue depth[0]=%d\n",
|
2853 |
|
|
nv->bus[0].max_queue_depth);
|
2854 |
|
|
dprintk(1, "qla1280 : max queue depth[1]=%d\n",
|
2855 |
|
|
nv->bus[1].max_queue_depth);
|
2856 |
|
|
|
2857 |
|
|
/* Disable RISC load of firmware. */
|
2858 |
|
|
ha->flags.disable_risc_code_load =
|
2859 |
|
|
nv->cntr_flags_1.disable_loading_risc_code;
|
2860 |
|
|
|
2861 |
|
|
#ifdef QLA_64BIT_PTR
|
2862 |
|
|
/* Enable 64bit addressing for OS/System combination supporting it */
|
2863 |
|
|
/* actual NVRAM bit is: nv->cntr_flags_1.enable_64bit_addressing */
|
2864 |
|
|
/* but we will ignore it and use BITS_PER_LONG macro to setup for */
|
2865 |
|
|
/* 64 or 32 bit access of host memory in all x86/ia-64/Alpha systems */
|
2866 |
|
|
ha->flags.enable_64bit_addressing = 1;
|
2867 |
|
|
#else
|
2868 |
|
|
ha->flags.enable_64bit_addressing = 0;
|
2869 |
|
|
#endif
|
2870 |
|
|
|
2871 |
|
|
if (ha->flags.enable_64bit_addressing) {
|
2872 |
|
|
dprintk(2, "scsi(%li): 64 Bit PCI Addressing Enabled\n",
|
2873 |
|
|
ha->host_no);
|
2874 |
|
|
|
2875 |
|
|
pci_set_dma_mask(ha->pdev, (dma_addr_t) ~ 0ULL);
|
2876 |
|
|
}
|
2877 |
|
|
|
2878 |
|
|
/* Set ISP hardware DMA burst */
|
2879 |
|
|
mb[0] = nv->isp_config.c;
|
2880 |
|
|
/* Enable DMA arbitration on dual channel controllers */
|
2881 |
|
|
if (ha->ports > 1)
|
2882 |
|
|
mb[0] |= BIT_13;
|
2883 |
|
|
WRT_REG_WORD(®->cfg_1, mb[0]);
|
2884 |
|
|
|
2885 |
|
|
#if 1 /* Is this safe? */
|
2886 |
|
|
/* Set SCSI termination. */
|
2887 |
|
|
WRT_REG_WORD(®->gpio_enable, (BIT_3 + BIT_2 + BIT_1 + BIT_0));
|
2888 |
|
|
mb[0] = nv->termination.c & (BIT_3 + BIT_2 + BIT_1 + BIT_0);
|
2889 |
|
|
WRT_REG_WORD(®->gpio_data, mb[0]);
|
2890 |
|
|
#endif
|
2891 |
|
|
|
2892 |
|
|
/* ISP parameter word. */
|
2893 |
|
|
mb[0] = MBC_SET_SYSTEM_PARAMETER;
|
2894 |
|
|
mb[1] = nv->isp_parameter;
|
2895 |
|
|
status |= qla1280_mailbox_command(ha, BIT_1 | BIT_0, &mb[0]);
|
2896 |
|
|
|
2897 |
|
|
#if 0
|
2898 |
|
|
/* clock rate - for qla1240 and older, only */
|
2899 |
|
|
mb[0] = MBC_SET_CLOCK_RATE;
|
2900 |
|
|
mb[1] = 0x50;
|
2901 |
|
|
status |= qla1280_mailbox_command(ha, BIT_1 | BIT_0, &mb[0]);
|
2902 |
|
|
#endif
|
2903 |
|
|
/* Firmware feature word. */
|
2904 |
|
|
mb[0] = MBC_SET_FIRMWARE_FEATURES;
|
2905 |
|
|
mask = BIT_5 | BIT_1 | BIT_0;
|
2906 |
|
|
mb[1] = le16_to_cpu(nv->firmware_feature.w) & (mask);
|
2907 |
|
|
#if defined(CONFIG_IA64_GENERIC) || defined (CONFIG_IA64_SGI_SN2)
|
2908 |
|
|
if (ia64_platform_is("sn2")) {
|
2909 |
|
|
printk(KERN_INFO "scsi(%li): Enabling SN2 PCI DMA "
|
2910 |
|
|
"workaround\n", ha->host_no);
|
2911 |
|
|
mb[1] |= BIT_9;
|
2912 |
|
|
}
|
2913 |
|
|
#endif
|
2914 |
|
|
status |= qla1280_mailbox_command(ha, mask, &mb[0]);
|
2915 |
|
|
|
2916 |
|
|
/* Retry count and delay. */
|
2917 |
|
|
mb[0] = MBC_SET_RETRY_COUNT;
|
2918 |
|
|
mb[1] = nv->bus[0].retry_count;
|
2919 |
|
|
mb[2] = nv->bus[0].retry_delay;
|
2920 |
|
|
mb[6] = nv->bus[1].retry_count;
|
2921 |
|
|
mb[7] = nv->bus[1].retry_delay;
|
2922 |
|
|
status |= qla1280_mailbox_command(ha, BIT_7 | BIT_6 | BIT_2 |
|
2923 |
|
|
BIT_1 | BIT_0, &mb[0]);
|
2924 |
|
|
|
2925 |
|
|
/* ASYNC data setup time. */
|
2926 |
|
|
mb[0] = MBC_SET_ASYNC_DATA_SETUP;
|
2927 |
|
|
mb[1] = nv->bus[0].config_2.async_data_setup_time;
|
2928 |
|
|
mb[2] = nv->bus[1].config_2.async_data_setup_time;
|
2929 |
|
|
status |= qla1280_mailbox_command(ha, BIT_2 | BIT_1 | BIT_0, &mb[0]);
|
2930 |
|
|
|
2931 |
|
|
/* Active negation states. */
|
2932 |
|
|
mb[0] = MBC_SET_ACTIVE_NEGATION;
|
2933 |
|
|
mb[1] = 0;
|
2934 |
|
|
if (nv->bus[0].config_2.req_ack_active_negation)
|
2935 |
|
|
mb[1] |= BIT_5;
|
2936 |
|
|
if (nv->bus[0].config_2.data_line_active_negation)
|
2937 |
|
|
mb[1] |= BIT_4;
|
2938 |
|
|
mb[2] = 0;
|
2939 |
|
|
if (nv->bus[1].config_2.req_ack_active_negation)
|
2940 |
|
|
mb[2] |= BIT_5;
|
2941 |
|
|
if (nv->bus[1].config_2.data_line_active_negation)
|
2942 |
|
|
mb[2] |= BIT_4;
|
2943 |
|
|
status |= qla1280_mailbox_command(ha, BIT_2 | BIT_1 | BIT_0, &mb[0]);
|
2944 |
|
|
|
2945 |
|
|
mb[0] = MBC_SET_DATA_OVERRUN_RECOVERY;
|
2946 |
|
|
mb[1] = 2; /* Reset SCSI bus and return all outstanding IO */
|
2947 |
|
|
status |= qla1280_mailbox_command(ha, BIT_1 | BIT_0, &mb[0]);
|
2948 |
|
|
|
2949 |
|
|
/* thingy */
|
2950 |
|
|
mb[0] = MBC_SET_PCI_CONTROL;
|
2951 |
|
|
mb[1] = 2; /* Data DMA Channel Burst Enable */
|
2952 |
|
|
mb[2] = 2; /* Command DMA Channel Burst Enable */
|
2953 |
|
|
status |= qla1280_mailbox_command(ha, BIT_2 | BIT_1 | BIT_0, &mb[0]);
|
2954 |
|
|
|
2955 |
|
|
/* Selection timeout. */
|
2956 |
|
|
mb[0] = MBC_SET_SELECTION_TIMEOUT;
|
2957 |
|
|
mb[1] = nv->bus[0].selection_timeout;
|
2958 |
|
|
mb[2] = nv->bus[1].selection_timeout;
|
2959 |
|
|
status |= qla1280_mailbox_command(ha, BIT_2 | BIT_1 | BIT_0, &mb[0]);
|
2960 |
|
|
|
2961 |
|
|
for (bus = 0; bus < ha->ports; bus++) {
|
2962 |
|
|
/* SCSI Reset Disable. */
|
2963 |
|
|
ha->bus_settings[bus].disable_scsi_reset =
|
2964 |
|
|
nv->bus[bus].config_1.scsi_reset_disable;
|
2965 |
|
|
|
2966 |
|
|
/* Initiator ID. */
|
2967 |
|
|
ha->bus_settings[bus].id = nv->bus[bus].config_1.initiator_id;
|
2968 |
|
|
mb[0] = MBC_SET_INITIATOR_ID;
|
2969 |
|
|
mb[1] = bus ? ha->bus_settings[bus].id | BIT_7 :
|
2970 |
|
|
ha->bus_settings[bus].id;
|
2971 |
|
|
status |= qla1280_mailbox_command(ha, BIT_1 | BIT_0, &mb[0]);
|
2972 |
|
|
|
2973 |
|
|
/* Reset Delay. */
|
2974 |
|
|
ha->bus_settings[bus].bus_reset_delay =
|
2975 |
|
|
nv->bus[bus].bus_reset_delay;
|
2976 |
|
|
|
2977 |
|
|
/* Command queue depth per device. */
|
2978 |
|
|
ha->bus_settings[bus].hiwat = nv->bus[bus].max_queue_depth - 1;
|
2979 |
|
|
|
2980 |
|
|
/* Set target parameters. */
|
2981 |
|
|
for (target = 0; target < MAX_TARGETS; target++) {
|
2982 |
|
|
uint8_t mr = BIT_2 | BIT_1 | BIT_0;
|
2983 |
|
|
|
2984 |
|
|
/* Set Target Parameters. */
|
2985 |
|
|
mb[0] = MBC_SET_TARGET_PARAMETERS;
|
2986 |
|
|
mb[1] = (uint16_t) (bus ? target | BIT_7 : target);
|
2987 |
|
|
mb[1] <<= 8;
|
2988 |
|
|
/*
|
2989 |
|
|
* Do not enable wide, sync, and ppr for the initial
|
2990 |
|
|
* INQUIRY run. We enable this later if we determine
|
2991 |
|
|
* the target actually supports it.
|
2992 |
|
|
*/
|
2993 |
|
|
nv->bus[bus].target[target].parameter.f.
|
2994 |
|
|
auto_request_sense = 1;
|
2995 |
|
|
nv->bus[bus].target[target].parameter.f.
|
2996 |
|
|
stop_queue_on_check = 0;
|
2997 |
|
|
|
2998 |
|
|
if (is1x160)
|
2999 |
|
|
nv->bus[bus].target[target].ppr_1x160.
|
3000 |
|
|
flags.enable_ppr = 0;
|
3001 |
|
|
/*
|
3002 |
|
|
* No sync, wide, etc. while probing
|
3003 |
|
|
*/
|
3004 |
|
|
mb[2] = (nv->bus[bus].target[target].parameter.c << 8)&
|
3005 |
|
|
~(TP_SYNC /*| TP_WIDE | TP_PPR*/);
|
3006 |
|
|
|
3007 |
|
|
if (is1x160)
|
3008 |
|
|
mb[3] = nv->bus[bus].target[target].flags.flags1x160.sync_offset << 8;
|
3009 |
|
|
else
|
3010 |
|
|
mb[3] = nv->bus[bus].target[target].flags.flags1x80.sync_offset << 8;
|
3011 |
|
|
mb[3] |= nv->bus[bus].target[target].sync_period;
|
3012 |
|
|
mr |= BIT_3;
|
3013 |
|
|
|
3014 |
|
|
/*
|
3015 |
|
|
* We don't want to enable ppr etc. before we have
|
3016 |
|
|
* determined that the target actually supports it
|
3017 |
|
|
*/
|
3018 |
|
|
#if 0
|
3019 |
|
|
if (is1x160) {
|
3020 |
|
|
mb[2] |= nv->bus[bus].target[target].ppr_1x160.flags.enable_ppr << 5;
|
3021 |
|
|
|
3022 |
|
|
mb[6] = nv->bus[bus].target[target].ppr_1x160.flags.ppr_options << 8;
|
3023 |
|
|
mb[6] |= nv->bus[bus].target[target].ppr_1x160.flags.ppr_bus_width;
|
3024 |
|
|
mr |= BIT_6;
|
3025 |
|
|
}
|
3026 |
|
|
#endif
|
3027 |
|
|
|
3028 |
|
|
status = qla1280_mailbox_command(ha, mr, &mb[0]);
|
3029 |
|
|
|
3030 |
|
|
/* Save Tag queuing enable flag. */
|
3031 |
|
|
mb[0] = BIT_0 << target;
|
3032 |
|
|
if (nv->bus[bus].target[target].parameter.f.tag_queuing)
|
3033 |
|
|
ha->bus_settings[bus].qtag_enables |= mb[0];
|
3034 |
|
|
|
3035 |
|
|
/* Save Device enable flag. */
|
3036 |
|
|
if (is1x160) {
|
3037 |
|
|
if (nv->bus[bus].target[target].flags.flags1x160.device_enable)
|
3038 |
|
|
ha->bus_settings[bus].device_enables |= mb[0];
|
3039 |
|
|
ha->bus_settings[bus].lun_disables |= 0;
|
3040 |
|
|
} else {
|
3041 |
|
|
if (nv->bus[bus].target[target].flags.flags1x80.device_enable)
|
3042 |
|
|
ha->bus_settings[bus].device_enables |= mb[0];
|
3043 |
|
|
/* Save LUN disable flag. */
|
3044 |
|
|
if (nv->bus[bus].target[target].flags.flags1x80.lun_disable)
|
3045 |
|
|
ha->bus_settings[bus].lun_disables |= mb[0];
|
3046 |
|
|
}
|
3047 |
|
|
|
3048 |
|
|
|
3049 |
|
|
/* Set Device Queue Parameters. */
|
3050 |
|
|
for (lun = 0; lun < MAX_LUNS; lun++) {
|
3051 |
|
|
mb[0] = MBC_SET_DEVICE_QUEUE;
|
3052 |
|
|
mb[1] = (uint16_t)(bus ? target | BIT_7 : target);
|
3053 |
|
|
mb[1] = mb[1] << 8 | lun;
|
3054 |
|
|
mb[2] = nv->bus[bus].max_queue_depth;
|
3055 |
|
|
mb[3] = nv->bus[bus].target[target].execution_throttle;
|
3056 |
|
|
status |= qla1280_mailbox_command(ha, 0x0f,
|
3057 |
|
|
&mb[0]);
|
3058 |
|
|
}
|
3059 |
|
|
}
|
3060 |
|
|
}
|
3061 |
|
|
|
3062 |
|
|
if (status)
|
3063 |
|
|
dprintk(2, "qla1280_nvram_config: **** FAILED ****\n");
|
3064 |
|
|
|
3065 |
|
|
LEAVE("qla1280_nvram_config");
|
3066 |
|
|
return status;
|
3067 |
|
|
}
|
3068 |
|
|
|
3069 |
|
|
/*
|
3070 |
|
|
* Get NVRAM data word
|
3071 |
|
|
* Calculates word position in NVRAM and calls request routine to
|
3072 |
|
|
* get the word from NVRAM.
|
3073 |
|
|
*
|
3074 |
|
|
* Input:
|
3075 |
|
|
* ha = adapter block pointer.
|
3076 |
|
|
* address = NVRAM word address.
|
3077 |
|
|
*
|
3078 |
|
|
* Returns:
|
3079 |
|
|
* data word.
|
3080 |
|
|
*/
|
3081 |
|
|
static uint16_t
|
3082 |
|
|
qla1280_get_nvram_word(struct scsi_qla_host *ha, uint32_t address)
|
3083 |
|
|
{
|
3084 |
|
|
uint32_t nv_cmd;
|
3085 |
|
|
uint16_t data;
|
3086 |
|
|
|
3087 |
|
|
nv_cmd = address << 16;
|
3088 |
|
|
nv_cmd |= NV_READ_OP;
|
3089 |
|
|
|
3090 |
|
|
data = le16_to_cpu(qla1280_nvram_request(ha, nv_cmd));
|
3091 |
|
|
|
3092 |
|
|
dprintk(8, "qla1280_get_nvram_word: exiting normally NVRAM data = "
|
3093 |
|
|
"0x%x", data);
|
3094 |
|
|
|
3095 |
|
|
return data;
|
3096 |
|
|
}
|
3097 |
|
|
|
3098 |
|
|
/*
|
3099 |
|
|
* NVRAM request
|
3100 |
|
|
* Sends read command to NVRAM and gets data from NVRAM.
|
3101 |
|
|
*
|
3102 |
|
|
* Input:
|
3103 |
|
|
* ha = adapter block pointer.
|
3104 |
|
|
* nv_cmd = Bit 26 = start bit
|
3105 |
|
|
* Bit 25, 24 = opcode
|
3106 |
|
|
* Bit 23-16 = address
|
3107 |
|
|
* Bit 15-0 = write data
|
3108 |
|
|
*
|
3109 |
|
|
* Returns:
|
3110 |
|
|
* data word.
|
3111 |
|
|
*/
|
3112 |
|
|
static uint16_t
|
3113 |
|
|
qla1280_nvram_request(struct scsi_qla_host *ha, uint32_t nv_cmd)
|
3114 |
|
|
{
|
3115 |
|
|
struct device_reg *reg = ha->iobase;
|
3116 |
|
|
int cnt;
|
3117 |
|
|
uint16_t data = 0;
|
3118 |
|
|
uint16_t reg_data;
|
3119 |
|
|
|
3120 |
|
|
/* Send command to NVRAM. */
|
3121 |
|
|
|
3122 |
|
|
nv_cmd <<= 5;
|
3123 |
|
|
for (cnt = 0; cnt < 11; cnt++) {
|
3124 |
|
|
if (nv_cmd & BIT_31)
|
3125 |
|
|
qla1280_nv_write(ha, NV_DATA_OUT);
|
3126 |
|
|
else
|
3127 |
|
|
qla1280_nv_write(ha, 0);
|
3128 |
|
|
nv_cmd <<= 1;
|
3129 |
|
|
}
|
3130 |
|
|
|
3131 |
|
|
/* Read data from NVRAM. */
|
3132 |
|
|
|
3133 |
|
|
for (cnt = 0; cnt < 16; cnt++) {
|
3134 |
|
|
WRT_REG_WORD(®->nvram, (NV_SELECT | NV_CLOCK));
|
3135 |
|
|
RD_REG_WORD(®->id_l); /* Flush PCI write */
|
3136 |
|
|
NVRAM_DELAY();
|
3137 |
|
|
data <<= 1;
|
3138 |
|
|
reg_data = RD_REG_WORD(®->nvram);
|
3139 |
|
|
if (reg_data & NV_DATA_IN)
|
3140 |
|
|
data |= BIT_0;
|
3141 |
|
|
WRT_REG_WORD(®->nvram, NV_SELECT);
|
3142 |
|
|
RD_REG_WORD(®->id_l); /* Flush PCI write */
|
3143 |
|
|
NVRAM_DELAY();
|
3144 |
|
|
}
|
3145 |
|
|
|
3146 |
|
|
/* Deselect chip. */
|
3147 |
|
|
|
3148 |
|
|
WRT_REG_WORD(®->nvram, NV_DESELECT);
|
3149 |
|
|
RD_REG_WORD(®->id_l); /* Flush PCI write */
|
3150 |
|
|
NVRAM_DELAY();
|
3151 |
|
|
|
3152 |
|
|
return data;
|
3153 |
|
|
}
|
3154 |
|
|
|
3155 |
|
|
static void
|
3156 |
|
|
qla1280_nv_write(struct scsi_qla_host *ha, uint16_t data)
|
3157 |
|
|
{
|
3158 |
|
|
struct device_reg *reg = ha->iobase;
|
3159 |
|
|
|
3160 |
|
|
WRT_REG_WORD(®->nvram, data | NV_SELECT);
|
3161 |
|
|
RD_REG_WORD(®->id_l); /* Flush PCI write */
|
3162 |
|
|
NVRAM_DELAY();
|
3163 |
|
|
WRT_REG_WORD(®->nvram, data | NV_SELECT | NV_CLOCK);
|
3164 |
|
|
RD_REG_WORD(®->id_l); /* Flush PCI write */
|
3165 |
|
|
NVRAM_DELAY();
|
3166 |
|
|
WRT_REG_WORD(®->nvram, data | NV_SELECT);
|
3167 |
|
|
RD_REG_WORD(®->id_l); /* Flush PCI write */
|
3168 |
|
|
NVRAM_DELAY();
|
3169 |
|
|
}
|
3170 |
|
|
|
3171 |
|
|
/*
|
3172 |
|
|
* Mailbox Command
|
3173 |
|
|
* Issue mailbox command and waits for completion.
|
3174 |
|
|
*
|
3175 |
|
|
* Input:
|
3176 |
|
|
* ha = adapter block pointer.
|
3177 |
|
|
* mr = mailbox registers to load.
|
3178 |
|
|
* mb = data pointer for mailbox registers.
|
3179 |
|
|
*
|
3180 |
|
|
* Output:
|
3181 |
|
|
* mb[MAILBOX_REGISTER_COUNT] = returned mailbox data.
|
3182 |
|
|
*
|
3183 |
|
|
* Returns:
|
3184 |
|
|
* 0 = success
|
3185 |
|
|
*/
|
3186 |
|
|
static int
|
3187 |
|
|
qla1280_mailbox_command(struct scsi_qla_host *ha, uint8_t mr, uint16_t *mb)
|
3188 |
|
|
{
|
3189 |
|
|
struct device_reg *reg = ha->iobase;
|
3190 |
|
|
#if 0
|
3191 |
|
|
struct srb *done_q_first = 0;
|
3192 |
|
|
struct srb *done_q_last = 0;
|
3193 |
|
|
#endif
|
3194 |
|
|
int status = 0;
|
3195 |
|
|
int cnt;
|
3196 |
|
|
uint16_t *optr, *iptr;
|
3197 |
|
|
uint16_t data;
|
3198 |
|
|
DECLARE_COMPLETION(wait);
|
3199 |
|
|
struct timer_list timer;
|
3200 |
|
|
|
3201 |
|
|
ENTER("qla1280_mailbox_command");
|
3202 |
|
|
|
3203 |
|
|
ha->flags.mbox_busy = 1;
|
3204 |
|
|
|
3205 |
|
|
if (ha->mailbox_wait) {
|
3206 |
|
|
printk(KERN_ERR "Warning mailbox wait already in use!\n");
|
3207 |
|
|
}
|
3208 |
|
|
ha->mailbox_wait = &wait;
|
3209 |
|
|
|
3210 |
|
|
/*
|
3211 |
|
|
* We really should start out by verifying that the mailbox is
|
3212 |
|
|
* available before starting sending the command data
|
3213 |
|
|
*/
|
3214 |
|
|
/* Load mailbox registers. */
|
3215 |
|
|
optr = (uint16_t *) ®->mailbox0;
|
3216 |
|
|
iptr = mb;
|
3217 |
|
|
for (cnt = 0; cnt < MAILBOX_REGISTER_COUNT; cnt++) {
|
3218 |
|
|
if (mr & BIT_0) {
|
3219 |
|
|
WRT_REG_WORD(optr, (*iptr));
|
3220 |
|
|
}
|
3221 |
|
|
|
3222 |
|
|
mr >>= 1;
|
3223 |
|
|
optr++;
|
3224 |
|
|
iptr++;
|
3225 |
|
|
}
|
3226 |
|
|
|
3227 |
|
|
/* Issue set host interrupt command. */
|
3228 |
|
|
ha->flags.mbox_busy = 0;
|
3229 |
|
|
|
3230 |
|
|
/* set up a timer just in case we're really jammed */
|
3231 |
|
|
init_timer(&timer);
|
3232 |
|
|
timer.expires = jiffies + 20*HZ;
|
3233 |
|
|
timer.data = (unsigned long)ha;
|
3234 |
|
|
timer.function = qla1280_mailbox_timeout;
|
3235 |
|
|
add_timer(&timer);
|
3236 |
|
|
|
3237 |
|
|
spin_unlock_irq(HOST_LOCK);
|
3238 |
|
|
WRT_REG_WORD(®->host_cmd, HC_SET_HOST_INT);
|
3239 |
|
|
data = qla1280_debounce_register(®->istatus);
|
3240 |
|
|
|
3241 |
|
|
wait_for_completion(&wait);
|
3242 |
|
|
del_timer_sync(&timer);
|
3243 |
|
|
|
3244 |
|
|
spin_lock_irq(HOST_LOCK);
|
3245 |
|
|
|
3246 |
|
|
ha->mailbox_wait = NULL;
|
3247 |
|
|
|
3248 |
|
|
/* Check for mailbox command timeout. */
|
3249 |
|
|
if (ha->mailbox_out[0] != MBS_CMD_CMP) {
|
3250 |
|
|
printk(KERN_WARNING "qla1280_mailbox_command: Command failed, "
|
3251 |
|
|
"mailbox0 = 0x%04x, mailbox_out0 = 0x%04x, istatus = "
|
3252 |
|
|
"0x%04x\n",
|
3253 |
|
|
mb[0], ha->mailbox_out[0], RD_REG_WORD(®->istatus));
|
3254 |
|
|
printk(KERN_WARNING "m0 %04x, m1 %04x, m2 %04x, m3 %04x\n",
|
3255 |
|
|
RD_REG_WORD(®->mailbox0), RD_REG_WORD(®->mailbox1),
|
3256 |
|
|
RD_REG_WORD(®->mailbox2), RD_REG_WORD(®->mailbox3));
|
3257 |
|
|
printk(KERN_WARNING "m4 %04x, m5 %04x, m6 %04x, m7 %04x\n",
|
3258 |
|
|
RD_REG_WORD(®->mailbox4), RD_REG_WORD(®->mailbox5),
|
3259 |
|
|
RD_REG_WORD(®->mailbox6), RD_REG_WORD(®->mailbox7));
|
3260 |
|
|
status = 1;
|
3261 |
|
|
}
|
3262 |
|
|
|
3263 |
|
|
/* Load return mailbox registers. */
|
3264 |
|
|
optr = mb;
|
3265 |
|
|
iptr = (uint16_t *) &ha->mailbox_out[0];
|
3266 |
|
|
mr = MAILBOX_REGISTER_COUNT;
|
3267 |
|
|
memcpy(optr, iptr, MAILBOX_REGISTER_COUNT * sizeof(uint16_t));
|
3268 |
|
|
|
3269 |
|
|
#if 0
|
3270 |
|
|
/* Go check for any response interrupts pending. */
|
3271 |
|
|
qla1280_isr(ha, &done_q_first, &done_q_last);
|
3272 |
|
|
#endif
|
3273 |
|
|
|
3274 |
|
|
if (ha->flags.reset_marker)
|
3275 |
|
|
qla1280_rst_aen(ha);
|
3276 |
|
|
|
3277 |
|
|
#if 0
|
3278 |
|
|
if (done_q_first)
|
3279 |
|
|
qla1280_done (ha, &done_q_first, &done_q_last);
|
3280 |
|
|
#endif
|
3281 |
|
|
|
3282 |
|
|
if (status)
|
3283 |
|
|
dprintk(2, "qla1280_mailbox_command: **** FAILED, mailbox0 = "
|
3284 |
|
|
"0x%x ****\n", mb[0]);
|
3285 |
|
|
|
3286 |
|
|
LEAVE("qla1280_mailbox_command");
|
3287 |
|
|
return status;
|
3288 |
|
|
}
|
3289 |
|
|
|
3290 |
|
|
/*
|
3291 |
|
|
* qla1280_poll
|
3292 |
|
|
* Polls ISP for interrupts.
|
3293 |
|
|
*
|
3294 |
|
|
* Input:
|
3295 |
|
|
* ha = adapter block pointer.
|
3296 |
|
|
*/
|
3297 |
|
|
static void
|
3298 |
|
|
qla1280_poll(struct scsi_qla_host *ha)
|
3299 |
|
|
{
|
3300 |
|
|
struct device_reg *reg = ha->iobase;
|
3301 |
|
|
uint16_t data;
|
3302 |
|
|
struct srb *done_q_first = 0;
|
3303 |
|
|
struct srb *done_q_last = 0;
|
3304 |
|
|
|
3305 |
|
|
/* ENTER("qla1280_poll"); */
|
3306 |
|
|
|
3307 |
|
|
/* Check for pending interrupts. */
|
3308 |
|
|
data = RD_REG_WORD(®->istatus);
|
3309 |
|
|
if (data & RISC_INT)
|
3310 |
|
|
qla1280_isr(ha, &done_q_first, &done_q_last);
|
3311 |
|
|
|
3312 |
|
|
if (!ha->flags.mbox_busy) {
|
3313 |
|
|
if (ha->flags.reset_marker)
|
3314 |
|
|
qla1280_rst_aen(ha);
|
3315 |
|
|
}
|
3316 |
|
|
|
3317 |
|
|
if (done_q_first)
|
3318 |
|
|
qla1280_done(ha, &done_q_first, &done_q_last);
|
3319 |
|
|
|
3320 |
|
|
/* LEAVE("qla1280_poll"); */
|
3321 |
|
|
}
|
3322 |
|
|
|
3323 |
|
|
/*
|
3324 |
|
|
* qla1280_bus_reset
|
3325 |
|
|
* Issue SCSI bus reset.
|
3326 |
|
|
*
|
3327 |
|
|
* Input:
|
3328 |
|
|
* ha = adapter block pointer.
|
3329 |
|
|
* bus = SCSI bus number.
|
3330 |
|
|
*
|
3331 |
|
|
* Returns:
|
3332 |
|
|
* 0 = success
|
3333 |
|
|
*/
|
3334 |
|
|
static int
|
3335 |
|
|
qla1280_bus_reset(struct scsi_qla_host *ha, int bus)
|
3336 |
|
|
{
|
3337 |
|
|
uint16_t mb[MAILBOX_REGISTER_COUNT];
|
3338 |
|
|
uint16_t reset_delay;
|
3339 |
|
|
int status;
|
3340 |
|
|
|
3341 |
|
|
dprintk(3, "qla1280_bus_reset: entered\n");
|
3342 |
|
|
|
3343 |
|
|
if (qla1280_verbose)
|
3344 |
|
|
printk(KERN_INFO "scsi(%li:%i): Resetting SCSI BUS\n",
|
3345 |
|
|
ha->host_no, bus);
|
3346 |
|
|
|
3347 |
|
|
reset_delay = ha->bus_settings[bus].bus_reset_delay;
|
3348 |
|
|
mb[0] = MBC_BUS_RESET;
|
3349 |
|
|
mb[1] = reset_delay;
|
3350 |
|
|
mb[2] = (uint16_t) bus;
|
3351 |
|
|
status = qla1280_mailbox_command(ha, BIT_2 | BIT_1 | BIT_0, &mb[0]);
|
3352 |
|
|
|
3353 |
|
|
if (status) {
|
3354 |
|
|
if (ha->bus_settings[bus].failed_reset_count > 2)
|
3355 |
|
|
ha->bus_settings[bus].scsi_bus_dead = 1;
|
3356 |
|
|
ha->bus_settings[bus].failed_reset_count++;
|
3357 |
|
|
} else {
|
3358 |
|
|
spin_unlock_irq(HOST_LOCK);
|
3359 |
|
|
schedule_timeout(reset_delay * HZ);
|
3360 |
|
|
spin_lock_irq(HOST_LOCK);
|
3361 |
|
|
|
3362 |
|
|
ha->bus_settings[bus].scsi_bus_dead = 0;
|
3363 |
|
|
ha->bus_settings[bus].failed_reset_count = 0;
|
3364 |
|
|
ha->bus_settings[bus].reset_marker = 0;
|
3365 |
|
|
/* Issue marker command. */
|
3366 |
|
|
qla1280_marker(ha, bus, 0, 0, MK_SYNC_ALL);
|
3367 |
|
|
}
|
3368 |
|
|
|
3369 |
|
|
/*
|
3370 |
|
|
* We should probably call qla1280_set_target_parameters()
|
3371 |
|
|
* here as well for all devices on the bus.
|
3372 |
|
|
*/
|
3373 |
|
|
|
3374 |
|
|
if (status)
|
3375 |
|
|
dprintk(2, "qla1280_bus_reset: **** FAILED ****\n");
|
3376 |
|
|
else
|
3377 |
|
|
dprintk(3, "qla1280_bus_reset: exiting normally\n");
|
3378 |
|
|
|
3379 |
|
|
return status;
|
3380 |
|
|
}
|
3381 |
|
|
|
3382 |
|
|
/*
|
3383 |
|
|
* qla1280_device_reset
|
3384 |
|
|
* Issue bus device reset message to the target.
|
3385 |
|
|
*
|
3386 |
|
|
* Input:
|
3387 |
|
|
* ha = adapter block pointer.
|
3388 |
|
|
* bus = SCSI BUS number.
|
3389 |
|
|
* target = SCSI ID.
|
3390 |
|
|
*
|
3391 |
|
|
* Returns:
|
3392 |
|
|
* 0 = success
|
3393 |
|
|
*/
|
3394 |
|
|
static int
|
3395 |
|
|
qla1280_device_reset(struct scsi_qla_host *ha, int bus, int target)
|
3396 |
|
|
{
|
3397 |
|
|
uint16_t mb[MAILBOX_REGISTER_COUNT];
|
3398 |
|
|
int status;
|
3399 |
|
|
|
3400 |
|
|
ENTER("qla1280_device_reset");
|
3401 |
|
|
|
3402 |
|
|
mb[0] = MBC_ABORT_TARGET;
|
3403 |
|
|
mb[1] = (bus ? (target | BIT_7) : target) << 8;
|
3404 |
|
|
mb[2] = 1;
|
3405 |
|
|
status = qla1280_mailbox_command(ha, BIT_2 | BIT_1 | BIT_0, &mb[0]);
|
3406 |
|
|
|
3407 |
|
|
/* Issue marker command. */
|
3408 |
|
|
qla1280_marker(ha, bus, target, 0, MK_SYNC_ID);
|
3409 |
|
|
|
3410 |
|
|
if (status)
|
3411 |
|
|
dprintk(2, "qla1280_device_reset: **** FAILED ****\n");
|
3412 |
|
|
|
3413 |
|
|
LEAVE("qla1280_device_reset");
|
3414 |
|
|
return status;
|
3415 |
|
|
}
|
3416 |
|
|
|
3417 |
|
|
/*
|
3418 |
|
|
* qla1280_abort_device
|
3419 |
|
|
* Issue an abort message to the device
|
3420 |
|
|
*
|
3421 |
|
|
* Input:
|
3422 |
|
|
* ha = adapter block pointer.
|
3423 |
|
|
* bus = SCSI BUS.
|
3424 |
|
|
* target = SCSI ID.
|
3425 |
|
|
* lun = SCSI LUN.
|
3426 |
|
|
*
|
3427 |
|
|
* Returns:
|
3428 |
|
|
* 0 = success
|
3429 |
|
|
*/
|
3430 |
|
|
static int
|
3431 |
|
|
qla1280_abort_device(struct scsi_qla_host *ha, int bus, int target, int lun)
|
3432 |
|
|
{
|
3433 |
|
|
uint16_t mb[MAILBOX_REGISTER_COUNT];
|
3434 |
|
|
int status;
|
3435 |
|
|
|
3436 |
|
|
ENTER("qla1280_abort_device");
|
3437 |
|
|
|
3438 |
|
|
mb[0] = MBC_ABORT_DEVICE;
|
3439 |
|
|
mb[1] = (bus ? target | BIT_7 : target) << 8 | lun;
|
3440 |
|
|
status = qla1280_mailbox_command(ha, BIT_1 | BIT_0, &mb[0]);
|
3441 |
|
|
|
3442 |
|
|
/* Issue marker command. */
|
3443 |
|
|
qla1280_marker(ha, bus, target, lun, MK_SYNC_ID_LUN);
|
3444 |
|
|
|
3445 |
|
|
if (status)
|
3446 |
|
|
dprintk(2, "qla1280_abort_device: **** FAILED ****\n");
|
3447 |
|
|
|
3448 |
|
|
LEAVE("qla1280_abort_device");
|
3449 |
|
|
return status;
|
3450 |
|
|
}
|
3451 |
|
|
|
3452 |
|
|
/*
|
3453 |
|
|
* qla1280_abort_command
|
3454 |
|
|
* Abort command aborts a specified IOCB.
|
3455 |
|
|
*
|
3456 |
|
|
* Input:
|
3457 |
|
|
* ha = adapter block pointer.
|
3458 |
|
|
* sp = SB structure pointer.
|
3459 |
|
|
*
|
3460 |
|
|
* Returns:
|
3461 |
|
|
* 0 = success
|
3462 |
|
|
*/
|
3463 |
|
|
static int
|
3464 |
|
|
qla1280_abort_command(struct scsi_qla_host *ha, struct srb * sp, int handle)
|
3465 |
|
|
{
|
3466 |
|
|
uint16_t mb[MAILBOX_REGISTER_COUNT];
|
3467 |
|
|
unsigned int bus, target, lun;
|
3468 |
|
|
int status;
|
3469 |
|
|
|
3470 |
|
|
ENTER("qla1280_abort_command");
|
3471 |
|
|
|
3472 |
|
|
bus = SCSI_BUS_32(sp->cmd);
|
3473 |
|
|
target = SCSI_TCN_32(sp->cmd);
|
3474 |
|
|
lun = SCSI_LUN_32(sp->cmd);
|
3475 |
|
|
|
3476 |
|
|
sp->flags |= SRB_ABORT_PENDING;
|
3477 |
|
|
|
3478 |
|
|
mb[0] = MBC_ABORT_COMMAND;
|
3479 |
|
|
mb[1] = (bus ? target | BIT_7 : target) << 8 | lun;
|
3480 |
|
|
mb[2] = handle >> 16;
|
3481 |
|
|
mb[3] = handle & 0xffff;
|
3482 |
|
|
status = qla1280_mailbox_command(ha, 0x0f, &mb[0]);
|
3483 |
|
|
|
3484 |
|
|
if (status) {
|
3485 |
|
|
dprintk(2, "qla1280_abort_command: **** FAILED ****\n");
|
3486 |
|
|
sp->flags &= ~SRB_ABORT_PENDING;
|
3487 |
|
|
}
|
3488 |
|
|
|
3489 |
|
|
|
3490 |
|
|
LEAVE("qla1280_abort_command");
|
3491 |
|
|
return status;
|
3492 |
|
|
}
|
3493 |
|
|
|
3494 |
|
|
/*
|
3495 |
|
|
* qla1280_reset_adapter
|
3496 |
|
|
* Reset adapter.
|
3497 |
|
|
*
|
3498 |
|
|
* Input:
|
3499 |
|
|
* ha = adapter block pointer.
|
3500 |
|
|
*/
|
3501 |
|
|
static void
|
3502 |
|
|
qla1280_reset_adapter(struct scsi_qla_host *ha)
|
3503 |
|
|
{
|
3504 |
|
|
struct device_reg *reg = ha->iobase;
|
3505 |
|
|
|
3506 |
|
|
ENTER("qla1280_reset_adapter");
|
3507 |
|
|
|
3508 |
|
|
/* Disable ISP chip */
|
3509 |
|
|
ha->flags.online = 0;
|
3510 |
|
|
WRT_REG_WORD(®->ictrl, ISP_RESET);
|
3511 |
|
|
WRT_REG_WORD(®->host_cmd,
|
3512 |
|
|
HC_RESET_RISC | HC_RELEASE_RISC | HC_DISABLE_BIOS);
|
3513 |
|
|
RD_REG_WORD(®->id_l); /* Flush PCI write */
|
3514 |
|
|
|
3515 |
|
|
LEAVE("qla1280_reset_adapter");
|
3516 |
|
|
}
|
3517 |
|
|
|
3518 |
|
|
/*
|
3519 |
|
|
* Issue marker command.
|
3520 |
|
|
* Function issues marker IOCB.
|
3521 |
|
|
*
|
3522 |
|
|
* Input:
|
3523 |
|
|
* ha = adapter block pointer.
|
3524 |
|
|
* bus = SCSI BUS number
|
3525 |
|
|
* id = SCSI ID
|
3526 |
|
|
* lun = SCSI LUN
|
3527 |
|
|
* type = marker modifier
|
3528 |
|
|
*/
|
3529 |
|
|
static void
|
3530 |
|
|
qla1280_marker(struct scsi_qla_host *ha, int bus, int id, int lun, u8 type)
|
3531 |
|
|
{
|
3532 |
|
|
struct mrk_entry *pkt;
|
3533 |
|
|
|
3534 |
|
|
ENTER("qla1280_marker");
|
3535 |
|
|
|
3536 |
|
|
/* Get request packet. */
|
3537 |
|
|
if ((pkt = (struct mrk_entry *) qla1280_req_pkt(ha))) {
|
3538 |
|
|
pkt->entry_type = MARKER_TYPE;
|
3539 |
|
|
pkt->lun = (uint8_t) lun;
|
3540 |
|
|
pkt->target = (uint8_t) (bus ? (id | BIT_7) : id);
|
3541 |
|
|
pkt->modifier = type;
|
3542 |
|
|
pkt->entry_status = 0;
|
3543 |
|
|
|
3544 |
|
|
/* Issue command to ISP */
|
3545 |
|
|
qla1280_isp_cmd(ha);
|
3546 |
|
|
}
|
3547 |
|
|
|
3548 |
|
|
LEAVE("qla1280_marker");
|
3549 |
|
|
}
|
3550 |
|
|
|
3551 |
|
|
|
3552 |
|
|
/*
|
3553 |
|
|
* qla1280_64bit_start_scsi
|
3554 |
|
|
* The start SCSI is responsible for building request packets on
|
3555 |
|
|
* request ring and modifying ISP input pointer.
|
3556 |
|
|
*
|
3557 |
|
|
* Input:
|
3558 |
|
|
* ha = adapter block pointer.
|
3559 |
|
|
* sp = SB structure pointer.
|
3560 |
|
|
*
|
3561 |
|
|
* Returns:
|
3562 |
|
|
* 0 = success, was able to issue command.
|
3563 |
|
|
*/
|
3564 |
|
|
static int
|
3565 |
|
|
qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp)
|
3566 |
|
|
{
|
3567 |
|
|
struct device_reg *reg = ha->iobase;
|
3568 |
|
|
Scsi_Cmnd *cmd = sp->cmd;
|
3569 |
|
|
cmd_a64_entry_t *pkt;
|
3570 |
|
|
struct scatterlist *sg = NULL;
|
3571 |
|
|
u32 *dword_ptr;
|
3572 |
|
|
dma_addr_t dma_handle;
|
3573 |
|
|
int status = 0;
|
3574 |
|
|
int cnt;
|
3575 |
|
|
int req_cnt;
|
3576 |
|
|
u16 seg_cnt;
|
3577 |
|
|
|
3578 |
|
|
ENTER("qla1280_64bit_start_scsi:");
|
3579 |
|
|
|
3580 |
|
|
/* Calculate number of entries and segments required. */
|
3581 |
|
|
req_cnt = 1;
|
3582 |
|
|
if (cmd->use_sg) {
|
3583 |
|
|
sg = (struct scatterlist *) cmd->request_buffer;
|
3584 |
|
|
seg_cnt = pci_map_sg(ha->pdev, sg, cmd->use_sg,
|
3585 |
|
|
scsi_to_pci_dma_dir(cmd->sc_data_direction));
|
3586 |
|
|
|
3587 |
|
|
if (seg_cnt > 2) {
|
3588 |
|
|
req_cnt += (seg_cnt - 2) / 5;
|
3589 |
|
|
if ((seg_cnt - 2) % 5)
|
3590 |
|
|
req_cnt++;
|
3591 |
|
|
}
|
3592 |
|
|
} else if (cmd->request_bufflen) { /* If data transfer. */
|
3593 |
|
|
seg_cnt = 1;
|
3594 |
|
|
} else {
|
3595 |
|
|
seg_cnt = 0;
|
3596 |
|
|
}
|
3597 |
|
|
|
3598 |
|
|
if ((req_cnt + 2) >= ha->req_q_cnt) {
|
3599 |
|
|
/* Calculate number of free request entries. */
|
3600 |
|
|
cnt = RD_REG_WORD(®->mailbox4);
|
3601 |
|
|
if (ha->req_ring_index < cnt)
|
3602 |
|
|
ha->req_q_cnt = cnt - ha->req_ring_index;
|
3603 |
|
|
else
|
3604 |
|
|
ha->req_q_cnt =
|
3605 |
|
|
REQUEST_ENTRY_CNT - (ha->req_ring_index - cnt);
|
3606 |
|
|
}
|
3607 |
|
|
|
3608 |
|
|
/* If room for request in request ring. */
|
3609 |
|
|
if ((req_cnt + 2) >= ha->req_q_cnt) {
|
3610 |
|
|
status = 1;
|
3611 |
|
|
dprintk(2, "qla1280_64bit_start_scsi: in-ptr=0x%x req_q_cnt="
|
3612 |
|
|
"0x%xreq_cnt=0x%x", ha->req_ring_index, ha->req_q_cnt,
|
3613 |
|
|
req_cnt);
|
3614 |
|
|
goto out;
|
3615 |
|
|
}
|
3616 |
|
|
|
3617 |
|
|
/* Check for room in outstanding command list. */
|
3618 |
|
|
for (cnt = 0; cnt < MAX_OUTSTANDING_COMMANDS &&
|
3619 |
|
|
ha->outstanding_cmds[cnt] != 0; cnt++);
|
3620 |
|
|
|
3621 |
|
|
if (cnt >= MAX_OUTSTANDING_COMMANDS) {
|
3622 |
|
|
status = 1;
|
3623 |
|
|
dprintk(2, "qla1280_64bit_start_scsi: NO ROOM IN "
|
3624 |
|
|
"OUTSTANDING ARRAY, req_q_cnt=0x%x", ha->req_q_cnt);
|
3625 |
|
|
goto out;
|
3626 |
|
|
}
|
3627 |
|
|
|
3628 |
|
|
ha->outstanding_cmds[cnt] = sp;
|
3629 |
|
|
ha->req_q_cnt -= req_cnt;
|
3630 |
|
|
CMD_HANDLE(sp->cmd) = (unsigned char *)(unsigned long)(cnt + 1);
|
3631 |
|
|
|
3632 |
|
|
dprintk(2, "64bit_start: cmd=%p sp=%p CDB=%xm, handle %lx\n", cmd, sp,
|
3633 |
|
|
cmd->cmnd[0], (long)CMD_HANDLE(sp->cmd));
|
3634 |
|
|
dprintk(2, " bus %i, target %i, lun %i\n",
|
3635 |
|
|
SCSI_BUS_32(cmd), SCSI_TCN_32(cmd), SCSI_LUN_32(cmd));
|
3636 |
|
|
qla1280_dump_buffer(2, cmd->cmnd, MAX_COMMAND_SIZE);
|
3637 |
|
|
|
3638 |
|
|
/*
|
3639 |
|
|
* Build command packet.
|
3640 |
|
|
*/
|
3641 |
|
|
pkt = (cmd_a64_entry_t *) ha->request_ring_ptr;
|
3642 |
|
|
|
3643 |
|
|
pkt->entry_type = COMMAND_A64_TYPE;
|
3644 |
|
|
pkt->entry_count = (uint8_t) req_cnt;
|
3645 |
|
|
pkt->sys_define = (uint8_t) ha->req_ring_index;
|
3646 |
|
|
pkt->entry_status = 0;
|
3647 |
|
|
pkt->handle = cpu_to_le32(cnt);
|
3648 |
|
|
|
3649 |
|
|
/* Zero out remaining portion of packet. */
|
3650 |
|
|
memset(((char *)pkt + 8), 0, (REQUEST_ENTRY_SIZE - 8));
|
3651 |
|
|
|
3652 |
|
|
/* Set ISP command timeout. */
|
3653 |
|
|
pkt->timeout = cpu_to_le16(30);
|
3654 |
|
|
|
3655 |
|
|
/* Set device target ID and LUN */
|
3656 |
|
|
pkt->lun = SCSI_LUN_32(cmd);
|
3657 |
|
|
pkt->target = SCSI_BUS_32(cmd) ?
|
3658 |
|
|
(SCSI_TCN_32(cmd) | BIT_7) : SCSI_TCN_32(cmd);
|
3659 |
|
|
|
3660 |
|
|
/* Enable simple tag queuing if device supports it. */
|
3661 |
|
|
if (DEV_SIMPLE_TAGS(cmd->device))
|
3662 |
|
|
pkt->control_flags |= cpu_to_le16(BIT_3);
|
3663 |
|
|
|
3664 |
|
|
/* Load SCSI command packet. */
|
3665 |
|
|
pkt->cdb_len = cpu_to_le16(CMD_CDBLEN(cmd));
|
3666 |
|
|
memcpy(pkt->scsi_cdb, &(CMD_CDBP(cmd)), CMD_CDBLEN(cmd));
|
3667 |
|
|
/* dprintk(1, "Build packet for command[0]=0x%x\n",pkt->scsi_cdb[0]); */
|
3668 |
|
|
|
3669 |
|
|
/* Set transfer direction. */
|
3670 |
|
|
sp->dir = qla1280_data_direction(cmd);
|
3671 |
|
|
pkt->control_flags |= cpu_to_le16(sp->dir);
|
3672 |
|
|
|
3673 |
|
|
/* Set total data segment count. */
|
3674 |
|
|
pkt->dseg_count = cpu_to_le16(seg_cnt);
|
3675 |
|
|
|
3676 |
|
|
/*
|
3677 |
|
|
* Load data segments.
|
3678 |
|
|
*/
|
3679 |
|
|
if (seg_cnt) { /* If data transfer. */
|
3680 |
|
|
/* Setup packet address segment pointer. */
|
3681 |
|
|
dword_ptr = (u32 *)&pkt->dseg_0_address;
|
3682 |
|
|
|
3683 |
|
|
if (cmd->use_sg) { /* If scatter gather */
|
3684 |
|
|
/* Load command entry data segments. */
|
3685 |
|
|
for (cnt = 0; cnt < 2 && seg_cnt; cnt++, seg_cnt--) {
|
3686 |
|
|
dma_handle = sg_dma_address(sg);
|
3687 |
|
|
#if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2)
|
3688 |
|
|
if (ha->flags.use_pci_vchannel)
|
3689 |
|
|
sn_pci_set_vchan(ha->pdev, &dma_handle,
|
3690 |
|
|
SCSI_BUS_32(cmd));
|
3691 |
|
|
#endif
|
3692 |
|
|
*dword_ptr++ =
|
3693 |
|
|
cpu_to_le32(pci_dma_lo32(dma_handle));
|
3694 |
|
|
*dword_ptr++ =
|
3695 |
|
|
cpu_to_le32(pci_dma_hi32(dma_handle));
|
3696 |
|
|
*dword_ptr++ = cpu_to_le32(sg_dma_len(sg));
|
3697 |
|
|
sg++;
|
3698 |
|
|
dprintk(3, "S/G Segment phys_addr=%x %x, len=0x%x\n",
|
3699 |
|
|
cpu_to_le32(pci_dma_hi32(dma_handle)),
|
3700 |
|
|
cpu_to_le32(pci_dma_lo32(dma_handle)),
|
3701 |
|
|
cpu_to_le32(sg_dma_len(sg)));
|
3702 |
|
|
}
|
3703 |
|
|
dprintk(5, "qla1280_64bit_start_scsi: Scatter/gather "
|
3704 |
|
|
"command packet data - b %i, t %i, l %i \n",
|
3705 |
|
|
SCSI_BUS_32(cmd), SCSI_TCN_32(cmd),
|
3706 |
|
|
SCSI_LUN_32(cmd));
|
3707 |
|
|
qla1280_dump_buffer(5, (char *)pkt,
|
3708 |
|
|
REQUEST_ENTRY_SIZE);
|
3709 |
|
|
|
3710 |
|
|
/*
|
3711 |
|
|
* Build continuation packets.
|
3712 |
|
|
*/
|
3713 |
|
|
dprintk(3, "S/G Building Continuation...seg_cnt=0x%x "
|
3714 |
|
|
"remains\n", seg_cnt);
|
3715 |
|
|
|
3716 |
|
|
while (seg_cnt > 0) {
|
3717 |
|
|
/* Adjust ring index. */
|
3718 |
|
|
ha->req_ring_index++;
|
3719 |
|
|
if (ha->req_ring_index == REQUEST_ENTRY_CNT) {
|
3720 |
|
|
ha->req_ring_index = 0;
|
3721 |
|
|
ha->request_ring_ptr =
|
3722 |
|
|
ha->request_ring;
|
3723 |
|
|
} else
|
3724 |
|
|
ha->request_ring_ptr++;
|
3725 |
|
|
|
3726 |
|
|
pkt = (cmd_a64_entry_t *)ha->request_ring_ptr;
|
3727 |
|
|
|
3728 |
|
|
/* Zero out packet. */
|
3729 |
|
|
memset(pkt, 0, REQUEST_ENTRY_SIZE);
|
3730 |
|
|
|
3731 |
|
|
/* Load packet defaults. */
|
3732 |
|
|
((struct cont_a64_entry *) pkt)->entry_type =
|
3733 |
|
|
CONTINUE_A64_TYPE;
|
3734 |
|
|
((struct cont_a64_entry *) pkt)->entry_count = 1;
|
3735 |
|
|
((struct cont_a64_entry *) pkt)->sys_define =
|
3736 |
|
|
(uint8_t)ha->req_ring_index;
|
3737 |
|
|
/* Setup packet address segment pointer. */
|
3738 |
|
|
dword_ptr =
|
3739 |
|
|
(u32 *)&((struct cont_a64_entry *) pkt)->dseg_0_address;
|
3740 |
|
|
|
3741 |
|
|
/* Load continuation entry data segments. */
|
3742 |
|
|
for (cnt = 0; cnt < 5 && seg_cnt;
|
3743 |
|
|
cnt++, seg_cnt--) {
|
3744 |
|
|
dma_handle = sg_dma_address(sg);
|
3745 |
|
|
#if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2)
|
3746 |
|
|
if (ha->flags.use_pci_vchannel)
|
3747 |
|
|
sn_pci_set_vchan(ha->pdev, &dma_handle,
|
3748 |
|
|
SCSI_BUS_32(cmd));
|
3749 |
|
|
#endif
|
3750 |
|
|
*dword_ptr++ =
|
3751 |
|
|
cpu_to_le32(pci_dma_lo32(dma_handle));
|
3752 |
|
|
*dword_ptr++ =
|
3753 |
|
|
cpu_to_le32(pci_dma_hi32(dma_handle));
|
3754 |
|
|
*dword_ptr++ =
|
3755 |
|
|
cpu_to_le32(sg_dma_len(sg));
|
3756 |
|
|
dprintk(3, "S/G Segment Cont. phys_addr=%x %x, len=0x%x\n",
|
3757 |
|
|
cpu_to_le32(pci_dma_hi32(dma_handle)),
|
3758 |
|
|
cpu_to_le32(pci_dma_lo32(dma_handle)),
|
3759 |
|
|
cpu_to_le32(sg_dma_len(sg)));
|
3760 |
|
|
sg++;
|
3761 |
|
|
}
|
3762 |
|
|
dprintk(5, "qla1280_64bit_start_scsi: "
|
3763 |
|
|
"continuation packet data - b %i, t "
|
3764 |
|
|
"%i, l %i \n", SCSI_BUS_32(cmd),
|
3765 |
|
|
SCSI_TCN_32(cmd), SCSI_LUN_32(cmd));
|
3766 |
|
|
qla1280_dump_buffer(5, (char *)pkt,
|
3767 |
|
|
REQUEST_ENTRY_SIZE);
|
3768 |
|
|
}
|
3769 |
|
|
} else { /* No scatter gather data transfer */
|
3770 |
|
|
struct page *page = virt_to_page(cmd->request_buffer);
|
3771 |
|
|
unsigned long off = (unsigned long)cmd->request_buffer & ~PAGE_MASK;
|
3772 |
|
|
|
3773 |
|
|
dma_handle = pci_map_page(ha->pdev, page, off,
|
3774 |
|
|
cmd->request_bufflen,
|
3775 |
|
|
scsi_to_pci_dma_dir(cmd->sc_data_direction));
|
3776 |
|
|
|
3777 |
|
|
/* save dma_handle for pci_unmap_page */
|
3778 |
|
|
sp->saved_dma_handle = dma_handle;
|
3779 |
|
|
#if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2)
|
3780 |
|
|
if (ha->flags.use_pci_vchannel)
|
3781 |
|
|
sn_pci_set_vchan(ha->pdev, &dma_handle,
|
3782 |
|
|
SCSI_BUS_32(cmd));
|
3783 |
|
|
#endif
|
3784 |
|
|
*dword_ptr++ = cpu_to_le32(pci_dma_lo32(dma_handle));
|
3785 |
|
|
*dword_ptr++ = cpu_to_le32(pci_dma_hi32(dma_handle));
|
3786 |
|
|
*dword_ptr = (uint32_t)cmd->request_bufflen;
|
3787 |
|
|
|
3788 |
|
|
dprintk(5, "qla1280_64bit_start_scsi: No scatter/"
|
3789 |
|
|
"gather command packet data - b %i, t %i, "
|
3790 |
|
|
"l %i \n", SCSI_BUS_32(cmd), SCSI_TCN_32(cmd),
|
3791 |
|
|
SCSI_LUN_32(cmd));
|
3792 |
|
|
qla1280_dump_buffer(5, (char *)pkt,
|
3793 |
|
|
REQUEST_ENTRY_SIZE);
|
3794 |
|
|
}
|
3795 |
|
|
} else { /* No data transfer */
|
3796 |
|
|
dword_ptr = (uint32_t *)(pkt + 1);
|
3797 |
|
|
*dword_ptr++ = 0;
|
3798 |
|
|
*dword_ptr++ = 0;
|
3799 |
|
|
*dword_ptr = 0;
|
3800 |
|
|
dprintk(5, "qla1280_64bit_start_scsi: No data, command "
|
3801 |
|
|
"packet data - b %i, t %i, l %i \n",
|
3802 |
|
|
SCSI_BUS_32(cmd), SCSI_TCN_32(cmd), SCSI_LUN_32(cmd));
|
3803 |
|
|
qla1280_dump_buffer(5, (char *)pkt, REQUEST_ENTRY_SIZE);
|
3804 |
|
|
}
|
3805 |
|
|
/* Adjust ring index. */
|
3806 |
|
|
ha->req_ring_index++;
|
3807 |
|
|
if (ha->req_ring_index == REQUEST_ENTRY_CNT) {
|
3808 |
|
|
ha->req_ring_index = 0;
|
3809 |
|
|
ha->request_ring_ptr = ha->request_ring;
|
3810 |
|
|
} else
|
3811 |
|
|
ha->request_ring_ptr++;
|
3812 |
|
|
|
3813 |
|
|
/* Set chip new ring index. */
|
3814 |
|
|
dprintk(2,
|
3815 |
|
|
"qla1280_64bit_start_scsi: Wakeup RISC for pending command\n");
|
3816 |
|
|
sp->flags |= SRB_SENT;
|
3817 |
|
|
ha->actthreads++;
|
3818 |
|
|
WRT_REG_WORD(®->mailbox4, ha->req_ring_index);
|
3819 |
|
|
|
3820 |
|
|
out:
|
3821 |
|
|
if (status)
|
3822 |
|
|
dprintk(2, "qla1280_64bit_start_scsi: **** FAILED ****\n");
|
3823 |
|
|
else
|
3824 |
|
|
dprintk(3, "qla1280_64bit_start_scsi: exiting normally\n");
|
3825 |
|
|
|
3826 |
|
|
return status;
|
3827 |
|
|
}
|
3828 |
|
|
|
3829 |
|
|
|
3830 |
|
|
/*
|
3831 |
|
|
* qla1280_32bit_start_scsi
|
3832 |
|
|
* The start SCSI is responsible for building request packets on
|
3833 |
|
|
* request ring and modifying ISP input pointer.
|
3834 |
|
|
*
|
3835 |
|
|
* The Qlogic firmware interface allows every queue slot to have a SCSI
|
3836 |
|
|
* command and up to 4 scatter/gather (SG) entries. If we need more
|
3837 |
|
|
* than 4 SG entries, then continuation entries are used that can
|
3838 |
|
|
* hold another 7 entries each. The start routine determines if there
|
3839 |
|
|
* is eought empty slots then build the combination of requests to
|
3840 |
|
|
* fulfill the OS request.
|
3841 |
|
|
*
|
3842 |
|
|
* Input:
|
3843 |
|
|
* ha = adapter block pointer.
|
3844 |
|
|
* sp = SCSI Request Block structure pointer.
|
3845 |
|
|
*
|
3846 |
|
|
* Returns:
|
3847 |
|
|
* 0 = success, was able to issue command.
|
3848 |
|
|
*/
|
3849 |
|
|
static int
|
3850 |
|
|
qla1280_32bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp)
|
3851 |
|
|
{
|
3852 |
|
|
struct device_reg *reg = ha->iobase;
|
3853 |
|
|
Scsi_Cmnd *cmd = sp->cmd;
|
3854 |
|
|
struct cmd_entry *pkt;
|
3855 |
|
|
struct scatterlist *sg = NULL;
|
3856 |
|
|
uint32_t *dword_ptr;
|
3857 |
|
|
int status = 0;
|
3858 |
|
|
int cnt;
|
3859 |
|
|
int req_cnt;
|
3860 |
|
|
uint16_t seg_cnt;
|
3861 |
|
|
dma_addr_t dma_handle;
|
3862 |
|
|
|
3863 |
|
|
ENTER("qla1280_32bit_start_scsi");
|
3864 |
|
|
|
3865 |
|
|
dprintk(1, "32bit_start: cmd=%p sp=%p CDB=%x\n", cmd, sp,
|
3866 |
|
|
cmd->cmnd[0]);
|
3867 |
|
|
|
3868 |
|
|
/* Calculate number of entries and segments required. */
|
3869 |
|
|
req_cnt = 1;
|
3870 |
|
|
if (cmd->use_sg) {
|
3871 |
|
|
/*
|
3872 |
|
|
* We must build an SG list in adapter format, as the kernel's
|
3873 |
|
|
* SG list cannot be used directly because of data field size
|
3874 |
|
|
* (__alpha__) differences and the kernel SG list uses virtual
|
3875 |
|
|
* addresses where we need physical addresses.
|
3876 |
|
|
*/
|
3877 |
|
|
sg = (struct scatterlist *) cmd->request_buffer;
|
3878 |
|
|
seg_cnt = pci_map_sg(ha->pdev, sg, cmd->use_sg,
|
3879 |
|
|
scsi_to_pci_dma_dir(cmd->sc_data_direction));
|
3880 |
|
|
|
3881 |
|
|
/*
|
3882 |
|
|
* if greater than four sg entries then we need to allocate
|
3883 |
|
|
* continuation entries
|
3884 |
|
|
*/
|
3885 |
|
|
if (seg_cnt > 4) {
|
3886 |
|
|
req_cnt += (seg_cnt - 4) / 7;
|
3887 |
|
|
if ((seg_cnt - 4) % 7)
|
3888 |
|
|
req_cnt++;
|
3889 |
|
|
}
|
3890 |
|
|
dprintk(3, "S/G Transfer cmd=%p seg_cnt=0x%x, req_cnt=%x\n",
|
3891 |
|
|
cmd, seg_cnt, req_cnt);
|
3892 |
|
|
} else if (cmd->request_bufflen) { /* If data transfer. */
|
3893 |
|
|
dprintk(3, "No S/G transfer t=%x cmd=%p len=%x CDB=%x\n",
|
3894 |
|
|
SCSI_TCN_32(cmd), cmd, cmd->request_bufflen,
|
3895 |
|
|
cmd->cmnd[0]);
|
3896 |
|
|
seg_cnt = 1;
|
3897 |
|
|
} else {
|
3898 |
|
|
/* dprintk(1, "No data transfer \n"); */
|
3899 |
|
|
seg_cnt = 0;
|
3900 |
|
|
}
|
3901 |
|
|
|
3902 |
|
|
if ((req_cnt + 2) >= ha->req_q_cnt) {
|
3903 |
|
|
/* Calculate number of free request entries. */
|
3904 |
|
|
cnt = RD_REG_WORD(®->mailbox4);
|
3905 |
|
|
if (ha->req_ring_index < cnt)
|
3906 |
|
|
ha->req_q_cnt = cnt - ha->req_ring_index;
|
3907 |
|
|
else
|
3908 |
|
|
ha->req_q_cnt =
|
3909 |
|
|
REQUEST_ENTRY_CNT - (ha->req_ring_index - cnt);
|
3910 |
|
|
}
|
3911 |
|
|
|
3912 |
|
|
dprintk(3, "Number of free entries=(%d) seg_cnt=0x%x\n",
|
3913 |
|
|
ha->req_q_cnt, seg_cnt);
|
3914 |
|
|
/* If room for request in request ring. */
|
3915 |
|
|
if ((req_cnt + 2) >= ha->req_q_cnt) {
|
3916 |
|
|
status = 1;
|
3917 |
|
|
dprintk(2, "qla1280_32bit_start_scsi: in-ptr=0x%x, "
|
3918 |
|
|
"req_q_cnt=0x%x, req_cnt=0x%x", ha->req_ring_index,
|
3919 |
|
|
ha->req_q_cnt, req_cnt);
|
3920 |
|
|
goto out;
|
3921 |
|
|
}
|
3922 |
|
|
|
3923 |
|
|
/* Check for empty slot in outstanding command list. */
|
3924 |
|
|
for (cnt = 0; cnt < MAX_OUTSTANDING_COMMANDS &&
|
3925 |
|
|
(ha->outstanding_cmds[cnt] != 0); cnt++) ;
|
3926 |
|
|
|
3927 |
|
|
if (cnt >= MAX_OUTSTANDING_COMMANDS) {
|
3928 |
|
|
status = 1;
|
3929 |
|
|
dprintk(2, "qla1280_32bit_start_scsi: NO ROOM IN OUTSTANDING "
|
3930 |
|
|
"ARRAY, req_q_cnt=0x%x\n", ha->req_q_cnt);
|
3931 |
|
|
goto out;
|
3932 |
|
|
}
|
3933 |
|
|
|
3934 |
|
|
CMD_HANDLE(sp->cmd) = (unsigned char *) (unsigned long)(cnt + 1);
|
3935 |
|
|
ha->outstanding_cmds[cnt] = sp;
|
3936 |
|
|
ha->req_q_cnt -= req_cnt;
|
3937 |
|
|
|
3938 |
|
|
/*
|
3939 |
|
|
* Build command packet.
|
3940 |
|
|
*/
|
3941 |
|
|
pkt = (struct cmd_entry *) ha->request_ring_ptr;
|
3942 |
|
|
|
3943 |
|
|
pkt->entry_type = COMMAND_TYPE;
|
3944 |
|
|
pkt->entry_count = (uint8_t) req_cnt;
|
3945 |
|
|
pkt->sys_define = (uint8_t) ha->req_ring_index;
|
3946 |
|
|
pkt->entry_status = 0;
|
3947 |
|
|
pkt->handle = cpu_to_le32(cnt);
|
3948 |
|
|
|
3949 |
|
|
/* Zero out remaining portion of packet. */
|
3950 |
|
|
memset(((char *)pkt + 8), 0, (REQUEST_ENTRY_SIZE - 8));
|
3951 |
|
|
|
3952 |
|
|
/* Set ISP command timeout. */
|
3953 |
|
|
pkt->timeout = cpu_to_le16(30);
|
3954 |
|
|
|
3955 |
|
|
/* Set device target ID and LUN */
|
3956 |
|
|
pkt->lun = SCSI_LUN_32(cmd);
|
3957 |
|
|
pkt->target = SCSI_BUS_32(cmd) ?
|
3958 |
|
|
(SCSI_TCN_32(cmd) | BIT_7) : SCSI_TCN_32(cmd);
|
3959 |
|
|
|
3960 |
|
|
/* Enable simple tag queuing if device supports it. */
|
3961 |
|
|
if (DEV_SIMPLE_TAGS(cmd->device))
|
3962 |
|
|
pkt->control_flags |= cpu_to_le16(BIT_3);
|
3963 |
|
|
|
3964 |
|
|
/* Load SCSI command packet. */
|
3965 |
|
|
pkt->cdb_len = cpu_to_le16(CMD_CDBLEN(cmd));
|
3966 |
|
|
memcpy(pkt->scsi_cdb, &(CMD_CDBP(cmd)), CMD_CDBLEN(cmd));
|
3967 |
|
|
|
3968 |
|
|
/*dprintk(1, "Build packet for command[0]=0x%x\n",pkt->scsi_cdb[0]); */
|
3969 |
|
|
/* Set transfer direction. */
|
3970 |
|
|
sp->dir = qla1280_data_direction(cmd);
|
3971 |
|
|
pkt->control_flags |= cpu_to_le16(sp->dir);
|
3972 |
|
|
|
3973 |
|
|
/* Set total data segment count. */
|
3974 |
|
|
pkt->dseg_count = cpu_to_le16(seg_cnt);
|
3975 |
|
|
|
3976 |
|
|
/*
|
3977 |
|
|
* Load data segments.
|
3978 |
|
|
*/
|
3979 |
|
|
if (seg_cnt) {
|
3980 |
|
|
/* Setup packet address segment pointer. */
|
3981 |
|
|
dword_ptr = &pkt->dseg_0_address;
|
3982 |
|
|
|
3983 |
|
|
if (cmd->use_sg) { /* If scatter gather */
|
3984 |
|
|
dprintk(3, "Building S/G data segments..\n");
|
3985 |
|
|
qla1280_dump_buffer(1, (char *)sg, 4 * 16);
|
3986 |
|
|
|
3987 |
|
|
/* Load command entry data segments. */
|
3988 |
|
|
for (cnt = 0; cnt < 4 && seg_cnt; cnt++, seg_cnt--) {
|
3989 |
|
|
*dword_ptr++ =
|
3990 |
|
|
cpu_to_le32(pci_dma_lo32(sg_dma_address(sg)));
|
3991 |
|
|
*dword_ptr++ =
|
3992 |
|
|
cpu_to_le32(sg_dma_len(sg));
|
3993 |
|
|
dprintk(3, "S/G Segment phys_addr=0x%lx, len=0x%x\n",
|
3994 |
|
|
(pci_dma_lo32(sg_dma_address(sg))),
|
3995 |
|
|
(sg_dma_len(sg)));
|
3996 |
|
|
sg++;
|
3997 |
|
|
}
|
3998 |
|
|
/*
|
3999 |
|
|
* Build continuation packets.
|
4000 |
|
|
*/
|
4001 |
|
|
dprintk(3, "S/G Building Continuation"
|
4002 |
|
|
"...seg_cnt=0x%x remains\n", seg_cnt);
|
4003 |
|
|
while (seg_cnt > 0) {
|
4004 |
|
|
/* Adjust ring index. */
|
4005 |
|
|
ha->req_ring_index++;
|
4006 |
|
|
if (ha->req_ring_index == REQUEST_ENTRY_CNT) {
|
4007 |
|
|
ha->req_ring_index = 0;
|
4008 |
|
|
ha->request_ring_ptr =
|
4009 |
|
|
ha->request_ring;
|
4010 |
|
|
} else
|
4011 |
|
|
ha->request_ring_ptr++;
|
4012 |
|
|
|
4013 |
|
|
pkt = (struct cmd_entry *)ha->request_ring_ptr;
|
4014 |
|
|
|
4015 |
|
|
/* Zero out packet. */
|
4016 |
|
|
memset(pkt, 0, REQUEST_ENTRY_SIZE);
|
4017 |
|
|
|
4018 |
|
|
/* Load packet defaults. */
|
4019 |
|
|
((struct cont_entry *) pkt)->
|
4020 |
|
|
entry_type = CONTINUE_TYPE;
|
4021 |
|
|
((struct cont_entry *) pkt)->entry_count = 1;
|
4022 |
|
|
|
4023 |
|
|
((struct cont_entry *) pkt)->sys_define =
|
4024 |
|
|
(uint8_t) ha->req_ring_index;
|
4025 |
|
|
|
4026 |
|
|
/* Setup packet address segment pointer. */
|
4027 |
|
|
dword_ptr =
|
4028 |
|
|
&((struct cont_entry *) pkt)->dseg_0_address;
|
4029 |
|
|
|
4030 |
|
|
/* Load continuation entry data segments. */
|
4031 |
|
|
for (cnt = 0; cnt < 7 && seg_cnt;
|
4032 |
|
|
cnt++, seg_cnt--) {
|
4033 |
|
|
*dword_ptr++ =
|
4034 |
|
|
cpu_to_le32(pci_dma_lo32(sg_dma_address(sg)));
|
4035 |
|
|
*dword_ptr++ =
|
4036 |
|
|
cpu_to_le32(sg_dma_len(sg));
|
4037 |
|
|
dprintk(1,
|
4038 |
|
|
"S/G Segment Cont. phys_addr=0x%x, "
|
4039 |
|
|
"len=0x%x\n",
|
4040 |
|
|
cpu_to_le32(pci_dma_lo32(sg_dma_address(sg))),
|
4041 |
|
|
cpu_to_le32(sg_dma_len(sg)));
|
4042 |
|
|
sg++;
|
4043 |
|
|
}
|
4044 |
|
|
dprintk(5, "qla1280_32bit_start_scsi: "
|
4045 |
|
|
"continuation packet data - "
|
4046 |
|
|
"scsi(%i:%i:%i)\n", SCSI_BUS_32(cmd),
|
4047 |
|
|
SCSI_TCN_32(cmd), SCSI_LUN_32(cmd));
|
4048 |
|
|
qla1280_dump_buffer(5, (char *)pkt,
|
4049 |
|
|
REQUEST_ENTRY_SIZE);
|
4050 |
|
|
}
|
4051 |
|
|
} else { /* No S/G data transfer */
|
4052 |
|
|
struct page *page = virt_to_page(cmd->request_buffer);
|
4053 |
|
|
unsigned long off = (unsigned long)cmd->request_buffer & ~PAGE_MASK;
|
4054 |
|
|
dma_handle = pci_map_page(ha->pdev, page, off,
|
4055 |
|
|
cmd->request_bufflen,
|
4056 |
|
|
scsi_to_pci_dma_dir(cmd->sc_data_direction));
|
4057 |
|
|
sp->saved_dma_handle = dma_handle;
|
4058 |
|
|
|
4059 |
|
|
*dword_ptr++ = cpu_to_le32(pci_dma_lo32(dma_handle));
|
4060 |
|
|
*dword_ptr = cpu_to_le32(cmd->request_bufflen);
|
4061 |
|
|
}
|
4062 |
|
|
} else { /* No data transfer at all */
|
4063 |
|
|
dword_ptr = (uint32_t *)(pkt + 1);
|
4064 |
|
|
*dword_ptr++ = 0;
|
4065 |
|
|
*dword_ptr = 0;
|
4066 |
|
|
dprintk(5, "qla1280_32bit_start_scsi: No data, command "
|
4067 |
|
|
"packet data - \n");
|
4068 |
|
|
qla1280_dump_buffer(5, (char *)pkt, REQUEST_ENTRY_SIZE);
|
4069 |
|
|
}
|
4070 |
|
|
dprintk(5, "qla1280_32bit_start_scsi: First IOCB block:\n");
|
4071 |
|
|
qla1280_dump_buffer(5, (char *)ha->request_ring_ptr,
|
4072 |
|
|
REQUEST_ENTRY_SIZE);
|
4073 |
|
|
|
4074 |
|
|
/* Adjust ring index. */
|
4075 |
|
|
ha->req_ring_index++;
|
4076 |
|
|
if (ha->req_ring_index == REQUEST_ENTRY_CNT) {
|
4077 |
|
|
ha->req_ring_index = 0;
|
4078 |
|
|
ha->request_ring_ptr = ha->request_ring;
|
4079 |
|
|
} else
|
4080 |
|
|
ha->request_ring_ptr++;
|
4081 |
|
|
|
4082 |
|
|
/* Set chip new ring index. */
|
4083 |
|
|
dprintk(2, "qla1280_32bit_start_scsi: Wakeup RISC "
|
4084 |
|
|
"for pending command\n");
|
4085 |
|
|
sp->flags |= SRB_SENT;
|
4086 |
|
|
ha->actthreads++;
|
4087 |
|
|
WRT_REG_WORD(®->mailbox4, ha->req_ring_index);
|
4088 |
|
|
|
4089 |
|
|
out:
|
4090 |
|
|
if (status)
|
4091 |
|
|
dprintk(2, "qla1280_32bit_start_scsi: **** FAILED ****\n");
|
4092 |
|
|
|
4093 |
|
|
LEAVE("qla1280_32bit_start_scsi");
|
4094 |
|
|
|
4095 |
|
|
return status;
|
4096 |
|
|
}
|
4097 |
|
|
|
4098 |
|
|
/*
|
4099 |
|
|
* qla1280_req_pkt
|
4100 |
|
|
* Function is responsible for locking ring and
|
4101 |
|
|
* getting a zeroed out request packet.
|
4102 |
|
|
*
|
4103 |
|
|
* Input:
|
4104 |
|
|
* ha = adapter block pointer.
|
4105 |
|
|
*
|
4106 |
|
|
* Returns:
|
4107 |
|
|
* 0 = failed to get slot.
|
4108 |
|
|
*/
|
4109 |
|
|
static request_t *
|
4110 |
|
|
qla1280_req_pkt(struct scsi_qla_host *ha)
|
4111 |
|
|
{
|
4112 |
|
|
struct device_reg *reg = ha->iobase;
|
4113 |
|
|
request_t *pkt = 0;
|
4114 |
|
|
int cnt;
|
4115 |
|
|
uint32_t timer;
|
4116 |
|
|
|
4117 |
|
|
ENTER("qla1280_req_pkt");
|
4118 |
|
|
|
4119 |
|
|
/*
|
4120 |
|
|
* This can be called from interrupt context, damn it!!!
|
4121 |
|
|
*/
|
4122 |
|
|
/* Wait for 30 seconds for slot. */
|
4123 |
|
|
for (timer = 15000000; timer; timer--) {
|
4124 |
|
|
if (ha->req_q_cnt > 0) {
|
4125 |
|
|
/* Calculate number of free request entries. */
|
4126 |
|
|
cnt = RD_REG_WORD(®->mailbox4);
|
4127 |
|
|
if (ha->req_ring_index < cnt)
|
4128 |
|
|
ha->req_q_cnt = cnt - ha->req_ring_index;
|
4129 |
|
|
else
|
4130 |
|
|
ha->req_q_cnt =
|
4131 |
|
|
REQUEST_ENTRY_CNT - (ha->req_ring_index - cnt);
|
4132 |
|
|
}
|
4133 |
|
|
|
4134 |
|
|
/* Found empty request ring slot? */
|
4135 |
|
|
if (ha->req_q_cnt > 0) {
|
4136 |
|
|
ha->req_q_cnt--;
|
4137 |
|
|
pkt = ha->request_ring_ptr;
|
4138 |
|
|
|
4139 |
|
|
/* Zero out packet. */
|
4140 |
|
|
memset(pkt, 0, REQUEST_ENTRY_SIZE);
|
4141 |
|
|
|
4142 |
|
|
/*
|
4143 |
|
|
* How can this be right when we have a ring
|
4144 |
|
|
* size of 512???
|
4145 |
|
|
*/
|
4146 |
|
|
/* Set system defined field. */
|
4147 |
|
|
pkt->sys_define = (uint8_t) ha->req_ring_index;
|
4148 |
|
|
|
4149 |
|
|
/* Set entry count. */
|
4150 |
|
|
pkt->entry_count = 1;
|
4151 |
|
|
|
4152 |
|
|
break;
|
4153 |
|
|
}
|
4154 |
|
|
|
4155 |
|
|
udelay(2); /* 10 */
|
4156 |
|
|
|
4157 |
|
|
/* Check for pending interrupts. */
|
4158 |
|
|
qla1280_poll(ha);
|
4159 |
|
|
}
|
4160 |
|
|
|
4161 |
|
|
if (!pkt)
|
4162 |
|
|
dprintk(2, "qla1280_req_pkt: **** FAILED ****\n");
|
4163 |
|
|
else
|
4164 |
|
|
dprintk(3, "qla1280_req_pkt: exiting normally\n");
|
4165 |
|
|
|
4166 |
|
|
return pkt;
|
4167 |
|
|
}
|
4168 |
|
|
|
4169 |
|
|
/*
|
4170 |
|
|
* qla1280_isp_cmd
|
4171 |
|
|
* Function is responsible for modifying ISP input pointer.
|
4172 |
|
|
* Releases ring lock.
|
4173 |
|
|
*
|
4174 |
|
|
* Input:
|
4175 |
|
|
* ha = adapter block pointer.
|
4176 |
|
|
*/
|
4177 |
|
|
static void
|
4178 |
|
|
qla1280_isp_cmd(struct scsi_qla_host *ha)
|
4179 |
|
|
{
|
4180 |
|
|
struct device_reg *reg = ha->iobase;
|
4181 |
|
|
|
4182 |
|
|
ENTER("qla1280_isp_cmd");
|
4183 |
|
|
|
4184 |
|
|
dprintk(5, "qla1280_isp_cmd: IOCB data:\n");
|
4185 |
|
|
qla1280_dump_buffer(5, (char *)ha->request_ring_ptr,
|
4186 |
|
|
REQUEST_ENTRY_SIZE);
|
4187 |
|
|
|
4188 |
|
|
/* Adjust ring index. */
|
4189 |
|
|
ha->req_ring_index++;
|
4190 |
|
|
if (ha->req_ring_index == REQUEST_ENTRY_CNT) {
|
4191 |
|
|
ha->req_ring_index = 0;
|
4192 |
|
|
ha->request_ring_ptr = ha->request_ring;
|
4193 |
|
|
} else
|
4194 |
|
|
ha->request_ring_ptr++;
|
4195 |
|
|
|
4196 |
|
|
/* Set chip new ring index. */
|
4197 |
|
|
WRT_REG_WORD(®->mailbox4, ha->req_ring_index);
|
4198 |
|
|
|
4199 |
|
|
LEAVE("qla1280_isp_cmd");
|
4200 |
|
|
}
|
4201 |
|
|
|
4202 |
|
|
#if QL1280_LUN_SUPPORT
|
4203 |
|
|
/*
|
4204 |
|
|
* qla1280_enable_lun
|
4205 |
|
|
* Issue enable LUN entry IOCB.
|
4206 |
|
|
*
|
4207 |
|
|
* Input:
|
4208 |
|
|
* ha = adapter block pointer.
|
4209 |
|
|
* bus = SCSI BUS number.
|
4210 |
|
|
* lun = LUN number.
|
4211 |
|
|
*/
|
4212 |
|
|
static void
|
4213 |
|
|
qla1280_enable_lun(struct scsi_qla_host *ha, int bus, int lun)
|
4214 |
|
|
{
|
4215 |
|
|
struct elun_entry *pkt;
|
4216 |
|
|
|
4217 |
|
|
ENTER("qla1280_enable_lun");
|
4218 |
|
|
|
4219 |
|
|
/* Get request packet. */
|
4220 |
|
|
/*
|
4221 |
|
|
if (pkt = (struct elun_entry *)qla1280_req_pkt(ha))
|
4222 |
|
|
{
|
4223 |
|
|
pkt->entry_type = ENABLE_LUN_TYPE;
|
4224 |
|
|
pkt->lun = cpu_to_le16(bus ? lun | BIT_15 : lun);
|
4225 |
|
|
pkt->command_count = 32;
|
4226 |
|
|
pkt->immed_notify_count = 1;
|
4227 |
|
|
pkt->group_6_length = MAX_CMDSZ;
|
4228 |
|
|
pkt->group_7_length = MAX_CMDSZ;
|
4229 |
|
|
pkt->timeout = cpu_to_le16(0x30);
|
4230 |
|
|
|
4231 |
|
|
qla1280_isp_cmd(ha);
|
4232 |
|
|
}
|
4233 |
|
|
*/
|
4234 |
|
|
pkt = (struct elun_entry *) 1;
|
4235 |
|
|
|
4236 |
|
|
if (!pkt)
|
4237 |
|
|
dprintk(2, "qla1280_enable_lun: **** FAILED ****\n");
|
4238 |
|
|
else
|
4239 |
|
|
dprintk(3, "qla1280_enable_lun: exiting normally\n");
|
4240 |
|
|
}
|
4241 |
|
|
#endif
|
4242 |
|
|
|
4243 |
|
|
|
4244 |
|
|
/****************************************************************************/
|
4245 |
|
|
/* Interrupt Service Routine. */
|
4246 |
|
|
/****************************************************************************/
|
4247 |
|
|
|
4248 |
|
|
/****************************************************************************
|
4249 |
|
|
* qla1280_isr
|
4250 |
|
|
* Calls I/O done on command completion.
|
4251 |
|
|
*
|
4252 |
|
|
* Input:
|
4253 |
|
|
* ha = adapter block pointer.
|
4254 |
|
|
* done_q_first = done queue first pointer.
|
4255 |
|
|
* done_q_last = done queue last pointer.
|
4256 |
|
|
****************************************************************************/
|
4257 |
|
|
static void
|
4258 |
|
|
qla1280_isr(struct scsi_qla_host *ha, struct srb ** done_q_first,
|
4259 |
|
|
struct srb ** done_q_last)
|
4260 |
|
|
{
|
4261 |
|
|
struct device_reg *reg = ha->iobase;
|
4262 |
|
|
struct response *pkt;
|
4263 |
|
|
struct srb *sp = 0;
|
4264 |
|
|
uint16_t mailbox[MAILBOX_REGISTER_COUNT];
|
4265 |
|
|
uint16_t *wptr;
|
4266 |
|
|
uint32_t index;
|
4267 |
|
|
u16 istatus;
|
4268 |
|
|
|
4269 |
|
|
ENTER("qla1280_isr");
|
4270 |
|
|
|
4271 |
|
|
istatus = RD_REG_WORD(®->istatus);
|
4272 |
|
|
if (!(istatus & (RISC_INT | PCI_INT)))
|
4273 |
|
|
return;
|
4274 |
|
|
|
4275 |
|
|
/* Save mailbox register 5 */
|
4276 |
|
|
mailbox[5] = RD_REG_WORD(®->mailbox5);
|
4277 |
|
|
|
4278 |
|
|
/* Check for mailbox interrupt. */
|
4279 |
|
|
|
4280 |
|
|
mailbox[0] = RD_REG_WORD(®->semaphore);
|
4281 |
|
|
|
4282 |
|
|
if (mailbox[0] & BIT_0) {
|
4283 |
|
|
/* Get mailbox data. */
|
4284 |
|
|
/* dprintk(1, "qla1280_isr: In Get mailbox data \n"); */
|
4285 |
|
|
|
4286 |
|
|
wptr = &mailbox[0];
|
4287 |
|
|
*wptr++ = RD_REG_WORD(®->mailbox0);
|
4288 |
|
|
*wptr++ = RD_REG_WORD(®->mailbox1);
|
4289 |
|
|
*wptr = RD_REG_WORD(®->mailbox2);
|
4290 |
|
|
if (mailbox[0] != MBA_SCSI_COMPLETION) {
|
4291 |
|
|
wptr++;
|
4292 |
|
|
*wptr++ = RD_REG_WORD(®->mailbox3);
|
4293 |
|
|
*wptr++ = RD_REG_WORD(®->mailbox4);
|
4294 |
|
|
wptr++;
|
4295 |
|
|
*wptr++ = RD_REG_WORD(®->mailbox6);
|
4296 |
|
|
*wptr = RD_REG_WORD(®->mailbox7);
|
4297 |
|
|
}
|
4298 |
|
|
|
4299 |
|
|
/* Release mailbox registers. */
|
4300 |
|
|
|
4301 |
|
|
WRT_REG_WORD(®->semaphore, 0);
|
4302 |
|
|
WRT_REG_WORD(®->host_cmd, HC_CLR_RISC_INT);
|
4303 |
|
|
|
4304 |
|
|
dprintk(5, "qla1280_isr: mailbox interrupt mailbox[0] = 0x%x",
|
4305 |
|
|
mailbox[0]);
|
4306 |
|
|
|
4307 |
|
|
/* Handle asynchronous event */
|
4308 |
|
|
switch (mailbox[0]) {
|
4309 |
|
|
case MBA_SCSI_COMPLETION: /* Response completion */
|
4310 |
|
|
dprintk(5, "qla1280_isr: mailbox SCSI response "
|
4311 |
|
|
"completion\n");
|
4312 |
|
|
|
4313 |
|
|
if (ha->flags.online) {
|
4314 |
|
|
/* Get outstanding command index. */
|
4315 |
|
|
index = mailbox[2] << 16 | mailbox[1];
|
4316 |
|
|
|
4317 |
|
|
/* Validate handle. */
|
4318 |
|
|
if (index < MAX_OUTSTANDING_COMMANDS)
|
4319 |
|
|
sp = ha->outstanding_cmds[index];
|
4320 |
|
|
else
|
4321 |
|
|
sp = 0;
|
4322 |
|
|
|
4323 |
|
|
if (sp) {
|
4324 |
|
|
/* Free outstanding command slot. */
|
4325 |
|
|
ha->outstanding_cmds[index] = 0;
|
4326 |
|
|
|
4327 |
|
|
/* Save ISP completion status */
|
4328 |
|
|
CMD_RESULT(sp->cmd) = 0;
|
4329 |
|
|
|
4330 |
|
|
/* Place block on done queue */
|
4331 |
|
|
sp->s_next = NULL;
|
4332 |
|
|
sp->s_prev = *done_q_last;
|
4333 |
|
|
if (!*done_q_first)
|
4334 |
|
|
*done_q_first = sp;
|
4335 |
|
|
else
|
4336 |
|
|
(*done_q_last)->s_next = sp;
|
4337 |
|
|
*done_q_last = sp;
|
4338 |
|
|
} else {
|
4339 |
|
|
/*
|
4340 |
|
|
* If we get here we have a real problem!
|
4341 |
|
|
*/
|
4342 |
|
|
printk(KERN_WARNING
|
4343 |
|
|
"qla1280: ISP invalid handle");
|
4344 |
|
|
}
|
4345 |
|
|
}
|
4346 |
|
|
break;
|
4347 |
|
|
|
4348 |
|
|
case MBA_BUS_RESET: /* SCSI Bus Reset */
|
4349 |
|
|
ha->flags.reset_marker = 1;
|
4350 |
|
|
index = mailbox[6] & BIT_0;
|
4351 |
|
|
ha->bus_settings[index].reset_marker = 1;
|
4352 |
|
|
|
4353 |
|
|
printk(KERN_DEBUG "qla1280_isr(): index %i "
|
4354 |
|
|
"asynchronous BUS_RESET\n", index);
|
4355 |
|
|
break;
|
4356 |
|
|
|
4357 |
|
|
case MBA_SYSTEM_ERR: /* System Error */
|
4358 |
|
|
printk(KERN_WARNING
|
4359 |
|
|
"qla1280: ISP System Error - mbx1=%xh, mbx2="
|
4360 |
|
|
"%xh, mbx3=%xh\n", mailbox[1], mailbox[2],
|
4361 |
|
|
mailbox[3]);
|
4362 |
|
|
break;
|
4363 |
|
|
|
4364 |
|
|
case MBA_REQ_TRANSFER_ERR: /* Request Transfer Error */
|
4365 |
|
|
printk(KERN_WARNING
|
4366 |
|
|
"qla1280: ISP Request Transfer Error\n");
|
4367 |
|
|
break;
|
4368 |
|
|
|
4369 |
|
|
case MBA_RSP_TRANSFER_ERR: /* Response Transfer Error */
|
4370 |
|
|
printk(KERN_WARNING
|
4371 |
|
|
"qla1280: ISP Response Transfer Error\n");
|
4372 |
|
|
break;
|
4373 |
|
|
|
4374 |
|
|
case MBA_WAKEUP_THRES: /* Request Queue Wake-up */
|
4375 |
|
|
dprintk(2, "qla1280_isr: asynchronous WAKEUP_THRES\n");
|
4376 |
|
|
break;
|
4377 |
|
|
|
4378 |
|
|
case MBA_TIMEOUT_RESET: /* Execution Timeout Reset */
|
4379 |
|
|
dprintk(2,
|
4380 |
|
|
"qla1280_isr: asynchronous TIMEOUT_RESET\n");
|
4381 |
|
|
break;
|
4382 |
|
|
|
4383 |
|
|
case MBA_DEVICE_RESET: /* Bus Device Reset */
|
4384 |
|
|
printk(KERN_INFO "qla1280_isr(): asynchronous "
|
4385 |
|
|
"BUS_DEVICE_RESET\n");
|
4386 |
|
|
|
4387 |
|
|
ha->flags.reset_marker = 1;
|
4388 |
|
|
index = mailbox[6] & BIT_0;
|
4389 |
|
|
ha->bus_settings[index].reset_marker = 1;
|
4390 |
|
|
break;
|
4391 |
|
|
|
4392 |
|
|
case MBA_BUS_MODE_CHANGE:
|
4393 |
|
|
dprintk(2,
|
4394 |
|
|
"qla1280_isr: asynchronous BUS_MODE_CHANGE\n");
|
4395 |
|
|
break;
|
4396 |
|
|
|
4397 |
|
|
default:
|
4398 |
|
|
/* dprintk(1, "qla1280_isr: default case of switch MB \n"); */
|
4399 |
|
|
if (mailbox[0] < MBA_ASYNC_EVENT) {
|
4400 |
|
|
wptr = &mailbox[0];
|
4401 |
|
|
memcpy((uint16_t *) ha->mailbox_out, wptr,
|
4402 |
|
|
MAILBOX_REGISTER_COUNT *
|
4403 |
|
|
sizeof(uint16_t));
|
4404 |
|
|
|
4405 |
|
|
if(ha->mailbox_wait != NULL)
|
4406 |
|
|
complete(ha->mailbox_wait);
|
4407 |
|
|
}
|
4408 |
|
|
break;
|
4409 |
|
|
}
|
4410 |
|
|
} else {
|
4411 |
|
|
WRT_REG_WORD(®->host_cmd, HC_CLR_RISC_INT);
|
4412 |
|
|
}
|
4413 |
|
|
|
4414 |
|
|
/*
|
4415 |
|
|
* Response ring - waiting for the mbox_busy flag here seems
|
4416 |
|
|
* unnecessary as the mailbox data has been copied to ha->mailbox_out
|
4417 |
|
|
* by the time we actually get here!
|
4418 |
|
|
*/
|
4419 |
|
|
if (!(ha->flags.online
|
4420 |
|
|
#if 0
|
4421 |
|
|
&& !ha->flags.mbox_busy
|
4422 |
|
|
#endif
|
4423 |
|
|
)) {
|
4424 |
|
|
dprintk(2, "qla1280_isr: Response pointer Error\n");
|
4425 |
|
|
goto out;
|
4426 |
|
|
}
|
4427 |
|
|
|
4428 |
|
|
if (mailbox[5] >= RESPONSE_ENTRY_CNT)
|
4429 |
|
|
goto out;
|
4430 |
|
|
|
4431 |
|
|
while (ha->rsp_ring_index != mailbox[5]) {
|
4432 |
|
|
pkt = ha->response_ring_ptr;
|
4433 |
|
|
|
4434 |
|
|
dprintk(5, "qla1280_isr: ha->rsp_ring_index = 0x%x, mailbox[5]"
|
4435 |
|
|
" = 0x%x\n", ha->rsp_ring_index, mailbox[5]);
|
4436 |
|
|
dprintk(5,"qla1280_isr: response packet data\n");
|
4437 |
|
|
qla1280_dump_buffer(5, (char *)pkt, RESPONSE_ENTRY_SIZE);
|
4438 |
|
|
|
4439 |
|
|
if (pkt->entry_type == STATUS_TYPE) {
|
4440 |
|
|
if ((le16_to_cpu(pkt->scsi_status) & 0xff)
|
4441 |
|
|
|| pkt->comp_status || pkt->entry_status) {
|
4442 |
|
|
dprintk(2, "qla1280_isr: ha->rsp_ring_index = "
|
4443 |
|
|
"0x%x mailbox[5] = 0x%x, comp_status "
|
4444 |
|
|
"= 0x%x, scsi_status = 0x%x\n",
|
4445 |
|
|
ha->rsp_ring_index, mailbox[5],
|
4446 |
|
|
le16_to_cpu(pkt->comp_status),
|
4447 |
|
|
le16_to_cpu(pkt->scsi_status));
|
4448 |
|
|
}
|
4449 |
|
|
} else {
|
4450 |
|
|
dprintk(2, "qla1280_isr: ha->rsp_ring_index = "
|
4451 |
|
|
"0x%x, mailbox[5] = 0x%x\n",
|
4452 |
|
|
ha->rsp_ring_index, mailbox[5]);
|
4453 |
|
|
dprintk(2, "qla1280_isr: response packet data\n");
|
4454 |
|
|
qla1280_dump_buffer(2, (char *)pkt,
|
4455 |
|
|
RESPONSE_ENTRY_SIZE);
|
4456 |
|
|
}
|
4457 |
|
|
|
4458 |
|
|
if (pkt->entry_type == STATUS_TYPE || pkt->entry_status) {
|
4459 |
|
|
dprintk(2, "status: Cmd %p, handle %i\n",
|
4460 |
|
|
ha->outstanding_cmds[pkt->handle]->cmd,
|
4461 |
|
|
pkt->handle);
|
4462 |
|
|
if (pkt->entry_type == STATUS_TYPE)
|
4463 |
|
|
qla1280_status_entry(ha, pkt, done_q_first,
|
4464 |
|
|
done_q_last);
|
4465 |
|
|
else
|
4466 |
|
|
qla1280_error_entry(ha, pkt, done_q_first,
|
4467 |
|
|
done_q_last);
|
4468 |
|
|
|
4469 |
|
|
/* Adjust ring index. */
|
4470 |
|
|
ha->rsp_ring_index++;
|
4471 |
|
|
if (ha->rsp_ring_index == RESPONSE_ENTRY_CNT) {
|
4472 |
|
|
ha->rsp_ring_index = 0;
|
4473 |
|
|
ha->response_ring_ptr = ha->response_ring;
|
4474 |
|
|
} else
|
4475 |
|
|
ha->response_ring_ptr++;
|
4476 |
|
|
WRT_REG_WORD(®->mailbox5, ha->rsp_ring_index);
|
4477 |
|
|
}
|
4478 |
|
|
}
|
4479 |
|
|
|
4480 |
|
|
out:
|
4481 |
|
|
LEAVE("qla1280_isr");
|
4482 |
|
|
}
|
4483 |
|
|
|
4484 |
|
|
/*
|
4485 |
|
|
* qla1280_rst_aen
|
4486 |
|
|
* Processes asynchronous reset.
|
4487 |
|
|
*
|
4488 |
|
|
* Input:
|
4489 |
|
|
* ha = adapter block pointer.
|
4490 |
|
|
*/
|
4491 |
|
|
static void
|
4492 |
|
|
qla1280_rst_aen(struct scsi_qla_host *ha)
|
4493 |
|
|
{
|
4494 |
|
|
uint8_t bus;
|
4495 |
|
|
|
4496 |
|
|
ENTER("qla1280_rst_aen");
|
4497 |
|
|
|
4498 |
|
|
if (ha->flags.online && !ha->flags.reset_active &&
|
4499 |
|
|
!ha->flags.abort_isp_active) {
|
4500 |
|
|
ha->flags.reset_active = 1;
|
4501 |
|
|
while (ha->flags.reset_marker) {
|
4502 |
|
|
/* Issue marker command. */
|
4503 |
|
|
ha->flags.reset_marker = 0;
|
4504 |
|
|
for (bus = 0; bus < ha->ports &&
|
4505 |
|
|
!ha->flags.reset_marker; bus++) {
|
4506 |
|
|
if (ha->bus_settings[bus].reset_marker) {
|
4507 |
|
|
ha->bus_settings[bus].reset_marker = 0;
|
4508 |
|
|
qla1280_marker(ha, bus, 0, 0,
|
4509 |
|
|
MK_SYNC_ALL);
|
4510 |
|
|
}
|
4511 |
|
|
}
|
4512 |
|
|
}
|
4513 |
|
|
}
|
4514 |
|
|
|
4515 |
|
|
LEAVE("qla1280_rst_aen");
|
4516 |
|
|
}
|
4517 |
|
|
|
4518 |
|
|
|
4519 |
|
|
#if LINUX_VERSION_CODE < 0x020500
|
4520 |
|
|
/*
|
4521 |
|
|
*
|
4522 |
|
|
*/
|
4523 |
|
|
static void
|
4524 |
|
|
qla1280_get_target_options(struct scsi_cmnd *cmd, struct scsi_qla_host *ha)
|
4525 |
|
|
{
|
4526 |
|
|
unsigned char *result;
|
4527 |
|
|
struct nvram *n;
|
4528 |
|
|
int bus, target, lun;
|
4529 |
|
|
|
4530 |
|
|
bus = SCSI_BUS_32(cmd);
|
4531 |
|
|
target = SCSI_TCN_32(cmd);
|
4532 |
|
|
lun = SCSI_LUN_32(cmd);
|
4533 |
|
|
|
4534 |
|
|
/*
|
4535 |
|
|
* Make sure to not touch anything if someone is using the
|
4536 |
|
|
* sg interface.
|
4537 |
|
|
*/
|
4538 |
|
|
if (cmd->use_sg || (CMD_RESULT(cmd) >> 16) != DID_OK || lun)
|
4539 |
|
|
return;
|
4540 |
|
|
|
4541 |
|
|
result = cmd->request_buffer;
|
4542 |
|
|
n = &ha->nvram;
|
4543 |
|
|
|
4544 |
|
|
n->bus[bus].target[target].parameter.f.enable_wide = 0;
|
4545 |
|
|
n->bus[bus].target[target].parameter.f.enable_sync = 0;
|
4546 |
|
|
n->bus[bus].target[target].ppr_1x160.flags.enable_ppr = 0;
|
4547 |
|
|
|
4548 |
|
|
if (result[7] & 0x60)
|
4549 |
|
|
n->bus[bus].target[target].parameter.f.enable_wide = 1;
|
4550 |
|
|
if (result[7] & 0x10)
|
4551 |
|
|
n->bus[bus].target[target].parameter.f.enable_sync = 1;
|
4552 |
|
|
if ((result[2] >= 3) && (result[4] + 5 > 56) &&
|
4553 |
|
|
(result[56] & 0x4))
|
4554 |
|
|
n->bus[bus].target[target].ppr_1x160.flags.enable_ppr = 1;
|
4555 |
|
|
|
4556 |
|
|
dprintk(2, "get_target_options(): wide %i, sync %i, ppr %i\n",
|
4557 |
|
|
n->bus[bus].target[target].parameter.f.enable_wide,
|
4558 |
|
|
n->bus[bus].target[target].parameter.f.enable_sync,
|
4559 |
|
|
n->bus[bus].target[target].ppr_1x160.flags.enable_ppr);
|
4560 |
|
|
}
|
4561 |
|
|
#endif
|
4562 |
|
|
|
4563 |
|
|
/*
|
4564 |
|
|
* qla1280_status_entry
|
4565 |
|
|
* Processes received ISP status entry.
|
4566 |
|
|
*
|
4567 |
|
|
* Input:
|
4568 |
|
|
* ha = adapter block pointer.
|
4569 |
|
|
* pkt = entry pointer.
|
4570 |
|
|
* done_q_first = done queue first pointer.
|
4571 |
|
|
* done_q_last = done queue last pointer.
|
4572 |
|
|
*/
|
4573 |
|
|
static void
|
4574 |
|
|
qla1280_status_entry(struct scsi_qla_host *ha, struct response *pkt,
|
4575 |
|
|
struct srb **done_q_first, struct srb **done_q_last)
|
4576 |
|
|
{
|
4577 |
|
|
unsigned int bus, target, lun;
|
4578 |
|
|
int sense_sz;
|
4579 |
|
|
struct srb *sp;
|
4580 |
|
|
Scsi_Cmnd *cmd;
|
4581 |
|
|
uint32_t handle = le32_to_cpu(pkt->handle);
|
4582 |
|
|
uint16_t scsi_status = le16_to_cpu(pkt->scsi_status);
|
4583 |
|
|
uint16_t comp_status = le16_to_cpu(pkt->comp_status);
|
4584 |
|
|
|
4585 |
|
|
ENTER("qla1280_status_entry");
|
4586 |
|
|
|
4587 |
|
|
/* Validate handle. */
|
4588 |
|
|
if (handle < MAX_OUTSTANDING_COMMANDS)
|
4589 |
|
|
sp = ha->outstanding_cmds[handle];
|
4590 |
|
|
else
|
4591 |
|
|
sp = NULL;
|
4592 |
|
|
|
4593 |
|
|
if (!sp) {
|
4594 |
|
|
printk(KERN_WARNING "qla1280: Status Entry invalid handle\n");
|
4595 |
|
|
goto out;
|
4596 |
|
|
}
|
4597 |
|
|
|
4598 |
|
|
/* Free outstanding command slot. */
|
4599 |
|
|
ha->outstanding_cmds[handle] = 0;
|
4600 |
|
|
|
4601 |
|
|
cmd = sp->cmd;
|
4602 |
|
|
|
4603 |
|
|
/* Generate LU queue on cntrl, target, LUN */
|
4604 |
|
|
bus = SCSI_BUS_32(cmd);
|
4605 |
|
|
target = SCSI_TCN_32(cmd);
|
4606 |
|
|
lun = SCSI_LUN_32(cmd);
|
4607 |
|
|
|
4608 |
|
|
if (comp_status || scsi_status) {
|
4609 |
|
|
dprintk(3, "scsi: comp_status = 0x%x, scsi_status = "
|
4610 |
|
|
"0x%x, handle = 0x%x\n", comp_status,
|
4611 |
|
|
scsi_status, handle);
|
4612 |
|
|
}
|
4613 |
|
|
|
4614 |
|
|
/* Target busy */
|
4615 |
|
|
if (scsi_status & SS_BUSY_CONDITION &&
|
4616 |
|
|
scsi_status != SS_RESERVE_CONFLICT) {
|
4617 |
|
|
CMD_RESULT(cmd) =
|
4618 |
|
|
DID_BUS_BUSY << 16 | (scsi_status & 0xff);
|
4619 |
|
|
} else {
|
4620 |
|
|
|
4621 |
|
|
/* Save ISP completion status */
|
4622 |
|
|
CMD_RESULT(cmd) = qla1280_return_status(pkt, cmd);
|
4623 |
|
|
|
4624 |
|
|
if (scsi_status & SS_CHECK_CONDITION) {
|
4625 |
|
|
if (comp_status != CS_ARS_FAILED) {
|
4626 |
|
|
uint16_t req_sense_length =
|
4627 |
|
|
le16_to_cpu(pkt->req_sense_length);
|
4628 |
|
|
if (req_sense_length < CMD_SNSLEN(cmd))
|
4629 |
|
|
sense_sz = req_sense_length;
|
4630 |
|
|
else
|
4631 |
|
|
/*
|
4632 |
|
|
* Scsi_Cmnd->sense_buffer is
|
4633 |
|
|
* 64 bytes, why only copy 63?
|
4634 |
|
|
* This looks wrong! /Jes
|
4635 |
|
|
*/
|
4636 |
|
|
sense_sz = CMD_SNSLEN(cmd) - 1;
|
4637 |
|
|
|
4638 |
|
|
memcpy(cmd->sense_buffer,
|
4639 |
|
|
&pkt->req_sense_data, sense_sz);
|
4640 |
|
|
} else
|
4641 |
|
|
sense_sz = 0;
|
4642 |
|
|
memset(cmd->sense_buffer + sense_sz, 0,
|
4643 |
|
|
sizeof(cmd->sense_buffer) - sense_sz);
|
4644 |
|
|
|
4645 |
|
|
dprintk(2, "qla1280_status_entry: Check "
|
4646 |
|
|
"condition Sense data, b %i, t %i, "
|
4647 |
|
|
"l %i\n", bus, target, lun);
|
4648 |
|
|
if (sense_sz)
|
4649 |
|
|
qla1280_dump_buffer(2,
|
4650 |
|
|
(char *)cmd->sense_buffer,
|
4651 |
|
|
sense_sz);
|
4652 |
|
|
}
|
4653 |
|
|
}
|
4654 |
|
|
/* Place command on done queue. */
|
4655 |
|
|
qla1280_done_q_put(sp, done_q_first, done_q_last);
|
4656 |
|
|
|
4657 |
|
|
out:
|
4658 |
|
|
LEAVE("qla1280_status_entry");
|
4659 |
|
|
}
|
4660 |
|
|
|
4661 |
|
|
/*
|
4662 |
|
|
* qla1280_error_entry
|
4663 |
|
|
* Processes error entry.
|
4664 |
|
|
*
|
4665 |
|
|
* Input:
|
4666 |
|
|
* ha = adapter block pointer.
|
4667 |
|
|
* pkt = entry pointer.
|
4668 |
|
|
* done_q_first = done queue first pointer.
|
4669 |
|
|
* done_q_last = done queue last pointer.
|
4670 |
|
|
*/
|
4671 |
|
|
static void
|
4672 |
|
|
qla1280_error_entry(struct scsi_qla_host *ha, struct response * pkt,
|
4673 |
|
|
struct srb ** done_q_first, struct srb ** done_q_last)
|
4674 |
|
|
{
|
4675 |
|
|
struct srb *sp;
|
4676 |
|
|
uint32_t handle = le32_to_cpu(pkt->handle);
|
4677 |
|
|
|
4678 |
|
|
ENTER("qla1280_error_entry");
|
4679 |
|
|
|
4680 |
|
|
if (pkt->entry_status & BIT_3)
|
4681 |
|
|
dprintk(2, "qla1280_error_entry: BAD PAYLOAD flag error\n");
|
4682 |
|
|
else if (pkt->entry_status & BIT_2)
|
4683 |
|
|
dprintk(2, "qla1280_error_entry: BAD HEADER flag error\n");
|
4684 |
|
|
else if (pkt->entry_status & BIT_1)
|
4685 |
|
|
dprintk(2, "qla1280_error_entry: FULL flag error\n");
|
4686 |
|
|
else
|
4687 |
|
|
dprintk(2, "qla1280_error_entry: UNKNOWN flag error\n");
|
4688 |
|
|
|
4689 |
|
|
/* Validate handle. */
|
4690 |
|
|
if (handle < MAX_OUTSTANDING_COMMANDS)
|
4691 |
|
|
sp = ha->outstanding_cmds[handle];
|
4692 |
|
|
else
|
4693 |
|
|
sp = 0;
|
4694 |
|
|
|
4695 |
|
|
if (sp) {
|
4696 |
|
|
/* Free outstanding command slot. */
|
4697 |
|
|
ha->outstanding_cmds[handle] = 0;
|
4698 |
|
|
|
4699 |
|
|
/* Bad payload or header */
|
4700 |
|
|
if (pkt->entry_status & (BIT_3 + BIT_2)) {
|
4701 |
|
|
/* Bad payload or header, set error status. */
|
4702 |
|
|
/* CMD_RESULT(sp->cmd) = CS_BAD_PAYLOAD; */
|
4703 |
|
|
CMD_RESULT(sp->cmd) = DID_ERROR << 16;
|
4704 |
|
|
} else if (pkt->entry_status & BIT_1) { /* FULL flag */
|
4705 |
|
|
CMD_RESULT(sp->cmd) = DID_BUS_BUSY << 16;
|
4706 |
|
|
} else {
|
4707 |
|
|
/* Set error status. */
|
4708 |
|
|
CMD_RESULT(sp->cmd) = DID_ERROR << 16;
|
4709 |
|
|
}
|
4710 |
|
|
/* Place command on done queue. */
|
4711 |
|
|
qla1280_done_q_put(sp, done_q_first, done_q_last);
|
4712 |
|
|
}
|
4713 |
|
|
#ifdef QLA_64BIT_PTR
|
4714 |
|
|
else if (pkt->entry_type == COMMAND_A64_TYPE) {
|
4715 |
|
|
printk(KERN_WARNING "!qla1280: Error Entry invalid handle");
|
4716 |
|
|
}
|
4717 |
|
|
#endif
|
4718 |
|
|
|
4719 |
|
|
LEAVE("qla1280_error_entry");
|
4720 |
|
|
}
|
4721 |
|
|
|
4722 |
|
|
/*
|
4723 |
|
|
* qla1280_abort_isp
|
4724 |
|
|
* Resets ISP and aborts all outstanding commands.
|
4725 |
|
|
*
|
4726 |
|
|
* Input:
|
4727 |
|
|
* ha = adapter block pointer.
|
4728 |
|
|
*
|
4729 |
|
|
* Returns:
|
4730 |
|
|
* 0 = success
|
4731 |
|
|
*/
|
4732 |
|
|
static int
|
4733 |
|
|
qla1280_abort_isp(struct scsi_qla_host *ha)
|
4734 |
|
|
{
|
4735 |
|
|
struct srb *sp;
|
4736 |
|
|
int status = 0;
|
4737 |
|
|
int cnt;
|
4738 |
|
|
int bus;
|
4739 |
|
|
|
4740 |
|
|
ENTER("qla1280_abort_isp");
|
4741 |
|
|
|
4742 |
|
|
if (!ha->flags.abort_isp_active && ha->flags.online) {
|
4743 |
|
|
struct device_reg *reg = ha->iobase;
|
4744 |
|
|
ha->flags.abort_isp_active = 1;
|
4745 |
|
|
|
4746 |
|
|
/* Disable ISP interrupts. */
|
4747 |
|
|
qla1280_disable_intrs(ha);
|
4748 |
|
|
WRT_REG_WORD(®->host_cmd, HC_PAUSE_RISC);
|
4749 |
|
|
RD_REG_WORD(®->id_l);
|
4750 |
|
|
|
4751 |
|
|
printk(KERN_INFO "scsi(%li): dequeuing outstanding commands\n",
|
4752 |
|
|
ha->host_no);
|
4753 |
|
|
/* Dequeue all commands in outstanding command list. */
|
4754 |
|
|
for (cnt = 0; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
|
4755 |
|
|
Scsi_Cmnd *cmd;
|
4756 |
|
|
sp = ha->outstanding_cmds[cnt];
|
4757 |
|
|
if (sp) {
|
4758 |
|
|
|
4759 |
|
|
cmd = sp->cmd;
|
4760 |
|
|
CMD_RESULT(cmd) = DID_RESET << 16;
|
4761 |
|
|
|
4762 |
|
|
sp->cmd = NULL;
|
4763 |
|
|
ha->outstanding_cmds[cnt] = NULL;
|
4764 |
|
|
|
4765 |
|
|
(*cmd->scsi_done)(cmd);
|
4766 |
|
|
|
4767 |
|
|
sp->flags = 0;
|
4768 |
|
|
}
|
4769 |
|
|
}
|
4770 |
|
|
|
4771 |
|
|
/* If firmware needs to be loaded */
|
4772 |
|
|
if (qla1280_isp_firmware (ha)) {
|
4773 |
|
|
if (!(status = qla1280_chip_diag(ha)))
|
4774 |
|
|
status = qla1280_setup_chip(ha);
|
4775 |
|
|
}
|
4776 |
|
|
|
4777 |
|
|
if (!status) {
|
4778 |
|
|
/* Setup adapter based on NVRAM parameters. */
|
4779 |
|
|
qla1280_nvram_config (ha);
|
4780 |
|
|
|
4781 |
|
|
if (!(status = qla1280_init_rings(ha))) {
|
4782 |
|
|
/* Issue SCSI reset. */
|
4783 |
|
|
for (bus = 0; bus < ha->ports; bus++) {
|
4784 |
|
|
qla1280_bus_reset(ha, bus);
|
4785 |
|
|
}
|
4786 |
|
|
/*
|
4787 |
|
|
* qla1280_bus_reset() will do the marker
|
4788 |
|
|
* dance - no reason to repeat here!
|
4789 |
|
|
*/
|
4790 |
|
|
#if 0
|
4791 |
|
|
/* Issue marker command. */
|
4792 |
|
|
ha->flags.reset_marker = 0;
|
4793 |
|
|
for (bus = 0; bus < ha->ports; bus++) {
|
4794 |
|
|
ha->bus_settings[bus].
|
4795 |
|
|
reset_marker = 0;
|
4796 |
|
|
qla1280_marker(ha, bus, 0, 0,
|
4797 |
|
|
MK_SYNC_ALL);
|
4798 |
|
|
}
|
4799 |
|
|
#endif
|
4800 |
|
|
ha->flags.abort_isp_active = 0;
|
4801 |
|
|
}
|
4802 |
|
|
}
|
4803 |
|
|
}
|
4804 |
|
|
|
4805 |
|
|
if (status) {
|
4806 |
|
|
printk(KERN_WARNING
|
4807 |
|
|
"qla1280: ISP error recovery failed, board disabled");
|
4808 |
|
|
qla1280_reset_adapter(ha);
|
4809 |
|
|
dprintk(2, "qla1280_abort_isp: **** FAILED ****\n");
|
4810 |
|
|
}
|
4811 |
|
|
|
4812 |
|
|
LEAVE("qla1280_abort_isp");
|
4813 |
|
|
return status;
|
4814 |
|
|
}
|
4815 |
|
|
|
4816 |
|
|
|
4817 |
|
|
/*
|
4818 |
|
|
* qla1280_debounce_register
|
4819 |
|
|
* Debounce register.
|
4820 |
|
|
*
|
4821 |
|
|
* Input:
|
4822 |
|
|
* port = register address.
|
4823 |
|
|
*
|
4824 |
|
|
* Returns:
|
4825 |
|
|
* register value.
|
4826 |
|
|
*/
|
4827 |
|
|
static u16
|
4828 |
|
|
qla1280_debounce_register(volatile u16 * addr)
|
4829 |
|
|
{
|
4830 |
|
|
volatile u16 ret;
|
4831 |
|
|
volatile u16 ret2;
|
4832 |
|
|
|
4833 |
|
|
ret = RD_REG_WORD(addr);
|
4834 |
|
|
ret2 = RD_REG_WORD(addr);
|
4835 |
|
|
|
4836 |
|
|
if (ret == ret2)
|
4837 |
|
|
return ret;
|
4838 |
|
|
|
4839 |
|
|
do {
|
4840 |
|
|
cpu_relax();
|
4841 |
|
|
ret = RD_REG_WORD(addr);
|
4842 |
|
|
ret2 = RD_REG_WORD(addr);
|
4843 |
|
|
} while (ret != ret2);
|
4844 |
|
|
|
4845 |
|
|
return ret;
|
4846 |
|
|
}
|
4847 |
|
|
|
4848 |
|
|
|
4849 |
|
|
/************************************************************************
|
4850 |
|
|
* qla1280_check_for_dead_scsi_bus *
|
4851 |
|
|
* *
|
4852 |
|
|
* This routine checks for a dead SCSI bus *
|
4853 |
|
|
************************************************************************/
|
4854 |
|
|
#define SET_SXP_BANK 0x0100
|
4855 |
|
|
#define SCSI_PHASE_INVALID 0x87FF
|
4856 |
|
|
static int
|
4857 |
|
|
qla1280_check_for_dead_scsi_bus(struct scsi_qla_host *ha, unsigned int bus)
|
4858 |
|
|
{
|
4859 |
|
|
uint16_t config_reg, scsi_control;
|
4860 |
|
|
struct device_reg *reg = ha->iobase;
|
4861 |
|
|
|
4862 |
|
|
if (ha->bus_settings[bus].scsi_bus_dead) {
|
4863 |
|
|
WRT_REG_WORD(®->host_cmd, HC_PAUSE_RISC);
|
4864 |
|
|
config_reg = RD_REG_WORD(®->cfg_1);
|
4865 |
|
|
WRT_REG_WORD(®->cfg_1, SET_SXP_BANK);
|
4866 |
|
|
scsi_control = RD_REG_WORD(®->scsiControlPins);
|
4867 |
|
|
WRT_REG_WORD(®->cfg_1, config_reg);
|
4868 |
|
|
WRT_REG_WORD(®->host_cmd, HC_RELEASE_RISC);
|
4869 |
|
|
|
4870 |
|
|
if (scsi_control == SCSI_PHASE_INVALID) {
|
4871 |
|
|
ha->bus_settings[bus].scsi_bus_dead = 1;
|
4872 |
|
|
#if 0
|
4873 |
|
|
CMD_RESULT(cp) = DID_NO_CONNECT << 16;
|
4874 |
|
|
CMD_HANDLE(cp) = INVALID_HANDLE;
|
4875 |
|
|
/* ha->actthreads--; */
|
4876 |
|
|
|
4877 |
|
|
(*(cp)->scsi_done)(cp);
|
4878 |
|
|
#endif
|
4879 |
|
|
return 1; /* bus is dead */
|
4880 |
|
|
} else {
|
4881 |
|
|
ha->bus_settings[bus].scsi_bus_dead = 0;
|
4882 |
|
|
ha->bus_settings[bus].failed_reset_count = 0;
|
4883 |
|
|
}
|
4884 |
|
|
}
|
4885 |
|
|
return 0; /* bus is not dead */
|
4886 |
|
|
}
|
4887 |
|
|
|
4888 |
|
|
static void
|
4889 |
|
|
qla12160_get_target_parameters(struct scsi_qla_host *ha, Scsi_Device *device)
|
4890 |
|
|
{
|
4891 |
|
|
uint16_t mb[MAILBOX_REGISTER_COUNT];
|
4892 |
|
|
int bus, target, lun;
|
4893 |
|
|
|
4894 |
|
|
bus = device->channel;
|
4895 |
|
|
target = device->id;
|
4896 |
|
|
lun = device->lun;
|
4897 |
|
|
|
4898 |
|
|
|
4899 |
|
|
mb[0] = MBC_GET_TARGET_PARAMETERS;
|
4900 |
|
|
mb[1] = (uint16_t) (bus ? target | BIT_7 : target);
|
4901 |
|
|
mb[1] <<= 8;
|
4902 |
|
|
qla1280_mailbox_command(ha, BIT_6 | BIT_3 | BIT_2 | BIT_1 | BIT_0,
|
4903 |
|
|
&mb[0]);
|
4904 |
|
|
|
4905 |
|
|
printk(KERN_INFO "scsi(%li:%d:%d:%d):", ha->host_no, bus, target, lun);
|
4906 |
|
|
|
4907 |
|
|
if (mb[3] != 0) {
|
4908 |
|
|
printk(" Sync: period %d, offset %d",
|
4909 |
|
|
(mb[3] & 0xff), (mb[3] >> 8));
|
4910 |
|
|
if (mb[2] & BIT_13)
|
4911 |
|
|
printk(", Wide");
|
4912 |
|
|
if ((mb[2] & BIT_5) && ((mb[6] >> 8) & 0xff) >= 2)
|
4913 |
|
|
printk(", DT");
|
4914 |
|
|
} else
|
4915 |
|
|
printk(" Async");
|
4916 |
|
|
|
4917 |
|
|
if (DEV_SIMPLE_TAGS(device))
|
4918 |
|
|
printk(", Tagged queuing: depth %d", device->queue_depth);
|
4919 |
|
|
printk("\n");
|
4920 |
|
|
}
|
4921 |
|
|
|
4922 |
|
|
|
4923 |
|
|
#if DEBUG_QLA1280
|
4924 |
|
|
static void
|
4925 |
|
|
__qla1280_dump_buffer(char *b, int size)
|
4926 |
|
|
{
|
4927 |
|
|
int cnt;
|
4928 |
|
|
u8 c;
|
4929 |
|
|
|
4930 |
|
|
printk(KERN_DEBUG " 0 1 2 3 4 5 6 7 8 9 Ah "
|
4931 |
|
|
"Bh Ch Dh Eh Fh\n");
|
4932 |
|
|
printk(KERN_DEBUG "---------------------------------------------"
|
4933 |
|
|
"------------------\n");
|
4934 |
|
|
|
4935 |
|
|
for (cnt = 0; cnt < size;) {
|
4936 |
|
|
c = *b++;
|
4937 |
|
|
|
4938 |
|
|
printk("0x%02x", c);
|
4939 |
|
|
cnt++;
|
4940 |
|
|
if (!(cnt % 16))
|
4941 |
|
|
printk("\n");
|
4942 |
|
|
else
|
4943 |
|
|
printk(" ");
|
4944 |
|
|
}
|
4945 |
|
|
if (cnt % 16)
|
4946 |
|
|
printk("\n");
|
4947 |
|
|
}
|
4948 |
|
|
|
4949 |
|
|
/**************************************************************************
|
4950 |
|
|
* ql1280_print_scsi_cmd
|
4951 |
|
|
*
|
4952 |
|
|
**************************************************************************/
|
4953 |
|
|
static void
|
4954 |
|
|
__qla1280_print_scsi_cmd(Scsi_Cmnd * cmd)
|
4955 |
|
|
{
|
4956 |
|
|
struct scsi_qla_host *ha;
|
4957 |
|
|
struct Scsi_Host *host = CMD_HOST(cmd);
|
4958 |
|
|
struct srb *sp;
|
4959 |
|
|
/* struct scatterlist *sg; */
|
4960 |
|
|
|
4961 |
|
|
int i;
|
4962 |
|
|
ha = (struct scsi_qla_host *)host->hostdata;
|
4963 |
|
|
|
4964 |
|
|
sp = (struct srb *)CMD_SP(cmd);
|
4965 |
|
|
printk("SCSI Command @= 0x%p, Handle=0x%p\n", cmd, CMD_HANDLE(cmd));
|
4966 |
|
|
printk(" chan=%d, target = 0x%02x, lun = 0x%02x, cmd_len = 0x%02x\n",
|
4967 |
|
|
SCSI_BUS_32(cmd), SCSI_TCN_32(cmd), SCSI_LUN_32(cmd),
|
4968 |
|
|
CMD_CDBLEN(cmd));
|
4969 |
|
|
printk(" CDB = ");
|
4970 |
|
|
for (i = 0; i < cmd->cmd_len; i++) {
|
4971 |
|
|
printk("0x%02x ", cmd->cmnd[i]);
|
4972 |
|
|
}
|
4973 |
|
|
printk(" seg_cnt =%d\n", cmd->use_sg);
|
4974 |
|
|
printk(" request buffer=0x%p, request buffer len=0x%x\n",
|
4975 |
|
|
cmd->request_buffer, cmd->request_bufflen);
|
4976 |
|
|
/* if (cmd->use_sg)
|
4977 |
|
|
{
|
4978 |
|
|
sg = (struct scatterlist *) cmd->request_buffer;
|
4979 |
|
|
printk(" SG buffer: \n");
|
4980 |
|
|
qla1280_dump_buffer(1, (char *)sg, (cmd->use_sg*sizeof(struct scatterlist)));
|
4981 |
|
|
} */
|
4982 |
|
|
printk(" tag=%d, flags=0x%x, transfersize=0x%x \n",
|
4983 |
|
|
cmd->tag, cmd->flags, cmd->transfersize);
|
4984 |
|
|
printk(" Pid=%li, SP=0x%p\n", cmd->pid, CMD_SP(cmd));
|
4985 |
|
|
printk(" underflow size = 0x%x, direction=0x%x\n",
|
4986 |
|
|
cmd->underflow, sp->dir);
|
4987 |
|
|
}
|
4988 |
|
|
|
4989 |
|
|
/**************************************************************************
|
4990 |
|
|
* ql1280_dump_device
|
4991 |
|
|
*
|
4992 |
|
|
**************************************************************************/
|
4993 |
|
|
static void
|
4994 |
|
|
ql1280_dump_device(struct scsi_qla_host *ha)
|
4995 |
|
|
{
|
4996 |
|
|
|
4997 |
|
|
Scsi_Cmnd *cp;
|
4998 |
|
|
struct srb *sp;
|
4999 |
|
|
int i;
|
5000 |
|
|
|
5001 |
|
|
printk(KERN_DEBUG "Outstanding Commands on controller:\n");
|
5002 |
|
|
|
5003 |
|
|
for (i = 0; i < MAX_OUTSTANDING_COMMANDS; i++) {
|
5004 |
|
|
if ((sp = ha->outstanding_cmds[i]) == NULL)
|
5005 |
|
|
continue;
|
5006 |
|
|
if ((cp = sp->cmd) == NULL)
|
5007 |
|
|
continue;
|
5008 |
|
|
qla1280_print_scsi_cmd(1, cp);
|
5009 |
|
|
}
|
5010 |
|
|
}
|
5011 |
|
|
#endif
|
5012 |
|
|
|
5013 |
|
|
|
5014 |
|
|
enum tokens {
|
5015 |
|
|
TOKEN_NVRAM,
|
5016 |
|
|
TOKEN_SYNC,
|
5017 |
|
|
TOKEN_WIDE,
|
5018 |
|
|
TOKEN_PPR,
|
5019 |
|
|
TOKEN_VERBOSE,
|
5020 |
|
|
TOKEN_DEBUG,
|
5021 |
|
|
};
|
5022 |
|
|
|
5023 |
|
|
struct setup_tokens {
|
5024 |
|
|
char *token;
|
5025 |
|
|
int val;
|
5026 |
|
|
};
|
5027 |
|
|
|
5028 |
|
|
static struct setup_tokens setup_token[] __initdata =
|
5029 |
|
|
{
|
5030 |
|
|
{ "nvram", TOKEN_NVRAM },
|
5031 |
|
|
{ "sync", TOKEN_SYNC },
|
5032 |
|
|
{ "wide", TOKEN_WIDE },
|
5033 |
|
|
{ "ppr", TOKEN_PPR },
|
5034 |
|
|
{ "verbose", TOKEN_VERBOSE },
|
5035 |
|
|
{ "debug", TOKEN_DEBUG },
|
5036 |
|
|
};
|
5037 |
|
|
|
5038 |
|
|
|
5039 |
|
|
/**************************************************************************
|
5040 |
|
|
* qla1280_setup
|
5041 |
|
|
*
|
5042 |
|
|
* Handle boot parameters. This really needs to be changed so one
|
5043 |
|
|
* can specify per adapter parameters.
|
5044 |
|
|
**************************************************************************/
|
5045 |
|
|
static int __init
|
5046 |
|
|
qla1280_setup(char *s)
|
5047 |
|
|
{
|
5048 |
|
|
char *cp, *ptr;
|
5049 |
|
|
unsigned long val;
|
5050 |
|
|
int toke;
|
5051 |
|
|
|
5052 |
|
|
cp = s;
|
5053 |
|
|
|
5054 |
|
|
while (cp && (ptr = strchr(cp, ':'))) {
|
5055 |
|
|
ptr++;
|
5056 |
|
|
if (!strcmp(ptr, "yes")) {
|
5057 |
|
|
val = 0x10000;
|
5058 |
|
|
ptr += 3;
|
5059 |
|
|
} else if (!strcmp(ptr, "no")) {
|
5060 |
|
|
val = 0;
|
5061 |
|
|
ptr += 2;
|
5062 |
|
|
} else
|
5063 |
|
|
val = simple_strtoul(ptr, &ptr, 0);
|
5064 |
|
|
|
5065 |
|
|
switch ((toke = qla1280_get_token(cp))) {
|
5066 |
|
|
case TOKEN_NVRAM:
|
5067 |
|
|
if (!val)
|
5068 |
|
|
driver_setup.no_nvram = 1;
|
5069 |
|
|
break;
|
5070 |
|
|
case TOKEN_SYNC:
|
5071 |
|
|
if (!val)
|
5072 |
|
|
driver_setup.no_sync = 1;
|
5073 |
|
|
else if (val != 0x10000)
|
5074 |
|
|
driver_setup.sync_mask = val;
|
5075 |
|
|
break;
|
5076 |
|
|
case TOKEN_WIDE:
|
5077 |
|
|
if (!val)
|
5078 |
|
|
driver_setup.no_wide = 1;
|
5079 |
|
|
else if (val != 0x10000)
|
5080 |
|
|
driver_setup.wide_mask = val;
|
5081 |
|
|
break;
|
5082 |
|
|
case TOKEN_PPR:
|
5083 |
|
|
if (!val)
|
5084 |
|
|
driver_setup.no_ppr = 1;
|
5085 |
|
|
else if (val != 0x10000)
|
5086 |
|
|
driver_setup.ppr_mask = val;
|
5087 |
|
|
break;
|
5088 |
|
|
case TOKEN_VERBOSE:
|
5089 |
|
|
qla1280_verbose = val;
|
5090 |
|
|
break;
|
5091 |
|
|
default:
|
5092 |
|
|
printk(KERN_INFO "qla1280: unknown boot option %s\n",
|
5093 |
|
|
cp);
|
5094 |
|
|
}
|
5095 |
|
|
|
5096 |
|
|
cp = strchr(ptr, ';');
|
5097 |
|
|
if (cp)
|
5098 |
|
|
cp++;
|
5099 |
|
|
else {
|
5100 |
|
|
break;
|
5101 |
|
|
}
|
5102 |
|
|
}
|
5103 |
|
|
return 1;
|
5104 |
|
|
}
|
5105 |
|
|
|
5106 |
|
|
|
5107 |
|
|
static int
|
5108 |
|
|
qla1280_get_token(char *str)
|
5109 |
|
|
{
|
5110 |
|
|
char *sep;
|
5111 |
|
|
long ret = -1;
|
5112 |
|
|
int i, len;
|
5113 |
|
|
|
5114 |
|
|
len = sizeof(setup_token)/sizeof(struct setup_tokens);
|
5115 |
|
|
|
5116 |
|
|
sep = strchr(str, ':');
|
5117 |
|
|
|
5118 |
|
|
if (sep) {
|
5119 |
|
|
for (i = 0; i < len; i++){
|
5120 |
|
|
|
5121 |
|
|
if (!strncmp(setup_token[i].token, str, (sep - str))) {
|
5122 |
|
|
ret = setup_token[i].val;
|
5123 |
|
|
break;
|
5124 |
|
|
}
|
5125 |
|
|
}
|
5126 |
|
|
}
|
5127 |
|
|
|
5128 |
|
|
return ret;
|
5129 |
|
|
}
|
5130 |
|
|
|
5131 |
|
|
|
5132 |
|
|
static Scsi_Host_Template driver_template = {
|
5133 |
|
|
.proc_info = qla1280_proc_info,
|
5134 |
|
|
.name = "Qlogic ISP 1280/12160",
|
5135 |
|
|
.detect = qla1280_detect,
|
5136 |
|
|
.release = qla1280_release,
|
5137 |
|
|
.info = qla1280_info,
|
5138 |
|
|
.queuecommand = qla1280_queuecommand,
|
5139 |
|
|
#if LINUX_VERSION_CODE >= 0x020545
|
5140 |
|
|
.slave_configure = qla1280_slave_configure,
|
5141 |
|
|
#endif
|
5142 |
|
|
.eh_abort_handler = qla1280_eh_abort,
|
5143 |
|
|
.eh_device_reset_handler= qla1280_eh_device_reset,
|
5144 |
|
|
.eh_bus_reset_handler = qla1280_eh_bus_reset,
|
5145 |
|
|
.eh_host_reset_handler = qla1280_eh_adapter_reset,
|
5146 |
|
|
.bios_param = qla1280_biosparam,
|
5147 |
|
|
.can_queue = 255,
|
5148 |
|
|
.this_id = -1,
|
5149 |
|
|
.sg_tablesize = SG_ALL,
|
5150 |
|
|
.cmd_per_lun = 3,
|
5151 |
|
|
.use_clustering = ENABLE_CLUSTERING,
|
5152 |
|
|
#if LINUX_VERSION_CODE < 0x020545
|
5153 |
|
|
.use_new_eh_code = 1,
|
5154 |
|
|
#endif
|
5155 |
|
|
};
|
5156 |
|
|
|
5157 |
|
|
#include "scsi_module.c"
|
5158 |
|
|
|
5159 |
|
|
|
5160 |
|
|
/*
|
5161 |
|
|
* Overrides for Emacs so that we almost follow Linus's tabbing style.
|
5162 |
|
|
* Emacs will notice this stuff at the end of the file and automatically
|
5163 |
|
|
* adjust the settings for this buffer only. This must remain at the end
|
5164 |
|
|
* of the file.
|
5165 |
|
|
* ---------------------------------------------------------------------------
|
5166 |
|
|
* Local variables:
|
5167 |
|
|
* c-basic-offset: 8
|
5168 |
|
|
* tab-width: 8
|
5169 |
|
|
* End:
|
5170 |
|
|
*/
|