History

Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (200 commits) [SCSI] usbstorage: use last_sector_bug flag universally [SCSI] libsas: abstract STP task status into a function [SCSI] ultrastor: clean up inline asm warnings [SCSI] aic7xxx: fix firmware build [SCSI] aacraid: fib context lock for management ioctls [SCSI] ch: remove forward declarations [SCSI] ch: fix device minor number management bug [SCSI] ch: handle class_device_create failure properly [SCSI] NCR5380: fix section mismatch [SCSI] sg: fix /proc/scsi/sg/devices when no SCSI devices [SCSI] IB/iSER: add logical unit reset support [SCSI] don't use __GFP_DMA for sense buffers if not required [SCSI] use dynamically allocated sense buffer [SCSI] scsi.h: add macro for enclosure bit of inquiry data [SCSI] sd: add fix for devices with last sector access problems [SCSI] fix pcmcia compile problem [SCSI] aacraid: add Voodoo Lite class of cards. [SCSI] aacraid: add new driver features flags [SCSI] qla2xxx: Update version number to 8.02.00-k7. [SCSI] qla2xxx: Issue correct MBC_INITIALIZE_FIRMWARE command. ...

Linus Torvalds committed 18 years ago

Commit 9b73e762 parents 50d9a12 23c3e29210 files · +10523 −9023Browse files

Unified · Split

210 files
  1. Documentation/DocBook/Makefile +1 −1
  2. Documentation/DocBook/scsi.tmpl +409 −0
  3. Documentation/dontdiff +0 −2
  4. Documentation/kernel-parameters.txt +7 −1
  5. Documentation/m68k/kernel-options.txt +0 −60
  6. Documentation/scsi/00-INDEX +0 −2
  7. Documentation/scsi/ChangeLog.megaraid_sas +159 −0
  8. Documentation/scsi/aacraid.txt +4 −0
  9. Documentation/scsi/hptiop.txt +21 −9
  10. Documentation/scsi/ncr53c7xx.txt +0 −40
  11. MAINTAINERS +4 −2
  12. block/bsg.c +12 −2
  13. block/ll_rw_blk.c +24 −0
  14. drivers/ata/libata-scsi.c +9 −2
  15. drivers/base/attribute_container.c +12 −2
  16. drivers/firewire/fw-sbp2.c +6 −0
  17. drivers/ieee1394/sbp2.c +6 −0
  18. drivers/infiniband/ulp/iser/iscsi_iser.c +7 −8
  19. drivers/infiniband/ulp/iser/iser_initiator.c +1 −3
  20. drivers/message/fusion/mptbase.c +52 −42
  21. drivers/message/fusion/mptbase.h +1 −1
  22. drivers/message/fusion/mptsas.c +2 −0
  23. drivers/message/fusion/mptscsih.c +1 −1
  24. drivers/message/i2o/i2o_scsi.c +1 −1
  25. drivers/s390/scsi/zfcp_aux.c +0 −2
  26. drivers/s390/scsi/zfcp_ccw.c +3 −0
  27. drivers/s390/scsi/zfcp_dbf.c +0 −6
  28. drivers/s390/scsi/zfcp_def.h +16 −6
  29. drivers/s390/scsi/zfcp_erp.c +7 −7
  30. drivers/s390/scsi/zfcp_fsf.c +35 −35
  31. drivers/s390/scsi/zfcp_scsi.c +11 −13
  32. drivers/scsi/.gitignore +0 −2
  33. drivers/scsi/3w-9xxx.c +1 −0
  34. drivers/scsi/53c700.c +6 −5
  35. drivers/scsi/BusLogic.c +1 −1
  36. drivers/scsi/Kconfig +3 −29
  37. drivers/scsi/Makefile +1 −4
  38. drivers/scsi/NCR5380.c +12 −11
  39. drivers/scsi/a2091.c +5 −31
  40. drivers/scsi/a3000.c +3 −12
  41. drivers/scsi/aacraid/aachba.c +215 −185
  42. drivers/scsi/aacraid/aacraid.h +174 −161
  43. drivers/scsi/aacraid/commctrl.c +58 −54
  44. drivers/scsi/aacraid/comminit.c +2 −2
  45. drivers/scsi/aacraid/commsup.c +239 −155
  46. drivers/scsi/aacraid/dpcsup.c +5 −5
  47. drivers/scsi/aacraid/linit.c +165 −77
  48. drivers/scsi/aacraid/rx.c +4 −2
  49. drivers/scsi/advansys.c +7 −7
  50. drivers/scsi/aha152x.c +8 −30
  51. drivers/scsi/aha1542.c +12 −37
  52. drivers/scsi/aha1740.c +1 −1
  53. drivers/scsi/aic7xxx/Makefile +18 −27
  54. drivers/scsi/aic7xxx/aic79xx_osm.c +3 −3
  55. drivers/scsi/aic7xxx/aic7xxx_osm.c +3 −3
  56. drivers/scsi/aic7xxx_old.c +5 −6
  57. drivers/scsi/aic94xx/aic94xx_dev.c +3 −3
  58. drivers/scsi/aic94xx/aic94xx_dump.c +2 −2
  59. drivers/scsi/aic94xx/aic94xx_hwi.c +1 −1
  60. drivers/scsi/aic94xx/aic94xx_hwi.h +3 −0
  61. drivers/scsi/aic94xx/aic94xx_init.c +187 −3
  62. drivers/scsi/aic94xx/aic94xx_scb.c +3 −3
  63. drivers/scsi/aic94xx/aic94xx_sds.c +389 −0
  64. drivers/scsi/aic94xx/aic94xx_sds.h +121 −0
  65. drivers/scsi/aic94xx/aic94xx_task.c +17 −33
  66. drivers/scsi/aic94xx/aic94xx_tmf.c +6 −6
  67. drivers/scsi/arcmsr/arcmsr_hba.c +3 −3
  68. drivers/scsi/atari_NCR5380.c +12 −12
  69. drivers/scsi/atp870u.c +17 −85
  70. drivers/scsi/ch.c +109 −106
  71. drivers/scsi/constants.c +1 −2
  72. drivers/scsi/dc395x.c +7 −9
  73. drivers/scsi/dpt_i2o.c +2 −3
  74. drivers/scsi/eata.c +2 −2
  75. drivers/scsi/eata_pio.c +6 −7
  76. drivers/scsi/fd_mcs.c +11 −25
  77. drivers/scsi/gdth.c +10 −12
  78. drivers/scsi/hosts.c +1 −3
  79. drivers/scsi/hptiop.c +464 −129
  80. drivers/scsi/hptiop.h +89 −35
  81. drivers/scsi/ibmvscsi/ibmvscsi.c +99 −56
  82. drivers/scsi/ibmvscsi/ibmvstgt.c +1 −1
  83. drivers/scsi/imm.c +5 −8
  84. drivers/scsi/in2000.c +5 −5
  85. drivers/scsi/ipr.c +1 −1
  86. drivers/scsi/ips.c +154 −172
  87. drivers/scsi/ips.h +14 −18
  88. drivers/scsi/iscsi_tcp.c +896 −1187
  89. drivers/scsi/iscsi_tcp.h +51 −83
  90. drivers/scsi/libiscsi.c +713 −378
  91. drivers/scsi/libsas/Kconfig +9 −0
  92. drivers/scsi/libsas/Makefile +3 −1
  93. drivers/scsi/libsas/sas_ata.c +1 −1
  94. drivers/scsi/libsas/sas_discover.c +1 −1
  95. drivers/scsi/libsas/sas_expander.c +26 −9
  96. drivers/scsi/libsas/sas_host_smp.c +274 −0
  97. drivers/scsi/libsas/sas_internal.h +15 −1
  98. drivers/scsi/libsas/sas_scsi_host.c +6 −3
  99. drivers/scsi/libsas/sas_task.c +36 −0
  100. drivers/scsi/libsrp.c +12 −11
  101. drivers/scsi/lpfc/lpfc.h +46 −7
  102. drivers/scsi/lpfc/lpfc_attr.c +191 −26
  103. drivers/scsi/lpfc/lpfc_crtn.h +14 −19
  104. drivers/scsi/lpfc/lpfc_ct.c +218 −86
  105. drivers/scsi/lpfc/lpfc_debugfs.c +127 −30
  106. drivers/scsi/lpfc/lpfc_disc.h +1 −1
  107. drivers/scsi/lpfc/lpfc_els.c +439 −184
  108. drivers/scsi/lpfc/lpfc_hbadisc.c +242 −130
  109. drivers/scsi/lpfc/lpfc_hw.h +99 −13
  110. drivers/scsi/lpfc/lpfc_init.c +318 −111
  111. drivers/scsi/lpfc/lpfc_logmsg.h +1 −0
  112. drivers/scsi/lpfc/lpfc_mbox.c +27 −5
  113. drivers/scsi/lpfc/lpfc_mem.c +1 −0
  114. drivers/scsi/lpfc/lpfc_nportdisc.c +132 −28
  115. drivers/scsi/lpfc/lpfc_scsi.c +37 −17
  116. drivers/scsi/lpfc/lpfc_scsi.h +1 −0
  117. drivers/scsi/lpfc/lpfc_sli.c +358 −176
  118. drivers/scsi/lpfc/lpfc_sli.h +5 −7
  119. drivers/scsi/lpfc/lpfc_version.h +3 −3
  120. drivers/scsi/lpfc/lpfc_vport.c +57 −36
  121. drivers/scsi/lpfc/lpfc_vport.h +1 −1
  122. drivers/scsi/megaraid.c +1 −1
  123. drivers/scsi/megaraid/megaraid_mbox.c +3 −3
  124. drivers/scsi/megaraid/megaraid_sas.c +448 −124
  125. drivers/scsi/megaraid/megaraid_sas.h +12 −6
  126. drivers/scsi/ncr53c8xx.c +2 −1
  127. drivers/scsi/pcmcia/Kconfig +2 −1
  128. drivers/scsi/pcmcia/nsp_cs.c +34 −20
  129. drivers/scsi/ppa.c +5 −7
  130. drivers/scsi/psi240i.c +0 −689
  131. drivers/scsi/psi240i.h +0 −315
  132. drivers/scsi/psi_chip.h +0 −195
  133. drivers/scsi/qla1280.c +2 −2
  134. drivers/scsi/qla2xxx/Makefile +1 −1
  135. drivers/scsi/qla2xxx/qla_attr.c +35 −19
  136. drivers/scsi/qla2xxx/qla_dbg.c +22 −15
  137. drivers/scsi/qla2xxx/qla_dbg.h +19 −0
  138. drivers/scsi/qla2xxx/qla_def.h +28 −24
  139. drivers/scsi/qla2xxx/qla_dfs.c +175 −0
  140. drivers/scsi/qla2xxx/qla_fw.h +24 −6
  141. drivers/scsi/qla2xxx/qla_gbl.h +21 −30
  142. drivers/scsi/qla2xxx/qla_init.c +70 −27
  143. drivers/scsi/qla2xxx/qla_isr.c +54 −66
  144. drivers/scsi/qla2xxx/qla_mbx.c +144 −286
  145. drivers/scsi/qla2xxx/qla_mid.c +20 −26
  146. drivers/scsi/qla2xxx/qla_os.c +29 −51
  147. drivers/scsi/qla2xxx/qla_sup.c +12 −6
  148. drivers/scsi/qla2xxx/qla_version.h +1 −1
  149. drivers/scsi/qla4xxx/ql4_init.c +3 −1
  150. drivers/scsi/qla4xxx/ql4_isr.c +4 −7
  151. drivers/scsi/qla4xxx/ql4_os.c +2 −5
  152. drivers/scsi/qlogicpti.c +8 −23
  153. drivers/scsi/scsi.c +168 −114
  154. drivers/scsi/scsi_debug.c +10 −27
  155. drivers/scsi/scsi_devinfo.c +15 −19
  156. drivers/scsi/scsi_error.c +64 −67
  157. drivers/scsi/scsi_ioctl.c +17 −9
  158. drivers/scsi/scsi_lib.c +72 −45
  159. drivers/scsi/scsi_netlink.c +7 −12
  160. drivers/scsi/scsi_proc.c +108 −2
  161. drivers/scsi/scsi_scan.c +23 −13
  162. drivers/scsi/scsi_sysfs.c +1 −0
  163. drivers/scsi/scsi_tgt_if.c +1 −1
  164. drivers/scsi/scsi_tgt_lib.c +13 −17
  165. drivers/scsi/scsi_transport_fc.c +46 −56
  166. drivers/scsi/scsi_transport_iscsi.c +185 −145
  167. drivers/scsi/scsi_transport_sas.c +22 −19
  168. drivers/scsi/scsi_transport_spi.c +176 −82
  169. drivers/scsi/scsi_transport_srp.c +6 −7
  170. drivers/scsi/scsicam.c +24 −11
  171. drivers/scsi/sd.c +33 −11
  172. drivers/scsi/seagate.c +0 −1667
  173. drivers/scsi/sg.c +16 −8
  174. drivers/scsi/sgiwd93.c +1 −0
  175. drivers/scsi/sr.c +24 −11
  176. drivers/scsi/sr.h +4 −0
  177. drivers/scsi/sr_ioctl.c +34 −14
  178. drivers/scsi/st.c +4 −5
  179. drivers/scsi/sun3_NCR5380.c +12 −12
  180. drivers/scsi/sym53c416.c +1 −15
  181. drivers/scsi/sym53c8xx_2/sym_glue.c +11 −11
  182. drivers/scsi/tmscsim.c +3 −3
  183. drivers/scsi/u14-34f.c +2 −2
  184. drivers/scsi/ultrastor.c +11 −4
  185. drivers/scsi/wd33c93.c +5 −5
  186. drivers/scsi/wd7000.c +6 −6
  187. drivers/usb/storage/freecom.c +6 −8
  188. drivers/usb/storage/isd200.c +46 −20
  189. drivers/usb/storage/protocol.c +53 −73
  190. drivers/usb/storage/scsiglue.c +14 −10
  191. drivers/usb/storage/sddr09.c +3 −6
  192. drivers/usb/storage/shuttle_usbat.c +26 −42
  193. drivers/usb/storage/transport.c +28 −17
  194. drivers/usb/storage/transport.h +2 −0
  195. fs/sysfs/file.c +9 −2
  196. fs/sysfs/group.c +16 −10
  197. include/linux/attribute_container.h +1 −0
  198. include/linux/blkdev.h +1 −0
  199. include/linux/sysfs.h +2 −0
  200. include/scsi/iscsi_if.h +20 −0
  201. include/scsi/iscsi_proto.h +13 −1
  202. include/scsi/libiscsi.h +65 −17
  203. include/scsi/libsas.h +14 −14
  204. include/scsi/sas.h +6 −7
  205. include/scsi/scsi_cmnd.h +1 −1
  206. include/scsi/scsi_device.h +9 −4
  207. include/scsi/scsi_transport_iscsi.h +7 −3
  208. include/scsi/scsi_transport_sas.h +5 −11
  209. include/scsi/sd.h +1 −0
  210. kernel/params.c +1 −1
Documentation/DocBook/Makefile+1−1
@@ -11,7 +11,7 @@ DOCBOOKS := wanbook.xml z8530book.xml mcabook.xml videobook.xml \ · 10 unmodified lines
11 procfs-guide.xml writing_usb_driver.xml \11 procfs-guide.xml writing_usb_driver.xml \
12 kernel-api.xml filesystems.xml lsm.xml usb.xml \12 kernel-api.xml filesystems.xml lsm.xml usb.xml \
13 gadget.xml libata.xml mtdnand.xml librs.xml rapidio.xml \13 gadget.xml libata.xml mtdnand.xml librs.xml rapidio.xml \
14 genericirq.xml s390-drivers.xml uio-howto.xml14 genericirq.xml s390-drivers.xml uio-howto.xml scsi.xml
15 15
16###16###
17# The build process is as follows (targets):17# The build process is as follows (targets):
Documentation/DocBook/scsi.tmpl+409−0
@@ -0,0 +1,409 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []>
4
5<book id="scsimid">
6 <bookinfo>
7 <title>SCSI Interfaces Guide</title>
8
9 <authorgroup>
10 <author>
11 <firstname>James</firstname>
12 <surname>Bottomley</surname>
13 <affiliation>
14 <address>
15 <email>James.Bottomley@steeleye.com</email>
16 </address>
17 </affiliation>
18 </author>
19
20 <author>
21 <firstname>Rob</firstname>
22 <surname>Landley</surname>
23 <affiliation>
24 <address>
25 <email>rob@landley.net</email>
26 </address>
27 </affiliation>
28 </author>
29
30 </authorgroup>
31
32 <copyright>
33 <year>2007</year>
34 <holder>Linux Foundation</holder>
35 </copyright>
36
37 <legalnotice>
38 <para>
39 This documentation is free software; you can redistribute
40 it and/or modify it under the terms of the GNU General Public
41 License version 2.
42 </para>
43
44 <para>
45 This program is distributed in the hope that it will be
46 useful, but WITHOUT ANY WARRANTY; without even the implied
47 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
48 For more details see the file COPYING in the source
49 distribution of Linux.
50 </para>
51 </legalnotice>
52 </bookinfo>
53
54 <toc></toc>
55
56 <chapter id="intro">
57 <title>Introduction</title>
58 <sect1 id="protocol_vs_bus">
59 <title>Protocol vs bus</title>
60 <para>
61 Once upon a time, the Small Computer Systems Interface defined both
62 a parallel I/O bus and a data protocol to connect a wide variety of
63 peripherals (disk drives, tape drives, modems, printers, scanners,
64 optical drives, test equipment, and medical devices) to a host
65 computer.
66 </para>
67 <para>
68 Although the old parallel (fast/wide/ultra) SCSI bus has largely
69 fallen out of use, the SCSI command set is more widely used than ever
70 to communicate with devices over a number of different busses.
71 </para>
72 <para>
73 The <ulink url='http://www.t10.org/scsi-3.htm'>SCSI protocol</ulink>
74 is a big-endian peer-to-peer packet based protocol. SCSI commands
75 are 6, 10, 12, or 16 bytes long, often followed by an associated data
76 payload.
77 </para>
78 <para>
79 SCSI commands can be transported over just about any kind of bus, and
80 are the default protocol for storage devices attached to USB, SATA,
81 SAS, Fibre Channel, FireWire, and ATAPI devices. SCSI packets are
82 also commonly exchanged over Infiniband,
83 <ulink url='http://i2o.shadowconnect.com/faq.php'>I20</ulink>, TCP/IP
84 (<ulink url='http://en.wikipedia.org/wiki/ISCSI'>iSCSI</ulink>), even
85 <ulink url='http://cyberelk.net/tim/parport/parscsi.html'>Parallel
86 ports</ulink>.
87 </para>
88 </sect1>
89 <sect1 id="subsystem_design">
90 <title>Design of the Linux SCSI subsystem</title>
91 <para>
92 The SCSI subsystem uses a three layer design, with upper, mid, and low
93 layers. Every operation involving the SCSI subsystem (such as reading
94 a sector from a disk) uses one driver at each of the 3 levels: one
95 upper layer driver, one lower layer driver, and the SCSI midlayer.
96 </para>
97 <para>
98 The SCSI upper layer provides the interface between userspace and the
99 kernel, in the form of block and char device nodes for I/O and
100 ioctl(). The SCSI lower layer contains drivers for specific hardware
101 devices.
102 </para>
103 <para>
104 In between is the SCSI mid-layer, analogous to a network routing
105 layer such as the IPv4 stack. The SCSI mid-layer routes a packet
106 based data protocol between the upper layer's /dev nodes and the
107 corresponding devices in the lower layer. It manages command queues,
108 provides error handling and power management functions, and responds
109 to ioctl() requests.
110 </para>
111 </sect1>
112 </chapter>
113
114 <chapter id="upper_layer">
115 <title>SCSI upper layer</title>
116 <para>
117 The upper layer supports the user-kernel interface by providing
118 device nodes.
119 </para>
120 <sect1 id="sd">
121 <title>sd (SCSI Disk)</title>
122 <para>sd (sd_mod.o)</para>
123<!-- !Idrivers/scsi/sd.c -->
124 </sect1>
125 <sect1 id="sr">
126 <title>sr (SCSI CD-ROM)</title>
127 <para>sr (sr_mod.o)</para>
128 </sect1>
129 <sect1 id="st">
130 <title>st (SCSI Tape)</title>
131 <para>st (st.o)</para>
132 </sect1>
133 <sect1 id="sg">
134 <title>sg (SCSI Generic)</title>
135 <para>sg (sg.o)</para>
136 </sect1>
137 <sect1 id="ch">
138 <title>ch (SCSI Media Changer)</title>
139 <para>ch (ch.c)</para>
140 </sect1>
141 </chapter>
142
143 <chapter id="mid_layer">
144 <title>SCSI mid layer</title>
145
146 <sect1 id="midlayer_implementation">
147 <title>SCSI midlayer implementation</title>
148 <sect2 id="scsi_device.h">
149 <title>include/scsi/scsi_device.h</title>
150 <para>
151 </para>
152!Iinclude/scsi/scsi_device.h
153 </sect2>
154
155 <sect2 id="scsi.c">
156 <title>drivers/scsi/scsi.c</title>
157 <para>Main file for the SCSI midlayer.</para>
158!Edrivers/scsi/scsi.c
159 </sect2>
160 <sect2 id="scsicam.c">
161 <title>drivers/scsi/scsicam.c</title>
162 <para>
163 <ulink url='http://www.t10.org/ftp/t10/drafts/cam/cam-r12b.pdf'>SCSI
164 Common Access Method</ulink> support functions, for use with
165 HDIO_GETGEO, etc.
166 </para>
167!Edrivers/scsi/scsicam.c
168 </sect2>
169 <sect2 id="scsi_error.c">
170 <title>drivers/scsi/scsi_error.c</title>
171 <para>Common SCSI error/timeout handling routines.</para>
172!Edrivers/scsi/scsi_error.c
173 </sect2>
174 <sect2 id="scsi_devinfo.c">
175 <title>drivers/scsi/scsi_devinfo.c</title>
176 <para>
177 Manage scsi_dev_info_list, which tracks blacklisted and whitelisted
178 devices.
179 </para>
180!Idrivers/scsi/scsi_devinfo.c
181 </sect2>
182 <sect2 id="scsi_ioctl.c">
183 <title>drivers/scsi/scsi_ioctl.c</title>
184 <para>
185 Handle ioctl() calls for SCSI devices.
186 </para>
187!Edrivers/scsi/scsi_ioctl.c
188 </sect2>
189 <sect2 id="scsi_lib.c">
190 <title>drivers/scsi/scsi_lib.c</title>
191 <para>
192 SCSI queuing library.
193 </para>
194!Edrivers/scsi/scsi_lib.c
195 </sect2>
196 <sect2 id="scsi_lib_dma.c">
197 <title>drivers/scsi/scsi_lib_dma.c</title>
198 <para>
199 SCSI library functions depending on DMA
200 (map and unmap scatter-gather lists).
201 </para>
202!Edrivers/scsi/scsi_lib_dma.c
203 </sect2>
204 <sect2 id="scsi_module.c">
205 <title>drivers/scsi/scsi_module.c</title>
206 <para>
207 The file drivers/scsi/scsi_module.c contains legacy support for
208 old-style host templates. It should never be used by any new driver.
209 </para>
210 </sect2>
211 <sect2 id="scsi_proc.c">
212 <title>drivers/scsi/scsi_proc.c</title>
213 <para>
214 The functions in this file provide an interface between
215 the PROC file system and the SCSI device drivers
216 It is mainly used for debugging, statistics and to pass
217 information directly to the lowlevel driver.
218
219 I.E. plumbing to manage /proc/scsi/*
220 </para>
221!Idrivers/scsi/scsi_proc.c
222 </sect2>
223 <sect2 id="scsi_netlink.c">
224 <title>drivers/scsi/scsi_netlink.c</title>
225 <para>
226 Infrastructure to provide async events from transports to userspace
227 via netlink, using a single NETLINK_SCSITRANSPORT protocol for all
228 transports.
229
230 See <ulink url='http://marc.info/?l=linux-scsi&amp;m=115507374832500&amp;w=2'>the
231 original patch submission</ulink> for more details.
232 </para>
233!Idrivers/scsi/scsi_netlink.c
234 </sect2>
235 <sect2 id="scsi_scan.c">
236 <title>drivers/scsi/scsi_scan.c</title>
237 <para>
238 Scan a host to determine which (if any) devices are attached.
239
240 The general scanning/probing algorithm is as follows, exceptions are
241 made to it depending on device specific flags, compilation options,
242 and global variable (boot or module load time) settings.
243
244 A specific LUN is scanned via an INQUIRY command; if the LUN has a
245 device attached, a scsi_device is allocated and setup for it.
246
247 For every id of every channel on the given host, start by scanning
248 LUN 0. Skip hosts that don't respond at all to a scan of LUN 0.
249 Otherwise, if LUN 0 has a device attached, allocate and setup a
250 scsi_device for it. If target is SCSI-3 or up, issue a REPORT LUN,
251 and scan all of the LUNs returned by the REPORT LUN; else,
252 sequentially scan LUNs up until some maximum is reached, or a LUN is
253 seen that cannot have a device attached to it.
254 </para>
255!Idrivers/scsi/scsi_scan.c
256 </sect2>
257 <sect2 id="scsi_sysctl.c">
258 <title>drivers/scsi/scsi_sysctl.c</title>
259 <para>
260 Set up the sysctl entry: "/dev/scsi/logging_level"
261 (DEV_SCSI_LOGGING_LEVEL) which sets/returns scsi_logging_level.
262 </para>
263 </sect2>
264 <sect2 id="scsi_sysfs.c">
265 <title>drivers/scsi/scsi_sysfs.c</title>
266 <para>
267 SCSI sysfs interface routines.
268 </para>
269!Edrivers/scsi/scsi_sysfs.c
270 </sect2>
271 <sect2 id="hosts.c">
272 <title>drivers/scsi/hosts.c</title>
273 <para>
274 mid to lowlevel SCSI driver interface
275 </para>
276!Edrivers/scsi/hosts.c
277 </sect2>
278 <sect2 id="constants.c">
279 <title>drivers/scsi/constants.c</title>
280 <para>
281 mid to lowlevel SCSI driver interface
282 </para>
283!Edrivers/scsi/constants.c
284 </sect2>
285 </sect1>
286
287 <sect1 id="Transport_classes">
288 <title>Transport classes</title>
289 <para>
290 Transport classes are service libraries for drivers in the SCSI
291 lower layer, which expose transport attributes in sysfs.
292 </para>
293 <sect2 id="Fibre_Channel_transport">
294 <title>Fibre Channel transport</title>
295 <para>
296 The file drivers/scsi/scsi_transport_fc.c defines transport attributes
297 for Fibre Channel.
298 </para>
299!Edrivers/scsi/scsi_transport_fc.c
300 </sect2>
301 <sect2 id="iSCSI_transport">
302 <title>iSCSI transport class</title>
303 <para>
304 The file drivers/scsi/scsi_transport_iscsi.c defines transport
305 attributes for the iSCSI class, which sends SCSI packets over TCP/IP
306 connections.
307 </para>
308!Edrivers/scsi/scsi_transport_iscsi.c
309 </sect2>
310 <sect2 id="SAS_transport">
311 <title>Serial Attached SCSI (SAS) transport class</title>
312 <para>
313 The file drivers/scsi/scsi_transport_sas.c defines transport
314 attributes for Serial Attached SCSI, a variant of SATA aimed at
315 large high-end systems.
316 </para>
317 <para>
318 The SAS transport class contains common code to deal with SAS HBAs,
319 an aproximated representation of SAS topologies in the driver model,
320 and various sysfs attributes to expose these topologies and managment
321 interfaces to userspace.
322 </para>
323 <para>
324 In addition to the basic SCSI core objects this transport class
325 introduces two additional intermediate objects: The SAS PHY
326 as represented by struct sas_phy defines an "outgoing" PHY on
327 a SAS HBA or Expander, and the SAS remote PHY represented by
328 struct sas_rphy defines an "incoming" PHY on a SAS Expander or
329 end device. Note that this is purely a software concept, the
330 underlying hardware for a PHY and a remote PHY is the exactly
331 the same.
332 </para>
333 <para>
334 There is no concept of a SAS port in this code, users can see
335 what PHYs form a wide port based on the port_identifier attribute,
336 which is the same for all PHYs in a port.
337 </para>
338!Edrivers/scsi/scsi_transport_sas.c
339 </sect2>
340 <sect2 id="SATA_transport">
341 <title>SATA transport class</title>
342 <para>
343 The SATA transport is handled by libata, which has its own book of
344 documentation in this directory.
345 </para>
346 </sect2>
347 <sect2 id="SPI_transport">
348 <title>Parallel SCSI (SPI) transport class</title>
349 <para>
350 The file drivers/scsi/scsi_transport_spi.c defines transport
351 attributes for traditional (fast/wide/ultra) SCSI busses.
352 </para>
353!Edrivers/scsi/scsi_transport_spi.c
354 </sect2>
355 <sect2 id="SRP_transport">
356 <title>SCSI RDMA (SRP) transport class</title>
357 <para>
358 The file drivers/scsi/scsi_transport_srp.c defines transport
359 attributes for SCSI over Remote Direct Memory Access.
360 </para>
361!Edrivers/scsi/scsi_transport_srp.c
362 </sect2>
363 </sect1>
364
365 </chapter>
366
367 <chapter id="lower_layer">
368 <title>SCSI lower layer</title>
369 <sect1 id="hba_drivers">
370 <title>Host Bus Adapter transport types</title>
371 <para>
372 Many modern device controllers use the SCSI command set as a protocol to
373 communicate with their devices through many different types of physical
374 connections.
375 </para>
376 <para>
377 In SCSI language a bus capable of carrying SCSI commands is
378 called a "transport", and a controller connecting to such a bus is
379 called a "host bus adapter" (HBA).
380 </para>
381 <sect2 id="scsi_debug.c">
382 <title>Debug transport</title>
383 <para>
384 The file drivers/scsi/scsi_debug.c simulates a host adapter with a
385 variable number of disks (or disk like devices) attached, sharing a
386 common amount of RAM. Does a lot of checking to make sure that we are
387 not getting blocks mixed up, and panics the kernel if anything out of
388 the ordinary is seen.
389 </para>
390 <para>
391 To be more realistic, the simulated devices have the transport
392 attributes of SAS disks.
393 </para>
394 <para>
395 For documentation see
396 <ulink url='http://www.torque.net/sg/sdebug26.html'>http://www.torque.net/sg/sdebug26.html</ulink>
397 </para>
398<!-- !Edrivers/scsi/scsi_debug.c -->
399 </sect2>
400 <sect2 id="todo">
401 <title>todo</title>
402 <para>Parallel (fast/wide/ultra) SCSI, USB, SATA,
403 SAS, Fibre Channel, FireWire, ATAPI devices, Infiniband,
404 I20, iSCSI, Parallel ports, netlink...
405 </para>
406 </sect2>
407 </sect1>
408 </chapter>
409</book>
Documentation/dontdiff+0−2
@@ -46,8 +46,6 @@ · 45 unmodified lines
46.mailmap46.mailmap
47.mm47.mm
4853c700_d.h4853c700_d.h
4953c7xx_d.h
5053c7xx_u.h
5153c8xx_d.h*4953c8xx_d.h*
52BitKeeper50BitKeeper
53COPYING51COPYING
Documentation/kernel-parameters.txt+7−1
@@ -1598,7 +1598,13 @@ and is between 256 and 4096 characters. It is defined in the file · 1597 unmodified lines
1598 Format: <vendor>:<model>:<flags>1598 Format: <vendor>:<model>:<flags>
1599 (flags are integer value)1599 (flags are integer value)
1600 1600
1601 scsi_logging= [SCSI]1601 scsi_logging_level= [SCSI] a bit mask of logging levels
1602 See drivers/scsi/scsi_logging.h for bits. Also
1603 settable via sysctl at dev.scsi.logging_level
1604 (/proc/sys/dev/scsi/logging_level).
1605 There is also a nice 'scsi_logging_level' script in the
1606 S390-tools package, available for download at
1607 http://www-128.ibm.com/developerworks/linux/linux390/s390-tools-1.5.4.html
1602 1608
1603 scsi_mod.scan= [SCSI] sync (default) scans SCSI busses as they are1609 scsi_mod.scan= [SCSI] sync (default) scans SCSI busses as they are
1604 discovered. async scans them in kernel threads,1610 discovered. async scans them in kernel threads,
Documentation/m68k/kernel-options.txt+0−60
@@ -867,66 +867,6 @@ controller and should be autodetected by the driver. An example is the · 866 unmodified lines
86724 bit region which is specified by a mask of 0x00fffffe.86724 bit region which is specified by a mask of 0x00fffffe.
868 868
869 869
8705.5) 53c7xx=
871------------
872
873Syntax: 53c7xx=<sub-options...>
874
875These options affect the A4000T, A4091, WarpEngine, Blizzard 603e+,
876and GForce 040/060 SCSI controllers on the Amiga, as well as the
877builtin MVME 16x SCSI controller.
878
879The <sub-options> is a comma-separated list of the sub-options listed
880below.
881
8825.5.1) nosync
883-------------
884
885Syntax: nosync:0
886
887 Disables sync negotiation for all devices. Any value after the
888 colon is acceptable (and has the same effect).
889
8905.5.2) noasync
891--------------
892
893[OBSOLETE, REMOVED]
894
8955.5.3) nodisconnect
896-------------------
897
898Syntax: nodisconnect:0
899
900 Disables SCSI disconnects. Any value after the colon is acceptable
901 (and has the same effect).
902
9035.5.4) validids
904---------------
905
906Syntax: validids:0xNN
907
908 Specify which SCSI ids the driver should pay attention to. This is
909 a bitmask (i.e. to only pay attention to ID#4, you'd use 0x10).
910 Default is 0x7f (devices 0-6).
911
9125.5.5) opthi
9135.5.6) optlo
914------------
915
916Syntax: opthi:M,optlo:N
917
918 Specify options for "hostdata->options". The acceptable definitions
919 are listed in drivers/scsi/53c7xx.h; the 32 high bits should be in
920 opthi and the 32 low bits in optlo. They must be specified in the
921 order opthi=M,optlo=N.
922
9235.5.7) next
924-----------
925
926 No argument. Used to separate blocks of keywords when there's more
927 than one 53c7xx host adapter in the system.
928
929
930/* Local Variables: */870/* Local Variables: */
931/* mode: text */871/* mode: text */
932/* End: */872/* End: */
Documentation/scsi/00-INDEX+0−2
@@ -64,8 +64,6 @@ lpfc.txt · 63 unmodified lines
64 - LPFC driver release notes64 - LPFC driver release notes
65megaraid.txt65megaraid.txt
66 - Common Management Module, shared code handling ioctls for LSI drivers66 - Common Management Module, shared code handling ioctls for LSI drivers
67ncr53c7xx.txt
68 - info on driver for NCR53c7xx based adapters
69ncr53c8xx.txt67ncr53c8xx.txt
70 - info on driver for NCR53c8xx based adapters68 - info on driver for NCR53c8xx based adapters
71osst.txt69osst.txt
Documentation/scsi/ChangeLog.megaraid_sas+159−0
@@ -1,3 +1,162 @@
11 Release Date : Thur. Nov. 07 16:30:43 PST 2007 -
2 (emaild-id:megaraidlinux@lsi.com)
3 Sumant Patro
4 Bo Yang
5
62 Current Version : 00.00.03.16
73 Older Version : 00.00.03.15
8
91. Increased MFI_POLL_TIMEOUT_SECS to 60 seconds from 10. FW may take
10 a max of 60 seconds to respond to the INIT cmd.
11
121 Release Date : Fri. Sep. 07 16:30:43 PST 2007 -
13 (emaild-id:megaraidlinux@lsi.com)
14 Sumant Patro
15 Bo Yang
16
172 Current Version : 00.00.03.15
183 Older Version : 00.00.03.14
19
201. Added module parameter "poll_mode_io" to support for "polling"
21 (reduced interrupt operation). In this mode, IO completion
22 interrupts are delayed. At the end of initiating IOs, the
23 driver schedules for cmd completion if there are pending cmds
24 to be completed. A timer-based interrupt has also been added
25 to prevent IO completion processing from being delayed
26 indefinitely in the case that no new IOs are initiated.
27
281 Release Date : Fri. Sep. 07 16:30:43 PST 2007 -
29 (emaild-id:megaraidlinux@lsi.com)
30 Sumant Patro
31 Bo Yang
32
332 Current Version : 00.00.03.14
343 Older Version : 00.00.03.13
35
361. Setting the max_sectors_per_req based on max SGL supported by the
37 FW. Prior versions calculated this value from controller info
38 (max_sectors_1, max_sectors_2). For certain controllers/FW,
39 this was resulting in a value greater than max SGL supported
40 by the FW. Issue was first reported by users running LUKS+XFS
41 with megaraid_sas. Thanks to RB for providing the logs and
42 duplication steps that helped to get to the root cause of the
43 issue. 2. Increased MFI_POLL_TIMEOUT_SECS to 60 seconds from
44 10. FW may take a max of 60 seconds to respond to the INIT
45 cmd.
46
471 Release Date : Fri. June. 15 16:30:43 PST 2007 -
48 (emaild-id:megaraidlinux@lsi.com)
49 Sumant Patro
50 Bo Yang
51
522 Current Version : 00.00.03.13
533 Older Version : 00.00.03.12
54
551. Added the megasas_reset_timer routine to intercept cmd timeout and throttle io.
56
57On Fri, 2007-03-16 at 16:44 -0600, James Bottomley wrote:
58It looks like megaraid_sas at least needs this to throttle its commands
59> as they begin to time out. The code keeps the existing transport
60> template use of eh_timed_out (and allows the transport to override the
61> host if they both have this callback).
62>
63> James
64
651 Release Date : Sat May. 12 16:30:43 PST 2007 -
66 (emaild-id:megaraidlinux@lsi.com)
67 Sumant Patro
68 Bo Yang
69
702 Current Version : 00.00.03.12
713 Older Version : 00.00.03.11
72
731. When MegaSAS driver receives reset call from OS, driver waits in reset
74routine for max 3 minutes for all pending command completion. Now driver will
75call completion routine every 5 seconds from the reset routine instead of
76waiting for depending on cmd completion from isr path.
77
781 Release Date : Mon Apr. 30 10:25:52 PST 2007 -
79 (emaild-id:megaraidlinux@lsi.com)
80 Sumant Patro
81 Bo Yang
82
832 Current Version : 00.00.03.11
843 Older Version : 00.00.03.09
85
86 1. Memory Manager for IOCTL removed for 2.6 kernels.
87 pci_alloc_consistent replaced by dma_alloc_coherent. With this
88 change there is no need of memory manager in the driver code
89
90 On Wed, 2007-02-07 at 13:30 -0800, Andrew Morton wrote:
91 > I suspect all this horror is due to stupidity in the DMA API.
92 >
93 > pci_alloc_consistent() just goes and assumes GFP_ATOMIC, whereas
94 > the caller (megasas_mgmt_fw_ioctl) would have been perfectly happy
95 > to use GFP_KERNEL.
96 >
97 > I bet this fixes it
98
99 It does, but the DMA API was expanded to cope with this exact case, so
100 use dma_alloc_coherent() directly in the megaraid code instead. The dev
101 is just &pci_dev->dev.
102
103 James <James.Bottomley@SteelEye.com>
104
105 3. SYNCHRONIZE_CACHE is not supported by FW and thus blocked by driver.
106 4. Hibernation support added
107 5. Performing diskdump while running IO in RHEL 4 was failing. Fixed.
108
1091 Release Date : Fri Feb. 09 14:36:28 PST 2007 -
110 (emaild-id:megaraidlinux@lsi.com)
111 Sumant Patro
112 Bo Yang
113
1142 Current Version : 00.00.03.09
1153 Older Version : 00.00.03.08
116
117i. Under heavy IO mid-layer prints "DRIVER_TIMEOUT" errors
118
119 The driver now waits for 10 seconds to elapse instead of 5 (as in
120 previous release) to resume IO.
121
1221 Release Date : Mon Feb. 05 11:35:24 PST 2007 -
123 (emaild-id:megaraidlinux@lsi.com)
124 Sumant Patro
125 Bo Yang
1262 Current Version : 00.00.03.08
1273 Older Version : 00.00.03.07
128
129i. Under heavy IO mid-layer prints "DRIVER_TIMEOUT" errors
130
131 Fix: The driver is now throttling IO.
132 Checks added in megasas_queue_command to know if FW is able to
133 process commands within timeout period. If number of retries
134 is 2 or greater,the driver stops sending cmd to FW temporarily. IO is
135 resumed if pending cmd count reduces to 16 or 5 seconds has elapsed
136 from the time cmds were last sent to FW.
137
138ii. FW enables WCE bit in Mode Sense cmd for drives that are configured
139 as WriteBack. The OS may send "SYNCHRONIZE_CACHE" cmd when Logical
140 Disks are exposed with WCE=1. User is advised to enable Write Back
141 mode only when the controller has battery backup. At this time
142 Synhronize cache is not supported by the FW. Driver will short-cycle
143 the cmd and return sucess without sending down to FW.
144
1451 Release Date : Sun Jan. 14 11:21:32 PDT 2007 -
146 Sumant Patro <Sumant.Patro@lsil.com>/Bo Yang
1472 Current Version : 00.00.03.07
1483 Older Version : 00.00.03.06
149
150i. bios_param entry added in scsi_host_template that returns disk geometry
151 information.
152
1531 Release Date : Fri Oct 20 11:21:32 PDT 2006 - Sumant Patro <Sumant.Patro@lsil.com>/Bo Yang
1542 Current Version : 00.00.03.06
1553 Older Version : 00.00.03.05
156
1571. Added new memory management module to support the IOCTL memory allocation. For IOCTL we try to allocate from the memory pool created during driver initialization. If mem pool is empty then we allocate at run time.
1582. Added check in megasas_queue_command and dpc/isr routine to see if we have already declared adapter dead
159 (hw_crit_error=1). If hw_crit_error==1, now we donot accept any processing of pending cmds/accept any cmd from OS
1 160
21 Release Date : Mon Oct 02 11:21:32 PDT 2006 - Sumant Patro <Sumant.Patro@lsil.com>1611 Release Date : Mon Oct 02 11:21:32 PDT 2006 - Sumant Patro <Sumant.Patro@lsil.com>
32 Current Version : 00.00.03.051622 Current Version : 00.00.03.05
Documentation/scsi/aacraid.txt+4−0
@@ -56,6 +56,10 @@ Supported Cards/Chipsets · 55 unmodified lines
56 9005:0285:9005:02d1 Adaptec 5405 (Voodoo40)56 9005:0285:9005:02d1 Adaptec 5405 (Voodoo40)
57 9005:0285:15d9:02d2 SMC AOC-USAS-S8i-LP57 9005:0285:15d9:02d2 SMC AOC-USAS-S8i-LP
58 9005:0285:15d9:02d3 SMC AOC-USAS-S8iR-LP58 9005:0285:15d9:02d3 SMC AOC-USAS-S8iR-LP
59 9005:0285:9005:02d4 Adaptec 2045 (Voodoo04 Lite)
60 9005:0285:9005:02d5 Adaptec 2405 (Voodoo40 Lite)
61 9005:0285:9005:02d6 Adaptec 2445 (Voodoo44 Lite)
62 9005:0285:9005:02d7 Adaptec 2805 (Voodoo80 Lite)
59 1011:0046:9005:0364 Adaptec 5400S (Mustang)63 1011:0046:9005:0364 Adaptec 5400S (Mustang)
60 9005:0287:9005:0800 Adaptec Themisto (Jupiter)64 9005:0287:9005:0800 Adaptec Themisto (Jupiter)
61 9005:0200:9005:0200 Adaptec Themisto (Jupiter)65 9005:0200:9005:0200 Adaptec Themisto (Jupiter)
Documentation/scsi/hptiop.txt+21−9
@@ -1,9 +1,9 @@
1HIGHPOINT ROCKETRAID 3xxx RAID DRIVER (hptiop)1HIGHPOINT ROCKETRAID 3xxx/4xxx ADAPTER DRIVER (hptiop)
2 2
3Controller Register Map3Controller Register Map
4-------------------------4-------------------------
5 5
6The controller IOP is accessed via PCI BAR0.6For Intel IOP based adapters, the controller IOP is accessed via PCI BAR0:
7 7
8 BAR0 offset Register8 BAR0 offset Register
9 0x10 Inbound Message Register 09 0x10 Inbound Message Register 0
@@ -18,6 +18,24 @@ The controller IOP is accessed via PCI BAR0. · 8 unmodified lines
18 0x40 Inbound Queue Port18 0x40 Inbound Queue Port
19 0x44 Outbound Queue Port19 0x44 Outbound Queue Port
20 20
21For Marvell IOP based adapters, the IOP is accessed via PCI BAR0 and BAR1:
22
23 BAR0 offset Register
24 0x20400 Inbound Doorbell Register
25 0x20404 Inbound Interrupt Mask Register
26 0x20408 Outbound Doorbell Register
27 0x2040C Outbound Interrupt Mask Register
28
29 BAR1 offset Register
30 0x0 Inbound Queue Head Pointer
31 0x4 Inbound Queue Tail Pointer
32 0x8 Outbound Queue Head Pointer
33 0xC Outbound Queue Tail Pointer
34 0x10 Inbound Message Register
35 0x14 Outbound Message Register
36 0x40-0x1040 Inbound Queue
37 0x1040-0x2040 Outbound Queue
38
21 39
22I/O Request Workflow40I/O Request Workflow
23----------------------41----------------------
@@ -73,15 +91,9 @@ The driver exposes following sysfs attributes: · 49 unmodified lines
73 driver-version R driver version string91 driver-version R driver version string
74 firmware-version R firmware version string92 firmware-version R firmware version string
75 93
76The driver registers char device "hptiop" to communicate with HighPoint RAID
77management software. Its ioctl routine acts as a general binary interface
78between the IOP firmware and HighPoint RAID management software. New management
79functions can be implemented in application/firmware without modification
80in driver code.
81
82 94
83-----------------------------------------------------------------------------95-----------------------------------------------------------------------------
84Copyright (C) 2006 HighPoint Technologies, Inc. All Rights Reserved.96Copyright (C) 2006-2007 HighPoint Technologies, Inc. All Rights Reserved.
85 97
86 This file is distributed in the hope that it will be useful,98 This file is distributed in the hope that it will be useful,
87 but WITHOUT ANY WARRANTY; without even the implied warranty of99 but WITHOUT ANY WARRANTY; without even the implied warranty of
Documentation/scsi/ncr53c7xx.txt+0−40
@@ -1,40 +0,0 @@
1README for WarpEngine/A4000T/A4091 SCSI kernels.
2
3Use the following options to disable options in the SCSI driver.
4
5Using amiboot for example.....
6
7To disable Synchronous Negotiation....
8
9 amiboot -k kernel 53c7xx=nosync:0
10
11To disable Disconnection....
12
13 amiboot -k kernel 53c7xx=nodisconnect:0
14
15To disable certain SCSI devices...
16
17 amiboot -k kernel 53c7xx=validids:0x3F
18
19 this allows only device ID's 0,1,2,3,4 and 5 for linux to handle.
20 (this is a bitmasked field - i.e. each bit represents a SCSI ID)
21
22These commands work on a per controller basis and use the option 'next' to
23move to the next controller in the system.
24
25e.g.
26 amiboot -k kernel 53c7xx=nodisconnect:0,next,nosync:0
27
28 this uses No Disconnection on the first controller and Asynchronous
29 SCSI on the second controller.
30
31Known Issues:
32
33Two devices are known not to function with the default settings of using
34synchronous SCSI. These are the Archive Viper 150 Tape Drive and the
35SyQuest SQ555 removeable hard drive. When using these devices on a controller
36use the 'nosync:0' option.
37
38Please try these options and post any problems/successes to me.
39
40Alan Hourihane <alanh@fairlite.demon.co.uk>
MAINTAINERS+4−2
@@ -3269,8 +3269,10 @@ W: http://www.ibm.com/developerworks/linux/linux390/ · 3268 unmodified lines
3269S: Supported3269S: Supported
3270 3270
3271S390 ZFCP DRIVER3271S390 ZFCP DRIVER
3272P: Swen Schillig3272P: Christof Schmitt
3273M: swen@vnet.ibm.com3273M: christof.schmitt@de.ibm.com
3274P: Martin Peschke
3275M: mp3@de.ibm.com
3274M: linux390@de.ibm.com3276M: linux390@de.ibm.com
3275L: linux-s390@vger.kernel.org3277L: linux-s390@vger.kernel.org
3276W: http://www.ibm.com/developerworks/linux/linux390/3278W: http://www.ibm.com/developerworks/linux/linux390/
block/bsg.c+12−2
@@ -445,6 +445,15 @@ static int blk_complete_sgv4_hdr_rq(struct request *rq, struct sg_io_v4 *hdr, · 444 unmodified lines
445 else445 else
446 hdr->dout_resid = rq->data_len;446 hdr->dout_resid = rq->data_len;
447 447
448 /*
449 * If the request generated a negative error number, return it
450 * (providing we aren't already returning an error); if it's
451 * just a protocol response (i.e. non negative), that gets
452 * processed above.
453 */
454 if (!ret && rq->errors < 0)
455 ret = rq->errors;
456
448 blk_rq_unmap_user(bio);457 blk_rq_unmap_user(bio);
449 blk_put_request(rq);458 blk_put_request(rq);
450 459
@@ -837,6 +846,7 @@ static long bsg_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · 386 unmodified lines
837{846{
838 struct bsg_device *bd = file->private_data;847 struct bsg_device *bd = file->private_data;
839 int __user *uarg = (int __user *) arg;848 int __user *uarg = (int __user *) arg;
849 int ret;
840 850
841 switch (cmd) {851 switch (cmd) {
842 /*852 /*
@@ -889,12 +899,12 @@ static long bsg_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · 46 unmodified lines
889 if (rq->next_rq)899 if (rq->next_rq)
890 bidi_bio = rq->next_rq->bio;900 bidi_bio = rq->next_rq->bio;
891 blk_execute_rq(bd->queue, NULL, rq, 0);901 blk_execute_rq(bd->queue, NULL, rq, 0);
892 blk_complete_sgv4_hdr_rq(rq, &hdr, bio, bidi_bio);902 ret = blk_complete_sgv4_hdr_rq(rq, &hdr, bio, bidi_bio);
893 903
894 if (copy_to_user(uarg, &hdr, sizeof(hdr)))904 if (copy_to_user(uarg, &hdr, sizeof(hdr)))
895 return -EFAULT;905 return -EFAULT;
896 906
897 return 0;907 return ret;
898 }908 }
899 /*909 /*
900 * block device ioctls910 * block device ioctls
block/ll_rw_blk.c+24−0
@@ -759,6 +759,30 @@ void blk_queue_dma_alignment(struct request_queue *q, int mask) · 758 unmodified lines
759 759
760EXPORT_SYMBOL(blk_queue_dma_alignment);760EXPORT_SYMBOL(blk_queue_dma_alignment);
761 761
762/**
763 * blk_queue_update_dma_alignment - update dma length and memory alignment
764 * @q: the request queue for the device
765 * @mask: alignment mask
766 *
767 * description:
768 * update required memory and length aligment for direct dma transactions.
769 * If the requested alignment is larger than the current alignment, then
770 * the current queue alignment is updated to the new value, otherwise it
771 * is left alone. The design of this is to allow multiple objects
772 * (driver, device, transport etc) to set their respective
773 * alignments without having them interfere.
774 *
775 **/
776void blk_queue_update_dma_alignment(struct request_queue *q, int mask)
777{
778 BUG_ON(mask > PAGE_SIZE);
779
780 if (mask > q->dma_alignment)
781 q->dma_alignment = mask;
782}
783
784EXPORT_SYMBOL(blk_queue_update_dma_alignment);
785
762/**786/**
763 * blk_queue_find_tag - find a request by its tag and queue787 * blk_queue_find_tag - find a request by its tag and queue
764 * @q: The request queue for the device788 * @q: The request queue for the device
drivers/ata/libata-scsi.c+9−2
@@ -839,7 +839,14 @@ static void ata_scsi_dev_config(struct scsi_device *sdev, · 838 unmodified lines
839 if (dev->class == ATA_DEV_ATAPI) {839 if (dev->class == ATA_DEV_ATAPI) {
840 struct request_queue *q = sdev->request_queue;840 struct request_queue *q = sdev->request_queue;
841 blk_queue_max_hw_segments(q, q->max_hw_segments - 1);841 blk_queue_max_hw_segments(q, q->max_hw_segments - 1);
842 }842
843 /* set the min alignment */
844 blk_queue_update_dma_alignment(sdev->request_queue,
845 ATA_DMA_PAD_SZ - 1);
846 } else
847 /* ATA devices must be sector aligned */
848 blk_queue_update_dma_alignment(sdev->request_queue,
849 ATA_SECT_SIZE - 1);
843 850
844 if (dev->class == ATA_DEV_ATA)851 if (dev->class == ATA_DEV_ATA)
845 sdev->manage_start_stop = 1;852 sdev->manage_start_stop = 1;
@@ -878,7 +885,7 @@ int ata_scsi_slave_config(struct scsi_device *sdev) · 32 unmodified lines
878 if (dev)885 if (dev)
879 ata_scsi_dev_config(sdev, dev);886 ata_scsi_dev_config(sdev, dev);
880 887
881 return 0; /* scsi layer doesn't check return value, sigh */888 return 0;
882}889}
883 890
884/**891/**
drivers/base/attribute_container.c+12−2
@@ -320,9 +320,14 @@ attribute_container_add_attrs(struct class_device *classdev) · 319 unmodified lines
320 struct class_device_attribute **attrs = cont->attrs;320 struct class_device_attribute **attrs = cont->attrs;
321 int i, error;321 int i, error;
322 322
323 if (!attrs)323 BUG_ON(attrs && cont->grp);
324
325 if (!attrs && !cont->grp)
324 return 0;326 return 0;
325 327
328 if (cont->grp)
329 return sysfs_create_group(&classdev->kobj, cont->grp);
330
326 for (i = 0; attrs[i]; i++) {331 for (i = 0; attrs[i]; i++) {
327 error = class_device_create_file(classdev, attrs[i]);332 error = class_device_create_file(classdev, attrs[i]);
328 if (error)333 if (error)
@@ -378,9 +383,14 @@ attribute_container_remove_attrs(struct class_device *classdev) · 49 unmodified lines
378 struct class_device_attribute **attrs = cont->attrs;383 struct class_device_attribute **attrs = cont->attrs;
379 int i;384 int i;
380 385
381 if (!attrs)386 if (!attrs && !cont->grp)
382 return;387 return;
383 388
389 if (cont->grp) {
390 sysfs_remove_group(&classdev->kobj, cont->grp);
391 return ;
392 }
393
384 for (i = 0; attrs[i]; i++)394 for (i = 0; attrs[i]; i++)
385 class_device_remove_file(classdev, attrs[i]);395 class_device_remove_file(classdev, attrs[i]);
386}396}
drivers/firewire/fw-sbp2.c+6−0
@@ -1238,6 +1238,12 @@ static int sbp2_scsi_slave_alloc(struct scsi_device *sdev) · 1237 unmodified lines
1238 1238
1239 sdev->allow_restart = 1;1239 sdev->allow_restart = 1;
1240 1240
1241 /*
1242 * Update the dma alignment (minimum alignment requirements for
1243 * start and end of DMA transfers) to be a sector
1244 */
1245 blk_queue_update_dma_alignment(sdev->request_queue, 511);
1246
1241 if (lu->tgt->workarounds & SBP2_WORKAROUND_INQUIRY_36)1247 if (lu->tgt->workarounds & SBP2_WORKAROUND_INQUIRY_36)
1242 sdev->inquiry_len = 36;1248 sdev->inquiry_len = 36;
1243 1249
drivers/ieee1394/sbp2.c+6−0
@@ -1963,6 +1963,12 @@ static int sbp2scsi_slave_alloc(struct scsi_device *sdev) · 1962 unmodified lines
1963 lu->sdev = sdev;1963 lu->sdev = sdev;
1964 sdev->allow_restart = 1;1964 sdev->allow_restart = 1;
1965 1965
1966 /*
1967 * Update the dma alignment (minimum alignment requirements for
1968 * start and end of DMA transfers) to be a sector
1969 */
1970 blk_queue_update_dma_alignment(sdev->request_queue, 511);
1971
1966 if (lu->workarounds & SBP2_WORKAROUND_INQUIRY_36)1972 if (lu->workarounds & SBP2_WORKAROUND_INQUIRY_36)
1967 sdev->inquiry_len = 36;1973 sdev->inquiry_len = 36;
1968 return 0;1974 return 0;
drivers/infiniband/ulp/iser/iscsi_iser.c+7−8
@@ -129,7 +129,7 @@ error: · 128 unmodified lines
129 * iscsi_iser_cmd_init - Initialize iSCSI SCSI_READ or SCSI_WRITE commands129 * iscsi_iser_cmd_init - Initialize iSCSI SCSI_READ or SCSI_WRITE commands
130 *130 *
131 **/131 **/
132static void132static int
133iscsi_iser_cmd_init(struct iscsi_cmd_task *ctask)133iscsi_iser_cmd_init(struct iscsi_cmd_task *ctask)
134{134{
135 struct iscsi_iser_conn *iser_conn = ctask->conn->dd_data;135 struct iscsi_iser_conn *iser_conn = ctask->conn->dd_data;
@@ -138,6 +138,7 @@ iscsi_iser_cmd_init(struct iscsi_cmd_task *ctask) · 2 unmodified lines
138 iser_ctask->command_sent = 0;138 iser_ctask->command_sent = 0;
139 iser_ctask->iser_conn = iser_conn;139 iser_ctask->iser_conn = iser_conn;
140 iser_ctask_rdma_init(iser_ctask);140 iser_ctask_rdma_init(iser_ctask);
141 return 0;
141}142}
142 143
143/**144/**
@@ -220,12 +221,6 @@ iscsi_iser_ctask_xmit(struct iscsi_conn *conn, · 76 unmodified lines
220 debug_scsi("ctask deq [cid %d itt 0x%x]\n",221 debug_scsi("ctask deq [cid %d itt 0x%x]\n",
221 conn->id, ctask->itt);222 conn->id, ctask->itt);
222 223
223 /*
224 * serialize with TMF AbortTask
225 */
226 if (ctask->mtask)
227 return error;
228
229 /* Send the cmd PDU */224 /* Send the cmd PDU */
230 if (!iser_ctask->command_sent) {225 if (!iser_ctask->command_sent) {
231 error = iser_send_command(conn, ctask);226 error = iser_send_command(conn, ctask);
@@ -406,6 +401,7 @@ iscsi_iser_session_create(struct iscsi_transport *iscsit, · 174 unmodified lines
406 ctask = session->cmds[i];401 ctask = session->cmds[i];
407 iser_ctask = ctask->dd_data;402 iser_ctask = ctask->dd_data;
408 ctask->hdr = (struct iscsi_cmd *)&iser_ctask->desc.iscsi_header;403 ctask->hdr = (struct iscsi_cmd *)&iser_ctask->desc.iscsi_header;
404 ctask->hdr_max = sizeof(iser_ctask->desc.iscsi_header);
409 }405 }
410 406
411 for (i = 0; i < session->mgmtpool_max; i++) {407 for (i = 0; i < session->mgmtpool_max; i++) {
@@ -557,6 +553,7 @@ static struct scsi_host_template iscsi_iser_sht = { · 145 unmodified lines
557 .max_sectors = 1024,553 .max_sectors = 1024,
558 .cmd_per_lun = ISCSI_MAX_CMD_PER_LUN,554 .cmd_per_lun = ISCSI_MAX_CMD_PER_LUN,
559 .eh_abort_handler = iscsi_eh_abort,555 .eh_abort_handler = iscsi_eh_abort,
556 .eh_device_reset_handler= iscsi_eh_device_reset,
560 .eh_host_reset_handler = iscsi_eh_host_reset,557 .eh_host_reset_handler = iscsi_eh_host_reset,
561 .use_clustering = DISABLE_CLUSTERING,558 .use_clustering = DISABLE_CLUSTERING,
562 .proc_name = "iscsi_iser",559 .proc_name = "iscsi_iser",
@@ -583,7 +580,9 @@ static struct iscsi_transport iscsi_iser_transport = { · 20 unmodified lines
583 ISCSI_PERSISTENT_ADDRESS |580 ISCSI_PERSISTENT_ADDRESS |
584 ISCSI_TARGET_NAME | ISCSI_TPGT |581 ISCSI_TARGET_NAME | ISCSI_TPGT |
585 ISCSI_USERNAME | ISCSI_PASSWORD |582 ISCSI_USERNAME | ISCSI_PASSWORD |
586 ISCSI_USERNAME_IN | ISCSI_PASSWORD_IN,583 ISCSI_USERNAME_IN | ISCSI_PASSWORD_IN |
584 ISCSI_FAST_ABORT | ISCSI_ABORT_TMO |
585 ISCSI_PING_TMO | ISCSI_RECV_TMO,
587 .host_param_mask = ISCSI_HOST_HWADDRESS |586 .host_param_mask = ISCSI_HOST_HWADDRESS |
588 ISCSI_HOST_NETDEV_NAME |587 ISCSI_HOST_NETDEV_NAME |
589 ISCSI_HOST_INITIATOR_NAME,588 ISCSI_HOST_INITIATOR_NAME,
drivers/infiniband/ulp/iser/iser_initiator.c+1−3
@@ -621,9 +621,7 @@ void iser_snd_completion(struct iser_desc *tx_desc) · 620 unmodified lines
621 struct iscsi_session *session = conn->session;621 struct iscsi_session *session = conn->session;
622 622
623 spin_lock(&conn->session->lock);623 spin_lock(&conn->session->lock);
624 list_del(&mtask->running);624 iscsi_free_mgmt_task(conn, mtask);
625 __kfifo_put(session->mgmtpool.queue, (void*)&mtask,
626 sizeof(void*));
627 spin_unlock(&session->lock);625 spin_unlock(&session->lock);
628 }626 }
629 }627 }
drivers/message/fusion/mptbase.c+52−42
@@ -2056,7 +2056,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag) · 2055 unmodified lines
2056 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT2056 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2057 "mpt_upload: alt_%s has cached_fw=%p \n",2057 "mpt_upload: alt_%s has cached_fw=%p \n",
2058 ioc->name, ioc->alt_ioc->name, ioc->alt_ioc->cached_fw));2058 ioc->name, ioc->alt_ioc->name, ioc->alt_ioc->cached_fw));
2059 ioc->alt_ioc->cached_fw = NULL;2059 ioc->cached_fw = NULL;
2060 }2060 }
2061 } else {2061 } else {
2062 printk(MYIOC_s_WARN_FMT2062 printk(MYIOC_s_WARN_FMT
@@ -2262,10 +2262,12 @@ mpt_adapter_disable(MPT_ADAPTER *ioc) · 199 unmodified lines
2262 int ret;2262 int ret;
2263 2263
2264 if (ioc->cached_fw != NULL) {2264 if (ioc->cached_fw != NULL) {
2265 ddlprintk(ioc, printk(MYIOC_s_INFO_FMT2265 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "%s: Pushing FW onto "
2266 "mpt_adapter_disable: Pushing FW onto adapter\n", ioc->name));2266 "adapter\n", __FUNCTION__, ioc->name));
2267 if ((ret = mpt_downloadboot(ioc, (MpiFwHeader_t *)ioc->cached_fw, NO_SLEEP)) < 0) {2267 if ((ret = mpt_downloadboot(ioc, (MpiFwHeader_t *)
2268 printk(MYIOC_s_WARN_FMT "firmware downloadboot failure (%d)!\n",2268 ioc->cached_fw, CAN_SLEEP)) < 0) {
2269 printk(MYIOC_s_WARN_FMT
2270 ": firmware downloadboot failure (%d)!\n",
2269 ioc->name, ret);2271 ioc->name, ret);
2270 }2272 }
2271 }2273 }
@@ -2303,13 +2305,7 @@ mpt_adapter_disable(MPT_ADAPTER *ioc) · 31 unmodified lines
2303 ioc->alloc_total -= sz;2305 ioc->alloc_total -= sz;
2304 }2306 }
2305 2307
2306 if (ioc->cached_fw != NULL) {2308 mpt_free_fw_memory(ioc);
2307 sz = ioc->facts.FWImageSize;
2308 pci_free_consistent(ioc->pcidev, sz,
2309 ioc->cached_fw, ioc->cached_fw_dma);
2310 ioc->cached_fw = NULL;
2311 ioc->alloc_total -= sz;
2312 }
2313 2309
2314 kfree(ioc->spi_data.nvram);2310 kfree(ioc->spi_data.nvram);
2315 mpt_inactive_raid_list_free(ioc);2311 mpt_inactive_raid_list_free(ioc);
@@ -3047,44 +3043,62 @@ SendPortEnable(MPT_ADAPTER *ioc, int portnum, int sleepFlag) · 731 unmodified lines
3047 *3043 *
3048 * If memory has already been allocated, the same (cached) value3044 * If memory has already been allocated, the same (cached) value
3049 * is returned.3045 * is returned.
3050 */3046 *
3051void3047 * Return 0 if successfull, or non-zero for failure
3048 **/
3049int
3052mpt_alloc_fw_memory(MPT_ADAPTER *ioc, int size)3050mpt_alloc_fw_memory(MPT_ADAPTER *ioc, int size)
3053{3051{
3054 if (ioc->cached_fw)3052 int rc;
3055 return; /* use already allocated memory */3053
3056 if (ioc->alt_ioc && ioc->alt_ioc->cached_fw) {3054 if (ioc->cached_fw) {
3055 rc = 0; /* use already allocated memory */
3056 goto out;
3057 }
3058 else if (ioc->alt_ioc && ioc->alt_ioc->cached_fw) {
3057 ioc->cached_fw = ioc->alt_ioc->cached_fw; /* use alt_ioc's memory */3059 ioc->cached_fw = ioc->alt_ioc->cached_fw; /* use alt_ioc's memory */
3058 ioc->cached_fw_dma = ioc->alt_ioc->cached_fw_dma;3060 ioc->cached_fw_dma = ioc->alt_ioc->cached_fw_dma;
3059 ioc->alloc_total += size;3061 rc = 0;
3060 ioc->alt_ioc->alloc_total -= size;3062 goto out;
3063 }
3064 ioc->cached_fw = pci_alloc_consistent(ioc->pcidev, size, &ioc->cached_fw_dma);
3065 if (!ioc->cached_fw) {
3066 printk(MYIOC_s_ERR_FMT "Unable to allocate memory for the cached firmware image!\n",
3067 ioc->name);
3068 rc = -1;
3061 } else {3069 } else {
3062 if ( (ioc->cached_fw = pci_alloc_consistent(ioc->pcidev, size, &ioc->cached_fw_dma) ) )3070 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "FW Image @ %p[%p], sz=%d[%x] bytes\n",
3063 ioc->alloc_total += size;3071 ioc->name, ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, size, size));
3072 ioc->alloc_total += size;
3073 rc = 0;
3064 }3074 }
3075 out:
3076 return rc;
3065}3077}
3078
3066/**3079/**
3067 * mpt_free_fw_memory - free firmware memory3080 * mpt_free_fw_memory - free firmware memory
3068 * @ioc: Pointer to MPT_ADAPTER structure3081 * @ioc: Pointer to MPT_ADAPTER structure
3069 *3082 *
3070 * If alt_img is NULL, delete from ioc structure.3083 * If alt_img is NULL, delete from ioc structure.
3071 * Else, delete a secondary image in same format.3084 * Else, delete a secondary image in same format.
3072 */3085 **/
3073void3086void
3074mpt_free_fw_memory(MPT_ADAPTER *ioc)3087mpt_free_fw_memory(MPT_ADAPTER *ioc)
3075{3088{
3076 int sz;3089 int sz;
3077 3090
3091 if (!ioc->cached_fw)
3092 return;
3093
3078 sz = ioc->facts.FWImageSize;3094 sz = ioc->facts.FWImageSize;
3079 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT "free_fw_memory: FW Image @ %p[%p], sz=%d[%x] bytes\n",3095 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "free_fw_memory: FW Image @ %p[%p], sz=%d[%x] bytes\n",
3080 ioc->name, ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, sz, sz));3096 ioc->name, ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, sz, sz));
3081 pci_free_consistent(ioc->pcidev, sz, ioc->cached_fw, ioc->cached_fw_dma);3097 pci_free_consistent(ioc->pcidev, sz, ioc->cached_fw, ioc->cached_fw_dma);
3098 ioc->alloc_total -= sz;
3082 ioc->cached_fw = NULL;3099 ioc->cached_fw = NULL;
3083
3084 return;
3085}3100}
3086 3101
3087
3088/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/3102/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3089/**3103/**
3090 * mpt_do_upload - Construct and Send FWUpload request to MPT adapter port.3104 * mpt_do_upload - Construct and Send FWUpload request to MPT adapter port.
@@ -3116,17 +3130,12 @@ mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag) · 25 unmodified lines
3116 if ((sz = ioc->facts.FWImageSize) == 0)3130 if ((sz = ioc->facts.FWImageSize) == 0)
3117 return 0;3131 return 0;
3118 3132
3119 mpt_alloc_fw_memory(ioc, sz);3133 if (mpt_alloc_fw_memory(ioc, ioc->facts.FWImageSize) != 0)
3134 return -ENOMEM;
3120 3135
3121 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT ": FW Image @ %p[%p], sz=%d[%x] bytes\n",3136 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT ": FW Image @ %p[%p], sz=%d[%x] bytes\n",
3122 ioc->name, ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, sz, sz));3137 ioc->name, ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, sz, sz));
3123 3138
3124 if (ioc->cached_fw == NULL) {
3125 /* Major Failure.
3126 */
3127 return -ENOMEM;
3128 }
3129
3130 prequest = (sleepFlag == NO_SLEEP) ? kzalloc(ioc->req_sz, GFP_ATOMIC) :3139 prequest = (sleepFlag == NO_SLEEP) ? kzalloc(ioc->req_sz, GFP_ATOMIC) :
3131 kzalloc(ioc->req_sz, GFP_KERNEL);3140 kzalloc(ioc->req_sz, GFP_KERNEL);
3132 if (!prequest) {3141 if (!prequest) {
@@ -3498,12 +3507,12 @@ KickStart(MPT_ADAPTER *ioc, int force, int sleepFlag) · 365 unmodified lines
3498static int3507static int
3499mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)3508mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3500{3509{
3501 MPT_ADAPTER *iocp=NULL;
3502 u32 diag0val;3510 u32 diag0val;
3503 u32 doorbell;3511 u32 doorbell;
3504 int hard_reset_done = 0;3512 int hard_reset_done = 0;
3505 int count = 0;3513 int count = 0;
3506 u32 diag1val = 0;3514 u32 diag1val = 0;
3515 MpiFwHeader_t *cached_fw; /* Pointer to FW */
3507 3516
3508 /* Clear any existing interrupts */3517 /* Clear any existing interrupts */
3509 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0);3518 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0);
@@ -3635,22 +3644,24 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag) · 125 unmodified lines
3635 }3644 }
3636 3645
3637 if (ioc->cached_fw)3646 if (ioc->cached_fw)
3638 iocp = ioc;3647 cached_fw = (MpiFwHeader_t *)ioc->cached_fw;
3639 else if (ioc->alt_ioc && ioc->alt_ioc->cached_fw)3648 else if (ioc->alt_ioc && ioc->alt_ioc->cached_fw)
3640 iocp = ioc->alt_ioc;3649 cached_fw = (MpiFwHeader_t *)ioc->alt_ioc->cached_fw;
3641 if (iocp) {3650 else
3651 cached_fw = NULL;
3652 if (cached_fw) {
3642 /* If the DownloadBoot operation fails, the3653 /* If the DownloadBoot operation fails, the
3643 * IOC will be left unusable. This is a fatal error3654 * IOC will be left unusable. This is a fatal error
3644 * case. _diag_reset will return < 03655 * case. _diag_reset will return < 0
3645 */3656 */
3646 for (count = 0; count < 30; count ++) {3657 for (count = 0; count < 30; count ++) {
3647 diag0val = CHIPREG_READ32(&iocp->chip->Diagnostic);3658 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic);
3648 if (!(diag0val & MPI_DIAG_RESET_ADAPTER)) {3659 if (!(diag0val & MPI_DIAG_RESET_ADAPTER)) {
3649 break;3660 break;
3650 }3661 }
3651 3662
3652 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "cached_fw: diag0val=%x count=%d\n",3663 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "cached_fw: diag0val=%x count=%d\n",
3653 iocp->name, diag0val, count));3664 ioc->name, diag0val, count));
3654 /* wait 1 sec */3665 /* wait 1 sec */
3655 if (sleepFlag == CAN_SLEEP) {3666 if (sleepFlag == CAN_SLEEP) {
3656 msleep (1000);3667 msleep (1000);
@@ -3658,8 +3669,7 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag) · 1 unmodified line
3658 mdelay (1000);3669 mdelay (1000);
3659 }3670 }
3660 }3671 }
3661 if ((count = mpt_downloadboot(ioc,3672 if ((count = mpt_downloadboot(ioc, cached_fw, sleepFlag)) < 0) {
3662 (MpiFwHeader_t *)iocp->cached_fw, sleepFlag)) < 0) {
3663 printk(MYIOC_s_WARN_FMT3673 printk(MYIOC_s_WARN_FMT
3664 "firmware downloadboot failure (%d)!\n", ioc->name, count);3674 "firmware downloadboot failure (%d)!\n", ioc->name, count);
3665 }3675 }
drivers/message/fusion/mptbase.h+1−1
@@ -907,7 +907,7 @@ extern u32 mpt_GetIocState(MPT_ADAPTER *ioc, int cooked); · 906 unmodified lines
907extern void mpt_print_ioc_summary(MPT_ADAPTER *ioc, char *buf, int *size, int len, int showlan);907extern void mpt_print_ioc_summary(MPT_ADAPTER *ioc, char *buf, int *size, int len, int showlan);
908extern int mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag);908extern int mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag);
909extern int mpt_config(MPT_ADAPTER *ioc, CONFIGPARMS *cfg);909extern int mpt_config(MPT_ADAPTER *ioc, CONFIGPARMS *cfg);
910extern void mpt_alloc_fw_memory(MPT_ADAPTER *ioc, int size);910extern int mpt_alloc_fw_memory(MPT_ADAPTER *ioc, int size);
911extern void mpt_free_fw_memory(MPT_ADAPTER *ioc);911extern void mpt_free_fw_memory(MPT_ADAPTER *ioc);
912extern int mpt_findImVolumes(MPT_ADAPTER *ioc);912extern int mpt_findImVolumes(MPT_ADAPTER *ioc);
913extern int mptbase_sas_persist_operation(MPT_ADAPTER *ioc, u8 persist_opcode);913extern int mptbase_sas_persist_operation(MPT_ADAPTER *ioc, u8 persist_opcode);
drivers/message/fusion/mptsas.c+2−0
@@ -1343,6 +1343,8 @@ static int mptsas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, · 1342 unmodified lines
1343 smprep = (SmpPassthroughReply_t *)ioc->sas_mgmt.reply;1343 smprep = (SmpPassthroughReply_t *)ioc->sas_mgmt.reply;
1344 memcpy(req->sense, smprep, sizeof(*smprep));1344 memcpy(req->sense, smprep, sizeof(*smprep));
1345 req->sense_len = sizeof(*smprep);1345 req->sense_len = sizeof(*smprep);
1346 req->data_len = 0;
1347 rsp->data_len -= smprep->ResponseDataLength;
1346 } else {1348 } else {
1347 printk(MYIOC_s_ERR_FMT "%s: smp passthru reply failed to be returned\n",1349 printk(MYIOC_s_ERR_FMT "%s: smp passthru reply failed to be returned\n",
1348 ioc->name, __FUNCTION__);1350 ioc->name, __FUNCTION__);
drivers/message/fusion/mptscsih.c+1−1
@@ -111,7 +111,7 @@ int mptscsih_suspend(struct pci_dev *pdev, pm_message_t state); · 110 unmodified lines
111int mptscsih_resume(struct pci_dev *pdev);111int mptscsih_resume(struct pci_dev *pdev);
112#endif112#endif
113 113
114#define SNS_LEN(scp) sizeof((scp)->sense_buffer)114#define SNS_LEN(scp) SCSI_SENSE_BUFFERSIZE
115 115
116/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/116/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
117/**117/**
drivers/message/i2o/i2o_scsi.c+1−1
@@ -370,7 +370,7 @@ static int i2o_scsi_reply(struct i2o_controller *c, u32 m, · 369 unmodified lines
370 */370 */
371 if (cmd->result)371 if (cmd->result)
372 memcpy(cmd->sense_buffer, &msg->body[3],372 memcpy(cmd->sense_buffer, &msg->body[3],
373 min(sizeof(cmd->sense_buffer), (size_t) 40));373 min(SCSI_SENSE_BUFFERSIZE, 40));
374 374
375 /* only output error code if AdapterStatus is not HBA_SUCCESS */375 /* only output error code if AdapterStatus is not HBA_SUCCESS */
376 if ((error >> 8) & 0xff)376 if ((error >> 8) & 0xff)
drivers/s390/scsi/zfcp_aux.c+0−2
@@ -844,8 +844,6 @@ zfcp_unit_enqueue(struct zfcp_port *port, fcp_lun_t fcp_lun) · 843 unmodified lines
844 unit->sysfs_device.release = zfcp_sysfs_unit_release;844 unit->sysfs_device.release = zfcp_sysfs_unit_release;
845 dev_set_drvdata(&unit->sysfs_device, unit);845 dev_set_drvdata(&unit->sysfs_device, unit);
846 846
847 init_waitqueue_head(&unit->scsi_scan_wq);
848
849 /* mark unit unusable as long as sysfs registration is not complete */847 /* mark unit unusable as long as sysfs registration is not complete */
850 atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &unit->status);848 atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &unit->status);
851 849
drivers/s390/scsi/zfcp_ccw.c+3−0
@@ -123,6 +123,9 @@ zfcp_ccw_remove(struct ccw_device *ccw_device) · 122 unmodified lines
123 123
124 list_for_each_entry_safe(port, p, &adapter->port_remove_lh, list) {124 list_for_each_entry_safe(port, p, &adapter->port_remove_lh, list) {
125 list_for_each_entry_safe(unit, u, &port->unit_remove_lh, list) {125 list_for_each_entry_safe(unit, u, &port->unit_remove_lh, list) {
126 if (atomic_test_mask(ZFCP_STATUS_UNIT_REGISTERED,
127 &unit->status))
128 scsi_remove_device(unit->device);
126 zfcp_unit_dequeue(unit);129 zfcp_unit_dequeue(unit);
127 }130 }
128 zfcp_port_dequeue(port);131 zfcp_port_dequeue(port);
drivers/s390/scsi/zfcp_dbf.c+0−6
@@ -161,12 +161,6 @@ void zfcp_hba_dbf_event_fsf_response(struct zfcp_fsf_req *fsf_req) · 160 unmodified lines
161 (fsf_req->fsf_command == FSF_QTCB_OPEN_LUN)) {161 (fsf_req->fsf_command == FSF_QTCB_OPEN_LUN)) {
162 strncpy(rec->tag2, "open", ZFCP_DBF_TAG_SIZE);162 strncpy(rec->tag2, "open", ZFCP_DBF_TAG_SIZE);
163 level = 4;163 level = 4;
164 } else if ((prot_status_qual->doubleword[0] != 0) ||
165 (prot_status_qual->doubleword[1] != 0) ||
166 (fsf_status_qual->doubleword[0] != 0) ||
167 (fsf_status_qual->doubleword[1] != 0)) {
168 strncpy(rec->tag2, "qual", ZFCP_DBF_TAG_SIZE);
169 level = 3;
170 } else {164 } else {
171 strncpy(rec->tag2, "norm", ZFCP_DBF_TAG_SIZE);165 strncpy(rec->tag2, "norm", ZFCP_DBF_TAG_SIZE);
172 level = 6;166 level = 6;
drivers/s390/scsi/zfcp_def.h+16−6
@@ -118,7 +118,7 @@ zfcp_address_to_sg(void *address, struct scatterlist *list, unsigned int size) · 117 unmodified lines
118 118
119#define ZFCP_SBAL_TIMEOUT (5*HZ)119#define ZFCP_SBAL_TIMEOUT (5*HZ)
120 120
121#define ZFCP_TYPE2_RECOVERY_TIME (8*HZ)121#define ZFCP_TYPE2_RECOVERY_TIME 8 /* seconds */
122 122
123/* queue polling (values in microseconds) */123/* queue polling (values in microseconds) */
124#define ZFCP_MAX_INPUT_THRESHOLD 5000 /* FIXME: tune */124#define ZFCP_MAX_INPUT_THRESHOLD 5000 /* FIXME: tune */
@@ -139,7 +139,7 @@ zfcp_address_to_sg(void *address, struct scatterlist *list, unsigned int size) · 14 unmodified lines
139#define ZFCP_STATUS_READS_RECOM FSF_STATUS_READS_RECOM139#define ZFCP_STATUS_READS_RECOM FSF_STATUS_READS_RECOM
140 140
141/* Do 1st retry in 1 second, then double the timeout for each following retry */141/* Do 1st retry in 1 second, then double the timeout for each following retry */
142#define ZFCP_EXCHANGE_CONFIG_DATA_FIRST_SLEEP 100142#define ZFCP_EXCHANGE_CONFIG_DATA_FIRST_SLEEP 1
143#define ZFCP_EXCHANGE_CONFIG_DATA_RETRIES 7143#define ZFCP_EXCHANGE_CONFIG_DATA_RETRIES 7
144 144
145/* timeout value for "default timer" for fsf requests */145/* timeout value for "default timer" for fsf requests */
@@ -983,10 +983,6 @@ struct zfcp_unit { · 837 unmodified lines
983 struct scsi_device *device; /* scsi device struct pointer */983 struct scsi_device *device; /* scsi device struct pointer */
984 struct zfcp_erp_action erp_action; /* pending error recovery */984 struct zfcp_erp_action erp_action; /* pending error recovery */
985 atomic_t erp_counter;985 atomic_t erp_counter;
986 wait_queue_head_t scsi_scan_wq; /* can be used to wait until
987 all scsi_scan_target
988 requests have been
989 completed. */
990};986};
991 987
992/* FSF request */988/* FSF request */
@@ -1127,6 +1123,20 @@ zfcp_reqlist_find(struct zfcp_adapter *adapter, unsigned long req_id) · 134 unmodified lines
1127 return NULL;1123 return NULL;
1128}1124}
1129 1125
1126static inline struct zfcp_fsf_req *
1127zfcp_reqlist_find_safe(struct zfcp_adapter *adapter, struct zfcp_fsf_req *req)
1128{
1129 struct zfcp_fsf_req *request;
1130 unsigned int idx;
1131
1132 for (idx = 0; idx < REQUEST_LIST_SIZE; idx++) {
1133 list_for_each_entry(request, &adapter->req_list[idx], list)
1134 if (request == req)
1135 return request;
1136 }
1137 return NULL;
1138}
1139
1130/*1140/*
1131 * functions needed for reference/usage counting1141 * functions needed for reference/usage counting
1132 */1142 */
drivers/s390/scsi/zfcp_erp.c+7−7
@@ -131,7 +131,7 @@ static void zfcp_close_qdio(struct zfcp_adapter *adapter) · 130 unmodified lines
131 debug_text_event(adapter->erp_dbf, 3, "qdio_down2a");131 debug_text_event(adapter->erp_dbf, 3, "qdio_down2a");
132 while (qdio_shutdown(adapter->ccw_device,132 while (qdio_shutdown(adapter->ccw_device,
133 QDIO_FLAG_CLEANUP_USING_CLEAR) == -EINPROGRESS)133 QDIO_FLAG_CLEANUP_USING_CLEAR) == -EINPROGRESS)
134 msleep(1000);134 ssleep(1);
135 debug_text_event(adapter->erp_dbf, 3, "qdio_down2b");135 debug_text_event(adapter->erp_dbf, 3, "qdio_down2b");
136 136
137 /* cleanup used outbound sbals */137 /* cleanup used outbound sbals */
@@ -456,7 +456,7 @@ zfcp_test_link(struct zfcp_port *port) · 318 unmodified lines
456 456
457 zfcp_port_get(port);457 zfcp_port_get(port);
458 retval = zfcp_erp_adisc(port);458 retval = zfcp_erp_adisc(port);
459 if (retval != 0) {459 if (retval != 0 && retval != -EBUSY) {
460 zfcp_port_put(port);460 zfcp_port_put(port);
461 ZFCP_LOG_NORMAL("reopen needed for port 0x%016Lx "461 ZFCP_LOG_NORMAL("reopen needed for port 0x%016Lx "
462 "on adapter %s\n ", port->wwpn,462 "on adapter %s\n ", port->wwpn,
@@ -846,7 +846,8 @@ zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action *erp_action) · 383 unmodified lines
846 if (erp_action->fsf_req) {846 if (erp_action->fsf_req) {
847 /* take lock to ensure that request is not deleted meanwhile */847 /* take lock to ensure that request is not deleted meanwhile */
848 spin_lock(&adapter->req_list_lock);848 spin_lock(&adapter->req_list_lock);
849 if (zfcp_reqlist_find(adapter, erp_action->fsf_req->req_id)) {849 if (zfcp_reqlist_find_safe(adapter, erp_action->fsf_req) &&
850 erp_action->fsf_req->erp_action == erp_action) {
850 /* fsf_req still exists */851 /* fsf_req still exists */
851 debug_text_event(adapter->erp_dbf, 3, "a_ca_req");852 debug_text_event(adapter->erp_dbf, 3, "a_ca_req");
852 debug_event(adapter->erp_dbf, 3, &erp_action->fsf_req,853 debug_event(adapter->erp_dbf, 3, &erp_action->fsf_req,
@@ -1609,7 +1610,6 @@ static void zfcp_erp_scsi_scan(struct work_struct *work) · 756 unmodified lines
1609 scsi_scan_target(&rport->dev, 0, rport->scsi_target_id,1610 scsi_scan_target(&rport->dev, 0, rport->scsi_target_id,
1610 unit->scsi_lun, 0);1611 unit->scsi_lun, 0);
1611 atomic_clear_mask(ZFCP_STATUS_UNIT_SCSI_WORK_PENDING, &unit->status);1612 atomic_clear_mask(ZFCP_STATUS_UNIT_SCSI_WORK_PENDING, &unit->status);
1612 wake_up(&unit->scsi_scan_wq);
1613 zfcp_unit_put(unit);1613 zfcp_unit_put(unit);
1614 kfree(p);1614 kfree(p);
1615}1615}
@@ -1900,7 +1900,7 @@ zfcp_erp_adapter_strategy(struct zfcp_erp_action *erp_action) · 284 unmodified lines
1900 ZFCP_LOG_INFO("Waiting to allow the adapter %s "1900 ZFCP_LOG_INFO("Waiting to allow the adapter %s "
1901 "to recover itself\n",1901 "to recover itself\n",
1902 zfcp_get_busid_by_adapter(adapter));1902 zfcp_get_busid_by_adapter(adapter));
1903 msleep(jiffies_to_msecs(ZFCP_TYPE2_RECOVERY_TIME));1903 ssleep(ZFCP_TYPE2_RECOVERY_TIME);
1904 }1904 }
1905 1905
1906 return retval;1906 return retval;
@@ -2080,7 +2080,7 @@ zfcp_erp_adapter_strategy_open_qdio(struct zfcp_erp_action *erp_action) · 173 unmodified lines
2080 debug_text_event(adapter->erp_dbf, 3, "qdio_down1a");2080 debug_text_event(adapter->erp_dbf, 3, "qdio_down1a");
2081 while (qdio_shutdown(adapter->ccw_device,2081 while (qdio_shutdown(adapter->ccw_device,
2082 QDIO_FLAG_CLEANUP_USING_CLEAR) == -EINPROGRESS)2082 QDIO_FLAG_CLEANUP_USING_CLEAR) == -EINPROGRESS)
2083 msleep(1000);2083 ssleep(1);
2084 debug_text_event(adapter->erp_dbf, 3, "qdio_down1b");2084 debug_text_event(adapter->erp_dbf, 3, "qdio_down1b");
2085 2085
2086 failed_qdio_establish:2086 failed_qdio_establish:
@@ -2165,7 +2165,7 @@ zfcp_erp_adapter_strategy_open_fsf_xconfig(struct zfcp_erp_action *erp_action) · 78 unmodified lines
2165 ZFCP_LOG_DEBUG("host connection still initialising... "2165 ZFCP_LOG_DEBUG("host connection still initialising... "
2166 "waiting and retrying...\n");2166 "waiting and retrying...\n");
2167 /* sleep a little bit before retry */2167 /* sleep a little bit before retry */
2168 msleep(jiffies_to_msecs(sleep));2168 ssleep(sleep);
2169 sleep *= 2;2169 sleep *= 2;
2170 }2170 }
2171 2171
drivers/s390/scsi/zfcp_fsf.c+35−35
@@ -1116,6 +1116,10 @@ zfcp_fsf_abort_fcp_command(unsigned long old_req_id, · 1115 unmodified lines
1116 goto out;1116 goto out;
1117 }1117 }
1118 1118
1119 if (unlikely(!atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED,
1120 &unit->status)))
1121 goto unit_blocked;
1122
1119 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);1123 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
1120 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;1124 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1121 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;1125 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
@@ -1131,22 +1135,13 @@ zfcp_fsf_abort_fcp_command(unsigned long old_req_id, · 9 unmodified lines
1131 1135
1132 zfcp_fsf_start_timer(fsf_req, ZFCP_SCSI_ER_TIMEOUT);1136 zfcp_fsf_start_timer(fsf_req, ZFCP_SCSI_ER_TIMEOUT);
1133 retval = zfcp_fsf_req_send(fsf_req);1137 retval = zfcp_fsf_req_send(fsf_req);
1134 if (retval) {1138 if (!retval)
1135 ZFCP_LOG_INFO("error: Failed to send abort command request "1139 goto out;
1136 "on adapter %s, port 0x%016Lx, unit 0x%016Lx\n",1140
1137 zfcp_get_busid_by_adapter(adapter),1141 unit_blocked:
1138 unit->port->wwpn, unit->fcp_lun);
1139 zfcp_fsf_req_free(fsf_req);1142 zfcp_fsf_req_free(fsf_req);
1140 fsf_req = NULL;1143 fsf_req = NULL;
1141 goto out;
1142 }
1143 1144
1144 ZFCP_LOG_DEBUG("Abort FCP Command request initiated "
1145 "(adapter%s, port d_id=0x%06x, "
1146 "unit x%016Lx, old_req_id=0x%lx)\n",
1147 zfcp_get_busid_by_adapter(adapter),
1148 unit->port->d_id,
1149 unit->fcp_lun, old_req_id);
1150 out:1145 out:
1151 write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);1146 write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
1152 return fsf_req;1147 return fsf_req;
@@ -1164,8 +1159,8 @@ zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *new_fsf_req) · 11 unmodified lines
1164{1159{
1165 int retval = -EINVAL;1160 int retval = -EINVAL;
1166 struct zfcp_unit *unit;1161 struct zfcp_unit *unit;
1167 unsigned char status_qual =1162 union fsf_status_qual *fsf_stat_qual =
1168 new_fsf_req->qtcb->header.fsf_status_qual.word[0];1163 &new_fsf_req->qtcb->header.fsf_status_qual;
1169 1164
1170 if (new_fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {1165 if (new_fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
1171 /* do not set ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED */1166 /* do not set ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED */
@@ -1178,7 +1173,7 @@ zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *new_fsf_req) · 6 unmodified lines
1178 switch (new_fsf_req->qtcb->header.fsf_status) {1173 switch (new_fsf_req->qtcb->header.fsf_status) {
1179 1174
1180 case FSF_PORT_HANDLE_NOT_VALID:1175 case FSF_PORT_HANDLE_NOT_VALID:
1181 if (status_qual >> 4 != status_qual % 0xf) {1176 if (fsf_stat_qual->word[0] != fsf_stat_qual->word[1]) {
1182 debug_text_event(new_fsf_req->adapter->erp_dbf, 3,1177 debug_text_event(new_fsf_req->adapter->erp_dbf, 3,
1183 "fsf_s_phand_nv0");1178 "fsf_s_phand_nv0");
1184 /*1179 /*
@@ -1207,8 +1202,7 @@ zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *new_fsf_req) · 22 unmodified lines
1207 break;1202 break;
1208 1203
1209 case FSF_LUN_HANDLE_NOT_VALID:1204 case FSF_LUN_HANDLE_NOT_VALID:
1210 if (status_qual >> 4 != status_qual % 0xf) {1205 if (fsf_stat_qual->word[0] != fsf_stat_qual->word[1]) {
1211 /* 2 */
1212 debug_text_event(new_fsf_req->adapter->erp_dbf, 3,1206 debug_text_event(new_fsf_req->adapter->erp_dbf, 3,
1213 "fsf_s_lhand_nv0");1207 "fsf_s_lhand_nv0");
1214 /*1208 /*
@@ -1674,6 +1668,12 @@ zfcp_fsf_send_els(struct zfcp_send_els *els) · 459 unmodified lines
1674 goto failed_req;1668 goto failed_req;
1675 }1669 }
1676 1670
1671 if (unlikely(!atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED,
1672 &els->port->status))) {
1673 ret = -EBUSY;
1674 goto port_blocked;
1675 }
1676
1677 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);1677 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
1678 if (zfcp_use_one_sbal(els->req, els->req_count,1678 if (zfcp_use_one_sbal(els->req, els->req_count,
1679 els->resp, els->resp_count)){1679 els->resp, els->resp_count)){
@@ -1755,6 +1755,7 @@ zfcp_fsf_send_els(struct zfcp_send_els *els) · 75 unmodified lines
1755 "0x%06x)\n", zfcp_get_busid_by_adapter(adapter), d_id);1755 "0x%06x)\n", zfcp_get_busid_by_adapter(adapter), d_id);
1756 goto out;1756 goto out;
1757 1757
1758 port_blocked:
1758 failed_send:1759 failed_send:
1759 zfcp_fsf_req_free(fsf_req);1760 zfcp_fsf_req_free(fsf_req);
1760 1761
@@ -3592,6 +3593,12 @@ zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *adapter, · 1831 unmodified lines
3592 goto failed_req_create;3593 goto failed_req_create;
3593 }3594 }
3594 3595
3596 if (unlikely(!atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED,
3597 &unit->status))) {
3598 retval = -EBUSY;
3599 goto unit_blocked;
3600 }
3601
3595 zfcp_unit_get(unit);3602 zfcp_unit_get(unit);
3596 fsf_req->unit = unit;3603 fsf_req->unit = unit;
3597 3604
@@ -3732,6 +3739,7 @@ zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *adapter, · 134 unmodified lines
3732 send_failed:3739 send_failed:
3733 no_fit:3740 no_fit:
3734 failed_scsi_cmnd:3741 failed_scsi_cmnd:
3742 unit_blocked:
3735 zfcp_unit_put(unit);3743 zfcp_unit_put(unit);
3736 zfcp_fsf_req_free(fsf_req);3744 zfcp_fsf_req_free(fsf_req);
3737 fsf_req = NULL;3745 fsf_req = NULL;
@@ -3766,6 +3774,10 @@ zfcp_fsf_send_fcp_command_task_management(struct zfcp_adapter *adapter, · 28 unmodified lines
3766 goto out;3774 goto out;
3767 }3775 }
3768 3776
3777 if (unlikely(!atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED,
3778 &unit->status)))
3779 goto unit_blocked;
3780
3769 /*3781 /*
3770 * Used to decide on proper handler in the return path,3782 * Used to decide on proper handler in the return path,
3771 * could be either zfcp_fsf_send_fcp_command_task_handler or3783 * could be either zfcp_fsf_send_fcp_command_task_handler or
@@ -3799,25 +3811,13 @@ zfcp_fsf_send_fcp_command_task_management(struct zfcp_adapter *adapter, · 27 unmodified lines
3799 3811
3800 zfcp_fsf_start_timer(fsf_req, ZFCP_SCSI_ER_TIMEOUT);3812 zfcp_fsf_start_timer(fsf_req, ZFCP_SCSI_ER_TIMEOUT);
3801 retval = zfcp_fsf_req_send(fsf_req);3813 retval = zfcp_fsf_req_send(fsf_req);
3802 if (retval) {3814 if (!retval)
3803 ZFCP_LOG_INFO("error: Could not send an FCP-command (task "
3804 "management) on adapter %s, port 0x%016Lx for "
3805 "unit LUN 0x%016Lx\n",
3806 zfcp_get_busid_by_adapter(adapter),
3807 unit->port->wwpn,
3808 unit->fcp_lun);
3809 zfcp_fsf_req_free(fsf_req);
3810 fsf_req = NULL;
3811 goto out;3815 goto out;
3812 }
3813 3816
3814 ZFCP_LOG_TRACE("Send FCP Command (task management function) initiated "3817 unit_blocked:
3815 "(adapter %s, port 0x%016Lx, unit 0x%016Lx, "3818 zfcp_fsf_req_free(fsf_req);
3816 "tm_flags=0x%x)\n",3819 fsf_req = NULL;
3817 zfcp_get_busid_by_adapter(adapter),3820
3818 unit->port->wwpn,
3819 unit->fcp_lun,
3820 tm_flags);
3821 out:3821 out:
3822 write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);3822 write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
3823 return fsf_req;3823 return fsf_req;
drivers/s390/scsi/zfcp_scsi.c+11−13
@@ -51,7 +51,6 @@ struct zfcp_data zfcp_data = { · 50 unmodified lines
51 .queuecommand = zfcp_scsi_queuecommand,51 .queuecommand = zfcp_scsi_queuecommand,
52 .eh_abort_handler = zfcp_scsi_eh_abort_handler,52 .eh_abort_handler = zfcp_scsi_eh_abort_handler,
53 .eh_device_reset_handler = zfcp_scsi_eh_device_reset_handler,53 .eh_device_reset_handler = zfcp_scsi_eh_device_reset_handler,
54 .eh_bus_reset_handler = zfcp_scsi_eh_host_reset_handler,
55 .eh_host_reset_handler = zfcp_scsi_eh_host_reset_handler,54 .eh_host_reset_handler = zfcp_scsi_eh_host_reset_handler,
56 .can_queue = 4096,55 .can_queue = 4096,
57 .this_id = -1,56 .this_id = -1,
@@ -181,9 +180,6 @@ static void zfcp_scsi_slave_destroy(struct scsi_device *sdpnt) · 123 unmodified lines
181 180
182 if (unit) {181 if (unit) {
183 zfcp_erp_wait(unit->port->adapter);182 zfcp_erp_wait(unit->port->adapter);
184 wait_event(unit->scsi_scan_wq,
185 atomic_test_mask(ZFCP_STATUS_UNIT_SCSI_WORK_PENDING,
186 &unit->status) == 0);
187 atomic_clear_mask(ZFCP_STATUS_UNIT_REGISTERED, &unit->status);183 atomic_clear_mask(ZFCP_STATUS_UNIT_REGISTERED, &unit->status);
188 sdpnt->hostdata = NULL;184 sdpnt->hostdata = NULL;
189 unit->device = NULL;185 unit->device = NULL;
@@ -262,8 +258,9 @@ zfcp_scsi_command_async(struct zfcp_adapter *adapter, struct zfcp_unit *unit, · 72 unmodified lines
262 goto out;258 goto out;
263 }259 }
264 260
265 if (unlikely(261 tmp = zfcp_fsf_send_fcp_command_task(adapter, unit, scpnt, use_timer,
266 !atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &unit->status))) {262 ZFCP_REQ_AUTO_CLEANUP);
263 if (unlikely(tmp == -EBUSY)) {
267 ZFCP_LOG_DEBUG("adapter %s not ready or unit 0x%016Lx "264 ZFCP_LOG_DEBUG("adapter %s not ready or unit 0x%016Lx "
268 "on port 0x%016Lx in recovery\n",265 "on port 0x%016Lx in recovery\n",
269 zfcp_get_busid_by_unit(unit),266 zfcp_get_busid_by_unit(unit),
@@ -272,9 +269,6 @@ zfcp_scsi_command_async(struct zfcp_adapter *adapter, struct zfcp_unit *unit, · 2 unmodified lines
272 goto out;269 goto out;
273 }270 }
274 271
275 tmp = zfcp_fsf_send_fcp_command_task(adapter, unit, scpnt, use_timer,
276 ZFCP_REQ_AUTO_CLEANUP);
277
278 if (unlikely(tmp < 0)) {272 if (unlikely(tmp < 0)) {
279 ZFCP_LOG_DEBUG("error: initiation of Send FCP Cmnd failed\n");273 ZFCP_LOG_DEBUG("error: initiation of Send FCP Cmnd failed\n");
280 retval = SCSI_MLQUEUE_HOST_BUSY;274 retval = SCSI_MLQUEUE_HOST_BUSY;
@@ -459,7 +453,9 @@ zfcp_scsi_eh_device_reset_handler(struct scsi_cmnd *scpnt) · 178 unmodified lines
459 retval = SUCCESS;453 retval = SUCCESS;
460 goto out;454 goto out;
461 }455 }
462 ZFCP_LOG_NORMAL("resetting unit 0x%016Lx\n", unit->fcp_lun);456 ZFCP_LOG_NORMAL("resetting unit 0x%016Lx on port 0x%016Lx, adapter %s\n",
457 unit->fcp_lun, unit->port->wwpn,
458 zfcp_get_busid_by_adapter(unit->port->adapter));
463 459
464 /*460 /*
465 * If we do not know whether the unit supports 'logical unit reset'461 * If we do not know whether the unit supports 'logical unit reset'
@@ -542,7 +538,7 @@ zfcp_task_management_function(struct zfcp_unit *unit, u8 tm_flags, · 76 unmodified lines
542}538}
543 539
544/**540/**
545 * zfcp_scsi_eh_host_reset_handler - handler for host and bus reset541 * zfcp_scsi_eh_host_reset_handler - handler for host reset
546 */542 */
547static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt)543static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt)
548{544{
@@ -552,8 +548,10 @@ static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt) · 3 unmodified lines
552 unit = (struct zfcp_unit*) scpnt->device->hostdata;548 unit = (struct zfcp_unit*) scpnt->device->hostdata;
553 adapter = unit->port->adapter;549 adapter = unit->port->adapter;
554 550
555 ZFCP_LOG_NORMAL("host/bus reset because of problems with "551 ZFCP_LOG_NORMAL("host reset because of problems with "
556 "unit 0x%016Lx\n", unit->fcp_lun);552 "unit 0x%016Lx on port 0x%016Lx, adapter %s\n",
553 unit->fcp_lun, unit->port->wwpn,
554 zfcp_get_busid_by_adapter(unit->port->adapter));
557 555
558 zfcp_erp_adapter_reopen(adapter, 0);556 zfcp_erp_adapter_reopen(adapter, 0);
559 zfcp_erp_wait(adapter);557 zfcp_erp_wait(adapter);
drivers/scsi/.gitignore+0−2
@@ -1,3 +1 @@
153c700_d.h153c700_d.h
253c7xx_d.h
353c7xx_u.h
drivers/scsi/3w-9xxx.c+1−0
@@ -2010,6 +2010,7 @@ static int __devinit twa_probe(struct pci_dev *pdev, const struct pci_device_id · 2009 unmodified lines
2010 }2010 }
2011 2011
2012 pci_set_master(pdev);2012 pci_set_master(pdev);
2013 pci_try_set_mwi(pdev);
2013 2014
2014 if (pci_set_dma_mask(pdev, DMA_64BIT_MASK)2015 if (pci_set_dma_mask(pdev, DMA_64BIT_MASK)
2015 || pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK))2016 || pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK))
drivers/scsi/53c700.c+6−5
@@ -608,7 +608,8 @@ NCR_700_scsi_done(struct NCR_700_Host_Parameters *hostdata, · 607 unmodified lines
608 scsi_print_sense("53c700", SCp);608 scsi_print_sense("53c700", SCp);
609 609
610#endif610#endif
611 dma_unmap_single(hostdata->dev, slot->dma_handle, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE);611 dma_unmap_single(hostdata->dev, slot->dma_handle,
612 SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
612 /* restore the old result if the request sense was613 /* restore the old result if the request sense was
613 * successful */614 * successful */
614 if (result == 0)615 if (result == 0)
@@ -1010,7 +1011,7 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp, · 395 unmodified lines
1010 cmnd[1] = (SCp->device->lun & 0x7) << 5;1011 cmnd[1] = (SCp->device->lun & 0x7) << 5;
1011 cmnd[2] = 0;1012 cmnd[2] = 0;
1012 cmnd[3] = 0;1013 cmnd[3] = 0;
1013 cmnd[4] = sizeof(SCp->sense_buffer);1014 cmnd[4] = SCSI_SENSE_BUFFERSIZE;
1014 cmnd[5] = 0;1015 cmnd[5] = 0;
1015 /* Here's a quiet hack: the1016 /* Here's a quiet hack: the
1016 * REQUEST_SENSE command is six bytes,1017 * REQUEST_SENSE command is six bytes,
@@ -1024,14 +1025,14 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp, · 7 unmodified lines
1024 SCp->cmd_len = 6; /* command length for1025 SCp->cmd_len = 6; /* command length for
1025 * REQUEST_SENSE */1026 * REQUEST_SENSE */
1026 slot->pCmd = dma_map_single(hostdata->dev, cmnd, MAX_COMMAND_SIZE, DMA_TO_DEVICE);1027 slot->pCmd = dma_map_single(hostdata->dev, cmnd, MAX_COMMAND_SIZE, DMA_TO_DEVICE);
1027 slot->dma_handle = dma_map_single(hostdata->dev, SCp->sense_buffer, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE);1028 slot->dma_handle = dma_map_single(hostdata->dev, SCp->sense_buffer, SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
1028 slot->SG[0].ins = bS_to_host(SCRIPT_MOVE_DATA_IN | sizeof(SCp->sense_buffer));1029 slot->SG[0].ins = bS_to_host(SCRIPT_MOVE_DATA_IN | SCSI_SENSE_BUFFERSIZE);
1029 slot->SG[0].pAddr = bS_to_host(slot->dma_handle);1030 slot->SG[0].pAddr = bS_to_host(slot->dma_handle);
1030 slot->SG[1].ins = bS_to_host(SCRIPT_RETURN);1031 slot->SG[1].ins = bS_to_host(SCRIPT_RETURN);
1031 slot->SG[1].pAddr = 0;1032 slot->SG[1].pAddr = 0;
1032 slot->resume_offset = hostdata->pScript;1033 slot->resume_offset = hostdata->pScript;
1033 dma_cache_sync(hostdata->dev, slot->SG, sizeof(slot->SG[0])*2, DMA_TO_DEVICE);1034 dma_cache_sync(hostdata->dev, slot->SG, sizeof(slot->SG[0])*2, DMA_TO_DEVICE);
1034 dma_cache_sync(hostdata->dev, SCp->sense_buffer, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE);1035 dma_cache_sync(hostdata->dev, SCp->sense_buffer, SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
1035 1036
1036 /* queue the command for reissue */1037 /* queue the command for reissue */
1037 slot->state = NCR_700_SLOT_QUEUED;1038 slot->state = NCR_700_SLOT_QUEUED;
drivers/scsi/BusLogic.c+1−1
@@ -2947,7 +2947,7 @@ static int BusLogic_QueueCommand(struct scsi_cmnd *Command, void (*CompletionRou · 2946 unmodified lines
2947 }2947 }
2948 }2948 }
2949 memcpy(CCB->CDB, CDB, CDB_Length);2949 memcpy(CCB->CDB, CDB, CDB_Length);
2950 CCB->SenseDataLength = sizeof(Command->sense_buffer);2950 CCB->SenseDataLength = SCSI_SENSE_BUFFERSIZE;
2951 CCB->SenseDataPointer = pci_map_single(HostAdapter->PCI_Device, Command->sense_buffer, CCB->SenseDataLength, PCI_DMA_FROMDEVICE);2951 CCB->SenseDataPointer = pci_map_single(HostAdapter->PCI_Device, Command->sense_buffer, CCB->SenseDataLength, PCI_DMA_FROMDEVICE);
2952 CCB->Command = Command;2952 CCB->Command = Command;
2953 Command->scsi_done = CompletionRoutine;2953 Command->scsi_done = CompletionRoutine;
drivers/scsi/Kconfig+3−29
@@ -341,7 +341,7 @@ config ISCSI_TCP · 340 unmodified lines
341 The userspace component needed to initialize the driver, documentation,341 The userspace component needed to initialize the driver, documentation,
342 and sample configuration files can be found here:342 and sample configuration files can be found here:
343 343
344 http://linux-iscsi.sf.net344 http://open-iscsi.org
345 345
346config SGIWD93_SCSI346config SGIWD93_SCSI
347 tristate "SGI WD93C93 SCSI Driver"347 tristate "SGI WD93C93 SCSI Driver"
@@ -573,10 +573,10 @@ config SCSI_ARCMSR_AER · 225 unmodified lines
573source "drivers/scsi/megaraid/Kconfig.megaraid"573source "drivers/scsi/megaraid/Kconfig.megaraid"
574 574
575config SCSI_HPTIOP575config SCSI_HPTIOP
576 tristate "HighPoint RocketRAID 3xxx Controller support"576 tristate "HighPoint RocketRAID 3xxx/4xxx Controller support"
577 depends on SCSI && PCI577 depends on SCSI && PCI
578 help578 help
579 This option enables support for HighPoint RocketRAID 3xxx579 This option enables support for HighPoint RocketRAID 3xxx/4xxx
580 controllers.580 controllers.
581 581
582 To compile this driver as a module, choose M here; the module582 To compile this driver as a module, choose M here; the module
@@ -1288,17 +1288,6 @@ config SCSI_PAS16 · 705 unmodified lines
1288 To compile this driver as a module, choose M here: the1288 To compile this driver as a module, choose M here: the
1289 module will be called pas16.1289 module will be called pas16.
1290 1290
1291config SCSI_PSI240I
1292 tristate "PSI240i support"
1293 depends on ISA && SCSI
1294 help
1295 This is support for the PSI240i EIDE interface card which acts as a
1296 SCSI host adapter. Please read the SCSI-HOWTO, available from
1297 <http://www.tldp.org/docs.html#howto>.
1298
1299 To compile this driver as a module, choose M here: the
1300 module will be called psi240i.
1301
1302config SCSI_QLOGIC_FAS1291config SCSI_QLOGIC_FAS
1303 tristate "Qlogic FAS SCSI support"1292 tristate "Qlogic FAS SCSI support"
1304 depends on ISA && SCSI1293 depends on ISA && SCSI
@@ -1359,21 +1348,6 @@ config SCSI_LPFC · 54 unmodified lines
1359 This lpfc driver supports the Emulex LightPulse1348 This lpfc driver supports the Emulex LightPulse
1360 Family of Fibre Channel PCI host adapters.1349 Family of Fibre Channel PCI host adapters.
1361 1350
1362config SCSI_SEAGATE
1363 tristate "Seagate ST-02 and Future Domain TMC-8xx SCSI support"
1364 depends on X86 && ISA && SCSI
1365 select CHECK_SIGNATURE
1366 ---help---
1367 These are 8-bit SCSI controllers; the ST-01 is also supported by
1368 this driver. It is explained in section 3.9 of the SCSI-HOWTO,
1369 available from <http://www.tldp.org/docs.html#howto>. If it
1370 doesn't work out of the box, you may have to change some macros at
1371 compiletime, which are described in <file:drivers/scsi/seagate.c>.
1372
1373 To compile this driver as a module, choose M here: the
1374 module will be called seagate.
1375
1376# definitely looks not 64bit safe:
1377config SCSI_SIM7101351config SCSI_SIM710
1378 tristate "Simple 53c710 SCSI support (Compaq, NCR machines)"1352 tristate "Simple 53c710 SCSI support (Compaq, NCR machines)"
1379 depends on (EISA || MCA) && SCSI1353 depends on (EISA || MCA) && SCSI
drivers/scsi/Makefile+1−4
@@ -16,9 +16,8 @@ · 15 unmodified lines
16 16
17CFLAGS_aha152x.o = -DAHA152X_STAT -DAUTOCONF17CFLAGS_aha152x.o = -DAHA152X_STAT -DAUTOCONF
18CFLAGS_gdth.o = # -DDEBUG_GDTH=2 -D__SERIAL__ -D__COM2__ -DGDTH_STATISTICS18CFLAGS_gdth.o = # -DDEBUG_GDTH=2 -D__SERIAL__ -D__COM2__ -DGDTH_STATISTICS
19CFLAGS_seagate.o = -DARBITRATE -DPARITY -DSEAGATE_USE_ASM
20 19
21subdir-$(CONFIG_PCMCIA) += pcmcia20obj-$(CONFIG_PCMCIA) += pcmcia/
22 21
23obj-$(CONFIG_SCSI) += scsi_mod.o22obj-$(CONFIG_SCSI) += scsi_mod.o
24obj-$(CONFIG_SCSI_TGT) += scsi_tgt.o23obj-$(CONFIG_SCSI_TGT) += scsi_tgt.o
@@ -59,7 +58,6 @@ obj-$(CONFIG_MVME16x_SCSI) += 53c700.o mvme16x_scsi.o · 34 unmodified lines
59obj-$(CONFIG_BVME6000_SCSI) += 53c700.o bvme6000_scsi.o58obj-$(CONFIG_BVME6000_SCSI) += 53c700.o bvme6000_scsi.o
60obj-$(CONFIG_SCSI_SIM710) += 53c700.o sim710.o59obj-$(CONFIG_SCSI_SIM710) += 53c700.o sim710.o
61obj-$(CONFIG_SCSI_ADVANSYS) += advansys.o60obj-$(CONFIG_SCSI_ADVANSYS) += advansys.o
62obj-$(CONFIG_SCSI_PSI240I) += psi240i.o
63obj-$(CONFIG_SCSI_BUSLOGIC) += BusLogic.o61obj-$(CONFIG_SCSI_BUSLOGIC) += BusLogic.o
64obj-$(CONFIG_SCSI_DPT_I2O) += dpt_i2o.o62obj-$(CONFIG_SCSI_DPT_I2O) += dpt_i2o.o
65obj-$(CONFIG_SCSI_U14_34F) += u14-34f.o63obj-$(CONFIG_SCSI_U14_34F) += u14-34f.o
@@ -90,7 +88,6 @@ obj-$(CONFIG_SCSI_QLA_FC) += qla2xxx/ · 24 unmodified lines
90obj-$(CONFIG_SCSI_QLA_ISCSI) += qla4xxx/88obj-$(CONFIG_SCSI_QLA_ISCSI) += qla4xxx/
91obj-$(CONFIG_SCSI_LPFC) += lpfc/89obj-$(CONFIG_SCSI_LPFC) += lpfc/
92obj-$(CONFIG_SCSI_PAS16) += pas16.o90obj-$(CONFIG_SCSI_PAS16) += pas16.o
93obj-$(CONFIG_SCSI_SEAGATE) += seagate.o
94obj-$(CONFIG_SCSI_T128) += t128.o91obj-$(CONFIG_SCSI_T128) += t128.o
95obj-$(CONFIG_SCSI_DMX3191D) += dmx3191d.o92obj-$(CONFIG_SCSI_DMX3191D) += dmx3191d.o
96obj-$(CONFIG_SCSI_DTC3280) += dtc.o93obj-$(CONFIG_SCSI_DTC3280) += dtc.o
drivers/scsi/NCR5380.c+12−11
@@ -295,16 +295,16 @@ static __inline__ void initialize_SCp(Scsi_Cmnd * cmd) · 294 unmodified lines
295 * various queues are valid.295 * various queues are valid.
296 */296 */
297 297
298 if (cmd->use_sg) {298 if (scsi_bufflen(cmd)) {
299 cmd->SCp.buffer = (struct scatterlist *) cmd->request_buffer;299 cmd->SCp.buffer = scsi_sglist(cmd);
300 cmd->SCp.buffers_residual = cmd->use_sg - 1;300 cmd->SCp.buffers_residual = scsi_sg_count(cmd) - 1;
301 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);301 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
302 cmd->SCp.this_residual = cmd->SCp.buffer->length;302 cmd->SCp.this_residual = cmd->SCp.buffer->length;
303 } else {303 } else {
304 cmd->SCp.buffer = NULL;304 cmd->SCp.buffer = NULL;
305 cmd->SCp.buffers_residual = 0;305 cmd->SCp.buffers_residual = 0;
306 cmd->SCp.ptr = (char *) cmd->request_buffer;306 cmd->SCp.ptr = NULL;
307 cmd->SCp.this_residual = cmd->request_bufflen;307 cmd->SCp.this_residual = 0;
308 }308 }
309}309}
310 310
@@ -932,7 +932,7 @@ static int __devinit NCR5380_init(struct Scsi_Host *instance, int flags) · 621 unmodified lines
932 * @instance: adapter to remove932 * @instance: adapter to remove
933 */933 */
934 934
935static void __devexit NCR5380_exit(struct Scsi_Host *instance)935static void NCR5380_exit(struct Scsi_Host *instance)
936{936{
937 struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;937 struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
938 938
@@ -975,14 +975,14 @@ static int NCR5380_queue_command(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *)) · 36 unmodified lines
975 case WRITE_6:975 case WRITE_6:
976 case WRITE_10:976 case WRITE_10:
977 hostdata->time_write[cmd->device->id] -= (jiffies - hostdata->timebase);977 hostdata->time_write[cmd->device->id] -= (jiffies - hostdata->timebase);
978 hostdata->bytes_write[cmd->device->id] += cmd->request_bufflen;978 hostdata->bytes_write[cmd->device->id] += scsi_bufflen(cmd);
979 hostdata->pendingw++;979 hostdata->pendingw++;
980 break;980 break;
981 case READ:981 case READ:
982 case READ_6:982 case READ_6:
983 case READ_10:983 case READ_10:
984 hostdata->time_read[cmd->device->id] -= (jiffies - hostdata->timebase);984 hostdata->time_read[cmd->device->id] -= (jiffies - hostdata->timebase);
985 hostdata->bytes_read[cmd->device->id] += cmd->request_bufflen;985 hostdata->bytes_read[cmd->device->id] += scsi_bufflen(cmd);
986 hostdata->pendingr++;986 hostdata->pendingr++;
987 break;987 break;
988 }988 }
@@ -1157,16 +1157,17 @@ static void NCR5380_main(struct work_struct *work) · 168 unmodified lines
1157 * Locks: takes the needed instance locks1157 * Locks: takes the needed instance locks
1158 */1158 */
1159 1159
1160static irqreturn_t NCR5380_intr(int irq, void *dev_id) 1160static irqreturn_t NCR5380_intr(int dummy, void *dev_id)
1161{1161{
1162 NCR5380_local_declare();1162 NCR5380_local_declare();
1163 struct Scsi_Host *instance = (struct Scsi_Host *)dev_id;1163 struct Scsi_Host *instance = dev_id;
1164 struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;1164 struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
1165 int done;1165 int done;
1166 unsigned char basr;1166 unsigned char basr;
1167 unsigned long flags;1167 unsigned long flags;
1168 1168
1169 dprintk(NDEBUG_INTR, ("scsi : NCR5380 irq %d triggered\n", irq));1169 dprintk(NDEBUG_INTR, ("scsi : NCR5380 irq %d triggered\n",
1170 instance->irq));
1170 1171
1171 do {1172 do {
1172 done = 1;1173 done = 1;
drivers/scsi/a2091.c+5−31
@@ -73,18 +73,9 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in) · 72 unmodified lines
73 }73 }
74 74
75 if (!dir_in) {75 if (!dir_in) {
76 /* copy to bounce buffer for a write */76 /* copy to bounce buffer for a write */
77 if (cmd->use_sg)
78#if 0
79 panic ("scsi%ddma: incomplete s/g support",
80 instance->host_no);
81#else
82 memcpy (HDATA(instance)->dma_bounce_buffer,77 memcpy (HDATA(instance)->dma_bounce_buffer,
83 cmd->SCp.ptr, cmd->SCp.this_residual);78 cmd->SCp.ptr, cmd->SCp.this_residual);
84#endif
85 else
86 memcpy (HDATA(instance)->dma_bounce_buffer,
87 cmd->request_buffer, cmd->request_bufflen);
88 }79 }
89 }80 }
90 81
@@ -144,30 +135,13 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, · 53 unmodified lines
144 135
145 /* copy from a bounce buffer, if necessary */136 /* copy from a bounce buffer, if necessary */
146 if (status && HDATA(instance)->dma_bounce_buffer) {137 if (status && HDATA(instance)->dma_bounce_buffer) {
147 if (SCpnt && SCpnt->use_sg) {138 if( HDATA(instance)->dma_dir )
148#if 0
149 panic ("scsi%d: incomplete s/g support",
150 instance->host_no);
151#else
152 if( HDATA(instance)->dma_dir )
153 memcpy (SCpnt->SCp.ptr, 139 memcpy (SCpnt->SCp.ptr,
154 HDATA(instance)->dma_bounce_buffer,140 HDATA(instance)->dma_bounce_buffer,
155 SCpnt->SCp.this_residual);141 SCpnt->SCp.this_residual);
156 kfree (HDATA(instance)->dma_bounce_buffer);142 kfree (HDATA(instance)->dma_bounce_buffer);
157 HDATA(instance)->dma_bounce_buffer = NULL;143 HDATA(instance)->dma_bounce_buffer = NULL;
158 HDATA(instance)->dma_bounce_len = 0;144 HDATA(instance)->dma_bounce_len = 0;
159
160#endif
161 } else {
162 if (HDATA(instance)->dma_dir && SCpnt)
163 memcpy (SCpnt->request_buffer,
164 HDATA(instance)->dma_bounce_buffer,
165 SCpnt->request_bufflen);
166
167 kfree (HDATA(instance)->dma_bounce_buffer);
168 HDATA(instance)->dma_bounce_buffer = NULL;
169 HDATA(instance)->dma_bounce_len = 0;
170 }
171 }145 }
172}146}
173 147
drivers/scsi/a3000.c+3−12
@@ -70,12 +70,8 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in) · 69 unmodified lines
70 70
71 if (!dir_in) {71 if (!dir_in) {
72 /* copy to bounce buffer for a write */72 /* copy to bounce buffer for a write */
73 if (cmd->use_sg) {73 memcpy (HDATA(a3000_host)->dma_bounce_buffer,
74 memcpy (HDATA(a3000_host)->dma_bounce_buffer,74 cmd->SCp.ptr, cmd->SCp.this_residual);
75 cmd->SCp.ptr, cmd->SCp.this_residual);
76 } else
77 memcpy (HDATA(a3000_host)->dma_bounce_buffer,
78 cmd->request_buffer, cmd->request_bufflen);
79 }75 }
80 76
81 addr = virt_to_bus(HDATA(a3000_host)->dma_bounce_buffer);77 addr = virt_to_bus(HDATA(a3000_host)->dma_bounce_buffer);
@@ -146,7 +142,7 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, · 64 unmodified lines
146 142
147 /* copy from a bounce buffer, if necessary */143 /* copy from a bounce buffer, if necessary */
148 if (status && HDATA(instance)->dma_bounce_buffer) {144 if (status && HDATA(instance)->dma_bounce_buffer) {
149 if (SCpnt && SCpnt->use_sg) {145 if (SCpnt) {
150 if (HDATA(instance)->dma_dir && SCpnt)146 if (HDATA(instance)->dma_dir && SCpnt)
151 memcpy (SCpnt->SCp.ptr,147 memcpy (SCpnt->SCp.ptr,
152 HDATA(instance)->dma_bounce_buffer,148 HDATA(instance)->dma_bounce_buffer,
@@ -155,11 +151,6 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, · 2 unmodified lines
155 HDATA(instance)->dma_bounce_buffer = NULL;151 HDATA(instance)->dma_bounce_buffer = NULL;
156 HDATA(instance)->dma_bounce_len = 0;152 HDATA(instance)->dma_bounce_len = 0;
157 } else {153 } else {
158 if (HDATA(instance)->dma_dir && SCpnt)
159 memcpy (SCpnt->request_buffer,
160 HDATA(instance)->dma_bounce_buffer,
161 SCpnt->request_bufflen);
162
163 kfree (HDATA(instance)->dma_bounce_buffer);154 kfree (HDATA(instance)->dma_bounce_buffer);
164 HDATA(instance)->dma_bounce_buffer = NULL;155 HDATA(instance)->dma_bounce_buffer = NULL;
165 HDATA(instance)->dma_bounce_len = 0;156 HDATA(instance)->dma_bounce_len = 0;
drivers/scsi/aacraid/aachba.c+215−185
@@ -31,9 +31,9 @@ · 30 unmodified lines
31#include <linux/slab.h>31#include <linux/slab.h>
32#include <linux/completion.h>32#include <linux/completion.h>
33#include <linux/blkdev.h>33#include <linux/blkdev.h>
34#include <linux/dma-mapping.h>
35#include <asm/semaphore.h>34#include <asm/semaphore.h>
36#include <asm/uaccess.h>35#include <asm/uaccess.h>
36#include <linux/highmem.h> /* For flush_kernel_dcache_page */
37 37
38#include <scsi/scsi.h>38#include <scsi/scsi.h>
39#include <scsi/scsi_cmnd.h>39#include <scsi/scsi_cmnd.h>
@@ -56,54 +56,54 @@ · 16 unmodified lines
56/*56/*
57 * Sense codes57 * Sense codes
58 */58 */
59 59
60#define SENCODE_NO_SENSE 0x0060#define SENCODE_NO_SENSE 0x00
61#define SENCODE_END_OF_DATA 0x0061#define SENCODE_END_OF_DATA 0x00
62#define SENCODE_BECOMING_READY 0x0462#define SENCODE_BECOMING_READY 0x04
63#define SENCODE_INIT_CMD_REQUIRED 0x0463#define SENCODE_INIT_CMD_REQUIRED 0x04
64#define SENCODE_PARAM_LIST_LENGTH_ERROR 0x1A64#define SENCODE_PARAM_LIST_LENGTH_ERROR 0x1A
65#define SENCODE_INVALID_COMMAND 0x2065#define SENCODE_INVALID_COMMAND 0x20
66#define SENCODE_LBA_OUT_OF_RANGE 0x2166#define SENCODE_LBA_OUT_OF_RANGE 0x21
67#define SENCODE_INVALID_CDB_FIELD 0x2467#define SENCODE_INVALID_CDB_FIELD 0x24
68#define SENCODE_LUN_NOT_SUPPORTED 0x2568#define SENCODE_LUN_NOT_SUPPORTED 0x25
69#define SENCODE_INVALID_PARAM_FIELD 0x2669#define SENCODE_INVALID_PARAM_FIELD 0x26
70#define SENCODE_PARAM_NOT_SUPPORTED 0x2670#define SENCODE_PARAM_NOT_SUPPORTED 0x26
71#define SENCODE_PARAM_VALUE_INVALID 0x2671#define SENCODE_PARAM_VALUE_INVALID 0x26
72#define SENCODE_RESET_OCCURRED 0x2972#define SENCODE_RESET_OCCURRED 0x29
73#define SENCODE_LUN_NOT_SELF_CONFIGURED_YET 0x3E73#define SENCODE_LUN_NOT_SELF_CONFIGURED_YET 0x3E
74#define SENCODE_INQUIRY_DATA_CHANGED 0x3F74#define SENCODE_INQUIRY_DATA_CHANGED 0x3F
75#define SENCODE_SAVING_PARAMS_NOT_SUPPORTED 0x3975#define SENCODE_SAVING_PARAMS_NOT_SUPPORTED 0x39
76#define SENCODE_DIAGNOSTIC_FAILURE 0x4076#define SENCODE_DIAGNOSTIC_FAILURE 0x40
77#define SENCODE_INTERNAL_TARGET_FAILURE 0x4477#define SENCODE_INTERNAL_TARGET_FAILURE 0x44
78#define SENCODE_INVALID_MESSAGE_ERROR 0x4978#define SENCODE_INVALID_MESSAGE_ERROR 0x49
79#define SENCODE_LUN_FAILED_SELF_CONFIG 0x4c79#define SENCODE_LUN_FAILED_SELF_CONFIG 0x4c
80#define SENCODE_OVERLAPPED_COMMAND 0x4E80#define SENCODE_OVERLAPPED_COMMAND 0x4E
81 81
82/*82/*
83 * Additional sense codes83 * Additional sense codes
84 */84 */
85 85
86#define ASENCODE_NO_SENSE 0x0086#define ASENCODE_NO_SENSE 0x00
87#define ASENCODE_END_OF_DATA 0x0587#define ASENCODE_END_OF_DATA 0x05
88#define ASENCODE_BECOMING_READY 0x0188#define ASENCODE_BECOMING_READY 0x01
89#define ASENCODE_INIT_CMD_REQUIRED 0x0289#define ASENCODE_INIT_CMD_REQUIRED 0x02
90#define ASENCODE_PARAM_LIST_LENGTH_ERROR 0x0090#define ASENCODE_PARAM_LIST_LENGTH_ERROR 0x00
91#define ASENCODE_INVALID_COMMAND 0x0091#define ASENCODE_INVALID_COMMAND 0x00
92#define ASENCODE_LBA_OUT_OF_RANGE 0x0092#define ASENCODE_LBA_OUT_OF_RANGE 0x00
93#define ASENCODE_INVALID_CDB_FIELD 0x0093#define ASENCODE_INVALID_CDB_FIELD 0x00
94#define ASENCODE_LUN_NOT_SUPPORTED 0x0094#define ASENCODE_LUN_NOT_SUPPORTED 0x00
95#define ASENCODE_INVALID_PARAM_FIELD 0x0095#define ASENCODE_INVALID_PARAM_FIELD 0x00
96#define ASENCODE_PARAM_NOT_SUPPORTED 0x0196#define ASENCODE_PARAM_NOT_SUPPORTED 0x01
97#define ASENCODE_PARAM_VALUE_INVALID 0x0297#define ASENCODE_PARAM_VALUE_INVALID 0x02
98#define ASENCODE_RESET_OCCURRED 0x0098#define ASENCODE_RESET_OCCURRED 0x00
99#define ASENCODE_LUN_NOT_SELF_CONFIGURED_YET 0x0099#define ASENCODE_LUN_NOT_SELF_CONFIGURED_YET 0x00
100#define ASENCODE_INQUIRY_DATA_CHANGED 0x03100#define ASENCODE_INQUIRY_DATA_CHANGED 0x03
101#define ASENCODE_SAVING_PARAMS_NOT_SUPPORTED 0x00101#define ASENCODE_SAVING_PARAMS_NOT_SUPPORTED 0x00
102#define ASENCODE_DIAGNOSTIC_FAILURE 0x80102#define ASENCODE_DIAGNOSTIC_FAILURE 0x80
103#define ASENCODE_INTERNAL_TARGET_FAILURE 0x00103#define ASENCODE_INTERNAL_TARGET_FAILURE 0x00
104#define ASENCODE_INVALID_MESSAGE_ERROR 0x00104#define ASENCODE_INVALID_MESSAGE_ERROR 0x00
105#define ASENCODE_LUN_FAILED_SELF_CONFIG 0x00105#define ASENCODE_LUN_FAILED_SELF_CONFIG 0x00
106#define ASENCODE_OVERLAPPED_COMMAND 0x00106#define ASENCODE_OVERLAPPED_COMMAND 0x00
107 107
108#define BYTE0(x) (unsigned char)(x)108#define BYTE0(x) (unsigned char)(x)
109#define BYTE1(x) (unsigned char)((x) >> 8)109#define BYTE1(x) (unsigned char)((x) >> 8)
@@ -115,8 +115,8 @@ · 5 unmodified lines
115 *----------------------------------------------------------------------------*/115 *----------------------------------------------------------------------------*/
116/* SCSI inquiry data */116/* SCSI inquiry data */
117struct inquiry_data {117struct inquiry_data {
118 u8 inqd_pdt; /* Peripheral qualifier | Peripheral Device Type */118 u8 inqd_pdt; /* Peripheral qualifier | Peripheral Device Type */
119 u8 inqd_dtq; /* RMB | Device Type Qualifier */119 u8 inqd_dtq; /* RMB | Device Type Qualifier */
120 u8 inqd_ver; /* ISO version | ECMA version | ANSI-approved version */120 u8 inqd_ver; /* ISO version | ECMA version | ANSI-approved version */
121 u8 inqd_rdf; /* AENC | TrmIOP | Response data format */121 u8 inqd_rdf; /* AENC | TrmIOP | Response data format */
122 u8 inqd_len; /* Additional length (n-4) */122 u8 inqd_len; /* Additional length (n-4) */
@@ -130,7 +130,7 @@ struct inquiry_data { · 7 unmodified lines
130/*130/*
131 * M O D U L E G L O B A L S131 * M O D U L E G L O B A L S
132 */132 */
133 133
134static unsigned long aac_build_sg(struct scsi_cmnd* scsicmd, struct sgmap* sgmap);134static unsigned long aac_build_sg(struct scsi_cmnd* scsicmd, struct sgmap* sgmap);
135static unsigned long aac_build_sg64(struct scsi_cmnd* scsicmd, struct sgmap64* psg);135static unsigned long aac_build_sg64(struct scsi_cmnd* scsicmd, struct sgmap64* psg);
136static unsigned long aac_build_sgraw(struct scsi_cmnd* scsicmd, struct sgmapraw* psg);136static unsigned long aac_build_sgraw(struct scsi_cmnd* scsicmd, struct sgmapraw* psg);
@@ -141,9 +141,10 @@ static char *aac_get_status_string(u32 status); · 4 unmodified lines
141 141
142/*142/*
143 * Non dasd selection is handled entirely in aachba now143 * Non dasd selection is handled entirely in aachba now
144 */ 144 */
145 145
146static int nondasd = -1;146static int nondasd = -1;
147static int aac_cache = 0;
147static int dacmode = -1;148static int dacmode = -1;
148 149
149int aac_commit = -1;150int aac_commit = -1;
@@ -152,6 +153,8 @@ int aif_timeout = 120; · 2 unmodified lines
152 153
153module_param(nondasd, int, S_IRUGO|S_IWUSR);154module_param(nondasd, int, S_IRUGO|S_IWUSR);
154MODULE_PARM_DESC(nondasd, "Control scanning of hba for nondasd devices. 0=off, 1=on");155MODULE_PARM_DESC(nondasd, "Control scanning of hba for nondasd devices. 0=off, 1=on");
156module_param_named(cache, aac_cache, int, S_IRUGO|S_IWUSR);
157MODULE_PARM_DESC(cache, "Disable Queue Flush commands:\n\tbit 0 - Disable FUA in WRITE SCSI commands\n\tbit 1 - Disable SYNCHRONIZE_CACHE SCSI command\n\tbit 2 - Disable only if Battery not protecting Cache");
155module_param(dacmode, int, S_IRUGO|S_IWUSR);158module_param(dacmode, int, S_IRUGO|S_IWUSR);
156MODULE_PARM_DESC(dacmode, "Control whether dma addressing is using 64 bit DAC. 0=off, 1=on");159MODULE_PARM_DESC(dacmode, "Control whether dma addressing is using 64 bit DAC. 0=off, 1=on");
157module_param_named(commit, aac_commit, int, S_IRUGO|S_IWUSR);160module_param_named(commit, aac_commit, int, S_IRUGO|S_IWUSR);
@@ -179,7 +182,7 @@ MODULE_PARM_DESC(check_interval, "Interval in seconds between adapter health che · 21 unmodified lines
179 182
180int aac_check_reset = 1;183int aac_check_reset = 1;
181module_param_named(check_reset, aac_check_reset, int, S_IRUGO|S_IWUSR);184module_param_named(check_reset, aac_check_reset, int, S_IRUGO|S_IWUSR);
182MODULE_PARM_DESC(aac_check_reset, "If adapter fails health check, reset the adapter.");185MODULE_PARM_DESC(aac_check_reset, "If adapter fails health check, reset the adapter. a value of -1 forces the reset to adapters programmed to ignore it.");
183 186
184int expose_physicals = -1;187int expose_physicals = -1;
185module_param(expose_physicals, int, S_IRUGO|S_IWUSR);188module_param(expose_physicals, int, S_IRUGO|S_IWUSR);
@@ -193,12 +196,12 @@ static inline int aac_valid_context(struct scsi_cmnd *scsicmd, · 7 unmodified lines
193 struct fib *fibptr) {196 struct fib *fibptr) {
194 struct scsi_device *device;197 struct scsi_device *device;
195 198
196 if (unlikely(!scsicmd || !scsicmd->scsi_done )) {199 if (unlikely(!scsicmd || !scsicmd->scsi_done)) {
197 dprintk((KERN_WARNING "aac_valid_context: scsi command corrupt\n"));200 dprintk((KERN_WARNING "aac_valid_context: scsi command corrupt\n"));
198 aac_fib_complete(fibptr);201 aac_fib_complete(fibptr);
199 aac_fib_free(fibptr);202 aac_fib_free(fibptr);
200 return 0;203 return 0;
201 }204 }
202 scsicmd->SCp.phase = AAC_OWNER_MIDLEVEL;205 scsicmd->SCp.phase = AAC_OWNER_MIDLEVEL;
203 device = scsicmd->device;206 device = scsicmd->device;
204 if (unlikely(!device || !scsi_device_online(device))) {207 if (unlikely(!device || !scsi_device_online(device))) {
@@ -240,7 +243,7 @@ int aac_get_config_status(struct aac_dev *dev, int commit_flag) · 35 unmodified lines
240 FsaNormal,243 FsaNormal,
241 1, 1,244 1, 1,
242 NULL, NULL);245 NULL, NULL);
243 if (status < 0 ) {246 if (status < 0) {
244 printk(KERN_WARNING "aac_get_config_status: SendFIB failed.\n");247 printk(KERN_WARNING "aac_get_config_status: SendFIB failed.\n");
245 } else {248 } else {
246 struct aac_get_config_status_resp *reply249 struct aac_get_config_status_resp *reply
@@ -264,10 +267,10 @@ int aac_get_config_status(struct aac_dev *dev, int commit_flag) · 17 unmodified lines
264 struct aac_commit_config * dinfo;267 struct aac_commit_config * dinfo;
265 aac_fib_init(fibptr);268 aac_fib_init(fibptr);
266 dinfo = (struct aac_commit_config *) fib_data(fibptr);269 dinfo = (struct aac_commit_config *) fib_data(fibptr);
267 270
268 dinfo->command = cpu_to_le32(VM_ContainerConfig);271 dinfo->command = cpu_to_le32(VM_ContainerConfig);
269 dinfo->type = cpu_to_le32(CT_COMMIT_CONFIG);272 dinfo->type = cpu_to_le32(CT_COMMIT_CONFIG);
270 273
271 status = aac_fib_send(ContainerCommand,274 status = aac_fib_send(ContainerCommand,
272 fibptr,275 fibptr,
273 sizeof (struct aac_commit_config),276 sizeof (struct aac_commit_config),
@@ -293,7 +296,7 @@ int aac_get_config_status(struct aac_dev *dev, int commit_flag) · 19 unmodified lines
293int aac_get_containers(struct aac_dev *dev)296int aac_get_containers(struct aac_dev *dev)
294{297{
295 struct fsa_dev_info *fsa_dev_ptr;298 struct fsa_dev_info *fsa_dev_ptr;
296 u32 index; 299 u32 index;
297 int status = 0;300 int status = 0;
298 struct fib * fibptr;301 struct fib * fibptr;
299 struct aac_get_container_count *dinfo;302 struct aac_get_container_count *dinfo;
@@ -363,6 +366,7 @@ static void aac_internal_transfer(struct scsi_cmnd *scsicmd, void *data, unsigne · 63 unmodified lines
363 if (buf && transfer_len > 0)366 if (buf && transfer_len > 0)
364 memcpy(buf + offset, data, transfer_len);367 memcpy(buf + offset, data, transfer_len);
365 368
369 flush_kernel_dcache_page(kmap_atomic_to_page(buf - sg->offset));
366 kunmap_atomic(buf - sg->offset, KM_IRQ0);370 kunmap_atomic(buf - sg->offset, KM_IRQ0);
367 371
368}372}
@@ -395,7 +399,7 @@ static void get_container_name_callback(void *context, struct fib * fibptr) · 26 unmodified lines
395 do {399 do {
396 *dp++ = (*sp) ? *sp++ : ' ';400 *dp++ = (*sp) ? *sp++ : ' ';
397 } while (--count > 0);401 } while (--count > 0);
398 aac_internal_transfer(scsicmd, d, 402 aac_internal_transfer(scsicmd, d,
399 offsetof(struct inquiry_data, inqd_pid), sizeof(d));403 offsetof(struct inquiry_data, inqd_pid), sizeof(d));
400 }404 }
401 }405 }
@@ -431,13 +435,13 @@ static int aac_get_container_name(struct scsi_cmnd * scsicmd) · 29 unmodified lines
431 dinfo->count = cpu_to_le32(sizeof(((struct aac_get_name_resp *)NULL)->data));435 dinfo->count = cpu_to_le32(sizeof(((struct aac_get_name_resp *)NULL)->data));
432 436
433 status = aac_fib_send(ContainerCommand,437 status = aac_fib_send(ContainerCommand,
434 cmd_fibcontext, 438 cmd_fibcontext,
435 sizeof (struct aac_get_name),439 sizeof (struct aac_get_name),
436 FsaNormal, 440 FsaNormal,
437 0, 1, 441 0, 1,
438 (fib_callback) get_container_name_callback, 442 (fib_callback)get_container_name_callback,
439 (void *) scsicmd);443 (void *) scsicmd);
440 444
441 /*445 /*
442 * Check that the command queued to the controller446 * Check that the command queued to the controller
443 */447 */
@@ -445,7 +449,7 @@ static int aac_get_container_name(struct scsi_cmnd * scsicmd) · 1 unmodified line
445 scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;449 scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
446 return 0;450 return 0;
447 }451 }
448 452
449 printk(KERN_WARNING "aac_get_container_name: aac_fib_send failed with status: %d.\n", status);453 printk(KERN_WARNING "aac_get_container_name: aac_fib_send failed with status: %d.\n", status);
450 aac_fib_complete(cmd_fibcontext);454 aac_fib_complete(cmd_fibcontext);
451 aac_fib_free(cmd_fibcontext);455 aac_fib_free(cmd_fibcontext);
@@ -652,42 +656,47 @@ struct scsi_inq { · 200 unmodified lines
652 * @a: string to copy from656 * @a: string to copy from
653 * @b: string to copy to657 * @b: string to copy to
654 *658 *
655 * Copy a String from one location to another659 * Copy a String from one location to another
656 * without copying \0660 * without copying \0
657 */661 */
658 662
659static void inqstrcpy(char *a, char *b)663static void inqstrcpy(char *a, char *b)
660{664{
661 665
662 while(*a != (char)0) 666 while (*a != (char)0)
663 *b++ = *a++;667 *b++ = *a++;
664}668}
665 669
666static char *container_types[] = {670static char *container_types[] = {
667 "None",671 "None",
668 "Volume",672 "Volume",
669 "Mirror",673 "Mirror",
670 "Stripe",674 "Stripe",
671 "RAID5",675 "RAID5",
672 "SSRW",676 "SSRW",
673 "SSRO",677 "SSRO",
674 "Morph",678 "Morph",
675 "Legacy",679 "Legacy",
676 "RAID4",680 "RAID4",
677 "RAID10", 681 "RAID10",
678 "RAID00", 682 "RAID00",
679 "V-MIRRORS", 683 "V-MIRRORS",
680 "PSEUDO R4", 684 "PSEUDO R4",
681 "RAID50",685 "RAID50",
682 "RAID5D",686 "RAID5D",
683 "RAID5D0",687 "RAID5D0",
684 "RAID1E",688 "RAID1E",
685 "RAID6",689 "RAID6",
686 "RAID60",690 "RAID60",
687 "Unknown"691 "Unknown"
688};692};
689 693
690 694char * get_container_type(unsigned tindex)
695{
696 if (tindex >= ARRAY_SIZE(container_types))
697 tindex = ARRAY_SIZE(container_types) - 1;
698 return container_types[tindex];
699}
691 700
692/* Function: setinqstr701/* Function: setinqstr
693 *702 *
@@ -707,16 +716,21 @@ static void setinqstr(struct aac_dev *dev, void *data, int tindex) · 13 unmodified lines
707 716
708 if (dev->supplement_adapter_info.AdapterTypeText[0]) {717 if (dev->supplement_adapter_info.AdapterTypeText[0]) {
709 char * cp = dev->supplement_adapter_info.AdapterTypeText;718 char * cp = dev->supplement_adapter_info.AdapterTypeText;
710 int c = sizeof(str->vid);719 int c;
711 while (*cp && *cp != ' ' && --c)720 if ((cp[0] == 'A') && (cp[1] == 'O') && (cp[2] == 'C'))
712 ++cp;721 inqstrcpy("SMC", str->vid);
713 c = *cp;722 else {
714 *cp = '\0';723 c = sizeof(str->vid);
715 inqstrcpy (dev->supplement_adapter_info.AdapterTypeText,724 while (*cp && *cp != ' ' && --c)
716 str->vid); 725 ++cp;
717 *cp = c;726 c = *cp;
718 while (*cp && *cp != ' ')727 *cp = '\0';
719 ++cp;728 inqstrcpy (dev->supplement_adapter_info.AdapterTypeText,
729 str->vid);
730 *cp = c;
731 while (*cp && *cp != ' ')
732 ++cp;
733 }
720 while (*cp == ' ')734 while (*cp == ' ')
721 ++cp;735 ++cp;
722 /* last six chars reserved for vol type */736 /* last six chars reserved for vol type */
@@ -898,9 +912,8 @@ static int aac_bounds_32(struct aac_dev * dev, struct scsi_cmnd * cmd, u64 lba) · 175 unmodified lines
898 ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,912 ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
899 0, 0);913 0, 0);
900 memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data,914 memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
901 (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(cmd->sense_buffer))915 min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data),
902 ? sizeof(cmd->sense_buffer)916 SCSI_SENSE_BUFFERSIZE));
903 : sizeof(dev->fsa_dev[cid].sense_data));
904 cmd->scsi_done(cmd);917 cmd->scsi_done(cmd);
905 return 1;918 return 1;
906 }919 }
@@ -981,7 +994,7 @@ static int aac_read_block(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 · 74 unmodified lines
981 aac_fib_init(fib);994 aac_fib_init(fib);
982 readcmd = (struct aac_read *) fib_data(fib);995 readcmd = (struct aac_read *) fib_data(fib);
983 readcmd->command = cpu_to_le32(VM_CtBlockRead);996 readcmd->command = cpu_to_le32(VM_CtBlockRead);
984 readcmd->cid = cpu_to_le16(scmd_id(cmd));997 readcmd->cid = cpu_to_le32(scmd_id(cmd));
985 readcmd->block = cpu_to_le32((u32)(lba&0xffffffff));998 readcmd->block = cpu_to_le32((u32)(lba&0xffffffff));
986 readcmd->count = cpu_to_le32(count * 512);999 readcmd->count = cpu_to_le32(count * 512);
987 1000
@@ -1013,7 +1026,8 @@ static int aac_write_raw_io(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u · 25 unmodified lines
1013 writecmd->block[1] = cpu_to_le32((u32)((lba&0xffffffff00000000LL)>>32));1026 writecmd->block[1] = cpu_to_le32((u32)((lba&0xffffffff00000000LL)>>32));
1014 writecmd->count = cpu_to_le32(count<<9);1027 writecmd->count = cpu_to_le32(count<<9);
1015 writecmd->cid = cpu_to_le16(scmd_id(cmd));1028 writecmd->cid = cpu_to_le16(scmd_id(cmd));
1016 writecmd->flags = fua ?1029 writecmd->flags = (fua && ((aac_cache & 5) != 1) &&
1030 (((aac_cache & 5) != 5) || !fib->dev->cache_protected)) ?
1017 cpu_to_le16(IO_TYPE_WRITE|IO_SUREWRITE) :1031 cpu_to_le16(IO_TYPE_WRITE|IO_SUREWRITE) :
1018 cpu_to_le16(IO_TYPE_WRITE);1032 cpu_to_le16(IO_TYPE_WRITE);
1019 writecmd->bpTotal = 0;1033 writecmd->bpTotal = 0;
@@ -1072,7 +1086,7 @@ static int aac_write_block(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u3 · 52 unmodified lines
1072 aac_fib_init(fib);1086 aac_fib_init(fib);
1073 writecmd = (struct aac_write *) fib_data(fib);1087 writecmd = (struct aac_write *) fib_data(fib);
1074 writecmd->command = cpu_to_le32(VM_CtBlockWrite);1088 writecmd->command = cpu_to_le32(VM_CtBlockWrite);
1075 writecmd->cid = cpu_to_le16(scmd_id(cmd));1089 writecmd->cid = cpu_to_le32(scmd_id(cmd));
1076 writecmd->block = cpu_to_le32((u32)(lba&0xffffffff));1090 writecmd->block = cpu_to_le32((u32)(lba&0xffffffff));
1077 writecmd->count = cpu_to_le32(count * 512);1091 writecmd->count = cpu_to_le32(count * 512);
1078 writecmd->sg.count = cpu_to_le32(1);1092 writecmd->sg.count = cpu_to_le32(1);
@@ -1190,6 +1204,15 @@ static int aac_scsi_32(struct fib * fib, struct scsi_cmnd * cmd) · 111 unmodified lines
1190 (fib_callback) aac_srb_callback, (void *) cmd);1204 (fib_callback) aac_srb_callback, (void *) cmd);
1191}1205}
1192 1206
1207static int aac_scsi_32_64(struct fib * fib, struct scsi_cmnd * cmd)
1208{
1209 if ((sizeof(dma_addr_t) > 4) &&
1210 (num_physpages > (0xFFFFFFFFULL >> PAGE_SHIFT)) &&
1211 (fib->dev->adapter_info.options & AAC_OPT_SGMAP_HOST64))
1212 return FAILED;
1213 return aac_scsi_32(fib, cmd);
1214}
1215
1193int aac_get_adapter_info(struct aac_dev* dev)1216int aac_get_adapter_info(struct aac_dev* dev)
1194{1217{
1195 struct fib* fibptr;1218 struct fib* fibptr;
@@ -1207,11 +1230,11 @@ int aac_get_adapter_info(struct aac_dev* dev) · 11 unmodified lines
1207 memset(info,0,sizeof(*info));1230 memset(info,0,sizeof(*info));
1208 1231
1209 rcode = aac_fib_send(RequestAdapterInfo,1232 rcode = aac_fib_send(RequestAdapterInfo,
1210 fibptr, 1233 fibptr,
1211 sizeof(*info),1234 sizeof(*info),
1212 FsaNormal, 1235 FsaNormal,
1213 -1, 1, /* First `interrupt' command uses special wait */1236 -1, 1, /* First `interrupt' command uses special wait */
1214 NULL, 1237 NULL,
1215 NULL);1238 NULL);
1216 1239
1217 if (rcode < 0) {1240 if (rcode < 0) {
@@ -1222,29 +1245,29 @@ int aac_get_adapter_info(struct aac_dev* dev) · 4 unmodified lines
1222 memcpy(&dev->adapter_info, info, sizeof(*info));1245 memcpy(&dev->adapter_info, info, sizeof(*info));
1223 1246
1224 if (dev->adapter_info.options & AAC_OPT_SUPPLEMENT_ADAPTER_INFO) {1247 if (dev->adapter_info.options & AAC_OPT_SUPPLEMENT_ADAPTER_INFO) {
1225 struct aac_supplement_adapter_info * info;1248 struct aac_supplement_adapter_info * sinfo;
1226 1249
1227 aac_fib_init(fibptr);1250 aac_fib_init(fibptr);
1228 1251
1229 info = (struct aac_supplement_adapter_info *) fib_data(fibptr);1252 sinfo = (struct aac_supplement_adapter_info *) fib_data(fibptr);
1230 1253
1231 memset(info,0,sizeof(*info));1254 memset(sinfo,0,sizeof(*sinfo));
1232 1255
1233 rcode = aac_fib_send(RequestSupplementAdapterInfo,1256 rcode = aac_fib_send(RequestSupplementAdapterInfo,
1234 fibptr,1257 fibptr,
1235 sizeof(*info),1258 sizeof(*sinfo),
1236 FsaNormal,1259 FsaNormal,
1237 1, 1,1260 1, 1,
1238 NULL,1261 NULL,
1239 NULL);1262 NULL);
1240 1263
1241 if (rcode >= 0)1264 if (rcode >= 0)
1242 memcpy(&dev->supplement_adapter_info, info, sizeof(*info));1265 memcpy(&dev->supplement_adapter_info, sinfo, sizeof(*sinfo));
1243 }1266 }
1244 1267
1245 1268
1246 /* 1269 /*
1247 * GetBusInfo 1270 * GetBusInfo
1248 */1271 */
1249 1272
1250 aac_fib_init(fibptr);1273 aac_fib_init(fibptr);
@@ -1267,6 +1290,8 @@ int aac_get_adapter_info(struct aac_dev* dev) · 16 unmodified lines
1267 1, 1,1290 1, 1,
1268 NULL, NULL);1291 NULL, NULL);
1269 1292
1293 /* reasoned default */
1294 dev->maximum_num_physicals = 16;
1270 if (rcode >= 0 && le32_to_cpu(bus_info->Status) == ST_OK) {1295 if (rcode >= 0 && le32_to_cpu(bus_info->Status) == ST_OK) {
1271 dev->maximum_num_physicals = le32_to_cpu(bus_info->TargetsPerBus);1296 dev->maximum_num_physicals = le32_to_cpu(bus_info->TargetsPerBus);
1272 dev->maximum_num_channels = le32_to_cpu(bus_info->BusCount);1297 dev->maximum_num_channels = le32_to_cpu(bus_info->BusCount);
@@ -1276,7 +1301,7 @@ int aac_get_adapter_info(struct aac_dev* dev) · 3 unmodified lines
1276 char buffer[16];1301 char buffer[16];
1277 tmp = le32_to_cpu(dev->adapter_info.kernelrev);1302 tmp = le32_to_cpu(dev->adapter_info.kernelrev);
1278 printk(KERN_INFO "%s%d: kernel %d.%d-%d[%d] %.*s\n",1303 printk(KERN_INFO "%s%d: kernel %d.%d-%d[%d] %.*s\n",
1279 dev->name, 1304 dev->name,
1280 dev->id,1305 dev->id,
1281 tmp>>24,1306 tmp>>24,
1282 (tmp>>16)&0xff,1307 (tmp>>16)&0xff,
@@ -1305,19 +1330,21 @@ int aac_get_adapter_info(struct aac_dev* dev) · 22 unmodified lines
1305 (int)sizeof(dev->supplement_adapter_info.VpdInfo.Tsid),1330 (int)sizeof(dev->supplement_adapter_info.VpdInfo.Tsid),
1306 dev->supplement_adapter_info.VpdInfo.Tsid);1331 dev->supplement_adapter_info.VpdInfo.Tsid);
1307 }1332 }
1308 if (!aac_check_reset ||1333 if (!aac_check_reset || ((aac_check_reset != 1) &&
1309 (dev->supplement_adapter_info.SupportedOptions2 &1334 (dev->supplement_adapter_info.SupportedOptions2 &
1310 le32_to_cpu(AAC_OPTION_IGNORE_RESET))) {1335 AAC_OPTION_IGNORE_RESET))) {
1311 printk(KERN_INFO "%s%d: Reset Adapter Ignored\n",1336 printk(KERN_INFO "%s%d: Reset Adapter Ignored\n",
1312 dev->name, dev->id);1337 dev->name, dev->id);
1313 }1338 }
1314 }1339 }
1315 1340
1341 dev->cache_protected = 0;
1342 dev->jbod = ((dev->supplement_adapter_info.FeatureBits &
1343 AAC_FEATURE_JBOD) != 0);
1316 dev->nondasd_support = 0;1344 dev->nondasd_support = 0;
1317 dev->raid_scsi_mode = 0;1345 dev->raid_scsi_mode = 0;
1318 if(dev->adapter_info.options & AAC_OPT_NONDASD){1346 if(dev->adapter_info.options & AAC_OPT_NONDASD)
1319 dev->nondasd_support = 1;1347 dev->nondasd_support = 1;
1320 }
1321 1348
1322 /*1349 /*
1323 * If the firmware supports ROMB RAID/SCSI mode and we are currently1350 * If the firmware supports ROMB RAID/SCSI mode and we are currently
@@ -1338,11 +1365,10 @@ int aac_get_adapter_info(struct aac_dev* dev) · 14 unmodified lines
1338 if (dev->raid_scsi_mode != 0)1365 if (dev->raid_scsi_mode != 0)
1339 printk(KERN_INFO "%s%d: ROMB RAID/SCSI mode enabled\n",1366 printk(KERN_INFO "%s%d: ROMB RAID/SCSI mode enabled\n",
1340 dev->name, dev->id);1367 dev->name, dev->id);
1341 1368
1342 if(nondasd != -1) { 1369 if (nondasd != -1)
1343 dev->nondasd_support = (nondasd!=0);1370 dev->nondasd_support = (nondasd!=0);
1344 }1371 if(dev->nondasd_support != 0) {
1345 if(dev->nondasd_support != 0){
1346 printk(KERN_INFO "%s%d: Non-DASD support enabled.\n",dev->name, dev->id);1372 printk(KERN_INFO "%s%d: Non-DASD support enabled.\n",dev->name, dev->id);
1347 }1373 }
1348 1374
@@ -1371,12 +1397,14 @@ int aac_get_adapter_info(struct aac_dev* dev) · 22 unmodified lines
1371 rcode = -ENOMEM;1397 rcode = -ENOMEM;
1372 }1398 }
1373 }1399 }
1374 /* 1400 /*
1375 * Deal with configuring for the individualized limits of each packet1401 * Deal with configuring for the individualized limits of each packet
1376 * interface.1402 * interface.
1377 */1403 */
1378 dev->a_ops.adapter_scsi = (dev->dac_support)1404 dev->a_ops.adapter_scsi = (dev->dac_support)
1379 ? aac_scsi_641405 ? ((aac_get_driver_ident(dev->cardtype)->quirks & AAC_QUIRK_SCSI_32)
1406 ? aac_scsi_32_64
1407 : aac_scsi_64)
1380 : aac_scsi_32;1408 : aac_scsi_32;
1381 if (dev->raw_io_interface) {1409 if (dev->raw_io_interface) {
1382 dev->a_ops.adapter_bounds = (dev->raw_io_64)1410 dev->a_ops.adapter_bounds = (dev->raw_io_64)
@@ -1393,8 +1421,8 @@ int aac_get_adapter_info(struct aac_dev* dev) · 10 unmodified lines
1393 if (dev->dac_support) {1421 if (dev->dac_support) {
1394 dev->a_ops.adapter_read = aac_read_block64;1422 dev->a_ops.adapter_read = aac_read_block64;
1395 dev->a_ops.adapter_write = aac_write_block64;1423 dev->a_ops.adapter_write = aac_write_block64;
1396 /* 1424 /*
1397 * 38 scatter gather elements 1425 * 38 scatter gather elements
1398 */1426 */
1399 dev->scsi_host_ptr->sg_tablesize =1427 dev->scsi_host_ptr->sg_tablesize =
1400 (dev->max_fib_size -1428 (dev->max_fib_size -
@@ -1498,9 +1526,8 @@ static void io_callback(void *context, struct fib * fibptr) · 97 unmodified lines
1498 ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,1526 ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
1499 0, 0);1527 0, 0);
1500 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,1528 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
1501 (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer))1529 min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data),
1502 ? sizeof(scsicmd->sense_buffer)1530 SCSI_SENSE_BUFFERSIZE));
1503 : sizeof(dev->fsa_dev[cid].sense_data));
1504 }1531 }
1505 aac_fib_complete(fibptr);1532 aac_fib_complete(fibptr);
1506 aac_fib_free(fibptr);1533 aac_fib_free(fibptr);
@@ -1524,7 +1551,7 @@ static int aac_read(struct scsi_cmnd * scsicmd) · 17 unmodified lines
1524 case READ_6:1551 case READ_6:
1525 dprintk((KERN_DEBUG "aachba: received a read(6) command on id %d.\n", scmd_id(scsicmd)));1552 dprintk((KERN_DEBUG "aachba: received a read(6) command on id %d.\n", scmd_id(scsicmd)));
1526 1553
1527 lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | 1554 lba = ((scsicmd->cmnd[1] & 0x1F) << 16) |
1528 (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3];1555 (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3];
1529 count = scsicmd->cmnd[4];1556 count = scsicmd->cmnd[4];
1530 1557
@@ -1534,32 +1561,32 @@ static int aac_read(struct scsi_cmnd * scsicmd) · 3 unmodified lines
1534 case READ_16:1561 case READ_16:
1535 dprintk((KERN_DEBUG "aachba: received a read(16) command on id %d.\n", scmd_id(scsicmd)));1562 dprintk((KERN_DEBUG "aachba: received a read(16) command on id %d.\n", scmd_id(scsicmd)));
1536 1563
1537 lba = ((u64)scsicmd->cmnd[2] << 56) |1564 lba = ((u64)scsicmd->cmnd[2] << 56) |
1538 ((u64)scsicmd->cmnd[3] << 48) |1565 ((u64)scsicmd->cmnd[3] << 48) |
1539 ((u64)scsicmd->cmnd[4] << 40) |1566 ((u64)scsicmd->cmnd[4] << 40) |
1540 ((u64)scsicmd->cmnd[5] << 32) |1567 ((u64)scsicmd->cmnd[5] << 32) |
1541 ((u64)scsicmd->cmnd[6] << 24) | 1568 ((u64)scsicmd->cmnd[6] << 24) |
1542 (scsicmd->cmnd[7] << 16) |1569 (scsicmd->cmnd[7] << 16) |
1543 (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9];1570 (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9];
1544 count = (scsicmd->cmnd[10] << 24) | 1571 count = (scsicmd->cmnd[10] << 24) |
1545 (scsicmd->cmnd[11] << 16) |1572 (scsicmd->cmnd[11] << 16) |
1546 (scsicmd->cmnd[12] << 8) | scsicmd->cmnd[13];1573 (scsicmd->cmnd[12] << 8) | scsicmd->cmnd[13];
1547 break;1574 break;
1548 case READ_12:1575 case READ_12:
1549 dprintk((KERN_DEBUG "aachba: received a read(12) command on id %d.\n", scmd_id(scsicmd)));1576 dprintk((KERN_DEBUG "aachba: received a read(12) command on id %d.\n", scmd_id(scsicmd)));
1550 1577
1551 lba = ((u64)scsicmd->cmnd[2] << 24) | 1578 lba = ((u64)scsicmd->cmnd[2] << 24) |
1552 (scsicmd->cmnd[3] << 16) |1579 (scsicmd->cmnd[3] << 16) |
1553 (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];1580 (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
1554 count = (scsicmd->cmnd[6] << 24) | 1581 count = (scsicmd->cmnd[6] << 24) |
1555 (scsicmd->cmnd[7] << 16) |1582 (scsicmd->cmnd[7] << 16) |
1556 (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9];1583 (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9];
1557 break;1584 break;
1558 default:1585 default:
1559 dprintk((KERN_DEBUG "aachba: received a read(10) command on id %d.\n", scmd_id(scsicmd)));1586 dprintk((KERN_DEBUG "aachba: received a read(10) command on id %d.\n", scmd_id(scsicmd)));
1560 1587
1561 lba = ((u64)scsicmd->cmnd[2] << 24) | 1588 lba = ((u64)scsicmd->cmnd[2] << 24) |
1562 (scsicmd->cmnd[3] << 16) | 1589 (scsicmd->cmnd[3] << 16) |
1563 (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];1590 (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
1564 count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8];1591 count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8];
1565 break;1592 break;
@@ -1584,7 +1611,7 @@ static int aac_read(struct scsi_cmnd * scsicmd) · 18 unmodified lines
1584 scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;1611 scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
1585 return 0;1612 return 0;
1586 }1613 }
1587 1614
1588 printk(KERN_WARNING "aac_read: aac_fib_send failed with status: %d.\n", status);1615 printk(KERN_WARNING "aac_read: aac_fib_send failed with status: %d.\n", status);
1589 /*1616 /*
1590 * For some reason, the Fib didn't queue, return QUEUE_FULL1617 * For some reason, the Fib didn't queue, return QUEUE_FULL
@@ -1619,11 +1646,11 @@ static int aac_write(struct scsi_cmnd * scsicmd) · 28 unmodified lines
1619 } else if (scsicmd->cmnd[0] == WRITE_16) { /* 16 byte command */1646 } else if (scsicmd->cmnd[0] == WRITE_16) { /* 16 byte command */
1620 dprintk((KERN_DEBUG "aachba: received a write(16) command on id %d.\n", scmd_id(scsicmd)));1647 dprintk((KERN_DEBUG "aachba: received a write(16) command on id %d.\n", scmd_id(scsicmd)));
1621 1648
1622 lba = ((u64)scsicmd->cmnd[2] << 56) |1649 lba = ((u64)scsicmd->cmnd[2] << 56) |
1623 ((u64)scsicmd->cmnd[3] << 48) |1650 ((u64)scsicmd->cmnd[3] << 48) |
1624 ((u64)scsicmd->cmnd[4] << 40) |1651 ((u64)scsicmd->cmnd[4] << 40) |
1625 ((u64)scsicmd->cmnd[5] << 32) |1652 ((u64)scsicmd->cmnd[5] << 32) |
1626 ((u64)scsicmd->cmnd[6] << 24) | 1653 ((u64)scsicmd->cmnd[6] << 24) |
1627 (scsicmd->cmnd[7] << 16) |1654 (scsicmd->cmnd[7] << 16) |
1628 (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9];1655 (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9];
1629 count = (scsicmd->cmnd[10] << 24) | (scsicmd->cmnd[11] << 16) |1656 count = (scsicmd->cmnd[10] << 24) | (scsicmd->cmnd[11] << 16) |
@@ -1712,8 +1739,8 @@ static void synchronize_callback(void *context, struct fib *fibptr) · 82 unmodified lines
1712 ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,1739 ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
1713 0, 0);1740 0, 0);
1714 memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data,1741 memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
1715 min(sizeof(dev->fsa_dev[cid].sense_data),1742 min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data),
1716 sizeof(cmd->sense_buffer)));1743 SCSI_SENSE_BUFFERSIZE));
1717 }1744 }
1718 1745
1719 aac_fib_complete(fibptr);1746 aac_fib_complete(fibptr);
@@ -1798,7 +1825,7 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd) · 78 unmodified lines
1798 if (active)1825 if (active)
1799 return SCSI_MLQUEUE_DEVICE_BUSY;1826 return SCSI_MLQUEUE_DEVICE_BUSY;
1800 1827
1801 aac = (struct aac_dev *)scsicmd->device->host->hostdata;1828 aac = (struct aac_dev *)sdev->host->hostdata;
1802 if (aac->in_reset)1829 if (aac->in_reset)
1803 return SCSI_MLQUEUE_HOST_BUSY;1830 return SCSI_MLQUEUE_HOST_BUSY;
1804 1831
@@ -1850,14 +1877,14 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd) · 45 unmodified lines
1850 * Emulate a SCSI command and queue the required request for the1877 * Emulate a SCSI command and queue the required request for the
1851 * aacraid firmware.1878 * aacraid firmware.
1852 */1879 */
1853 1880
1854int aac_scsi_cmd(struct scsi_cmnd * scsicmd)1881int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
1855{1882{
1856 u32 cid;1883 u32 cid;
1857 struct Scsi_Host *host = scsicmd->device->host;1884 struct Scsi_Host *host = scsicmd->device->host;
1858 struct aac_dev *dev = (struct aac_dev *)host->hostdata;1885 struct aac_dev *dev = (struct aac_dev *)host->hostdata;
1859 struct fsa_dev_info *fsa_dev_ptr = dev->fsa_dev;1886 struct fsa_dev_info *fsa_dev_ptr = dev->fsa_dev;
1860 1887
1861 if (fsa_dev_ptr == NULL)1888 if (fsa_dev_ptr == NULL)
1862 return -1;1889 return -1;
1863 /*1890 /*
@@ -1898,7 +1925,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) · 34 unmodified lines
1898 }1925 }
1899 }1926 }
1900 } else { /* check for physical non-dasd devices */1927 } else { /* check for physical non-dasd devices */
1901 if ((dev->nondasd_support == 1) || expose_physicals) {1928 if (dev->nondasd_support || expose_physicals ||
1929 dev->jbod) {
1902 if (dev->in_reset)1930 if (dev->in_reset)
1903 return -1;1931 return -1;
1904 return aac_send_srb_fib(scsicmd);1932 return aac_send_srb_fib(scsicmd);
@@ -1913,7 +1941,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) · 8 unmodified lines
1913 * else Command for the controller itself1941 * else Command for the controller itself
1914 */1942 */
1915 else if ((scsicmd->cmnd[0] != INQUIRY) && /* only INQUIRY & TUR cmnd supported for controller */1943 else if ((scsicmd->cmnd[0] != INQUIRY) && /* only INQUIRY & TUR cmnd supported for controller */
1916 (scsicmd->cmnd[0] != TEST_UNIT_READY)) 1944 (scsicmd->cmnd[0] != TEST_UNIT_READY))
1917 {1945 {
1918 dprintk((KERN_WARNING "Only INQUIRY & TUR command supported for controller, rcvd = 0x%x.\n", scsicmd->cmnd[0]));1946 dprintk((KERN_WARNING "Only INQUIRY & TUR command supported for controller, rcvd = 0x%x.\n", scsicmd->cmnd[0]));
1919 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;1947 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
@@ -1922,9 +1950,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) · 2 unmodified lines
1922 SENCODE_INVALID_COMMAND,1950 SENCODE_INVALID_COMMAND,
1923 ASENCODE_INVALID_COMMAND, 0, 0, 0, 0);1951 ASENCODE_INVALID_COMMAND, 0, 0, 0, 0);
1924 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,1952 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
1925 (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer))1953 min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data),
1926 ? sizeof(scsicmd->sense_buffer)1954 SCSI_SENSE_BUFFERSIZE));
1927 : sizeof(dev->fsa_dev[cid].sense_data));
1928 scsicmd->scsi_done(scsicmd);1955 scsicmd->scsi_done(scsicmd);
1929 return 0;1956 return 0;
1930 }1957 }
@@ -1939,7 +1966,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) · 8 unmodified lines
1939 dprintk((KERN_DEBUG "INQUIRY command, ID: %d.\n", cid));1966 dprintk((KERN_DEBUG "INQUIRY command, ID: %d.\n", cid));
1940 memset(&inq_data, 0, sizeof (struct inquiry_data));1967 memset(&inq_data, 0, sizeof (struct inquiry_data));
1941 1968
1942 if (scsicmd->cmnd[1] & 0x1 ) {1969 if (scsicmd->cmnd[1] & 0x1) {
1943 char *arr = (char *)&inq_data;1970 char *arr = (char *)&inq_data;
1944 1971
1945 /* EVPD bit set */1972 /* EVPD bit set */
@@ -1974,10 +2001,9 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) · 28 unmodified lines
1974 ASENCODE_NO_SENSE, 0, 7, 2, 0);2001 ASENCODE_NO_SENSE, 0, 7, 2, 0);
1975 memcpy(scsicmd->sense_buffer,2002 memcpy(scsicmd->sense_buffer,
1976 &dev->fsa_dev[cid].sense_data,2003 &dev->fsa_dev[cid].sense_data,
1977 (sizeof(dev->fsa_dev[cid].sense_data) >2004 min_t(size_t,
1978 sizeof(scsicmd->sense_buffer))2005 sizeof(dev->fsa_dev[cid].sense_data),
1979 ? sizeof(scsicmd->sense_buffer)2006 SCSI_SENSE_BUFFERSIZE));
1980 : sizeof(dev->fsa_dev[cid].sense_data));
1981 }2007 }
1982 scsicmd->scsi_done(scsicmd);2008 scsicmd->scsi_done(scsicmd);
1983 return 0;2009 return 0;
@@ -2092,7 +2118,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) · 108 unmodified lines
2092 mode_buf[2] = 0; /* Device-specific param,2118 mode_buf[2] = 0; /* Device-specific param,
2093 bit 8: 0/1 = write enabled/protected2119 bit 8: 0/1 = write enabled/protected
2094 bit 4: 0/1 = FUA enabled */2120 bit 4: 0/1 = FUA enabled */
2095 if (dev->raw_io_interface)2121 if (dev->raw_io_interface && ((aac_cache & 5) != 1))
2096 mode_buf[2] = 0x10;2122 mode_buf[2] = 0x10;
2097 mode_buf[3] = 0; /* Block descriptor length */2123 mode_buf[3] = 0; /* Block descriptor length */
2098 if (((scsicmd->cmnd[2] & 0x3f) == 8) ||2124 if (((scsicmd->cmnd[2] & 0x3f) == 8) ||
@@ -2100,7 +2126,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) · 1 unmodified line
2100 mode_buf[0] = 6;2126 mode_buf[0] = 6;
2101 mode_buf[4] = 8;2127 mode_buf[4] = 8;
2102 mode_buf[5] = 1;2128 mode_buf[5] = 1;
2103 mode_buf[6] = 0x04; /* WCE */2129 mode_buf[6] = ((aac_cache & 6) == 2)
2130 ? 0 : 0x04; /* WCE */
2104 mode_buf_length = 7;2131 mode_buf_length = 7;
2105 if (mode_buf_length > scsicmd->cmnd[4])2132 if (mode_buf_length > scsicmd->cmnd[4])
2106 mode_buf_length = scsicmd->cmnd[4];2133 mode_buf_length = scsicmd->cmnd[4];
@@ -2123,7 +2150,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) · 16 unmodified lines
2123 mode_buf[3] = 0; /* Device-specific param,2150 mode_buf[3] = 0; /* Device-specific param,
2124 bit 8: 0/1 = write enabled/protected2151 bit 8: 0/1 = write enabled/protected
2125 bit 4: 0/1 = FUA enabled */2152 bit 4: 0/1 = FUA enabled */
2126 if (dev->raw_io_interface)2153 if (dev->raw_io_interface && ((aac_cache & 5) != 1))
2127 mode_buf[3] = 0x10;2154 mode_buf[3] = 0x10;
2128 mode_buf[4] = 0; /* reserved */2155 mode_buf[4] = 0; /* reserved */
2129 mode_buf[5] = 0; /* reserved */2156 mode_buf[5] = 0; /* reserved */
@@ -2134,7 +2161,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) · 4 unmodified lines
2134 mode_buf[1] = 9;2161 mode_buf[1] = 9;
2135 mode_buf[8] = 8;2162 mode_buf[8] = 8;
2136 mode_buf[9] = 1;2163 mode_buf[9] = 1;
2137 mode_buf[10] = 0x04; /* WCE */2164 mode_buf[10] = ((aac_cache & 6) == 2)
2165 ? 0 : 0x04; /* WCE */
2138 mode_buf_length = 11;2166 mode_buf_length = 11;
2139 if (mode_buf_length > scsicmd->cmnd[8])2167 if (mode_buf_length > scsicmd->cmnd[8])
2140 mode_buf_length = scsicmd->cmnd[8];2168 mode_buf_length = scsicmd->cmnd[8];
@@ -2179,7 +2207,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) · 38 unmodified lines
2179 return 0;2207 return 0;
2180 }2208 }
2181 2209
2182 switch (scsicmd->cmnd[0]) 2210 switch (scsicmd->cmnd[0])
2183 {2211 {
2184 case READ_6:2212 case READ_6:
2185 case READ_10:2213 case READ_10:
@@ -2192,11 +2220,11 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) · 6 unmodified lines
2192 * corresponds to a container. Needed to convert2220 * corresponds to a container. Needed to convert
2193 * containers to /dev/sd device names2221 * containers to /dev/sd device names
2194 */2222 */
2195 2223
2196 if (scsicmd->request->rq_disk)2224 if (scsicmd->request->rq_disk)
2197 strlcpy(fsa_dev_ptr[cid].devname,2225 strlcpy(fsa_dev_ptr[cid].devname,
2198 scsicmd->request->rq_disk->disk_name,2226 scsicmd->request->rq_disk->disk_name,
2199 min(sizeof(fsa_dev_ptr[cid].devname),2227 min(sizeof(fsa_dev_ptr[cid].devname),
2200 sizeof(scsicmd->request->rq_disk->disk_name) + 1));2228 sizeof(scsicmd->request->rq_disk->disk_name) + 1));
2201 2229
2202 return aac_read(scsicmd);2230 return aac_read(scsicmd);
@@ -2210,9 +2238,16 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) · 7 unmodified lines
2210 return aac_write(scsicmd);2238 return aac_write(scsicmd);
2211 2239
2212 case SYNCHRONIZE_CACHE:2240 case SYNCHRONIZE_CACHE:
2241 if (((aac_cache & 6) == 6) && dev->cache_protected) {
2242 scsicmd->result = DID_OK << 16 |
2243 COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
2244 scsicmd->scsi_done(scsicmd);
2245 return 0;
2246 }
2213 /* Issue FIB to tell Firmware to flush it's cache */2247 /* Issue FIB to tell Firmware to flush it's cache */
2214 return aac_synchronize(scsicmd);2248 if ((aac_cache & 6) != 2)
2215 2249 return aac_synchronize(scsicmd);
2250 /* FALLTHRU */
2216 default:2251 default:
2217 /*2252 /*
2218 * Unhandled commands2253 * Unhandled commands
@@ -2223,9 +2258,9 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) · 4 unmodified lines
2223 ILLEGAL_REQUEST, SENCODE_INVALID_COMMAND,2258 ILLEGAL_REQUEST, SENCODE_INVALID_COMMAND,
2224 ASENCODE_INVALID_COMMAND, 0, 0, 0, 0);2259 ASENCODE_INVALID_COMMAND, 0, 0, 0, 0);
2225 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,2260 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
2226 (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer))2261 min_t(size_t,
2227 ? sizeof(scsicmd->sense_buffer)2262 sizeof(dev->fsa_dev[cid].sense_data),
2228 : sizeof(dev->fsa_dev[cid].sense_data));2263 SCSI_SENSE_BUFFERSIZE));
2229 scsicmd->scsi_done(scsicmd);2264 scsicmd->scsi_done(scsicmd);
2230 return 0;2265 return 0;
2231 }2266 }
@@ -2243,7 +2278,7 @@ static int query_disk(struct aac_dev *dev, void __user *arg) · 11 unmodified lines
2243 return -EFAULT;2278 return -EFAULT;
2244 if (qd.cnum == -1)2279 if (qd.cnum == -1)
2245 qd.cnum = qd.id;2280 qd.cnum = qd.id;
2246 else if ((qd.bus == -1) && (qd.id == -1) && (qd.lun == -1)) 2281 else if ((qd.bus == -1) && (qd.id == -1) && (qd.lun == -1))
2247 {2282 {
2248 if (qd.cnum < 0 || qd.cnum >= dev->maximum_num_containers)2283 if (qd.cnum < 0 || qd.cnum >= dev->maximum_num_containers)
2249 return -EINVAL;2284 return -EINVAL;
@@ -2370,7 +2405,7 @@ static void aac_srb_callback(void *context, struct fib * fibptr) · 120 unmodified lines
2370 2405
2371 scsicmd->sense_buffer[0] = '\0'; /* Initialize sense valid flag to false */2406 scsicmd->sense_buffer[0] = '\0'; /* Initialize sense valid flag to false */
2372 /*2407 /*
2373 * Calculate resid for sg 2408 * Calculate resid for sg
2374 */2409 */
2375 2410
2376 scsi_set_resid(scsicmd, scsi_bufflen(scsicmd)2411 scsi_set_resid(scsicmd, scsi_bufflen(scsicmd)
@@ -2385,10 +2420,8 @@ static void aac_srb_callback(void *context, struct fib * fibptr) · 8 unmodified lines
2385 if (le32_to_cpu(srbreply->status) != ST_OK){2420 if (le32_to_cpu(srbreply->status) != ST_OK){
2386 int len;2421 int len;
2387 printk(KERN_WARNING "aac_srb_callback: srb failed, status = %d\n", le32_to_cpu(srbreply->status));2422 printk(KERN_WARNING "aac_srb_callback: srb failed, status = %d\n", le32_to_cpu(srbreply->status));
2388 len = (le32_to_cpu(srbreply->sense_data_size) > 2423 len = min_t(u32, le32_to_cpu(srbreply->sense_data_size),
2389 sizeof(scsicmd->sense_buffer)) ?2424 SCSI_SENSE_BUFFERSIZE);
2390 sizeof(scsicmd->sense_buffer) :
2391 le32_to_cpu(srbreply->sense_data_size);
2392 scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;2425 scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
2393 memcpy(scsicmd->sense_buffer, srbreply->sense_data, len);2426 memcpy(scsicmd->sense_buffer, srbreply->sense_data, len);
2394 }2427 }
@@ -2412,7 +2445,7 @@ static void aac_srb_callback(void *context, struct fib * fibptr) · 17 unmodified lines
2412 case WRITE_12:2445 case WRITE_12:
2413 case READ_16:2446 case READ_16:
2414 case WRITE_16:2447 case WRITE_16:
2415 if(le32_to_cpu(srbreply->data_xfer_length) < scsicmd->underflow ) {2448 if (le32_to_cpu(srbreply->data_xfer_length) < scsicmd->underflow) {
2416 printk(KERN_WARNING"aacraid: SCSI CMD underflow\n");2449 printk(KERN_WARNING"aacraid: SCSI CMD underflow\n");
2417 } else {2450 } else {
2418 printk(KERN_WARNING"aacraid: SCSI CMD Data Overrun\n");2451 printk(KERN_WARNING"aacraid: SCSI CMD Data Overrun\n");
@@ -2481,26 +2514,23 @@ static void aac_srb_callback(void *context, struct fib * fibptr) · 62 unmodified lines
2481 printk("aacraid: SRB ERROR(%u) %s scsi cmd 0x%x - scsi status 0x%x\n",2514 printk("aacraid: SRB ERROR(%u) %s scsi cmd 0x%x - scsi status 0x%x\n",
2482 le32_to_cpu(srbreply->srb_status) & 0x3F,2515 le32_to_cpu(srbreply->srb_status) & 0x3F,
2483 aac_get_status_string(2516 aac_get_status_string(
2484 le32_to_cpu(srbreply->srb_status) & 0x3F), 2517 le32_to_cpu(srbreply->srb_status) & 0x3F),
2485 scsicmd->cmnd[0], 2518 scsicmd->cmnd[0],
2486 le32_to_cpu(srbreply->scsi_status));2519 le32_to_cpu(srbreply->scsi_status));
2487#endif2520#endif
2488 scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8;2521 scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8;
2489 break;2522 break;
2490 }2523 }
2491 if (le32_to_cpu(srbreply->scsi_status) == 0x02 ){ // Check Condition2524 if (le32_to_cpu(srbreply->scsi_status) == SAM_STAT_CHECK_CONDITION) {
2492 int len;2525 int len;
2493 scsicmd->result |= SAM_STAT_CHECK_CONDITION;2526 scsicmd->result |= SAM_STAT_CHECK_CONDITION;
2494 len = (le32_to_cpu(srbreply->sense_data_size) > 2527 len = min_t(u32, le32_to_cpu(srbreply->sense_data_size),
2495 sizeof(scsicmd->sense_buffer)) ?2528 SCSI_SENSE_BUFFERSIZE);
2496 sizeof(scsicmd->sense_buffer) :
2497 le32_to_cpu(srbreply->sense_data_size);
2498#ifdef AAC_DETAILED_STATUS_INFO2529#ifdef AAC_DETAILED_STATUS_INFO
2499 printk(KERN_WARNING "aac_srb_callback: check condition, status = %d len=%d\n",2530 printk(KERN_WARNING "aac_srb_callback: check condition, status = %d len=%d\n",
2500 le32_to_cpu(srbreply->status), len);2531 le32_to_cpu(srbreply->status), len);
2501#endif2532#endif
2502 memcpy(scsicmd->sense_buffer, srbreply->sense_data, len);2533 memcpy(scsicmd->sense_buffer, srbreply->sense_data, len);
2503
2504 }2534 }
2505 /*2535 /*
2506 * OR in the scsi status (already shifted up a bit)2536 * OR in the scsi status (already shifted up a bit)
@@ -2517,7 +2547,7 @@ static void aac_srb_callback(void *context, struct fib * fibptr) · 10 unmodified lines
2517 * aac_send_scb_fib2547 * aac_send_scb_fib
2518 * @scsicmd: the scsi command block2548 * @scsicmd: the scsi command block
2519 *2549 *
2520 * This routine will form a FIB and fill in the aac_srb from the 2550 * This routine will form a FIB and fill in the aac_srb from the
2521 * scsicmd passed in.2551 * scsicmd passed in.
2522 */2552 */
2523 2553
@@ -2731,7 +2761,7 @@ static struct aac_srb_status_info srb_status_info[] = { · 207 unmodified lines
2731 { SRB_STATUS_ERROR_RECOVERY, "Error Recovery"},2761 { SRB_STATUS_ERROR_RECOVERY, "Error Recovery"},
2732 { SRB_STATUS_NOT_STARTED, "Not Started"},2762 { SRB_STATUS_NOT_STARTED, "Not Started"},
2733 { SRB_STATUS_NOT_IN_USE, "Not In Use"},2763 { SRB_STATUS_NOT_IN_USE, "Not In Use"},
2734 { SRB_STATUS_FORCE_ABORT, "Force Abort"},2764 { SRB_STATUS_FORCE_ABORT, "Force Abort"},
2735 { SRB_STATUS_DOMAIN_VALIDATION_FAIL,"Domain Validation Failure"},2765 { SRB_STATUS_DOMAIN_VALIDATION_FAIL,"Domain Validation Failure"},
2736 { 0xff, "Unknown Error"}2766 { 0xff, "Unknown Error"}
2737};2767};
drivers/scsi/aacraid/aacraid.h+174−161
@@ -1,4 +1,4 @@
1#if (!defined(dprintk))1#ifndef dprintk
2# define dprintk(x)2# define dprintk(x)
3#endif3#endif
4/* eg: if (nblank(dprintk(x))) */4/* eg: if (nblank(dprintk(x))) */
@@ -12,7 +12,7 @@ · 7 unmodified lines
12 *----------------------------------------------------------------------------*/12 *----------------------------------------------------------------------------*/
13 13
14#ifndef AAC_DRIVER_BUILD14#ifndef AAC_DRIVER_BUILD
15# define AAC_DRIVER_BUILD 244915# define AAC_DRIVER_BUILD 2455
16# define AAC_DRIVER_BRANCH "-ms"16# define AAC_DRIVER_BRANCH "-ms"
17#endif17#endif
18#define MAXIMUM_NUM_CONTAINERS 3218#define MAXIMUM_NUM_CONTAINERS 32
@@ -50,9 +50,9 @@ struct diskparm · 31 unmodified lines
50/*50/*
51 * Firmware constants51 * Firmware constants
52 */52 */
53 53
54#define CT_NONE 054#define CT_NONE 0
55#define CT_OK 21855#define CT_OK 218
56#define FT_FILESYS 8 /* ADAPTEC's "FSA"(tm) filesystem */56#define FT_FILESYS 8 /* ADAPTEC's "FSA"(tm) filesystem */
57#define FT_DRIVE 9 /* physical disk - addressable in scsi by bus/id/lun */57#define FT_DRIVE 9 /* physical disk - addressable in scsi by bus/id/lun */
58 58
@@ -107,12 +107,12 @@ struct user_sgentryraw { · 48 unmodified lines
107 107
108struct sgmap {108struct sgmap {
109 __le32 count;109 __le32 count;
110 struct sgentry sg[1]; 110 struct sgentry sg[1];
111};111};
112 112
113struct user_sgmap {113struct user_sgmap {
114 u32 count;114 u32 count;
115 struct user_sgentry sg[1]; 115 struct user_sgentry sg[1];
116};116};
117 117
118struct sgmap64 {118struct sgmap64 {
@@ -137,18 +137,18 @@ struct user_sgmapraw { · 18 unmodified lines
137 137
138struct creation_info138struct creation_info
139{139{
140 u8 buildnum; /* e.g., 588 */140 u8 buildnum; /* e.g., 588 */
141 u8 usec; /* e.g., 588 */141 u8 usec; /* e.g., 588 */
142 u8 via; /* e.g., 1 = FSU,142 u8 via; /* e.g., 1 = FSU,
143 * 2 = API143 * 2 = API
144 */144 */
145 u8 year; /* e.g., 1997 = 97 */145 u8 year; /* e.g., 1997 = 97 */
146 __le32 date; /*146 __le32 date; /*
147 * unsigned Month :4; // 1 - 12147 * unsigned Month :4; // 1 - 12
148 * unsigned Day :6; // 1 - 32148 * unsigned Day :6; // 1 - 32
149 * unsigned Hour :6; // 0 - 23149 * unsigned Hour :6; // 0 - 23
150 * unsigned Minute :6; // 0 - 60150 * unsigned Minute :6; // 0 - 60
151 * unsigned Second :6; // 0 - 60151 * unsigned Second :6; // 0 - 60
152 */152 */
153 __le32 serial[2]; /* e.g., 0x1DEADB0BFAFAF001 */153 __le32 serial[2]; /* e.g., 0x1DEADB0BFAFAF001 */
154};154};
@@ -184,7 +184,7 @@ struct creation_info · 29 unmodified lines
184/*184/*
185 * Set the queues on a 16 byte alignment185 * Set the queues on a 16 byte alignment
186 */186 */
187 187
188#define QUEUE_ALIGNMENT 16188#define QUEUE_ALIGNMENT 16
189 189
190/*190/*
@@ -203,9 +203,9 @@ struct aac_entry { · 12 unmodified lines
203 * The adapter assumes the ProducerIndex and ConsumerIndex are grouped203 * The adapter assumes the ProducerIndex and ConsumerIndex are grouped
204 * adjacently and in that order.204 * adjacently and in that order.
205 */205 */
206 206
207struct aac_qhdr {207struct aac_qhdr {
208 __le64 header_addr;/* Address to hand the adapter to access 208 __le64 header_addr;/* Address to hand the adapter to access
209 to this queue head */209 to this queue head */
210 __le32 *producer; /* The producer index for this queue (host address) */210 __le32 *producer; /* The producer index for this queue (host address) */
211 __le32 *consumer; /* The consumer index for this queue (host address) */211 __le32 *consumer; /* The consumer index for this queue (host address) */
@@ -215,7 +215,7 @@ struct aac_qhdr { · 3 unmodified lines
215 * Define all the events which the adapter would like to notify215 * Define all the events which the adapter would like to notify
216 * the host of.216 * the host of.
217 */217 */
218 218
219#define HostNormCmdQue 1 /* Change in host normal priority command queue */219#define HostNormCmdQue 1 /* Change in host normal priority command queue */
220#define HostHighCmdQue 2 /* Change in host high priority command queue */220#define HostHighCmdQue 2 /* Change in host high priority command queue */
221#define HostNormRespQue 3 /* Change in host normal priority response queue */221#define HostNormRespQue 3 /* Change in host normal priority response queue */
@@ -286,17 +286,17 @@ struct aac_fibhdr { · 64 unmodified lines
286 u8 StructType; /* Type FIB */286 u8 StructType; /* Type FIB */
287 u8 Flags; /* Flags for FIB */287 u8 Flags; /* Flags for FIB */
288 __le16 Size; /* Size of this FIB in bytes */288 __le16 Size; /* Size of this FIB in bytes */
289 __le16 SenderSize; /* Size of the FIB in the sender 289 __le16 SenderSize; /* Size of the FIB in the sender
290 (for response sizing) */290 (for response sizing) */
291 __le32 SenderFibAddress; /* Host defined data in the FIB */291 __le32 SenderFibAddress; /* Host defined data in the FIB */
292 __le32 ReceiverFibAddress;/* Logical address of this FIB for 292 __le32 ReceiverFibAddress;/* Logical address of this FIB for
293 the adapter */293 the adapter */
294 u32 SenderData; /* Place holder for the sender to store data */294 u32 SenderData; /* Place holder for the sender to store data */
295 union {295 union {
296 struct {296 struct {
297 __le32 _ReceiverTimeStart; /* Timestamp for 297 __le32 _ReceiverTimeStart; /* Timestamp for
298 receipt of fib */298 receipt of fib */
299 __le32 _ReceiverTimeDone; /* Timestamp for 299 __le32 _ReceiverTimeDone; /* Timestamp for
300 completion of fib */300 completion of fib */
301 } _s;301 } _s;
302 } _u;302 } _u;
@@ -311,7 +311,7 @@ struct hw_fib { · 8 unmodified lines
311 * FIB commands311 * FIB commands
312 */312 */
313 313
314#define TestCommandResponse 1314#define TestCommandResponse 1
315#define TestAdapterCommand 2315#define TestAdapterCommand 2
316/*316/*
317 * Lowlevel and comm commands317 * Lowlevel and comm commands
@@ -349,10 +349,6 @@ struct hw_fib { · 31 unmodified lines
349#define ContainerCommand 500349#define ContainerCommand 500
350#define ContainerCommand64 501350#define ContainerCommand64 501
351#define ContainerRawIo 502351#define ContainerRawIo 502
352/*
353 * Cluster Commands
354 */
355#define ClusterCommand 550
356/*352/*
357 * Scsi Port commands (scsi passthrough)353 * Scsi Port commands (scsi passthrough)
358 */354 */
@@ -375,19 +371,19 @@ struct hw_fib { · 16 unmodified lines
375 */371 */
376 372
377enum fib_xfer_state {373enum fib_xfer_state {
378 HostOwned = (1<<0),374 HostOwned = (1<<0),
379 AdapterOwned = (1<<1),375 AdapterOwned = (1<<1),
380 FibInitialized = (1<<2),376 FibInitialized = (1<<2),
381 FibEmpty = (1<<3),377 FibEmpty = (1<<3),
382 AllocatedFromPool = (1<<4),378 AllocatedFromPool = (1<<4),
383 SentFromHost = (1<<5),379 SentFromHost = (1<<5),
384 SentFromAdapter = (1<<6),380 SentFromAdapter = (1<<6),
385 ResponseExpected = (1<<7),381 ResponseExpected = (1<<7),
386 NoResponseExpected = (1<<8),382 NoResponseExpected = (1<<8),
387 AdapterProcessed = (1<<9),383 AdapterProcessed = (1<<9),
388 HostProcessed = (1<<10),384 HostProcessed = (1<<10),
389 HighPriority = (1<<11),385 HighPriority = (1<<11),
390 NormalPriority = (1<<12),386 NormalPriority = (1<<12),
391 Async = (1<<13),387 Async = (1<<13),
392 AsyncIo = (1<<13), // rpbfix: remove with new regime388 AsyncIo = (1<<13), // rpbfix: remove with new regime
393 PageFileIo = (1<<14), // rpbfix: remove with new regime389 PageFileIo = (1<<14), // rpbfix: remove with new regime
@@ -420,7 +416,7 @@ struct aac_init · 26 unmodified lines
420 __le32 AdapterFibAlign;416 __le32 AdapterFibAlign;
421 __le32 printfbuf;417 __le32 printfbuf;
422 __le32 printfbufsiz;418 __le32 printfbufsiz;
423 __le32 HostPhysMemPages; /* number of 4k pages of host 419 __le32 HostPhysMemPages; /* number of 4k pages of host
424 physical memory */420 physical memory */
425 __le32 HostElapsedSeconds; /* number of seconds since 1970. */421 __le32 HostElapsedSeconds; /* number of seconds since 1970. */
426 /*422 /*
@@ -481,7 +477,7 @@ struct adapter_ops · 54 unmodified lines
481 477
482struct aac_driver_ident478struct aac_driver_ident
483{479{
484 int (*init)(struct aac_dev *dev);480 int (*init)(struct aac_dev *dev);
485 char * name;481 char * name;
486 char * vname;482 char * vname;
487 char * model;483 char * model;
@@ -489,7 +485,7 @@ struct aac_driver_ident · 1 unmodified line
489 int quirks;485 int quirks;
490};486};
491/*487/*
492 * Some adapter firmware needs communication memory 488 * Some adapter firmware needs communication memory
493 * below 2gig. This tells the init function to set the489 * below 2gig. This tells the init function to set the
494 * dma mask such that fib memory will be allocated where the490 * dma mask such that fib memory will be allocated where the
495 * adapter firmware can get to it.491 * adapter firmware can get to it.
@@ -520,34 +516,40 @@ struct aac_driver_ident · 24 unmodified lines
520 */516 */
521#define AAC_QUIRK_17SG 0x0010517#define AAC_QUIRK_17SG 0x0010
522 518
519/*
520 * Some adapter firmware does not support 64 bit scsi passthrough
521 * commands.
522 */
523#define AAC_QUIRK_SCSI_32 0x0020
524
523/*525/*
524 * The adapter interface specs all queues to be located in the same526 * The adapter interface specs all queues to be located in the same
525 * physically contigous block. The host structure that defines the527 * physically contigous block. The host structure that defines the
526 * commuication queues will assume they are each a separate physically528 * commuication queues will assume they are each a separate physically
527 * contigous memory region that will support them all being one big529 * contigous memory region that will support them all being one big
528 * contigous block. 530 * contigous block.
529 * There is a command and response queue for each level and direction of531 * There is a command and response queue for each level and direction of
530 * commuication. These regions are accessed by both the host and adapter.532 * commuication. These regions are accessed by both the host and adapter.
531 */533 */
532 534
533struct aac_queue {535struct aac_queue {
534 u64 logical; /*address we give the adapter */536 u64 logical; /*address we give the adapter */
535 struct aac_entry *base; /*system virtual address */537 struct aac_entry *base; /*system virtual address */
536 struct aac_qhdr headers; /*producer,consumer q headers*/538 struct aac_qhdr headers; /*producer,consumer q headers*/
537 u32 entries; /*Number of queue entries */539 u32 entries; /*Number of queue entries */
538 wait_queue_head_t qfull; /*Event to wait on if q full */540 wait_queue_head_t qfull; /*Event to wait on if q full */
539 wait_queue_head_t cmdready; /*Cmd ready from the adapter */541 wait_queue_head_t cmdready; /*Cmd ready from the adapter */
540 /* This is only valid for adapter to host command queues. */ 542 /* This is only valid for adapter to host command queues. */
541 spinlock_t *lock; /* Spinlock for this queue must take this lock before accessing the lock */543 spinlock_t *lock; /* Spinlock for this queue must take this lock before accessing the lock */
542 spinlock_t lockdata; /* Actual lock (used only on one side of the lock) */544 spinlock_t lockdata; /* Actual lock (used only on one side of the lock) */
543 struct list_head cmdq; /* A queue of FIBs which need to be prcessed by the FS thread. This is */545 struct list_head cmdq; /* A queue of FIBs which need to be prcessed by the FS thread. This is */
544 /* only valid for command queues which receive entries from the adapter. */546 /* only valid for command queues which receive entries from the adapter. */
545 u32 numpending; /* Number of entries on outstanding queue. */547 u32 numpending; /* Number of entries on outstanding queue. */
546 struct aac_dev * dev; /* Back pointer to adapter structure */548 struct aac_dev * dev; /* Back pointer to adapter structure */
547};549};
548 550
549/*551/*
550 * Message queues. The order here is important, see also the 552 * Message queues. The order here is important, see also the
551 * queue type ordering553 * queue type ordering
552 */554 */
553 555
@@ -559,12 +561,12 @@ struct aac_queue_block · 5 unmodified lines
559/*561/*
560 * SaP1 Message Unit Registers562 * SaP1 Message Unit Registers
561 */563 */
562 564
563struct sa_drawbridge_CSR {565struct sa_drawbridge_CSR {
564 /* Offset | Name */566 /* Offset | Name */
565 __le32 reserved[10]; /* 00h-27h | Reserved */567 __le32 reserved[10]; /* 00h-27h | Reserved */
566 u8 LUT_Offset; /* 28h | Lookup Table Offset */568 u8 LUT_Offset; /* 28h | Lookup Table Offset */
567 u8 reserved1[3]; /* 29h-2bh | Reserved */569 u8 reserved1[3]; /* 29h-2bh | Reserved */
568 __le32 LUT_Data; /* 2ch | Looup Table Data */570 __le32 LUT_Data; /* 2ch | Looup Table Data */
569 __le32 reserved2[26]; /* 30h-97h | Reserved */571 __le32 reserved2[26]; /* 30h-97h | Reserved */
570 __le16 PRICLEARIRQ; /* 98h | Primary Clear Irq */572 __le16 PRICLEARIRQ; /* 98h | Primary Clear Irq */
@@ -583,8 +585,8 @@ struct sa_drawbridge_CSR { · 12 unmodified lines
583 __le32 MAILBOX5; /* bch | Scratchpad 5 */585 __le32 MAILBOX5; /* bch | Scratchpad 5 */
584 __le32 MAILBOX6; /* c0h | Scratchpad 6 */586 __le32 MAILBOX6; /* c0h | Scratchpad 6 */
585 __le32 MAILBOX7; /* c4h | Scratchpad 7 */587 __le32 MAILBOX7; /* c4h | Scratchpad 7 */
586 __le32 ROM_Setup_Data; /* c8h | Rom Setup and Data */588 __le32 ROM_Setup_Data; /* c8h | Rom Setup and Data */
587 __le32 ROM_Control_Addr;/* cch | Rom Control and Address */589 __le32 ROM_Control_Addr;/* cch | Rom Control and Address */
588 __le32 reserved3[12]; /* d0h-ffh | reserved */590 __le32 reserved3[12]; /* d0h-ffh | reserved */
589 __le32 LUT[64]; /* 100h-1ffh | Lookup Table Entries */591 __le32 LUT[64]; /* 100h-1ffh | Lookup Table Entries */
590};592};
@@ -597,7 +599,7 @@ struct sa_drawbridge_CSR { · 6 unmodified lines
597#define Mailbox5 SaDbCSR.MAILBOX5599#define Mailbox5 SaDbCSR.MAILBOX5
598#define Mailbox6 SaDbCSR.MAILBOX6600#define Mailbox6 SaDbCSR.MAILBOX6
599#define Mailbox7 SaDbCSR.MAILBOX7601#define Mailbox7 SaDbCSR.MAILBOX7
600 602
601#define DoorbellReg_p SaDbCSR.PRISETIRQ603#define DoorbellReg_p SaDbCSR.PRISETIRQ
602#define DoorbellReg_s SaDbCSR.SECSETIRQ604#define DoorbellReg_s SaDbCSR.SECSETIRQ
603#define DoorbellClrReg_p SaDbCSR.PRICLEARIRQ605#define DoorbellClrReg_p SaDbCSR.PRICLEARIRQ
@@ -611,19 +613,19 @@ struct sa_drawbridge_CSR { · 7 unmodified lines
611#define DOORBELL_5 0x0020613#define DOORBELL_5 0x0020
612#define DOORBELL_6 0x0040614#define DOORBELL_6 0x0040
613 615
614 616
615#define PrintfReady DOORBELL_5617#define PrintfReady DOORBELL_5
616#define PrintfDone DOORBELL_5618#define PrintfDone DOORBELL_5
617 619
618struct sa_registers {620struct sa_registers {
619 struct sa_drawbridge_CSR SaDbCSR; /* 98h - c4h */621 struct sa_drawbridge_CSR SaDbCSR; /* 98h - c4h */
620};622};
621 623
622 624
623#define Sa_MINIPORT_REVISION 1625#define Sa_MINIPORT_REVISION 1
624 626
625#define sa_readw(AEP, CSR) readl(&((AEP)->regs.sa->CSR))627#define sa_readw(AEP, CSR) readl(&((AEP)->regs.sa->CSR))
626#define sa_readl(AEP, CSR) readl(&((AEP)->regs.sa->CSR))628#define sa_readl(AEP, CSR) readl(&((AEP)->regs.sa->CSR))
627#define sa_writew(AEP, CSR, value) writew(value, &((AEP)->regs.sa->CSR))629#define sa_writew(AEP, CSR, value) writew(value, &((AEP)->regs.sa->CSR))
628#define sa_writel(AEP, CSR, value) writel(value, &((AEP)->regs.sa->CSR))630#define sa_writel(AEP, CSR, value) writel(value, &((AEP)->regs.sa->CSR))
629 631
@@ -640,21 +642,21 @@ struct rx_mu_registers { · 10 unmodified lines
640 __le32 IMRx[2]; /* 1310h | 10h | Inbound Message Registers */642 __le32 IMRx[2]; /* 1310h | 10h | Inbound Message Registers */
641 __le32 OMRx[2]; /* 1318h | 18h | Outbound Message Registers */643 __le32 OMRx[2]; /* 1318h | 18h | Outbound Message Registers */
642 __le32 IDR; /* 1320h | 20h | Inbound Doorbell Register */644 __le32 IDR; /* 1320h | 20h | Inbound Doorbell Register */
643 __le32 IISR; /* 1324h | 24h | Inbound Interrupt 645 __le32 IISR; /* 1324h | 24h | Inbound Interrupt
644 Status Register */646 Status Register */
645 __le32 IIMR; /* 1328h | 28h | Inbound Interrupt 647 __le32 IIMR; /* 1328h | 28h | Inbound Interrupt
646 Mask Register */648 Mask Register */
647 __le32 ODR; /* 132Ch | 2Ch | Outbound Doorbell Register */649 __le32 ODR; /* 132Ch | 2Ch | Outbound Doorbell Register */
648 __le32 OISR; /* 1330h | 30h | Outbound Interrupt 650 __le32 OISR; /* 1330h | 30h | Outbound Interrupt
649 Status Register */651 Status Register */
650 __le32 OIMR; /* 1334h | 34h | Outbound Interrupt 652 __le32 OIMR; /* 1334h | 34h | Outbound Interrupt
651 Mask Register */653 Mask Register */
652 __le32 reserved2; /* 1338h | 38h | Reserved */654 __le32 reserved2; /* 1338h | 38h | Reserved */
653 __le32 reserved3; /* 133Ch | 3Ch | Reserved */655 __le32 reserved3; /* 133Ch | 3Ch | Reserved */
654 __le32 InboundQueue;/* 1340h | 40h | Inbound Queue Port relative to firmware */656 __le32 InboundQueue;/* 1340h | 40h | Inbound Queue Port relative to firmware */
655 __le32 OutboundQueue;/*1344h | 44h | Outbound Queue Port relative to firmware */657 __le32 OutboundQueue;/*1344h | 44h | Outbound Queue Port relative to firmware */
656 /* * Must access through ATU Inbound 658 /* * Must access through ATU Inbound
657 Translation Window */659 Translation Window */
658};660};
659 661
660struct rx_inbound {662struct rx_inbound {
@@ -710,12 +712,12 @@ struct rkt_registers { · 49 unmodified lines
710typedef void (*fib_callback)(void *ctxt, struct fib *fibctx);712typedef void (*fib_callback)(void *ctxt, struct fib *fibctx);
711 713
712struct aac_fib_context {714struct aac_fib_context {
713 s16 type; // used for verification of structure 715 s16 type; // used for verification of structure
714 s16 size;716 s16 size;
715 u32 unique; // unique value representing this context717 u32 unique; // unique value representing this context
716 ulong jiffies; // used for cleanup - dmb changed to ulong718 ulong jiffies; // used for cleanup - dmb changed to ulong
717 struct list_head next; // used to link context's into a linked list719 struct list_head next; // used to link context's into a linked list
718 struct semaphore wait_sem; // this is used to wait for the next fib to arrive.720 struct semaphore wait_sem; // this is used to wait for the next fib to arrive.
719 int wait; // Set to true when thread is in WaitForSingleObject721 int wait; // Set to true when thread is in WaitForSingleObject
720 unsigned long count; // total number of FIBs on FibList722 unsigned long count; // total number of FIBs on FibList
721 struct list_head fib_list; // this holds fibs and their attachd hw_fibs723 struct list_head fib_list; // this holds fibs and their attachd hw_fibs
@@ -734,9 +736,9 @@ struct sense_data { · 12 unmodified lines
734 u8 EOM:1; /* End Of Medium - reserved for random access devices */736 u8 EOM:1; /* End Of Medium - reserved for random access devices */
735 u8 filemark:1; /* Filemark - reserved for random access devices */737 u8 filemark:1; /* Filemark - reserved for random access devices */
736 738
737 u8 information[4]; /* for direct-access devices, contains the unsigned 739 u8 information[4]; /* for direct-access devices, contains the unsigned
738 * logical block address or residue associated with 740 * logical block address or residue associated with
739 * the sense key 741 * the sense key
740 */742 */
741 u8 add_sense_len; /* number of additional sense bytes to follow this field */743 u8 add_sense_len; /* number of additional sense bytes to follow this field */
742 u8 cmnd_info[4]; /* not used */744 u8 cmnd_info[4]; /* not used */
@@ -746,7 +748,7 @@ struct sense_data { · 3 unmodified lines
746 u8 bit_ptr:3; /* indicates which byte of the CDB or parameter data748 u8 bit_ptr:3; /* indicates which byte of the CDB or parameter data
747 * was in error749 * was in error
748 */750 */
749 u8 BPV:1; /* bit pointer valid (BPV): 1- indicates that 751 u8 BPV:1; /* bit pointer valid (BPV): 1- indicates that
750 * the bit_ptr field has valid value752 * the bit_ptr field has valid value
751 */753 */
752 u8 reserved2:2;754 u8 reserved2:2;
@@ -780,24 +782,24 @@ struct fib { · 27 unmodified lines
780 /*782 /*
781 * The Adapter that this I/O is destined for.783 * The Adapter that this I/O is destined for.
782 */784 */
783 struct aac_dev *dev;785 struct aac_dev *dev;
784 /*786 /*
785 * This is the event the sendfib routine will wait on if the787 * This is the event the sendfib routine will wait on if the
786 * caller did not pass one and this is synch io.788 * caller did not pass one and this is synch io.
787 */789 */
788 struct semaphore event_wait;790 struct semaphore event_wait;
789 spinlock_t event_lock;791 spinlock_t event_lock;
790 792
791 u32 done; /* gets set to 1 when fib is complete */793 u32 done; /* gets set to 1 when fib is complete */
792 fib_callback callback;794 fib_callback callback;
793 void *callback_data;795 void *callback_data;
794 u32 flags; // u32 dmb was ulong796 u32 flags; // u32 dmb was ulong
795 /*797 /*
796 * And for the internal issue/reply queues (we may be able798 * And for the internal issue/reply queues (we may be able
797 * to merge these two)799 * to merge these two)
798 */800 */
799 struct list_head fiblink;801 struct list_head fiblink;
800 void *data;802 void *data;
801 struct hw_fib *hw_fib_va; /* Actual shared object */803 struct hw_fib *hw_fib_va; /* Actual shared object */
802 dma_addr_t hw_fib_pa; /* physical address of hw_fib*/804 dma_addr_t hw_fib_pa; /* physical address of hw_fib*/
803};805};
@@ -807,7 +809,7 @@ struct fib { · 3 unmodified lines
807 *809 *
808 * This is returned by the RequestAdapterInfo block810 * This is returned by the RequestAdapterInfo block
809 */811 */
810 812
811struct aac_adapter_info813struct aac_adapter_info
812{814{
813 __le32 platform;815 __le32 platform;
@@ -826,7 +828,7 @@ struct aac_adapter_info · 12 unmodified lines
826 __le32 biosrev;828 __le32 biosrev;
827 __le32 biosbuild;829 __le32 biosbuild;
828 __le32 cluster;830 __le32 cluster;
829 __le32 clusterchannelmask; 831 __le32 clusterchannelmask;
830 __le32 serial[2];832 __le32 serial[2];
831 __le32 battery;833 __le32 battery;
832 __le32 options;834 __le32 options;
@@ -863,9 +865,10 @@ struct aac_supplement_adapter_info · 30 unmodified lines
863 __le32 SupportedOptions2;865 __le32 SupportedOptions2;
864 __le32 ReservedGrowth[1];866 __le32 ReservedGrowth[1];
865};867};
866#define AAC_FEATURE_FALCON 0x00000010868#define AAC_FEATURE_FALCON cpu_to_le32(0x00000010)
867#define AAC_OPTION_MU_RESET 0x00000001869#define AAC_FEATURE_JBOD cpu_to_le32(0x08000000)
868#define AAC_OPTION_IGNORE_RESET 0x00000002870#define AAC_OPTION_MU_RESET cpu_to_le32(0x00000001)
871#define AAC_OPTION_IGNORE_RESET cpu_to_le32(0x00000002)
869#define AAC_SIS_VERSION_V3 3872#define AAC_SIS_VERSION_V3 3
870#define AAC_SIS_SLOT_UNKNOWN 0xFF873#define AAC_SIS_SLOT_UNKNOWN 0xFF
871 874
@@ -916,13 +919,13 @@ struct aac_bus_info_response { · 44 unmodified lines
916#define AAC_OPT_HOST_TIME_FIB cpu_to_le32(1<<4)919#define AAC_OPT_HOST_TIME_FIB cpu_to_le32(1<<4)
917#define AAC_OPT_RAID50 cpu_to_le32(1<<5)920#define AAC_OPT_RAID50 cpu_to_le32(1<<5)
918#define AAC_OPT_4GB_WINDOW cpu_to_le32(1<<6)921#define AAC_OPT_4GB_WINDOW cpu_to_le32(1<<6)
919#define AAC_OPT_SCSI_UPGRADEABLE cpu_to_le32(1<<7)922#define AAC_OPT_SCSI_UPGRADEABLE cpu_to_le32(1<<7)
920#define AAC_OPT_SOFT_ERR_REPORT cpu_to_le32(1<<8)923#define AAC_OPT_SOFT_ERR_REPORT cpu_to_le32(1<<8)
921#define AAC_OPT_SUPPORTED_RECONDITION cpu_to_le32(1<<9)924#define AAC_OPT_SUPPORTED_RECONDITION cpu_to_le32(1<<9)
922#define AAC_OPT_SGMAP_HOST64 cpu_to_le32(1<<10)925#define AAC_OPT_SGMAP_HOST64 cpu_to_le32(1<<10)
923#define AAC_OPT_ALARM cpu_to_le32(1<<11)926#define AAC_OPT_ALARM cpu_to_le32(1<<11)
924#define AAC_OPT_NONDASD cpu_to_le32(1<<12)927#define AAC_OPT_NONDASD cpu_to_le32(1<<12)
925#define AAC_OPT_SCSI_MANAGED cpu_to_le32(1<<13)928#define AAC_OPT_SCSI_MANAGED cpu_to_le32(1<<13)
926#define AAC_OPT_RAID_SCSI_MODE cpu_to_le32(1<<14)929#define AAC_OPT_RAID_SCSI_MODE cpu_to_le32(1<<14)
927#define AAC_OPT_SUPPLEMENT_ADAPTER_INFO cpu_to_le32(1<<16)930#define AAC_OPT_SUPPLEMENT_ADAPTER_INFO cpu_to_le32(1<<16)
928#define AAC_OPT_NEW_COMM cpu_to_le32(1<<17)931#define AAC_OPT_NEW_COMM cpu_to_le32(1<<17)
@@ -942,7 +945,7 @@ struct aac_dev · 13 unmodified lines
942 945
943 /*946 /*
944 * Map for 128 fib objects (64k)947 * Map for 128 fib objects (64k)
945 */ 948 */
946 dma_addr_t hw_fib_pa;949 dma_addr_t hw_fib_pa;
947 struct hw_fib *hw_fib_va;950 struct hw_fib *hw_fib_va;
948 struct hw_fib *aif_base_va;951 struct hw_fib *aif_base_va;
@@ -953,24 +956,24 @@ struct aac_dev · 4 unmodified lines
953 956
954 struct fib *free_fib;957 struct fib *free_fib;
955 spinlock_t fib_lock;958 spinlock_t fib_lock;
956 959
957 struct aac_queue_block *queues;960 struct aac_queue_block *queues;
958 /*961 /*
959 * The user API will use an IOCTL to register itself to receive962 * The user API will use an IOCTL to register itself to receive
960 * FIBs from the adapter. The following list is used to keep963 * FIBs from the adapter. The following list is used to keep
961 * track of all the threads that have requested these FIBs. The964 * track of all the threads that have requested these FIBs. The
962 * mutex is used to synchronize access to all data associated 965 * mutex is used to synchronize access to all data associated
963 * with the adapter fibs.966 * with the adapter fibs.
964 */967 */
965 struct list_head fib_list;968 struct list_head fib_list;
966 969
967 struct adapter_ops a_ops;970 struct adapter_ops a_ops;
968 unsigned long fsrev; /* Main driver's revision number */971 unsigned long fsrev; /* Main driver's revision number */
969 972
970 unsigned base_size; /* Size of mapped in region */973 unsigned base_size; /* Size of mapped in region */
971 struct aac_init *init; /* Holds initialization info to communicate with adapter */974 struct aac_init *init; /* Holds initialization info to communicate with adapter */
972 dma_addr_t init_pa; /* Holds physical address of the init struct */975 dma_addr_t init_pa; /* Holds physical address of the init struct */
973 976
974 struct pci_dev *pdev; /* Our PCI interface */977 struct pci_dev *pdev; /* Our PCI interface */
975 void * printfbuf; /* pointer to buffer used for printf's from the adapter */978 void * printfbuf; /* pointer to buffer used for printf's from the adapter */
976 void * comm_addr; /* Base address of Comm area */979 void * comm_addr; /* Base address of Comm area */
@@ -984,11 +987,11 @@ struct aac_dev · 7 unmodified lines
984 struct fsa_dev_info *fsa_dev;987 struct fsa_dev_info *fsa_dev;
985 struct task_struct *thread;988 struct task_struct *thread;
986 int cardtype;989 int cardtype;
987 990
988 /*991 /*
989 * The following is the device specific extension.992 * The following is the device specific extension.
990 */993 */
991#if (!defined(AAC_MIN_FOOTPRINT_SIZE))994#ifndef AAC_MIN_FOOTPRINT_SIZE
992# define AAC_MIN_FOOTPRINT_SIZE 8192995# define AAC_MIN_FOOTPRINT_SIZE 8192
993#endif996#endif
994 union997 union
@@ -1009,7 +1012,9 @@ struct aac_dev · 14 unmodified lines
1009 /* These are in adapter info but they are in the io flow so1012 /* These are in adapter info but they are in the io flow so
1010 * lets break them out so we don't have to do an AND to check them1013 * lets break them out so we don't have to do an AND to check them
1011 */1014 */
1012 u8 nondasd_support; 1015 u8 nondasd_support;
1016 u8 jbod;
1017 u8 cache_protected;
1013 u8 dac_support;1018 u8 dac_support;
1014 u8 raid_scsi_mode;1019 u8 raid_scsi_mode;
1015 u8 comm_interface;1020 u8 comm_interface;
@@ -1066,18 +1071,19 @@ struct aac_dev · 50 unmodified lines
1066 (dev)->a_ops.adapter_comm(dev, comm)1071 (dev)->a_ops.adapter_comm(dev, comm)
1067 1072
1068#define FIB_CONTEXT_FLAG_TIMED_OUT (0x00000001)1073#define FIB_CONTEXT_FLAG_TIMED_OUT (0x00000001)
1074#define FIB_CONTEXT_FLAG (0x00000002)
1069 1075
1070/*1076/*
1071 * Define the command values1077 * Define the command values
1072 */1078 */
1073 1079
1074#define Null 01080#define Null 0
1075#define GetAttributes 11081#define GetAttributes 1
1076#define SetAttributes 21082#define SetAttributes 2
1077#define Lookup 31083#define Lookup 3
1078#define ReadLink 41084#define ReadLink 4
1079#define Read 51085#define Read 5
1080#define Write 61086#define Write 6
1081#define Create 71087#define Create 7
1082#define MakeDirectory 81088#define MakeDirectory 8
1083#define SymbolicLink 91089#define SymbolicLink 9
@@ -1173,19 +1179,19 @@ struct aac_dev · 89 unmodified lines
1173 1179
1174struct aac_read1180struct aac_read
1175{1181{
1176 __le32 command;1182 __le32 command;
1177 __le32 cid;1183 __le32 cid;
1178 __le32 block;1184 __le32 block;
1179 __le32 count;1185 __le32 count;
1180 struct sgmap sg; // Must be last in struct because it is variable1186 struct sgmap sg; // Must be last in struct because it is variable
1181};1187};
1182 1188
1183struct aac_read641189struct aac_read64
1184{1190{
1185 __le32 command;1191 __le32 command;
1186 __le16 cid;1192 __le16 cid;
1187 __le16 sector_count;1193 __le16 sector_count;
1188 __le32 block;1194 __le32 block;
1189 __le16 pad;1195 __le16 pad;
1190 __le16 flags;1196 __le16 flags;
1191 struct sgmap64 sg; // Must be last in struct because it is variable1197 struct sgmap64 sg; // Must be last in struct because it is variable
@@ -1193,26 +1199,26 @@ struct aac_read64 · 1 unmodified line
1193 1199
1194struct aac_read_reply1200struct aac_read_reply
1195{1201{
1196 __le32 status;1202 __le32 status;
1197 __le32 count;1203 __le32 count;
1198};1204};
1199 1205
1200struct aac_write1206struct aac_write
1201{1207{
1202 __le32 command;1208 __le32 command;
1203 __le32 cid;1209 __le32 cid;
1204 __le32 block;1210 __le32 block;
1205 __le32 count;1211 __le32 count;
1206 __le32 stable; // Not used1212 __le32 stable; // Not used
1207 struct sgmap sg; // Must be last in struct because it is variable1213 struct sgmap sg; // Must be last in struct because it is variable
1208};1214};
1209 1215
1210struct aac_write641216struct aac_write64
1211{1217{
1212 __le32 command;1218 __le32 command;
1213 __le16 cid;1219 __le16 cid;
1214 __le16 sector_count;1220 __le16 sector_count;
1215 __le32 block;1221 __le32 block;
1216 __le16 pad;1222 __le16 pad;
1217 __le16 flags;1223 __le16 flags;
1218#define IO_TYPE_WRITE 0x000000001224#define IO_TYPE_WRITE 0x00000000
@@ -1223,7 +1229,7 @@ struct aac_write64 · 4 unmodified lines
1223struct aac_write_reply1229struct aac_write_reply
1224{1230{
1225 __le32 status;1231 __le32 status;
1226 __le32 count;1232 __le32 count;
1227 __le32 committed;1233 __le32 committed;
1228};1234};
1229 1235
@@ -1326,10 +1332,10 @@ struct aac_srb_reply · 96 unmodified lines
1326#define SRB_NoDataXfer 0x00001332#define SRB_NoDataXfer 0x0000
1327#define SRB_DisableDisconnect 0x00041333#define SRB_DisableDisconnect 0x0004
1328#define SRB_DisableSynchTransfer 0x00081334#define SRB_DisableSynchTransfer 0x0008
1329#define SRB_BypassFrozenQueue 0x00101335#define SRB_BypassFrozenQueue 0x0010
1330#define SRB_DisableAutosense 0x00201336#define SRB_DisableAutosense 0x0020
1331#define SRB_DataIn 0x00401337#define SRB_DataIn 0x0040
1332#define SRB_DataOut 0x00801338#define SRB_DataOut 0x0080
1333 1339
1334/*1340/*
1335 * SRB Functions - set in aac_srb->function1341 * SRB Functions - set in aac_srb->function
@@ -1352,7 +1358,7 @@ struct aac_srb_reply · 16 unmodified lines
1352#define SRBF_RemoveDevice 0x00161358#define SRBF_RemoveDevice 0x0016
1353#define SRBF_DomainValidation 0x00171359#define SRBF_DomainValidation 0x0017
1354 1360
1355/* 1361/*
1356 * SRB SCSI Status - set in aac_srb->scsi_status1362 * SRB SCSI Status - set in aac_srb->scsi_status
1357 */1363 */
1358#define SRB_STATUS_PENDING 0x001364#define SRB_STATUS_PENDING 0x00
@@ -1511,17 +1517,17 @@ struct aac_get_container_count_resp { · 152 unmodified lines
1511 */1517 */
1512 1518
1513struct aac_mntent {1519struct aac_mntent {
1514 __le32 oid;1520 __le32 oid;
1515 u8 name[16]; /* if applicable */1521 u8 name[16]; /* if applicable */
1516 struct creation_info create_info; /* if applicable */1522 struct creation_info create_info; /* if applicable */
1517 __le32 capacity;1523 __le32 capacity;
1518 __le32 vol; /* substrate structure */1524 __le32 vol; /* substrate structure */
1519 __le32 obj; /* FT_FILESYS, etc. */1525 __le32 obj; /* FT_FILESYS, etc. */
1520 __le32 state; /* unready for mounting, 1526 __le32 state; /* unready for mounting,
1521 readonly, etc. */1527 readonly, etc. */
1522 union aac_contentinfo fileinfo; /* Info specific to content 1528 union aac_contentinfo fileinfo; /* Info specific to content
1523 manager (eg, filesystem) */1529 manager (eg, filesystem) */
1524 __le32 altoid; /* != oid <==> snapshot or 1530 __le32 altoid; /* != oid <==> snapshot or
1525 broken mirror exists */1531 broken mirror exists */
1526 __le32 capacityhigh;1532 __le32 capacityhigh;
1527};1533};
@@ -1538,7 +1544,7 @@ struct aac_query_mount { · 10 unmodified lines
1538 1544
1539struct aac_mount {1545struct aac_mount {
1540 __le32 status;1546 __le32 status;
1541 __le32 type; /* should be same as that requested */1547 __le32 type; /* should be same as that requested */
1542 __le32 count;1548 __le32 count;
1543 struct aac_mntent mnt[1];1549 struct aac_mntent mnt[1];
1544};1550};
@@ -1608,7 +1614,7 @@ struct aac_delete_disk { · 63 unmodified lines
1608 u32 disknum;1614 u32 disknum;
1609 u32 cnum;1615 u32 cnum;
1610};1616};
1611 1617
1612struct fib_ioctl1618struct fib_ioctl
1613{1619{
1614 u32 fibctx;1620 u32 fibctx;
@@ -1622,10 +1628,10 @@ struct revision · 7 unmodified lines
1622 __le32 version;1628 __le32 version;
1623 __le32 build;1629 __le32 build;
1624};1630};
1625 1631
1626 1632
1627/*1633/*
1628 * Ugly - non Linux like ioctl coding for back compat.1634 * Ugly - non Linux like ioctl coding for back compat.
1629 */1635 */
1630 1636
1631#define CTL_CODE(function, method) ( \1637#define CTL_CODE(function, method) ( \
@@ -1633,7 +1639,7 @@ struct revision · 1 unmodified line
1633)1639)
1634 1640
1635/*1641/*
1636 * Define the method codes for how buffers are passed for I/O and FS 1642 * Define the method codes for how buffers are passed for I/O and FS
1637 * controls1643 * controls
1638 */1644 */
1639 1645
@@ -1644,15 +1650,15 @@ struct revision · 4 unmodified lines
1644 * Filesystem ioctls1650 * Filesystem ioctls
1645 */1651 */
1646 1652
1647#define FSACTL_SENDFIB CTL_CODE(2050, METHOD_BUFFERED)1653#define FSACTL_SENDFIB CTL_CODE(2050, METHOD_BUFFERED)
1648#define FSACTL_SEND_RAW_SRB CTL_CODE(2067, METHOD_BUFFERED)1654#define FSACTL_SEND_RAW_SRB CTL_CODE(2067, METHOD_BUFFERED)
1649#define FSACTL_DELETE_DISK 0x1631655#define FSACTL_DELETE_DISK 0x163
1650#define FSACTL_QUERY_DISK 0x1731656#define FSACTL_QUERY_DISK 0x173
1651#define FSACTL_OPEN_GET_ADAPTER_FIB CTL_CODE(2100, METHOD_BUFFERED)1657#define FSACTL_OPEN_GET_ADAPTER_FIB CTL_CODE(2100, METHOD_BUFFERED)
1652#define FSACTL_GET_NEXT_ADAPTER_FIB CTL_CODE(2101, METHOD_BUFFERED)1658#define FSACTL_GET_NEXT_ADAPTER_FIB CTL_CODE(2101, METHOD_BUFFERED)
1653#define FSACTL_CLOSE_GET_ADAPTER_FIB CTL_CODE(2102, METHOD_BUFFERED)1659#define FSACTL_CLOSE_GET_ADAPTER_FIB CTL_CODE(2102, METHOD_BUFFERED)
1654#define FSACTL_MINIPORT_REV_CHECK CTL_CODE(2107, METHOD_BUFFERED)1660#define FSACTL_MINIPORT_REV_CHECK CTL_CODE(2107, METHOD_BUFFERED)
1655#define FSACTL_GET_PCI_INFO CTL_CODE(2119, METHOD_BUFFERED)1661#define FSACTL_GET_PCI_INFO CTL_CODE(2119, METHOD_BUFFERED)
1656#define FSACTL_FORCE_DELETE_DISK CTL_CODE(2120, METHOD_NEITHER)1662#define FSACTL_FORCE_DELETE_DISK CTL_CODE(2120, METHOD_NEITHER)
1657#define FSACTL_GET_CONTAINERS 21311663#define FSACTL_GET_CONTAINERS 2131
1658#define FSACTL_SEND_LARGE_FIB CTL_CODE(2138, METHOD_BUFFERED)1664#define FSACTL_SEND_LARGE_FIB CTL_CODE(2138, METHOD_BUFFERED)
@@ -1661,7 +1667,7 @@ struct revision · 2 unmodified lines
1661struct aac_common1667struct aac_common
1662{1668{
1663 /*1669 /*
1664 * If this value is set to 1 then interrupt moderation will occur 1670 * If this value is set to 1 then interrupt moderation will occur
1665 * in the base commuication support.1671 * in the base commuication support.
1666 */1672 */
1667 u32 irq_mod;1673 u32 irq_mod;
@@ -1690,11 +1696,11 @@ extern struct aac_common aac_config; · 22 unmodified lines
1690 * The following macro is used when sending and receiving FIBs. It is1696 * The following macro is used when sending and receiving FIBs. It is
1691 * only used for debugging.1697 * only used for debugging.
1692 */1698 */
1693 1699
1694#ifdef DBG1700#ifdef DBG
1695#define FIB_COUNTER_INCREMENT(counter) (counter)++1701#define FIB_COUNTER_INCREMENT(counter) (counter)++
1696#else1702#else
1697#define FIB_COUNTER_INCREMENT(counter) 1703#define FIB_COUNTER_INCREMENT(counter)
1698#endif1704#endif
1699 1705
1700/*1706/*
@@ -1726,17 +1732,17 @@ extern struct aac_common aac_config; · 25 unmodified lines
1726 *1732 *
1727 * The adapter reports is present state through the phase. Only1733 * The adapter reports is present state through the phase. Only
1728 * a single phase should be ever be set. Each phase can have multiple1734 * a single phase should be ever be set. Each phase can have multiple
1729 * phase status bits to provide more detailed information about the 1735 * phase status bits to provide more detailed information about the
1730 * state of the board. Care should be taken to ensure that any phase 1736 * state of the board. Care should be taken to ensure that any phase
1731 * status bits that are set when changing the phase are also valid1737 * status bits that are set when changing the phase are also valid
1732 * for the new phase or be cleared out. Adapter software (monitor,1738 * for the new phase or be cleared out. Adapter software (monitor,
1733 * iflash, kernel) is responsible for properly maintining the phase 1739 * iflash, kernel) is responsible for properly maintining the phase
1734 * status mailbox when it is running.1740 * status mailbox when it is running.
1735 *
1736 * MONKER_API Phases
1737 *1741 *
1738 * Phases are bit oriented. It is NOT valid to have multiple bits set 1742 * MONKER_API Phases
1739 */ 1743 *
1744 * Phases are bit oriented. It is NOT valid to have multiple bits set
1745 */
1740 1746
1741#define SELF_TEST_FAILED 0x000000041747#define SELF_TEST_FAILED 0x00000004
1742#define MONITOR_PANIC 0x000000201748#define MONITOR_PANIC 0x00000020
@@ -1759,16 +1765,22 @@ extern struct aac_common aac_config; · 16 unmodified lines
1759 * For FIB communication, we need all of the following things1765 * For FIB communication, we need all of the following things
1760 * to send back to the user.1766 * to send back to the user.
1761 */1767 */
1762 1768
1763#define AifCmdEventNotify 1 /* Notify of event */1769#define AifCmdEventNotify 1 /* Notify of event */
1764#define AifEnConfigChange 3 /* Adapter configuration change */1770#define AifEnConfigChange 3 /* Adapter configuration change */
1765#define AifEnContainerChange 4 /* Container configuration change */1771#define AifEnContainerChange 4 /* Container configuration change */
1766#define AifEnDeviceFailure 5 /* SCSI device failed */1772#define AifEnDeviceFailure 5 /* SCSI device failed */
1773#define AifEnEnclosureManagement 13 /* EM_DRIVE_* */
1774#define EM_DRIVE_INSERTION 31
1775#define EM_DRIVE_REMOVAL 32
1776#define AifEnBatteryEvent 14 /* Change in Battery State */
1767#define AifEnAddContainer 15 /* A new array was created */1777#define AifEnAddContainer 15 /* A new array was created */
1768#define AifEnDeleteContainer 16 /* A container was deleted */1778#define AifEnDeleteContainer 16 /* A container was deleted */
1769#define AifEnExpEvent 23 /* Firmware Event Log */1779#define AifEnExpEvent 23 /* Firmware Event Log */
1770#define AifExeFirmwarePanic 3 /* Firmware Event Panic */1780#define AifExeFirmwarePanic 3 /* Firmware Event Panic */
1771#define AifHighPriority 3 /* Highest Priority Event */1781#define AifHighPriority 3 /* Highest Priority Event */
1782#define AifEnAddJBOD 30 /* JBOD created */
1783#define AifEnDeleteJBOD 31 /* JBOD deleted */
1772 1784
1773#define AifCmdJobProgress 2 /* Progress report */1785#define AifCmdJobProgress 2 /* Progress report */
1774#define AifJobCtrZero 101 /* Array Zero progress */1786#define AifJobCtrZero 101 /* Array Zero progress */
@@ -1780,11 +1792,11 @@ extern struct aac_common aac_config; · 5 unmodified lines
1780#define AifDenVolumeExtendComplete 201 /* A volume extend completed */1792#define AifDenVolumeExtendComplete 201 /* A volume extend completed */
1781#define AifReqJobList 100 /* Gets back complete job list */1793#define AifReqJobList 100 /* Gets back complete job list */
1782#define AifReqJobsForCtr 101 /* Gets back jobs for specific container */1794#define AifReqJobsForCtr 101 /* Gets back jobs for specific container */
1783#define AifReqJobsForScsi 102 /* Gets back jobs for specific SCSI device */ 1795#define AifReqJobsForScsi 102 /* Gets back jobs for specific SCSI device */
1784#define AifReqJobReport 103 /* Gets back a specific job report or list of them */ 1796#define AifReqJobReport 103 /* Gets back a specific job report or list of them */
1785#define AifReqTerminateJob 104 /* Terminates job */1797#define AifReqTerminateJob 104 /* Terminates job */
1786#define AifReqSuspendJob 105 /* Suspends a job */1798#define AifReqSuspendJob 105 /* Suspends a job */
1787#define AifReqResumeJob 106 /* Resumes a job */ 1799#define AifReqResumeJob 106 /* Resumes a job */
1788#define AifReqSendAPIReport 107 /* API generic report requests */1800#define AifReqSendAPIReport 107 /* API generic report requests */
1789#define AifReqAPIJobStart 108 /* Start a job from the API */1801#define AifReqAPIJobStart 108 /* Start a job from the API */
1790#define AifReqAPIJobUpdate 109 /* Update a job report from the API */1802#define AifReqAPIJobUpdate 109 /* Update a job report from the API */
@@ -1803,8 +1815,8 @@ struct aac_aifcmd { · 12 unmodified lines
1803};1815};
1804 1816
1805/**1817/**
1806 * Convert capacity to cylinders1818 * Convert capacity to cylinders
1807 * accounting for the fact capacity could be a 64 bit value1819 * accounting for the fact capacity could be a 64 bit value
1808 *1820 *
1809 */1821 */
1810static inline unsigned int cap_to_cyls(sector_t capacity, unsigned divisor)1822static inline unsigned int cap_to_cyls(sector_t capacity, unsigned divisor)
@@ -1861,6 +1873,7 @@ int aac_probe_container(struct aac_dev *dev, int cid); · 50 unmodified lines
1861int _aac_rx_init(struct aac_dev *dev);1873int _aac_rx_init(struct aac_dev *dev);
1862int aac_rx_select_comm(struct aac_dev *dev, int comm);1874int aac_rx_select_comm(struct aac_dev *dev, int comm);
1863int aac_rx_deliver_producer(struct fib * fib);1875int aac_rx_deliver_producer(struct fib * fib);
1876char * get_container_type(unsigned type);
1864extern int numacb;1877extern int numacb;
1865extern int acbsize;1878extern int acbsize;
1866extern char aac_driver_version[];1879extern char aac_driver_version[];
drivers/scsi/aacraid/commctrl.c+58−54
@@ -48,13 +48,13 @@ · 47 unmodified lines
48 * ioctl_send_fib - send a FIB from userspace48 * ioctl_send_fib - send a FIB from userspace
49 * @dev: adapter is being processed49 * @dev: adapter is being processed
50 * @arg: arguments to the ioctl call50 * @arg: arguments to the ioctl call
51 * 51 *
52 * This routine sends a fib to the adapter on behalf of a user level52 * This routine sends a fib to the adapter on behalf of a user level
53 * program.53 * program.
54 */54 */
55# define AAC_DEBUG_PREAMBLE KERN_INFO55# define AAC_DEBUG_PREAMBLE KERN_INFO
56# define AAC_DEBUG_POSTAMBLE56# define AAC_DEBUG_POSTAMBLE
57 57
58static int ioctl_send_fib(struct aac_dev * dev, void __user *arg)58static int ioctl_send_fib(struct aac_dev * dev, void __user *arg)
59{59{
60 struct hw_fib * kfib;60 struct hw_fib * kfib;
@@ -71,7 +71,7 @@ static int ioctl_send_fib(struct aac_dev * dev, void __user *arg) · 10 unmodified lines
71 if(fibptr == NULL) {71 if(fibptr == NULL) {
72 return -ENOMEM;72 return -ENOMEM;
73 }73 }
74 74
75 kfib = fibptr->hw_fib_va;75 kfib = fibptr->hw_fib_va;
76 /*76 /*
77 * First copy in the header so that we can check the size field.77 * First copy in the header so that we can check the size field.
@@ -109,7 +109,7 @@ static int ioctl_send_fib(struct aac_dev * dev, void __user *arg) · 31 unmodified lines
109 if (kfib->header.Command == cpu_to_le16(TakeABreakPt)) {109 if (kfib->header.Command == cpu_to_le16(TakeABreakPt)) {
110 aac_adapter_interrupt(dev);110 aac_adapter_interrupt(dev);
111 /*111 /*
112 * Since we didn't really send a fib, zero out the state to allow 112 * Since we didn't really send a fib, zero out the state to allow
113 * cleanup code not to assert.113 * cleanup code not to assert.
114 */114 */
115 kfib->header.XferState = 0;115 kfib->header.XferState = 0;
@@ -169,7 +169,7 @@ static int open_getadapter_fib(struct aac_dev * dev, void __user *arg) · 53 unmodified lines
169 169
170 fibctx->type = FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT;170 fibctx->type = FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT;
171 fibctx->size = sizeof(struct aac_fib_context);171 fibctx->size = sizeof(struct aac_fib_context);
172 /*172 /*
173 * Yes yes, I know this could be an index, but we have a173 * Yes yes, I know this could be an index, but we have a
174 * better guarantee of uniqueness for the locked loop below.174 * better guarantee of uniqueness for the locked loop below.
175 * Without the aid of a persistent history, this also helps175 * Without the aid of a persistent history, this also helps
@@ -189,7 +189,7 @@ static int open_getadapter_fib(struct aac_dev * dev, void __user *arg) · 13 unmodified lines
189 INIT_LIST_HEAD(&fibctx->fib_list);189 INIT_LIST_HEAD(&fibctx->fib_list);
190 fibctx->jiffies = jiffies/HZ;190 fibctx->jiffies = jiffies/HZ;
191 /*191 /*
192 * Now add this context onto the adapter's 192 * Now add this context onto the adapter's
193 * AdapterFibContext list.193 * AdapterFibContext list.
194 */194 */
195 spin_lock_irqsave(&dev->fib_lock, flags);195 spin_lock_irqsave(&dev->fib_lock, flags);
@@ -207,12 +207,12 @@ static int open_getadapter_fib(struct aac_dev * dev, void __user *arg) · 11 unmodified lines
207 }207 }
208 list_add_tail(&fibctx->next, &dev->fib_list);208 list_add_tail(&fibctx->next, &dev->fib_list);
209 spin_unlock_irqrestore(&dev->fib_lock, flags);209 spin_unlock_irqrestore(&dev->fib_lock, flags);
210 if (copy_to_user(arg, &fibctx->unique, 210 if (copy_to_user(arg, &fibctx->unique,
211 sizeof(fibctx->unique))) {211 sizeof(fibctx->unique))) {
212 status = -EFAULT;212 status = -EFAULT;
213 } else {213 } else {
214 status = 0;214 status = 0;
215 } 215 }
216 }216 }
217 return status;217 return status;
218}218}
@@ -221,8 +221,8 @@ static int open_getadapter_fib(struct aac_dev * dev, void __user *arg) · 2 unmodified lines
221 * next_getadapter_fib - get the next fib221 * next_getadapter_fib - get the next fib
222 * @dev: adapter to use222 * @dev: adapter to use
223 * @arg: ioctl argument223 * @arg: ioctl argument
224 * 224 *
225 * This routine will get the next Fib, if available, from the AdapterFibContext225 * This routine will get the next Fib, if available, from the AdapterFibContext
226 * passed in from the user.226 * passed in from the user.
227 */227 */
228 228
@@ -234,7 +234,7 @@ static int next_getadapter_fib(struct aac_dev * dev, void __user *arg) · 5 unmodified lines
234 int status;234 int status;
235 struct list_head * entry;235 struct list_head * entry;
236 unsigned long flags;236 unsigned long flags;
237 237
238 if(copy_from_user((void *)&f, arg, sizeof(struct fib_ioctl)))238 if(copy_from_user((void *)&f, arg, sizeof(struct fib_ioctl)))
239 return -EFAULT;239 return -EFAULT;
240 /*240 /*
@@ -243,6 +243,7 @@ static int next_getadapter_fib(struct aac_dev * dev, void __user *arg) · 2 unmodified lines
243 * Search the list of AdapterFibContext addresses on the adapter243 * Search the list of AdapterFibContext addresses on the adapter
244 * to be sure this is a valid address244 * to be sure this is a valid address
245 */245 */
246 spin_lock_irqsave(&dev->fib_lock, flags);
246 entry = dev->fib_list.next;247 entry = dev->fib_list.next;
247 fibctx = NULL;248 fibctx = NULL;
248 249
@@ -251,37 +252,37 @@ static int next_getadapter_fib(struct aac_dev * dev, void __user *arg) · 2 unmodified lines
251 /*252 /*
252 * Extract the AdapterFibContext from the Input parameters.253 * Extract the AdapterFibContext from the Input parameters.
253 */254 */
254 if (fibctx->unique == f.fibctx) { /* We found a winner */255 if (fibctx->unique == f.fibctx) { /* We found a winner */
255 break;256 break;
256 }257 }
257 entry = entry->next;258 entry = entry->next;
258 fibctx = NULL;259 fibctx = NULL;
259 }260 }
260 if (!fibctx) {261 if (!fibctx) {
262 spin_unlock_irqrestore(&dev->fib_lock, flags);
261 dprintk ((KERN_INFO "Fib Context not found\n"));263 dprintk ((KERN_INFO "Fib Context not found\n"));
262 return -EINVAL;264 return -EINVAL;
263 }265 }
264 266
265 if((fibctx->type != FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT) ||267 if((fibctx->type != FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT) ||
266 (fibctx->size != sizeof(struct aac_fib_context))) {268 (fibctx->size != sizeof(struct aac_fib_context))) {
269 spin_unlock_irqrestore(&dev->fib_lock, flags);
267 dprintk ((KERN_INFO "Fib Context corrupt?\n"));270 dprintk ((KERN_INFO "Fib Context corrupt?\n"));
268 return -EINVAL;271 return -EINVAL;
269 }272 }
270 status = 0;273 status = 0;
271 spin_lock_irqsave(&dev->fib_lock, flags);
272 /*274 /*
273 * If there are no fibs to send back, then either wait or return275 * If there are no fibs to send back, then either wait or return
274 * -EAGAIN276 * -EAGAIN
275 */277 */
276return_fib:278return_fib:
277 if (!list_empty(&fibctx->fib_list)) {279 if (!list_empty(&fibctx->fib_list)) {
278 struct list_head * entry;
279 /*280 /*
280 * Pull the next fib from the fibs281 * Pull the next fib from the fibs
281 */282 */
282 entry = fibctx->fib_list.next;283 entry = fibctx->fib_list.next;
283 list_del(entry);284 list_del(entry);
284 285
285 fib = list_entry(entry, struct fib, fiblink);286 fib = list_entry(entry, struct fib, fiblink);
286 fibctx->count--;287 fibctx->count--;
287 spin_unlock_irqrestore(&dev->fib_lock, flags);288 spin_unlock_irqrestore(&dev->fib_lock, flags);
@@ -289,7 +290,7 @@ return_fib: · 1 unmodified line
289 kfree(fib->hw_fib_va);290 kfree(fib->hw_fib_va);
290 kfree(fib);291 kfree(fib);
291 return -EFAULT;292 return -EFAULT;
292 } 293 }
293 /*294 /*
294 * Free the space occupied by this copy of the fib.295 * Free the space occupied by this copy of the fib.
295 */296 */
@@ -318,7 +319,7 @@ return_fib: · 22 unmodified lines
318 }319 }
319 } else {320 } else {
320 status = -EAGAIN;321 status = -EAGAIN;
321 } 322 }
322 }323 }
323 fibctx->jiffies = jiffies/HZ;324 fibctx->jiffies = jiffies/HZ;
324 return status;325 return status;
@@ -327,7 +328,9 @@ return_fib: · 2 unmodified lines
327int aac_close_fib_context(struct aac_dev * dev, struct aac_fib_context * fibctx)328int aac_close_fib_context(struct aac_dev * dev, struct aac_fib_context * fibctx)
328{329{
329 struct fib *fib;330 struct fib *fib;
331 unsigned long flags;
330 332
333 spin_lock_irqsave(&dev->fib_lock, flags);
331 /*334 /*
332 * First free any FIBs that have not been consumed.335 * First free any FIBs that have not been consumed.
333 */336 */
@@ -350,6 +353,7 @@ int aac_close_fib_context(struct aac_dev * dev, struct aac_fib_context * fibctx) · 16 unmodified lines
350 * Remove the Context from the AdapterFibContext List353 * Remove the Context from the AdapterFibContext List
351 */354 */
352 list_del(&fibctx->next);355 list_del(&fibctx->next);
356 spin_unlock_irqrestore(&dev->fib_lock, flags);
353 /*357 /*
354 * Invalidate context358 * Invalidate context
355 */359 */
@@ -368,7 +372,7 @@ int aac_close_fib_context(struct aac_dev * dev, struct aac_fib_context * fibctx) · 12 unmodified lines
368 *372 *
369 * This routine will close down the fibctx passed in from the user.373 * This routine will close down the fibctx passed in from the user.
370 */374 */
371 375
372static int close_getadapter_fib(struct aac_dev * dev, void __user *arg)376static int close_getadapter_fib(struct aac_dev * dev, void __user *arg)
373{377{
374 struct aac_fib_context *fibctx;378 struct aac_fib_context *fibctx;
@@ -415,8 +419,8 @@ static int close_getadapter_fib(struct aac_dev * dev, void __user *arg) · 40 unmodified lines
415 * @arg: ioctl arguments419 * @arg: ioctl arguments
416 *420 *
417 * This routine returns the driver version.421 * This routine returns the driver version.
418 * Under Linux, there have been no version incompatibilities, so this is 422 * Under Linux, there have been no version incompatibilities, so this is
419 * simple!423 * simple!
420 */424 */
421 425
422static int check_revision(struct aac_dev *dev, void __user *arg)426static int check_revision(struct aac_dev *dev, void __user *arg)
@@ -426,12 +430,12 @@ static int check_revision(struct aac_dev *dev, void __user *arg) · 3 unmodified lines
426 u32 version;430 u32 version;
427 431
428 response.compat = 1;432 response.compat = 1;
429 version = (simple_strtol(driver_version, 433 version = (simple_strtol(driver_version,
430 &driver_version, 10) << 24) | 0x00000400;434 &driver_version, 10) << 24) | 0x00000400;
431 version += simple_strtol(driver_version + 1, &driver_version, 10) << 16;435 version += simple_strtol(driver_version + 1, &driver_version, 10) << 16;
432 version += simple_strtol(driver_version + 1, NULL, 10);436 version += simple_strtol(driver_version + 1, NULL, 10);
433 response.version = cpu_to_le32(version);437 response.version = cpu_to_le32(version);
434# if (defined(AAC_DRIVER_BUILD))438# ifdef AAC_DRIVER_BUILD
435 response.build = cpu_to_le32(AAC_DRIVER_BUILD);439 response.build = cpu_to_le32(AAC_DRIVER_BUILD);
436# else440# else
437 response.build = cpu_to_le32(9999);441 response.build = cpu_to_le32(9999);
@@ -464,7 +468,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 26 unmodified lines
464 u32 data_dir;468 u32 data_dir;
465 void __user *sg_user[32];469 void __user *sg_user[32];
466 void *sg_list[32];470 void *sg_list[32];
467 u32 sg_indx = 0;471 u32 sg_indx = 0;
468 u32 byte_count = 0;472 u32 byte_count = 0;
469 u32 actual_fibsize64, actual_fibsize = 0;473 u32 actual_fibsize64, actual_fibsize = 0;
470 int i;474 int i;
@@ -475,7 +479,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 4 unmodified lines
475 return -EBUSY;479 return -EBUSY;
476 }480 }
477 if (!capable(CAP_SYS_ADMIN)){481 if (!capable(CAP_SYS_ADMIN)){
478 dprintk((KERN_DEBUG"aacraid: No permission to send raw srb\n")); 482 dprintk((KERN_DEBUG"aacraid: No permission to send raw srb\n"));
479 return -EPERM;483 return -EPERM;
480 }484 }
481 /*485 /*
@@ -490,7 +494,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 8 unmodified lines
490 494
491 memset(sg_list, 0, sizeof(sg_list)); /* cleanup may take issue */495 memset(sg_list, 0, sizeof(sg_list)); /* cleanup may take issue */
492 if(copy_from_user(&fibsize, &user_srb->count,sizeof(u32))){496 if(copy_from_user(&fibsize, &user_srb->count,sizeof(u32))){
493 dprintk((KERN_DEBUG"aacraid: Could not copy data size from user\n")); 497 dprintk((KERN_DEBUG"aacraid: Could not copy data size from user\n"));
494 rcode = -EFAULT;498 rcode = -EFAULT;
495 goto cleanup;499 goto cleanup;
496 }500 }
@@ -507,7 +511,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 10 unmodified lines
507 goto cleanup;511 goto cleanup;
508 }512 }
509 if(copy_from_user(user_srbcmd, user_srb,fibsize)){513 if(copy_from_user(user_srbcmd, user_srb,fibsize)){
510 dprintk((KERN_DEBUG"aacraid: Could not copy srb from user\n")); 514 dprintk((KERN_DEBUG"aacraid: Could not copy srb from user\n"));
511 rcode = -EFAULT;515 rcode = -EFAULT;
512 goto cleanup;516 goto cleanup;
513 }517 }
@@ -518,15 +522,15 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 4 unmodified lines
518 // Fix up srb for endian and force some values522 // Fix up srb for endian and force some values
519 523
520 srbcmd->function = cpu_to_le32(SRBF_ExecuteScsi); // Force this524 srbcmd->function = cpu_to_le32(SRBF_ExecuteScsi); // Force this
521 srbcmd->channel = cpu_to_le32(user_srbcmd->channel);525 srbcmd->channel = cpu_to_le32(user_srbcmd->channel);
522 srbcmd->id = cpu_to_le32(user_srbcmd->id);526 srbcmd->id = cpu_to_le32(user_srbcmd->id);
523 srbcmd->lun = cpu_to_le32(user_srbcmd->lun);527 srbcmd->lun = cpu_to_le32(user_srbcmd->lun);
524 srbcmd->timeout = cpu_to_le32(user_srbcmd->timeout);528 srbcmd->timeout = cpu_to_le32(user_srbcmd->timeout);
525 srbcmd->flags = cpu_to_le32(flags);529 srbcmd->flags = cpu_to_le32(flags);
526 srbcmd->retry_limit = 0; // Obsolete parameter530 srbcmd->retry_limit = 0; // Obsolete parameter
527 srbcmd->cdb_size = cpu_to_le32(user_srbcmd->cdb_size);531 srbcmd->cdb_size = cpu_to_le32(user_srbcmd->cdb_size);
528 memcpy(srbcmd->cdb, user_srbcmd->cdb, sizeof(srbcmd->cdb));532 memcpy(srbcmd->cdb, user_srbcmd->cdb, sizeof(srbcmd->cdb));
529 533
530 switch (flags & (SRB_DataIn | SRB_DataOut)) {534 switch (flags & (SRB_DataIn | SRB_DataOut)) {
531 case SRB_DataOut:535 case SRB_DataOut:
532 data_dir = DMA_TO_DEVICE;536 data_dir = DMA_TO_DEVICE;
@@ -582,7 +586,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 49 unmodified lines
582 void* p;586 void* p;
583 /* Does this really need to be GFP_DMA? */587 /* Does this really need to be GFP_DMA? */
584 p = kmalloc(upsg->sg[i].count,GFP_KERNEL|__GFP_DMA);588 p = kmalloc(upsg->sg[i].count,GFP_KERNEL|__GFP_DMA);
585 if(p == 0) {589 if(!p) {
586 dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",590 dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
587 upsg->sg[i].count,i,upsg->count));591 upsg->sg[i].count,i,upsg->count));
588 rcode = -ENOMEM;592 rcode = -ENOMEM;
@@ -594,7 +598,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 5 unmodified lines
594 sg_list[i] = p; // save so we can clean up later598 sg_list[i] = p; // save so we can clean up later
595 sg_indx = i;599 sg_indx = i;
596 600
597 if( flags & SRB_DataOut ){601 if (flags & SRB_DataOut) {
598 if(copy_from_user(p,sg_user[i],upsg->sg[i].count)){602 if(copy_from_user(p,sg_user[i],upsg->sg[i].count)){
599 dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n"));603 dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n"));
600 rcode = -EFAULT;604 rcode = -EFAULT;
@@ -626,7 +630,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 25 unmodified lines
626 void* p;630 void* p;
627 /* Does this really need to be GFP_DMA? */631 /* Does this really need to be GFP_DMA? */
628 p = kmalloc(usg->sg[i].count,GFP_KERNEL|__GFP_DMA);632 p = kmalloc(usg->sg[i].count,GFP_KERNEL|__GFP_DMA);
629 if(p == 0) {633 if(!p) {
630 kfree (usg);634 kfree (usg);
631 dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",635 dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
632 usg->sg[i].count,i,usg->count));636 usg->sg[i].count,i,usg->count));
@@ -637,7 +641,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 4 unmodified lines
637 sg_list[i] = p; // save so we can clean up later641 sg_list[i] = p; // save so we can clean up later
638 sg_indx = i;642 sg_indx = i;
639 643
640 if( flags & SRB_DataOut ){644 if (flags & SRB_DataOut) {
641 if(copy_from_user(p,sg_user[i],upsg->sg[i].count)){645 if(copy_from_user(p,sg_user[i],upsg->sg[i].count)){
642 kfree (usg);646 kfree (usg);
643 dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n"));647 dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n"));
@@ -668,7 +672,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 24 unmodified lines
668 void* p;672 void* p;
669 /* Does this really need to be GFP_DMA? */673 /* Does this really need to be GFP_DMA? */
670 p = kmalloc(usg->sg[i].count,GFP_KERNEL|__GFP_DMA);674 p = kmalloc(usg->sg[i].count,GFP_KERNEL|__GFP_DMA);
671 if(p == 0) {675 if(!p) {
672 dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",676 dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
673 usg->sg[i].count,i,usg->count));677 usg->sg[i].count,i,usg->count));
674 rcode = -ENOMEM;678 rcode = -ENOMEM;
@@ -680,7 +684,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 5 unmodified lines
680 sg_list[i] = p; // save so we can clean up later684 sg_list[i] = p; // save so we can clean up later
681 sg_indx = i;685 sg_indx = i;
682 686
683 if( flags & SRB_DataOut ){687 if (flags & SRB_DataOut) {
684 if(copy_from_user(p,sg_user[i],usg->sg[i].count)){688 if(copy_from_user(p,sg_user[i],usg->sg[i].count)){
685 dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n"));689 dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n"));
686 rcode = -EFAULT;690 rcode = -EFAULT;
@@ -698,7 +702,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 11 unmodified lines
698 dma_addr_t addr;702 dma_addr_t addr;
699 void* p;703 void* p;
700 p = kmalloc(upsg->sg[i].count, GFP_KERNEL);704 p = kmalloc(upsg->sg[i].count, GFP_KERNEL);
701 if(p == 0) {705 if (!p) {
702 dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",706 dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
703 upsg->sg[i].count, i, upsg->count));707 upsg->sg[i].count, i, upsg->count));
704 rcode = -ENOMEM;708 rcode = -ENOMEM;
@@ -708,7 +712,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 3 unmodified lines
708 sg_list[i] = p; // save so we can clean up later712 sg_list[i] = p; // save so we can clean up later
709 sg_indx = i;713 sg_indx = i;
710 714
711 if( flags & SRB_DataOut ){715 if (flags & SRB_DataOut) {
712 if(copy_from_user(p, sg_user[i],716 if(copy_from_user(p, sg_user[i],
713 upsg->sg[i].count)) {717 upsg->sg[i].count)) {
714 dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n"));718 dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n"));
@@ -734,19 +738,19 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 19 unmodified lines
734 }738 }
735 739
736 if (status != 0){740 if (status != 0){
737 dprintk((KERN_DEBUG"aacraid: Could not send raw srb fib to hba\n")); 741 dprintk((KERN_DEBUG"aacraid: Could not send raw srb fib to hba\n"));
738 rcode = -ENXIO;742 rcode = -ENXIO;
739 goto cleanup;743 goto cleanup;
740 }744 }
741 745
742 if( flags & SRB_DataIn ) {746 if (flags & SRB_DataIn) {
743 for(i = 0 ; i <= sg_indx; i++){747 for(i = 0 ; i <= sg_indx; i++){
744 byte_count = le32_to_cpu(748 byte_count = le32_to_cpu(
745 (dev->adapter_info.options & AAC_OPT_SGMAP_HOST64)749 (dev->adapter_info.options & AAC_OPT_SGMAP_HOST64)
746 ? ((struct sgmap64*)&srbcmd->sg)->sg[i].count750 ? ((struct sgmap64*)&srbcmd->sg)->sg[i].count
747 : srbcmd->sg.sg[i].count);751 : srbcmd->sg.sg[i].count);
748 if(copy_to_user(sg_user[i], sg_list[i], byte_count)){752 if(copy_to_user(sg_user[i], sg_list[i], byte_count)){
749 dprintk((KERN_DEBUG"aacraid: Could not copy sg data to user\n")); 753 dprintk((KERN_DEBUG"aacraid: Could not copy sg data to user\n"));
750 rcode = -EFAULT;754 rcode = -EFAULT;
751 goto cleanup;755 goto cleanup;
752 756
@@ -756,7 +760,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) · 3 unmodified lines
756 760
757 reply = (struct aac_srb_reply *) fib_data(srbfib);761 reply = (struct aac_srb_reply *) fib_data(srbfib);
758 if(copy_to_user(user_reply,reply,sizeof(struct aac_srb_reply))){762 if(copy_to_user(user_reply,reply,sizeof(struct aac_srb_reply))){
759 dprintk((KERN_DEBUG"aacraid: Could not copy reply to user\n")); 763 dprintk((KERN_DEBUG"aacraid: Could not copy reply to user\n"));
760 rcode = -EFAULT;764 rcode = -EFAULT;
761 goto cleanup;765 goto cleanup;
762 }766 }
@@ -775,34 +779,34 @@ cleanup: · 12 unmodified lines
775}779}
776 780
777struct aac_pci_info {781struct aac_pci_info {
778 u32 bus;782 u32 bus;
779 u32 slot;783 u32 slot;
780};784};
781 785
782 786
783static int aac_get_pci_info(struct aac_dev* dev, void __user *arg)787static int aac_get_pci_info(struct aac_dev* dev, void __user *arg)
784{788{
785 struct aac_pci_info pci_info;789 struct aac_pci_info pci_info;
786 790
787 pci_info.bus = dev->pdev->bus->number;791 pci_info.bus = dev->pdev->bus->number;
788 pci_info.slot = PCI_SLOT(dev->pdev->devfn);792 pci_info.slot = PCI_SLOT(dev->pdev->devfn);
789 793
790 if (copy_to_user(arg, &pci_info, sizeof(struct aac_pci_info))) {794 if (copy_to_user(arg, &pci_info, sizeof(struct aac_pci_info))) {
791 dprintk((KERN_DEBUG "aacraid: Could not copy pci info\n"));795 dprintk((KERN_DEBUG "aacraid: Could not copy pci info\n"));
792 return -EFAULT;796 return -EFAULT;
793 }797 }
794 return 0;798 return 0;
795}799}
796 800
797 801
798int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg)802int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg)
799{803{
800 int status;804 int status;
801 805
802 /*806 /*
803 * HBA gets first crack807 * HBA gets first crack
804 */808 */
805 809
806 status = aac_dev_ioctl(dev, cmd, arg);810 status = aac_dev_ioctl(dev, cmd, arg);
807 if(status != -ENOTTY)811 if(status != -ENOTTY)
808 return status;812 return status;
@@ -832,7 +836,7 @@ int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg) · 23 unmodified lines
832 break;836 break;
833 default:837 default:
834 status = -ENOTTY;838 status = -ENOTTY;
835 break; 839 break;
836 }840 }
837 return status;841 return status;
838}842}
drivers/scsi/aacraid/comminit.c+2−2
@@ -301,10 +301,10 @@ struct aac_dev *aac_init_adapter(struct aac_dev *dev) · 300 unmodified lines
301 if ((!aac_adapter_sync_cmd(dev, GET_ADAPTER_PROPERTIES,301 if ((!aac_adapter_sync_cmd(dev, GET_ADAPTER_PROPERTIES,
302 0, 0, 0, 0, 0, 0, status+0, status+1, status+2, NULL, NULL)) &&302 0, 0, 0, 0, 0, 0, status+0, status+1, status+2, NULL, NULL)) &&
303 (status[0] == 0x00000001)) {303 (status[0] == 0x00000001)) {
304 if (status[1] & AAC_OPT_NEW_COMM_64)304 if (status[1] & le32_to_cpu(AAC_OPT_NEW_COMM_64))
305 dev->raw_io_64 = 1;305 dev->raw_io_64 = 1;
306 if (dev->a_ops.adapter_comm &&306 if (dev->a_ops.adapter_comm &&
307 (status[1] & AAC_OPT_NEW_COMM))307 (status[1] & le32_to_cpu(AAC_OPT_NEW_COMM)))
308 dev->comm_interface = AAC_COMM_MESSAGE;308 dev->comm_interface = AAC_COMM_MESSAGE;
309 if ((dev->comm_interface == AAC_COMM_MESSAGE) &&309 if ((dev->comm_interface == AAC_COMM_MESSAGE) &&
310 (status[2] > dev->base_size)) {310 (status[2] > dev->base_size)) {
drivers/scsi/aacraid/commsup.c+239−155
@@ -56,7 +56,7 @@ · 55 unmodified lines
56 * Allocate and map the shared PCI space for the FIB blocks used to56 * Allocate and map the shared PCI space for the FIB blocks used to
57 * talk to the Adaptec firmware.57 * talk to the Adaptec firmware.
58 */58 */
59 59
60static int fib_map_alloc(struct aac_dev *dev)60static int fib_map_alloc(struct aac_dev *dev)
61{61{
62 dprintk((KERN_INFO62 dprintk((KERN_INFO
@@ -109,14 +109,16 @@ int aac_fib_setup(struct aac_dev * dev) · 46 unmodified lines
109 }109 }
110 if (i<0)110 if (i<0)
111 return -ENOMEM;111 return -ENOMEM;
112 112
113 hw_fib = dev->hw_fib_va;113 hw_fib = dev->hw_fib_va;
114 hw_fib_pa = dev->hw_fib_pa;114 hw_fib_pa = dev->hw_fib_pa;
115 memset(hw_fib, 0, dev->max_fib_size * (dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB));115 memset(hw_fib, 0, dev->max_fib_size * (dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB));
116 /*116 /*
117 * Initialise the fibs117 * Initialise the fibs
118 */118 */
119 for (i = 0, fibptr = &dev->fibs[i]; i < (dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB); i++, fibptr++) 119 for (i = 0, fibptr = &dev->fibs[i];
120 i < (dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB);
121 i++, fibptr++)
120 {122 {
121 fibptr->dev = dev;123 fibptr->dev = dev;
122 fibptr->hw_fib_va = hw_fib;124 fibptr->hw_fib_va = hw_fib;
@@ -148,13 +150,13 @@ int aac_fib_setup(struct aac_dev * dev) · 25 unmodified lines
148 * Allocate a fib from the adapter fib pool. If the pool is empty we150 * Allocate a fib from the adapter fib pool. If the pool is empty we
149 * return NULL.151 * return NULL.
150 */152 */
151 153
152struct fib *aac_fib_alloc(struct aac_dev *dev)154struct fib *aac_fib_alloc(struct aac_dev *dev)
153{155{
154 struct fib * fibptr;156 struct fib * fibptr;
155 unsigned long flags;157 unsigned long flags;
156 spin_lock_irqsave(&dev->fib_lock, flags);158 spin_lock_irqsave(&dev->fib_lock, flags);
157 fibptr = dev->free_fib; 159 fibptr = dev->free_fib;
158 if(!fibptr){160 if(!fibptr){
159 spin_unlock_irqrestore(&dev->fib_lock, flags);161 spin_unlock_irqrestore(&dev->fib_lock, flags);
160 return fibptr;162 return fibptr;
@@ -171,6 +173,7 @@ struct fib *aac_fib_alloc(struct aac_dev *dev) · 10 unmodified lines
171 * each I/O173 * each I/O
172 */174 */
173 fibptr->hw_fib_va->header.XferState = 0;175 fibptr->hw_fib_va->header.XferState = 0;
176 fibptr->flags = 0;
174 fibptr->callback = NULL;177 fibptr->callback = NULL;
175 fibptr->callback_data = NULL;178 fibptr->callback_data = NULL;
176 179
@@ -183,7 +186,7 @@ struct fib *aac_fib_alloc(struct aac_dev *dev) · 6 unmodified lines
183 *186 *
184 * Frees up a fib and places it on the appropriate queue187 * Frees up a fib and places it on the appropriate queue
185 */188 */
186 189
187void aac_fib_free(struct fib *fibptr)190void aac_fib_free(struct fib *fibptr)
188{191{
189 unsigned long flags;192 unsigned long flags;
@@ -204,10 +207,10 @@ void aac_fib_free(struct fib *fibptr) · 14 unmodified lines
204/**207/**
205 * aac_fib_init - initialise a fib208 * aac_fib_init - initialise a fib
206 * @fibptr: The fib to initialize209 * @fibptr: The fib to initialize
207 * 210 *
208 * Set up the generic fib fields ready for use211 * Set up the generic fib fields ready for use
209 */212 */
210 213
211void aac_fib_init(struct fib *fibptr)214void aac_fib_init(struct fib *fibptr)
212{215{
213 struct hw_fib *hw_fib = fibptr->hw_fib_va;216 struct hw_fib *hw_fib = fibptr->hw_fib_va;
@@ -227,12 +230,12 @@ void aac_fib_init(struct fib *fibptr) · 13 unmodified lines
227 * Will deallocate and return to the free pool the FIB pointed to by the230 * Will deallocate and return to the free pool the FIB pointed to by the
228 * caller.231 * caller.
229 */232 */
230 233
231static void fib_dealloc(struct fib * fibptr)234static void fib_dealloc(struct fib * fibptr)
232{235{
233 struct hw_fib *hw_fib = fibptr->hw_fib_va;236 struct hw_fib *hw_fib = fibptr->hw_fib_va;
234 BUG_ON(hw_fib->header.StructType != FIB_MAGIC);237 BUG_ON(hw_fib->header.StructType != FIB_MAGIC);
235 hw_fib->header.XferState = 0; 238 hw_fib->header.XferState = 0;
236}239}
237 240
238/*241/*
@@ -241,7 +244,7 @@ static void fib_dealloc(struct fib * fibptr) · 2 unmodified lines
241 * these routines and are the only routines which have a knowledge of the244 * these routines and are the only routines which have a knowledge of the
242 * how these queues are implemented.245 * how these queues are implemented.
243 */246 */
244 247
245/**248/**
246 * aac_get_entry - get a queue entry249 * aac_get_entry - get a queue entry
247 * @dev: Adapter250 * @dev: Adapter
@@ -254,7 +257,7 @@ static void fib_dealloc(struct fib * fibptr) · 6 unmodified lines
254 * is full(no free entries) than no entry is returned and the function returns 0 otherwise 1 is257 * is full(no free entries) than no entry is returned and the function returns 0 otherwise 1 is
255 * returned.258 * returned.
256 */259 */
257 260
258static int aac_get_entry (struct aac_dev * dev, u32 qid, struct aac_entry **entry, u32 * index, unsigned long *nonotify)261static int aac_get_entry (struct aac_dev * dev, u32 qid, struct aac_entry **entry, u32 * index, unsigned long *nonotify)
259{262{
260 struct aac_queue * q;263 struct aac_queue * q;
@@ -279,26 +282,27 @@ static int aac_get_entry (struct aac_dev * dev, u32 qid, struct aac_entry **entr · 18 unmodified lines
279 idx = ADAP_NORM_RESP_ENTRIES;282 idx = ADAP_NORM_RESP_ENTRIES;
280 }283 }
281 if (idx != le32_to_cpu(*(q->headers.consumer)))284 if (idx != le32_to_cpu(*(q->headers.consumer)))
282 *nonotify = 1; 285 *nonotify = 1;
283 }286 }
284 287
285 if (qid == AdapNormCmdQueue) {288 if (qid == AdapNormCmdQueue) {
286 if (*index >= ADAP_NORM_CMD_ENTRIES) 289 if (*index >= ADAP_NORM_CMD_ENTRIES)
287 *index = 0; /* Wrap to front of the Producer Queue. */290 *index = 0; /* Wrap to front of the Producer Queue. */
288 } else {291 } else {
289 if (*index >= ADAP_NORM_RESP_ENTRIES) 292 if (*index >= ADAP_NORM_RESP_ENTRIES)
290 *index = 0; /* Wrap to front of the Producer Queue. */293 *index = 0; /* Wrap to front of the Producer Queue. */
291 }294 }
292 295
293 if ((*index + 1) == le32_to_cpu(*(q->headers.consumer))) { /* Queue is full */296 /* Queue is full */
297 if ((*index + 1) == le32_to_cpu(*(q->headers.consumer))) {
294 printk(KERN_WARNING "Queue %d full, %u outstanding.\n",298 printk(KERN_WARNING "Queue %d full, %u outstanding.\n",
295 qid, q->numpending);299 qid, q->numpending);
296 return 0;300 return 0;
297 } else {301 } else {
298 *entry = q->base + *index;302 *entry = q->base + *index;
299 return 1;303 return 1;
300 }304 }
301} 305}
302 306
303/**307/**
304 * aac_queue_get - get the next free QE308 * aac_queue_get - get the next free QE
@@ -320,31 +324,29 @@ int aac_queue_get(struct aac_dev * dev, u32 * index, u32 qid, struct hw_fib * hw · 15 unmodified lines
320{324{
321 struct aac_entry * entry = NULL;325 struct aac_entry * entry = NULL;
322 int map = 0;326 int map = 0;
323 327
324 if (qid == AdapNormCmdQueue) {328 if (qid == AdapNormCmdQueue) {
325 /* if no entries wait for some if caller wants to */329 /* if no entries wait for some if caller wants to */
326 while (!aac_get_entry(dev, qid, &entry, index, nonotify)) 330 while (!aac_get_entry(dev, qid, &entry, index, nonotify)) {
327 {
328 printk(KERN_ERR "GetEntries failed\n");331 printk(KERN_ERR "GetEntries failed\n");
329 }332 }
330 /*333 /*
331 * Setup queue entry with a command, status and fib mapped334 * Setup queue entry with a command, status and fib mapped
332 */335 */
333 entry->size = cpu_to_le32(le16_to_cpu(hw_fib->header.Size));336 entry->size = cpu_to_le32(le16_to_cpu(hw_fib->header.Size));
334 map = 1;337 map = 1;
335 } else {338 } else {
336 while(!aac_get_entry(dev, qid, &entry, index, nonotify)) 339 while (!aac_get_entry(dev, qid, &entry, index, nonotify)) {
337 {
338 /* if no entries wait for some if caller wants to */340 /* if no entries wait for some if caller wants to */
339 }341 }
340 /*342 /*
341 * Setup queue entry with command, status and fib mapped343 * Setup queue entry with command, status and fib mapped
342 */344 */
343 entry->size = cpu_to_le32(le16_to_cpu(hw_fib->header.Size));345 entry->size = cpu_to_le32(le16_to_cpu(hw_fib->header.Size));
344 entry->addr = hw_fib->header.SenderFibAddress;346 entry->addr = hw_fib->header.SenderFibAddress;
345 /* Restore adapters pointer to the FIB */347 /* Restore adapters pointer to the FIB */
346 hw_fib->header.ReceiverFibAddress = hw_fib->header.SenderFibAddress; /* Let the adapter now where to find its data */348 hw_fib->header.ReceiverFibAddress = hw_fib->header.SenderFibAddress; /* Let the adapter now where to find its data */
347 map = 0;349 map = 0;
348 }350 }
349 /*351 /*
350 * If MapFib is true than we need to map the Fib and put pointers352 * If MapFib is true than we need to map the Fib and put pointers
@@ -356,8 +358,8 @@ int aac_queue_get(struct aac_dev * dev, u32 * index, u32 qid, struct hw_fib * hw · 5 unmodified lines
356}358}
357 359
358/*360/*
359 * Define the highest level of host to adapter communication routines. 361 * Define the highest level of host to adapter communication routines.
360 * These routines will support host to adapter FS commuication. These 362 * These routines will support host to adapter FS commuication. These
361 * routines have no knowledge of the commuication method used. This level363 * routines have no knowledge of the commuication method used. This level
362 * sends and receives FIBs. This level has no knowledge of how these FIBs364 * sends and receives FIBs. This level has no knowledge of how these FIBs
363 * get passed back and forth.365 * get passed back and forth.
@@ -379,7 +381,7 @@ int aac_queue_get(struct aac_dev * dev, u32 * index, u32 qid, struct hw_fib * hw · 15 unmodified lines
379 * an event to wait on must be supplied. This event will be set when a381 * an event to wait on must be supplied. This event will be set when a
380 * response FIB is received from the adapter.382 * response FIB is received from the adapter.
381 */383 */
382 384
383int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size,385int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size,
384 int priority, int wait, int reply, fib_callback callback,386 int priority, int wait, int reply, fib_callback callback,
385 void *callback_data)387 void *callback_data)
@@ -392,16 +394,17 @@ int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size, · 6 unmodified lines
392 if (!(hw_fib->header.XferState & cpu_to_le32(HostOwned)))394 if (!(hw_fib->header.XferState & cpu_to_le32(HostOwned)))
393 return -EBUSY;395 return -EBUSY;
394 /*396 /*
395 * There are 5 cases with the wait and reponse requested flags. 397 * There are 5 cases with the wait and reponse requested flags.
396 * The only invalid cases are if the caller requests to wait and398 * The only invalid cases are if the caller requests to wait and
397 * does not request a response and if the caller does not want a399 * does not request a response and if the caller does not want a
398 * response and the Fib is not allocated from pool. If a response400 * response and the Fib is not allocated from pool. If a response
399 * is not requesed the Fib will just be deallocaed by the DPC401 * is not requesed the Fib will just be deallocaed by the DPC
400 * routine when the response comes back from the adapter. No402 * routine when the response comes back from the adapter. No
401 * further processing will be done besides deleting the Fib. We 403 * further processing will be done besides deleting the Fib. We
402 * will have a debug mode where the adapter can notify the host404 * will have a debug mode where the adapter can notify the host
403 * it had a problem and the host can log that fact.405 * it had a problem and the host can log that fact.
404 */406 */
407 fibptr->flags = 0;
405 if (wait && !reply) {408 if (wait && !reply) {
406 return -EINVAL;409 return -EINVAL;
407 } else if (!wait && reply) {410 } else if (!wait && reply) {
@@ -413,7 +416,7 @@ int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size, · 5 unmodified lines
413 } else if (wait && reply) {416 } else if (wait && reply) {
414 hw_fib->header.XferState |= cpu_to_le32(ResponseExpected);417 hw_fib->header.XferState |= cpu_to_le32(ResponseExpected);
415 FIB_COUNTER_INCREMENT(aac_config.NormalSent);418 FIB_COUNTER_INCREMENT(aac_config.NormalSent);
416 } 419 }
417 /*420 /*
418 * Map the fib into 32bits by using the fib number421 * Map the fib into 32bits by using the fib number
419 */422 */
@@ -436,7 +439,7 @@ int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size, · 16 unmodified lines
436 hw_fib->header.Size = cpu_to_le16(sizeof(struct aac_fibhdr) + size);439 hw_fib->header.Size = cpu_to_le16(sizeof(struct aac_fibhdr) + size);
437 if (le16_to_cpu(hw_fib->header.Size) > le16_to_cpu(hw_fib->header.SenderSize)) {440 if (le16_to_cpu(hw_fib->header.Size) > le16_to_cpu(hw_fib->header.SenderSize)) {
438 return -EMSGSIZE;441 return -EMSGSIZE;
439 } 442 }
440 /*443 /*
441 * Get a queue entry connect the FIB to it and send an notify444 * Get a queue entry connect the FIB to it and send an notify
442 * the adapter a command is ready.445 * the adapter a command is ready.
@@ -450,10 +453,10 @@ int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size, · 7 unmodified lines
450 if (!wait) {453 if (!wait) {
451 fibptr->callback = callback;454 fibptr->callback = callback;
452 fibptr->callback_data = callback_data;455 fibptr->callback_data = callback_data;
456 fibptr->flags = FIB_CONTEXT_FLAG;
453 }457 }
454 458
455 fibptr->done = 0;459 fibptr->done = 0;
456 fibptr->flags = 0;
457 460
458 FIB_COUNTER_INCREMENT(aac_config.FibsSent);461 FIB_COUNTER_INCREMENT(aac_config.FibsSent);
459 462
@@ -473,9 +476,9 @@ int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size, · 13 unmodified lines
473 aac_adapter_deliver(fibptr);476 aac_adapter_deliver(fibptr);
474 477
475 /*478 /*
476 * If the caller wanted us to wait for response wait now. 479 * If the caller wanted us to wait for response wait now.
477 */480 */
478 481
479 if (wait) {482 if (wait) {
480 spin_unlock_irqrestore(&fibptr->event_lock, flags);483 spin_unlock_irqrestore(&fibptr->event_lock, flags);
481 /* Only set for first known interruptable command */484 /* Only set for first known interruptable command */
@@ -522,7 +525,7 @@ int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size, · 40 unmodified lines
522 }525 }
523 spin_unlock_irqrestore(&fibptr->event_lock, flags);526 spin_unlock_irqrestore(&fibptr->event_lock, flags);
524 BUG_ON(fibptr->done == 0);527 BUG_ON(fibptr->done == 0);
525 528
526 if(unlikely(fibptr->flags & FIB_CONTEXT_FLAG_TIMED_OUT))529 if(unlikely(fibptr->flags & FIB_CONTEXT_FLAG_TIMED_OUT))
527 return -ETIMEDOUT;530 return -ETIMEDOUT;
528 return 0;531 return 0;
@@ -537,15 +540,15 @@ int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size, · 8 unmodified lines
537 return 0;540 return 0;
538}541}
539 542
540/** 543/**
541 * aac_consumer_get - get the top of the queue544 * aac_consumer_get - get the top of the queue
542 * @dev: Adapter545 * @dev: Adapter
543 * @q: Queue546 * @q: Queue
544 * @entry: Return entry547 * @entry: Return entry
545 *548 *
546 * Will return a pointer to the entry on the top of the queue requested that549 * Will return a pointer to the entry on the top of the queue requested that
547 * we are a consumer of, and return the address of the queue entry. It does550 * we are a consumer of, and return the address of the queue entry. It does
548 * not change the state of the queue. 551 * not change the state of the queue.
549 */552 */
550 553
551int aac_consumer_get(struct aac_dev * dev, struct aac_queue * q, struct aac_entry **entry)554int aac_consumer_get(struct aac_dev * dev, struct aac_queue * q, struct aac_entry **entry)
@@ -560,10 +563,10 @@ int aac_consumer_get(struct aac_dev * dev, struct aac_queue * q, struct aac_entr · 8 unmodified lines
560 * the end of the queue, else we just use the entry563 * the end of the queue, else we just use the entry
561 * pointed to by the header index564 * pointed to by the header index
562 */565 */
563 if (le32_to_cpu(*q->headers.consumer) >= q->entries) 566 if (le32_to_cpu(*q->headers.consumer) >= q->entries)
564 index = 0; 567 index = 0;
565 else568 else
566 index = le32_to_cpu(*q->headers.consumer);569 index = le32_to_cpu(*q->headers.consumer);
567 *entry = q->base + index;570 *entry = q->base + index;
568 status = 1;571 status = 1;
569 }572 }
@@ -587,12 +590,12 @@ void aac_consumer_free(struct aac_dev * dev, struct aac_queue *q, u32 qid) · 17 unmodified lines
587 590
588 if ((le32_to_cpu(*q->headers.producer)+1) == le32_to_cpu(*q->headers.consumer))591 if ((le32_to_cpu(*q->headers.producer)+1) == le32_to_cpu(*q->headers.consumer))
589 wasfull = 1;592 wasfull = 1;
590 593
591 if (le32_to_cpu(*q->headers.consumer) >= q->entries)594 if (le32_to_cpu(*q->headers.consumer) >= q->entries)
592 *q->headers.consumer = cpu_to_le32(1);595 *q->headers.consumer = cpu_to_le32(1);
593 else596 else
594 *q->headers.consumer = cpu_to_le32(le32_to_cpu(*q->headers.consumer)+1);597 *q->headers.consumer = cpu_to_le32(le32_to_cpu(*q->headers.consumer)+1);
595 598
596 if (wasfull) {599 if (wasfull) {
597 switch (qid) {600 switch (qid) {
598 601
@@ -608,7 +611,7 @@ void aac_consumer_free(struct aac_dev * dev, struct aac_queue *q, u32 qid) · 9 unmodified lines
608 }611 }
609 aac_adapter_notify(dev, notify);612 aac_adapter_notify(dev, notify);
610 }613 }
611} 614}
612 615
613/**616/**
614 * aac_fib_adapter_complete - complete adapter issued fib617 * aac_fib_adapter_complete - complete adapter issued fib
@@ -630,32 +633,32 @@ int aac_fib_adapter_complete(struct fib *fibptr, unsigned short size) · 15 unmodified lines
630 if (hw_fib->header.XferState == 0) {633 if (hw_fib->header.XferState == 0) {
631 if (dev->comm_interface == AAC_COMM_MESSAGE)634 if (dev->comm_interface == AAC_COMM_MESSAGE)
632 kfree (hw_fib);635 kfree (hw_fib);
633 return 0;636 return 0;
634 }637 }
635 /*638 /*
636 * If we plan to do anything check the structure type first.639 * If we plan to do anything check the structure type first.
637 */ 640 */
638 if ( hw_fib->header.StructType != FIB_MAGIC ) {641 if (hw_fib->header.StructType != FIB_MAGIC) {
639 if (dev->comm_interface == AAC_COMM_MESSAGE)642 if (dev->comm_interface == AAC_COMM_MESSAGE)
640 kfree (hw_fib);643 kfree (hw_fib);
641 return -EINVAL;644 return -EINVAL;
642 }645 }
643 /*646 /*
644 * This block handles the case where the adapter had sent us a647 * This block handles the case where the adapter had sent us a
645 * command and we have finished processing the command. We648 * command and we have finished processing the command. We
646 * call completeFib when we are done processing the command 649 * call completeFib when we are done processing the command
647 * and want to send a response back to the adapter. This will 650 * and want to send a response back to the adapter. This will
648 * send the completed cdb to the adapter.651 * send the completed cdb to the adapter.
649 */652 */
650 if (hw_fib->header.XferState & cpu_to_le32(SentFromAdapter)) {653 if (hw_fib->header.XferState & cpu_to_le32(SentFromAdapter)) {
651 if (dev->comm_interface == AAC_COMM_MESSAGE) {654 if (dev->comm_interface == AAC_COMM_MESSAGE) {
652 kfree (hw_fib);655 kfree (hw_fib);
653 } else {656 } else {
654 u32 index;657 u32 index;
655 hw_fib->header.XferState |= cpu_to_le32(HostProcessed);658 hw_fib->header.XferState |= cpu_to_le32(HostProcessed);
656 if (size) {659 if (size) {
657 size += sizeof(struct aac_fibhdr);660 size += sizeof(struct aac_fibhdr);
658 if (size > le16_to_cpu(hw_fib->header.SenderSize)) 661 if (size > le16_to_cpu(hw_fib->header.SenderSize))
659 return -EMSGSIZE;662 return -EMSGSIZE;
660 hw_fib->header.Size = cpu_to_le16(size);663 hw_fib->header.Size = cpu_to_le16(size);
661 }664 }
@@ -667,12 +670,11 @@ int aac_fib_adapter_complete(struct fib *fibptr, unsigned short size) · 5 unmodified lines
667 if (!(nointr & (int)aac_config.irq_mod))670 if (!(nointr & (int)aac_config.irq_mod))
668 aac_adapter_notify(dev, AdapNormRespQueue);671 aac_adapter_notify(dev, AdapNormRespQueue);
669 }672 }
673 } else {
674 printk(KERN_WARNING "aac_fib_adapter_complete: "
675 "Unknown xferstate detected.\n");
676 BUG();
670 }677 }
671 else
672 {
673 printk(KERN_WARNING "aac_fib_adapter_complete: Unknown xferstate detected.\n");
674 BUG();
675 }
676 return 0;678 return 0;
677}679}
678 680
@@ -682,7 +684,7 @@ int aac_fib_adapter_complete(struct fib *fibptr, unsigned short size) · 3 unmodified lines
682 *684 *
683 * Will do all necessary work to complete a FIB.685 * Will do all necessary work to complete a FIB.
684 */686 */
685 687
686int aac_fib_complete(struct fib *fibptr)688int aac_fib_complete(struct fib *fibptr)
687{689{
688 struct hw_fib * hw_fib = fibptr->hw_fib_va;690 struct hw_fib * hw_fib = fibptr->hw_fib_va;
@@ -692,15 +694,15 @@ int aac_fib_complete(struct fib *fibptr) · 3 unmodified lines
692 */694 */
693 695
694 if (hw_fib->header.XferState == 0)696 if (hw_fib->header.XferState == 0)
695 return 0;697 return 0;
696 /*698 /*
697 * If we plan to do anything check the structure type first.699 * If we plan to do anything check the structure type first.
698 */ 700 */
699 701
700 if (hw_fib->header.StructType != FIB_MAGIC)702 if (hw_fib->header.StructType != FIB_MAGIC)
701 return -EINVAL;703 return -EINVAL;
702 /*704 /*
703 * This block completes a cdb which orginated on the host and we 705 * This block completes a cdb which orginated on the host and we
704 * just need to deallocate the cdb or reinit it. At this point the706 * just need to deallocate the cdb or reinit it. At this point the
705 * command is complete that we had sent to the adapter and this707 * command is complete that we had sent to the adapter and this
706 * cdb could be reused.708 * cdb could be reused.
@@ -721,7 +723,7 @@ int aac_fib_complete(struct fib *fibptr) · 14 unmodified lines
721 fib_dealloc(fibptr);723 fib_dealloc(fibptr);
722 } else {724 } else {
723 BUG();725 BUG();
724 } 726 }
725 return 0;727 return 0;
726}728}
727 729
@@ -741,7 +743,7 @@ void aac_printf(struct aac_dev *dev, u32 val) · 13 unmodified lines
741 {743 {
742 int length = val & 0xffff;744 int length = val & 0xffff;
743 int level = (val >> 16) & 0xffff;745 int level = (val >> 16) & 0xffff;
744 746
745 /*747 /*
746 * The size of the printfbuf is set in port.c748 * The size of the printfbuf is set in port.c
747 * There is no variable or define for it749 * There is no variable or define for it
@@ -755,7 +757,7 @@ void aac_printf(struct aac_dev *dev, u32 val) · 7 unmodified lines
755 else757 else
756 printk(KERN_INFO "%s:%s", dev->name, cp);758 printk(KERN_INFO "%s:%s", dev->name, cp);
757 }759 }
758 memset(cp, 0, 256);760 memset(cp, 0, 256);
759}761}
760 762
761 763
@@ -773,20 +775,20 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) · 11 unmodified lines
773{775{
774 struct hw_fib * hw_fib = fibptr->hw_fib_va;776 struct hw_fib * hw_fib = fibptr->hw_fib_va;
775 struct aac_aifcmd * aifcmd = (struct aac_aifcmd *)hw_fib->data;777 struct aac_aifcmd * aifcmd = (struct aac_aifcmd *)hw_fib->data;
776 u32 container;778 u32 channel, id, lun, container;
777 struct scsi_device *device;779 struct scsi_device *device;
778 enum {780 enum {
779 NOTHING,781 NOTHING,
780 DELETE,782 DELETE,
781 ADD,783 ADD,
782 CHANGE784 CHANGE
783 } device_config_needed;785 } device_config_needed = NOTHING;
784 786
785 /* Sniff for container changes */787 /* Sniff for container changes */
786 788
787 if (!dev || !dev->fsa_dev)789 if (!dev || !dev->fsa_dev)
788 return;790 return;
789 container = (u32)-1;791 container = channel = id = lun = (u32)-1;
790 792
791 /*793 /*
792 * We have set this up to try and minimize the number of794 * We have set this up to try and minimize the number of
@@ -796,13 +798,13 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) · 3 unmodified lines
796 */798 */
797 switch (le32_to_cpu(aifcmd->command)) {799 switch (le32_to_cpu(aifcmd->command)) {
798 case AifCmdDriverNotify:800 case AifCmdDriverNotify:
799 switch (le32_to_cpu(((u32 *)aifcmd->data)[0])) {801 switch (le32_to_cpu(((__le32 *)aifcmd->data)[0])) {
800 /*802 /*
801 * Morph or Expand complete803 * Morph or Expand complete
802 */804 */
803 case AifDenMorphComplete:805 case AifDenMorphComplete:
804 case AifDenVolumeExtendComplete:806 case AifDenVolumeExtendComplete:
805 container = le32_to_cpu(((u32 *)aifcmd->data)[1]);807 container = le32_to_cpu(((__le32 *)aifcmd->data)[1]);
806 if (container >= dev->maximum_num_containers)808 if (container >= dev->maximum_num_containers)
807 break;809 break;
808 810
@@ -814,9 +816,9 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) · 5 unmodified lines
814 */816 */
815 817
816 if ((dev != NULL) && (dev->scsi_host_ptr != NULL)) {818 if ((dev != NULL) && (dev->scsi_host_ptr != NULL)) {
817 device = scsi_device_lookup(dev->scsi_host_ptr, 819 device = scsi_device_lookup(dev->scsi_host_ptr,
818 CONTAINER_TO_CHANNEL(container), 820 CONTAINER_TO_CHANNEL(container),
819 CONTAINER_TO_ID(container), 821 CONTAINER_TO_ID(container),
820 CONTAINER_TO_LUN(container));822 CONTAINER_TO_LUN(container));
821 if (device) {823 if (device) {
822 dev->fsa_dev[container].config_needed = CHANGE;824 dev->fsa_dev[container].config_needed = CHANGE;
@@ -835,25 +837,29 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) · 12 unmodified lines
835 if (container >= dev->maximum_num_containers)837 if (container >= dev->maximum_num_containers)
836 break;838 break;
837 if ((dev->fsa_dev[container].config_waiting_on ==839 if ((dev->fsa_dev[container].config_waiting_on ==
838 le32_to_cpu(*(u32 *)aifcmd->data)) &&840 le32_to_cpu(*(__le32 *)aifcmd->data)) &&
839 time_before(jiffies, dev->fsa_dev[container].config_waiting_stamp + AIF_SNIFF_TIMEOUT))841 time_before(jiffies, dev->fsa_dev[container].config_waiting_stamp + AIF_SNIFF_TIMEOUT))
840 dev->fsa_dev[container].config_waiting_on = 0;842 dev->fsa_dev[container].config_waiting_on = 0;
841 } else for (container = 0;843 } else for (container = 0;
842 container < dev->maximum_num_containers; ++container) {844 container < dev->maximum_num_containers; ++container) {
843 if ((dev->fsa_dev[container].config_waiting_on ==845 if ((dev->fsa_dev[container].config_waiting_on ==
844 le32_to_cpu(*(u32 *)aifcmd->data)) &&846 le32_to_cpu(*(__le32 *)aifcmd->data)) &&
845 time_before(jiffies, dev->fsa_dev[container].config_waiting_stamp + AIF_SNIFF_TIMEOUT))847 time_before(jiffies, dev->fsa_dev[container].config_waiting_stamp + AIF_SNIFF_TIMEOUT))
846 dev->fsa_dev[container].config_waiting_on = 0;848 dev->fsa_dev[container].config_waiting_on = 0;
847 }849 }
848 break;850 break;
849 851
850 case AifCmdEventNotify:852 case AifCmdEventNotify:
851 switch (le32_to_cpu(((u32 *)aifcmd->data)[0])) {853 switch (le32_to_cpu(((__le32 *)aifcmd->data)[0])) {
854 case AifEnBatteryEvent:
855 dev->cache_protected =
856 (((__le32 *)aifcmd->data)[1] == cpu_to_le32(3));
857 break;
852 /*858 /*
853 * Add an Array.859 * Add an Array.
854 */860 */
855 case AifEnAddContainer:861 case AifEnAddContainer:
856 container = le32_to_cpu(((u32 *)aifcmd->data)[1]);862 container = le32_to_cpu(((__le32 *)aifcmd->data)[1]);
857 if (container >= dev->maximum_num_containers)863 if (container >= dev->maximum_num_containers)
858 break;864 break;
859 dev->fsa_dev[container].config_needed = ADD;865 dev->fsa_dev[container].config_needed = ADD;
@@ -866,7 +872,7 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) · 6 unmodified lines
866 * Delete an Array.872 * Delete an Array.
867 */873 */
868 case AifEnDeleteContainer:874 case AifEnDeleteContainer:
869 container = le32_to_cpu(((u32 *)aifcmd->data)[1]);875 container = le32_to_cpu(((__le32 *)aifcmd->data)[1]);
870 if (container >= dev->maximum_num_containers)876 if (container >= dev->maximum_num_containers)
871 break;877 break;
872 dev->fsa_dev[container].config_needed = DELETE;878 dev->fsa_dev[container].config_needed = DELETE;
@@ -880,7 +886,7 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) · 7 unmodified lines
880 * waiting on something else, setup to wait on a Config Change.886 * waiting on something else, setup to wait on a Config Change.
881 */887 */
882 case AifEnContainerChange:888 case AifEnContainerChange:
883 container = le32_to_cpu(((u32 *)aifcmd->data)[1]);889 container = le32_to_cpu(((__le32 *)aifcmd->data)[1]);
884 if (container >= dev->maximum_num_containers)890 if (container >= dev->maximum_num_containers)
885 break;891 break;
886 if (dev->fsa_dev[container].config_waiting_on &&892 if (dev->fsa_dev[container].config_waiting_on &&
@@ -895,6 +901,60 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) · 8 unmodified lines
895 case AifEnConfigChange:901 case AifEnConfigChange:
896 break;902 break;
897 903
904 case AifEnAddJBOD:
905 case AifEnDeleteJBOD:
906 container = le32_to_cpu(((__le32 *)aifcmd->data)[1]);
907 if ((container >> 28))
908 break;
909 channel = (container >> 24) & 0xF;
910 if (channel >= dev->maximum_num_channels)
911 break;
912 id = container & 0xFFFF;
913 if (id >= dev->maximum_num_physicals)
914 break;
915 lun = (container >> 16) & 0xFF;
916 channel = aac_phys_to_logical(channel);
917 device_config_needed =
918 (((__le32 *)aifcmd->data)[0] ==
919 cpu_to_le32(AifEnAddJBOD)) ? ADD : DELETE;
920 break;
921
922 case AifEnEnclosureManagement:
923 /*
924 * If in JBOD mode, automatic exposure of new
925 * physical target to be suppressed until configured.
926 */
927 if (dev->jbod)
928 break;
929 switch (le32_to_cpu(((__le32 *)aifcmd->data)[3])) {
930 case EM_DRIVE_INSERTION:
931 case EM_DRIVE_REMOVAL:
932 container = le32_to_cpu(
933 ((__le32 *)aifcmd->data)[2]);
934 if ((container >> 28))
935 break;
936 channel = (container >> 24) & 0xF;
937 if (channel >= dev->maximum_num_channels)
938 break;
939 id = container & 0xFFFF;
940 lun = (container >> 16) & 0xFF;
941 if (id >= dev->maximum_num_physicals) {
942 /* legacy dev_t ? */
943 if ((0x2000 <= id) || lun || channel ||
944 ((channel = (id >> 7) & 0x3F) >=
945 dev->maximum_num_channels))
946 break;
947 lun = (id >> 4) & 7;
948 id &= 0xF;
949 }
950 channel = aac_phys_to_logical(channel);
951 device_config_needed =
952 (((__le32 *)aifcmd->data)[3]
953 == cpu_to_le32(EM_DRIVE_INSERTION)) ?
954 ADD : DELETE;
955 break;
956 }
957 break;
898 }958 }
899 959
900 /*960 /*
@@ -905,13 +965,13 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) · 4 unmodified lines
905 if (container >= dev->maximum_num_containers)965 if (container >= dev->maximum_num_containers)
906 break;966 break;
907 if ((dev->fsa_dev[container].config_waiting_on ==967 if ((dev->fsa_dev[container].config_waiting_on ==
908 le32_to_cpu(*(u32 *)aifcmd->data)) &&968 le32_to_cpu(*(__le32 *)aifcmd->data)) &&
909 time_before(jiffies, dev->fsa_dev[container].config_waiting_stamp + AIF_SNIFF_TIMEOUT))969 time_before(jiffies, dev->fsa_dev[container].config_waiting_stamp + AIF_SNIFF_TIMEOUT))
910 dev->fsa_dev[container].config_waiting_on = 0;970 dev->fsa_dev[container].config_waiting_on = 0;
911 } else for (container = 0;971 } else for (container = 0;
912 container < dev->maximum_num_containers; ++container) {972 container < dev->maximum_num_containers; ++container) {
913 if ((dev->fsa_dev[container].config_waiting_on ==973 if ((dev->fsa_dev[container].config_waiting_on ==
914 le32_to_cpu(*(u32 *)aifcmd->data)) &&974 le32_to_cpu(*(__le32 *)aifcmd->data)) &&
915 time_before(jiffies, dev->fsa_dev[container].config_waiting_stamp + AIF_SNIFF_TIMEOUT))975 time_before(jiffies, dev->fsa_dev[container].config_waiting_stamp + AIF_SNIFF_TIMEOUT))
916 dev->fsa_dev[container].config_waiting_on = 0;976 dev->fsa_dev[container].config_waiting_on = 0;
917 }977 }
@@ -926,9 +986,9 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) · 8 unmodified lines
926 * wait for a container change.986 * wait for a container change.
927 */987 */
928 988
929 if ((((u32 *)aifcmd->data)[1] == cpu_to_le32(AifJobCtrZero))989 if (((__le32 *)aifcmd->data)[1] == cpu_to_le32(AifJobCtrZero) &&
930 && ((((u32 *)aifcmd->data)[6] == ((u32 *)aifcmd->data)[5])990 (((__le32 *)aifcmd->data)[6] == ((__le32 *)aifcmd->data)[5] ||
931 || (((u32 *)aifcmd->data)[4] == cpu_to_le32(AifJobStsSuccess)))) {991 ((__le32 *)aifcmd->data)[4] == cpu_to_le32(AifJobStsSuccess))) {
932 for (container = 0;992 for (container = 0;
933 container < dev->maximum_num_containers;993 container < dev->maximum_num_containers;
934 ++container) {994 ++container) {
@@ -943,9 +1003,9 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) · 8 unmodified lines
943 jiffies;1003 jiffies;
944 }1004 }
945 }1005 }
946 if ((((u32 *)aifcmd->data)[1] == cpu_to_le32(AifJobCtrZero))1006 if (((__le32 *)aifcmd->data)[1] == cpu_to_le32(AifJobCtrZero) &&
947 && (((u32 *)aifcmd->data)[6] == 0)1007 ((__le32 *)aifcmd->data)[6] == 0 &&
948 && (((u32 *)aifcmd->data)[4] == cpu_to_le32(AifJobStsRunning))) {1008 ((__le32 *)aifcmd->data)[4] == cpu_to_le32(AifJobStsRunning)) {
949 for (container = 0;1009 for (container = 0;
950 container < dev->maximum_num_containers;1010 container < dev->maximum_num_containers;
951 ++container) {1011 ++container) {
@@ -963,7 +1023,7 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) · 11 unmodified lines
963 break;1023 break;
964 }1024 }
965 1025
966 device_config_needed = NOTHING;1026 if (device_config_needed == NOTHING)
967 for (container = 0; container < dev->maximum_num_containers;1027 for (container = 0; container < dev->maximum_num_containers;
968 ++container) {1028 ++container) {
969 if ((dev->fsa_dev[container].config_waiting_on == 0) &&1029 if ((dev->fsa_dev[container].config_waiting_on == 0) &&
@@ -972,6 +1032,9 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) · 2 unmodified lines
972 device_config_needed =1032 device_config_needed =
973 dev->fsa_dev[container].config_needed;1033 dev->fsa_dev[container].config_needed;
974 dev->fsa_dev[container].config_needed = NOTHING;1034 dev->fsa_dev[container].config_needed = NOTHING;
1035 channel = CONTAINER_TO_CHANNEL(container);
1036 id = CONTAINER_TO_ID(container);
1037 lun = CONTAINER_TO_LUN(container);
975 break;1038 break;
976 }1039 }
977 }1040 }
@@ -995,34 +1058,56 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr) · 17 unmodified lines
995 /*1058 /*
996 * force reload of disk info via aac_probe_container1059 * force reload of disk info via aac_probe_container
997 */1060 */
998 if ((device_config_needed == CHANGE)1061 if ((channel == CONTAINER_CHANNEL) &&
999 && (dev->fsa_dev[container].valid == 1))1062 (device_config_needed != NOTHING)) {
1000 dev->fsa_dev[container].valid = 2;1063 if (dev->fsa_dev[container].valid == 1)
1001 if ((device_config_needed == CHANGE) ||1064 dev->fsa_dev[container].valid = 2;
1002 (device_config_needed == ADD))
1003 aac_probe_container(dev, container);1065 aac_probe_container(dev, container);
1004 device = scsi_device_lookup(dev->scsi_host_ptr, 1066 }
1005 CONTAINER_TO_CHANNEL(container), 1067 device = scsi_device_lookup(dev->scsi_host_ptr, channel, id, lun);
1006 CONTAINER_TO_ID(container),
1007 CONTAINER_TO_LUN(container));
1008 if (device) {1068 if (device) {
1009 switch (device_config_needed) {1069 switch (device_config_needed) {
1010 case DELETE:1070 case DELETE:
1071 if (scsi_device_online(device)) {
1072 scsi_device_set_state(device, SDEV_OFFLINE);
1073 sdev_printk(KERN_INFO, device,
1074 "Device offlined - %s\n",
1075 (channel == CONTAINER_CHANNEL) ?
1076 "array deleted" :
1077 "enclosure services event");
1078 }
1079 break;
1080 case ADD:
1081 if (!scsi_device_online(device)) {
1082 sdev_printk(KERN_INFO, device,
1083 "Device online - %s\n",
1084 (channel == CONTAINER_CHANNEL) ?
1085 "array created" :
1086 "enclosure services event");
1087 scsi_device_set_state(device, SDEV_RUNNING);
1088 }
1089 /* FALLTHRU */
1011 case CHANGE:1090 case CHANGE:
1091 if ((channel == CONTAINER_CHANNEL)
1092 && (!dev->fsa_dev[container].valid)) {
1093 if (!scsi_device_online(device))
1094 break;
1095 scsi_device_set_state(device, SDEV_OFFLINE);
1096 sdev_printk(KERN_INFO, device,
1097 "Device offlined - %s\n",
1098 "array failed");
1099 break;
1100 }
1012 scsi_rescan_device(&device->sdev_gendev);1101 scsi_rescan_device(&device->sdev_gendev);
1013 1102
1014 default:1103 default:
1015 break;1104 break;
1016 }1105 }
1017 scsi_device_put(device);1106 scsi_device_put(device);
1107 device_config_needed = NOTHING;
1018 }1108 }
1019 if (device_config_needed == ADD) {1109 if (device_config_needed == ADD)
1020 scsi_add_device(dev->scsi_host_ptr,1110 scsi_add_device(dev->scsi_host_ptr, channel, id, lun);
1021 CONTAINER_TO_CHANNEL(container),
1022 CONTAINER_TO_ID(container),
1023 CONTAINER_TO_LUN(container));
1024 }
1025
1026}1111}
1027 1112
1028static int _aac_reset_adapter(struct aac_dev *aac, int forced)1113static int _aac_reset_adapter(struct aac_dev *aac, int forced)
@@ -1099,7 +1184,8 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced) · 70 unmodified lines
1099 free_irq(aac->pdev->irq, aac);1184 free_irq(aac->pdev->irq, aac);
1100 kfree(aac->fsa_dev);1185 kfree(aac->fsa_dev);
1101 aac->fsa_dev = NULL;1186 aac->fsa_dev = NULL;
1102 if (aac_get_driver_ident(index)->quirks & AAC_QUIRK_31BIT) {1187 quirks = aac_get_driver_ident(index)->quirks;
1188 if (quirks & AAC_QUIRK_31BIT) {
1103 if (((retval = pci_set_dma_mask(aac->pdev, DMA_31BIT_MASK))) ||1189 if (((retval = pci_set_dma_mask(aac->pdev, DMA_31BIT_MASK))) ||
1104 ((retval = pci_set_consistent_dma_mask(aac->pdev, DMA_31BIT_MASK))))1190 ((retval = pci_set_consistent_dma_mask(aac->pdev, DMA_31BIT_MASK))))
1105 goto out;1191 goto out;
@@ -1110,7 +1196,7 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced) · 4 unmodified lines
1110 }1196 }
1111 if ((retval = (*(aac_get_driver_ident(index)->init))(aac)))1197 if ((retval = (*(aac_get_driver_ident(index)->init))(aac)))
1112 goto out;1198 goto out;
1113 if (aac_get_driver_ident(index)->quirks & AAC_QUIRK_31BIT)1199 if (quirks & AAC_QUIRK_31BIT)
1114 if ((retval = pci_set_dma_mask(aac->pdev, DMA_32BIT_MASK)))1200 if ((retval = pci_set_dma_mask(aac->pdev, DMA_32BIT_MASK)))
1115 goto out;1201 goto out;
1116 if (jafo) {1202 if (jafo) {
@@ -1121,15 +1207,14 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced) · 4 unmodified lines
1121 }1207 }
1122 }1208 }
1123 (void)aac_get_adapter_info(aac);1209 (void)aac_get_adapter_info(aac);
1124 quirks = aac_get_driver_ident(index)->quirks;
1125 if ((quirks & AAC_QUIRK_34SG) && (host->sg_tablesize > 34)) {1210 if ((quirks & AAC_QUIRK_34SG) && (host->sg_tablesize > 34)) {
1126 host->sg_tablesize = 34;1211 host->sg_tablesize = 34;
1127 host->max_sectors = (host->sg_tablesize * 8) + 112;1212 host->max_sectors = (host->sg_tablesize * 8) + 112;
1128 }1213 }
1129 if ((quirks & AAC_QUIRK_17SG) && (host->sg_tablesize > 17)) {1214 if ((quirks & AAC_QUIRK_17SG) && (host->sg_tablesize > 17)) {
1130 host->sg_tablesize = 17;1215 host->sg_tablesize = 17;
1131 host->max_sectors = (host->sg_tablesize * 8) + 112;1216 host->max_sectors = (host->sg_tablesize * 8) + 112;
1132 }1217 }
1133 aac_get_config_status(aac, 1);1218 aac_get_config_status(aac, 1);
1134 aac_get_containers(aac);1219 aac_get_containers(aac);
1135 /*1220 /*
@@ -1217,12 +1302,13 @@ int aac_reset_adapter(struct aac_dev * aac, int forced) · 81 unmodified lines
1217 }1302 }
1218 1303
1219 /* Quiesce build, flush cache, write through mode */1304 /* Quiesce build, flush cache, write through mode */
1220 aac_send_shutdown(aac);1305 if (forced < 2)
1306 aac_send_shutdown(aac);
1221 spin_lock_irqsave(host->host_lock, flagv);1307 spin_lock_irqsave(host->host_lock, flagv);
1222 retval = _aac_reset_adapter(aac, forced);1308 retval = _aac_reset_adapter(aac, forced ? forced : ((aac_check_reset != 0) && (aac_check_reset != 1)));
1223 spin_unlock_irqrestore(host->host_lock, flagv);1309 spin_unlock_irqrestore(host->host_lock, flagv);
1224 1310
1225 if (retval == -ENODEV) {1311 if ((forced < 2) && (retval == -ENODEV)) {
1226 /* Unwind aac_send_shutdown() IOP_RESET unsupported/disabled */1312 /* Unwind aac_send_shutdown() IOP_RESET unsupported/disabled */
1227 struct fib * fibctx = aac_fib_alloc(aac);1313 struct fib * fibctx = aac_fib_alloc(aac);
1228 if (fibctx) {1314 if (fibctx) {
@@ -1338,11 +1424,11 @@ int aac_check_health(struct aac_dev * aac) · 109 unmodified lines
1338 fib->data = hw_fib->data;1424 fib->data = hw_fib->data;
1339 aif = (struct aac_aifcmd *)hw_fib->data;1425 aif = (struct aac_aifcmd *)hw_fib->data;
1340 aif->command = cpu_to_le32(AifCmdEventNotify);1426 aif->command = cpu_to_le32(AifCmdEventNotify);
1341 aif->seqnum = cpu_to_le32(0xFFFFFFFF);1427 aif->seqnum = cpu_to_le32(0xFFFFFFFF);
1342 aif->data[0] = AifEnExpEvent;1428 ((__le32 *)aif->data)[0] = cpu_to_le32(AifEnExpEvent);
1343 aif->data[1] = AifExeFirmwarePanic;1429 ((__le32 *)aif->data)[1] = cpu_to_le32(AifExeFirmwarePanic);
1344 aif->data[2] = AifHighPriority;1430 ((__le32 *)aif->data)[2] = cpu_to_le32(AifHighPriority);
1345 aif->data[3] = BlinkLED;1431 ((__le32 *)aif->data)[3] = cpu_to_le32(BlinkLED);
1346 1432
1347 /*1433 /*
1348 * Put the FIB onto the1434 * Put the FIB onto the
@@ -1372,14 +1458,14 @@ int aac_check_health(struct aac_dev * aac) · 23 unmodified lines
1372 1458
1373 printk(KERN_ERR "%s: Host adapter BLINK LED 0x%x\n", aac->name, BlinkLED);1459 printk(KERN_ERR "%s: Host adapter BLINK LED 0x%x\n", aac->name, BlinkLED);
1374 1460
1375 if (!aac_check_reset ||1461 if (!aac_check_reset || ((aac_check_reset != 1) &&
1376 (aac->supplement_adapter_info.SupportedOptions2 &1462 (aac->supplement_adapter_info.SupportedOptions2 &
1377 le32_to_cpu(AAC_OPTION_IGNORE_RESET)))1463 AAC_OPTION_IGNORE_RESET)))
1378 goto out;1464 goto out;
1379 host = aac->scsi_host_ptr;1465 host = aac->scsi_host_ptr;
1380 if (aac->thread->pid != current->pid)1466 if (aac->thread->pid != current->pid)
1381 spin_lock_irqsave(host->host_lock, flagv);1467 spin_lock_irqsave(host->host_lock, flagv);
1382 BlinkLED = _aac_reset_adapter(aac, 0);1468 BlinkLED = _aac_reset_adapter(aac, aac_check_reset != 1);
1383 if (aac->thread->pid != current->pid)1469 if (aac->thread->pid != current->pid)
1384 spin_unlock_irqrestore(host->host_lock, flagv);1470 spin_unlock_irqrestore(host->host_lock, flagv);
1385 return BlinkLED;1471 return BlinkLED;
@@ -1399,7 +1485,7 @@ out: · 13 unmodified lines
1399 * until the queue is empty. When the queue is empty it will wait for1485 * until the queue is empty. When the queue is empty it will wait for
1400 * more FIBs.1486 * more FIBs.
1401 */1487 */
1402 1488
1403int aac_command_thread(void *data)1489int aac_command_thread(void *data)
1404{1490{
1405 struct aac_dev *dev = data;1491 struct aac_dev *dev = data;
@@ -1425,30 +1511,29 @@ int aac_command_thread(void *data) · 19 unmodified lines
1425 add_wait_queue(&dev->queues->queue[HostNormCmdQueue].cmdready, &wait);1511 add_wait_queue(&dev->queues->queue[HostNormCmdQueue].cmdready, &wait);
1426 set_current_state(TASK_INTERRUPTIBLE);1512 set_current_state(TASK_INTERRUPTIBLE);
1427 dprintk ((KERN_INFO "aac_command_thread start\n"));1513 dprintk ((KERN_INFO "aac_command_thread start\n"));
1428 while(1) 1514 while (1) {
1429 {
1430 spin_lock_irqsave(dev->queues->queue[HostNormCmdQueue].lock, flags);1515 spin_lock_irqsave(dev->queues->queue[HostNormCmdQueue].lock, flags);
1431 while(!list_empty(&(dev->queues->queue[HostNormCmdQueue].cmdq))) {1516 while(!list_empty(&(dev->queues->queue[HostNormCmdQueue].cmdq))) {
1432 struct list_head *entry;1517 struct list_head *entry;
1433 struct aac_aifcmd * aifcmd;1518 struct aac_aifcmd * aifcmd;
1434 1519
1435 set_current_state(TASK_RUNNING);1520 set_current_state(TASK_RUNNING);
1436 1521
1437 entry = dev->queues->queue[HostNormCmdQueue].cmdq.next;1522 entry = dev->queues->queue[HostNormCmdQueue].cmdq.next;
1438 list_del(entry);1523 list_del(entry);
1439 1524
1440 spin_unlock_irqrestore(dev->queues->queue[HostNormCmdQueue].lock, flags);1525 spin_unlock_irqrestore(dev->queues->queue[HostNormCmdQueue].lock, flags);
1441 fib = list_entry(entry, struct fib, fiblink);1526 fib = list_entry(entry, struct fib, fiblink);
1442 /*1527 /*
1443 * We will process the FIB here or pass it to a 1528 * We will process the FIB here or pass it to a
1444 * worker thread that is TBD. We Really can't 1529 * worker thread that is TBD. We Really can't
1445 * do anything at this point since we don't have1530 * do anything at this point since we don't have
1446 * anything defined for this thread to do.1531 * anything defined for this thread to do.
1447 */1532 */
1448 hw_fib = fib->hw_fib_va;1533 hw_fib = fib->hw_fib_va;
1449 memset(fib, 0, sizeof(struct fib));1534 memset(fib, 0, sizeof(struct fib));
1450 fib->type = FSAFS_NTC_FIB_CONTEXT;1535 fib->type = FSAFS_NTC_FIB_CONTEXT;
1451 fib->size = sizeof( struct fib );1536 fib->size = sizeof(struct fib);
1452 fib->hw_fib_va = hw_fib;1537 fib->hw_fib_va = hw_fib;
1453 fib->data = hw_fib->data;1538 fib->data = hw_fib->data;
1454 fib->dev = dev;1539 fib->dev = dev;
@@ -1462,20 +1547,19 @@ int aac_command_thread(void *data) · 7 unmodified lines
1462 *(__le32 *)hw_fib->data = cpu_to_le32(ST_OK);1547 *(__le32 *)hw_fib->data = cpu_to_le32(ST_OK);
1463 aac_fib_adapter_complete(fib, (u16)sizeof(u32));1548 aac_fib_adapter_complete(fib, (u16)sizeof(u32));
1464 } else {1549 } else {
1465 struct list_head *entry;
1466 /* The u32 here is important and intended. We are using1550 /* The u32 here is important and intended. We are using
1467 32bit wrapping time to fit the adapter field */1551 32bit wrapping time to fit the adapter field */
1468 1552
1469 u32 time_now, time_last;1553 u32 time_now, time_last;
1470 unsigned long flagv;1554 unsigned long flagv;
1471 unsigned num;1555 unsigned num;
1472 struct hw_fib ** hw_fib_pool, ** hw_fib_p;1556 struct hw_fib ** hw_fib_pool, ** hw_fib_p;
1473 struct fib ** fib_pool, ** fib_p;1557 struct fib ** fib_pool, ** fib_p;
1474 1558
1475 /* Sniff events */1559 /* Sniff events */
1476 if ((aifcmd->command == 1560 if ((aifcmd->command ==
1477 cpu_to_le32(AifCmdEventNotify)) ||1561 cpu_to_le32(AifCmdEventNotify)) ||
1478 (aifcmd->command == 1562 (aifcmd->command ==
1479 cpu_to_le32(AifCmdJobProgress))) {1563 cpu_to_le32(AifCmdJobProgress))) {
1480 aac_handle_aif(dev, fib);1564 aac_handle_aif(dev, fib);
1481 }1565 }
@@ -1527,7 +1611,7 @@ int aac_command_thread(void *data) · 45 unmodified lines
1527 spin_lock_irqsave(&dev->fib_lock, flagv);1611 spin_lock_irqsave(&dev->fib_lock, flagv);
1528 entry = dev->fib_list.next;1612 entry = dev->fib_list.next;
1529 /*1613 /*
1530 * For each Context that is on the 1614 * For each Context that is on the
1531 * fibctxList, make a copy of the1615 * fibctxList, make a copy of the
1532 * fib, and then set the event to wake up the1616 * fib, and then set the event to wake up the
1533 * thread that is waiting for it.1617 * thread that is waiting for it.
@@ -1552,7 +1636,7 @@ int aac_command_thread(void *data) · 18 unmodified lines
1552 */1636 */
1553 time_last = fibctx->jiffies;1637 time_last = fibctx->jiffies;
1554 /*1638 /*
1555 * Has it been > 2 minutes 1639 * Has it been > 2 minutes
1556 * since the last read off1640 * since the last read off
1557 * the queue?1641 * the queue?
1558 */1642 */
@@ -1583,7 +1667,7 @@ int aac_command_thread(void *data) · 24 unmodified lines
1583 */1667 */
1584 list_add_tail(&newfib->fiblink, &fibctx->fib_list);1668 list_add_tail(&newfib->fiblink, &fibctx->fib_list);
1585 fibctx->count++;1669 fibctx->count++;
1586 /* 1670 /*
1587 * Set the event to wake up the1671 * Set the event to wake up the
1588 * thread that is waiting.1672 * thread that is waiting.
1589 */1673 */
@@ -1655,11 +1739,11 @@ int aac_command_thread(void *data) · 65 unmodified lines
1655 struct fib *fibptr;1739 struct fib *fibptr;
1656 1740
1657 if ((fibptr = aac_fib_alloc(dev))) {1741 if ((fibptr = aac_fib_alloc(dev))) {
1658 u32 * info;1742 __le32 *info;
1659 1743
1660 aac_fib_init(fibptr);1744 aac_fib_init(fibptr);
1661 1745
1662 info = (u32 *) fib_data(fibptr);1746 info = (__le32 *) fib_data(fibptr);
1663 if (now.tv_usec > 500000)1747 if (now.tv_usec > 500000)
1664 ++now.tv_sec;1748 ++now.tv_sec;
1665 1749
drivers/scsi/aacraid/dpcsup.c+5−5
@@ -120,6 +120,7 @@ unsigned int aac_response_normal(struct aac_queue * q) · 119 unmodified lines
120 * NOTE: we cannot touch the fib after this120 * NOTE: we cannot touch the fib after this
121 * call, because it may have been deallocated.121 * call, because it may have been deallocated.
122 */122 */
123 fib->flags = 0;
123 fib->callback(fib->callback_data, fib);124 fib->callback(fib->callback_data, fib);
124 } else {125 } else {
125 unsigned long flagv;126 unsigned long flagv;
@@ -229,11 +230,9 @@ unsigned int aac_command_normal(struct aac_queue *q) · 103 unmodified lines
229 * all QE there are and wake up all the waiters before exiting.230 * all QE there are and wake up all the waiters before exiting.
230 */231 */
231 232
232unsigned int aac_intr_normal(struct aac_dev * dev, u32 Index)233unsigned int aac_intr_normal(struct aac_dev * dev, u32 index)
233{234{
234 u32 index = le32_to_cpu(Index);235 dprintk((KERN_INFO "aac_intr_normal(%p,%x)\n", dev, index));
235
236 dprintk((KERN_INFO "aac_intr_normal(%p,%x)\n", dev, Index));
237 if ((index & 0x00000002L)) {236 if ((index & 0x00000002L)) {
238 struct hw_fib * hw_fib;237 struct hw_fib * hw_fib;
239 struct fib * fib;238 struct fib * fib;
@@ -301,7 +300,7 @@ unsigned int aac_intr_normal(struct aac_dev * dev, u32 Index) · 61 unmodified lines
301 300
302 if (hwfib->header.Command == cpu_to_le16(NuFileSystem))301 if (hwfib->header.Command == cpu_to_le16(NuFileSystem))
303 {302 {
304 u32 *pstatus = (u32 *)hwfib->data;303 __le32 *pstatus = (__le32 *)hwfib->data;
305 if (*pstatus & cpu_to_le32(0xffff0000))304 if (*pstatus & cpu_to_le32(0xffff0000))
306 *pstatus = cpu_to_le32(ST_OK);305 *pstatus = cpu_to_le32(ST_OK);
307 }306 }
@@ -315,6 +314,7 @@ unsigned int aac_intr_normal(struct aac_dev * dev, u32 Index) · 7 unmodified lines
315 * NOTE: we cannot touch the fib after this314 * NOTE: we cannot touch the fib after this
316 * call, because it may have been deallocated.315 * call, because it may have been deallocated.
317 */316 */
317 fib->flags = 0;
318 fib->callback(fib->callback_data, fib);318 fib->callback(fib->callback_data, fib);
319 } else {319 } else {
320 unsigned long flagv;320 unsigned long flagv;
drivers/scsi/aacraid/linit.c+165−77
@@ -159,27 +159,27 @@ static struct pci_device_id aac_pci_tbl[] = { · 158 unmodified lines
159MODULE_DEVICE_TABLE(pci, aac_pci_tbl);159MODULE_DEVICE_TABLE(pci, aac_pci_tbl);
160 160
161/*161/*
162 * dmb - For now we add the number of channels to this structure. 162 * dmb - For now we add the number of channels to this structure.
163 * In the future we should add a fib that reports the number of channels163 * In the future we should add a fib that reports the number of channels
164 * for the card. At that time we can remove the channels from here164 * for the card. At that time we can remove the channels from here
165 */165 */
166static struct aac_driver_ident aac_drivers[] = {166static struct aac_driver_ident aac_drivers[] = {
167 { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* PERC 2/Si (Iguana/PERC2Si) */167 { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* PERC 2/Si (Iguana/PERC2Si) */
168 { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* PERC 3/Di (Opal/PERC3Di) */168 { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* PERC 3/Di (Opal/PERC3Di) */
169 { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* PERC 3/Si (SlimFast/PERC3Si */169 { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* PERC 3/Si (SlimFast/PERC3Si */
170 { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* PERC 3/Di (Iguana FlipChip/PERC3DiF */170 { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* PERC 3/Di (Iguana FlipChip/PERC3DiF */
171 { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* PERC 3/Di (Viper/PERC3DiV) */171 { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* PERC 3/Di (Viper/PERC3DiV) */
172 { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* PERC 3/Di (Lexus/PERC3DiL) */172 { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* PERC 3/Di (Lexus/PERC3DiL) */
173 { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 1, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* PERC 3/Di (Jaguar/PERC3DiJ) */173 { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 1, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* PERC 3/Di (Jaguar/PERC3DiJ) */
174 { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* PERC 3/Di (Dagger/PERC3DiD) */174 { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* PERC 3/Di (Dagger/PERC3DiD) */
175 { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* PERC 3/Di (Boxster/PERC3DiB) */175 { aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* PERC 3/Di (Boxster/PERC3DiB) */
176 { aac_rx_init, "aacraid", "ADAPTEC ", "catapult ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* catapult */176 { aac_rx_init, "aacraid", "ADAPTEC ", "catapult ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* catapult */
177 { aac_rx_init, "aacraid", "ADAPTEC ", "tomcat ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* tomcat */177 { aac_rx_init, "aacraid", "ADAPTEC ", "tomcat ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* tomcat */
178 { aac_rx_init, "aacraid", "ADAPTEC ", "Adaptec 2120S ", 1, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* Adaptec 2120S (Crusader) */178 { aac_rx_init, "aacraid", "ADAPTEC ", "Adaptec 2120S ", 1, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* Adaptec 2120S (Crusader) */
179 { aac_rx_init, "aacraid", "ADAPTEC ", "Adaptec 2200S ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* Adaptec 2200S (Vulcan) */179 { aac_rx_init, "aacraid", "ADAPTEC ", "Adaptec 2200S ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* Adaptec 2200S (Vulcan) */
180 { aac_rx_init, "aacraid", "ADAPTEC ", "Adaptec 2200S ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* Adaptec 2200S (Vulcan-2m) */180 { aac_rx_init, "aacraid", "ADAPTEC ", "Adaptec 2200S ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* Adaptec 2200S (Vulcan-2m) */
181 { aac_rx_init, "aacraid", "Legend ", "Legend S220 ", 1, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* Legend S220 (Legend Crusader) */181 { aac_rx_init, "aacraid", "Legend ", "Legend S220 ", 1, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* Legend S220 (Legend Crusader) */
182 { aac_rx_init, "aacraid", "Legend ", "Legend S230 ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* Legend S230 (Legend Vulcan) */182 { aac_rx_init, "aacraid", "Legend ", "Legend S230 ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* Legend S230 (Legend Vulcan) */
183 183
184 { aac_rx_init, "aacraid", "ADAPTEC ", "Adaptec 3230S ", 2 }, /* Adaptec 3230S (Harrier) */184 { aac_rx_init, "aacraid", "ADAPTEC ", "Adaptec 3230S ", 2 }, /* Adaptec 3230S (Harrier) */
185 { aac_rx_init, "aacraid", "ADAPTEC ", "Adaptec 3240S ", 2 }, /* Adaptec 3240S (Tornado) */185 { aac_rx_init, "aacraid", "ADAPTEC ", "Adaptec 3240S ", 2 }, /* Adaptec 3240S (Tornado) */
@@ -224,8 +224,8 @@ static struct aac_driver_ident aac_drivers[] = { · 38 unmodified lines
224 { aac_sa_init, "percraid", "DELL ", "PERCRAID ", 4, AAC_QUIRK_34SG }, /* Dell PERC2/QC */224 { aac_sa_init, "percraid", "DELL ", "PERCRAID ", 4, AAC_QUIRK_34SG }, /* Dell PERC2/QC */
225 { aac_sa_init, "hpnraid", "HP ", "NetRAID ", 4, AAC_QUIRK_34SG }, /* HP NetRAID-4M */225 { aac_sa_init, "hpnraid", "HP ", "NetRAID ", 4, AAC_QUIRK_34SG }, /* HP NetRAID-4M */
226 226
227 { aac_rx_init, "aacraid", "DELL ", "RAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* Dell Catchall */227 { aac_rx_init, "aacraid", "DELL ", "RAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* Dell Catchall */
228 { aac_rx_init, "aacraid", "Legend ", "RAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG }, /* Legend Catchall */228 { aac_rx_init, "aacraid", "Legend ", "RAID ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* Legend Catchall */
229 { aac_rx_init, "aacraid", "ADAPTEC ", "RAID ", 2 }, /* Adaptec Catch All */229 { aac_rx_init, "aacraid", "ADAPTEC ", "RAID ", 2 }, /* Adaptec Catch All */
230 { aac_rkt_init, "aacraid", "ADAPTEC ", "RAID ", 2 }, /* Adaptec Rocket Catch All */230 { aac_rkt_init, "aacraid", "ADAPTEC ", "RAID ", 2 }, /* Adaptec Rocket Catch All */
231 { aac_nark_init, "aacraid", "ADAPTEC ", "RAID ", 2 } /* Adaptec NEMER/ARK Catch All */231 { aac_nark_init, "aacraid", "ADAPTEC ", "RAID ", 2 } /* Adaptec NEMER/ARK Catch All */
@@ -239,7 +239,7 @@ static struct aac_driver_ident aac_drivers[] = { · 7 unmodified lines
239 * Queues a command for execution by the associated Host Adapter.239 * Queues a command for execution by the associated Host Adapter.
240 *240 *
241 * TODO: unify with aac_scsi_cmd().241 * TODO: unify with aac_scsi_cmd().
242 */ 242 */
243 243
244static int aac_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))244static int aac_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
245{245{
@@ -258,7 +258,7 @@ static int aac_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd · 12 unmodified lines
258 }258 }
259 cmd->SCp.phase = AAC_OWNER_LOWLEVEL;259 cmd->SCp.phase = AAC_OWNER_LOWLEVEL;
260 return (aac_scsi_cmd(cmd) ? FAILED : 0);260 return (aac_scsi_cmd(cmd) ? FAILED : 0);
261} 261}
262 262
263/**263/**
264 * aac_info - Returns the host adapter name264 * aac_info - Returns the host adapter name
@@ -292,21 +292,21 @@ struct aac_driver_ident* aac_get_driver_ident(int devtype) · 27 unmodified lines
292 * @capacity: the sector capacity of the disk292 * @capacity: the sector capacity of the disk
293 * @geom: geometry block to fill in293 * @geom: geometry block to fill in
294 *294 *
295 * Return the Heads/Sectors/Cylinders BIOS Disk Parameters for Disk. 295 * Return the Heads/Sectors/Cylinders BIOS Disk Parameters for Disk.
296 * The default disk geometry is 64 heads, 32 sectors, and the appropriate 296 * The default disk geometry is 64 heads, 32 sectors, and the appropriate
297 * number of cylinders so as not to exceed drive capacity. In order for 297 * number of cylinders so as not to exceed drive capacity. In order for
298 * disks equal to or larger than 1 GB to be addressable by the BIOS298 * disks equal to or larger than 1 GB to be addressable by the BIOS
299 * without exceeding the BIOS limitation of 1024 cylinders, Extended 299 * without exceeding the BIOS limitation of 1024 cylinders, Extended
300 * Translation should be enabled. With Extended Translation enabled, 300 * Translation should be enabled. With Extended Translation enabled,
301 * drives between 1 GB inclusive and 2 GB exclusive are given a disk 301 * drives between 1 GB inclusive and 2 GB exclusive are given a disk
302 * geometry of 128 heads and 32 sectors, and drives above 2 GB inclusive 302 * geometry of 128 heads and 32 sectors, and drives above 2 GB inclusive
303 * are given a disk geometry of 255 heads and 63 sectors. However, if 303 * are given a disk geometry of 255 heads and 63 sectors. However, if
304 * the BIOS detects that the Extended Translation setting does not match 304 * the BIOS detects that the Extended Translation setting does not match
305 * the geometry in the partition table, then the translation inferred 305 * the geometry in the partition table, then the translation inferred
306 * from the partition table will be used by the BIOS, and a warning may 306 * from the partition table will be used by the BIOS, and a warning may
307 * be displayed.307 * be displayed.
308 */308 */
309 309
310static int aac_biosparm(struct scsi_device *sdev, struct block_device *bdev,310static int aac_biosparm(struct scsi_device *sdev, struct block_device *bdev,
311 sector_t capacity, int *geom)311 sector_t capacity, int *geom)
312{312{
@@ -333,10 +333,10 @@ static int aac_biosparm(struct scsi_device *sdev, struct block_device *bdev, · 20 unmodified lines
333 333
334 param->cylinders = cap_to_cyls(capacity, param->heads * param->sectors);334 param->cylinders = cap_to_cyls(capacity, param->heads * param->sectors);
335 335
336 /* 336 /*
337 * Read the first 1024 bytes from the disk device, if the boot337 * Read the first 1024 bytes from the disk device, if the boot
338 * sector partition table is valid, search for a partition table338 * sector partition table is valid, search for a partition table
339 * entry whose end_head matches one of the standard geometry 339 * entry whose end_head matches one of the standard geometry
340 * translations ( 64/32, 128/32, 255/63 ).340 * translations ( 64/32, 128/32, 255/63 ).
341 */341 */
342 buf = scsi_bios_ptable(bdev);342 buf = scsi_bios_ptable(bdev);
@@ -401,30 +401,44 @@ static int aac_biosparm(struct scsi_device *sdev, struct block_device *bdev, · 58 unmodified lines
401 401
402static int aac_slave_configure(struct scsi_device *sdev)402static int aac_slave_configure(struct scsi_device *sdev)
403{403{
404 struct aac_dev *aac = (struct aac_dev *)sdev->host->hostdata;
404 if ((sdev->type == TYPE_DISK) &&405 if ((sdev->type == TYPE_DISK) &&
405 (sdev_channel(sdev) != CONTAINER_CHANNEL)) {406 (sdev_channel(sdev) != CONTAINER_CHANNEL) &&
407 (!aac->jbod || sdev->inq_periph_qual) &&
408 (!aac->raid_scsi_mode || (sdev_channel(sdev) != 2))) {
406 if (expose_physicals == 0)409 if (expose_physicals == 0)
407 return -ENXIO;410 return -ENXIO;
408 if (expose_physicals < 0) {411 if (expose_physicals < 0)
409 struct aac_dev *aac =412 sdev->no_uld_attach = 1;
410 (struct aac_dev *)sdev->host->hostdata;
411 if (!aac->raid_scsi_mode || (sdev_channel(sdev) != 2))
412 sdev->no_uld_attach = 1;
413 }
414 }413 }
415 if (sdev->tagged_supported && (sdev->type == TYPE_DISK) &&414 if (sdev->tagged_supported && (sdev->type == TYPE_DISK) &&
416 (sdev_channel(sdev) == CONTAINER_CHANNEL)) {415 (!aac->raid_scsi_mode || (sdev_channel(sdev) != 2)) &&
416 !sdev->no_uld_attach) {
417 struct scsi_device * dev;417 struct scsi_device * dev;
418 struct Scsi_Host *host = sdev->host;418 struct Scsi_Host *host = sdev->host;
419 unsigned num_lsu = 0;419 unsigned num_lsu = 0;
420 unsigned num_one = 0;420 unsigned num_one = 0;
421 unsigned depth;421 unsigned depth;
422 unsigned cid;
422 423
424 /*
425 * Firmware has an individual device recovery time typically
426 * of 35 seconds, give us a margin.
427 */
428 if (sdev->timeout < (45 * HZ))
429 sdev->timeout = 45 * HZ;
430 for (cid = 0; cid < aac->maximum_num_containers; ++cid)
431 if (aac->fsa_dev[cid].valid)
432 ++num_lsu;
423 __shost_for_each_device(dev, host) {433 __shost_for_each_device(dev, host) {
424 if (dev->tagged_supported && (dev->type == TYPE_DISK) &&434 if (dev->tagged_supported && (dev->type == TYPE_DISK) &&
425 (sdev_channel(dev) == CONTAINER_CHANNEL))435 (!aac->raid_scsi_mode ||
426 ++num_lsu;436 (sdev_channel(sdev) != 2)) &&
427 else437 !dev->no_uld_attach) {
438 if ((sdev_channel(dev) != CONTAINER_CHANNEL)
439 || !aac->fsa_dev[sdev_id(dev)].valid)
440 ++num_lsu;
441 } else
428 ++num_one;442 ++num_one;
429 }443 }
430 if (num_lsu == 0)444 if (num_lsu == 0)
@@ -481,9 +495,35 @@ static int aac_change_queue_depth(struct scsi_device *sdev, int depth) · 50 unmodified lines
481 return sdev->queue_depth;495 return sdev->queue_depth;
482}496}
483 497
498static ssize_t aac_show_raid_level(struct device *dev, struct device_attribute *attr, char *buf)
499{
500 struct scsi_device * sdev = to_scsi_device(dev);
501 if (sdev_channel(sdev) != CONTAINER_CHANNEL)
502 return snprintf(buf, PAGE_SIZE, sdev->no_uld_attach
503 ? "Hidden\n" : "JBOD");
504 return snprintf(buf, PAGE_SIZE, "%s\n",
505 get_container_type(((struct aac_dev *)(sdev->host->hostdata))
506 ->fsa_dev[sdev_id(sdev)].type));
507}
508
509static struct device_attribute aac_raid_level_attr = {
510 .attr = {
511 .name = "level",
512 .mode = S_IRUGO,
513 },
514 .show = aac_show_raid_level
515};
516
517static struct device_attribute *aac_dev_attrs[] = {
518 &aac_raid_level_attr,
519 NULL,
520};
521
484static int aac_ioctl(struct scsi_device *sdev, int cmd, void __user * arg)522static int aac_ioctl(struct scsi_device *sdev, int cmd, void __user * arg)
485{523{
486 struct aac_dev *dev = (struct aac_dev *)sdev->host->hostdata;524 struct aac_dev *dev = (struct aac_dev *)sdev->host->hostdata;
525 if (!capable(CAP_SYS_RAWIO))
526 return -EPERM;
487 return aac_do_ioctl(dev, cmd, arg);527 return aac_do_ioctl(dev, cmd, arg);
488}528}
489 529
@@ -506,17 +546,33 @@ static int aac_eh_abort(struct scsi_cmnd* cmd) · 16 unmodified lines
506 break;546 break;
507 case INQUIRY:547 case INQUIRY:
508 case READ_CAPACITY:548 case READ_CAPACITY:
509 case TEST_UNIT_READY:
510 /* Mark associated FIB to not complete, eh handler does this */549 /* Mark associated FIB to not complete, eh handler does this */
511 for (count = 0; count < (host->can_queue + AAC_NUM_MGT_FIB); ++count) {550 for (count = 0; count < (host->can_queue + AAC_NUM_MGT_FIB); ++count) {
512 struct fib * fib = &aac->fibs[count];551 struct fib * fib = &aac->fibs[count];
513 if (fib->hw_fib_va->header.XferState &&552 if (fib->hw_fib_va->header.XferState &&
553 (fib->flags & FIB_CONTEXT_FLAG) &&
514 (fib->callback_data == cmd)) {554 (fib->callback_data == cmd)) {
515 fib->flags |= FIB_CONTEXT_FLAG_TIMED_OUT;555 fib->flags |= FIB_CONTEXT_FLAG_TIMED_OUT;
516 cmd->SCp.phase = AAC_OWNER_ERROR_HANDLER;556 cmd->SCp.phase = AAC_OWNER_ERROR_HANDLER;
517 ret = SUCCESS;557 ret = SUCCESS;
518 }558 }
519 }559 }
560 break;
561 case TEST_UNIT_READY:
562 /* Mark associated FIB to not complete, eh handler does this */
563 for (count = 0; count < (host->can_queue + AAC_NUM_MGT_FIB); ++count) {
564 struct scsi_cmnd * command;
565 struct fib * fib = &aac->fibs[count];
566 if ((fib->hw_fib_va->header.XferState & cpu_to_le32(Async | NoResponseExpected)) &&
567 (fib->flags & FIB_CONTEXT_FLAG) &&
568 ((command = fib->callback_data)) &&
569 (command->device == cmd->device)) {
570 fib->flags |= FIB_CONTEXT_FLAG_TIMED_OUT;
571 command->SCp.phase = AAC_OWNER_ERROR_HANDLER;
572 if (command == cmd)
573 ret = SUCCESS;
574 }
575 }
520 }576 }
521 return ret;577 return ret;
522}578}
@@ -539,12 +595,13 @@ static int aac_eh_reset(struct scsi_cmnd* cmd) · 16 unmodified lines
539 for (count = 0; count < (host->can_queue + AAC_NUM_MGT_FIB); ++count) {595 for (count = 0; count < (host->can_queue + AAC_NUM_MGT_FIB); ++count) {
540 struct fib * fib = &aac->fibs[count];596 struct fib * fib = &aac->fibs[count];
541 if (fib->hw_fib_va->header.XferState &&597 if (fib->hw_fib_va->header.XferState &&
598 (fib->flags & FIB_CONTEXT_FLAG) &&
542 (fib->callback_data == cmd)) {599 (fib->callback_data == cmd)) {
543 fib->flags |= FIB_CONTEXT_FLAG_TIMED_OUT;600 fib->flags |= FIB_CONTEXT_FLAG_TIMED_OUT;
544 cmd->SCp.phase = AAC_OWNER_ERROR_HANDLER;601 cmd->SCp.phase = AAC_OWNER_ERROR_HANDLER;
545 }602 }
546 }603 }
547 printk(KERN_ERR "%s: Host adapter reset request. SCSI hang ?\n", 604 printk(KERN_ERR "%s: Host adapter reset request. SCSI hang ?\n",
548 AAC_DRIVERNAME);605 AAC_DRIVERNAME);
549 606
550 if ((count = aac_check_health(aac)))607 if ((count = aac_check_health(aac)))
@@ -584,8 +641,11 @@ static int aac_eh_reset(struct scsi_cmnd* cmd) · 33 unmodified lines
584 * support a register, instead of a commanded, reset.641 * support a register, instead of a commanded, reset.
585 */642 */
586 if ((aac->supplement_adapter_info.SupportedOptions2 &643 if ((aac->supplement_adapter_info.SupportedOptions2 &
587 le32_to_cpu(AAC_OPTION_MU_RESET|AAC_OPTION_IGNORE_RESET)) ==644 AAC_OPTION_MU_RESET) &&
588 le32_to_cpu(AAC_OPTION_MU_RESET))645 aac_check_reset &&
646 ((aac_check_reset != 1) ||
647 (aac->supplement_adapter_info.SupportedOptions2 &
648 AAC_OPTION_IGNORE_RESET)))
589 aac_reset_adapter(aac, 2); /* Bypass wait for command quiesce */649 aac_reset_adapter(aac, 2); /* Bypass wait for command quiesce */
590 return SUCCESS; /* Cause an immediate retry of the command with a ten second delay after successful tur */650 return SUCCESS; /* Cause an immediate retry of the command with a ten second delay after successful tur */
591}651}
@@ -632,8 +692,8 @@ static int aac_cfg_open(struct inode *inode, struct file *file) · 40 unmodified lines
632 * Bugs: Needs locking against parallel ioctls lower down692 * Bugs: Needs locking against parallel ioctls lower down
633 * Bugs: Needs to handle hot plugging693 * Bugs: Needs to handle hot plugging
634 */694 */
635 695
636static int aac_cfg_ioctl(struct inode *inode, struct file *file,696static int aac_cfg_ioctl(struct inode *inode, struct file *file,
637 unsigned int cmd, unsigned long arg)697 unsigned int cmd, unsigned long arg)
638{698{
639 if (!capable(CAP_SYS_RAWIO))699 if (!capable(CAP_SYS_RAWIO))
@@ -646,7 +706,7 @@ static long aac_compat_do_ioctl(struct aac_dev *dev, unsigned cmd, unsigned long · 6 unmodified lines
646{706{
647 long ret;707 long ret;
648 lock_kernel();708 lock_kernel();
649 switch (cmd) { 709 switch (cmd) {
650 case FSACTL_MINIPORT_REV_CHECK:710 case FSACTL_MINIPORT_REV_CHECK:
651 case FSACTL_SENDFIB:711 case FSACTL_SENDFIB:
652 case FSACTL_OPEN_GET_ADAPTER_FIB:712 case FSACTL_OPEN_GET_ADAPTER_FIB:
@@ -656,14 +716,14 @@ static long aac_compat_do_ioctl(struct aac_dev *dev, unsigned cmd, unsigned long · 3 unmodified lines
656 case FSACTL_QUERY_DISK:716 case FSACTL_QUERY_DISK:
657 case FSACTL_DELETE_DISK:717 case FSACTL_DELETE_DISK:
658 case FSACTL_FORCE_DELETE_DISK:718 case FSACTL_FORCE_DELETE_DISK:
659 case FSACTL_GET_CONTAINERS: 719 case FSACTL_GET_CONTAINERS:
660 case FSACTL_SEND_LARGE_FIB:720 case FSACTL_SEND_LARGE_FIB:
661 ret = aac_do_ioctl(dev, cmd, (void __user *)arg);721 ret = aac_do_ioctl(dev, cmd, (void __user *)arg);
662 break;722 break;
663 723
664 case FSACTL_GET_NEXT_ADAPTER_FIB: {724 case FSACTL_GET_NEXT_ADAPTER_FIB: {
665 struct fib_ioctl __user *f;725 struct fib_ioctl __user *f;
666 726
667 f = compat_alloc_user_space(sizeof(*f));727 f = compat_alloc_user_space(sizeof(*f));
668 ret = 0;728 ret = 0;
669 if (clear_user(f, sizeof(*f)))729 if (clear_user(f, sizeof(*f)))
@@ -676,9 +736,9 @@ static long aac_compat_do_ioctl(struct aac_dev *dev, unsigned cmd, unsigned long · 6 unmodified lines
676 }736 }
677 737
678 default:738 default:
679 ret = -ENOIOCTLCMD; 739 ret = -ENOIOCTLCMD;
680 break;740 break;
681 } 741 }
682 unlock_kernel();742 unlock_kernel();
683 return ret;743 return ret;
684}744}
@@ -735,6 +795,25 @@ static ssize_t aac_show_vendor(struct class_device *class_dev, · 50 unmodified lines
735 return len;795 return len;
736}796}
737 797
798static ssize_t aac_show_flags(struct class_device *class_dev, char *buf)
799{
800 int len = 0;
801 struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata;
802
803 if (nblank(dprintk(x)))
804 len = snprintf(buf, PAGE_SIZE, "dprintk\n");
805#ifdef AAC_DETAILED_STATUS_INFO
806 len += snprintf(buf + len, PAGE_SIZE - len,
807 "AAC_DETAILED_STATUS_INFO\n");
808#endif
809 if (dev->raw_io_interface && dev->raw_io_64)
810 len += snprintf(buf + len, PAGE_SIZE - len,
811 "SAI_READ_CAPACITY_16\n");
812 if (dev->jbod)
813 len += snprintf(buf + len, PAGE_SIZE - len, "SUPPORTED_JBOD\n");
814 return len;
815}
816
738static ssize_t aac_show_kernel_version(struct class_device *class_dev,817static ssize_t aac_show_kernel_version(struct class_device *class_dev,
739 char *buf)818 char *buf)
740{819{
@@ -742,7 +821,7 @@ static ssize_t aac_show_kernel_version(struct class_device *class_dev, · 1 unmodified line
742 int len, tmp;821 int len, tmp;
743 822
744 tmp = le32_to_cpu(dev->adapter_info.kernelrev);823 tmp = le32_to_cpu(dev->adapter_info.kernelrev);
745 len = snprintf(buf, PAGE_SIZE, "%d.%d-%d[%d]\n", 824 len = snprintf(buf, PAGE_SIZE, "%d.%d-%d[%d]\n",
746 tmp >> 24, (tmp >> 16) & 0xff, tmp & 0xff,825 tmp >> 24, (tmp >> 16) & 0xff, tmp & 0xff,
747 le32_to_cpu(dev->adapter_info.kernelbuild));826 le32_to_cpu(dev->adapter_info.kernelbuild));
748 return len;827 return len;
@@ -755,7 +834,7 @@ static ssize_t aac_show_monitor_version(struct class_device *class_dev, · 6 unmodified lines
755 int len, tmp;834 int len, tmp;
756 835
757 tmp = le32_to_cpu(dev->adapter_info.monitorrev);836 tmp = le32_to_cpu(dev->adapter_info.monitorrev);
758 len = snprintf(buf, PAGE_SIZE, "%d.%d-%d[%d]\n", 837 len = snprintf(buf, PAGE_SIZE, "%d.%d-%d[%d]\n",
759 tmp >> 24, (tmp >> 16) & 0xff, tmp & 0xff,838 tmp >> 24, (tmp >> 16) & 0xff, tmp & 0xff,
760 le32_to_cpu(dev->adapter_info.monitorbuild));839 le32_to_cpu(dev->adapter_info.monitorbuild));
761 return len;840 return len;
@@ -768,7 +847,7 @@ static ssize_t aac_show_bios_version(struct class_device *class_dev, · 6 unmodified lines
768 int len, tmp;847 int len, tmp;
769 848
770 tmp = le32_to_cpu(dev->adapter_info.biosrev);849 tmp = le32_to_cpu(dev->adapter_info.biosrev);
771 len = snprintf(buf, PAGE_SIZE, "%d.%d-%d[%d]\n", 850 len = snprintf(buf, PAGE_SIZE, "%d.%d-%d[%d]\n",
772 tmp >> 24, (tmp >> 16) & 0xff, tmp & 0xff,851 tmp >> 24, (tmp >> 16) & 0xff, tmp & 0xff,
773 le32_to_cpu(dev->adapter_info.biosbuild));852 le32_to_cpu(dev->adapter_info.biosbuild));
774 return len;853 return len;
@@ -844,6 +923,13 @@ static struct class_device_attribute aac_vendor = { · 69 unmodified lines
844 },923 },
845 .show = aac_show_vendor,924 .show = aac_show_vendor,
846};925};
926static struct class_device_attribute aac_flags = {
927 .attr = {
928 .name = "flags",
929 .mode = S_IRUGO,
930 },
931 .show = aac_show_flags,
932};
847static struct class_device_attribute aac_kernel_version = {933static struct class_device_attribute aac_kernel_version = {
848 .attr = {934 .attr = {
849 .name = "hba_kernel_version",935 .name = "hba_kernel_version",
@@ -898,6 +984,7 @@ static struct class_device_attribute aac_reset = { · 48 unmodified lines
898static struct class_device_attribute *aac_attrs[] = {984static struct class_device_attribute *aac_attrs[] = {
899 &aac_model,985 &aac_model,
900 &aac_vendor,986 &aac_vendor,
987 &aac_flags,
901 &aac_kernel_version,988 &aac_kernel_version,
902 &aac_monitor_version,989 &aac_monitor_version,
903 &aac_bios_version,990 &aac_bios_version,
@@ -928,21 +1015,22 @@ static struct scsi_host_template aac_driver_template = { · 24 unmodified lines
928 .compat_ioctl = aac_compat_ioctl,1015 .compat_ioctl = aac_compat_ioctl,
929#endif1016#endif
930 .queuecommand = aac_queuecommand,1017 .queuecommand = aac_queuecommand,
931 .bios_param = aac_biosparm, 1018 .bios_param = aac_biosparm,
932 .shost_attrs = aac_attrs,1019 .shost_attrs = aac_attrs,
933 .slave_configure = aac_slave_configure,1020 .slave_configure = aac_slave_configure,
934 .change_queue_depth = aac_change_queue_depth,1021 .change_queue_depth = aac_change_queue_depth,
1022 .sdev_attrs = aac_dev_attrs,
935 .eh_abort_handler = aac_eh_abort,1023 .eh_abort_handler = aac_eh_abort,
936 .eh_host_reset_handler = aac_eh_reset,1024 .eh_host_reset_handler = aac_eh_reset,
937 .can_queue = AAC_NUM_IO_FIB, 1025 .can_queue = AAC_NUM_IO_FIB,
938 .this_id = MAXIMUM_NUM_CONTAINERS,1026 .this_id = MAXIMUM_NUM_CONTAINERS,
939 .sg_tablesize = 16,1027 .sg_tablesize = 16,
940 .max_sectors = 128,1028 .max_sectors = 128,
941#if (AAC_NUM_IO_FIB > 256)1029#if (AAC_NUM_IO_FIB > 256)
942 .cmd_per_lun = 256,1030 .cmd_per_lun = 256,
943#else 1031#else
944 .cmd_per_lun = AAC_NUM_IO_FIB, 1032 .cmd_per_lun = AAC_NUM_IO_FIB,
945#endif 1033#endif
946 .use_clustering = ENABLE_CLUSTERING,1034 .use_clustering = ENABLE_CLUSTERING,
947 .use_sg_chaining = ENABLE_SG_CHAINING,1035 .use_sg_chaining = ENABLE_SG_CHAINING,
948 .emulated = 1,1036 .emulated = 1,
@@ -979,18 +1067,18 @@ static int __devinit aac_probe_one(struct pci_dev *pdev, · 30 unmodified lines
979 goto out;1067 goto out;
980 error = -ENODEV;1068 error = -ENODEV;
981 1069
982 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK) || 1070 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK) ||
983 pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK))1071 pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK))
984 goto out_disable_pdev;1072 goto out_disable_pdev;
985 /*1073 /*
986 * If the quirk31 bit is set, the adapter needs adapter1074 * If the quirk31 bit is set, the adapter needs adapter
987 * to driver communication memory to be allocated below 2gig1075 * to driver communication memory to be allocated below 2gig
988 */1076 */
989 if (aac_drivers[index].quirks & AAC_QUIRK_31BIT) 1077 if (aac_drivers[index].quirks & AAC_QUIRK_31BIT)
990 if (pci_set_dma_mask(pdev, DMA_31BIT_MASK) ||1078 if (pci_set_dma_mask(pdev, DMA_31BIT_MASK) ||
991 pci_set_consistent_dma_mask(pdev, DMA_31BIT_MASK))1079 pci_set_consistent_dma_mask(pdev, DMA_31BIT_MASK))
992 goto out_disable_pdev;1080 goto out_disable_pdev;
993 1081
994 pci_set_master(pdev);1082 pci_set_master(pdev);
995 1083
996 shost = scsi_host_alloc(&aac_driver_template, sizeof(struct aac_dev));1084 shost = scsi_host_alloc(&aac_driver_template, sizeof(struct aac_dev));
@@ -1003,7 +1091,7 @@ static int __devinit aac_probe_one(struct pci_dev *pdev, · 6 unmodified lines
1003 shost->max_cmd_len = 16;1091 shost->max_cmd_len = 16;
1004 1092
1005 aac = (struct aac_dev *)shost->hostdata;1093 aac = (struct aac_dev *)shost->hostdata;
1006 aac->scsi_host_ptr = shost; 1094 aac->scsi_host_ptr = shost;
1007 aac->pdev = pdev;1095 aac->pdev = pdev;
1008 aac->name = aac_driver_template.name;1096 aac->name = aac_driver_template.name;
1009 aac->id = shost->unique_id;1097 aac->id = shost->unique_id;
@@ -1040,7 +1128,7 @@ static int __devinit aac_probe_one(struct pci_dev *pdev, · 30 unmodified lines
1040 if (aac_drivers[index].quirks & AAC_QUIRK_31BIT)1128 if (aac_drivers[index].quirks & AAC_QUIRK_31BIT)
1041 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK))1129 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK))
1042 goto out_deinit;1130 goto out_deinit;
1043 1131
1044 aac->maximum_num_channels = aac_drivers[index].channels;1132 aac->maximum_num_channels = aac_drivers[index].channels;
1045 error = aac_get_adapter_info(aac);1133 error = aac_get_adapter_info(aac);
1046 if (error < 0)1134 if (error < 0)
@@ -1049,7 +1137,7 @@ static int __devinit aac_probe_one(struct pci_dev *pdev, · 2 unmodified lines
1049 /*1137 /*
1050 * Lets override negotiations and drop the maximum SG limit to 341138 * Lets override negotiations and drop the maximum SG limit to 34
1051 */1139 */
1052 if ((aac_drivers[index].quirks & AAC_QUIRK_34SG) && 1140 if ((aac_drivers[index].quirks & AAC_QUIRK_34SG) &&
1053 (aac->scsi_host_ptr->sg_tablesize > 34)) {1141 (aac->scsi_host_ptr->sg_tablesize > 34)) {
1054 aac->scsi_host_ptr->sg_tablesize = 34;1142 aac->scsi_host_ptr->sg_tablesize = 34;
1055 aac->scsi_host_ptr->max_sectors1143 aac->scsi_host_ptr->max_sectors
@@ -1066,17 +1154,17 @@ static int __devinit aac_probe_one(struct pci_dev *pdev, · 10 unmodified lines
1066 /*1154 /*
1067 * Firware printf works only with older firmware.1155 * Firware printf works only with older firmware.
1068 */1156 */
1069 if (aac_drivers[index].quirks & AAC_QUIRK_34SG) 1157 if (aac_drivers[index].quirks & AAC_QUIRK_34SG)
1070 aac->printf_enabled = 1;1158 aac->printf_enabled = 1;
1071 else1159 else
1072 aac->printf_enabled = 0;1160 aac->printf_enabled = 0;
1073 1161
1074 /*1162 /*
1075 * max channel will be the physical channels plus 1 virtual channel1163 * max channel will be the physical channels plus 1 virtual channel
1076 * all containers are on the virtual channel 0 (CONTAINER_CHANNEL)1164 * all containers are on the virtual channel 0 (CONTAINER_CHANNEL)
1077 * physical channels are address by their actual physical number+11165 * physical channels are address by their actual physical number+1
1078 */1166 */
1079 if ((aac->nondasd_support == 1) || expose_physicals)1167 if (aac->nondasd_support || expose_physicals || aac->jbod)
1080 shost->max_channel = aac->maximum_num_channels;1168 shost->max_channel = aac->maximum_num_channels;
1081 else1169 else
1082 shost->max_channel = 0;1170 shost->max_channel = 0;
@@ -1148,10 +1236,10 @@ static void __devexit aac_remove_one(struct pci_dev *pdev) · 65 unmodified lines
1148 kfree(aac->queues);1236 kfree(aac->queues);
1149 1237
1150 aac_adapter_ioremap(aac, 0);1238 aac_adapter_ioremap(aac, 0);
1151 1239
1152 kfree(aac->fibs);1240 kfree(aac->fibs);
1153 kfree(aac->fsa_dev);1241 kfree(aac->fsa_dev);
1154 1242
1155 list_del(&aac->entry);1243 list_del(&aac->entry);
1156 scsi_host_put(shost);1244 scsi_host_put(shost);
1157 pci_disable_device(pdev);1245 pci_disable_device(pdev);
@@ -1172,7 +1260,7 @@ static struct pci_driver aac_pci_driver = { · 14 unmodified lines
1172static int __init aac_init(void)1260static int __init aac_init(void)
1173{1261{
1174 int error;1262 int error;
1175 1263
1176 printk(KERN_INFO "Adaptec %s driver %s\n",1264 printk(KERN_INFO "Adaptec %s driver %s\n",
1177 AAC_DRIVERNAME, aac_driver_version);1265 AAC_DRIVERNAME, aac_driver_version);
1178 1266
drivers/scsi/aacraid/rx.c+4−2
@@ -465,7 +465,7 @@ static int aac_rx_restart_adapter(struct aac_dev *dev, int bled) · 464 unmodified lines
465 u32 var;465 u32 var;
466 466
467 if (!(dev->supplement_adapter_info.SupportedOptions2 &467 if (!(dev->supplement_adapter_info.SupportedOptions2 &
468 le32_to_cpu(AAC_OPTION_MU_RESET)) || (bled >= 0) || (bled == -2)) {468 AAC_OPTION_MU_RESET) || (bled >= 0) || (bled == -2)) {
469 if (bled)469 if (bled)
470 printk(KERN_ERR "%s%d: adapter kernel panic'd %x.\n",470 printk(KERN_ERR "%s%d: adapter kernel panic'd %x.\n",
471 dev->name, dev->id, bled);471 dev->name, dev->id, bled);
@@ -549,7 +549,9 @@ int _aac_rx_init(struct aac_dev *dev) · 77 unmodified lines
549 dev->OIMR = status = rx_readb (dev, MUnit.OIMR);549 dev->OIMR = status = rx_readb (dev, MUnit.OIMR);
550 if ((((status & 0x0c) != 0x0c) || aac_reset_devices || reset_devices) &&550 if ((((status & 0x0c) != 0x0c) || aac_reset_devices || reset_devices) &&
551 !aac_rx_restart_adapter(dev, 0))551 !aac_rx_restart_adapter(dev, 0))
552 ++restart;552 /* Make sure the Hardware FIFO is empty */
553 while ((++restart < 512) &&
554 (rx_readl(dev, MUnit.OutboundQueue) != 0xFFFFFFFFL));
553 /*555 /*
554 * Check to see if the board panic'd while booting.556 * Check to see if the board panic'd while booting.
555 */557 */
drivers/scsi/advansys.c+7−7
@@ -8233,7 +8233,7 @@ static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp) · 8232 unmodified lines
8233 if (scsiqp->scsi_status == SAM_STAT_CHECK_CONDITION) {8233 if (scsiqp->scsi_status == SAM_STAT_CHECK_CONDITION) {
8234 ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n");8234 ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n");
8235 ASC_DBG_PRT_SENSE(2, scp->sense_buffer,8235 ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
8236 sizeof(scp->sense_buffer));8236 SCSI_SENSE_BUFFERSIZE);
8237 /*8237 /*
8238 * Note: The 'status_byte()' macro used by8238 * Note: The 'status_byte()' macro used by
8239 * target drivers defined in scsi.h shifts the8239 * target drivers defined in scsi.h shifts the
@@ -9136,7 +9136,7 @@ static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep) · 896 unmodified lines
9136 BUG_ON(asc_dvc_varp != &boardp->dvc_var.asc_dvc_var);9136 BUG_ON(asc_dvc_varp != &boardp->dvc_var.asc_dvc_var);
9137 9137
9138 dma_unmap_single(boardp->dev, scp->SCp.dma_handle,9138 dma_unmap_single(boardp->dev, scp->SCp.dma_handle,
9139 sizeof(scp->sense_buffer), DMA_FROM_DEVICE);9139 SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
9140 /*9140 /*
9141 * 'qdonep' contains the command's ending status.9141 * 'qdonep' contains the command's ending status.
9142 */9142 */
@@ -9166,7 +9166,7 @@ static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep) · 23 unmodified lines
9166 if (qdonep->d3.scsi_stat == SAM_STAT_CHECK_CONDITION) {9166 if (qdonep->d3.scsi_stat == SAM_STAT_CHECK_CONDITION) {
9167 ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n");9167 ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n");
9168 ASC_DBG_PRT_SENSE(2, scp->sense_buffer,9168 ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
9169 sizeof(scp->sense_buffer));9169 SCSI_SENSE_BUFFERSIZE);
9170 /*9170 /*
9171 * Note: The 'status_byte()' macro used by9171 * Note: The 'status_byte()' macro used by
9172 * target drivers defined in scsi.h shifts the9172 * target drivers defined in scsi.h shifts the
@@ -9881,9 +9881,9 @@ static __le32 advansys_get_sense_buffer_dma(struct scsi_cmnd *scp) · 708 unmodified lines
9881{9881{
9882 struct asc_board *board = shost_priv(scp->device->host);9882 struct asc_board *board = shost_priv(scp->device->host);
9883 scp->SCp.dma_handle = dma_map_single(board->dev, scp->sense_buffer,9883 scp->SCp.dma_handle = dma_map_single(board->dev, scp->sense_buffer,
9884 sizeof(scp->sense_buffer), DMA_FROM_DEVICE);9884 SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
9885 dma_cache_sync(board->dev, scp->sense_buffer,9885 dma_cache_sync(board->dev, scp->sense_buffer,
9886 sizeof(scp->sense_buffer), DMA_FROM_DEVICE);9886 SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
9887 return cpu_to_le32(scp->SCp.dma_handle);9887 return cpu_to_le32(scp->SCp.dma_handle);
9888}9888}
9889 9889
@@ -9914,7 +9914,7 @@ static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp, · 24 unmodified lines
9914 asc_scsi_q->q2.target_ix =9914 asc_scsi_q->q2.target_ix =
9915 ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun);9915 ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun);
9916 asc_scsi_q->q1.sense_addr = advansys_get_sense_buffer_dma(scp);9916 asc_scsi_q->q1.sense_addr = advansys_get_sense_buffer_dma(scp);
9917 asc_scsi_q->q1.sense_len = sizeof(scp->sense_buffer);9917 asc_scsi_q->q1.sense_len = SCSI_SENSE_BUFFERSIZE;
9918 9918
9919 /*9919 /*
9920 * If there are any outstanding requests for the current target,9920 * If there are any outstanding requests for the current target,
@@ -10173,7 +10173,7 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp, · 252 unmodified lines
10173 scsiqp->target_lun = scp->device->lun;10173 scsiqp->target_lun = scp->device->lun;
10174 10174
10175 scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));10175 scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
10176 scsiqp->sense_len = sizeof(scp->sense_buffer);10176 scsiqp->sense_len = SCSI_SENSE_BUFFERSIZE;
10177 10177
10178 /* Build ADV_SCSI_REQ_Q */10178 /* Build ADV_SCSI_REQ_Q */
10179 10179
drivers/scsi/aha152x.c+8−30
@@ -260,6 +260,7 @@ · 259 unmodified lines
260#include <scsi/scsi_dbg.h>260#include <scsi/scsi_dbg.h>
261#include <scsi/scsi_host.h>261#include <scsi/scsi_host.h>
262#include <scsi/scsi_transport_spi.h>262#include <scsi/scsi_transport_spi.h>
263#include <scsi/scsi_eh.h>
263#include "aha152x.h"264#include "aha152x.h"
264 265
265static LIST_HEAD(aha152x_host_list);266static LIST_HEAD(aha152x_host_list);
@@ -558,9 +559,7 @@ struct aha152x_hostdata { · 292 unmodified lines
558struct aha152x_scdata {559struct aha152x_scdata {
559 Scsi_Cmnd *next; /* next sc in queue */560 Scsi_Cmnd *next; /* next sc in queue */
560 struct completion *done;/* semaphore to block on */561 struct completion *done;/* semaphore to block on */
561 unsigned char aha_orig_cmd_len;562 struct scsi_eh_save ses;
562 unsigned char aha_orig_cmnd[MAX_COMMAND_SIZE];
563 int aha_orig_resid;
564};563};
565 564
566/* access macros for hostdata */565/* access macros for hostdata */
@@ -1017,16 +1016,10 @@ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete, · 450 unmodified lines
1017 SCp.buffers_residual : left buffers in list1016 SCp.buffers_residual : left buffers in list
1018 SCp.phase : current state of the command */1017 SCp.phase : current state of the command */
1019 1018
1020 if ((phase & (check_condition|resetting)) || !scsi_sglist(SCpnt)) {1019 if ((phase & resetting) || !scsi_sglist(SCpnt)) {
1021 if (phase & check_condition) {1020 SCpnt->SCp.ptr = NULL;
1022 SCpnt->SCp.ptr = SCpnt->sense_buffer;1021 SCpnt->SCp.this_residual = 0;
1023 SCpnt->SCp.this_residual = sizeof(SCpnt->sense_buffer);1022 scsi_set_resid(SCpnt, 0);
1024 scsi_set_resid(SCpnt, sizeof(SCpnt->sense_buffer));
1025 } else {
1026 SCpnt->SCp.ptr = NULL;
1027 SCpnt->SCp.this_residual = 0;
1028 scsi_set_resid(SCpnt, 0);
1029 }
1030 SCpnt->SCp.buffer = NULL;1023 SCpnt->SCp.buffer = NULL;
1031 SCpnt->SCp.buffers_residual = 0;1024 SCpnt->SCp.buffers_residual = 0;
1032 } else {1025 } else {
@@ -1561,10 +1554,7 @@ static void busfree_run(struct Scsi_Host *shpnt) · 528 unmodified lines
1561 }1554 }
1562#endif1555#endif
1563 1556
1564 /* restore old command */1557 scsi_eh_restore_cmnd(cmd, &sc->ses);
1565 memcpy(cmd->cmnd, sc->aha_orig_cmnd, sizeof(cmd->cmnd));
1566 cmd->cmd_len = sc->aha_orig_cmd_len;
1567 scsi_set_resid(cmd, sc->aha_orig_resid);
1568 1558
1569 cmd->SCp.Status = SAM_STAT_CHECK_CONDITION;1559 cmd->SCp.Status = SAM_STAT_CHECK_CONDITION;
1570 1560
@@ -1587,22 +1577,10 @@ static void busfree_run(struct Scsi_Host *shpnt) · 16 unmodified lines
1587 DPRINTK(debug_eh, ERR_LEAD "requesting sense\n", CMDINFO(ptr));1577 DPRINTK(debug_eh, ERR_LEAD "requesting sense\n", CMDINFO(ptr));
1588#endif1578#endif
1589 1579
1590 /* save old command */
1591 sc = SCDATA(ptr);1580 sc = SCDATA(ptr);
1592 /* It was allocated in aha152x_internal_queue? */1581 /* It was allocated in aha152x_internal_queue? */
1593 BUG_ON(!sc);1582 BUG_ON(!sc);
1594 memcpy(sc->aha_orig_cmnd, ptr->cmnd,1583 scsi_eh_prep_cmnd(ptr, &sc->ses, NULL, 0, ~0);
1595 sizeof(ptr->cmnd));
1596 sc->aha_orig_cmd_len = ptr->cmd_len;
1597 sc->aha_orig_resid = scsi_get_resid(ptr);
1598
1599 ptr->cmnd[0] = REQUEST_SENSE;
1600 ptr->cmnd[1] = 0;
1601 ptr->cmnd[2] = 0;
1602 ptr->cmnd[3] = 0;
1603 ptr->cmnd[4] = sizeof(ptr->sense_buffer);
1604 ptr->cmnd[5] = 0;
1605 ptr->cmd_len = 6;
1606 1584
1607 DO_UNLOCK(flags);1585 DO_UNLOCK(flags);
1608 aha152x_internal_queue(ptr, NULL, check_condition, ptr->scsi_done);1586 aha152x_internal_queue(ptr, NULL, check_condition, ptr->scsi_done);
drivers/scsi/aha1542.c+12−37
@@ -51,15 +51,6 @@ · 50 unmodified lines
51#define SCSI_BUF_PA(address) isa_virt_to_bus(address)51#define SCSI_BUF_PA(address) isa_virt_to_bus(address)
52#define SCSI_SG_PA(sgent) (isa_page_to_bus(sg_page((sgent))) + (sgent)->offset)52#define SCSI_SG_PA(sgent) (isa_page_to_bus(sg_page((sgent))) + (sgent)->offset)
53 53
54static void BAD_DMA(void *address, unsigned int length)
55{
56 printk(KERN_CRIT "buf vaddress %p paddress 0x%lx length %d\n",
57 address,
58 SCSI_BUF_PA(address),
59 length);
60 panic("Buffer at physical address > 16Mb used for aha1542");
61}
62
63static void BAD_SG_DMA(Scsi_Cmnd * SCpnt,54static void BAD_SG_DMA(Scsi_Cmnd * SCpnt,
64 struct scatterlist *sgp,55 struct scatterlist *sgp,
65 int nseg,56 int nseg,
@@ -545,7 +536,7 @@ static void aha1542_intr_handle(struct Scsi_Host *shost, void *dev_id) · 479 unmodified lines
545 we will still have it in the cdb when we come back */536 we will still have it in the cdb when we come back */
546 if (ccb[mbo].tarstat == 2)537 if (ccb[mbo].tarstat == 2)
547 memcpy(SCtmp->sense_buffer, &ccb[mbo].cdb[ccb[mbo].cdblen],538 memcpy(SCtmp->sense_buffer, &ccb[mbo].cdb[ccb[mbo].cdblen],
548 sizeof(SCtmp->sense_buffer));539 SCSI_SENSE_BUFFERSIZE);
549 540
550 541
551 /* is there mail :-) */542 /* is there mail :-) */
@@ -597,8 +588,7 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) · 45 unmodified lines
597 unchar target = SCpnt->device->id;588 unchar target = SCpnt->device->id;
598 unchar lun = SCpnt->device->lun;589 unchar lun = SCpnt->device->lun;
599 unsigned long flags;590 unsigned long flags;
600 void *buff = SCpnt->request_buffer;591 int bufflen = scsi_bufflen(SCpnt);
601 int bufflen = SCpnt->request_bufflen;
602 int mbo;592 int mbo;
603 struct mailbox *mb;593 struct mailbox *mb;
604 struct ccb *ccb;594 struct ccb *ccb;
@@ -619,7 +609,7 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) · 14 unmodified lines
619#if 0609#if 0
620 /* scsi_request_sense() provides a buffer of size 256,610 /* scsi_request_sense() provides a buffer of size 256,
621 so there is no reason to expect equality */611 so there is no reason to expect equality */
622 if (bufflen != sizeof(SCpnt->sense_buffer))612 if (bufflen != SCSI_SENSE_BUFFERSIZE)
623 printk(KERN_CRIT "aha1542: Wrong buffer length supplied "613 printk(KERN_CRIT "aha1542: Wrong buffer length supplied "
624 "for request sense (%d)\n", bufflen);614 "for request sense (%d)\n", bufflen);
625#endif615#endif
@@ -689,42 +679,29 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) · 63 unmodified lines
689 679
690 memcpy(ccb[mbo].cdb, cmd, ccb[mbo].cdblen);680 memcpy(ccb[mbo].cdb, cmd, ccb[mbo].cdblen);
691 681
692 if (SCpnt->use_sg) {682 if (bufflen) {
693 struct scatterlist *sg;683 struct scatterlist *sg;
694 struct chain *cptr;684 struct chain *cptr;
695#ifdef DEBUG685#ifdef DEBUG
696 unsigned char *ptr;686 unsigned char *ptr;
697#endif687#endif
698 int i;688 int i, sg_count = scsi_sg_count(SCpnt);
699 ccb[mbo].op = 2; /* SCSI Initiator Command w/scatter-gather */689 ccb[mbo].op = 2; /* SCSI Initiator Command w/scatter-gather */
700 SCpnt->host_scribble = kmalloc(512, GFP_KERNEL | GFP_DMA);690 SCpnt->host_scribble = kmalloc(sizeof(*cptr)*sg_count,
691 GFP_KERNEL | GFP_DMA);
701 cptr = (struct chain *) SCpnt->host_scribble;692 cptr = (struct chain *) SCpnt->host_scribble;
702 if (cptr == NULL) {693 if (cptr == NULL) {
703 /* free the claimed mailbox slot */694 /* free the claimed mailbox slot */
704 HOSTDATA(SCpnt->device->host)->SCint[mbo] = NULL;695 HOSTDATA(SCpnt->device->host)->SCint[mbo] = NULL;
705 return SCSI_MLQUEUE_HOST_BUSY;696 return SCSI_MLQUEUE_HOST_BUSY;
706 }697 }
707 scsi_for_each_sg(SCpnt, sg, SCpnt->use_sg, i) {698 scsi_for_each_sg(SCpnt, sg, sg_count, i) {
708 if (sg->length == 0 || SCpnt->use_sg > 16 ||
709 (((int) sg->offset) & 1) || (sg->length & 1)) {
710 unsigned char *ptr;
711 printk(KERN_CRIT "Bad segment list supplied to aha1542.c (%d, %d)\n", SCpnt->use_sg, i);
712 scsi_for_each_sg(SCpnt, sg, SCpnt->use_sg, i) {
713 printk(KERN_CRIT "%d: %p %d\n", i,
714 sg_virt(sg), sg->length);
715 };
716 printk(KERN_CRIT "cptr %x: ", (unsigned int) cptr);
717 ptr = (unsigned char *) &cptr[i];
718 for (i = 0; i < 18; i++)
719 printk("%02x ", ptr[i]);
720 panic("Foooooooood fight!");
721 };
722 any2scsi(cptr[i].dataptr, SCSI_SG_PA(sg));699 any2scsi(cptr[i].dataptr, SCSI_SG_PA(sg));
723 if (SCSI_SG_PA(sg) + sg->length - 1 > ISA_DMA_THRESHOLD)700 if (SCSI_SG_PA(sg) + sg->length - 1 > ISA_DMA_THRESHOLD)
724 BAD_SG_DMA(SCpnt, sg, SCpnt->use_sg, i);701 BAD_SG_DMA(SCpnt, scsi_sglist(SCpnt), sg_count, i);
725 any2scsi(cptr[i].datalen, sg->length);702 any2scsi(cptr[i].datalen, sg->length);
726 };703 };
727 any2scsi(ccb[mbo].datalen, SCpnt->use_sg * sizeof(struct chain));704 any2scsi(ccb[mbo].datalen, sg_count * sizeof(struct chain));
728 any2scsi(ccb[mbo].dataptr, SCSI_BUF_PA(cptr));705 any2scsi(ccb[mbo].dataptr, SCSI_BUF_PA(cptr));
729#ifdef DEBUG706#ifdef DEBUG
730 printk("cptr %x: ", cptr);707 printk("cptr %x: ", cptr);
@@ -735,10 +712,8 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) · 4 unmodified lines
735 } else {712 } else {
736 ccb[mbo].op = 0; /* SCSI Initiator Command */713 ccb[mbo].op = 0; /* SCSI Initiator Command */
737 SCpnt->host_scribble = NULL;714 SCpnt->host_scribble = NULL;
738 any2scsi(ccb[mbo].datalen, bufflen);715 any2scsi(ccb[mbo].datalen, 0);
739 if (buff && SCSI_BUF_PA(buff + bufflen - 1) > ISA_DMA_THRESHOLD)716 any2scsi(ccb[mbo].dataptr, 0);
740 BAD_DMA(buff, bufflen);
741 any2scsi(ccb[mbo].dataptr, SCSI_BUF_PA(buff));
742 };717 };
743 ccb[mbo].idlun = (target & 7) << 5 | direction | (lun & 7); /*SCSI Target Id */718 ccb[mbo].idlun = (target & 7) << 5 | direction | (lun & 7); /*SCSI Target Id */
744 ccb[mbo].rsalen = 16;719 ccb[mbo].rsalen = 16;
drivers/scsi/aha1740.c+1−1
@@ -286,7 +286,7 @@ static irqreturn_t aha1740_intr_handle(int irq, void *dev_id) · 285 unmodified lines
286 cdb when we come back */286 cdb when we come back */
287 if ( (adapstat & G2INTST_MASK) == G2INTST_CCBERROR ) {287 if ( (adapstat & G2INTST_MASK) == G2INTST_CCBERROR ) {
288 memcpy(SCtmp->sense_buffer, ecbptr->sense, 288 memcpy(SCtmp->sense_buffer, ecbptr->sense,
289 sizeof(SCtmp->sense_buffer));289 SCSI_SENSE_BUFFERSIZE);
290 errstatus = aha1740_makecode(ecbptr->sense,ecbptr->status);290 errstatus = aha1740_makecode(ecbptr->sense,ecbptr->status);
291 } else291 } else
292 errstatus = 0;292 errstatus = 0;
drivers/scsi/aic7xxx/Makefile+18−27
@@ -33,11 +33,10 @@ aic79xx-y += aic79xx_osm.o \ · 32 unmodified lines
33 aic79xx_proc.o \33 aic79xx_proc.o \
34 aic79xx_osm_pci.o34 aic79xx_osm_pci.o
35 35
36EXTRA_CFLAGS += -Idrivers/scsi36ccflags-y += -Idrivers/scsi
37ifdef WARNINGS_BECOME_ERRORS37ifdef WARNINGS_BECOME_ERRORS
38EXTRA_CFLAGS += -Werror38ccflags-y += -Werror
39endif39endif
40#EXTRA_CFLAGS += -g
41 40
42# Files generated that shall be removed upon make clean41# Files generated that shall be removed upon make clean
43clean-files := aic7xxx_seq.h aic7xxx_reg.h aic7xxx_reg_print.c42clean-files := aic7xxx_seq.h aic7xxx_reg.h aic7xxx_reg_print.c
@@ -46,53 +45,45 @@ clean-files += aic79xx_seq.h aic79xx_reg.h aic79xx_reg_print.c · 2 unmodified lines
46# Dependencies for generated files need to be listed explicitly45# Dependencies for generated files need to be listed explicitly
47 46
48$(obj)/aic7xxx_core.o: $(obj)/aic7xxx_seq.h47$(obj)/aic7xxx_core.o: $(obj)/aic7xxx_seq.h
48$(obj)/aic7xxx_core.o: $(obj)/aic7xxx_reg.h
49$(obj)/aic79xx_core.o: $(obj)/aic79xx_seq.h49$(obj)/aic79xx_core.o: $(obj)/aic79xx_seq.h
50$(obj)/aic79xx_reg_print.c: $(src)/aic79xx_reg_print.c_shipped50$(obj)/aic79xx_core.o: $(obj)/aic79xx_reg.h
51$(obj)/aic7xxx_reg_print.c: $(src)/aic7xxx_reg_print.c_shipped
52 51
53$(addprefix $(obj)/,$(aic7xxx-y)): $(obj)/aic7xxx_reg.h52$(addprefix $(obj)/,$(aic7xxx-y)): $(obj)/aic7xxx_seq.h
54$(addprefix $(obj)/,$(aic79xx-y)): $(obj)/aic79xx_reg.h53$(addprefix $(obj)/,$(aic79xx-y)): $(obj)/aic79xx_seq.h
55 54
56aic7xxx-gen-$(CONFIG_AIC7XXX_BUILD_FIRMWARE) := $(obj)/aic7xxx_seq.h \55aic7xxx-gen-$(CONFIG_AIC7XXX_BUILD_FIRMWARE) := $(obj)/aic7xxx_reg.h
57 $(obj)/aic7xxx_reg.h
58aic7xxx-gen-$(CONFIG_AIC7XXX_REG_PRETTY_PRINT) += $(obj)/aic7xxx_reg_print.c56aic7xxx-gen-$(CONFIG_AIC7XXX_REG_PRETTY_PRINT) += $(obj)/aic7xxx_reg_print.c
59 57
60aicasm-7xxx-opts-$(CONFIG_AIC7XXX_REG_PRETTY_PRINT) := \58aicasm-7xxx-opts-$(CONFIG_AIC7XXX_REG_PRETTY_PRINT) := \
61 -p $(obj)/aic7xxx_reg_print.c -i aic7xxx_osm.h59 -p $(obj)/aic7xxx_reg_print.c -i aic7xxx_osm.h
62 60
63ifeq ($(CONFIG_AIC7XXX_BUILD_FIRMWARE),y)61ifeq ($(CONFIG_AIC7XXX_BUILD_FIRMWARE),y)
64# Create a dependency chain in generated files62$(obj)/aic7xxx_seq.h: $(src)/aic7xxx.seq $(src)/aic7xxx.reg $(obj)/aicasm/aicasm
65# to avoid concurrent invocations of the single
66# rule that builds them all.
67aic7xxx_seq.h: aic7xxx_reg.h
68ifeq ($(CONFIG_AIC7XXX_REG_PRETTY_PRINT),y)
69aic7xxx_reg.h: aic7xxx_reg_print.c
70endif
71$(aic7xxx-gen-y): $(src)/aic7xxx.seq $(src)/aic7xxx.reg $(obj)/aicasm/aicasm
72 $(obj)/aicasm/aicasm -I$(src) -r $(obj)/aic7xxx_reg.h \63 $(obj)/aicasm/aicasm -I$(src) -r $(obj)/aic7xxx_reg.h \
73 $(aicasm-7xxx-opts-y) -o $(obj)/aic7xxx_seq.h \64 $(aicasm-7xxx-opts-y) -o $(obj)/aic7xxx_seq.h \
74 $(src)/aic7xxx.seq65 $(src)/aic7xxx.seq
66
67$(aic7xxx-gen-y): $(obj)/aic7xxx_seq.h
68else
69$(obj)/aic7xxx_reg_print.c: $(src)/aic7xxx_reg_print.c_shipped
75endif70endif
76 71
77aic79xx-gen-$(CONFIG_AIC79XX_BUILD_FIRMWARE) := $(obj)/aic79xx_seq.h \72aic79xx-gen-$(CONFIG_AIC79XX_BUILD_FIRMWARE) := $(obj)/aic79xx_reg.h
78 $(obj)/aic79xx_reg.h
79aic79xx-gen-$(CONFIG_AIC79XX_REG_PRETTY_PRINT) += $(obj)/aic79xx_reg_print.c73aic79xx-gen-$(CONFIG_AIC79XX_REG_PRETTY_PRINT) += $(obj)/aic79xx_reg_print.c
80 74
81aicasm-79xx-opts-$(CONFIG_AIC79XX_REG_PRETTY_PRINT) := \75aicasm-79xx-opts-$(CONFIG_AIC79XX_REG_PRETTY_PRINT) := \
82 -p $(obj)/aic79xx_reg_print.c -i aic79xx_osm.h76 -p $(obj)/aic79xx_reg_print.c -i aic79xx_osm.h
83 77
84ifeq ($(CONFIG_AIC79XX_BUILD_FIRMWARE),y)78ifeq ($(CONFIG_AIC79XX_BUILD_FIRMWARE),y)
85# Create a dependency chain in generated files79$(obj)/aic79xx_seq.h: $(src)/aic79xx.seq $(src)/aic79xx.reg $(obj)/aicasm/aicasm
86# to avoid concurrent invocations of the single
87# rule that builds them all.
88aic79xx_seq.h: aic79xx_reg.h
89ifeq ($(CONFIG_AIC79XX_REG_PRETTY_PRINT),y)
90aic79xx_reg.h: aic79xx_reg_print.c
91endif
92$(aic79xx-gen-y): $(src)/aic79xx.seq $(src)/aic79xx.reg $(obj)/aicasm/aicasm
93 $(obj)/aicasm/aicasm -I$(src) -r $(obj)/aic79xx_reg.h \80 $(obj)/aicasm/aicasm -I$(src) -r $(obj)/aic79xx_reg.h \
94 $(aicasm-79xx-opts-y) -o $(obj)/aic79xx_seq.h \81 $(aicasm-79xx-opts-y) -o $(obj)/aic79xx_seq.h \
95 $(src)/aic79xx.seq82 $(src)/aic79xx.seq
83
84$(aic79xx-gen-y): $(obj)/aic79xx_seq.h
85else
86$(obj)/aic79xx_reg_print.c: $(src)/aic79xx_reg_print.c_shipped
96endif87endif
97 88
98$(obj)/aicasm/aicasm: $(src)/aicasm/*.[chyl]89$(obj)/aicasm/aicasm: $(src)/aicasm/*.[chyl]
drivers/scsi/aic7xxx/aic79xx_osm.c+3−3
@@ -1784,7 +1784,7 @@ ahd_linux_handle_scsi_status(struct ahd_softc *ahd, · 1783 unmodified lines
1784 if (scb->flags & SCB_SENSE) {1784 if (scb->flags & SCB_SENSE) {
1785 sense_size = min(sizeof(struct scsi_sense_data)1785 sense_size = min(sizeof(struct scsi_sense_data)
1786 - ahd_get_sense_residual(scb),1786 - ahd_get_sense_residual(scb),
1787 (u_long)sizeof(cmd->sense_buffer));1787 (u_long)SCSI_SENSE_BUFFERSIZE);
1788 sense_offset = 0;1788 sense_offset = 0;
1789 } else {1789 } else {
1790 /*1790 /*
@@ -1795,11 +1795,11 @@ ahd_linux_handle_scsi_status(struct ahd_softc *ahd, · 4 unmodified lines
1795 scb->sense_data;1795 scb->sense_data;
1796 sense_size = min_t(size_t,1796 sense_size = min_t(size_t,
1797 scsi_4btoul(siu->sense_length),1797 scsi_4btoul(siu->sense_length),
1798 sizeof(cmd->sense_buffer));1798 SCSI_SENSE_BUFFERSIZE);
1799 sense_offset = SIU_SENSE_OFFSET(siu);1799 sense_offset = SIU_SENSE_OFFSET(siu);
1800 }1800 }
1801 1801
1802 memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer));1802 memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
1803 memcpy(cmd->sense_buffer,1803 memcpy(cmd->sense_buffer,
1804 ahd_get_sense_buf(ahd, scb)1804 ahd_get_sense_buf(ahd, scb)
1805 + sense_offset, sense_size);1805 + sense_offset, sense_size);
drivers/scsi/aic7xxx/aic7xxx_osm.c+3−3
@@ -1801,12 +1801,12 @@ ahc_linux_handle_scsi_status(struct ahc_softc *ahc, · 1800 unmodified lines
1801 1801
1802 sense_size = min(sizeof(struct scsi_sense_data)1802 sense_size = min(sizeof(struct scsi_sense_data)
1803 - ahc_get_sense_residual(scb),1803 - ahc_get_sense_residual(scb),
1804 (u_long)sizeof(cmd->sense_buffer));1804 (u_long)SCSI_SENSE_BUFFERSIZE);
1805 memcpy(cmd->sense_buffer,1805 memcpy(cmd->sense_buffer,
1806 ahc_get_sense_buf(ahc, scb), sense_size);1806 ahc_get_sense_buf(ahc, scb), sense_size);
1807 if (sense_size < sizeof(cmd->sense_buffer))1807 if (sense_size < SCSI_SENSE_BUFFERSIZE)
1808 memset(&cmd->sense_buffer[sense_size], 0,1808 memset(&cmd->sense_buffer[sense_size], 0,
1809 sizeof(cmd->sense_buffer) - sense_size);1809 SCSI_SENSE_BUFFERSIZE - sense_size);
1810 cmd->result |= (DRIVER_SENSE << 24);1810 cmd->result |= (DRIVER_SENSE << 24);
1811#ifdef AHC_DEBUG1811#ifdef AHC_DEBUG
1812 if (ahc_debug & AHC_SHOW_SENSE) {1812 if (ahc_debug & AHC_SHOW_SENSE) {
drivers/scsi/aic7xxx_old.c+5−6
@@ -2696,7 +2696,7 @@ aic7xxx_done(struct aic7xxx_host *p, struct aic7xxx_scb *scb) · 2695 unmodified lines
2696 {2696 {
2697 pci_unmap_single(p->pdev,2697 pci_unmap_single(p->pdev,
2698 le32_to_cpu(scb->sg_list[0].address),2698 le32_to_cpu(scb->sg_list[0].address),
2699 sizeof(cmd->sense_buffer),2699 SCSI_SENSE_BUFFERSIZE,
2700 PCI_DMA_FROMDEVICE);2700 PCI_DMA_FROMDEVICE);
2701 }2701 }
2702 if (scb->flags & SCB_RECOVERY_SCB)2702 if (scb->flags & SCB_RECOVERY_SCB)
@@ -4267,13 +4267,13 @@ aic7xxx_handle_seqint(struct aic7xxx_host *p, unsigned char intstat) · 1564 unmodified lines
4267 sizeof(generic_sense));4267 sizeof(generic_sense));
4268 4268
4269 scb->sense_cmd[1] = (cmd->device->lun << 5);4269 scb->sense_cmd[1] = (cmd->device->lun << 5);
4270 scb->sense_cmd[4] = sizeof(cmd->sense_buffer);4270 scb->sense_cmd[4] = SCSI_SENSE_BUFFERSIZE;
4271 4271
4272 scb->sg_list[0].length = 4272 scb->sg_list[0].length =
4273 cpu_to_le32(sizeof(cmd->sense_buffer));4273 cpu_to_le32(SCSI_SENSE_BUFFERSIZE);
4274 scb->sg_list[0].address =4274 scb->sg_list[0].address =
4275 cpu_to_le32(pci_map_single(p->pdev, cmd->sense_buffer,4275 cpu_to_le32(pci_map_single(p->pdev, cmd->sense_buffer,
4276 sizeof(cmd->sense_buffer),4276 SCSI_SENSE_BUFFERSIZE,
4277 PCI_DMA_FROMDEVICE));4277 PCI_DMA_FROMDEVICE));
4278 4278
4279 /*4279 /*
@@ -4296,7 +4296,7 @@ aic7xxx_handle_seqint(struct aic7xxx_host *p, unsigned char intstat) · 16 unmodified lines
4296 hscb->residual_data_count[2] = 0;4296 hscb->residual_data_count[2] = 0;
4297 4297
4298 scb->sg_count = hscb->SG_segment_count = 1;4298 scb->sg_count = hscb->SG_segment_count = 1;
4299 scb->sg_length = sizeof(cmd->sense_buffer);4299 scb->sg_length = SCSI_SENSE_BUFFERSIZE;
4300 scb->tag_action = 0;4300 scb->tag_action = 0;
4301 scb->flags |= SCB_SENSE;4301 scb->flags |= SCB_SENSE;
4302 /*4302 /*
@@ -10293,7 +10293,6 @@ static int aic7xxx_queue(struct scsi_cmnd *cmd, void (*fn)(struct scsi_cmnd *)) · 5990 unmodified lines
10293 aic7xxx_position(cmd) = scb->hscb->tag;10293 aic7xxx_position(cmd) = scb->hscb->tag;
10294 cmd->scsi_done = fn;10294 cmd->scsi_done = fn;
10295 cmd->result = DID_OK;10295 cmd->result = DID_OK;
10296 memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer));
10297 aic7xxx_error(cmd) = DID_OK;10296 aic7xxx_error(cmd) = DID_OK;
10298 aic7xxx_status(cmd) = 0;10297 aic7xxx_status(cmd) = 0;
10299 cmd->host_scribble = NULL;10298 cmd->host_scribble = NULL;
drivers/scsi/aic94xx/aic94xx_dev.c+3−3
@@ -165,7 +165,7 @@ static int asd_init_target_ddb(struct domain_device *dev) · 164 unmodified lines
165 if (dev->port->oob_mode != SATA_OOB_MODE) {165 if (dev->port->oob_mode != SATA_OOB_MODE) {
166 flags |= OPEN_REQUIRED;166 flags |= OPEN_REQUIRED;
167 if ((dev->dev_type == SATA_DEV) ||167 if ((dev->dev_type == SATA_DEV) ||
168 (dev->tproto & SAS_PROTO_STP)) {168 (dev->tproto & SAS_PROTOCOL_STP)) {
169 struct smp_resp *rps_resp = &dev->sata_dev.rps_resp;169 struct smp_resp *rps_resp = &dev->sata_dev.rps_resp;
170 if (rps_resp->frame_type == SMP_RESPONSE &&170 if (rps_resp->frame_type == SMP_RESPONSE &&
171 rps_resp->function == SMP_REPORT_PHY_SATA &&171 rps_resp->function == SMP_REPORT_PHY_SATA &&
@@ -193,7 +193,7 @@ static int asd_init_target_ddb(struct domain_device *dev) · 21 unmodified lines
193 asd_ddbsite_write_byte(asd_ha, ddb, DDB_TARG_FLAGS, flags);193 asd_ddbsite_write_byte(asd_ha, ddb, DDB_TARG_FLAGS, flags);
194 194
195 flags = 0;195 flags = 0;
196 if (dev->tproto & SAS_PROTO_STP)196 if (dev->tproto & SAS_PROTOCOL_STP)
197 flags |= STP_CL_POL_NO_TX;197 flags |= STP_CL_POL_NO_TX;
198 asd_ddbsite_write_byte(asd_ha, ddb, DDB_TARG_FLAGS2, flags);198 asd_ddbsite_write_byte(asd_ha, ddb, DDB_TARG_FLAGS2, flags);
199 199
@@ -201,7 +201,7 @@ static int asd_init_target_ddb(struct domain_device *dev) · 1 unmodified line
201 asd_ddbsite_write_word(asd_ha, ddb, SEND_QUEUE_TAIL, 0xFFFF);201 asd_ddbsite_write_word(asd_ha, ddb, SEND_QUEUE_TAIL, 0xFFFF);
202 asd_ddbsite_write_word(asd_ha, ddb, SISTER_DDB, 0xFFFF);202 asd_ddbsite_write_word(asd_ha, ddb, SISTER_DDB, 0xFFFF);
203 203
204 if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTO_STP)) {204 if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) {
205 i = asd_init_sata(dev);205 i = asd_init_sata(dev);
206 if (i < 0) {206 if (i < 0) {
207 asd_free_ddb(asd_ha, ddb);207 asd_free_ddb(asd_ha, ddb);
drivers/scsi/aic94xx/aic94xx_dump.c+2−2
@@ -903,11 +903,11 @@ void asd_dump_frame_rcvd(struct asd_phy *phy, · 902 unmodified lines
903 int i;903 int i;
904 904
905 switch ((dl->status_block[1] & 0x70) >> 3) {905 switch ((dl->status_block[1] & 0x70) >> 3) {
906 case SAS_PROTO_STP:906 case SAS_PROTOCOL_STP:
907 ASD_DPRINTK("STP proto device-to-host FIS:\n");907 ASD_DPRINTK("STP proto device-to-host FIS:\n");
908 break;908 break;
909 default:909 default:
910 case SAS_PROTO_SSP:910 case SAS_PROTOCOL_SSP:
911 ASD_DPRINTK("SAS proto IDENTIFY:\n");911 ASD_DPRINTK("SAS proto IDENTIFY:\n");
912 break;912 break;
913 }913 }
drivers/scsi/aic94xx/aic94xx_hwi.c+1−1
@@ -91,7 +91,7 @@ static int asd_init_phy(struct asd_phy *phy) · 90 unmodified lines
91 91
92 sas_phy->enabled = 1;92 sas_phy->enabled = 1;
93 sas_phy->class = SAS;93 sas_phy->class = SAS;
94 sas_phy->iproto = SAS_PROTO_ALL;94 sas_phy->iproto = SAS_PROTOCOL_ALL;
95 sas_phy->tproto = 0;95 sas_phy->tproto = 0;
96 sas_phy->type = PHY_TYPE_PHYSICAL;96 sas_phy->type = PHY_TYPE_PHYSICAL;
97 sas_phy->role = PHY_ROLE_INITIATOR;97 sas_phy->role = PHY_ROLE_INITIATOR;
drivers/scsi/aic94xx/aic94xx_hwi.h+3−0
@@ -72,6 +72,7 @@ struct flash_struct { · 71 unmodified lines
72 u8 manuf;72 u8 manuf;
73 u8 dev_id;73 u8 dev_id;
74 u8 sec_prot;74 u8 sec_prot;
75 u8 method;
75 76
76 u32 dir_offs;77 u32 dir_offs;
77};78};
@@ -216,6 +217,8 @@ struct asd_ha_struct { · 138 unmodified lines
216 struct dma_pool *scb_pool;217 struct dma_pool *scb_pool;
217 218
218 struct asd_seq_data seq; /* sequencer related */219 struct asd_seq_data seq; /* sequencer related */
220 u32 bios_status;
221 const struct firmware *bios_image;
219};222};
220 223
221/* ---------- Common macros ---------- */224/* ---------- Common macros ---------- */
drivers/scsi/aic94xx/aic94xx_init.c+187−3
@@ -29,6 +29,7 @@ · 28 unmodified lines
29#include <linux/kernel.h>29#include <linux/kernel.h>
30#include <linux/pci.h>30#include <linux/pci.h>
31#include <linux/delay.h>31#include <linux/delay.h>
32#include <linux/firmware.h>
32 33
33#include <scsi/scsi_host.h>34#include <scsi/scsi_host.h>
34 35
@@ -36,6 +37,7 @@ · 1 unmodified line
36#include "aic94xx_reg.h"37#include "aic94xx_reg.h"
37#include "aic94xx_hwi.h"38#include "aic94xx_hwi.h"
38#include "aic94xx_seq.h"39#include "aic94xx_seq.h"
40#include "aic94xx_sds.h"
39 41
40/* The format is "version.release.patchlevel" */42/* The format is "version.release.patchlevel" */
41#define ASD_DRIVER_VERSION "1.0.3"43#define ASD_DRIVER_VERSION "1.0.3"
@@ -134,7 +136,7 @@ Err: · 92 unmodified lines
134 return err;136 return err;
135}137}
136 138
137static void __devexit asd_unmap_memio(struct asd_ha_struct *asd_ha)139static void asd_unmap_memio(struct asd_ha_struct *asd_ha)
138{140{
139 struct asd_ha_addrspace *io_handle;141 struct asd_ha_addrspace *io_handle;
140 142
@@ -171,7 +173,7 @@ static int __devinit asd_map_ioport(struct asd_ha_struct *asd_ha) · 30 unmodified lines
171 return err;173 return err;
172}174}
173 175
174static void __devexit asd_unmap_ioport(struct asd_ha_struct *asd_ha)176static void asd_unmap_ioport(struct asd_ha_struct *asd_ha)
175{177{
176 pci_release_region(asd_ha->pcidev, PCI_IOBAR_OFFSET);178 pci_release_region(asd_ha->pcidev, PCI_IOBAR_OFFSET);
177}179}
@@ -208,7 +210,7 @@ Err: · 30 unmodified lines
208 return err;210 return err;
209}211}
210 212
211static void __devexit asd_unmap_ha(struct asd_ha_struct *asd_ha)213static void asd_unmap_ha(struct asd_ha_struct *asd_ha)
212{214{
213 if (asd_ha->iospace)215 if (asd_ha->iospace)
214 asd_unmap_ioport(asd_ha);216 asd_unmap_ioport(asd_ha);
@@ -313,6 +315,181 @@ static ssize_t asd_show_dev_pcba_sn(struct device *dev, · 98 unmodified lines
313}315}
314static DEVICE_ATTR(pcba_sn, S_IRUGO, asd_show_dev_pcba_sn, NULL);316static DEVICE_ATTR(pcba_sn, S_IRUGO, asd_show_dev_pcba_sn, NULL);
315 317
318#define FLASH_CMD_NONE 0x00
319#define FLASH_CMD_UPDATE 0x01
320#define FLASH_CMD_VERIFY 0x02
321
322struct flash_command {
323 u8 command[8];
324 int code;
325};
326
327static struct flash_command flash_command_table[] =
328{
329 {"verify", FLASH_CMD_VERIFY},
330 {"update", FLASH_CMD_UPDATE},
331 {"", FLASH_CMD_NONE} /* Last entry should be NULL. */
332};
333
334struct error_bios {
335 char *reason;
336 int err_code;
337};
338
339static struct error_bios flash_error_table[] =
340{
341 {"Failed to open bios image file", FAIL_OPEN_BIOS_FILE},
342 {"PCI ID mismatch", FAIL_CHECK_PCI_ID},
343 {"Checksum mismatch", FAIL_CHECK_SUM},
344 {"Unknown Error", FAIL_UNKNOWN},
345 {"Failed to verify.", FAIL_VERIFY},
346 {"Failed to reset flash chip.", FAIL_RESET_FLASH},
347 {"Failed to find flash chip type.", FAIL_FIND_FLASH_ID},
348 {"Failed to erash flash chip.", FAIL_ERASE_FLASH},
349 {"Failed to program flash chip.", FAIL_WRITE_FLASH},
350 {"Flash in progress", FLASH_IN_PROGRESS},
351 {"Image file size Error", FAIL_FILE_SIZE},
352 {"Input parameter error", FAIL_PARAMETERS},
353 {"Out of memory", FAIL_OUT_MEMORY},
354 {"OK", 0} /* Last entry err_code = 0. */
355};
356
357static ssize_t asd_store_update_bios(struct device *dev,
358 struct device_attribute *attr,
359 const char *buf, size_t count)
360{
361 struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev);
362 char *cmd_ptr, *filename_ptr;
363 struct bios_file_header header, *hdr_ptr;
364 int res, i;
365 u32 csum = 0;
366 int flash_command = FLASH_CMD_NONE;
367 int err = 0;
368
369 cmd_ptr = kzalloc(count*2, GFP_KERNEL);
370
371 if (!cmd_ptr) {
372 err = FAIL_OUT_MEMORY;
373 goto out;
374 }
375
376 filename_ptr = cmd_ptr + count;
377 res = sscanf(buf, "%s %s", cmd_ptr, filename_ptr);
378 if (res != 2) {
379 err = FAIL_PARAMETERS;
380 goto out1;
381 }
382
383 for (i = 0; flash_command_table[i].code != FLASH_CMD_NONE; i++) {
384 if (!memcmp(flash_command_table[i].command,
385 cmd_ptr, strlen(cmd_ptr))) {
386 flash_command = flash_command_table[i].code;
387 break;
388 }
389 }
390 if (flash_command == FLASH_CMD_NONE) {
391 err = FAIL_PARAMETERS;
392 goto out1;
393 }
394
395 if (asd_ha->bios_status == FLASH_IN_PROGRESS) {
396 err = FLASH_IN_PROGRESS;
397 goto out1;
398 }
399 err = request_firmware(&asd_ha->bios_image,
400 filename_ptr,
401 &asd_ha->pcidev->dev);
402 if (err) {
403 asd_printk("Failed to load bios image file %s, error %d\n",
404 filename_ptr, err);
405 err = FAIL_OPEN_BIOS_FILE;
406 goto out1;
407 }
408
409 hdr_ptr = (struct bios_file_header *)asd_ha->bios_image->data;
410
411 if ((hdr_ptr->contrl_id.vendor != asd_ha->pcidev->vendor ||
412 hdr_ptr->contrl_id.device != asd_ha->pcidev->device) &&
413 (hdr_ptr->contrl_id.sub_vendor != asd_ha->pcidev->vendor ||
414 hdr_ptr->contrl_id.sub_device != asd_ha->pcidev->device)) {
415
416 ASD_DPRINTK("The PCI vendor or device id does not match\n");
417 ASD_DPRINTK("vendor=%x dev=%x sub_vendor=%x sub_dev=%x"
418 " pci vendor=%x pci dev=%x\n",
419 hdr_ptr->contrl_id.vendor,
420 hdr_ptr->contrl_id.device,
421 hdr_ptr->contrl_id.sub_vendor,
422 hdr_ptr->contrl_id.sub_device,
423 asd_ha->pcidev->vendor,
424 asd_ha->pcidev->device);
425 err = FAIL_CHECK_PCI_ID;
426 goto out2;
427 }
428
429 if (hdr_ptr->filelen != asd_ha->bios_image->size) {
430 err = FAIL_FILE_SIZE;
431 goto out2;
432 }
433
434 /* calculate checksum */
435 for (i = 0; i < hdr_ptr->filelen; i++)
436 csum += asd_ha->bios_image->data[i];
437
438 if ((csum & 0x0000ffff) != hdr_ptr->checksum) {
439 ASD_DPRINTK("BIOS file checksum mismatch\n");
440 err = FAIL_CHECK_SUM;
441 goto out2;
442 }
443 if (flash_command == FLASH_CMD_UPDATE) {
444 asd_ha->bios_status = FLASH_IN_PROGRESS;
445 err = asd_write_flash_seg(asd_ha,
446 &asd_ha->bios_image->data[sizeof(*hdr_ptr)],
447 0, hdr_ptr->filelen-sizeof(*hdr_ptr));
448 if (!err)
449 err = asd_verify_flash_seg(asd_ha,
450 &asd_ha->bios_image->data[sizeof(*hdr_ptr)],
451 0, hdr_ptr->filelen-sizeof(*hdr_ptr));
452 } else {
453 asd_ha->bios_status = FLASH_IN_PROGRESS;
454 err = asd_verify_flash_seg(asd_ha,
455 &asd_ha->bios_image->data[sizeof(header)],
456 0, hdr_ptr->filelen-sizeof(header));
457 }
458
459out2:
460 release_firmware(asd_ha->bios_image);
461out1:
462 kfree(cmd_ptr);
463out:
464 asd_ha->bios_status = err;
465
466 if (!err)
467 return count;
468 else
469 return -err;
470}
471
472static ssize_t asd_show_update_bios(struct device *dev,
473 struct device_attribute *attr, char *buf)
474{
475 int i;
476 struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev);
477
478 for (i = 0; flash_error_table[i].err_code != 0; i++) {
479 if (flash_error_table[i].err_code == asd_ha->bios_status)
480 break;
481 }
482 if (asd_ha->bios_status != FLASH_IN_PROGRESS)
483 asd_ha->bios_status = FLASH_OK;
484
485 return snprintf(buf, PAGE_SIZE, "status=%x %s\n",
486 flash_error_table[i].err_code,
487 flash_error_table[i].reason);
488}
489
490static DEVICE_ATTR(update_bios, S_IRUGO|S_IWUGO,
491 asd_show_update_bios, asd_store_update_bios);
492
316static int asd_create_dev_attrs(struct asd_ha_struct *asd_ha)493static int asd_create_dev_attrs(struct asd_ha_struct *asd_ha)
317{494{
318 int err;495 int err;
@@ -328,9 +505,14 @@ static int asd_create_dev_attrs(struct asd_ha_struct *asd_ha) · 9 unmodified lines
328 err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_pcba_sn);505 err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_pcba_sn);
329 if (err)506 if (err)
330 goto err_biosb;507 goto err_biosb;
508 err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_update_bios);
509 if (err)
510 goto err_update_bios;
331 511
332 return 0;512 return 0;
333 513
514err_update_bios:
515 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_pcba_sn);
334err_biosb:516err_biosb:
335 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_bios_build);517 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_bios_build);
336err_rev:518err_rev:
@@ -343,6 +525,7 @@ static void asd_remove_dev_attrs(struct asd_ha_struct *asd_ha) · 6 unmodified lines
343 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_revision);525 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_revision);
344 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_bios_build);526 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_bios_build);
345 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_pcba_sn);527 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_pcba_sn);
528 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_update_bios);
346}529}
347 530
348/* The first entry, 0, is used for dynamic ids, the rest for devices531/* The first entry, 0, is used for dynamic ids, the rest for devices
@@ -589,6 +772,7 @@ static int __devinit asd_pci_probe(struct pci_dev *dev, · 240 unmodified lines
589 asd_ha->sas_ha.dev = &asd_ha->pcidev->dev;772 asd_ha->sas_ha.dev = &asd_ha->pcidev->dev;
590 asd_ha->sas_ha.lldd_ha = asd_ha;773 asd_ha->sas_ha.lldd_ha = asd_ha;
591 774
775 asd_ha->bios_status = FLASH_OK;
592 asd_ha->name = asd_dev->name;776 asd_ha->name = asd_dev->name;
593 asd_printk("found %s, device %s\n", asd_ha->name, pci_name(dev));777 asd_printk("found %s, device %s\n", asd_ha->name, pci_name(dev));
594 778
drivers/scsi/aic94xx/aic94xx_scb.c+3−3
@@ -788,12 +788,12 @@ void asd_build_control_phy(struct asd_ascb *ascb, int phy_id, u8 subfunc) · 787 unmodified lines
788 788
789 /* initiator port settings are in the hi nibble */789 /* initiator port settings are in the hi nibble */
790 if (phy->sas_phy.role == PHY_ROLE_INITIATOR)790 if (phy->sas_phy.role == PHY_ROLE_INITIATOR)
791 control_phy->port_type = SAS_PROTO_ALL << 4;791 control_phy->port_type = SAS_PROTOCOL_ALL << 4;
792 else if (phy->sas_phy.role == PHY_ROLE_TARGET)792 else if (phy->sas_phy.role == PHY_ROLE_TARGET)
793 control_phy->port_type = SAS_PROTO_ALL;793 control_phy->port_type = SAS_PROTOCOL_ALL;
794 else794 else
795 control_phy->port_type =795 control_phy->port_type =
796 (SAS_PROTO_ALL << 4) | SAS_PROTO_ALL;796 (SAS_PROTOCOL_ALL << 4) | SAS_PROTOCOL_ALL;
797 797
798 /* link reset retries, this should be nominal */798 /* link reset retries, this should be nominal */
799 control_phy->link_reset_retries = 10;799 control_phy->link_reset_retries = 10;
drivers/scsi/aic94xx/aic94xx_sds.c+389−0
@@ -30,6 +30,7 @@ · 29 unmodified lines
30 30
31#include "aic94xx.h"31#include "aic94xx.h"
32#include "aic94xx_reg.h"32#include "aic94xx_reg.h"
33#include "aic94xx_sds.h"
33 34
34/* ---------- OCM stuff ---------- */35/* ---------- OCM stuff ---------- */
35 36
@@ -1083,3 +1084,391 @@ out: · 1047 unmodified lines
1083 kfree(flash_dir);1084 kfree(flash_dir);
1084 return err;1085 return err;
1085}1086}
1087
1088/**
1089 * asd_verify_flash_seg - verify data with flash memory
1090 * @asd_ha: pointer to the host adapter structure
1091 * @src: pointer to the source data to be verified
1092 * @dest_offset: offset from flash memory
1093 * @bytes_to_verify: total bytes to verify
1094 */
1095int asd_verify_flash_seg(struct asd_ha_struct *asd_ha,
1096 void *src, u32 dest_offset, u32 bytes_to_verify)
1097{
1098 u8 *src_buf;
1099 u8 flash_char;
1100 int err;
1101 u32 nv_offset, reg, i;
1102
1103 reg = asd_ha->hw_prof.flash.bar;
1104 src_buf = NULL;
1105
1106 err = FLASH_OK;
1107 nv_offset = dest_offset;
1108 src_buf = (u8 *)src;
1109 for (i = 0; i < bytes_to_verify; i++) {
1110 flash_char = asd_read_reg_byte(asd_ha, reg + nv_offset + i);
1111 if (flash_char != src_buf[i]) {
1112 err = FAIL_VERIFY;
1113 break;
1114 }
1115 }
1116 return err;
1117}
1118
1119/**
1120 * asd_write_flash_seg - write data into flash memory
1121 * @asd_ha: pointer to the host adapter structure
1122 * @src: pointer to the source data to be written
1123 * @dest_offset: offset from flash memory
1124 * @bytes_to_write: total bytes to write
1125 */
1126int asd_write_flash_seg(struct asd_ha_struct *asd_ha,
1127 void *src, u32 dest_offset, u32 bytes_to_write)
1128{
1129 u8 *src_buf;
1130 u32 nv_offset, reg, i;
1131 int err;
1132
1133 reg = asd_ha->hw_prof.flash.bar;
1134 src_buf = NULL;
1135
1136 err = asd_check_flash_type(asd_ha);
1137 if (err) {
1138 ASD_DPRINTK("couldn't find the type of flash. err=%d\n", err);
1139 return err;
1140 }
1141
1142 nv_offset = dest_offset;
1143 err = asd_erase_nv_sector(asd_ha, nv_offset, bytes_to_write);
1144 if (err) {
1145 ASD_DPRINTK("Erase failed at offset:0x%x\n",
1146 nv_offset);
1147 return err;
1148 }
1149
1150 err = asd_reset_flash(asd_ha);
1151 if (err) {
1152 ASD_DPRINTK("couldn't reset flash. err=%d\n", err);
1153 return err;
1154 }
1155
1156 src_buf = (u8 *)src;
1157 for (i = 0; i < bytes_to_write; i++) {
1158 /* Setup program command sequence */
1159 switch (asd_ha->hw_prof.flash.method) {
1160 case FLASH_METHOD_A:
1161 {
1162 asd_write_reg_byte(asd_ha,
1163 (reg + 0xAAA), 0xAA);
1164 asd_write_reg_byte(asd_ha,
1165 (reg + 0x555), 0x55);
1166 asd_write_reg_byte(asd_ha,
1167 (reg + 0xAAA), 0xA0);
1168 asd_write_reg_byte(asd_ha,
1169 (reg + nv_offset + i),
1170 (*(src_buf + i)));
1171 break;
1172 }
1173 case FLASH_METHOD_B:
1174 {
1175 asd_write_reg_byte(asd_ha,
1176 (reg + 0x555), 0xAA);
1177 asd_write_reg_byte(asd_ha,
1178 (reg + 0x2AA), 0x55);
1179 asd_write_reg_byte(asd_ha,
1180 (reg + 0x555), 0xA0);
1181 asd_write_reg_byte(asd_ha,
1182 (reg + nv_offset + i),
1183 (*(src_buf + i)));
1184 break;
1185 }
1186 default:
1187 break;
1188 }
1189 if (asd_chk_write_status(asd_ha,
1190 (nv_offset + i), 0) != 0) {
1191 ASD_DPRINTK("aicx: Write failed at offset:0x%x\n",
1192 reg + nv_offset + i);
1193 return FAIL_WRITE_FLASH;
1194 }
1195 }
1196
1197 err = asd_reset_flash(asd_ha);
1198 if (err) {
1199 ASD_DPRINTK("couldn't reset flash. err=%d\n", err);
1200 return err;
1201 }
1202 return 0;
1203}
1204
1205int asd_chk_write_status(struct asd_ha_struct *asd_ha,
1206 u32 sector_addr, u8 erase_flag)
1207{
1208 u32 reg;
1209 u32 loop_cnt;
1210 u8 nv_data1, nv_data2;
1211 u8 toggle_bit1;
1212
1213 /*
1214 * Read from DQ2 requires sector address
1215 * while it's dont care for DQ6
1216 */
1217 reg = asd_ha->hw_prof.flash.bar;
1218
1219 for (loop_cnt = 0; loop_cnt < 50000; loop_cnt++) {
1220 nv_data1 = asd_read_reg_byte(asd_ha, reg);
1221 nv_data2 = asd_read_reg_byte(asd_ha, reg);
1222
1223 toggle_bit1 = ((nv_data1 & FLASH_STATUS_BIT_MASK_DQ6)
1224 ^ (nv_data2 & FLASH_STATUS_BIT_MASK_DQ6));
1225
1226 if (toggle_bit1 == 0) {
1227 return 0;
1228 } else {
1229 if (nv_data2 & FLASH_STATUS_BIT_MASK_DQ5) {
1230 nv_data1 = asd_read_reg_byte(asd_ha,
1231 reg);
1232 nv_data2 = asd_read_reg_byte(asd_ha,
1233 reg);
1234 toggle_bit1 =
1235 ((nv_data1 & FLASH_STATUS_BIT_MASK_DQ6)
1236 ^ (nv_data2 & FLASH_STATUS_BIT_MASK_DQ6));
1237
1238 if (toggle_bit1 == 0)
1239 return 0;
1240 }
1241 }
1242
1243 /*
1244 * ERASE is a sector-by-sector operation and requires
1245 * more time to finish while WRITE is byte-byte-byte
1246 * operation and takes lesser time to finish.
1247 *
1248 * For some strange reason a reduced ERASE delay gives different
1249 * behaviour across different spirit boards. Hence we set
1250 * a optimum balance of 50mus for ERASE which works well
1251 * across all boards.
1252 */
1253 if (erase_flag) {
1254 udelay(FLASH_STATUS_ERASE_DELAY_COUNT);
1255 } else {
1256 udelay(FLASH_STATUS_WRITE_DELAY_COUNT);
1257 }
1258 }
1259 return -1;
1260}
1261
1262/**
1263 * asd_hwi_erase_nv_sector - Erase the flash memory sectors.
1264 * @asd_ha: pointer to the host adapter structure
1265 * @flash_addr: pointer to offset from flash memory
1266 * @size: total bytes to erase.
1267 */
1268int asd_erase_nv_sector(struct asd_ha_struct *asd_ha, u32 flash_addr, u32 size)
1269{
1270 u32 reg;
1271 u32 sector_addr;
1272
1273 reg = asd_ha->hw_prof.flash.bar;
1274
1275 /* sector staring address */
1276 sector_addr = flash_addr & FLASH_SECTOR_SIZE_MASK;
1277
1278 /*
1279 * Erasing an flash sector needs to be done in six consecutive
1280 * write cyles.
1281 */
1282 while (sector_addr < flash_addr+size) {
1283 switch (asd_ha->hw_prof.flash.method) {
1284 case FLASH_METHOD_A:
1285 asd_write_reg_byte(asd_ha, (reg + 0xAAA), 0xAA);
1286 asd_write_reg_byte(asd_ha, (reg + 0x555), 0x55);
1287 asd_write_reg_byte(asd_ha, (reg + 0xAAA), 0x80);
1288 asd_write_reg_byte(asd_ha, (reg + 0xAAA), 0xAA);
1289 asd_write_reg_byte(asd_ha, (reg + 0x555), 0x55);
1290 asd_write_reg_byte(asd_ha, (reg + sector_addr), 0x30);
1291 break;
1292 case FLASH_METHOD_B:
1293 asd_write_reg_byte(asd_ha, (reg + 0x555), 0xAA);
1294 asd_write_reg_byte(asd_ha, (reg + 0x2AA), 0x55);
1295 asd_write_reg_byte(asd_ha, (reg + 0x555), 0x80);
1296 asd_write_reg_byte(asd_ha, (reg + 0x555), 0xAA);
1297 asd_write_reg_byte(asd_ha, (reg + 0x2AA), 0x55);
1298 asd_write_reg_byte(asd_ha, (reg + sector_addr), 0x30);
1299 break;
1300 default:
1301 break;
1302 }
1303
1304 if (asd_chk_write_status(asd_ha, sector_addr, 1) != 0)
1305 return FAIL_ERASE_FLASH;
1306
1307 sector_addr += FLASH_SECTOR_SIZE;
1308 }
1309
1310 return 0;
1311}
1312
1313int asd_check_flash_type(struct asd_ha_struct *asd_ha)
1314{
1315 u8 manuf_id;
1316 u8 dev_id;
1317 u8 sec_prot;
1318 u32 inc;
1319 u32 reg;
1320 int err;
1321
1322 /* get Flash memory base address */
1323 reg = asd_ha->hw_prof.flash.bar;
1324
1325 /* Determine flash info */
1326 err = asd_reset_flash(asd_ha);
1327 if (err) {
1328 ASD_DPRINTK("couldn't reset flash. err=%d\n", err);
1329 return err;
1330 }
1331
1332 asd_ha->hw_prof.flash.method = FLASH_METHOD_UNKNOWN;
1333 asd_ha->hw_prof.flash.manuf = FLASH_MANUF_ID_UNKNOWN;
1334 asd_ha->hw_prof.flash.dev_id = FLASH_DEV_ID_UNKNOWN;
1335
1336 /* Get flash info. This would most likely be AMD Am29LV family flash.
1337 * First try the sequence for word mode. It is the same as for
1338 * 008B (byte mode only), 160B (word mode) and 800D (word mode).
1339 */
1340 inc = asd_ha->hw_prof.flash.wide ? 2 : 1;
1341 asd_write_reg_byte(asd_ha, reg + 0xAAA, 0xAA);
1342 asd_write_reg_byte(asd_ha, reg + 0x555, 0x55);
1343 asd_write_reg_byte(asd_ha, reg + 0xAAA, 0x90);
1344 manuf_id = asd_read_reg_byte(asd_ha, reg);
1345 dev_id = asd_read_reg_byte(asd_ha, reg + inc);
1346 sec_prot = asd_read_reg_byte(asd_ha, reg + inc + inc);
1347 /* Get out of autoselect mode. */
1348 err = asd_reset_flash(asd_ha);
1349 if (err) {
1350 ASD_DPRINTK("couldn't reset flash. err=%d\n", err);
1351 return err;
1352 }
1353 ASD_DPRINTK("Flash MethodA manuf_id(0x%x) dev_id(0x%x) "
1354 "sec_prot(0x%x)\n", manuf_id, dev_id, sec_prot);
1355 err = asd_reset_flash(asd_ha);
1356 if (err != 0)
1357 return err;
1358
1359 switch (manuf_id) {
1360 case FLASH_MANUF_ID_AMD:
1361 switch (sec_prot) {
1362 case FLASH_DEV_ID_AM29LV800DT:
1363 case FLASH_DEV_ID_AM29LV640MT:
1364 case FLASH_DEV_ID_AM29F800B:
1365 asd_ha->hw_prof.flash.method = FLASH_METHOD_A;
1366 break;
1367 default:
1368 break;
1369 }
1370 break;
1371 case FLASH_MANUF_ID_ST:
1372 switch (sec_prot) {
1373 case FLASH_DEV_ID_STM29W800DT:
1374 case FLASH_DEV_ID_STM29LV640:
1375 asd_ha->hw_prof.flash.method = FLASH_METHOD_A;
1376 break;
1377 default:
1378 break;
1379 }
1380 break;
1381 case FLASH_MANUF_ID_FUJITSU:
1382 switch (sec_prot) {
1383 case FLASH_DEV_ID_MBM29LV800TE:
1384 case FLASH_DEV_ID_MBM29DL800TA:
1385 asd_ha->hw_prof.flash.method = FLASH_METHOD_A;
1386 break;
1387 }
1388 break;
1389 case FLASH_MANUF_ID_MACRONIX:
1390 switch (sec_prot) {
1391 case FLASH_DEV_ID_MX29LV800BT:
1392 asd_ha->hw_prof.flash.method = FLASH_METHOD_A;
1393 break;
1394 }
1395 break;
1396 }
1397
1398 if (asd_ha->hw_prof.flash.method == FLASH_METHOD_UNKNOWN) {
1399 err = asd_reset_flash(asd_ha);
1400 if (err) {
1401 ASD_DPRINTK("couldn't reset flash. err=%d\n", err);
1402 return err;
1403 }
1404
1405 /* Issue Unlock sequence for AM29LV008BT */
1406 asd_write_reg_byte(asd_ha, (reg + 0x555), 0xAA);
1407 asd_write_reg_byte(asd_ha, (reg + 0x2AA), 0x55);
1408 asd_write_reg_byte(asd_ha, (reg + 0x555), 0x90);
1409 manuf_id = asd_read_reg_byte(asd_ha, reg);
1410 dev_id = asd_read_reg_byte(asd_ha, reg + inc);
1411 sec_prot = asd_read_reg_byte(asd_ha, reg + inc + inc);
1412
1413 ASD_DPRINTK("Flash MethodB manuf_id(0x%x) dev_id(0x%x) sec_prot"
1414 "(0x%x)\n", manuf_id, dev_id, sec_prot);
1415
1416 err = asd_reset_flash(asd_ha);
1417 if (err != 0) {
1418 ASD_DPRINTK("couldn't reset flash. err=%d\n", err);
1419 return err;
1420 }
1421
1422 switch (manuf_id) {
1423 case FLASH_MANUF_ID_AMD:
1424 switch (dev_id) {
1425 case FLASH_DEV_ID_AM29LV008BT:
1426 asd_ha->hw_prof.flash.method = FLASH_METHOD_B;
1427 break;
1428 default:
1429 break;
1430 }
1431 break;
1432 case FLASH_MANUF_ID_ST:
1433 switch (dev_id) {
1434 case FLASH_DEV_ID_STM29008:
1435 asd_ha->hw_prof.flash.method = FLASH_METHOD_B;
1436 break;
1437 default:
1438 break;
1439 }
1440 break;
1441 case FLASH_MANUF_ID_FUJITSU:
1442 switch (dev_id) {
1443 case FLASH_DEV_ID_MBM29LV008TA:
1444 asd_ha->hw_prof.flash.method = FLASH_METHOD_B;
1445 break;
1446 }
1447 break;
1448 case FLASH_MANUF_ID_INTEL:
1449 switch (dev_id) {
1450 case FLASH_DEV_ID_I28LV00TAT:
1451 asd_ha->hw_prof.flash.method = FLASH_METHOD_B;
1452 break;
1453 }
1454 break;
1455 case FLASH_MANUF_ID_MACRONIX:
1456 switch (dev_id) {
1457 case FLASH_DEV_ID_I28LV00TAT:
1458 asd_ha->hw_prof.flash.method = FLASH_METHOD_B;
1459 break;
1460 }
1461 break;
1462 default:
1463 return FAIL_FIND_FLASH_ID;
1464 }
1465 }
1466
1467 if (asd_ha->hw_prof.flash.method == FLASH_METHOD_UNKNOWN)
1468 return FAIL_FIND_FLASH_ID;
1469
1470 asd_ha->hw_prof.flash.manuf = manuf_id;
1471 asd_ha->hw_prof.flash.dev_id = dev_id;
1472 asd_ha->hw_prof.flash.sec_prot = sec_prot;
1473 return 0;
1474}
drivers/scsi/aic94xx/aic94xx_sds.h+121−0
@@ -0,0 +1,121 @@
1/*
2 * Aic94xx SAS/SATA driver hardware interface header file.
3 *
4 * Copyright (C) 2005 Adaptec, Inc. All rights reserved.
5 * Copyright (C) 2005 Gilbert Wu <gilbert_wu@adaptec.com>
6 *
7 * This file is licensed under GPLv2.
8 *
9 * This file is part of the aic94xx driver.
10 *
11 * The aic94xx driver is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; version 2 of the
14 * License.
15 *
16 * The aic94xx driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with the aic94xx driver; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 *
25 */
26#ifndef _AIC94XX_SDS_H_
27#define _AIC94XX_SDS_H_
28
29enum {
30 FLASH_METHOD_UNKNOWN,
31 FLASH_METHOD_A,
32 FLASH_METHOD_B
33};
34
35#define FLASH_MANUF_ID_AMD 0x01
36#define FLASH_MANUF_ID_ST 0x20
37#define FLASH_MANUF_ID_FUJITSU 0x04
38#define FLASH_MANUF_ID_MACRONIX 0xC2
39#define FLASH_MANUF_ID_INTEL 0x89
40#define FLASH_MANUF_ID_UNKNOWN 0xFF
41
42#define FLASH_DEV_ID_AM29LV008BT 0x3E
43#define FLASH_DEV_ID_AM29LV800DT 0xDA
44#define FLASH_DEV_ID_STM29W800DT 0xD7
45#define FLASH_DEV_ID_STM29LV640 0xDE
46#define FLASH_DEV_ID_STM29008 0xEA
47#define FLASH_DEV_ID_MBM29LV800TE 0xDA
48#define FLASH_DEV_ID_MBM29DL800TA 0x4A
49#define FLASH_DEV_ID_MBM29LV008TA 0x3E
50#define FLASH_DEV_ID_AM29LV640MT 0x7E
51#define FLASH_DEV_ID_AM29F800B 0xD6
52#define FLASH_DEV_ID_MX29LV800BT 0xDA
53#define FLASH_DEV_ID_MX29LV008CT 0xDA
54#define FLASH_DEV_ID_I28LV00TAT 0x3E
55#define FLASH_DEV_ID_UNKNOWN 0xFF
56
57/* status bit mask values */
58#define FLASH_STATUS_BIT_MASK_DQ6 0x40
59#define FLASH_STATUS_BIT_MASK_DQ5 0x20
60#define FLASH_STATUS_BIT_MASK_DQ2 0x04
61
62/* minimum value in micro seconds needed for checking status */
63#define FLASH_STATUS_ERASE_DELAY_COUNT 50
64#define FLASH_STATUS_WRITE_DELAY_COUNT 25
65
66#define FLASH_SECTOR_SIZE 0x010000
67#define FLASH_SECTOR_SIZE_MASK 0xffff0000
68
69#define FLASH_OK 0x000000
70#define FAIL_OPEN_BIOS_FILE 0x000100
71#define FAIL_CHECK_PCI_ID 0x000200
72#define FAIL_CHECK_SUM 0x000300
73#define FAIL_UNKNOWN 0x000400
74#define FAIL_VERIFY 0x000500
75#define FAIL_RESET_FLASH 0x000600
76#define FAIL_FIND_FLASH_ID 0x000700
77#define FAIL_ERASE_FLASH 0x000800
78#define FAIL_WRITE_FLASH 0x000900
79#define FAIL_FILE_SIZE 0x000a00
80#define FAIL_PARAMETERS 0x000b00
81#define FAIL_OUT_MEMORY 0x000c00
82#define FLASH_IN_PROGRESS 0x001000
83
84struct controller_id {
85 u32 vendor; /* PCI Vendor ID */
86 u32 device; /* PCI Device ID */
87 u32 sub_vendor; /* PCI Subvendor ID */
88 u32 sub_device; /* PCI Subdevice ID */
89};
90
91struct image_info {
92 u32 ImageId; /* Identifies the image */
93 u32 ImageOffset; /* Offset the beginning of the file */
94 u32 ImageLength; /* length of the image */
95 u32 ImageChecksum; /* Image checksum */
96 u32 ImageVersion; /* Version of the image, could be build number */
97};
98
99struct bios_file_header {
100 u8 signature[32]; /* Signature/Cookie to identify the file */
101 u32 checksum; /*Entire file checksum with this field zero */
102 u32 antidote; /* Entire file checksum with this field 0xFFFFFFFF */
103 struct controller_id contrl_id; /*PCI id to identify the controller */
104 u32 filelen; /*Length of the entire file*/
105 u32 chunk_num; /*The chunk/part number for multiple Image files */
106 u32 total_chunks; /*Total number of chunks/parts in the image file */
107 u32 num_images; /* Number of images in the file */
108 u32 build_num; /* Build number of this image */
109 struct image_info image_header;
110};
111
112int asd_verify_flash_seg(struct asd_ha_struct *asd_ha,
113 void *src, u32 dest_offset, u32 bytes_to_verify);
114int asd_write_flash_seg(struct asd_ha_struct *asd_ha,
115 void *src, u32 dest_offset, u32 bytes_to_write);
116int asd_chk_write_status(struct asd_ha_struct *asd_ha,
117 u32 sector_addr, u8 erase_flag);
118int asd_check_flash_type(struct asd_ha_struct *asd_ha);
119int asd_erase_nv_sector(struct asd_ha_struct *asd_ha,
120 u32 flash_addr, u32 size);
121#endif
drivers/scsi/aic94xx/aic94xx_task.c+17−33
@@ -187,29 +187,13 @@ static void asd_get_response_tasklet(struct asd_ascb *ascb, · 186 unmodified lines
187 ts->buf_valid_size = 0;187 ts->buf_valid_size = 0;
188 edb = asd_ha->seq.edb_arr[edb_id + escb->edb_index];188 edb = asd_ha->seq.edb_arr[edb_id + escb->edb_index];
189 r = edb->vaddr;189 r = edb->vaddr;
190 if (task->task_proto == SAS_PROTO_SSP) {190 if (task->task_proto == SAS_PROTOCOL_SSP) {
191 struct ssp_response_iu *iu =191 struct ssp_response_iu *iu =
192 r + 16 + sizeof(struct ssp_frame_hdr);192 r + 16 + sizeof(struct ssp_frame_hdr);
193 193
194 ts->residual = le32_to_cpu(*(__le32 *)r);194 ts->residual = le32_to_cpu(*(__le32 *)r);
195 ts->resp = SAS_TASK_COMPLETE;195
196 if (iu->datapres == 0)196 sas_ssp_task_response(&asd_ha->pcidev->dev, task, iu);
197 ts->stat = iu->status;
198 else if (iu->datapres == 1)
199 ts->stat = iu->resp_data[3];
200 else if (iu->datapres == 2) {
201 ts->stat = SAM_CHECK_COND;
202 ts->buf_valid_size = min((u32) SAS_STATUS_BUF_SIZE,
203 be32_to_cpu(iu->sense_data_len));
204 memcpy(ts->buf, iu->sense_data, ts->buf_valid_size);
205 if (iu->status != SAM_CHECK_COND) {
206 ASD_DPRINTK("device %llx sent sense data, but "
207 "stat(0x%x) is not CHECK_CONDITION"
208 "\n",
209 SAS_ADDR(task->dev->sas_addr),
210 iu->status);
211 }
212 }
213 } else {197 } else {
214 struct ata_task_resp *resp = (void *) &ts->buf[0];198 struct ata_task_resp *resp = (void *) &ts->buf[0];
215 199
@@ -341,14 +325,14 @@ Again: · 125 unmodified lines
341 }325 }
342 326
343 switch (task->task_proto) {327 switch (task->task_proto) {
344 case SATA_PROTO:328 case SAS_PROTOCOL_SATA:
345 case SAS_PROTO_STP:329 case SAS_PROTOCOL_STP:
346 asd_unbuild_ata_ascb(ascb);330 asd_unbuild_ata_ascb(ascb);
347 break;331 break;
348 case SAS_PROTO_SMP:332 case SAS_PROTOCOL_SMP:
349 asd_unbuild_smp_ascb(ascb);333 asd_unbuild_smp_ascb(ascb);
350 break;334 break;
351 case SAS_PROTO_SSP:335 case SAS_PROTOCOL_SSP:
352 asd_unbuild_ssp_ascb(ascb);336 asd_unbuild_ssp_ascb(ascb);
353 default:337 default:
354 break;338 break;
@@ -586,17 +570,17 @@ int asd_execute_task(struct sas_task *task, const int num, · 231 unmodified lines
586 list_for_each_entry(a, &alist, list) {570 list_for_each_entry(a, &alist, list) {
587 t = a->uldd_task;571 t = a->uldd_task;
588 a->uldd_timer = 1;572 a->uldd_timer = 1;
589 if (t->task_proto & SAS_PROTO_STP)573 if (t->task_proto & SAS_PROTOCOL_STP)
590 t->task_proto = SAS_PROTO_STP;574 t->task_proto = SAS_PROTOCOL_STP;
591 switch (t->task_proto) {575 switch (t->task_proto) {
592 case SATA_PROTO:576 case SAS_PROTOCOL_SATA:
593 case SAS_PROTO_STP:577 case SAS_PROTOCOL_STP:
594 res = asd_build_ata_ascb(a, t, gfp_flags);578 res = asd_build_ata_ascb(a, t, gfp_flags);
595 break;579 break;
596 case SAS_PROTO_SMP:580 case SAS_PROTOCOL_SMP:
597 res = asd_build_smp_ascb(a, t, gfp_flags);581 res = asd_build_smp_ascb(a, t, gfp_flags);
598 break;582 break;
599 case SAS_PROTO_SSP:583 case SAS_PROTOCOL_SSP:
600 res = asd_build_ssp_ascb(a, t, gfp_flags);584 res = asd_build_ssp_ascb(a, t, gfp_flags);
601 break;585 break;
602 default:586 default:
@@ -633,14 +617,14 @@ out_err_unmap: · 30 unmodified lines
633 t->task_state_flags &= ~SAS_TASK_AT_INITIATOR;617 t->task_state_flags &= ~SAS_TASK_AT_INITIATOR;
634 spin_unlock_irqrestore(&t->task_state_lock, flags);618 spin_unlock_irqrestore(&t->task_state_lock, flags);
635 switch (t->task_proto) {619 switch (t->task_proto) {
636 case SATA_PROTO:620 case SAS_PROTOCOL_SATA:
637 case SAS_PROTO_STP:621 case SAS_PROTOCOL_STP:
638 asd_unbuild_ata_ascb(a);622 asd_unbuild_ata_ascb(a);
639 break;623 break;
640 case SAS_PROTO_SMP:624 case SAS_PROTOCOL_SMP:
641 asd_unbuild_smp_ascb(a);625 asd_unbuild_smp_ascb(a);
642 break;626 break;
643 case SAS_PROTO_SSP:627 case SAS_PROTOCOL_SSP:
644 asd_unbuild_ssp_ascb(a);628 asd_unbuild_ssp_ascb(a);
645 default:629 default:
646 break;630 break;
drivers/scsi/aic94xx/aic94xx_tmf.c+6−6
@@ -372,21 +372,21 @@ int asd_abort_task(struct sas_task *task) · 371 unmodified lines
372 scb->header.opcode = ABORT_TASK;372 scb->header.opcode = ABORT_TASK;
373 373
374 switch (task->task_proto) {374 switch (task->task_proto) {
375 case SATA_PROTO:375 case SAS_PROTOCOL_SATA:
376 case SAS_PROTO_STP:376 case SAS_PROTOCOL_STP:
377 scb->abort_task.proto_conn_rate = (1 << 5); /* STP */377 scb->abort_task.proto_conn_rate = (1 << 5); /* STP */
378 break;378 break;
379 case SAS_PROTO_SSP:379 case SAS_PROTOCOL_SSP:
380 scb->abort_task.proto_conn_rate = (1 << 4); /* SSP */380 scb->abort_task.proto_conn_rate = (1 << 4); /* SSP */
381 scb->abort_task.proto_conn_rate |= task->dev->linkrate;381 scb->abort_task.proto_conn_rate |= task->dev->linkrate;
382 break;382 break;
383 case SAS_PROTO_SMP:383 case SAS_PROTOCOL_SMP:
384 break;384 break;
385 default:385 default:
386 break;386 break;
387 }387 }
388 388
389 if (task->task_proto == SAS_PROTO_SSP) {389 if (task->task_proto == SAS_PROTOCOL_SSP) {
390 scb->abort_task.ssp_frame.frame_type = SSP_TASK;390 scb->abort_task.ssp_frame.frame_type = SSP_TASK;
391 memcpy(scb->abort_task.ssp_frame.hashed_dest_addr,391 memcpy(scb->abort_task.ssp_frame.hashed_dest_addr,
392 task->dev->hashed_sas_addr, HASHED_SAS_ADDR_SIZE);392 task->dev->hashed_sas_addr, HASHED_SAS_ADDR_SIZE);
@@ -512,7 +512,7 @@ static int asd_initiate_ssp_tmf(struct domain_device *dev, u8 *lun, · 119 unmodified lines
512 int res = 1;512 int res = 1;
513 struct scb *scb;513 struct scb *scb;
514 514
515 if (!(dev->tproto & SAS_PROTO_SSP))515 if (!(dev->tproto & SAS_PROTOCOL_SSP))
516 return TMF_RESP_FUNC_ESUPP;516 return TMF_RESP_FUNC_ESUPP;
517 517
518 ascb = asd_ascb_alloc_list(asd_ha, &res, GFP_KERNEL);518 ascb = asd_ascb_alloc_list(asd_ha, &res, GFP_KERNEL);
drivers/scsi/arcmsr/arcmsr_hba.c+3−3
@@ -634,9 +634,9 @@ static void arcmsr_report_sense_info(struct CommandControlBlock *ccb) · 633 unmodified lines
634 pcmd->result = DID_OK << 16;634 pcmd->result = DID_OK << 16;
635 if (sensebuffer) {635 if (sensebuffer) {
636 int sense_data_length =636 int sense_data_length =
637 sizeof(struct SENSE_DATA) < sizeof(pcmd->sense_buffer)637 sizeof(struct SENSE_DATA) < SCSI_SENSE_BUFFERSIZE
638 ? sizeof(struct SENSE_DATA) : sizeof(pcmd->sense_buffer);638 ? sizeof(struct SENSE_DATA) : SCSI_SENSE_BUFFERSIZE;
639 memset(sensebuffer, 0, sizeof(pcmd->sense_buffer));639 memset(sensebuffer, 0, SCSI_SENSE_BUFFERSIZE);
640 memcpy(sensebuffer, ccb->arcmsr_cdb.SenseData, sense_data_length);640 memcpy(sensebuffer, ccb->arcmsr_cdb.SenseData, sense_data_length);
641 sensebuffer->ErrorCode = SCSI_SENSE_CURRENT_ERRORS;641 sensebuffer->ErrorCode = SCSI_SENSE_CURRENT_ERRORS;
642 sensebuffer->Valid = 1;642 sensebuffer->Valid = 1;
drivers/scsi/atari_NCR5380.c+12−12
@@ -511,9 +511,9 @@ static inline void initialize_SCp(Scsi_Cmnd *cmd) · 510 unmodified lines
511 * various queues are valid.511 * various queues are valid.
512 */512 */
513 513
514 if (cmd->use_sg) {514 if (scsi_bufflen(cmd)) {
515 cmd->SCp.buffer = (struct scatterlist *)cmd->request_buffer;515 cmd->SCp.buffer = scsi_sglist(cmd);
516 cmd->SCp.buffers_residual = cmd->use_sg - 1;516 cmd->SCp.buffers_residual = scsi_sg_count(cmd) - 1;
517 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);517 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
518 cmd->SCp.this_residual = cmd->SCp.buffer->length;518 cmd->SCp.this_residual = cmd->SCp.buffer->length;
519 /* ++roman: Try to merge some scatter-buffers if they are at519 /* ++roman: Try to merge some scatter-buffers if they are at
@@ -523,8 +523,8 @@ static inline void initialize_SCp(Scsi_Cmnd *cmd) · 3 unmodified lines
523 } else {523 } else {
524 cmd->SCp.buffer = NULL;524 cmd->SCp.buffer = NULL;
525 cmd->SCp.buffers_residual = 0;525 cmd->SCp.buffers_residual = 0;
526 cmd->SCp.ptr = (char *)cmd->request_buffer;526 cmd->SCp.ptr = NULL;
527 cmd->SCp.this_residual = cmd->request_bufflen;527 cmd->SCp.this_residual = 0;
528 }528 }
529}529}
530 530
@@ -936,21 +936,21 @@ static int NCR5380_queue_command(Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *)) · 405 unmodified lines
936 }936 }
937# endif937# endif
938# ifdef NCR5380_STAT_LIMIT938# ifdef NCR5380_STAT_LIMIT
939 if (cmd->request_bufflen > NCR5380_STAT_LIMIT)939 if (scsi_bufflen(cmd) > NCR5380_STAT_LIMIT)
940# endif940# endif
941 switch (cmd->cmnd[0]) {941 switch (cmd->cmnd[0]) {
942 case WRITE:942 case WRITE:
943 case WRITE_6:943 case WRITE_6:
944 case WRITE_10:944 case WRITE_10:
945 hostdata->time_write[cmd->device->id] -= (jiffies - hostdata->timebase);945 hostdata->time_write[cmd->device->id] -= (jiffies - hostdata->timebase);
946 hostdata->bytes_write[cmd->device->id] += cmd->request_bufflen;946 hostdata->bytes_write[cmd->device->id] += scsi_bufflen(cmd);
947 hostdata->pendingw++;947 hostdata->pendingw++;
948 break;948 break;
949 case READ:949 case READ:
950 case READ_6:950 case READ_6:
951 case READ_10:951 case READ_10:
952 hostdata->time_read[cmd->device->id] -= (jiffies - hostdata->timebase);952 hostdata->time_read[cmd->device->id] -= (jiffies - hostdata->timebase);
953 hostdata->bytes_read[cmd->device->id] += cmd->request_bufflen;953 hostdata->bytes_read[cmd->device->id] += scsi_bufflen(cmd);
954 hostdata->pendingr++;954 hostdata->pendingr++;
955 break;955 break;
956 }956 }
@@ -1352,21 +1352,21 @@ static irqreturn_t NCR5380_intr(int irq, void *dev_id) · 395 unmodified lines
1352static void collect_stats(struct NCR5380_hostdata* hostdata, Scsi_Cmnd *cmd)1352static void collect_stats(struct NCR5380_hostdata* hostdata, Scsi_Cmnd *cmd)
1353{1353{
1354# ifdef NCR5380_STAT_LIMIT1354# ifdef NCR5380_STAT_LIMIT
1355 if (cmd->request_bufflen > NCR5380_STAT_LIMIT)1355 if (scsi_bufflen(cmd) > NCR5380_STAT_LIMIT)
1356# endif1356# endif
1357 switch (cmd->cmnd[0]) {1357 switch (cmd->cmnd[0]) {
1358 case WRITE:1358 case WRITE:
1359 case WRITE_6:1359 case WRITE_6:
1360 case WRITE_10:1360 case WRITE_10:
1361 hostdata->time_write[cmd->device->id] += (jiffies - hostdata->timebase);1361 hostdata->time_write[cmd->device->id] += (jiffies - hostdata->timebase);
1362 /*hostdata->bytes_write[cmd->device->id] += cmd->request_bufflen;*/1362 /*hostdata->bytes_write[cmd->device->id] += scsi_bufflen(cmd);*/
1363 hostdata->pendingw--;1363 hostdata->pendingw--;
1364 break;1364 break;
1365 case READ:1365 case READ:
1366 case READ_6:1366 case READ_6:
1367 case READ_10:1367 case READ_10:
1368 hostdata->time_read[cmd->device->id] += (jiffies - hostdata->timebase);1368 hostdata->time_read[cmd->device->id] += (jiffies - hostdata->timebase);
1369 /*hostdata->bytes_read[cmd->device->id] += cmd->request_bufflen;*/1369 /*hostdata->bytes_read[cmd->device->id] += scsi_bufflen(cmd);*/
1370 hostdata->pendingr--;1370 hostdata->pendingr--;
1371 break;1371 break;
1372 }1372 }
@@ -1868,7 +1868,7 @@ static int do_abort(struct Scsi_Host *host) · 495 unmodified lines
1868 * the target sees, so we just handshake.1868 * the target sees, so we just handshake.
1869 */1869 */
1870 1870
1871 while (!(tmp = NCR5380_read(STATUS_REG)) & SR_REQ)1871 while (!((tmp = NCR5380_read(STATUS_REG)) & SR_REQ))
1872 ;1872 ;
1873 1873
1874 NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(tmp));1874 NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(tmp));
drivers/scsi/atp870u.c+17−85
@@ -471,18 +471,8 @@ go_42: · 470 unmodified lines
471 /*471 /*
472 * Complete the command472 * Complete the command
473 */473 */
474 if (workreq->use_sg) {474 scsi_dma_unmap(workreq);
475 pci_unmap_sg(dev->pdev,475
476 (struct scatterlist *)workreq->request_buffer,
477 workreq->use_sg,
478 workreq->sc_data_direction);
479 } else if (workreq->request_bufflen &&
480 workreq->sc_data_direction != DMA_NONE) {
481 pci_unmap_single(dev->pdev,
482 workreq->SCp.dma_handle,
483 workreq->request_bufflen,
484 workreq->sc_data_direction);
485 }
486 spin_lock_irqsave(dev->host->host_lock, flags);476 spin_lock_irqsave(dev->host->host_lock, flags);
487 (*workreq->scsi_done) (workreq);477 (*workreq->scsi_done) (workreq);
488#ifdef ED_DBGP478#ifdef ED_DBGP
@@ -624,7 +614,7 @@ static int atp870u_queuecommand(struct scsi_cmnd * req_p, · 135 unmodified lines
624 614
625 c = scmd_channel(req_p);615 c = scmd_channel(req_p);
626 req_p->sense_buffer[0]=0;616 req_p->sense_buffer[0]=0;
627 req_p->resid = 0;617 scsi_set_resid(req_p, 0);
628 if (scmd_channel(req_p) > 1) {618 if (scmd_channel(req_p) > 1) {
629 req_p->result = 0x00040000;619 req_p->result = 0x00040000;
630 done(req_p);620 done(req_p);
@@ -722,7 +712,6 @@ static void send_s870(struct atp_unit *dev,unsigned char c) · 91 unmodified lines
722 unsigned short int tmpcip, w;712 unsigned short int tmpcip, w;
723 unsigned long l, bttl = 0;713 unsigned long l, bttl = 0;
724 unsigned int workport;714 unsigned int workport;
725 struct scatterlist *sgpnt;
726 unsigned long sg_count;715 unsigned long sg_count;
727 716
728 if (dev->in_snd[c] != 0) {717 if (dev->in_snd[c] != 0) {
@@ -793,6 +782,8 @@ oktosend: · 64 unmodified lines
793 }782 }
794 printk("\n");783 printk("\n");
795#endif 784#endif
785 l = scsi_bufflen(workreq);
786
796 if (dev->dev_id == ATP885_DEVID) {787 if (dev->dev_id == ATP885_DEVID) {
797 j = inb(dev->baseport + 0x29) & 0xfe;788 j = inb(dev->baseport + 0x29) & 0xfe;
798 outb(j, dev->baseport + 0x29);789 outb(j, dev->baseport + 0x29);
@@ -800,12 +791,11 @@ oktosend: · 1 unmodified line
800 }791 }
801 792
802 if (workreq->cmnd[0] == READ_CAPACITY) {793 if (workreq->cmnd[0] == READ_CAPACITY) {
803 if (workreq->request_bufflen > 8) {794 if (l > 8)
804 workreq->request_bufflen = 0x08;795 l = 8;
805 }
806 }796 }
807 if (workreq->cmnd[0] == 0x00) {797 if (workreq->cmnd[0] == 0x00) {
808 workreq->request_bufflen = 0;798 l = 0;
809 }799 }
810 800
811 tmport = workport + 0x1b;801 tmport = workport + 0x1b;
@@ -852,40 +842,8 @@ oktosend: · 40 unmodified lines
852#ifdef ED_DBGP 842#ifdef ED_DBGP
853 printk("dev->id[%d][%d].devsp = %2x\n",c,target_id,dev->id[c][target_id].devsp);843 printk("dev->id[%d][%d].devsp = %2x\n",c,target_id,dev->id[c][target_id].devsp);
854#endif844#endif
855 /*845
856 * Figure out the transfer size846 sg_count = scsi_dma_map(workreq);
857 */
858 if (workreq->use_sg) {
859#ifdef ED_DBGP
860 printk("Using SGL\n");
861#endif
862 l = 0;
863
864 sgpnt = (struct scatterlist *) workreq->request_buffer;
865 sg_count = pci_map_sg(dev->pdev, sgpnt, workreq->use_sg,
866 workreq->sc_data_direction);
867
868 for (i = 0; i < workreq->use_sg; i++) {
869 if (sgpnt[i].length == 0 || workreq->use_sg > ATP870U_SCATTER) {
870 panic("Foooooooood fight!");
871 }
872 l += sgpnt[i].length;
873 }
874#ifdef ED_DBGP
875 printk( "send_s870: workreq->use_sg %d, sg_count %d l %8ld\n", workreq->use_sg, sg_count, l);
876#endif
877 } else if(workreq->request_bufflen && workreq->sc_data_direction != PCI_DMA_NONE) {
878#ifdef ED_DBGP
879 printk("Not using SGL\n");
880#endif
881 workreq->SCp.dma_handle = pci_map_single(dev->pdev, workreq->request_buffer,
882 workreq->request_bufflen,
883 workreq->sc_data_direction);
884 l = workreq->request_bufflen;
885#ifdef ED_DBGP
886 printk( "send_s870: workreq->use_sg %d, l %8ld\n", workreq->use_sg, l);
887#endif
888 } else l = 0;
889 /*847 /*
890 * Write transfer size848 * Write transfer size
891 */849 */
@@ -938,16 +896,16 @@ oktosend: · 46 unmodified lines
938 * a linear chain.896 * a linear chain.
939 */897 */
940 898
941 if (workreq->use_sg) {899 if (l) {
942 sgpnt = (struct scatterlist *) workreq->request_buffer;900 struct scatterlist *sgpnt;
943 i = 0;901 i = 0;
944 for (j = 0; j < workreq->use_sg; j++) {902 scsi_for_each_sg(workreq, sgpnt, sg_count, j) {
945 bttl = sg_dma_address(&sgpnt[j]);903 bttl = sg_dma_address(sgpnt);
946 l=sg_dma_len(&sgpnt[j]);904 l=sg_dma_len(sgpnt);
947#ifdef ED_DBGP 905#ifdef ED_DBGP
948 printk("1. bttl %x, l %x\n",bttl, l);906 printk("1. bttl %x, l %x\n",bttl, l);
949#endif 907#endif
950 while (l > 0x10000) {908 while (l > 0x10000) {
951 (((u16 *) (prd))[i + 3]) = 0x0000;909 (((u16 *) (prd))[i + 3]) = 0x0000;
952 (((u16 *) (prd))[i + 2]) = 0x0000;910 (((u16 *) (prd))[i + 2]) = 0x0000;
953 (((u32 *) (prd))[i >> 1]) = cpu_to_le32(bttl);911 (((u32 *) (prd))[i >> 1]) = cpu_to_le32(bttl);
@@ -965,32 +923,6 @@ oktosend: · 11 unmodified lines
965 printk("prd %4x %4x %4x %4x\n",(((unsigned short int *)prd)[0]),(((unsigned short int *)prd)[1]),(((unsigned short int *)prd)[2]),(((unsigned short int *)prd)[3]));923 printk("prd %4x %4x %4x %4x\n",(((unsigned short int *)prd)[0]),(((unsigned short int *)prd)[1]),(((unsigned short int *)prd)[2]),(((unsigned short int *)prd)[3]));
966 printk("2. bttl %x, l %x\n",bttl, l);924 printk("2. bttl %x, l %x\n",bttl, l);
967#endif 925#endif
968 } else {
969 /*
970 * For a linear request write a chain of blocks
971 */
972 bttl = workreq->SCp.dma_handle;
973 l = workreq->request_bufflen;
974 i = 0;
975#ifdef ED_DBGP
976 printk("3. bttl %x, l %x\n",bttl, l);
977#endif
978 while (l > 0x10000) {
979 (((u16 *) (prd))[i + 3]) = 0x0000;
980 (((u16 *) (prd))[i + 2]) = 0x0000;
981 (((u32 *) (prd))[i >> 1]) = cpu_to_le32(bttl);
982 l -= 0x10000;
983 bttl += 0x10000;
984 i += 0x04;
985 }
986 (((u16 *) (prd))[i + 3]) = cpu_to_le16(0x8000);
987 (((u16 *) (prd))[i + 2]) = cpu_to_le16(l);
988 (((u32 *) (prd))[i >> 1]) = cpu_to_le32(bttl);
989#ifdef ED_DBGP
990 printk("prd %4x %4x %4x %4x\n",(((unsigned short int *)prd)[0]),(((unsigned short int *)prd)[1]),(((unsigned short int *)prd)[2]),(((unsigned short int *)prd)[3]));
991 printk("4. bttl %x, l %x\n",bttl, l);
992#endif
993
994 }926 }
995 tmpcip += 4;927 tmpcip += 4;
996#ifdef ED_DBGP 928#ifdef ED_DBGP
drivers/scsi/ch.c+109−106
@@ -21,6 +21,7 @@ · 20 unmodified lines
21#include <linux/compat.h>21#include <linux/compat.h>
22#include <linux/chio.h> /* here are all the ioctls */22#include <linux/chio.h> /* here are all the ioctls */
23#include <linux/mutex.h>23#include <linux/mutex.h>
24#include <linux/idr.h>
24 25
25#include <scsi/scsi.h>26#include <scsi/scsi.h>
26#include <scsi/scsi_cmnd.h>27#include <scsi/scsi_cmnd.h>
@@ -33,6 +34,7 @@ · 6 unmodified lines
33 34
34#define CH_DT_MAX 1635#define CH_DT_MAX 16
35#define CH_TYPES 836#define CH_TYPES 8
37#define CH_MAX_DEVS 128
36 38
37MODULE_DESCRIPTION("device driver for scsi media changer devices");39MODULE_DESCRIPTION("device driver for scsi media changer devices");
38MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org>");40MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org>");
@@ -88,17 +90,6 @@ static const char * vendor_labels[CH_TYPES-4] = { · 49 unmodified lines
88 90
89#define MAX_RETRIES 191#define MAX_RETRIES 1
90 92
91static int ch_probe(struct device *);
92static int ch_remove(struct device *);
93static int ch_open(struct inode * inode, struct file * filp);
94static int ch_release(struct inode * inode, struct file * filp);
95static int ch_ioctl(struct inode * inode, struct file * filp,
96 unsigned int cmd, unsigned long arg);
97#ifdef CONFIG_COMPAT
98static long ch_ioctl_compat(struct file * filp,
99 unsigned int cmd, unsigned long arg);
100#endif
101
102static struct class * ch_sysfs_class;93static struct class * ch_sysfs_class;
103 94
104typedef struct {95typedef struct {
@@ -114,30 +105,8 @@ typedef struct { · 9 unmodified lines
114 struct mutex lock;105 struct mutex lock;
115} scsi_changer;106} scsi_changer;
116 107
117static LIST_HEAD(ch_devlist);108static DEFINE_IDR(ch_index_idr);
118static DEFINE_SPINLOCK(ch_devlist_lock);109static DEFINE_SPINLOCK(ch_index_lock);
119static int ch_devcount;
120
121static struct scsi_driver ch_template =
122{
123 .owner = THIS_MODULE,
124 .gendrv = {
125 .name = "ch",
126 .probe = ch_probe,
127 .remove = ch_remove,
128 },
129};
130
131static const struct file_operations changer_fops =
132{
133 .owner = THIS_MODULE,
134 .open = ch_open,
135 .release = ch_release,
136 .ioctl = ch_ioctl,
137#ifdef CONFIG_COMPAT
138 .compat_ioctl = ch_ioctl_compat,
139#endif
140};
141 110
142static const struct {111static const struct {
143 unsigned char sense;112 unsigned char sense;
@@ -207,7 +176,7 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, · 63 unmodified lines
207{176{
208 int errno, retries = 0, timeout, result;177 int errno, retries = 0, timeout, result;
209 struct scsi_sense_hdr sshdr;178 struct scsi_sense_hdr sshdr;
210 179
211 timeout = (cmd[0] == INITIALIZE_ELEMENT_STATUS)180 timeout = (cmd[0] == INITIALIZE_ELEMENT_STATUS)
212 ? timeout_init : timeout_move;181 ? timeout_init : timeout_move;
213 182
@@ -245,7 +214,7 @@ static int · 31 unmodified lines
245ch_elem_to_typecode(scsi_changer *ch, u_int elem)214ch_elem_to_typecode(scsi_changer *ch, u_int elem)
246{215{
247 int i;216 int i;
248 217
249 for (i = 0; i < CH_TYPES; i++) {218 for (i = 0; i < CH_TYPES; i++) {
250 if (elem >= ch->firsts[i] &&219 if (elem >= ch->firsts[i] &&
251 elem < ch->firsts[i] +220 elem < ch->firsts[i] +
@@ -261,15 +230,15 @@ ch_read_element_status(scsi_changer *ch, u_int elem, char *data) · 9 unmodified lines
261 u_char cmd[12];230 u_char cmd[12];
262 u_char *buffer;231 u_char *buffer;
263 int result;232 int result;
264 233
265 buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);234 buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
266 if(!buffer)235 if(!buffer)
267 return -ENOMEM;236 return -ENOMEM;
268 237
269 retry:238 retry:
270 memset(cmd,0,sizeof(cmd));239 memset(cmd,0,sizeof(cmd));
271 cmd[0] = READ_ELEMENT_STATUS;240 cmd[0] = READ_ELEMENT_STATUS;
272 cmd[1] = (ch->device->lun << 5) | 241 cmd[1] = (ch->device->lun << 5) |
273 (ch->voltags ? 0x10 : 0) |242 (ch->voltags ? 0x10 : 0) |
274 ch_elem_to_typecode(ch,elem);243 ch_elem_to_typecode(ch,elem);
275 cmd[2] = (elem >> 8) & 0xff;244 cmd[2] = (elem >> 8) & 0xff;
@@ -296,7 +265,7 @@ ch_read_element_status(scsi_changer *ch, u_int elem, char *data) · 20 unmodified lines
296 return result;265 return result;
297}266}
298 267
299static int 268static int
300ch_init_elem(scsi_changer *ch)269ch_init_elem(scsi_changer *ch)
301{270{
302 int err;271 int err;
@@ -322,7 +291,7 @@ ch_readconfig(scsi_changer *ch) · 19 unmodified lines
322 buffer = kzalloc(512, GFP_KERNEL | GFP_DMA);291 buffer = kzalloc(512, GFP_KERNEL | GFP_DMA);
323 if (!buffer)292 if (!buffer)
324 return -ENOMEM;293 return -ENOMEM;
325 294
326 memset(cmd,0,sizeof(cmd));295 memset(cmd,0,sizeof(cmd));
327 cmd[0] = MODE_SENSE;296 cmd[0] = MODE_SENSE;
328 cmd[1] = ch->device->lun << 5;297 cmd[1] = ch->device->lun << 5;
@@ -365,7 +334,7 @@ ch_readconfig(scsi_changer *ch) · 36 unmodified lines
365 } else {334 } else {
366 vprintk("reading element address assigment page failed!\n");335 vprintk("reading element address assigment page failed!\n");
367 }336 }
368 337
369 /* vendor specific element types */338 /* vendor specific element types */
370 for (i = 0; i < 4; i++) {339 for (i = 0; i < 4; i++) {
371 if (0 == vendor_counts[i])340 if (0 == vendor_counts[i])
@@ -443,7 +412,7 @@ static int · 71 unmodified lines
443ch_position(scsi_changer *ch, u_int trans, u_int elem, int rotate)412ch_position(scsi_changer *ch, u_int trans, u_int elem, int rotate)
444{413{
445 u_char cmd[10];414 u_char cmd[10];
446 415
447 dprintk("position: 0x%x\n",elem);416 dprintk("position: 0x%x\n",elem);
448 if (0 == trans)417 if (0 == trans)
449 trans = ch->firsts[CHET_MT];418 trans = ch->firsts[CHET_MT];
@@ -462,7 +431,7 @@ static int · 12 unmodified lines
462ch_move(scsi_changer *ch, u_int trans, u_int src, u_int dest, int rotate)431ch_move(scsi_changer *ch, u_int trans, u_int src, u_int dest, int rotate)
463{432{
464 u_char cmd[12];433 u_char cmd[12];
465 434
466 dprintk("move: 0x%x => 0x%x\n",src,dest);435 dprintk("move: 0x%x => 0x%x\n",src,dest);
467 if (0 == trans)436 if (0 == trans)
468 trans = ch->firsts[CHET_MT];437 trans = ch->firsts[CHET_MT];
@@ -484,7 +453,7 @@ ch_exchange(scsi_changer *ch, u_int trans, u_int src, · 15 unmodified lines
484 u_int dest1, u_int dest2, int rotate1, int rotate2)453 u_int dest1, u_int dest2, int rotate1, int rotate2)
485{454{
486 u_char cmd[12];455 u_char cmd[12];
487 456
488 dprintk("exchange: 0x%x => 0x%x => 0x%x\n",457 dprintk("exchange: 0x%x => 0x%x => 0x%x\n",
489 src,dest1,dest2);458 src,dest1,dest2);
490 if (0 == trans)459 if (0 == trans)
@@ -501,7 +470,7 @@ ch_exchange(scsi_changer *ch, u_int trans, u_int src, · 10 unmodified lines
501 cmd[8] = (dest2 >> 8) & 0xff;470 cmd[8] = (dest2 >> 8) & 0xff;
502 cmd[9] = dest2 & 0xff;471 cmd[9] = dest2 & 0xff;
503 cmd[10] = (rotate1 ? 1 : 0) | (rotate2 ? 2 : 0);472 cmd[10] = (rotate1 ? 1 : 0) | (rotate2 ? 2 : 0);
504 473
505 return ch_do_scsi(ch, cmd, NULL,0, DMA_NONE);474 return ch_do_scsi(ch, cmd, NULL,0, DMA_NONE);
506}475}
507 476
@@ -539,14 +508,14 @@ ch_set_voltag(scsi_changer *ch, u_int elem, · 31 unmodified lines
539 elem, tag);508 elem, tag);
540 memset(cmd,0,sizeof(cmd));509 memset(cmd,0,sizeof(cmd));
541 cmd[0] = SEND_VOLUME_TAG;510 cmd[0] = SEND_VOLUME_TAG;
542 cmd[1] = (ch->device->lun << 5) | 511 cmd[1] = (ch->device->lun << 5) |
543 ch_elem_to_typecode(ch,elem);512 ch_elem_to_typecode(ch,elem);
544 cmd[2] = (elem >> 8) & 0xff;513 cmd[2] = (elem >> 8) & 0xff;
545 cmd[3] = elem & 0xff;514 cmd[3] = elem & 0xff;
546 cmd[5] = clear515 cmd[5] = clear
547 ? (alternate ? 0x0d : 0x0c)516 ? (alternate ? 0x0d : 0x0c)
548 : (alternate ? 0x0b : 0x0a);517 : (alternate ? 0x0b : 0x0a);
549 518
550 cmd[9] = 255;519 cmd[9] = 255;
551 520
552 memcpy(buffer,tag,32);521 memcpy(buffer,tag,32);
@@ -562,7 +531,7 @@ static int ch_gstatus(scsi_changer *ch, int type, unsigned char __user *dest) · 9 unmodified lines
562 int retval = 0;531 int retval = 0;
563 u_char data[16];532 u_char data[16];
564 unsigned int i;533 unsigned int i;
565 534
566 mutex_lock(&ch->lock);535 mutex_lock(&ch->lock);
567 for (i = 0; i < ch->counts[type]; i++) {536 for (i = 0; i < ch->counts[type]; i++) {
568 if (0 != ch_read_element_status537 if (0 != ch_read_element_status
@@ -599,20 +568,17 @@ ch_release(struct inode *inode, struct file *file) · 30 unmodified lines
599static int568static int
600ch_open(struct inode *inode, struct file *file)569ch_open(struct inode *inode, struct file *file)
601{570{
602 scsi_changer *tmp, *ch;571 scsi_changer *ch;
603 int minor = iminor(inode);572 int minor = iminor(inode);
604 573
605 spin_lock(&ch_devlist_lock);574 spin_lock(&ch_index_lock);
606 ch = NULL;575 ch = idr_find(&ch_index_idr, minor);
607 list_for_each_entry(tmp,&ch_devlist,list) {576
608 if (tmp->minor == minor)
609 ch = tmp;
610 }
611 if (NULL == ch || scsi_device_get(ch->device)) {577 if (NULL == ch || scsi_device_get(ch->device)) {
612 spin_unlock(&ch_devlist_lock);578 spin_unlock(&ch_index_lock);
613 return -ENXIO;579 return -ENXIO;
614 }580 }
615 spin_unlock(&ch_devlist_lock);581 spin_unlock(&ch_index_lock);
616 582
617 file->private_data = ch;583 file->private_data = ch;
618 return 0;584 return 0;
@@ -626,24 +592,24 @@ ch_checkrange(scsi_changer *ch, unsigned int type, unsigned int unit) · 7 unmodified lines
626 return 0;592 return 0;
627}593}
628 594
629static int ch_ioctl(struct inode * inode, struct file * file,595static long ch_ioctl(struct file *file,
630 unsigned int cmd, unsigned long arg)596 unsigned int cmd, unsigned long arg)
631{597{
632 scsi_changer *ch = file->private_data;598 scsi_changer *ch = file->private_data;
633 int retval;599 int retval;
634 void __user *argp = (void __user *)arg;600 void __user *argp = (void __user *)arg;
635 601
636 switch (cmd) {602 switch (cmd) {
637 case CHIOGPARAMS:603 case CHIOGPARAMS:
638 {604 {
639 struct changer_params params;605 struct changer_params params;
640 606
641 params.cp_curpicker = 0;607 params.cp_curpicker = 0;
642 params.cp_npickers = ch->counts[CHET_MT];608 params.cp_npickers = ch->counts[CHET_MT];
643 params.cp_nslots = ch->counts[CHET_ST];609 params.cp_nslots = ch->counts[CHET_ST];
644 params.cp_nportals = ch->counts[CHET_IE];610 params.cp_nportals = ch->counts[CHET_IE];
645 params.cp_ndrives = ch->counts[CHET_DT];611 params.cp_ndrives = ch->counts[CHET_DT];
646 612
647 if (copy_to_user(argp, &params, sizeof(params)))613 if (copy_to_user(argp, &params, sizeof(params)))
648 return -EFAULT;614 return -EFAULT;
649 return 0;615 return 0;
@@ -673,11 +639,11 @@ static int ch_ioctl(struct inode * inode, struct file * file, · 23 unmodified lines
673 return -EFAULT;639 return -EFAULT;
674 return 0;640 return 0;
675 }641 }
676 642
677 case CHIOPOSITION:643 case CHIOPOSITION:
678 {644 {
679 struct changer_position pos;645 struct changer_position pos;
680 646
681 if (copy_from_user(&pos, argp, sizeof (pos)))647 if (copy_from_user(&pos, argp, sizeof (pos)))
682 return -EFAULT;648 return -EFAULT;
683 649
@@ -692,7 +658,7 @@ static int ch_ioctl(struct inode * inode, struct file * file, · 8 unmodified lines
692 mutex_unlock(&ch->lock);658 mutex_unlock(&ch->lock);
693 return retval;659 return retval;
694 }660 }
695 661
696 case CHIOMOVE:662 case CHIOMOVE:
697 {663 {
698 struct changer_move mv;664 struct changer_move mv;
@@ -705,7 +671,7 @@ static int ch_ioctl(struct inode * inode, struct file * file, · 6 unmodified lines
705 dprintk("CHIOMOVE: invalid parameter\n");671 dprintk("CHIOMOVE: invalid parameter\n");
706 return -EBADSLT;672 return -EBADSLT;
707 }673 }
708 674
709 mutex_lock(&ch->lock);675 mutex_lock(&ch->lock);
710 retval = ch_move(ch,0,676 retval = ch_move(ch,0,
711 ch->firsts[mv.cm_fromtype] + mv.cm_fromunit,677 ch->firsts[mv.cm_fromtype] + mv.cm_fromunit,
@@ -718,7 +684,7 @@ static int ch_ioctl(struct inode * inode, struct file * file, · 6 unmodified lines
718 case CHIOEXCHANGE:684 case CHIOEXCHANGE:
719 {685 {
720 struct changer_exchange mv;686 struct changer_exchange mv;
721 687
722 if (copy_from_user(&mv, argp, sizeof (mv)))688 if (copy_from_user(&mv, argp, sizeof (mv)))
723 return -EFAULT;689 return -EFAULT;
724 690
@@ -728,7 +694,7 @@ static int ch_ioctl(struct inode * inode, struct file * file, · 3 unmodified lines
728 dprintk("CHIOEXCHANGE: invalid parameter\n");694 dprintk("CHIOEXCHANGE: invalid parameter\n");
729 return -EBADSLT;695 return -EBADSLT;
730 }696 }
731 697
732 mutex_lock(&ch->lock);698 mutex_lock(&ch->lock);
733 retval = ch_exchange699 retval = ch_exchange
734 (ch,0,700 (ch,0,
@@ -743,7 +709,7 @@ static int ch_ioctl(struct inode * inode, struct file * file, · 8 unmodified lines
743 case CHIOGSTATUS:709 case CHIOGSTATUS:
744 {710 {
745 struct changer_element_status ces;711 struct changer_element_status ces;
746 712
747 if (copy_from_user(&ces, argp, sizeof (ces)))713 if (copy_from_user(&ces, argp, sizeof (ces)))
748 return -EFAULT;714 return -EFAULT;
749 if (ces.ces_type < 0 || ces.ces_type >= CH_TYPES)715 if (ces.ces_type < 0 || ces.ces_type >= CH_TYPES)
@@ -759,19 +725,19 @@ static int ch_ioctl(struct inode * inode, struct file * file, · 9 unmodified lines
759 u_char *buffer;725 u_char *buffer;
760 unsigned int elem;726 unsigned int elem;
761 int result,i;727 int result,i;
762 728
763 if (copy_from_user(&cge, argp, sizeof (cge)))729 if (copy_from_user(&cge, argp, sizeof (cge)))
764 return -EFAULT;730 return -EFAULT;
765 731
766 if (0 != ch_checkrange(ch, cge.cge_type, cge.cge_unit))732 if (0 != ch_checkrange(ch, cge.cge_type, cge.cge_unit))
767 return -EINVAL;733 return -EINVAL;
768 elem = ch->firsts[cge.cge_type] + cge.cge_unit;734 elem = ch->firsts[cge.cge_type] + cge.cge_unit;
769 735
770 buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);736 buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
771 if (!buffer)737 if (!buffer)
772 return -ENOMEM;738 return -ENOMEM;
773 mutex_lock(&ch->lock);739 mutex_lock(&ch->lock);
774 740
775 voltag_retry:741 voltag_retry:
776 memset(cmd,0,sizeof(cmd));742 memset(cmd,0,sizeof(cmd));
777 cmd[0] = READ_ELEMENT_STATUS;743 cmd[0] = READ_ELEMENT_STATUS;
@@ -782,7 +748,7 @@ static int ch_ioctl(struct inode * inode, struct file * file, · 4 unmodified lines
782 cmd[3] = elem & 0xff;748 cmd[3] = elem & 0xff;
783 cmd[5] = 1;749 cmd[5] = 1;
784 cmd[9] = 255;750 cmd[9] = 255;
785 751
786 if (0 == (result = ch_do_scsi(ch, cmd, buffer, 256, DMA_FROM_DEVICE))) {752 if (0 == (result = ch_do_scsi(ch, cmd, buffer, 256, DMA_FROM_DEVICE))) {
787 cge.cge_status = buffer[18];753 cge.cge_status = buffer[18];
788 cge.cge_flags = 0;754 cge.cge_flags = 0;
@@ -822,7 +788,7 @@ static int ch_ioctl(struct inode * inode, struct file * file, · 33 unmodified lines
822 }788 }
823 kfree(buffer);789 kfree(buffer);
824 mutex_unlock(&ch->lock);790 mutex_unlock(&ch->lock);
825 791
826 if (copy_to_user(argp, &cge, sizeof (cge)))792 if (copy_to_user(argp, &cge, sizeof (cge)))
827 return -EFAULT;793 return -EFAULT;
828 return result;794 return result;
@@ -835,7 +801,7 @@ static int ch_ioctl(struct inode * inode, struct file * file, · 6 unmodified lines
835 mutex_unlock(&ch->lock);801 mutex_unlock(&ch->lock);
836 return retval;802 return retval;
837 }803 }
838 804
839 case CHIOSVOLTAG:805 case CHIOSVOLTAG:
840 {806 {
841 struct changer_set_voltag csv;807 struct changer_set_voltag csv;
@@ -876,7 +842,7 @@ static long ch_ioctl_compat(struct file * file, · 34 unmodified lines
876 unsigned int cmd, unsigned long arg)842 unsigned int cmd, unsigned long arg)
877{843{
878 scsi_changer *ch = file->private_data;844 scsi_changer *ch = file->private_data;
879 845
880 switch (cmd) {846 switch (cmd) {
881 case CHIOGPARAMS:847 case CHIOGPARAMS:
882 case CHIOGVPARAMS:848 case CHIOGVPARAMS:
@@ -887,13 +853,12 @@ static long ch_ioctl_compat(struct file * file, · 4 unmodified lines
887 case CHIOINITELEM:853 case CHIOINITELEM:
888 case CHIOSVOLTAG:854 case CHIOSVOLTAG:
889 /* compatible */855 /* compatible */
890 return ch_ioctl(NULL /* inode, unused */,856 return ch_ioctl(file, cmd, arg);
891 file, cmd, arg);
892 case CHIOGSTATUS32:857 case CHIOGSTATUS32:
893 {858 {
894 struct changer_element_status32 ces32;859 struct changer_element_status32 ces32;
895 unsigned char __user *data;860 unsigned char __user *data;
896 861
897 if (copy_from_user(&ces32, (void __user *)arg, sizeof (ces32)))862 if (copy_from_user(&ces32, (void __user *)arg, sizeof (ces32)))
898 return -EFAULT;863 return -EFAULT;
899 if (ces32.ces_type < 0 || ces32.ces_type >= CH_TYPES)864 if (ces32.ces_type < 0 || ces32.ces_type >= CH_TYPES)
@@ -915,63 +880,100 @@ static long ch_ioctl_compat(struct file * file, · 15 unmodified lines
915static int ch_probe(struct device *dev)880static int ch_probe(struct device *dev)
916{881{
917 struct scsi_device *sd = to_scsi_device(dev);882 struct scsi_device *sd = to_scsi_device(dev);
883 struct class_device *class_dev;
884 int minor, ret = -ENOMEM;
918 scsi_changer *ch;885 scsi_changer *ch;
919 886
920 if (sd->type != TYPE_MEDIUM_CHANGER)887 if (sd->type != TYPE_MEDIUM_CHANGER)
921 return -ENODEV;888 return -ENODEV;
922 889
923 ch = kzalloc(sizeof(*ch), GFP_KERNEL);890 ch = kzalloc(sizeof(*ch), GFP_KERNEL);
924 if (NULL == ch)891 if (NULL == ch)
925 return -ENOMEM;892 return -ENOMEM;
926 893
927 ch->minor = ch_devcount;894 if (!idr_pre_get(&ch_index_idr, GFP_KERNEL))
895 goto free_ch;
896
897 spin_lock(&ch_index_lock);
898 ret = idr_get_new(&ch_index_idr, ch, &minor);
899 spin_unlock(&ch_index_lock);
900
901 if (ret)
902 goto free_ch;
903
904 if (minor > CH_MAX_DEVS) {
905 ret = -ENODEV;
906 goto remove_idr;
907 }
908
909 ch->minor = minor;
928 sprintf(ch->name,"ch%d",ch->minor);910 sprintf(ch->name,"ch%d",ch->minor);
911
912 class_dev = class_device_create(ch_sysfs_class, NULL,
913 MKDEV(SCSI_CHANGER_MAJOR, ch->minor),
914 dev, "s%s", ch->name);
915 if (IS_ERR(class_dev)) {
916 printk(KERN_WARNING "ch%d: class_device_create failed\n",
917 ch->minor);
918 ret = PTR_ERR(class_dev);
919 goto remove_idr;
920 }
921
929 mutex_init(&ch->lock);922 mutex_init(&ch->lock);
930 ch->device = sd;923 ch->device = sd;
931 ch_readconfig(ch);924 ch_readconfig(ch);
932 if (init)925 if (init)
933 ch_init_elem(ch);926 ch_init_elem(ch);
934 927
935 class_device_create(ch_sysfs_class, NULL,928 dev_set_drvdata(dev, ch);
936 MKDEV(SCSI_CHANGER_MAJOR,ch->minor),
937 dev, "s%s", ch->name);
938
939 sdev_printk(KERN_INFO, sd, "Attached scsi changer %s\n", ch->name);929 sdev_printk(KERN_INFO, sd, "Attached scsi changer %s\n", ch->name);
940 930
941 spin_lock(&ch_devlist_lock);
942 list_add_tail(&ch->list,&ch_devlist);
943 ch_devcount++;
944 spin_unlock(&ch_devlist_lock);
945 return 0;931 return 0;
932remove_idr:
933 idr_remove(&ch_index_idr, minor);
934free_ch:
935 kfree(ch);
936 return ret;
946}937}
947 938
948static int ch_remove(struct device *dev)939static int ch_remove(struct device *dev)
949{940{
950 struct scsi_device *sd = to_scsi_device(dev);941 scsi_changer *ch = dev_get_drvdata(dev);
951 scsi_changer *tmp, *ch;
952 942
953 spin_lock(&ch_devlist_lock);943 spin_lock(&ch_index_lock);
954 ch = NULL;944 idr_remove(&ch_index_idr, ch->minor);
955 list_for_each_entry(tmp,&ch_devlist,list) {945 spin_unlock(&ch_index_lock);
956 if (tmp->device == sd)
957 ch = tmp;
958 }
959 BUG_ON(NULL == ch);
960 list_del(&ch->list);
961 spin_unlock(&ch_devlist_lock);
962 946
963 class_device_destroy(ch_sysfs_class,947 class_device_destroy(ch_sysfs_class,
964 MKDEV(SCSI_CHANGER_MAJOR,ch->minor));948 MKDEV(SCSI_CHANGER_MAJOR,ch->minor));
965 kfree(ch->dt);949 kfree(ch->dt);
966 kfree(ch);950 kfree(ch);
967 ch_devcount--;
968 return 0;951 return 0;
969}952}
970 953
954static struct scsi_driver ch_template = {
955 .owner = THIS_MODULE,
956 .gendrv = {
957 .name = "ch",
958 .probe = ch_probe,
959 .remove = ch_remove,
960 },
961};
962
963static const struct file_operations changer_fops = {
964 .owner = THIS_MODULE,
965 .open = ch_open,
966 .release = ch_release,
967 .unlocked_ioctl = ch_ioctl,
968#ifdef CONFIG_COMPAT
969 .compat_ioctl = ch_ioctl_compat,
970#endif
971};
972
971static int __init init_ch_module(void)973static int __init init_ch_module(void)
972{974{
973 int rc;975 int rc;
974 976
975 printk(KERN_INFO "SCSI Media Changer driver v" VERSION " \n");977 printk(KERN_INFO "SCSI Media Changer driver v" VERSION " \n");
976 ch_sysfs_class = class_create(THIS_MODULE, "scsi_changer");978 ch_sysfs_class = class_create(THIS_MODULE, "scsi_changer");
977 if (IS_ERR(ch_sysfs_class)) {979 if (IS_ERR(ch_sysfs_class)) {
@@ -996,11 +998,12 @@ static int __init init_ch_module(void) · 18 unmodified lines
996 return rc;998 return rc;
997}999}
998 1000
999static void __exit exit_ch_module(void) 1001static void __exit exit_ch_module(void)
1000{1002{
1001 scsi_unregister_driver(&ch_template.gendrv);1003 scsi_unregister_driver(&ch_template.gendrv);
1002 unregister_chrdev(SCSI_CHANGER_MAJOR, "ch");1004 unregister_chrdev(SCSI_CHANGER_MAJOR, "ch");
1003 class_destroy(ch_sysfs_class);1005 class_destroy(ch_sysfs_class);
1006 idr_destroy(&ch_index_idr);
1004}1007}
1005 1008
1006module_init(init_ch_module);1009module_init(init_ch_module);
drivers/scsi/constants.c+1−2
@@ -362,7 +362,6 @@ void scsi_print_command(struct scsi_cmnd *cmd) · 361 unmodified lines
362EXPORT_SYMBOL(scsi_print_command);362EXPORT_SYMBOL(scsi_print_command);
363 363
364/**364/**
365 *
366 * scsi_print_status - print scsi status description365 * scsi_print_status - print scsi status description
367 * @scsi_status: scsi status value366 * @scsi_status: scsi status value
368 *367 *
@@ -1369,7 +1368,7 @@ EXPORT_SYMBOL(scsi_print_sense); · 1000 unmodified lines
1369static const char * const hostbyte_table[]={1368static const char * const hostbyte_table[]={
1370"DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET",1369"DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET",
1371"DID_ABORT", "DID_PARITY", "DID_ERROR", "DID_RESET", "DID_BAD_INTR",1370"DID_ABORT", "DID_PARITY", "DID_ERROR", "DID_RESET", "DID_BAD_INTR",
1372"DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY"};1371"DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY", "DID_REQUEUE"};
1373#define NUM_HOSTBYTE_STRS ARRAY_SIZE(hostbyte_table)1372#define NUM_HOSTBYTE_STRS ARRAY_SIZE(hostbyte_table)
1374 1373
1375static const char * const driverbyte_table[]={1374static const char * const driverbyte_table[]={
drivers/scsi/dc395x.c+7−9
@@ -1629,8 +1629,7 @@ static u8 start_scsi(struct AdapterCtlBlk* acb, struct DeviceCtlBlk* dcb, · 1628 unmodified lines
1629 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, (dcb->target_lun << 5));1629 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, (dcb->target_lun << 5));
1630 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);1630 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);
1631 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);1631 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);
1632 DC395x_write8(acb, TRM_S1040_SCSI_FIFO,1632 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, SCSI_SENSE_BUFFERSIZE);
1633 sizeof(srb->cmd->sense_buffer));
1634 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);1633 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);
1635 } else {1634 } else {
1636 ptr = (u8 *)srb->cmd->cmnd;1635 ptr = (u8 *)srb->cmd->cmnd;
@@ -1915,8 +1914,7 @@ static void command_phase1(struct AdapterCtlBlk *acb, struct ScsiReqBlk *srb, · 278 unmodified lines
1915 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, (dcb->target_lun << 5));1914 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, (dcb->target_lun << 5));
1916 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);1915 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);
1917 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);1916 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);
1918 DC395x_write8(acb, TRM_S1040_SCSI_FIFO,1917 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, SCSI_SENSE_BUFFERSIZE);
1919 sizeof(srb->cmd->sense_buffer));
1920 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);1918 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);
1921 }1919 }
1922 srb->state |= SRB_COMMAND;1920 srb->state |= SRB_COMMAND;
@@ -3685,7 +3683,7 @@ static void request_sense(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, · 1762 unmodified lines
3685 srb->target_status = 0;3683 srb->target_status = 0;
3686 3684
3687 /* KG: Can this prevent crap sense data ? */3685 /* KG: Can this prevent crap sense data ? */
3688 memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer));3686 memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
3689 3687
3690 /* Save some data */3688 /* Save some data */
3691 srb->segment_x[DC395x_MAX_SG_LISTENTRY - 1].address =3689 srb->segment_x[DC395x_MAX_SG_LISTENTRY - 1].address =
@@ -3694,15 +3692,15 @@ static void request_sense(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, · 2 unmodified lines
3694 srb->segment_x[0].length;3692 srb->segment_x[0].length;
3695 srb->xferred = srb->total_xfer_length;3693 srb->xferred = srb->total_xfer_length;
3696 /* srb->segment_x : a one entry of S/G list table */3694 /* srb->segment_x : a one entry of S/G list table */
3697 srb->total_xfer_length = sizeof(cmd->sense_buffer);3695 srb->total_xfer_length = SCSI_SENSE_BUFFERSIZE;
3698 srb->segment_x[0].length = sizeof(cmd->sense_buffer);3696 srb->segment_x[0].length = SCSI_SENSE_BUFFERSIZE;
3699 /* Map sense buffer */3697 /* Map sense buffer */
3700 srb->segment_x[0].address =3698 srb->segment_x[0].address =
3701 pci_map_single(acb->dev, cmd->sense_buffer,3699 pci_map_single(acb->dev, cmd->sense_buffer,
3702 sizeof(cmd->sense_buffer), PCI_DMA_FROMDEVICE);3700 SCSI_SENSE_BUFFERSIZE, PCI_DMA_FROMDEVICE);
3703 dprintkdbg(DBG_SG, "request_sense: map buffer %p->%08x(%05x)\n",3701 dprintkdbg(DBG_SG, "request_sense: map buffer %p->%08x(%05x)\n",
3704 cmd->sense_buffer, srb->segment_x[0].address,3702 cmd->sense_buffer, srb->segment_x[0].address,
3705 sizeof(cmd->sense_buffer));3703 SCSI_SENSE_BUFFERSIZE);
3706 srb->sg_count = 1;3704 srb->sg_count = 1;
3707 srb->sg_index = 0;3705 srb->sg_index = 0;
3708 3706
drivers/scsi/dpt_i2o.c+2−3
@@ -2296,9 +2296,8 @@ static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd) · 2295 unmodified lines
2296 2296
2297 // copy over the request sense data if it was a check2297 // copy over the request sense data if it was a check
2298 // condition status2298 // condition status
2299 if(dev_status == 0x02 /*CHECK_CONDITION*/) {2299 if (dev_status == SAM_STAT_CHECK_CONDITION) {
2300 u32 len = sizeof(cmd->sense_buffer);2300 u32 len = min(SCSI_SENSE_BUFFERSIZE, 40);
2301 len = (len > 40) ? 40 : len;
2302 // Copy over the sense data2301 // Copy over the sense data
2303 memcpy_fromio(cmd->sense_buffer, (reply+28) , len);2302 memcpy_fromio(cmd->sense_buffer, (reply+28) , len);
2304 if(cmd->sense_buffer[0] == 0x70 /* class 7 */ && 2303 if(cmd->sense_buffer[0] == 0x70 /* class 7 */ &&
drivers/scsi/eata.c+2−2
@@ -1623,9 +1623,9 @@ static void map_dma(unsigned int i, struct hostdata *ha) · 1622 unmodified lines
1623 if (SCpnt->sense_buffer)1623 if (SCpnt->sense_buffer)
1624 cpp->sense_addr =1624 cpp->sense_addr =
1625 H2DEV(pci_map_single(ha->pdev, SCpnt->sense_buffer,1625 H2DEV(pci_map_single(ha->pdev, SCpnt->sense_buffer,
1626 sizeof SCpnt->sense_buffer, PCI_DMA_FROMDEVICE));1626 SCSI_SENSE_BUFFERSIZE, PCI_DMA_FROMDEVICE));
1627 1627
1628 cpp->sense_len = sizeof SCpnt->sense_buffer;1628 cpp->sense_len = SCSI_SENSE_BUFFERSIZE;
1629 1629
1630 count = scsi_dma_map(SCpnt);1630 count = scsi_dma_map(SCpnt);
1631 BUG_ON(count < 0);1631 BUG_ON(count < 0);
drivers/scsi/eata_pio.c+6−7
@@ -369,7 +369,6 @@ static int eata_pio_queue(struct scsi_cmnd *cmd, · 368 unmodified lines
369 cp = &hd->ccb[y];369 cp = &hd->ccb[y];
370 370
371 memset(cp, 0, sizeof(struct eata_ccb));371 memset(cp, 0, sizeof(struct eata_ccb));
372 memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer));
373 372
374 cp->status = USED; /* claim free slot */373 cp->status = USED; /* claim free slot */
375 374
@@ -385,7 +384,7 @@ static int eata_pio_queue(struct scsi_cmnd *cmd, · 9 unmodified lines
385 cp->DataIn = 0; /* Input mode */384 cp->DataIn = 0; /* Input mode */
386 385
387 cp->Interpret = (cmd->device->id == hd->hostid);386 cp->Interpret = (cmd->device->id == hd->hostid);
388 cp->cp_datalen = cpu_to_be32(cmd->request_bufflen);387 cp->cp_datalen = cpu_to_be32(scsi_bufflen(cmd));
389 cp->Auto_Req_Sen = 0;388 cp->Auto_Req_Sen = 0;
390 cp->cp_reqDMA = 0;389 cp->cp_reqDMA = 0;
391 cp->reqlen = 0;390 cp->reqlen = 0;
@@ -402,14 +401,14 @@ static int eata_pio_queue(struct scsi_cmnd *cmd, · 10 unmodified lines
402 cp->cmd = cmd;401 cp->cmd = cmd;
403 cmd->host_scribble = (char *) &hd->ccb[y];402 cmd->host_scribble = (char *) &hd->ccb[y];
404 403
405 if (cmd->use_sg == 0) {404 if (!scsi_bufflen(cmd)) {
406 cmd->SCp.buffers_residual = 1;405 cmd->SCp.buffers_residual = 1;
407 cmd->SCp.ptr = cmd->request_buffer;406 cmd->SCp.ptr = NULL;
408 cmd->SCp.this_residual = cmd->request_bufflen;407 cmd->SCp.this_residual = 0;
409 cmd->SCp.buffer = NULL;408 cmd->SCp.buffer = NULL;
410 } else {409 } else {
411 cmd->SCp.buffer = cmd->request_buffer;410 cmd->SCp.buffer = scsi_sglist(cmd);
412 cmd->SCp.buffers_residual = cmd->use_sg;411 cmd->SCp.buffers_residual = scsi_sg_count(cmd);
413 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);412 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
414 cmd->SCp.this_residual = cmd->SCp.buffer->length;413 cmd->SCp.this_residual = cmd->SCp.buffer->length;
415 }414 }
drivers/scsi/fd_mcs.c+11−25
@@ -1017,24 +1017,6 @@ static irqreturn_t fd_mcs_intr(int irq, void *dev_id) · 1016 unmodified lines
1017 printk(" ** IN DONE %d ** ", current_SC->SCp.have_data_in);1017 printk(" ** IN DONE %d ** ", current_SC->SCp.have_data_in);
1018#endif1018#endif
1019 1019
1020#if ERRORS_ONLY
1021 if (current_SC->cmnd[0] == REQUEST_SENSE && !current_SC->SCp.Status) {
1022 if ((unsigned char) (*((char *) current_SC->request_buffer + 2)) & 0x0f) {
1023 unsigned char key;
1024 unsigned char code;
1025 unsigned char qualifier;
1026
1027 key = (unsigned char) (*((char *) current_SC->request_buffer + 2)) & 0x0f;
1028 code = (unsigned char) (*((char *) current_SC->request_buffer + 12));
1029 qualifier = (unsigned char) (*((char *) current_SC->request_buffer + 13));
1030
1031 if (key != UNIT_ATTENTION && !(key == NOT_READY && code == 0x04 && (!qualifier || qualifier == 0x02 || qualifier == 0x01))
1032 && !(key == ILLEGAL_REQUEST && (code == 0x25 || code == 0x24 || !code)))
1033
1034 printk("fd_mcs: REQUEST SENSE " "Key = %x, Code = %x, Qualifier = %x\n", key, code, qualifier);
1035 }
1036 }
1037#endif
1038#if EVERY_ACCESS1020#if EVERY_ACCESS
1039 printk("BEFORE MY_DONE. . .");1021 printk("BEFORE MY_DONE. . .");
1040#endif1022#endif
@@ -1097,7 +1079,9 @@ static int fd_mcs_queue(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) · 56 unmodified lines
1097 panic("fd_mcs: fd_mcs_queue() NOT REENTRANT!\n");1079 panic("fd_mcs: fd_mcs_queue() NOT REENTRANT!\n");
1098 }1080 }
1099#if EVERY_ACCESS1081#if EVERY_ACCESS
1100 printk("queue: target = %d cmnd = 0x%02x pieces = %d size = %u\n", SCpnt->target, *(unsigned char *) SCpnt->cmnd, SCpnt->use_sg, SCpnt->request_bufflen);1082 printk("queue: target = %d cmnd = 0x%02x pieces = %d size = %u\n",
1083 SCpnt->target, *(unsigned char *) SCpnt->cmnd,
1084 scsi_sg_count(SCpnt), scsi_bufflen(SCpnt));
1101#endif1085#endif
1102 1086
1103 fd_mcs_make_bus_idle(shpnt);1087 fd_mcs_make_bus_idle(shpnt);
@@ -1107,14 +1091,14 @@ static int fd_mcs_queue(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) · 3 unmodified lines
1107 1091
1108 /* Initialize static data */1092 /* Initialize static data */
1109 1093
1110 if (current_SC->use_sg) {1094 if (scsi_bufflen(current_SC)) {
1111 current_SC->SCp.buffer = (struct scatterlist *) current_SC->request_buffer;1095 current_SC->SCp.buffer = scsi_sglist(current_SC);
1112 current_SC->SCp.ptr = sg_virt(current_SC->SCp.buffer);1096 current_SC->SCp.ptr = sg_virt(current_SC->SCp.buffer);
1113 current_SC->SCp.this_residual = current_SC->SCp.buffer->length;1097 current_SC->SCp.this_residual = current_SC->SCp.buffer->length;
1114 current_SC->SCp.buffers_residual = current_SC->use_sg - 1;1098 current_SC->SCp.buffers_residual = scsi_sg_count(current_SC) - 1;
1115 } else {1099 } else {
1116 current_SC->SCp.ptr = (char *) current_SC->request_buffer;1100 current_SC->SCp.ptr = NULL;
1117 current_SC->SCp.this_residual = current_SC->request_bufflen;1101 current_SC->SCp.this_residual = 0;
1118 current_SC->SCp.buffer = NULL;1102 current_SC->SCp.buffer = NULL;
1119 current_SC->SCp.buffers_residual = 0;1103 current_SC->SCp.buffers_residual = 0;
1120 }1104 }
@@ -1166,7 +1150,9 @@ static void fd_mcs_print_info(Scsi_Cmnd * SCpnt) · 45 unmodified lines
1166 break;1150 break;
1167 }1151 }
1168 1152
1169 printk("(%d), target = %d cmnd = 0x%02x pieces = %d size = %u\n", SCpnt->SCp.phase, SCpnt->device->id, *(unsigned char *) SCpnt->cmnd, SCpnt->use_sg, SCpnt->request_bufflen);1153 printk("(%d), target = %d cmnd = 0x%02x pieces = %d size = %u\n",
1154 SCpnt->SCp.phase, SCpnt->device->id, *(unsigned char *) SCpnt->cmnd,
1155 scsi_sg_count(SCpnt), scsi_bufflen(SCpnt));
1170 printk("sent_command = %d, have_data_in = %d, timeout = %d\n", SCpnt->SCp.sent_command, SCpnt->SCp.have_data_in, SCpnt->timeout);1156 printk("sent_command = %d, have_data_in = %d, timeout = %d\n", SCpnt->SCp.sent_command, SCpnt->SCp.have_data_in, SCpnt->timeout);
1171#if DEBUG_RACE1157#if DEBUG_RACE
1172 printk("in_interrupt_flag = %d\n", in_interrupt_flag);1158 printk("in_interrupt_flag = %d\n", in_interrupt_flag);
drivers/scsi/gdth.c+10−12
@@ -141,7 +141,7 @@ · 140 unmodified lines
141static void gdth_delay(int milliseconds);141static void gdth_delay(int milliseconds);
142static void gdth_eval_mapping(ulong32 size, ulong32 *cyls, int *heads, int *secs);142static void gdth_eval_mapping(ulong32 size, ulong32 *cyls, int *heads, int *secs);
143static irqreturn_t gdth_interrupt(int irq, void *dev_id);143static irqreturn_t gdth_interrupt(int irq, void *dev_id);
144static irqreturn_t __gdth_interrupt(gdth_ha_str *ha, int irq,144static irqreturn_t __gdth_interrupt(gdth_ha_str *ha,
145 int gdth_from_wait, int* pIndex);145 int gdth_from_wait, int* pIndex);
146static int gdth_sync_event(gdth_ha_str *ha, int service, unchar index,146static int gdth_sync_event(gdth_ha_str *ha, int service, unchar index,
147 Scsi_Cmnd *scp);147 Scsi_Cmnd *scp);
@@ -165,7 +165,6 @@ static int gdth_internal_cache_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp); · 17 unmodified lines
165static int gdth_fill_cache_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp, ushort hdrive);165static int gdth_fill_cache_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp, ushort hdrive);
166 166
167static void gdth_enable_int(gdth_ha_str *ha);167static void gdth_enable_int(gdth_ha_str *ha);
168static unchar gdth_get_status(gdth_ha_str *ha, int irq);
169static int gdth_test_busy(gdth_ha_str *ha);168static int gdth_test_busy(gdth_ha_str *ha);
170static int gdth_get_cmd_index(gdth_ha_str *ha);169static int gdth_get_cmd_index(gdth_ha_str *ha);
171static void gdth_release_event(gdth_ha_str *ha);170static void gdth_release_event(gdth_ha_str *ha);
@@ -1334,14 +1333,12 @@ static void __init gdth_enable_int(gdth_ha_str *ha) · 1162 unmodified lines
1334}1333}
1335 1334
1336/* return IStatus if interrupt was from this card else 0 */1335/* return IStatus if interrupt was from this card else 0 */
1337static unchar gdth_get_status(gdth_ha_str *ha, int irq)1336static unchar gdth_get_status(gdth_ha_str *ha)
1338{1337{
1339 unchar IStatus = 0;1338 unchar IStatus = 0;
1340 1339
1341 TRACE(("gdth_get_status() irq %d ctr_count %d\n", irq, gdth_ctr_count));1340 TRACE(("gdth_get_status() irq %d ctr_count %d\n", ha->irq, gdth_ctr_count));
1342 1341
1343 if (ha->irq != (unchar)irq) /* check IRQ */
1344 return false;
1345 if (ha->type == GDT_EISA)1342 if (ha->type == GDT_EISA)
1346 IStatus = inb((ushort)ha->bmic + EDOORREG);1343 IStatus = inb((ushort)ha->bmic + EDOORREG);
1347 else if (ha->type == GDT_ISA)1344 else if (ha->type == GDT_ISA)
@@ -1523,7 +1520,7 @@ static int gdth_wait(gdth_ha_str *ha, int index, ulong32 time) · 175 unmodified lines
1523 return 1; /* no wait required */1520 return 1; /* no wait required */
1524 1521
1525 do {1522 do {
1526 __gdth_interrupt(ha, (int)ha->irq, true, &wait_index);1523 __gdth_interrupt(ha, true, &wait_index);
1527 if (wait_index == index) {1524 if (wait_index == index) {
1528 answer_found = TRUE;1525 answer_found = TRUE;
1529 break;1526 break;
@@ -3036,7 +3033,7 @@ static void gdth_clear_events(void) · 1506 unmodified lines
3036 3033
3037/* SCSI interface functions */3034/* SCSI interface functions */
3038 3035
3039static irqreturn_t __gdth_interrupt(gdth_ha_str *ha, int irq,3036static irqreturn_t __gdth_interrupt(gdth_ha_str *ha,
3040 int gdth_from_wait, int* pIndex)3037 int gdth_from_wait, int* pIndex)
3041{3038{
3042 gdt6m_dpram_str __iomem *dp6m_ptr = NULL;3039 gdt6m_dpram_str __iomem *dp6m_ptr = NULL;
@@ -3054,7 +3051,7 @@ static irqreturn_t __gdth_interrupt(gdth_ha_str *ha, int irq, · 11 unmodified lines
3054 int act_int_coal = 0; 3051 int act_int_coal = 0;
3055#endif3052#endif
3056 3053
3057 TRACE(("gdth_interrupt() IRQ %d\n",irq));3054 TRACE(("gdth_interrupt() IRQ %d\n", ha->irq));
3058 3055
3059 /* if polling and not from gdth_wait() -> return */3056 /* if polling and not from gdth_wait() -> return */
3060 if (gdth_polling) {3057 if (gdth_polling) {
@@ -3067,7 +3064,8 @@ static irqreturn_t __gdth_interrupt(gdth_ha_str *ha, int irq, · 6 unmodified lines
3067 spin_lock_irqsave(&ha->smp_lock, flags);3064 spin_lock_irqsave(&ha->smp_lock, flags);
3068 3065
3069 /* search controller */3066 /* search controller */
3070 if (0 == (IStatus = gdth_get_status(ha, irq))) {3067 IStatus = gdth_get_status(ha);
3068 if (IStatus == 0) {
3071 /* spurious interrupt */3069 /* spurious interrupt */
3072 if (!gdth_polling)3070 if (!gdth_polling)
3073 spin_unlock_irqrestore(&ha->smp_lock, flags);3071 spin_unlock_irqrestore(&ha->smp_lock, flags);
@@ -3294,9 +3292,9 @@ static irqreturn_t __gdth_interrupt(gdth_ha_str *ha, int irq, · 220 unmodified lines
3294 3292
3295static irqreturn_t gdth_interrupt(int irq, void *dev_id)3293static irqreturn_t gdth_interrupt(int irq, void *dev_id)
3296{3294{
3297 gdth_ha_str *ha = (gdth_ha_str *)dev_id;3295 gdth_ha_str *ha = dev_id;
3298 3296
3299 return __gdth_interrupt(ha, irq, false, NULL);3297 return __gdth_interrupt(ha, false, NULL);
3300}3298}
3301 3299
3302static int gdth_sync_event(gdth_ha_str *ha, int service, unchar index,3300static int gdth_sync_event(gdth_ha_str *ha, int service, unchar index,
drivers/scsi/hosts.c+1−3
@@ -54,8 +54,7 @@ static struct class shost_class = { · 53 unmodified lines
54};54};
55 55
56/**56/**
57 * scsi_host_set_state - Take the given host through the host57 * scsi_host_set_state - Take the given host through the host state model.
58 * state model.
59 * @shost: scsi host to change the state of.58 * @shost: scsi host to change the state of.
60 * @state: state to change to.59 * @state: state to change to.
61 *60 *
@@ -440,7 +439,6 @@ static int __scsi_host_match(struct class_device *cdev, void *data) · 378 unmodified lines
440 439
441/**440/**
442 * scsi_host_lookup - get a reference to a Scsi_Host by host no441 * scsi_host_lookup - get a reference to a Scsi_Host by host no
443 *
444 * @hostnum: host number to locate442 * @hostnum: host number to locate
445 *443 *
446 * Return value:444 * Return value:
drivers/scsi/hptiop.c+464−129
@@ -1,5 +1,5 @@
1/*1/*
2 * HighPoint RR3xxx controller driver for Linux2 * HighPoint RR3xxx/4xxx controller driver for Linux
3 * Copyright (C) 2006-2007 HighPoint Technologies, Inc. All Rights Reserved.3 * Copyright (C) 2006-2007 HighPoint Technologies, Inc. All Rights Reserved.
4 *4 *
5 * This program is free software; you can redistribute it and/or modify5 * This program is free software; you can redistribute it and/or modify
@@ -38,80 +38,84 @@ · 32 unmodified lines
38#include "hptiop.h"38#include "hptiop.h"
39 39
40MODULE_AUTHOR("HighPoint Technologies, Inc.");40MODULE_AUTHOR("HighPoint Technologies, Inc.");
41MODULE_DESCRIPTION("HighPoint RocketRAID 3xxx SATA Controller Driver");41MODULE_DESCRIPTION("HighPoint RocketRAID 3xxx/4xxx Controller Driver");
42 42
43static char driver_name[] = "hptiop";43static char driver_name[] = "hptiop";
44static const char driver_name_long[] = "RocketRAID 3xxx SATA Controller driver";44static const char driver_name_long[] = "RocketRAID 3xxx/4xxx Controller driver";
45static const char driver_ver[] = "v1.2 (070830)";45static const char driver_ver[] = "v1.3 (071203)";
46 46
47static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 tag);47static int iop_send_sync_msg(struct hptiop_hba *hba, u32 msg, u32 millisec);
48static void hptiop_iop_request_callback(struct hptiop_hba *hba, u32 tag);48static void hptiop_finish_scsi_req(struct hptiop_hba *hba, u32 tag,
49 struct hpt_iop_request_scsi_command *req);
50static void hptiop_host_request_callback_itl(struct hptiop_hba *hba, u32 tag);
51static void hptiop_iop_request_callback_itl(struct hptiop_hba *hba, u32 tag);
49static void hptiop_message_callback(struct hptiop_hba *hba, u32 msg);52static void hptiop_message_callback(struct hptiop_hba *hba, u32 msg);
50 53
51static inline void hptiop_pci_posting_flush(struct hpt_iopmu __iomem *iop)54static int iop_wait_ready_itl(struct hptiop_hba *hba, u32 millisec)
52{
53 readl(&iop->outbound_intstatus);
54}
55
56static int iop_wait_ready(struct hpt_iopmu __iomem *iop, u32 millisec)
57{55{
58 u32 req = 0;56 u32 req = 0;
59 int i;57 int i;
60 58
61 for (i = 0; i < millisec; i++) {59 for (i = 0; i < millisec; i++) {
62 req = readl(&iop->inbound_queue);60 req = readl(&hba->u.itl.iop->inbound_queue);
63 if (req != IOPMU_QUEUE_EMPTY)61 if (req != IOPMU_QUEUE_EMPTY)
64 break;62 break;
65 msleep(1);63 msleep(1);
66 }64 }
67 65
68 if (req != IOPMU_QUEUE_EMPTY) {66 if (req != IOPMU_QUEUE_EMPTY) {
69 writel(req, &iop->outbound_queue);67 writel(req, &hba->u.itl.iop->outbound_queue);
70 hptiop_pci_posting_flush(iop);68 readl(&hba->u.itl.iop->outbound_intstatus);
71 return 0;69 return 0;
72 }70 }
73 71
74 return -1;72 return -1;
75}73}
76 74
77static void hptiop_request_callback(struct hptiop_hba *hba, u32 tag)75static int iop_wait_ready_mv(struct hptiop_hba *hba, u32 millisec)
76{
77 return iop_send_sync_msg(hba, IOPMU_INBOUND_MSG0_NOP, millisec);
78}
79
80static void hptiop_request_callback_itl(struct hptiop_hba *hba, u32 tag)
78{81{
79 if (tag & IOPMU_QUEUE_ADDR_HOST_BIT)82 if (tag & IOPMU_QUEUE_ADDR_HOST_BIT)
80 return hptiop_host_request_callback(hba,83 hptiop_host_request_callback_itl(hba,
81 tag & ~IOPMU_QUEUE_ADDR_HOST_BIT);84 tag & ~IOPMU_QUEUE_ADDR_HOST_BIT);
82 else85 else
83 return hptiop_iop_request_callback(hba, tag);86 hptiop_iop_request_callback_itl(hba, tag);
84}87}
85 88
86static inline void hptiop_drain_outbound_queue(struct hptiop_hba *hba)89static void hptiop_drain_outbound_queue_itl(struct hptiop_hba *hba)
87{90{
88 u32 req;91 u32 req;
89 92
90 while ((req = readl(&hba->iop->outbound_queue)) != IOPMU_QUEUE_EMPTY) {93 while ((req = readl(&hba->u.itl.iop->outbound_queue)) !=
94 IOPMU_QUEUE_EMPTY) {
91 95
92 if (req & IOPMU_QUEUE_MASK_HOST_BITS)96 if (req & IOPMU_QUEUE_MASK_HOST_BITS)
93 hptiop_request_callback(hba, req);97 hptiop_request_callback_itl(hba, req);
94 else {98 else {
95 struct hpt_iop_request_header __iomem * p;99 struct hpt_iop_request_header __iomem * p;
96 100
97 p = (struct hpt_iop_request_header __iomem *)101 p = (struct hpt_iop_request_header __iomem *)
98 ((char __iomem *)hba->iop + req);102 ((char __iomem *)hba->u.itl.iop + req);
99 103
100 if (readl(&p->flags) & IOP_REQUEST_FLAG_SYNC_REQUEST) {104 if (readl(&p->flags) & IOP_REQUEST_FLAG_SYNC_REQUEST) {
101 if (readl(&p->context))105 if (readl(&p->context))
102 hptiop_request_callback(hba, req);106 hptiop_request_callback_itl(hba, req);
103 else107 else
104 writel(1, &p->context);108 writel(1, &p->context);
105 }109 }
106 else110 else
107 hptiop_request_callback(hba, req);111 hptiop_request_callback_itl(hba, req);
108 }112 }
109 }113 }
110}114}
111 115
112static int __iop_intr(struct hptiop_hba *hba)116static int iop_intr_itl(struct hptiop_hba *hba)
113{117{
114 struct hpt_iopmu __iomem *iop = hba->iop;118 struct hpt_iopmu_itl __iomem *iop = hba->u.itl.iop;
115 u32 status;119 u32 status;
116 int ret = 0;120 int ret = 0;
117 121
@@ -119,6 +123,7 @@ static int __iop_intr(struct hptiop_hba *hba) · 1 unmodified line
119 123
120 if (status & IOPMU_OUTBOUND_INT_MSG0) {124 if (status & IOPMU_OUTBOUND_INT_MSG0) {
121 u32 msg = readl(&iop->outbound_msgaddr0);125 u32 msg = readl(&iop->outbound_msgaddr0);
126
122 dprintk("received outbound msg %x\n", msg);127 dprintk("received outbound msg %x\n", msg);
123 writel(IOPMU_OUTBOUND_INT_MSG0, &iop->outbound_intstatus);128 writel(IOPMU_OUTBOUND_INT_MSG0, &iop->outbound_intstatus);
124 hptiop_message_callback(hba, msg);129 hptiop_message_callback(hba, msg);
@@ -126,31 +131,115 @@ static int __iop_intr(struct hptiop_hba *hba) · 1 unmodified line
126 }131 }
127 132
128 if (status & IOPMU_OUTBOUND_INT_POSTQUEUE) {133 if (status & IOPMU_OUTBOUND_INT_POSTQUEUE) {
129 hptiop_drain_outbound_queue(hba);134 hptiop_drain_outbound_queue_itl(hba);
135 ret = 1;
136 }
137
138 return ret;
139}
140
141static u64 mv_outbound_read(struct hpt_iopmu_mv __iomem *mu)
142{
143 u32 outbound_tail = readl(&mu->outbound_tail);
144 u32 outbound_head = readl(&mu->outbound_head);
145
146 if (outbound_tail != outbound_head) {
147 u64 p;
148
149 memcpy_fromio(&p, &mu->outbound_q[mu->outbound_tail], 8);
150 outbound_tail++;
151
152 if (outbound_tail == MVIOP_QUEUE_LEN)
153 outbound_tail = 0;
154 writel(outbound_tail, &mu->outbound_tail);
155 return p;
156 } else
157 return 0;
158}
159
160static void mv_inbound_write(u64 p, struct hptiop_hba *hba)
161{
162 u32 inbound_head = readl(&hba->u.mv.mu->inbound_head);
163 u32 head = inbound_head + 1;
164
165 if (head == MVIOP_QUEUE_LEN)
166 head = 0;
167
168 memcpy_toio(&hba->u.mv.mu->inbound_q[inbound_head], &p, 8);
169 writel(head, &hba->u.mv.mu->inbound_head);
170 writel(MVIOP_MU_INBOUND_INT_POSTQUEUE,
171 &hba->u.mv.regs->inbound_doorbell);
172}
173
174static void hptiop_request_callback_mv(struct hptiop_hba *hba, u64 tag)
175{
176 u32 req_type = (tag >> 5) & 0x7;
177 struct hpt_iop_request_scsi_command *req;
178
179 dprintk("hptiop_request_callback_mv: tag=%llx\n", tag);
180
181 BUG_ON((tag & MVIOP_MU_QUEUE_REQUEST_RETURN_CONTEXT) == 0);
182
183 switch (req_type) {
184 case IOP_REQUEST_TYPE_GET_CONFIG:
185 case IOP_REQUEST_TYPE_SET_CONFIG:
186 hba->msg_done = 1;
187 break;
188
189 case IOP_REQUEST_TYPE_SCSI_COMMAND:
190 req = hba->reqs[tag >> 8].req_virt;
191 if (likely(tag & MVIOP_MU_QUEUE_REQUEST_RESULT_BIT))
192 req->header.result = cpu_to_le32(IOP_RESULT_SUCCESS);
193
194 hptiop_finish_scsi_req(hba, tag>>8, req);
195 break;
196
197 default:
198 break;
199 }
200}
201
202static int iop_intr_mv(struct hptiop_hba *hba)
203{
204 u32 status;
205 int ret = 0;
206
207 status = readl(&hba->u.mv.regs->outbound_doorbell);
208 writel(~status, &hba->u.mv.regs->outbound_doorbell);
209
210 if (status & MVIOP_MU_OUTBOUND_INT_MSG) {
211 u32 msg;
212 msg = readl(&hba->u.mv.mu->outbound_msg);
213 dprintk("received outbound msg %x\n", msg);
214 hptiop_message_callback(hba, msg);
215 ret = 1;
216 }
217
218 if (status & MVIOP_MU_OUTBOUND_INT_POSTQUEUE) {
219 u64 tag;
220
221 while ((tag = mv_outbound_read(hba->u.mv.mu)))
222 hptiop_request_callback_mv(hba, tag);
130 ret = 1;223 ret = 1;
131 }224 }
132 225
133 return ret;226 return ret;
134}227}
135 228
136static int iop_send_sync_request(struct hptiop_hba *hba,229static int iop_send_sync_request_itl(struct hptiop_hba *hba,
137 void __iomem *_req, u32 millisec)230 void __iomem *_req, u32 millisec)
138{231{
139 struct hpt_iop_request_header __iomem *req = _req;232 struct hpt_iop_request_header __iomem *req = _req;
140 u32 i;233 u32 i;
141 234
142 writel(readl(&req->flags) | IOP_REQUEST_FLAG_SYNC_REQUEST,235 writel(readl(&req->flags) | IOP_REQUEST_FLAG_SYNC_REQUEST, &req->flags);
143 &req->flags);
144
145 writel(0, &req->context);236 writel(0, &req->context);
146 237 writel((unsigned long)req - (unsigned long)hba->u.itl.iop,
147 writel((unsigned long)req - (unsigned long)hba->iop,238 &hba->u.itl.iop->inbound_queue);
148 &hba->iop->inbound_queue);239 readl(&hba->u.itl.iop->outbound_intstatus);
149
150 hptiop_pci_posting_flush(hba->iop);
151 240
152 for (i = 0; i < millisec; i++) {241 for (i = 0; i < millisec; i++) {
153 __iop_intr(hba);242 iop_intr_itl(hba);
154 if (readl(&req->context))243 if (readl(&req->context))
155 return 0;244 return 0;
156 msleep(1);245 msleep(1);
@@ -159,19 +248,49 @@ static int iop_send_sync_request(struct hptiop_hba *hba, · 2 unmodified lines
159 return -1;248 return -1;
160}249}
161 250
162static int iop_send_sync_msg(struct hptiop_hba *hba, u32 msg, u32 millisec)251static int iop_send_sync_request_mv(struct hptiop_hba *hba,
252 u32 size_bits, u32 millisec)
163{253{
254 struct hpt_iop_request_header *reqhdr = hba->u.mv.internal_req;
164 u32 i;255 u32 i;
165 256
166 hba->msg_done = 0;257 hba->msg_done = 0;
258 reqhdr->flags |= cpu_to_le32(IOP_REQUEST_FLAG_SYNC_REQUEST);
259 mv_inbound_write(hba->u.mv.internal_req_phy |
260 MVIOP_MU_QUEUE_ADDR_HOST_BIT | size_bits, hba);
261
262 for (i = 0; i < millisec; i++) {
263 iop_intr_mv(hba);
264 if (hba->msg_done)
265 return 0;
266 msleep(1);
267 }
268 return -1;
269}
270
271static void hptiop_post_msg_itl(struct hptiop_hba *hba, u32 msg)
272{
273 writel(msg, &hba->u.itl.iop->inbound_msgaddr0);
274 readl(&hba->u.itl.iop->outbound_intstatus);
275}
276
277static void hptiop_post_msg_mv(struct hptiop_hba *hba, u32 msg)
278{
279 writel(msg, &hba->u.mv.mu->inbound_msg);
280 writel(MVIOP_MU_INBOUND_INT_MSG, &hba->u.mv.regs->inbound_doorbell);
281 readl(&hba->u.mv.regs->inbound_doorbell);
282}
167 283
168 writel(msg, &hba->iop->inbound_msgaddr0);284static int iop_send_sync_msg(struct hptiop_hba *hba, u32 msg, u32 millisec)
285{
286 u32 i;
169 287
170 hptiop_pci_posting_flush(hba->iop);288 hba->msg_done = 0;
289 hba->ops->post_msg(hba, msg);
171 290
172 for (i = 0; i < millisec; i++) {291 for (i = 0; i < millisec; i++) {
173 spin_lock_irq(hba->host->host_lock);292 spin_lock_irq(hba->host->host_lock);
174 __iop_intr(hba);293 hba->ops->iop_intr(hba);
175 spin_unlock_irq(hba->host->host_lock);294 spin_unlock_irq(hba->host->host_lock);
176 if (hba->msg_done)295 if (hba->msg_done)
177 break;296 break;
@@ -181,46 +300,67 @@ static int iop_send_sync_msg(struct hptiop_hba *hba, u32 msg, u32 millisec) · 3 unmodified lines
181 return hba->msg_done? 0 : -1;300 return hba->msg_done? 0 : -1;
182}301}
183 302
184static int iop_get_config(struct hptiop_hba *hba,303static int iop_get_config_itl(struct hptiop_hba *hba,
185 struct hpt_iop_request_get_config *config)304 struct hpt_iop_request_get_config *config)
186{305{
187 u32 req32;306 u32 req32;
188 struct hpt_iop_request_get_config __iomem *req;307 struct hpt_iop_request_get_config __iomem *req;
189 308
190 req32 = readl(&hba->iop->inbound_queue);309 req32 = readl(&hba->u.itl.iop->inbound_queue);
191 if (req32 == IOPMU_QUEUE_EMPTY)310 if (req32 == IOPMU_QUEUE_EMPTY)
192 return -1;311 return -1;
193 312
194 req = (struct hpt_iop_request_get_config __iomem *)313 req = (struct hpt_iop_request_get_config __iomem *)
195 ((unsigned long)hba->iop + req32);314 ((unsigned long)hba->u.itl.iop + req32);
196 315
197 writel(0, &req->header.flags);316 writel(0, &req->header.flags);
198 writel(IOP_REQUEST_TYPE_GET_CONFIG, &req->header.type);317 writel(IOP_REQUEST_TYPE_GET_CONFIG, &req->header.type);
199 writel(sizeof(struct hpt_iop_request_get_config), &req->header.size);318 writel(sizeof(struct hpt_iop_request_get_config), &req->header.size);
200 writel(IOP_RESULT_PENDING, &req->header.result);319 writel(IOP_RESULT_PENDING, &req->header.result);
201 320
202 if (iop_send_sync_request(hba, req, 20000)) {321 if (iop_send_sync_request_itl(hba, req, 20000)) {
203 dprintk("Get config send cmd failed\n");322 dprintk("Get config send cmd failed\n");
204 return -1;323 return -1;
205 }324 }
206 325
207 memcpy_fromio(config, req, sizeof(*config));326 memcpy_fromio(config, req, sizeof(*config));
208 writel(req32, &hba->iop->outbound_queue);327 writel(req32, &hba->u.itl.iop->outbound_queue);
328 return 0;
329}
330
331static int iop_get_config_mv(struct hptiop_hba *hba,
332 struct hpt_iop_request_get_config *config)
333{
334 struct hpt_iop_request_get_config *req = hba->u.mv.internal_req;
335
336 req->header.flags = cpu_to_le32(IOP_REQUEST_FLAG_OUTPUT_CONTEXT);
337 req->header.type = cpu_to_le32(IOP_REQUEST_TYPE_GET_CONFIG);
338 req->header.size =
339 cpu_to_le32(sizeof(struct hpt_iop_request_get_config));
340 req->header.result = cpu_to_le32(IOP_RESULT_PENDING);
341 req->header.context = cpu_to_le64(IOP_REQUEST_TYPE_GET_CONFIG<<5);
342
343 if (iop_send_sync_request_mv(hba, 0, 20000)) {
344 dprintk("Get config send cmd failed\n");
345 return -1;
346 }
347
348 memcpy(config, req, sizeof(struct hpt_iop_request_get_config));
209 return 0;349 return 0;
210}350}
211 351
212static int iop_set_config(struct hptiop_hba *hba,352static int iop_set_config_itl(struct hptiop_hba *hba,
213 struct hpt_iop_request_set_config *config)353 struct hpt_iop_request_set_config *config)
214{354{
215 u32 req32;355 u32 req32;
216 struct hpt_iop_request_set_config __iomem *req;356 struct hpt_iop_request_set_config __iomem *req;
217 357
218 req32 = readl(&hba->iop->inbound_queue);358 req32 = readl(&hba->u.itl.iop->inbound_queue);
219 if (req32 == IOPMU_QUEUE_EMPTY)359 if (req32 == IOPMU_QUEUE_EMPTY)
220 return -1;360 return -1;
221 361
222 req = (struct hpt_iop_request_set_config __iomem *)362 req = (struct hpt_iop_request_set_config __iomem *)
223 ((unsigned long)hba->iop + req32);363 ((unsigned long)hba->u.itl.iop + req32);
224 364
225 memcpy_toio((u8 __iomem *)req + sizeof(struct hpt_iop_request_header),365 memcpy_toio((u8 __iomem *)req + sizeof(struct hpt_iop_request_header),
226 (u8 *)config + sizeof(struct hpt_iop_request_header),366 (u8 *)config + sizeof(struct hpt_iop_request_header),
@@ -232,22 +372,52 @@ static int iop_set_config(struct hptiop_hba *hba, · 5 unmodified lines
232 writel(sizeof(struct hpt_iop_request_set_config), &req->header.size);372 writel(sizeof(struct hpt_iop_request_set_config), &req->header.size);
233 writel(IOP_RESULT_PENDING, &req->header.result);373 writel(IOP_RESULT_PENDING, &req->header.result);
234 374
235 if (iop_send_sync_request(hba, req, 20000)) {375 if (iop_send_sync_request_itl(hba, req, 20000)) {
236 dprintk("Set config send cmd failed\n");376 dprintk("Set config send cmd failed\n");
237 return -1;377 return -1;
238 }378 }
239 379
240 writel(req32, &hba->iop->outbound_queue);380 writel(req32, &hba->u.itl.iop->outbound_queue);
241 return 0;381 return 0;
242}382}
243 383
244static int hptiop_initialize_iop(struct hptiop_hba *hba)384static int iop_set_config_mv(struct hptiop_hba *hba,
385 struct hpt_iop_request_set_config *config)
245{386{
246 struct hpt_iopmu __iomem *iop = hba->iop;387 struct hpt_iop_request_set_config *req = hba->u.mv.internal_req;
247 388
248 /* enable interrupts */389 memcpy(req, config, sizeof(struct hpt_iop_request_set_config));
390 req->header.flags = cpu_to_le32(IOP_REQUEST_FLAG_OUTPUT_CONTEXT);
391 req->header.type = cpu_to_le32(IOP_REQUEST_TYPE_SET_CONFIG);
392 req->header.size =
393 cpu_to_le32(sizeof(struct hpt_iop_request_set_config));
394 req->header.result = cpu_to_le32(IOP_RESULT_PENDING);
395 req->header.context = cpu_to_le64(IOP_REQUEST_TYPE_SET_CONFIG<<5);
396
397 if (iop_send_sync_request_mv(hba, 0, 20000)) {
398 dprintk("Set config send cmd failed\n");
399 return -1;
400 }
401
402 return 0;
403}
404
405static void hptiop_enable_intr_itl(struct hptiop_hba *hba)
406{
249 writel(~(IOPMU_OUTBOUND_INT_POSTQUEUE | IOPMU_OUTBOUND_INT_MSG0),407 writel(~(IOPMU_OUTBOUND_INT_POSTQUEUE | IOPMU_OUTBOUND_INT_MSG0),
250 &iop->outbound_intmask);408 &hba->u.itl.iop->outbound_intmask);
409}
410
411static void hptiop_enable_intr_mv(struct hptiop_hba *hba)
412{
413 writel(MVIOP_MU_OUTBOUND_INT_POSTQUEUE | MVIOP_MU_OUTBOUND_INT_MSG,
414 &hba->u.mv.regs->outbound_intmask);
415}
416
417static int hptiop_initialize_iop(struct hptiop_hba *hba)
418{
419 /* enable interrupts */
420 hba->ops->enable_intr(hba);
251 421
252 hba->initialized = 1;422 hba->initialized = 1;
253 423
@@ -261,37 +431,74 @@ static int hptiop_initialize_iop(struct hptiop_hba *hba) · 7 unmodified lines
261 return 0;431 return 0;
262}432}
263 433
264static int hptiop_map_pci_bar(struct hptiop_hba *hba)434static void __iomem *hptiop_map_pci_bar(struct hptiop_hba *hba, int index)
265{435{
266 u32 mem_base_phy, length;436 u32 mem_base_phy, length;
267 void __iomem *mem_base_virt;437 void __iomem *mem_base_virt;
438
268 struct pci_dev *pcidev = hba->pcidev;439 struct pci_dev *pcidev = hba->pcidev;
269 440
270 if (!(pci_resource_flags(pcidev, 0) & IORESOURCE_MEM)) {441
442 if (!(pci_resource_flags(pcidev, index) & IORESOURCE_MEM)) {
271 printk(KERN_ERR "scsi%d: pci resource invalid\n",443 printk(KERN_ERR "scsi%d: pci resource invalid\n",
272 hba->host->host_no);444 hba->host->host_no);
273 return -1;445 return 0;
274 }446 }
275 447
276 mem_base_phy = pci_resource_start(pcidev, 0);448 mem_base_phy = pci_resource_start(pcidev, index);
277 length = pci_resource_len(pcidev, 0);449 length = pci_resource_len(pcidev, index);
278 mem_base_virt = ioremap(mem_base_phy, length);450 mem_base_virt = ioremap(mem_base_phy, length);
279 451
280 if (!mem_base_virt) {452 if (!mem_base_virt) {
281 printk(KERN_ERR "scsi%d: Fail to ioremap memory space\n",453 printk(KERN_ERR "scsi%d: Fail to ioremap memory space\n",
282 hba->host->host_no);454 hba->host->host_no);
455 return 0;
456 }
457 return mem_base_virt;
458}
459
460static int hptiop_map_pci_bar_itl(struct hptiop_hba *hba)
461{
462 hba->u.itl.iop = hptiop_map_pci_bar(hba, 0);
463 if (hba->u.itl.iop)
464 return 0;
465 else
466 return -1;
467}
468
469static void hptiop_unmap_pci_bar_itl(struct hptiop_hba *hba)
470{
471 iounmap(hba->u.itl.iop);
472}
473
474static int hptiop_map_pci_bar_mv(struct hptiop_hba *hba)
475{
476 hba->u.mv.regs = hptiop_map_pci_bar(hba, 0);
477 if (hba->u.mv.regs == 0)
478 return -1;
479
480 hba->u.mv.mu = hptiop_map_pci_bar(hba, 2);
481 if (hba->u.mv.mu == 0) {
482 iounmap(hba->u.mv.regs);
283 return -1;483 return -1;
284 }484 }
285 485
286 hba->iop = mem_base_virt;
287 dprintk("hptiop_map_pci_bar: iop=%p\n", hba->iop);
288 return 0;486 return 0;
289}487}
290 488
489static void hptiop_unmap_pci_bar_mv(struct hptiop_hba *hba)
490{
491 iounmap(hba->u.mv.regs);
492 iounmap(hba->u.mv.mu);
493}
494
291static void hptiop_message_callback(struct hptiop_hba *hba, u32 msg)495static void hptiop_message_callback(struct hptiop_hba *hba, u32 msg)
292{496{
293 dprintk("iop message 0x%x\n", msg);497 dprintk("iop message 0x%x\n", msg);
294 498
499 if (msg == IOPMU_INBOUND_MSG0_NOP)
500 hba->msg_done = 1;
501
295 if (!hba->initialized)502 if (!hba->initialized)
296 return;503 return;
297 504
@@ -303,7 +510,7 @@ static void hptiop_message_callback(struct hptiop_hba *hba, u32 msg) · 5 unmodified lines
303 hba->msg_done = 1;510 hba->msg_done = 1;
304}511}
305 512
306static inline struct hptiop_request *get_req(struct hptiop_hba *hba)513static struct hptiop_request *get_req(struct hptiop_hba *hba)
307{514{
308 struct hptiop_request *ret;515 struct hptiop_request *ret;
309 516
@@ -316,30 +523,19 @@ static inline struct hptiop_request *get_req(struct hptiop_hba *hba) · 6 unmodified lines
316 return ret;523 return ret;
317}524}
318 525
319static inline void free_req(struct hptiop_hba *hba, struct hptiop_request *req)526static void free_req(struct hptiop_hba *hba, struct hptiop_request *req)
320{527{
321 dprintk("free_req(%d, %p)\n", req->index, req);528 dprintk("free_req(%d, %p)\n", req->index, req);
322 req->next = hba->req_list;529 req->next = hba->req_list;
323 hba->req_list = req;530 hba->req_list = req;
324}531}
325 532
326static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 _tag)533static void hptiop_finish_scsi_req(struct hptiop_hba *hba, u32 tag,
534 struct hpt_iop_request_scsi_command *req)
327{535{
328 struct hpt_iop_request_scsi_command *req;
329 struct scsi_cmnd *scp;536 struct scsi_cmnd *scp;
330 u32 tag;
331
332 if (hba->iopintf_v2) {
333 tag = _tag & ~ IOPMU_QUEUE_REQUEST_RESULT_BIT;
334 req = hba->reqs[tag].req_virt;
335 if (likely(_tag & IOPMU_QUEUE_REQUEST_RESULT_BIT))
336 req->header.result = IOP_RESULT_SUCCESS;
337 } else {
338 tag = _tag;
339 req = hba->reqs[tag].req_virt;
340 }
341 537
342 dprintk("hptiop_host_request_callback: req=%p, type=%d, "538 dprintk("hptiop_finish_scsi_req: req=%p, type=%d, "
343 "result=%d, context=0x%x tag=%d\n",539 "result=%d, context=0x%x tag=%d\n",
344 req, req->header.type, req->header.result,540 req, req->header.type, req->header.result,
345 req->header.context, tag);541 req->header.context, tag);
@@ -354,6 +550,8 @@ static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 _tag) · 8 unmodified lines
354 550
355 switch (le32_to_cpu(req->header.result)) {551 switch (le32_to_cpu(req->header.result)) {
356 case IOP_RESULT_SUCCESS:552 case IOP_RESULT_SUCCESS:
553 scsi_set_resid(scp,
554 scsi_bufflen(scp) - le32_to_cpu(req->dataxfer_length));
357 scp->result = (DID_OK<<16);555 scp->result = (DID_OK<<16);
358 break;556 break;
359 case IOP_RESULT_BAD_TARGET:557 case IOP_RESULT_BAD_TARGET:
@@ -371,12 +569,12 @@ static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 _tag) · 11 unmodified lines
371 case IOP_RESULT_INVALID_REQUEST:569 case IOP_RESULT_INVALID_REQUEST:
372 scp->result = (DID_ABORT<<16);570 scp->result = (DID_ABORT<<16);
373 break;571 break;
374 case IOP_RESULT_MODE_SENSE_CHECK_CONDITION:572 case IOP_RESULT_CHECK_CONDITION:
573 scsi_set_resid(scp,
574 scsi_bufflen(scp) - le32_to_cpu(req->dataxfer_length));
375 scp->result = SAM_STAT_CHECK_CONDITION;575 scp->result = SAM_STAT_CHECK_CONDITION;
376 memset(&scp->sense_buffer,
377 0, sizeof(scp->sense_buffer));
378 memcpy(&scp->sense_buffer, &req->sg_list,576 memcpy(&scp->sense_buffer, &req->sg_list,
379 min(sizeof(scp->sense_buffer),577 min_t(size_t, SCSI_SENSE_BUFFERSIZE,
380 le32_to_cpu(req->dataxfer_length)));578 le32_to_cpu(req->dataxfer_length)));
381 break;579 break;
382 580
@@ -391,15 +589,33 @@ static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 _tag) · 8 unmodified lines
391 free_req(hba, &hba->reqs[tag]);589 free_req(hba, &hba->reqs[tag]);
392}590}
393 591
394void hptiop_iop_request_callback(struct hptiop_hba *hba, u32 tag)592static void hptiop_host_request_callback_itl(struct hptiop_hba *hba, u32 _tag)
593{
594 struct hpt_iop_request_scsi_command *req;
595 u32 tag;
596
597 if (hba->iopintf_v2) {
598 tag = _tag & ~IOPMU_QUEUE_REQUEST_RESULT_BIT;
599 req = hba->reqs[tag].req_virt;
600 if (likely(_tag & IOPMU_QUEUE_REQUEST_RESULT_BIT))
601 req->header.result = cpu_to_le32(IOP_RESULT_SUCCESS);
602 } else {
603 tag = _tag;
604 req = hba->reqs[tag].req_virt;
605 }
606
607 hptiop_finish_scsi_req(hba, tag, req);
608}
609
610void hptiop_iop_request_callback_itl(struct hptiop_hba *hba, u32 tag)
395{611{
396 struct hpt_iop_request_header __iomem *req;612 struct hpt_iop_request_header __iomem *req;
397 struct hpt_iop_request_ioctl_command __iomem *p;613 struct hpt_iop_request_ioctl_command __iomem *p;
398 struct hpt_ioctl_k *arg;614 struct hpt_ioctl_k *arg;
399 615
400 req = (struct hpt_iop_request_header __iomem *)616 req = (struct hpt_iop_request_header __iomem *)
401 ((unsigned long)hba->iop + tag);617 ((unsigned long)hba->u.itl.iop + tag);
402 dprintk("hptiop_iop_request_callback: req=%p, type=%d, "618 dprintk("hptiop_iop_request_callback_itl: req=%p, type=%d, "
403 "result=%d, context=0x%x tag=%d\n",619 "result=%d, context=0x%x tag=%d\n",
404 req, readl(&req->type), readl(&req->result),620 req, readl(&req->type), readl(&req->result),
405 readl(&req->context), tag);621 readl(&req->context), tag);
@@ -427,7 +643,7 @@ void hptiop_iop_request_callback(struct hptiop_hba *hba, u32 tag) · 21 unmodified lines
427 arg->result = HPT_IOCTL_RESULT_FAILED;643 arg->result = HPT_IOCTL_RESULT_FAILED;
428 644
429 arg->done(arg);645 arg->done(arg);
430 writel(tag, &hba->iop->outbound_queue);646 writel(tag, &hba->u.itl.iop->outbound_queue);
431}647}
432 648
433static irqreturn_t hptiop_intr(int irq, void *dev_id)649static irqreturn_t hptiop_intr(int irq, void *dev_id)
@@ -437,7 +653,7 @@ static irqreturn_t hptiop_intr(int irq, void *dev_id) · 3 unmodified lines
437 unsigned long flags;653 unsigned long flags;
438 654
439 spin_lock_irqsave(hba->host->host_lock, flags);655 spin_lock_irqsave(hba->host->host_lock, flags);
440 handled = __iop_intr(hba);656 handled = hba->ops->iop_intr(hba);
441 spin_unlock_irqrestore(hba->host->host_lock, flags);657 spin_unlock_irqrestore(hba->host->host_lock, flags);
442 658
443 return handled;659 return handled;
@@ -469,6 +685,57 @@ static int hptiop_buildsgl(struct scsi_cmnd *scp, struct hpt_iopsg *psg) · 25 unmodified lines
469 return HPT_SCP(scp)->sgcnt;685 return HPT_SCP(scp)->sgcnt;
470}686}
471 687
688static void hptiop_post_req_itl(struct hptiop_hba *hba,
689 struct hptiop_request *_req)
690{
691 struct hpt_iop_request_header *reqhdr = _req->req_virt;
692
693 reqhdr->context = cpu_to_le32(IOPMU_QUEUE_ADDR_HOST_BIT |
694 (u32)_req->index);
695 reqhdr->context_hi32 = 0;
696
697 if (hba->iopintf_v2) {
698 u32 size, size_bits;
699
700 size = le32_to_cpu(reqhdr->size);
701 if (size < 256)
702 size_bits = IOPMU_QUEUE_REQUEST_SIZE_BIT;
703 else if (size < 512)
704 size_bits = IOPMU_QUEUE_ADDR_HOST_BIT;
705 else
706 size_bits = IOPMU_QUEUE_REQUEST_SIZE_BIT |
707 IOPMU_QUEUE_ADDR_HOST_BIT;
708 writel(_req->req_shifted_phy | size_bits,
709 &hba->u.itl.iop->inbound_queue);
710 } else
711 writel(_req->req_shifted_phy | IOPMU_QUEUE_ADDR_HOST_BIT,
712 &hba->u.itl.iop->inbound_queue);
713}
714
715static void hptiop_post_req_mv(struct hptiop_hba *hba,
716 struct hptiop_request *_req)
717{
718 struct hpt_iop_request_header *reqhdr = _req->req_virt;
719 u32 size, size_bit;
720
721 reqhdr->context = cpu_to_le32(_req->index<<8 |
722 IOP_REQUEST_TYPE_SCSI_COMMAND<<5);
723 reqhdr->context_hi32 = 0;
724 size = le32_to_cpu(reqhdr->size);
725
726 if (size <= 256)
727 size_bit = 0;
728 else if (size <= 256*2)
729 size_bit = 1;
730 else if (size <= 256*3)
731 size_bit = 2;
732 else
733 size_bit = 3;
734
735 mv_inbound_write((_req->req_shifted_phy << 5) |
736 MVIOP_MU_QUEUE_ADDR_HOST_BIT | size_bit, hba);
737}
738
472static int hptiop_queuecommand(struct scsi_cmnd *scp,739static int hptiop_queuecommand(struct scsi_cmnd *scp,
473 void (*done)(struct scsi_cmnd *))740 void (*done)(struct scsi_cmnd *))
474{741{
@@ -518,9 +785,6 @@ static int hptiop_queuecommand(struct scsi_cmnd *scp, · 43 unmodified lines
518 req->header.flags = cpu_to_le32(IOP_REQUEST_FLAG_OUTPUT_CONTEXT);785 req->header.flags = cpu_to_le32(IOP_REQUEST_FLAG_OUTPUT_CONTEXT);
519 req->header.type = cpu_to_le32(IOP_REQUEST_TYPE_SCSI_COMMAND);786 req->header.type = cpu_to_le32(IOP_REQUEST_TYPE_SCSI_COMMAND);
520 req->header.result = cpu_to_le32(IOP_RESULT_PENDING);787 req->header.result = cpu_to_le32(IOP_RESULT_PENDING);
521 req->header.context = cpu_to_le32(IOPMU_QUEUE_ADDR_HOST_BIT |
522 (u32)_req->index);
523 req->header.context_hi32 = 0;
524 req->dataxfer_length = cpu_to_le32(scsi_bufflen(scp));788 req->dataxfer_length = cpu_to_le32(scsi_bufflen(scp));
525 req->channel = scp->device->channel;789 req->channel = scp->device->channel;
526 req->target = scp->device->id;790 req->target = scp->device->id;
@@ -531,21 +795,7 @@ static int hptiop_queuecommand(struct scsi_cmnd *scp, · 4 unmodified lines
531 + sg_count * sizeof(struct hpt_iopsg));795 + sg_count * sizeof(struct hpt_iopsg));
532 796
533 memcpy(req->cdb, scp->cmnd, sizeof(req->cdb));797 memcpy(req->cdb, scp->cmnd, sizeof(req->cdb));
534 798 hba->ops->post_req(hba, _req);
535 if (hba->iopintf_v2) {
536 u32 size_bits;
537 if (req->header.size < 256)
538 size_bits = IOPMU_QUEUE_REQUEST_SIZE_BIT;
539 else if (req->header.size < 512)
540 size_bits = IOPMU_QUEUE_ADDR_HOST_BIT;
541 else
542 size_bits = IOPMU_QUEUE_REQUEST_SIZE_BIT |
543 IOPMU_QUEUE_ADDR_HOST_BIT;
544 writel(_req->req_shifted_phy | size_bits, &hba->iop->inbound_queue);
545 } else
546 writel(_req->req_shifted_phy | IOPMU_QUEUE_ADDR_HOST_BIT,
547 &hba->iop->inbound_queue);
548
549 return 0;799 return 0;
550 800
551cmd_done:801cmd_done:
@@ -563,9 +813,7 @@ static int hptiop_reset_hba(struct hptiop_hba *hba) · 11 unmodified lines
563{813{
564 if (atomic_xchg(&hba->resetting, 1) == 0) {814 if (atomic_xchg(&hba->resetting, 1) == 0) {
565 atomic_inc(&hba->reset_count);815 atomic_inc(&hba->reset_count);
566 writel(IOPMU_INBOUND_MSG0_RESET,816 hba->ops->post_msg(hba, IOPMU_INBOUND_MSG0_RESET);
567 &hba->iop->inbound_msgaddr0);
568 hptiop_pci_posting_flush(hba->iop);
569 }817 }
570 818
571 wait_event_timeout(hba->reset_wq,819 wait_event_timeout(hba->reset_wq,
@@ -601,8 +849,10 @@ static int hptiop_reset(struct scsi_cmnd *scp) · 29 unmodified lines
601static int hptiop_adjust_disk_queue_depth(struct scsi_device *sdev,849static int hptiop_adjust_disk_queue_depth(struct scsi_device *sdev,
602 int queue_depth)850 int queue_depth)
603{851{
604 if(queue_depth > 256)852 struct hptiop_hba *hba = (struct hptiop_hba *)sdev->host->hostdata;
605 queue_depth = 256;853
854 if (queue_depth > hba->max_requests)
855 queue_depth = hba->max_requests;
606 scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, queue_depth);856 scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, queue_depth);
607 return queue_depth;857 return queue_depth;
608}858}
@@ -663,6 +913,26 @@ static struct scsi_host_template driver_template = { · 54 unmodified lines
663 .change_queue_depth = hptiop_adjust_disk_queue_depth,913 .change_queue_depth = hptiop_adjust_disk_queue_depth,
664};914};
665 915
916static int hptiop_internal_memalloc_mv(struct hptiop_hba *hba)
917{
918 hba->u.mv.internal_req = dma_alloc_coherent(&hba->pcidev->dev,
919 0x800, &hba->u.mv.internal_req_phy, GFP_KERNEL);
920 if (hba->u.mv.internal_req)
921 return 0;
922 else
923 return -1;
924}
925
926static int hptiop_internal_memfree_mv(struct hptiop_hba *hba)
927{
928 if (hba->u.mv.internal_req) {
929 dma_free_coherent(&hba->pcidev->dev, 0x800,
930 hba->u.mv.internal_req, hba->u.mv.internal_req_phy);
931 return 0;
932 } else
933 return -1;
934}
935
666static int __devinit hptiop_probe(struct pci_dev *pcidev,936static int __devinit hptiop_probe(struct pci_dev *pcidev,
667 const struct pci_device_id *id)937 const struct pci_device_id *id)
668{938{
@@ -708,6 +978,7 @@ static int __devinit hptiop_probe(struct pci_dev *pcidev, · 39 unmodified lines
708 978
709 hba = (struct hptiop_hba *)host->hostdata;979 hba = (struct hptiop_hba *)host->hostdata;
710 980
981 hba->ops = (struct hptiop_adapter_ops *)id->driver_data;
711 hba->pcidev = pcidev;982 hba->pcidev = pcidev;
712 hba->host = host;983 hba->host = host;
713 hba->initialized = 0;984 hba->initialized = 0;
@@ -725,16 +996,24 @@ static int __devinit hptiop_probe(struct pci_dev *pcidev, · 11 unmodified lines
725 host->n_io_port = 0;996 host->n_io_port = 0;
726 host->irq = pcidev->irq;997 host->irq = pcidev->irq;
727 998
728 if (hptiop_map_pci_bar(hba))999 if (hba->ops->map_pci_bar(hba))
729 goto free_scsi_host;1000 goto free_scsi_host;
730 1001
731 if (iop_wait_ready(hba->iop, 20000)) {1002 if (hba->ops->iop_wait_ready(hba, 20000)) {
732 printk(KERN_ERR "scsi%d: firmware not ready\n",1003 printk(KERN_ERR "scsi%d: firmware not ready\n",
733 hba->host->host_no);1004 hba->host->host_no);
734 goto unmap_pci_bar;1005 goto unmap_pci_bar;
735 }1006 }
736 1007
737 if (iop_get_config(hba, &iop_config)) {1008 if (hba->ops->internal_memalloc) {
1009 if (hba->ops->internal_memalloc(hba)) {
1010 printk(KERN_ERR "scsi%d: internal_memalloc failed\n",
1011 hba->host->host_no);
1012 goto unmap_pci_bar;
1013 }
1014 }
1015
1016 if (hba->ops->get_config(hba, &iop_config)) {
738 printk(KERN_ERR "scsi%d: get config failed\n",1017 printk(KERN_ERR "scsi%d: get config failed\n",
739 hba->host->host_no);1018 hba->host->host_no);
740 goto unmap_pci_bar;1019 goto unmap_pci_bar;
@@ -770,7 +1049,7 @@ static int __devinit hptiop_probe(struct pci_dev *pcidev, · 29 unmodified lines
770 set_config.vbus_id = cpu_to_le16(host->host_no);1049 set_config.vbus_id = cpu_to_le16(host->host_no);
771 set_config.max_host_request_size = cpu_to_le16(req_size);1050 set_config.max_host_request_size = cpu_to_le16(req_size);
772 1051
773 if (iop_set_config(hba, &set_config)) {1052 if (hba->ops->set_config(hba, &set_config)) {
774 printk(KERN_ERR "scsi%d: set config failed\n",1053 printk(KERN_ERR "scsi%d: set config failed\n",
775 hba->host->host_no);1054 hba->host->host_no);
776 goto unmap_pci_bar;1055 goto unmap_pci_bar;
@@ -839,21 +1118,24 @@ static int __devinit hptiop_probe(struct pci_dev *pcidev, · 62 unmodified lines
839 1118
840free_request_mem:1119free_request_mem:
841 dma_free_coherent(&hba->pcidev->dev,1120 dma_free_coherent(&hba->pcidev->dev,
842 hba->req_size*hba->max_requests + 0x20,1121 hba->req_size * hba->max_requests + 0x20,
843 hba->dma_coherent, hba->dma_coherent_handle);1122 hba->dma_coherent, hba->dma_coherent_handle);
844 1123
845free_request_irq:1124free_request_irq:
846 free_irq(hba->pcidev->irq, hba);1125 free_irq(hba->pcidev->irq, hba);
847 1126
848unmap_pci_bar:1127unmap_pci_bar:
849 iounmap(hba->iop);1128 if (hba->ops->internal_memfree)
1129 hba->ops->internal_memfree(hba);
850 1130
851free_pci_regions:1131 hba->ops->unmap_pci_bar(hba);
852 pci_release_regions(pcidev) ;
853 1132
854free_scsi_host:1133free_scsi_host:
855 scsi_host_put(host);1134 scsi_host_put(host);
856 1135
1136free_pci_regions:
1137 pci_release_regions(pcidev);
1138
857disable_pci_device:1139disable_pci_device:
858 pci_disable_device(pcidev);1140 pci_disable_device(pcidev);
859 1141
@@ -865,8 +1147,6 @@ static void hptiop_shutdown(struct pci_dev *pcidev) · 5 unmodified lines
865{1147{
866 struct Scsi_Host *host = pci_get_drvdata(pcidev);1148 struct Scsi_Host *host = pci_get_drvdata(pcidev);
867 struct hptiop_hba *hba = (struct hptiop_hba *)host->hostdata;1149 struct hptiop_hba *hba = (struct hptiop_hba *)host->hostdata;
868 struct hpt_iopmu __iomem *iop = hba->iop;
869 u32 int_mask;
870 1150
871 dprintk("hptiop_shutdown(%p)\n", hba);1151 dprintk("hptiop_shutdown(%p)\n", hba);
872 1152
@@ -876,11 +1156,24 @@ static void hptiop_shutdown(struct pci_dev *pcidev) · 3 unmodified lines
876 hba->host->host_no);1156 hba->host->host_no);
877 1157
878 /* disable all outbound interrupts */1158 /* disable all outbound interrupts */
879 int_mask = readl(&iop->outbound_intmask);1159 hba->ops->disable_intr(hba);
1160}
1161
1162static void hptiop_disable_intr_itl(struct hptiop_hba *hba)
1163{
1164 u32 int_mask;
1165
1166 int_mask = readl(&hba->u.itl.iop->outbound_intmask);
880 writel(int_mask |1167 writel(int_mask |
881 IOPMU_OUTBOUND_INT_MSG0 | IOPMU_OUTBOUND_INT_POSTQUEUE,1168 IOPMU_OUTBOUND_INT_MSG0 | IOPMU_OUTBOUND_INT_POSTQUEUE,
882 &iop->outbound_intmask);1169 &hba->u.itl.iop->outbound_intmask);
883 hptiop_pci_posting_flush(iop);1170 readl(&hba->u.itl.iop->outbound_intmask);
1171}
1172
1173static void hptiop_disable_intr_mv(struct hptiop_hba *hba)
1174{
1175 writel(0, &hba->u.mv.regs->outbound_intmask);
1176 readl(&hba->u.mv.regs->outbound_intmask);
884}1177}
885 1178
886static void hptiop_remove(struct pci_dev *pcidev)1179static void hptiop_remove(struct pci_dev *pcidev)
@@ -901,7 +1194,10 @@ static void hptiop_remove(struct pci_dev *pcidev) · 14 unmodified lines
901 hba->dma_coherent,1194 hba->dma_coherent,
902 hba->dma_coherent_handle);1195 hba->dma_coherent_handle);
903 1196
904 iounmap(hba->iop);1197 if (hba->ops->internal_memfree)
1198 hba->ops->internal_memfree(hba);
1199
1200 hba->ops->unmap_pci_bar(hba);
905 1201
906 pci_release_regions(hba->pcidev);1202 pci_release_regions(hba->pcidev);
907 pci_set_drvdata(hba->pcidev, NULL);1203 pci_set_drvdata(hba->pcidev, NULL);
@@ -910,11 +1206,50 @@ static void hptiop_remove(struct pci_dev *pcidev) · 2 unmodified lines
910 scsi_host_put(host);1206 scsi_host_put(host);
911}1207}
912 1208
1209static struct hptiop_adapter_ops hptiop_itl_ops = {
1210 .iop_wait_ready = iop_wait_ready_itl,
1211 .internal_memalloc = 0,
1212 .internal_memfree = 0,
1213 .map_pci_bar = hptiop_map_pci_bar_itl,
1214 .unmap_pci_bar = hptiop_unmap_pci_bar_itl,
1215 .enable_intr = hptiop_enable_intr_itl,
1216 .disable_intr = hptiop_disable_intr_itl,
1217 .get_config = iop_get_config_itl,
1218 .set_config = iop_set_config_itl,
1219 .iop_intr = iop_intr_itl,
1220 .post_msg = hptiop_post_msg_itl,
1221 .post_req = hptiop_post_req_itl,
1222};
1223
1224static struct hptiop_adapter_ops hptiop_mv_ops = {
1225 .iop_wait_ready = iop_wait_ready_mv,
1226 .internal_memalloc = hptiop_internal_memalloc_mv,
1227 .internal_memfree = hptiop_internal_memfree_mv,
1228 .map_pci_bar = hptiop_map_pci_bar_mv,
1229 .unmap_pci_bar = hptiop_unmap_pci_bar_mv,
1230 .enable_intr = hptiop_enable_intr_mv,
1231 .disable_intr = hptiop_disable_intr_mv,
1232 .get_config = iop_get_config_mv,
1233 .set_config = iop_set_config_mv,
1234 .iop_intr = iop_intr_mv,
1235 .post_msg = hptiop_post_msg_mv,
1236 .post_req = hptiop_post_req_mv,
1237};
1238
913static struct pci_device_id hptiop_id_table[] = {1239static struct pci_device_id hptiop_id_table[] = {
914 { PCI_VDEVICE(TTI, 0x3220) },1240 { PCI_VDEVICE(TTI, 0x3220), (kernel_ulong_t)&hptiop_itl_ops },
915 { PCI_VDEVICE(TTI, 0x3320) },1241 { PCI_VDEVICE(TTI, 0x3320), (kernel_ulong_t)&hptiop_itl_ops },
916 { PCI_VDEVICE(TTI, 0x3520) },1242 { PCI_VDEVICE(TTI, 0x3520), (kernel_ulong_t)&hptiop_itl_ops },
917 { PCI_VDEVICE(TTI, 0x4320) },1243 { PCI_VDEVICE(TTI, 0x4320), (kernel_ulong_t)&hptiop_itl_ops },
1244 { PCI_VDEVICE(TTI, 0x3510), (kernel_ulong_t)&hptiop_itl_ops },
1245 { PCI_VDEVICE(TTI, 0x3511), (kernel_ulong_t)&hptiop_itl_ops },
1246 { PCI_VDEVICE(TTI, 0x3521), (kernel_ulong_t)&hptiop_itl_ops },
1247 { PCI_VDEVICE(TTI, 0x3522), (kernel_ulong_t)&hptiop_itl_ops },
1248 { PCI_VDEVICE(TTI, 0x3410), (kernel_ulong_t)&hptiop_itl_ops },
1249 { PCI_VDEVICE(TTI, 0x3540), (kernel_ulong_t)&hptiop_itl_ops },
1250 { PCI_VDEVICE(TTI, 0x3120), (kernel_ulong_t)&hptiop_mv_ops },
1251 { PCI_VDEVICE(TTI, 0x3122), (kernel_ulong_t)&hptiop_mv_ops },
1252 { PCI_VDEVICE(TTI, 0x3020), (kernel_ulong_t)&hptiop_mv_ops },
918 {},1253 {},
919};1254};
920 1255
drivers/scsi/hptiop.h+89−35
@@ -1,5 +1,5 @@
1/*1/*
2 * HighPoint RR3xxx controller driver for Linux2 * HighPoint RR3xxx/4xxx controller driver for Linux
3 * Copyright (C) 2006-2007 HighPoint Technologies, Inc. All Rights Reserved.3 * Copyright (C) 2006-2007 HighPoint Technologies, Inc. All Rights Reserved.
4 *4 *
5 * This program is free software; you can redistribute it and/or modify5 * This program is free software; you can redistribute it and/or modify
@@ -18,8 +18,7 @@ · 12 unmodified lines
18#ifndef _HPTIOP_H_18#ifndef _HPTIOP_H_
19#define _HPTIOP_H_19#define _HPTIOP_H_
20 20
21struct hpt_iopmu21struct hpt_iopmu_itl {
22{
23 __le32 resrved0[4];22 __le32 resrved0[4];
24 __le32 inbound_msgaddr0;23 __le32 inbound_msgaddr0;
25 __le32 inbound_msgaddr1;24 __le32 inbound_msgaddr1;
@@ -54,6 +53,40 @@ struct hpt_iopmu · 28 unmodified lines
54#define IOPMU_INBOUND_INT_ERROR 853#define IOPMU_INBOUND_INT_ERROR 8
55#define IOPMU_INBOUND_INT_POSTQUEUE 0x1054#define IOPMU_INBOUND_INT_POSTQUEUE 0x10
56 55
56#define MVIOP_QUEUE_LEN 512
57
58struct hpt_iopmu_mv {
59 __le32 inbound_head;
60 __le32 inbound_tail;
61 __le32 outbound_head;
62 __le32 outbound_tail;
63 __le32 inbound_msg;
64 __le32 outbound_msg;
65 __le32 reserve[10];
66 __le64 inbound_q[MVIOP_QUEUE_LEN];
67 __le64 outbound_q[MVIOP_QUEUE_LEN];
68};
69
70struct hpt_iopmv_regs {
71 __le32 reserved[0x20400 / 4];
72 __le32 inbound_doorbell;
73 __le32 inbound_intmask;
74 __le32 outbound_doorbell;
75 __le32 outbound_intmask;
76};
77
78#define MVIOP_MU_QUEUE_ADDR_HOST_MASK (~(0x1full))
79#define MVIOP_MU_QUEUE_ADDR_HOST_BIT 4
80
81#define MVIOP_MU_QUEUE_ADDR_IOP_HIGH32 0xffffffff
82#define MVIOP_MU_QUEUE_REQUEST_RESULT_BIT 1
83#define MVIOP_MU_QUEUE_REQUEST_RETURN_CONTEXT 2
84
85#define MVIOP_MU_INBOUND_INT_MSG 1
86#define MVIOP_MU_INBOUND_INT_POSTQUEUE 2
87#define MVIOP_MU_OUTBOUND_INT_MSG 1
88#define MVIOP_MU_OUTBOUND_INT_POSTQUEUE 2
89
57enum hpt_iopmu_message {90enum hpt_iopmu_message {
58 /* host-to-iop messages */91 /* host-to-iop messages */
59 IOPMU_INBOUND_MSG0_NOP = 0,92 IOPMU_INBOUND_MSG0_NOP = 0,
@@ -72,8 +105,7 @@ enum hpt_iopmu_message { · 12 unmodified lines
72 IOPMU_OUTBOUND_MSG0_REVALIDATE_DEVICE_MAX = 0x3ff,105 IOPMU_OUTBOUND_MSG0_REVALIDATE_DEVICE_MAX = 0x3ff,
73};106};
74 107
75struct hpt_iop_request_header108struct hpt_iop_request_header {
76{
77 __le32 size;109 __le32 size;
78 __le32 type;110 __le32 type;
79 __le32 flags;111 __le32 flags;
@@ -104,11 +136,10 @@ enum hpt_iop_result_type { · 24 unmodified lines
104 IOP_RESULT_RESET,136 IOP_RESULT_RESET,
105 IOP_RESULT_INVALID_REQUEST,137 IOP_RESULT_INVALID_REQUEST,
106 IOP_RESULT_BAD_TARGET,138 IOP_RESULT_BAD_TARGET,
107 IOP_RESULT_MODE_SENSE_CHECK_CONDITION,139 IOP_RESULT_CHECK_CONDITION,
108};140};
109 141
110struct hpt_iop_request_get_config142struct hpt_iop_request_get_config {
111{
112 struct hpt_iop_request_header header;143 struct hpt_iop_request_header header;
113 __le32 interface_version;144 __le32 interface_version;
114 __le32 firmware_version;145 __le32 firmware_version;
@@ -121,8 +152,7 @@ struct hpt_iop_request_get_config · 6 unmodified lines
121 __le32 sdram_size;152 __le32 sdram_size;
122};153};
123 154
124struct hpt_iop_request_set_config155struct hpt_iop_request_set_config {
125{
126 struct hpt_iop_request_header header;156 struct hpt_iop_request_header header;
127 __le32 iop_id;157 __le32 iop_id;
128 __le16 vbus_id;158 __le16 vbus_id;
@@ -130,15 +160,13 @@ struct hpt_iop_request_set_config · 1 unmodified line
130 __le32 reserve[6];160 __le32 reserve[6];
131};161};
132 162
133struct hpt_iopsg163struct hpt_iopsg {
134{
135 __le32 size;164 __le32 size;
136 __le32 eot; /* non-zero: end of table */165 __le32 eot; /* non-zero: end of table */
137 __le64 pci_address;166 __le64 pci_address;
138};167};
139 168
140struct hpt_iop_request_block_command169struct hpt_iop_request_block_command {
141{
142 struct hpt_iop_request_header header;170 struct hpt_iop_request_header header;
143 u8 channel;171 u8 channel;
144 u8 target;172 u8 target;
@@ -156,8 +184,7 @@ struct hpt_iop_request_block_command · 11 unmodified lines
156#define IOP_BLOCK_COMMAND_FLUSH 4184#define IOP_BLOCK_COMMAND_FLUSH 4
157#define IOP_BLOCK_COMMAND_SHUTDOWN 5185#define IOP_BLOCK_COMMAND_SHUTDOWN 5
158 186
159struct hpt_iop_request_scsi_command187struct hpt_iop_request_scsi_command {
160{
161 struct hpt_iop_request_header header;188 struct hpt_iop_request_header header;
162 u8 channel;189 u8 channel;
163 u8 target;190 u8 target;
@@ -168,8 +195,7 @@ struct hpt_iop_request_scsi_command · 4 unmodified lines
168 struct hpt_iopsg sg_list[1];195 struct hpt_iopsg sg_list[1];
169};196};
170 197
171struct hpt_iop_request_ioctl_command198struct hpt_iop_request_ioctl_command {
172{
173 struct hpt_iop_request_header header;199 struct hpt_iop_request_header header;
174 __le32 ioctl_code;200 __le32 ioctl_code;
175 __le32 inbuf_size;201 __le32 inbuf_size;
@@ -182,11 +208,11 @@ struct hpt_iop_request_ioctl_command · 6 unmodified lines
182#define HPTIOP_MAX_REQUESTS 256u208#define HPTIOP_MAX_REQUESTS 256u
183 209
184struct hptiop_request {210struct hptiop_request {
185 struct hptiop_request * next;211 struct hptiop_request *next;
186 void * req_virt;212 void *req_virt;
187 u32 req_shifted_phy;213 u32 req_shifted_phy;
188 struct scsi_cmnd * scp;214 struct scsi_cmnd *scp;
189 int index;215 int index;
190};216};
191 217
192struct hpt_scsi_pointer {218struct hpt_scsi_pointer {
@@ -198,9 +224,21 @@ struct hpt_scsi_pointer { · 5 unmodified lines
198#define HPT_SCP(scp) ((struct hpt_scsi_pointer *)&(scp)->SCp)224#define HPT_SCP(scp) ((struct hpt_scsi_pointer *)&(scp)->SCp)
199 225
200struct hptiop_hba {226struct hptiop_hba {
201 struct hpt_iopmu __iomem * iop;227 struct hptiop_adapter_ops *ops;
202 struct Scsi_Host * host;228 union {
203 struct pci_dev * pcidev;229 struct {
230 struct hpt_iopmu_itl __iomem *iop;
231 } itl;
232 struct {
233 struct hpt_iopmv_regs *regs;
234 struct hpt_iopmu_mv __iomem *mu;
235 void *internal_req;
236 dma_addr_t internal_req_phy;
237 } mv;
238 } u;
239
240 struct Scsi_Host *host;
241 struct pci_dev *pcidev;
204 242
205 /* IOP config info */243 /* IOP config info */
206 u32 interface_version;244 u32 interface_version;
@@ -213,15 +251,15 @@ struct hptiop_hba { · 6 unmodified lines
213 251
214 u32 req_size; /* host-allocated request buffer size */252 u32 req_size; /* host-allocated request buffer size */
215 253
216 int iopintf_v2: 1;254 u32 iopintf_v2: 1;
217 int initialized: 1;255 u32 initialized: 1;
218 int msg_done: 1;256 u32 msg_done: 1;
219 257
220 struct hptiop_request * req_list;258 struct hptiop_request * req_list;
221 struct hptiop_request reqs[HPTIOP_MAX_REQUESTS];259 struct hptiop_request reqs[HPTIOP_MAX_REQUESTS];
222 260
223 /* used to free allocated dma area */261 /* used to free allocated dma area */
224 void * dma_coherent;262 void *dma_coherent;
225 dma_addr_t dma_coherent_handle;263 dma_addr_t dma_coherent_handle;
226 264
227 atomic_t reset_count;265 atomic_t reset_count;
@@ -231,19 +269,35 @@ struct hptiop_hba { · 3 unmodified lines
231 wait_queue_head_t ioctl_wq;269 wait_queue_head_t ioctl_wq;
232};270};
233 271
234struct hpt_ioctl_k272struct hpt_ioctl_k {
235{
236 struct hptiop_hba * hba;273 struct hptiop_hba * hba;
237 u32 ioctl_code;274 u32 ioctl_code;
238 u32 inbuf_size;275 u32 inbuf_size;
239 u32 outbuf_size;276 u32 outbuf_size;
240 void * inbuf;277 void *inbuf;
241 void * outbuf;278 void *outbuf;
242 u32 * bytes_returned;279 u32 *bytes_returned;
243 void (*done)(struct hpt_ioctl_k *);280 void (*done)(struct hpt_ioctl_k *);
244 int result; /* HPT_IOCTL_RESULT_ */281 int result; /* HPT_IOCTL_RESULT_ */
245};282};
246 283
284struct hptiop_adapter_ops {
285 int (*iop_wait_ready)(struct hptiop_hba *hba, u32 millisec);
286 int (*internal_memalloc)(struct hptiop_hba *hba);
287 int (*internal_memfree)(struct hptiop_hba *hba);
288 int (*map_pci_bar)(struct hptiop_hba *hba);
289 void (*unmap_pci_bar)(struct hptiop_hba *hba);
290 void (*enable_intr)(struct hptiop_hba *hba);
291 void (*disable_intr)(struct hptiop_hba *hba);
292 int (*get_config)(struct hptiop_hba *hba,
293 struct hpt_iop_request_get_config *config);
294 int (*set_config)(struct hptiop_hba *hba,
295 struct hpt_iop_request_set_config *config);
296 int (*iop_intr)(struct hptiop_hba *hba);
297 void (*post_msg)(struct hptiop_hba *hba, u32 msg);
298 void (*post_req)(struct hptiop_hba *hba, struct hptiop_request *_req);
299};
300
247#define HPT_IOCTL_RESULT_OK 0301#define HPT_IOCTL_RESULT_OK 0
248#define HPT_IOCTL_RESULT_FAILED (-1)302#define HPT_IOCTL_RESULT_FAILED (-1)
249 303
drivers/scsi/ibmvscsi/ibmvscsi.c+99−56
@@ -629,6 +629,16 @@ static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct, · 628 unmodified lines
629 list_del(&evt_struct->list);629 list_del(&evt_struct->list);
630 del_timer(&evt_struct->timer);630 del_timer(&evt_struct->timer);
631 631
632 /* If send_crq returns H_CLOSED, return SCSI_MLQUEUE_HOST_BUSY.
633 * Firmware will send a CRQ with a transport event (0xFF) to
634 * tell this client what has happened to the transport. This
635 * will be handled in ibmvscsi_handle_crq()
636 */
637 if (rc == H_CLOSED) {
638 dev_warn(hostdata->dev, "send warning. "
639 "Receive queue closed, will retry.\n");
640 goto send_busy;
641 }
632 dev_err(hostdata->dev, "send error %d\n", rc);642 dev_err(hostdata->dev, "send error %d\n", rc);
633 atomic_inc(&hostdata->request_limit);643 atomic_inc(&hostdata->request_limit);
634 goto send_error;644 goto send_error;
@@ -976,58 +986,74 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd) · 341 unmodified lines
976 int rsp_rc;986 int rsp_rc;
977 unsigned long flags;987 unsigned long flags;
978 u16 lun = lun_from_dev(cmd->device);988 u16 lun = lun_from_dev(cmd->device);
989 unsigned long wait_switch = 0;
979 990
980 /* First, find this command in our sent list so we can figure991 /* First, find this command in our sent list so we can figure
981 * out the correct tag992 * out the correct tag
982 */993 */
983 spin_lock_irqsave(hostdata->host->host_lock, flags);994 spin_lock_irqsave(hostdata->host->host_lock, flags);
984 found_evt = NULL;995 wait_switch = jiffies + (init_timeout * HZ);
985 list_for_each_entry(tmp_evt, &hostdata->sent, list) {996 do {
986 if (tmp_evt->cmnd == cmd) {997 found_evt = NULL;
987 found_evt = tmp_evt;998 list_for_each_entry(tmp_evt, &hostdata->sent, list) {
988 break;999 if (tmp_evt->cmnd == cmd) {
1000 found_evt = tmp_evt;
1001 break;
1002 }
989 }1003 }
990 }
991 1004
992 if (!found_evt) {1005 if (!found_evt) {
993 spin_unlock_irqrestore(hostdata->host->host_lock, flags);1006 spin_unlock_irqrestore(hostdata->host->host_lock, flags);
994 return SUCCESS;1007 return SUCCESS;
995 }1008 }
996 1009
997 evt = get_event_struct(&hostdata->pool);1010 evt = get_event_struct(&hostdata->pool);
998 if (evt == NULL) {1011 if (evt == NULL) {
999 spin_unlock_irqrestore(hostdata->host->host_lock, flags);1012 spin_unlock_irqrestore(hostdata->host->host_lock, flags);
1000 sdev_printk(KERN_ERR, cmd->device, "failed to allocate abort event\n");1013 sdev_printk(KERN_ERR, cmd->device,
1001 return FAILED;1014 "failed to allocate abort event\n");
1002 }1015 return FAILED;
1016 }
1003 1017
1004 init_event_struct(evt,1018 init_event_struct(evt,
1005 sync_completion,1019 sync_completion,
1006 VIOSRP_SRP_FORMAT,1020 VIOSRP_SRP_FORMAT,
1007 init_timeout);1021 init_timeout);
1008 1022
1009 tsk_mgmt = &evt->iu.srp.tsk_mgmt;1023 tsk_mgmt = &evt->iu.srp.tsk_mgmt;
1010 1024
1011 /* Set up an abort SRP command */1025 /* Set up an abort SRP command */
1012 memset(tsk_mgmt, 0x00, sizeof(*tsk_mgmt));1026 memset(tsk_mgmt, 0x00, sizeof(*tsk_mgmt));
1013 tsk_mgmt->opcode = SRP_TSK_MGMT;1027 tsk_mgmt->opcode = SRP_TSK_MGMT;
1014 tsk_mgmt->lun = ((u64) lun) << 48;1028 tsk_mgmt->lun = ((u64) lun) << 48;
1015 tsk_mgmt->tsk_mgmt_func = SRP_TSK_ABORT_TASK;1029 tsk_mgmt->tsk_mgmt_func = SRP_TSK_ABORT_TASK;
1016 tsk_mgmt->task_tag = (u64) found_evt;1030 tsk_mgmt->task_tag = (u64) found_evt;
1017 1031
1018 sdev_printk(KERN_INFO, cmd->device, "aborting command. lun 0x%lx, tag 0x%lx\n",1032 evt->sync_srp = &srp_rsp;
1019 tsk_mgmt->lun, tsk_mgmt->task_tag);1033
1020 1034 init_completion(&evt->comp);
1021 evt->sync_srp = &srp_rsp;1035 rsp_rc = ibmvscsi_send_srp_event(evt, hostdata, init_timeout * 2);
1022 init_completion(&evt->comp);1036
1023 rsp_rc = ibmvscsi_send_srp_event(evt, hostdata, init_timeout * 2);1037 if (rsp_rc != SCSI_MLQUEUE_HOST_BUSY)
1038 break;
1039
1040 spin_unlock_irqrestore(hostdata->host->host_lock, flags);
1041 msleep(10);
1042 spin_lock_irqsave(hostdata->host->host_lock, flags);
1043 } while (time_before(jiffies, wait_switch));
1044
1024 spin_unlock_irqrestore(hostdata->host->host_lock, flags);1045 spin_unlock_irqrestore(hostdata->host->host_lock, flags);
1046
1025 if (rsp_rc != 0) {1047 if (rsp_rc != 0) {
1026 sdev_printk(KERN_ERR, cmd->device,1048 sdev_printk(KERN_ERR, cmd->device,
1027 "failed to send abort() event. rc=%d\n", rsp_rc);1049 "failed to send abort() event. rc=%d\n", rsp_rc);
1028 return FAILED;1050 return FAILED;
1029 }1051 }
1030 1052
1053 sdev_printk(KERN_INFO, cmd->device,
1054 "aborting command. lun 0x%lx, tag 0x%lx\n",
1055 (((u64) lun) << 48), (u64) found_evt);
1056
1031 wait_for_completion(&evt->comp);1057 wait_for_completion(&evt->comp);
1032 1058
1033 /* make sure we got a good response */1059 /* make sure we got a good response */
@@ -1099,41 +1125,56 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd) · 65 unmodified lines
1099 int rsp_rc;1125 int rsp_rc;
1100 unsigned long flags;1126 unsigned long flags;
1101 u16 lun = lun_from_dev(cmd->device);1127 u16 lun = lun_from_dev(cmd->device);
1128 unsigned long wait_switch = 0;
1102 1129
1103 spin_lock_irqsave(hostdata->host->host_lock, flags);1130 spin_lock_irqsave(hostdata->host->host_lock, flags);
1104 evt = get_event_struct(&hostdata->pool);1131 wait_switch = jiffies + (init_timeout * HZ);
1105 if (evt == NULL) {1132 do {
1106 spin_unlock_irqrestore(hostdata->host->host_lock, flags);1133 evt = get_event_struct(&hostdata->pool);
1107 sdev_printk(KERN_ERR, cmd->device, "failed to allocate reset event\n");1134 if (evt == NULL) {
1108 return FAILED;1135 spin_unlock_irqrestore(hostdata->host->host_lock, flags);
1109 }1136 sdev_printk(KERN_ERR, cmd->device,
1137 "failed to allocate reset event\n");
1138 return FAILED;
1139 }
1110 1140
1111 init_event_struct(evt,1141 init_event_struct(evt,
1112 sync_completion,1142 sync_completion,
1113 VIOSRP_SRP_FORMAT,1143 VIOSRP_SRP_FORMAT,
1114 init_timeout);1144 init_timeout);
1115 1145
1116 tsk_mgmt = &evt->iu.srp.tsk_mgmt;1146 tsk_mgmt = &evt->iu.srp.tsk_mgmt;
1117 1147
1118 /* Set up a lun reset SRP command */1148 /* Set up a lun reset SRP command */
1119 memset(tsk_mgmt, 0x00, sizeof(*tsk_mgmt));1149 memset(tsk_mgmt, 0x00, sizeof(*tsk_mgmt));
1120 tsk_mgmt->opcode = SRP_TSK_MGMT;1150 tsk_mgmt->opcode = SRP_TSK_MGMT;
1121 tsk_mgmt->lun = ((u64) lun) << 48;1151 tsk_mgmt->lun = ((u64) lun) << 48;
1122 tsk_mgmt->tsk_mgmt_func = SRP_TSK_LUN_RESET;1152 tsk_mgmt->tsk_mgmt_func = SRP_TSK_LUN_RESET;
1123 1153
1124 sdev_printk(KERN_INFO, cmd->device, "resetting device. lun 0x%lx\n",1154 evt->sync_srp = &srp_rsp;
1125 tsk_mgmt->lun);1155
1156 init_completion(&evt->comp);
1157 rsp_rc = ibmvscsi_send_srp_event(evt, hostdata, init_timeout * 2);
1158
1159 if (rsp_rc != SCSI_MLQUEUE_HOST_BUSY)
1160 break;
1161
1162 spin_unlock_irqrestore(hostdata->host->host_lock, flags);
1163 msleep(10);
1164 spin_lock_irqsave(hostdata->host->host_lock, flags);
1165 } while (time_before(jiffies, wait_switch));
1126 1166
1127 evt->sync_srp = &srp_rsp;
1128 init_completion(&evt->comp);
1129 rsp_rc = ibmvscsi_send_srp_event(evt, hostdata, init_timeout * 2);
1130 spin_unlock_irqrestore(hostdata->host->host_lock, flags);1167 spin_unlock_irqrestore(hostdata->host->host_lock, flags);
1168
1131 if (rsp_rc != 0) {1169 if (rsp_rc != 0) {
1132 sdev_printk(KERN_ERR, cmd->device,1170 sdev_printk(KERN_ERR, cmd->device,
1133 "failed to send reset event. rc=%d\n", rsp_rc);1171 "failed to send reset event. rc=%d\n", rsp_rc);
1134 return FAILED;1172 return FAILED;
1135 }1173 }
1136 1174
1175 sdev_printk(KERN_INFO, cmd->device, "resetting device. lun 0x%lx\n",
1176 (((u64) lun) << 48));
1177
1137 wait_for_completion(&evt->comp);1178 wait_for_completion(&evt->comp);
1138 1179
1139 /* make sure we got a good response */1180 /* make sure we got a good response */
@@ -1386,8 +1427,10 @@ static int ibmvscsi_slave_configure(struct scsi_device *sdev) · 246 unmodified lines
1386 unsigned long lock_flags = 0;1427 unsigned long lock_flags = 0;
1387 1428
1388 spin_lock_irqsave(shost->host_lock, lock_flags);1429 spin_lock_irqsave(shost->host_lock, lock_flags);
1389 if (sdev->type == TYPE_DISK)1430 if (sdev->type == TYPE_DISK) {
1390 sdev->allow_restart = 1;1431 sdev->allow_restart = 1;
1432 sdev->timeout = 60 * HZ;
1433 }
1391 scsi_adjust_queue_depth(sdev, 0, shost->cmd_per_lun);1434 scsi_adjust_queue_depth(sdev, 0, shost->cmd_per_lun);
1392 spin_unlock_irqrestore(shost->host_lock, lock_flags);1435 spin_unlock_irqrestore(shost->host_lock, lock_flags);
1393 return 0;1436 return 0;
drivers/scsi/ibmvscsi/ibmvstgt.c+1−1
@@ -292,7 +292,7 @@ static int ibmvstgt_cmd_done(struct scsi_cmnd *sc, · 291 unmodified lines
292 dprintk("%p %p %x %u\n", iue, target, vio_iu(iue)->srp.cmd.cdb[0],292 dprintk("%p %p %x %u\n", iue, target, vio_iu(iue)->srp.cmd.cdb[0],
293 cmd->usg_sg);293 cmd->usg_sg);
294 294
295 if (sc->use_sg)295 if (scsi_sg_count(sc))
296 err = srp_transfer_data(sc, &vio_iu(iue)->srp.cmd, ibmvstgt_rdma, 1, 1);296 err = srp_transfer_data(sc, &vio_iu(iue)->srp.cmd, ibmvstgt_rdma, 1, 1);
297 297
298 spin_lock_irqsave(&target->lock, flags);298 spin_lock_irqsave(&target->lock, flags);
drivers/scsi/imm.c+5−8
@@ -837,19 +837,16 @@ static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd) · 836 unmodified lines
837 837
838 /* Phase 4 - Setup scatter/gather buffers */838 /* Phase 4 - Setup scatter/gather buffers */
839 case 4:839 case 4:
840 if (cmd->use_sg) {840 if (scsi_bufflen(cmd)) {
841 /* if many buffers are available, start filling the first */841 cmd->SCp.buffer = scsi_sglist(cmd);
842 cmd->SCp.buffer =
843 (struct scatterlist *) cmd->request_buffer;
844 cmd->SCp.this_residual = cmd->SCp.buffer->length;842 cmd->SCp.this_residual = cmd->SCp.buffer->length;
845 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);843 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
846 } else {844 } else {
847 /* else fill the only available buffer */
848 cmd->SCp.buffer = NULL;845 cmd->SCp.buffer = NULL;
849 cmd->SCp.this_residual = cmd->request_bufflen;846 cmd->SCp.this_residual = 0;
850 cmd->SCp.ptr = cmd->request_buffer;847 cmd->SCp.ptr = NULL;
851 }848 }
852 cmd->SCp.buffers_residual = cmd->use_sg - 1;849 cmd->SCp.buffers_residual = scsi_sg_count(cmd) - 1;
853 cmd->SCp.phase++;850 cmd->SCp.phase++;
854 if (cmd->SCp.this_residual & 0x01)851 if (cmd->SCp.this_residual & 0x01)
855 cmd->SCp.this_residual++;852 cmd->SCp.this_residual++;
drivers/scsi/in2000.c+5−5
@@ -369,16 +369,16 @@ static int in2000_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *)) · 368 unmodified lines
369 * - SCp.phase records this command's SRCID_ER bit setting369 * - SCp.phase records this command's SRCID_ER bit setting
370 */370 */
371 371
372 if (cmd->use_sg) {372 if (scsi_bufflen(cmd)) {
373 cmd->SCp.buffer = (struct scatterlist *) cmd->request_buffer;373 cmd->SCp.buffer = scsi_sglist(cmd);
374 cmd->SCp.buffers_residual = cmd->use_sg - 1;374 cmd->SCp.buffers_residual = scsi_sg_count(cmd) - 1;
375 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);375 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
376 cmd->SCp.this_residual = cmd->SCp.buffer->length;376 cmd->SCp.this_residual = cmd->SCp.buffer->length;
377 } else {377 } else {
378 cmd->SCp.buffer = NULL;378 cmd->SCp.buffer = NULL;
379 cmd->SCp.buffers_residual = 0;379 cmd->SCp.buffers_residual = 0;
380 cmd->SCp.ptr = (char *) cmd->request_buffer;380 cmd->SCp.ptr = NULL;
381 cmd->SCp.this_residual = cmd->request_bufflen;381 cmd->SCp.this_residual = 0;
382 }382 }
383 cmd->SCp.have_data_in = 0;383 cmd->SCp.have_data_in = 0;
384 384
drivers/scsi/ipr.c+1−1
@@ -84,7 +84,7 @@ · 83 unmodified lines
84/*84/*
85 * Global Data85 * Global Data
86 */86 */
87static struct list_head ipr_ioa_head = LIST_HEAD_INIT(ipr_ioa_head);87static LIST_HEAD(ipr_ioa_head);
88static unsigned int ipr_log_level = IPR_DEFAULT_LOG_LEVEL;88static unsigned int ipr_log_level = IPR_DEFAULT_LOG_LEVEL;
89static unsigned int ipr_max_speed = 1;89static unsigned int ipr_max_speed = 1;
90static int ipr_testmode = 0;90static int ipr_testmode = 0;
drivers/scsi/ips.c+154−172
@@ -389,17 +389,17 @@ static struct pci_device_id ips_pci_table[] = { · 388 unmodified lines
389MODULE_DEVICE_TABLE( pci, ips_pci_table );389MODULE_DEVICE_TABLE( pci, ips_pci_table );
390 390
391static char ips_hot_plug_name[] = "ips";391static char ips_hot_plug_name[] = "ips";
392 392
393static int __devinit ips_insert_device(struct pci_dev *pci_dev, const struct pci_device_id *ent);393static int __devinit ips_insert_device(struct pci_dev *pci_dev, const struct pci_device_id *ent);
394static void __devexit ips_remove_device(struct pci_dev *pci_dev);394static void __devexit ips_remove_device(struct pci_dev *pci_dev);
395 395
396static struct pci_driver ips_pci_driver = {396static struct pci_driver ips_pci_driver = {
397 .name = ips_hot_plug_name,397 .name = ips_hot_plug_name,
398 .id_table = ips_pci_table,398 .id_table = ips_pci_table,
399 .probe = ips_insert_device,399 .probe = ips_insert_device,
400 .remove = __devexit_p(ips_remove_device),400 .remove = __devexit_p(ips_remove_device),
401};401};
402 402
403 403
404/*404/*
405 * Necessary forward function protoypes405 * Necessary forward function protoypes
@@ -587,7 +587,7 @@ static void · 181 unmodified lines
587ips_setup_funclist(ips_ha_t * ha)587ips_setup_funclist(ips_ha_t * ha)
588{588{
589 589
590 /* 590 /*
591 * Setup Functions591 * Setup Functions
592 */592 */
593 if (IPS_IS_MORPHEUS(ha) || IPS_IS_MARCO(ha)) {593 if (IPS_IS_MORPHEUS(ha) || IPS_IS_MARCO(ha)) {
@@ -702,12 +702,8 @@ ips_release(struct Scsi_Host *sh) · 108 unmodified lines
702 /* free extra memory */702 /* free extra memory */
703 ips_free(ha);703 ips_free(ha);
704 704
705 /* Free I/O Region */
706 if (ha->io_addr)
707 release_region(ha->io_addr, ha->io_len);
708
709 /* free IRQ */705 /* free IRQ */
710 free_irq(ha->irq, ha);706 free_irq(ha->pcidev->irq, ha);
711 707
712 scsi_host_put(sh);708 scsi_host_put(sh);
713 709
@@ -1637,7 +1633,7 @@ ips_make_passthru(ips_ha_t *ha, struct scsi_cmnd *SC, ips_scb_t *scb, int intr) · 923 unmodified lines
1637 return (IPS_FAILURE);1633 return (IPS_FAILURE);
1638 }1634 }
1639 1635
1640 if (ha->device_id == IPS_DEVICEID_COPPERHEAD &&1636 if (ha->pcidev->device == IPS_DEVICEID_COPPERHEAD &&
1641 pt->CoppCP.cmd.flashfw.op_code ==1637 pt->CoppCP.cmd.flashfw.op_code ==
1642 IPS_CMD_RW_BIOSFW) {1638 IPS_CMD_RW_BIOSFW) {
1643 ret = ips_flash_copperhead(ha, pt, scb);1639 ret = ips_flash_copperhead(ha, pt, scb);
@@ -2021,7 +2017,7 @@ ips_cleanup_passthru(ips_ha_t * ha, ips_scb_t * scb) · 377 unmodified lines
2021 pt->ExtendedStatus = scb->extended_status;2017 pt->ExtendedStatus = scb->extended_status;
2022 pt->AdapterType = ha->ad_type;2018 pt->AdapterType = ha->ad_type;
2023 2019
2024 if (ha->device_id == IPS_DEVICEID_COPPERHEAD &&2020 if (ha->pcidev->device == IPS_DEVICEID_COPPERHEAD &&
2025 (scb->cmd.flashfw.op_code == IPS_CMD_DOWNLOAD ||2021 (scb->cmd.flashfw.op_code == IPS_CMD_DOWNLOAD ||
2026 scb->cmd.flashfw.op_code == IPS_CMD_RW_BIOSFW))2022 scb->cmd.flashfw.op_code == IPS_CMD_RW_BIOSFW))
2027 ips_free_flash_copperhead(ha);2023 ips_free_flash_copperhead(ha);
@@ -2075,13 +2071,13 @@ ips_host_info(ips_ha_t * ha, char *ptr, off_t offset, int len) · 47 unmodified lines
2075 ha->mem_ptr);2071 ha->mem_ptr);
2076 }2072 }
2077 2073
2078 copy_info(&info, "\tIRQ number : %d\n", ha->irq);2074 copy_info(&info, "\tIRQ number : %d\n", ha->pcidev->irq);
2079 2075
2080 /* For the Next 3 lines Check for Binary 0 at the end and don't include it if it's there. */2076 /* For the Next 3 lines Check for Binary 0 at the end and don't include it if it's there. */
2081 /* That keeps everything happy for "text" operations on the proc file. */2077 /* That keeps everything happy for "text" operations on the proc file. */
2082 2078
2083 if (le32_to_cpu(ha->nvram->signature) == IPS_NVRAM_P5_SIG) {2079 if (le32_to_cpu(ha->nvram->signature) == IPS_NVRAM_P5_SIG) {
2084 if (ha->nvram->bios_low[3] == 0) { 2080 if (ha->nvram->bios_low[3] == 0) {
2085 copy_info(&info,2081 copy_info(&info,
2086 "\tBIOS Version : %c%c%c%c%c%c%c\n",2082 "\tBIOS Version : %c%c%c%c%c%c%c\n",
2087 ha->nvram->bios_high[0], ha->nvram->bios_high[1],2083 ha->nvram->bios_high[0], ha->nvram->bios_high[1],
@@ -2232,31 +2228,31 @@ ips_identify_controller(ips_ha_t * ha) · 144 unmodified lines
2232{2228{
2233 METHOD_TRACE("ips_identify_controller", 1);2229 METHOD_TRACE("ips_identify_controller", 1);
2234 2230
2235 switch (ha->device_id) {2231 switch (ha->pcidev->device) {
2236 case IPS_DEVICEID_COPPERHEAD:2232 case IPS_DEVICEID_COPPERHEAD:
2237 if (ha->revision_id <= IPS_REVID_SERVERAID) {2233 if (ha->pcidev->revision <= IPS_REVID_SERVERAID) {
2238 ha->ad_type = IPS_ADTYPE_SERVERAID;2234 ha->ad_type = IPS_ADTYPE_SERVERAID;
2239 } else if (ha->revision_id == IPS_REVID_SERVERAID2) {2235 } else if (ha->pcidev->revision == IPS_REVID_SERVERAID2) {
2240 ha->ad_type = IPS_ADTYPE_SERVERAID2;2236 ha->ad_type = IPS_ADTYPE_SERVERAID2;
2241 } else if (ha->revision_id == IPS_REVID_NAVAJO) {2237 } else if (ha->pcidev->revision == IPS_REVID_NAVAJO) {
2242 ha->ad_type = IPS_ADTYPE_NAVAJO;2238 ha->ad_type = IPS_ADTYPE_NAVAJO;
2243 } else if ((ha->revision_id == IPS_REVID_SERVERAID2)2239 } else if ((ha->pcidev->revision == IPS_REVID_SERVERAID2)
2244 && (ha->slot_num == 0)) {2240 && (ha->slot_num == 0)) {
2245 ha->ad_type = IPS_ADTYPE_KIOWA;2241 ha->ad_type = IPS_ADTYPE_KIOWA;
2246 } else if ((ha->revision_id >= IPS_REVID_CLARINETP1) &&2242 } else if ((ha->pcidev->revision >= IPS_REVID_CLARINETP1) &&
2247 (ha->revision_id <= IPS_REVID_CLARINETP3)) {2243 (ha->pcidev->revision <= IPS_REVID_CLARINETP3)) {
2248 if (ha->enq->ucMaxPhysicalDevices == 15)2244 if (ha->enq->ucMaxPhysicalDevices == 15)
2249 ha->ad_type = IPS_ADTYPE_SERVERAID3L;2245 ha->ad_type = IPS_ADTYPE_SERVERAID3L;
2250 else2246 else
2251 ha->ad_type = IPS_ADTYPE_SERVERAID3;2247 ha->ad_type = IPS_ADTYPE_SERVERAID3;
2252 } else if ((ha->revision_id >= IPS_REVID_TROMBONE32) &&2248 } else if ((ha->pcidev->revision >= IPS_REVID_TROMBONE32) &&
2253 (ha->revision_id <= IPS_REVID_TROMBONE64)) {2249 (ha->pcidev->revision <= IPS_REVID_TROMBONE64)) {
2254 ha->ad_type = IPS_ADTYPE_SERVERAID4H;2250 ha->ad_type = IPS_ADTYPE_SERVERAID4H;
2255 }2251 }
2256 break;2252 break;
2257 2253
2258 case IPS_DEVICEID_MORPHEUS:2254 case IPS_DEVICEID_MORPHEUS:
2259 switch (ha->subdevice_id) {2255 switch (ha->pcidev->subsystem_device) {
2260 case IPS_SUBDEVICEID_4L:2256 case IPS_SUBDEVICEID_4L:
2261 ha->ad_type = IPS_ADTYPE_SERVERAID4L;2257 ha->ad_type = IPS_ADTYPE_SERVERAID4L;
2262 break;2258 break;
@@ -2285,7 +2281,7 @@ ips_identify_controller(ips_ha_t * ha) · 22 unmodified lines
2285 break;2281 break;
2286 2282
2287 case IPS_DEVICEID_MARCO:2283 case IPS_DEVICEID_MARCO:
2288 switch (ha->subdevice_id) {2284 switch (ha->pcidev->subsystem_device) {
2289 case IPS_SUBDEVICEID_6M:2285 case IPS_SUBDEVICEID_6M:
2290 ha->ad_type = IPS_ADTYPE_SERVERAID6M;2286 ha->ad_type = IPS_ADTYPE_SERVERAID6M;
2291 break;2287 break;
@@ -2332,20 +2328,20 @@ ips_get_bios_version(ips_ha_t * ha, int intr) · 40 unmodified lines
2332 2328
2333 strncpy(ha->bios_version, " ?", 8);2329 strncpy(ha->bios_version, " ?", 8);
2334 2330
2335 if (ha->device_id == IPS_DEVICEID_COPPERHEAD) {2331 if (ha->pcidev->device == IPS_DEVICEID_COPPERHEAD) {
2336 if (IPS_USE_MEMIO(ha)) {2332 if (IPS_USE_MEMIO(ha)) {
2337 /* Memory Mapped I/O */2333 /* Memory Mapped I/O */
2338 2334
2339 /* test 1st byte */2335 /* test 1st byte */
2340 writel(0, ha->mem_ptr + IPS_REG_FLAP);2336 writel(0, ha->mem_ptr + IPS_REG_FLAP);
2341 if (ha->revision_id == IPS_REVID_TROMBONE64)2337 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
2342 udelay(25); /* 25 us */2338 udelay(25); /* 25 us */
2343 2339
2344 if (readb(ha->mem_ptr + IPS_REG_FLDP) != 0x55)2340 if (readb(ha->mem_ptr + IPS_REG_FLDP) != 0x55)
2345 return;2341 return;
2346 2342
2347 writel(1, ha->mem_ptr + IPS_REG_FLAP);2343 writel(1, ha->mem_ptr + IPS_REG_FLAP);
2348 if (ha->revision_id == IPS_REVID_TROMBONE64)2344 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
2349 udelay(25); /* 25 us */2345 udelay(25); /* 25 us */
2350 2346
2351 if (readb(ha->mem_ptr + IPS_REG_FLDP) != 0xAA)2347 if (readb(ha->mem_ptr + IPS_REG_FLDP) != 0xAA)
@@ -2353,20 +2349,20 @@ ips_get_bios_version(ips_ha_t * ha, int intr) · 1 unmodified line
2353 2349
2354 /* Get Major version */2350 /* Get Major version */
2355 writel(0x1FF, ha->mem_ptr + IPS_REG_FLAP);2351 writel(0x1FF, ha->mem_ptr + IPS_REG_FLAP);
2356 if (ha->revision_id == IPS_REVID_TROMBONE64)2352 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
2357 udelay(25); /* 25 us */2353 udelay(25); /* 25 us */
2358 2354
2359 major = readb(ha->mem_ptr + IPS_REG_FLDP);2355 major = readb(ha->mem_ptr + IPS_REG_FLDP);
2360 2356
2361 /* Get Minor version */2357 /* Get Minor version */
2362 writel(0x1FE, ha->mem_ptr + IPS_REG_FLAP);2358 writel(0x1FE, ha->mem_ptr + IPS_REG_FLAP);
2363 if (ha->revision_id == IPS_REVID_TROMBONE64)2359 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
2364 udelay(25); /* 25 us */2360 udelay(25); /* 25 us */
2365 minor = readb(ha->mem_ptr + IPS_REG_FLDP);2361 minor = readb(ha->mem_ptr + IPS_REG_FLDP);
2366 2362
2367 /* Get SubMinor version */2363 /* Get SubMinor version */
2368 writel(0x1FD, ha->mem_ptr + IPS_REG_FLAP);2364 writel(0x1FD, ha->mem_ptr + IPS_REG_FLAP);
2369 if (ha->revision_id == IPS_REVID_TROMBONE64)2365 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
2370 udelay(25); /* 25 us */2366 udelay(25); /* 25 us */
2371 subminor = readb(ha->mem_ptr + IPS_REG_FLDP);2367 subminor = readb(ha->mem_ptr + IPS_REG_FLDP);
2372 2368
@@ -2375,14 +2371,14 @@ ips_get_bios_version(ips_ha_t * ha, int intr) · 2 unmodified lines
2375 2371
2376 /* test 1st byte */2372 /* test 1st byte */
2377 outl(0, ha->io_addr + IPS_REG_FLAP);2373 outl(0, ha->io_addr + IPS_REG_FLAP);
2378 if (ha->revision_id == IPS_REVID_TROMBONE64)2374 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
2379 udelay(25); /* 25 us */2375 udelay(25); /* 25 us */
2380 2376
2381 if (inb(ha->io_addr + IPS_REG_FLDP) != 0x55)2377 if (inb(ha->io_addr + IPS_REG_FLDP) != 0x55)
2382 return;2378 return;
2383 2379
2384 outl(cpu_to_le32(1), ha->io_addr + IPS_REG_FLAP);2380 outl(cpu_to_le32(1), ha->io_addr + IPS_REG_FLAP);
2385 if (ha->revision_id == IPS_REVID_TROMBONE64)2381 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
2386 udelay(25); /* 25 us */2382 udelay(25); /* 25 us */
2387 2383
2388 if (inb(ha->io_addr + IPS_REG_FLDP) != 0xAA)2384 if (inb(ha->io_addr + IPS_REG_FLDP) != 0xAA)
@@ -2390,21 +2386,21 @@ ips_get_bios_version(ips_ha_t * ha, int intr) · 1 unmodified line
2390 2386
2391 /* Get Major version */2387 /* Get Major version */
2392 outl(cpu_to_le32(0x1FF), ha->io_addr + IPS_REG_FLAP);2388 outl(cpu_to_le32(0x1FF), ha->io_addr + IPS_REG_FLAP);
2393 if (ha->revision_id == IPS_REVID_TROMBONE64)2389 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
2394 udelay(25); /* 25 us */2390 udelay(25); /* 25 us */
2395 2391
2396 major = inb(ha->io_addr + IPS_REG_FLDP);2392 major = inb(ha->io_addr + IPS_REG_FLDP);
2397 2393
2398 /* Get Minor version */2394 /* Get Minor version */
2399 outl(cpu_to_le32(0x1FE), ha->io_addr + IPS_REG_FLAP);2395 outl(cpu_to_le32(0x1FE), ha->io_addr + IPS_REG_FLAP);
2400 if (ha->revision_id == IPS_REVID_TROMBONE64)2396 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
2401 udelay(25); /* 25 us */2397 udelay(25); /* 25 us */
2402 2398
2403 minor = inb(ha->io_addr + IPS_REG_FLDP);2399 minor = inb(ha->io_addr + IPS_REG_FLDP);
2404 2400
2405 /* Get SubMinor version */2401 /* Get SubMinor version */
2406 outl(cpu_to_le32(0x1FD), ha->io_addr + IPS_REG_FLAP);2402 outl(cpu_to_le32(0x1FD), ha->io_addr + IPS_REG_FLAP);
2407 if (ha->revision_id == IPS_REVID_TROMBONE64)2403 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
2408 udelay(25); /* 25 us */2404 udelay(25); /* 25 us */
2409 2405
2410 subminor = inb(ha->io_addr + IPS_REG_FLDP);2406 subminor = inb(ha->io_addr + IPS_REG_FLDP);
@@ -2740,8 +2736,6 @@ ips_next(ips_ha_t * ha, int intr) · 329 unmodified lines
2740 SC->result = DID_OK;2736 SC->result = DID_OK;
2741 SC->host_scribble = NULL;2737 SC->host_scribble = NULL;
2742 2738
2743 memset(SC->sense_buffer, 0, sizeof (SC->sense_buffer));
2744
2745 scb->target_id = SC->device->id;2739 scb->target_id = SC->device->id;
2746 scb->lun = SC->device->lun;2740 scb->lun = SC->device->lun;
2747 scb->bus = SC->device->channel;2741 scb->bus = SC->device->channel;
@@ -2780,10 +2774,11 @@ ips_next(ips_ha_t * ha, int intr) · 32 unmodified lines
2780 scb->dcdb.cmd_attribute =2774 scb->dcdb.cmd_attribute =
2781 ips_command_direction[scb->scsi_cmd->cmnd[0]];2775 ips_command_direction[scb->scsi_cmd->cmnd[0]];
2782 2776
2783 /* Allow a WRITE BUFFER Command to Have no Data */2777 /* Allow a WRITE BUFFER Command to Have no Data */
2784 /* This is Used by Tape Flash Utilites */2778 /* This is Used by Tape Flash Utilites */
2785 if ((scb->scsi_cmd->cmnd[0] == WRITE_BUFFER) && (scb->data_len == 0)) 2779 if ((scb->scsi_cmd->cmnd[0] == WRITE_BUFFER) &&
2786 scb->dcdb.cmd_attribute = 0; 2780 (scb->data_len == 0))
2781 scb->dcdb.cmd_attribute = 0;
2787 2782
2788 if (!(scb->dcdb.cmd_attribute & 0x3))2783 if (!(scb->dcdb.cmd_attribute & 0x3))
2789 scb->dcdb.transfer_length = 0;2784 scb->dcdb.transfer_length = 0;
@@ -3404,7 +3399,7 @@ ips_map_status(ips_ha_t * ha, ips_scb_t * scb, ips_stat_t * sp) · 614 unmodified lines
3404 3399
3405 /* Restrict access to physical DASD */3400 /* Restrict access to physical DASD */
3406 if (scb->scsi_cmd->cmnd[0] == INQUIRY) {3401 if (scb->scsi_cmd->cmnd[0] == INQUIRY) {
3407 ips_scmd_buf_read(scb->scsi_cmd, 3402 ips_scmd_buf_read(scb->scsi_cmd,
3408 &inquiryData, sizeof (inquiryData));3403 &inquiryData, sizeof (inquiryData));
3409 if ((inquiryData.DeviceType & 0x1f) == TYPE_DISK) {3404 if ((inquiryData.DeviceType & 0x1f) == TYPE_DISK) {
3410 errcode = DID_TIME_OUT;3405 errcode = DID_TIME_OUT;
@@ -3438,13 +3433,11 @@ ips_map_status(ips_ha_t * ha, ips_scb_t * scb, ips_stat_t * sp) · 27 unmodified lines
3438 (IPS_DCDB_TABLE_TAPE *) & scb->dcdb;3433 (IPS_DCDB_TABLE_TAPE *) & scb->dcdb;
3439 memcpy(scb->scsi_cmd->sense_buffer,3434 memcpy(scb->scsi_cmd->sense_buffer,
3440 tapeDCDB->sense_info,3435 tapeDCDB->sense_info,
3441 sizeof (scb->scsi_cmd->3436 SCSI_SENSE_BUFFERSIZE);
3442 sense_buffer));
3443 } else {3437 } else {
3444 memcpy(scb->scsi_cmd->sense_buffer,3438 memcpy(scb->scsi_cmd->sense_buffer,
3445 scb->dcdb.sense_info,3439 scb->dcdb.sense_info,
3446 sizeof (scb->scsi_cmd->3440 SCSI_SENSE_BUFFERSIZE);
3447 sense_buffer));
3448 }3441 }
3449 device_error = 2; /* check condition */3442 device_error = 2; /* check condition */
3450 }3443 }
@@ -3824,7 +3817,6 @@ ips_send_cmd(ips_ha_t * ha, ips_scb_t * scb) · 373 unmodified lines
3824 /* attempted, a Check Condition occurred, and Sense */3817 /* attempted, a Check Condition occurred, and Sense */
3825 /* Data indicating an Invalid CDB OpCode is returned. */3818 /* Data indicating an Invalid CDB OpCode is returned. */
3826 sp = (char *) scb->scsi_cmd->sense_buffer;3819 sp = (char *) scb->scsi_cmd->sense_buffer;
3827 memset(sp, 0, sizeof (scb->scsi_cmd->sense_buffer));
3828 3820
3829 sp[0] = 0x70; /* Error Code */3821 sp[0] = 0x70; /* Error Code */
3830 sp[2] = ILLEGAL_REQUEST; /* Sense Key 5 Illegal Req. */3822 sp[2] = ILLEGAL_REQUEST; /* Sense Key 5 Illegal Req. */
@@ -4090,10 +4082,10 @@ ips_chkstatus(ips_ha_t * ha, IPS_STATUS * pstatus) · 259 unmodified lines
4090 scb->scsi_cmd->result = errcode << 16;4082 scb->scsi_cmd->result = errcode << 16;
4091 } else { /* bus == 0 */4083 } else { /* bus == 0 */
4092 /* restrict access to physical drives */4084 /* restrict access to physical drives */
4093 if (scb->scsi_cmd->cmnd[0] == INQUIRY) { 4085 if (scb->scsi_cmd->cmnd[0] == INQUIRY) {
4094 ips_scmd_buf_read(scb->scsi_cmd, 4086 ips_scmd_buf_read(scb->scsi_cmd,
4095 &inquiryData, sizeof (inquiryData));4087 &inquiryData, sizeof (inquiryData));
4096 if ((inquiryData.DeviceType & 0x1f) == TYPE_DISK) 4088 if ((inquiryData.DeviceType & 0x1f) == TYPE_DISK)
4097 scb->scsi_cmd->result = DID_TIME_OUT << 16;4089 scb->scsi_cmd->result = DID_TIME_OUT << 16;
4098 }4090 }
4099 } /* else */4091 } /* else */
@@ -4393,8 +4385,6 @@ ips_free(ips_ha_t * ha) · 293 unmodified lines
4393 ha->mem_ptr = NULL;4385 ha->mem_ptr = NULL;
4394 }4386 }
4395 4387
4396 if (ha->mem_addr)
4397 release_mem_region(ha->mem_addr, ha->mem_len);
4398 ha->mem_addr = 0;4388 ha->mem_addr = 0;
4399 4389
4400 }4390 }
@@ -4661,8 +4651,8 @@ ips_isinit_morpheus(ips_ha_t * ha) · 260 unmodified lines
4661 uint32_t bits;4651 uint32_t bits;
4662 4652
4663 METHOD_TRACE("ips_is_init_morpheus", 1);4653 METHOD_TRACE("ips_is_init_morpheus", 1);
4664 4654
4665 if (ips_isintr_morpheus(ha)) 4655 if (ips_isintr_morpheus(ha))
4666 ips_flush_and_reset(ha);4656 ips_flush_and_reset(ha);
4667 4657
4668 post = readl(ha->mem_ptr + IPS_REG_I960_MSG0);4658 post = readl(ha->mem_ptr + IPS_REG_I960_MSG0);
@@ -4686,7 +4676,7 @@ ips_isinit_morpheus(ips_ha_t * ha) · 17 unmodified lines
4686/* state ( was trying to INIT and an interrupt was already pending ) ... */4676/* state ( was trying to INIT and an interrupt was already pending ) ... */
4687/* */4677/* */
4688/****************************************************************************/4678/****************************************************************************/
4689static void 4679static void
4690ips_flush_and_reset(ips_ha_t *ha)4680ips_flush_and_reset(ips_ha_t *ha)
4691{4681{
4692 ips_scb_t *scb;4682 ips_scb_t *scb;
@@ -4718,9 +4708,9 @@ ips_flush_and_reset(ips_ha_t *ha) · 25 unmodified lines
4718 if (ret == IPS_SUCCESS) {4708 if (ret == IPS_SUCCESS) {
4719 time = 60 * IPS_ONE_SEC; /* Max Wait time is 60 seconds */4709 time = 60 * IPS_ONE_SEC; /* Max Wait time is 60 seconds */
4720 done = 0;4710 done = 0;
4721 4711
4722 while ((time > 0) && (!done)) {4712 while ((time > 0) && (!done)) {
4723 done = ips_poll_for_flush_complete(ha); 4713 done = ips_poll_for_flush_complete(ha);
4724 /* This may look evil, but it's only done during extremely rare start-up conditions ! */4714 /* This may look evil, but it's only done during extremely rare start-up conditions ! */
4725 udelay(1000);4715 udelay(1000);
4726 time--;4716 time--;
@@ -4749,17 +4739,17 @@ static int · 22 unmodified lines
4749ips_poll_for_flush_complete(ips_ha_t * ha)4739ips_poll_for_flush_complete(ips_ha_t * ha)
4750{4740{
4751 IPS_STATUS cstatus;4741 IPS_STATUS cstatus;
4752 4742
4753 while (TRUE) {4743 while (TRUE) {
4754 cstatus.value = (*ha->func.statupd) (ha);4744 cstatus.value = (*ha->func.statupd) (ha);
4755 4745
4756 if (cstatus.value == 0xffffffff) /* If No Interrupt to process */4746 if (cstatus.value == 0xffffffff) /* If No Interrupt to process */
4757 break;4747 break;
4758 4748
4759 /* Success is when we see the Flush Command ID */4749 /* Success is when we see the Flush Command ID */
4760 if (cstatus.fields.command_id == IPS_MAX_CMDS ) 4750 if (cstatus.fields.command_id == IPS_MAX_CMDS)
4761 return 1;4751 return 1;
4762 } 4752 }
4763 4753
4764 return 0;4754 return 0;
4765}4755}
@@ -4903,7 +4893,7 @@ ips_init_copperhead(ips_ha_t * ha) · 137 unmodified lines
4903 /* Enable busmastering */4893 /* Enable busmastering */
4904 outb(IPS_BIT_EBM, ha->io_addr + IPS_REG_SCPR);4894 outb(IPS_BIT_EBM, ha->io_addr + IPS_REG_SCPR);
4905 4895
4906 if (ha->revision_id == IPS_REVID_TROMBONE64)4896 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
4907 /* fix for anaconda64 */4897 /* fix for anaconda64 */
4908 outl(0, ha->io_addr + IPS_REG_NDAE);4898 outl(0, ha->io_addr + IPS_REG_NDAE);
4909 4899
@@ -4997,7 +4987,7 @@ ips_init_copperhead_memio(ips_ha_t * ha) · 87 unmodified lines
4997 /* Enable busmastering */4987 /* Enable busmastering */
4998 writeb(IPS_BIT_EBM, ha->mem_ptr + IPS_REG_SCPR);4988 writeb(IPS_BIT_EBM, ha->mem_ptr + IPS_REG_SCPR);
4999 4989
5000 if (ha->revision_id == IPS_REVID_TROMBONE64)4990 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
5001 /* fix for anaconda64 */4991 /* fix for anaconda64 */
5002 writel(0, ha->mem_ptr + IPS_REG_NDAE);4992 writel(0, ha->mem_ptr + IPS_REG_NDAE);
5003 4993
@@ -5142,7 +5132,7 @@ ips_reset_copperhead(ips_ha_t * ha) · 138 unmodified lines
5142 METHOD_TRACE("ips_reset_copperhead", 1);5132 METHOD_TRACE("ips_reset_copperhead", 1);
5143 5133
5144 DEBUG_VAR(1, "(%s%d) ips_reset_copperhead: io addr: %x, irq: %d",5134 DEBUG_VAR(1, "(%s%d) ips_reset_copperhead: io addr: %x, irq: %d",
5145 ips_name, ha->host_num, ha->io_addr, ha->irq);5135 ips_name, ha->host_num, ha->io_addr, ha->pcidev->irq);
5146 5136
5147 reset_counter = 0;5137 reset_counter = 0;
5148 5138
@@ -5187,7 +5177,7 @@ ips_reset_copperhead_memio(ips_ha_t * ha) · 38 unmodified lines
5187 METHOD_TRACE("ips_reset_copperhead_memio", 1);5177 METHOD_TRACE("ips_reset_copperhead_memio", 1);
5188 5178
5189 DEBUG_VAR(1, "(%s%d) ips_reset_copperhead_memio: mem addr: %x, irq: %d",5179 DEBUG_VAR(1, "(%s%d) ips_reset_copperhead_memio: mem addr: %x, irq: %d",
5190 ips_name, ha->host_num, ha->mem_addr, ha->irq);5180 ips_name, ha->host_num, ha->mem_addr, ha->pcidev->irq);
5191 5181
5192 reset_counter = 0;5182 reset_counter = 0;
5193 5183
@@ -5233,7 +5223,7 @@ ips_reset_morpheus(ips_ha_t * ha) · 39 unmodified lines
5233 METHOD_TRACE("ips_reset_morpheus", 1);5223 METHOD_TRACE("ips_reset_morpheus", 1);
5234 5224
5235 DEBUG_VAR(1, "(%s%d) ips_reset_morpheus: mem addr: %x, irq: %d",5225 DEBUG_VAR(1, "(%s%d) ips_reset_morpheus: mem addr: %x, irq: %d",
5236 ips_name, ha->host_num, ha->mem_addr, ha->irq);5226 ips_name, ha->host_num, ha->mem_addr, ha->pcidev->irq);
5237 5227
5238 reset_counter = 0;5228 reset_counter = 0;
5239 5229
@@ -5920,7 +5910,7 @@ ips_read_config(ips_ha_t * ha, int intr) · 680 unmodified lines
5920 5910
5921 return (0);5911 return (0);
5922 }5912 }
5923 5913
5924 memcpy(ha->conf, ha->ioctl_data, sizeof(*ha->conf));5914 memcpy(ha->conf, ha->ioctl_data, sizeof(*ha->conf));
5925 return (1);5915 return (1);
5926}5916}
@@ -5959,7 +5949,7 @@ ips_readwrite_page5(ips_ha_t * ha, int write, int intr) · 32 unmodified lines
5959 scb->cmd.nvram.buffer_addr = ha->ioctl_busaddr;5949 scb->cmd.nvram.buffer_addr = ha->ioctl_busaddr;
5960 if (write)5950 if (write)
5961 memcpy(ha->ioctl_data, ha->nvram, sizeof(*ha->nvram));5951 memcpy(ha->ioctl_data, ha->nvram, sizeof(*ha->nvram));
5962 5952
5963 /* issue the command */5953 /* issue the command */
5964 if (((ret =5954 if (((ret =
5965 ips_send_wait(ha, scb, ips_cmd_timeout, intr)) == IPS_FAILURE)5955 ips_send_wait(ha, scb, ips_cmd_timeout, intr)) == IPS_FAILURE)
@@ -6196,32 +6186,32 @@ ips_erase_bios(ips_ha_t * ha) · 230 unmodified lines
6196 6186
6197 /* Clear the status register */6187 /* Clear the status register */
6198 outl(0, ha->io_addr + IPS_REG_FLAP);6188 outl(0, ha->io_addr + IPS_REG_FLAP);
6199 if (ha->revision_id == IPS_REVID_TROMBONE64)6189 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6200 udelay(25); /* 25 us */6190 udelay(25); /* 25 us */
6201 6191
6202 outb(0x50, ha->io_addr + IPS_REG_FLDP);6192 outb(0x50, ha->io_addr + IPS_REG_FLDP);
6203 if (ha->revision_id == IPS_REVID_TROMBONE64)6193 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6204 udelay(25); /* 25 us */6194 udelay(25); /* 25 us */
6205 6195
6206 /* Erase Setup */6196 /* Erase Setup */
6207 outb(0x20, ha->io_addr + IPS_REG_FLDP);6197 outb(0x20, ha->io_addr + IPS_REG_FLDP);
6208 if (ha->revision_id == IPS_REVID_TROMBONE64)6198 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6209 udelay(25); /* 25 us */6199 udelay(25); /* 25 us */
6210 6200
6211 /* Erase Confirm */6201 /* Erase Confirm */
6212 outb(0xD0, ha->io_addr + IPS_REG_FLDP);6202 outb(0xD0, ha->io_addr + IPS_REG_FLDP);
6213 if (ha->revision_id == IPS_REVID_TROMBONE64)6203 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6214 udelay(25); /* 25 us */6204 udelay(25); /* 25 us */
6215 6205
6216 /* Erase Status */6206 /* Erase Status */
6217 outb(0x70, ha->io_addr + IPS_REG_FLDP);6207 outb(0x70, ha->io_addr + IPS_REG_FLDP);
6218 if (ha->revision_id == IPS_REVID_TROMBONE64)6208 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6219 udelay(25); /* 25 us */6209 udelay(25); /* 25 us */
6220 6210
6221 timeout = 80000; /* 80 seconds */6211 timeout = 80000; /* 80 seconds */
6222 6212
6223 while (timeout > 0) {6213 while (timeout > 0) {
6224 if (ha->revision_id == IPS_REVID_TROMBONE64) {6214 if (ha->pcidev->revision == IPS_REVID_TROMBONE64) {
6225 outl(0, ha->io_addr + IPS_REG_FLAP);6215 outl(0, ha->io_addr + IPS_REG_FLAP);
6226 udelay(25); /* 25 us */6216 udelay(25); /* 25 us */
6227 }6217 }
@@ -6241,13 +6231,13 @@ ips_erase_bios(ips_ha_t * ha) · 13 unmodified lines
6241 6231
6242 /* try to suspend the erase */6232 /* try to suspend the erase */
6243 outb(0xB0, ha->io_addr + IPS_REG_FLDP);6233 outb(0xB0, ha->io_addr + IPS_REG_FLDP);
6244 if (ha->revision_id == IPS_REVID_TROMBONE64)6234 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6245 udelay(25); /* 25 us */6235 udelay(25); /* 25 us */
6246 6236
6247 /* wait for 10 seconds */6237 /* wait for 10 seconds */
6248 timeout = 10000;6238 timeout = 10000;
6249 while (timeout > 0) {6239 while (timeout > 0) {
6250 if (ha->revision_id == IPS_REVID_TROMBONE64) {6240 if (ha->pcidev->revision == IPS_REVID_TROMBONE64) {
6251 outl(0, ha->io_addr + IPS_REG_FLAP);6241 outl(0, ha->io_addr + IPS_REG_FLAP);
6252 udelay(25); /* 25 us */6242 udelay(25); /* 25 us */
6253 }6243 }
@@ -6277,12 +6267,12 @@ ips_erase_bios(ips_ha_t * ha) · 23 unmodified lines
6277 /* Otherwise, we were successful */6267 /* Otherwise, we were successful */
6278 /* clear status */6268 /* clear status */
6279 outb(0x50, ha->io_addr + IPS_REG_FLDP);6269 outb(0x50, ha->io_addr + IPS_REG_FLDP);
6280 if (ha->revision_id == IPS_REVID_TROMBONE64)6270 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6281 udelay(25); /* 25 us */6271 udelay(25); /* 25 us */
6282 6272
6283 /* enable reads */6273 /* enable reads */
6284 outb(0xFF, ha->io_addr + IPS_REG_FLDP);6274 outb(0xFF, ha->io_addr + IPS_REG_FLDP);
6285 if (ha->revision_id == IPS_REVID_TROMBONE64)6275 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6286 udelay(25); /* 25 us */6276 udelay(25); /* 25 us */
6287 6277
6288 return (0);6278 return (0);
@@ -6308,32 +6298,32 @@ ips_erase_bios_memio(ips_ha_t * ha) · 19 unmodified lines
6308 6298
6309 /* Clear the status register */6299 /* Clear the status register */
6310 writel(0, ha->mem_ptr + IPS_REG_FLAP);6300 writel(0, ha->mem_ptr + IPS_REG_FLAP);
6311 if (ha->revision_id == IPS_REVID_TROMBONE64)6301 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6312 udelay(25); /* 25 us */6302 udelay(25); /* 25 us */
6313 6303
6314 writeb(0x50, ha->mem_ptr + IPS_REG_FLDP);6304 writeb(0x50, ha->mem_ptr + IPS_REG_FLDP);
6315 if (ha->revision_id == IPS_REVID_TROMBONE64)6305 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6316 udelay(25); /* 25 us */6306 udelay(25); /* 25 us */
6317 6307
6318 /* Erase Setup */6308 /* Erase Setup */
6319 writeb(0x20, ha->mem_ptr + IPS_REG_FLDP);6309 writeb(0x20, ha->mem_ptr + IPS_REG_FLDP);
6320 if (ha->revision_id == IPS_REVID_TROMBONE64)6310 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6321 udelay(25); /* 25 us */6311 udelay(25); /* 25 us */
6322 6312
6323 /* Erase Confirm */6313 /* Erase Confirm */
6324 writeb(0xD0, ha->mem_ptr + IPS_REG_FLDP);6314 writeb(0xD0, ha->mem_ptr + IPS_REG_FLDP);
6325 if (ha->revision_id == IPS_REVID_TROMBONE64)6315 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6326 udelay(25); /* 25 us */6316 udelay(25); /* 25 us */
6327 6317
6328 /* Erase Status */6318 /* Erase Status */
6329 writeb(0x70, ha->mem_ptr + IPS_REG_FLDP);6319 writeb(0x70, ha->mem_ptr + IPS_REG_FLDP);
6330 if (ha->revision_id == IPS_REVID_TROMBONE64)6320 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6331 udelay(25); /* 25 us */6321 udelay(25); /* 25 us */
6332 6322
6333 timeout = 80000; /* 80 seconds */6323 timeout = 80000; /* 80 seconds */
6334 6324
6335 while (timeout > 0) {6325 while (timeout > 0) {
6336 if (ha->revision_id == IPS_REVID_TROMBONE64) {6326 if (ha->pcidev->revision == IPS_REVID_TROMBONE64) {
6337 writel(0, ha->mem_ptr + IPS_REG_FLAP);6327 writel(0, ha->mem_ptr + IPS_REG_FLAP);
6338 udelay(25); /* 25 us */6328 udelay(25); /* 25 us */
6339 }6329 }
@@ -6353,13 +6343,13 @@ ips_erase_bios_memio(ips_ha_t * ha) · 13 unmodified lines
6353 6343
6354 /* try to suspend the erase */6344 /* try to suspend the erase */
6355 writeb(0xB0, ha->mem_ptr + IPS_REG_FLDP);6345 writeb(0xB0, ha->mem_ptr + IPS_REG_FLDP);
6356 if (ha->revision_id == IPS_REVID_TROMBONE64)6346 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6357 udelay(25); /* 25 us */6347 udelay(25); /* 25 us */
6358 6348
6359 /* wait for 10 seconds */6349 /* wait for 10 seconds */
6360 timeout = 10000;6350 timeout = 10000;
6361 while (timeout > 0) {6351 while (timeout > 0) {
6362 if (ha->revision_id == IPS_REVID_TROMBONE64) {6352 if (ha->pcidev->revision == IPS_REVID_TROMBONE64) {
6363 writel(0, ha->mem_ptr + IPS_REG_FLAP);6353 writel(0, ha->mem_ptr + IPS_REG_FLAP);
6364 udelay(25); /* 25 us */6354 udelay(25); /* 25 us */
6365 }6355 }
@@ -6389,12 +6379,12 @@ ips_erase_bios_memio(ips_ha_t * ha) · 23 unmodified lines
6389 /* Otherwise, we were successful */6379 /* Otherwise, we were successful */
6390 /* clear status */6380 /* clear status */
6391 writeb(0x50, ha->mem_ptr + IPS_REG_FLDP);6381 writeb(0x50, ha->mem_ptr + IPS_REG_FLDP);
6392 if (ha->revision_id == IPS_REVID_TROMBONE64)6382 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6393 udelay(25); /* 25 us */6383 udelay(25); /* 25 us */
6394 6384
6395 /* enable reads */6385 /* enable reads */
6396 writeb(0xFF, ha->mem_ptr + IPS_REG_FLDP);6386 writeb(0xFF, ha->mem_ptr + IPS_REG_FLDP);
6397 if (ha->revision_id == IPS_REVID_TROMBONE64)6387 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6398 udelay(25); /* 25 us */6388 udelay(25); /* 25 us */
6399 6389
6400 return (0);6390 return (0);
@@ -6423,21 +6413,21 @@ ips_program_bios(ips_ha_t * ha, char *buffer, uint32_t buffersize, · 22 unmodified lines
6423 for (i = 0; i < buffersize; i++) {6413 for (i = 0; i < buffersize; i++) {
6424 /* write a byte */6414 /* write a byte */
6425 outl(cpu_to_le32(i + offset), ha->io_addr + IPS_REG_FLAP);6415 outl(cpu_to_le32(i + offset), ha->io_addr + IPS_REG_FLAP);
6426 if (ha->revision_id == IPS_REVID_TROMBONE64)6416 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6427 udelay(25); /* 25 us */6417 udelay(25); /* 25 us */
6428 6418
6429 outb(0x40, ha->io_addr + IPS_REG_FLDP);6419 outb(0x40, ha->io_addr + IPS_REG_FLDP);
6430 if (ha->revision_id == IPS_REVID_TROMBONE64)6420 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6431 udelay(25); /* 25 us */6421 udelay(25); /* 25 us */
6432 6422
6433 outb(buffer[i], ha->io_addr + IPS_REG_FLDP);6423 outb(buffer[i], ha->io_addr + IPS_REG_FLDP);
6434 if (ha->revision_id == IPS_REVID_TROMBONE64)6424 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6435 udelay(25); /* 25 us */6425 udelay(25); /* 25 us */
6436 6426
6437 /* wait up to one second */6427 /* wait up to one second */
6438 timeout = 1000;6428 timeout = 1000;
6439 while (timeout > 0) {6429 while (timeout > 0) {
6440 if (ha->revision_id == IPS_REVID_TROMBONE64) {6430 if (ha->pcidev->revision == IPS_REVID_TROMBONE64) {
6441 outl(0, ha->io_addr + IPS_REG_FLAP);6431 outl(0, ha->io_addr + IPS_REG_FLAP);
6442 udelay(25); /* 25 us */6432 udelay(25); /* 25 us */
6443 }6433 }
@@ -6454,11 +6444,11 @@ ips_program_bios(ips_ha_t * ha, char *buffer, uint32_t buffersize, · 10 unmodified lines
6454 if (timeout == 0) {6444 if (timeout == 0) {
6455 /* timeout error */6445 /* timeout error */
6456 outl(0, ha->io_addr + IPS_REG_FLAP);6446 outl(0, ha->io_addr + IPS_REG_FLAP);
6457 if (ha->revision_id == IPS_REVID_TROMBONE64)6447 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6458 udelay(25); /* 25 us */6448 udelay(25); /* 25 us */
6459 6449
6460 outb(0xFF, ha->io_addr + IPS_REG_FLDP);6450 outb(0xFF, ha->io_addr + IPS_REG_FLDP);
6461 if (ha->revision_id == IPS_REVID_TROMBONE64)6451 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6462 udelay(25); /* 25 us */6452 udelay(25); /* 25 us */
6463 6453
6464 return (1);6454 return (1);
@@ -6468,11 +6458,11 @@ ips_program_bios(ips_ha_t * ha, char *buffer, uint32_t buffersize, · 3 unmodified lines
6468 if (status & 0x18) {6458 if (status & 0x18) {
6469 /* programming error */6459 /* programming error */
6470 outl(0, ha->io_addr + IPS_REG_FLAP);6460 outl(0, ha->io_addr + IPS_REG_FLAP);
6471 if (ha->revision_id == IPS_REVID_TROMBONE64)6461 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6472 udelay(25); /* 25 us */6462 udelay(25); /* 25 us */
6473 6463
6474 outb(0xFF, ha->io_addr + IPS_REG_FLDP);6464 outb(0xFF, ha->io_addr + IPS_REG_FLDP);
6475 if (ha->revision_id == IPS_REVID_TROMBONE64)6465 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6476 udelay(25); /* 25 us */6466 udelay(25); /* 25 us */
6477 6467
6478 return (1);6468 return (1);
@@ -6481,11 +6471,11 @@ ips_program_bios(ips_ha_t * ha, char *buffer, uint32_t buffersize, · 2 unmodified lines
6481 6471
6482 /* Enable reading */6472 /* Enable reading */
6483 outl(0, ha->io_addr + IPS_REG_FLAP);6473 outl(0, ha->io_addr + IPS_REG_FLAP);
6484 if (ha->revision_id == IPS_REVID_TROMBONE64)6474 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6485 udelay(25); /* 25 us */6475 udelay(25); /* 25 us */
6486 6476
6487 outb(0xFF, ha->io_addr + IPS_REG_FLDP);6477 outb(0xFF, ha->io_addr + IPS_REG_FLDP);
6488 if (ha->revision_id == IPS_REVID_TROMBONE64)6478 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6489 udelay(25); /* 25 us */6479 udelay(25); /* 25 us */
6490 6480
6491 return (0);6481 return (0);
@@ -6514,21 +6504,21 @@ ips_program_bios_memio(ips_ha_t * ha, char *buffer, uint32_t buffersize, · 22 unmodified lines
6514 for (i = 0; i < buffersize; i++) {6504 for (i = 0; i < buffersize; i++) {
6515 /* write a byte */6505 /* write a byte */
6516 writel(i + offset, ha->mem_ptr + IPS_REG_FLAP);6506 writel(i + offset, ha->mem_ptr + IPS_REG_FLAP);
6517 if (ha->revision_id == IPS_REVID_TROMBONE64)6507 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6518 udelay(25); /* 25 us */6508 udelay(25); /* 25 us */
6519 6509
6520 writeb(0x40, ha->mem_ptr + IPS_REG_FLDP);6510 writeb(0x40, ha->mem_ptr + IPS_REG_FLDP);
6521 if (ha->revision_id == IPS_REVID_TROMBONE64)6511 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6522 udelay(25); /* 25 us */6512 udelay(25); /* 25 us */
6523 6513
6524 writeb(buffer[i], ha->mem_ptr + IPS_REG_FLDP);6514 writeb(buffer[i], ha->mem_ptr + IPS_REG_FLDP);
6525 if (ha->revision_id == IPS_REVID_TROMBONE64)6515 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6526 udelay(25); /* 25 us */6516 udelay(25); /* 25 us */
6527 6517
6528 /* wait up to one second */6518 /* wait up to one second */
6529 timeout = 1000;6519 timeout = 1000;
6530 while (timeout > 0) {6520 while (timeout > 0) {
6531 if (ha->revision_id == IPS_REVID_TROMBONE64) {6521 if (ha->pcidev->revision == IPS_REVID_TROMBONE64) {
6532 writel(0, ha->mem_ptr + IPS_REG_FLAP);6522 writel(0, ha->mem_ptr + IPS_REG_FLAP);
6533 udelay(25); /* 25 us */6523 udelay(25); /* 25 us */
6534 }6524 }
@@ -6545,11 +6535,11 @@ ips_program_bios_memio(ips_ha_t * ha, char *buffer, uint32_t buffersize, · 10 unmodified lines
6545 if (timeout == 0) {6535 if (timeout == 0) {
6546 /* timeout error */6536 /* timeout error */
6547 writel(0, ha->mem_ptr + IPS_REG_FLAP);6537 writel(0, ha->mem_ptr + IPS_REG_FLAP);
6548 if (ha->revision_id == IPS_REVID_TROMBONE64)6538 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6549 udelay(25); /* 25 us */6539 udelay(25); /* 25 us */
6550 6540
6551 writeb(0xFF, ha->mem_ptr + IPS_REG_FLDP);6541 writeb(0xFF, ha->mem_ptr + IPS_REG_FLDP);
6552 if (ha->revision_id == IPS_REVID_TROMBONE64)6542 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6553 udelay(25); /* 25 us */6543 udelay(25); /* 25 us */
6554 6544
6555 return (1);6545 return (1);
@@ -6559,11 +6549,11 @@ ips_program_bios_memio(ips_ha_t * ha, char *buffer, uint32_t buffersize, · 3 unmodified lines
6559 if (status & 0x18) {6549 if (status & 0x18) {
6560 /* programming error */6550 /* programming error */
6561 writel(0, ha->mem_ptr + IPS_REG_FLAP);6551 writel(0, ha->mem_ptr + IPS_REG_FLAP);
6562 if (ha->revision_id == IPS_REVID_TROMBONE64)6552 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6563 udelay(25); /* 25 us */6553 udelay(25); /* 25 us */
6564 6554
6565 writeb(0xFF, ha->mem_ptr + IPS_REG_FLDP);6555 writeb(0xFF, ha->mem_ptr + IPS_REG_FLDP);
6566 if (ha->revision_id == IPS_REVID_TROMBONE64)6556 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6567 udelay(25); /* 25 us */6557 udelay(25); /* 25 us */
6568 6558
6569 return (1);6559 return (1);
@@ -6572,11 +6562,11 @@ ips_program_bios_memio(ips_ha_t * ha, char *buffer, uint32_t buffersize, · 2 unmodified lines
6572 6562
6573 /* Enable reading */6563 /* Enable reading */
6574 writel(0, ha->mem_ptr + IPS_REG_FLAP);6564 writel(0, ha->mem_ptr + IPS_REG_FLAP);
6575 if (ha->revision_id == IPS_REVID_TROMBONE64)6565 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6576 udelay(25); /* 25 us */6566 udelay(25); /* 25 us */
6577 6567
6578 writeb(0xFF, ha->mem_ptr + IPS_REG_FLDP);6568 writeb(0xFF, ha->mem_ptr + IPS_REG_FLDP);
6579 if (ha->revision_id == IPS_REVID_TROMBONE64)6569 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6580 udelay(25); /* 25 us */6570 udelay(25); /* 25 us */
6581 6571
6582 return (0);6572 return (0);
@@ -6601,14 +6591,14 @@ ips_verify_bios(ips_ha_t * ha, char *buffer, uint32_t buffersize, · 18 unmodified lines
6601 6591
6602 /* test 1st byte */6592 /* test 1st byte */
6603 outl(0, ha->io_addr + IPS_REG_FLAP);6593 outl(0, ha->io_addr + IPS_REG_FLAP);
6604 if (ha->revision_id == IPS_REVID_TROMBONE64)6594 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6605 udelay(25); /* 25 us */6595 udelay(25); /* 25 us */
6606 6596
6607 if (inb(ha->io_addr + IPS_REG_FLDP) != 0x55)6597 if (inb(ha->io_addr + IPS_REG_FLDP) != 0x55)
6608 return (1);6598 return (1);
6609 6599
6610 outl(cpu_to_le32(1), ha->io_addr + IPS_REG_FLAP);6600 outl(cpu_to_le32(1), ha->io_addr + IPS_REG_FLAP);
6611 if (ha->revision_id == IPS_REVID_TROMBONE64)6601 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6612 udelay(25); /* 25 us */6602 udelay(25); /* 25 us */
6613 if (inb(ha->io_addr + IPS_REG_FLDP) != 0xAA)6603 if (inb(ha->io_addr + IPS_REG_FLDP) != 0xAA)
6614 return (1);6604 return (1);
@@ -6617,7 +6607,7 @@ ips_verify_bios(ips_ha_t * ha, char *buffer, uint32_t buffersize, · 2 unmodified lines
6617 for (i = 2; i < buffersize; i++) {6607 for (i = 2; i < buffersize; i++) {
6618 6608
6619 outl(cpu_to_le32(i + offset), ha->io_addr + IPS_REG_FLAP);6609 outl(cpu_to_le32(i + offset), ha->io_addr + IPS_REG_FLAP);
6620 if (ha->revision_id == IPS_REVID_TROMBONE64)6610 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6621 udelay(25); /* 25 us */6611 udelay(25); /* 25 us */
6622 6612
6623 checksum = (uint8_t) checksum + inb(ha->io_addr + IPS_REG_FLDP);6613 checksum = (uint8_t) checksum + inb(ha->io_addr + IPS_REG_FLDP);
@@ -6650,14 +6640,14 @@ ips_verify_bios_memio(ips_ha_t * ha, char *buffer, uint32_t buffersize, · 26 unmodified lines
6650 6640
6651 /* test 1st byte */6641 /* test 1st byte */
6652 writel(0, ha->mem_ptr + IPS_REG_FLAP);6642 writel(0, ha->mem_ptr + IPS_REG_FLAP);
6653 if (ha->revision_id == IPS_REVID_TROMBONE64)6643 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6654 udelay(25); /* 25 us */6644 udelay(25); /* 25 us */
6655 6645
6656 if (readb(ha->mem_ptr + IPS_REG_FLDP) != 0x55)6646 if (readb(ha->mem_ptr + IPS_REG_FLDP) != 0x55)
6657 return (1);6647 return (1);
6658 6648
6659 writel(1, ha->mem_ptr + IPS_REG_FLAP);6649 writel(1, ha->mem_ptr + IPS_REG_FLAP);
6660 if (ha->revision_id == IPS_REVID_TROMBONE64)6650 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6661 udelay(25); /* 25 us */6651 udelay(25); /* 25 us */
6662 if (readb(ha->mem_ptr + IPS_REG_FLDP) != 0xAA)6652 if (readb(ha->mem_ptr + IPS_REG_FLDP) != 0xAA)
6663 return (1);6653 return (1);
@@ -6666,7 +6656,7 @@ ips_verify_bios_memio(ips_ha_t * ha, char *buffer, uint32_t buffersize, · 2 unmodified lines
6666 for (i = 2; i < buffersize; i++) {6656 for (i = 2; i < buffersize; i++) {
6667 6657
6668 writel(i + offset, ha->mem_ptr + IPS_REG_FLAP);6658 writel(i + offset, ha->mem_ptr + IPS_REG_FLAP);
6669 if (ha->revision_id == IPS_REVID_TROMBONE64)6659 if (ha->pcidev->revision == IPS_REVID_TROMBONE64)
6670 udelay(25); /* 25 us */6660 udelay(25); /* 25 us */
6671 6661
6672 checksum =6662 checksum =
@@ -6837,24 +6827,18 @@ ips_register_scsi(int index) · 164 unmodified lines
6837 }6827 }
6838 ha = IPS_HA(sh);6828 ha = IPS_HA(sh);
6839 memcpy(ha, oldha, sizeof (ips_ha_t));6829 memcpy(ha, oldha, sizeof (ips_ha_t));
6840 free_irq(oldha->irq, oldha);6830 free_irq(oldha->pcidev->irq, oldha);
6841 /* Install the interrupt handler with the new ha */6831 /* Install the interrupt handler with the new ha */
6842 if (request_irq(ha->irq, do_ipsintr, IRQF_SHARED, ips_name, ha)) {6832 if (request_irq(ha->pcidev->irq, do_ipsintr, IRQF_SHARED, ips_name, ha)) {
6843 IPS_PRINTK(KERN_WARNING, ha->pcidev,6833 IPS_PRINTK(KERN_WARNING, ha->pcidev,
6844 "Unable to install interrupt handler\n");6834 "Unable to install interrupt handler\n");
6845 scsi_host_put(sh);6835 goto err_out_sh;
6846 return -1;
6847 }6836 }
6848 6837
6849 kfree(oldha);6838 kfree(oldha);
6850 ips_sh[index] = sh;
6851 ips_ha[index] = ha;
6852 6839
6853 /* Store away needed values for later use */6840 /* Store away needed values for later use */
6854 sh->io_port = ha->io_addr;
6855 sh->n_io_port = ha->io_addr ? 255 : 0;
6856 sh->unique_id = (ha->io_addr) ? ha->io_addr : ha->mem_addr;6841 sh->unique_id = (ha->io_addr) ? ha->io_addr : ha->mem_addr;
6857 sh->irq = ha->irq;
6858 sh->sg_tablesize = sh->hostt->sg_tablesize;6842 sh->sg_tablesize = sh->hostt->sg_tablesize;
6859 sh->can_queue = sh->hostt->can_queue;6843 sh->can_queue = sh->hostt->can_queue;
6860 sh->cmd_per_lun = sh->hostt->cmd_per_lun;6844 sh->cmd_per_lun = sh->hostt->cmd_per_lun;
@@ -6867,10 +6851,21 @@ ips_register_scsi(int index) · 6 unmodified lines
6867 sh->max_channel = ha->nbus - 1;6851 sh->max_channel = ha->nbus - 1;
6868 sh->can_queue = ha->max_cmds - 1;6852 sh->can_queue = ha->max_cmds - 1;
6869 6853
6870 scsi_add_host(sh, NULL);6854 if (scsi_add_host(sh, &ha->pcidev->dev))
6855 goto err_out;
6856
6857 ips_sh[index] = sh;
6858 ips_ha[index] = ha;
6859
6871 scsi_scan_host(sh);6860 scsi_scan_host(sh);
6872 6861
6873 return 0;6862 return 0;
6863
6864err_out:
6865 free_irq(ha->pcidev->irq, ha);
6866err_out_sh:
6867 scsi_host_put(sh);
6868 return -1;
6874}6869}
6875 6870
6876/*---------------------------------------------------------------------------*/6871/*---------------------------------------------------------------------------*/
@@ -6882,20 +6877,14 @@ ips_register_scsi(int index) · 5 unmodified lines
6882static void __devexit6877static void __devexit
6883ips_remove_device(struct pci_dev *pci_dev)6878ips_remove_device(struct pci_dev *pci_dev)
6884{6879{
6885 int i;6880 struct Scsi_Host *sh = pci_get_drvdata(pci_dev);
6886 struct Scsi_Host *sh;
6887 ips_ha_t *ha;
6888 6881
6889 for (i = 0; i < IPS_MAX_ADAPTERS; i++) {6882 pci_set_drvdata(pci_dev, NULL);
6890 ha = ips_ha[i];6883
6891 if (ha) {6884 ips_release(sh);
6892 if ((pci_dev->bus->number == ha->pcidev->bus->number) &&6885
6893 (pci_dev->devfn == ha->pcidev->devfn)) {6886 pci_release_regions(pci_dev);
6894 sh = ips_sh[i];6887 pci_disable_device(pci_dev);
6895 ips_release(sh);
6896 }
6897 }
6898 }
6899}6888}
6900 6889
6901/****************************************************************************/6890/****************************************************************************/
@@ -6949,12 +6938,17 @@ module_exit(ips_module_exit); · 47 unmodified lines
6949static int __devinit6938static int __devinit
6950ips_insert_device(struct pci_dev *pci_dev, const struct pci_device_id *ent)6939ips_insert_device(struct pci_dev *pci_dev, const struct pci_device_id *ent)
6951{6940{
6952 int uninitialized_var(index);6941 int index = -1;
6953 int rc;6942 int rc;
6954 6943
6955 METHOD_TRACE("ips_insert_device", 1);6944 METHOD_TRACE("ips_insert_device", 1);
6956 if (pci_enable_device(pci_dev))6945 rc = pci_enable_device(pci_dev);
6957 return -1;6946 if (rc)
6947 return rc;
6948
6949 rc = pci_request_regions(pci_dev, "ips");
6950 if (rc)
6951 goto err_out;
6958 6952
6959 rc = ips_init_phase1(pci_dev, &index);6953 rc = ips_init_phase1(pci_dev, &index);
6960 if (rc == SUCCESS)6954 if (rc == SUCCESS)
@@ -6970,6 +6964,19 @@ ips_insert_device(struct pci_dev *pci_dev, const struct pci_device_id *ent) · 9 unmodified lines
6970 ips_num_controllers++;6964 ips_num_controllers++;
6971 6965
6972 ips_next_controller = ips_num_controllers;6966 ips_next_controller = ips_num_controllers;
6967
6968 if (rc < 0) {
6969 rc = -ENODEV;
6970 goto err_out_regions;
6971 }
6972
6973 pci_set_drvdata(pci_dev, ips_sh[index]);
6974 return 0;
6975
6976err_out_regions:
6977 pci_release_regions(pci_dev);
6978err_out:
6979 pci_disable_device(pci_dev);
6973 return rc;6980 return rc;
6974}6981}
6975 6982
@@ -6992,8 +6999,6 @@ ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr) · 16 unmodified lines
6992 uint32_t mem_len;6999 uint32_t mem_len;
6993 uint8_t bus;7000 uint8_t bus;
6994 uint8_t func;7001 uint8_t func;
6995 uint8_t irq;
6996 uint16_t subdevice_id;
6997 int j;7002 int j;
6998 int index;7003 int index;
6999 dma_addr_t dma_address;7004 dma_addr_t dma_address;
@@ -7004,7 +7009,7 @@ ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr) · 4 unmodified lines
7004 METHOD_TRACE("ips_init_phase1", 1);7009 METHOD_TRACE("ips_init_phase1", 1);
7005 index = IPS_MAX_ADAPTERS;7010 index = IPS_MAX_ADAPTERS;
7006 for (j = 0; j < IPS_MAX_ADAPTERS; j++) {7011 for (j = 0; j < IPS_MAX_ADAPTERS; j++) {
7007 if (ips_ha[j] == 0) {7012 if (ips_ha[j] == NULL) {
7008 index = j;7013 index = j;
7009 break;7014 break;
7010 }7015 }
@@ -7014,7 +7019,6 @@ ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr) · 3 unmodified lines
7014 return -1;7019 return -1;
7015 7020
7016 /* stuff that we get in dev */7021 /* stuff that we get in dev */
7017 irq = pci_dev->irq;
7018 bus = pci_dev->bus->number;7022 bus = pci_dev->bus->number;
7019 func = pci_dev->devfn;7023 func = pci_dev->devfn;
7020 7024
@@ -7042,34 +7046,17 @@ ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr) · 21 unmodified lines
7042 uint32_t base;7046 uint32_t base;
7043 uint32_t offs;7047 uint32_t offs;
7044 7048
7045 if (!request_mem_region(mem_addr, mem_len, "ips")) {
7046 IPS_PRINTK(KERN_WARNING, pci_dev,
7047 "Couldn't allocate IO Memory space %x len %d.\n",
7048 mem_addr, mem_len);
7049 return -1;
7050 }
7051
7052 base = mem_addr & PAGE_MASK;7049 base = mem_addr & PAGE_MASK;
7053 offs = mem_addr - base;7050 offs = mem_addr - base;
7054 ioremap_ptr = ioremap(base, PAGE_SIZE);7051 ioremap_ptr = ioremap(base, PAGE_SIZE);
7052 if (!ioremap_ptr)
7053 return -1;
7055 mem_ptr = ioremap_ptr + offs;7054 mem_ptr = ioremap_ptr + offs;
7056 } else {7055 } else {
7057 ioremap_ptr = NULL;7056 ioremap_ptr = NULL;
7058 mem_ptr = NULL;7057 mem_ptr = NULL;
7059 }7058 }
7060 7059
7061 /* setup I/O mapped area (if applicable) */
7062 if (io_addr) {
7063 if (!request_region(io_addr, io_len, "ips")) {
7064 IPS_PRINTK(KERN_WARNING, pci_dev,
7065 "Couldn't allocate IO space %x len %d.\n",
7066 io_addr, io_len);
7067 return -1;
7068 }
7069 }
7070
7071 subdevice_id = pci_dev->subsystem_device;
7072
7073 /* found a controller */7060 /* found a controller */
7074 ha = kzalloc(sizeof (ips_ha_t), GFP_KERNEL);7061 ha = kzalloc(sizeof (ips_ha_t), GFP_KERNEL);
7075 if (ha == NULL) {7062 if (ha == NULL) {
@@ -7078,13 +7065,11 @@ ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr) · 2 unmodified lines
7078 return -1;7065 return -1;
7079 }7066 }
7080 7067
7081
7082 ips_sh[index] = NULL;7068 ips_sh[index] = NULL;
7083 ips_ha[index] = ha;7069 ips_ha[index] = ha;
7084 ha->active = 1;7070 ha->active = 1;
7085 7071
7086 /* Store info in HA structure */7072 /* Store info in HA structure */
7087 ha->irq = irq;
7088 ha->io_addr = io_addr;7073 ha->io_addr = io_addr;
7089 ha->io_len = io_len;7074 ha->io_len = io_len;
7090 ha->mem_addr = mem_addr;7075 ha->mem_addr = mem_addr;
@@ -7092,10 +7077,7 @@ ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr) · 1 unmodified line
7092 ha->mem_ptr = mem_ptr;7077 ha->mem_ptr = mem_ptr;
7093 ha->ioremap_ptr = ioremap_ptr;7078 ha->ioremap_ptr = ioremap_ptr;
7094 ha->host_num = (uint32_t) index;7079 ha->host_num = (uint32_t) index;
7095 ha->revision_id = pci_dev->revision;
7096 ha->slot_num = PCI_SLOT(pci_dev->devfn);7080 ha->slot_num = PCI_SLOT(pci_dev->devfn);
7097 ha->device_id = pci_dev->device;
7098 ha->subdevice_id = subdevice_id;
7099 ha->pcidev = pci_dev;7081 ha->pcidev = pci_dev;
7100 7082
7101 /*7083 /*
@@ -7240,7 +7222,7 @@ ips_init_phase2(int index) · 138 unmodified lines
7240 }7222 }
7241 7223
7242 /* Install the interrupt handler */7224 /* Install the interrupt handler */
7243 if (request_irq(ha->irq, do_ipsintr, IRQF_SHARED, ips_name, ha)) {7225 if (request_irq(ha->pcidev->irq, do_ipsintr, IRQF_SHARED, ips_name, ha)) {
7244 IPS_PRINTK(KERN_WARNING, ha->pcidev,7226 IPS_PRINTK(KERN_WARNING, ha->pcidev,
7245 "Unable to install interrupt handler\n");7227 "Unable to install interrupt handler\n");
7246 return ips_abort_init(ha, index);7228 return ips_abort_init(ha, index);
@@ -7253,14 +7235,14 @@ ips_init_phase2(int index) · 6 unmodified lines
7253 if (!ips_allocatescbs(ha)) {7235 if (!ips_allocatescbs(ha)) {
7254 IPS_PRINTK(KERN_WARNING, ha->pcidev,7236 IPS_PRINTK(KERN_WARNING, ha->pcidev,
7255 "Unable to allocate a CCB\n");7237 "Unable to allocate a CCB\n");
7256 free_irq(ha->irq, ha);7238 free_irq(ha->pcidev->irq, ha);
7257 return ips_abort_init(ha, index);7239 return ips_abort_init(ha, index);
7258 }7240 }
7259 7241
7260 if (!ips_hainit(ha)) {7242 if (!ips_hainit(ha)) {
7261 IPS_PRINTK(KERN_WARNING, ha->pcidev,7243 IPS_PRINTK(KERN_WARNING, ha->pcidev,
7262 "Unable to initialize controller\n");7244 "Unable to initialize controller\n");
7263 free_irq(ha->irq, ha);7245 free_irq(ha->pcidev->irq, ha);
7264 return ips_abort_init(ha, index);7246 return ips_abort_init(ha, index);
7265 }7247 }
7266 /* Free the temporary SCB */7248 /* Free the temporary SCB */
@@ -7270,7 +7252,7 @@ ips_init_phase2(int index) · 3 unmodified lines
7270 if (!ips_allocatescbs(ha)) {7252 if (!ips_allocatescbs(ha)) {
7271 IPS_PRINTK(KERN_WARNING, ha->pcidev,7253 IPS_PRINTK(KERN_WARNING, ha->pcidev,
7272 "Unable to allocate CCBs\n");7254 "Unable to allocate CCBs\n");
7273 free_irq(ha->irq, ha);7255 free_irq(ha->pcidev->irq, ha);
7274 return ips_abort_init(ha, index);7256 return ips_abort_init(ha, index);
7275 }7257 }
7276 7258
drivers/scsi/ips.h+14−18
@@ -60,14 +60,14 @@ · 59 unmodified lines
60 */60 */
61 #define IPS_HA(x) ((ips_ha_t *) x->hostdata)61 #define IPS_HA(x) ((ips_ha_t *) x->hostdata)
62 #define IPS_COMMAND_ID(ha, scb) (int) (scb - ha->scbs)62 #define IPS_COMMAND_ID(ha, scb) (int) (scb - ha->scbs)
63 #define IPS_IS_TROMBONE(ha) (((ha->device_id == IPS_DEVICEID_COPPERHEAD) && \63 #define IPS_IS_TROMBONE(ha) (((ha->pcidev->device == IPS_DEVICEID_COPPERHEAD) && \
64 (ha->revision_id >= IPS_REVID_TROMBONE32) && \64 (ha->pcidev->revision >= IPS_REVID_TROMBONE32) && \
65 (ha->revision_id <= IPS_REVID_TROMBONE64)) ? 1 : 0)65 (ha->pcidev->revision <= IPS_REVID_TROMBONE64)) ? 1 : 0)
66 #define IPS_IS_CLARINET(ha) (((ha->device_id == IPS_DEVICEID_COPPERHEAD) && \66 #define IPS_IS_CLARINET(ha) (((ha->pcidev->device == IPS_DEVICEID_COPPERHEAD) && \
67 (ha->revision_id >= IPS_REVID_CLARINETP1) && \67 (ha->pcidev->revision >= IPS_REVID_CLARINETP1) && \
68 (ha->revision_id <= IPS_REVID_CLARINETP3)) ? 1 : 0)68 (ha->pcidev->revision <= IPS_REVID_CLARINETP3)) ? 1 : 0)
69 #define IPS_IS_MORPHEUS(ha) (ha->device_id == IPS_DEVICEID_MORPHEUS)69 #define IPS_IS_MORPHEUS(ha) (ha->pcidev->device == IPS_DEVICEID_MORPHEUS)
70 #define IPS_IS_MARCO(ha) (ha->device_id == IPS_DEVICEID_MARCO)70 #define IPS_IS_MARCO(ha) (ha->pcidev->device == IPS_DEVICEID_MARCO)
71 #define IPS_USE_I2O_DELIVER(ha) ((IPS_IS_MORPHEUS(ha) || \71 #define IPS_USE_I2O_DELIVER(ha) ((IPS_IS_MORPHEUS(ha) || \
72 (IPS_IS_TROMBONE(ha) && \72 (IPS_IS_TROMBONE(ha) && \
73 (ips_force_i2o))) ? 1 : 0)73 (ips_force_i2o))) ? 1 : 0)
@@ -92,7 +92,7 @@ · 18 unmodified lines
92 #ifndef min92 #ifndef min
93 #define min(x,y) ((x) < (y) ? x : y)93 #define min(x,y) ((x) < (y) ? x : y)
94 #endif94 #endif
95 95
96 #ifndef __iomem /* For clean compiles in earlier kernels without __iomem annotations */96 #ifndef __iomem /* For clean compiles in earlier kernels without __iomem annotations */
97 #define __iomem97 #define __iomem
98 #endif98 #endif
@@ -171,7 +171,7 @@ · 72 unmodified lines
171 #define IPS_CMD_DOWNLOAD 0x20171 #define IPS_CMD_DOWNLOAD 0x20
172 #define IPS_CMD_RW_BIOSFW 0x22172 #define IPS_CMD_RW_BIOSFW 0x22
173 #define IPS_CMD_GET_VERSION_INFO 0xC6173 #define IPS_CMD_GET_VERSION_INFO 0xC6
174 #define IPS_CMD_RESET_CHANNEL 0x1A 174 #define IPS_CMD_RESET_CHANNEL 0x1A
175 175
176 /*176 /*
177 * Adapter Equates177 * Adapter Equates
@@ -458,7 +458,7 @@ typedef struct { · 280 unmodified lines
458 uint32_t reserved3;458 uint32_t reserved3;
459 uint32_t buffer_addr;459 uint32_t buffer_addr;
460 uint32_t reserved4;460 uint32_t reserved4;
461} IPS_IOCTL_CMD, *PIPS_IOCTL_CMD; 461} IPS_IOCTL_CMD, *PIPS_IOCTL_CMD;
462 462
463typedef struct {463typedef struct {
464 uint8_t op_code;464 uint8_t op_code;
@@ -552,7 +552,7 @@ typedef struct { · 87 unmodified lines
552 uint32_t cccr;552 uint32_t cccr;
553} IPS_NVRAM_CMD, *PIPS_NVRAM_CMD;553} IPS_NVRAM_CMD, *PIPS_NVRAM_CMD;
554 554
555typedef struct 555typedef struct
556{556{
557 uint8_t op_code;557 uint8_t op_code;
558 uint8_t command_id;558 uint8_t command_id;
@@ -650,7 +650,7 @@ typedef struct { · 91 unmodified lines
650 uint8_t device_address;650 uint8_t device_address;
651 uint8_t cmd_attribute;651 uint8_t cmd_attribute;
652 uint8_t cdb_length;652 uint8_t cdb_length;
653 uint8_t reserved_for_LUN; 653 uint8_t reserved_for_LUN;
654 uint32_t transfer_length;654 uint32_t transfer_length;
655 uint32_t buffer_pointer;655 uint32_t buffer_pointer;
656 uint16_t sg_count;656 uint16_t sg_count;
@@ -790,7 +790,7 @@ typedef struct { · 133 unmodified lines
790 /* SubSystem Parameter[4] */790 /* SubSystem Parameter[4] */
791#define IPS_GET_VERSION_SUPPORT 0x00018000 /* Mask for Versioning Support */791#define IPS_GET_VERSION_SUPPORT 0x00018000 /* Mask for Versioning Support */
792 792
793typedef struct 793typedef struct
794{794{
795 uint32_t revision;795 uint32_t revision;
796 uint8_t bootBlkVersion[32];796 uint8_t bootBlkVersion[32];
@@ -1034,7 +1034,6 @@ typedef struct ips_ha { · 237 unmodified lines
1034 uint8_t ha_id[IPS_MAX_CHANNELS+1];1034 uint8_t ha_id[IPS_MAX_CHANNELS+1];
1035 uint32_t dcdb_active[IPS_MAX_CHANNELS];1035 uint32_t dcdb_active[IPS_MAX_CHANNELS];
1036 uint32_t io_addr; /* Base I/O address */1036 uint32_t io_addr; /* Base I/O address */
1037 uint8_t irq; /* IRQ for adapter */
1038 uint8_t ntargets; /* Number of targets */1037 uint8_t ntargets; /* Number of targets */
1039 uint8_t nbus; /* Number of buses */1038 uint8_t nbus; /* Number of buses */
1040 uint8_t nlun; /* Number of Luns */1039 uint8_t nlun; /* Number of Luns */
@@ -1066,10 +1065,7 @@ typedef struct ips_ha { · 25 unmodified lines
1066 int ioctl_reset; /* IOCTL Requested Reset Flag */1065 int ioctl_reset; /* IOCTL Requested Reset Flag */
1067 uint16_t reset_count; /* number of resets */1066 uint16_t reset_count; /* number of resets */
1068 time_t last_ffdc; /* last time we sent ffdc info*/1067 time_t last_ffdc; /* last time we sent ffdc info*/
1069 uint8_t revision_id; /* Revision level */
1070 uint16_t device_id; /* PCI device ID */
1071 uint8_t slot_num; /* PCI Slot Number */1068 uint8_t slot_num; /* PCI Slot Number */
1072 uint16_t subdevice_id; /* Subsystem device ID */
1073 int ioctl_len; /* size of ioctl buffer */1069 int ioctl_len; /* size of ioctl buffer */
1074 dma_addr_t ioctl_busaddr; /* dma address of ioctl buffer*/1070 dma_addr_t ioctl_busaddr; /* dma address of ioctl buffer*/
1075 uint8_t bios_version[8]; /* BIOS Revision */1071 uint8_t bios_version[8]; /* BIOS Revision */
drivers/scsi/iscsi_tcp.c+896−1187
@@ -48,7 +48,7 @@ MODULE_AUTHOR("Dmitry Yusupov <dmitry_yus@yahoo.com>, " · 47 unmodified lines
48 "Alex Aizman <itn780@yahoo.com>");48 "Alex Aizman <itn780@yahoo.com>");
49MODULE_DESCRIPTION("iSCSI/TCP data-path");49MODULE_DESCRIPTION("iSCSI/TCP data-path");
50MODULE_LICENSE("GPL");50MODULE_LICENSE("GPL");
51/* #define DEBUG_TCP */51#undef DEBUG_TCP
52#define DEBUG_ASSERT52#define DEBUG_ASSERT
53 53
54#ifdef DEBUG_TCP54#ifdef DEBUG_TCP
@@ -67,115 +67,429 @@ MODULE_LICENSE("GPL"); · 12 unmodified lines
67static unsigned int iscsi_max_lun = 512;67static unsigned int iscsi_max_lun = 512;
68module_param_named(max_lun, iscsi_max_lun, uint, S_IRUGO);68module_param_named(max_lun, iscsi_max_lun, uint, S_IRUGO);
69 69
70static int iscsi_tcp_hdr_recv_done(struct iscsi_tcp_conn *tcp_conn,
71 struct iscsi_segment *segment);
72
73/*
74 * Scatterlist handling: inside the iscsi_segment, we
75 * remember an index into the scatterlist, and set data/size
76 * to the current scatterlist entry. For highmem pages, we
77 * kmap as needed.
78 *
79 * Note that the page is unmapped when we return from
80 * TCP's data_ready handler, so we may end up mapping and
81 * unmapping the same page repeatedly. The whole reason
82 * for this is that we shouldn't keep the page mapped
83 * outside the softirq.
84 */
85
86/**
87 * iscsi_tcp_segment_init_sg - init indicated scatterlist entry
88 * @segment: the buffer object
89 * @sg: scatterlist
90 * @offset: byte offset into that sg entry
91 *
92 * This function sets up the segment so that subsequent
93 * data is copied to the indicated sg entry, at the given
94 * offset.
95 */
70static inline void96static inline void
71iscsi_buf_init_iov(struct iscsi_buf *ibuf, char *vbuf, int size)97iscsi_tcp_segment_init_sg(struct iscsi_segment *segment,
98 struct scatterlist *sg, unsigned int offset)
72{99{
73 sg_init_one(&ibuf->sg, vbuf, size);100 segment->sg = sg;
74 ibuf->sent = 0;101 segment->sg_offset = offset;
75 ibuf->use_sendmsg = 1;102 segment->size = min(sg->length - offset,
103 segment->total_size - segment->total_copied);
104 segment->data = NULL;
76}105}
77 106
107/**
108 * iscsi_tcp_segment_map - map the current S/G page
109 * @segment: iscsi_segment
110 * @recv: 1 if called from recv path
111 *
112 * We only need to possibly kmap data if scatter lists are being used,
113 * because the iscsi passthrough and internal IO paths will never use high
114 * mem pages.
115 */
78static inline void116static inline void
79iscsi_buf_init_sg(struct iscsi_buf *ibuf, struct scatterlist *sg)117iscsi_tcp_segment_map(struct iscsi_segment *segment, int recv)
80{118{
81 sg_init_table(&ibuf->sg, 1);119 struct scatterlist *sg;
82 sg_set_page(&ibuf->sg, sg_page(sg), sg->length, sg->offset);120
121 if (segment->data != NULL || !segment->sg)
122 return;
123
124 sg = segment->sg;
125 BUG_ON(segment->sg_mapped);
126 BUG_ON(sg->length == 0);
127
83 /*128 /*
84 * Fastpath: sg element fits into single page129 * If the page count is greater than one it is ok to send
130 * to the network layer's zero copy send path. If not we
131 * have to go the slow sendmsg path. We always map for the
132 * recv path.
85 */133 */
86 if (sg->length + sg->offset <= PAGE_SIZE && !PageSlab(sg_page(sg)))134 if (page_count(sg_page(sg)) >= 1 && !recv)
87 ibuf->use_sendmsg = 0;135 return;
88 else136
89 ibuf->use_sendmsg = 1;137 debug_tcp("iscsi_tcp_segment_map %s %p\n", recv ? "recv" : "xmit",
90 ibuf->sent = 0;138 segment);
139 segment->sg_mapped = kmap_atomic(sg_page(sg), KM_SOFTIRQ0);
140 segment->data = segment->sg_mapped + sg->offset + segment->sg_offset;
91}141}
92 142
93static inline int143static inline void
94iscsi_buf_left(struct iscsi_buf *ibuf)144iscsi_tcp_segment_unmap(struct iscsi_segment *segment)
95{145{
96 int rc;146 debug_tcp("iscsi_tcp_segment_unmap %p\n", segment);
97 147
98 rc = ibuf->sg.length - ibuf->sent;148 if (segment->sg_mapped) {
99 BUG_ON(rc < 0);149 debug_tcp("iscsi_tcp_segment_unmap valid\n");
100 return rc;150 kunmap_atomic(segment->sg_mapped, KM_SOFTIRQ0);
151 segment->sg_mapped = NULL;
152 segment->data = NULL;
153 }
101}154}
102 155
156/*
157 * Splice the digest buffer into the buffer
158 */
103static inline void159static inline void
104iscsi_hdr_digest(struct iscsi_conn *conn, struct iscsi_buf *buf,160iscsi_tcp_segment_splice_digest(struct iscsi_segment *segment, void *digest)
105 u8* crc)
106{161{
107 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;162 segment->data = digest;
108 163 segment->digest_len = ISCSI_DIGEST_SIZE;
109 crypto_hash_digest(&tcp_conn->tx_hash, &buf->sg, buf->sg.length, crc);164 segment->total_size += ISCSI_DIGEST_SIZE;
110 buf->sg.length += sizeof(u32);165 segment->size = ISCSI_DIGEST_SIZE;
166 segment->copied = 0;
167 segment->sg = NULL;
168 segment->hash = NULL;
111}169}
112 170
171/**
172 * iscsi_tcp_segment_done - check whether the segment is complete
173 * @segment: iscsi segment to check
174 * @recv: set to one of this is called from the recv path
175 * @copied: number of bytes copied
176 *
177 * Check if we're done receiving this segment. If the receive
178 * buffer is full but we expect more data, move on to the
179 * next entry in the scatterlist.
180 *
181 * If the amount of data we received isn't a multiple of 4,
182 * we will transparently receive the pad bytes, too.
183 *
184 * This function must be re-entrant.
185 */
113static inline int186static inline int
114iscsi_hdr_extract(struct iscsi_tcp_conn *tcp_conn)187iscsi_tcp_segment_done(struct iscsi_segment *segment, int recv, unsigned copied)
115{188{
116 struct sk_buff *skb = tcp_conn->in.skb;189 static unsigned char padbuf[ISCSI_PAD_LEN];
117 190 struct scatterlist sg;
118 tcp_conn->in.zero_copy_hdr = 0;191 unsigned int pad;
119 192
120 if (tcp_conn->in.copy >= tcp_conn->hdr_size &&193 debug_tcp("copied %u %u size %u %s\n", segment->copied, copied,
121 tcp_conn->in_progress == IN_PROGRESS_WAIT_HEADER) {194 segment->size, recv ? "recv" : "xmit");
195 if (segment->hash && copied) {
122 /*196 /*
123 * Zero-copy PDU Header: using connection context197 * If a segment is kmapd we must unmap it before sending
124 * to store header pointer.198 * to the crypto layer since that will try to kmap it again.
125 */199 */
126 if (skb_shinfo(skb)->frag_list == NULL &&200 iscsi_tcp_segment_unmap(segment);
127 !skb_shinfo(skb)->nr_frags) {201
128 tcp_conn->in.hdr = (struct iscsi_hdr *)202 if (!segment->data) {
129 ((char*)skb->data + tcp_conn->in.offset);203 sg_init_table(&sg, 1);
130 tcp_conn->in.zero_copy_hdr = 1;204 sg_set_page(&sg, sg_page(segment->sg), copied,
205 segment->copied + segment->sg_offset +
206 segment->sg->offset);
207 } else
208 sg_init_one(&sg, segment->data + segment->copied,
209 copied);
210 crypto_hash_update(segment->hash, &sg, copied);
211 }
212
213 segment->copied += copied;
214 if (segment->copied < segment->size) {
215 iscsi_tcp_segment_map(segment, recv);
216 return 0;
217 }
218
219 segment->total_copied += segment->copied;
220 segment->copied = 0;
221 segment->size = 0;
222
223 /* Unmap the current scatterlist page, if there is one. */
224 iscsi_tcp_segment_unmap(segment);
225
226 /* Do we have more scatterlist entries? */
227 debug_tcp("total copied %u total size %u\n", segment->total_copied,
228 segment->total_size);
229 if (segment->total_copied < segment->total_size) {
230 /* Proceed to the next entry in the scatterlist. */
231 iscsi_tcp_segment_init_sg(segment, sg_next(segment->sg),
232 0);
233 iscsi_tcp_segment_map(segment, recv);
234 BUG_ON(segment->size == 0);
235 return 0;
236 }
237
238 /* Do we need to handle padding? */
239 pad = iscsi_padding(segment->total_copied);
240 if (pad != 0) {
241 debug_tcp("consume %d pad bytes\n", pad);
242 segment->total_size += pad;
243 segment->size = pad;
244 segment->data = padbuf;
245 return 0;
246 }
247
248 /*
249 * Set us up for transferring the data digest. hdr digest
250 * is completely handled in hdr done function.
251 */
252 if (segment->hash) {
253 crypto_hash_final(segment->hash, segment->digest);
254 iscsi_tcp_segment_splice_digest(segment,
255 recv ? segment->recv_digest : segment->digest);
256 return 0;
257 }
258
259 return 1;
260}
261
262/**
263 * iscsi_tcp_xmit_segment - transmit segment
264 * @tcp_conn: the iSCSI TCP connection
265 * @segment: the buffer to transmnit
266 *
267 * This function transmits as much of the buffer as
268 * the network layer will accept, and returns the number of
269 * bytes transmitted.
270 *
271 * If CRC hashing is enabled, the function will compute the
272 * hash as it goes. When the entire segment has been transmitted,
273 * it will retrieve the hash value and send it as well.
274 */
275static int
276iscsi_tcp_xmit_segment(struct iscsi_tcp_conn *tcp_conn,
277 struct iscsi_segment *segment)
278{
279 struct socket *sk = tcp_conn->sock;
280 unsigned int copied = 0;
281 int r = 0;
282
283 while (!iscsi_tcp_segment_done(segment, 0, r)) {
284 struct scatterlist *sg;
285 unsigned int offset, copy;
286 int flags = 0;
287
288 r = 0;
289 offset = segment->copied;
290 copy = segment->size - offset;
291
292 if (segment->total_copied + segment->size < segment->total_size)
293 flags |= MSG_MORE;
294
295 /* Use sendpage if we can; else fall back to sendmsg */
296 if (!segment->data) {
297 sg = segment->sg;
298 offset += segment->sg_offset + sg->offset;
299 r = tcp_conn->sendpage(sk, sg_page(sg), offset, copy,
300 flags);
131 } else {301 } else {
132 /* ignoring return code since we checked302 struct msghdr msg = { .msg_flags = flags };
133 * in.copy before */303 struct kvec iov = {
134 skb_copy_bits(skb, tcp_conn->in.offset,304 .iov_base = segment->data + offset,
135 &tcp_conn->hdr, tcp_conn->hdr_size);305 .iov_len = copy
136 tcp_conn->in.hdr = &tcp_conn->hdr;306 };
307
308 r = kernel_sendmsg(sk, &msg, &iov, 1, copy);
137 }309 }
138 tcp_conn->in.offset += tcp_conn->hdr_size;
139 tcp_conn->in.copy -= tcp_conn->hdr_size;
140 } else {
141 int hdr_remains;
142 int copylen;
143 310
144 /*311 if (r < 0) {
145 * PDU header scattered across SKB's,312 iscsi_tcp_segment_unmap(segment);
146 * copying it... This'll happen quite rarely.313 if (copied || r == -EAGAIN)
147 */314 break;
315 return r;
316 }
317 copied += r;
318 }
319 return copied;
320}
321
322/**
323 * iscsi_tcp_segment_recv - copy data to segment
324 * @tcp_conn: the iSCSI TCP connection
325 * @segment: the buffer to copy to
326 * @ptr: data pointer
327 * @len: amount of data available
328 *
329 * This function copies up to @len bytes to the
330 * given buffer, and returns the number of bytes
331 * consumed, which can actually be less than @len.
332 *
333 * If hash digest is enabled, the function will update the
334 * hash while copying.
335 * Combining these two operations doesn't buy us a lot (yet),
336 * but in the future we could implement combined copy+crc,
337 * just way we do for network layer checksums.
338 */
339static int
340iscsi_tcp_segment_recv(struct iscsi_tcp_conn *tcp_conn,
341 struct iscsi_segment *segment, const void *ptr,
342 unsigned int len)
343{
344 unsigned int copy = 0, copied = 0;
148 345
149 if (tcp_conn->in_progress == IN_PROGRESS_WAIT_HEADER)346 while (!iscsi_tcp_segment_done(segment, 1, copy)) {
150 tcp_conn->in.hdr_offset = 0;347 if (copied == len) {
348 debug_tcp("iscsi_tcp_segment_recv copied %d bytes\n",
349 len);
350 break;
351 }
151 352
152 hdr_remains = tcp_conn->hdr_size - tcp_conn->in.hdr_offset;353 copy = min(len - copied, segment->size - segment->copied);
153 BUG_ON(hdr_remains <= 0);354 debug_tcp("iscsi_tcp_segment_recv copying %d\n", copy);
355 memcpy(segment->data + segment->copied, ptr + copied, copy);
356 copied += copy;
357 }
358 return copied;
359}
154 360
155 copylen = min(tcp_conn->in.copy, hdr_remains);361static inline void
156 skb_copy_bits(skb, tcp_conn->in.offset,362iscsi_tcp_dgst_header(struct hash_desc *hash, const void *hdr, size_t hdrlen,
157 (char*)&tcp_conn->hdr + tcp_conn->in.hdr_offset,363 unsigned char digest[ISCSI_DIGEST_SIZE])
158 copylen);364{
365 struct scatterlist sg;
366
367 sg_init_one(&sg, hdr, hdrlen);
368 crypto_hash_digest(hash, &sg, hdrlen, digest);
369}
159 370
160 debug_tcp("PDU gather offset %d bytes %d in.offset %d "371static inline int
161 "in.copy %d\n", tcp_conn->in.hdr_offset, copylen,372iscsi_tcp_dgst_verify(struct iscsi_tcp_conn *tcp_conn,
162 tcp_conn->in.offset, tcp_conn->in.copy);373 struct iscsi_segment *segment)
374{
375 if (!segment->digest_len)
376 return 1;
163 377
164 tcp_conn->in.offset += copylen;378 if (memcmp(segment->recv_digest, segment->digest,
165 tcp_conn->in.copy -= copylen;379 segment->digest_len)) {
166 if (copylen < hdr_remains) {380 debug_scsi("digest mismatch\n");
167 tcp_conn->in_progress = IN_PROGRESS_HEADER_GATHER;381 return 0;
168 tcp_conn->in.hdr_offset += copylen;382 }
169 return -EAGAIN;383
384 return 1;
385}
386
387/*
388 * Helper function to set up segment buffer
389 */
390static inline void
391__iscsi_segment_init(struct iscsi_segment *segment, size_t size,
392 iscsi_segment_done_fn_t *done, struct hash_desc *hash)
393{
394 memset(segment, 0, sizeof(*segment));
395 segment->total_size = size;
396 segment->done = done;
397
398 if (hash) {
399 segment->hash = hash;
400 crypto_hash_init(hash);
401 }
402}
403
404static inline void
405iscsi_segment_init_linear(struct iscsi_segment *segment, void *data,
406 size_t size, iscsi_segment_done_fn_t *done,
407 struct hash_desc *hash)
408{
409 __iscsi_segment_init(segment, size, done, hash);
410 segment->data = data;
411 segment->size = size;
412}
413
414static inline int
415iscsi_segment_seek_sg(struct iscsi_segment *segment,
416 struct scatterlist *sg_list, unsigned int sg_count,
417 unsigned int offset, size_t size,
418 iscsi_segment_done_fn_t *done, struct hash_desc *hash)
419{
420 struct scatterlist *sg;
421 unsigned int i;
422
423 debug_scsi("iscsi_segment_seek_sg offset %u size %llu\n",
424 offset, size);
425 __iscsi_segment_init(segment, size, done, hash);
426 for_each_sg(sg_list, sg, sg_count, i) {
427 debug_scsi("sg %d, len %u offset %u\n", i, sg->length,
428 sg->offset);
429 if (offset < sg->length) {
430 iscsi_tcp_segment_init_sg(segment, sg, offset);
431 return 0;
170 }432 }
171 tcp_conn->in.hdr = &tcp_conn->hdr;433 offset -= sg->length;
172 tcp_conn->discontiguous_hdr_cnt++;
173 tcp_conn->in_progress = IN_PROGRESS_WAIT_HEADER;
174 }434 }
175 435
436 return ISCSI_ERR_DATA_OFFSET;
437}
438
439/**
440 * iscsi_tcp_hdr_recv_prep - prep segment for hdr reception
441 * @tcp_conn: iscsi connection to prep for
442 *
443 * This function always passes NULL for the hash argument, because when this
444 * function is called we do not yet know the final size of the header and want
445 * to delay the digest processing until we know that.
446 */
447static void
448iscsi_tcp_hdr_recv_prep(struct iscsi_tcp_conn *tcp_conn)
449{
450 debug_tcp("iscsi_tcp_hdr_recv_prep(%p%s)\n", tcp_conn,
451 tcp_conn->iscsi_conn->hdrdgst_en ? ", digest enabled" : "");
452 iscsi_segment_init_linear(&tcp_conn->in.segment,
453 tcp_conn->in.hdr_buf, sizeof(struct iscsi_hdr),
454 iscsi_tcp_hdr_recv_done, NULL);
455}
456
457/*
458 * Handle incoming reply to any other type of command
459 */
460static int
461iscsi_tcp_data_recv_done(struct iscsi_tcp_conn *tcp_conn,
462 struct iscsi_segment *segment)
463{
464 struct iscsi_conn *conn = tcp_conn->iscsi_conn;
465 int rc = 0;
466
467 if (!iscsi_tcp_dgst_verify(tcp_conn, segment))
468 return ISCSI_ERR_DATA_DGST;
469
470 rc = iscsi_complete_pdu(conn, tcp_conn->in.hdr,
471 conn->data, tcp_conn->in.datalen);
472 if (rc)
473 return rc;
474
475 iscsi_tcp_hdr_recv_prep(tcp_conn);
176 return 0;476 return 0;
177}477}
178 478
479static void
480iscsi_tcp_data_recv_prep(struct iscsi_tcp_conn *tcp_conn)
481{
482 struct iscsi_conn *conn = tcp_conn->iscsi_conn;
483 struct hash_desc *rx_hash = NULL;
484
485 if (conn->datadgst_en)
486 rx_hash = &tcp_conn->rx_hash;
487
488 iscsi_segment_init_linear(&tcp_conn->in.segment,
489 conn->data, tcp_conn->in.datalen,
490 iscsi_tcp_data_recv_done, rx_hash);
491}
492
179/*493/*
180 * must be called with session lock494 * must be called with session lock
181 */495 */
@@ -184,7 +498,6 @@ iscsi_tcp_cleanup_ctask(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask) · 2 unmodified lines
184{498{
185 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;499 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
186 struct iscsi_r2t_info *r2t;500 struct iscsi_r2t_info *r2t;
187 struct scsi_cmnd *sc;
188 501
189 /* flush ctask's r2t queues */502 /* flush ctask's r2t queues */
190 while (__kfifo_get(tcp_ctask->r2tqueue, (void*)&r2t, sizeof(void*))) {503 while (__kfifo_get(tcp_ctask->r2tqueue, (void*)&r2t, sizeof(void*))) {
@@ -193,12 +506,12 @@ iscsi_tcp_cleanup_ctask(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask) · 2 unmodified lines
193 debug_scsi("iscsi_tcp_cleanup_ctask pending r2t dropped\n");506 debug_scsi("iscsi_tcp_cleanup_ctask pending r2t dropped\n");
194 }507 }
195 508
196 sc = ctask->sc;509 r2t = tcp_ctask->r2t;
197 if (unlikely(!sc))510 if (r2t != NULL) {
198 return;511 __kfifo_put(tcp_ctask->r2tpool.queue, (void*)&r2t,
199 512 sizeof(void*));
200 tcp_ctask->xmstate = XMSTATE_VALUE_IDLE;513 tcp_ctask->r2t = NULL;
201 tcp_ctask->r2t = NULL;514 }
202}515}
203 516
204/**517/**
@@ -217,11 +530,6 @@ iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask) · 12 unmodified lines
217 int datasn = be32_to_cpu(rhdr->datasn);530 int datasn = be32_to_cpu(rhdr->datasn);
218 531
219 iscsi_update_cmdsn(session, (struct iscsi_nopin*)rhdr);532 iscsi_update_cmdsn(session, (struct iscsi_nopin*)rhdr);
220 /*
221 * setup Data-In byte counter (gets decremented..)
222 */
223 ctask->data_count = tcp_conn->in.datalen;
224
225 if (tcp_conn->in.datalen == 0)533 if (tcp_conn->in.datalen == 0)
226 return 0;534 return 0;
227 535
@@ -242,22 +550,20 @@ iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask) · 14 unmodified lines
242 }550 }
243 551
244 if (rhdr->flags & ISCSI_FLAG_DATA_STATUS) {552 if (rhdr->flags & ISCSI_FLAG_DATA_STATUS) {
553 sc->result = (DID_OK << 16) | rhdr->cmd_status;
245 conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1;554 conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1;
246 if (rhdr->flags & ISCSI_FLAG_DATA_UNDERFLOW) {555 if (rhdr->flags & (ISCSI_FLAG_DATA_UNDERFLOW |
556 ISCSI_FLAG_DATA_OVERFLOW)) {
247 int res_count = be32_to_cpu(rhdr->residual_count);557 int res_count = be32_to_cpu(rhdr->residual_count);
248 558
249 if (res_count > 0 &&559 if (res_count > 0 &&
250 res_count <= scsi_bufflen(sc)) {560 (rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW ||
561 res_count <= scsi_bufflen(sc)))
251 scsi_set_resid(sc, res_count);562 scsi_set_resid(sc, res_count);
252 sc->result = (DID_OK << 16) | rhdr->cmd_status;563 else
253 } else
254 sc->result = (DID_BAD_TARGET << 16) |564 sc->result = (DID_BAD_TARGET << 16) |
255 rhdr->cmd_status;565 rhdr->cmd_status;
256 } else if (rhdr->flags & ISCSI_FLAG_DATA_OVERFLOW) {566 }
257 scsi_set_resid(sc, be32_to_cpu(rhdr->residual_count));
258 sc->result = (DID_OK << 16) | rhdr->cmd_status;
259 } else
260 sc->result = (DID_OK << 16) | rhdr->cmd_status;
261 }567 }
262 568
263 conn->datain_pdus_cnt++;569 conn->datain_pdus_cnt++;
@@ -281,9 +587,6 @@ iscsi_solicit_data_init(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask, · 17 unmodified lines
281 struct iscsi_r2t_info *r2t)587 struct iscsi_r2t_info *r2t)
282{588{
283 struct iscsi_data *hdr;589 struct iscsi_data *hdr;
284 struct scsi_cmnd *sc = ctask->sc;
285 int i, sg_count = 0;
286 struct scatterlist *sg;
287 590
288 hdr = &r2t->dtask.hdr;591 hdr = &r2t->dtask.hdr;
289 memset(hdr, 0, sizeof(struct iscsi_data));592 memset(hdr, 0, sizeof(struct iscsi_data));
@@ -307,34 +610,6 @@ iscsi_solicit_data_init(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask, · 17 unmodified lines
307 conn->dataout_pdus_cnt++;610 conn->dataout_pdus_cnt++;
308 611
309 r2t->sent = 0;612 r2t->sent = 0;
310
311 iscsi_buf_init_iov(&r2t->headbuf, (char*)hdr,
312 sizeof(struct iscsi_hdr));
313
314 sg = scsi_sglist(sc);
315 r2t->sg = NULL;
316 for (i = 0; i < scsi_sg_count(sc); i++, sg += 1) {
317 /* FIXME: prefetch ? */
318 if (sg_count + sg->length > r2t->data_offset) {
319 int page_offset;
320
321 /* sg page found! */
322
323 /* offset within this page */
324 page_offset = r2t->data_offset - sg_count;
325
326 /* fill in this buffer */
327 iscsi_buf_init_sg(&r2t->sendbuf, sg);
328 r2t->sendbuf.sg.offset += page_offset;
329 r2t->sendbuf.sg.length -= page_offset;
330
331 /* xmit logic will continue with next one */
332 r2t->sg = sg + 1;
333 break;
334 }
335 sg_count += sg->length;
336 }
337 BUG_ON(r2t->sg == NULL);
338}613}
339 614
340/**615/**
@@ -366,14 +641,11 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask) · 25 unmodified lines
366 }641 }
367 642
368 /* fill-in new R2T associated with the task */643 /* fill-in new R2T associated with the task */
369 spin_lock(&session->lock);
370 iscsi_update_cmdsn(session, (struct iscsi_nopin*)rhdr);644 iscsi_update_cmdsn(session, (struct iscsi_nopin*)rhdr);
371 645
372 if (!ctask->sc || ctask->mtask ||646 if (!ctask->sc || session->state != ISCSI_STATE_LOGGED_IN) {
373 session->state != ISCSI_STATE_LOGGED_IN) {
374 printk(KERN_INFO "iscsi_tcp: dropping R2T itt %d in "647 printk(KERN_INFO "iscsi_tcp: dropping R2T itt %d in "
375 "recovery...\n", ctask->itt);648 "recovery...\n", ctask->itt);
376 spin_unlock(&session->lock);
377 return 0;649 return 0;
378 }650 }
379 651
@@ -384,7 +656,8 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask) · 4 unmodified lines
384 r2t->data_length = be32_to_cpu(rhdr->data_length);656 r2t->data_length = be32_to_cpu(rhdr->data_length);
385 if (r2t->data_length == 0) {657 if (r2t->data_length == 0) {
386 printk(KERN_ERR "iscsi_tcp: invalid R2T with zero data len\n");658 printk(KERN_ERR "iscsi_tcp: invalid R2T with zero data len\n");
387 spin_unlock(&session->lock);659 __kfifo_put(tcp_ctask->r2tpool.queue, (void*)&r2t,
660 sizeof(void*));
388 return ISCSI_ERR_DATALEN;661 return ISCSI_ERR_DATALEN;
389 }662 }
390 663
@@ -395,10 +668,11 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask) · 4 unmodified lines
395 668
396 r2t->data_offset = be32_to_cpu(rhdr->data_offset);669 r2t->data_offset = be32_to_cpu(rhdr->data_offset);
397 if (r2t->data_offset + r2t->data_length > scsi_bufflen(ctask->sc)) {670 if (r2t->data_offset + r2t->data_length > scsi_bufflen(ctask->sc)) {
398 spin_unlock(&session->lock);
399 printk(KERN_ERR "iscsi_tcp: invalid R2T with data len %u at "671 printk(KERN_ERR "iscsi_tcp: invalid R2T with data len %u at "
400 "offset %u and total length %d\n", r2t->data_length,672 "offset %u and total length %d\n", r2t->data_length,
401 r2t->data_offset, scsi_bufflen(ctask->sc));673 r2t->data_offset, scsi_bufflen(ctask->sc));
674 __kfifo_put(tcp_ctask->r2tpool.queue, (void*)&r2t,
675 sizeof(void*));
402 return ISCSI_ERR_DATALEN;676 return ISCSI_ERR_DATALEN;
403 }677 }
404 678
@@ -409,26 +683,55 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask) · 4 unmodified lines
409 683
410 tcp_ctask->exp_datasn = r2tsn + 1;684 tcp_ctask->exp_datasn = r2tsn + 1;
411 __kfifo_put(tcp_ctask->r2tqueue, (void*)&r2t, sizeof(void*));685 __kfifo_put(tcp_ctask->r2tqueue, (void*)&r2t, sizeof(void*));
412 set_bit(XMSTATE_BIT_SOL_HDR_INIT, &tcp_ctask->xmstate);
413 list_move_tail(&ctask->running, &conn->xmitqueue);
414
415 scsi_queue_work(session->host, &conn->xmitwork);
416 conn->r2t_pdus_cnt++;686 conn->r2t_pdus_cnt++;
417 spin_unlock(&session->lock);
418 687
688 iscsi_requeue_ctask(ctask);
419 return 0;689 return 0;
420}690}
421 691
692/*
693 * Handle incoming reply to DataIn command
694 */
422static int695static int
423iscsi_tcp_hdr_recv(struct iscsi_conn *conn)696iscsi_tcp_process_data_in(struct iscsi_tcp_conn *tcp_conn,
697 struct iscsi_segment *segment)
698{
699 struct iscsi_conn *conn = tcp_conn->iscsi_conn;
700 struct iscsi_hdr *hdr = tcp_conn->in.hdr;
701 int rc;
702
703 if (!iscsi_tcp_dgst_verify(tcp_conn, segment))
704 return ISCSI_ERR_DATA_DGST;
705
706 /* check for non-exceptional status */
707 if (hdr->flags & ISCSI_FLAG_DATA_STATUS) {
708 rc = iscsi_complete_pdu(conn, tcp_conn->in.hdr, NULL, 0);
709 if (rc)
710 return rc;
711 }
712
713 iscsi_tcp_hdr_recv_prep(tcp_conn);
714 return 0;
715}
716
717/**
718 * iscsi_tcp_hdr_dissect - process PDU header
719 * @conn: iSCSI connection
720 * @hdr: PDU header
721 *
722 * This function analyzes the header of the PDU received,
723 * and performs several sanity checks. If the PDU is accompanied
724 * by data, the receive buffer is set up to copy the incoming data
725 * to the correct location.
726 */
727static int
728iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr)
424{729{
425 int rc = 0, opcode, ahslen;730 int rc = 0, opcode, ahslen;
426 struct iscsi_hdr *hdr;
427 struct iscsi_session *session = conn->session;731 struct iscsi_session *session = conn->session;
428 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;732 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
429 uint32_t cdgst, rdgst = 0, itt;733 struct iscsi_cmd_task *ctask;
430 734 uint32_t itt;
431 hdr = tcp_conn->in.hdr;
432 735
433 /* verify PDU length */736 /* verify PDU length */
434 tcp_conn->in.datalen = ntoh24(hdr->dlength);737 tcp_conn->in.datalen = ntoh24(hdr->dlength);
@@ -437,78 +740,73 @@ iscsi_tcp_hdr_recv(struct iscsi_conn *conn) · 2 unmodified lines
437 tcp_conn->in.datalen, conn->max_recv_dlength);740 tcp_conn->in.datalen, conn->max_recv_dlength);
438 return ISCSI_ERR_DATALEN;741 return ISCSI_ERR_DATALEN;
439 }742 }
440 tcp_conn->data_copied = 0;
441 743
442 /* read AHS */744 /* Additional header segments. So far, we don't
745 * process additional headers.
746 */
443 ahslen = hdr->hlength << 2;747 ahslen = hdr->hlength << 2;
444 tcp_conn->in.offset += ahslen;
445 tcp_conn->in.copy -= ahslen;
446 if (tcp_conn->in.copy < 0) {
447 printk(KERN_ERR "iscsi_tcp: can't handle AHS with length "
448 "%d bytes\n", ahslen);
449 return ISCSI_ERR_AHSLEN;
450 }
451
452 /* calculate read padding */
453 tcp_conn->in.padding = tcp_conn->in.datalen & (ISCSI_PAD_LEN-1);
454 if (tcp_conn->in.padding) {
455 tcp_conn->in.padding = ISCSI_PAD_LEN - tcp_conn->in.padding;
456 debug_scsi("read padding %d bytes\n", tcp_conn->in.padding);
457 }
458
459 if (conn->hdrdgst_en) {
460 struct scatterlist sg;
461
462 sg_init_one(&sg, (u8 *)hdr,
463 sizeof(struct iscsi_hdr) + ahslen);
464 crypto_hash_digest(&tcp_conn->rx_hash, &sg, sg.length,
465 (u8 *)&cdgst);
466 rdgst = *(uint32_t*)((char*)hdr + sizeof(struct iscsi_hdr) +
467 ahslen);
468 if (cdgst != rdgst) {
469 printk(KERN_ERR "iscsi_tcp: hdrdgst error "
470 "recv 0x%x calc 0x%x\n", rdgst, cdgst);
471 return ISCSI_ERR_HDR_DGST;
472 }
473 }
474 748
475 opcode = hdr->opcode & ISCSI_OPCODE_MASK;749 opcode = hdr->opcode & ISCSI_OPCODE_MASK;
476 /* verify itt (itt encoding: age+cid+itt) */750 /* verify itt (itt encoding: age+cid+itt) */
477 rc = iscsi_verify_itt(conn, hdr, &itt);751 rc = iscsi_verify_itt(conn, hdr, &itt);
478 if (rc == ISCSI_ERR_NO_SCSI_CMD) {752 if (rc)
479 tcp_conn->in.datalen = 0; /* force drop */
480 return 0;
481 } else if (rc)
482 return rc;753 return rc;
483 754
484 debug_tcp("opcode 0x%x offset %d copy %d ahslen %d datalen %d\n",755 debug_tcp("opcode 0x%x ahslen %d datalen %d\n",
485 opcode, tcp_conn->in.offset, tcp_conn->in.copy,756 opcode, ahslen, tcp_conn->in.datalen);
486 ahslen, tcp_conn->in.datalen);
487 757
488 switch(opcode) {758 switch(opcode) {
489 case ISCSI_OP_SCSI_DATA_IN:759 case ISCSI_OP_SCSI_DATA_IN:
490 tcp_conn->in.ctask = session->cmds[itt];760 ctask = session->cmds[itt];
491 rc = iscsi_data_rsp(conn, tcp_conn->in.ctask);761 spin_lock(&conn->session->lock);
762 rc = iscsi_data_rsp(conn, ctask);
763 spin_unlock(&conn->session->lock);
492 if (rc)764 if (rc)
493 return rc;765 return rc;
766 if (tcp_conn->in.datalen) {
767 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
768 struct hash_desc *rx_hash = NULL;
769
770 /*
771 * Setup copy of Data-In into the Scsi_Cmnd
772 * Scatterlist case:
773 * We set up the iscsi_segment to point to the next
774 * scatterlist entry to copy to. As we go along,
775 * we move on to the next scatterlist entry and
776 * update the digest per-entry.
777 */
778 if (conn->datadgst_en)
779 rx_hash = &tcp_conn->rx_hash;
780
781 debug_tcp("iscsi_tcp_begin_data_in(%p, offset=%d, "
782 "datalen=%d)\n", tcp_conn,
783 tcp_ctask->data_offset,
784 tcp_conn->in.datalen);
785 return iscsi_segment_seek_sg(&tcp_conn->in.segment,
786 scsi_sglist(ctask->sc),
787 scsi_sg_count(ctask->sc),
788 tcp_ctask->data_offset,
789 tcp_conn->in.datalen,
790 iscsi_tcp_process_data_in,
791 rx_hash);
792 }
494 /* fall through */793 /* fall through */
495 case ISCSI_OP_SCSI_CMD_RSP:794 case ISCSI_OP_SCSI_CMD_RSP:
496 tcp_conn->in.ctask = session->cmds[itt];795 if (tcp_conn->in.datalen) {
497 if (tcp_conn->in.datalen)796 iscsi_tcp_data_recv_prep(tcp_conn);
498 goto copy_hdr;797 return 0;
499 798 }
500 spin_lock(&session->lock);799 rc = iscsi_complete_pdu(conn, hdr, NULL, 0);
501 rc = __iscsi_complete_pdu(conn, hdr, NULL, 0);
502 spin_unlock(&session->lock);
503 break;800 break;
504 case ISCSI_OP_R2T:801 case ISCSI_OP_R2T:
505 tcp_conn->in.ctask = session->cmds[itt];802 ctask = session->cmds[itt];
506 if (ahslen)803 if (ahslen)
507 rc = ISCSI_ERR_AHSLEN;804 rc = ISCSI_ERR_AHSLEN;
508 else if (tcp_conn->in.ctask->sc->sc_data_direction ==805 else if (ctask->sc->sc_data_direction == DMA_TO_DEVICE) {
509 DMA_TO_DEVICE)806 spin_lock(&session->lock);
510 rc = iscsi_r2t_rsp(conn, tcp_conn->in.ctask);807 rc = iscsi_r2t_rsp(conn, ctask);
511 else808 spin_unlock(&session->lock);
809 } else
512 rc = ISCSI_ERR_PROTO;810 rc = ISCSI_ERR_PROTO;
513 break;811 break;
514 case ISCSI_OP_LOGIN_RSP:812 case ISCSI_OP_LOGIN_RSP:
@@ -520,8 +818,7 @@ iscsi_tcp_hdr_recv(struct iscsi_conn *conn) · 5 unmodified lines
520 * than 8K, but there are no targets that currently do this.818 * than 8K, but there are no targets that currently do this.
521 * For now we fail until we find a vendor that needs it819 * For now we fail until we find a vendor that needs it
522 */820 */
523 if (ISCSI_DEF_MAX_RECV_SEG_LEN <821 if (ISCSI_DEF_MAX_RECV_SEG_LEN < tcp_conn->in.datalen) {
524 tcp_conn->in.datalen) {
525 printk(KERN_ERR "iscsi_tcp: received buffer of len %u "822 printk(KERN_ERR "iscsi_tcp: received buffer of len %u "
526 "but conn buffer is only %u (opcode %0x)\n",823 "but conn buffer is only %u (opcode %0x)\n",
527 tcp_conn->in.datalen,824 tcp_conn->in.datalen,
@@ -530,8 +827,13 @@ iscsi_tcp_hdr_recv(struct iscsi_conn *conn) · 2 unmodified lines
530 break;827 break;
531 }828 }
532 829
533 if (tcp_conn->in.datalen)830 /* If there's data coming in with the response,
534 goto copy_hdr;831 * receive it to the connection's buffer.
832 */
833 if (tcp_conn->in.datalen) {
834 iscsi_tcp_data_recv_prep(tcp_conn);
835 return 0;
836 }
535 /* fall through */837 /* fall through */
536 case ISCSI_OP_LOGOUT_RSP:838 case ISCSI_OP_LOGOUT_RSP:
537 case ISCSI_OP_NOOP_IN:839 case ISCSI_OP_NOOP_IN:
@@ -543,461 +845,161 @@ iscsi_tcp_hdr_recv(struct iscsi_conn *conn) · 5 unmodified lines
543 break;845 break;
544 }846 }
545 847
546 return rc;848 if (rc == 0) {
547 849 /* Anything that comes with data should have
548copy_hdr:850 * been handled above. */
549 /*851 if (tcp_conn->in.datalen)
550 * if we did zero copy for the header but we will need multiple852 return ISCSI_ERR_PROTO;
551 * skbs to complete the command then we have to copy the header853 iscsi_tcp_hdr_recv_prep(tcp_conn);
552 * for later use
553 */
554 if (tcp_conn->in.zero_copy_hdr && tcp_conn->in.copy <=
555 (tcp_conn->in.datalen + tcp_conn->in.padding +
556 (conn->datadgst_en ? 4 : 0))) {
557 debug_tcp("Copying header for later use. in.copy %d in.datalen"
558 " %d\n", tcp_conn->in.copy, tcp_conn->in.datalen);
559 memcpy(&tcp_conn->hdr, tcp_conn->in.hdr,
560 sizeof(struct iscsi_hdr));
561 tcp_conn->in.hdr = &tcp_conn->hdr;
562 tcp_conn->in.zero_copy_hdr = 0;
563 }
564 return 0;
565}
566
567/**
568 * iscsi_ctask_copy - copy skb bits to the destanation cmd task
569 * @conn: iscsi tcp connection
570 * @ctask: scsi command task
571 * @buf: buffer to copy to
572 * @buf_size: size of buffer
573 * @offset: offset within the buffer
574 *
575 * Notes:
576 * The function calls skb_copy_bits() and updates per-connection and
577 * per-cmd byte counters.
578 *
579 * Read counters (in bytes):
580 *
581 * conn->in.offset offset within in progress SKB
582 * conn->in.copy left to copy from in progress SKB
583 * including padding
584 * conn->in.copied copied already from in progress SKB
585 * conn->data_copied copied already from in progress buffer
586 * ctask->sent total bytes sent up to the MidLayer
587 * ctask->data_count left to copy from in progress Data-In
588 * buf_left left to copy from in progress buffer
589 **/
590static inline int
591iscsi_ctask_copy(struct iscsi_tcp_conn *tcp_conn, struct iscsi_cmd_task *ctask,
592 void *buf, int buf_size, int offset)
593{
594 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
595 int buf_left = buf_size - (tcp_conn->data_copied + offset);
596 unsigned size = min(tcp_conn->in.copy, buf_left);
597 int rc;
598
599 size = min(size, ctask->data_count);
600
601 debug_tcp("ctask_copy %d bytes at offset %d copied %d\n",
602 size, tcp_conn->in.offset, tcp_conn->in.copied);
603
604 BUG_ON(size <= 0);
605 BUG_ON(tcp_ctask->sent + size > scsi_bufflen(ctask->sc));
606
607 rc = skb_copy_bits(tcp_conn->in.skb, tcp_conn->in.offset,
608 (char*)buf + (offset + tcp_conn->data_copied), size);
609 /* must fit into skb->len */
610 BUG_ON(rc);
611
612 tcp_conn->in.offset += size;
613 tcp_conn->in.copy -= size;
614 tcp_conn->in.copied += size;
615 tcp_conn->data_copied += size;
616 tcp_ctask->sent += size;
617 ctask->data_count -= size;
618
619 BUG_ON(tcp_conn->in.copy < 0);
620 BUG_ON(ctask->data_count < 0);
621
622 if (buf_size != (tcp_conn->data_copied + offset)) {
623 if (!ctask->data_count) {
624 BUG_ON(buf_size - tcp_conn->data_copied < 0);
625 /* done with this PDU */
626 return buf_size - tcp_conn->data_copied;
627 }
628 return -EAGAIN;
629 }854 }
630 855
631 /* done with this buffer or with both - PDU and buffer */856 return rc;
632 tcp_conn->data_copied = 0;
633 return 0;
634}857}
635 858
636/**859/**
637 * iscsi_tcp_copy - copy skb bits to the destanation buffer860 * iscsi_tcp_hdr_recv_done - process PDU header
638 * @conn: iscsi tcp connection
639 *861 *
640 * Notes:862 * This is the callback invoked when the PDU header has
641 * The function calls skb_copy_bits() and updates per-connection863 * been received. If the header is followed by additional
642 * byte counters.864 * header segments, we go back for more data.
643 **/865 */
644static inline int866static int
645iscsi_tcp_copy(struct iscsi_conn *conn, int buf_size)867iscsi_tcp_hdr_recv_done(struct iscsi_tcp_conn *tcp_conn,
646{868 struct iscsi_segment *segment)
647 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
648 int buf_left = buf_size - tcp_conn->data_copied;
649 int size = min(tcp_conn->in.copy, buf_left);
650 int rc;
651
652 debug_tcp("tcp_copy %d bytes at offset %d copied %d\n",
653 size, tcp_conn->in.offset, tcp_conn->data_copied);
654 BUG_ON(size <= 0);
655
656 rc = skb_copy_bits(tcp_conn->in.skb, tcp_conn->in.offset,
657 (char*)conn->data + tcp_conn->data_copied, size);
658 BUG_ON(rc);
659
660 tcp_conn->in.offset += size;
661 tcp_conn->in.copy -= size;
662 tcp_conn->in.copied += size;
663 tcp_conn->data_copied += size;
664
665 if (buf_size != tcp_conn->data_copied)
666 return -EAGAIN;
667
668 return 0;
669}
670
671static inline void
672partial_sg_digest_update(struct hash_desc *desc, struct scatterlist *sg,
673 int offset, int length)
674{
675 struct scatterlist temp;
676
677 sg_init_table(&temp, 1);
678 sg_set_page(&temp, sg_page(sg), length, offset);
679 crypto_hash_update(desc, &temp, length);
680}
681
682static void
683iscsi_recv_digest_update(struct iscsi_tcp_conn *tcp_conn, char* buf, int len)
684{
685 struct scatterlist tmp;
686
687 sg_init_one(&tmp, buf, len);
688 crypto_hash_update(&tcp_conn->rx_hash, &tmp, len);
689}
690
691static int iscsi_scsi_data_in(struct iscsi_conn *conn)
692{869{
693 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;870 struct iscsi_conn *conn = tcp_conn->iscsi_conn;
694 struct iscsi_cmd_task *ctask = tcp_conn->in.ctask;871 struct iscsi_hdr *hdr;
695 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
696 struct scsi_cmnd *sc = ctask->sc;
697 struct scatterlist *sg;
698 int i, offset, rc = 0;
699
700 BUG_ON((void*)ctask != sc->SCp.ptr);
701
702 offset = tcp_ctask->data_offset;
703 sg = scsi_sglist(sc);
704
705 if (tcp_ctask->data_offset)
706 for (i = 0; i < tcp_ctask->sg_count; i++)
707 offset -= sg[i].length;
708 /* we've passed through partial sg*/
709 if (offset < 0)
710 offset = 0;
711
712 for (i = tcp_ctask->sg_count; i < scsi_sg_count(sc); i++) {
713 char *dest;
714
715 dest = kmap_atomic(sg_page(&sg[i]), KM_SOFTIRQ0);
716 rc = iscsi_ctask_copy(tcp_conn, ctask, dest + sg[i].offset,
717 sg[i].length, offset);
718 kunmap_atomic(dest, KM_SOFTIRQ0);
719 if (rc == -EAGAIN)
720 /* continue with the next SKB/PDU */
721 return rc;
722 if (!rc) {
723 if (conn->datadgst_en) {
724 if (!offset)
725 crypto_hash_update(
726 &tcp_conn->rx_hash,
727 &sg[i], sg[i].length);
728 else
729 partial_sg_digest_update(
730 &tcp_conn->rx_hash,
731 &sg[i],
732 sg[i].offset + offset,
733 sg[i].length - offset);
734 }
735 offset = 0;
736 tcp_ctask->sg_count++;
737 }
738
739 if (!ctask->data_count) {
740 if (rc && conn->datadgst_en)
741 /*
742 * data-in is complete, but buffer not...
743 */
744 partial_sg_digest_update(&tcp_conn->rx_hash,
745 &sg[i],
746 sg[i].offset,
747 sg[i].length-rc);
748 rc = 0;
749 break;
750 }
751
752 if (!tcp_conn->in.copy)
753 return -EAGAIN;
754 }
755 BUG_ON(ctask->data_count);
756 872
757 /* check for non-exceptional status */873 /* Check if there are additional header segments
758 if (tcp_conn->in.hdr->flags & ISCSI_FLAG_DATA_STATUS) {874 * *prior* to computing the digest, because we
759 debug_scsi("done [sc %lx res %d itt 0x%x flags 0x%x]\n",875 * may need to go back to the caller for more.
760 (long)sc, sc->result, ctask->itt,876 */
761 tcp_conn->in.hdr->flags);877 hdr = (struct iscsi_hdr *) tcp_conn->in.hdr_buf;
762 spin_lock(&conn->session->lock);878 if (segment->copied == sizeof(struct iscsi_hdr) && hdr->hlength) {
763 __iscsi_complete_pdu(conn, tcp_conn->in.hdr, NULL, 0);879 /* Bump the header length - the caller will
764 spin_unlock(&conn->session->lock);880 * just loop around and get the AHS for us, and
881 * call again. */
882 unsigned int ahslen = hdr->hlength << 2;
883
884 /* Make sure we don't overflow */
885 if (sizeof(*hdr) + ahslen > sizeof(tcp_conn->in.hdr_buf))
886 return ISCSI_ERR_AHSLEN;
887
888 segment->total_size += ahslen;
889 segment->size += ahslen;
890 return 0;
765 }891 }
766 892
767 return rc;893 /* We're done processing the header. See if we're doing
768}894 * header digests; if so, set up the recv_digest buffer
769 895 * and go back for more. */
770static int896 if (conn->hdrdgst_en) {
771iscsi_data_recv(struct iscsi_conn *conn)897 if (segment->digest_len == 0) {
772{898 iscsi_tcp_segment_splice_digest(segment,
773 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;899 segment->recv_digest);
774 int rc = 0, opcode;900 return 0;
775
776 opcode = tcp_conn->in.hdr->opcode & ISCSI_OPCODE_MASK;
777 switch (opcode) {
778 case ISCSI_OP_SCSI_DATA_IN:
779 rc = iscsi_scsi_data_in(conn);
780 break;
781 case ISCSI_OP_SCSI_CMD_RSP:
782 case ISCSI_OP_TEXT_RSP:
783 case ISCSI_OP_LOGIN_RSP:
784 case ISCSI_OP_ASYNC_EVENT:
785 case ISCSI_OP_REJECT:
786 /*
787 * Collect data segment to the connection's data
788 * placeholder
789 */
790 if (iscsi_tcp_copy(conn, tcp_conn->in.datalen)) {
791 rc = -EAGAIN;
792 goto exit;
793 }901 }
902 iscsi_tcp_dgst_header(&tcp_conn->rx_hash, hdr,
903 segment->total_copied - ISCSI_DIGEST_SIZE,
904 segment->digest);
794 905
795 rc = iscsi_complete_pdu(conn, tcp_conn->in.hdr, conn->data,906 if (!iscsi_tcp_dgst_verify(tcp_conn, segment))
796 tcp_conn->in.datalen);907 return ISCSI_ERR_HDR_DGST;
797 if (!rc && conn->datadgst_en && opcode != ISCSI_OP_LOGIN_RSP)
798 iscsi_recv_digest_update(tcp_conn, conn->data,
799 tcp_conn->in.datalen);
800 break;
801 default:
802 BUG_ON(1);
803 }908 }
804exit:909
805 return rc;910 tcp_conn->in.hdr = hdr;
911 return iscsi_tcp_hdr_dissect(conn, hdr);
806}912}
807 913
808/**914/**
809 * iscsi_tcp_data_recv - TCP receive in sendfile fashion915 * iscsi_tcp_recv - TCP receive in sendfile fashion
810 * @rd_desc: read descriptor916 * @rd_desc: read descriptor
811 * @skb: socket buffer917 * @skb: socket buffer
812 * @offset: offset in skb918 * @offset: offset in skb
813 * @len: skb->len - offset919 * @len: skb->len - offset
814 **/920 **/
815static int921static int
816iscsi_tcp_data_recv(read_descriptor_t *rd_desc, struct sk_buff *skb,922iscsi_tcp_recv(read_descriptor_t *rd_desc, struct sk_buff *skb,
817 unsigned int offset, size_t len)923 unsigned int offset, size_t len)
818{924{
819 int rc;
820 struct iscsi_conn *conn = rd_desc->arg.data;925 struct iscsi_conn *conn = rd_desc->arg.data;
821 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;926 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
822 int processed;927 struct iscsi_segment *segment = &tcp_conn->in.segment;
823 char pad[ISCSI_PAD_LEN];928 struct skb_seq_state seq;
824 struct scatterlist sg;929 unsigned int consumed = 0;
825 930 int rc = 0;
826 /*
827 * Save current SKB and its offset in the corresponding
828 * connection context.
829 */
830 tcp_conn->in.copy = skb->len - offset;
831 tcp_conn->in.offset = offset;
832 tcp_conn->in.skb = skb;
833 tcp_conn->in.len = tcp_conn->in.copy;
834 BUG_ON(tcp_conn->in.copy <= 0);
835 debug_tcp("in %d bytes\n", tcp_conn->in.copy);
836 931
837more:932 debug_tcp("in %d bytes\n", skb->len - offset);
838 tcp_conn->in.copied = 0;
839 rc = 0;
840 933
841 if (unlikely(conn->suspend_rx)) {934 if (unlikely(conn->suspend_rx)) {
842 debug_tcp("conn %d Rx suspended!\n", conn->id);935 debug_tcp("conn %d Rx suspended!\n", conn->id);
843 return 0;936 return 0;
844 }937 }
845 938
846 if (tcp_conn->in_progress == IN_PROGRESS_WAIT_HEADER ||939 skb_prepare_seq_read(skb, offset, skb->len, &seq);
847 tcp_conn->in_progress == IN_PROGRESS_HEADER_GATHER) {940 while (1) {
848 rc = iscsi_hdr_extract(tcp_conn);941 unsigned int avail;
849 if (rc) {942 const u8 *ptr;
850 if (rc == -EAGAIN)
851 goto nomore;
852 else {
853 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
854 return 0;
855 }
856 }
857 943
858 /*944 avail = skb_seq_read(consumed, &ptr, &seq);
859 * Verify and process incoming PDU header.945 if (avail == 0) {
860 */946 debug_tcp("no more data avail. Consumed %d\n",
861 rc = iscsi_tcp_hdr_recv(conn);947 consumed);
862 if (!rc && tcp_conn->in.datalen) {948 break;
863 if (conn->datadgst_en)
864 crypto_hash_init(&tcp_conn->rx_hash);
865 tcp_conn->in_progress = IN_PROGRESS_DATA_RECV;
866 } else if (rc) {
867 iscsi_conn_failure(conn, rc);
868 return 0;
869 }949 }
870 }950 BUG_ON(segment->copied >= segment->size);
871 951
872 if (tcp_conn->in_progress == IN_PROGRESS_DDIGEST_RECV &&952 debug_tcp("skb %p ptr=%p avail=%u\n", skb, ptr, avail);
873 tcp_conn->in.copy) {953 rc = iscsi_tcp_segment_recv(tcp_conn, segment, ptr, avail);
874 uint32_t recv_digest;954 BUG_ON(rc == 0);
875 955 consumed += rc;
876 debug_tcp("extra data_recv offset %d copy %d\n",956
877 tcp_conn->in.offset, tcp_conn->in.copy);957 if (segment->total_copied >= segment->total_size) {
878 958 debug_tcp("segment done\n");
879 if (!tcp_conn->data_copied) {959 rc = segment->done(tcp_conn, segment);
880 if (tcp_conn->in.padding) {960 if (rc != 0) {
881 debug_tcp("padding -> %d\n",961 skb_abort_seq_read(&seq);
882 tcp_conn->in.padding);962 goto error;
883 memset(pad, 0, tcp_conn->in.padding);
884 sg_init_one(&sg, pad, tcp_conn->in.padding);
885 crypto_hash_update(&tcp_conn->rx_hash,
886 &sg, sg.length);
887 }963 }
888 crypto_hash_final(&tcp_conn->rx_hash,
889 (u8 *) &tcp_conn->in.datadgst);
890 debug_tcp("rx digest 0x%x\n", tcp_conn->in.datadgst);
891 }
892 964
893 rc = iscsi_tcp_copy(conn, sizeof(uint32_t));965 /* The done() functions sets up the
894 if (rc) {966 * next segment. */
895 if (rc == -EAGAIN)
896 goto again;
897 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
898 return 0;
899 }
900
901 memcpy(&recv_digest, conn->data, sizeof(uint32_t));
902 if (recv_digest != tcp_conn->in.datadgst) {
903 debug_tcp("iscsi_tcp: data digest error!"
904 "0x%x != 0x%x\n", recv_digest,
905 tcp_conn->in.datadgst);
906 iscsi_conn_failure(conn, ISCSI_ERR_DATA_DGST);
907 return 0;
908 } else {
909 debug_tcp("iscsi_tcp: data digest match!"
910 "0x%x == 0x%x\n", recv_digest,
911 tcp_conn->in.datadgst);
912 tcp_conn->in_progress = IN_PROGRESS_WAIT_HEADER;
913 }967 }
914 }968 }
969 skb_abort_seq_read(&seq);
970 conn->rxdata_octets += consumed;
971 return consumed;
915 972
916 if (tcp_conn->in_progress == IN_PROGRESS_DATA_RECV &&973error:
917 tcp_conn->in.copy) {974 debug_tcp("Error receiving PDU, errno=%d\n", rc);
918 debug_tcp("data_recv offset %d copy %d\n",975 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
919 tcp_conn->in.offset, tcp_conn->in.copy);976 return 0;
920
921 rc = iscsi_data_recv(conn);
922 if (rc) {
923 if (rc == -EAGAIN)
924 goto again;
925 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
926 return 0;
927 }
928
929 if (tcp_conn->in.padding)
930 tcp_conn->in_progress = IN_PROGRESS_PAD_RECV;
931 else if (conn->datadgst_en)
932 tcp_conn->in_progress = IN_PROGRESS_DDIGEST_RECV;
933 else
934 tcp_conn->in_progress = IN_PROGRESS_WAIT_HEADER;
935 tcp_conn->data_copied = 0;
936 }
937
938 if (tcp_conn->in_progress == IN_PROGRESS_PAD_RECV &&
939 tcp_conn->in.copy) {
940 int copylen = min(tcp_conn->in.padding - tcp_conn->data_copied,
941 tcp_conn->in.copy);
942
943 tcp_conn->in.copy -= copylen;
944 tcp_conn->in.offset += copylen;
945 tcp_conn->data_copied += copylen;
946
947 if (tcp_conn->data_copied != tcp_conn->in.padding)
948 tcp_conn->in_progress = IN_PROGRESS_PAD_RECV;
949 else if (conn->datadgst_en)
950 tcp_conn->in_progress = IN_PROGRESS_DDIGEST_RECV;
951 else
952 tcp_conn->in_progress = IN_PROGRESS_WAIT_HEADER;
953 tcp_conn->data_copied = 0;
954 }
955
956 debug_tcp("f, processed %d from out of %d padding %d\n",
957 tcp_conn->in.offset - offset, (int)len, tcp_conn->in.padding);
958 BUG_ON(tcp_conn->in.offset - offset > len);
959
960 if (tcp_conn->in.offset - offset != len) {
961 debug_tcp("continue to process %d bytes\n",
962 (int)len - (tcp_conn->in.offset - offset));
963 goto more;
964 }
965
966nomore:
967 processed = tcp_conn->in.offset - offset;
968 BUG_ON(processed == 0);
969 return processed;
970
971again:
972 processed = tcp_conn->in.offset - offset;
973 debug_tcp("c, processed %d from out of %d rd_desc_cnt %d\n",
974 processed, (int)len, (int)rd_desc->count);
975 BUG_ON(processed == 0);
976 BUG_ON(processed > len);
977
978 conn->rxdata_octets += processed;
979 return processed;
980}977}
981 978
982static void979static void
983iscsi_tcp_data_ready(struct sock *sk, int flag)980iscsi_tcp_data_ready(struct sock *sk, int flag)
984{981{
985 struct iscsi_conn *conn = sk->sk_user_data;982 struct iscsi_conn *conn = sk->sk_user_data;
983 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
986 read_descriptor_t rd_desc;984 read_descriptor_t rd_desc;
987 985
988 read_lock(&sk->sk_callback_lock);986 read_lock(&sk->sk_callback_lock);
989 987
990 /*988 /*
991 * Use rd_desc to pass 'conn' to iscsi_tcp_data_recv.989 * Use rd_desc to pass 'conn' to iscsi_tcp_recv.
992 * We set count to 1 because we want the network layer to990 * We set count to 1 because we want the network layer to
993 * hand us all the skbs that are available. iscsi_tcp_data_recv991 * hand us all the skbs that are available. iscsi_tcp_recv
994 * handled pdus that cross buffers or pdus that still need data.992 * handled pdus that cross buffers or pdus that still need data.
995 */993 */
996 rd_desc.arg.data = conn;994 rd_desc.arg.data = conn;
997 rd_desc.count = 1;995 rd_desc.count = 1;
998 tcp_read_sock(sk, &rd_desc, iscsi_tcp_data_recv);996 tcp_read_sock(sk, &rd_desc, iscsi_tcp_recv);
999 997
1000 read_unlock(&sk->sk_callback_lock);998 read_unlock(&sk->sk_callback_lock);
999
1000 /* If we had to (atomically) map a highmem page,
1001 * unmap it now. */
1002 iscsi_tcp_segment_unmap(&tcp_conn->in.segment);
1001}1003}
1002 1004
1003static void1005static void
@@ -1077,121 +1079,173 @@ iscsi_conn_restore_callbacks(struct iscsi_tcp_conn *tcp_conn) · 73 unmodified lines
1077}1079}
1078 1080
1079/**1081/**
1080 * iscsi_send - generic send routine1082 * iscsi_xmit - TCP transmit
1081 * @sk: kernel's socket1083 **/
1082 * @buf: buffer to write from1084static int
1083 * @size: actual size to write1085iscsi_xmit(struct iscsi_conn *conn)
1084 * @flags: socket's flags1086{
1087 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
1088 struct iscsi_segment *segment = &tcp_conn->out.segment;
1089 unsigned int consumed = 0;
1090 int rc = 0;
1091
1092 while (1) {
1093 rc = iscsi_tcp_xmit_segment(tcp_conn, segment);
1094 if (rc < 0)
1095 goto error;
1096 if (rc == 0)
1097 break;
1098
1099 consumed += rc;
1100
1101 if (segment->total_copied >= segment->total_size) {
1102 if (segment->done != NULL) {
1103 rc = segment->done(tcp_conn, segment);
1104 if (rc < 0)
1105 goto error;
1106 }
1107 }
1108 }
1109
1110 debug_tcp("xmit %d bytes\n", consumed);
1111
1112 conn->txdata_octets += consumed;
1113 return consumed;
1114
1115error:
1116 /* Transmit error. We could initiate error recovery
1117 * here. */
1118 debug_tcp("Error sending PDU, errno=%d\n", rc);
1119 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
1120 return rc;
1121}
1122
1123/**
1124 * iscsi_tcp_xmit_qlen - return the number of bytes queued for xmit
1085 */1125 */
1086static inline int1126static inline int
1087iscsi_send(struct iscsi_conn *conn, struct iscsi_buf *buf, int size, int flags)1127iscsi_tcp_xmit_qlen(struct iscsi_conn *conn)
1088{1128{
1089 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;1129 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
1090 struct socket *sk = tcp_conn->sock;1130 struct iscsi_segment *segment = &tcp_conn->out.segment;
1091 int offset = buf->sg.offset + buf->sent, res;
1092 1131
1093 /*1132 return segment->total_copied - segment->total_size;
1094 * if we got use_sg=0 or are sending something we kmallocd1133}
1095 * then we did not have to do kmap (kmap returns page_address)1134
1096 *1135static inline int
1097 * if we got use_sg > 0, but had to drop down, we do not1136iscsi_tcp_flush(struct iscsi_conn *conn)
1098 * set clustering so this should only happen for that1137{
1099 * slab case.1138 int rc;
1139
1140 while (iscsi_tcp_xmit_qlen(conn)) {
1141 rc = iscsi_xmit(conn);
1142 if (rc == 0)
1143 return -EAGAIN;
1144 if (rc < 0)
1145 return rc;
1146 }
1147
1148 return 0;
1149}
1150
1151/*
1152 * This is called when we're done sending the header.
1153 * Simply copy the data_segment to the send segment, and return.
1154 */
1155static int
1156iscsi_tcp_send_hdr_done(struct iscsi_tcp_conn *tcp_conn,
1157 struct iscsi_segment *segment)
1158{
1159 tcp_conn->out.segment = tcp_conn->out.data_segment;
1160 debug_tcp("Header done. Next segment size %u total_size %u\n",
1161 tcp_conn->out.segment.size, tcp_conn->out.segment.total_size);
1162 return 0;
1163}
1164
1165static void
1166iscsi_tcp_send_hdr_prep(struct iscsi_conn *conn, void *hdr, size_t hdrlen)
1167{
1168 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
1169
1170 debug_tcp("%s(%p%s)\n", __FUNCTION__, tcp_conn,
1171 conn->hdrdgst_en? ", digest enabled" : "");
1172
1173 /* Clear the data segment - needs to be filled in by the
1174 * caller using iscsi_tcp_send_data_prep() */
1175 memset(&tcp_conn->out.data_segment, 0, sizeof(struct iscsi_segment));
1176
1177 /* If header digest is enabled, compute the CRC and
1178 * place the digest into the same buffer. We make
1179 * sure that both iscsi_tcp_ctask and mtask have
1180 * sufficient room.
1100 */1181 */
1101 if (buf->use_sendmsg)1182 if (conn->hdrdgst_en) {
1102 res = sock_no_sendpage(sk, sg_page(&buf->sg), offset, size, flags);1183 iscsi_tcp_dgst_header(&tcp_conn->tx_hash, hdr, hdrlen,
1103 else1184 hdr + hdrlen);
1104 res = tcp_conn->sendpage(sk, sg_page(&buf->sg), offset, size, flags);1185 hdrlen += ISCSI_DIGEST_SIZE;
1105
1106 if (res >= 0) {
1107 conn->txdata_octets += res;
1108 buf->sent += res;
1109 return res;
1110 }1186 }
1111 1187
1112 tcp_conn->sendpage_failures_cnt++;1188 /* Remember header pointer for later, when we need
1113 if (res == -EAGAIN)1189 * to decide whether there's a payload to go along
1114 res = -ENOBUFS;1190 * with the header. */
1115 else1191 tcp_conn->out.hdr = hdr;
1116 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);1192
1117 return res;1193 iscsi_segment_init_linear(&tcp_conn->out.segment, hdr, hdrlen,
1194 iscsi_tcp_send_hdr_done, NULL);
1118}1195}
1119 1196
1120/**1197/*
1121 * iscsi_sendhdr - send PDU Header via tcp_sendpage()1198 * Prepare the send buffer for the payload data.
1122 * @conn: iscsi connection1199 * Padding and checksumming will all be taken care
1123 * @buf: buffer to write from1200 * of by the iscsi_segment routines.
1124 * @datalen: lenght of data to be sent after the header1201 */
1125 *1202static int
1126 * Notes:1203iscsi_tcp_send_data_prep(struct iscsi_conn *conn, struct scatterlist *sg,
1127 * (Tx, Fast Path)1204 unsigned int count, unsigned int offset,
1128 **/1205 unsigned int len)
1129static inline int
1130iscsi_sendhdr(struct iscsi_conn *conn, struct iscsi_buf *buf, int datalen)
1131{1206{
1132 int flags = 0; /* MSG_DONTWAIT; */1207 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
1133 int res, size;1208 struct hash_desc *tx_hash = NULL;
1134 1209 unsigned int hdr_spec_len;
1135 size = buf->sg.length - buf->sent;
1136 BUG_ON(buf->sent + size > buf->sg.length);
1137 if (buf->sent + size != buf->sg.length || datalen)
1138 flags |= MSG_MORE;
1139
1140 res = iscsi_send(conn, buf, size, flags);
1141 debug_tcp("sendhdr %d bytes, sent %d res %d\n", size, buf->sent, res);
1142 if (res >= 0) {
1143 if (size != res)
1144 return -EAGAIN;
1145 return 0;
1146 }
1147 1210
1148 return res;1211 debug_tcp("%s(%p, offset=%d, datalen=%d%s)\n", __FUNCTION__,
1149}1212 tcp_conn, offset, len,
1213 conn->datadgst_en? ", digest enabled" : "");
1150 1214
1151/**1215 /* Make sure the datalen matches what the caller
1152 * iscsi_sendpage - send one page of iSCSI Data-Out.1216 said he would send. */
1153 * @conn: iscsi connection1217 hdr_spec_len = ntoh24(tcp_conn->out.hdr->dlength);
1154 * @buf: buffer to write from1218 WARN_ON(iscsi_padded(len) != iscsi_padded(hdr_spec_len));
1155 * @count: remaining data1219
1156 * @sent: number of bytes sent1220 if (conn->datadgst_en)
1157 *1221 tx_hash = &tcp_conn->tx_hash;
1158 * Notes:
1159 * (Tx, Fast Path)
1160 **/
1161static inline int
1162iscsi_sendpage(struct iscsi_conn *conn, struct iscsi_buf *buf,
1163 int *count, int *sent)
1164{
1165 int flags = 0; /* MSG_DONTWAIT; */
1166 int res, size;
1167
1168 size = buf->sg.length - buf->sent;
1169 BUG_ON(buf->sent + size > buf->sg.length);
1170 if (size > *count)
1171 size = *count;
1172 if (buf->sent + size != buf->sg.length || *count != size)
1173 flags |= MSG_MORE;
1174
1175 res = iscsi_send(conn, buf, size, flags);
1176 debug_tcp("sendpage: %d bytes, sent %d left %d sent %d res %d\n",
1177 size, buf->sent, *count, *sent, res);
1178 if (res >= 0) {
1179 *count -= res;
1180 *sent += res;
1181 if (size != res)
1182 return -EAGAIN;
1183 return 0;
1184 }
1185 1222
1186 return res;1223 return iscsi_segment_seek_sg(&tcp_conn->out.data_segment,
1224 sg, count, offset, len,
1225 NULL, tx_hash);
1187}1226}
1188 1227
1189static inline void1228static void
1190iscsi_data_digest_init(struct iscsi_tcp_conn *tcp_conn,1229iscsi_tcp_send_linear_data_prepare(struct iscsi_conn *conn, void *data,
1191 struct iscsi_tcp_cmd_task *tcp_ctask)1230 size_t len)
1192{1231{
1193 crypto_hash_init(&tcp_conn->tx_hash);1232 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
1194 tcp_ctask->digest_count = 4;1233 struct hash_desc *tx_hash = NULL;
1234 unsigned int hdr_spec_len;
1235
1236 debug_tcp("%s(%p, datalen=%d%s)\n", __FUNCTION__, tcp_conn, len,
1237 conn->datadgst_en? ", digest enabled" : "");
1238
1239 /* Make sure the datalen matches what the caller
1240 said he would send. */
1241 hdr_spec_len = ntoh24(tcp_conn->out.hdr->dlength);
1242 WARN_ON(iscsi_padded(len) != iscsi_padded(hdr_spec_len));
1243
1244 if (conn->datadgst_en)
1245 tx_hash = &tcp_conn->tx_hash;
1246
1247 iscsi_segment_init_linear(&tcp_conn->out.data_segment,
1248 data, len, NULL, tx_hash);
1195}1249}
1196 1250
1197/**1251/**
@@ -1207,12 +1261,17 @@ iscsi_data_digest_init(struct iscsi_tcp_conn *tcp_conn, · 9 unmodified lines
1207 *1261 *
1208 * Called under connection lock.1262 * Called under connection lock.
1209 **/1263 **/
1210static void1264static int
1211iscsi_solicit_data_cont(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask,1265iscsi_solicit_data_cont(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask,
1212 struct iscsi_r2t_info *r2t, int left)1266 struct iscsi_r2t_info *r2t)
1213{1267{
1214 struct iscsi_data *hdr;1268 struct iscsi_data *hdr;
1215 int new_offset;1269 int new_offset, left;
1270
1271 BUG_ON(r2t->data_length - r2t->sent < 0);
1272 left = r2t->data_length - r2t->sent;
1273 if (left == 0)
1274 return 0;
1216 1275
1217 hdr = &r2t->dtask.hdr;1276 hdr = &r2t->dtask.hdr;
1218 memset(hdr, 0, sizeof(struct iscsi_data));1277 memset(hdr, 0, sizeof(struct iscsi_data));
@@ -1233,43 +1292,46 @@ iscsi_solicit_data_cont(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask, · 14 unmodified lines
1233 r2t->data_count = left;1292 r2t->data_count = left;
1234 hdr->flags = ISCSI_FLAG_CMD_FINAL;1293 hdr->flags = ISCSI_FLAG_CMD_FINAL;
1235 }1294 }
1236 conn->dataout_pdus_cnt++;
1237
1238 iscsi_buf_init_iov(&r2t->headbuf, (char*)hdr,
1239 sizeof(struct iscsi_hdr));
1240
1241 if (iscsi_buf_left(&r2t->sendbuf))
1242 return;
1243
1244 iscsi_buf_init_sg(&r2t->sendbuf, r2t->sg);
1245 r2t->sg += 1;
1246}
1247
1248static void iscsi_set_padding(struct iscsi_tcp_cmd_task *tcp_ctask,
1249 unsigned long len)
1250{
1251 tcp_ctask->pad_count = len & (ISCSI_PAD_LEN - 1);
1252 if (!tcp_ctask->pad_count)
1253 return;
1254 1295
1255 tcp_ctask->pad_count = ISCSI_PAD_LEN - tcp_ctask->pad_count;1296 conn->dataout_pdus_cnt++;
1256 debug_scsi("write padding %d bytes\n", tcp_ctask->pad_count);1297 return 1;
1257 set_bit(XMSTATE_BIT_W_PAD, &tcp_ctask->xmstate);
1258}1298}
1259 1299
1260/**1300/**
1261 * iscsi_tcp_cmd_init - Initialize iSCSI SCSI_READ or SCSI_WRITE commands1301 * iscsi_tcp_ctask - Initialize iSCSI SCSI_READ or SCSI_WRITE commands
1262 * @conn: iscsi connection1302 * @conn: iscsi connection
1263 * @ctask: scsi command task1303 * @ctask: scsi command task
1264 * @sc: scsi command1304 * @sc: scsi command
1265 **/1305 **/
1266static void1306static int
1267iscsi_tcp_cmd_init(struct iscsi_cmd_task *ctask)1307iscsi_tcp_ctask_init(struct iscsi_cmd_task *ctask)
1268{1308{
1269 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;1309 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
1310 struct iscsi_conn *conn = ctask->conn;
1311 struct scsi_cmnd *sc = ctask->sc;
1312 int err;
1270 1313
1271 BUG_ON(__kfifo_len(tcp_ctask->r2tqueue));1314 BUG_ON(__kfifo_len(tcp_ctask->r2tqueue));
1272 tcp_ctask->xmstate = 1 << XMSTATE_BIT_CMD_HDR_INIT;1315 tcp_ctask->sent = 0;
1316 tcp_ctask->exp_datasn = 0;
1317
1318 /* Prepare PDU, optionally w/ immediate data */
1319 debug_scsi("ctask deq [cid %d itt 0x%x imm %d unsol %d]\n",
1320 conn->id, ctask->itt, ctask->imm_count,
1321 ctask->unsol_count);
1322 iscsi_tcp_send_hdr_prep(conn, ctask->hdr, ctask->hdr_len);
1323
1324 if (!ctask->imm_count)
1325 return 0;
1326
1327 /* If we have immediate data, attach a payload */
1328 err = iscsi_tcp_send_data_prep(conn, scsi_sglist(sc), scsi_sg_count(sc),
1329 0, ctask->imm_count);
1330 if (err)
1331 return err;
1332 tcp_ctask->sent += ctask->imm_count;
1333 ctask->imm_count = 0;
1334 return 0;
1273}1335}
1274 1336
1275/**1337/**
@@ -1281,484 +1343,130 @@ iscsi_tcp_cmd_init(struct iscsi_cmd_task *ctask) · 5 unmodified lines
1281 * The function can return -EAGAIN in which case caller must1343 * The function can return -EAGAIN in which case caller must
1282 * call it again later, or recover. '0' return code means successful1344 * call it again later, or recover. '0' return code means successful
1283 * xmit.1345 * xmit.
1284 *
1285 * Management xmit state machine consists of these states:
1286 * XMSTATE_BIT_IMM_HDR_INIT - calculate digest of PDU Header
1287 * XMSTATE_BIT_IMM_HDR - PDU Header xmit in progress
1288 * XMSTATE_BIT_IMM_DATA - PDU Data xmit in progress
1289 * XMSTATE_VALUE_IDLE - management PDU is done
1290 **/1346 **/
1291static int1347static int
1292iscsi_tcp_mtask_xmit(struct iscsi_conn *conn, struct iscsi_mgmt_task *mtask)1348iscsi_tcp_mtask_xmit(struct iscsi_conn *conn, struct iscsi_mgmt_task *mtask)
1293{1349{
1294 struct iscsi_tcp_mgmt_task *tcp_mtask = mtask->dd_data;
1295 int rc;1350 int rc;
1296 1351
1297 debug_scsi("mtask deq [cid %d state %x itt 0x%x]\n",1352 /* Flush any pending data first. */
1298 conn->id, tcp_mtask->xmstate, mtask->itt);1353 rc = iscsi_tcp_flush(conn);
1299 1354 if (rc < 0)
1300 if (test_bit(XMSTATE_BIT_IMM_HDR_INIT, &tcp_mtask->xmstate)) {1355 return rc;
1301 iscsi_buf_init_iov(&tcp_mtask->headbuf, (char*)mtask->hdr,
1302 sizeof(struct iscsi_hdr));
1303
1304 if (mtask->data_count) {
1305 set_bit(XMSTATE_BIT_IMM_DATA, &tcp_mtask->xmstate);
1306 iscsi_buf_init_iov(&tcp_mtask->sendbuf,
1307 (char*)mtask->data,
1308 mtask->data_count);
1309 }
1310
1311 if (conn->c_stage != ISCSI_CONN_INITIAL_STAGE &&
1312 conn->stop_stage != STOP_CONN_RECOVER &&
1313 conn->hdrdgst_en)
1314 iscsi_hdr_digest(conn, &tcp_mtask->headbuf,
1315 (u8*)tcp_mtask->hdrext);
1316
1317 tcp_mtask->sent = 0;
1318 clear_bit(XMSTATE_BIT_IMM_HDR_INIT, &tcp_mtask->xmstate);
1319 set_bit(XMSTATE_BIT_IMM_HDR, &tcp_mtask->xmstate);
1320 }
1321
1322 if (test_bit(XMSTATE_BIT_IMM_HDR, &tcp_mtask->xmstate)) {
1323 rc = iscsi_sendhdr(conn, &tcp_mtask->headbuf,
1324 mtask->data_count);
1325 if (rc)
1326 return rc;
1327 clear_bit(XMSTATE_BIT_IMM_HDR, &tcp_mtask->xmstate);
1328 }
1329
1330 if (test_and_clear_bit(XMSTATE_BIT_IMM_DATA, &tcp_mtask->xmstate)) {
1331 BUG_ON(!mtask->data_count);
1332 /* FIXME: implement.
1333 * Virtual buffer could be spreaded across multiple pages...
1334 */
1335 do {
1336 int rc;
1337
1338 rc = iscsi_sendpage(conn, &tcp_mtask->sendbuf,
1339 &mtask->data_count, &tcp_mtask->sent);
1340 if (rc) {
1341 set_bit(XMSTATE_BIT_IMM_DATA, &tcp_mtask->xmstate);
1342 return rc;
1343 }
1344 } while (mtask->data_count);
1345 }
1346 1356
1347 BUG_ON(tcp_mtask->xmstate != XMSTATE_VALUE_IDLE);
1348 if (mtask->hdr->itt == RESERVED_ITT) {1357 if (mtask->hdr->itt == RESERVED_ITT) {
1349 struct iscsi_session *session = conn->session;1358 struct iscsi_session *session = conn->session;
1350 1359
1351 spin_lock_bh(&session->lock);1360 spin_lock_bh(&session->lock);
1352 list_del(&conn->mtask->running);1361 iscsi_free_mgmt_task(conn, mtask);
1353 __kfifo_put(session->mgmtpool.queue, (void*)&conn->mtask,
1354 sizeof(void*));
1355 spin_unlock_bh(&session->lock);1362 spin_unlock_bh(&session->lock);
1356 }1363 }
1364
1357 return 0;1365 return 0;
1358}1366}
1359 1367
1368/*
1369 * iscsi_tcp_ctask_xmit - xmit normal PDU task
1370 * @conn: iscsi connection
1371 * @ctask: iscsi command task
1372 *
1373 * We're expected to return 0 when everything was transmitted succesfully,
1374 * -EAGAIN if there's still data in the queue, or != 0 for any other kind
1375 * of error.
1376 */
1360static int1377static int
1361iscsi_send_cmd_hdr(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)1378iscsi_tcp_ctask_xmit(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
1362{1379{
1363 struct scsi_cmnd *sc = ctask->sc;
1364 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;1380 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
1381 struct scsi_cmnd *sc = ctask->sc;
1365 int rc = 0;1382 int rc = 0;
1366 1383
1367 if (test_bit(XMSTATE_BIT_CMD_HDR_INIT, &tcp_ctask->xmstate)) {1384flush:
1368 tcp_ctask->sent = 0;1385 /* Flush any pending data first. */
1369 tcp_ctask->sg_count = 0;1386 rc = iscsi_tcp_flush(conn);
1370 tcp_ctask->exp_datasn = 0;1387 if (rc < 0)
1371
1372 if (sc->sc_data_direction == DMA_TO_DEVICE) {
1373 struct scatterlist *sg = scsi_sglist(sc);
1374
1375 iscsi_buf_init_sg(&tcp_ctask->sendbuf, sg);
1376 tcp_ctask->sg = sg + 1;
1377 tcp_ctask->bad_sg = sg + scsi_sg_count(sc);
1378
1379 debug_scsi("cmd [itt 0x%x total %d imm_data %d "
1380 "unsol count %d, unsol offset %d]\n",
1381 ctask->itt, scsi_bufflen(sc),
1382 ctask->imm_count, ctask->unsol_count,
1383 ctask->unsol_offset);
1384 }
1385
1386 iscsi_buf_init_iov(&tcp_ctask->headbuf, (char*)ctask->hdr,
1387 sizeof(struct iscsi_hdr));
1388
1389 if (conn->hdrdgst_en)
1390 iscsi_hdr_digest(conn, &tcp_ctask->headbuf,
1391 (u8*)tcp_ctask->hdrext);
1392 clear_bit(XMSTATE_BIT_CMD_HDR_INIT, &tcp_ctask->xmstate);
1393 set_bit(XMSTATE_BIT_CMD_HDR_XMIT, &tcp_ctask->xmstate);
1394 }
1395
1396 if (test_bit(XMSTATE_BIT_CMD_HDR_XMIT, &tcp_ctask->xmstate)) {
1397 rc = iscsi_sendhdr(conn, &tcp_ctask->headbuf, ctask->imm_count);
1398 if (rc)
1399 return rc;
1400 clear_bit(XMSTATE_BIT_CMD_HDR_XMIT, &tcp_ctask->xmstate);
1401
1402 if (sc->sc_data_direction != DMA_TO_DEVICE)
1403 return 0;
1404
1405 if (ctask->imm_count) {
1406 set_bit(XMSTATE_BIT_IMM_DATA, &tcp_ctask->xmstate);
1407 iscsi_set_padding(tcp_ctask, ctask->imm_count);
1408
1409 if (ctask->conn->datadgst_en) {
1410 iscsi_data_digest_init(ctask->conn->dd_data,
1411 tcp_ctask);
1412 tcp_ctask->immdigest = 0;
1413 }
1414 }
1415
1416 if (ctask->unsol_count) {
1417 set_bit(XMSTATE_BIT_UNS_HDR, &tcp_ctask->xmstate);
1418 set_bit(XMSTATE_BIT_UNS_INIT, &tcp_ctask->xmstate);
1419 }
1420 }
1421 return rc;
1422}
1423
1424static int
1425iscsi_send_padding(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
1426{
1427 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
1428 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
1429 int sent = 0, rc;
1430
1431 if (test_bit(XMSTATE_BIT_W_PAD, &tcp_ctask->xmstate)) {
1432 iscsi_buf_init_iov(&tcp_ctask->sendbuf, (char*)&tcp_ctask->pad,
1433 tcp_ctask->pad_count);
1434 if (conn->datadgst_en)
1435 crypto_hash_update(&tcp_conn->tx_hash,
1436 &tcp_ctask->sendbuf.sg,
1437 tcp_ctask->sendbuf.sg.length);
1438 } else if (!test_bit(XMSTATE_BIT_W_RESEND_PAD, &tcp_ctask->xmstate))
1439 return 0;
1440
1441 clear_bit(XMSTATE_BIT_W_PAD, &tcp_ctask->xmstate);
1442 clear_bit(XMSTATE_BIT_W_RESEND_PAD, &tcp_ctask->xmstate);
1443 debug_scsi("sending %d pad bytes for itt 0x%x\n",
1444 tcp_ctask->pad_count, ctask->itt);
1445 rc = iscsi_sendpage(conn, &tcp_ctask->sendbuf, &tcp_ctask->pad_count,
1446 &sent);
1447 if (rc) {
1448 debug_scsi("padding send failed %d\n", rc);
1449 set_bit(XMSTATE_BIT_W_RESEND_PAD, &tcp_ctask->xmstate);
1450 }
1451 return rc;
1452}
1453
1454static int
1455iscsi_send_digest(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask,
1456 struct iscsi_buf *buf, uint32_t *digest)
1457{
1458 struct iscsi_tcp_cmd_task *tcp_ctask;
1459 struct iscsi_tcp_conn *tcp_conn;
1460 int rc, sent = 0;
1461
1462 if (!conn->datadgst_en)
1463 return 0;
1464
1465 tcp_ctask = ctask->dd_data;
1466 tcp_conn = conn->dd_data;
1467
1468 if (!test_bit(XMSTATE_BIT_W_RESEND_DATA_DIGEST, &tcp_ctask->xmstate)) {
1469 crypto_hash_final(&tcp_conn->tx_hash, (u8*)digest);
1470 iscsi_buf_init_iov(buf, (char*)digest, 4);
1471 }
1472 clear_bit(XMSTATE_BIT_W_RESEND_DATA_DIGEST, &tcp_ctask->xmstate);
1473
1474 rc = iscsi_sendpage(conn, buf, &tcp_ctask->digest_count, &sent);
1475 if (!rc)
1476 debug_scsi("sent digest 0x%x for itt 0x%x\n", *digest,
1477 ctask->itt);
1478 else {
1479 debug_scsi("sending digest 0x%x failed for itt 0x%x!\n",
1480 *digest, ctask->itt);
1481 set_bit(XMSTATE_BIT_W_RESEND_DATA_DIGEST, &tcp_ctask->xmstate);
1482 }
1483 return rc;
1484}
1485
1486static int
1487iscsi_send_data(struct iscsi_cmd_task *ctask, struct iscsi_buf *sendbuf,
1488 struct scatterlist **sg, int *sent, int *count,
1489 struct iscsi_buf *digestbuf, uint32_t *digest)
1490{
1491 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
1492 struct iscsi_conn *conn = ctask->conn;
1493 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
1494 int rc, buf_sent, offset;
1495
1496 while (*count) {
1497 buf_sent = 0;
1498 offset = sendbuf->sent;
1499
1500 rc = iscsi_sendpage(conn, sendbuf, count, &buf_sent);
1501 *sent = *sent + buf_sent;
1502 if (buf_sent && conn->datadgst_en)
1503 partial_sg_digest_update(&tcp_conn->tx_hash,
1504 &sendbuf->sg, sendbuf->sg.offset + offset,
1505 buf_sent);
1506 if (!iscsi_buf_left(sendbuf) && *sg != tcp_ctask->bad_sg) {
1507 iscsi_buf_init_sg(sendbuf, *sg);
1508 *sg = *sg + 1;
1509 }
1510
1511 if (rc)
1512 return rc;
1513 }
1514
1515 rc = iscsi_send_padding(conn, ctask);
1516 if (rc)
1517 return rc;1388 return rc;
1518 1389
1519 return iscsi_send_digest(conn, ctask, digestbuf, digest);1390 /* Are we done already? */
1520}1391 if (sc->sc_data_direction != DMA_TO_DEVICE)
1521 1392 return 0;
1522static int
1523iscsi_send_unsol_hdr(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
1524{
1525 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
1526 struct iscsi_data_task *dtask;
1527 int rc;
1528
1529 set_bit(XMSTATE_BIT_UNS_DATA, &tcp_ctask->xmstate);
1530 if (test_bit(XMSTATE_BIT_UNS_INIT, &tcp_ctask->xmstate)) {
1531 dtask = &tcp_ctask->unsol_dtask;
1532
1533 iscsi_prep_unsolicit_data_pdu(ctask, &dtask->hdr);
1534 iscsi_buf_init_iov(&tcp_ctask->headbuf, (char*)&dtask->hdr,
1535 sizeof(struct iscsi_hdr));
1536 if (conn->hdrdgst_en)
1537 iscsi_hdr_digest(conn, &tcp_ctask->headbuf,
1538 (u8*)dtask->hdrext);
1539
1540 clear_bit(XMSTATE_BIT_UNS_INIT, &tcp_ctask->xmstate);
1541 iscsi_set_padding(tcp_ctask, ctask->data_count);
1542 }
1543
1544 rc = iscsi_sendhdr(conn, &tcp_ctask->headbuf, ctask->data_count);
1545 if (rc) {
1546 clear_bit(XMSTATE_BIT_UNS_DATA, &tcp_ctask->xmstate);
1547 set_bit(XMSTATE_BIT_UNS_HDR, &tcp_ctask->xmstate);
1548 return rc;
1549 }
1550 1393
1551 if (conn->datadgst_en) {1394 if (ctask->unsol_count != 0) {
1552 dtask = &tcp_ctask->unsol_dtask;1395 struct iscsi_data *hdr = &tcp_ctask->unsol_dtask.hdr;
1553 iscsi_data_digest_init(ctask->conn->dd_data, tcp_ctask);
1554 dtask->digest = 0;
1555 }
1556 1396
1557 debug_scsi("uns dout [itt 0x%x dlen %d sent %d]\n",1397 /* Prepare a header for the unsolicited PDU.
1558 ctask->itt, ctask->unsol_count, tcp_ctask->sent);1398 * The amount of data we want to send will be
1559 return 0;1399 * in ctask->data_count.
1560}1400 * FIXME: return the data count instead.
1401 */
1402 iscsi_prep_unsolicit_data_pdu(ctask, hdr);
1561 1403
1562static int1404 debug_tcp("unsol dout [itt 0x%x doff %d dlen %d]\n",
1563iscsi_send_unsol_pdu(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)1405 ctask->itt, tcp_ctask->sent, ctask->data_count);
1564{
1565 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
1566 int rc;
1567 1406
1568 if (test_and_clear_bit(XMSTATE_BIT_UNS_HDR, &tcp_ctask->xmstate)) {1407 iscsi_tcp_send_hdr_prep(conn, hdr, sizeof(*hdr));
1569 BUG_ON(!ctask->unsol_count);1408 rc = iscsi_tcp_send_data_prep(conn, scsi_sglist(sc),
1570send_hdr:1409 scsi_sg_count(sc),
1571 rc = iscsi_send_unsol_hdr(conn, ctask);1410 tcp_ctask->sent,
1411 ctask->data_count);
1572 if (rc)1412 if (rc)
1573 return rc;1413 goto fail;
1574 }1414 tcp_ctask->sent += ctask->data_count;
1575 1415 ctask->unsol_count -= ctask->data_count;
1576 if (test_bit(XMSTATE_BIT_UNS_DATA, &tcp_ctask->xmstate)) {1416 goto flush;
1577 struct iscsi_data_task *dtask = &tcp_ctask->unsol_dtask;1417 } else {
1578 int start = tcp_ctask->sent;1418 struct iscsi_session *session = conn->session;
1419 struct iscsi_r2t_info *r2t;
1579 1420
1580 rc = iscsi_send_data(ctask, &tcp_ctask->sendbuf, &tcp_ctask->sg,1421 /* All unsolicited PDUs sent. Check for solicited PDUs.
1581 &tcp_ctask->sent, &ctask->data_count,
1582 &dtask->digestbuf, &dtask->digest);
1583 ctask->unsol_count -= tcp_ctask->sent - start;
1584 if (rc)
1585 return rc;
1586 clear_bit(XMSTATE_BIT_UNS_DATA, &tcp_ctask->xmstate);
1587 /*
1588 * Done with the Data-Out. Next, check if we need
1589 * to send another unsolicited Data-Out.
1590 */1422 */
1591 if (ctask->unsol_count) {1423 spin_lock_bh(&session->lock);
1592 debug_scsi("sending more uns\n");1424 r2t = tcp_ctask->r2t;
1593 set_bit(XMSTATE_BIT_UNS_INIT, &tcp_ctask->xmstate);1425 if (r2t != NULL) {
1594 goto send_hdr;1426 /* Continue with this R2T? */
1427 if (!iscsi_solicit_data_cont(conn, ctask, r2t)) {
1428 debug_scsi(" done with r2t %p\n", r2t);
1429
1430 __kfifo_put(tcp_ctask->r2tpool.queue,
1431 (void*)&r2t, sizeof(void*));
1432 tcp_ctask->r2t = r2t = NULL;
1433 }
1595 }1434 }
1596 }
1597 return 0;
1598}
1599
1600static int iscsi_send_sol_pdu(struct iscsi_conn *conn,
1601 struct iscsi_cmd_task *ctask)
1602{
1603 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
1604 struct iscsi_session *session = conn->session;
1605 struct iscsi_r2t_info *r2t;
1606 struct iscsi_data_task *dtask;
1607 int left, rc;
1608 1435
1609 if (test_bit(XMSTATE_BIT_SOL_HDR_INIT, &tcp_ctask->xmstate)) {1436 if (r2t == NULL) {
1610 if (!tcp_ctask->r2t) {
1611 spin_lock_bh(&session->lock);
1612 __kfifo_get(tcp_ctask->r2tqueue, (void*)&tcp_ctask->r2t,1437 __kfifo_get(tcp_ctask->r2tqueue, (void*)&tcp_ctask->r2t,
1613 sizeof(void*));1438 sizeof(void*));
1614 spin_unlock_bh(&session->lock);1439 r2t = tcp_ctask->r2t;
1615 }1440 }
1616send_hdr:1441 spin_unlock_bh(&session->lock);
1617 r2t = tcp_ctask->r2t;
1618 dtask = &r2t->dtask;
1619
1620 if (conn->hdrdgst_en)
1621 iscsi_hdr_digest(conn, &r2t->headbuf,
1622 (u8*)dtask->hdrext);
1623 clear_bit(XMSTATE_BIT_SOL_HDR_INIT, &tcp_ctask->xmstate);
1624 set_bit(XMSTATE_BIT_SOL_HDR, &tcp_ctask->xmstate);
1625 }
1626
1627 if (test_bit(XMSTATE_BIT_SOL_HDR, &tcp_ctask->xmstate)) {
1628 r2t = tcp_ctask->r2t;
1629 dtask = &r2t->dtask;
1630
1631 rc = iscsi_sendhdr(conn, &r2t->headbuf, r2t->data_count);
1632 if (rc)
1633 return rc;
1634 clear_bit(XMSTATE_BIT_SOL_HDR, &tcp_ctask->xmstate);
1635 set_bit(XMSTATE_BIT_SOL_DATA, &tcp_ctask->xmstate);
1636 1442
1637 if (conn->datadgst_en) {1443 /* Waiting for more R2Ts to arrive. */
1638 iscsi_data_digest_init(conn->dd_data, tcp_ctask);1444 if (r2t == NULL) {
1639 dtask->digest = 0;1445 debug_tcp("no R2Ts yet\n");
1446 return 0;
1640 }1447 }
1641 1448
1642 iscsi_set_padding(tcp_ctask, r2t->data_count);1449 debug_scsi("sol dout %p [dsn %d itt 0x%x doff %d dlen %d]\n",
1643 debug_scsi("sol dout [dsn %d itt 0x%x dlen %d sent %d]\n",1450 r2t, r2t->solicit_datasn - 1, ctask->itt,
1644 r2t->solicit_datasn - 1, ctask->itt, r2t->data_count,1451 r2t->data_offset + r2t->sent, r2t->data_count);
1645 r2t->sent);
1646 }
1647 1452
1648 if (test_bit(XMSTATE_BIT_SOL_DATA, &tcp_ctask->xmstate)) {1453 iscsi_tcp_send_hdr_prep(conn, &r2t->dtask.hdr,
1649 r2t = tcp_ctask->r2t;1454 sizeof(struct iscsi_hdr));
1650 dtask = &r2t->dtask;
1651 1455
1652 rc = iscsi_send_data(ctask, &r2t->sendbuf, &r2t->sg,1456 rc = iscsi_tcp_send_data_prep(conn, scsi_sglist(sc),
1653 &r2t->sent, &r2t->data_count,1457 scsi_sg_count(sc),
1654 &dtask->digestbuf, &dtask->digest);1458 r2t->data_offset + r2t->sent,
1459 r2t->data_count);
1655 if (rc)1460 if (rc)
1656 return rc;1461 goto fail;
1657 clear_bit(XMSTATE_BIT_SOL_DATA, &tcp_ctask->xmstate);1462 tcp_ctask->sent += r2t->data_count;
1658 1463 r2t->sent += r2t->data_count;
1659 /*1464 goto flush;
1660 * Done with this Data-Out. Next, check if we have
1661 * to send another Data-Out for this R2T.
1662 */
1663 BUG_ON(r2t->data_length - r2t->sent < 0);
1664 left = r2t->data_length - r2t->sent;
1665 if (left) {
1666 iscsi_solicit_data_cont(conn, ctask, r2t, left);
1667 goto send_hdr;
1668 }
1669
1670 /*
1671 * Done with this R2T. Check if there are more
1672 * outstanding R2Ts ready to be processed.
1673 */
1674 spin_lock_bh(&session->lock);
1675 tcp_ctask->r2t = NULL;
1676 __kfifo_put(tcp_ctask->r2tpool.queue, (void*)&r2t,
1677 sizeof(void*));
1678 if (__kfifo_get(tcp_ctask->r2tqueue, (void*)&r2t,
1679 sizeof(void*))) {
1680 tcp_ctask->r2t = r2t;
1681 spin_unlock_bh(&session->lock);
1682 goto send_hdr;
1683 }
1684 spin_unlock_bh(&session->lock);
1685 }1465 }
1686 return 0;1466 return 0;
1687}1467fail:
1688 1468 iscsi_conn_failure(conn, rc);
1689/**1469 return -EIO;
1690 * iscsi_tcp_ctask_xmit - xmit normal PDU task
1691 * @conn: iscsi connection
1692 * @ctask: iscsi command task
1693 *
1694 * Notes:
1695 * The function can return -EAGAIN in which case caller must
1696 * call it again later, or recover. '0' return code means successful
1697 * xmit.
1698 * The function is devided to logical helpers (above) for the different
1699 * xmit stages.
1700 *
1701 *iscsi_send_cmd_hdr()
1702 * XMSTATE_BIT_CMD_HDR_INIT - prepare Header and Data buffers Calculate
1703 * Header Digest
1704 * XMSTATE_BIT_CMD_HDR_XMIT - Transmit header in progress
1705 *
1706 *iscsi_send_padding
1707 * XMSTATE_BIT_W_PAD - Prepare and send pading
1708 * XMSTATE_BIT_W_RESEND_PAD - retry send pading
1709 *
1710 *iscsi_send_digest
1711 * XMSTATE_BIT_W_RESEND_DATA_DIGEST - Finalize and send Data Digest
1712 * XMSTATE_BIT_W_RESEND_DATA_DIGEST - retry sending digest
1713 *
1714 *iscsi_send_unsol_hdr
1715 * XMSTATE_BIT_UNS_INIT - prepare un-solicit data header and digest
1716 * XMSTATE_BIT_UNS_HDR - send un-solicit header
1717 *
1718 *iscsi_send_unsol_pdu
1719 * XMSTATE_BIT_UNS_DATA - send un-solicit data in progress
1720 *
1721 *iscsi_send_sol_pdu
1722 * XMSTATE_BIT_SOL_HDR_INIT - solicit data header and digest initialize
1723 * XMSTATE_BIT_SOL_HDR - send solicit header
1724 * XMSTATE_BIT_SOL_DATA - send solicit data
1725 *
1726 *iscsi_tcp_ctask_xmit
1727 * XMSTATE_BIT_IMM_DATA - xmit managment data (??)
1728 **/
1729static int
1730iscsi_tcp_ctask_xmit(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
1731{
1732 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
1733 int rc = 0;
1734
1735 debug_scsi("ctask deq [cid %d xmstate %x itt 0x%x]\n",
1736 conn->id, tcp_ctask->xmstate, ctask->itt);
1737
1738 rc = iscsi_send_cmd_hdr(conn, ctask);
1739 if (rc)
1740 return rc;
1741 if (ctask->sc->sc_data_direction != DMA_TO_DEVICE)
1742 return 0;
1743
1744 if (test_bit(XMSTATE_BIT_IMM_DATA, &tcp_ctask->xmstate)) {
1745 rc = iscsi_send_data(ctask, &tcp_ctask->sendbuf, &tcp_ctask->sg,
1746 &tcp_ctask->sent, &ctask->imm_count,
1747 &tcp_ctask->immbuf, &tcp_ctask->immdigest);
1748 if (rc)
1749 return rc;
1750 clear_bit(XMSTATE_BIT_IMM_DATA, &tcp_ctask->xmstate);
1751 }
1752
1753 rc = iscsi_send_unsol_pdu(conn, ctask);
1754 if (rc)
1755 return rc;
1756
1757 rc = iscsi_send_sol_pdu(conn, ctask);
1758 if (rc)
1759 return rc;
1760
1761 return rc;
1762}1470}
1763 1471
1764static struct iscsi_cls_conn *1472static struct iscsi_cls_conn *
@@ -1784,9 +1492,6 @@ iscsi_tcp_conn_create(struct iscsi_cls_session *cls_session, uint32_t conn_idx) · 19 unmodified lines
1784 1492
1785 conn->dd_data = tcp_conn;1493 conn->dd_data = tcp_conn;
1786 tcp_conn->iscsi_conn = conn;1494 tcp_conn->iscsi_conn = conn;
1787 tcp_conn->in_progress = IN_PROGRESS_WAIT_HEADER;
1788 /* initial operational parameters */
1789 tcp_conn->hdr_size = sizeof(struct iscsi_hdr);
1790 1495
1791 tcp_conn->tx_hash.tfm = crypto_alloc_hash("crc32c", 0,1496 tcp_conn->tx_hash.tfm = crypto_alloc_hash("crc32c", 0,
1792 CRYPTO_ALG_ASYNC);1497 CRYPTO_ALG_ASYNC);
@@ -1863,11 +1568,9 @@ static void · 70 unmodified lines
1863iscsi_tcp_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)1568iscsi_tcp_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)
1864{1569{
1865 struct iscsi_conn *conn = cls_conn->dd_data;1570 struct iscsi_conn *conn = cls_conn->dd_data;
1866 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
1867 1571
1868 iscsi_conn_stop(cls_conn, flag);1572 iscsi_conn_stop(cls_conn, flag);
1869 iscsi_tcp_release_conn(conn);1573 iscsi_tcp_release_conn(conn);
1870 tcp_conn->hdr_size = sizeof(struct iscsi_hdr);
1871}1574}
1872 1575
1873static int iscsi_tcp_get_addr(struct iscsi_conn *conn, struct socket *sock,1576static int iscsi_tcp_get_addr(struct iscsi_conn *conn, struct socket *sock,
@@ -1967,7 +1670,7 @@ iscsi_tcp_conn_bind(struct iscsi_cls_session *cls_session, · 93 unmodified lines
1967 /*1670 /*
1968 * set receive state machine into initial state1671 * set receive state machine into initial state
1969 */1672 */
1970 tcp_conn->in_progress = IN_PROGRESS_WAIT_HEADER;1673 iscsi_tcp_hdr_recv_prep(tcp_conn);
1971 return 0;1674 return 0;
1972 1675
1973free_socket:1676free_socket:
@@ -1977,10 +1680,17 @@ free_socket: · 3 unmodified lines
1977 1680
1978/* called with host lock */1681/* called with host lock */
1979static void1682static void
1980iscsi_tcp_mgmt_init(struct iscsi_conn *conn, struct iscsi_mgmt_task *mtask)1683iscsi_tcp_mtask_init(struct iscsi_conn *conn, struct iscsi_mgmt_task *mtask)
1981{1684{
1982 struct iscsi_tcp_mgmt_task *tcp_mtask = mtask->dd_data;1685 debug_scsi("mtask deq [cid %d itt 0x%x]\n", conn->id, mtask->itt);
1983 tcp_mtask->xmstate = 1 << XMSTATE_BIT_IMM_HDR_INIT;1686
1687 /* Prepare PDU, optionally w/ immediate data */
1688 iscsi_tcp_send_hdr_prep(conn, mtask->hdr, sizeof(*mtask->hdr));
1689
1690 /* If we have immediate data, attach a payload */
1691 if (mtask->data_count)
1692 iscsi_tcp_send_linear_data_prepare(conn, mtask->data,
1693 mtask->data_count);
1984}1694}
1985 1695
1986static int1696static int
@@ -2003,8 +1713,7 @@ iscsi_r2tpool_alloc(struct iscsi_session *session) · 16 unmodified lines
2003 */1713 */
2004 1714
2005 /* R2T pool */1715 /* R2T pool */
2006 if (iscsi_pool_init(&tcp_ctask->r2tpool, session->max_r2t * 4,1716 if (iscsi_pool_init(&tcp_ctask->r2tpool, session->max_r2t * 4, NULL,
2007 (void***)&tcp_ctask->r2ts,
2008 sizeof(struct iscsi_r2t_info))) {1717 sizeof(struct iscsi_r2t_info))) {
2009 goto r2t_alloc_fail;1718 goto r2t_alloc_fail;
2010 }1719 }
@@ -2013,8 +1722,7 @@ iscsi_r2tpool_alloc(struct iscsi_session *session) · 2 unmodified lines
2013 tcp_ctask->r2tqueue = kfifo_alloc(1722 tcp_ctask->r2tqueue = kfifo_alloc(
2014 session->max_r2t * 4 * sizeof(void*), GFP_KERNEL, NULL);1723 session->max_r2t * 4 * sizeof(void*), GFP_KERNEL, NULL);
2015 if (tcp_ctask->r2tqueue == ERR_PTR(-ENOMEM)) {1724 if (tcp_ctask->r2tqueue == ERR_PTR(-ENOMEM)) {
2016 iscsi_pool_free(&tcp_ctask->r2tpool,1725 iscsi_pool_free(&tcp_ctask->r2tpool);
2017 (void**)tcp_ctask->r2ts);
2018 goto r2t_alloc_fail;1726 goto r2t_alloc_fail;
2019 }1727 }
2020 }1728 }
@@ -2027,8 +1735,7 @@ r2t_alloc_fail: · 6 unmodified lines
2027 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;1735 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
2028 1736
2029 kfifo_free(tcp_ctask->r2tqueue);1737 kfifo_free(tcp_ctask->r2tqueue);
2030 iscsi_pool_free(&tcp_ctask->r2tpool,1738 iscsi_pool_free(&tcp_ctask->r2tpool);
2031 (void**)tcp_ctask->r2ts);
2032 }1739 }
2033 return -ENOMEM;1740 return -ENOMEM;
2034}1741}
@@ -2043,8 +1750,7 @@ iscsi_r2tpool_free(struct iscsi_session *session) · 8 unmodified lines
2043 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;1750 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
2044 1751
2045 kfifo_free(tcp_ctask->r2tqueue);1752 kfifo_free(tcp_ctask->r2tqueue);
2046 iscsi_pool_free(&tcp_ctask->r2tpool,1753 iscsi_pool_free(&tcp_ctask->r2tpool);
2047 (void**)tcp_ctask->r2ts);
2048 }1754 }
2049}1755}
2050 1756
@@ -2060,9 +1766,6 @@ iscsi_conn_set_param(struct iscsi_cls_conn *cls_conn, enum iscsi_param param, · 9 unmodified lines
2060 switch(param) {1766 switch(param) {
2061 case ISCSI_PARAM_HDRDGST_EN:1767 case ISCSI_PARAM_HDRDGST_EN:
2062 iscsi_set_param(cls_conn, param, buf, buflen);1768 iscsi_set_param(cls_conn, param, buf, buflen);
2063 tcp_conn->hdr_size = sizeof(struct iscsi_hdr);
2064 if (conn->hdrdgst_en)
2065 tcp_conn->hdr_size += sizeof(__u32);
2066 break;1769 break;
2067 case ISCSI_PARAM_DATADGST_EN:1770 case ISCSI_PARAM_DATADGST_EN:
2068 iscsi_set_param(cls_conn, param, buf, buflen);1771 iscsi_set_param(cls_conn, param, buf, buflen);
@@ -2071,12 +1774,12 @@ iscsi_conn_set_param(struct iscsi_cls_conn *cls_conn, enum iscsi_param param, · 2 unmodified lines
2071 break;1774 break;
2072 case ISCSI_PARAM_MAX_R2T:1775 case ISCSI_PARAM_MAX_R2T:
2073 sscanf(buf, "%d", &value);1776 sscanf(buf, "%d", &value);
2074 if (session->max_r2t == roundup_pow_of_two(value))1777 if (value <= 0 || !is_power_of_2(value))
1778 return -EINVAL;
1779 if (session->max_r2t == value)
2075 break;1780 break;
2076 iscsi_r2tpool_free(session);1781 iscsi_r2tpool_free(session);
2077 iscsi_set_param(cls_conn, param, buf, buflen);1782 iscsi_set_param(cls_conn, param, buf, buflen);
2078 if (session->max_r2t & (session->max_r2t - 1))
2079 session->max_r2t = roundup_pow_of_two(session->max_r2t);
2080 if (iscsi_r2tpool_alloc(session))1783 if (iscsi_r2tpool_alloc(session))
2081 return -ENOMEM;1784 return -ENOMEM;
2082 break;1785 break;
@@ -2183,14 +1886,15 @@ iscsi_tcp_session_create(struct iscsi_transport *iscsit, · 100 unmodified lines
2183 struct iscsi_cmd_task *ctask = session->cmds[cmd_i];1886 struct iscsi_cmd_task *ctask = session->cmds[cmd_i];
2184 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;1887 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;
2185 1888
2186 ctask->hdr = &tcp_ctask->hdr;1889 ctask->hdr = &tcp_ctask->hdr.cmd_hdr;
1890 ctask->hdr_max = sizeof(tcp_ctask->hdr) - ISCSI_DIGEST_SIZE;
2187 }1891 }
2188 1892
2189 for (cmd_i = 0; cmd_i < session->mgmtpool_max; cmd_i++) {1893 for (cmd_i = 0; cmd_i < session->mgmtpool_max; cmd_i++) {
2190 struct iscsi_mgmt_task *mtask = session->mgmt_cmds[cmd_i];1894 struct iscsi_mgmt_task *mtask = session->mgmt_cmds[cmd_i];
2191 struct iscsi_tcp_mgmt_task *tcp_mtask = mtask->dd_data;1895 struct iscsi_tcp_mgmt_task *tcp_mtask = mtask->dd_data;
2192 1896
2193 mtask->hdr = &tcp_mtask->hdr;1897 mtask->hdr = (struct iscsi_hdr *) &tcp_mtask->hdr;
2194 }1898 }
2195 1899
2196 if (iscsi_r2tpool_alloc(class_to_transport_session(cls_session)))1900 if (iscsi_r2tpool_alloc(class_to_transport_session(cls_session)))
@@ -2222,12 +1926,14 @@ static struct scsi_host_template iscsi_sht = { · 25 unmodified lines
2222 .queuecommand = iscsi_queuecommand,1926 .queuecommand = iscsi_queuecommand,
2223 .change_queue_depth = iscsi_change_queue_depth,1927 .change_queue_depth = iscsi_change_queue_depth,
2224 .can_queue = ISCSI_DEF_XMIT_CMDS_MAX - 1,1928 .can_queue = ISCSI_DEF_XMIT_CMDS_MAX - 1,
2225 .sg_tablesize = ISCSI_SG_TABLESIZE,1929 .sg_tablesize = 4096,
2226 .max_sectors = 0xFFFF,1930 .max_sectors = 0xFFFF,
2227 .cmd_per_lun = ISCSI_DEF_CMD_PER_LUN,1931 .cmd_per_lun = ISCSI_DEF_CMD_PER_LUN,
2228 .eh_abort_handler = iscsi_eh_abort,1932 .eh_abort_handler = iscsi_eh_abort,
1933 .eh_device_reset_handler= iscsi_eh_device_reset,
2229 .eh_host_reset_handler = iscsi_eh_host_reset,1934 .eh_host_reset_handler = iscsi_eh_host_reset,
2230 .use_clustering = DISABLE_CLUSTERING,1935 .use_clustering = DISABLE_CLUSTERING,
1936 .use_sg_chaining = ENABLE_SG_CHAINING,
2231 .slave_configure = iscsi_tcp_slave_configure,1937 .slave_configure = iscsi_tcp_slave_configure,
2232 .proc_name = "iscsi_tcp",1938 .proc_name = "iscsi_tcp",
2233 .this_id = -1,1939 .this_id = -1,
@@ -2257,14 +1963,17 @@ static struct iscsi_transport iscsi_tcp_transport = { · 23 unmodified lines
2257 ISCSI_PERSISTENT_ADDRESS |1963 ISCSI_PERSISTENT_ADDRESS |
2258 ISCSI_TARGET_NAME | ISCSI_TPGT |1964 ISCSI_TARGET_NAME | ISCSI_TPGT |
2259 ISCSI_USERNAME | ISCSI_PASSWORD |1965 ISCSI_USERNAME | ISCSI_PASSWORD |
2260 ISCSI_USERNAME_IN | ISCSI_PASSWORD_IN,1966 ISCSI_USERNAME_IN | ISCSI_PASSWORD_IN |
1967 ISCSI_FAST_ABORT | ISCSI_ABORT_TMO |
1968 ISCSI_LU_RESET_TMO |
1969 ISCSI_PING_TMO | ISCSI_RECV_TMO,
2261 .host_param_mask = ISCSI_HOST_HWADDRESS | ISCSI_HOST_IPADDRESS |1970 .host_param_mask = ISCSI_HOST_HWADDRESS | ISCSI_HOST_IPADDRESS |
2262 ISCSI_HOST_INITIATOR_NAME |1971 ISCSI_HOST_INITIATOR_NAME |
2263 ISCSI_HOST_NETDEV_NAME,1972 ISCSI_HOST_NETDEV_NAME,
2264 .host_template = &iscsi_sht,1973 .host_template = &iscsi_sht,
2265 .conndata_size = sizeof(struct iscsi_conn),1974 .conndata_size = sizeof(struct iscsi_conn),
2266 .max_conn = 1,1975 .max_conn = 1,
2267 .max_cmd_len = ISCSI_TCP_MAX_CMD_LEN,1976 .max_cmd_len = 16,
2268 /* session management */1977 /* session management */
2269 .create_session = iscsi_tcp_session_create,1978 .create_session = iscsi_tcp_session_create,
2270 .destroy_session = iscsi_tcp_session_destroy,1979 .destroy_session = iscsi_tcp_session_destroy,
@@ -2283,8 +1992,8 @@ static struct iscsi_transport iscsi_tcp_transport = { · 12 unmodified lines
2283 /* IO */1992 /* IO */
2284 .send_pdu = iscsi_conn_send_pdu,1993 .send_pdu = iscsi_conn_send_pdu,
2285 .get_stats = iscsi_conn_get_stats,1994 .get_stats = iscsi_conn_get_stats,
2286 .init_cmd_task = iscsi_tcp_cmd_init,1995 .init_cmd_task = iscsi_tcp_ctask_init,
2287 .init_mgmt_task = iscsi_tcp_mgmt_init,1996 .init_mgmt_task = iscsi_tcp_mtask_init,
2288 .xmit_cmd_task = iscsi_tcp_ctask_xmit,1997 .xmit_cmd_task = iscsi_tcp_ctask_xmit,
2289 .xmit_mgmt_task = iscsi_tcp_mtask_xmit,1998 .xmit_mgmt_task = iscsi_tcp_mtask_xmit,
2290 .cleanup_cmd_task = iscsi_tcp_cleanup_ctask,1999 .cleanup_cmd_task = iscsi_tcp_cleanup_ctask,
drivers/scsi/iscsi_tcp.h+51−83
@@ -24,71 +24,61 @@ · 23 unmodified lines
24 24
25#include <scsi/libiscsi.h>25#include <scsi/libiscsi.h>
26 26
27/* Socket's Receive state machine */
28#define IN_PROGRESS_WAIT_HEADER 0x0
29#define IN_PROGRESS_HEADER_GATHER 0x1
30#define IN_PROGRESS_DATA_RECV 0x2
31#define IN_PROGRESS_DDIGEST_RECV 0x3
32#define IN_PROGRESS_PAD_RECV 0x4
33
34/* xmit state machine */
35#define XMSTATE_VALUE_IDLE 0
36#define XMSTATE_BIT_CMD_HDR_INIT 0
37#define XMSTATE_BIT_CMD_HDR_XMIT 1
38#define XMSTATE_BIT_IMM_HDR 2
39#define XMSTATE_BIT_IMM_DATA 3
40#define XMSTATE_BIT_UNS_INIT 4
41#define XMSTATE_BIT_UNS_HDR 5
42#define XMSTATE_BIT_UNS_DATA 6
43#define XMSTATE_BIT_SOL_HDR 7
44#define XMSTATE_BIT_SOL_DATA 8
45#define XMSTATE_BIT_W_PAD 9
46#define XMSTATE_BIT_W_RESEND_PAD 10
47#define XMSTATE_BIT_W_RESEND_DATA_DIGEST 11
48#define XMSTATE_BIT_IMM_HDR_INIT 12
49#define XMSTATE_BIT_SOL_HDR_INIT 13
50
51#define ISCSI_PAD_LEN 4
52#define ISCSI_SG_TABLESIZE SG_ALL
53#define ISCSI_TCP_MAX_CMD_LEN 16
54
55struct crypto_hash;27struct crypto_hash;
56struct socket;28struct socket;
29struct iscsi_tcp_conn;
30struct iscsi_segment;
31
32typedef int iscsi_segment_done_fn_t(struct iscsi_tcp_conn *,
33 struct iscsi_segment *);
34
35struct iscsi_segment {
36 unsigned char *data;
37 unsigned int size;
38 unsigned int copied;
39 unsigned int total_size;
40 unsigned int total_copied;
41
42 struct hash_desc *hash;
43 unsigned char recv_digest[ISCSI_DIGEST_SIZE];
44 unsigned char digest[ISCSI_DIGEST_SIZE];
45 unsigned int digest_len;
46
47 struct scatterlist *sg;
48 void *sg_mapped;
49 unsigned int sg_offset;
50
51 iscsi_segment_done_fn_t *done;
52};
57 53
58/* Socket connection recieve helper */54/* Socket connection recieve helper */
59struct iscsi_tcp_recv {55struct iscsi_tcp_recv {
60 struct iscsi_hdr *hdr;56 struct iscsi_hdr *hdr;
61 struct sk_buff *skb;57 struct iscsi_segment segment;
62 int offset;58
63 int len;59 /* Allocate buffer for BHS + AHS */
64 int hdr_offset;60 uint32_t hdr_buf[64];
65 int copy;
66 int copied;
67 int padding;
68 struct iscsi_cmd_task *ctask; /* current cmd in progress */
69 61
70 /* copied and flipped values */62 /* copied and flipped values */
71 int datalen;63 int datalen;
72 int datadgst;64};
73 char zero_copy_hdr;65
66/* Socket connection send helper */
67struct iscsi_tcp_send {
68 struct iscsi_hdr *hdr;
69 struct iscsi_segment segment;
70 struct iscsi_segment data_segment;
74};71};
75 72
76struct iscsi_tcp_conn {73struct iscsi_tcp_conn {
77 struct iscsi_conn *iscsi_conn;74 struct iscsi_conn *iscsi_conn;
78 struct socket *sock;75 struct socket *sock;
79 struct iscsi_hdr hdr; /* header placeholder */
80 char hdrext[4*sizeof(__u16) +
81 sizeof(__u32)];
82 int data_copied;
83 int stop_stage; /* conn_stop() flag: *76 int stop_stage; /* conn_stop() flag: *
84 * stop to recover, *77 * stop to recover, *
85 * stop to terminate */78 * stop to terminate */
86 /* iSCSI connection-wide sequencing */
87 int hdr_size; /* PDU header size */
88
89 /* control data */79 /* control data */
90 struct iscsi_tcp_recv in; /* TCP receive context */80 struct iscsi_tcp_recv in; /* TCP receive context */
91 int in_progress; /* connection state machine */81 struct iscsi_tcp_send out; /* TCP send context */
92 82
93 /* old values for socket callbacks */83 /* old values for socket callbacks */
94 void (*old_data_ready)(struct sock *, int);84 void (*old_data_ready)(struct sock *, int);
@@ -103,29 +93,19 @@ struct iscsi_tcp_conn { · 8 unmodified lines
103 uint32_t sendpage_failures_cnt;93 uint32_t sendpage_failures_cnt;
104 uint32_t discontiguous_hdr_cnt;94 uint32_t discontiguous_hdr_cnt;
105 95
106 ssize_t (*sendpage)(struct socket *, struct page *, int, size_t, int);96 int error;
107};
108 97
109struct iscsi_buf {98 ssize_t (*sendpage)(struct socket *, struct page *, int, size_t, int);
110 struct scatterlist sg;
111 unsigned int sent;
112 char use_sendmsg;
113};99};
114 100
115struct iscsi_data_task {101struct iscsi_data_task {
116 struct iscsi_data hdr; /* PDU */102 struct iscsi_data hdr; /* PDU */
117 char hdrext[sizeof(__u32)]; /* Header-Digest */103 char hdrext[ISCSI_DIGEST_SIZE];/* Header-Digest */
118 struct iscsi_buf digestbuf; /* digest buffer */
119 uint32_t digest; /* data digest */
120};104};
121 105
122struct iscsi_tcp_mgmt_task {106struct iscsi_tcp_mgmt_task {
123 struct iscsi_hdr hdr;107 struct iscsi_hdr hdr;
124 char hdrext[sizeof(__u32)]; /* Header-Digest */108 char hdrext[ISCSI_DIGEST_SIZE]; /* Header-Digest */
125 unsigned long xmstate; /* mgmt xmit progress */
126 struct iscsi_buf headbuf; /* header buffer */
127 struct iscsi_buf sendbuf; /* in progress buffer */
128 int sent;
129};109};
130 110
131struct iscsi_r2t_info {111struct iscsi_r2t_info {
@@ -133,38 +113,26 @@ struct iscsi_r2t_info { · 1 unmodified line
133 __be32 exp_statsn; /* copied from R2T */113 __be32 exp_statsn; /* copied from R2T */
134 uint32_t data_length; /* copied from R2T */114 uint32_t data_length; /* copied from R2T */
135 uint32_t data_offset; /* copied from R2T */115 uint32_t data_offset; /* copied from R2T */
136 struct iscsi_buf headbuf; /* Data-Out Header Buffer */
137 struct iscsi_buf sendbuf; /* Data-Out in progress buffer*/
138 int sent; /* R2T sequence progress */116 int sent; /* R2T sequence progress */
139 int data_count; /* DATA-Out payload progress */117 int data_count; /* DATA-Out payload progress */
140 struct scatterlist *sg; /* per-R2T SG list */
141 int solicit_datasn;118 int solicit_datasn;
142 struct iscsi_data_task dtask; /* which data task */119 struct iscsi_data_task dtask; /* Data-Out header buf */
143};120};
144 121
145struct iscsi_tcp_cmd_task {122struct iscsi_tcp_cmd_task {
146 struct iscsi_cmd hdr;123 struct iscsi_hdr_buff {
147 char hdrext[4*sizeof(__u16)+ /* AHS */124 struct iscsi_cmd cmd_hdr;
148 sizeof(__u32)]; /* HeaderDigest */125 char hdrextbuf[ISCSI_MAX_AHS_SIZE +
149 char pad[ISCSI_PAD_LEN];126 ISCSI_DIGEST_SIZE];
150 int pad_count; /* padded bytes */127 } hdr;
151 struct iscsi_buf headbuf; /* header buf (xmit) */128
152 struct iscsi_buf sendbuf; /* in progress buffer*/
153 unsigned long xmstate; /* xmit xtate machine */
154 int sent;129 int sent;
155 struct scatterlist *sg; /* per-cmd SG list */130 uint32_t exp_datasn; /* expected target's R2TSN/DataSN */
156 struct scatterlist *bad_sg; /* assert statement */
157 int sg_count; /* SG's to process */
158 uint32_t exp_datasn; /* expected target's R2TSN/DataSN */
159 int data_offset;131 int data_offset;
160 struct iscsi_r2t_info *r2t; /* in progress R2T */132 struct iscsi_r2t_info *r2t; /* in progress R2T */
161 struct iscsi_queue r2tpool;133 struct iscsi_pool r2tpool;
162 struct kfifo *r2tqueue;134 struct kfifo *r2tqueue;
163 struct iscsi_r2t_info **r2ts;135 struct iscsi_data_task unsol_dtask; /* Data-Out header buf */
164 int digest_count;
165 uint32_t immdigest; /* for imm data */
166 struct iscsi_buf immbuf; /* for imm data digest */
167 struct iscsi_data_task unsol_dtask; /* unsol data task */
168};136};
169 137
170#endif /* ISCSI_H */138#endif /* ISCSI_H */
drivers/scsi/libiscsi.c+713−378
@@ -24,6 +24,7 @@ · 23 unmodified lines
24#include <linux/types.h>24#include <linux/types.h>
25#include <linux/kfifo.h>25#include <linux/kfifo.h>
26#include <linux/delay.h>26#include <linux/delay.h>
27#include <linux/log2.h>
27#include <asm/unaligned.h>28#include <asm/unaligned.h>
28#include <net/tcp.h>29#include <net/tcp.h>
29#include <scsi/scsi_cmnd.h>30#include <scsi/scsi_cmnd.h>
@@ -86,7 +87,7 @@ iscsi_update_cmdsn(struct iscsi_session *session, struct iscsi_nopin *hdr) · 56 unmodified lines
86 * xmit thread87 * xmit thread
87 */88 */
88 if (!list_empty(&session->leadconn->xmitqueue) ||89 if (!list_empty(&session->leadconn->xmitqueue) ||
89 __kfifo_len(session->leadconn->mgmtqueue))90 !list_empty(&session->leadconn->mgmtqueue))
90 scsi_queue_work(session->host,91 scsi_queue_work(session->host,
91 &session->leadconn->xmitwork);92 &session->leadconn->xmitwork);
92 }93 }
@@ -122,6 +123,20 @@ void iscsi_prep_unsolicit_data_pdu(struct iscsi_cmd_task *ctask, · 29 unmodified lines
122}123}
123EXPORT_SYMBOL_GPL(iscsi_prep_unsolicit_data_pdu);124EXPORT_SYMBOL_GPL(iscsi_prep_unsolicit_data_pdu);
124 125
126static int iscsi_add_hdr(struct iscsi_cmd_task *ctask, unsigned len)
127{
128 unsigned exp_len = ctask->hdr_len + len;
129
130 if (exp_len > ctask->hdr_max) {
131 WARN_ON(1);
132 return -EINVAL;
133 }
134
135 WARN_ON(len & (ISCSI_PAD_LEN - 1)); /* caller must pad the AHS */
136 ctask->hdr_len = exp_len;
137 return 0;
138}
139
125/**140/**
126 * iscsi_prep_scsi_cmd_pdu - prep iscsi scsi cmd pdu141 * iscsi_prep_scsi_cmd_pdu - prep iscsi scsi cmd pdu
127 * @ctask: iscsi cmd task142 * @ctask: iscsi cmd task
@@ -129,27 +144,32 @@ EXPORT_SYMBOL_GPL(iscsi_prep_unsolicit_data_pdu); · 1 unmodified line
129 * Prep basic iSCSI PDU fields for a scsi cmd pdu. The LLD should set144 * Prep basic iSCSI PDU fields for a scsi cmd pdu. The LLD should set
130 * fields like dlength or final based on how much data it sends145 * fields like dlength or final based on how much data it sends
131 */146 */
132static void iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask)147static int iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask)
133{148{
134 struct iscsi_conn *conn = ctask->conn;149 struct iscsi_conn *conn = ctask->conn;
135 struct iscsi_session *session = conn->session;150 struct iscsi_session *session = conn->session;
136 struct iscsi_cmd *hdr = ctask->hdr;151 struct iscsi_cmd *hdr = ctask->hdr;
137 struct scsi_cmnd *sc = ctask->sc;152 struct scsi_cmnd *sc = ctask->sc;
153 unsigned hdrlength;
154 int rc;
138 155
139 hdr->opcode = ISCSI_OP_SCSI_CMD;156 ctask->hdr_len = 0;
140 hdr->flags = ISCSI_ATTR_SIMPLE;157 rc = iscsi_add_hdr(ctask, sizeof(*hdr));
141 int_to_scsilun(sc->device->lun, (struct scsi_lun *)hdr->lun);158 if (rc)
142 hdr->itt = build_itt(ctask->itt, conn->id, session->age);159 return rc;
143 hdr->data_length = cpu_to_be32(scsi_bufflen(sc));160 hdr->opcode = ISCSI_OP_SCSI_CMD;
144 hdr->cmdsn = cpu_to_be32(session->cmdsn);161 hdr->flags = ISCSI_ATTR_SIMPLE;
145 session->cmdsn++;162 int_to_scsilun(sc->device->lun, (struct scsi_lun *)hdr->lun);
146 hdr->exp_statsn = cpu_to_be32(conn->exp_statsn);163 hdr->itt = build_itt(ctask->itt, conn->id, session->age);
147 memcpy(hdr->cdb, sc->cmnd, sc->cmd_len);164 hdr->data_length = cpu_to_be32(scsi_bufflen(sc));
165 hdr->cmdsn = cpu_to_be32(session->cmdsn);
166 session->cmdsn++;
167 hdr->exp_statsn = cpu_to_be32(conn->exp_statsn);
168 memcpy(hdr->cdb, sc->cmnd, sc->cmd_len);
148 if (sc->cmd_len < MAX_COMMAND_SIZE)169 if (sc->cmd_len < MAX_COMMAND_SIZE)
149 memset(&hdr->cdb[sc->cmd_len], 0,170 memset(&hdr->cdb[sc->cmd_len], 0,
150 MAX_COMMAND_SIZE - sc->cmd_len);171 MAX_COMMAND_SIZE - sc->cmd_len);
151 172
152 ctask->data_count = 0;
153 ctask->imm_count = 0;173 ctask->imm_count = 0;
154 if (sc->sc_data_direction == DMA_TO_DEVICE) {174 if (sc->sc_data_direction == DMA_TO_DEVICE) {
155 hdr->flags |= ISCSI_FLAG_CMD_WRITE;175 hdr->flags |= ISCSI_FLAG_CMD_WRITE;
@@ -178,9 +198,9 @@ static void iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask) · 22 unmodified lines
178 else198 else
179 ctask->imm_count = min(scsi_bufflen(sc),199 ctask->imm_count = min(scsi_bufflen(sc),
180 conn->max_xmit_dlength);200 conn->max_xmit_dlength);
181 hton24(ctask->hdr->dlength, ctask->imm_count);201 hton24(hdr->dlength, ctask->imm_count);
182 } else202 } else
183 zero_data(ctask->hdr->dlength);203 zero_data(hdr->dlength);
184 204
185 if (!session->initial_r2t_en) {205 if (!session->initial_r2t_en) {
186 ctask->unsol_count = min((session->first_burst),206 ctask->unsol_count = min((session->first_burst),
@@ -190,7 +210,7 @@ static void iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask) · 3 unmodified lines
190 210
191 if (!ctask->unsol_count)211 if (!ctask->unsol_count)
192 /* No unsolicit Data-Out's */212 /* No unsolicit Data-Out's */
193 ctask->hdr->flags |= ISCSI_FLAG_CMD_FINAL;213 hdr->flags |= ISCSI_FLAG_CMD_FINAL;
194 } else {214 } else {
195 hdr->flags |= ISCSI_FLAG_CMD_FINAL;215 hdr->flags |= ISCSI_FLAG_CMD_FINAL;
196 zero_data(hdr->dlength);216 zero_data(hdr->dlength);
@@ -199,13 +219,25 @@ static void iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask) · 2 unmodified lines
199 hdr->flags |= ISCSI_FLAG_CMD_READ;219 hdr->flags |= ISCSI_FLAG_CMD_READ;
200 }220 }
201 221
202 conn->scsicmd_pdus_cnt++;222 /* calculate size of additional header segments (AHSs) */
223 hdrlength = ctask->hdr_len - sizeof(*hdr);
224
225 WARN_ON(hdrlength & (ISCSI_PAD_LEN-1));
226 hdrlength /= ISCSI_PAD_LEN;
227
228 WARN_ON(hdrlength >= 256);
229 hdr->hlength = hdrlength & 0xFF;
230
231 if (conn->session->tt->init_cmd_task(conn->ctask))
232 return EIO;
203 233
204 debug_scsi("iscsi prep [%s cid %d sc %p cdb 0x%x itt 0x%x len %d "234 conn->scsicmd_pdus_cnt++;
235 debug_scsi("iscsi prep [%s cid %d sc %p cdb 0x%x itt 0x%x len %d "
205 "cmdsn %d win %d]\n",236 "cmdsn %d win %d]\n",
206 sc->sc_data_direction == DMA_TO_DEVICE ? "write" : "read",237 sc->sc_data_direction == DMA_TO_DEVICE ? "write" : "read",
207 conn->id, sc, sc->cmnd[0], ctask->itt, scsi_bufflen(sc),238 conn->id, sc, sc->cmnd[0], ctask->itt, scsi_bufflen(sc),
208 session->cmdsn, session->max_cmdsn - session->exp_cmdsn + 1);239 session->cmdsn, session->max_cmdsn - session->exp_cmdsn + 1);
240 return 0;
209}241}
210 242
211/**243/**
@@ -218,13 +250,16 @@ static void iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask) · 6 unmodified lines
218 */250 */
219static void iscsi_complete_command(struct iscsi_cmd_task *ctask)251static void iscsi_complete_command(struct iscsi_cmd_task *ctask)
220{252{
221 struct iscsi_session *session = ctask->conn->session;253 struct iscsi_conn *conn = ctask->conn;
254 struct iscsi_session *session = conn->session;
222 struct scsi_cmnd *sc = ctask->sc;255 struct scsi_cmnd *sc = ctask->sc;
223 256
224 ctask->state = ISCSI_TASK_COMPLETED;257 ctask->state = ISCSI_TASK_COMPLETED;
225 ctask->sc = NULL;258 ctask->sc = NULL;
226 /* SCSI eh reuses commands to verify us */259 /* SCSI eh reuses commands to verify us */
227 sc->SCp.ptr = NULL;260 sc->SCp.ptr = NULL;
261 if (conn->ctask == ctask)
262 conn->ctask = NULL;
228 list_del_init(&ctask->running);263 list_del_init(&ctask->running);
229 __kfifo_put(session->cmdpool.queue, (void*)&ctask, sizeof(void*));264 __kfifo_put(session->cmdpool.queue, (void*)&ctask, sizeof(void*));
230 sc->scsi_done(sc);265 sc->scsi_done(sc);
@@ -241,6 +276,112 @@ static void __iscsi_put_ctask(struct iscsi_cmd_task *ctask) · 10 unmodified lines
241 iscsi_complete_command(ctask);276 iscsi_complete_command(ctask);
242}277}
243 278
279/*
280 * session lock must be held
281 */
282static void fail_command(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask,
283 int err)
284{
285 struct scsi_cmnd *sc;
286
287 sc = ctask->sc;
288 if (!sc)
289 return;
290
291 if (ctask->state == ISCSI_TASK_PENDING)
292 /*
293 * cmd never made it to the xmit thread, so we should not count
294 * the cmd in the sequencing
295 */
296 conn->session->queued_cmdsn--;
297 else
298 conn->session->tt->cleanup_cmd_task(conn, ctask);
299
300 sc->result = err;
301 scsi_set_resid(sc, scsi_bufflen(sc));
302 if (conn->ctask == ctask)
303 conn->ctask = NULL;
304 /* release ref from queuecommand */
305 __iscsi_put_ctask(ctask);
306}
307
308/**
309 * iscsi_free_mgmt_task - return mgmt task back to pool
310 * @conn: iscsi connection
311 * @mtask: mtask
312 *
313 * Must be called with session lock.
314 */
315void iscsi_free_mgmt_task(struct iscsi_conn *conn,
316 struct iscsi_mgmt_task *mtask)
317{
318 list_del_init(&mtask->running);
319 if (conn->login_mtask == mtask)
320 return;
321
322 if (conn->ping_mtask == mtask)
323 conn->ping_mtask = NULL;
324 __kfifo_put(conn->session->mgmtpool.queue,
325 (void*)&mtask, sizeof(void*));
326}
327EXPORT_SYMBOL_GPL(iscsi_free_mgmt_task);
328
329static struct iscsi_mgmt_task *
330__iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
331 char *data, uint32_t data_size)
332{
333 struct iscsi_session *session = conn->session;
334 struct iscsi_mgmt_task *mtask;
335
336 if (session->state == ISCSI_STATE_TERMINATE)
337 return NULL;
338
339 if (hdr->opcode == (ISCSI_OP_LOGIN | ISCSI_OP_IMMEDIATE) ||
340 hdr->opcode == (ISCSI_OP_TEXT | ISCSI_OP_IMMEDIATE))
341 /*
342 * Login and Text are sent serially, in
343 * request-followed-by-response sequence.
344 * Same mtask can be used. Same ITT must be used.
345 * Note that login_mtask is preallocated at conn_create().
346 */
347 mtask = conn->login_mtask;
348 else {
349 BUG_ON(conn->c_stage == ISCSI_CONN_INITIAL_STAGE);
350 BUG_ON(conn->c_stage == ISCSI_CONN_STOPPED);
351
352 if (!__kfifo_get(session->mgmtpool.queue,
353 (void*)&mtask, sizeof(void*)))
354 return NULL;
355 }
356
357 if (data_size) {
358 memcpy(mtask->data, data, data_size);
359 mtask->data_count = data_size;
360 } else
361 mtask->data_count = 0;
362
363 memcpy(mtask->hdr, hdr, sizeof(struct iscsi_hdr));
364 INIT_LIST_HEAD(&mtask->running);
365 list_add_tail(&mtask->running, &conn->mgmtqueue);
366 return mtask;
367}
368
369int iscsi_conn_send_pdu(struct iscsi_cls_conn *cls_conn, struct iscsi_hdr *hdr,
370 char *data, uint32_t data_size)
371{
372 struct iscsi_conn *conn = cls_conn->dd_data;
373 struct iscsi_session *session = conn->session;
374 int err = 0;
375
376 spin_lock_bh(&session->lock);
377 if (!__iscsi_conn_send_pdu(conn, hdr, data, data_size))
378 err = -EPERM;
379 spin_unlock_bh(&session->lock);
380 scsi_queue_work(session->host, &conn->xmitwork);
381 return err;
382}
383EXPORT_SYMBOL_GPL(iscsi_conn_send_pdu);
384
244/**385/**
245 * iscsi_cmd_rsp - SCSI Command Response processing386 * iscsi_cmd_rsp - SCSI Command Response processing
246 * @conn: iscsi connection387 * @conn: iscsi connection
@@ -291,17 +432,19 @@ invalid_datalen: · 44 unmodified lines
291 min_t(uint16_t, senselen, SCSI_SENSE_BUFFERSIZE));432 min_t(uint16_t, senselen, SCSI_SENSE_BUFFERSIZE));
292 }433 }
293 434
294 if (rhdr->flags & ISCSI_FLAG_CMD_UNDERFLOW) {435 if (rhdr->flags & (ISCSI_FLAG_CMD_UNDERFLOW |
436 ISCSI_FLAG_CMD_OVERFLOW)) {
295 int res_count = be32_to_cpu(rhdr->residual_count);437 int res_count = be32_to_cpu(rhdr->residual_count);
296 438
297 if (res_count > 0 && res_count <= scsi_bufflen(sc))439 if (res_count > 0 &&
440 (rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW ||
441 res_count <= scsi_bufflen(sc)))
298 scsi_set_resid(sc, res_count);442 scsi_set_resid(sc, res_count);
299 else443 else
300 sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status;444 sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
301 } else if (rhdr->flags & ISCSI_FLAG_CMD_BIDI_UNDERFLOW)445 } else if (rhdr->flags & (ISCSI_FLAG_CMD_BIDI_UNDERFLOW |
446 ISCSI_FLAG_CMD_BIDI_OVERFLOW))
302 sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status;447 sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status;
303 else if (rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW)
304 scsi_set_resid(sc, be32_to_cpu(rhdr->residual_count));
305 448
306out:449out:
307 debug_scsi("done [sc %lx res %d itt 0x%x]\n",450 debug_scsi("done [sc %lx res %d itt 0x%x]\n",
@@ -318,18 +461,51 @@ static void iscsi_tmf_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr) · 10 unmodified lines
318 conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1;461 conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1;
319 conn->tmfrsp_pdus_cnt++;462 conn->tmfrsp_pdus_cnt++;
320 463
321 if (conn->tmabort_state != TMABORT_INITIAL)464 if (conn->tmf_state != TMF_QUEUED)
322 return;465 return;
323 466
324 if (tmf->response == ISCSI_TMF_RSP_COMPLETE)467 if (tmf->response == ISCSI_TMF_RSP_COMPLETE)
325 conn->tmabort_state = TMABORT_SUCCESS;468 conn->tmf_state = TMF_SUCCESS;
326 else if (tmf->response == ISCSI_TMF_RSP_NO_TASK)469 else if (tmf->response == ISCSI_TMF_RSP_NO_TASK)
327 conn->tmabort_state = TMABORT_NOT_FOUND;470 conn->tmf_state = TMF_NOT_FOUND;
328 else471 else
329 conn->tmabort_state = TMABORT_FAILED;472 conn->tmf_state = TMF_FAILED;
330 wake_up(&conn->ehwait);473 wake_up(&conn->ehwait);
331}474}
332 475
476static void iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin *rhdr)
477{
478 struct iscsi_nopout hdr;
479 struct iscsi_mgmt_task *mtask;
480
481 if (!rhdr && conn->ping_mtask)
482 return;
483
484 memset(&hdr, 0, sizeof(struct iscsi_nopout));
485 hdr.opcode = ISCSI_OP_NOOP_OUT | ISCSI_OP_IMMEDIATE;
486 hdr.flags = ISCSI_FLAG_CMD_FINAL;
487
488 if (rhdr) {
489 memcpy(hdr.lun, rhdr->lun, 8);
490 hdr.ttt = rhdr->ttt;
491 hdr.itt = RESERVED_ITT;
492 } else
493 hdr.ttt = RESERVED_ITT;
494
495 mtask = __iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)&hdr, NULL, 0);
496 if (!mtask) {
497 printk(KERN_ERR "Could not send nopout\n");
498 return;
499 }
500
501 /* only track our nops */
502 if (!rhdr) {
503 conn->ping_mtask = mtask;
504 conn->last_ping = jiffies;
505 }
506 scsi_queue_work(conn->session->host, &conn->xmitwork);
507}
508
333static int iscsi_handle_reject(struct iscsi_conn *conn, struct iscsi_hdr *hdr,509static int iscsi_handle_reject(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
334 char *data, int datalen)510 char *data, int datalen)
335{511{
@@ -374,6 +550,7 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, · 38 unmodified lines
374 struct iscsi_mgmt_task *mtask;550 struct iscsi_mgmt_task *mtask;
375 uint32_t itt;551 uint32_t itt;
376 552
553 conn->last_recv = jiffies;
377 if (hdr->itt != RESERVED_ITT)554 if (hdr->itt != RESERVED_ITT)
378 itt = get_itt(hdr->itt);555 itt = get_itt(hdr->itt);
379 else556 else
@@ -429,10 +606,7 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, · 49 unmodified lines
429 */606 */
430 if (iscsi_recv_pdu(conn->cls_conn, hdr, data, datalen))607 if (iscsi_recv_pdu(conn->cls_conn, hdr, data, datalen))
431 rc = ISCSI_ERR_CONN_FAILED;608 rc = ISCSI_ERR_CONN_FAILED;
432 list_del(&mtask->running);609 iscsi_free_mgmt_task(conn, mtask);
433 if (conn->login_mtask != mtask)
434 __kfifo_put(session->mgmtpool.queue,
435 (void*)&mtask, sizeof(void*));
436 break;610 break;
437 case ISCSI_OP_SCSI_TMFUNC_RSP:611 case ISCSI_OP_SCSI_TMFUNC_RSP:
438 if (datalen) {612 if (datalen) {
@@ -441,20 +615,26 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, · 2 unmodified lines
441 }615 }
442 616
443 iscsi_tmf_rsp(conn, hdr);617 iscsi_tmf_rsp(conn, hdr);
618 iscsi_free_mgmt_task(conn, mtask);
444 break;619 break;
445 case ISCSI_OP_NOOP_IN:620 case ISCSI_OP_NOOP_IN:
446 if (hdr->ttt != cpu_to_be32(ISCSI_RESERVED_TAG) || datalen) {621 if (hdr->ttt != cpu_to_be32(ISCSI_RESERVED_TAG) ||
622 datalen) {
447 rc = ISCSI_ERR_PROTO;623 rc = ISCSI_ERR_PROTO;
448 break;624 break;
449 }625 }
450 conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1;626 conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1;
451 627
452 if (iscsi_recv_pdu(conn->cls_conn, hdr, data, datalen))628 if (conn->ping_mtask != mtask) {
453 rc = ISCSI_ERR_CONN_FAILED;629 /*
454 list_del(&mtask->running);630 * If this is not in response to one of our
455 if (conn->login_mtask != mtask)631 * nops then it must be from userspace.
456 __kfifo_put(session->mgmtpool.queue,632 */
457 (void*)&mtask, sizeof(void*));633 if (iscsi_recv_pdu(conn->cls_conn, hdr, data,
634 datalen))
635 rc = ISCSI_ERR_CONN_FAILED;
636 }
637 iscsi_free_mgmt_task(conn, mtask);
458 break;638 break;
459 default:639 default:
460 rc = ISCSI_ERR_BAD_OPCODE;640 rc = ISCSI_ERR_BAD_OPCODE;
@@ -473,8 +653,7 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, · 12 unmodified lines
473 if (hdr->ttt == cpu_to_be32(ISCSI_RESERVED_TAG))653 if (hdr->ttt == cpu_to_be32(ISCSI_RESERVED_TAG))
474 break;654 break;
475 655
476 if (iscsi_recv_pdu(conn->cls_conn, hdr, NULL, 0))656 iscsi_send_nopout(conn, (struct iscsi_nopin*)hdr);
477 rc = ISCSI_ERR_CONN_FAILED;
478 break;657 break;
479 case ISCSI_OP_REJECT:658 case ISCSI_OP_REJECT:
480 rc = iscsi_handle_reject(conn, hdr, data, datalen);659 rc = iscsi_handle_reject(conn, hdr, data, datalen);
@@ -609,20 +788,19 @@ static void iscsi_prep_mtask(struct iscsi_conn *conn, · 128 unmodified lines
609 session->tt->init_mgmt_task(conn, mtask);788 session->tt->init_mgmt_task(conn, mtask);
610 789
611 debug_scsi("mgmtpdu [op 0x%x hdr->itt 0x%x datalen %d]\n",790 debug_scsi("mgmtpdu [op 0x%x hdr->itt 0x%x datalen %d]\n",
612 hdr->opcode, hdr->itt, mtask->data_count);791 hdr->opcode & ISCSI_OPCODE_MASK, hdr->itt,
792 mtask->data_count);
613}793}
614 794
615static int iscsi_xmit_mtask(struct iscsi_conn *conn)795static int iscsi_xmit_mtask(struct iscsi_conn *conn)
616{796{
617 struct iscsi_hdr *hdr = conn->mtask->hdr;797 struct iscsi_hdr *hdr = conn->mtask->hdr;
618 int rc, was_logout = 0;798 int rc;
619 799
800 if ((hdr->opcode & ISCSI_OPCODE_MASK) == ISCSI_OP_LOGOUT)
801 conn->session->state = ISCSI_STATE_LOGGING_OUT;
620 spin_unlock_bh(&conn->session->lock);802 spin_unlock_bh(&conn->session->lock);
621 if ((hdr->opcode & ISCSI_OPCODE_MASK) == ISCSI_OP_LOGOUT) {803
622 conn->session->state = ISCSI_STATE_IN_RECOVERY;
623 iscsi_block_session(session_to_cls(conn->session));
624 was_logout = 1;
625 }
626 rc = conn->session->tt->xmit_mgmt_task(conn, conn->mtask);804 rc = conn->session->tt->xmit_mgmt_task(conn, conn->mtask);
627 spin_lock_bh(&conn->session->lock);805 spin_lock_bh(&conn->session->lock);
628 if (rc)806 if (rc)
@@ -630,11 +808,6 @@ static int iscsi_xmit_mtask(struct iscsi_conn *conn) · 1 unmodified line
630 808
631 /* done with this in-progress mtask */809 /* done with this in-progress mtask */
632 conn->mtask = NULL;810 conn->mtask = NULL;
633
634 if (was_logout) {
635 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
636 return -ENODATA;
637 }
638 return 0;811 return 0;
639}812}
640 813
@@ -658,27 +831,35 @@ static int iscsi_check_cmdsn_window_closed(struct iscsi_conn *conn) · 17 unmodified lines
658static int iscsi_xmit_ctask(struct iscsi_conn *conn)831static int iscsi_xmit_ctask(struct iscsi_conn *conn)
659{832{
660 struct iscsi_cmd_task *ctask = conn->ctask;833 struct iscsi_cmd_task *ctask = conn->ctask;
661 int rc = 0;834 int rc;
662
663 /*
664 * serialize with TMF AbortTask
665 */
666 if (ctask->state == ISCSI_TASK_ABORTING)
667 goto done;
668 835
669 __iscsi_get_ctask(ctask);836 __iscsi_get_ctask(ctask);
670 spin_unlock_bh(&conn->session->lock);837 spin_unlock_bh(&conn->session->lock);
671 rc = conn->session->tt->xmit_cmd_task(conn, ctask);838 rc = conn->session->tt->xmit_cmd_task(conn, ctask);
672 spin_lock_bh(&conn->session->lock);839 spin_lock_bh(&conn->session->lock);
673 __iscsi_put_ctask(ctask);840 __iscsi_put_ctask(ctask);
674
675done:
676 if (!rc)841 if (!rc)
677 /* done with this ctask */842 /* done with this ctask */
678 conn->ctask = NULL;843 conn->ctask = NULL;
679 return rc;844 return rc;
680}845}
681 846
847/**
848 * iscsi_requeue_ctask - requeue ctask to run from session workqueue
849 * @ctask: ctask to requeue
850 *
851 * LLDs that need to run a ctask from the session workqueue should call
852 * this. The session lock must be held.
853 */
854void iscsi_requeue_ctask(struct iscsi_cmd_task *ctask)
855{
856 struct iscsi_conn *conn = ctask->conn;
857
858 list_move_tail(&ctask->running, &conn->requeue);
859 scsi_queue_work(conn->session->host, &conn->xmitwork);
860}
861EXPORT_SYMBOL_GPL(iscsi_requeue_ctask);
862
682/**863/**
683 * iscsi_data_xmit - xmit any command into the scheduled connection864 * iscsi_data_xmit - xmit any command into the scheduled connection
684 * @conn: iscsi connection865 * @conn: iscsi connection
@@ -717,36 +898,40 @@ static int iscsi_data_xmit(struct iscsi_conn *conn) · 32 unmodified lines
717 * overflow us with nop-ins898 * overflow us with nop-ins
718 */899 */
719check_mgmt:900check_mgmt:
720 while (__kfifo_get(conn->mgmtqueue, (void*)&conn->mtask,901 while (!list_empty(&conn->mgmtqueue)) {
721 sizeof(void*))) {902 conn->mtask = list_entry(conn->mgmtqueue.next,
903 struct iscsi_mgmt_task, running);
904 if (conn->session->state == ISCSI_STATE_LOGGING_OUT) {
905 iscsi_free_mgmt_task(conn, conn->mtask);
906 conn->mtask = NULL;
907 continue;
908 }
909
722 iscsi_prep_mtask(conn, conn->mtask);910 iscsi_prep_mtask(conn, conn->mtask);
723 list_add_tail(&conn->mtask->running, &conn->mgmt_run_list);911 list_move_tail(conn->mgmtqueue.next, &conn->mgmt_run_list);
724 rc = iscsi_xmit_mtask(conn);912 rc = iscsi_xmit_mtask(conn);
725 if (rc)913 if (rc)
726 goto again;914 goto again;
727 }915 }
728 916
729 /* process command queue */917 /* process pending command queue */
730 while (!list_empty(&conn->xmitqueue)) {918 while (!list_empty(&conn->xmitqueue)) {
731 /*919 if (conn->tmf_state == TMF_QUEUED)
732 * iscsi tcp may readd the task to the xmitqueue to send920 break;
733 * write data921
734 */
735 conn->ctask = list_entry(conn->xmitqueue.next,922 conn->ctask = list_entry(conn->xmitqueue.next,
736 struct iscsi_cmd_task, running);923 struct iscsi_cmd_task, running);
737 switch (conn->ctask->state) {924 if (conn->session->state == ISCSI_STATE_LOGGING_OUT) {
738 case ISCSI_TASK_ABORTING:925 fail_command(conn, conn->ctask, DID_IMM_RETRY << 16);
739 break;926 continue;
740 case ISCSI_TASK_PENDING:927 }
741 iscsi_prep_scsi_cmd_pdu(conn->ctask);928 if (iscsi_prep_scsi_cmd_pdu(conn->ctask)) {
742 conn->session->tt->init_cmd_task(conn->ctask);929 fail_command(conn, conn->ctask, DID_ABORT << 16);
743 /* fall through */930 continue;
744 default:
745 conn->ctask->state = ISCSI_TASK_RUNNING;
746 break;
747 }931 }
748 list_move_tail(conn->xmitqueue.next, &conn->run_list);
749 932
933 conn->ctask->state = ISCSI_TASK_RUNNING;
934 list_move_tail(conn->xmitqueue.next, &conn->run_list);
750 rc = iscsi_xmit_ctask(conn);935 rc = iscsi_xmit_ctask(conn);
751 if (rc)936 if (rc)
752 goto again;937 goto again;
@@ -755,7 +940,28 @@ check_mgmt: · 2 unmodified lines
755 * we need to check the mgmt queue for nops that need to940 * we need to check the mgmt queue for nops that need to
756 * be sent to aviod starvation941 * be sent to aviod starvation
757 */942 */
758 if (__kfifo_len(conn->mgmtqueue))943 if (!list_empty(&conn->mgmtqueue))
944 goto check_mgmt;
945 }
946
947 while (!list_empty(&conn->requeue)) {
948 if (conn->session->fast_abort && conn->tmf_state != TMF_INITIAL)
949 break;
950
951 /*
952 * we always do fastlogout - conn stop code will clean up.
953 */
954 if (conn->session->state == ISCSI_STATE_LOGGING_OUT)
955 break;
956
957 conn->ctask = list_entry(conn->requeue.next,
958 struct iscsi_cmd_task, running);
959 conn->ctask->state = ISCSI_TASK_RUNNING;
960 list_move_tail(conn->requeue.next, &conn->run_list);
961 rc = iscsi_xmit_ctask(conn);
962 if (rc)
963 goto again;
964 if (!list_empty(&conn->mgmtqueue))
759 goto check_mgmt;965 goto check_mgmt;
760 }966 }
761 spin_unlock_bh(&conn->session->lock);967 spin_unlock_bh(&conn->session->lock);
@@ -790,6 +996,7 @@ enum { · 28 unmodified lines
790 FAILURE_SESSION_TERMINATE,996 FAILURE_SESSION_TERMINATE,
791 FAILURE_SESSION_IN_RECOVERY,997 FAILURE_SESSION_IN_RECOVERY,
792 FAILURE_SESSION_RECOVERY_TIMEOUT,998 FAILURE_SESSION_RECOVERY_TIMEOUT,
999 FAILURE_SESSION_LOGGING_OUT,
793};1000};
794 1001
795int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))1002int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
@@ -805,8 +1012,9 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) · 9 unmodified lines
805 sc->SCp.ptr = NULL;1012 sc->SCp.ptr = NULL;
806 1013
807 host = sc->device->host;1014 host = sc->device->host;
808 session = iscsi_hostdata(host->hostdata);1015 spin_unlock(host->host_lock);
809 1016
1017 session = iscsi_hostdata(host->hostdata);
810 spin_lock(&session->lock);1018 spin_lock(&session->lock);
811 1019
812 /*1020 /*
@@ -822,17 +1030,22 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) · 9 unmodified lines
822 * be entering our queuecommand while a block is starting1030 * be entering our queuecommand while a block is starting
823 * up because the block code is not locked)1031 * up because the block code is not locked)
824 */1032 */
825 if (session->state == ISCSI_STATE_IN_RECOVERY) {1033 switch (session->state) {
1034 case ISCSI_STATE_IN_RECOVERY:
826 reason = FAILURE_SESSION_IN_RECOVERY;1035 reason = FAILURE_SESSION_IN_RECOVERY;
827 goto reject;1036 goto reject;
828 }1037 case ISCSI_STATE_LOGGING_OUT:
829 1038 reason = FAILURE_SESSION_LOGGING_OUT;
830 if (session->state == ISCSI_STATE_RECOVERY_FAILED)1039 goto reject;
1040 case ISCSI_STATE_RECOVERY_FAILED:
831 reason = FAILURE_SESSION_RECOVERY_TIMEOUT;1041 reason = FAILURE_SESSION_RECOVERY_TIMEOUT;
832 else if (session->state == ISCSI_STATE_TERMINATE)1042 break;
1043 case ISCSI_STATE_TERMINATE:
833 reason = FAILURE_SESSION_TERMINATE;1044 reason = FAILURE_SESSION_TERMINATE;
834 else1045 break;
1046 default:
835 reason = FAILURE_SESSION_FREED;1047 reason = FAILURE_SESSION_FREED;
1048 }
836 goto fault;1049 goto fault;
837 }1050 }
838 1051
@@ -859,7 +1072,6 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) · 20 unmodified lines
859 1072
860 atomic_set(&ctask->refcount, 1);1073 atomic_set(&ctask->refcount, 1);
861 ctask->state = ISCSI_TASK_PENDING;1074 ctask->state = ISCSI_TASK_PENDING;
862 ctask->mtask = NULL;
863 ctask->conn = conn;1075 ctask->conn = conn;
864 ctask->sc = sc;1076 ctask->sc = sc;
865 INIT_LIST_HEAD(&ctask->running);1077 INIT_LIST_HEAD(&ctask->running);
@@ -868,11 +1080,13 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) · 2 unmodified lines
868 spin_unlock(&session->lock);1080 spin_unlock(&session->lock);
869 1081
870 scsi_queue_work(host, &conn->xmitwork);1082 scsi_queue_work(host, &conn->xmitwork);
1083 spin_lock(host->host_lock);
871 return 0;1084 return 0;
872 1085
873reject:1086reject:
874 spin_unlock(&session->lock);1087 spin_unlock(&session->lock);
875 debug_scsi("cmd 0x%x rejected (%d)\n", sc->cmnd[0], reason);1088 debug_scsi("cmd 0x%x rejected (%d)\n", sc->cmnd[0], reason);
1089 spin_lock(host->host_lock);
876 return SCSI_MLQUEUE_HOST_BUSY;1090 return SCSI_MLQUEUE_HOST_BUSY;
877 1091
878fault:1092fault:
@@ -882,6 +1096,7 @@ fault: · 3 unmodified lines
882 sc->result = (DID_NO_CONNECT << 16);1096 sc->result = (DID_NO_CONNECT << 16);
883 scsi_set_resid(sc, scsi_bufflen(sc));1097 scsi_set_resid(sc, scsi_bufflen(sc));
884 sc->scsi_done(sc);1098 sc->scsi_done(sc);
1099 spin_lock(host->host_lock);
885 return 0;1100 return 0;
886}1101}
887EXPORT_SYMBOL_GPL(iscsi_queuecommand);1102EXPORT_SYMBOL_GPL(iscsi_queuecommand);
@@ -895,72 +1110,15 @@ int iscsi_change_queue_depth(struct scsi_device *sdev, int depth) · 7 unmodified lines
895}1110}
896EXPORT_SYMBOL_GPL(iscsi_change_queue_depth);1111EXPORT_SYMBOL_GPL(iscsi_change_queue_depth);
897 1112
898static struct iscsi_mgmt_task *
899__iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
900 char *data, uint32_t data_size)
901{
902 struct iscsi_session *session = conn->session;
903 struct iscsi_mgmt_task *mtask;
904
905 if (session->state == ISCSI_STATE_TERMINATE)
906 return NULL;
907
908 if (hdr->opcode == (ISCSI_OP_LOGIN | ISCSI_OP_IMMEDIATE) ||
909 hdr->opcode == (ISCSI_OP_TEXT | ISCSI_OP_IMMEDIATE))
910 /*
911 * Login and Text are sent serially, in
912 * request-followed-by-response sequence.
913 * Same mtask can be used. Same ITT must be used.
914 * Note that login_mtask is preallocated at conn_create().
915 */
916 mtask = conn->login_mtask;
917 else {
918 BUG_ON(conn->c_stage == ISCSI_CONN_INITIAL_STAGE);
919 BUG_ON(conn->c_stage == ISCSI_CONN_STOPPED);
920
921 if (!__kfifo_get(session->mgmtpool.queue,
922 (void*)&mtask, sizeof(void*)))
923 return NULL;
924 }
925
926 if (data_size) {
927 memcpy(mtask->data, data, data_size);
928 mtask->data_count = data_size;
929 } else
930 mtask->data_count = 0;
931
932 INIT_LIST_HEAD(&mtask->running);
933 memcpy(mtask->hdr, hdr, sizeof(struct iscsi_hdr));
934 __kfifo_put(conn->mgmtqueue, (void*)&mtask, sizeof(void*));
935 return mtask;
936}
937
938int iscsi_conn_send_pdu(struct iscsi_cls_conn *cls_conn, struct iscsi_hdr *hdr,
939 char *data, uint32_t data_size)
940{
941 struct iscsi_conn *conn = cls_conn->dd_data;
942 struct iscsi_session *session = conn->session;
943 int err = 0;
944
945 spin_lock_bh(&session->lock);
946 if (!__iscsi_conn_send_pdu(conn, hdr, data, data_size))
947 err = -EPERM;
948 spin_unlock_bh(&session->lock);
949 scsi_queue_work(session->host, &conn->xmitwork);
950 return err;
951}
952EXPORT_SYMBOL_GPL(iscsi_conn_send_pdu);
953
954void iscsi_session_recovery_timedout(struct iscsi_cls_session *cls_session)1113void iscsi_session_recovery_timedout(struct iscsi_cls_session *cls_session)
955{1114{
956 struct iscsi_session *session = class_to_transport_session(cls_session);1115 struct iscsi_session *session = class_to_transport_session(cls_session);
957 struct iscsi_conn *conn = session->leadconn;
958 1116
959 spin_lock_bh(&session->lock);1117 spin_lock_bh(&session->lock);
960 if (session->state != ISCSI_STATE_LOGGED_IN) {1118 if (session->state != ISCSI_STATE_LOGGED_IN) {
961 session->state = ISCSI_STATE_RECOVERY_FAILED;1119 session->state = ISCSI_STATE_RECOVERY_FAILED;
962 if (conn)1120 if (session->leadconn)
963 wake_up(&conn->ehwait);1121 wake_up(&session->leadconn->ehwait);
964 }1122 }
965 spin_unlock_bh(&session->lock);1123 spin_unlock_bh(&session->lock);
966}1124}
@@ -971,30 +1129,25 @@ int iscsi_eh_host_reset(struct scsi_cmnd *sc) · 4 unmodified lines
971 struct Scsi_Host *host = sc->device->host;1129 struct Scsi_Host *host = sc->device->host;
972 struct iscsi_session *session = iscsi_hostdata(host->hostdata);1130 struct iscsi_session *session = iscsi_hostdata(host->hostdata);
973 struct iscsi_conn *conn = session->leadconn;1131 struct iscsi_conn *conn = session->leadconn;
974 int fail_session = 0;
975 1132
1133 mutex_lock(&session->eh_mutex);
976 spin_lock_bh(&session->lock);1134 spin_lock_bh(&session->lock);
977 if (session->state == ISCSI_STATE_TERMINATE) {1135 if (session->state == ISCSI_STATE_TERMINATE) {
978failed:1136failed:
979 debug_scsi("failing host reset: session terminated "1137 debug_scsi("failing host reset: session terminated "
980 "[CID %d age %d]\n", conn->id, session->age);1138 "[CID %d age %d]\n", conn->id, session->age);
981 spin_unlock_bh(&session->lock);1139 spin_unlock_bh(&session->lock);
1140 mutex_unlock(&session->eh_mutex);
982 return FAILED;1141 return FAILED;
983 }1142 }
984 1143
985 if (sc->SCp.phase == session->age) {
986 debug_scsi("failing connection CID %d due to SCSI host reset\n",
987 conn->id);
988 fail_session = 1;
989 }
990 spin_unlock_bh(&session->lock);1144 spin_unlock_bh(&session->lock);
991 1145 mutex_unlock(&session->eh_mutex);
992 /*1146 /*
993 * we drop the lock here but the leadconn cannot be destoyed while1147 * we drop the lock here but the leadconn cannot be destoyed while
994 * we are in the scsi eh1148 * we are in the scsi eh
995 */1149 */
996 if (fail_session)1150 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
997 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
998 1151
999 debug_scsi("iscsi_eh_host_reset wait for relogin\n");1152 debug_scsi("iscsi_eh_host_reset wait for relogin\n");
1000 wait_event_interruptible(conn->ehwait,1153 wait_event_interruptible(conn->ehwait,
@@ -1004,73 +1157,56 @@ failed: · 3 unmodified lines
1004 if (signal_pending(current))1157 if (signal_pending(current))
1005 flush_signals(current);1158 flush_signals(current);
1006 1159
1160 mutex_lock(&session->eh_mutex);
1007 spin_lock_bh(&session->lock);1161 spin_lock_bh(&session->lock);
1008 if (session->state == ISCSI_STATE_LOGGED_IN)1162 if (session->state == ISCSI_STATE_LOGGED_IN)
1009 printk(KERN_INFO "iscsi: host reset succeeded\n");1163 printk(KERN_INFO "iscsi: host reset succeeded\n");
1010 else1164 else
1011 goto failed;1165 goto failed;
1012 spin_unlock_bh(&session->lock);1166 spin_unlock_bh(&session->lock);
1013 1167 mutex_unlock(&session->eh_mutex);
1014 return SUCCESS;1168 return SUCCESS;
1015}1169}
1016EXPORT_SYMBOL_GPL(iscsi_eh_host_reset);1170EXPORT_SYMBOL_GPL(iscsi_eh_host_reset);
1017 1171
1018static void iscsi_tmabort_timedout(unsigned long data)1172static void iscsi_tmf_timedout(unsigned long data)
1019{1173{
1020 struct iscsi_cmd_task *ctask = (struct iscsi_cmd_task *)data;1174 struct iscsi_conn *conn = (struct iscsi_conn *)data;
1021 struct iscsi_conn *conn = ctask->conn;
1022 struct iscsi_session *session = conn->session;1175 struct iscsi_session *session = conn->session;
1023 1176
1024 spin_lock(&session->lock);1177 spin_lock(&session->lock);
1025 if (conn->tmabort_state == TMABORT_INITIAL) {1178 if (conn->tmf_state == TMF_QUEUED) {
1026 conn->tmabort_state = TMABORT_TIMEDOUT;1179 conn->tmf_state = TMF_TIMEDOUT;
1027 debug_scsi("tmabort timedout [sc %p itt 0x%x]\n",1180 debug_scsi("tmf timedout\n");
1028 ctask->sc, ctask->itt);
1029 /* unblock eh_abort() */1181 /* unblock eh_abort() */
1030 wake_up(&conn->ehwait);1182 wake_up(&conn->ehwait);
1031 }1183 }
1032 spin_unlock(&session->lock);1184 spin_unlock(&session->lock);
1033}1185}
1034 1186
1035static int iscsi_exec_abort_task(struct scsi_cmnd *sc,1187static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn,
1036 struct iscsi_cmd_task *ctask)1188 struct iscsi_tm *hdr, int age,
1189 int timeout)
1037{1190{
1038 struct iscsi_conn *conn = ctask->conn;
1039 struct iscsi_session *session = conn->session;1191 struct iscsi_session *session = conn->session;
1040 struct iscsi_tm *hdr = &conn->tmhdr;1192 struct iscsi_mgmt_task *mtask;
1041
1042 /*
1043 * ctask timed out but session is OK requests must be serialized.
1044 */
1045 memset(hdr, 0, sizeof(struct iscsi_tm));
1046 hdr->opcode = ISCSI_OP_SCSI_TMFUNC | ISCSI_OP_IMMEDIATE;
1047 hdr->flags = ISCSI_TM_FUNC_ABORT_TASK;
1048 hdr->flags |= ISCSI_FLAG_CMD_FINAL;
1049 memcpy(hdr->lun, ctask->hdr->lun, sizeof(hdr->lun));
1050 hdr->rtt = ctask->hdr->itt;
1051 hdr->refcmdsn = ctask->hdr->cmdsn;
1052 1193
1053 ctask->mtask = __iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)hdr,1194 mtask = __iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)hdr,
1054 NULL, 0);1195 NULL, 0);
1055 if (!ctask->mtask) {1196 if (!mtask) {
1056 spin_unlock_bh(&session->lock);1197 spin_unlock_bh(&session->lock);
1057 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);1198 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
1058 spin_lock_bh(&session->lock)1199 spin_lock_bh(&session->lock);
1059 debug_scsi("abort sent failure [itt 0x%x]\n", ctask->itt);1200 debug_scsi("tmf exec failure\n");
1060 return -EPERM;1201 return -EPERM;
1061 }1202 }
1062 ctask->state = ISCSI_TASK_ABORTING;1203 conn->tmfcmd_pdus_cnt++;
1204 conn->tmf_timer.expires = timeout * HZ + jiffies;
1205 conn->tmf_timer.function = iscsi_tmf_timedout;
1206 conn->tmf_timer.data = (unsigned long)conn;
1207 add_timer(&conn->tmf_timer);
1208 debug_scsi("tmf set timeout\n");
1063 1209
1064 debug_scsi("abort sent [itt 0x%x]\n", ctask->itt);
1065
1066 if (conn->tmabort_state == TMABORT_INITIAL) {
1067 conn->tmfcmd_pdus_cnt++;
1068 conn->tmabort_timer.expires = 20*HZ + jiffies;
1069 conn->tmabort_timer.function = iscsi_tmabort_timedout;
1070 conn->tmabort_timer.data = (unsigned long)ctask;
1071 add_timer(&conn->tmabort_timer);
1072 debug_scsi("abort set timeout [itt 0x%x]\n", ctask->itt);
1073 }
1074 spin_unlock_bh(&session->lock);1210 spin_unlock_bh(&session->lock);
1075 mutex_unlock(&session->eh_mutex);1211 mutex_unlock(&session->eh_mutex);
1076 scsi_queue_work(session->host, &conn->xmitwork);1212 scsi_queue_work(session->host, &conn->xmitwork);
@@ -1078,113 +1214,197 @@ static int iscsi_exec_abort_task(struct scsi_cmnd *sc, · 1 unmodified line
1078 /*1214 /*
1079 * block eh thread until:1215 * block eh thread until:
1080 *1216 *
1081 * 1) abort response1217 * 1) tmf response
1082 * 2) abort timeout1218 * 2) tmf timeout
1083 * 3) session is terminated or restarted or userspace has1219 * 3) session is terminated or restarted or userspace has
1084 * given up on recovery1220 * given up on recovery
1085 */1221 */
1086 wait_event_interruptible(conn->ehwait,1222 wait_event_interruptible(conn->ehwait, age != session->age ||
1087 sc->SCp.phase != session->age ||
1088 session->state != ISCSI_STATE_LOGGED_IN ||1223 session->state != ISCSI_STATE_LOGGED_IN ||
1089 conn->tmabort_state != TMABORT_INITIAL);1224 conn->tmf_state != TMF_QUEUED);
1090 if (signal_pending(current))1225 if (signal_pending(current))
1091 flush_signals(current);1226 flush_signals(current);
1092 del_timer_sync(&conn->tmabort_timer);1227 del_timer_sync(&conn->tmf_timer);
1228
1093 mutex_lock(&session->eh_mutex);1229 mutex_lock(&session->eh_mutex);
1094 spin_lock_bh(&session->lock);1230 spin_lock_bh(&session->lock);
1231 /* if the session drops it will clean up the mtask */
1232 if (age != session->age ||
1233 session->state != ISCSI_STATE_LOGGED_IN)
1234 return -ENOTCONN;
1095 return 0;1235 return 0;
1096}1236}
1097 1237
1098/*1238/*
1099 * session lock must be held1239 * Fail commands. session lock held and recv side suspended and xmit
1240 * thread flushed
1100 */1241 */
1101static struct iscsi_mgmt_task *1242static void fail_all_commands(struct iscsi_conn *conn, unsigned lun)
1102iscsi_remove_mgmt_task(struct kfifo *fifo, uint32_t itt)
1103{1243{
1104 int i, nr_tasks = __kfifo_len(fifo) / sizeof(void*);1244 struct iscsi_cmd_task *ctask, *tmp;
1105 struct iscsi_mgmt_task *task;
1106 1245
1107 debug_scsi("searching %d tasks\n", nr_tasks);1246 if (conn->ctask && (conn->ctask->sc->device->lun == lun || lun == -1))
1247 conn->ctask = NULL;
1108 1248
1109 for (i = 0; i < nr_tasks; i++) {1249 /* flush pending */
1110 __kfifo_get(fifo, (void*)&task, sizeof(void*));1250 list_for_each_entry_safe(ctask, tmp, &conn->xmitqueue, running) {
1111 debug_scsi("check task %u\n", task->itt);1251 if (lun == ctask->sc->device->lun || lun == -1) {
1252 debug_scsi("failing pending sc %p itt 0x%x\n",
1253 ctask->sc, ctask->itt);
1254 fail_command(conn, ctask, DID_BUS_BUSY << 16);
1255 }
1256 }
1112 1257
1113 if (task->itt == itt) {1258 list_for_each_entry_safe(ctask, tmp, &conn->requeue, running) {
1114 debug_scsi("matched task\n");1259 if (lun == ctask->sc->device->lun || lun == -1) {
1115 return task;1260 debug_scsi("failing requeued sc %p itt 0x%x\n",
1261 ctask->sc, ctask->itt);
1262 fail_command(conn, ctask, DID_BUS_BUSY << 16);
1116 }1263 }
1264 }
1117 1265
1118 __kfifo_put(fifo, (void*)&task, sizeof(void*));1266 /* fail all other running */
1267 list_for_each_entry_safe(ctask, tmp, &conn->run_list, running) {
1268 if (lun == ctask->sc->device->lun || lun == -1) {
1269 debug_scsi("failing in progress sc %p itt 0x%x\n",
1270 ctask->sc, ctask->itt);
1271 fail_command(conn, ctask, DID_BUS_BUSY << 16);
1272 }
1119 }1273 }
1120 return NULL;
1121}1274}
1122 1275
1123static int iscsi_ctask_mtask_cleanup(struct iscsi_cmd_task *ctask)1276static void iscsi_suspend_tx(struct iscsi_conn *conn)
1124{1277{
1125 struct iscsi_conn *conn = ctask->conn;1278 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
1126 struct iscsi_session *session = conn->session;1279 scsi_flush_work(conn->session->host);
1127 1280}
1128 if (!ctask->mtask)
1129 return -EINVAL;
1130 1281
1131 if (!iscsi_remove_mgmt_task(conn->mgmtqueue, ctask->mtask->itt))1282static void iscsi_start_tx(struct iscsi_conn *conn)
1132 list_del(&ctask->mtask->running);1283{
1133 __kfifo_put(session->mgmtpool.queue, (void*)&ctask->mtask,1284 clear_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
1134 sizeof(void*));1285 scsi_queue_work(conn->session->host, &conn->xmitwork);
1135 ctask->mtask = NULL;
1136 return 0;
1137}1286}
1138 1287
1139/*1288static enum scsi_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *scmd)
1140 * session lock must be held
1141 */
1142static void fail_command(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask,
1143 int err)
1144{1289{
1145 struct scsi_cmnd *sc;1290 struct iscsi_cls_session *cls_session;
1291 struct iscsi_session *session;
1292 struct iscsi_conn *conn;
1293 enum scsi_eh_timer_return rc = EH_NOT_HANDLED;
1146 1294
1147 sc = ctask->sc;1295 cls_session = starget_to_session(scsi_target(scmd->device));
1148 if (!sc)1296 session = class_to_transport_session(cls_session);
1149 return;
1150 1297
1151 if (ctask->state == ISCSI_TASK_PENDING)1298 debug_scsi("scsi cmd %p timedout\n", scmd);
1299
1300 spin_lock(&session->lock);
1301 if (session->state != ISCSI_STATE_LOGGED_IN) {
1152 /*1302 /*
1153 * cmd never made it to the xmit thread, so we should not count1303 * We are probably in the middle of iscsi recovery so let
1154 * the cmd in the sequencing1304 * that complete and handle the error.
1155 */1305 */
1156 conn->session->queued_cmdsn--;1306 rc = EH_RESET_TIMER;
1157 else1307 goto done;
1158 conn->session->tt->cleanup_cmd_task(conn, ctask);1308 }
1159 iscsi_ctask_mtask_cleanup(ctask);
1160 1309
1161 sc->result = err;1310 conn = session->leadconn;
1162 scsi_set_resid(sc, scsi_bufflen(sc));1311 if (!conn) {
1163 if (conn->ctask == ctask)1312 /* In the middle of shuting down */
1164 conn->ctask = NULL;1313 rc = EH_RESET_TIMER;
1165 /* release ref from queuecommand */1314 goto done;
1166 __iscsi_put_ctask(ctask);1315 }
1316
1317 if (!conn->recv_timeout && !conn->ping_timeout)
1318 goto done;
1319 /*
1320 * if the ping timedout then we are in the middle of cleaning up
1321 * and can let the iscsi eh handle it
1322 */
1323 if (time_before_eq(conn->last_recv + (conn->recv_timeout * HZ) +
1324 (conn->ping_timeout * HZ), jiffies))
1325 rc = EH_RESET_TIMER;
1326 /*
1327 * if we are about to check the transport then give the command
1328 * more time
1329 */
1330 if (time_before_eq(conn->last_recv + (conn->recv_timeout * HZ),
1331 jiffies))
1332 rc = EH_RESET_TIMER;
1333 /* if in the middle of checking the transport then give us more time */
1334 if (conn->ping_mtask)
1335 rc = EH_RESET_TIMER;
1336done:
1337 spin_unlock(&session->lock);
1338 debug_scsi("return %s\n", rc == EH_RESET_TIMER ? "timer reset" : "nh");
1339 return rc;
1167}1340}
1168 1341
1169static void iscsi_suspend_tx(struct iscsi_conn *conn)1342static void iscsi_check_transport_timeouts(unsigned long data)
1170{1343{
1171 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);1344 struct iscsi_conn *conn = (struct iscsi_conn *)data;
1172 scsi_flush_work(conn->session->host);1345 struct iscsi_session *session = conn->session;
1346 unsigned long timeout, next_timeout = 0, last_recv;
1347
1348 spin_lock(&session->lock);
1349 if (session->state != ISCSI_STATE_LOGGED_IN)
1350 goto done;
1351
1352 timeout = conn->recv_timeout;
1353 if (!timeout)
1354 goto done;
1355
1356 timeout *= HZ;
1357 last_recv = conn->last_recv;
1358 if (time_before_eq(last_recv + timeout + (conn->ping_timeout * HZ),
1359 jiffies)) {
1360 printk(KERN_ERR "ping timeout of %d secs expired, "
1361 "last rx %lu, last ping %lu, now %lu\n",
1362 conn->ping_timeout, last_recv,
1363 conn->last_ping, jiffies);
1364 spin_unlock(&session->lock);
1365 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
1366 return;
1367 }
1368
1369 if (time_before_eq(last_recv + timeout, jiffies)) {
1370 if (time_before_eq(conn->last_ping, last_recv)) {
1371 /* send a ping to try to provoke some traffic */
1372 debug_scsi("Sending nopout as ping on conn %p\n", conn);
1373 iscsi_send_nopout(conn, NULL);
1374 }
1375 next_timeout = last_recv + timeout + (conn->ping_timeout * HZ);
1376 } else {
1377 next_timeout = last_recv + timeout;
1378 }
1379
1380 if (next_timeout) {
1381 debug_scsi("Setting next tmo %lu\n", next_timeout);
1382 mod_timer(&conn->transport_timer, next_timeout);
1383 }
1384done:
1385 spin_unlock(&session->lock);
1173}1386}
1174 1387
1175static void iscsi_start_tx(struct iscsi_conn *conn)1388static void iscsi_prep_abort_task_pdu(struct iscsi_cmd_task *ctask,
1389 struct iscsi_tm *hdr)
1176{1390{
1177 clear_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);1391 memset(hdr, 0, sizeof(*hdr));
1178 scsi_queue_work(conn->session->host, &conn->xmitwork);1392 hdr->opcode = ISCSI_OP_SCSI_TMFUNC | ISCSI_OP_IMMEDIATE;
1393 hdr->flags = ISCSI_TM_FUNC_ABORT_TASK & ISCSI_FLAG_TM_FUNC_MASK;
1394 hdr->flags |= ISCSI_FLAG_CMD_FINAL;
1395 memcpy(hdr->lun, ctask->hdr->lun, sizeof(hdr->lun));
1396 hdr->rtt = ctask->hdr->itt;
1397 hdr->refcmdsn = ctask->hdr->cmdsn;
1179}1398}
1180 1399
1181int iscsi_eh_abort(struct scsi_cmnd *sc)1400int iscsi_eh_abort(struct scsi_cmnd *sc)
1182{1401{
1183 struct Scsi_Host *host = sc->device->host;1402 struct Scsi_Host *host = sc->device->host;
1184 struct iscsi_session *session = iscsi_hostdata(host->hostdata);1403 struct iscsi_session *session = iscsi_hostdata(host->hostdata);
1185 struct iscsi_cmd_task *ctask;
1186 struct iscsi_conn *conn;1404 struct iscsi_conn *conn;
1187 int rc;1405 struct iscsi_cmd_task *ctask;
1406 struct iscsi_tm *hdr;
1407 int rc, age;
1188 1408
1189 mutex_lock(&session->eh_mutex);1409 mutex_lock(&session->eh_mutex);
1190 spin_lock_bh(&session->lock);1410 spin_lock_bh(&session->lock);
@@ -1199,19 +1419,23 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) · 8 unmodified lines
1199 return SUCCESS;1419 return SUCCESS;
1200 }1420 }
1201 1421
1202 ctask = (struct iscsi_cmd_task *)sc->SCp.ptr;
1203 conn = ctask->conn;
1204
1205 conn->eh_abort_cnt++;
1206 debug_scsi("aborting [sc %p itt 0x%x]\n", sc, ctask->itt);
1207
1208 /*1422 /*
1209 * If we are not logged in or we have started a new session1423 * If we are not logged in or we have started a new session
1210 * then let the host reset code handle this1424 * then let the host reset code handle this
1211 */1425 */
1212 if (session->state != ISCSI_STATE_LOGGED_IN ||1426 if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN ||
1213 sc->SCp.phase != session->age)1427 sc->SCp.phase != session->age) {
1214 goto failed;1428 spin_unlock_bh(&session->lock);
1429 mutex_unlock(&session->eh_mutex);
1430 return FAILED;
1431 }
1432
1433 conn = session->leadconn;
1434 conn->eh_abort_cnt++;
1435 age = session->age;
1436
1437 ctask = (struct iscsi_cmd_task *)sc->SCp.ptr;
1438 debug_scsi("aborting [sc %p itt 0x%x]\n", sc, ctask->itt);
1215 1439
1216 /* ctask completed before time out */1440 /* ctask completed before time out */
1217 if (!ctask->sc) {1441 if (!ctask->sc) {
@@ -1219,27 +1443,26 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) · 1 unmodified line
1219 goto success;1443 goto success;
1220 }1444 }
1221 1445
1222 /* what should we do here ? */
1223 if (conn->ctask == ctask) {
1224 printk(KERN_INFO "iscsi: sc %p itt 0x%x partially sent. "
1225 "Failing abort\n", sc, ctask->itt);
1226 goto failed;
1227 }
1228
1229 if (ctask->state == ISCSI_TASK_PENDING) {1446 if (ctask->state == ISCSI_TASK_PENDING) {
1230 fail_command(conn, ctask, DID_ABORT << 16);1447 fail_command(conn, ctask, DID_ABORT << 16);
1231 goto success;1448 goto success;
1232 }1449 }
1233 1450
1234 conn->tmabort_state = TMABORT_INITIAL;1451 /* only have one tmf outstanding at a time */
1235 rc = iscsi_exec_abort_task(sc, ctask);1452 if (conn->tmf_state != TMF_INITIAL)
1236 if (rc || sc->SCp.phase != session->age ||1453 goto failed;
1237 session->state != ISCSI_STATE_LOGGED_IN)1454 conn->tmf_state = TMF_QUEUED;
1455
1456 hdr = &conn->tmhdr;
1457 iscsi_prep_abort_task_pdu(ctask, hdr);
1458
1459 if (iscsi_exec_task_mgmt_fn(conn, hdr, age, session->abort_timeout)) {
1460 rc = FAILED;
1238 goto failed;1461 goto failed;
1239 iscsi_ctask_mtask_cleanup(ctask);1462 }
1240 1463
1241 switch (conn->tmabort_state) {1464 switch (conn->tmf_state) {
1242 case TMABORT_SUCCESS:1465 case TMF_SUCCESS:
1243 spin_unlock_bh(&session->lock);1466 spin_unlock_bh(&session->lock);
1244 iscsi_suspend_tx(conn);1467 iscsi_suspend_tx(conn);
1245 /*1468 /*
@@ -1248,22 +1471,26 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) · 2 unmodified lines
1248 write_lock_bh(conn->recv_lock);1471 write_lock_bh(conn->recv_lock);
1249 spin_lock(&session->lock);1472 spin_lock(&session->lock);
1250 fail_command(conn, ctask, DID_ABORT << 16);1473 fail_command(conn, ctask, DID_ABORT << 16);
1474 conn->tmf_state = TMF_INITIAL;
1251 spin_unlock(&session->lock);1475 spin_unlock(&session->lock);
1252 write_unlock_bh(conn->recv_lock);1476 write_unlock_bh(conn->recv_lock);
1253 iscsi_start_tx(conn);1477 iscsi_start_tx(conn);
1254 goto success_unlocked;1478 goto success_unlocked;
1255 case TMABORT_NOT_FOUND:1479 case TMF_TIMEDOUT:
1256 if (!ctask->sc) {1480 spin_unlock_bh(&session->lock);
1481 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
1482 goto failed_unlocked;
1483 case TMF_NOT_FOUND:
1484 if (!sc->SCp.ptr) {
1485 conn->tmf_state = TMF_INITIAL;
1257 /* ctask completed before tmf abort response */1486 /* ctask completed before tmf abort response */
1258 debug_scsi("sc completed while abort in progress\n");1487 debug_scsi("sc completed while abort in progress\n");
1259 goto success;1488 goto success;
1260 }1489 }
1261 /* fall through */1490 /* fall through */
1262 default:1491 default:
1263 /* timedout or failed */1492 conn->tmf_state = TMF_INITIAL;
1264 spin_unlock_bh(&session->lock);1493 goto failed;
1265 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
1266 goto failed_unlocked;
1267 }1494 }
1268 1495
1269success:1496success:
@@ -1276,65 +1503,152 @@ success_unlocked: · 6 unmodified lines
1276failed:1503failed:
1277 spin_unlock_bh(&session->lock);1504 spin_unlock_bh(&session->lock);
1278failed_unlocked:1505failed_unlocked:
1279 debug_scsi("abort failed [sc %lx itt 0x%x]\n", (long)sc, ctask->itt);1506 debug_scsi("abort failed [sc %p itt 0x%x]\n", sc,
1507 ctask ? ctask->itt : 0);
1280 mutex_unlock(&session->eh_mutex);1508 mutex_unlock(&session->eh_mutex);
1281 return FAILED;1509 return FAILED;
1282}1510}
1283EXPORT_SYMBOL_GPL(iscsi_eh_abort);1511EXPORT_SYMBOL_GPL(iscsi_eh_abort);
1284 1512
1513static void iscsi_prep_lun_reset_pdu(struct scsi_cmnd *sc, struct iscsi_tm *hdr)
1514{
1515 memset(hdr, 0, sizeof(*hdr));
1516 hdr->opcode = ISCSI_OP_SCSI_TMFUNC | ISCSI_OP_IMMEDIATE;
1517 hdr->flags = ISCSI_TM_FUNC_LOGICAL_UNIT_RESET & ISCSI_FLAG_TM_FUNC_MASK;
1518 hdr->flags |= ISCSI_FLAG_CMD_FINAL;
1519 int_to_scsilun(sc->device->lun, (struct scsi_lun *)hdr->lun);
1520 hdr->rtt = RESERVED_ITT;
1521}
1522
1523int iscsi_eh_device_reset(struct scsi_cmnd *sc)
1524{
1525 struct Scsi_Host *host = sc->device->host;
1526 struct iscsi_session *session = iscsi_hostdata(host->hostdata);
1527 struct iscsi_conn *conn;
1528 struct iscsi_tm *hdr;
1529 int rc = FAILED;
1530
1531 debug_scsi("LU Reset [sc %p lun %u]\n", sc, sc->device->lun);
1532
1533 mutex_lock(&session->eh_mutex);
1534 spin_lock_bh(&session->lock);
1535 /*
1536 * Just check if we are not logged in. We cannot check for
1537 * the phase because the reset could come from a ioctl.
1538 */
1539 if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN)
1540 goto unlock;
1541 conn = session->leadconn;
1542
1543 /* only have one tmf outstanding at a time */
1544 if (conn->tmf_state != TMF_INITIAL)
1545 goto unlock;
1546 conn->tmf_state = TMF_QUEUED;
1547
1548 hdr = &conn->tmhdr;
1549 iscsi_prep_lun_reset_pdu(sc, hdr);
1550
1551 if (iscsi_exec_task_mgmt_fn(conn, hdr, session->age,
1552 session->lu_reset_timeout)) {
1553 rc = FAILED;
1554 goto unlock;
1555 }
1556
1557 switch (conn->tmf_state) {
1558 case TMF_SUCCESS:
1559 break;
1560 case TMF_TIMEDOUT:
1561 spin_unlock_bh(&session->lock);
1562 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
1563 goto done;
1564 default:
1565 conn->tmf_state = TMF_INITIAL;
1566 goto unlock;
1567 }
1568
1569 rc = SUCCESS;
1570 spin_unlock_bh(&session->lock);
1571
1572 iscsi_suspend_tx(conn);
1573 /* need to grab the recv lock then session lock */
1574 write_lock_bh(conn->recv_lock);
1575 spin_lock(&session->lock);
1576 fail_all_commands(conn, sc->device->lun);
1577 conn->tmf_state = TMF_INITIAL;
1578 spin_unlock(&session->lock);
1579 write_unlock_bh(conn->recv_lock);
1580
1581 iscsi_start_tx(conn);
1582 goto done;
1583
1584unlock:
1585 spin_unlock_bh(&session->lock);
1586done:
1587 debug_scsi("iscsi_eh_device_reset %s\n",
1588 rc == SUCCESS ? "SUCCESS" : "FAILED");
1589 mutex_unlock(&session->eh_mutex);
1590 return rc;
1591}
1592EXPORT_SYMBOL_GPL(iscsi_eh_device_reset);
1593
1594/*
1595 * Pre-allocate a pool of @max items of @item_size. By default, the pool
1596 * should be accessed via kfifo_{get,put} on q->queue.
1597 * Optionally, the caller can obtain the array of object pointers
1598 * by passing in a non-NULL @items pointer
1599 */
1285int1600int
1286iscsi_pool_init(struct iscsi_queue *q, int max, void ***items, int item_size)1601iscsi_pool_init(struct iscsi_pool *q, int max, void ***items, int item_size)
1287{1602{
1288 int i;1603 int i, num_arrays = 1;
1289 1604
1290 *items = kmalloc(max * sizeof(void*), GFP_KERNEL);1605 memset(q, 0, sizeof(*q));
1291 if (*items == NULL)
1292 return -ENOMEM;
1293 1606
1294 q->max = max;1607 q->max = max;
1295 q->pool = kmalloc(max * sizeof(void*), GFP_KERNEL);1608
1296 if (q->pool == NULL) {1609 /* If the user passed an items pointer, he wants a copy of
1297 kfree(*items);1610 * the array. */
1298 return -ENOMEM;1611 if (items)
1299 }1612 num_arrays++;
1613 q->pool = kzalloc(num_arrays * max * sizeof(void*), GFP_KERNEL);
1614 if (q->pool == NULL)
1615 goto enomem;
1300 1616
1301 q->queue = kfifo_init((void*)q->pool, max * sizeof(void*),1617 q->queue = kfifo_init((void*)q->pool, max * sizeof(void*),
1302 GFP_KERNEL, NULL);1618 GFP_KERNEL, NULL);
1303 if (q->queue == ERR_PTR(-ENOMEM)) {1619 if (q->queue == ERR_PTR(-ENOMEM))
1304 kfree(q->pool);1620 goto enomem;
1305 kfree(*items);
1306 return -ENOMEM;
1307 }
1308 1621
1309 for (i = 0; i < max; i++) {1622 for (i = 0; i < max; i++) {
1310 q->pool[i] = kmalloc(item_size, GFP_KERNEL);1623 q->pool[i] = kzalloc(item_size, GFP_KERNEL);
1311 if (q->pool[i] == NULL) {1624 if (q->pool[i] == NULL) {
1312 int j;1625 q->max = i;
1313 1626 goto enomem;
1314 for (j = 0; j < i; j++)
1315 kfree(q->pool[j]);
1316
1317 kfifo_free(q->queue);
1318 kfree(q->pool);
1319 kfree(*items);
1320 return -ENOMEM;
1321 }1627 }
1322 memset(q->pool[i], 0, item_size);
1323 (*items)[i] = q->pool[i];
1324 __kfifo_put(q->queue, (void*)&q->pool[i], sizeof(void*));1628 __kfifo_put(q->queue, (void*)&q->pool[i], sizeof(void*));
1325 }1629 }
1630
1631 if (items) {
1632 *items = q->pool + max;
1633 memcpy(*items, q->pool, max * sizeof(void *));
1634 }
1635
1326 return 0;1636 return 0;
1637
1638enomem:
1639 iscsi_pool_free(q);
1640 return -ENOMEM;
1327}1641}
1328EXPORT_SYMBOL_GPL(iscsi_pool_init);1642EXPORT_SYMBOL_GPL(iscsi_pool_init);
1329 1643
1330void iscsi_pool_free(struct iscsi_queue *q, void **items)1644void iscsi_pool_free(struct iscsi_pool *q)
1331{1645{
1332 int i;1646 int i;
1333 1647
1334 for (i = 0; i < q->max; i++)1648 for (i = 0; i < q->max; i++)
1335 kfree(items[i]);1649 kfree(q->pool[i]);
1336 kfree(q->pool);1650 if (q->pool)
1337 kfree(items);1651 kfree(q->pool);
1338}1652}
1339EXPORT_SYMBOL_GPL(iscsi_pool_free);1653EXPORT_SYMBOL_GPL(iscsi_pool_free);
1340 1654
@@ -1387,7 +1701,7 @@ iscsi_session_setup(struct iscsi_transport *iscsit, · 46 unmodified lines
1387 qdepth = ISCSI_DEF_CMD_PER_LUN;1701 qdepth = ISCSI_DEF_CMD_PER_LUN;
1388 }1702 }
1389 1703
1390 if (cmds_max < 2 || (cmds_max & (cmds_max - 1)) ||1704 if (!is_power_of_2(cmds_max) ||
1391 cmds_max >= ISCSI_MGMT_ITT_OFFSET) {1705 cmds_max >= ISCSI_MGMT_ITT_OFFSET) {
1392 if (cmds_max != 0)1706 if (cmds_max != 0)
1393 printk(KERN_ERR "iscsi: invalid can_queue of %d. "1707 printk(KERN_ERR "iscsi: invalid can_queue of %d. "
@@ -1411,12 +1725,16 @@ iscsi_session_setup(struct iscsi_transport *iscsit, · 17 unmodified lines
1411 shost->max_cmd_len = iscsit->max_cmd_len;1725 shost->max_cmd_len = iscsit->max_cmd_len;
1412 shost->transportt = scsit;1726 shost->transportt = scsit;
1413 shost->transportt->create_work_queue = 1;1727 shost->transportt->create_work_queue = 1;
1728 shost->transportt->eh_timed_out = iscsi_eh_cmd_timed_out;
1414 *hostno = shost->host_no;1729 *hostno = shost->host_no;
1415 1730
1416 session = iscsi_hostdata(shost->hostdata);1731 session = iscsi_hostdata(shost->hostdata);
1417 memset(session, 0, sizeof(struct iscsi_session));1732 memset(session, 0, sizeof(struct iscsi_session));
1418 session->host = shost;1733 session->host = shost;
1419 session->state = ISCSI_STATE_FREE;1734 session->state = ISCSI_STATE_FREE;
1735 session->fast_abort = 1;
1736 session->lu_reset_timeout = 15;
1737 session->abort_timeout = 10;
1420 session->mgmtpool_max = ISCSI_MGMT_CMDS_MAX;1738 session->mgmtpool_max = ISCSI_MGMT_CMDS_MAX;
1421 session->cmds_max = cmds_max;1739 session->cmds_max = cmds_max;
1422 session->queued_cmdsn = session->cmdsn = initial_cmdsn;1740 session->queued_cmdsn = session->cmdsn = initial_cmdsn;
@@ -1479,9 +1797,9 @@ module_put: · 56 unmodified lines
1479cls_session_fail:1797cls_session_fail:
1480 scsi_remove_host(shost);1798 scsi_remove_host(shost);
1481add_host_fail:1799add_host_fail:
1482 iscsi_pool_free(&session->mgmtpool, (void**)session->mgmt_cmds);1800 iscsi_pool_free(&session->mgmtpool);
1483mgmtpool_alloc_fail:1801mgmtpool_alloc_fail:
1484 iscsi_pool_free(&session->cmdpool, (void**)session->cmds);1802 iscsi_pool_free(&session->cmdpool);
1485cmdpool_alloc_fail:1803cmdpool_alloc_fail:
1486 scsi_host_put(shost);1804 scsi_host_put(shost);
1487 return NULL;1805 return NULL;
@@ -1501,11 +1819,11 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session) · 13 unmodified lines
1501 struct iscsi_session *session = iscsi_hostdata(shost->hostdata);1819 struct iscsi_session *session = iscsi_hostdata(shost->hostdata);
1502 struct module *owner = cls_session->transport->owner;1820 struct module *owner = cls_session->transport->owner;
1503 1821
1504 iscsi_unblock_session(cls_session);1822 iscsi_remove_session(cls_session);
1505 scsi_remove_host(shost);1823 scsi_remove_host(shost);
1506 1824
1507 iscsi_pool_free(&session->mgmtpool, (void**)session->mgmt_cmds);1825 iscsi_pool_free(&session->mgmtpool);
1508 iscsi_pool_free(&session->cmdpool, (void**)session->cmds);1826 iscsi_pool_free(&session->cmdpool);
1509 1827
1510 kfree(session->password);1828 kfree(session->password);
1511 kfree(session->password_in);1829 kfree(session->password_in);
@@ -1516,7 +1834,7 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session) · 4 unmodified lines
1516 kfree(session->hwaddress);1834 kfree(session->hwaddress);
1517 kfree(session->initiatorname);1835 kfree(session->initiatorname);
1518 1836
1519 iscsi_destroy_session(cls_session);1837 iscsi_free_session(cls_session);
1520 scsi_host_put(shost);1838 scsi_host_put(shost);
1521 module_put(owner);1839 module_put(owner);
1522}1840}
@@ -1546,17 +1864,17 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, uint32_t conn_idx) · 23 unmodified lines
1546 conn->c_stage = ISCSI_CONN_INITIAL_STAGE;1864 conn->c_stage = ISCSI_CONN_INITIAL_STAGE;
1547 conn->id = conn_idx;1865 conn->id = conn_idx;
1548 conn->exp_statsn = 0;1866 conn->exp_statsn = 0;
1549 conn->tmabort_state = TMABORT_INITIAL;1867 conn->tmf_state = TMF_INITIAL;
1868
1869 init_timer(&conn->transport_timer);
1870 conn->transport_timer.data = (unsigned long)conn;
1871 conn->transport_timer.function = iscsi_check_transport_timeouts;
1872
1550 INIT_LIST_HEAD(&conn->run_list);1873 INIT_LIST_HEAD(&conn->run_list);
1551 INIT_LIST_HEAD(&conn->mgmt_run_list);1874 INIT_LIST_HEAD(&conn->mgmt_run_list);
1875 INIT_LIST_HEAD(&conn->mgmtqueue);
1552 INIT_LIST_HEAD(&conn->xmitqueue);1876 INIT_LIST_HEAD(&conn->xmitqueue);
1553 1877 INIT_LIST_HEAD(&conn->requeue);
1554 /* initialize general immediate & non-immediate PDU commands queue */
1555 conn->mgmtqueue = kfifo_alloc(session->mgmtpool_max * sizeof(void*),
1556 GFP_KERNEL, NULL);
1557 if (conn->mgmtqueue == ERR_PTR(-ENOMEM))
1558 goto mgmtqueue_alloc_fail;
1559
1560 INIT_WORK(&conn->xmitwork, iscsi_xmitworker);1878 INIT_WORK(&conn->xmitwork, iscsi_xmitworker);
1561 1879
1562 /* allocate login_mtask used for the login/text sequences */1880 /* allocate login_mtask used for the login/text sequences */
@@ -1574,7 +1892,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, uint32_t conn_idx) · 11 unmodified lines
1574 goto login_mtask_data_alloc_fail;1892 goto login_mtask_data_alloc_fail;
1575 conn->login_mtask->data = conn->data = data;1893 conn->login_mtask->data = conn->data = data;
1576 1894
1577 init_timer(&conn->tmabort_timer);1895 init_timer(&conn->tmf_timer);
1578 init_waitqueue_head(&conn->ehwait);1896 init_waitqueue_head(&conn->ehwait);
1579 1897
1580 return cls_conn;1898 return cls_conn;
@@ -1583,8 +1901,6 @@ login_mtask_data_alloc_fail: · 2 unmodified lines
1583 __kfifo_put(session->mgmtpool.queue, (void*)&conn->login_mtask,1901 __kfifo_put(session->mgmtpool.queue, (void*)&conn->login_mtask,
1584 sizeof(void*));1902 sizeof(void*));
1585login_mtask_alloc_fail:1903login_mtask_alloc_fail:
1586 kfifo_free(conn->mgmtqueue);
1587mgmtqueue_alloc_fail:
1588 iscsi_destroy_conn(cls_conn);1904 iscsi_destroy_conn(cls_conn);
1589 return NULL;1905 return NULL;
1590}1906}
@@ -1603,8 +1919,9 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn) · 12 unmodified lines
1603 struct iscsi_session *session = conn->session;1919 struct iscsi_session *session = conn->session;
1604 unsigned long flags;1920 unsigned long flags;
1605 1921
1922 del_timer_sync(&conn->transport_timer);
1923
1606 spin_lock_bh(&session->lock);1924 spin_lock_bh(&session->lock);
1607 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
1608 conn->c_stage = ISCSI_CONN_CLEANUP_WAIT;1925 conn->c_stage = ISCSI_CONN_CLEANUP_WAIT;
1609 if (session->leadconn == conn) {1926 if (session->leadconn == conn) {
1610 /*1927 /*
@@ -1637,7 +1954,7 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn) · 26 unmodified lines
1637 }1954 }
1638 1955
1639 /* flush queued up work because we free the connection below */1956 /* flush queued up work because we free the connection below */
1640 scsi_flush_work(session->host);1957 iscsi_suspend_tx(conn);
1641 1958
1642 spin_lock_bh(&session->lock);1959 spin_lock_bh(&session->lock);
1643 kfree(conn->data);1960 kfree(conn->data);
@@ -1648,8 +1965,6 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn) · 4 unmodified lines
1648 session->leadconn = NULL;1965 session->leadconn = NULL;
1649 spin_unlock_bh(&session->lock);1966 spin_unlock_bh(&session->lock);
1650 1967
1651 kfifo_free(conn->mgmtqueue);
1652
1653 iscsi_destroy_conn(cls_conn);1968 iscsi_destroy_conn(cls_conn);
1654}1969}
1655EXPORT_SYMBOL_GPL(iscsi_conn_teardown);1970EXPORT_SYMBOL_GPL(iscsi_conn_teardown);
@@ -1672,11 +1987,29 @@ int iscsi_conn_start(struct iscsi_cls_conn *cls_conn) · 16 unmodified lines
1672 return -EINVAL;1987 return -EINVAL;
1673 }1988 }
1674 1989
1990 if (conn->ping_timeout && !conn->recv_timeout) {
1991 printk(KERN_ERR "iscsi: invalid recv timeout of zero "
1992 "Using 5 seconds\n.");
1993 conn->recv_timeout = 5;
1994 }
1995
1996 if (conn->recv_timeout && !conn->ping_timeout) {
1997 printk(KERN_ERR "iscsi: invalid ping timeout of zero "
1998 "Using 5 seconds.\n");
1999 conn->ping_timeout = 5;
2000 }
2001
1675 spin_lock_bh(&session->lock);2002 spin_lock_bh(&session->lock);
1676 conn->c_stage = ISCSI_CONN_STARTED;2003 conn->c_stage = ISCSI_CONN_STARTED;
1677 session->state = ISCSI_STATE_LOGGED_IN;2004 session->state = ISCSI_STATE_LOGGED_IN;
1678 session->queued_cmdsn = session->cmdsn;2005 session->queued_cmdsn = session->cmdsn;
1679 2006
2007 conn->last_recv = jiffies;
2008 conn->last_ping = jiffies;
2009 if (conn->recv_timeout && conn->ping_timeout)
2010 mod_timer(&conn->transport_timer,
2011 jiffies + (conn->recv_timeout * HZ));
2012
1680 switch(conn->stop_stage) {2013 switch(conn->stop_stage) {
1681 case STOP_CONN_RECOVER:2014 case STOP_CONN_RECOVER:
1682 /*2015 /*
@@ -1684,7 +2017,7 @@ int iscsi_conn_start(struct iscsi_cls_conn *cls_conn) · 1 unmodified line
1684 * commands after successful recovery2017 * commands after successful recovery
1685 */2018 */
1686 conn->stop_stage = 0;2019 conn->stop_stage = 0;
1687 conn->tmabort_state = TMABORT_INITIAL;2020 conn->tmf_state = TMF_INITIAL;
1688 session->age++;2021 session->age++;
1689 spin_unlock_bh(&session->lock);2022 spin_unlock_bh(&session->lock);
1690 2023
@@ -1709,55 +2042,27 @@ flush_control_queues(struct iscsi_session *session, struct iscsi_conn *conn) · 18 unmodified lines
1709 struct iscsi_mgmt_task *mtask, *tmp;2042 struct iscsi_mgmt_task *mtask, *tmp;
1710 2043
1711 /* handle pending */2044 /* handle pending */
1712 while (__kfifo_get(conn->mgmtqueue, (void*)&mtask, sizeof(void*))) {2045 list_for_each_entry_safe(mtask, tmp, &conn->mgmtqueue, running) {
1713 if (mtask == conn->login_mtask)
1714 continue;
1715 debug_scsi("flushing pending mgmt task itt 0x%x\n", mtask->itt);2046 debug_scsi("flushing pending mgmt task itt 0x%x\n", mtask->itt);
1716 __kfifo_put(session->mgmtpool.queue, (void*)&mtask,2047 iscsi_free_mgmt_task(conn, mtask);
1717 sizeof(void*));
1718 }2048 }
1719 2049
1720 /* handle running */2050 /* handle running */
1721 list_for_each_entry_safe(mtask, tmp, &conn->mgmt_run_list, running) {2051 list_for_each_entry_safe(mtask, tmp, &conn->mgmt_run_list, running) {
1722 debug_scsi("flushing running mgmt task itt 0x%x\n", mtask->itt);2052 debug_scsi("flushing running mgmt task itt 0x%x\n", mtask->itt);
1723 list_del(&mtask->running);2053 iscsi_free_mgmt_task(conn, mtask);
1724
1725 if (mtask == conn->login_mtask)
1726 continue;
1727 __kfifo_put(session->mgmtpool.queue, (void*)&mtask,
1728 sizeof(void*));
1729 }2054 }
1730 2055
1731 conn->mtask = NULL;2056 conn->mtask = NULL;
1732}2057}
1733 2058
1734/* Fail commands. Mutex and session lock held and recv side suspended */
1735static void fail_all_commands(struct iscsi_conn *conn)
1736{
1737 struct iscsi_cmd_task *ctask, *tmp;
1738
1739 /* flush pending */
1740 list_for_each_entry_safe(ctask, tmp, &conn->xmitqueue, running) {
1741 debug_scsi("failing pending sc %p itt 0x%x\n", ctask->sc,
1742 ctask->itt);
1743 fail_command(conn, ctask, DID_BUS_BUSY << 16);
1744 }
1745
1746 /* fail all other running */
1747 list_for_each_entry_safe(ctask, tmp, &conn->run_list, running) {
1748 debug_scsi("failing in progress sc %p itt 0x%x\n",
1749 ctask->sc, ctask->itt);
1750 fail_command(conn, ctask, DID_BUS_BUSY << 16);
1751 }
1752
1753 conn->ctask = NULL;
1754}
1755
1756static void iscsi_start_session_recovery(struct iscsi_session *session,2059static void iscsi_start_session_recovery(struct iscsi_session *session,
1757 struct iscsi_conn *conn, int flag)2060 struct iscsi_conn *conn, int flag)
1758{2061{
1759 int old_stop_stage;2062 int old_stop_stage;
1760 2063
2064 del_timer_sync(&conn->transport_timer);
2065
1761 mutex_lock(&session->eh_mutex);2066 mutex_lock(&session->eh_mutex);
1762 spin_lock_bh(&session->lock);2067 spin_lock_bh(&session->lock);
1763 if (conn->stop_stage == STOP_CONN_TERM) {2068 if (conn->stop_stage == STOP_CONN_TERM) {
@@ -1818,7 +2123,7 @@ static void iscsi_start_session_recovery(struct iscsi_session *session, · 54 unmodified lines
1818 * flush queues.2123 * flush queues.
1819 */2124 */
1820 spin_lock_bh(&session->lock);2125 spin_lock_bh(&session->lock);
1821 fail_all_commands(conn);2126 fail_all_commands(conn, -1);
1822 flush_control_queues(session, conn);2127 flush_control_queues(session, conn);
1823 spin_unlock_bh(&session->lock);2128 spin_unlock_bh(&session->lock);
1824 mutex_unlock(&session->eh_mutex);2129 mutex_unlock(&session->eh_mutex);
@@ -1869,6 +2174,21 @@ int iscsi_set_param(struct iscsi_cls_conn *cls_conn, · 44 unmodified lines
1869 uint32_t value;2174 uint32_t value;
1870 2175
1871 switch(param) {2176 switch(param) {
2177 case ISCSI_PARAM_FAST_ABORT:
2178 sscanf(buf, "%d", &session->fast_abort);
2179 break;
2180 case ISCSI_PARAM_ABORT_TMO:
2181 sscanf(buf, "%d", &session->abort_timeout);
2182 break;
2183 case ISCSI_PARAM_LU_RESET_TMO:
2184 sscanf(buf, "%d", &session->lu_reset_timeout);
2185 break;
2186 case ISCSI_PARAM_PING_TMO:
2187 sscanf(buf, "%d", &conn->ping_timeout);
2188 break;
2189 case ISCSI_PARAM_RECV_TMO:
2190 sscanf(buf, "%d", &conn->recv_timeout);
2191 break;
1872 case ISCSI_PARAM_MAX_RECV_DLENGTH:2192 case ISCSI_PARAM_MAX_RECV_DLENGTH:
1873 sscanf(buf, "%d", &conn->max_recv_dlength);2193 sscanf(buf, "%d", &conn->max_recv_dlength);
1874 break;2194 break;
@@ -1983,6 +2303,15 @@ int iscsi_session_get_param(struct iscsi_cls_session *cls_session, · 108 unmodified lines
1983 int len;2303 int len;
1984 2304
1985 switch(param) {2305 switch(param) {
2306 case ISCSI_PARAM_FAST_ABORT:
2307 len = sprintf(buf, "%d\n", session->fast_abort);
2308 break;
2309 case ISCSI_PARAM_ABORT_TMO:
2310 len = sprintf(buf, "%d\n", session->abort_timeout);
2311 break;
2312 case ISCSI_PARAM_LU_RESET_TMO:
2313 len = sprintf(buf, "%d\n", session->lu_reset_timeout);
2314 break;
1986 case ISCSI_PARAM_INITIAL_R2T_EN:2315 case ISCSI_PARAM_INITIAL_R2T_EN:
1987 len = sprintf(buf, "%d\n", session->initial_r2t_en);2316 len = sprintf(buf, "%d\n", session->initial_r2t_en);
1988 break;2317 break;
@@ -2040,6 +2369,12 @@ int iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn, · 51 unmodified lines
2040 int len;2369 int len;
2041 2370
2042 switch(param) {2371 switch(param) {
2372 case ISCSI_PARAM_PING_TMO:
2373 len = sprintf(buf, "%u\n", conn->ping_timeout);
2374 break;
2375 case ISCSI_PARAM_RECV_TMO:
2376 len = sprintf(buf, "%u\n", conn->recv_timeout);
2377 break;
2043 case ISCSI_PARAM_MAX_RECV_DLENGTH:2378 case ISCSI_PARAM_MAX_RECV_DLENGTH:
2044 len = sprintf(buf, "%u\n", conn->max_recv_dlength);2379 len = sprintf(buf, "%u\n", conn->max_recv_dlength);
2045 break;2380 break;
drivers/scsi/libsas/Kconfig+9−0
@@ -38,6 +38,15 @@ config SCSI_SAS_ATA · 37 unmodified lines
38 Builds in ATA support into libsas. Will necessitate38 Builds in ATA support into libsas. Will necessitate
39 the loading of libata along with libsas.39 the loading of libata along with libsas.
40 40
41config SCSI_SAS_HOST_SMP
42 bool "Support for SMP interpretation for SAS hosts"
43 default y
44 depends on SCSI_SAS_LIBSAS
45 help
46 Allows sas hosts to receive SMP frames. Selecting this
47 option builds an SMP interpreter into libsas. Say
48 N here if you want to save the few kb this consumes.
49
41config SCSI_SAS_LIBSAS_DEBUG50config SCSI_SAS_LIBSAS_DEBUG
42 bool "Compile the SAS Domain Transport Attributes in debug mode"51 bool "Compile the SAS Domain Transport Attributes in debug mode"
43 default y52 default y
drivers/scsi/libsas/Makefile+3−1
@@ -33,5 +33,7 @@ libsas-y += sas_init.o \ · 32 unmodified lines
33 sas_dump.o \33 sas_dump.o \
34 sas_discover.o \34 sas_discover.o \
35 sas_expander.o \35 sas_expander.o \
36 sas_scsi_host.o36 sas_scsi_host.o \
37 sas_task.o
37libsas-$(CONFIG_SCSI_SAS_ATA) += sas_ata.o38libsas-$(CONFIG_SCSI_SAS_ATA) += sas_ata.o
39libsas-$(CONFIG_SCSI_SAS_HOST_SMP) += sas_host_smp.o
drivers/scsi/libsas/sas_ata.c+1−1
@@ -498,7 +498,7 @@ static int sas_execute_task(struct sas_task *task, void *buffer, int size, · 497 unmodified lines
498 goto ex_err;498 goto ex_err;
499 }499 }
500 wait_for_completion(&task->completion);500 wait_for_completion(&task->completion);
501 res = -ETASK;501 res = -ECOMM;
502 if (task->task_state_flags & SAS_TASK_STATE_ABORTED) {502 if (task->task_state_flags & SAS_TASK_STATE_ABORTED) {
503 int res2;503 int res2;
504 SAS_DPRINTK("task aborted, flags:0x%x\n",504 SAS_DPRINTK("task aborted, flags:0x%x\n",
drivers/scsi/libsas/sas_discover.c+1−1
@@ -98,7 +98,7 @@ static int sas_get_port_device(struct asd_sas_port *port) · 97 unmodified lines
98 dev->dev_type = SATA_PM;98 dev->dev_type = SATA_PM;
99 else99 else
100 dev->dev_type = SATA_DEV;100 dev->dev_type = SATA_DEV;
101 dev->tproto = SATA_PROTO;101 dev->tproto = SAS_PROTOCOL_SATA;
102 } else {102 } else {
103 struct sas_identify_frame *id =103 struct sas_identify_frame *id =
104 (struct sas_identify_frame *) dev->frame_rcvd;104 (struct sas_identify_frame *) dev->frame_rcvd;
drivers/scsi/libsas/sas_expander.c+26−9
@@ -96,7 +96,7 @@ static int smp_execute_task(struct domain_device *dev, void *req, int req_size, · 95 unmodified lines
96 }96 }
97 97
98 wait_for_completion(&task->completion);98 wait_for_completion(&task->completion);
99 res = -ETASK;99 res = -ECOMM;
100 if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) {100 if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) {
101 SAS_DPRINTK("smp task timed out or aborted\n");101 SAS_DPRINTK("smp task timed out or aborted\n");
102 i->dft->lldd_abort_task(task);102 i->dft->lldd_abort_task(task);
@@ -109,6 +109,16 @@ static int smp_execute_task(struct domain_device *dev, void *req, int req_size, · 6 unmodified lines
109 task->task_status.stat == SAM_GOOD) {109 task->task_status.stat == SAM_GOOD) {
110 res = 0;110 res = 0;
111 break;111 break;
112 } if (task->task_status.resp == SAS_TASK_COMPLETE &&
113 task->task_status.stat == SAS_DATA_UNDERRUN) {
114 /* no error, but return the number of bytes of
115 * underrun */
116 res = task->task_status.residual;
117 break;
118 } if (task->task_status.resp == SAS_TASK_COMPLETE &&
119 task->task_status.stat == SAS_DATA_OVERRUN) {
120 res = -EMSGSIZE;
121 break;
112 } else {122 } else {
113 SAS_DPRINTK("%s: task to dev %016llx response: 0x%x "123 SAS_DPRINTK("%s: task to dev %016llx response: 0x%x "
114 "status 0x%x\n", __FUNCTION__,124 "status 0x%x\n", __FUNCTION__,
@@ -656,9 +666,9 @@ static struct domain_device *sas_ex_discover_end_dev( · 541 unmodified lines
656 sas_ex_get_linkrate(parent, child, phy);666 sas_ex_get_linkrate(parent, child, phy);
657 667
658#ifdef CONFIG_SCSI_SAS_ATA668#ifdef CONFIG_SCSI_SAS_ATA
659 if ((phy->attached_tproto & SAS_PROTO_STP) || phy->attached_sata_dev) {669 if ((phy->attached_tproto & SAS_PROTOCOL_STP) || phy->attached_sata_dev) {
660 child->dev_type = SATA_DEV;670 child->dev_type = SATA_DEV;
661 if (phy->attached_tproto & SAS_PROTO_STP)671 if (phy->attached_tproto & SAS_PROTOCOL_STP)
662 child->tproto = phy->attached_tproto;672 child->tproto = phy->attached_tproto;
663 if (phy->attached_sata_dev)673 if (phy->attached_sata_dev)
664 child->tproto |= SATA_DEV;674 child->tproto |= SATA_DEV;
@@ -695,7 +705,7 @@ static struct domain_device *sas_ex_discover_end_dev( · 30 unmodified lines
695 }705 }
696 } else706 } else
697#endif707#endif
698 if (phy->attached_tproto & SAS_PROTO_SSP) {708 if (phy->attached_tproto & SAS_PROTOCOL_SSP) {
699 child->dev_type = SAS_END_DEV;709 child->dev_type = SAS_END_DEV;
700 rphy = sas_end_device_alloc(phy->port);710 rphy = sas_end_device_alloc(phy->port);
701 /* FIXME: error handling */711 /* FIXME: error handling */
@@ -1896,11 +1906,9 @@ int sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, · 1194 unmodified lines
1896 }1906 }
1897 1907
1898 /* no rphy means no smp target support (ie aic94xx host) */1908 /* no rphy means no smp target support (ie aic94xx host) */
1899 if (!rphy) {1909 if (!rphy)
1900 printk("%s: can we send a smp request to a host?\n",1910 return sas_smp_host_handler(shost, req, rsp);
1901 __FUNCTION__);1911
1902 return -EINVAL;
1903 }
1904 type = rphy->identify.device_type;1912 type = rphy->identify.device_type;
1905 1913
1906 if (type != SAS_EDGE_EXPANDER_DEVICE &&1914 if (type != SAS_EDGE_EXPANDER_DEVICE &&
@@ -1926,6 +1934,15 @@ int sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, · 19 unmodified lines
1926 1934
1927 ret = smp_execute_task(dev, bio_data(req->bio), req->data_len,1935 ret = smp_execute_task(dev, bio_data(req->bio), req->data_len,
1928 bio_data(rsp->bio), rsp->data_len);1936 bio_data(rsp->bio), rsp->data_len);
1937 if (ret > 0) {
1938 /* positive number is the untransferred residual */
1939 rsp->data_len = ret;
1940 req->data_len = 0;
1941 ret = 0;
1942 } else if (ret == 0) {
1943 rsp->data_len = 0;
1944 req->data_len = 0;
1945 }
1929 1946
1930 return ret;1947 return ret;
1931}1948}
drivers/scsi/libsas/sas_host_smp.c+274−0
@@ -0,0 +1,274 @@
1/*
2 * Serial Attached SCSI (SAS) Expander discovery and configuration
3 *
4 * Copyright (C) 2007 James E.J. Bottomley
5 * <James.Bottomley@HansenPartnership.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; version 2 only.
10 */
11#include <linux/scatterlist.h>
12#include <linux/blkdev.h>
13
14#include "sas_internal.h"
15
16#include <scsi/scsi_transport.h>
17#include <scsi/scsi_transport_sas.h>
18#include "../scsi_sas_internal.h"
19
20static void sas_host_smp_discover(struct sas_ha_struct *sas_ha, u8 *resp_data,
21 u8 phy_id)
22{
23 struct sas_phy *phy;
24 struct sas_rphy *rphy;
25
26 if (phy_id >= sas_ha->num_phys) {
27 resp_data[2] = SMP_RESP_NO_PHY;
28 return;
29 }
30 resp_data[2] = SMP_RESP_FUNC_ACC;
31
32 phy = sas_ha->sas_phy[phy_id]->phy;
33 resp_data[9] = phy_id;
34 resp_data[13] = phy->negotiated_linkrate;
35 memcpy(resp_data + 16, sas_ha->sas_addr, SAS_ADDR_SIZE);
36 memcpy(resp_data + 24, sas_ha->sas_phy[phy_id]->attached_sas_addr,
37 SAS_ADDR_SIZE);
38 resp_data[40] = (phy->minimum_linkrate << 4) |
39 phy->minimum_linkrate_hw;
40 resp_data[41] = (phy->maximum_linkrate << 4) |
41 phy->maximum_linkrate_hw;
42
43 if (!sas_ha->sas_phy[phy_id]->port ||
44 !sas_ha->sas_phy[phy_id]->port->port_dev)
45 return;
46
47 rphy = sas_ha->sas_phy[phy_id]->port->port_dev->rphy;
48 resp_data[12] = rphy->identify.device_type << 4;
49 resp_data[14] = rphy->identify.initiator_port_protocols;
50 resp_data[15] = rphy->identify.target_port_protocols;
51}
52
53static void sas_report_phy_sata(struct sas_ha_struct *sas_ha, u8 *resp_data,
54 u8 phy_id)
55{
56 struct sas_rphy *rphy;
57 struct dev_to_host_fis *fis;
58 int i;
59
60 if (phy_id >= sas_ha->num_phys) {
61 resp_data[2] = SMP_RESP_NO_PHY;
62 return;
63 }
64
65 resp_data[2] = SMP_RESP_PHY_NO_SATA;
66
67 if (!sas_ha->sas_phy[phy_id]->port)
68 return;
69
70 rphy = sas_ha->sas_phy[phy_id]->port->port_dev->rphy;
71 fis = (struct dev_to_host_fis *)
72 sas_ha->sas_phy[phy_id]->port->port_dev->frame_rcvd;
73 if (rphy->identify.target_port_protocols != SAS_PROTOCOL_SATA)
74 return;
75
76 resp_data[2] = SMP_RESP_FUNC_ACC;
77 resp_data[9] = phy_id;
78 memcpy(resp_data + 16, sas_ha->sas_phy[phy_id]->attached_sas_addr,
79 SAS_ADDR_SIZE);
80
81 /* check to see if we have a valid d2h fis */
82 if (fis->fis_type != 0x34)
83 return;
84
85 /* the d2h fis is required by the standard to be in LE format */
86 for (i = 0; i < 20; i += 4) {
87 u8 *dst = resp_data + 24 + i, *src =
88 &sas_ha->sas_phy[phy_id]->port->port_dev->frame_rcvd[i];
89 dst[0] = src[3];
90 dst[1] = src[2];
91 dst[2] = src[1];
92 dst[3] = src[0];
93 }
94}
95
96static void sas_phy_control(struct sas_ha_struct *sas_ha, u8 phy_id,
97 u8 phy_op, enum sas_linkrate min,
98 enum sas_linkrate max, u8 *resp_data)
99{
100 struct sas_internal *i =
101 to_sas_internal(sas_ha->core.shost->transportt);
102 struct sas_phy_linkrates rates;
103
104 if (phy_id >= sas_ha->num_phys) {
105 resp_data[2] = SMP_RESP_NO_PHY;
106 return;
107 }
108 switch (phy_op) {
109 case PHY_FUNC_NOP:
110 case PHY_FUNC_LINK_RESET:
111 case PHY_FUNC_HARD_RESET:
112 case PHY_FUNC_DISABLE:
113 case PHY_FUNC_CLEAR_ERROR_LOG:
114 case PHY_FUNC_CLEAR_AFFIL:
115 case PHY_FUNC_TX_SATA_PS_SIGNAL:
116 break;
117
118 default:
119 resp_data[2] = SMP_RESP_PHY_UNK_OP;
120 return;
121 }
122
123 rates.minimum_linkrate = min;
124 rates.maximum_linkrate = max;
125
126 if (i->dft->lldd_control_phy(sas_ha->sas_phy[phy_id], phy_op, &rates))
127 resp_data[2] = SMP_RESP_FUNC_FAILED;
128 else
129 resp_data[2] = SMP_RESP_FUNC_ACC;
130}
131
132int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
133 struct request *rsp)
134{
135 u8 *req_data = NULL, *resp_data = NULL, *buf;
136 struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(shost);
137 int error = -EINVAL, resp_data_len = rsp->data_len;
138
139 /* eight is the minimum size for request and response frames */
140 if (req->data_len < 8 || rsp->data_len < 8)
141 goto out;
142
143 if (bio_offset(req->bio) + req->data_len > PAGE_SIZE ||
144 bio_offset(rsp->bio) + rsp->data_len > PAGE_SIZE) {
145 shost_printk(KERN_ERR, shost,
146 "SMP request/response frame crosses page boundary");
147 goto out;
148 }
149
150 req_data = kzalloc(req->data_len, GFP_KERNEL);
151
152 /* make sure frame can always be built ... we copy
153 * back only the requested length */
154 resp_data = kzalloc(max(rsp->data_len, 128U), GFP_KERNEL);
155
156 if (!req_data || !resp_data) {
157 error = -ENOMEM;
158 goto out;
159 }
160
161 local_irq_disable();
162 buf = kmap_atomic(bio_page(req->bio), KM_USER0) + bio_offset(req->bio);
163 memcpy(req_data, buf, req->data_len);
164 kunmap_atomic(buf - bio_offset(req->bio), KM_USER0);
165 local_irq_enable();
166
167 if (req_data[0] != SMP_REQUEST)
168 goto out;
169
170 /* always succeeds ... even if we can't process the request
171 * the result is in the response frame */
172 error = 0;
173
174 /* set up default don't know response */
175 resp_data[0] = SMP_RESPONSE;
176 resp_data[1] = req_data[1];
177 resp_data[2] = SMP_RESP_FUNC_UNK;
178
179 switch (req_data[1]) {
180 case SMP_REPORT_GENERAL:
181 req->data_len -= 8;
182 resp_data_len -= 32;
183 resp_data[2] = SMP_RESP_FUNC_ACC;
184 resp_data[9] = sas_ha->num_phys;
185 break;
186
187 case SMP_REPORT_MANUF_INFO:
188 req->data_len -= 8;
189 resp_data_len -= 64;
190 resp_data[2] = SMP_RESP_FUNC_ACC;
191 memcpy(resp_data + 12, shost->hostt->name,
192 SAS_EXPANDER_VENDOR_ID_LEN);
193 memcpy(resp_data + 20, "libsas virt phy",
194 SAS_EXPANDER_PRODUCT_ID_LEN);
195 break;
196
197 case SMP_READ_GPIO_REG:
198 /* FIXME: need GPIO support in the transport class */
199 break;
200
201 case SMP_DISCOVER:
202 req->data_len =- 16;
203 if (req->data_len < 0) {
204 req->data_len = 0;
205 error = -EINVAL;
206 goto out;
207 }
208 resp_data_len -= 56;
209 sas_host_smp_discover(sas_ha, resp_data, req_data[9]);
210 break;
211
212 case SMP_REPORT_PHY_ERR_LOG:
213 /* FIXME: could implement this with additional
214 * libsas callbacks providing the HW supports it */
215 break;
216
217 case SMP_REPORT_PHY_SATA:
218 req->data_len =- 16;
219 if (req->data_len < 0) {
220 req->data_len = 0;
221 error = -EINVAL;
222 goto out;
223 }
224 resp_data_len -= 60;
225 sas_report_phy_sata(sas_ha, resp_data, req_data[9]);
226 break;
227
228 case SMP_REPORT_ROUTE_INFO:
229 /* Can't implement; hosts have no routes */
230 break;
231
232 case SMP_WRITE_GPIO_REG:
233 /* FIXME: need GPIO support in the transport class */
234 break;
235
236 case SMP_CONF_ROUTE_INFO:
237 /* Can't implement; hosts have no routes */
238 break;
239
240 case SMP_PHY_CONTROL:
241 req->data_len =- 44;
242 if (req->data_len < 0) {
243 req->data_len = 0;
244 error = -EINVAL;
245 goto out;
246 }
247 resp_data_len -= 8;
248 sas_phy_control(sas_ha, req_data[9], req_data[10],
249 req_data[32] >> 4, req_data[33] >> 4,
250 resp_data);
251 break;
252
253 case SMP_PHY_TEST_FUNCTION:
254 /* FIXME: should this be implemented? */
255 break;
256
257 default:
258 /* probably a 2.0 function */
259 break;
260 }
261
262 local_irq_disable();
263 buf = kmap_atomic(bio_page(rsp->bio), KM_USER0) + bio_offset(rsp->bio);
264 memcpy(buf, resp_data, rsp->data_len);
265 flush_kernel_dcache_page(bio_page(rsp->bio));
266 kunmap_atomic(buf - bio_offset(rsp->bio), KM_USER0);
267 local_irq_enable();
268 rsp->data_len = resp_data_len;
269
270 out:
271 kfree(req_data);
272 kfree(resp_data);
273 return error;
274}
drivers/scsi/libsas/sas_internal.h+15−1
@@ -45,7 +45,7 @@ · 44 unmodified lines
45void sas_scsi_recover_host(struct Scsi_Host *shost);45void sas_scsi_recover_host(struct Scsi_Host *shost);
46 46
47int sas_show_class(enum sas_class class, char *buf);47int sas_show_class(enum sas_class class, char *buf);
48int sas_show_proto(enum sas_proto proto, char *buf);48int sas_show_proto(enum sas_protocol proto, char *buf);
49int sas_show_linkrate(enum sas_linkrate linkrate, char *buf);49int sas_show_linkrate(enum sas_linkrate linkrate, char *buf);
50int sas_show_oob_mode(enum sas_oob_mode oob_mode, char *buf);50int sas_show_oob_mode(enum sas_oob_mode oob_mode, char *buf);
51 51
@@ -80,6 +80,20 @@ struct domain_device *sas_find_dev_by_rphy(struct sas_rphy *rphy); · 28 unmodified lines
80 80
81void sas_hae_reset(struct work_struct *work);81void sas_hae_reset(struct work_struct *work);
82 82
83#ifdef CONFIG_SCSI_SAS_HOST_SMP
84extern int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
85 struct request *rsp);
86#else
87static inline int sas_smp_host_handler(struct Scsi_Host *shost,
88 struct request *req,
89 struct request *rsp)
90{
91 shost_printk(KERN_ERR, shost,
92 "Cannot send SMP to a sas host (not enabled in CONFIG)\n");
93 return -EINVAL;
94}
95#endif
96
83static inline void sas_queue_event(int event, spinlock_t *lock,97static inline void sas_queue_event(int event, spinlock_t *lock,
84 unsigned long *pending,98 unsigned long *pending,
85 struct work_struct *work,99 struct work_struct *work,
drivers/scsi/libsas/sas_scsi_host.c+6−3
@@ -108,7 +108,7 @@ static void sas_scsi_task_done(struct sas_task *task) · 107 unmodified lines
108 break;108 break;
109 case SAM_CHECK_COND:109 case SAM_CHECK_COND:
110 memcpy(sc->sense_buffer, ts->buf,110 memcpy(sc->sense_buffer, ts->buf,
111 max(SCSI_SENSE_BUFFERSIZE, ts->buf_valid_size));111 min(SCSI_SENSE_BUFFERSIZE, ts->buf_valid_size));
112 stat = SAM_CHECK_COND;112 stat = SAM_CHECK_COND;
113 break;113 break;
114 default:114 default:
@@ -148,7 +148,6 @@ static struct sas_task *sas_create_task(struct scsi_cmnd *cmd, · 33 unmodified lines
148 if (!task)148 if (!task)
149 return NULL;149 return NULL;
150 150
151 *(u32 *)cmd->sense_buffer = 0;
152 task->uldd_task = cmd;151 task->uldd_task = cmd;
153 ASSIGN_SAS_TASK(cmd, task);152 ASSIGN_SAS_TASK(cmd, task);
154 153
@@ -200,6 +199,10 @@ int sas_queue_up(struct sas_task *task) · 45 unmodified lines
200 */199 */
201int sas_queuecommand(struct scsi_cmnd *cmd,200int sas_queuecommand(struct scsi_cmnd *cmd,
202 void (*scsi_done)(struct scsi_cmnd *))201 void (*scsi_done)(struct scsi_cmnd *))
202 __releases(host->host_lock)
203 __acquires(dev->sata_dev.ap->lock)
204 __releases(dev->sata_dev.ap->lock)
205 __acquires(host->host_lock)
203{206{
204 int res = 0;207 int res = 0;
205 struct domain_device *dev = cmd_to_domain_dev(cmd);208 struct domain_device *dev = cmd_to_domain_dev(cmd);
@@ -410,7 +413,7 @@ static int sas_recover_I_T(struct domain_device *dev) · 204 unmodified lines
410}413}
411 414
412/* Find the sas_phy that's attached to this device */415/* Find the sas_phy that's attached to this device */
413struct sas_phy *find_local_sas_phy(struct domain_device *dev)416static struct sas_phy *find_local_sas_phy(struct domain_device *dev)
414{417{
415 struct domain_device *pdev = dev->parent;418 struct domain_device *pdev = dev->parent;
416 struct ex_phy *exphy = NULL;419 struct ex_phy *exphy = NULL;
drivers/scsi/libsas/sas_task.c+36−0
@@ -0,0 +1,36 @@
1#include <linux/kernel.h>
2#include <scsi/sas.h>
3#include <scsi/libsas.h>
4
5/* fill task_status_struct based on SSP response frame */
6void sas_ssp_task_response(struct device *dev, struct sas_task *task,
7 struct ssp_response_iu *iu)
8{
9 struct task_status_struct *tstat = &task->task_status;
10
11 tstat->resp = SAS_TASK_COMPLETE;
12
13 if (iu->datapres == 0)
14 tstat->stat = iu->status;
15 else if (iu->datapres == 1)
16 tstat->stat = iu->resp_data[3];
17 else if (iu->datapres == 2) {
18 tstat->stat = SAM_CHECK_COND;
19 tstat->buf_valid_size =
20 min_t(int, SAS_STATUS_BUF_SIZE,
21 be32_to_cpu(iu->sense_data_len));
22 memcpy(tstat->buf, iu->sense_data, tstat->buf_valid_size);
23
24 if (iu->status != SAM_CHECK_COND)
25 dev_printk(KERN_WARNING, dev,
26 "dev %llx sent sense data, but "
27 "stat(%x) is not CHECK CONDITION\n",
28 SAS_ADDR(task->dev->sas_addr),
29 iu->status);
30 }
31 else
32 /* when datapres contains corrupt/unknown value... */
33 tstat->stat = SAM_CHECK_COND;
34}
35EXPORT_SYMBOL_GPL(sas_ssp_task_response);
36
drivers/scsi/libsrp.c+12−11
@@ -192,18 +192,18 @@ static int srp_direct_data(struct scsi_cmnd *sc, struct srp_direct_buf *md, · 191 unmodified lines
192 192
193 if (dma_map) {193 if (dma_map) {
194 iue = (struct iu_entry *) sc->SCp.ptr;194 iue = (struct iu_entry *) sc->SCp.ptr;
195 sg = sc->request_buffer;195 sg = scsi_sglist(sc);
196 196
197 dprintk("%p %u %u %d\n", iue, sc->request_bufflen,197 dprintk("%p %u %u %d\n", iue, scsi_bufflen(sc),
198 md->len, sc->use_sg);198 md->len, scsi_sg_count(sc));
199 199
200 nsg = dma_map_sg(iue->target->dev, sg, sc->use_sg,200 nsg = dma_map_sg(iue->target->dev, sg, scsi_sg_count(sc),
201 DMA_BIDIRECTIONAL);201 DMA_BIDIRECTIONAL);
202 if (!nsg) {202 if (!nsg) {
203 printk("fail to map %p %d\n", iue, sc->use_sg);203 printk("fail to map %p %d\n", iue, scsi_sg_count(sc));
204 return 0;204 return 0;
205 }205 }
206 len = min(sc->request_bufflen, md->len);206 len = min(scsi_bufflen(sc), md->len);
207 } else207 } else
208 len = md->len;208 len = md->len;
209 209
@@ -229,10 +229,10 @@ static int srp_indirect_data(struct scsi_cmnd *sc, struct srp_cmd *cmd, · 19 unmodified lines
229 229
230 if (dma_map || ext_desc) {230 if (dma_map || ext_desc) {
231 iue = (struct iu_entry *) sc->SCp.ptr;231 iue = (struct iu_entry *) sc->SCp.ptr;
232 sg = sc->request_buffer;232 sg = scsi_sglist(sc);
233 233
234 dprintk("%p %u %u %d %d\n",234 dprintk("%p %u %u %d %d\n",
235 iue, sc->request_bufflen, id->len,235 iue, scsi_bufflen(sc), id->len,
236 cmd->data_in_desc_cnt, cmd->data_out_desc_cnt);236 cmd->data_in_desc_cnt, cmd->data_out_desc_cnt);
237 }237 }
238 238
@@ -268,13 +268,14 @@ static int srp_indirect_data(struct scsi_cmnd *sc, struct srp_cmd *cmd, · 29 unmodified lines
268 268
269rdma:269rdma:
270 if (dma_map) {270 if (dma_map) {
271 nsg = dma_map_sg(iue->target->dev, sg, sc->use_sg, DMA_BIDIRECTIONAL);271 nsg = dma_map_sg(iue->target->dev, sg, scsi_sg_count(sc),
272 DMA_BIDIRECTIONAL);
272 if (!nsg) {273 if (!nsg) {
273 eprintk("fail to map %p %d\n", iue, sc->use_sg);274 eprintk("fail to map %p %d\n", iue, scsi_sg_count(sc));
274 err = -EIO;275 err = -EIO;
275 goto free_mem;276 goto free_mem;
276 }277 }
277 len = min(sc->request_bufflen, id->len);278 len = min(scsi_bufflen(sc), id->len);
278 } else279 } else
279 len = id->len;280 len = id->len;
280 281
drivers/scsi/lpfc/lpfc.h+46−7
@@ -29,7 +29,8 @@ struct lpfc_sli2_slim; · 28 unmodified lines
29#define LPFC_MAX_NS_RETRY 3 /* Number of retry attempts to contact29#define LPFC_MAX_NS_RETRY 3 /* Number of retry attempts to contact
30 the NameServer before giving up. */30 the NameServer before giving up. */
31#define LPFC_CMD_PER_LUN 3 /* max outstanding cmds per lun */31#define LPFC_CMD_PER_LUN 3 /* max outstanding cmds per lun */
32#define LPFC_SG_SEG_CNT 64 /* sg element count per scsi cmnd */32#define LPFC_DEFAULT_SG_SEG_CNT 64 /* sg element count per scsi cmnd */
33#define LPFC_MAX_SG_SEG_CNT 256 /* sg element count per scsi cmnd */
33#define LPFC_IOCB_LIST_CNT 2250 /* list of IOCBs for fast-path usage. */34#define LPFC_IOCB_LIST_CNT 2250 /* list of IOCBs for fast-path usage. */
34#define LPFC_Q_RAMP_UP_INTERVAL 120 /* lun q_depth ramp up interval */35#define LPFC_Q_RAMP_UP_INTERVAL 120 /* lun q_depth ramp up interval */
35 36
@@ -68,6 +69,7 @@ struct lpfc_dmabuf { · 32 unmodified lines
68 struct list_head list;69 struct list_head list;
69 void *virt; /* virtual address ptr */70 void *virt; /* virtual address ptr */
70 dma_addr_t phys; /* mapped address */71 dma_addr_t phys; /* mapped address */
72 uint32_t buffer_tag; /* used for tagged queue ring */
71};73};
72 74
73struct lpfc_dma_pool {75struct lpfc_dma_pool {
@@ -272,10 +274,16 @@ struct lpfc_vport { · 198 unmodified lines
272#define FC_ABORT_DISCOVERY 0x8000 /* we want to abort discovery */274#define FC_ABORT_DISCOVERY 0x8000 /* we want to abort discovery */
273#define FC_NDISC_ACTIVE 0x10000 /* NPort discovery active */275#define FC_NDISC_ACTIVE 0x10000 /* NPort discovery active */
274#define FC_BYPASSED_MODE 0x20000 /* NPort is in bypassed mode */276#define FC_BYPASSED_MODE 0x20000 /* NPort is in bypassed mode */
275#define FC_RFF_NOT_SUPPORTED 0x40000 /* RFF_ID was rejected by switch */
276#define FC_VPORT_NEEDS_REG_VPI 0x80000 /* Needs to have its vpi registered */277#define FC_VPORT_NEEDS_REG_VPI 0x80000 /* Needs to have its vpi registered */
277#define FC_RSCN_DEFERRED 0x100000 /* A deferred RSCN being processed */278#define FC_RSCN_DEFERRED 0x100000 /* A deferred RSCN being processed */
278 279
280 uint32_t ct_flags;
281#define FC_CT_RFF_ID 0x1 /* RFF_ID accepted by switch */
282#define FC_CT_RNN_ID 0x2 /* RNN_ID accepted by switch */
283#define FC_CT_RSNN_NN 0x4 /* RSNN_NN accepted by switch */
284#define FC_CT_RSPN_ID 0x8 /* RSPN_ID accepted by switch */
285#define FC_CT_RFT_ID 0x10 /* RFT_ID accepted by switch */
286
279 struct list_head fc_nodes;287 struct list_head fc_nodes;
280 288
281 /* Keep counters for the number of entries in each list. */289 /* Keep counters for the number of entries in each list. */
@@ -344,6 +352,7 @@ struct lpfc_vport { · 62 unmodified lines
344 uint32_t cfg_discovery_threads;352 uint32_t cfg_discovery_threads;
345 uint32_t cfg_log_verbose;353 uint32_t cfg_log_verbose;
346 uint32_t cfg_max_luns;354 uint32_t cfg_max_luns;
355 uint32_t cfg_enable_da_id;
347 356
348 uint32_t dev_loss_tmo_changed;357 uint32_t dev_loss_tmo_changed;
349 358
@@ -360,6 +369,7 @@ struct lpfc_vport { · 10 unmodified lines
360 369
361struct hbq_s {370struct hbq_s {
362 uint16_t entry_count; /* Current number of HBQ slots */371 uint16_t entry_count; /* Current number of HBQ slots */
372 uint16_t buffer_count; /* Current number of buffers posted */
363 uint32_t next_hbqPutIdx; /* Index to next HBQ slot to use */373 uint32_t next_hbqPutIdx; /* Index to next HBQ slot to use */
364 uint32_t hbqPutIdx; /* HBQ slot to use */374 uint32_t hbqPutIdx; /* HBQ slot to use */
365 uint32_t local_hbqGetIdx; /* Local copy of Get index from Port */375 uint32_t local_hbqGetIdx; /* Local copy of Get index from Port */
@@ -377,6 +387,11 @@ struct hbq_s { · 11 unmodified lines
377#define LPFC_ELS_HBQ 0387#define LPFC_ELS_HBQ 0
378#define LPFC_EXTRA_HBQ 1388#define LPFC_EXTRA_HBQ 1
379 389
390enum hba_temp_state {
391 HBA_NORMAL_TEMP,
392 HBA_OVER_TEMP
393};
394
380struct lpfc_hba {395struct lpfc_hba {
381 struct lpfc_sli sli;396 struct lpfc_sli sli;
382 uint32_t sli_rev; /* SLI2 or SLI3 */397 uint32_t sli_rev; /* SLI2 or SLI3 */
@@ -457,7 +472,8 @@ struct lpfc_hba { · 74 unmodified lines
457 uint64_t cfg_soft_wwnn;472 uint64_t cfg_soft_wwnn;
458 uint64_t cfg_soft_wwpn;473 uint64_t cfg_soft_wwpn;
459 uint32_t cfg_hba_queue_depth;474 uint32_t cfg_hba_queue_depth;
460 475 uint32_t cfg_enable_hba_reset;
476 uint32_t cfg_enable_hba_heartbeat;
461 477
462 lpfc_vpd_t vpd; /* vital product data */478 lpfc_vpd_t vpd; /* vital product data */
463 479
@@ -544,8 +560,7 @@ struct lpfc_hba { · 80 unmodified lines
544 struct list_head port_list;560 struct list_head port_list;
545 struct lpfc_vport *pport; /* physical lpfc_vport pointer */561 struct lpfc_vport *pport; /* physical lpfc_vport pointer */
546 uint16_t max_vpi; /* Maximum virtual nports */562 uint16_t max_vpi; /* Maximum virtual nports */
547#define LPFC_MAX_VPI 100 /* Max number of VPI supported */563#define LPFC_MAX_VPI 0xFFFF /* Max number of VPI supported */
548#define LPFC_MAX_VPORTS (LPFC_MAX_VPI+1)/* Max number of VPorts supported */
549 unsigned long *vpi_bmask; /* vpi allocation table */564 unsigned long *vpi_bmask; /* vpi allocation table */
550 565
551 /* Data structure used by fabric iocb scheduler */566 /* Data structure used by fabric iocb scheduler */
@@ -563,16 +578,30 @@ struct lpfc_hba { · 11 unmodified lines
563 struct dentry *hba_debugfs_root;578 struct dentry *hba_debugfs_root;
564 atomic_t debugfs_vport_count;579 atomic_t debugfs_vport_count;
565 struct dentry *debug_hbqinfo;580 struct dentry *debug_hbqinfo;
566 struct dentry *debug_dumpslim;581 struct dentry *debug_dumpHostSlim;
582 struct dentry *debug_dumpHBASlim;
567 struct dentry *debug_slow_ring_trc;583 struct dentry *debug_slow_ring_trc;
568 struct lpfc_debugfs_trc *slow_ring_trc;584 struct lpfc_debugfs_trc *slow_ring_trc;
569 atomic_t slow_ring_trc_cnt;585 atomic_t slow_ring_trc_cnt;
570#endif586#endif
571 587
588 /* Used for deferred freeing of ELS data buffers */
589 struct list_head elsbuf;
590 int elsbuf_cnt;
591 int elsbuf_prev_cnt;
592
593 uint8_t temp_sensor_support;
572 /* Fields used for heart beat. */594 /* Fields used for heart beat. */
573 unsigned long last_completion_time;595 unsigned long last_completion_time;
574 struct timer_list hb_tmofunc;596 struct timer_list hb_tmofunc;
575 uint8_t hb_outstanding;597 uint8_t hb_outstanding;
598 /*
599 * Following bit will be set for all buffer tags which are not
600 * associated with any HBQ.
601 */
602#define QUE_BUFTAG_BIT (1<<31)
603 uint32_t buffer_tag_count;
604 enum hba_temp_state over_temp_state;
576};605};
577 606
578static inline struct Scsi_Host *607static inline struct Scsi_Host *
@@ -598,5 +627,15 @@ lpfc_is_link_up(struct lpfc_hba *phba) · 19 unmodified lines
598 phba->link_state == LPFC_HBA_READY;627 phba->link_state == LPFC_HBA_READY;
599}628}
600 629
601#define FC_REG_DUMP_EVENT 0x10 /* Register for Dump events */630#define FC_REG_DUMP_EVENT 0x10 /* Register for Dump events */
631#define FC_REG_TEMPERATURE_EVENT 0x20 /* Register for temperature
632 event */
602 633
634struct temp_event {
635 uint32_t event_type;
636 uint32_t event_code;
637 uint32_t data;
638};
639#define LPFC_CRIT_TEMP 0x1
640#define LPFC_THRESHOLD_TEMP 0x2
641#define LPFC_NORMAL_TEMP 0x3
drivers/scsi/lpfc/lpfc_attr.c+191−26
@@ -1,7 +1,7 @@
1/*******************************************************************1/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2007 Emulex. All rights reserved. *4 * Copyright (C) 2004-2008 Emulex. All rights reserved. *
5 * EMULEX and SLI are trademarks of Emulex. *5 * EMULEX and SLI are trademarks of Emulex. *
6 * www.emulex.com *6 * www.emulex.com *
7 * Portions Copyright (C) 2004-2005 Christoph Hellwig *7 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
@@ -45,6 +45,10 @@ · 37 unmodified lines
45#define LPFC_MIN_DEVLOSS_TMO 145#define LPFC_MIN_DEVLOSS_TMO 1
46#define LPFC_MAX_DEVLOSS_TMO 25546#define LPFC_MAX_DEVLOSS_TMO 255
47 47
48#define LPFC_MAX_LINK_SPEED 8
49#define LPFC_LINK_SPEED_BITMAP 0x00000117
50#define LPFC_LINK_SPEED_STRING "0, 1, 2, 4, 8"
51
48static void52static void
49lpfc_jedec_to_ascii(int incr, char hdw[])53lpfc_jedec_to_ascii(int incr, char hdw[])
50{54{
@@ -85,6 +89,15 @@ lpfc_serialnum_show(struct class_device *cdev, char *buf) · 34 unmodified lines
85 return snprintf(buf, PAGE_SIZE, "%s\n",phba->SerialNumber);89 return snprintf(buf, PAGE_SIZE, "%s\n",phba->SerialNumber);
86}90}
87 91
92static ssize_t
93lpfc_temp_sensor_show(struct class_device *cdev, char *buf)
94{
95 struct Scsi_Host *shost = class_to_shost(cdev);
96 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
97 struct lpfc_hba *phba = vport->phba;
98 return snprintf(buf, PAGE_SIZE, "%d\n",phba->temp_sensor_support);
99}
100
88static ssize_t101static ssize_t
89lpfc_modeldesc_show(struct class_device *cdev, char *buf)102lpfc_modeldesc_show(struct class_device *cdev, char *buf)
90{103{
@@ -178,12 +191,9 @@ lpfc_state_show(struct class_device *cdev, char *buf) · 87 unmodified lines
178 case LPFC_LINK_UP:191 case LPFC_LINK_UP:
179 case LPFC_CLEAR_LA:192 case LPFC_CLEAR_LA:
180 case LPFC_HBA_READY:193 case LPFC_HBA_READY:
181 len += snprintf(buf + len, PAGE_SIZE-len, "Link Up - \n");194 len += snprintf(buf + len, PAGE_SIZE-len, "Link Up - ");
182 195
183 switch (vport->port_state) {196 switch (vport->port_state) {
184 len += snprintf(buf + len, PAGE_SIZE-len,
185 "initializing\n");
186 break;
187 case LPFC_LOCAL_CFG_LINK:197 case LPFC_LOCAL_CFG_LINK:
188 len += snprintf(buf + len, PAGE_SIZE-len,198 len += snprintf(buf + len, PAGE_SIZE-len,
189 "Configuring Link\n");199 "Configuring Link\n");
@@ -252,8 +262,7 @@ lpfc_issue_lip(struct Scsi_Host *shost) · 62 unmodified lines
252 int mbxstatus = MBXERR_ERROR;262 int mbxstatus = MBXERR_ERROR;
253 263
254 if ((vport->fc_flag & FC_OFFLINE_MODE) ||264 if ((vport->fc_flag & FC_OFFLINE_MODE) ||
255 (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) ||265 (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO))
256 (vport->port_state != LPFC_VPORT_READY))
257 return -EPERM;266 return -EPERM;
258 267
259 pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL);268 pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL);
@@ -305,12 +314,14 @@ lpfc_do_offline(struct lpfc_hba *phba, uint32_t type) · 45 unmodified lines
305 314
306 psli = &phba->sli;315 psli = &phba->sli;
307 316
317 /* Wait a little for things to settle down, but not
318 * long enough for dev loss timeout to expire.
319 */
308 for (i = 0; i < psli->num_rings; i++) {320 for (i = 0; i < psli->num_rings; i++) {
309 pring = &psli->ring[i];321 pring = &psli->ring[i];
310 /* The linkdown event takes 30 seconds to timeout. */
311 while (pring->txcmplq_cnt) {322 while (pring->txcmplq_cnt) {
312 msleep(10);323 msleep(10);
313 if (cnt++ > 3000) {324 if (cnt++ > 500) { /* 5 secs */
314 lpfc_printf_log(phba,325 lpfc_printf_log(phba,
315 KERN_WARNING, LOG_INIT,326 KERN_WARNING, LOG_INIT,
316 "0466 Outstanding IO when "327 "0466 Outstanding IO when "
@@ -336,6 +347,9 @@ lpfc_selective_reset(struct lpfc_hba *phba) · 19 unmodified lines
336 struct completion online_compl;347 struct completion online_compl;
337 int status = 0;348 int status = 0;
338 349
350 if (!phba->cfg_enable_hba_reset)
351 return -EIO;
352
339 status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);353 status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
340 354
341 if (status != 0)355 if (status != 0)
@@ -409,6 +423,8 @@ lpfc_board_mode_store(struct class_device *cdev, const char *buf, size_t count) · 67 unmodified lines
409 struct completion online_compl;423 struct completion online_compl;
410 int status=0;424 int status=0;
411 425
426 if (!phba->cfg_enable_hba_reset)
427 return -EACCES;
412 init_completion(&online_compl);428 init_completion(&online_compl);
413 429
414 if(strncmp(buf, "online", sizeof("online") - 1) == 0) {430 if(strncmp(buf, "online", sizeof("online") - 1) == 0) {
@@ -908,6 +924,8 @@ static CLASS_DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL); · 493 unmodified lines
908static CLASS_DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL);924static CLASS_DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL);
909static CLASS_DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL);925static CLASS_DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL);
910static CLASS_DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL);926static CLASS_DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL);
927static CLASS_DEVICE_ATTR(lpfc_temp_sensor, S_IRUGO, lpfc_temp_sensor_show,
928 NULL);
911 929
912 930
913static char *lpfc_soft_wwn_key = "C99G71SL8032A";931static char *lpfc_soft_wwn_key = "C99G71SL8032A";
@@ -971,6 +989,14 @@ lpfc_soft_wwpn_store(struct class_device *cdev, const char *buf, size_t count) · 57 unmodified lines
971 unsigned int i, j, cnt=count;989 unsigned int i, j, cnt=count;
972 u8 wwpn[8];990 u8 wwpn[8];
973 991
992 if (!phba->cfg_enable_hba_reset)
993 return -EACCES;
994 spin_lock_irq(&phba->hbalock);
995 if (phba->over_temp_state == HBA_OVER_TEMP) {
996 spin_unlock_irq(&phba->hbalock);
997 return -EACCES;
998 }
999 spin_unlock_irq(&phba->hbalock);
974 /* count may include a LF at end of string */1000 /* count may include a LF at end of string */
975 if (buf[cnt-1] == '\n')1001 if (buf[cnt-1] == '\n')
976 cnt--;1002 cnt--;
@@ -1102,7 +1128,13 @@ MODULE_PARM_DESC(lpfc_sli_mode, "SLI mode selector:" · 125 unmodified lines
1102 " 2 - select SLI-2 even on SLI-3 capable HBAs,"1128 " 2 - select SLI-2 even on SLI-3 capable HBAs,"
1103 " 3 - select SLI-3");1129 " 3 - select SLI-3");
1104 1130
1105LPFC_ATTR_R(enable_npiv, 0, 0, 1, "Enable NPIV functionality");1131int lpfc_enable_npiv = 0;
1132module_param(lpfc_enable_npiv, int, 0);
1133MODULE_PARM_DESC(lpfc_enable_npiv, "Enable NPIV functionality");
1134lpfc_param_show(enable_npiv);
1135lpfc_param_init(enable_npiv, 0, 0, 1);
1136static CLASS_DEVICE_ATTR(lpfc_enable_npiv, S_IRUGO,
1137 lpfc_enable_npiv_show, NULL);
1106 1138
1107/*1139/*
1108# lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear1140# lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear
@@ -1247,6 +1279,13 @@ static CLASS_DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR, · 138 unmodified lines
1247LPFC_VPORT_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffff,1279LPFC_VPORT_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffff,
1248 "Verbose logging bit-mask");1280 "Verbose logging bit-mask");
1249 1281
1282/*
1283# lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters
1284# objects that have been registered with the nameserver after login.
1285*/
1286LPFC_VPORT_ATTR_R(enable_da_id, 0, 0, 1,
1287 "Deregister nameserver objects before LOGO");
1288
1250/*1289/*
1251# lun_queue_depth: This parameter is used to limit the number of outstanding1290# lun_queue_depth: This parameter is used to limit the number of outstanding
1252# commands per FCP LUN. Value range is [1,128]. Default value is 30.1291# commands per FCP LUN. Value range is [1,128]. Default value is 30.
@@ -1369,7 +1408,33 @@ LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1, · 116 unmodified lines
1369# Set loop mode if you want to run as an NL_Port. Value range is [0,0x6].1408# Set loop mode if you want to run as an NL_Port. Value range is [0,0x6].
1370# Default value is 0.1409# Default value is 0.
1371*/1410*/
1372LPFC_ATTR_RW(topology, 0, 0, 6, "Select Fibre Channel topology");1411static int
1412lpfc_topology_set(struct lpfc_hba *phba, int val)
1413{
1414 int err;
1415 uint32_t prev_val;
1416 if (val >= 0 && val <= 6) {
1417 prev_val = phba->cfg_topology;
1418 phba->cfg_topology = val;
1419 err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport));
1420 if (err)
1421 phba->cfg_topology = prev_val;
1422 return err;
1423 }
1424 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
1425 "%d:0467 lpfc_topology attribute cannot be set to %d, "
1426 "allowed range is [0, 6]\n",
1427 phba->brd_no, val);
1428 return -EINVAL;
1429}
1430static int lpfc_topology = 0;
1431module_param(lpfc_topology, int, 0);
1432MODULE_PARM_DESC(lpfc_topology, "Select Fibre Channel topology");
1433lpfc_param_show(topology)
1434lpfc_param_init(topology, 0, 0, 6)
1435lpfc_param_store(topology)
1436static CLASS_DEVICE_ATTR(lpfc_topology, S_IRUGO | S_IWUSR,
1437 lpfc_topology_show, lpfc_topology_store);
1373 1438
1374/*1439/*
1375# lpfc_link_speed: Link speed selection for initializing the Fibre Channel1440# lpfc_link_speed: Link speed selection for initializing the Fibre Channel
@@ -1381,7 +1446,59 @@ LPFC_ATTR_RW(topology, 0, 0, 6, "Select Fibre Channel topology"); · 5 unmodified lines
1381# 8 = 8 Gigabaud1446# 8 = 8 Gigabaud
1382# Value range is [0,8]. Default value is 0.1447# Value range is [0,8]. Default value is 0.
1383*/1448*/
1384LPFC_ATTR_R(link_speed, 0, 0, 8, "Select link speed");1449static int
1450lpfc_link_speed_set(struct lpfc_hba *phba, int val)
1451{
1452 int err;
1453 uint32_t prev_val;
1454
1455 if (((val == LINK_SPEED_1G) && !(phba->lmt & LMT_1Gb)) ||
1456 ((val == LINK_SPEED_2G) && !(phba->lmt & LMT_2Gb)) ||
1457 ((val == LINK_SPEED_4G) && !(phba->lmt & LMT_4Gb)) ||
1458 ((val == LINK_SPEED_8G) && !(phba->lmt & LMT_8Gb)) ||
1459 ((val == LINK_SPEED_10G) && !(phba->lmt & LMT_10Gb)))
1460 return -EINVAL;
1461
1462 if ((val >= 0 && val <= LPFC_MAX_LINK_SPEED)
1463 && (LPFC_LINK_SPEED_BITMAP & (1 << val))) {
1464 prev_val = phba->cfg_link_speed;
1465 phba->cfg_link_speed = val;
1466 err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport));
1467 if (err)
1468 phba->cfg_link_speed = prev_val;
1469 return err;
1470 }
1471
1472 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
1473 "%d:0469 lpfc_link_speed attribute cannot be set to %d, "
1474 "allowed range is [0, 8]\n",
1475 phba->brd_no, val);
1476 return -EINVAL;
1477}
1478
1479static int lpfc_link_speed = 0;
1480module_param(lpfc_link_speed, int, 0);
1481MODULE_PARM_DESC(lpfc_link_speed, "Select link speed");
1482lpfc_param_show(link_speed)
1483static int
1484lpfc_link_speed_init(struct lpfc_hba *phba, int val)
1485{
1486 if ((val >= 0 && val <= LPFC_MAX_LINK_SPEED)
1487 && (LPFC_LINK_SPEED_BITMAP & (1 << val))) {
1488 phba->cfg_link_speed = val;
1489 return 0;
1490 }
1491 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
1492 "0454 lpfc_link_speed attribute cannot "
1493 "be set to %d, allowed values are "
1494 "["LPFC_LINK_SPEED_STRING"]\n", val);
1495 phba->cfg_link_speed = 0;
1496 return -EINVAL;
1497}
1498
1499lpfc_param_store(link_speed)
1500static CLASS_DEVICE_ATTR(lpfc_link_speed, S_IRUGO | S_IWUSR,
1501 lpfc_link_speed_show, lpfc_link_speed_store);
1385 1502
1386/*1503/*
1387# lpfc_fcp_class: Determines FC class to use for the FCP protocol.1504# lpfc_fcp_class: Determines FC class to use for the FCP protocol.
@@ -1479,7 +1596,30 @@ LPFC_ATTR_RW(poll_tmo, 10, 1, 255, · 91 unmodified lines
1479*/1596*/
1480LPFC_ATTR_R(use_msi, 0, 0, 1, "Use Message Signaled Interrupts, if possible");1597LPFC_ATTR_R(use_msi, 0, 0, 1, "Use Message Signaled Interrupts, if possible");
1481 1598
1599/*
1600# lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware.
1601# 0 = HBA resets disabled
1602# 1 = HBA resets enabled (default)
1603# Value range is [0,1]. Default value is 1.
1604*/
1605LPFC_ATTR_R(enable_hba_reset, 1, 0, 1, "Enable HBA resets from the driver.");
1606
1607/*
1608# lpfc_enable_hba_heartbeat: Enable HBA heartbeat timer..
1609# 0 = HBA Heartbeat disabled
1610# 1 = HBA Heartbeat enabled (default)
1611# Value range is [0,1]. Default value is 1.
1612*/
1613LPFC_ATTR_R(enable_hba_heartbeat, 1, 0, 1, "Enable HBA Heartbeat.");
1482 1614
1615/*
1616 * lpfc_sg_seg_cnt: Initial Maximum DMA Segment Count
1617 * This value can be set to values between 64 and 256. The default value is
1618 * 64, but may be increased to allow for larger Max I/O sizes. The scsi layer
1619 * will be allowed to request I/Os of sizes up to (MAX_SEG_COUNT * SEG_SIZE).
1620 */
1621LPFC_ATTR_R(sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, LPFC_DEFAULT_SG_SEG_CNT,
1622 LPFC_MAX_SG_SEG_CNT, "Max Scatter Gather Segment Count");
1483 1623
1484struct class_device_attribute *lpfc_hba_attrs[] = {1624struct class_device_attribute *lpfc_hba_attrs[] = {
1485 &class_device_attr_info,1625 &class_device_attr_info,
@@ -1494,6 +1634,7 @@ struct class_device_attribute *lpfc_hba_attrs[] = { · 8 unmodified lines
1494 &class_device_attr_state,1634 &class_device_attr_state,
1495 &class_device_attr_num_discovered_ports,1635 &class_device_attr_num_discovered_ports,
1496 &class_device_attr_lpfc_drvr_version,1636 &class_device_attr_lpfc_drvr_version,
1637 &class_device_attr_lpfc_temp_sensor,
1497 &class_device_attr_lpfc_log_verbose,1638 &class_device_attr_lpfc_log_verbose,
1498 &class_device_attr_lpfc_lun_queue_depth,1639 &class_device_attr_lpfc_lun_queue_depth,
1499 &class_device_attr_lpfc_hba_queue_depth,1640 &class_device_attr_lpfc_hba_queue_depth,
@@ -1530,6 +1671,9 @@ struct class_device_attribute *lpfc_hba_attrs[] = { · 30 unmodified lines
1530 &class_device_attr_lpfc_soft_wwnn,1671 &class_device_attr_lpfc_soft_wwnn,
1531 &class_device_attr_lpfc_soft_wwpn,1672 &class_device_attr_lpfc_soft_wwpn,
1532 &class_device_attr_lpfc_soft_wwn_enable,1673 &class_device_attr_lpfc_soft_wwn_enable,
1674 &class_device_attr_lpfc_enable_hba_reset,
1675 &class_device_attr_lpfc_enable_hba_heartbeat,
1676 &class_device_attr_lpfc_sg_seg_cnt,
1533 NULL,1677 NULL,
1534};1678};
1535 1679
@@ -1552,6 +1696,7 @@ struct class_device_attribute *lpfc_vport_attrs[] = { · 16 unmodified lines
1552 &class_device_attr_lpfc_max_luns,1696 &class_device_attr_lpfc_max_luns,
1553 &class_device_attr_nport_evt_cnt,1697 &class_device_attr_nport_evt_cnt,
1554 &class_device_attr_npiv_info,1698 &class_device_attr_npiv_info,
1699 &class_device_attr_lpfc_enable_da_id,
1555 NULL,1700 NULL,
1556};1701};
1557 1702
@@ -1727,13 +1872,18 @@ sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr, · 169 unmodified lines
1727 1872
1728 spin_lock_irq(&phba->hbalock);1873 spin_lock_irq(&phba->hbalock);
1729 1874
1875 if (phba->over_temp_state == HBA_OVER_TEMP) {
1876 sysfs_mbox_idle(phba);
1877 spin_unlock_irq(&phba->hbalock);
1878 return -EACCES;
1879 }
1880
1730 if (off == 0 &&1881 if (off == 0 &&
1731 phba->sysfs_mbox.state == SMBOX_WRITING &&1882 phba->sysfs_mbox.state == SMBOX_WRITING &&
1732 phba->sysfs_mbox.offset >= 2 * sizeof(uint32_t)) {1883 phba->sysfs_mbox.offset >= 2 * sizeof(uint32_t)) {
1733 1884
1734 switch (phba->sysfs_mbox.mbox->mb.mbxCommand) {1885 switch (phba->sysfs_mbox.mbox->mb.mbxCommand) {
1735 /* Offline only */1886 /* Offline only */
1736 case MBX_WRITE_NV:
1737 case MBX_INIT_LINK:1887 case MBX_INIT_LINK:
1738 case MBX_DOWN_LINK:1888 case MBX_DOWN_LINK:
1739 case MBX_CONFIG_LINK:1889 case MBX_CONFIG_LINK:
@@ -1744,9 +1894,7 @@ sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr, · 4 unmodified lines
1744 case MBX_DUMP_CONTEXT:1894 case MBX_DUMP_CONTEXT:
1745 case MBX_RUN_DIAGS:1895 case MBX_RUN_DIAGS:
1746 case MBX_RESTART:1896 case MBX_RESTART:
1747 case MBX_FLASH_WR_ULA:
1748 case MBX_SET_MASK:1897 case MBX_SET_MASK:
1749 case MBX_SET_SLIM:
1750 case MBX_SET_DEBUG:1898 case MBX_SET_DEBUG:
1751 if (!(vport->fc_flag & FC_OFFLINE_MODE)) {1899 if (!(vport->fc_flag & FC_OFFLINE_MODE)) {
1752 printk(KERN_WARNING "mbox_read:Command 0x%x "1900 printk(KERN_WARNING "mbox_read:Command 0x%x "
@@ -1756,6 +1904,8 @@ sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr, · 3 unmodified lines
1756 spin_unlock_irq(&phba->hbalock);1904 spin_unlock_irq(&phba->hbalock);
1757 return -EPERM;1905 return -EPERM;
1758 }1906 }
1907 case MBX_WRITE_NV:
1908 case MBX_WRITE_VPARMS:
1759 case MBX_LOAD_SM:1909 case MBX_LOAD_SM:
1760 case MBX_READ_NV:1910 case MBX_READ_NV:
1761 case MBX_READ_CONFIG:1911 case MBX_READ_CONFIG:
@@ -1772,6 +1922,8 @@ sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr, · 10 unmodified lines
1772 case MBX_LOAD_EXP_ROM:1922 case MBX_LOAD_EXP_ROM:
1773 case MBX_BEACON:1923 case MBX_BEACON:
1774 case MBX_DEL_LD_ENTRY:1924 case MBX_DEL_LD_ENTRY:
1925 case MBX_SET_VARIABLE:
1926 case MBX_WRITE_WWN:
1775 break;1927 break;
1776 case MBX_READ_SPARM64:1928 case MBX_READ_SPARM64:
1777 case MBX_READ_LA:1929 case MBX_READ_LA:
@@ -1793,6 +1945,17 @@ sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr, · 15 unmodified lines
1793 return -EPERM;1945 return -EPERM;
1794 }1946 }
1795 1947
1948 /* If HBA encountered an error attention, allow only DUMP
1949 * mailbox command until the HBA is restarted.
1950 */
1951 if ((phba->pport->stopped) &&
1952 (phba->sysfs_mbox.mbox->mb.mbxCommand
1953 != MBX_DUMP_MEMORY)) {
1954 sysfs_mbox_idle(phba);
1955 spin_unlock_irq(&phba->hbalock);
1956 return -EPERM;
1957 }
1958
1796 phba->sysfs_mbox.mbox->vport = vport;1959 phba->sysfs_mbox.mbox->vport = vport;
1797 1960
1798 if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) {1961 if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) {
@@ -1993,7 +2156,8 @@ lpfc_get_host_speed(struct Scsi_Host *shost) · 194 unmodified lines
1993 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;2156 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
1994 break;2157 break;
1995 }2158 }
1996 }2159 } else
2160 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
1997 2161
1998 spin_unlock_irq(shost->host_lock);2162 spin_unlock_irq(shost->host_lock);
1999}2163}
@@ -2013,7 +2177,7 @@ lpfc_get_host_fabric_name (struct Scsi_Host *shost) · 13 unmodified lines
2013 node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn);2177 node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn);
2014 else2178 else
2015 /* fabric is local port if there is no F/FL_Port */2179 /* fabric is local port if there is no F/FL_Port */
2016 node_name = wwn_to_u64(vport->fc_nodename.u.wwn);2180 node_name = 0;
2017 2181
2018 spin_unlock_irq(shost->host_lock);2182 spin_unlock_irq(shost->host_lock);
2019 2183
@@ -2337,8 +2501,6 @@ struct fc_function_template lpfc_transport_functions = { · 317 unmodified lines
2337 .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk,2501 .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk,
2338 .terminate_rport_io = lpfc_terminate_rport_io,2502 .terminate_rport_io = lpfc_terminate_rport_io,
2339 2503
2340 .vport_create = lpfc_vport_create,
2341 .vport_delete = lpfc_vport_delete,
2342 .dd_fcvport_size = sizeof(struct lpfc_vport *),2504 .dd_fcvport_size = sizeof(struct lpfc_vport *),
2343};2505};
2344 2506
@@ -2414,21 +2576,23 @@ lpfc_get_cfgparam(struct lpfc_hba *phba) · 69 unmodified lines
2414 lpfc_poll_tmo_init(phba, lpfc_poll_tmo);2576 lpfc_poll_tmo_init(phba, lpfc_poll_tmo);
2415 lpfc_enable_npiv_init(phba, lpfc_enable_npiv);2577 lpfc_enable_npiv_init(phba, lpfc_enable_npiv);
2416 lpfc_use_msi_init(phba, lpfc_use_msi);2578 lpfc_use_msi_init(phba, lpfc_use_msi);
2579 lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset);
2580 lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat);
2417 phba->cfg_poll = lpfc_poll;2581 phba->cfg_poll = lpfc_poll;
2418 phba->cfg_soft_wwnn = 0L;2582 phba->cfg_soft_wwnn = 0L;
2419 phba->cfg_soft_wwpn = 0L;2583 phba->cfg_soft_wwpn = 0L;
2420 /*2584 lpfc_sg_seg_cnt_init(phba, lpfc_sg_seg_cnt);
2421 * The total number of segments is the configuration value plus 22585 /* Also reinitialize the host templates with new values. */
2422 * since the IOCB need a command and response bde.2586 lpfc_vport_template.sg_tablesize = phba->cfg_sg_seg_cnt;
2423 */2587 lpfc_template.sg_tablesize = phba->cfg_sg_seg_cnt;
2424 phba->cfg_sg_seg_cnt = LPFC_SG_SEG_CNT + 2;
2425 /*2588 /*
2426 * Since the sg_tablesize is module parameter, the sg_dma_buf_size2589 * Since the sg_tablesize is module parameter, the sg_dma_buf_size
2427 * used to create the sg_dma_buf_pool must be dynamically calculated2590 * used to create the sg_dma_buf_pool must be dynamically calculated.
2591 * 2 segments are added since the IOCB needs a command and response bde.
2428 */2592 */
2429 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) +2593 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) +
2430 sizeof(struct fcp_rsp) +2594 sizeof(struct fcp_rsp) +
2431 (phba->cfg_sg_seg_cnt * sizeof(struct ulp_bde64));2595 ((phba->cfg_sg_seg_cnt + 2) * sizeof(struct ulp_bde64));
2432 lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth);2596 lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth);
2433 return;2597 return;
2434}2598}
@@ -2448,5 +2612,6 @@ lpfc_get_vport_cfgparam(struct lpfc_vport *vport) · 13 unmodified lines
2448 lpfc_discovery_threads_init(vport, lpfc_discovery_threads);2612 lpfc_discovery_threads_init(vport, lpfc_discovery_threads);
2449 lpfc_max_luns_init(vport, lpfc_max_luns);2613 lpfc_max_luns_init(vport, lpfc_max_luns);
2450 lpfc_scan_down_init(vport, lpfc_scan_down);2614 lpfc_scan_down_init(vport, lpfc_scan_down);
2615 lpfc_enable_da_id_init(vport, lpfc_enable_da_id);
2451 return;2616 return;
2452}2617}
drivers/scsi/lpfc/lpfc_crtn.h+14−19
@@ -23,6 +23,8 @@ typedef int (*node_filter)(struct lpfc_nodelist *ndlp, void *param); · 22 unmodified lines
23struct fc_rport;23struct fc_rport;
24void lpfc_dump_mem(struct lpfc_hba *, LPFC_MBOXQ_t *, uint16_t);24void lpfc_dump_mem(struct lpfc_hba *, LPFC_MBOXQ_t *, uint16_t);
25void lpfc_read_nv(struct lpfc_hba *, LPFC_MBOXQ_t *);25void lpfc_read_nv(struct lpfc_hba *, LPFC_MBOXQ_t *);
26void lpfc_config_async(struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t);
27
26void lpfc_heart_beat(struct lpfc_hba *, LPFC_MBOXQ_t *);28void lpfc_heart_beat(struct lpfc_hba *, LPFC_MBOXQ_t *);
27int lpfc_read_la(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb,29int lpfc_read_la(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb,
28 struct lpfc_dmabuf *mp);30 struct lpfc_dmabuf *mp);
@@ -43,9 +45,9 @@ void lpfc_init_link(struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t, uint32_t); · 14 unmodified lines
43struct lpfc_vport *lpfc_find_vport_by_did(struct lpfc_hba *, uint32_t);45struct lpfc_vport *lpfc_find_vport_by_did(struct lpfc_hba *, uint32_t);
44void lpfc_cleanup_rpis(struct lpfc_vport *vport, int remove);46void lpfc_cleanup_rpis(struct lpfc_vport *vport, int remove);
45int lpfc_linkdown(struct lpfc_hba *);47int lpfc_linkdown(struct lpfc_hba *);
48void lpfc_port_link_failure(struct lpfc_vport *);
46void lpfc_mbx_cmpl_read_la(struct lpfc_hba *, LPFC_MBOXQ_t *);49void lpfc_mbx_cmpl_read_la(struct lpfc_hba *, LPFC_MBOXQ_t *);
47 50
48void lpfc_mbx_cmpl_clear_la(struct lpfc_hba *, LPFC_MBOXQ_t *);
49void lpfc_mbx_cmpl_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *);51void lpfc_mbx_cmpl_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *);
50void lpfc_mbx_cmpl_dflt_rpi(struct lpfc_hba *, LPFC_MBOXQ_t *);52void lpfc_mbx_cmpl_dflt_rpi(struct lpfc_hba *, LPFC_MBOXQ_t *);
51void lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *);53void lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *);
@@ -66,15 +68,15 @@ int lpfc_check_sli_ndlp(struct lpfc_hba *, struct lpfc_sli_ring *, · 14 unmodified lines
66void lpfc_nlp_init(struct lpfc_vport *, struct lpfc_nodelist *, uint32_t);68void lpfc_nlp_init(struct lpfc_vport *, struct lpfc_nodelist *, uint32_t);
67struct lpfc_nodelist *lpfc_nlp_get(struct lpfc_nodelist *);69struct lpfc_nodelist *lpfc_nlp_get(struct lpfc_nodelist *);
68int lpfc_nlp_put(struct lpfc_nodelist *);70int lpfc_nlp_put(struct lpfc_nodelist *);
71int lpfc_nlp_not_used(struct lpfc_nodelist *ndlp);
69struct lpfc_nodelist *lpfc_setup_disc_node(struct lpfc_vport *, uint32_t);72struct lpfc_nodelist *lpfc_setup_disc_node(struct lpfc_vport *, uint32_t);
70void lpfc_disc_list_loopmap(struct lpfc_vport *);73void lpfc_disc_list_loopmap(struct lpfc_vport *);
71void lpfc_disc_start(struct lpfc_vport *);74void lpfc_disc_start(struct lpfc_vport *);
72void lpfc_disc_flush_list(struct lpfc_vport *);
73void lpfc_cleanup_discovery_resources(struct lpfc_vport *);75void lpfc_cleanup_discovery_resources(struct lpfc_vport *);
76void lpfc_cleanup(struct lpfc_vport *);
74void lpfc_disc_timeout(unsigned long);77void lpfc_disc_timeout(unsigned long);
75 78
76struct lpfc_nodelist *__lpfc_findnode_rpi(struct lpfc_vport *, uint16_t);79struct lpfc_nodelist *__lpfc_findnode_rpi(struct lpfc_vport *, uint16_t);
77struct lpfc_nodelist *lpfc_findnode_rpi(struct lpfc_vport *, uint16_t);
78 80
79void lpfc_worker_wake_up(struct lpfc_hba *);81void lpfc_worker_wake_up(struct lpfc_hba *);
80int lpfc_workq_post_event(struct lpfc_hba *, void *, void *, uint32_t);82int lpfc_workq_post_event(struct lpfc_hba *, void *, void *, uint32_t);
@@ -82,17 +84,17 @@ int lpfc_do_work(void *); · 1 unmodified line
82int lpfc_disc_state_machine(struct lpfc_vport *, struct lpfc_nodelist *, void *,84int lpfc_disc_state_machine(struct lpfc_vport *, struct lpfc_nodelist *, void *,
83 uint32_t);85 uint32_t);
84 86
85void lpfc_register_new_vport(struct lpfc_hba *, struct lpfc_vport *,
86 struct lpfc_nodelist *);
87void lpfc_do_scr_ns_plogi(struct lpfc_hba *, struct lpfc_vport *);87void lpfc_do_scr_ns_plogi(struct lpfc_hba *, struct lpfc_vport *);
88int lpfc_check_sparm(struct lpfc_vport *, struct lpfc_nodelist *,88int lpfc_check_sparm(struct lpfc_vport *, struct lpfc_nodelist *,
89 struct serv_parm *, uint32_t);89 struct serv_parm *, uint32_t);
90int lpfc_els_abort(struct lpfc_hba *, struct lpfc_nodelist *);90int lpfc_els_abort(struct lpfc_hba *, struct lpfc_nodelist *);
91void lpfc_more_plogi(struct lpfc_vport *);
92void lpfc_more_adisc(struct lpfc_vport *);
93void lpfc_end_rscn(struct lpfc_vport *);
91int lpfc_els_chk_latt(struct lpfc_vport *);94int lpfc_els_chk_latt(struct lpfc_vport *);
92int lpfc_els_abort_flogi(struct lpfc_hba *);95int lpfc_els_abort_flogi(struct lpfc_hba *);
93int lpfc_initial_flogi(struct lpfc_vport *);96int lpfc_initial_flogi(struct lpfc_vport *);
94int lpfc_initial_fdisc(struct lpfc_vport *);97int lpfc_initial_fdisc(struct lpfc_vport *);
95int lpfc_issue_els_fdisc(struct lpfc_vport *, struct lpfc_nodelist *, uint8_t);
96int lpfc_issue_els_plogi(struct lpfc_vport *, uint32_t, uint8_t);98int lpfc_issue_els_plogi(struct lpfc_vport *, uint32_t, uint8_t);
97int lpfc_issue_els_prli(struct lpfc_vport *, struct lpfc_nodelist *, uint8_t);99int lpfc_issue_els_prli(struct lpfc_vport *, struct lpfc_nodelist *, uint8_t);
98int lpfc_issue_els_adisc(struct lpfc_vport *, struct lpfc_nodelist *, uint8_t);100int lpfc_issue_els_adisc(struct lpfc_vport *, struct lpfc_nodelist *, uint8_t);
@@ -112,7 +114,6 @@ int lpfc_els_rsp_prli_acc(struct lpfc_vport *, struct lpfc_iocbq *, · 13 unmodified lines
112void lpfc_cancel_retry_delay_tmo(struct lpfc_vport *, struct lpfc_nodelist *);114void lpfc_cancel_retry_delay_tmo(struct lpfc_vport *, struct lpfc_nodelist *);
113void lpfc_els_retry_delay(unsigned long);115void lpfc_els_retry_delay(unsigned long);
114void lpfc_els_retry_delay_handler(struct lpfc_nodelist *);116void lpfc_els_retry_delay_handler(struct lpfc_nodelist *);
115void lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *);
116void lpfc_els_unsol_event(struct lpfc_hba *, struct lpfc_sli_ring *,117void lpfc_els_unsol_event(struct lpfc_hba *, struct lpfc_sli_ring *,
117 struct lpfc_iocbq *);118 struct lpfc_iocbq *);
118int lpfc_els_handle_rscn(struct lpfc_vport *);119int lpfc_els_handle_rscn(struct lpfc_vport *);
@@ -124,7 +125,6 @@ int lpfc_els_disc_adisc(struct lpfc_vport *); · 5 unmodified lines
124int lpfc_els_disc_plogi(struct lpfc_vport *);125int lpfc_els_disc_plogi(struct lpfc_vport *);
125void lpfc_els_timeout(unsigned long);126void lpfc_els_timeout(unsigned long);
126void lpfc_els_timeout_handler(struct lpfc_vport *);127void lpfc_els_timeout_handler(struct lpfc_vport *);
127void lpfc_hb_timeout(unsigned long);
128void lpfc_hb_timeout_handler(struct lpfc_hba *);128void lpfc_hb_timeout_handler(struct lpfc_hba *);
129 129
130void lpfc_ct_unsol_event(struct lpfc_hba *, struct lpfc_sli_ring *,130void lpfc_ct_unsol_event(struct lpfc_hba *, struct lpfc_sli_ring *,
@@ -142,7 +142,6 @@ void lpfc_hba_init(struct lpfc_hba *, uint32_t *); · 11 unmodified lines
142int lpfc_post_buffer(struct lpfc_hba *, struct lpfc_sli_ring *, int, int);142int lpfc_post_buffer(struct lpfc_hba *, struct lpfc_sli_ring *, int, int);
143void lpfc_decode_firmware_rev(struct lpfc_hba *, char *, int);143void lpfc_decode_firmware_rev(struct lpfc_hba *, char *, int);
144int lpfc_online(struct lpfc_hba *);144int lpfc_online(struct lpfc_hba *);
145void lpfc_block_mgmt_io(struct lpfc_hba *);
146void lpfc_unblock_mgmt_io(struct lpfc_hba *);145void lpfc_unblock_mgmt_io(struct lpfc_hba *);
147void lpfc_offline_prep(struct lpfc_hba *);146void lpfc_offline_prep(struct lpfc_hba *);
148void lpfc_offline(struct lpfc_hba *);147void lpfc_offline(struct lpfc_hba *);
@@ -165,7 +164,6 @@ int lpfc_mbox_tmo_val(struct lpfc_hba *, int); · 16 unmodified lines
165 164
166void lpfc_config_hbq(struct lpfc_hba *, uint32_t, struct lpfc_hbq_init *,165void lpfc_config_hbq(struct lpfc_hba *, uint32_t, struct lpfc_hbq_init *,
167 uint32_t , LPFC_MBOXQ_t *);166 uint32_t , LPFC_MBOXQ_t *);
168struct lpfc_hbq_entry * lpfc_sli_next_hbq_slot(struct lpfc_hba *, uint32_t);
169struct hbq_dmabuf *lpfc_els_hbq_alloc(struct lpfc_hba *);167struct hbq_dmabuf *lpfc_els_hbq_alloc(struct lpfc_hba *);
170void lpfc_els_hbq_free(struct lpfc_hba *, struct hbq_dmabuf *);168void lpfc_els_hbq_free(struct lpfc_hba *, struct hbq_dmabuf *);
171 169
@@ -178,7 +176,6 @@ void lpfc_poll_start_timer(struct lpfc_hba * phba); · 6 unmodified lines
178void lpfc_sli_poll_fcp_ring(struct lpfc_hba * hba);176void lpfc_sli_poll_fcp_ring(struct lpfc_hba * hba);
179struct lpfc_iocbq * lpfc_sli_get_iocbq(struct lpfc_hba *);177struct lpfc_iocbq * lpfc_sli_get_iocbq(struct lpfc_hba *);
180void lpfc_sli_release_iocbq(struct lpfc_hba * phba, struct lpfc_iocbq * iocb);178void lpfc_sli_release_iocbq(struct lpfc_hba * phba, struct lpfc_iocbq * iocb);
181void __lpfc_sli_release_iocbq(struct lpfc_hba * phba, struct lpfc_iocbq * iocb);
182uint16_t lpfc_sli_next_iotag(struct lpfc_hba * phba, struct lpfc_iocbq * iocb);179uint16_t lpfc_sli_next_iotag(struct lpfc_hba * phba, struct lpfc_iocbq * iocb);
183 180
184void lpfc_reset_barrier(struct lpfc_hba * phba);181void lpfc_reset_barrier(struct lpfc_hba * phba);
@@ -204,11 +201,14 @@ int lpfc_sli_ringpostbuf_put(struct lpfc_hba *, struct lpfc_sli_ring *, · 19 unmodified lines
204struct lpfc_dmabuf *lpfc_sli_ringpostbuf_get(struct lpfc_hba *,201struct lpfc_dmabuf *lpfc_sli_ringpostbuf_get(struct lpfc_hba *,
205 struct lpfc_sli_ring *,202 struct lpfc_sli_ring *,
206 dma_addr_t);203 dma_addr_t);
204
205uint32_t lpfc_sli_get_buffer_tag(struct lpfc_hba *);
206struct lpfc_dmabuf * lpfc_sli_ring_taggedbuf_get(struct lpfc_hba *,
207 struct lpfc_sli_ring *, uint32_t );
208
207int lpfc_sli_hbq_count(void);209int lpfc_sli_hbq_count(void);
208int lpfc_sli_hbqbuf_init_hbqs(struct lpfc_hba *, uint32_t);
209int lpfc_sli_hbqbuf_add_hbqs(struct lpfc_hba *, uint32_t);210int lpfc_sli_hbqbuf_add_hbqs(struct lpfc_hba *, uint32_t);
210void lpfc_sli_hbqbuf_free_all(struct lpfc_hba *);211void lpfc_sli_hbqbuf_free_all(struct lpfc_hba *);
211struct hbq_dmabuf *lpfc_sli_hbqbuf_find(struct lpfc_hba *, uint32_t);
212int lpfc_sli_hbq_size(void);212int lpfc_sli_hbq_size(void);
213int lpfc_sli_issue_abort_iotag(struct lpfc_hba *, struct lpfc_sli_ring *,213int lpfc_sli_issue_abort_iotag(struct lpfc_hba *, struct lpfc_sli_ring *,
214 struct lpfc_iocbq *);214 struct lpfc_iocbq *);
@@ -219,9 +219,6 @@ int lpfc_sli_abort_iocb(struct lpfc_vport *, struct lpfc_sli_ring *, uint16_t, · 4 unmodified lines
219void lpfc_mbox_timeout(unsigned long);219void lpfc_mbox_timeout(unsigned long);
220void lpfc_mbox_timeout_handler(struct lpfc_hba *);220void lpfc_mbox_timeout_handler(struct lpfc_hba *);
221 221
222struct lpfc_nodelist *__lpfc_find_node(struct lpfc_vport *, node_filter,
223 void *);
224struct lpfc_nodelist *lpfc_find_node(struct lpfc_vport *, node_filter, void *);
225struct lpfc_nodelist *lpfc_findnode_did(struct lpfc_vport *, uint32_t);222struct lpfc_nodelist *lpfc_findnode_did(struct lpfc_vport *, uint32_t);
226struct lpfc_nodelist *lpfc_findnode_wwpn(struct lpfc_vport *,223struct lpfc_nodelist *lpfc_findnode_wwpn(struct lpfc_vport *,
227 struct lpfc_name *);224 struct lpfc_name *);
@@ -260,6 +257,7 @@ extern struct scsi_host_template lpfc_vport_template; · 32 unmodified lines
260extern struct fc_function_template lpfc_transport_functions;257extern struct fc_function_template lpfc_transport_functions;
261extern struct fc_function_template lpfc_vport_transport_functions;258extern struct fc_function_template lpfc_vport_transport_functions;
262extern int lpfc_sli_mode;259extern int lpfc_sli_mode;
260extern int lpfc_enable_npiv;
263 261
264int lpfc_vport_symbolic_node_name(struct lpfc_vport *, char *, size_t);262int lpfc_vport_symbolic_node_name(struct lpfc_vport *, char *, size_t);
265void lpfc_terminate_rport_io(struct fc_rport *);263void lpfc_terminate_rport_io(struct fc_rport *);
@@ -281,11 +279,8 @@ extern void lpfc_debugfs_slow_ring_trc(struct lpfc_hba *, char *, uint32_t, · 15 unmodified lines
281extern struct lpfc_hbq_init *lpfc_hbq_defs[];279extern struct lpfc_hbq_init *lpfc_hbq_defs[];
282 280
283/* Interface exported by fabric iocb scheduler */281/* Interface exported by fabric iocb scheduler */
284int lpfc_issue_fabric_iocb(struct lpfc_hba *, struct lpfc_iocbq *);
285void lpfc_fabric_abort_vport(struct lpfc_vport *);
286void lpfc_fabric_abort_nport(struct lpfc_nodelist *);282void lpfc_fabric_abort_nport(struct lpfc_nodelist *);
287void lpfc_fabric_abort_hba(struct lpfc_hba *);283void lpfc_fabric_abort_hba(struct lpfc_hba *);
288void lpfc_fabric_abort_flogi(struct lpfc_hba *);
289void lpfc_fabric_block_timeout(unsigned long);284void lpfc_fabric_block_timeout(unsigned long);
290void lpfc_unblock_fabric_iocbs(struct lpfc_hba *);285void lpfc_unblock_fabric_iocbs(struct lpfc_hba *);
291void lpfc_adjust_queue_depth(struct lpfc_hba *);286void lpfc_adjust_queue_depth(struct lpfc_hba *);
drivers/scsi/lpfc/lpfc_ct.c+218−86
@@ -19,7 +19,7 @@ · 18 unmodified lines
19 *******************************************************************/19 *******************************************************************/
20 20
21/*21/*
22 * Fibre Channel SCSI LAN Device Driver CT support22 * Fibre Channel SCSI LAN Device Driver CT support: FC Generic Services FC-GS
23 */23 */
24 24
25#include <linux/blkdev.h>25#include <linux/blkdev.h>
@@ -57,45 +57,27 @@ · 31 unmodified lines
57 57
58static char *lpfc_release_version = LPFC_DRIVER_VERSION;58static char *lpfc_release_version = LPFC_DRIVER_VERSION;
59 59
60/*
61 * lpfc_ct_unsol_event
62 */
63static void60static void
64lpfc_ct_unsol_buffer(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq,61lpfc_ct_ignore_hbq_buffer(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq,
65 struct lpfc_dmabuf *mp, uint32_t size)62 struct lpfc_dmabuf *mp, uint32_t size)
66{63{
67 if (!mp) {64 if (!mp) {
68 printk(KERN_ERR "%s (%d): Unsolited CT, no buffer, "65 lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
69 "piocbq = %p, status = x%x, mp = %p, size = %d\n",66 "0146 Ignoring unsolicted CT No HBQ "
70 __FUNCTION__, __LINE__,67 "status = x%x\n",
71 piocbq, piocbq->iocb.ulpStatus, mp, size);68 piocbq->iocb.ulpStatus);
72 }69 }
73 70 lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
74 printk(KERN_ERR "%s (%d): Ignoring unsolicted CT piocbq = %p, "71 "0145 Ignoring unsolicted CT HBQ Size:%d "
75 "buffer = %p, size = %d, status = x%x\n",72 "status = x%x\n",
76 __FUNCTION__, __LINE__,73 size, piocbq->iocb.ulpStatus);
77 piocbq, mp, size,
78 piocbq->iocb.ulpStatus);
79
80}74}
81 75
82static void76static void
83lpfc_ct_ignore_hbq_buffer(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq,77lpfc_ct_unsol_buffer(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq,
84 struct lpfc_dmabuf *mp, uint32_t size)78 struct lpfc_dmabuf *mp, uint32_t size)
85{79{
86 if (!mp) {80 lpfc_ct_ignore_hbq_buffer(phba, piocbq, mp, size);
87 printk(KERN_ERR "%s (%d): Unsolited CT, no "
88 "HBQ buffer, piocbq = %p, status = x%x\n",
89 __FUNCTION__, __LINE__,
90 piocbq, piocbq->iocb.ulpStatus);
91 } else {
92 lpfc_ct_unsol_buffer(phba, piocbq, mp, size);
93 printk(KERN_ERR "%s (%d): Ignoring unsolicted CT "
94 "piocbq = %p, buffer = %p, size = %d, "
95 "status = x%x\n",
96 __FUNCTION__, __LINE__,
97 piocbq, mp, size, piocbq->iocb.ulpStatus);
98 }
99}81}
100 82
101void83void
@@ -109,11 +91,8 @@ lpfc_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 7 unmodified lines
109 struct lpfc_iocbq *iocbq;91 struct lpfc_iocbq *iocbq;
110 dma_addr_t paddr;92 dma_addr_t paddr;
111 uint32_t size;93 uint32_t size;
112 struct lpfc_dmabuf *bdeBuf1 = piocbq->context2;94 struct list_head head;
113 struct lpfc_dmabuf *bdeBuf2 = piocbq->context3;95 struct lpfc_dmabuf *bdeBuf;
114
115 piocbq->context2 = NULL;
116 piocbq->context3 = NULL;
117 96
118 if (unlikely(icmd->ulpStatus == IOSTAT_NEED_BUFFER)) {97 if (unlikely(icmd->ulpStatus == IOSTAT_NEED_BUFFER)) {
119 lpfc_sli_hbqbuf_add_hbqs(phba, LPFC_ELS_HBQ);98 lpfc_sli_hbqbuf_add_hbqs(phba, LPFC_ELS_HBQ);
@@ -122,7 +101,7 @@ lpfc_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 2 unmodified lines
122 /* Not enough posted buffers; Try posting more buffers */101 /* Not enough posted buffers; Try posting more buffers */
123 phba->fc_stat.NoRcvBuf++;102 phba->fc_stat.NoRcvBuf++;
124 if (!(phba->sli3_options & LPFC_SLI3_HBQ_ENABLED))103 if (!(phba->sli3_options & LPFC_SLI3_HBQ_ENABLED))
125 lpfc_post_buffer(phba, pring, 0, 1);104 lpfc_post_buffer(phba, pring, 2, 1);
126 return;105 return;
127 }106 }
128 107
@@ -133,38 +112,34 @@ lpfc_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 4 unmodified lines
133 return;112 return;
134 113
135 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) {114 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) {
136 list_for_each_entry(iocbq, &piocbq->list, list) {115 INIT_LIST_HEAD(&head);
116 list_add_tail(&head, &piocbq->list);
117 list_for_each_entry(iocbq, &head, list) {
137 icmd = &iocbq->iocb;118 icmd = &iocbq->iocb;
138 if (icmd->ulpBdeCount == 0) {119 if (icmd->ulpBdeCount == 0)
139 printk(KERN_ERR "%s (%d): Unsolited CT, no "
140 "BDE, iocbq = %p, status = x%x\n",
141 __FUNCTION__, __LINE__,
142 iocbq, iocbq->iocb.ulpStatus);
143 continue;120 continue;
144 }121 bdeBuf = iocbq->context2;
145 122 iocbq->context2 = NULL;
146 size = icmd->un.cont64[0].tus.f.bdeSize;123 size = icmd->un.cont64[0].tus.f.bdeSize;
147 lpfc_ct_ignore_hbq_buffer(phba, piocbq, bdeBuf1, size);124 lpfc_ct_unsol_buffer(phba, piocbq, bdeBuf, size);
148 lpfc_in_buf_free(phba, bdeBuf1);125 lpfc_in_buf_free(phba, bdeBuf);
149 if (icmd->ulpBdeCount == 2) {126 if (icmd->ulpBdeCount == 2) {
150 lpfc_ct_ignore_hbq_buffer(phba, piocbq, bdeBuf2,127 bdeBuf = iocbq->context3;
151 size);128 iocbq->context3 = NULL;
152 lpfc_in_buf_free(phba, bdeBuf2);129 size = icmd->unsli3.rcvsli3.bde2.tus.f.bdeSize;
130 lpfc_ct_unsol_buffer(phba, piocbq, bdeBuf,
131 size);
132 lpfc_in_buf_free(phba, bdeBuf);
153 }133 }
154 }134 }
135 list_del(&head);
155 } else {136 } else {
156 struct lpfc_iocbq *next;137 struct lpfc_iocbq *next;
157 138
158 list_for_each_entry_safe(iocbq, next, &piocbq->list, list) {139 list_for_each_entry_safe(iocbq, next, &piocbq->list, list) {
159 icmd = &iocbq->iocb;140 icmd = &iocbq->iocb;
160 if (icmd->ulpBdeCount == 0) {141 if (icmd->ulpBdeCount == 0)
161 printk(KERN_ERR "%s (%d): Unsolited CT, no "142 lpfc_ct_unsol_buffer(phba, piocbq, NULL, 0);
162 "BDE, iocbq = %p, status = x%x\n",
163 __FUNCTION__, __LINE__,
164 iocbq, iocbq->iocb.ulpStatus);
165 continue;
166 }
167
168 for (i = 0; i < icmd->ulpBdeCount; i++) {143 for (i = 0; i < icmd->ulpBdeCount; i++) {
169 paddr = getPaddr(icmd->un.cont64[i].addrHigh,144 paddr = getPaddr(icmd->un.cont64[i].addrHigh,
170 icmd->un.cont64[i].addrLow);145 icmd->un.cont64[i].addrLow);
@@ -176,6 +151,7 @@ lpfc_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 5 unmodified lines
176 }151 }
177 list_del(&iocbq->list);152 list_del(&iocbq->list);
178 lpfc_sli_release_iocbq(phba, iocbq);153 lpfc_sli_release_iocbq(phba, iocbq);
154 lpfc_post_buffer(phba, pring, i, 1);
179 }155 }
180 }156 }
181}157}
@@ -203,7 +179,7 @@ lpfc_alloc_ct_rsp(struct lpfc_hba *phba, int cmdcode, struct ulp_bde64 *bpl, · 21 unmodified lines
203 struct lpfc_dmabuf *mp;179 struct lpfc_dmabuf *mp;
204 int cnt, i = 0;180 int cnt, i = 0;
205 181
206 /* We get chucks of FCELSSIZE */182 /* We get chunks of FCELSSIZE */
207 cnt = size > FCELSSIZE ? FCELSSIZE: size;183 cnt = size > FCELSSIZE ? FCELSSIZE: size;
208 184
209 while (size) {185 while (size) {
@@ -426,6 +402,7 @@ lpfc_ns_rsp(struct lpfc_vport *vport, struct lpfc_dmabuf *mp, uint32_t Size) · 216 unmodified lines
426 402
427 lpfc_set_disctmo(vport);403 lpfc_set_disctmo(vport);
428 vport->num_disc_nodes = 0;404 vport->num_disc_nodes = 0;
405 vport->fc_ns_retry = 0;
429 406
430 407
431 list_add_tail(&head, &mp->list);408 list_add_tail(&head, &mp->list);
@@ -458,7 +435,7 @@ lpfc_ns_rsp(struct lpfc_vport *vport, struct lpfc_dmabuf *mp, uint32_t Size) · 26 unmodified lines
458 ((lpfc_find_vport_by_did(phba, Did) == NULL) ||435 ((lpfc_find_vport_by_did(phba, Did) == NULL) ||
459 vport->cfg_peer_port_login)) {436 vport->cfg_peer_port_login)) {
460 if ((vport->port_type != LPFC_NPIV_PORT) ||437 if ((vport->port_type != LPFC_NPIV_PORT) ||
461 (vport->fc_flag & FC_RFF_NOT_SUPPORTED) ||438 (!(vport->ct_flags & FC_CT_RFF_ID)) ||
462 (!vport->cfg_restrict_login)) {439 (!vport->cfg_restrict_login)) {
463 ndlp = lpfc_setup_disc_node(vport, Did);440 ndlp = lpfc_setup_disc_node(vport, Did);
464 if (ndlp) {441 if (ndlp) {
@@ -506,7 +483,17 @@ lpfc_ns_rsp(struct lpfc_vport *vport, struct lpfc_dmabuf *mp, uint32_t Size) · 41 unmodified lines
506 Did, vport->fc_flag,483 Did, vport->fc_flag,
507 vport->fc_rscn_id_cnt);484 vport->fc_rscn_id_cnt);
508 485
509 if (lpfc_ns_cmd(vport,486 /* This NPortID was previously
487 * a FCP target, * Don't even
488 * bother to send GFF_ID.
489 */
490 ndlp = lpfc_findnode_did(vport,
491 Did);
492 if (ndlp && (ndlp->nlp_type &
493 NLP_FCP_TARGET))
494 lpfc_setup_disc_node
495 (vport, Did);
496 else if (lpfc_ns_cmd(vport,
510 SLI_CTNS_GFF_ID,497 SLI_CTNS_GFF_ID,
511 0, Did) == 0)498 0, Did) == 0)
512 vport->num_disc_nodes++;499 vport->num_disc_nodes++;
@@ -554,7 +541,7 @@ lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 41 unmodified lines
554 struct lpfc_dmabuf *outp;541 struct lpfc_dmabuf *outp;
555 struct lpfc_sli_ct_request *CTrsp;542 struct lpfc_sli_ct_request *CTrsp;
556 struct lpfc_nodelist *ndlp;543 struct lpfc_nodelist *ndlp;
557 int rc;544 int rc, retry;
558 545
559 /* First save ndlp, before we overwrite it */546 /* First save ndlp, before we overwrite it */
560 ndlp = cmdiocb->context_un.ndlp;547 ndlp = cmdiocb->context_un.ndlp;
@@ -574,7 +561,6 @@ lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 13 unmodified lines
574 if (vport->load_flag & FC_UNLOADING)561 if (vport->load_flag & FC_UNLOADING)
575 goto out;562 goto out;
576 563
577
578 if (lpfc_els_chk_latt(vport) || lpfc_error_lost_link(irsp)) {564 if (lpfc_els_chk_latt(vport) || lpfc_error_lost_link(irsp)) {
579 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,565 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
580 "0216 Link event during NS query\n");566 "0216 Link event during NS query\n");
@@ -585,14 +571,35 @@ lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 4 unmodified lines
585 if (irsp->ulpStatus) {571 if (irsp->ulpStatus) {
586 /* Check for retry */572 /* Check for retry */
587 if (vport->fc_ns_retry < LPFC_MAX_NS_RETRY) {573 if (vport->fc_ns_retry < LPFC_MAX_NS_RETRY) {
588 if ((irsp->ulpStatus != IOSTAT_LOCAL_REJECT) ||574 retry = 1;
589 (irsp->un.ulpWord[4] != IOERR_NO_RESOURCES))575 if (irsp->ulpStatus == IOSTAT_LOCAL_REJECT) {
576 switch (irsp->un.ulpWord[4]) {
577 case IOERR_NO_RESOURCES:
578 /* We don't increment the retry
579 * count for this case.
580 */
581 break;
582 case IOERR_LINK_DOWN:
583 case IOERR_SLI_ABORTED:
584 case IOERR_SLI_DOWN:
585 retry = 0;
586 break;
587 default:
588 vport->fc_ns_retry++;
589 }
590 }
591 else
590 vport->fc_ns_retry++;592 vport->fc_ns_retry++;
591 /* CT command is being retried */593
592 rc = lpfc_ns_cmd(vport, SLI_CTNS_GID_FT,594 if (retry) {
595 /* CT command is being retried */
596 rc = lpfc_ns_cmd(vport, SLI_CTNS_GID_FT,
593 vport->fc_ns_retry, 0);597 vport->fc_ns_retry, 0);
594 if (rc == 0)598 if (rc == 0) {
595 goto out;599 /* success */
600 goto out;
601 }
602 }
596 }603 }
597 lpfc_vport_set_state(vport, FC_VPORT_FAILED);604 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
598 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,605 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
@@ -698,7 +705,7 @@ lpfc_cmpl_ct_cmd_gff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 99 unmodified lines
698 struct lpfc_dmabuf *inp = (struct lpfc_dmabuf *) cmdiocb->context1;705 struct lpfc_dmabuf *inp = (struct lpfc_dmabuf *) cmdiocb->context1;
699 struct lpfc_dmabuf *outp = (struct lpfc_dmabuf *) cmdiocb->context2;706 struct lpfc_dmabuf *outp = (struct lpfc_dmabuf *) cmdiocb->context2;
700 struct lpfc_sli_ct_request *CTrsp;707 struct lpfc_sli_ct_request *CTrsp;
701 int did;708 int did, rc, retry;
702 uint8_t fbits;709 uint8_t fbits;
703 struct lpfc_nodelist *ndlp;710 struct lpfc_nodelist *ndlp;
704 711
@@ -729,6 +736,39 @@ lpfc_cmpl_ct_cmd_gff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 24 unmodified lines
729 }736 }
730 }737 }
731 else {738 else {
739 /* Check for retry */
740 if (cmdiocb->retry < LPFC_MAX_NS_RETRY) {
741 retry = 1;
742 if (irsp->ulpStatus == IOSTAT_LOCAL_REJECT) {
743 switch (irsp->un.ulpWord[4]) {
744 case IOERR_NO_RESOURCES:
745 /* We don't increment the retry
746 * count for this case.
747 */
748 break;
749 case IOERR_LINK_DOWN:
750 case IOERR_SLI_ABORTED:
751 case IOERR_SLI_DOWN:
752 retry = 0;
753 break;
754 default:
755 cmdiocb->retry++;
756 }
757 }
758 else
759 cmdiocb->retry++;
760
761 if (retry) {
762 /* CT command is being retried */
763 rc = lpfc_ns_cmd(vport, SLI_CTNS_GFF_ID,
764 cmdiocb->retry, did);
765 if (rc == 0) {
766 /* success */
767 lpfc_ct_free_iocb(phba, cmdiocb);
768 return;
769 }
770 }
771 }
732 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,772 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
733 "0267 NameServer GFF Rsp "773 "0267 NameServer GFF Rsp "
734 "x%x Error (%d %d) Data: x%x x%x\n",774 "x%x Error (%d %d) Data: x%x x%x\n",
@@ -778,8 +818,8 @@ out: · 43 unmodified lines
778 818
779 819
780static void820static void
781lpfc_cmpl_ct_cmd_rft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,821lpfc_cmpl_ct(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
782 struct lpfc_iocbq *rspiocb)822 struct lpfc_iocbq *rspiocb)
783{823{
784 struct lpfc_vport *vport = cmdiocb->vport;824 struct lpfc_vport *vport = cmdiocb->vport;
785 struct lpfc_dmabuf *inp;825 struct lpfc_dmabuf *inp;
@@ -809,7 +849,7 @@ lpfc_cmpl_ct_cmd_rft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 23 unmodified lines
809 849
810 /* RFT request completes status <ulpStatus> CmdRsp <CmdRsp> */850 /* RFT request completes status <ulpStatus> CmdRsp <CmdRsp> */
811 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,851 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
812 "0209 RFT request completes, latt %d, "852 "0209 CT Request completes, latt %d, "
813 "ulpStatus x%x CmdRsp x%x, Context x%x, Tag x%x\n",853 "ulpStatus x%x CmdRsp x%x, Context x%x, Tag x%x\n",
814 latt, irsp->ulpStatus,854 latt, irsp->ulpStatus,
815 CTrsp->CommandResponse.bits.CmdRsp,855 CTrsp->CommandResponse.bits.CmdRsp,
@@ -847,11 +887,45 @@ out: · 31 unmodified lines
847 return;887 return;
848}888}
849 889
890static void
891lpfc_cmpl_ct_cmd_rft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
892 struct lpfc_iocbq *rspiocb)
893{
894 IOCB_t *irsp = &rspiocb->iocb;
895 struct lpfc_vport *vport = cmdiocb->vport;
896
897 if (irsp->ulpStatus == IOSTAT_SUCCESS) {
898 struct lpfc_dmabuf *outp;
899 struct lpfc_sli_ct_request *CTrsp;
900
901 outp = (struct lpfc_dmabuf *) cmdiocb->context2;
902 CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
903 if (CTrsp->CommandResponse.bits.CmdRsp ==
904 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
905 vport->ct_flags |= FC_CT_RFT_ID;
906 }
907 lpfc_cmpl_ct(phba, cmdiocb, rspiocb);
908 return;
909}
910
850static void911static void
851lpfc_cmpl_ct_cmd_rnn_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,912lpfc_cmpl_ct_cmd_rnn_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
852 struct lpfc_iocbq *rspiocb)913 struct lpfc_iocbq *rspiocb)
853{914{
854 lpfc_cmpl_ct_cmd_rft_id(phba, cmdiocb, rspiocb);915 IOCB_t *irsp = &rspiocb->iocb;
916 struct lpfc_vport *vport = cmdiocb->vport;
917
918 if (irsp->ulpStatus == IOSTAT_SUCCESS) {
919 struct lpfc_dmabuf *outp;
920 struct lpfc_sli_ct_request *CTrsp;
921
922 outp = (struct lpfc_dmabuf *) cmdiocb->context2;
923 CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
924 if (CTrsp->CommandResponse.bits.CmdRsp ==
925 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
926 vport->ct_flags |= FC_CT_RNN_ID;
927 }
928 lpfc_cmpl_ct(phba, cmdiocb, rspiocb);
855 return;929 return;
856}930}
857 931
@@ -859,7 +933,20 @@ static void · 1 unmodified line
859lpfc_cmpl_ct_cmd_rspn_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,933lpfc_cmpl_ct_cmd_rspn_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
860 struct lpfc_iocbq *rspiocb)934 struct lpfc_iocbq *rspiocb)
861{935{
862 lpfc_cmpl_ct_cmd_rft_id(phba, cmdiocb, rspiocb);936 IOCB_t *irsp = &rspiocb->iocb;
937 struct lpfc_vport *vport = cmdiocb->vport;
938
939 if (irsp->ulpStatus == IOSTAT_SUCCESS) {
940 struct lpfc_dmabuf *outp;
941 struct lpfc_sli_ct_request *CTrsp;
942
943 outp = (struct lpfc_dmabuf *) cmdiocb->context2;
944 CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
945 if (CTrsp->CommandResponse.bits.CmdRsp ==
946 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
947 vport->ct_flags |= FC_CT_RSPN_ID;
948 }
949 lpfc_cmpl_ct(phba, cmdiocb, rspiocb);
863 return;950 return;
864}951}
865 952
@@ -867,7 +954,32 @@ static void · 1 unmodified line
867lpfc_cmpl_ct_cmd_rsnn_nn(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,954lpfc_cmpl_ct_cmd_rsnn_nn(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
868 struct lpfc_iocbq *rspiocb)955 struct lpfc_iocbq *rspiocb)
869{956{
870 lpfc_cmpl_ct_cmd_rft_id(phba, cmdiocb, rspiocb);957 IOCB_t *irsp = &rspiocb->iocb;
958 struct lpfc_vport *vport = cmdiocb->vport;
959
960 if (irsp->ulpStatus == IOSTAT_SUCCESS) {
961 struct lpfc_dmabuf *outp;
962 struct lpfc_sli_ct_request *CTrsp;
963
964 outp = (struct lpfc_dmabuf *) cmdiocb->context2;
965 CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
966 if (CTrsp->CommandResponse.bits.CmdRsp ==
967 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
968 vport->ct_flags |= FC_CT_RSNN_NN;
969 }
970 lpfc_cmpl_ct(phba, cmdiocb, rspiocb);
971 return;
972}
973
974static void
975lpfc_cmpl_ct_cmd_da_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
976 struct lpfc_iocbq *rspiocb)
977{
978 struct lpfc_vport *vport = cmdiocb->vport;
979
980 /* even if it fails we will act as though it succeeded. */
981 vport->ct_flags = 0;
982 lpfc_cmpl_ct(phba, cmdiocb, rspiocb);
871 return;983 return;
872}984}
873 985
@@ -878,10 +990,17 @@ lpfc_cmpl_ct_cmd_rff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 4 unmodified lines
878 IOCB_t *irsp = &rspiocb->iocb;990 IOCB_t *irsp = &rspiocb->iocb;
879 struct lpfc_vport *vport = cmdiocb->vport;991 struct lpfc_vport *vport = cmdiocb->vport;
880 992
881 if (irsp->ulpStatus != IOSTAT_SUCCESS)993 if (irsp->ulpStatus == IOSTAT_SUCCESS) {
882 vport->fc_flag |= FC_RFF_NOT_SUPPORTED;994 struct lpfc_dmabuf *outp;
995 struct lpfc_sli_ct_request *CTrsp;
883 996
884 lpfc_cmpl_ct_cmd_rft_id(phba, cmdiocb, rspiocb);997 outp = (struct lpfc_dmabuf *) cmdiocb->context2;
998 CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
999 if (CTrsp->CommandResponse.bits.CmdRsp ==
1000 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
1001 vport->ct_flags |= FC_CT_RFF_ID;
1002 }
1003 lpfc_cmpl_ct(phba, cmdiocb, rspiocb);
885 return;1004 return;
886}1005}
887 1006
@@ -1001,6 +1120,8 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode, · 113 unmodified lines
1001 bpl->tus.f.bdeSize = RSPN_REQUEST_SZ;1120 bpl->tus.f.bdeSize = RSPN_REQUEST_SZ;
1002 else if (cmdcode == SLI_CTNS_RSNN_NN)1121 else if (cmdcode == SLI_CTNS_RSNN_NN)
1003 bpl->tus.f.bdeSize = RSNN_REQUEST_SZ;1122 bpl->tus.f.bdeSize = RSNN_REQUEST_SZ;
1123 else if (cmdcode == SLI_CTNS_DA_ID)
1124 bpl->tus.f.bdeSize = DA_ID_REQUEST_SZ;
1004 else if (cmdcode == SLI_CTNS_RFF_ID)1125 else if (cmdcode == SLI_CTNS_RFF_ID)
1005 bpl->tus.f.bdeSize = RFF_REQUEST_SZ;1126 bpl->tus.f.bdeSize = RFF_REQUEST_SZ;
1006 else1127 else
@@ -1029,31 +1150,34 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode, · 22 unmodified lines
1029 case SLI_CTNS_GFF_ID:1150 case SLI_CTNS_GFF_ID:
1030 CtReq->CommandResponse.bits.CmdRsp =1151 CtReq->CommandResponse.bits.CmdRsp =
1031 be16_to_cpu(SLI_CTNS_GFF_ID);1152 be16_to_cpu(SLI_CTNS_GFF_ID);
1032 CtReq->un.gff.PortId = be32_to_cpu(context);1153 CtReq->un.gff.PortId = cpu_to_be32(context);
1033 cmpl = lpfc_cmpl_ct_cmd_gff_id;1154 cmpl = lpfc_cmpl_ct_cmd_gff_id;
1034 break;1155 break;
1035 1156
1036 case SLI_CTNS_RFT_ID:1157 case SLI_CTNS_RFT_ID:
1158 vport->ct_flags &= ~FC_CT_RFT_ID;
1037 CtReq->CommandResponse.bits.CmdRsp =1159 CtReq->CommandResponse.bits.CmdRsp =
1038 be16_to_cpu(SLI_CTNS_RFT_ID);1160 be16_to_cpu(SLI_CTNS_RFT_ID);
1039 CtReq->un.rft.PortId = be32_to_cpu(vport->fc_myDID);1161 CtReq->un.rft.PortId = cpu_to_be32(vport->fc_myDID);
1040 CtReq->un.rft.fcpReg = 1;1162 CtReq->un.rft.fcpReg = 1;
1041 cmpl = lpfc_cmpl_ct_cmd_rft_id;1163 cmpl = lpfc_cmpl_ct_cmd_rft_id;
1042 break;1164 break;
1043 1165
1044 case SLI_CTNS_RNN_ID:1166 case SLI_CTNS_RNN_ID:
1167 vport->ct_flags &= ~FC_CT_RNN_ID;
1045 CtReq->CommandResponse.bits.CmdRsp =1168 CtReq->CommandResponse.bits.CmdRsp =
1046 be16_to_cpu(SLI_CTNS_RNN_ID);1169 be16_to_cpu(SLI_CTNS_RNN_ID);
1047 CtReq->un.rnn.PortId = be32_to_cpu(vport->fc_myDID);1170 CtReq->un.rnn.PortId = cpu_to_be32(vport->fc_myDID);
1048 memcpy(CtReq->un.rnn.wwnn, &vport->fc_nodename,1171 memcpy(CtReq->un.rnn.wwnn, &vport->fc_nodename,
1049 sizeof (struct lpfc_name));1172 sizeof (struct lpfc_name));
1050 cmpl = lpfc_cmpl_ct_cmd_rnn_id;1173 cmpl = lpfc_cmpl_ct_cmd_rnn_id;
1051 break;1174 break;
1052 1175
1053 case SLI_CTNS_RSPN_ID:1176 case SLI_CTNS_RSPN_ID:
1177 vport->ct_flags &= ~FC_CT_RSPN_ID;
1054 CtReq->CommandResponse.bits.CmdRsp =1178 CtReq->CommandResponse.bits.CmdRsp =
1055 be16_to_cpu(SLI_CTNS_RSPN_ID);1179 be16_to_cpu(SLI_CTNS_RSPN_ID);
1056 CtReq->un.rspn.PortId = be32_to_cpu(vport->fc_myDID);1180 CtReq->un.rspn.PortId = cpu_to_be32(vport->fc_myDID);
1057 size = sizeof(CtReq->un.rspn.symbname);1181 size = sizeof(CtReq->un.rspn.symbname);
1058 CtReq->un.rspn.len =1182 CtReq->un.rspn.len =
1059 lpfc_vport_symbolic_port_name(vport,1183 lpfc_vport_symbolic_port_name(vport,
@@ -1061,6 +1185,7 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode, · 1 unmodified line
1061 cmpl = lpfc_cmpl_ct_cmd_rspn_id;1185 cmpl = lpfc_cmpl_ct_cmd_rspn_id;
1062 break;1186 break;
1063 case SLI_CTNS_RSNN_NN:1187 case SLI_CTNS_RSNN_NN:
1188 vport->ct_flags &= ~FC_CT_RSNN_NN;
1064 CtReq->CommandResponse.bits.CmdRsp =1189 CtReq->CommandResponse.bits.CmdRsp =
1065 be16_to_cpu(SLI_CTNS_RSNN_NN);1190 be16_to_cpu(SLI_CTNS_RSNN_NN);
1066 memcpy(CtReq->un.rsnn.wwnn, &vport->fc_nodename,1191 memcpy(CtReq->un.rsnn.wwnn, &vport->fc_nodename,
@@ -1071,11 +1196,18 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode, · 4 unmodified lines
1071 CtReq->un.rsnn.symbname, size);1196 CtReq->un.rsnn.symbname, size);
1072 cmpl = lpfc_cmpl_ct_cmd_rsnn_nn;1197 cmpl = lpfc_cmpl_ct_cmd_rsnn_nn;
1073 break;1198 break;
1199 case SLI_CTNS_DA_ID:
1200 /* Implement DA_ID Nameserver request */
1201 CtReq->CommandResponse.bits.CmdRsp =
1202 be16_to_cpu(SLI_CTNS_DA_ID);
1203 CtReq->un.da_id.port_id = cpu_to_be32(vport->fc_myDID);
1204 cmpl = lpfc_cmpl_ct_cmd_da_id;
1205 break;
1074 case SLI_CTNS_RFF_ID:1206 case SLI_CTNS_RFF_ID:
1075 vport->fc_flag &= ~FC_RFF_NOT_SUPPORTED;1207 vport->ct_flags &= ~FC_CT_RFF_ID;
1076 CtReq->CommandResponse.bits.CmdRsp =1208 CtReq->CommandResponse.bits.CmdRsp =
1077 be16_to_cpu(SLI_CTNS_RFF_ID);1209 be16_to_cpu(SLI_CTNS_RFF_ID);
1078 CtReq->un.rff.PortId = be32_to_cpu(vport->fc_myDID);;1210 CtReq->un.rff.PortId = cpu_to_be32(vport->fc_myDID);;
1079 CtReq->un.rff.fbits = FC4_FEATURE_INIT;1211 CtReq->un.rff.fbits = FC4_FEATURE_INIT;
1080 CtReq->un.rff.type_code = FC_FCP_DATA;1212 CtReq->un.rff.type_code = FC_FCP_DATA;
1081 cmpl = lpfc_cmpl_ct_cmd_rff_id;1213 cmpl = lpfc_cmpl_ct_cmd_rff_id;
drivers/scsi/lpfc/lpfc_debugfs.c+127−30
@@ -43,6 +43,7 @@ · 42 unmodified lines
43#include "lpfc_crtn.h"43#include "lpfc_crtn.h"
44#include "lpfc_vport.h"44#include "lpfc_vport.h"
45#include "lpfc_version.h"45#include "lpfc_version.h"
46#include "lpfc_compat.h"
46#include "lpfc_debugfs.h"47#include "lpfc_debugfs.h"
47 48
48#ifdef CONFIG_LPFC_DEBUG_FS49#ifdef CONFIG_LPFC_DEBUG_FS
@@ -75,18 +76,18 @@ module_param(lpfc_debugfs_enable, int, 0); · 26 unmodified lines
75MODULE_PARM_DESC(lpfc_debugfs_enable, "Enable debugfs services");76MODULE_PARM_DESC(lpfc_debugfs_enable, "Enable debugfs services");
76 77
77/* This MUST be a power of 2 */78/* This MUST be a power of 2 */
78static int lpfc_debugfs_max_disc_trc = 0;79static int lpfc_debugfs_max_disc_trc;
79module_param(lpfc_debugfs_max_disc_trc, int, 0);80module_param(lpfc_debugfs_max_disc_trc, int, 0);
80MODULE_PARM_DESC(lpfc_debugfs_max_disc_trc,81MODULE_PARM_DESC(lpfc_debugfs_max_disc_trc,
81 "Set debugfs discovery trace depth");82 "Set debugfs discovery trace depth");
82 83
83/* This MUST be a power of 2 */84/* This MUST be a power of 2 */
84static int lpfc_debugfs_max_slow_ring_trc = 0;85static int lpfc_debugfs_max_slow_ring_trc;
85module_param(lpfc_debugfs_max_slow_ring_trc, int, 0);86module_param(lpfc_debugfs_max_slow_ring_trc, int, 0);
86MODULE_PARM_DESC(lpfc_debugfs_max_slow_ring_trc,87MODULE_PARM_DESC(lpfc_debugfs_max_slow_ring_trc,
87 "Set debugfs slow ring trace depth");88 "Set debugfs slow ring trace depth");
88 89
89static int lpfc_debugfs_mask_disc_trc = 0;90int lpfc_debugfs_mask_disc_trc;
90module_param(lpfc_debugfs_mask_disc_trc, int, 0);91module_param(lpfc_debugfs_mask_disc_trc, int, 0);
91MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,92MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
92 "Set debugfs discovery trace mask");93 "Set debugfs discovery trace mask");
@@ -100,8 +101,11 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc, · 7 unmodified lines
100#define LPFC_NODELIST_SIZE 8192101#define LPFC_NODELIST_SIZE 8192
101#define LPFC_NODELIST_ENTRY_SIZE 120102#define LPFC_NODELIST_ENTRY_SIZE 120
102 103
103/* dumpslim output buffer size */104/* dumpHBASlim output buffer size */
104#define LPFC_DUMPSLIM_SIZE 4096105#define LPFC_DUMPHBASLIM_SIZE 4096
106
107/* dumpHostSlim output buffer size */
108#define LPFC_DUMPHOSTSLIM_SIZE 4096
105 109
106/* hbqinfo output buffer size */110/* hbqinfo output buffer size */
107#define LPFC_HBQINFO_SIZE 8192111#define LPFC_HBQINFO_SIZE 8192
@@ -243,16 +247,17 @@ lpfc_debugfs_hbqinfo_data(struct lpfc_hba *phba, char *buf, int size) · 135 unmodified lines
243 raw_index = phba->hbq_get[i];247 raw_index = phba->hbq_get[i];
244 getidx = le32_to_cpu(raw_index);248 getidx = le32_to_cpu(raw_index);
245 len += snprintf(buf+len, size-len,249 len += snprintf(buf+len, size-len,
246 "entrys:%d Put:%d nPut:%d localGet:%d hbaGet:%d\n",250 "entrys:%d bufcnt:%d Put:%d nPut:%d localGet:%d hbaGet:%d\n",
247 hbqs->entry_count, hbqs->hbqPutIdx, hbqs->next_hbqPutIdx,251 hbqs->entry_count, hbqs->buffer_count, hbqs->hbqPutIdx,
248 hbqs->local_hbqGetIdx, getidx);252 hbqs->next_hbqPutIdx, hbqs->local_hbqGetIdx, getidx);
249 253
250 hbqe = (struct lpfc_hbq_entry *) phba->hbqs[i].hbq_virt;254 hbqe = (struct lpfc_hbq_entry *) phba->hbqs[i].hbq_virt;
251 for (j=0; j<hbqs->entry_count; j++) {255 for (j=0; j<hbqs->entry_count; j++) {
252 len += snprintf(buf+len, size-len,256 len += snprintf(buf+len, size-len,
253 "%03d: %08x %04x %05x ", j,257 "%03d: %08x %04x %05x ", j,
254 hbqe->bde.addrLow, hbqe->bde.tus.w, hbqe->buffer_tag);258 le32_to_cpu(hbqe->bde.addrLow),
255 259 le32_to_cpu(hbqe->bde.tus.w),
260 le32_to_cpu(hbqe->buffer_tag));
256 i = 0;261 i = 0;
257 found = 0;262 found = 0;
258 263
@@ -276,7 +281,7 @@ lpfc_debugfs_hbqinfo_data(struct lpfc_hba *phba, char *buf, int size) · 17 unmodified lines
276 list_for_each_entry(d_buf, &hbqs->hbq_buffer_list, list) {281 list_for_each_entry(d_buf, &hbqs->hbq_buffer_list, list) {
277 hbq_buf = container_of(d_buf, struct hbq_dmabuf, dbuf);282 hbq_buf = container_of(d_buf, struct hbq_dmabuf, dbuf);
278 phys = ((uint64_t)hbq_buf->dbuf.phys & 0xffffffff);283 phys = ((uint64_t)hbq_buf->dbuf.phys & 0xffffffff);
279 if (phys == hbqe->bde.addrLow) {284 if (phys == le32_to_cpu(hbqe->bde.addrLow)) {
280 len += snprintf(buf+len, size-len,285 len += snprintf(buf+len, size-len,
281 "Buf%d: %p %06x\n", i,286 "Buf%d: %p %06x\n", i,
282 hbq_buf->dbuf.virt, hbq_buf->tag);287 hbq_buf->dbuf.virt, hbq_buf->tag);
@@ -297,18 +302,58 @@ skipit: · 14 unmodified lines
297 return len;302 return len;
298}303}
299 304
305static int lpfc_debugfs_last_hba_slim_off;
306
307static int
308lpfc_debugfs_dumpHBASlim_data(struct lpfc_hba *phba, char *buf, int size)
309{
310 int len = 0;
311 int i, off;
312 uint32_t *ptr;
313 char buffer[1024];
314
315 off = 0;
316 spin_lock_irq(&phba->hbalock);
317
318 len += snprintf(buf+len, size-len, "HBA SLIM\n");
319 lpfc_memcpy_from_slim(buffer,
320 ((uint8_t *)phba->MBslimaddr) + lpfc_debugfs_last_hba_slim_off,
321 1024);
322
323 ptr = (uint32_t *)&buffer[0];
324 off = lpfc_debugfs_last_hba_slim_off;
325
326 /* Set it up for the next time */
327 lpfc_debugfs_last_hba_slim_off += 1024;
328 if (lpfc_debugfs_last_hba_slim_off >= 4096)
329 lpfc_debugfs_last_hba_slim_off = 0;
330
331 i = 1024;
332 while (i > 0) {
333 len += snprintf(buf+len, size-len,
334 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
335 off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4),
336 *(ptr+5), *(ptr+6), *(ptr+7));
337 ptr += 8;
338 i -= (8 * sizeof(uint32_t));
339 off += (8 * sizeof(uint32_t));
340 }
341
342 spin_unlock_irq(&phba->hbalock);
343 return len;
344}
345
300static int346static int
301lpfc_debugfs_dumpslim_data(struct lpfc_hba *phba, char *buf, int size)347lpfc_debugfs_dumpHostSlim_data(struct lpfc_hba *phba, char *buf, int size)
302{348{
303 int len = 0;349 int len = 0;
304 int cnt, i, off;350 int i, off;
305 uint32_t word0, word1, word2, word3;351 uint32_t word0, word1, word2, word3;
306 uint32_t *ptr;352 uint32_t *ptr;
307 struct lpfc_pgp *pgpp;353 struct lpfc_pgp *pgpp;
308 struct lpfc_sli *psli = &phba->sli;354 struct lpfc_sli *psli = &phba->sli;
309 struct lpfc_sli_ring *pring;355 struct lpfc_sli_ring *pring;
310 356
311 cnt = LPFC_DUMPSLIM_SIZE;
312 off = 0;357 off = 0;
313 spin_lock_irq(&phba->hbalock);358 spin_lock_irq(&phba->hbalock);
314 359
@@ -620,7 +665,34 @@ out: · 305 unmodified lines
620}665}
621 666
622static int667static int
623lpfc_debugfs_dumpslim_open(struct inode *inode, struct file *file)668lpfc_debugfs_dumpHBASlim_open(struct inode *inode, struct file *file)
669{
670 struct lpfc_hba *phba = inode->i_private;
671 struct lpfc_debug *debug;
672 int rc = -ENOMEM;
673
674 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
675 if (!debug)
676 goto out;
677
678 /* Round to page boundry */
679 debug->buffer = kmalloc(LPFC_DUMPHBASLIM_SIZE, GFP_KERNEL);
680 if (!debug->buffer) {
681 kfree(debug);
682 goto out;
683 }
684
685 debug->len = lpfc_debugfs_dumpHBASlim_data(phba, debug->buffer,
686 LPFC_DUMPHBASLIM_SIZE);
687 file->private_data = debug;
688
689 rc = 0;
690out:
691 return rc;
692}
693
694static int
695lpfc_debugfs_dumpHostSlim_open(struct inode *inode, struct file *file)
624{696{
625 struct lpfc_hba *phba = inode->i_private;697 struct lpfc_hba *phba = inode->i_private;
626 struct lpfc_debug *debug;698 struct lpfc_debug *debug;
@@ -631,14 +703,14 @@ lpfc_debugfs_dumpslim_open(struct inode *inode, struct file *file) · 4 unmodified lines
631 goto out;703 goto out;
632 704
633 /* Round to page boundry */705 /* Round to page boundry */
634 debug->buffer = kmalloc(LPFC_DUMPSLIM_SIZE, GFP_KERNEL);706 debug->buffer = kmalloc(LPFC_DUMPHOSTSLIM_SIZE, GFP_KERNEL);
635 if (!debug->buffer) {707 if (!debug->buffer) {
636 kfree(debug);708 kfree(debug);
637 goto out;709 goto out;
638 }710 }
639 711
640 debug->len = lpfc_debugfs_dumpslim_data(phba, debug->buffer,712 debug->len = lpfc_debugfs_dumpHostSlim_data(phba, debug->buffer,
641 LPFC_DUMPSLIM_SIZE);713 LPFC_DUMPHOSTSLIM_SIZE);
642 file->private_data = debug;714 file->private_data = debug;
643 715
644 rc = 0;716 rc = 0;
@@ -741,10 +813,19 @@ static struct file_operations lpfc_debugfs_op_hbqinfo = { · 96 unmodified lines
741 .release = lpfc_debugfs_release,813 .release = lpfc_debugfs_release,
742};814};
743 815
744#undef lpfc_debugfs_op_dumpslim816#undef lpfc_debugfs_op_dumpHBASlim
745static struct file_operations lpfc_debugfs_op_dumpslim = {817static struct file_operations lpfc_debugfs_op_dumpHBASlim = {
818 .owner = THIS_MODULE,
819 .open = lpfc_debugfs_dumpHBASlim_open,
820 .llseek = lpfc_debugfs_lseek,
821 .read = lpfc_debugfs_read,
822 .release = lpfc_debugfs_release,
823};
824
825#undef lpfc_debugfs_op_dumpHostSlim
826static struct file_operations lpfc_debugfs_op_dumpHostSlim = {
746 .owner = THIS_MODULE,827 .owner = THIS_MODULE,
747 .open = lpfc_debugfs_dumpslim_open,828 .open = lpfc_debugfs_dumpHostSlim_open,
748 .llseek = lpfc_debugfs_lseek,829 .llseek = lpfc_debugfs_lseek,
749 .read = lpfc_debugfs_read,830 .read = lpfc_debugfs_read,
750 .release = lpfc_debugfs_release,831 .release = lpfc_debugfs_release,
@@ -812,15 +893,27 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport) · 61 unmodified lines
812 goto debug_failed;893 goto debug_failed;
813 }894 }
814 895
815 /* Setup dumpslim */896 /* Setup dumpHBASlim */
816 snprintf(name, sizeof(name), "dumpslim");897 snprintf(name, sizeof(name), "dumpHBASlim");
817 phba->debug_dumpslim =898 phba->debug_dumpHBASlim =
899 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
900 phba->hba_debugfs_root,
901 phba, &lpfc_debugfs_op_dumpHBASlim);
902 if (!phba->debug_dumpHBASlim) {
903 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
904 "0409 Cannot create debugfs dumpHBASlim\n");
905 goto debug_failed;
906 }
907
908 /* Setup dumpHostSlim */
909 snprintf(name, sizeof(name), "dumpHostSlim");
910 phba->debug_dumpHostSlim =
818 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,911 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
819 phba->hba_debugfs_root,912 phba->hba_debugfs_root,
820 phba, &lpfc_debugfs_op_dumpslim);913 phba, &lpfc_debugfs_op_dumpHostSlim);
821 if (!phba->debug_dumpslim) {914 if (!phba->debug_dumpHostSlim) {
822 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,915 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
823 "0409 Cannot create debugfs dumpslim\n");916 "0409 Cannot create debugfs dumpHostSlim\n");
824 goto debug_failed;917 goto debug_failed;
825 }918 }
826 919
@@ -970,9 +1063,13 @@ lpfc_debugfs_terminate(struct lpfc_vport *vport) · 143 unmodified lines
970 debugfs_remove(phba->debug_hbqinfo); /* hbqinfo */1063 debugfs_remove(phba->debug_hbqinfo); /* hbqinfo */
971 phba->debug_hbqinfo = NULL;1064 phba->debug_hbqinfo = NULL;
972 }1065 }
973 if (phba->debug_dumpslim) {1066 if (phba->debug_dumpHBASlim) {
974 debugfs_remove(phba->debug_dumpslim); /* dumpslim */1067 debugfs_remove(phba->debug_dumpHBASlim); /* HBASlim */
975 phba->debug_dumpslim = NULL;1068 phba->debug_dumpHBASlim = NULL;
1069 }
1070 if (phba->debug_dumpHostSlim) {
1071 debugfs_remove(phba->debug_dumpHostSlim); /* HostSlim */
1072 phba->debug_dumpHostSlim = NULL;
976 }1073 }
977 if (phba->slow_ring_trc) {1074 if (phba->slow_ring_trc) {
978 kfree(phba->slow_ring_trc);1075 kfree(phba->slow_ring_trc);
drivers/scsi/lpfc/lpfc_disc.h+1−1
@@ -36,7 +36,6 @@ enum lpfc_work_type { · 35 unmodified lines
36 LPFC_EVT_WARM_START,36 LPFC_EVT_WARM_START,
37 LPFC_EVT_KILL,37 LPFC_EVT_KILL,
38 LPFC_EVT_ELS_RETRY,38 LPFC_EVT_ELS_RETRY,
39 LPFC_EVT_DEV_LOSS_DELAY,
40 LPFC_EVT_DEV_LOSS,39 LPFC_EVT_DEV_LOSS,
41};40};
42 41
@@ -92,6 +91,7 @@ struct lpfc_nodelist { · 49 unmodified lines
92#define NLP_LOGO_SND 0x100 /* sent LOGO request for this entry */91#define NLP_LOGO_SND 0x100 /* sent LOGO request for this entry */
93#define NLP_RNID_SND 0x400 /* sent RNID request for this entry */92#define NLP_RNID_SND 0x400 /* sent RNID request for this entry */
94#define NLP_ELS_SND_MASK 0x7e0 /* sent ELS request for this entry */93#define NLP_ELS_SND_MASK 0x7e0 /* sent ELS request for this entry */
94#define NLP_DEFER_RM 0x10000 /* Remove this ndlp if no longer used */
95#define NLP_DELAY_TMO 0x20000 /* delay timeout is running for node */95#define NLP_DELAY_TMO 0x20000 /* delay timeout is running for node */
96#define NLP_NPR_2B_DISC 0x40000 /* node is included in num_disc_nodes */96#define NLP_NPR_2B_DISC 0x40000 /* node is included in num_disc_nodes */
97#define NLP_RCV_PLOGI 0x80000 /* Rcv'ed PLOGI from remote system */97#define NLP_RCV_PLOGI 0x80000 /* Rcv'ed PLOGI from remote system */
drivers/scsi/lpfc/lpfc_els.c+439−184
@@ -18,7 +18,7 @@ · 17 unmodified lines
18 * more details, a copy of which can be found in the file COPYING *18 * more details, a copy of which can be found in the file COPYING *
19 * included with this package. *19 * included with this package. *
20 *******************************************************************/20 *******************************************************************/
21 21/* See Fibre Channel protocol T11 FC-LS for details */
22#include <linux/blkdev.h>22#include <linux/blkdev.h>
23#include <linux/pci.h>23#include <linux/pci.h>
24#include <linux/interrupt.h>24#include <linux/interrupt.h>
@@ -42,6 +42,14 @@ static int lpfc_els_retry(struct lpfc_hba *, struct lpfc_iocbq *, · 17 unmodified lines
42 struct lpfc_iocbq *);42 struct lpfc_iocbq *);
43static void lpfc_cmpl_fabric_iocb(struct lpfc_hba *, struct lpfc_iocbq *,43static void lpfc_cmpl_fabric_iocb(struct lpfc_hba *, struct lpfc_iocbq *,
44 struct lpfc_iocbq *);44 struct lpfc_iocbq *);
45static void lpfc_fabric_abort_vport(struct lpfc_vport *vport);
46static int lpfc_issue_els_fdisc(struct lpfc_vport *vport,
47 struct lpfc_nodelist *ndlp, uint8_t retry);
48static int lpfc_issue_fabric_iocb(struct lpfc_hba *phba,
49 struct lpfc_iocbq *iocb);
50static void lpfc_register_new_vport(struct lpfc_hba *phba,
51 struct lpfc_vport *vport,
52 struct lpfc_nodelist *ndlp);
45 53
46static int lpfc_max_els_tries = 3;54static int lpfc_max_els_tries = 3;
47 55
@@ -109,14 +117,11 @@ lpfc_prep_els_iocb(struct lpfc_vport *vport, uint8_t expectRsp, · 61 unmodified lines
109 117
110 /* fill in BDEs for command */118 /* fill in BDEs for command */
111 /* Allocate buffer for command payload */119 /* Allocate buffer for command payload */
112 if (((pcmd = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL)) == 0) ||120 pcmd = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
113 ((pcmd->virt = lpfc_mbuf_alloc(phba,121 if (pcmd)
114 MEM_PRI, &(pcmd->phys))) == 0)) {122 pcmd->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &pcmd->phys);
115 kfree(pcmd);123 if (!pcmd || !pcmd->virt)
116 124 goto els_iocb_free_pcmb_exit;
117 lpfc_sli_release_iocbq(phba, elsiocb);
118 return NULL;
119 }
120 125
121 INIT_LIST_HEAD(&pcmd->list);126 INIT_LIST_HEAD(&pcmd->list);
122 127
@@ -126,13 +131,8 @@ lpfc_prep_els_iocb(struct lpfc_vport *vport, uint8_t expectRsp, · 3 unmodified lines
126 if (prsp)131 if (prsp)
127 prsp->virt = lpfc_mbuf_alloc(phba, MEM_PRI,132 prsp->virt = lpfc_mbuf_alloc(phba, MEM_PRI,
128 &prsp->phys);133 &prsp->phys);
129 if (prsp == 0 || prsp->virt == 0) {134 if (!prsp || !prsp->virt)
130 kfree(prsp);135 goto els_iocb_free_prsp_exit;
131 lpfc_mbuf_free(phba, pcmd->virt, pcmd->phys);
132 kfree(pcmd);
133 lpfc_sli_release_iocbq(phba, elsiocb);
134 return NULL;
135 }
136 INIT_LIST_HEAD(&prsp->list);136 INIT_LIST_HEAD(&prsp->list);
137 } else {137 } else {
138 prsp = NULL;138 prsp = NULL;
@@ -143,15 +143,8 @@ lpfc_prep_els_iocb(struct lpfc_vport *vport, uint8_t expectRsp, · 4 unmodified lines
143 if (pbuflist)143 if (pbuflist)
144 pbuflist->virt = lpfc_mbuf_alloc(phba, MEM_PRI,144 pbuflist->virt = lpfc_mbuf_alloc(phba, MEM_PRI,
145 &pbuflist->phys);145 &pbuflist->phys);
146 if (pbuflist == 0 || pbuflist->virt == 0) {146 if (!pbuflist || !pbuflist->virt)
147 lpfc_sli_release_iocbq(phba, elsiocb);147 goto els_iocb_free_pbuf_exit;
148 lpfc_mbuf_free(phba, pcmd->virt, pcmd->phys);
149 lpfc_mbuf_free(phba, prsp->virt, prsp->phys);
150 kfree(pcmd);
151 kfree(prsp);
152 kfree(pbuflist);
153 return NULL;
154 }
155 148
156 INIT_LIST_HEAD(&pbuflist->list);149 INIT_LIST_HEAD(&pbuflist->list);
157 150
@@ -196,7 +189,10 @@ lpfc_prep_els_iocb(struct lpfc_vport *vport, uint8_t expectRsp, · 38 unmodified lines
196 bpl->tus.w = le32_to_cpu(bpl->tus.w);189 bpl->tus.w = le32_to_cpu(bpl->tus.w);
197 }190 }
198 191
192 /* prevent preparing iocb with NULL ndlp reference */
199 elsiocb->context1 = lpfc_nlp_get(ndlp);193 elsiocb->context1 = lpfc_nlp_get(ndlp);
194 if (!elsiocb->context1)
195 goto els_iocb_free_pbuf_exit;
200 elsiocb->context2 = pcmd;196 elsiocb->context2 = pcmd;
201 elsiocb->context3 = pbuflist;197 elsiocb->context3 = pbuflist;
202 elsiocb->retry = retry;198 elsiocb->retry = retry;
@@ -222,8 +218,20 @@ lpfc_prep_els_iocb(struct lpfc_vport *vport, uint8_t expectRsp, · 19 unmodified lines
222 cmdSize);218 cmdSize);
223 }219 }
224 return elsiocb;220 return elsiocb;
225}
226 221
222els_iocb_free_pbuf_exit:
223 lpfc_mbuf_free(phba, prsp->virt, prsp->phys);
224 kfree(pbuflist);
225
226els_iocb_free_prsp_exit:
227 lpfc_mbuf_free(phba, pcmd->virt, pcmd->phys);
228 kfree(prsp);
229
230els_iocb_free_pcmb_exit:
231 kfree(pcmd);
232 lpfc_sli_release_iocbq(phba, elsiocb);
233 return NULL;
234}
227 235
228static int236static int
229lpfc_issue_fabric_reglogin(struct lpfc_vport *vport)237lpfc_issue_fabric_reglogin(struct lpfc_vport *vport)
@@ -234,40 +242,53 @@ lpfc_issue_fabric_reglogin(struct lpfc_vport *vport) · 4 unmodified lines
234 struct lpfc_nodelist *ndlp;242 struct lpfc_nodelist *ndlp;
235 struct serv_parm *sp;243 struct serv_parm *sp;
236 int rc;244 int rc;
245 int err = 0;
237 246
238 sp = &phba->fc_fabparam;247 sp = &phba->fc_fabparam;
239 ndlp = lpfc_findnode_did(vport, Fabric_DID);248 ndlp = lpfc_findnode_did(vport, Fabric_DID);
240 if (!ndlp)249 if (!ndlp) {
250 err = 1;
241 goto fail;251 goto fail;
252 }
242 253
243 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);254 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
244 if (!mbox)255 if (!mbox) {
256 err = 2;
245 goto fail;257 goto fail;
258 }
246 259
247 vport->port_state = LPFC_FABRIC_CFG_LINK;260 vport->port_state = LPFC_FABRIC_CFG_LINK;
248 lpfc_config_link(phba, mbox);261 lpfc_config_link(phba, mbox);
249 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;262 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
250 mbox->vport = vport;263 mbox->vport = vport;
251 264
252 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT | MBX_STOP_IOCB);265 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
253 if (rc == MBX_NOT_FINISHED)266 if (rc == MBX_NOT_FINISHED) {
267 err = 3;
254 goto fail_free_mbox;268 goto fail_free_mbox;
269 }
255 270
256 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);271 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
257 if (!mbox)272 if (!mbox) {
273 err = 4;
258 goto fail;274 goto fail;
275 }
259 rc = lpfc_reg_login(phba, vport->vpi, Fabric_DID, (uint8_t *)sp, mbox,276 rc = lpfc_reg_login(phba, vport->vpi, Fabric_DID, (uint8_t *)sp, mbox,
260 0);277 0);
261 if (rc)278 if (rc) {
279 err = 5;
262 goto fail_free_mbox;280 goto fail_free_mbox;
281 }
263 282
264 mbox->mbox_cmpl = lpfc_mbx_cmpl_fabric_reg_login;283 mbox->mbox_cmpl = lpfc_mbx_cmpl_fabric_reg_login;
265 mbox->vport = vport;284 mbox->vport = vport;
266 mbox->context2 = lpfc_nlp_get(ndlp);285 mbox->context2 = lpfc_nlp_get(ndlp);
267 286
268 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT | MBX_STOP_IOCB);287 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
269 if (rc == MBX_NOT_FINISHED)288 if (rc == MBX_NOT_FINISHED) {
289 err = 6;
270 goto fail_issue_reg_login;290 goto fail_issue_reg_login;
291 }
271 292
272 return 0;293 return 0;
273 294
@@ -282,7 +303,7 @@ fail_free_mbox: · 8 unmodified lines
282fail:303fail:
283 lpfc_vport_set_state(vport, FC_VPORT_FAILED);304 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
284 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,305 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
285 "0249 Cannot issue Register Fabric login\n");306 "0249 Cannot issue Register Fabric login: Err %d\n", err);
286 return -ENXIO;307 return -ENXIO;
287}308}
288 309
@@ -370,11 +391,12 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 81 unmodified lines
370 }391 }
371 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) {392 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) {
372 lpfc_mbx_unreg_vpi(vport);393 lpfc_mbx_unreg_vpi(vport);
394 spin_lock_irq(shost->host_lock);
373 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;395 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
396 spin_unlock_irq(shost->host_lock);
374 }397 }
375 }398 }
376 399
377 ndlp->nlp_sid = irsp->un.ulpWord[4] & Mask_DID;
378 lpfc_nlp_set_state(vport, ndlp, NLP_STE_REG_LOGIN_ISSUE);400 lpfc_nlp_set_state(vport, ndlp, NLP_STE_REG_LOGIN_ISSUE);
379 401
380 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED &&402 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED &&
@@ -429,8 +451,7 @@ lpfc_cmpl_els_flogi_nport(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 48 unmodified lines
429 451
430 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;452 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
431 mbox->vport = vport;453 mbox->vport = vport;
432 rc = lpfc_sli_issue_mbox(phba, mbox,454 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
433 MBX_NOWAIT | MBX_STOP_IOCB);
434 if (rc == MBX_NOT_FINISHED) {455 if (rc == MBX_NOT_FINISHED) {
435 mempool_free(mbox, phba->mbox_mem_pool);456 mempool_free(mbox, phba->mbox_mem_pool);
436 goto fail;457 goto fail;
@@ -463,6 +484,9 @@ lpfc_cmpl_els_flogi_nport(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 26 unmodified lines
463 lpfc_nlp_put(ndlp);484 lpfc_nlp_put(ndlp);
464 }485 }
465 486
487 /* If we are pt2pt with another NPort, force NPIV off! */
488 phba->sli3_options &= ~LPFC_SLI3_NPIV_ENABLED;
489
466 spin_lock_irq(shost->host_lock);490 spin_lock_irq(shost->host_lock);
467 vport->fc_flag |= FC_PT2PT;491 vport->fc_flag |= FC_PT2PT;
468 spin_unlock_irq(shost->host_lock);492 spin_unlock_irq(shost->host_lock);
@@ -488,6 +512,9 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 19 unmodified lines
488 512
489 /* Check to see if link went down during discovery */513 /* Check to see if link went down during discovery */
490 if (lpfc_els_chk_latt(vport)) {514 if (lpfc_els_chk_latt(vport)) {
515 /* One additional decrement on node reference count to
516 * trigger the release of the node
517 */
491 lpfc_nlp_put(ndlp);518 lpfc_nlp_put(ndlp);
492 goto out;519 goto out;
493 }520 }
@@ -562,8 +589,13 @@ flogifail: · 68 unmodified lines
562 589
563 /* Start discovery */590 /* Start discovery */
564 lpfc_disc_start(vport);591 lpfc_disc_start(vport);
592 } else if (((irsp->ulpStatus != IOSTAT_LOCAL_REJECT) ||
593 ((irsp->un.ulpWord[4] != IOERR_SLI_ABORTED) &&
594 (irsp->un.ulpWord[4] != IOERR_SLI_DOWN))) &&
595 (phba->link_state != LPFC_CLEAR_LA)) {
596 /* If FLOGI failed enable link interrupt. */
597 lpfc_issue_clear_la(phba, vport);
565 }598 }
566
567out:599out:
568 lpfc_els_free_iocb(phba, cmdiocb);600 lpfc_els_free_iocb(phba, cmdiocb);
569}601}
@@ -685,6 +717,9 @@ lpfc_initial_flogi(struct lpfc_vport *vport) · 115 unmodified lines
685 struct lpfc_hba *phba = vport->phba;717 struct lpfc_hba *phba = vport->phba;
686 struct lpfc_nodelist *ndlp;718 struct lpfc_nodelist *ndlp;
687 719
720 vport->port_state = LPFC_FLOGI;
721 lpfc_set_disctmo(vport);
722
688 /* First look for the Fabric ndlp */723 /* First look for the Fabric ndlp */
689 ndlp = lpfc_findnode_did(vport, Fabric_DID);724 ndlp = lpfc_findnode_did(vport, Fabric_DID);
690 if (!ndlp) {725 if (!ndlp) {
@@ -696,7 +731,11 @@ lpfc_initial_flogi(struct lpfc_vport *vport) · 5 unmodified lines
696 } else {731 } else {
697 lpfc_dequeue_node(vport, ndlp);732 lpfc_dequeue_node(vport, ndlp);
698 }733 }
734
699 if (lpfc_issue_els_flogi(vport, ndlp, 0)) {735 if (lpfc_issue_els_flogi(vport, ndlp, 0)) {
736 /* This decrement of reference count to node shall kick off
737 * the release of the node.
738 */
700 lpfc_nlp_put(ndlp);739 lpfc_nlp_put(ndlp);
701 }740 }
702 return 1;741 return 1;
@@ -720,11 +759,16 @@ lpfc_initial_fdisc(struct lpfc_vport *vport) · 17 unmodified lines
720 lpfc_dequeue_node(vport, ndlp);759 lpfc_dequeue_node(vport, ndlp);
721 }760 }
722 if (lpfc_issue_els_fdisc(vport, ndlp, 0)) {761 if (lpfc_issue_els_fdisc(vport, ndlp, 0)) {
762 /* decrement node reference count to trigger the release of
763 * the node.
764 */
723 lpfc_nlp_put(ndlp);765 lpfc_nlp_put(ndlp);
766 return 0;
724 }767 }
725 return 1;768 return 1;
726}769}
727static void770
771void
728lpfc_more_plogi(struct lpfc_vport *vport)772lpfc_more_plogi(struct lpfc_vport *vport)
729{773{
730 int sentplogi;774 int sentplogi;
@@ -752,6 +796,8 @@ lpfc_plogi_confirm_nport(struct lpfc_hba *phba, uint32_t *prsp, · 21 unmodified lines
752{796{
753 struct lpfc_vport *vport = ndlp->vport;797 struct lpfc_vport *vport = ndlp->vport;
754 struct lpfc_nodelist *new_ndlp;798 struct lpfc_nodelist *new_ndlp;
799 struct lpfc_rport_data *rdata;
800 struct fc_rport *rport;
755 struct serv_parm *sp;801 struct serv_parm *sp;
756 uint8_t name[sizeof(struct lpfc_name)];802 uint8_t name[sizeof(struct lpfc_name)];
757 uint32_t rc;803 uint32_t rc;
@@ -788,11 +834,34 @@ lpfc_plogi_confirm_nport(struct lpfc_hba *phba, uint32_t *prsp, · 30 unmodified lines
788 lpfc_unreg_rpi(vport, new_ndlp);834 lpfc_unreg_rpi(vport, new_ndlp);
789 new_ndlp->nlp_DID = ndlp->nlp_DID;835 new_ndlp->nlp_DID = ndlp->nlp_DID;
790 new_ndlp->nlp_prev_state = ndlp->nlp_prev_state;836 new_ndlp->nlp_prev_state = ndlp->nlp_prev_state;
837
838 if (ndlp->nlp_flag & NLP_NPR_2B_DISC)
839 new_ndlp->nlp_flag |= NLP_NPR_2B_DISC;
840 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
841
791 lpfc_nlp_set_state(vport, new_ndlp, ndlp->nlp_state);842 lpfc_nlp_set_state(vport, new_ndlp, ndlp->nlp_state);
792 843
793 /* Move this back to NPR state */844 /* Move this back to NPR state */
794 if (memcmp(&ndlp->nlp_portname, name, sizeof(struct lpfc_name)) == 0)845 if (memcmp(&ndlp->nlp_portname, name, sizeof(struct lpfc_name)) == 0) {
846 /* The new_ndlp is replacing ndlp totally, so we need
847 * to put ndlp on UNUSED list and try to free it.
848 */
849
850 /* Fix up the rport accordingly */
851 rport = ndlp->rport;
852 if (rport) {
853 rdata = rport->dd_data;
854 if (rdata->pnode == ndlp) {
855 lpfc_nlp_put(ndlp);
856 ndlp->rport = NULL;
857 rdata->pnode = lpfc_nlp_get(new_ndlp);
858 new_ndlp->rport = rport;
859 }
860 new_ndlp->nlp_type = ndlp->nlp_type;
861 }
862
795 lpfc_drop_node(vport, ndlp);863 lpfc_drop_node(vport, ndlp);
864 }
796 else {865 else {
797 lpfc_unreg_rpi(vport, ndlp);866 lpfc_unreg_rpi(vport, ndlp);
798 ndlp->nlp_DID = 0; /* Two ndlps cannot have the same did */867 ndlp->nlp_DID = 0; /* Two ndlps cannot have the same did */
@@ -801,6 +870,27 @@ lpfc_plogi_confirm_nport(struct lpfc_hba *phba, uint32_t *prsp, · 2 unmodified lines
801 return new_ndlp;870 return new_ndlp;
802}871}
803 872
873void
874lpfc_end_rscn(struct lpfc_vport *vport)
875{
876 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
877
878 if (vport->fc_flag & FC_RSCN_MODE) {
879 /*
880 * Check to see if more RSCNs came in while we were
881 * processing this one.
882 */
883 if (vport->fc_rscn_id_cnt ||
884 (vport->fc_flag & FC_RSCN_DISCOVERY) != 0)
885 lpfc_els_handle_rscn(vport);
886 else {
887 spin_lock_irq(shost->host_lock);
888 vport->fc_flag &= ~FC_RSCN_MODE;
889 spin_unlock_irq(shost->host_lock);
890 }
891 }
892}
893
804static void894static void
805lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,895lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
806 struct lpfc_iocbq *rspiocb)896 struct lpfc_iocbq *rspiocb)
@@ -871,13 +961,6 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 64 unmodified lines
871 goto out;961 goto out;
872 }962 }
873 /* PLOGI failed */963 /* PLOGI failed */
874 if (ndlp->nlp_DID == NameServer_DID) {
875 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
876 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
877 "0250 Nameserver login error: "
878 "0x%x / 0x%x\n",
879 irsp->ulpStatus, irsp->un.ulpWord[4]);
880 }
881 /* Do not call DSM for lpfc_els_abort'ed ELS cmds */964 /* Do not call DSM for lpfc_els_abort'ed ELS cmds */
882 if (lpfc_error_lost_link(irsp)) {965 if (lpfc_error_lost_link(irsp)) {
883 rc = NLP_STE_FREED_NODE;966 rc = NLP_STE_FREED_NODE;
@@ -905,20 +988,7 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 21 unmodified lines
905 spin_unlock_irq(shost->host_lock);988 spin_unlock_irq(shost->host_lock);
906 989
907 lpfc_can_disctmo(vport);990 lpfc_can_disctmo(vport);
908 if (vport->fc_flag & FC_RSCN_MODE) {991 lpfc_end_rscn(vport);
909 /*
910 * Check to see if more RSCNs came in while
911 * we were processing this one.
912 */
913 if ((vport->fc_rscn_id_cnt == 0) &&
914 (!(vport->fc_flag & FC_RSCN_DISCOVERY))) {
915 spin_lock_irq(shost->host_lock);
916 vport->fc_flag &= ~FC_RSCN_MODE;
917 spin_unlock_irq(shost->host_lock);
918 } else {
919 lpfc_els_handle_rscn(vport);
920 }
921 }
922 }992 }
923 }993 }
924 994
@@ -933,6 +1003,7 @@ lpfc_issue_els_plogi(struct lpfc_vport *vport, uint32_t did, uint8_t retry) · 8 unmodified lines
933 struct lpfc_hba *phba = vport->phba;1003 struct lpfc_hba *phba = vport->phba;
934 struct serv_parm *sp;1004 struct serv_parm *sp;
935 IOCB_t *icmd;1005 IOCB_t *icmd;
1006 struct lpfc_nodelist *ndlp;
936 struct lpfc_iocbq *elsiocb;1007 struct lpfc_iocbq *elsiocb;
937 struct lpfc_sli_ring *pring;1008 struct lpfc_sli_ring *pring;
938 struct lpfc_sli *psli;1009 struct lpfc_sli *psli;
@@ -943,8 +1014,11 @@ lpfc_issue_els_plogi(struct lpfc_vport *vport, uint32_t did, uint8_t retry) · 4 unmodified lines
943 psli = &phba->sli;1014 psli = &phba->sli;
944 pring = &psli->ring[LPFC_ELS_RING]; /* ELS ring */1015 pring = &psli->ring[LPFC_ELS_RING]; /* ELS ring */
945 1016
1017 ndlp = lpfc_findnode_did(vport, did);
1018 /* If ndlp if not NULL, we will bump the reference count on it */
1019
946 cmdsize = (sizeof(uint32_t) + sizeof(struct serv_parm));1020 cmdsize = (sizeof(uint32_t) + sizeof(struct serv_parm));
947 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, NULL, did,1021 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, did,
948 ELS_CMD_PLOGI);1022 ELS_CMD_PLOGI);
949 if (!elsiocb)1023 if (!elsiocb)
950 return 1;1024 return 1;
@@ -1109,7 +1183,7 @@ lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 158 unmodified lines
1109 return 0;1183 return 0;
1110}1184}
1111 1185
1112static void1186void
1113lpfc_more_adisc(struct lpfc_vport *vport)1187lpfc_more_adisc(struct lpfc_vport *vport)
1114{1188{
1115 int sentadisc;1189 int sentadisc;
@@ -1134,8 +1208,6 @@ lpfc_more_adisc(struct lpfc_vport *vport) · 18 unmodified lines
1134static void1208static void
1135lpfc_rscn_disc(struct lpfc_vport *vport)1209lpfc_rscn_disc(struct lpfc_vport *vport)
1136{1210{
1137 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1138
1139 lpfc_can_disctmo(vport);1211 lpfc_can_disctmo(vport);
1140 1212
1141 /* RSCN discovery */1213 /* RSCN discovery */
@@ -1144,19 +1216,7 @@ lpfc_rscn_disc(struct lpfc_vport *vport) · 2 unmodified lines
1144 if (lpfc_els_disc_plogi(vport))1216 if (lpfc_els_disc_plogi(vport))
1145 return;1217 return;
1146 1218
1147 if (vport->fc_flag & FC_RSCN_MODE) {1219 lpfc_end_rscn(vport);
1148 /* Check to see if more RSCNs came in while we were
1149 * processing this one.
1150 */
1151 if ((vport->fc_rscn_id_cnt == 0) &&
1152 (!(vport->fc_flag & FC_RSCN_DISCOVERY))) {
1153 spin_lock_irq(shost->host_lock);
1154 vport->fc_flag &= ~FC_RSCN_MODE;
1155 spin_unlock_irq(shost->host_lock);
1156 } else {
1157 lpfc_els_handle_rscn(vport);
1158 }
1159 }
1160}1220}
1161 1221
1162static void1222static void
@@ -1413,6 +1473,13 @@ lpfc_issue_els_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 250 unmodified lines
1413 psli = &phba->sli;1473 psli = &phba->sli;
1414 pring = &psli->ring[LPFC_ELS_RING];1474 pring = &psli->ring[LPFC_ELS_RING];
1415 1475
1476 spin_lock_irq(shost->host_lock);
1477 if (ndlp->nlp_flag & NLP_LOGO_SND) {
1478 spin_unlock_irq(shost->host_lock);
1479 return 0;
1480 }
1481 spin_unlock_irq(shost->host_lock);
1482
1416 cmdsize = (2 * sizeof(uint32_t)) + sizeof(struct lpfc_name);1483 cmdsize = (2 * sizeof(uint32_t)) + sizeof(struct lpfc_name);
1417 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,1484 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
1418 ndlp->nlp_DID, ELS_CMD_LOGO);1485 ndlp->nlp_DID, ELS_CMD_LOGO);
@@ -1499,6 +1566,9 @@ lpfc_issue_els_scr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) · 80 unmodified lines
1499 ndlp->nlp_DID, ELS_CMD_SCR);1566 ndlp->nlp_DID, ELS_CMD_SCR);
1500 1567
1501 if (!elsiocb) {1568 if (!elsiocb) {
1569 /* This will trigger the release of the node just
1570 * allocated
1571 */
1502 lpfc_nlp_put(ndlp);1572 lpfc_nlp_put(ndlp);
1503 return 1;1573 return 1;
1504 }1574 }
@@ -1520,10 +1590,17 @@ lpfc_issue_els_scr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) · 15 unmodified lines
1520 phba->fc_stat.elsXmitSCR++;1590 phba->fc_stat.elsXmitSCR++;
1521 elsiocb->iocb_cmpl = lpfc_cmpl_els_cmd;1591 elsiocb->iocb_cmpl = lpfc_cmpl_els_cmd;
1522 if (lpfc_sli_issue_iocb(phba, pring, elsiocb, 0) == IOCB_ERROR) {1592 if (lpfc_sli_issue_iocb(phba, pring, elsiocb, 0) == IOCB_ERROR) {
1593 /* The additional lpfc_nlp_put will cause the following
1594 * lpfc_els_free_iocb routine to trigger the rlease of
1595 * the node.
1596 */
1523 lpfc_nlp_put(ndlp);1597 lpfc_nlp_put(ndlp);
1524 lpfc_els_free_iocb(phba, elsiocb);1598 lpfc_els_free_iocb(phba, elsiocb);
1525 return 1;1599 return 1;
1526 }1600 }
1601 /* This will cause the callback-function lpfc_cmpl_els_cmd to
1602 * trigger the release of node.
1603 */
1527 lpfc_nlp_put(ndlp);1604 lpfc_nlp_put(ndlp);
1528 return 0;1605 return 0;
1529}1606}
@@ -1555,6 +1632,9 @@ lpfc_issue_els_farpr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) · 25 unmodified lines
1555 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,1632 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
1556 ndlp->nlp_DID, ELS_CMD_RNID);1633 ndlp->nlp_DID, ELS_CMD_RNID);
1557 if (!elsiocb) {1634 if (!elsiocb) {
1635 /* This will trigger the release of the node just
1636 * allocated
1637 */
1558 lpfc_nlp_put(ndlp);1638 lpfc_nlp_put(ndlp);
1559 return 1;1639 return 1;
1560 }1640 }
@@ -1591,35 +1671,21 @@ lpfc_issue_els_farpr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) · 30 unmodified lines
1591 phba->fc_stat.elsXmitFARPR++;1671 phba->fc_stat.elsXmitFARPR++;
1592 elsiocb->iocb_cmpl = lpfc_cmpl_els_cmd;1672 elsiocb->iocb_cmpl = lpfc_cmpl_els_cmd;
1593 if (lpfc_sli_issue_iocb(phba, pring, elsiocb, 0) == IOCB_ERROR) {1673 if (lpfc_sli_issue_iocb(phba, pring, elsiocb, 0) == IOCB_ERROR) {
1674 /* The additional lpfc_nlp_put will cause the following
1675 * lpfc_els_free_iocb routine to trigger the release of
1676 * the node.
1677 */
1594 lpfc_nlp_put(ndlp);1678 lpfc_nlp_put(ndlp);
1595 lpfc_els_free_iocb(phba, elsiocb);1679 lpfc_els_free_iocb(phba, elsiocb);
1596 return 1;1680 return 1;
1597 }1681 }
1682 /* This will cause the callback-function lpfc_cmpl_els_cmd to
1683 * trigger the release of the node.
1684 */
1598 lpfc_nlp_put(ndlp);1685 lpfc_nlp_put(ndlp);
1599 return 0;1686 return 0;
1600}1687}
1601 1688
1602static void
1603lpfc_end_rscn(struct lpfc_vport *vport)
1604{
1605 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1606
1607 if (vport->fc_flag & FC_RSCN_MODE) {
1608 /*
1609 * Check to see if more RSCNs came in while we were
1610 * processing this one.
1611 */
1612 if (vport->fc_rscn_id_cnt ||
1613 (vport->fc_flag & FC_RSCN_DISCOVERY) != 0)
1614 lpfc_els_handle_rscn(vport);
1615 else {
1616 spin_lock_irq(shost->host_lock);
1617 vport->fc_flag &= ~FC_RSCN_MODE;
1618 spin_unlock_irq(shost->host_lock);
1619 }
1620 }
1621}
1622
1623void1689void
1624lpfc_cancel_retry_delay_tmo(struct lpfc_vport *vport, struct lpfc_nodelist *nlp)1690lpfc_cancel_retry_delay_tmo(struct lpfc_vport *vport, struct lpfc_nodelist *nlp)
1625{1691{
@@ -1675,7 +1741,10 @@ lpfc_els_retry_delay(unsigned long ptr) · 49 unmodified lines
1675 return;1741 return;
1676 }1742 }
1677 1743
1678 evtp->evt_arg1 = ndlp;1744 /* We need to hold the node by incrementing the reference
1745 * count until the queued work is done
1746 */
1747 evtp->evt_arg1 = lpfc_nlp_get(ndlp);
1679 evtp->evt = LPFC_EVT_ELS_RETRY;1748 evtp->evt = LPFC_EVT_ELS_RETRY;
1680 list_add_tail(&evtp->evt_listp, &phba->work_list);1749 list_add_tail(&evtp->evt_listp, &phba->work_list);
1681 if (phba->work_wait)1750 if (phba->work_wait)
@@ -1759,6 +1828,7 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 77 unmodified lines
1759 uint32_t *elscmd;1828 uint32_t *elscmd;
1760 struct ls_rjt stat;1829 struct ls_rjt stat;
1761 int retry = 0, maxretry = lpfc_max_els_tries, delay = 0;1830 int retry = 0, maxretry = lpfc_max_els_tries, delay = 0;
1831 int logerr = 0;
1762 uint32_t cmd = 0;1832 uint32_t cmd = 0;
1763 uint32_t did;1833 uint32_t did;
1764 1834
@@ -1815,6 +1885,7 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 50 unmodified lines
1815 break;1885 break;
1816 1886
1817 case IOERR_NO_RESOURCES:1887 case IOERR_NO_RESOURCES:
1888 logerr = 1; /* HBA out of resources */
1818 retry = 1;1889 retry = 1;
1819 if (cmdiocb->retry > 100)1890 if (cmdiocb->retry > 100)
1820 delay = 100;1891 delay = 100;
@@ -1843,6 +1914,7 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 22 unmodified lines
1843 1914
1844 case IOSTAT_NPORT_BSY:1915 case IOSTAT_NPORT_BSY:
1845 case IOSTAT_FABRIC_BSY:1916 case IOSTAT_FABRIC_BSY:
1917 logerr = 1; /* Fabric / Remote NPort out of resources */
1846 retry = 1;1918 retry = 1;
1847 break;1919 break;
1848 1920
@@ -1923,6 +1995,15 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 74 unmodified lines
1923 if (did == FDMI_DID)1995 if (did == FDMI_DID)
1924 retry = 1;1996 retry = 1;
1925 1997
1998 if ((cmd == ELS_CMD_FLOGI) &&
1999 (phba->fc_topology != TOPOLOGY_LOOP)) {
2000 /* FLOGI retry policy */
2001 retry = 1;
2002 maxretry = 48;
2003 if (cmdiocb->retry >= 32)
2004 delay = 1000;
2005 }
2006
1926 if ((++cmdiocb->retry) >= maxretry) {2007 if ((++cmdiocb->retry) >= maxretry) {
1927 phba->fc_stat.elsRetryExceeded++;2008 phba->fc_stat.elsRetryExceeded++;
1928 retry = 0;2009 retry = 0;
@@ -2006,11 +2087,46 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 77 unmodified lines
2006 }2087 }
2007 }2088 }
2008 /* No retry ELS command <elsCmd> to remote NPORT <did> */2089 /* No retry ELS command <elsCmd> to remote NPORT <did> */
2009 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,2090 if (logerr) {
2091 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
2092 "0137 No retry ELS command x%x to remote "
2093 "NPORT x%x: Out of Resources: Error:x%x/%x\n",
2094 cmd, did, irsp->ulpStatus,
2095 irsp->un.ulpWord[4]);
2096 }
2097 else {
2098 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2010 "0108 No retry ELS command x%x to remote "2099 "0108 No retry ELS command x%x to remote "
2011 "NPORT x%x Retried:%d Error:x%x/%x\n",2100 "NPORT x%x Retried:%d Error:x%x/%x\n",
2012 cmd, did, cmdiocb->retry, irsp->ulpStatus,2101 cmd, did, cmdiocb->retry, irsp->ulpStatus,
2013 irsp->un.ulpWord[4]);2102 irsp->un.ulpWord[4]);
2103 }
2104 return 0;
2105}
2106
2107static int
2108lpfc_els_free_data(struct lpfc_hba *phba, struct lpfc_dmabuf *buf_ptr1)
2109{
2110 struct lpfc_dmabuf *buf_ptr;
2111
2112 /* Free the response before processing the command. */
2113 if (!list_empty(&buf_ptr1->list)) {
2114 list_remove_head(&buf_ptr1->list, buf_ptr,
2115 struct lpfc_dmabuf,
2116 list);
2117 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys);
2118 kfree(buf_ptr);
2119 }
2120 lpfc_mbuf_free(phba, buf_ptr1->virt, buf_ptr1->phys);
2121 kfree(buf_ptr1);
2122 return 0;
2123}
2124
2125static int
2126lpfc_els_free_bpl(struct lpfc_hba *phba, struct lpfc_dmabuf *buf_ptr)
2127{
2128 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys);
2129 kfree(buf_ptr);
2014 return 0;2130 return 0;
2015}2131}
2016 2132
@@ -2018,30 +2134,63 @@ int · 1 unmodified line
2018lpfc_els_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *elsiocb)2134lpfc_els_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *elsiocb)
2019{2135{
2020 struct lpfc_dmabuf *buf_ptr, *buf_ptr1;2136 struct lpfc_dmabuf *buf_ptr, *buf_ptr1;
2137 struct lpfc_nodelist *ndlp;
2021 2138
2022 if (elsiocb->context1) {2139 ndlp = (struct lpfc_nodelist *)elsiocb->context1;
2023 lpfc_nlp_put(elsiocb->context1);2140 if (ndlp) {
2141 if (ndlp->nlp_flag & NLP_DEFER_RM) {
2142 lpfc_nlp_put(ndlp);
2143
2144 /* If the ndlp is not being used by another discovery
2145 * thread, free it.
2146 */
2147 if (!lpfc_nlp_not_used(ndlp)) {
2148 /* If ndlp is being used by another discovery
2149 * thread, just clear NLP_DEFER_RM
2150 */
2151 ndlp->nlp_flag &= ~NLP_DEFER_RM;
2152 }
2153 }
2154 else
2155 lpfc_nlp_put(ndlp);
2024 elsiocb->context1 = NULL;2156 elsiocb->context1 = NULL;
2025 }2157 }
2026 /* context2 = cmd, context2->next = rsp, context3 = bpl */2158 /* context2 = cmd, context2->next = rsp, context3 = bpl */
2027 if (elsiocb->context2) {2159 if (elsiocb->context2) {
2028 buf_ptr1 = (struct lpfc_dmabuf *) elsiocb->context2;2160 if (elsiocb->iocb_flag & LPFC_DELAY_MEM_FREE) {
2029 /* Free the response before processing the command. */2161 /* Firmware could still be in progress of DMAing
2030 if (!list_empty(&buf_ptr1->list)) {2162 * payload, so don't free data buffer till after
2031 list_remove_head(&buf_ptr1->list, buf_ptr,2163 * a hbeat.
2032 struct lpfc_dmabuf,2164 */
2033 list);2165 elsiocb->iocb_flag &= ~LPFC_DELAY_MEM_FREE;
2034 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys);2166 buf_ptr = elsiocb->context2;
2035 kfree(buf_ptr);2167 elsiocb->context2 = NULL;
2168 if (buf_ptr) {
2169 buf_ptr1 = NULL;
2170 spin_lock_irq(&phba->hbalock);
2171 if (!list_empty(&buf_ptr->list)) {
2172 list_remove_head(&buf_ptr->list,
2173 buf_ptr1, struct lpfc_dmabuf,
2174 list);
2175 INIT_LIST_HEAD(&buf_ptr1->list);
2176 list_add_tail(&buf_ptr1->list,
2177 &phba->elsbuf);
2178 phba->elsbuf_cnt++;
2179 }
2180 INIT_LIST_HEAD(&buf_ptr->list);
2181 list_add_tail(&buf_ptr->list, &phba->elsbuf);
2182 phba->elsbuf_cnt++;
2183 spin_unlock_irq(&phba->hbalock);
2184 }
2185 } else {
2186 buf_ptr1 = (struct lpfc_dmabuf *) elsiocb->context2;
2187 lpfc_els_free_data(phba, buf_ptr1);
2036 }2188 }
2037 lpfc_mbuf_free(phba, buf_ptr1->virt, buf_ptr1->phys);
2038 kfree(buf_ptr1);
2039 }2189 }
2040 2190
2041 if (elsiocb->context3) {2191 if (elsiocb->context3) {
2042 buf_ptr = (struct lpfc_dmabuf *) elsiocb->context3;2192 buf_ptr = (struct lpfc_dmabuf *) elsiocb->context3;
2043 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys);2193 lpfc_els_free_bpl(phba, buf_ptr);
2044 kfree(buf_ptr);
2045 }2194 }
2046 lpfc_sli_release_iocbq(phba, elsiocb);2195 lpfc_sli_release_iocbq(phba, elsiocb);
2047 return 0;2196 return 0;
@@ -2065,15 +2214,20 @@ lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 17 unmodified lines
2065 "Data: x%x x%x x%x\n",2214 "Data: x%x x%x x%x\n",
2066 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,2215 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
2067 ndlp->nlp_rpi);2216 ndlp->nlp_rpi);
2068 switch (ndlp->nlp_state) {2217
2069 case NLP_STE_UNUSED_NODE: /* node is just allocated */2218 if (ndlp->nlp_state == NLP_STE_NPR_NODE) {
2070 lpfc_drop_node(vport, ndlp);2219 /* NPort Recovery mode or node is just allocated */
2071 break;2220 if (!lpfc_nlp_not_used(ndlp)) {
2072 case NLP_STE_NPR_NODE: /* NPort Recovery mode */2221 /* If the ndlp is being used by another discovery
2073 lpfc_unreg_rpi(vport, ndlp);2222 * thread, just unregister the RPI.
2074 break;2223 */
2075 default:2224 lpfc_unreg_rpi(vport, ndlp);
2076 break;2225 } else {
2226 /* Indicate the node has already released, should
2227 * not reference to it from within lpfc_els_free_iocb.
2228 */
2229 cmdiocb->context1 = NULL;
2230 }
2077 }2231 }
2078 lpfc_els_free_iocb(phba, cmdiocb);2232 lpfc_els_free_iocb(phba, cmdiocb);
2079 return;2233 return;
@@ -2089,7 +2243,14 @@ lpfc_mbx_cmpl_dflt_rpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 9 unmodified lines
2089 lpfc_mbuf_free(phba, mp->virt, mp->phys);2243 lpfc_mbuf_free(phba, mp->virt, mp->phys);
2090 kfree(mp);2244 kfree(mp);
2091 mempool_free(pmb, phba->mbox_mem_pool);2245 mempool_free(pmb, phba->mbox_mem_pool);
2092 lpfc_nlp_put(ndlp);2246 if (ndlp) {
2247 lpfc_nlp_put(ndlp);
2248 /* This is the end of the default RPI cleanup logic for this
2249 * ndlp. If no other discovery threads are using this ndlp.
2250 * we should free all resources associated with it.
2251 */
2252 lpfc_nlp_not_used(ndlp);
2253 }
2093 return;2254 return;
2094}2255}
2095 2256
@@ -2100,15 +2261,29 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 4 unmodified lines
2100 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1;2261 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1;
2101 struct lpfc_vport *vport = ndlp ? ndlp->vport : NULL;2262 struct lpfc_vport *vport = ndlp ? ndlp->vport : NULL;
2102 struct Scsi_Host *shost = vport ? lpfc_shost_from_vport(vport) : NULL;2263 struct Scsi_Host *shost = vport ? lpfc_shost_from_vport(vport) : NULL;
2103 IOCB_t *irsp;2264 IOCB_t *irsp;
2265 uint8_t *pcmd;
2104 LPFC_MBOXQ_t *mbox = NULL;2266 LPFC_MBOXQ_t *mbox = NULL;
2105 struct lpfc_dmabuf *mp = NULL;2267 struct lpfc_dmabuf *mp = NULL;
2268 uint32_t ls_rjt = 0;
2106 2269
2107 irsp = &rspiocb->iocb;2270 irsp = &rspiocb->iocb;
2108 2271
2109 if (cmdiocb->context_un.mbox)2272 if (cmdiocb->context_un.mbox)
2110 mbox = cmdiocb->context_un.mbox;2273 mbox = cmdiocb->context_un.mbox;
2111 2274
2275 /* First determine if this is a LS_RJT cmpl. Note, this callback
2276 * function can have cmdiocb->contest1 (ndlp) field set to NULL.
2277 */
2278 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) cmdiocb->context2)->virt);
2279 if (ndlp && (*((uint32_t *) (pcmd)) == ELS_CMD_LS_RJT)) {
2280 /* A LS_RJT associated with Default RPI cleanup has its own
2281 * seperate code path.
2282 */
2283 if (!(ndlp->nlp_flag & NLP_RM_DFLT_RPI))
2284 ls_rjt = 1;
2285 }
2286
2112 /* Check to see if link went down during discovery */2287 /* Check to see if link went down during discovery */
2113 if (!ndlp || lpfc_els_chk_latt(vport)) {2288 if (!ndlp || lpfc_els_chk_latt(vport)) {
2114 if (mbox) {2289 if (mbox) {
@@ -2119,6 +2294,15 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 4 unmodified lines
2119 }2294 }
2120 mempool_free(mbox, phba->mbox_mem_pool);2295 mempool_free(mbox, phba->mbox_mem_pool);
2121 }2296 }
2297 if (ndlp && (ndlp->nlp_flag & NLP_RM_DFLT_RPI))
2298 if (lpfc_nlp_not_used(ndlp)) {
2299 ndlp = NULL;
2300 /* Indicate the node has already released,
2301 * should not reference to it from within
2302 * the routine lpfc_els_free_iocb.
2303 */
2304 cmdiocb->context1 = NULL;
2305 }
2122 goto out;2306 goto out;
2123 }2307 }
2124 2308
@@ -2150,20 +2334,39 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 25 unmodified lines
2150 lpfc_nlp_set_state(vport, ndlp,2334 lpfc_nlp_set_state(vport, ndlp,
2151 NLP_STE_REG_LOGIN_ISSUE);2335 NLP_STE_REG_LOGIN_ISSUE);
2152 }2336 }
2153 if (lpfc_sli_issue_mbox(phba, mbox,2337 if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT)
2154 (MBX_NOWAIT | MBX_STOP_IOCB))
2155 != MBX_NOT_FINISHED) {2338 != MBX_NOT_FINISHED) {
2156 goto out;2339 goto out;
2157 }2340 }
2158 lpfc_nlp_put(ndlp);2341
2159 /* NOTE: we should have messages for unsuccessful2342 /* ELS rsp: Cannot issue reg_login for <NPortid> */
2160 reglogin */2343 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
2344 "0138 ELS rsp: Cannot issue reg_login for x%x "
2345 "Data: x%x x%x x%x\n",
2346 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
2347 ndlp->nlp_rpi);
2348
2349 if (lpfc_nlp_not_used(ndlp)) {
2350 ndlp = NULL;
2351 /* Indicate node has already been released,
2352 * should not reference to it from within
2353 * the routine lpfc_els_free_iocb.
2354 */
2355 cmdiocb->context1 = NULL;
2356 }
2161 } else {2357 } else {
2162 /* Do not drop node for lpfc_els_abort'ed ELS cmds */2358 /* Do not drop node for lpfc_els_abort'ed ELS cmds */
2163 if (!lpfc_error_lost_link(irsp) &&2359 if (!lpfc_error_lost_link(irsp) &&
2164 ndlp->nlp_flag & NLP_ACC_REGLOGIN) {2360 ndlp->nlp_flag & NLP_ACC_REGLOGIN) {
2165 lpfc_drop_node(vport, ndlp);2361 if (lpfc_nlp_not_used(ndlp)) {
2166 ndlp = NULL;2362 ndlp = NULL;
2363 /* Indicate node has already been
2364 * released, should not reference
2365 * to it from within the routine
2366 * lpfc_els_free_iocb.
2367 */
2368 cmdiocb->context1 = NULL;
2369 }
2167 }2370 }
2168 }2371 }
2169 mp = (struct lpfc_dmabuf *) mbox->context1;2372 mp = (struct lpfc_dmabuf *) mbox->context1;
@@ -2178,7 +2381,21 @@ out: · 8 unmodified lines
2178 spin_lock_irq(shost->host_lock);2381 spin_lock_irq(shost->host_lock);
2179 ndlp->nlp_flag &= ~(NLP_ACC_REGLOGIN | NLP_RM_DFLT_RPI);2382 ndlp->nlp_flag &= ~(NLP_ACC_REGLOGIN | NLP_RM_DFLT_RPI);
2180 spin_unlock_irq(shost->host_lock);2383 spin_unlock_irq(shost->host_lock);
2384
2385 /* If the node is not being used by another discovery thread,
2386 * and we are sending a reject, we are done with it.
2387 * Release driver reference count here and free associated
2388 * resources.
2389 */
2390 if (ls_rjt)
2391 if (lpfc_nlp_not_used(ndlp))
2392 /* Indicate node has already been released,
2393 * should not reference to it from within
2394 * the routine lpfc_els_free_iocb.
2395 */
2396 cmdiocb->context1 = NULL;
2181 }2397 }
2398
2182 lpfc_els_free_iocb(phba, cmdiocb);2399 lpfc_els_free_iocb(phba, cmdiocb);
2183 return;2400 return;
2184}2401}
@@ -2349,14 +2566,6 @@ lpfc_els_rsp_reject(struct lpfc_vport *vport, uint32_t rejectError, · 164 unmodified lines
2349 elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp;2566 elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp;
2350 rc = lpfc_sli_issue_iocb(phba, pring, elsiocb, 0);2567 rc = lpfc_sli_issue_iocb(phba, pring, elsiocb, 0);
2351 2568
2352 /* If the node is in the UNUSED state, and we are sending
2353 * a reject, we are done with it. Release driver reference
2354 * count here. The outstanding els will release its reference on
2355 * completion and the node can be freed then.
2356 */
2357 if (ndlp->nlp_state == NLP_STE_UNUSED_NODE)
2358 lpfc_nlp_put(ndlp);
2359
2360 if (rc == IOCB_ERROR) {2569 if (rc == IOCB_ERROR) {
2361 lpfc_els_free_iocb(phba, elsiocb);2570 lpfc_els_free_iocb(phba, elsiocb);
2362 return 1;2571 return 1;
@@ -2642,7 +2851,10 @@ lpfc_els_disc_plogi(struct lpfc_vport *vport) · 279 unmodified lines
2642 }2851 }
2643 }2852 }
2644 }2853 }
2645 if (sentplogi == 0) {2854 if (sentplogi) {
2855 lpfc_set_disctmo(vport);
2856 }
2857 else {
2646 spin_lock_irq(shost->host_lock);2858 spin_lock_irq(shost->host_lock);
2647 vport->fc_flag &= ~FC_NLP_MORE;2859 vport->fc_flag &= ~FC_NLP_MORE;
2648 spin_unlock_irq(shost->host_lock);2860 spin_unlock_irq(shost->host_lock);
@@ -2830,10 +3042,10 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 181 unmodified lines
2830 "RCV RSCN defer: did:x%x/ste:x%x flg:x%x",3042 "RCV RSCN defer: did:x%x/ste:x%x flg:x%x",
2831 ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag);3043 ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag);
2832 3044
3045 spin_lock_irq(shost->host_lock);
2833 vport->fc_flag |= FC_RSCN_DEFERRED;3046 vport->fc_flag |= FC_RSCN_DEFERRED;
2834 if ((rscn_cnt < FC_MAX_HOLD_RSCN) &&3047 if ((rscn_cnt < FC_MAX_HOLD_RSCN) &&
2835 !(vport->fc_flag & FC_RSCN_DISCOVERY)) {3048 !(vport->fc_flag & FC_RSCN_DISCOVERY)) {
2836 spin_lock_irq(shost->host_lock);
2837 vport->fc_flag |= FC_RSCN_MODE;3049 vport->fc_flag |= FC_RSCN_MODE;
2838 spin_unlock_irq(shost->host_lock);3050 spin_unlock_irq(shost->host_lock);
2839 if (rscn_cnt) {3051 if (rscn_cnt) {
@@ -2862,7 +3074,6 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 22 unmodified lines
2862 vport->fc_rscn_id_cnt, vport->fc_flag,3074 vport->fc_rscn_id_cnt, vport->fc_flag,
2863 vport->port_state);3075 vport->port_state);
2864 } else {3076 } else {
2865 spin_lock_irq(shost->host_lock);
2866 vport->fc_flag |= FC_RSCN_DISCOVERY;3077 vport->fc_flag |= FC_RSCN_DISCOVERY;
2867 spin_unlock_irq(shost->host_lock);3078 spin_unlock_irq(shost->host_lock);
2868 /* ReDiscovery RSCN */3079 /* ReDiscovery RSCN */
@@ -2877,7 +3088,9 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 8 unmodified lines
2877 3088
2878 /* send RECOVERY event for ALL nodes that match RSCN payload */3089 /* send RECOVERY event for ALL nodes that match RSCN payload */
2879 lpfc_rscn_recovery_check(vport);3090 lpfc_rscn_recovery_check(vport);
3091 spin_lock_irq(shost->host_lock);
2880 vport->fc_flag &= ~FC_RSCN_DEFERRED;3092 vport->fc_flag &= ~FC_RSCN_DEFERRED;
3093 spin_unlock_irq(shost->host_lock);
2881 return 0;3094 return 0;
2882 }3095 }
2883 3096
@@ -2929,6 +3142,8 @@ lpfc_els_handle_rscn(struct lpfc_vport *vport) · 45 unmodified lines
2929 3142
2930 /* To process RSCN, first compare RSCN data with NameServer */3143 /* To process RSCN, first compare RSCN data with NameServer */
2931 vport->fc_ns_retry = 0;3144 vport->fc_ns_retry = 0;
3145 vport->num_disc_nodes = 0;
3146
2932 ndlp = lpfc_findnode_did(vport, NameServer_DID);3147 ndlp = lpfc_findnode_did(vport, NameServer_DID);
2933 if (ndlp && ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) {3148 if (ndlp && ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) {
2934 /* Good ndlp, issue CT Request to NameServer */3149 /* Good ndlp, issue CT Request to NameServer */
@@ -3022,8 +3237,7 @@ lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 87 unmodified lines
3022 mbox->mb.un.varInitLnk.lipsr_AL_PA = 0;3237 mbox->mb.un.varInitLnk.lipsr_AL_PA = 0;
3023 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;3238 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
3024 mbox->vport = vport;3239 mbox->vport = vport;
3025 rc = lpfc_sli_issue_mbox3240 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
3026 (phba, mbox, (MBX_NOWAIT | MBX_STOP_IOCB));
3027 lpfc_set_loopback_flag(phba);3241 lpfc_set_loopback_flag(phba);
3028 if (rc == MBX_NOT_FINISHED) {3242 if (rc == MBX_NOT_FINISHED) {
3029 mempool_free(mbox, phba->mbox_mem_pool);3243 mempool_free(mbox, phba->mbox_mem_pool);
@@ -3140,7 +3354,10 @@ lpfc_els_rsp_rps_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 110 unmodified lines
3140 elsiocb = lpfc_prep_els_iocb(phba->pport, 0, cmdsize,3354 elsiocb = lpfc_prep_els_iocb(phba->pport, 0, cmdsize,
3141 lpfc_max_els_tries, ndlp,3355 lpfc_max_els_tries, ndlp,
3142 ndlp->nlp_DID, ELS_CMD_ACC);3356 ndlp->nlp_DID, ELS_CMD_ACC);
3357
3358 /* Decrement the ndlp reference count from previous mbox command */
3143 lpfc_nlp_put(ndlp);3359 lpfc_nlp_put(ndlp);
3360
3144 if (!elsiocb)3361 if (!elsiocb)
3145 return;3362 return;
3146 3363
@@ -3160,13 +3377,13 @@ lpfc_els_rsp_rps_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 13 unmodified lines
3160 status |= 0x4;3377 status |= 0x4;
3161 3378
3162 rps_rsp->rsvd1 = 0;3379 rps_rsp->rsvd1 = 0;
3163 rps_rsp->portStatus = be16_to_cpu(status);3380 rps_rsp->portStatus = cpu_to_be16(status);
3164 rps_rsp->linkFailureCnt = be32_to_cpu(mb->un.varRdLnk.linkFailureCnt);3381 rps_rsp->linkFailureCnt = cpu_to_be32(mb->un.varRdLnk.linkFailureCnt);
3165 rps_rsp->lossSyncCnt = be32_to_cpu(mb->un.varRdLnk.lossSyncCnt);3382 rps_rsp->lossSyncCnt = cpu_to_be32(mb->un.varRdLnk.lossSyncCnt);
3166 rps_rsp->lossSignalCnt = be32_to_cpu(mb->un.varRdLnk.lossSignalCnt);3383 rps_rsp->lossSignalCnt = cpu_to_be32(mb->un.varRdLnk.lossSignalCnt);
3167 rps_rsp->primSeqErrCnt = be32_to_cpu(mb->un.varRdLnk.primSeqErrCnt);3384 rps_rsp->primSeqErrCnt = cpu_to_be32(mb->un.varRdLnk.primSeqErrCnt);
3168 rps_rsp->invalidXmitWord = be32_to_cpu(mb->un.varRdLnk.invalidXmitWord);3385 rps_rsp->invalidXmitWord = cpu_to_be32(mb->un.varRdLnk.invalidXmitWord);
3169 rps_rsp->crcCnt = be32_to_cpu(mb->un.varRdLnk.crcCnt);3386 rps_rsp->crcCnt = cpu_to_be32(mb->un.varRdLnk.crcCnt);
3170 /* Xmit ELS RPS ACC response tag <ulpIoTag> */3387 /* Xmit ELS RPS ACC response tag <ulpIoTag> */
3171 lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_ELS,3388 lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_ELS,
3172 "0118 Xmit ELS RPS ACC response tag x%x xri x%x, "3389 "0118 Xmit ELS RPS ACC response tag x%x xri x%x, "
@@ -3223,11 +3440,13 @@ lpfc_els_rcv_rps(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 50 unmodified lines
3223 mbox->context2 = lpfc_nlp_get(ndlp);3440 mbox->context2 = lpfc_nlp_get(ndlp);
3224 mbox->vport = vport;3441 mbox->vport = vport;
3225 mbox->mbox_cmpl = lpfc_els_rsp_rps_acc;3442 mbox->mbox_cmpl = lpfc_els_rsp_rps_acc;
3226 if (lpfc_sli_issue_mbox (phba, mbox,3443 if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT)
3227 (MBX_NOWAIT | MBX_STOP_IOCB)) != MBX_NOT_FINISHED)3444 != MBX_NOT_FINISHED)
3228 /* Mbox completion will send ELS Response */3445 /* Mbox completion will send ELS Response */
3229 return 0;3446 return 0;
3230 3447 /* Decrement reference count used for the failed mbox
3448 * command.
3449 */
3231 lpfc_nlp_put(ndlp);3450 lpfc_nlp_put(ndlp);
3232 mempool_free(mbox, phba->mbox_mem_pool);3451 mempool_free(mbox, phba->mbox_mem_pool);
3233 }3452 }
@@ -3461,6 +3680,7 @@ lpfc_els_rcv_fan(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 227 unmodified lines
3461 * other NLP_FABRIC logins3680 * other NLP_FABRIC logins
3462 */3681 */
3463 lpfc_drop_node(vport, ndlp);3682 lpfc_drop_node(vport, ndlp);
3683
3464 } else if (!(ndlp->nlp_flag & NLP_NPR_ADISC)) {3684 } else if (!(ndlp->nlp_flag & NLP_NPR_ADISC)) {
3465 /* Fail outstanding I/O now since this3685 /* Fail outstanding I/O now since this
3466 * device is marked for PLOGI3686 * device is marked for PLOGI
@@ -3469,8 +3689,6 @@ lpfc_els_rcv_fan(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 2 unmodified lines
3469 }3689 }
3470 }3690 }
3471 3691
3472 vport->port_state = LPFC_FLOGI;
3473 lpfc_set_disctmo(vport);
3474 lpfc_initial_flogi(vport);3692 lpfc_initial_flogi(vport);
3475 return 0;3693 return 0;
3476 }3694 }
@@ -3711,6 +3929,7 @@ static void · 234 unmodified lines
3711lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,3929lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
3712 struct lpfc_vport *vport, struct lpfc_iocbq *elsiocb)3930 struct lpfc_vport *vport, struct lpfc_iocbq *elsiocb)
3713{3931{
3932 struct Scsi_Host *shost;
3714 struct lpfc_nodelist *ndlp;3933 struct lpfc_nodelist *ndlp;
3715 struct ls_rjt stat;3934 struct ls_rjt stat;
3716 uint32_t *payload;3935 uint32_t *payload;
@@ -3750,11 +3969,19 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 33 unmodified lines
3750 goto dropit;3969 goto dropit;
3751 3970
3752 lpfc_nlp_init(vport, ndlp, did);3971 lpfc_nlp_init(vport, ndlp, did);
3972 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
3753 newnode = 1;3973 newnode = 1;
3754 if ((did & Fabric_DID_MASK) == Fabric_DID_MASK) {3974 if ((did & Fabric_DID_MASK) == Fabric_DID_MASK) {
3755 ndlp->nlp_type |= NLP_FABRIC;3975 ndlp->nlp_type |= NLP_FABRIC;
3756 }3976 }
3757 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNUSED_NODE);3977 }
3978 else {
3979 if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) {
3980 /* This is simular to the new node path */
3981 lpfc_nlp_get(ndlp);
3982 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
3983 newnode = 1;
3984 }
3758 }3985 }
3759 3986
3760 phba->fc_stat.elsRcvFrame++;3987 phba->fc_stat.elsRcvFrame++;
@@ -3783,6 +4010,12 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 22 unmodified lines
3783 rjt_err = LSRJT_UNABLE_TPC;4010 rjt_err = LSRJT_UNABLE_TPC;
3784 break;4011 break;
3785 }4012 }
4013
4014 shost = lpfc_shost_from_vport(vport);
4015 spin_lock_irq(shost->host_lock);
4016 ndlp->nlp_flag &= ~NLP_TARGET_REMOVE;
4017 spin_unlock_irq(shost->host_lock);
4018
3786 lpfc_disc_state_machine(vport, ndlp, elsiocb,4019 lpfc_disc_state_machine(vport, ndlp, elsiocb,
3787 NLP_EVT_RCV_PLOGI);4020 NLP_EVT_RCV_PLOGI);
3788 4021
@@ -3795,7 +4028,7 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 6 unmodified lines
3795 phba->fc_stat.elsRcvFLOGI++;4028 phba->fc_stat.elsRcvFLOGI++;
3796 lpfc_els_rcv_flogi(vport, elsiocb, ndlp);4029 lpfc_els_rcv_flogi(vport, elsiocb, ndlp);
3797 if (newnode)4030 if (newnode)
3798 lpfc_drop_node(vport, ndlp);4031 lpfc_nlp_put(ndlp);
3799 break;4032 break;
3800 case ELS_CMD_LOGO:4033 case ELS_CMD_LOGO:
3801 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,4034 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
@@ -3825,7 +4058,7 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 23 unmodified lines
3825 phba->fc_stat.elsRcvRSCN++;4058 phba->fc_stat.elsRcvRSCN++;
3826 lpfc_els_rcv_rscn(vport, elsiocb, ndlp);4059 lpfc_els_rcv_rscn(vport, elsiocb, ndlp);
3827 if (newnode)4060 if (newnode)
3828 lpfc_drop_node(vport, ndlp);4061 lpfc_nlp_put(ndlp);
3829 break;4062 break;
3830 case ELS_CMD_ADISC:4063 case ELS_CMD_ADISC:
3831 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,4064 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
@@ -3897,7 +4130,7 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 65 unmodified lines
3897 phba->fc_stat.elsRcvLIRR++;4130 phba->fc_stat.elsRcvLIRR++;
3898 lpfc_els_rcv_lirr(vport, elsiocb, ndlp);4131 lpfc_els_rcv_lirr(vport, elsiocb, ndlp);
3899 if (newnode)4132 if (newnode)
3900 lpfc_drop_node(vport, ndlp);4133 lpfc_nlp_put(ndlp);
3901 break;4134 break;
3902 case ELS_CMD_RPS:4135 case ELS_CMD_RPS:
3903 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,4136 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
@@ -3907,7 +4140,7 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 3 unmodified lines
3907 phba->fc_stat.elsRcvRPS++;4140 phba->fc_stat.elsRcvRPS++;
3908 lpfc_els_rcv_rps(vport, elsiocb, ndlp);4141 lpfc_els_rcv_rps(vport, elsiocb, ndlp);
3909 if (newnode)4142 if (newnode)
3910 lpfc_drop_node(vport, ndlp);4143 lpfc_nlp_put(ndlp);
3911 break;4144 break;
3912 case ELS_CMD_RPL:4145 case ELS_CMD_RPL:
3913 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,4146 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
@@ -3917,7 +4150,7 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 3 unmodified lines
3917 phba->fc_stat.elsRcvRPL++;4150 phba->fc_stat.elsRcvRPL++;
3918 lpfc_els_rcv_rpl(vport, elsiocb, ndlp);4151 lpfc_els_rcv_rpl(vport, elsiocb, ndlp);
3919 if (newnode)4152 if (newnode)
3920 lpfc_drop_node(vport, ndlp);4153 lpfc_nlp_put(ndlp);
3921 break;4154 break;
3922 case ELS_CMD_RNID:4155 case ELS_CMD_RNID:
3923 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,4156 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
@@ -3927,7 +4160,7 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 3 unmodified lines
3927 phba->fc_stat.elsRcvRNID++;4160 phba->fc_stat.elsRcvRNID++;
3928 lpfc_els_rcv_rnid(vport, elsiocb, ndlp);4161 lpfc_els_rcv_rnid(vport, elsiocb, ndlp);
3929 if (newnode)4162 if (newnode)
3930 lpfc_drop_node(vport, ndlp);4163 lpfc_nlp_put(ndlp);
3931 break;4164 break;
3932 default:4165 default:
3933 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,4166 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
@@ -3942,7 +4175,7 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 8 unmodified lines
3942 "0115 Unknown ELS command x%x "4175 "0115 Unknown ELS command x%x "
3943 "received from NPORT x%x\n", cmd, did);4176 "received from NPORT x%x\n", cmd, did);
3944 if (newnode)4177 if (newnode)
3945 lpfc_drop_node(vport, ndlp);4178 lpfc_nlp_put(ndlp);
3946 break;4179 break;
3947 }4180 }
3948 4181
@@ -3958,10 +4191,11 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 9 unmodified lines
3958 return;4191 return;
3959 4192
3960dropit:4193dropit:
3961 lpfc_printf_log(phba, KERN_ERR, LOG_ELS,4194 if (vport && !(vport->load_flag & FC_UNLOADING))
4195 lpfc_printf_log(phba, KERN_ERR, LOG_ELS,
3962 "(%d):0111 Dropping received ELS cmd "4196 "(%d):0111 Dropping received ELS cmd "
3963 "Data: x%x x%x x%x\n",4197 "Data: x%x x%x x%x\n",
3964 vport ? vport->vpi : 0xffff, icmd->ulpStatus,4198 vport->vpi, icmd->ulpStatus,
3965 icmd->un.ulpWord[4], icmd->ulpTimeout);4199 icmd->un.ulpWord[4], icmd->ulpTimeout);
3966 phba->fc_stat.elsRcvDrop++;4200 phba->fc_stat.elsRcvDrop++;
3967}4201}
@@ -4114,8 +4348,9 @@ lpfc_cmpl_reg_new_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 146 unmodified lines
4114 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) pmb->context2;4348 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) pmb->context2;
4115 MAILBOX_t *mb = &pmb->mb;4349 MAILBOX_t *mb = &pmb->mb;
4116 4350
4351 spin_lock_irq(shost->host_lock);
4117 vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI;4352 vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI;
4118 lpfc_nlp_put(ndlp);4353 spin_unlock_irq(shost->host_lock);
4119 4354
4120 if (mb->mbxStatus) {4355 if (mb->mbxStatus) {
4121 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,4356 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
@@ -4135,7 +4370,9 @@ lpfc_cmpl_reg_new_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 13 unmodified lines
4135 default:4370 default:
4136 /* Try to recover from this error */4371 /* Try to recover from this error */
4137 lpfc_mbx_unreg_vpi(vport);4372 lpfc_mbx_unreg_vpi(vport);
4373 spin_lock_irq(shost->host_lock);
4138 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;4374 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
4375 spin_unlock_irq(shost->host_lock);
4139 lpfc_initial_fdisc(vport);4376 lpfc_initial_fdisc(vport);
4140 break;4377 break;
4141 }4378 }
@@ -4146,14 +4383,21 @@ lpfc_cmpl_reg_new_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 4 unmodified lines
4146 else4383 else
4147 lpfc_do_scr_ns_plogi(phba, vport);4384 lpfc_do_scr_ns_plogi(phba, vport);
4148 }4385 }
4386
4387 /* Now, we decrement the ndlp reference count held for this
4388 * callback function
4389 */
4390 lpfc_nlp_put(ndlp);
4391
4149 mempool_free(pmb, phba->mbox_mem_pool);4392 mempool_free(pmb, phba->mbox_mem_pool);
4150 return;4393 return;
4151}4394}
4152 4395
4153void4396static void
4154lpfc_register_new_vport(struct lpfc_hba *phba, struct lpfc_vport *vport,4397lpfc_register_new_vport(struct lpfc_hba *phba, struct lpfc_vport *vport,
4155 struct lpfc_nodelist *ndlp)4398 struct lpfc_nodelist *ndlp)
4156{4399{
4400 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
4157 LPFC_MBOXQ_t *mbox;4401 LPFC_MBOXQ_t *mbox;
4158 4402
4159 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);4403 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
@@ -4162,25 +4406,31 @@ lpfc_register_new_vport(struct lpfc_hba *phba, struct lpfc_vport *vport, · 2 unmodified lines
4162 mbox->vport = vport;4406 mbox->vport = vport;
4163 mbox->context2 = lpfc_nlp_get(ndlp);4407 mbox->context2 = lpfc_nlp_get(ndlp);
4164 mbox->mbox_cmpl = lpfc_cmpl_reg_new_vport;4408 mbox->mbox_cmpl = lpfc_cmpl_reg_new_vport;
4165 if (lpfc_sli_issue_mbox(phba, mbox,4409 if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT)
4166 MBX_NOWAIT | MBX_STOP_IOCB)
4167 == MBX_NOT_FINISHED) {4410 == MBX_NOT_FINISHED) {
4411 /* mailbox command not success, decrement ndlp
4412 * reference count for this command
4413 */
4414 lpfc_nlp_put(ndlp);
4168 mempool_free(mbox, phba->mbox_mem_pool);4415 mempool_free(mbox, phba->mbox_mem_pool);
4169 vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI;
4170 4416
4171 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
4172 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,4417 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
4173 "0253 Register VPI: Can't send mbox\n");4418 "0253 Register VPI: Can't send mbox\n");
4419 goto mbox_err_exit;
4174 }4420 }
4175 } else {4421 } else {
4176 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
4177
4178 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,4422 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
4179 "0254 Register VPI: no memory\n");4423 "0254 Register VPI: no memory\n");
4180 4424 goto mbox_err_exit;
4181 vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI;
4182 lpfc_nlp_put(ndlp);
4183 }4425 }
4426 return;
4427
4428mbox_err_exit:
4429 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
4430 spin_lock_irq(shost->host_lock);
4431 vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI;
4432 spin_unlock_irq(shost->host_lock);
4433 return;
4184}4434}
4185 4435
4186static void4436static void
@@ -4251,7 +4501,9 @@ lpfc_cmpl_els_fdisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 64 unmodified lines
4251 lpfc_unreg_rpi(vport, np);4501 lpfc_unreg_rpi(vport, np);
4252 }4502 }
4253 lpfc_mbx_unreg_vpi(vport);4503 lpfc_mbx_unreg_vpi(vport);
4504 spin_lock_irq(shost->host_lock);
4254 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;4505 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
4506 spin_unlock_irq(shost->host_lock);
4255 }4507 }
4256 4508
4257 if (vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)4509 if (vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)
@@ -4259,14 +4511,15 @@ lpfc_cmpl_els_fdisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 1 unmodified line
4259 else4511 else
4260 lpfc_do_scr_ns_plogi(phba, vport);4512 lpfc_do_scr_ns_plogi(phba, vport);
4261 4513
4262 lpfc_nlp_put(ndlp); /* Free Fabric ndlp for vports */4514 /* Unconditionaly kick off releasing fabric node for vports */
4515 lpfc_nlp_put(ndlp);
4263 }4516 }
4264 4517
4265out:4518out:
4266 lpfc_els_free_iocb(phba, cmdiocb);4519 lpfc_els_free_iocb(phba, cmdiocb);
4267}4520}
4268 4521
4269int4522static int
4270lpfc_issue_els_fdisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,4523lpfc_issue_els_fdisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
4271 uint8_t retry)4524 uint8_t retry)
4272{4525{
@@ -4539,7 +4792,7 @@ lpfc_cmpl_fabric_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 266 unmodified lines
4539 }4792 }
4540}4793}
4541 4794
4542int4795static int
4543lpfc_issue_fabric_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *iocb)4796lpfc_issue_fabric_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *iocb)
4544{4797{
4545 unsigned long iflags;4798 unsigned long iflags;
@@ -4583,7 +4836,7 @@ lpfc_issue_fabric_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *iocb) · 37 unmodified lines
4583}4836}
4584 4837
4585 4838
4586void lpfc_fabric_abort_vport(struct lpfc_vport *vport)4839static void lpfc_fabric_abort_vport(struct lpfc_vport *vport)
4587{4840{
4588 LIST_HEAD(completions);4841 LIST_HEAD(completions);
4589 struct lpfc_hba *phba = vport->phba;4842 struct lpfc_hba *phba = vport->phba;
@@ -4663,6 +4916,7 @@ void lpfc_fabric_abort_hba(struct lpfc_hba *phba) · 73 unmodified lines
4663}4916}
4664 4917
4665 4918
4919#if 0
4666void lpfc_fabric_abort_flogi(struct lpfc_hba *phba)4920void lpfc_fabric_abort_flogi(struct lpfc_hba *phba)
4667{4921{
4668 LIST_HEAD(completions);4922 LIST_HEAD(completions);
@@ -4693,5 +4947,6 @@ void lpfc_fabric_abort_flogi(struct lpfc_hba *phba) · 24 unmodified lines
4693 (piocb->iocb_cmpl) (phba, piocb, piocb);4947 (piocb->iocb_cmpl) (phba, piocb, piocb);
4694 }4948 }
4695}4949}
4950#endif /* 0 */
4696 4951
4697 4952
drivers/scsi/lpfc/lpfc_hbadisc.c+242−130
@@ -57,6 +57,7 @@ static uint8_t lpfcAlpaArray[] = { · 56 unmodified lines
57};57};
58 58
59static void lpfc_disc_timeout_handler(struct lpfc_vport *);59static void lpfc_disc_timeout_handler(struct lpfc_vport *);
60static void lpfc_disc_flush_list(struct lpfc_vport *vport);
60 61
61void62void
62lpfc_terminate_rport_io(struct fc_rport *rport)63lpfc_terminate_rport_io(struct fc_rport *rport)
@@ -107,20 +108,14 @@ lpfc_dev_loss_tmo_callbk(struct fc_rport *rport) · 44 unmodified lines
107 struct lpfc_nodelist * ndlp;108 struct lpfc_nodelist * ndlp;
108 struct lpfc_vport *vport;109 struct lpfc_vport *vport;
109 struct lpfc_hba *phba;110 struct lpfc_hba *phba;
110 struct completion devloss_compl;
111 struct lpfc_work_evt *evtp;111 struct lpfc_work_evt *evtp;
112 int put_node;
113 int put_rport;
112 114
113 rdata = rport->dd_data;115 rdata = rport->dd_data;
114 ndlp = rdata->pnode;116 ndlp = rdata->pnode;
115 117 if (!ndlp)
116 if (!ndlp) {
117 if (rport->scsi_target_id != -1) {
118 printk(KERN_ERR "Cannot find remote node"
119 " for rport in dev_loss_tmo_callbk x%x\n",
120 rport->port_id);
121 }
122 return;118 return;
123 }
124 119
125 vport = ndlp->vport;120 vport = ndlp->vport;
126 phba = vport->phba;121 phba = vport->phba;
@@ -129,15 +124,35 @@ lpfc_dev_loss_tmo_callbk(struct fc_rport *rport) · 2 unmodified lines
129 "rport devlosscb: sid:x%x did:x%x flg:x%x",124 "rport devlosscb: sid:x%x did:x%x flg:x%x",
130 ndlp->nlp_sid, ndlp->nlp_DID, ndlp->nlp_flag);125 ndlp->nlp_sid, ndlp->nlp_DID, ndlp->nlp_flag);
131 126
132 init_completion(&devloss_compl);127 /* Don't defer this if we are in the process of deleting the vport
128 * or unloading the driver. The unload will cleanup the node
129 * appropriately we just need to cleanup the ndlp rport info here.
130 */
131 if (vport->load_flag & FC_UNLOADING) {
132 put_node = rdata->pnode != NULL;
133 put_rport = ndlp->rport != NULL;
134 rdata->pnode = NULL;
135 ndlp->rport = NULL;
136 if (put_node)
137 lpfc_nlp_put(ndlp);
138 if (put_rport)
139 put_device(&rport->dev);
140 return;
141 }
142
143 if (ndlp->nlp_state == NLP_STE_MAPPED_NODE)
144 return;
145
133 evtp = &ndlp->dev_loss_evt;146 evtp = &ndlp->dev_loss_evt;
134 147
135 if (!list_empty(&evtp->evt_listp))148 if (!list_empty(&evtp->evt_listp))
136 return;149 return;
137 150
138 spin_lock_irq(&phba->hbalock);151 spin_lock_irq(&phba->hbalock);
139 evtp->evt_arg1 = ndlp;152 /* We need to hold the node by incrementing the reference
140 evtp->evt_arg2 = &devloss_compl;153 * count until this queued work is done
154 */
155 evtp->evt_arg1 = lpfc_nlp_get(ndlp);
141 evtp->evt = LPFC_EVT_DEV_LOSS;156 evtp->evt = LPFC_EVT_DEV_LOSS;
142 list_add_tail(&evtp->evt_listp, &phba->work_list);157 list_add_tail(&evtp->evt_listp, &phba->work_list);
143 if (phba->work_wait)158 if (phba->work_wait)
@@ -145,8 +160,6 @@ lpfc_dev_loss_tmo_callbk(struct fc_rport *rport) · 1 unmodified line
145 160
146 spin_unlock_irq(&phba->hbalock);161 spin_unlock_irq(&phba->hbalock);
147 162
148 wait_for_completion(&devloss_compl);
149
150 return;163 return;
151}164}
152 165
@@ -154,7 +167,7 @@ lpfc_dev_loss_tmo_callbk(struct fc_rport *rport) · 1 unmodified line
154 * This function is called from the worker thread when dev_loss_tmo167 * This function is called from the worker thread when dev_loss_tmo
155 * expire.168 * expire.
156 */169 */
157void170static void
158lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp)171lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp)
159{172{
160 struct lpfc_rport_data *rdata;173 struct lpfc_rport_data *rdata;
@@ -162,6 +175,8 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp) · 1 unmodified line
162 struct lpfc_vport *vport;175 struct lpfc_vport *vport;
163 struct lpfc_hba *phba;176 struct lpfc_hba *phba;
164 uint8_t *name;177 uint8_t *name;
178 int put_node;
179 int put_rport;
165 int warn_on = 0;180 int warn_on = 0;
166 181
167 rport = ndlp->rport;182 rport = ndlp->rport;
@@ -178,14 +193,32 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp) · 10 unmodified lines
178 "rport devlosstmo:did:x%x type:x%x id:x%x",193 "rport devlosstmo:did:x%x type:x%x id:x%x",
179 ndlp->nlp_DID, ndlp->nlp_type, rport->scsi_target_id);194 ndlp->nlp_DID, ndlp->nlp_type, rport->scsi_target_id);
180 195
181 if (!(vport->load_flag & FC_UNLOADING) &&196 /* Don't defer this if we are in the process of deleting the vport
182 ndlp->nlp_state == NLP_STE_MAPPED_NODE)197 * or unloading the driver. The unload will cleanup the node
198 * appropriately we just need to cleanup the ndlp rport info here.
199 */
200 if (vport->load_flag & FC_UNLOADING) {
201 if (ndlp->nlp_sid != NLP_NO_SID) {
202 /* flush the target */
203 lpfc_sli_abort_iocb(vport,
204 &phba->sli.ring[phba->sli.fcp_ring],
205 ndlp->nlp_sid, 0, LPFC_CTX_TGT);
206 }
207 put_node = rdata->pnode != NULL;
208 put_rport = ndlp->rport != NULL;
209 rdata->pnode = NULL;
210 ndlp->rport = NULL;
211 if (put_node)
212 lpfc_nlp_put(ndlp);
213 if (put_rport)
214 put_device(&rport->dev);
183 return;215 return;
216 }
184 217
185 if (ndlp->nlp_type & NLP_FABRIC) {218 if (ndlp->nlp_state == NLP_STE_MAPPED_NODE)
186 int put_node;219 return;
187 int put_rport;
188 220
221 if (ndlp->nlp_type & NLP_FABRIC) {
189 /* We will clean up these Nodes in linkup */222 /* We will clean up these Nodes in linkup */
190 put_node = rdata->pnode != NULL;223 put_node = rdata->pnode != NULL;
191 put_rport = ndlp->rport != NULL;224 put_rport = ndlp->rport != NULL;
@@ -227,23 +260,20 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp) · 35 unmodified lines
227 ndlp->nlp_state, ndlp->nlp_rpi);260 ndlp->nlp_state, ndlp->nlp_rpi);
228 }261 }
229 262
263 put_node = rdata->pnode != NULL;
264 put_rport = ndlp->rport != NULL;
265 rdata->pnode = NULL;
266 ndlp->rport = NULL;
267 if (put_node)
268 lpfc_nlp_put(ndlp);
269 if (put_rport)
270 put_device(&rport->dev);
271
230 if (!(vport->load_flag & FC_UNLOADING) &&272 if (!(vport->load_flag & FC_UNLOADING) &&
231 !(ndlp->nlp_flag & NLP_DELAY_TMO) &&273 !(ndlp->nlp_flag & NLP_DELAY_TMO) &&
232 !(ndlp->nlp_flag & NLP_NPR_2B_DISC) &&274 !(ndlp->nlp_flag & NLP_NPR_2B_DISC) &&
233 (ndlp->nlp_state != NLP_STE_UNMAPPED_NODE))275 (ndlp->nlp_state != NLP_STE_UNMAPPED_NODE)) {
234 lpfc_disc_state_machine(vport, ndlp, NULL, NLP_EVT_DEVICE_RM);276 lpfc_disc_state_machine(vport, ndlp, NULL, NLP_EVT_DEVICE_RM);
235 else {
236 int put_node;
237 int put_rport;
238
239 put_node = rdata->pnode != NULL;
240 put_rport = ndlp->rport != NULL;
241 rdata->pnode = NULL;
242 ndlp->rport = NULL;
243 if (put_node)
244 lpfc_nlp_put(ndlp);
245 if (put_rport)
246 put_device(&rport->dev);
247 }277 }
248}278}
249 279
@@ -260,7 +290,6 @@ lpfc_work_list_done(struct lpfc_hba *phba) · 10 unmodified lines
260{290{
261 struct lpfc_work_evt *evtp = NULL;291 struct lpfc_work_evt *evtp = NULL;
262 struct lpfc_nodelist *ndlp;292 struct lpfc_nodelist *ndlp;
263 struct lpfc_vport *vport;
264 int free_evt;293 int free_evt;
265 294
266 spin_lock_irq(&phba->hbalock);295 spin_lock_irq(&phba->hbalock);
@@ -270,35 +299,22 @@ lpfc_work_list_done(struct lpfc_hba *phba) · 3 unmodified lines
270 spin_unlock_irq(&phba->hbalock);299 spin_unlock_irq(&phba->hbalock);
271 free_evt = 1;300 free_evt = 1;
272 switch (evtp->evt) {301 switch (evtp->evt) {
273 case LPFC_EVT_DEV_LOSS_DELAY:
274 free_evt = 0; /* evt is part of ndlp */
275 ndlp = (struct lpfc_nodelist *) (evtp->evt_arg1);
276 vport = ndlp->vport;
277 if (!vport)
278 break;
279
280 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_RPORT,
281 "rport devlossdly:did:x%x flg:x%x",
282 ndlp->nlp_DID, ndlp->nlp_flag, 0);
283
284 if (!(vport->load_flag & FC_UNLOADING) &&
285 !(ndlp->nlp_flag & NLP_DELAY_TMO) &&
286 !(ndlp->nlp_flag & NLP_NPR_2B_DISC)) {
287 lpfc_disc_state_machine(vport, ndlp, NULL,
288 NLP_EVT_DEVICE_RM);
289 }
290 break;
291 case LPFC_EVT_ELS_RETRY:302 case LPFC_EVT_ELS_RETRY:
292 ndlp = (struct lpfc_nodelist *) (evtp->evt_arg1);303 ndlp = (struct lpfc_nodelist *) (evtp->evt_arg1);
293 lpfc_els_retry_delay_handler(ndlp);304 lpfc_els_retry_delay_handler(ndlp);
294 free_evt = 0; /* evt is part of ndlp */305 free_evt = 0; /* evt is part of ndlp */
306 /* decrement the node reference count held
307 * for this queued work
308 */
309 lpfc_nlp_put(ndlp);
295 break;310 break;
296 case LPFC_EVT_DEV_LOSS:311 case LPFC_EVT_DEV_LOSS:
297 ndlp = (struct lpfc_nodelist *)(evtp->evt_arg1);312 ndlp = (struct lpfc_nodelist *)(evtp->evt_arg1);
298 lpfc_nlp_get(ndlp);
299 lpfc_dev_loss_tmo_handler(ndlp);313 lpfc_dev_loss_tmo_handler(ndlp);
300 free_evt = 0;314 free_evt = 0;
301 complete((struct completion *)(evtp->evt_arg2));315 /* decrement the node reference count held for
316 * this queued work
317 */
302 lpfc_nlp_put(ndlp);318 lpfc_nlp_put(ndlp);
303 break;319 break;
304 case LPFC_EVT_ONLINE:320 case LPFC_EVT_ONLINE:
@@ -373,7 +389,7 @@ lpfc_work_done(struct lpfc_hba *phba) · 68 unmodified lines
373 lpfc_handle_latt(phba);389 lpfc_handle_latt(phba);
374 vports = lpfc_create_vport_work_array(phba);390 vports = lpfc_create_vport_work_array(phba);
375 if (vports != NULL)391 if (vports != NULL)
376 for(i = 0; i < LPFC_MAX_VPORTS; i++) {392 for(i = 0; i <= phba->max_vpi; i++) {
377 /*393 /*
378 * We could have no vports in array if unloading, so if394 * We could have no vports in array if unloading, so if
379 * this happens then just use the pport395 * this happens then just use the pport
@@ -405,14 +421,14 @@ lpfc_work_done(struct lpfc_hba *phba) · 25 unmodified lines
405 vport->work_port_events &= ~work_port_events;421 vport->work_port_events &= ~work_port_events;
406 spin_unlock_irq(&vport->work_port_lock);422 spin_unlock_irq(&vport->work_port_lock);
407 }423 }
408 lpfc_destroy_vport_work_array(vports);424 lpfc_destroy_vport_work_array(phba, vports);
409 425
410 pring = &phba->sli.ring[LPFC_ELS_RING];426 pring = &phba->sli.ring[LPFC_ELS_RING];
411 status = (ha_copy & (HA_RXMASK << (4*LPFC_ELS_RING)));427 status = (ha_copy & (HA_RXMASK << (4*LPFC_ELS_RING)));
412 status >>= (4*LPFC_ELS_RING);428 status >>= (4*LPFC_ELS_RING);
413 if ((status & HA_RXMASK)429 if ((status & HA_RXMASK)
414 || (pring->flag & LPFC_DEFERRED_RING_EVENT)) {430 || (pring->flag & LPFC_DEFERRED_RING_EVENT)) {
415 if (pring->flag & LPFC_STOP_IOCB_MASK) {431 if (pring->flag & LPFC_STOP_IOCB_EVENT) {
416 pring->flag |= LPFC_DEFERRED_RING_EVENT;432 pring->flag |= LPFC_DEFERRED_RING_EVENT;
417 } else {433 } else {
418 lpfc_sli_handle_slow_ring_event(phba, pring,434 lpfc_sli_handle_slow_ring_event(phba, pring,
@@ -544,6 +560,7 @@ lpfc_workq_post_event(struct lpfc_hba *phba, void *arg1, void *arg2, · 125 unmodified lines
544void560void
545lpfc_cleanup_rpis(struct lpfc_vport *vport, int remove)561lpfc_cleanup_rpis(struct lpfc_vport *vport, int remove)
546{562{
563 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
547 struct lpfc_hba *phba = vport->phba;564 struct lpfc_hba *phba = vport->phba;
548 struct lpfc_nodelist *ndlp, *next_ndlp;565 struct lpfc_nodelist *ndlp, *next_ndlp;
549 int rc;566 int rc;
@@ -552,7 +569,9 @@ lpfc_cleanup_rpis(struct lpfc_vport *vport, int remove) · 2 unmodified lines
552 if (ndlp->nlp_state == NLP_STE_UNUSED_NODE)569 if (ndlp->nlp_state == NLP_STE_UNUSED_NODE)
553 continue;570 continue;
554 571
555 if (phba->sli3_options & LPFC_SLI3_VPORT_TEARDOWN)572 if ((phba->sli3_options & LPFC_SLI3_VPORT_TEARDOWN) ||
573 ((vport->port_type == LPFC_NPIV_PORT) &&
574 (ndlp->nlp_DID == NameServer_DID)))
556 lpfc_unreg_rpi(vport, ndlp);575 lpfc_unreg_rpi(vport, ndlp);
557 576
558 /* Leave Fabric nodes alone on link down */577 /* Leave Fabric nodes alone on link down */
@@ -565,14 +584,30 @@ lpfc_cleanup_rpis(struct lpfc_vport *vport, int remove) · 6 unmodified lines
565 }584 }
566 if (phba->sli3_options & LPFC_SLI3_VPORT_TEARDOWN) {585 if (phba->sli3_options & LPFC_SLI3_VPORT_TEARDOWN) {
567 lpfc_mbx_unreg_vpi(vport);586 lpfc_mbx_unreg_vpi(vport);
587 spin_lock_irq(shost->host_lock);
568 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;588 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
589 spin_unlock_irq(shost->host_lock);
569 }590 }
570}591}
571 592
593void
594lpfc_port_link_failure(struct lpfc_vport *vport)
595{
596 /* Cleanup any outstanding RSCN activity */
597 lpfc_els_flush_rscn(vport);
598
599 /* Cleanup any outstanding ELS commands */
600 lpfc_els_flush_cmd(vport);
601
602 lpfc_cleanup_rpis(vport, 0);
603
604 /* Turn off discovery timer if its running */
605 lpfc_can_disctmo(vport);
606}
607
572static void608static void
573lpfc_linkdown_port(struct lpfc_vport *vport)609lpfc_linkdown_port(struct lpfc_vport *vport)
574{610{
575 struct lpfc_nodelist *ndlp, *next_ndlp;
576 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);611 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
577 612
578 fc_host_post_event(shost, fc_get_event_number(), FCH_EVT_LINKDOWN, 0);613 fc_host_post_event(shost, fc_get_event_number(), FCH_EVT_LINKDOWN, 0);
@@ -581,21 +616,8 @@ lpfc_linkdown_port(struct lpfc_vport *vport) · 2 unmodified lines
581 "Link Down: state:x%x rtry:x%x flg:x%x",616 "Link Down: state:x%x rtry:x%x flg:x%x",
582 vport->port_state, vport->fc_ns_retry, vport->fc_flag);617 vport->port_state, vport->fc_ns_retry, vport->fc_flag);
583 618
584 /* Cleanup any outstanding RSCN activity */619 lpfc_port_link_failure(vport);
585 lpfc_els_flush_rscn(vport);
586
587 /* Cleanup any outstanding ELS commands */
588 lpfc_els_flush_cmd(vport);
589 620
590 lpfc_cleanup_rpis(vport, 0);
591
592 /* free any ndlp's on unused list */
593 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp)
594 if (ndlp->nlp_state == NLP_STE_UNUSED_NODE)
595 lpfc_drop_node(vport, ndlp);
596
597 /* Turn off discovery timer if its running */
598 lpfc_can_disctmo(vport);
599}621}
600 622
601int623int
@@ -618,18 +640,18 @@ lpfc_linkdown(struct lpfc_hba *phba) · 16 unmodified lines
618 spin_unlock_irq(&phba->hbalock);640 spin_unlock_irq(&phba->hbalock);
619 vports = lpfc_create_vport_work_array(phba);641 vports = lpfc_create_vport_work_array(phba);
620 if (vports != NULL)642 if (vports != NULL)
621 for(i = 0; i < LPFC_MAX_VPORTS && vports[i] != NULL; i++) {643 for(i = 0; i <= phba->max_vpi && vports[i] != NULL; i++) {
622 /* Issue a LINK DOWN event to all nodes */644 /* Issue a LINK DOWN event to all nodes */
623 lpfc_linkdown_port(vports[i]);645 lpfc_linkdown_port(vports[i]);
624 }646 }
625 lpfc_destroy_vport_work_array(vports);647 lpfc_destroy_vport_work_array(phba, vports);
626 /* Clean up any firmware default rpi's */648 /* Clean up any firmware default rpi's */
627 mb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);649 mb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
628 if (mb) {650 if (mb) {
629 lpfc_unreg_did(phba, 0xffff, 0xffffffff, mb);651 lpfc_unreg_did(phba, 0xffff, 0xffffffff, mb);
630 mb->vport = vport;652 mb->vport = vport;
631 mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;653 mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
632 if (lpfc_sli_issue_mbox(phba, mb, (MBX_NOWAIT | MBX_STOP_IOCB))654 if (lpfc_sli_issue_mbox(phba, mb, MBX_NOWAIT)
633 == MBX_NOT_FINISHED) {655 == MBX_NOT_FINISHED) {
634 mempool_free(mb, phba->mbox_mem_pool);656 mempool_free(mb, phba->mbox_mem_pool);
635 }657 }
@@ -643,8 +665,7 @@ lpfc_linkdown(struct lpfc_hba *phba) · 7 unmodified lines
643 lpfc_config_link(phba, mb);665 lpfc_config_link(phba, mb);
644 mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;666 mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
645 mb->vport = vport;667 mb->vport = vport;
646 if (lpfc_sli_issue_mbox(phba, mb,668 if (lpfc_sli_issue_mbox(phba, mb, MBX_NOWAIT)
647 (MBX_NOWAIT | MBX_STOP_IOCB))
648 == MBX_NOT_FINISHED) {669 == MBX_NOT_FINISHED) {
649 mempool_free(mb, phba->mbox_mem_pool);670 mempool_free(mb, phba->mbox_mem_pool);
650 }671 }
@@ -686,7 +707,6 @@ static void · 35 unmodified lines
686lpfc_linkup_port(struct lpfc_vport *vport)707lpfc_linkup_port(struct lpfc_vport *vport)
687{708{
688 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);709 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
689 struct lpfc_nodelist *ndlp, *next_ndlp;
690 struct lpfc_hba *phba = vport->phba;710 struct lpfc_hba *phba = vport->phba;
691 711
692 if ((vport->load_flag & FC_UNLOADING) != 0)712 if ((vport->load_flag & FC_UNLOADING) != 0)
@@ -713,11 +733,6 @@ lpfc_linkup_port(struct lpfc_vport *vport) · 20 unmodified lines
713 if (vport->fc_flag & FC_LBIT)733 if (vport->fc_flag & FC_LBIT)
714 lpfc_linkup_cleanup_nodes(vport);734 lpfc_linkup_cleanup_nodes(vport);
715 735
716 /* free any ndlp's in unused state */
717 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes,
718 nlp_listp)
719 if (ndlp->nlp_state == NLP_STE_UNUSED_NODE)
720 lpfc_drop_node(vport, ndlp);
721}736}
722 737
723static int738static int
@@ -734,9 +749,9 @@ lpfc_linkup(struct lpfc_hba *phba) · 10 unmodified lines
734 749
735 vports = lpfc_create_vport_work_array(phba);750 vports = lpfc_create_vport_work_array(phba);
736 if (vports != NULL)751 if (vports != NULL)
737 for(i = 0; i < LPFC_MAX_VPORTS && vports[i] != NULL; i++)752 for(i = 0; i <= phba->max_vpi && vports[i] != NULL; i++)
738 lpfc_linkup_port(vports[i]);753 lpfc_linkup_port(vports[i]);
739 lpfc_destroy_vport_work_array(vports);754 lpfc_destroy_vport_work_array(phba, vports);
740 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED)755 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED)
741 lpfc_issue_clear_la(phba, phba->pport);756 lpfc_issue_clear_la(phba, phba->pport);
742 757
@@ -749,7 +764,7 @@ lpfc_linkup(struct lpfc_hba *phba) · 6 unmodified lines
749 * as the completion routine when the command is764 * as the completion routine when the command is
750 * handed off to the SLI layer.765 * handed off to the SLI layer.
751 */766 */
752void767static void
753lpfc_mbx_cmpl_clear_la(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)768lpfc_mbx_cmpl_clear_la(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
754{769{
755 struct lpfc_vport *vport = pmb->vport;770 struct lpfc_vport *vport = pmb->vport;
@@ -852,8 +867,6 @@ lpfc_mbx_cmpl_local_config_link(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 96 unmodified lines
852 * LPFC_FLOGI while waiting for FLOGI cmpl867 * LPFC_FLOGI while waiting for FLOGI cmpl
853 */868 */
854 if (vport->port_state != LPFC_FLOGI) {869 if (vport->port_state != LPFC_FLOGI) {
855 vport->port_state = LPFC_FLOGI;
856 lpfc_set_disctmo(vport);
857 lpfc_initial_flogi(vport);870 lpfc_initial_flogi(vport);
858 }871 }
859 return;872 return;
@@ -1022,8 +1035,7 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la) · 162 unmodified lines
1022 lpfc_read_sparam(phba, sparam_mbox, 0);1035 lpfc_read_sparam(phba, sparam_mbox, 0);
1023 sparam_mbox->vport = vport;1036 sparam_mbox->vport = vport;
1024 sparam_mbox->mbox_cmpl = lpfc_mbx_cmpl_read_sparam;1037 sparam_mbox->mbox_cmpl = lpfc_mbx_cmpl_read_sparam;
1025 rc = lpfc_sli_issue_mbox(phba, sparam_mbox,1038 rc = lpfc_sli_issue_mbox(phba, sparam_mbox, MBX_NOWAIT);
1026 (MBX_NOWAIT | MBX_STOP_IOCB));
1027 if (rc == MBX_NOT_FINISHED) {1039 if (rc == MBX_NOT_FINISHED) {
1028 mp = (struct lpfc_dmabuf *) sparam_mbox->context1;1040 mp = (struct lpfc_dmabuf *) sparam_mbox->context1;
1029 lpfc_mbuf_free(phba, mp->virt, mp->phys);1041 lpfc_mbuf_free(phba, mp->virt, mp->phys);
@@ -1040,8 +1052,7 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la) · 10 unmodified lines
1040 lpfc_config_link(phba, cfglink_mbox);1052 lpfc_config_link(phba, cfglink_mbox);
1041 cfglink_mbox->vport = vport;1053 cfglink_mbox->vport = vport;
1042 cfglink_mbox->mbox_cmpl = lpfc_mbx_cmpl_local_config_link;1054 cfglink_mbox->mbox_cmpl = lpfc_mbx_cmpl_local_config_link;
1043 rc = lpfc_sli_issue_mbox(phba, cfglink_mbox,1055 rc = lpfc_sli_issue_mbox(phba, cfglink_mbox, MBX_NOWAIT);
1044 (MBX_NOWAIT | MBX_STOP_IOCB));
1045 if (rc != MBX_NOT_FINISHED)1056 if (rc != MBX_NOT_FINISHED)
1046 return;1057 return;
1047 mempool_free(cfglink_mbox, phba->mbox_mem_pool);1058 mempool_free(cfglink_mbox, phba->mbox_mem_pool);
@@ -1174,6 +1185,9 @@ lpfc_mbx_cmpl_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 126 unmodified lines
1174 lpfc_mbuf_free(phba, mp->virt, mp->phys);1185 lpfc_mbuf_free(phba, mp->virt, mp->phys);
1175 kfree(mp);1186 kfree(mp);
1176 mempool_free(pmb, phba->mbox_mem_pool);1187 mempool_free(pmb, phba->mbox_mem_pool);
1188 /* decrement the node reference count held for this callback
1189 * function.
1190 */
1177 lpfc_nlp_put(ndlp);1191 lpfc_nlp_put(ndlp);
1178 1192
1179 return;1193 return;
@@ -1219,7 +1233,7 @@ lpfc_mbx_unreg_vpi(struct lpfc_vport *vport) · 39 unmodified lines
1219 lpfc_unreg_vpi(phba, vport->vpi, mbox);1233 lpfc_unreg_vpi(phba, vport->vpi, mbox);
1220 mbox->vport = vport;1234 mbox->vport = vport;
1221 mbox->mbox_cmpl = lpfc_mbx_cmpl_unreg_vpi;1235 mbox->mbox_cmpl = lpfc_mbx_cmpl_unreg_vpi;
1222 rc = lpfc_sli_issue_mbox(phba, mbox, (MBX_NOWAIT | MBX_STOP_IOCB));1236 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
1223 if (rc == MBX_NOT_FINISHED) {1237 if (rc == MBX_NOT_FINISHED) {
1224 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX | LOG_VPORT,1238 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX | LOG_VPORT,
1225 "1800 Could not issue unreg_vpi\n");1239 "1800 Could not issue unreg_vpi\n");
@@ -1319,7 +1333,7 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 93 unmodified lines
1319 vports = lpfc_create_vport_work_array(phba);1333 vports = lpfc_create_vport_work_array(phba);
1320 if (vports != NULL)1334 if (vports != NULL)
1321 for(i = 0;1335 for(i = 0;
1322 i < LPFC_MAX_VPORTS && vports[i] != NULL;1336 i <= phba->max_vpi && vports[i] != NULL;
1323 i++) {1337 i++) {
1324 if (vports[i]->port_type == LPFC_PHYSICAL_PORT)1338 if (vports[i]->port_type == LPFC_PHYSICAL_PORT)
1325 continue;1339 continue;
@@ -1335,7 +1349,7 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 9 unmodified lines
1335 "Fabric support\n");1349 "Fabric support\n");
1336 }1350 }
1337 }1351 }
1338 lpfc_destroy_vport_work_array(vports);1352 lpfc_destroy_vport_work_array(phba, vports);
1339 lpfc_do_scr_ns_plogi(phba, vport);1353 lpfc_do_scr_ns_plogi(phba, vport);
1340 }1354 }
1341 1355
@@ -1361,11 +1375,16 @@ lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 19 unmodified lines
1361 1375
1362 if (mb->mbxStatus) {1376 if (mb->mbxStatus) {
1363out:1377out:
1378 /* decrement the node reference count held for this
1379 * callback function.
1380 */
1364 lpfc_nlp_put(ndlp);1381 lpfc_nlp_put(ndlp);
1365 lpfc_mbuf_free(phba, mp->virt, mp->phys);1382 lpfc_mbuf_free(phba, mp->virt, mp->phys);
1366 kfree(mp);1383 kfree(mp);
1367 mempool_free(pmb, phba->mbox_mem_pool);1384 mempool_free(pmb, phba->mbox_mem_pool);
1368 lpfc_drop_node(vport, ndlp);1385
1386 /* If no other thread is using the ndlp, free it */
1387 lpfc_nlp_not_used(ndlp);
1369 1388
1370 if (phba->fc_topology == TOPOLOGY_LOOP) {1389 if (phba->fc_topology == TOPOLOGY_LOOP) {
1371 /*1390 /*
@@ -1410,6 +1429,9 @@ out: · 38 unmodified lines
1410 goto out;1429 goto out;
1411 }1430 }
1412 1431
1432 /* decrement the node reference count held for this
1433 * callback function.
1434 */
1413 lpfc_nlp_put(ndlp);1435 lpfc_nlp_put(ndlp);
1414 lpfc_mbuf_free(phba, mp->virt, mp->phys);1436 lpfc_mbuf_free(phba, mp->virt, mp->phys);
1415 kfree(mp);1437 kfree(mp);
@@ -1656,8 +1678,18 @@ lpfc_dequeue_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 240 unmodified lines
1656void1678void
1657lpfc_drop_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)1679lpfc_drop_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
1658{1680{
1681 /*
1682 * Use of lpfc_drop_node and UNUSED list: lpfc_drop_node should
1683 * be used if we wish to issue the "last" lpfc_nlp_put() to remove
1684 * the ndlp from the vport. The ndlp marked as UNUSED on the list
1685 * until ALL other outstanding threads have completed. We check
1686 * that the ndlp not already in the UNUSED state before we proceed.
1687 */
1688 if (ndlp->nlp_state == NLP_STE_UNUSED_NODE)
1689 return;
1659 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNUSED_NODE);1690 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNUSED_NODE);
1660 lpfc_nlp_put(ndlp);1691 lpfc_nlp_put(ndlp);
1692 return;
1661}1693}
1662 1694
1663/*1695/*
@@ -1868,8 +1900,7 @@ lpfc_unreg_rpi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 204 unmodified lines
1868 lpfc_unreg_login(phba, vport->vpi, ndlp->nlp_rpi, mbox);1900 lpfc_unreg_login(phba, vport->vpi, ndlp->nlp_rpi, mbox);
1869 mbox->vport = vport;1901 mbox->vport = vport;
1870 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;1902 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
1871 rc = lpfc_sli_issue_mbox(phba, mbox,1903 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
1872 (MBX_NOWAIT | MBX_STOP_IOCB));
1873 if (rc == MBX_NOT_FINISHED)1904 if (rc == MBX_NOT_FINISHED)
1874 mempool_free(mbox, phba->mbox_mem_pool);1905 mempool_free(mbox, phba->mbox_mem_pool);
1875 }1906 }
@@ -1892,8 +1923,8 @@ lpfc_unreg_all_rpis(struct lpfc_vport *vport) · 16 unmodified lines
1892 lpfc_unreg_login(phba, vport->vpi, 0xffff, mbox);1923 lpfc_unreg_login(phba, vport->vpi, 0xffff, mbox);
1893 mbox->vport = vport;1924 mbox->vport = vport;
1894 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;1925 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
1895 rc = lpfc_sli_issue_mbox(phba, mbox,1926 mbox->context1 = NULL;
1896 (MBX_NOWAIT | MBX_STOP_IOCB));1927 rc = lpfc_sli_issue_mbox_wait(phba, mbox, LPFC_MBOX_TMO);
1897 if (rc == MBX_NOT_FINISHED) {1928 if (rc == MBX_NOT_FINISHED) {
1898 mempool_free(mbox, phba->mbox_mem_pool);1929 mempool_free(mbox, phba->mbox_mem_pool);
1899 }1930 }
@@ -1912,8 +1943,8 @@ lpfc_unreg_default_rpis(struct lpfc_vport *vport) · 12 unmodified lines
1912 lpfc_unreg_did(phba, vport->vpi, 0xffffffff, mbox);1943 lpfc_unreg_did(phba, vport->vpi, 0xffffffff, mbox);
1913 mbox->vport = vport;1944 mbox->vport = vport;
1914 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;1945 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
1915 rc = lpfc_sli_issue_mbox(phba, mbox,1946 mbox->context1 = NULL;
1916 (MBX_NOWAIT | MBX_STOP_IOCB));1947 rc = lpfc_sli_issue_mbox_wait(phba, mbox, LPFC_MBOX_TMO);
1917 if (rc == MBX_NOT_FINISHED) {1948 if (rc == MBX_NOT_FINISHED) {
1918 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX | LOG_VPORT,1949 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX | LOG_VPORT,
1919 "1815 Could not issue "1950 "1815 Could not issue "
@@ -1981,11 +2012,6 @@ lpfc_cleanup_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 61 unmodified lines
1981 if (!list_empty(&ndlp->dev_loss_evt.evt_listp))2012 if (!list_empty(&ndlp->dev_loss_evt.evt_listp))
1982 list_del_init(&ndlp->dev_loss_evt.evt_listp);2013 list_del_init(&ndlp->dev_loss_evt.evt_listp);
1983 2014
1984 if (!list_empty(&ndlp->dev_loss_evt.evt_listp)) {
1985 list_del_init(&ndlp->dev_loss_evt.evt_listp);
1986 complete((struct completion *)(ndlp->dev_loss_evt.evt_arg2));
1987 }
1988
1989 lpfc_unreg_rpi(vport, ndlp);2015 lpfc_unreg_rpi(vport, ndlp);
1990 2016
1991 return 0;2017 return 0;
@@ -1999,12 +2025,39 @@ lpfc_cleanup_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 7 unmodified lines
1999static void2025static void
2000lpfc_nlp_remove(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)2026lpfc_nlp_remove(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
2001{2027{
2028 struct lpfc_hba *phba = vport->phba;
2002 struct lpfc_rport_data *rdata;2029 struct lpfc_rport_data *rdata;
2030 LPFC_MBOXQ_t *mbox;
2031 int rc;
2003 2032
2004 if (ndlp->nlp_flag & NLP_DELAY_TMO) {2033 if (ndlp->nlp_flag & NLP_DELAY_TMO) {
2005 lpfc_cancel_retry_delay_tmo(vport, ndlp);2034 lpfc_cancel_retry_delay_tmo(vport, ndlp);
2006 }2035 }
2007 2036
2037 if (ndlp->nlp_flag & NLP_DEFER_RM && !ndlp->nlp_rpi) {
2038 /* For this case we need to cleanup the default rpi
2039 * allocated by the firmware.
2040 */
2041 if ((mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL))
2042 != NULL) {
2043 rc = lpfc_reg_login(phba, vport->vpi, ndlp->nlp_DID,
2044 (uint8_t *) &vport->fc_sparam, mbox, 0);
2045 if (rc) {
2046 mempool_free(mbox, phba->mbox_mem_pool);
2047 }
2048 else {
2049 mbox->mbox_flag |= LPFC_MBX_IMED_UNREG;
2050 mbox->mbox_cmpl = lpfc_mbx_cmpl_dflt_rpi;
2051 mbox->vport = vport;
2052 mbox->context2 = NULL;
2053 rc =lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
2054 if (rc == MBX_NOT_FINISHED) {
2055 mempool_free(mbox, phba->mbox_mem_pool);
2056 }
2057 }
2058 }
2059 }
2060
2008 lpfc_cleanup_node(vport, ndlp);2061 lpfc_cleanup_node(vport, ndlp);
2009 2062
2010 /*2063 /*
@@ -2132,6 +2185,12 @@ lpfc_setup_disc_node(struct lpfc_vport *vport, uint32_t did) · 121 unmodified lines
2132 }2185 }
2133 if (vport->fc_flag & FC_RSCN_MODE) {2186 if (vport->fc_flag & FC_RSCN_MODE) {
2134 if (lpfc_rscn_payload_check(vport, did)) {2187 if (lpfc_rscn_payload_check(vport, did)) {
2188 /* If we've already recieved a PLOGI from this NPort
2189 * we don't need to try to discover it again.
2190 */
2191 if (ndlp->nlp_flag & NLP_RCV_PLOGI)
2192 return NULL;
2193
2135 spin_lock_irq(shost->host_lock);2194 spin_lock_irq(shost->host_lock);
2136 ndlp->nlp_flag |= NLP_NPR_2B_DISC;2195 ndlp->nlp_flag |= NLP_NPR_2B_DISC;
2137 spin_unlock_irq(shost->host_lock);2196 spin_unlock_irq(shost->host_lock);
@@ -2144,8 +2203,13 @@ lpfc_setup_disc_node(struct lpfc_vport *vport, uint32_t did) · 6 unmodified lines
2144 } else2203 } else
2145 ndlp = NULL;2204 ndlp = NULL;
2146 } else {2205 } else {
2206 /* If we've already recieved a PLOGI from this NPort,
2207 * or we are already in the process of discovery on it,
2208 * we don't need to try to discover it again.
2209 */
2147 if (ndlp->nlp_state == NLP_STE_ADISC_ISSUE ||2210 if (ndlp->nlp_state == NLP_STE_ADISC_ISSUE ||
2148 ndlp->nlp_state == NLP_STE_PLOGI_ISSUE)2211 ndlp->nlp_state == NLP_STE_PLOGI_ISSUE ||
2212 ndlp->nlp_flag & NLP_RCV_PLOGI)
2149 return NULL;2213 return NULL;
2150 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);2214 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
2151 spin_lock_irq(shost->host_lock);2215 spin_lock_irq(shost->host_lock);
@@ -2220,8 +2284,7 @@ lpfc_issue_clear_la(struct lpfc_hba *phba, struct lpfc_vport *vport) · 68 unmodified lines
2220 lpfc_clear_la(phba, mbox);2284 lpfc_clear_la(phba, mbox);
2221 mbox->mbox_cmpl = lpfc_mbx_cmpl_clear_la;2285 mbox->mbox_cmpl = lpfc_mbx_cmpl_clear_la;
2222 mbox->vport = vport;2286 mbox->vport = vport;
2223 rc = lpfc_sli_issue_mbox(phba, mbox, (MBX_NOWAIT |2287 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
2224 MBX_STOP_IOCB));
2225 if (rc == MBX_NOT_FINISHED) {2288 if (rc == MBX_NOT_FINISHED) {
2226 mempool_free(mbox, phba->mbox_mem_pool);2289 mempool_free(mbox, phba->mbox_mem_pool);
2227 lpfc_disc_flush_list(vport);2290 lpfc_disc_flush_list(vport);
@@ -2244,8 +2307,7 @@ lpfc_issue_reg_vpi(struct lpfc_hba *phba, struct lpfc_vport *vport) · 16 unmodified lines
2244 lpfc_reg_vpi(phba, vport->vpi, vport->fc_myDID, regvpimbox);2307 lpfc_reg_vpi(phba, vport->vpi, vport->fc_myDID, regvpimbox);
2245 regvpimbox->mbox_cmpl = lpfc_mbx_cmpl_reg_vpi;2308 regvpimbox->mbox_cmpl = lpfc_mbx_cmpl_reg_vpi;
2246 regvpimbox->vport = vport;2309 regvpimbox->vport = vport;
2247 if (lpfc_sli_issue_mbox(phba, regvpimbox,2310 if (lpfc_sli_issue_mbox(phba, regvpimbox, MBX_NOWAIT)
2248 (MBX_NOWAIT | MBX_STOP_IOCB))
2249 == MBX_NOT_FINISHED) {2311 == MBX_NOT_FINISHED) {
2250 mempool_free(regvpimbox, phba->mbox_mem_pool);2312 mempool_free(regvpimbox, phba->mbox_mem_pool);
2251 }2313 }
@@ -2414,7 +2476,7 @@ lpfc_free_tx(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) · 162 unmodified lines
2414 }2476 }
2415}2477}
2416 2478
2417void2479static void
2418lpfc_disc_flush_list(struct lpfc_vport *vport)2480lpfc_disc_flush_list(struct lpfc_vport *vport)
2419{2481{
2420 struct lpfc_nodelist *ndlp, *next_ndlp;2482 struct lpfc_nodelist *ndlp, *next_ndlp;
@@ -2426,7 +2488,6 @@ lpfc_disc_flush_list(struct lpfc_vport *vport) · 5 unmodified lines
2426 if (ndlp->nlp_state == NLP_STE_PLOGI_ISSUE ||2488 if (ndlp->nlp_state == NLP_STE_PLOGI_ISSUE ||
2427 ndlp->nlp_state == NLP_STE_ADISC_ISSUE) {2489 ndlp->nlp_state == NLP_STE_ADISC_ISSUE) {
2428 lpfc_free_tx(phba, ndlp);2490 lpfc_free_tx(phba, ndlp);
2429 lpfc_nlp_put(ndlp);
2430 }2491 }
2431 }2492 }
2432 }2493 }
@@ -2516,6 +2577,7 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport) · 83 unmodified lines
2516 if (ndlp->nlp_type & NLP_FABRIC) {2577 if (ndlp->nlp_type & NLP_FABRIC) {
2517 /* Clean up the ndlp on Fabric connections */2578 /* Clean up the ndlp on Fabric connections */
2518 lpfc_drop_node(vport, ndlp);2579 lpfc_drop_node(vport, ndlp);
2580
2519 } else if (!(ndlp->nlp_flag & NLP_NPR_ADISC)) {2581 } else if (!(ndlp->nlp_flag & NLP_NPR_ADISC)) {
2520 /* Fail outstanding IO now since device2582 /* Fail outstanding IO now since device
2521 * is marked for PLOGI.2583 * is marked for PLOGI.
@@ -2524,9 +2586,8 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport) · 2 unmodified lines
2524 }2586 }
2525 }2587 }
2526 if (vport->port_state != LPFC_FLOGI) {2588 if (vport->port_state != LPFC_FLOGI) {
2527 vport->port_state = LPFC_FLOGI;
2528 lpfc_set_disctmo(vport);
2529 lpfc_initial_flogi(vport);2589 lpfc_initial_flogi(vport);
2590 return;
2530 }2591 }
2531 break;2592 break;
2532 2593
@@ -2536,7 +2597,7 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport) · 3 unmodified lines
2536 /* Initial FLOGI timeout */2597 /* Initial FLOGI timeout */
2537 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,2598 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
2538 "0222 Initial %s timeout\n",2599 "0222 Initial %s timeout\n",
2539 vport->vpi ? "FLOGI" : "FDISC");2600 vport->vpi ? "FDISC" : "FLOGI");
2540 2601
2541 /* Assume no Fabric and go on with discovery.2602 /* Assume no Fabric and go on with discovery.
2542 * Check for outstanding ELS FLOGI to abort.2603 * Check for outstanding ELS FLOGI to abort.
@@ -2558,10 +2619,10 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport) · 15 unmodified lines
2558 /* Next look for NameServer ndlp */2619 /* Next look for NameServer ndlp */
2559 ndlp = lpfc_findnode_did(vport, NameServer_DID);2620 ndlp = lpfc_findnode_did(vport, NameServer_DID);
2560 if (ndlp)2621 if (ndlp)
2561 lpfc_nlp_put(ndlp);2622 lpfc_els_abort(phba, ndlp);
2562 /* Start discovery */2623
2563 lpfc_disc_start(vport);2624 /* ReStart discovery */
2564 break;2625 goto restart_disc;
2565 2626
2566 case LPFC_NS_QRY:2627 case LPFC_NS_QRY:
2567 /* Check for wait for NameServer Rsp timeout */2628 /* Check for wait for NameServer Rsp timeout */
@@ -2580,6 +2641,7 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport) · 12 unmodified lines
2580 }2641 }
2581 vport->fc_ns_retry = 0;2642 vport->fc_ns_retry = 0;
2582 2643
2644restart_disc:
2583 /*2645 /*
2584 * Discovery is over.2646 * Discovery is over.
2585 * set port_state to PORT_READY if SLI2.2647 * set port_state to PORT_READY if SLI2.
@@ -2608,8 +2670,7 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport) · 22 unmodified lines
2608 initlinkmbox->mb.un.varInitLnk.lipsr_AL_PA = 0;2670 initlinkmbox->mb.un.varInitLnk.lipsr_AL_PA = 0;
2609 initlinkmbox->vport = vport;2671 initlinkmbox->vport = vport;
2610 initlinkmbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;2672 initlinkmbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
2611 rc = lpfc_sli_issue_mbox(phba, initlinkmbox,2673 rc = lpfc_sli_issue_mbox(phba, initlinkmbox, MBX_NOWAIT);
2612 (MBX_NOWAIT | MBX_STOP_IOCB));
2613 lpfc_set_loopback_flag(phba);2674 lpfc_set_loopback_flag(phba);
2614 if (rc == MBX_NOT_FINISHED)2675 if (rc == MBX_NOT_FINISHED)
2615 mempool_free(initlinkmbox, phba->mbox_mem_pool);2676 mempool_free(initlinkmbox, phba->mbox_mem_pool);
@@ -2664,12 +2725,14 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport) · 48 unmodified lines
2664 clrlaerr = 1;2725 clrlaerr = 1;
2665 break;2726 break;
2666 2727
2728 case LPFC_LINK_UP:
2729 lpfc_issue_clear_la(phba, vport);
2730 /* Drop thru */
2667 case LPFC_LINK_UNKNOWN:2731 case LPFC_LINK_UNKNOWN:
2668 case LPFC_WARM_START:2732 case LPFC_WARM_START:
2669 case LPFC_INIT_START:2733 case LPFC_INIT_START:
2670 case LPFC_INIT_MBX_CMDS:2734 case LPFC_INIT_MBX_CMDS:
2671 case LPFC_LINK_DOWN:2735 case LPFC_LINK_DOWN:
2672 case LPFC_LINK_UP:
2673 case LPFC_HBA_ERROR:2736 case LPFC_HBA_ERROR:
2674 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,2737 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
2675 "0230 Unexpected timeout, hba link "2738 "0230 Unexpected timeout, hba link "
@@ -2723,7 +2786,9 @@ lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 47 unmodified lines
2723 else2786 else
2724 mod_timer(&vport->fc_fdmitmo, jiffies + HZ * 60);2787 mod_timer(&vport->fc_fdmitmo, jiffies + HZ * 60);
2725 2788
2726 /* Mailbox took a reference to the node */2789 /* decrement the node reference count held for this callback
2790 * function.
2791 */
2727 lpfc_nlp_put(ndlp);2792 lpfc_nlp_put(ndlp);
2728 lpfc_mbuf_free(phba, mp->virt, mp->phys);2793 lpfc_mbuf_free(phba, mp->virt, mp->phys);
2729 kfree(mp);2794 kfree(mp);
@@ -2747,19 +2812,19 @@ lpfc_filter_by_wwpn(struct lpfc_nodelist *ndlp, void *param) · 17 unmodified lines
2747 sizeof(ndlp->nlp_portname)) == 0;2812 sizeof(ndlp->nlp_portname)) == 0;
2748}2813}
2749 2814
2750struct lpfc_nodelist *2815static struct lpfc_nodelist *
2751__lpfc_find_node(struct lpfc_vport *vport, node_filter filter, void *param)2816__lpfc_find_node(struct lpfc_vport *vport, node_filter filter, void *param)
2752{2817{
2753 struct lpfc_nodelist *ndlp;2818 struct lpfc_nodelist *ndlp;
2754 2819
2755 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {2820 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
2756 if (ndlp->nlp_state != NLP_STE_UNUSED_NODE &&2821 if (filter(ndlp, param))
2757 filter(ndlp, param))
2758 return ndlp;2822 return ndlp;
2759 }2823 }
2760 return NULL;2824 return NULL;
2761}2825}
2762 2826
2827#if 0
2763/*2828/*
2764 * Search node lists for a remote port matching filter criteria2829 * Search node lists for a remote port matching filter criteria
2765 * Caller needs to hold host_lock before calling this routine.2830 * Caller needs to hold host_lock before calling this routine.
@@ -2775,6 +2840,7 @@ lpfc_find_node(struct lpfc_vport *vport, node_filter filter, void *param) · 9 unmodified lines
2775 spin_unlock_irq(shost->host_lock);2840 spin_unlock_irq(shost->host_lock);
2776 return ndlp;2841 return ndlp;
2777}2842}
2843#endif /* 0 */
2778 2844
2779/*2845/*
2780 * This routine looks up the ndlp lists for the given RPI. If rpi found it2846 * This routine looks up the ndlp lists for the given RPI. If rpi found it
@@ -2786,6 +2852,7 @@ __lpfc_findnode_rpi(struct lpfc_vport *vport, uint16_t rpi) · 5 unmodified lines
2786 return __lpfc_find_node(vport, lpfc_filter_by_rpi, &rpi);2852 return __lpfc_find_node(vport, lpfc_filter_by_rpi, &rpi);
2787}2853}
2788 2854
2855#if 0
2789struct lpfc_nodelist *2856struct lpfc_nodelist *
2790lpfc_findnode_rpi(struct lpfc_vport *vport, uint16_t rpi)2857lpfc_findnode_rpi(struct lpfc_vport *vport, uint16_t rpi)
2791{2858{
@@ -2797,6 +2864,7 @@ lpfc_findnode_rpi(struct lpfc_vport *vport, uint16_t rpi) · 5 unmodified lines
2797 spin_unlock_irq(shost->host_lock);2864 spin_unlock_irq(shost->host_lock);
2798 return ndlp;2865 return ndlp;
2799}2866}
2867#endif /* 0 */
2800 2868
2801/*2869/*
2802 * This routine looks up the ndlp lists for the given WWPN. If WWPN found it2870 * This routine looks up the ndlp lists for the given WWPN. If WWPN found it
@@ -2837,6 +2905,9 @@ lpfc_nlp_init(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 34 unmodified lines
2837 return;2905 return;
2838}2906}
2839 2907
2908/* This routine releases all resources associated with a specifc NPort's ndlp
2909 * and mempool_free's the nodelist.
2910 */
2840static void2911static void
2841lpfc_nlp_release(struct kref *kref)2912lpfc_nlp_release(struct kref *kref)
2842{2913{
@@ -2851,16 +2922,57 @@ lpfc_nlp_release(struct kref *kref) · 8 unmodified lines
2851 mempool_free(ndlp, ndlp->vport->phba->nlp_mem_pool);2922 mempool_free(ndlp, ndlp->vport->phba->nlp_mem_pool);
2852}2923}
2853 2924
2925/* This routine bumps the reference count for a ndlp structure to ensure
2926 * that one discovery thread won't free a ndlp while another discovery thread
2927 * is using it.
2928 */
2854struct lpfc_nodelist *2929struct lpfc_nodelist *
2855lpfc_nlp_get(struct lpfc_nodelist *ndlp)2930lpfc_nlp_get(struct lpfc_nodelist *ndlp)
2856{2931{
2857 if (ndlp)2932 if (ndlp) {
2933 lpfc_debugfs_disc_trc(ndlp->vport, LPFC_DISC_TRC_NODE,
2934 "node get: did:x%x flg:x%x refcnt:x%x",
2935 ndlp->nlp_DID, ndlp->nlp_flag,
2936 atomic_read(&ndlp->kref.refcount));
2858 kref_get(&ndlp->kref);2937 kref_get(&ndlp->kref);
2938 }
2859 return ndlp;2939 return ndlp;
2860}2940}
2861 2941
2942
2943/* This routine decrements the reference count for a ndlp structure. If the
2944 * count goes to 0, this indicates the the associated nodelist should be freed.
2945 */
2862int2946int
2863lpfc_nlp_put(struct lpfc_nodelist *ndlp)2947lpfc_nlp_put(struct lpfc_nodelist *ndlp)
2864{2948{
2949 if (ndlp) {
2950 lpfc_debugfs_disc_trc(ndlp->vport, LPFC_DISC_TRC_NODE,
2951 "node put: did:x%x flg:x%x refcnt:x%x",
2952 ndlp->nlp_DID, ndlp->nlp_flag,
2953 atomic_read(&ndlp->kref.refcount));
2954 }
2865 return ndlp ? kref_put(&ndlp->kref, lpfc_nlp_release) : 0;2955 return ndlp ? kref_put(&ndlp->kref, lpfc_nlp_release) : 0;
2866}2956}
2957
2958/* This routine free's the specified nodelist if it is not in use
2959 * by any other discovery thread. This routine returns 1 if the ndlp
2960 * is not being used by anyone and has been freed. A return value of
2961 * 0 indicates it is being used by another discovery thread and the
2962 * refcount is left unchanged.
2963 */
2964int
2965lpfc_nlp_not_used(struct lpfc_nodelist *ndlp)
2966{
2967 lpfc_debugfs_disc_trc(ndlp->vport, LPFC_DISC_TRC_NODE,
2968 "node not used: did:x%x flg:x%x refcnt:x%x",
2969 ndlp->nlp_DID, ndlp->nlp_flag,
2970 atomic_read(&ndlp->kref.refcount));
2971
2972 if (atomic_read(&ndlp->kref.refcount) == 1) {
2973 lpfc_nlp_put(ndlp);
2974 return 1;
2975 }
2976 return 0;
2977}
2978
drivers/scsi/lpfc/lpfc_hw.h+99−13
@@ -139,6 +139,9 @@ struct lpfc_sli_ct_request { · 138 unmodified lines
139 uint8_t len;139 uint8_t len;
140 uint8_t symbname[255];140 uint8_t symbname[255];
141 } rsnn;141 } rsnn;
142 struct da_id { /* For DA_ID requests */
143 uint32_t port_id;
144 } da_id;
142 struct rspn { /* For RSPN_ID requests */145 struct rspn { /* For RSPN_ID requests */
143 uint32_t PortId;146 uint32_t PortId;
144 uint8_t len;147 uint8_t len;
@@ -150,11 +153,7 @@ struct lpfc_sli_ct_request { · 5 unmodified lines
150 struct gff_acc {153 struct gff_acc {
151 uint8_t fbits[128];154 uint8_t fbits[128];
152 } gff_acc;155 } gff_acc;
153#ifdef __BIG_ENDIAN_BITFIELD
154#define FCP_TYPE_FEATURE_OFFSET 7156#define FCP_TYPE_FEATURE_OFFSET 7
155#else /* __LITTLE_ENDIAN_BITFIELD */
156#define FCP_TYPE_FEATURE_OFFSET 4
157#endif
158 struct rff {157 struct rff {
159 uint32_t PortId;158 uint32_t PortId;
160 uint8_t reserved[2];159 uint8_t reserved[2];
@@ -177,6 +176,8 @@ struct lpfc_sli_ct_request { · 16 unmodified lines
177 sizeof(struct rnn))176 sizeof(struct rnn))
178#define RSNN_REQUEST_SZ (offsetof(struct lpfc_sli_ct_request, un) + \177#define RSNN_REQUEST_SZ (offsetof(struct lpfc_sli_ct_request, un) + \
179 sizeof(struct rsnn))178 sizeof(struct rsnn))
179#define DA_ID_REQUEST_SZ (offsetof(struct lpfc_sli_ct_request, un) + \
180 sizeof(struct da_id))
180#define RSPN_REQUEST_SZ (offsetof(struct lpfc_sli_ct_request, un) + \181#define RSPN_REQUEST_SZ (offsetof(struct lpfc_sli_ct_request, un) + \
181 sizeof(struct rspn))182 sizeof(struct rspn))
182 183
@@ -1228,7 +1229,8 @@ typedef struct { /* FireFly BIU registers */ · 1045 unmodified lines
1228#define HS_FFER3 0x20000000 /* Bit 29 */1229#define HS_FFER3 0x20000000 /* Bit 29 */
1229#define HS_FFER2 0x40000000 /* Bit 30 */1230#define HS_FFER2 0x40000000 /* Bit 30 */
1230#define HS_FFER1 0x80000000 /* Bit 31 */1231#define HS_FFER1 0x80000000 /* Bit 31 */
1231#define HS_FFERM 0xFF000000 /* Mask for error bits 31:24 */1232#define HS_CRIT_TEMP 0x00000100 /* Bit 8 */
1233#define HS_FFERM 0xFF000100 /* Mask for error bits 31:24 and 8 */
1232 1234
1233/* Host Control Register */1235/* Host Control Register */
1234 1236
@@ -1277,12 +1279,14 @@ typedef struct { /* FireFly BIU registers */ · 42 unmodified lines
1277#define MBX_DEL_LD_ENTRY 0x1D1279#define MBX_DEL_LD_ENTRY 0x1D
1278#define MBX_RUN_PROGRAM 0x1E1280#define MBX_RUN_PROGRAM 0x1E
1279#define MBX_SET_MASK 0x201281#define MBX_SET_MASK 0x20
1280#define MBX_SET_SLIM 0x211282#define MBX_SET_VARIABLE 0x21
1281#define MBX_UNREG_D_ID 0x231283#define MBX_UNREG_D_ID 0x23
1282#define MBX_KILL_BOARD 0x241284#define MBX_KILL_BOARD 0x24
1283#define MBX_CONFIG_FARP 0x251285#define MBX_CONFIG_FARP 0x25
1284#define MBX_BEACON 0x2A1286#define MBX_BEACON 0x2A
1285#define MBX_HEARTBEAT 0x311287#define MBX_HEARTBEAT 0x31
1288#define MBX_WRITE_VPARMS 0x32
1289#define MBX_ASYNCEVT_ENABLE 0x33
1286 1290
1287#define MBX_CONFIG_HBQ 0x7C1291#define MBX_CONFIG_HBQ 0x7C
1288#define MBX_LOAD_AREA 0x811292#define MBX_LOAD_AREA 0x81
@@ -1297,7 +1301,7 @@ typedef struct { /* FireFly BIU registers */ · 8 unmodified lines
1297#define MBX_REG_VNPID 0x961301#define MBX_REG_VNPID 0x96
1298#define MBX_UNREG_VNPID 0x971302#define MBX_UNREG_VNPID 0x97
1299 1303
1300#define MBX_FLASH_WR_ULA 0x981304#define MBX_WRITE_WWN 0x98
1301#define MBX_SET_DEBUG 0x991305#define MBX_SET_DEBUG 0x99
1302#define MBX_LOAD_EXP_ROM 0x9C1306#define MBX_LOAD_EXP_ROM 0x9C
1303 1307
@@ -1344,6 +1348,7 @@ typedef struct { /* FireFly BIU registers */ · 40 unmodified lines
1344 1348
1345/* SLI_2 IOCB Command Set */1349/* SLI_2 IOCB Command Set */
1346 1350
1351#define CMD_ASYNC_STATUS 0x7C
1347#define CMD_RCV_SEQUENCE64_CX 0x811352#define CMD_RCV_SEQUENCE64_CX 0x81
1348#define CMD_XMIT_SEQUENCE64_CR 0x821353#define CMD_XMIT_SEQUENCE64_CR 0x82
1349#define CMD_XMIT_SEQUENCE64_CX 0x831354#define CMD_XMIT_SEQUENCE64_CX 0x83
@@ -1368,6 +1373,7 @@ typedef struct { /* FireFly BIU registers */ · 18 unmodified lines
1368#define CMD_FCP_TRECEIVE64_CX 0xA11373#define CMD_FCP_TRECEIVE64_CX 0xA1
1369#define CMD_FCP_TRSP64_CX 0xA31374#define CMD_FCP_TRSP64_CX 0xA3
1370 1375
1376#define CMD_QUE_XRI64_CX 0xB3
1371#define CMD_IOCB_RCV_SEQ64_CX 0xB51377#define CMD_IOCB_RCV_SEQ64_CX 0xB5
1372#define CMD_IOCB_RCV_ELS64_CX 0xB71378#define CMD_IOCB_RCV_ELS64_CX 0xB7
1373#define CMD_IOCB_RCV_CONT64_CX 0xBB1379#define CMD_IOCB_RCV_CONT64_CX 0xBB
@@ -1406,6 +1412,8 @@ typedef struct { /* FireFly BIU registers */ · 32 unmodified lines
1406#define MBX_BUSY 0xffffff /* Attempted cmd to busy Mailbox */1412#define MBX_BUSY 0xffffff /* Attempted cmd to busy Mailbox */
1407#define MBX_TIMEOUT 0xfffffe /* time-out expired waiting for */1413#define MBX_TIMEOUT 0xfffffe /* time-out expired waiting for */
1408 1414
1415#define TEMPERATURE_OFFSET 0xB0 /* Slim offset for critical temperature event */
1416
1409/*1417/*
1410 * Begin Structure Definitions for Mailbox Commands1418 * Begin Structure Definitions for Mailbox Commands
1411 */1419 */
@@ -2606,6 +2614,18 @@ typedef struct { · 1194 unmodified lines
2606 uint32_t IPAddress;2614 uint32_t IPAddress;
2607} CONFIG_FARP_VAR;2615} CONFIG_FARP_VAR;
2608 2616
2617/* Structure for MB Command MBX_ASYNCEVT_ENABLE (0x33) */
2618
2619typedef struct {
2620#ifdef __BIG_ENDIAN_BITFIELD
2621 uint32_t rsvd:30;
2622 uint32_t ring:2; /* Ring for ASYNC_EVENT iocb Bits 0-1*/
2623#else /* __LITTLE_ENDIAN */
2624 uint32_t ring:2; /* Ring for ASYNC_EVENT iocb Bits 0-1*/
2625 uint32_t rsvd:30;
2626#endif
2627} ASYNCEVT_ENABLE_VAR;
2628
2609/* Union of all Mailbox Command types */2629/* Union of all Mailbox Command types */
2610#define MAILBOX_CMD_WSIZE 322630#define MAILBOX_CMD_WSIZE 32
2611#define MAILBOX_CMD_SIZE (MAILBOX_CMD_WSIZE * sizeof(uint32_t))2631#define MAILBOX_CMD_SIZE (MAILBOX_CMD_WSIZE * sizeof(uint32_t))
@@ -2645,6 +2665,7 @@ typedef union { · 33 unmodified lines
2645 CONFIG_PORT_VAR varCfgPort; /* cmd = 0x88 (CONFIG_PORT) */2665 CONFIG_PORT_VAR varCfgPort; /* cmd = 0x88 (CONFIG_PORT) */
2646 REG_VPI_VAR varRegVpi; /* cmd = 0x96 (REG_VPI) */2666 REG_VPI_VAR varRegVpi; /* cmd = 0x96 (REG_VPI) */
2647 UNREG_VPI_VAR varUnregVpi; /* cmd = 0x97 (UNREG_VPI) */2667 UNREG_VPI_VAR varUnregVpi; /* cmd = 0x97 (UNREG_VPI) */
2668 ASYNCEVT_ENABLE_VAR varCfgAsyncEvent; /*cmd = x33 (CONFIG_ASYNC) */
2648} MAILVARIANTS;2669} MAILVARIANTS;
2649 2670
2650/*2671/*
@@ -2973,6 +2994,34 @@ typedef struct { · 322 unmodified lines
2973#endif2994#endif
2974} RCV_ELS_REQ64;2995} RCV_ELS_REQ64;
2975 2996
2997/* IOCB Command template for RCV_SEQ64 */
2998struct rcv_seq64 {
2999 struct ulp_bde64 elsReq;
3000 uint32_t hbq_1;
3001 uint32_t parmRo;
3002#ifdef __BIG_ENDIAN_BITFIELD
3003 uint32_t rctl:8;
3004 uint32_t type:8;
3005 uint32_t dfctl:8;
3006 uint32_t ls:1;
3007 uint32_t fs:1;
3008 uint32_t rsvd2:3;
3009 uint32_t si:1;
3010 uint32_t bc:1;
3011 uint32_t rsvd3:1;
3012#else /* __LITTLE_ENDIAN_BITFIELD */
3013 uint32_t rsvd3:1;
3014 uint32_t bc:1;
3015 uint32_t si:1;
3016 uint32_t rsvd2:3;
3017 uint32_t fs:1;
3018 uint32_t ls:1;
3019 uint32_t dfctl:8;
3020 uint32_t type:8;
3021 uint32_t rctl:8;
3022#endif
3023};
3024
2976/* IOCB Command template for all 64 bit FCP Initiator commands */3025/* IOCB Command template for all 64 bit FCP Initiator commands */
2977typedef struct {3026typedef struct {
2978 ULP_BDL bdl;3027 ULP_BDL bdl;
@@ -2987,6 +3036,21 @@ typedef struct { · 8 unmodified lines
2987 uint32_t fcpt_Length; /* transfer ready for IWRITE */3036 uint32_t fcpt_Length; /* transfer ready for IWRITE */
2988} FCPT_FIELDS64;3037} FCPT_FIELDS64;
2989 3038
3039/* IOCB Command template for Async Status iocb commands */
3040typedef struct {
3041 uint32_t rsvd[4];
3042 uint32_t param;
3043#ifdef __BIG_ENDIAN_BITFIELD
3044 uint16_t evt_code; /* High order bits word 5 */
3045 uint16_t sub_ctxt_tag; /* Low order bits word 5 */
3046#else /* __LITTLE_ENDIAN_BITFIELD */
3047 uint16_t sub_ctxt_tag; /* High order bits word 5 */
3048 uint16_t evt_code; /* Low order bits word 5 */
3049#endif
3050} ASYNCSTAT_FIELDS;
3051#define ASYNC_TEMP_WARN 0x100
3052#define ASYNC_TEMP_SAFE 0x101
3053
2990/* IOCB Command template for CMD_IOCB_RCV_ELS64_CX (0xB7)3054/* IOCB Command template for CMD_IOCB_RCV_ELS64_CX (0xB7)
2991 or CMD_IOCB_RCV_SEQ64_CX (0xB5) */3055 or CMD_IOCB_RCV_SEQ64_CX (0xB5) */
2992 3056
@@ -3004,7 +3068,26 @@ struct rcv_sli3 { · 11 unmodified lines
3004 struct ulp_bde64 bde2;3068 struct ulp_bde64 bde2;
3005};3069};
3006 3070
3071/* Structure used for a single HBQ entry */
3072struct lpfc_hbq_entry {
3073 struct ulp_bde64 bde;
3074 uint32_t buffer_tag;
3075};
3007 3076
3077/* IOCB Command template for QUE_XRI64_CX (0xB3) command */
3078typedef struct {
3079 struct lpfc_hbq_entry buff;
3080 uint32_t rsvd;
3081 uint32_t rsvd1;
3082} QUE_XRI64_CX_FIELDS;
3083
3084struct que_xri64cx_ext_fields {
3085 uint32_t iotag64_low;
3086 uint32_t iotag64_high;
3087 uint32_t ebde_count;
3088 uint32_t rsvd;
3089 struct lpfc_hbq_entry buff[5];
3090};
3008 3091
3009typedef struct _IOCB { /* IOCB structure */3092typedef struct _IOCB { /* IOCB structure */
3010 union {3093 union {
@@ -3028,6 +3111,9 @@ typedef struct _IOCB { /* IOCB structure */ · 17 unmodified lines
3028 XMT_SEQ_FIELDS64 xseq64; /* XMIT / BCAST cmd */3111 XMT_SEQ_FIELDS64 xseq64; /* XMIT / BCAST cmd */
3029 FCPI_FIELDS64 fcpi64; /* FCP 64 bit Initiator template */3112 FCPI_FIELDS64 fcpi64; /* FCP 64 bit Initiator template */
3030 FCPT_FIELDS64 fcpt64; /* FCP 64 bit target template */3113 FCPT_FIELDS64 fcpt64; /* FCP 64 bit target template */
3114 ASYNCSTAT_FIELDS asyncstat; /* async_status iocb */
3115 QUE_XRI64_CX_FIELDS quexri64cx; /* que_xri64_cx fields */
3116 struct rcv_seq64 rcvseq64; /* RCV_SEQ64 and RCV_CONT64 */
3031 3117
3032 uint32_t ulpWord[IOCB_WORD_SZ - 2]; /* generic 6 'words' */3118 uint32_t ulpWord[IOCB_WORD_SZ - 2]; /* generic 6 'words' */
3033 } un;3119 } un;
@@ -3085,6 +3171,10 @@ typedef struct _IOCB { /* IOCB structure */ · 51 unmodified lines
3085 3171
3086 union {3172 union {
3087 struct rcv_sli3 rcvsli3; /* words 8 - 15 */3173 struct rcv_sli3 rcvsli3; /* words 8 - 15 */
3174
3175 /* words 8-31 used for que_xri_cx iocb */
3176 struct que_xri64cx_ext_fields que_xri64cx_ext_words;
3177
3088 uint32_t sli3Words[24]; /* 96 extra bytes for SLI-3 */3178 uint32_t sli3Words[24]; /* 96 extra bytes for SLI-3 */
3089 } unsli3;3179 } unsli3;
3090 3180
@@ -3124,12 +3214,6 @@ typedef struct _IOCB { /* IOCB structure */ · 33 unmodified lines
3124 3214
3125} IOCB_t;3215} IOCB_t;
3126 3216
3127/* Structure used for a single HBQ entry */
3128struct lpfc_hbq_entry {
3129 struct ulp_bde64 bde;
3130 uint32_t buffer_tag;
3131};
3132
3133 3217
3134#define SLI1_SLIM_SIZE (4 * 1024)3218#define SLI1_SLIM_SIZE (4 * 1024)
3135 3219
@@ -3172,6 +3256,8 @@ lpfc_is_LC_HBA(unsigned short device) · 36 unmodified lines
3172 (device == PCI_DEVICE_ID_BSMB) ||3256 (device == PCI_DEVICE_ID_BSMB) ||
3173 (device == PCI_DEVICE_ID_ZMID) ||3257 (device == PCI_DEVICE_ID_ZMID) ||
3174 (device == PCI_DEVICE_ID_ZSMB) ||3258 (device == PCI_DEVICE_ID_ZSMB) ||
3259 (device == PCI_DEVICE_ID_SAT_MID) ||
3260 (device == PCI_DEVICE_ID_SAT_SMB) ||
3175 (device == PCI_DEVICE_ID_RFLY))3261 (device == PCI_DEVICE_ID_RFLY))
3176 return 1;3262 return 1;
3177 else3263 else
drivers/scsi/lpfc/lpfc_init.c+318−111
@@ -212,6 +212,18 @@ out_free_mbox: · 211 unmodified lines
212 return 0;212 return 0;
213}213}
214 214
215/* Completion handler for config async event mailbox command. */
216static void
217lpfc_config_async_cmpl(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq)
218{
219 if (pmboxq->mb.mbxStatus == MBX_SUCCESS)
220 phba->temp_sensor_support = 1;
221 else
222 phba->temp_sensor_support = 0;
223 mempool_free(pmboxq, phba->mbox_mem_pool);
224 return;
225}
226
215/************************************************************************/227/************************************************************************/
216/* */228/* */
217/* lpfc_config_port_post */229/* lpfc_config_port_post */
@@ -234,6 +246,15 @@ lpfc_config_port_post(struct lpfc_hba *phba) · 16 unmodified lines
234 int i, j;246 int i, j;
235 int rc;247 int rc;
236 248
249 spin_lock_irq(&phba->hbalock);
250 /*
251 * If the Config port completed correctly the HBA is not
252 * over heated any more.
253 */
254 if (phba->over_temp_state == HBA_OVER_TEMP)
255 phba->over_temp_state = HBA_NORMAL_TEMP;
256 spin_unlock_irq(&phba->hbalock);
257
237 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);258 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
238 if (!pmb) {259 if (!pmb) {
239 phba->link_state = LPFC_HBA_ERROR;260 phba->link_state = LPFC_HBA_ERROR;
@@ -343,7 +364,7 @@ lpfc_config_port_post(struct lpfc_hba *phba) · 103 unmodified lines
343 364
344 phba->link_state = LPFC_LINK_DOWN;365 phba->link_state = LPFC_LINK_DOWN;
345 366
346 /* Only process IOCBs on ring 0 till hba_state is READY */367 /* Only process IOCBs on ELS ring till hba_state is READY */
347 if (psli->ring[psli->extra_ring].cmdringaddr)368 if (psli->ring[psli->extra_ring].cmdringaddr)
348 psli->ring[psli->extra_ring].flag |= LPFC_STOP_IOCB_EVENT;369 psli->ring[psli->extra_ring].flag |= LPFC_STOP_IOCB_EVENT;
349 if (psli->ring[psli->fcp_ring].cmdringaddr)370 if (psli->ring[psli->fcp_ring].cmdringaddr)
@@ -409,7 +430,21 @@ lpfc_config_port_post(struct lpfc_hba *phba) · 59 unmodified lines
409 return -EIO;430 return -EIO;
410 }431 }
411 /* MBOX buffer will be freed in mbox compl */432 /* MBOX buffer will be freed in mbox compl */
433 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
434 lpfc_config_async(phba, pmb, LPFC_ELS_RING);
435 pmb->mbox_cmpl = lpfc_config_async_cmpl;
436 pmb->vport = phba->pport;
437 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);
412 438
439 if ((rc != MBX_BUSY) && (rc != MBX_SUCCESS)) {
440 lpfc_printf_log(phba,
441 KERN_ERR,
442 LOG_INIT,
443 "0456 Adapter failed to issue "
444 "ASYNCEVT_ENABLE mbox status x%x \n.",
445 rc);
446 mempool_free(pmb, phba->mbox_mem_pool);
447 }
413 return (0);448 return (0);
414}449}
415 450
@@ -449,6 +484,9 @@ lpfc_hba_down_post(struct lpfc_hba *phba) · 33 unmodified lines
449 struct lpfc_sli *psli = &phba->sli;484 struct lpfc_sli *psli = &phba->sli;
450 struct lpfc_sli_ring *pring;485 struct lpfc_sli_ring *pring;
451 struct lpfc_dmabuf *mp, *next_mp;486 struct lpfc_dmabuf *mp, *next_mp;
487 struct lpfc_iocbq *iocb;
488 IOCB_t *cmd = NULL;
489 LIST_HEAD(completions);
452 int i;490 int i;
453 491
454 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED)492 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED)
@@ -464,16 +502,42 @@ lpfc_hba_down_post(struct lpfc_hba *phba) · 9 unmodified lines
464 }502 }
465 }503 }
466 504
505 spin_lock_irq(&phba->hbalock);
467 for (i = 0; i < psli->num_rings; i++) {506 for (i = 0; i < psli->num_rings; i++) {
468 pring = &psli->ring[i];507 pring = &psli->ring[i];
508
509 /* At this point in time the HBA is either reset or DOA. Either
510 * way, nothing should be on txcmplq as it will NEVER complete.
511 */
512 list_splice_init(&pring->txcmplq, &completions);
513 pring->txcmplq_cnt = 0;
514 spin_unlock_irq(&phba->hbalock);
515
516 while (!list_empty(&completions)) {
517 iocb = list_get_first(&completions, struct lpfc_iocbq,
518 list);
519 cmd = &iocb->iocb;
520 list_del_init(&iocb->list);
521
522 if (!iocb->iocb_cmpl)
523 lpfc_sli_release_iocbq(phba, iocb);
524 else {
525 cmd->ulpStatus = IOSTAT_LOCAL_REJECT;
526 cmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
527 (iocb->iocb_cmpl) (phba, iocb, iocb);
528 }
529 }
530
469 lpfc_sli_abort_iocb_ring(phba, pring);531 lpfc_sli_abort_iocb_ring(phba, pring);
532 spin_lock_irq(&phba->hbalock);
470 }533 }
534 spin_unlock_irq(&phba->hbalock);
471 535
472 return 0;536 return 0;
473}537}
474 538
475/* HBA heart beat timeout handler */539/* HBA heart beat timeout handler */
476void540static void
477lpfc_hb_timeout(unsigned long ptr)541lpfc_hb_timeout(unsigned long ptr)
478{542{
479 struct lpfc_hba *phba;543 struct lpfc_hba *phba;
@@ -512,8 +576,10 @@ void · 32 unmodified lines
512lpfc_hb_timeout_handler(struct lpfc_hba *phba)576lpfc_hb_timeout_handler(struct lpfc_hba *phba)
513{577{
514 LPFC_MBOXQ_t *pmboxq;578 LPFC_MBOXQ_t *pmboxq;
579 struct lpfc_dmabuf *buf_ptr;
515 int retval;580 int retval;
516 struct lpfc_sli *psli = &phba->sli;581 struct lpfc_sli *psli = &phba->sli;
582 LIST_HEAD(completions);
517 583
518 if ((phba->link_state == LPFC_HBA_ERROR) ||584 if ((phba->link_state == LPFC_HBA_ERROR) ||
519 (phba->pport->load_flag & FC_UNLOADING) ||585 (phba->pport->load_flag & FC_UNLOADING) ||
@@ -540,49 +606,88 @@ lpfc_hb_timeout_handler(struct lpfc_hba *phba) · 20 unmodified lines
540 }606 }
541 spin_unlock_irq(&phba->pport->work_port_lock);607 spin_unlock_irq(&phba->pport->work_port_lock);
542 608
543 /* If there is no heart beat outstanding, issue a heartbeat command */609 if (phba->elsbuf_cnt &&
544 if (!phba->hb_outstanding) {610 (phba->elsbuf_cnt == phba->elsbuf_prev_cnt)) {
545 pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL);611 spin_lock_irq(&phba->hbalock);
546 if (!pmboxq) {612 list_splice_init(&phba->elsbuf, &completions);
547 mod_timer(&phba->hb_tmofunc,613 phba->elsbuf_cnt = 0;
548 jiffies + HZ * LPFC_HB_MBOX_INTERVAL);614 phba->elsbuf_prev_cnt = 0;
549 return;615 spin_unlock_irq(&phba->hbalock);
616
617 while (!list_empty(&completions)) {
618 list_remove_head(&completions, buf_ptr,
619 struct lpfc_dmabuf, list);
620 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys);
621 kfree(buf_ptr);
550 }622 }
623 }
624 phba->elsbuf_prev_cnt = phba->elsbuf_cnt;
551 625
552 lpfc_heart_beat(phba, pmboxq);626 /* If there is no heart beat outstanding, issue a heartbeat command */
553 pmboxq->mbox_cmpl = lpfc_hb_mbox_cmpl;627 if (phba->cfg_enable_hba_heartbeat) {
554 pmboxq->vport = phba->pport;628 if (!phba->hb_outstanding) {
555 retval = lpfc_sli_issue_mbox(phba, pmboxq, MBX_NOWAIT);629 pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL);
630 if (!pmboxq) {
631 mod_timer(&phba->hb_tmofunc,
632 jiffies + HZ * LPFC_HB_MBOX_INTERVAL);
633 return;
634 }
556 635
557 if (retval != MBX_BUSY && retval != MBX_SUCCESS) {636 lpfc_heart_beat(phba, pmboxq);
558 mempool_free(pmboxq, phba->mbox_mem_pool);637 pmboxq->mbox_cmpl = lpfc_hb_mbox_cmpl;
638 pmboxq->vport = phba->pport;
639 retval = lpfc_sli_issue_mbox(phba, pmboxq, MBX_NOWAIT);
640
641 if (retval != MBX_BUSY && retval != MBX_SUCCESS) {
642 mempool_free(pmboxq, phba->mbox_mem_pool);
643 mod_timer(&phba->hb_tmofunc,
644 jiffies + HZ * LPFC_HB_MBOX_INTERVAL);
645 return;
646 }
559 mod_timer(&phba->hb_tmofunc,647 mod_timer(&phba->hb_tmofunc,
560 jiffies + HZ * LPFC_HB_MBOX_INTERVAL);648 jiffies + HZ * LPFC_HB_MBOX_TIMEOUT);
649 phba->hb_outstanding = 1;
561 return;650 return;
651 } else {
652 /*
653 * If heart beat timeout called with hb_outstanding set
654 * we need to take the HBA offline.
655 */
656 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
657 "0459 Adapter heartbeat failure, "
658 "taking this port offline.\n");
659
660 spin_lock_irq(&phba->hbalock);
661 psli->sli_flag &= ~LPFC_SLI2_ACTIVE;
662 spin_unlock_irq(&phba->hbalock);
663
664 lpfc_offline_prep(phba);
665 lpfc_offline(phba);
666 lpfc_unblock_mgmt_io(phba);
667 phba->link_state = LPFC_HBA_ERROR;
668 lpfc_hba_down_post(phba);
562 }669 }
563 mod_timer(&phba->hb_tmofunc,670 }
564 jiffies + HZ * LPFC_HB_MBOX_TIMEOUT);671}
565 phba->hb_outstanding = 1;
566 return;
567 } else {
568 /*
569 * If heart beat timeout called with hb_outstanding set we
570 * need to take the HBA offline.
571 */
572 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
573 "0459 Adapter heartbeat failure, taking "
574 "this port offline.\n");
575 672
576 spin_lock_irq(&phba->hbalock);673static void
577 psli->sli_flag &= ~LPFC_SLI2_ACTIVE;674lpfc_offline_eratt(struct lpfc_hba *phba)
578 spin_unlock_irq(&phba->hbalock);675{
676 struct lpfc_sli *psli = &phba->sli;
579 677
580 lpfc_offline_prep(phba);678 spin_lock_irq(&phba->hbalock);
581 lpfc_offline(phba);679 psli->sli_flag &= ~LPFC_SLI2_ACTIVE;
582 lpfc_unblock_mgmt_io(phba);680 spin_unlock_irq(&phba->hbalock);
583 phba->link_state = LPFC_HBA_ERROR;681 lpfc_offline_prep(phba);
584 lpfc_hba_down_post(phba);682
585 }683 lpfc_offline(phba);
684 lpfc_reset_barrier(phba);
685 lpfc_sli_brdreset(phba);
686 lpfc_hba_down_post(phba);
687 lpfc_sli_brdready(phba, HS_MBRDY);
688 lpfc_unblock_mgmt_io(phba);
689 phba->link_state = LPFC_HBA_ERROR;
690 return;
586}691}
587 692
588/************************************************************************/693/************************************************************************/
@@ -601,6 +706,8 @@ lpfc_handle_eratt(struct lpfc_hba *phba) · 12 unmodified lines
601 struct lpfc_sli_ring *pring;706 struct lpfc_sli_ring *pring;
602 struct lpfc_vport **vports;707 struct lpfc_vport **vports;
603 uint32_t event_data;708 uint32_t event_data;
709 unsigned long temperature;
710 struct temp_event temp_event_data;
604 struct Scsi_Host *shost;711 struct Scsi_Host *shost;
605 int i;712 int i;
606 713
@@ -608,6 +715,9 @@ lpfc_handle_eratt(struct lpfc_hba *phba) · 1 unmodified line
608 * since we cannot communicate with the pci card anyway. */715 * since we cannot communicate with the pci card anyway. */
609 if (pci_channel_offline(phba->pcidev))716 if (pci_channel_offline(phba->pcidev))
610 return;717 return;
718 /* If resets are disabled then leave the HBA alone and return */
719 if (!phba->cfg_enable_hba_reset)
720 return;
611 721
612 if (phba->work_hs & HS_FFER6 ||722 if (phba->work_hs & HS_FFER6 ||
613 phba->work_hs & HS_FFER5) {723 phba->work_hs & HS_FFER5) {
@@ -620,14 +730,14 @@ lpfc_handle_eratt(struct lpfc_hba *phba) · 6 unmodified lines
620 vports = lpfc_create_vport_work_array(phba);730 vports = lpfc_create_vport_work_array(phba);
621 if (vports != NULL)731 if (vports != NULL)
622 for(i = 0;732 for(i = 0;
623 i < LPFC_MAX_VPORTS && vports[i] != NULL;733 i <= phba->max_vpi && vports[i] != NULL;
624 i++){734 i++){
625 shost = lpfc_shost_from_vport(vports[i]);735 shost = lpfc_shost_from_vport(vports[i]);
626 spin_lock_irq(shost->host_lock);736 spin_lock_irq(shost->host_lock);
627 vports[i]->fc_flag |= FC_ESTABLISH_LINK;737 vports[i]->fc_flag |= FC_ESTABLISH_LINK;
628 spin_unlock_irq(shost->host_lock);738 spin_unlock_irq(shost->host_lock);
629 }739 }
630 lpfc_destroy_vport_work_array(vports);740 lpfc_destroy_vport_work_array(phba, vports);
631 spin_lock_irq(&phba->hbalock);741 spin_lock_irq(&phba->hbalock);
632 psli->sli_flag &= ~LPFC_SLI2_ACTIVE;742 psli->sli_flag &= ~LPFC_SLI2_ACTIVE;
633 spin_unlock_irq(&phba->hbalock);743 spin_unlock_irq(&phba->hbalock);
@@ -655,6 +765,31 @@ lpfc_handle_eratt(struct lpfc_hba *phba) · 21 unmodified lines
655 return;765 return;
656 }766 }
657 lpfc_unblock_mgmt_io(phba);767 lpfc_unblock_mgmt_io(phba);
768 } else if (phba->work_hs & HS_CRIT_TEMP) {
769 temperature = readl(phba->MBslimaddr + TEMPERATURE_OFFSET);
770 temp_event_data.event_type = FC_REG_TEMPERATURE_EVENT;
771 temp_event_data.event_code = LPFC_CRIT_TEMP;
772 temp_event_data.data = (uint32_t)temperature;
773
774 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
775 "0459 Adapter maximum temperature exceeded "
776 "(%ld), taking this port offline "
777 "Data: x%x x%x x%x\n",
778 temperature, phba->work_hs,
779 phba->work_status[0], phba->work_status[1]);
780
781 shost = lpfc_shost_from_vport(phba->pport);
782 fc_host_post_vendor_event(shost, fc_get_event_number(),
783 sizeof(temp_event_data),
784 (char *) &temp_event_data,
785 SCSI_NL_VID_TYPE_PCI
786 | PCI_VENDOR_ID_EMULEX);
787
788 spin_lock_irq(&phba->hbalock);
789 phba->over_temp_state = HBA_OVER_TEMP;
790 spin_unlock_irq(&phba->hbalock);
791 lpfc_offline_eratt(phba);
792
658 } else {793 } else {
659 /* The if clause above forces this code path when the status794 /* The if clause above forces this code path when the status
660 * failure is a value other than FFER6. Do not call the offline795 * failure is a value other than FFER6. Do not call the offline
@@ -672,14 +807,7 @@ lpfc_handle_eratt(struct lpfc_hba *phba) · 11 unmodified lines
672 sizeof(event_data), (char *) &event_data,807 sizeof(event_data), (char *) &event_data,
673 SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_EMULEX);808 SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_EMULEX);
674 809
675 spin_lock_irq(&phba->hbalock);810 lpfc_offline_eratt(phba);
676 psli->sli_flag &= ~LPFC_SLI2_ACTIVE;
677 spin_unlock_irq(&phba->hbalock);
678 lpfc_offline_prep(phba);
679 lpfc_offline(phba);
680 lpfc_unblock_mgmt_io(phba);
681 phba->link_state = LPFC_HBA_ERROR;
682 lpfc_hba_down_post(phba);
683 }811 }
684}812}
685 813
@@ -699,21 +827,25 @@ lpfc_handle_latt(struct lpfc_hba *phba) · 13 unmodified lines
699 LPFC_MBOXQ_t *pmb;827 LPFC_MBOXQ_t *pmb;
700 volatile uint32_t control;828 volatile uint32_t control;
701 struct lpfc_dmabuf *mp;829 struct lpfc_dmabuf *mp;
702 int rc = -ENOMEM;830 int rc = 0;
703 831
704 pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);832 pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
705 if (!pmb)833 if (!pmb) {
834 rc = 1;
706 goto lpfc_handle_latt_err_exit;835 goto lpfc_handle_latt_err_exit;
836 }
707 837
708 mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);838 mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
709 if (!mp)839 if (!mp) {
840 rc = 2;
710 goto lpfc_handle_latt_free_pmb;841 goto lpfc_handle_latt_free_pmb;
842 }
711 843
712 mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys);844 mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys);
713 if (!mp->virt)

428 more lines aren’t shown here.

drivers/scsi/lpfc/lpfc_logmsg.h+1−0

This diff is large: its 8 lines aren’t shown here.

drivers/scsi/lpfc/lpfc_mbox.c+27−5

This diff is large: its 60 lines aren’t shown here.

drivers/scsi/lpfc/lpfc_mem.c+1−0

This diff is large: its 8 lines aren’t shown here.

drivers/scsi/lpfc/lpfc_nportdisc.c+132−28

This diff is large: its 319 lines aren’t shown here.

drivers/scsi/lpfc/lpfc_scsi.c+37−17

This diff is large: its 148 lines aren’t shown here.

drivers/scsi/lpfc/lpfc_scsi.h+1−0

This diff is large: its 8 lines aren’t shown here.

drivers/scsi/lpfc/lpfc_sli.c+358−176

This diff is large: its 897 lines aren’t shown here.

drivers/scsi/lpfc/lpfc_sli.h+5−7

This diff is large: its 58 lines aren’t shown here.

drivers/scsi/lpfc/lpfc_version.h+3−3

This diff is large: its 22 lines aren’t shown here.

drivers/scsi/lpfc/lpfc_vport.c+57−36

This diff is large: its 165 lines aren’t shown here.

drivers/scsi/lpfc/lpfc_vport.h+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/scsi/megaraid.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/scsi/megaraid/megaraid_mbox.c+3−3

This diff is large: its 27 lines aren’t shown here.

drivers/scsi/megaraid/megaraid_sas.c+448−124

This diff is large: its 825 lines aren’t shown here.

drivers/scsi/megaraid/megaraid_sas.h+12−6

This diff is large: its 66 lines aren’t shown here.

drivers/scsi/ncr53c8xx.c+2−1

This diff is large: its 10 lines aren’t shown here.

drivers/scsi/pcmcia/Kconfig+2−1

This diff is large: its 10 lines aren’t shown here.

drivers/scsi/pcmcia/nsp_cs.c+34−20

This diff is large: its 145 lines aren’t shown here.

drivers/scsi/ppa.c+5−7

This diff is large: its 24 lines aren’t shown here.

drivers/scsi/psi240i.c+0−689

This diff is large: its 690 lines aren’t shown here.

drivers/scsi/psi240i.h+0−315

This diff is large: its 316 lines aren’t shown here.

drivers/scsi/psi_chip.h+0−195

This diff is large: its 196 lines aren’t shown here.

drivers/scsi/qla1280.c+2−2

This diff is large: its 18 lines aren’t shown here.

drivers/scsi/qla2xxx/Makefile+1−1

This diff is large: its 6 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_attr.c+35−19

This diff is large: its 111 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_dbg.c+22−15

This diff is large: its 62 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_dbg.h+19−0

This diff is large: its 26 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_def.h+28−24

This diff is large: its 109 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_dfs.c+175−0

This diff is large: its 176 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_fw.h+24−6

This diff is large: its 53 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_gbl.h+21−30

This diff is large: its 133 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_init.c+70−27

This diff is large: its 184 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_isr.c+54−66

This diff is large: its 207 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_mbx.c+144−286

This diff is large: its 683 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_mid.c+20−26

This diff is large: its 123 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_os.c+29−51

This diff is large: its 215 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_sup.c+12−6

This diff is large: its 61 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_version.h+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/scsi/qla4xxx/ql4_init.c+3−1

This diff is large: its 18 lines aren’t shown here.

drivers/scsi/qla4xxx/ql4_isr.c+4−7

This diff is large: its 38 lines aren’t shown here.

drivers/scsi/qla4xxx/ql4_os.c+2−5

This diff is large: its 28 lines aren’t shown here.

drivers/scsi/qlogicpti.c+8−23

This diff is large: its 63 lines aren’t shown here.

drivers/scsi/scsi.c+168−114

This diff is large: its 535 lines aren’t shown here.

drivers/scsi/scsi_debug.c+10−27

This diff is large: its 79 lines aren’t shown here.

drivers/scsi/scsi_devinfo.c+15−19

This diff is large: its 89 lines aren’t shown here.

drivers/scsi/scsi_error.c+64−67

This diff is large: its 465 lines aren’t shown here.

drivers/scsi/scsi_ioctl.c+17−9

This diff is large: its 54 lines aren’t shown here.

drivers/scsi/scsi_lib.c+72−45

This diff is large: its 290 lines aren’t shown here.

drivers/scsi/scsi_netlink.c+7−12

This diff is large: its 49 lines aren’t shown here.

drivers/scsi/scsi_proc.c+108−2

This diff is large: its 211 lines aren’t shown here.

drivers/scsi/scsi_scan.c+23−13

This diff is large: its 113 lines aren’t shown here.

drivers/scsi/scsi_sysfs.c+1−0

This diff is large: its 8 lines aren’t shown here.

drivers/scsi/scsi_tgt_if.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/scsi/scsi_tgt_lib.c+13−17

This diff is large: its 75 lines aren’t shown here.

drivers/scsi/scsi_transport_fc.c+46−56

This diff is large: its 338 lines aren’t shown here.

drivers/scsi/scsi_transport_iscsi.c+185−145

This diff is large: its 622 lines aren’t shown here.

drivers/scsi/scsi_transport_sas.c+22−19

This diff is large: its 188 lines aren’t shown here.

drivers/scsi/scsi_transport_spi.c+176−82

This diff is large: its 406 lines aren’t shown here.

drivers/scsi/scsi_transport_srp.c+6−7

This diff is large: its 51 lines aren’t shown here.

drivers/scsi/scsicam.c+24−11

This diff is large: its 71 lines aren’t shown here.

drivers/scsi/sd.c+33−11

This diff is large: its 87 lines aren’t shown here.

drivers/scsi/seagate.c+0−1667

This diff is large: its 1668 lines aren’t shown here.

drivers/scsi/sg.c+16−8

This diff is large: its 67 lines aren’t shown here.

drivers/scsi/sgiwd93.c+1−0

This diff is large: its 8 lines aren’t shown here.

drivers/scsi/sr.c+24−11

This diff is large: its 65 lines aren’t shown here.

drivers/scsi/sr.h+4−0

This diff is large: its 18 lines aren’t shown here.

drivers/scsi/sr_ioctl.c+34−14

This diff is large: its 68 lines aren’t shown here.

drivers/scsi/st.c+4−5

This diff is large: its 37 lines aren’t shown here.

drivers/scsi/sun3_NCR5380.c+12−12

This diff is large: its 85 lines aren’t shown here.

drivers/scsi/sym53c416.c+1−15

This diff is large: its 29 lines aren’t shown here.

drivers/scsi/sym53c8xx_2/sym_glue.c+11−11

This diff is large: its 69 lines aren’t shown here.

drivers/scsi/tmscsim.c+3−3

This diff is large: its 27 lines aren’t shown here.

drivers/scsi/u14-34f.c+2−2

This diff is large: its 12 lines aren’t shown here.

drivers/scsi/ultrastor.c+11−4

This diff is large: its 29 lines aren’t shown here.

drivers/scsi/wd33c93.c+5−5

This diff is large: its 22 lines aren’t shown here.

drivers/scsi/wd7000.c+6−6

This diff is large: its 36 lines aren’t shown here.

drivers/usb/storage/freecom.c+6−8

This diff is large: its 45 lines aren’t shown here.

drivers/usb/storage/isd200.c+46−20

This diff is large: its 191 lines aren’t shown here.

drivers/usb/storage/protocol.c+53−73

This diff is large: its 153 lines aren’t shown here.

drivers/usb/storage/scsiglue.c+14−10

This diff is large: its 45 lines aren’t shown here.

drivers/usb/storage/sddr09.c+3−6

This diff is large: its 24 lines aren’t shown here.

drivers/usb/storage/shuttle_usbat.c+26−42

This diff is large: its 215 lines aren’t shown here.

drivers/usb/storage/transport.c+28−17

This diff is large: its 129 lines aren’t shown here.

drivers/usb/storage/transport.h+2−0

This diff is large: its 9 lines aren’t shown here.

fs/sysfs/file.c+9−2

This diff is large: its 25 lines aren’t shown here.

fs/sysfs/group.c+16−10

This diff is large: its 58 lines aren’t shown here.

include/linux/attribute_container.h+1−0

This diff is large: its 8 lines aren’t shown here.

include/linux/blkdev.h+1−0

This diff is large: its 8 lines aren’t shown here.

include/linux/sysfs.h+2−0

This diff is large: its 9 lines aren’t shown here.

include/scsi/iscsi_if.h+20−0

This diff is large: its 54 lines aren’t shown here.

include/scsi/iscsi_proto.h+13−1

This diff is large: its 41 lines aren’t shown here.

include/scsi/libiscsi.h+65−17

This diff is large: its 194 lines aren’t shown here.

include/scsi/libsas.h+14−14

This diff is large: its 96 lines aren’t shown here.

include/scsi/sas.h+6−7

This diff is large: its 20 lines aren’t shown here.

include/scsi/scsi_cmnd.h+1−1

This diff is large: its 9 lines aren’t shown here.

include/scsi/scsi_device.h+9−4

This diff is large: its 48 lines aren’t shown here.

include/scsi/scsi_transport_iscsi.h+7−3

This diff is large: its 45 lines aren’t shown here.

include/scsi/scsi_transport_sas.h+5−11

This diff is large: its 29 lines aren’t shown here.

include/scsi/sd.h+1−0

This diff is large: its 8 lines aren’t shown here.

kernel/params.c+1−1

This diff is large: its 9 lines aren’t shown here.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t