Commit 86f8a1b4b472e4b2b58df5826709d4797d84d46f
Committed by
James Bottomley
1 parent
a5b11dda12
Exists in
master
and in
7 other branches
[SCSI] zfcp: Remove UNIT_REGISTERED status flag
Use the device pointer in zfcp_unit for tracking if we have a registered SCSI device. With this approach, the flag ZFCP_STATUS_UNIT_REGISTERED is only redundant and can be removed. Acked-by: Swen Schillig <swen@vnet.ibm.com> Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Showing 4 changed files with 2 additions and 8 deletions Inline Diff
drivers/s390/scsi/zfcp_ccw.c
1 | /* | 1 | /* |
2 | * zfcp device driver | 2 | * zfcp device driver |
3 | * | 3 | * |
4 | * Registration and callback for the s390 common I/O layer. | 4 | * Registration and callback for the s390 common I/O layer. |
5 | * | 5 | * |
6 | * Copyright IBM Corporation 2002, 2008 | 6 | * Copyright IBM Corporation 2002, 2008 |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #define KMSG_COMPONENT "zfcp" | 9 | #define KMSG_COMPONENT "zfcp" |
10 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt | 10 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt |
11 | 11 | ||
12 | #include "zfcp_ext.h" | 12 | #include "zfcp_ext.h" |
13 | 13 | ||
14 | /** | 14 | /** |
15 | * zfcp_ccw_probe - probe function of zfcp driver | 15 | * zfcp_ccw_probe - probe function of zfcp driver |
16 | * @ccw_device: pointer to belonging ccw device | 16 | * @ccw_device: pointer to belonging ccw device |
17 | * | 17 | * |
18 | * This function gets called by the common i/o layer and sets up the initial | 18 | * This function gets called by the common i/o layer and sets up the initial |
19 | * data structures for each fcp adapter, which was detected by the system. | 19 | * data structures for each fcp adapter, which was detected by the system. |
20 | * Also the sysfs files for this adapter will be created by this function. | 20 | * Also the sysfs files for this adapter will be created by this function. |
21 | * In addition the nameserver port will be added to the ports of the adapter | 21 | * In addition the nameserver port will be added to the ports of the adapter |
22 | * and its sysfs representation will be created too. | 22 | * and its sysfs representation will be created too. |
23 | */ | 23 | */ |
24 | static int zfcp_ccw_probe(struct ccw_device *ccw_device) | 24 | static int zfcp_ccw_probe(struct ccw_device *ccw_device) |
25 | { | 25 | { |
26 | int retval = 0; | 26 | int retval = 0; |
27 | 27 | ||
28 | down(&zfcp_data.config_sema); | 28 | down(&zfcp_data.config_sema); |
29 | if (zfcp_adapter_enqueue(ccw_device)) { | 29 | if (zfcp_adapter_enqueue(ccw_device)) { |
30 | dev_err(&ccw_device->dev, | 30 | dev_err(&ccw_device->dev, |
31 | "Setting up data structures for the " | 31 | "Setting up data structures for the " |
32 | "FCP adapter failed\n"); | 32 | "FCP adapter failed\n"); |
33 | retval = -EINVAL; | 33 | retval = -EINVAL; |
34 | } | 34 | } |
35 | up(&zfcp_data.config_sema); | 35 | up(&zfcp_data.config_sema); |
36 | return retval; | 36 | return retval; |
37 | } | 37 | } |
38 | 38 | ||
39 | /** | 39 | /** |
40 | * zfcp_ccw_remove - remove function of zfcp driver | 40 | * zfcp_ccw_remove - remove function of zfcp driver |
41 | * @ccw_device: pointer to belonging ccw device | 41 | * @ccw_device: pointer to belonging ccw device |
42 | * | 42 | * |
43 | * This function gets called by the common i/o layer and removes an adapter | 43 | * This function gets called by the common i/o layer and removes an adapter |
44 | * from the system. Task of this function is to get rid of all units and | 44 | * from the system. Task of this function is to get rid of all units and |
45 | * ports that belong to this adapter. And in addition all resources of this | 45 | * ports that belong to this adapter. And in addition all resources of this |
46 | * adapter will be freed too. | 46 | * adapter will be freed too. |
47 | */ | 47 | */ |
48 | static void zfcp_ccw_remove(struct ccw_device *ccw_device) | 48 | static void zfcp_ccw_remove(struct ccw_device *ccw_device) |
49 | { | 49 | { |
50 | struct zfcp_adapter *adapter; | 50 | struct zfcp_adapter *adapter; |
51 | struct zfcp_port *port, *p; | 51 | struct zfcp_port *port, *p; |
52 | struct zfcp_unit *unit, *u; | 52 | struct zfcp_unit *unit, *u; |
53 | LIST_HEAD(unit_remove_lh); | 53 | LIST_HEAD(unit_remove_lh); |
54 | LIST_HEAD(port_remove_lh); | 54 | LIST_HEAD(port_remove_lh); |
55 | 55 | ||
56 | ccw_device_set_offline(ccw_device); | 56 | ccw_device_set_offline(ccw_device); |
57 | down(&zfcp_data.config_sema); | 57 | down(&zfcp_data.config_sema); |
58 | adapter = dev_get_drvdata(&ccw_device->dev); | 58 | adapter = dev_get_drvdata(&ccw_device->dev); |
59 | 59 | ||
60 | write_lock_irq(&zfcp_data.config_lock); | 60 | write_lock_irq(&zfcp_data.config_lock); |
61 | list_for_each_entry_safe(port, p, &adapter->port_list_head, list) { | 61 | list_for_each_entry_safe(port, p, &adapter->port_list_head, list) { |
62 | list_for_each_entry_safe(unit, u, &port->unit_list_head, list) { | 62 | list_for_each_entry_safe(unit, u, &port->unit_list_head, list) { |
63 | list_move(&unit->list, &unit_remove_lh); | 63 | list_move(&unit->list, &unit_remove_lh); |
64 | atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, | 64 | atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, |
65 | &unit->status); | 65 | &unit->status); |
66 | } | 66 | } |
67 | list_move(&port->list, &port_remove_lh); | 67 | list_move(&port->list, &port_remove_lh); |
68 | atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &port->status); | 68 | atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &port->status); |
69 | } | 69 | } |
70 | atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &adapter->status); | 70 | atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &adapter->status); |
71 | write_unlock_irq(&zfcp_data.config_lock); | 71 | write_unlock_irq(&zfcp_data.config_lock); |
72 | 72 | ||
73 | list_for_each_entry_safe(port, p, &port_remove_lh, list) { | 73 | list_for_each_entry_safe(port, p, &port_remove_lh, list) { |
74 | list_for_each_entry_safe(unit, u, &unit_remove_lh, list) { | 74 | list_for_each_entry_safe(unit, u, &unit_remove_lh, list) { |
75 | if (atomic_read(&unit->status) & | 75 | if (unit->device) |
76 | ZFCP_STATUS_UNIT_REGISTERED) | ||
77 | scsi_remove_device(unit->device); | 76 | scsi_remove_device(unit->device); |
78 | zfcp_unit_dequeue(unit); | 77 | zfcp_unit_dequeue(unit); |
79 | } | 78 | } |
80 | zfcp_port_dequeue(port); | 79 | zfcp_port_dequeue(port); |
81 | } | 80 | } |
82 | wait_event(adapter->remove_wq, atomic_read(&adapter->refcount) == 0); | 81 | wait_event(adapter->remove_wq, atomic_read(&adapter->refcount) == 0); |
83 | zfcp_adapter_dequeue(adapter); | 82 | zfcp_adapter_dequeue(adapter); |
84 | 83 | ||
85 | up(&zfcp_data.config_sema); | 84 | up(&zfcp_data.config_sema); |
86 | } | 85 | } |
87 | 86 | ||
88 | /** | 87 | /** |
89 | * zfcp_ccw_set_online - set_online function of zfcp driver | 88 | * zfcp_ccw_set_online - set_online function of zfcp driver |
90 | * @ccw_device: pointer to belonging ccw device | 89 | * @ccw_device: pointer to belonging ccw device |
91 | * | 90 | * |
92 | * This function gets called by the common i/o layer and sets an adapter | 91 | * This function gets called by the common i/o layer and sets an adapter |
93 | * into state online. Setting an fcp device online means that it will be | 92 | * into state online. Setting an fcp device online means that it will be |
94 | * registered with the SCSI stack, that the QDIO queues will be set up | 93 | * registered with the SCSI stack, that the QDIO queues will be set up |
95 | * and that the adapter will be opened (asynchronously). | 94 | * and that the adapter will be opened (asynchronously). |
96 | */ | 95 | */ |
97 | static int zfcp_ccw_set_online(struct ccw_device *ccw_device) | 96 | static int zfcp_ccw_set_online(struct ccw_device *ccw_device) |
98 | { | 97 | { |
99 | struct zfcp_adapter *adapter; | 98 | struct zfcp_adapter *adapter; |
100 | int retval; | 99 | int retval; |
101 | 100 | ||
102 | down(&zfcp_data.config_sema); | 101 | down(&zfcp_data.config_sema); |
103 | adapter = dev_get_drvdata(&ccw_device->dev); | 102 | adapter = dev_get_drvdata(&ccw_device->dev); |
104 | 103 | ||
105 | retval = zfcp_erp_thread_setup(adapter); | 104 | retval = zfcp_erp_thread_setup(adapter); |
106 | if (retval) | 105 | if (retval) |
107 | goto out; | 106 | goto out; |
108 | 107 | ||
109 | /* initialize request counter */ | 108 | /* initialize request counter */ |
110 | BUG_ON(!zfcp_reqlist_isempty(adapter)); | 109 | BUG_ON(!zfcp_reqlist_isempty(adapter)); |
111 | adapter->req_no = 0; | 110 | adapter->req_no = 0; |
112 | 111 | ||
113 | zfcp_erp_modify_adapter_status(adapter, 10, NULL, | 112 | zfcp_erp_modify_adapter_status(adapter, 10, NULL, |
114 | ZFCP_STATUS_COMMON_RUNNING, ZFCP_SET); | 113 | ZFCP_STATUS_COMMON_RUNNING, ZFCP_SET); |
115 | zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED, 85, | 114 | zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED, 85, |
116 | NULL); | 115 | NULL); |
117 | zfcp_erp_wait(adapter); | 116 | zfcp_erp_wait(adapter); |
118 | up(&zfcp_data.config_sema); | 117 | up(&zfcp_data.config_sema); |
119 | flush_work(&adapter->scan_work); | 118 | flush_work(&adapter->scan_work); |
120 | return 0; | 119 | return 0; |
121 | 120 | ||
122 | out: | 121 | out: |
123 | up(&zfcp_data.config_sema); | 122 | up(&zfcp_data.config_sema); |
124 | return retval; | 123 | return retval; |
125 | } | 124 | } |
126 | 125 | ||
127 | /** | 126 | /** |
128 | * zfcp_ccw_set_offline - set_offline function of zfcp driver | 127 | * zfcp_ccw_set_offline - set_offline function of zfcp driver |
129 | * @ccw_device: pointer to belonging ccw device | 128 | * @ccw_device: pointer to belonging ccw device |
130 | * | 129 | * |
131 | * This function gets called by the common i/o layer and sets an adapter | 130 | * This function gets called by the common i/o layer and sets an adapter |
132 | * into state offline. | 131 | * into state offline. |
133 | */ | 132 | */ |
134 | static int zfcp_ccw_set_offline(struct ccw_device *ccw_device) | 133 | static int zfcp_ccw_set_offline(struct ccw_device *ccw_device) |
135 | { | 134 | { |
136 | struct zfcp_adapter *adapter; | 135 | struct zfcp_adapter *adapter; |
137 | 136 | ||
138 | down(&zfcp_data.config_sema); | 137 | down(&zfcp_data.config_sema); |
139 | adapter = dev_get_drvdata(&ccw_device->dev); | 138 | adapter = dev_get_drvdata(&ccw_device->dev); |
140 | zfcp_erp_adapter_shutdown(adapter, 0, 86, NULL); | 139 | zfcp_erp_adapter_shutdown(adapter, 0, 86, NULL); |
141 | zfcp_erp_wait(adapter); | 140 | zfcp_erp_wait(adapter); |
142 | zfcp_erp_thread_kill(adapter); | 141 | zfcp_erp_thread_kill(adapter); |
143 | up(&zfcp_data.config_sema); | 142 | up(&zfcp_data.config_sema); |
144 | return 0; | 143 | return 0; |
145 | } | 144 | } |
146 | 145 | ||
147 | /** | 146 | /** |
148 | * zfcp_ccw_notify - ccw notify function | 147 | * zfcp_ccw_notify - ccw notify function |
149 | * @ccw_device: pointer to belonging ccw device | 148 | * @ccw_device: pointer to belonging ccw device |
150 | * @event: indicates if adapter was detached or attached | 149 | * @event: indicates if adapter was detached or attached |
151 | * | 150 | * |
152 | * This function gets called by the common i/o layer if an adapter has gone | 151 | * This function gets called by the common i/o layer if an adapter has gone |
153 | * or reappeared. | 152 | * or reappeared. |
154 | */ | 153 | */ |
155 | static int zfcp_ccw_notify(struct ccw_device *ccw_device, int event) | 154 | static int zfcp_ccw_notify(struct ccw_device *ccw_device, int event) |
156 | { | 155 | { |
157 | struct zfcp_adapter *adapter = dev_get_drvdata(&ccw_device->dev); | 156 | struct zfcp_adapter *adapter = dev_get_drvdata(&ccw_device->dev); |
158 | 157 | ||
159 | switch (event) { | 158 | switch (event) { |
160 | case CIO_GONE: | 159 | case CIO_GONE: |
161 | dev_warn(&adapter->ccw_device->dev, | 160 | dev_warn(&adapter->ccw_device->dev, |
162 | "The FCP device has been detached\n"); | 161 | "The FCP device has been detached\n"); |
163 | zfcp_erp_adapter_shutdown(adapter, 0, 87, NULL); | 162 | zfcp_erp_adapter_shutdown(adapter, 0, 87, NULL); |
164 | break; | 163 | break; |
165 | case CIO_NO_PATH: | 164 | case CIO_NO_PATH: |
166 | dev_warn(&adapter->ccw_device->dev, | 165 | dev_warn(&adapter->ccw_device->dev, |
167 | "The CHPID for the FCP device is offline\n"); | 166 | "The CHPID for the FCP device is offline\n"); |
168 | zfcp_erp_adapter_shutdown(adapter, 0, 88, NULL); | 167 | zfcp_erp_adapter_shutdown(adapter, 0, 88, NULL); |
169 | break; | 168 | break; |
170 | case CIO_OPER: | 169 | case CIO_OPER: |
171 | dev_info(&adapter->ccw_device->dev, | 170 | dev_info(&adapter->ccw_device->dev, |
172 | "The FCP device is operational again\n"); | 171 | "The FCP device is operational again\n"); |
173 | zfcp_erp_modify_adapter_status(adapter, 11, NULL, | 172 | zfcp_erp_modify_adapter_status(adapter, 11, NULL, |
174 | ZFCP_STATUS_COMMON_RUNNING, | 173 | ZFCP_STATUS_COMMON_RUNNING, |
175 | ZFCP_SET); | 174 | ZFCP_SET); |
176 | zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED, | 175 | zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED, |
177 | 89, NULL); | 176 | 89, NULL); |
178 | break; | 177 | break; |
179 | } | 178 | } |
180 | return 1; | 179 | return 1; |
181 | } | 180 | } |
182 | 181 | ||
183 | /** | 182 | /** |
184 | * zfcp_ccw_shutdown - handle shutdown from cio | 183 | * zfcp_ccw_shutdown - handle shutdown from cio |
185 | * @cdev: device for adapter to shutdown. | 184 | * @cdev: device for adapter to shutdown. |
186 | */ | 185 | */ |
187 | static void zfcp_ccw_shutdown(struct ccw_device *cdev) | 186 | static void zfcp_ccw_shutdown(struct ccw_device *cdev) |
188 | { | 187 | { |
189 | struct zfcp_adapter *adapter; | 188 | struct zfcp_adapter *adapter; |
190 | 189 | ||
191 | down(&zfcp_data.config_sema); | 190 | down(&zfcp_data.config_sema); |
192 | adapter = dev_get_drvdata(&cdev->dev); | 191 | adapter = dev_get_drvdata(&cdev->dev); |
193 | zfcp_erp_adapter_shutdown(adapter, 0, 90, NULL); | 192 | zfcp_erp_adapter_shutdown(adapter, 0, 90, NULL); |
194 | zfcp_erp_wait(adapter); | 193 | zfcp_erp_wait(adapter); |
195 | up(&zfcp_data.config_sema); | 194 | up(&zfcp_data.config_sema); |
196 | } | 195 | } |
197 | 196 | ||
198 | static struct ccw_device_id zfcp_ccw_device_id[] = { | 197 | static struct ccw_device_id zfcp_ccw_device_id[] = { |
199 | { CCW_DEVICE_DEVTYPE(0x1731, 0x3, 0x1732, 0x3) }, | 198 | { CCW_DEVICE_DEVTYPE(0x1731, 0x3, 0x1732, 0x3) }, |
200 | { CCW_DEVICE_DEVTYPE(0x1731, 0x3, 0x1732, 0x4) }, /* priv. */ | 199 | { CCW_DEVICE_DEVTYPE(0x1731, 0x3, 0x1732, 0x4) }, /* priv. */ |
201 | {}, | 200 | {}, |
202 | }; | 201 | }; |
203 | 202 | ||
204 | MODULE_DEVICE_TABLE(ccw, zfcp_ccw_device_id); | 203 | MODULE_DEVICE_TABLE(ccw, zfcp_ccw_device_id); |
205 | 204 | ||
206 | static struct ccw_driver zfcp_ccw_driver = { | 205 | static struct ccw_driver zfcp_ccw_driver = { |
207 | .owner = THIS_MODULE, | 206 | .owner = THIS_MODULE, |
208 | .name = "zfcp", | 207 | .name = "zfcp", |
209 | .ids = zfcp_ccw_device_id, | 208 | .ids = zfcp_ccw_device_id, |
210 | .probe = zfcp_ccw_probe, | 209 | .probe = zfcp_ccw_probe, |
211 | .remove = zfcp_ccw_remove, | 210 | .remove = zfcp_ccw_remove, |
212 | .set_online = zfcp_ccw_set_online, | 211 | .set_online = zfcp_ccw_set_online, |
213 | .set_offline = zfcp_ccw_set_offline, | 212 | .set_offline = zfcp_ccw_set_offline, |
214 | .notify = zfcp_ccw_notify, | 213 | .notify = zfcp_ccw_notify, |
215 | .shutdown = zfcp_ccw_shutdown, | 214 | .shutdown = zfcp_ccw_shutdown, |
216 | }; | 215 | }; |
217 | 216 | ||
218 | /** | 217 | /** |
219 | * zfcp_ccw_register - ccw register function | 218 | * zfcp_ccw_register - ccw register function |
220 | * | 219 | * |
221 | * Registers the driver at the common i/o layer. This function will be called | 220 | * Registers the driver at the common i/o layer. This function will be called |
222 | * at module load time/system start. | 221 | * at module load time/system start. |
223 | */ | 222 | */ |
224 | int __init zfcp_ccw_register(void) | 223 | int __init zfcp_ccw_register(void) |
225 | { | 224 | { |
226 | return ccw_driver_register(&zfcp_ccw_driver); | 225 | return ccw_driver_register(&zfcp_ccw_driver); |
227 | } | 226 | } |
228 | 227 | ||
229 | /** | 228 | /** |
230 | * zfcp_get_adapter_by_busid - find zfcp_adapter struct | 229 | * zfcp_get_adapter_by_busid - find zfcp_adapter struct |
231 | * @busid: bus id string of zfcp adapter to find | 230 | * @busid: bus id string of zfcp adapter to find |
232 | */ | 231 | */ |
233 | struct zfcp_adapter *zfcp_get_adapter_by_busid(char *busid) | 232 | struct zfcp_adapter *zfcp_get_adapter_by_busid(char *busid) |
234 | { | 233 | { |
235 | struct ccw_device *ccw_device; | 234 | struct ccw_device *ccw_device; |
236 | struct zfcp_adapter *adapter = NULL; | 235 | struct zfcp_adapter *adapter = NULL; |
237 | 236 | ||
238 | ccw_device = get_ccwdev_by_busid(&zfcp_ccw_driver, busid); | 237 | ccw_device = get_ccwdev_by_busid(&zfcp_ccw_driver, busid); |
239 | if (ccw_device) { | 238 | if (ccw_device) { |
240 | adapter = dev_get_drvdata(&ccw_device->dev); | 239 | adapter = dev_get_drvdata(&ccw_device->dev); |
241 | put_device(&ccw_device->dev); | 240 | put_device(&ccw_device->dev); |
242 | } | 241 | } |
243 | return adapter; | 242 | return adapter; |
244 | } | 243 | } |
245 | 244 |
drivers/s390/scsi/zfcp_def.h
1 | /* | 1 | /* |
2 | * zfcp device driver | 2 | * zfcp device driver |
3 | * | 3 | * |
4 | * Global definitions for the zfcp device driver. | 4 | * Global definitions for the zfcp device driver. |
5 | * | 5 | * |
6 | * Copyright IBM Corporation 2002, 2008 | 6 | * Copyright IBM Corporation 2002, 2008 |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #ifndef ZFCP_DEF_H | 9 | #ifndef ZFCP_DEF_H |
10 | #define ZFCP_DEF_H | 10 | #define ZFCP_DEF_H |
11 | 11 | ||
12 | /*************************** INCLUDES *****************************************/ | 12 | /*************************** INCLUDES *****************************************/ |
13 | 13 | ||
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/moduleparam.h> | 15 | #include <linux/moduleparam.h> |
16 | #include <linux/major.h> | 16 | #include <linux/major.h> |
17 | #include <linux/blkdev.h> | 17 | #include <linux/blkdev.h> |
18 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
19 | #include <linux/timer.h> | 19 | #include <linux/timer.h> |
20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
21 | #include <linux/mempool.h> | 21 | #include <linux/mempool.h> |
22 | #include <linux/syscalls.h> | 22 | #include <linux/syscalls.h> |
23 | #include <linux/scatterlist.h> | 23 | #include <linux/scatterlist.h> |
24 | #include <linux/ioctl.h> | 24 | #include <linux/ioctl.h> |
25 | #include <scsi/scsi.h> | 25 | #include <scsi/scsi.h> |
26 | #include <scsi/scsi_tcq.h> | 26 | #include <scsi/scsi_tcq.h> |
27 | #include <scsi/scsi_cmnd.h> | 27 | #include <scsi/scsi_cmnd.h> |
28 | #include <scsi/scsi_device.h> | 28 | #include <scsi/scsi_device.h> |
29 | #include <scsi/scsi_host.h> | 29 | #include <scsi/scsi_host.h> |
30 | #include <scsi/scsi_transport.h> | 30 | #include <scsi/scsi_transport.h> |
31 | #include <scsi/scsi_transport_fc.h> | 31 | #include <scsi/scsi_transport_fc.h> |
32 | #include <asm/ccwdev.h> | 32 | #include <asm/ccwdev.h> |
33 | #include <asm/qdio.h> | 33 | #include <asm/qdio.h> |
34 | #include <asm/debug.h> | 34 | #include <asm/debug.h> |
35 | #include <asm/ebcdic.h> | 35 | #include <asm/ebcdic.h> |
36 | #include <asm/sysinfo.h> | 36 | #include <asm/sysinfo.h> |
37 | #include "zfcp_dbf.h" | 37 | #include "zfcp_dbf.h" |
38 | #include "zfcp_fsf.h" | 38 | #include "zfcp_fsf.h" |
39 | 39 | ||
40 | 40 | ||
41 | /********************* GENERAL DEFINES *********************************/ | 41 | /********************* GENERAL DEFINES *********************************/ |
42 | 42 | ||
43 | #define REQUEST_LIST_SIZE 128 | 43 | #define REQUEST_LIST_SIZE 128 |
44 | 44 | ||
45 | /********************* SCSI SPECIFIC DEFINES *********************************/ | 45 | /********************* SCSI SPECIFIC DEFINES *********************************/ |
46 | #define ZFCP_SCSI_ER_TIMEOUT (10*HZ) | 46 | #define ZFCP_SCSI_ER_TIMEOUT (10*HZ) |
47 | 47 | ||
48 | /********************* CIO/QDIO SPECIFIC DEFINES *****************************/ | 48 | /********************* CIO/QDIO SPECIFIC DEFINES *****************************/ |
49 | 49 | ||
50 | /* Adapter Identification Parameters */ | 50 | /* Adapter Identification Parameters */ |
51 | #define ZFCP_CONTROL_UNIT_TYPE 0x1731 | 51 | #define ZFCP_CONTROL_UNIT_TYPE 0x1731 |
52 | #define ZFCP_CONTROL_UNIT_MODEL 0x03 | 52 | #define ZFCP_CONTROL_UNIT_MODEL 0x03 |
53 | #define ZFCP_DEVICE_TYPE 0x1732 | 53 | #define ZFCP_DEVICE_TYPE 0x1732 |
54 | #define ZFCP_DEVICE_MODEL 0x03 | 54 | #define ZFCP_DEVICE_MODEL 0x03 |
55 | #define ZFCP_DEVICE_MODEL_PRIV 0x04 | 55 | #define ZFCP_DEVICE_MODEL_PRIV 0x04 |
56 | 56 | ||
57 | /* DMQ bug workaround: don't use last SBALE */ | 57 | /* DMQ bug workaround: don't use last SBALE */ |
58 | #define ZFCP_MAX_SBALES_PER_SBAL (QDIO_MAX_ELEMENTS_PER_BUFFER - 1) | 58 | #define ZFCP_MAX_SBALES_PER_SBAL (QDIO_MAX_ELEMENTS_PER_BUFFER - 1) |
59 | 59 | ||
60 | /* index of last SBALE (with respect to DMQ bug workaround) */ | 60 | /* index of last SBALE (with respect to DMQ bug workaround) */ |
61 | #define ZFCP_LAST_SBALE_PER_SBAL (ZFCP_MAX_SBALES_PER_SBAL - 1) | 61 | #define ZFCP_LAST_SBALE_PER_SBAL (ZFCP_MAX_SBALES_PER_SBAL - 1) |
62 | 62 | ||
63 | /* max. number of (data buffer) SBALEs in largest SBAL chain */ | 63 | /* max. number of (data buffer) SBALEs in largest SBAL chain */ |
64 | #define ZFCP_MAX_SBALES_PER_REQ \ | 64 | #define ZFCP_MAX_SBALES_PER_REQ \ |
65 | (FSF_MAX_SBALS_PER_REQ * ZFCP_MAX_SBALES_PER_SBAL - 2) | 65 | (FSF_MAX_SBALS_PER_REQ * ZFCP_MAX_SBALES_PER_SBAL - 2) |
66 | /* request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */ | 66 | /* request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */ |
67 | 67 | ||
68 | #define ZFCP_MAX_SECTORS (ZFCP_MAX_SBALES_PER_REQ * 8) | 68 | #define ZFCP_MAX_SECTORS (ZFCP_MAX_SBALES_PER_REQ * 8) |
69 | /* max. number of (data buffer) SBALEs in largest SBAL chain | 69 | /* max. number of (data buffer) SBALEs in largest SBAL chain |
70 | multiplied with number of sectors per 4k block */ | 70 | multiplied with number of sectors per 4k block */ |
71 | 71 | ||
72 | /********************* FSF SPECIFIC DEFINES *********************************/ | 72 | /********************* FSF SPECIFIC DEFINES *********************************/ |
73 | 73 | ||
74 | /* ATTENTION: value must not be used by hardware */ | 74 | /* ATTENTION: value must not be used by hardware */ |
75 | #define FSF_QTCB_UNSOLICITED_STATUS 0x6305 | 75 | #define FSF_QTCB_UNSOLICITED_STATUS 0x6305 |
76 | 76 | ||
77 | /* timeout value for "default timer" for fsf requests */ | 77 | /* timeout value for "default timer" for fsf requests */ |
78 | #define ZFCP_FSF_REQUEST_TIMEOUT (60*HZ) | 78 | #define ZFCP_FSF_REQUEST_TIMEOUT (60*HZ) |
79 | 79 | ||
80 | /*************** FIBRE CHANNEL PROTOCOL SPECIFIC DEFINES ********************/ | 80 | /*************** FIBRE CHANNEL PROTOCOL SPECIFIC DEFINES ********************/ |
81 | 81 | ||
82 | /* timeout for name-server lookup (in seconds) */ | 82 | /* timeout for name-server lookup (in seconds) */ |
83 | #define ZFCP_NS_GID_PN_TIMEOUT 10 | 83 | #define ZFCP_NS_GID_PN_TIMEOUT 10 |
84 | 84 | ||
85 | /* task attribute values in FCP-2 FCP_CMND IU */ | 85 | /* task attribute values in FCP-2 FCP_CMND IU */ |
86 | #define SIMPLE_Q 0 | 86 | #define SIMPLE_Q 0 |
87 | #define HEAD_OF_Q 1 | 87 | #define HEAD_OF_Q 1 |
88 | #define ORDERED_Q 2 | 88 | #define ORDERED_Q 2 |
89 | #define ACA_Q 4 | 89 | #define ACA_Q 4 |
90 | #define UNTAGGED 5 | 90 | #define UNTAGGED 5 |
91 | 91 | ||
92 | /* task management flags in FCP-2 FCP_CMND IU */ | 92 | /* task management flags in FCP-2 FCP_CMND IU */ |
93 | #define FCP_CLEAR_ACA 0x40 | 93 | #define FCP_CLEAR_ACA 0x40 |
94 | #define FCP_TARGET_RESET 0x20 | 94 | #define FCP_TARGET_RESET 0x20 |
95 | #define FCP_LOGICAL_UNIT_RESET 0x10 | 95 | #define FCP_LOGICAL_UNIT_RESET 0x10 |
96 | #define FCP_CLEAR_TASK_SET 0x04 | 96 | #define FCP_CLEAR_TASK_SET 0x04 |
97 | #define FCP_ABORT_TASK_SET 0x02 | 97 | #define FCP_ABORT_TASK_SET 0x02 |
98 | 98 | ||
99 | #define FCP_CDB_LENGTH 16 | 99 | #define FCP_CDB_LENGTH 16 |
100 | 100 | ||
101 | #define ZFCP_DID_MASK 0x00FFFFFF | 101 | #define ZFCP_DID_MASK 0x00FFFFFF |
102 | 102 | ||
103 | /* FCP(-2) FCP_CMND IU */ | 103 | /* FCP(-2) FCP_CMND IU */ |
104 | struct fcp_cmnd_iu { | 104 | struct fcp_cmnd_iu { |
105 | u64 fcp_lun; /* FCP logical unit number */ | 105 | u64 fcp_lun; /* FCP logical unit number */ |
106 | u8 crn; /* command reference number */ | 106 | u8 crn; /* command reference number */ |
107 | u8 reserved0:5; /* reserved */ | 107 | u8 reserved0:5; /* reserved */ |
108 | u8 task_attribute:3; /* task attribute */ | 108 | u8 task_attribute:3; /* task attribute */ |
109 | u8 task_management_flags; /* task management flags */ | 109 | u8 task_management_flags; /* task management flags */ |
110 | u8 add_fcp_cdb_length:6; /* additional FCP_CDB length */ | 110 | u8 add_fcp_cdb_length:6; /* additional FCP_CDB length */ |
111 | u8 rddata:1; /* read data */ | 111 | u8 rddata:1; /* read data */ |
112 | u8 wddata:1; /* write data */ | 112 | u8 wddata:1; /* write data */ |
113 | u8 fcp_cdb[FCP_CDB_LENGTH]; | 113 | u8 fcp_cdb[FCP_CDB_LENGTH]; |
114 | } __attribute__((packed)); | 114 | } __attribute__((packed)); |
115 | 115 | ||
116 | /* FCP(-2) FCP_RSP IU */ | 116 | /* FCP(-2) FCP_RSP IU */ |
117 | struct fcp_rsp_iu { | 117 | struct fcp_rsp_iu { |
118 | u8 reserved0[10]; | 118 | u8 reserved0[10]; |
119 | union { | 119 | union { |
120 | struct { | 120 | struct { |
121 | u8 reserved1:3; | 121 | u8 reserved1:3; |
122 | u8 fcp_conf_req:1; | 122 | u8 fcp_conf_req:1; |
123 | u8 fcp_resid_under:1; | 123 | u8 fcp_resid_under:1; |
124 | u8 fcp_resid_over:1; | 124 | u8 fcp_resid_over:1; |
125 | u8 fcp_sns_len_valid:1; | 125 | u8 fcp_sns_len_valid:1; |
126 | u8 fcp_rsp_len_valid:1; | 126 | u8 fcp_rsp_len_valid:1; |
127 | } bits; | 127 | } bits; |
128 | u8 value; | 128 | u8 value; |
129 | } validity; | 129 | } validity; |
130 | u8 scsi_status; | 130 | u8 scsi_status; |
131 | u32 fcp_resid; | 131 | u32 fcp_resid; |
132 | u32 fcp_sns_len; | 132 | u32 fcp_sns_len; |
133 | u32 fcp_rsp_len; | 133 | u32 fcp_rsp_len; |
134 | } __attribute__((packed)); | 134 | } __attribute__((packed)); |
135 | 135 | ||
136 | 136 | ||
137 | #define RSP_CODE_GOOD 0 | 137 | #define RSP_CODE_GOOD 0 |
138 | #define RSP_CODE_LENGTH_MISMATCH 1 | 138 | #define RSP_CODE_LENGTH_MISMATCH 1 |
139 | #define RSP_CODE_FIELD_INVALID 2 | 139 | #define RSP_CODE_FIELD_INVALID 2 |
140 | #define RSP_CODE_RO_MISMATCH 3 | 140 | #define RSP_CODE_RO_MISMATCH 3 |
141 | #define RSP_CODE_TASKMAN_UNSUPP 4 | 141 | #define RSP_CODE_TASKMAN_UNSUPP 4 |
142 | #define RSP_CODE_TASKMAN_FAILED 5 | 142 | #define RSP_CODE_TASKMAN_FAILED 5 |
143 | 143 | ||
144 | /* see fc-fs */ | 144 | /* see fc-fs */ |
145 | #define LS_RSCN 0x61 | 145 | #define LS_RSCN 0x61 |
146 | #define LS_LOGO 0x05 | 146 | #define LS_LOGO 0x05 |
147 | #define LS_PLOGI 0x03 | 147 | #define LS_PLOGI 0x03 |
148 | 148 | ||
149 | struct fcp_rscn_head { | 149 | struct fcp_rscn_head { |
150 | u8 command; | 150 | u8 command; |
151 | u8 page_length; /* always 0x04 */ | 151 | u8 page_length; /* always 0x04 */ |
152 | u16 payload_len; | 152 | u16 payload_len; |
153 | } __attribute__((packed)); | 153 | } __attribute__((packed)); |
154 | 154 | ||
155 | struct fcp_rscn_element { | 155 | struct fcp_rscn_element { |
156 | u8 reserved:2; | 156 | u8 reserved:2; |
157 | u8 event_qual:4; | 157 | u8 event_qual:4; |
158 | u8 addr_format:2; | 158 | u8 addr_format:2; |
159 | u32 nport_did:24; | 159 | u32 nport_did:24; |
160 | } __attribute__((packed)); | 160 | } __attribute__((packed)); |
161 | 161 | ||
162 | /* see fc-ph */ | 162 | /* see fc-ph */ |
163 | struct fcp_logo { | 163 | struct fcp_logo { |
164 | u32 command; | 164 | u32 command; |
165 | u32 nport_did; | 165 | u32 nport_did; |
166 | u64 nport_wwpn; | 166 | u64 nport_wwpn; |
167 | } __attribute__((packed)); | 167 | } __attribute__((packed)); |
168 | 168 | ||
169 | /* | 169 | /* |
170 | * FC-FS stuff | 170 | * FC-FS stuff |
171 | */ | 171 | */ |
172 | #define R_A_TOV 10 /* seconds */ | 172 | #define R_A_TOV 10 /* seconds */ |
173 | 173 | ||
174 | #define ZFCP_LS_RLS 0x0f | 174 | #define ZFCP_LS_RLS 0x0f |
175 | #define ZFCP_LS_ADISC 0x52 | 175 | #define ZFCP_LS_ADISC 0x52 |
176 | #define ZFCP_LS_RPS 0x56 | 176 | #define ZFCP_LS_RPS 0x56 |
177 | #define ZFCP_LS_RSCN 0x61 | 177 | #define ZFCP_LS_RSCN 0x61 |
178 | #define ZFCP_LS_RNID 0x78 | 178 | #define ZFCP_LS_RNID 0x78 |
179 | 179 | ||
180 | struct zfcp_ls_adisc { | 180 | struct zfcp_ls_adisc { |
181 | u8 code; | 181 | u8 code; |
182 | u8 field[3]; | 182 | u8 field[3]; |
183 | u32 hard_nport_id; | 183 | u32 hard_nport_id; |
184 | u64 wwpn; | 184 | u64 wwpn; |
185 | u64 wwnn; | 185 | u64 wwnn; |
186 | u32 nport_id; | 186 | u32 nport_id; |
187 | } __attribute__ ((packed)); | 187 | } __attribute__ ((packed)); |
188 | 188 | ||
189 | /* | 189 | /* |
190 | * FC-GS-2 stuff | 190 | * FC-GS-2 stuff |
191 | */ | 191 | */ |
192 | #define ZFCP_CT_REVISION 0x01 | 192 | #define ZFCP_CT_REVISION 0x01 |
193 | #define ZFCP_CT_DIRECTORY_SERVICE 0xFC | 193 | #define ZFCP_CT_DIRECTORY_SERVICE 0xFC |
194 | #define ZFCP_CT_NAME_SERVER 0x02 | 194 | #define ZFCP_CT_NAME_SERVER 0x02 |
195 | #define ZFCP_CT_SYNCHRONOUS 0x00 | 195 | #define ZFCP_CT_SYNCHRONOUS 0x00 |
196 | #define ZFCP_CT_SCSI_FCP 0x08 | 196 | #define ZFCP_CT_SCSI_FCP 0x08 |
197 | #define ZFCP_CT_UNABLE_TO_PERFORM_CMD 0x09 | 197 | #define ZFCP_CT_UNABLE_TO_PERFORM_CMD 0x09 |
198 | #define ZFCP_CT_GID_PN 0x0121 | 198 | #define ZFCP_CT_GID_PN 0x0121 |
199 | #define ZFCP_CT_GPN_FT 0x0172 | 199 | #define ZFCP_CT_GPN_FT 0x0172 |
200 | #define ZFCP_CT_ACCEPT 0x8002 | 200 | #define ZFCP_CT_ACCEPT 0x8002 |
201 | #define ZFCP_CT_REJECT 0x8001 | 201 | #define ZFCP_CT_REJECT 0x8001 |
202 | 202 | ||
203 | /* | 203 | /* |
204 | * FC-GS-4 stuff | 204 | * FC-GS-4 stuff |
205 | */ | 205 | */ |
206 | #define ZFCP_CT_TIMEOUT (3 * R_A_TOV) | 206 | #define ZFCP_CT_TIMEOUT (3 * R_A_TOV) |
207 | 207 | ||
208 | /*************** ADAPTER/PORT/UNIT AND FSF_REQ STATUS FLAGS ******************/ | 208 | /*************** ADAPTER/PORT/UNIT AND FSF_REQ STATUS FLAGS ******************/ |
209 | 209 | ||
210 | /* | 210 | /* |
211 | * Note, the leftmost status byte is common among adapter, port | 211 | * Note, the leftmost status byte is common among adapter, port |
212 | * and unit | 212 | * and unit |
213 | */ | 213 | */ |
214 | #define ZFCP_COMMON_FLAGS 0xfff00000 | 214 | #define ZFCP_COMMON_FLAGS 0xfff00000 |
215 | 215 | ||
216 | /* common status bits */ | 216 | /* common status bits */ |
217 | #define ZFCP_STATUS_COMMON_REMOVE 0x80000000 | 217 | #define ZFCP_STATUS_COMMON_REMOVE 0x80000000 |
218 | #define ZFCP_STATUS_COMMON_RUNNING 0x40000000 | 218 | #define ZFCP_STATUS_COMMON_RUNNING 0x40000000 |
219 | #define ZFCP_STATUS_COMMON_ERP_FAILED 0x20000000 | 219 | #define ZFCP_STATUS_COMMON_ERP_FAILED 0x20000000 |
220 | #define ZFCP_STATUS_COMMON_UNBLOCKED 0x10000000 | 220 | #define ZFCP_STATUS_COMMON_UNBLOCKED 0x10000000 |
221 | #define ZFCP_STATUS_COMMON_OPEN 0x04000000 | 221 | #define ZFCP_STATUS_COMMON_OPEN 0x04000000 |
222 | #define ZFCP_STATUS_COMMON_ERP_INUSE 0x01000000 | 222 | #define ZFCP_STATUS_COMMON_ERP_INUSE 0x01000000 |
223 | #define ZFCP_STATUS_COMMON_ACCESS_DENIED 0x00800000 | 223 | #define ZFCP_STATUS_COMMON_ACCESS_DENIED 0x00800000 |
224 | #define ZFCP_STATUS_COMMON_ACCESS_BOXED 0x00400000 | 224 | #define ZFCP_STATUS_COMMON_ACCESS_BOXED 0x00400000 |
225 | #define ZFCP_STATUS_COMMON_NOESC 0x00200000 | 225 | #define ZFCP_STATUS_COMMON_NOESC 0x00200000 |
226 | 226 | ||
227 | /* adapter status */ | 227 | /* adapter status */ |
228 | #define ZFCP_STATUS_ADAPTER_QDIOUP 0x00000002 | 228 | #define ZFCP_STATUS_ADAPTER_QDIOUP 0x00000002 |
229 | #define ZFCP_STATUS_ADAPTER_XCONFIG_OK 0x00000008 | 229 | #define ZFCP_STATUS_ADAPTER_XCONFIG_OK 0x00000008 |
230 | #define ZFCP_STATUS_ADAPTER_HOST_CON_INIT 0x00000010 | 230 | #define ZFCP_STATUS_ADAPTER_HOST_CON_INIT 0x00000010 |
231 | #define ZFCP_STATUS_ADAPTER_ERP_THREAD_UP 0x00000020 | 231 | #define ZFCP_STATUS_ADAPTER_ERP_THREAD_UP 0x00000020 |
232 | #define ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL 0x00000080 | 232 | #define ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL 0x00000080 |
233 | #define ZFCP_STATUS_ADAPTER_ERP_PENDING 0x00000100 | 233 | #define ZFCP_STATUS_ADAPTER_ERP_PENDING 0x00000100 |
234 | #define ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED 0x00000200 | 234 | #define ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED 0x00000200 |
235 | 235 | ||
236 | /* FC-PH/FC-GS well-known address identifiers for generic services */ | 236 | /* FC-PH/FC-GS well-known address identifiers for generic services */ |
237 | #define ZFCP_DID_WKA 0xFFFFF0 | 237 | #define ZFCP_DID_WKA 0xFFFFF0 |
238 | #define ZFCP_DID_MANAGEMENT_SERVICE 0xFFFFFA | 238 | #define ZFCP_DID_MANAGEMENT_SERVICE 0xFFFFFA |
239 | #define ZFCP_DID_TIME_SERVICE 0xFFFFFB | 239 | #define ZFCP_DID_TIME_SERVICE 0xFFFFFB |
240 | #define ZFCP_DID_DIRECTORY_SERVICE 0xFFFFFC | 240 | #define ZFCP_DID_DIRECTORY_SERVICE 0xFFFFFC |
241 | #define ZFCP_DID_ALIAS_SERVICE 0xFFFFF8 | 241 | #define ZFCP_DID_ALIAS_SERVICE 0xFFFFF8 |
242 | #define ZFCP_DID_KEY_DISTRIBUTION_SERVICE 0xFFFFF7 | 242 | #define ZFCP_DID_KEY_DISTRIBUTION_SERVICE 0xFFFFF7 |
243 | 243 | ||
244 | /* remote port status */ | 244 | /* remote port status */ |
245 | #define ZFCP_STATUS_PORT_PHYS_OPEN 0x00000001 | 245 | #define ZFCP_STATUS_PORT_PHYS_OPEN 0x00000001 |
246 | 246 | ||
247 | /* well known address (WKA) port status*/ | 247 | /* well known address (WKA) port status*/ |
248 | enum zfcp_wka_status { | 248 | enum zfcp_wka_status { |
249 | ZFCP_WKA_PORT_OFFLINE, | 249 | ZFCP_WKA_PORT_OFFLINE, |
250 | ZFCP_WKA_PORT_CLOSING, | 250 | ZFCP_WKA_PORT_CLOSING, |
251 | ZFCP_WKA_PORT_OPENING, | 251 | ZFCP_WKA_PORT_OPENING, |
252 | ZFCP_WKA_PORT_ONLINE, | 252 | ZFCP_WKA_PORT_ONLINE, |
253 | }; | 253 | }; |
254 | 254 | ||
255 | /* logical unit status */ | 255 | /* logical unit status */ |
256 | #define ZFCP_STATUS_UNIT_SHARED 0x00000004 | 256 | #define ZFCP_STATUS_UNIT_SHARED 0x00000004 |
257 | #define ZFCP_STATUS_UNIT_READONLY 0x00000008 | 257 | #define ZFCP_STATUS_UNIT_READONLY 0x00000008 |
258 | #define ZFCP_STATUS_UNIT_REGISTERED 0x00000010 | ||
259 | #define ZFCP_STATUS_UNIT_SCSI_WORK_PENDING 0x00000020 | 258 | #define ZFCP_STATUS_UNIT_SCSI_WORK_PENDING 0x00000020 |
260 | 259 | ||
261 | /* FSF request status (this does not have a common part) */ | 260 | /* FSF request status (this does not have a common part) */ |
262 | #define ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT 0x00000002 | 261 | #define ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT 0x00000002 |
263 | #define ZFCP_STATUS_FSFREQ_COMPLETED 0x00000004 | 262 | #define ZFCP_STATUS_FSFREQ_COMPLETED 0x00000004 |
264 | #define ZFCP_STATUS_FSFREQ_ERROR 0x00000008 | 263 | #define ZFCP_STATUS_FSFREQ_ERROR 0x00000008 |
265 | #define ZFCP_STATUS_FSFREQ_CLEANUP 0x00000010 | 264 | #define ZFCP_STATUS_FSFREQ_CLEANUP 0x00000010 |
266 | #define ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED 0x00000040 | 265 | #define ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED 0x00000040 |
267 | #define ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED 0x00000080 | 266 | #define ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED 0x00000080 |
268 | #define ZFCP_STATUS_FSFREQ_ABORTED 0x00000100 | 267 | #define ZFCP_STATUS_FSFREQ_ABORTED 0x00000100 |
269 | #define ZFCP_STATUS_FSFREQ_TMFUNCFAILED 0x00000200 | 268 | #define ZFCP_STATUS_FSFREQ_TMFUNCFAILED 0x00000200 |
270 | #define ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP 0x00000400 | 269 | #define ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP 0x00000400 |
271 | #define ZFCP_STATUS_FSFREQ_RETRY 0x00000800 | 270 | #define ZFCP_STATUS_FSFREQ_RETRY 0x00000800 |
272 | #define ZFCP_STATUS_FSFREQ_DISMISSED 0x00001000 | 271 | #define ZFCP_STATUS_FSFREQ_DISMISSED 0x00001000 |
273 | 272 | ||
274 | /************************* STRUCTURE DEFINITIONS *****************************/ | 273 | /************************* STRUCTURE DEFINITIONS *****************************/ |
275 | 274 | ||
276 | struct zfcp_fsf_req; | 275 | struct zfcp_fsf_req; |
277 | 276 | ||
278 | /* holds various memory pools of an adapter */ | 277 | /* holds various memory pools of an adapter */ |
279 | struct zfcp_adapter_mempool { | 278 | struct zfcp_adapter_mempool { |
280 | mempool_t *fsf_req_erp; | 279 | mempool_t *fsf_req_erp; |
281 | mempool_t *fsf_req_scsi; | 280 | mempool_t *fsf_req_scsi; |
282 | mempool_t *fsf_req_abort; | 281 | mempool_t *fsf_req_abort; |
283 | mempool_t *fsf_req_status_read; | 282 | mempool_t *fsf_req_status_read; |
284 | mempool_t *data_status_read; | 283 | mempool_t *data_status_read; |
285 | mempool_t *data_gid_pn; | 284 | mempool_t *data_gid_pn; |
286 | }; | 285 | }; |
287 | 286 | ||
288 | /* | 287 | /* |
289 | * header for CT_IU | 288 | * header for CT_IU |
290 | */ | 289 | */ |
291 | struct ct_hdr { | 290 | struct ct_hdr { |
292 | u8 revision; // 0x01 | 291 | u8 revision; // 0x01 |
293 | u8 in_id[3]; // 0x00 | 292 | u8 in_id[3]; // 0x00 |
294 | u8 gs_type; // 0xFC Directory Service | 293 | u8 gs_type; // 0xFC Directory Service |
295 | u8 gs_subtype; // 0x02 Name Server | 294 | u8 gs_subtype; // 0x02 Name Server |
296 | u8 options; // 0x00 single bidirectional exchange | 295 | u8 options; // 0x00 single bidirectional exchange |
297 | u8 reserved0; | 296 | u8 reserved0; |
298 | u16 cmd_rsp_code; // 0x0121 GID_PN, or 0x0100 GA_NXT | 297 | u16 cmd_rsp_code; // 0x0121 GID_PN, or 0x0100 GA_NXT |
299 | u16 max_res_size; // <= (4096 - 16) / 4 | 298 | u16 max_res_size; // <= (4096 - 16) / 4 |
300 | u8 reserved1; | 299 | u8 reserved1; |
301 | u8 reason_code; | 300 | u8 reason_code; |
302 | u8 reason_code_expl; | 301 | u8 reason_code_expl; |
303 | u8 vendor_unique; | 302 | u8 vendor_unique; |
304 | } __attribute__ ((packed)); | 303 | } __attribute__ ((packed)); |
305 | 304 | ||
306 | /* nameserver request CT_IU -- for requests where | 305 | /* nameserver request CT_IU -- for requests where |
307 | * a port name is required */ | 306 | * a port name is required */ |
308 | struct ct_iu_gid_pn_req { | 307 | struct ct_iu_gid_pn_req { |
309 | struct ct_hdr header; | 308 | struct ct_hdr header; |
310 | u64 wwpn; | 309 | u64 wwpn; |
311 | } __attribute__ ((packed)); | 310 | } __attribute__ ((packed)); |
312 | 311 | ||
313 | /* FS_ACC IU and data unit for GID_PN nameserver request */ | 312 | /* FS_ACC IU and data unit for GID_PN nameserver request */ |
314 | struct ct_iu_gid_pn_resp { | 313 | struct ct_iu_gid_pn_resp { |
315 | struct ct_hdr header; | 314 | struct ct_hdr header; |
316 | u32 d_id; | 315 | u32 d_id; |
317 | } __attribute__ ((packed)); | 316 | } __attribute__ ((packed)); |
318 | 317 | ||
319 | /** | 318 | /** |
320 | * struct zfcp_send_ct - used to pass parameters to function zfcp_fsf_send_ct | 319 | * struct zfcp_send_ct - used to pass parameters to function zfcp_fsf_send_ct |
321 | * @wka_port: port where the request is sent to | 320 | * @wka_port: port where the request is sent to |
322 | * @req: scatter-gather list for request | 321 | * @req: scatter-gather list for request |
323 | * @resp: scatter-gather list for response | 322 | * @resp: scatter-gather list for response |
324 | * @handler: handler function (called for response to the request) | 323 | * @handler: handler function (called for response to the request) |
325 | * @handler_data: data passed to handler function | 324 | * @handler_data: data passed to handler function |
326 | * @timeout: FSF timeout for this request | 325 | * @timeout: FSF timeout for this request |
327 | * @completion: completion for synchronization purposes | 326 | * @completion: completion for synchronization purposes |
328 | * @status: used to pass error status to calling function | 327 | * @status: used to pass error status to calling function |
329 | */ | 328 | */ |
330 | struct zfcp_send_ct { | 329 | struct zfcp_send_ct { |
331 | struct zfcp_wka_port *wka_port; | 330 | struct zfcp_wka_port *wka_port; |
332 | struct scatterlist *req; | 331 | struct scatterlist *req; |
333 | struct scatterlist *resp; | 332 | struct scatterlist *resp; |
334 | void (*handler)(unsigned long); | 333 | void (*handler)(unsigned long); |
335 | unsigned long handler_data; | 334 | unsigned long handler_data; |
336 | int timeout; | 335 | int timeout; |
337 | struct completion *completion; | 336 | struct completion *completion; |
338 | int status; | 337 | int status; |
339 | }; | 338 | }; |
340 | 339 | ||
341 | /* used for name server requests in error recovery */ | 340 | /* used for name server requests in error recovery */ |
342 | struct zfcp_gid_pn_data { | 341 | struct zfcp_gid_pn_data { |
343 | struct zfcp_send_ct ct; | 342 | struct zfcp_send_ct ct; |
344 | struct scatterlist req; | 343 | struct scatterlist req; |
345 | struct scatterlist resp; | 344 | struct scatterlist resp; |
346 | struct ct_iu_gid_pn_req ct_iu_req; | 345 | struct ct_iu_gid_pn_req ct_iu_req; |
347 | struct ct_iu_gid_pn_resp ct_iu_resp; | 346 | struct ct_iu_gid_pn_resp ct_iu_resp; |
348 | struct zfcp_port *port; | 347 | struct zfcp_port *port; |
349 | }; | 348 | }; |
350 | 349 | ||
351 | /** | 350 | /** |
352 | * struct zfcp_send_els - used to pass parameters to function zfcp_fsf_send_els | 351 | * struct zfcp_send_els - used to pass parameters to function zfcp_fsf_send_els |
353 | * @adapter: adapter where request is sent from | 352 | * @adapter: adapter where request is sent from |
354 | * @port: port where ELS is destinated (port reference count has to be increased) | 353 | * @port: port where ELS is destinated (port reference count has to be increased) |
355 | * @d_id: destiniation id of port where request is sent to | 354 | * @d_id: destiniation id of port where request is sent to |
356 | * @req: scatter-gather list for request | 355 | * @req: scatter-gather list for request |
357 | * @resp: scatter-gather list for response | 356 | * @resp: scatter-gather list for response |
358 | * @handler: handler function (called for response to the request) | 357 | * @handler: handler function (called for response to the request) |
359 | * @handler_data: data passed to handler function | 358 | * @handler_data: data passed to handler function |
360 | * @completion: completion for synchronization purposes | 359 | * @completion: completion for synchronization purposes |
361 | * @ls_code: hex code of ELS command | 360 | * @ls_code: hex code of ELS command |
362 | * @status: used to pass error status to calling function | 361 | * @status: used to pass error status to calling function |
363 | */ | 362 | */ |
364 | struct zfcp_send_els { | 363 | struct zfcp_send_els { |
365 | struct zfcp_adapter *adapter; | 364 | struct zfcp_adapter *adapter; |
366 | struct zfcp_port *port; | 365 | struct zfcp_port *port; |
367 | u32 d_id; | 366 | u32 d_id; |
368 | struct scatterlist *req; | 367 | struct scatterlist *req; |
369 | struct scatterlist *resp; | 368 | struct scatterlist *resp; |
370 | void (*handler)(unsigned long); | 369 | void (*handler)(unsigned long); |
371 | unsigned long handler_data; | 370 | unsigned long handler_data; |
372 | struct completion *completion; | 371 | struct completion *completion; |
373 | int ls_code; | 372 | int ls_code; |
374 | int status; | 373 | int status; |
375 | }; | 374 | }; |
376 | 375 | ||
377 | struct zfcp_wka_port { | 376 | struct zfcp_wka_port { |
378 | struct zfcp_adapter *adapter; | 377 | struct zfcp_adapter *adapter; |
379 | wait_queue_head_t completion_wq; | 378 | wait_queue_head_t completion_wq; |
380 | enum zfcp_wka_status status; | 379 | enum zfcp_wka_status status; |
381 | atomic_t refcount; | 380 | atomic_t refcount; |
382 | u32 d_id; | 381 | u32 d_id; |
383 | u32 handle; | 382 | u32 handle; |
384 | struct mutex mutex; | 383 | struct mutex mutex; |
385 | struct delayed_work work; | 384 | struct delayed_work work; |
386 | }; | 385 | }; |
387 | 386 | ||
388 | struct zfcp_qdio_queue { | 387 | struct zfcp_qdio_queue { |
389 | struct qdio_buffer *sbal[QDIO_MAX_BUFFERS_PER_Q]; | 388 | struct qdio_buffer *sbal[QDIO_MAX_BUFFERS_PER_Q]; |
390 | u8 first; /* index of next free bfr in queue */ | 389 | u8 first; /* index of next free bfr in queue */ |
391 | atomic_t count; /* number of free buffers in queue */ | 390 | atomic_t count; /* number of free buffers in queue */ |
392 | }; | 391 | }; |
393 | 392 | ||
394 | struct zfcp_erp_action { | 393 | struct zfcp_erp_action { |
395 | struct list_head list; | 394 | struct list_head list; |
396 | int action; /* requested action code */ | 395 | int action; /* requested action code */ |
397 | struct zfcp_adapter *adapter; /* device which should be recovered */ | 396 | struct zfcp_adapter *adapter; /* device which should be recovered */ |
398 | struct zfcp_port *port; | 397 | struct zfcp_port *port; |
399 | struct zfcp_unit *unit; | 398 | struct zfcp_unit *unit; |
400 | u32 status; /* recovery status */ | 399 | u32 status; /* recovery status */ |
401 | u32 step; /* active step of this erp action */ | 400 | u32 step; /* active step of this erp action */ |
402 | struct zfcp_fsf_req *fsf_req; /* fsf request currently pending | 401 | struct zfcp_fsf_req *fsf_req; /* fsf request currently pending |
403 | for this action */ | 402 | for this action */ |
404 | struct timer_list timer; | 403 | struct timer_list timer; |
405 | }; | 404 | }; |
406 | 405 | ||
407 | struct fsf_latency_record { | 406 | struct fsf_latency_record { |
408 | u32 min; | 407 | u32 min; |
409 | u32 max; | 408 | u32 max; |
410 | u64 sum; | 409 | u64 sum; |
411 | }; | 410 | }; |
412 | 411 | ||
413 | struct latency_cont { | 412 | struct latency_cont { |
414 | struct fsf_latency_record channel; | 413 | struct fsf_latency_record channel; |
415 | struct fsf_latency_record fabric; | 414 | struct fsf_latency_record fabric; |
416 | u64 counter; | 415 | u64 counter; |
417 | }; | 416 | }; |
418 | 417 | ||
419 | struct zfcp_latencies { | 418 | struct zfcp_latencies { |
420 | struct latency_cont read; | 419 | struct latency_cont read; |
421 | struct latency_cont write; | 420 | struct latency_cont write; |
422 | struct latency_cont cmd; | 421 | struct latency_cont cmd; |
423 | spinlock_t lock; | 422 | spinlock_t lock; |
424 | }; | 423 | }; |
425 | 424 | ||
426 | struct zfcp_adapter { | 425 | struct zfcp_adapter { |
427 | atomic_t refcount; /* reference count */ | 426 | atomic_t refcount; /* reference count */ |
428 | wait_queue_head_t remove_wq; /* can be used to wait for | 427 | wait_queue_head_t remove_wq; /* can be used to wait for |
429 | refcount drop to zero */ | 428 | refcount drop to zero */ |
430 | u64 peer_wwnn; /* P2P peer WWNN */ | 429 | u64 peer_wwnn; /* P2P peer WWNN */ |
431 | u64 peer_wwpn; /* P2P peer WWPN */ | 430 | u64 peer_wwpn; /* P2P peer WWPN */ |
432 | u32 peer_d_id; /* P2P peer D_ID */ | 431 | u32 peer_d_id; /* P2P peer D_ID */ |
433 | struct ccw_device *ccw_device; /* S/390 ccw device */ | 432 | struct ccw_device *ccw_device; /* S/390 ccw device */ |
434 | u32 hydra_version; /* Hydra version */ | 433 | u32 hydra_version; /* Hydra version */ |
435 | u32 fsf_lic_version; | 434 | u32 fsf_lic_version; |
436 | u32 adapter_features; /* FCP channel features */ | 435 | u32 adapter_features; /* FCP channel features */ |
437 | u32 connection_features; /* host connection features */ | 436 | u32 connection_features; /* host connection features */ |
438 | u32 hardware_version; /* of FCP channel */ | 437 | u32 hardware_version; /* of FCP channel */ |
439 | u16 timer_ticks; /* time int for a tick */ | 438 | u16 timer_ticks; /* time int for a tick */ |
440 | struct Scsi_Host *scsi_host; /* Pointer to mid-layer */ | 439 | struct Scsi_Host *scsi_host; /* Pointer to mid-layer */ |
441 | struct list_head port_list_head; /* remote port list */ | 440 | struct list_head port_list_head; /* remote port list */ |
442 | unsigned long req_no; /* unique FSF req number */ | 441 | unsigned long req_no; /* unique FSF req number */ |
443 | struct list_head *req_list; /* list of pending reqs */ | 442 | struct list_head *req_list; /* list of pending reqs */ |
444 | spinlock_t req_list_lock; /* request list lock */ | 443 | spinlock_t req_list_lock; /* request list lock */ |
445 | struct zfcp_qdio_queue req_q; /* request queue */ | 444 | struct zfcp_qdio_queue req_q; /* request queue */ |
446 | spinlock_t req_q_lock; /* for operations on queue */ | 445 | spinlock_t req_q_lock; /* for operations on queue */ |
447 | int req_q_pci_batch; /* SBALs since PCI indication | 446 | int req_q_pci_batch; /* SBALs since PCI indication |
448 | was last set */ | 447 | was last set */ |
449 | u32 fsf_req_seq_no; /* FSF cmnd seq number */ | 448 | u32 fsf_req_seq_no; /* FSF cmnd seq number */ |
450 | wait_queue_head_t request_wq; /* can be used to wait for | 449 | wait_queue_head_t request_wq; /* can be used to wait for |
451 | more avaliable SBALs */ | 450 | more avaliable SBALs */ |
452 | struct zfcp_qdio_queue resp_q; /* response queue */ | 451 | struct zfcp_qdio_queue resp_q; /* response queue */ |
453 | rwlock_t abort_lock; /* Protects against SCSI | 452 | rwlock_t abort_lock; /* Protects against SCSI |
454 | stack abort/command | 453 | stack abort/command |
455 | completion races */ | 454 | completion races */ |
456 | atomic_t stat_miss; /* # missing status reads*/ | 455 | atomic_t stat_miss; /* # missing status reads*/ |
457 | struct work_struct stat_work; | 456 | struct work_struct stat_work; |
458 | atomic_t status; /* status of this adapter */ | 457 | atomic_t status; /* status of this adapter */ |
459 | struct list_head erp_ready_head; /* error recovery for this | 458 | struct list_head erp_ready_head; /* error recovery for this |
460 | adapter/devices */ | 459 | adapter/devices */ |
461 | struct list_head erp_running_head; | 460 | struct list_head erp_running_head; |
462 | rwlock_t erp_lock; | 461 | rwlock_t erp_lock; |
463 | struct semaphore erp_ready_sem; | 462 | struct semaphore erp_ready_sem; |
464 | wait_queue_head_t erp_thread_wqh; | 463 | wait_queue_head_t erp_thread_wqh; |
465 | wait_queue_head_t erp_done_wqh; | 464 | wait_queue_head_t erp_done_wqh; |
466 | struct zfcp_erp_action erp_action; /* pending error recovery */ | 465 | struct zfcp_erp_action erp_action; /* pending error recovery */ |
467 | atomic_t erp_counter; | 466 | atomic_t erp_counter; |
468 | u32 erp_total_count; /* total nr of enqueued erp | 467 | u32 erp_total_count; /* total nr of enqueued erp |
469 | actions */ | 468 | actions */ |
470 | u32 erp_low_mem_count; /* nr of erp actions waiting | 469 | u32 erp_low_mem_count; /* nr of erp actions waiting |
471 | for memory */ | 470 | for memory */ |
472 | struct zfcp_wka_port nsp; /* adapter's nameserver */ | 471 | struct zfcp_wka_port nsp; /* adapter's nameserver */ |
473 | debug_info_t *rec_dbf; | 472 | debug_info_t *rec_dbf; |
474 | debug_info_t *hba_dbf; | 473 | debug_info_t *hba_dbf; |
475 | debug_info_t *san_dbf; /* debug feature areas */ | 474 | debug_info_t *san_dbf; /* debug feature areas */ |
476 | debug_info_t *scsi_dbf; | 475 | debug_info_t *scsi_dbf; |
477 | spinlock_t rec_dbf_lock; | 476 | spinlock_t rec_dbf_lock; |
478 | spinlock_t hba_dbf_lock; | 477 | spinlock_t hba_dbf_lock; |
479 | spinlock_t san_dbf_lock; | 478 | spinlock_t san_dbf_lock; |
480 | spinlock_t scsi_dbf_lock; | 479 | spinlock_t scsi_dbf_lock; |
481 | struct zfcp_rec_dbf_record rec_dbf_buf; | 480 | struct zfcp_rec_dbf_record rec_dbf_buf; |
482 | struct zfcp_hba_dbf_record hba_dbf_buf; | 481 | struct zfcp_hba_dbf_record hba_dbf_buf; |
483 | struct zfcp_san_dbf_record san_dbf_buf; | 482 | struct zfcp_san_dbf_record san_dbf_buf; |
484 | struct zfcp_scsi_dbf_record scsi_dbf_buf; | 483 | struct zfcp_scsi_dbf_record scsi_dbf_buf; |
485 | struct zfcp_adapter_mempool pool; /* Adapter memory pools */ | 484 | struct zfcp_adapter_mempool pool; /* Adapter memory pools */ |
486 | struct qdio_initialize qdio_init_data; /* for qdio_establish */ | 485 | struct qdio_initialize qdio_init_data; /* for qdio_establish */ |
487 | struct fc_host_statistics *fc_stats; | 486 | struct fc_host_statistics *fc_stats; |
488 | struct fsf_qtcb_bottom_port *stats_reset_data; | 487 | struct fsf_qtcb_bottom_port *stats_reset_data; |
489 | unsigned long stats_reset; | 488 | unsigned long stats_reset; |
490 | struct work_struct scan_work; | 489 | struct work_struct scan_work; |
491 | struct service_level service_level; | 490 | struct service_level service_level; |
492 | atomic_t qdio_outb_full; /* queue full incidents */ | 491 | atomic_t qdio_outb_full; /* queue full incidents */ |
493 | }; | 492 | }; |
494 | 493 | ||
495 | struct zfcp_port { | 494 | struct zfcp_port { |
496 | struct device sysfs_device; /* sysfs device */ | 495 | struct device sysfs_device; /* sysfs device */ |
497 | struct fc_rport *rport; /* rport of fc transport class */ | 496 | struct fc_rport *rport; /* rport of fc transport class */ |
498 | struct list_head list; /* list of remote ports */ | 497 | struct list_head list; /* list of remote ports */ |
499 | atomic_t refcount; /* reference count */ | 498 | atomic_t refcount; /* reference count */ |
500 | wait_queue_head_t remove_wq; /* can be used to wait for | 499 | wait_queue_head_t remove_wq; /* can be used to wait for |
501 | refcount drop to zero */ | 500 | refcount drop to zero */ |
502 | struct zfcp_adapter *adapter; /* adapter used to access port */ | 501 | struct zfcp_adapter *adapter; /* adapter used to access port */ |
503 | struct list_head unit_list_head; /* head of logical unit list */ | 502 | struct list_head unit_list_head; /* head of logical unit list */ |
504 | atomic_t status; /* status of this remote port */ | 503 | atomic_t status; /* status of this remote port */ |
505 | u64 wwnn; /* WWNN if known */ | 504 | u64 wwnn; /* WWNN if known */ |
506 | u64 wwpn; /* WWPN */ | 505 | u64 wwpn; /* WWPN */ |
507 | u32 d_id; /* D_ID */ | 506 | u32 d_id; /* D_ID */ |
508 | u32 handle; /* handle assigned by FSF */ | 507 | u32 handle; /* handle assigned by FSF */ |
509 | struct zfcp_erp_action erp_action; /* pending error recovery */ | 508 | struct zfcp_erp_action erp_action; /* pending error recovery */ |
510 | atomic_t erp_counter; | 509 | atomic_t erp_counter; |
511 | u32 maxframe_size; | 510 | u32 maxframe_size; |
512 | u32 supported_classes; | 511 | u32 supported_classes; |
513 | struct work_struct gid_pn_work; | 512 | struct work_struct gid_pn_work; |
514 | }; | 513 | }; |
515 | 514 | ||
516 | struct zfcp_unit { | 515 | struct zfcp_unit { |
517 | struct device sysfs_device; /* sysfs device */ | 516 | struct device sysfs_device; /* sysfs device */ |
518 | struct list_head list; /* list of logical units */ | 517 | struct list_head list; /* list of logical units */ |
519 | atomic_t refcount; /* reference count */ | 518 | atomic_t refcount; /* reference count */ |
520 | wait_queue_head_t remove_wq; /* can be used to wait for | 519 | wait_queue_head_t remove_wq; /* can be used to wait for |
521 | refcount drop to zero */ | 520 | refcount drop to zero */ |
522 | struct zfcp_port *port; /* remote port of unit */ | 521 | struct zfcp_port *port; /* remote port of unit */ |
523 | atomic_t status; /* status of this logical unit */ | 522 | atomic_t status; /* status of this logical unit */ |
524 | u64 fcp_lun; /* own FCP_LUN */ | 523 | u64 fcp_lun; /* own FCP_LUN */ |
525 | u32 handle; /* handle assigned by FSF */ | 524 | u32 handle; /* handle assigned by FSF */ |
526 | struct scsi_device *device; /* scsi device struct pointer */ | 525 | struct scsi_device *device; /* scsi device struct pointer */ |
527 | struct zfcp_erp_action erp_action; /* pending error recovery */ | 526 | struct zfcp_erp_action erp_action; /* pending error recovery */ |
528 | atomic_t erp_counter; | 527 | atomic_t erp_counter; |
529 | struct zfcp_latencies latencies; | 528 | struct zfcp_latencies latencies; |
530 | }; | 529 | }; |
531 | 530 | ||
532 | /* FSF request */ | 531 | /* FSF request */ |
533 | struct zfcp_fsf_req { | 532 | struct zfcp_fsf_req { |
534 | struct list_head list; /* list of FSF requests */ | 533 | struct list_head list; /* list of FSF requests */ |
535 | unsigned long req_id; /* unique request ID */ | 534 | unsigned long req_id; /* unique request ID */ |
536 | struct zfcp_adapter *adapter; /* adapter request belongs to */ | 535 | struct zfcp_adapter *adapter; /* adapter request belongs to */ |
537 | u8 sbal_number; /* nr of SBALs free for use */ | 536 | u8 sbal_number; /* nr of SBALs free for use */ |
538 | u8 sbal_first; /* first SBAL for this request */ | 537 | u8 sbal_first; /* first SBAL for this request */ |
539 | u8 sbal_last; /* last SBAL for this request */ | 538 | u8 sbal_last; /* last SBAL for this request */ |
540 | u8 sbal_limit; /* last possible SBAL for | 539 | u8 sbal_limit; /* last possible SBAL for |
541 | this reuest */ | 540 | this reuest */ |
542 | u8 sbale_curr; /* current SBALE during creation | 541 | u8 sbale_curr; /* current SBALE during creation |
543 | of request */ | 542 | of request */ |
544 | u8 sbal_response; /* SBAL used in interrupt */ | 543 | u8 sbal_response; /* SBAL used in interrupt */ |
545 | wait_queue_head_t completion_wq; /* can be used by a routine | 544 | wait_queue_head_t completion_wq; /* can be used by a routine |
546 | to wait for completion */ | 545 | to wait for completion */ |
547 | u32 status; /* status of this request */ | 546 | u32 status; /* status of this request */ |
548 | u32 fsf_command; /* FSF Command copy */ | 547 | u32 fsf_command; /* FSF Command copy */ |
549 | struct fsf_qtcb *qtcb; /* address of associated QTCB */ | 548 | struct fsf_qtcb *qtcb; /* address of associated QTCB */ |
550 | u32 seq_no; /* Sequence number of request */ | 549 | u32 seq_no; /* Sequence number of request */ |
551 | void *data; /* private data of request */ | 550 | void *data; /* private data of request */ |
552 | struct timer_list timer; /* used for erp or scsi er */ | 551 | struct timer_list timer; /* used for erp or scsi er */ |
553 | struct zfcp_erp_action *erp_action; /* used if this request is | 552 | struct zfcp_erp_action *erp_action; /* used if this request is |
554 | issued on behalf of erp */ | 553 | issued on behalf of erp */ |
555 | mempool_t *pool; /* used if request was alloacted | 554 | mempool_t *pool; /* used if request was alloacted |
556 | from emergency pool */ | 555 | from emergency pool */ |
557 | unsigned long long issued; /* request sent time (STCK) */ | 556 | unsigned long long issued; /* request sent time (STCK) */ |
558 | struct zfcp_unit *unit; | 557 | struct zfcp_unit *unit; |
559 | void (*handler)(struct zfcp_fsf_req *); | 558 | void (*handler)(struct zfcp_fsf_req *); |
560 | u16 qdio_outb_usage;/* usage of outbound queue */ | 559 | u16 qdio_outb_usage;/* usage of outbound queue */ |
561 | u16 qdio_inb_usage; /* usage of inbound queue */ | 560 | u16 qdio_inb_usage; /* usage of inbound queue */ |
562 | }; | 561 | }; |
563 | 562 | ||
564 | /* driver data */ | 563 | /* driver data */ |
565 | struct zfcp_data { | 564 | struct zfcp_data { |
566 | struct scsi_host_template scsi_host_template; | 565 | struct scsi_host_template scsi_host_template; |
567 | struct scsi_transport_template *scsi_transport_template; | 566 | struct scsi_transport_template *scsi_transport_template; |
568 | rwlock_t config_lock; /* serialises changes | 567 | rwlock_t config_lock; /* serialises changes |
569 | to adapter/port/unit | 568 | to adapter/port/unit |
570 | lists */ | 569 | lists */ |
571 | struct semaphore config_sema; /* serialises configuration | 570 | struct semaphore config_sema; /* serialises configuration |
572 | changes */ | 571 | changes */ |
573 | struct kmem_cache *fsf_req_qtcb_cache; | 572 | struct kmem_cache *fsf_req_qtcb_cache; |
574 | struct kmem_cache *sr_buffer_cache; | 573 | struct kmem_cache *sr_buffer_cache; |
575 | struct kmem_cache *gid_pn_cache; | 574 | struct kmem_cache *gid_pn_cache; |
576 | struct workqueue_struct *work_queue; | 575 | struct workqueue_struct *work_queue; |
577 | }; | 576 | }; |
578 | 577 | ||
579 | /* struct used by memory pools for fsf_requests */ | 578 | /* struct used by memory pools for fsf_requests */ |
580 | struct zfcp_fsf_req_qtcb { | 579 | struct zfcp_fsf_req_qtcb { |
581 | struct zfcp_fsf_req fsf_req; | 580 | struct zfcp_fsf_req fsf_req; |
582 | struct fsf_qtcb qtcb; | 581 | struct fsf_qtcb qtcb; |
583 | }; | 582 | }; |
584 | 583 | ||
585 | /********************** ZFCP SPECIFIC DEFINES ********************************/ | 584 | /********************** ZFCP SPECIFIC DEFINES ********************************/ |
586 | 585 | ||
587 | #define ZFCP_REQ_AUTO_CLEANUP 0x00000002 | 586 | #define ZFCP_REQ_AUTO_CLEANUP 0x00000002 |
588 | #define ZFCP_REQ_NO_QTCB 0x00000008 | 587 | #define ZFCP_REQ_NO_QTCB 0x00000008 |
589 | 588 | ||
590 | #define ZFCP_SET 0x00000100 | 589 | #define ZFCP_SET 0x00000100 |
591 | #define ZFCP_CLEAR 0x00000200 | 590 | #define ZFCP_CLEAR 0x00000200 |
592 | 591 | ||
593 | /* | 592 | /* |
594 | * Helper functions for request ID management. | 593 | * Helper functions for request ID management. |
595 | */ | 594 | */ |
596 | static inline int zfcp_reqlist_hash(unsigned long req_id) | 595 | static inline int zfcp_reqlist_hash(unsigned long req_id) |
597 | { | 596 | { |
598 | return req_id % REQUEST_LIST_SIZE; | 597 | return req_id % REQUEST_LIST_SIZE; |
599 | } | 598 | } |
600 | 599 | ||
601 | static inline void zfcp_reqlist_remove(struct zfcp_adapter *adapter, | 600 | static inline void zfcp_reqlist_remove(struct zfcp_adapter *adapter, |
602 | struct zfcp_fsf_req *fsf_req) | 601 | struct zfcp_fsf_req *fsf_req) |
603 | { | 602 | { |
604 | list_del(&fsf_req->list); | 603 | list_del(&fsf_req->list); |
605 | } | 604 | } |
606 | 605 | ||
607 | static inline struct zfcp_fsf_req * | 606 | static inline struct zfcp_fsf_req * |
608 | zfcp_reqlist_find(struct zfcp_adapter *adapter, unsigned long req_id) | 607 | zfcp_reqlist_find(struct zfcp_adapter *adapter, unsigned long req_id) |
609 | { | 608 | { |
610 | struct zfcp_fsf_req *request; | 609 | struct zfcp_fsf_req *request; |
611 | unsigned int idx; | 610 | unsigned int idx; |
612 | 611 | ||
613 | idx = zfcp_reqlist_hash(req_id); | 612 | idx = zfcp_reqlist_hash(req_id); |
614 | list_for_each_entry(request, &adapter->req_list[idx], list) | 613 | list_for_each_entry(request, &adapter->req_list[idx], list) |
615 | if (request->req_id == req_id) | 614 | if (request->req_id == req_id) |
616 | return request; | 615 | return request; |
617 | return NULL; | 616 | return NULL; |
618 | } | 617 | } |
619 | 618 | ||
620 | static inline struct zfcp_fsf_req * | 619 | static inline struct zfcp_fsf_req * |
621 | zfcp_reqlist_find_safe(struct zfcp_adapter *adapter, struct zfcp_fsf_req *req) | 620 | zfcp_reqlist_find_safe(struct zfcp_adapter *adapter, struct zfcp_fsf_req *req) |
622 | { | 621 | { |
623 | struct zfcp_fsf_req *request; | 622 | struct zfcp_fsf_req *request; |
624 | unsigned int idx; | 623 | unsigned int idx; |
625 | 624 | ||
626 | for (idx = 0; idx < REQUEST_LIST_SIZE; idx++) { | 625 | for (idx = 0; idx < REQUEST_LIST_SIZE; idx++) { |
627 | list_for_each_entry(request, &adapter->req_list[idx], list) | 626 | list_for_each_entry(request, &adapter->req_list[idx], list) |
628 | if (request == req) | 627 | if (request == req) |
629 | return request; | 628 | return request; |
630 | } | 629 | } |
631 | return NULL; | 630 | return NULL; |
632 | } | 631 | } |
633 | 632 | ||
634 | /* | 633 | /* |
635 | * functions needed for reference/usage counting | 634 | * functions needed for reference/usage counting |
636 | */ | 635 | */ |
637 | 636 | ||
638 | static inline void | 637 | static inline void |
639 | zfcp_unit_get(struct zfcp_unit *unit) | 638 | zfcp_unit_get(struct zfcp_unit *unit) |
640 | { | 639 | { |
641 | atomic_inc(&unit->refcount); | 640 | atomic_inc(&unit->refcount); |
642 | } | 641 | } |
643 | 642 | ||
644 | static inline void | 643 | static inline void |
645 | zfcp_unit_put(struct zfcp_unit *unit) | 644 | zfcp_unit_put(struct zfcp_unit *unit) |
646 | { | 645 | { |
647 | if (atomic_dec_return(&unit->refcount) == 0) | 646 | if (atomic_dec_return(&unit->refcount) == 0) |
648 | wake_up(&unit->remove_wq); | 647 | wake_up(&unit->remove_wq); |
649 | } | 648 | } |
650 | 649 | ||
651 | static inline void | 650 | static inline void |
652 | zfcp_port_get(struct zfcp_port *port) | 651 | zfcp_port_get(struct zfcp_port *port) |
653 | { | 652 | { |
654 | atomic_inc(&port->refcount); | 653 | atomic_inc(&port->refcount); |
655 | } | 654 | } |
656 | 655 | ||
657 | static inline void | 656 | static inline void |
658 | zfcp_port_put(struct zfcp_port *port) | 657 | zfcp_port_put(struct zfcp_port *port) |
659 | { | 658 | { |
660 | if (atomic_dec_return(&port->refcount) == 0) | 659 | if (atomic_dec_return(&port->refcount) == 0) |
661 | wake_up(&port->remove_wq); | 660 | wake_up(&port->remove_wq); |
662 | } | 661 | } |
663 | 662 | ||
664 | static inline void | 663 | static inline void |
665 | zfcp_adapter_get(struct zfcp_adapter *adapter) | 664 | zfcp_adapter_get(struct zfcp_adapter *adapter) |
666 | { | 665 | { |
667 | atomic_inc(&adapter->refcount); | 666 | atomic_inc(&adapter->refcount); |
668 | } | 667 | } |
669 | 668 | ||
670 | static inline void | 669 | static inline void |
671 | zfcp_adapter_put(struct zfcp_adapter *adapter) | 670 | zfcp_adapter_put(struct zfcp_adapter *adapter) |
672 | { | 671 | { |
673 | if (atomic_dec_return(&adapter->refcount) == 0) | 672 | if (atomic_dec_return(&adapter->refcount) == 0) |
674 | wake_up(&adapter->remove_wq); | 673 | wake_up(&adapter->remove_wq); |
675 | } | 674 | } |
676 | 675 | ||
677 | #endif /* ZFCP_DEF_H */ | 676 | #endif /* ZFCP_DEF_H */ |
678 | 677 |
drivers/s390/scsi/zfcp_erp.c
1 | /* | 1 | /* |
2 | * zfcp device driver | 2 | * zfcp device driver |
3 | * | 3 | * |
4 | * Error Recovery Procedures (ERP). | 4 | * Error Recovery Procedures (ERP). |
5 | * | 5 | * |
6 | * Copyright IBM Corporation 2002, 2008 | 6 | * Copyright IBM Corporation 2002, 2008 |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #define KMSG_COMPONENT "zfcp" | 9 | #define KMSG_COMPONENT "zfcp" |
10 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt | 10 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt |
11 | 11 | ||
12 | #include "zfcp_ext.h" | 12 | #include "zfcp_ext.h" |
13 | 13 | ||
14 | #define ZFCP_MAX_ERPS 3 | 14 | #define ZFCP_MAX_ERPS 3 |
15 | 15 | ||
16 | enum zfcp_erp_act_flags { | 16 | enum zfcp_erp_act_flags { |
17 | ZFCP_STATUS_ERP_TIMEDOUT = 0x10000000, | 17 | ZFCP_STATUS_ERP_TIMEDOUT = 0x10000000, |
18 | ZFCP_STATUS_ERP_CLOSE_ONLY = 0x01000000, | 18 | ZFCP_STATUS_ERP_CLOSE_ONLY = 0x01000000, |
19 | ZFCP_STATUS_ERP_DISMISSING = 0x00100000, | 19 | ZFCP_STATUS_ERP_DISMISSING = 0x00100000, |
20 | ZFCP_STATUS_ERP_DISMISSED = 0x00200000, | 20 | ZFCP_STATUS_ERP_DISMISSED = 0x00200000, |
21 | ZFCP_STATUS_ERP_LOWMEM = 0x00400000, | 21 | ZFCP_STATUS_ERP_LOWMEM = 0x00400000, |
22 | }; | 22 | }; |
23 | 23 | ||
24 | enum zfcp_erp_steps { | 24 | enum zfcp_erp_steps { |
25 | ZFCP_ERP_STEP_UNINITIALIZED = 0x0000, | 25 | ZFCP_ERP_STEP_UNINITIALIZED = 0x0000, |
26 | ZFCP_ERP_STEP_FSF_XCONFIG = 0x0001, | 26 | ZFCP_ERP_STEP_FSF_XCONFIG = 0x0001, |
27 | ZFCP_ERP_STEP_PHYS_PORT_CLOSING = 0x0010, | 27 | ZFCP_ERP_STEP_PHYS_PORT_CLOSING = 0x0010, |
28 | ZFCP_ERP_STEP_PORT_CLOSING = 0x0100, | 28 | ZFCP_ERP_STEP_PORT_CLOSING = 0x0100, |
29 | ZFCP_ERP_STEP_NAMESERVER_LOOKUP = 0x0400, | 29 | ZFCP_ERP_STEP_NAMESERVER_LOOKUP = 0x0400, |
30 | ZFCP_ERP_STEP_PORT_OPENING = 0x0800, | 30 | ZFCP_ERP_STEP_PORT_OPENING = 0x0800, |
31 | ZFCP_ERP_STEP_UNIT_CLOSING = 0x1000, | 31 | ZFCP_ERP_STEP_UNIT_CLOSING = 0x1000, |
32 | ZFCP_ERP_STEP_UNIT_OPENING = 0x2000, | 32 | ZFCP_ERP_STEP_UNIT_OPENING = 0x2000, |
33 | }; | 33 | }; |
34 | 34 | ||
35 | enum zfcp_erp_act_type { | 35 | enum zfcp_erp_act_type { |
36 | ZFCP_ERP_ACTION_REOPEN_UNIT = 1, | 36 | ZFCP_ERP_ACTION_REOPEN_UNIT = 1, |
37 | ZFCP_ERP_ACTION_REOPEN_PORT = 2, | 37 | ZFCP_ERP_ACTION_REOPEN_PORT = 2, |
38 | ZFCP_ERP_ACTION_REOPEN_PORT_FORCED = 3, | 38 | ZFCP_ERP_ACTION_REOPEN_PORT_FORCED = 3, |
39 | ZFCP_ERP_ACTION_REOPEN_ADAPTER = 4, | 39 | ZFCP_ERP_ACTION_REOPEN_ADAPTER = 4, |
40 | }; | 40 | }; |
41 | 41 | ||
42 | enum zfcp_erp_act_state { | 42 | enum zfcp_erp_act_state { |
43 | ZFCP_ERP_ACTION_RUNNING = 1, | 43 | ZFCP_ERP_ACTION_RUNNING = 1, |
44 | ZFCP_ERP_ACTION_READY = 2, | 44 | ZFCP_ERP_ACTION_READY = 2, |
45 | }; | 45 | }; |
46 | 46 | ||
47 | enum zfcp_erp_act_result { | 47 | enum zfcp_erp_act_result { |
48 | ZFCP_ERP_SUCCEEDED = 0, | 48 | ZFCP_ERP_SUCCEEDED = 0, |
49 | ZFCP_ERP_FAILED = 1, | 49 | ZFCP_ERP_FAILED = 1, |
50 | ZFCP_ERP_CONTINUES = 2, | 50 | ZFCP_ERP_CONTINUES = 2, |
51 | ZFCP_ERP_EXIT = 3, | 51 | ZFCP_ERP_EXIT = 3, |
52 | ZFCP_ERP_DISMISSED = 4, | 52 | ZFCP_ERP_DISMISSED = 4, |
53 | ZFCP_ERP_NOMEM = 5, | 53 | ZFCP_ERP_NOMEM = 5, |
54 | }; | 54 | }; |
55 | 55 | ||
56 | static void zfcp_erp_adapter_block(struct zfcp_adapter *adapter, int mask) | 56 | static void zfcp_erp_adapter_block(struct zfcp_adapter *adapter, int mask) |
57 | { | 57 | { |
58 | zfcp_erp_modify_adapter_status(adapter, 15, NULL, | 58 | zfcp_erp_modify_adapter_status(adapter, 15, NULL, |
59 | ZFCP_STATUS_COMMON_UNBLOCKED | mask, | 59 | ZFCP_STATUS_COMMON_UNBLOCKED | mask, |
60 | ZFCP_CLEAR); | 60 | ZFCP_CLEAR); |
61 | } | 61 | } |
62 | 62 | ||
63 | static int zfcp_erp_action_exists(struct zfcp_erp_action *act) | 63 | static int zfcp_erp_action_exists(struct zfcp_erp_action *act) |
64 | { | 64 | { |
65 | struct zfcp_erp_action *curr_act; | 65 | struct zfcp_erp_action *curr_act; |
66 | 66 | ||
67 | list_for_each_entry(curr_act, &act->adapter->erp_running_head, list) | 67 | list_for_each_entry(curr_act, &act->adapter->erp_running_head, list) |
68 | if (act == curr_act) | 68 | if (act == curr_act) |
69 | return ZFCP_ERP_ACTION_RUNNING; | 69 | return ZFCP_ERP_ACTION_RUNNING; |
70 | return 0; | 70 | return 0; |
71 | } | 71 | } |
72 | 72 | ||
73 | static void zfcp_erp_action_ready(struct zfcp_erp_action *act) | 73 | static void zfcp_erp_action_ready(struct zfcp_erp_action *act) |
74 | { | 74 | { |
75 | struct zfcp_adapter *adapter = act->adapter; | 75 | struct zfcp_adapter *adapter = act->adapter; |
76 | 76 | ||
77 | list_move(&act->list, &act->adapter->erp_ready_head); | 77 | list_move(&act->list, &act->adapter->erp_ready_head); |
78 | zfcp_rec_dbf_event_action(146, act); | 78 | zfcp_rec_dbf_event_action(146, act); |
79 | up(&adapter->erp_ready_sem); | 79 | up(&adapter->erp_ready_sem); |
80 | zfcp_rec_dbf_event_thread(2, adapter); | 80 | zfcp_rec_dbf_event_thread(2, adapter); |
81 | } | 81 | } |
82 | 82 | ||
83 | static void zfcp_erp_action_dismiss(struct zfcp_erp_action *act) | 83 | static void zfcp_erp_action_dismiss(struct zfcp_erp_action *act) |
84 | { | 84 | { |
85 | act->status |= ZFCP_STATUS_ERP_DISMISSED; | 85 | act->status |= ZFCP_STATUS_ERP_DISMISSED; |
86 | if (zfcp_erp_action_exists(act) == ZFCP_ERP_ACTION_RUNNING) | 86 | if (zfcp_erp_action_exists(act) == ZFCP_ERP_ACTION_RUNNING) |
87 | zfcp_erp_action_ready(act); | 87 | zfcp_erp_action_ready(act); |
88 | } | 88 | } |
89 | 89 | ||
90 | static void zfcp_erp_action_dismiss_unit(struct zfcp_unit *unit) | 90 | static void zfcp_erp_action_dismiss_unit(struct zfcp_unit *unit) |
91 | { | 91 | { |
92 | if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_ERP_INUSE) | 92 | if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_ERP_INUSE) |
93 | zfcp_erp_action_dismiss(&unit->erp_action); | 93 | zfcp_erp_action_dismiss(&unit->erp_action); |
94 | } | 94 | } |
95 | 95 | ||
96 | static void zfcp_erp_action_dismiss_port(struct zfcp_port *port) | 96 | static void zfcp_erp_action_dismiss_port(struct zfcp_port *port) |
97 | { | 97 | { |
98 | struct zfcp_unit *unit; | 98 | struct zfcp_unit *unit; |
99 | 99 | ||
100 | if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_INUSE) | 100 | if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_INUSE) |
101 | zfcp_erp_action_dismiss(&port->erp_action); | 101 | zfcp_erp_action_dismiss(&port->erp_action); |
102 | else | 102 | else |
103 | list_for_each_entry(unit, &port->unit_list_head, list) | 103 | list_for_each_entry(unit, &port->unit_list_head, list) |
104 | zfcp_erp_action_dismiss_unit(unit); | 104 | zfcp_erp_action_dismiss_unit(unit); |
105 | } | 105 | } |
106 | 106 | ||
107 | static void zfcp_erp_action_dismiss_adapter(struct zfcp_adapter *adapter) | 107 | static void zfcp_erp_action_dismiss_adapter(struct zfcp_adapter *adapter) |
108 | { | 108 | { |
109 | struct zfcp_port *port; | 109 | struct zfcp_port *port; |
110 | 110 | ||
111 | if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_ERP_INUSE) | 111 | if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_ERP_INUSE) |
112 | zfcp_erp_action_dismiss(&adapter->erp_action); | 112 | zfcp_erp_action_dismiss(&adapter->erp_action); |
113 | else | 113 | else |
114 | list_for_each_entry(port, &adapter->port_list_head, list) | 114 | list_for_each_entry(port, &adapter->port_list_head, list) |
115 | zfcp_erp_action_dismiss_port(port); | 115 | zfcp_erp_action_dismiss_port(port); |
116 | } | 116 | } |
117 | 117 | ||
118 | static int zfcp_erp_required_act(int want, struct zfcp_adapter *adapter, | 118 | static int zfcp_erp_required_act(int want, struct zfcp_adapter *adapter, |
119 | struct zfcp_port *port, | 119 | struct zfcp_port *port, |
120 | struct zfcp_unit *unit) | 120 | struct zfcp_unit *unit) |
121 | { | 121 | { |
122 | int need = want; | 122 | int need = want; |
123 | int u_status, p_status, a_status; | 123 | int u_status, p_status, a_status; |
124 | 124 | ||
125 | switch (want) { | 125 | switch (want) { |
126 | case ZFCP_ERP_ACTION_REOPEN_UNIT: | 126 | case ZFCP_ERP_ACTION_REOPEN_UNIT: |
127 | u_status = atomic_read(&unit->status); | 127 | u_status = atomic_read(&unit->status); |
128 | if (u_status & ZFCP_STATUS_COMMON_ERP_INUSE) | 128 | if (u_status & ZFCP_STATUS_COMMON_ERP_INUSE) |
129 | return 0; | 129 | return 0; |
130 | p_status = atomic_read(&port->status); | 130 | p_status = atomic_read(&port->status); |
131 | if (!(p_status & ZFCP_STATUS_COMMON_RUNNING) || | 131 | if (!(p_status & ZFCP_STATUS_COMMON_RUNNING) || |
132 | p_status & ZFCP_STATUS_COMMON_ERP_FAILED) | 132 | p_status & ZFCP_STATUS_COMMON_ERP_FAILED) |
133 | return 0; | 133 | return 0; |
134 | if (!(p_status & ZFCP_STATUS_COMMON_UNBLOCKED)) | 134 | if (!(p_status & ZFCP_STATUS_COMMON_UNBLOCKED)) |
135 | need = ZFCP_ERP_ACTION_REOPEN_PORT; | 135 | need = ZFCP_ERP_ACTION_REOPEN_PORT; |
136 | /* fall through */ | 136 | /* fall through */ |
137 | case ZFCP_ERP_ACTION_REOPEN_PORT: | 137 | case ZFCP_ERP_ACTION_REOPEN_PORT: |
138 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: | 138 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: |
139 | p_status = atomic_read(&port->status); | 139 | p_status = atomic_read(&port->status); |
140 | if (p_status & ZFCP_STATUS_COMMON_ERP_INUSE) | 140 | if (p_status & ZFCP_STATUS_COMMON_ERP_INUSE) |
141 | return 0; | 141 | return 0; |
142 | a_status = atomic_read(&adapter->status); | 142 | a_status = atomic_read(&adapter->status); |
143 | if (!(a_status & ZFCP_STATUS_COMMON_RUNNING) || | 143 | if (!(a_status & ZFCP_STATUS_COMMON_RUNNING) || |
144 | a_status & ZFCP_STATUS_COMMON_ERP_FAILED) | 144 | a_status & ZFCP_STATUS_COMMON_ERP_FAILED) |
145 | return 0; | 145 | return 0; |
146 | if (!(a_status & ZFCP_STATUS_COMMON_UNBLOCKED)) | 146 | if (!(a_status & ZFCP_STATUS_COMMON_UNBLOCKED)) |
147 | need = ZFCP_ERP_ACTION_REOPEN_ADAPTER; | 147 | need = ZFCP_ERP_ACTION_REOPEN_ADAPTER; |
148 | /* fall through */ | 148 | /* fall through */ |
149 | case ZFCP_ERP_ACTION_REOPEN_ADAPTER: | 149 | case ZFCP_ERP_ACTION_REOPEN_ADAPTER: |
150 | a_status = atomic_read(&adapter->status); | 150 | a_status = atomic_read(&adapter->status); |
151 | if (a_status & ZFCP_STATUS_COMMON_ERP_INUSE) | 151 | if (a_status & ZFCP_STATUS_COMMON_ERP_INUSE) |
152 | return 0; | 152 | return 0; |
153 | } | 153 | } |
154 | 154 | ||
155 | return need; | 155 | return need; |
156 | } | 156 | } |
157 | 157 | ||
158 | static struct zfcp_erp_action *zfcp_erp_setup_act(int need, | 158 | static struct zfcp_erp_action *zfcp_erp_setup_act(int need, |
159 | struct zfcp_adapter *adapter, | 159 | struct zfcp_adapter *adapter, |
160 | struct zfcp_port *port, | 160 | struct zfcp_port *port, |
161 | struct zfcp_unit *unit) | 161 | struct zfcp_unit *unit) |
162 | { | 162 | { |
163 | struct zfcp_erp_action *erp_action; | 163 | struct zfcp_erp_action *erp_action; |
164 | u32 status = 0; | 164 | u32 status = 0; |
165 | 165 | ||
166 | switch (need) { | 166 | switch (need) { |
167 | case ZFCP_ERP_ACTION_REOPEN_UNIT: | 167 | case ZFCP_ERP_ACTION_REOPEN_UNIT: |
168 | zfcp_unit_get(unit); | 168 | zfcp_unit_get(unit); |
169 | atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status); | 169 | atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status); |
170 | erp_action = &unit->erp_action; | 170 | erp_action = &unit->erp_action; |
171 | if (!(atomic_read(&unit->status) & ZFCP_STATUS_COMMON_RUNNING)) | 171 | if (!(atomic_read(&unit->status) & ZFCP_STATUS_COMMON_RUNNING)) |
172 | status = ZFCP_STATUS_ERP_CLOSE_ONLY; | 172 | status = ZFCP_STATUS_ERP_CLOSE_ONLY; |
173 | break; | 173 | break; |
174 | 174 | ||
175 | case ZFCP_ERP_ACTION_REOPEN_PORT: | 175 | case ZFCP_ERP_ACTION_REOPEN_PORT: |
176 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: | 176 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: |
177 | zfcp_port_get(port); | 177 | zfcp_port_get(port); |
178 | zfcp_erp_action_dismiss_port(port); | 178 | zfcp_erp_action_dismiss_port(port); |
179 | atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &port->status); | 179 | atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &port->status); |
180 | erp_action = &port->erp_action; | 180 | erp_action = &port->erp_action; |
181 | if (!(atomic_read(&port->status) & ZFCP_STATUS_COMMON_RUNNING)) | 181 | if (!(atomic_read(&port->status) & ZFCP_STATUS_COMMON_RUNNING)) |
182 | status = ZFCP_STATUS_ERP_CLOSE_ONLY; | 182 | status = ZFCP_STATUS_ERP_CLOSE_ONLY; |
183 | break; | 183 | break; |
184 | 184 | ||
185 | case ZFCP_ERP_ACTION_REOPEN_ADAPTER: | 185 | case ZFCP_ERP_ACTION_REOPEN_ADAPTER: |
186 | zfcp_adapter_get(adapter); | 186 | zfcp_adapter_get(adapter); |
187 | zfcp_erp_action_dismiss_adapter(adapter); | 187 | zfcp_erp_action_dismiss_adapter(adapter); |
188 | atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status); | 188 | atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status); |
189 | erp_action = &adapter->erp_action; | 189 | erp_action = &adapter->erp_action; |
190 | if (!(atomic_read(&adapter->status) & | 190 | if (!(atomic_read(&adapter->status) & |
191 | ZFCP_STATUS_COMMON_RUNNING)) | 191 | ZFCP_STATUS_COMMON_RUNNING)) |
192 | status = ZFCP_STATUS_ERP_CLOSE_ONLY; | 192 | status = ZFCP_STATUS_ERP_CLOSE_ONLY; |
193 | break; | 193 | break; |
194 | 194 | ||
195 | default: | 195 | default: |
196 | return NULL; | 196 | return NULL; |
197 | } | 197 | } |
198 | 198 | ||
199 | memset(erp_action, 0, sizeof(struct zfcp_erp_action)); | 199 | memset(erp_action, 0, sizeof(struct zfcp_erp_action)); |
200 | erp_action->adapter = adapter; | 200 | erp_action->adapter = adapter; |
201 | erp_action->port = port; | 201 | erp_action->port = port; |
202 | erp_action->unit = unit; | 202 | erp_action->unit = unit; |
203 | erp_action->action = need; | 203 | erp_action->action = need; |
204 | erp_action->status = status; | 204 | erp_action->status = status; |
205 | 205 | ||
206 | return erp_action; | 206 | return erp_action; |
207 | } | 207 | } |
208 | 208 | ||
209 | static int zfcp_erp_action_enqueue(int want, struct zfcp_adapter *adapter, | 209 | static int zfcp_erp_action_enqueue(int want, struct zfcp_adapter *adapter, |
210 | struct zfcp_port *port, | 210 | struct zfcp_port *port, |
211 | struct zfcp_unit *unit, u8 id, void *ref) | 211 | struct zfcp_unit *unit, u8 id, void *ref) |
212 | { | 212 | { |
213 | int retval = 1, need; | 213 | int retval = 1, need; |
214 | struct zfcp_erp_action *act = NULL; | 214 | struct zfcp_erp_action *act = NULL; |
215 | 215 | ||
216 | if (!(atomic_read(&adapter->status) & | 216 | if (!(atomic_read(&adapter->status) & |
217 | ZFCP_STATUS_ADAPTER_ERP_THREAD_UP)) | 217 | ZFCP_STATUS_ADAPTER_ERP_THREAD_UP)) |
218 | return -EIO; | 218 | return -EIO; |
219 | 219 | ||
220 | need = zfcp_erp_required_act(want, adapter, port, unit); | 220 | need = zfcp_erp_required_act(want, adapter, port, unit); |
221 | if (!need) | 221 | if (!need) |
222 | goto out; | 222 | goto out; |
223 | 223 | ||
224 | atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING, &adapter->status); | 224 | atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING, &adapter->status); |
225 | act = zfcp_erp_setup_act(need, adapter, port, unit); | 225 | act = zfcp_erp_setup_act(need, adapter, port, unit); |
226 | if (!act) | 226 | if (!act) |
227 | goto out; | 227 | goto out; |
228 | ++adapter->erp_total_count; | 228 | ++adapter->erp_total_count; |
229 | list_add_tail(&act->list, &adapter->erp_ready_head); | 229 | list_add_tail(&act->list, &adapter->erp_ready_head); |
230 | up(&adapter->erp_ready_sem); | 230 | up(&adapter->erp_ready_sem); |
231 | zfcp_rec_dbf_event_thread(1, adapter); | 231 | zfcp_rec_dbf_event_thread(1, adapter); |
232 | retval = 0; | 232 | retval = 0; |
233 | out: | 233 | out: |
234 | zfcp_rec_dbf_event_trigger(id, ref, want, need, act, | 234 | zfcp_rec_dbf_event_trigger(id, ref, want, need, act, |
235 | adapter, port, unit); | 235 | adapter, port, unit); |
236 | return retval; | 236 | return retval; |
237 | } | 237 | } |
238 | 238 | ||
239 | static int _zfcp_erp_adapter_reopen(struct zfcp_adapter *adapter, | 239 | static int _zfcp_erp_adapter_reopen(struct zfcp_adapter *adapter, |
240 | int clear_mask, u8 id, void *ref) | 240 | int clear_mask, u8 id, void *ref) |
241 | { | 241 | { |
242 | zfcp_erp_adapter_block(adapter, clear_mask); | 242 | zfcp_erp_adapter_block(adapter, clear_mask); |
243 | 243 | ||
244 | /* ensure propagation of failed status to new devices */ | 244 | /* ensure propagation of failed status to new devices */ |
245 | if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_ERP_FAILED) { | 245 | if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_ERP_FAILED) { |
246 | zfcp_erp_adapter_failed(adapter, 13, NULL); | 246 | zfcp_erp_adapter_failed(adapter, 13, NULL); |
247 | return -EIO; | 247 | return -EIO; |
248 | } | 248 | } |
249 | return zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_ADAPTER, | 249 | return zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_ADAPTER, |
250 | adapter, NULL, NULL, id, ref); | 250 | adapter, NULL, NULL, id, ref); |
251 | } | 251 | } |
252 | 252 | ||
253 | /** | 253 | /** |
254 | * zfcp_erp_adapter_reopen - Reopen adapter. | 254 | * zfcp_erp_adapter_reopen - Reopen adapter. |
255 | * @adapter: Adapter to reopen. | 255 | * @adapter: Adapter to reopen. |
256 | * @clear: Status flags to clear. | 256 | * @clear: Status flags to clear. |
257 | * @id: Id for debug trace event. | 257 | * @id: Id for debug trace event. |
258 | * @ref: Reference for debug trace event. | 258 | * @ref: Reference for debug trace event. |
259 | */ | 259 | */ |
260 | void zfcp_erp_adapter_reopen(struct zfcp_adapter *adapter, int clear, | 260 | void zfcp_erp_adapter_reopen(struct zfcp_adapter *adapter, int clear, |
261 | u8 id, void *ref) | 261 | u8 id, void *ref) |
262 | { | 262 | { |
263 | unsigned long flags; | 263 | unsigned long flags; |
264 | 264 | ||
265 | read_lock_irqsave(&zfcp_data.config_lock, flags); | 265 | read_lock_irqsave(&zfcp_data.config_lock, flags); |
266 | write_lock(&adapter->erp_lock); | 266 | write_lock(&adapter->erp_lock); |
267 | _zfcp_erp_adapter_reopen(adapter, clear, id, ref); | 267 | _zfcp_erp_adapter_reopen(adapter, clear, id, ref); |
268 | write_unlock(&adapter->erp_lock); | 268 | write_unlock(&adapter->erp_lock); |
269 | read_unlock_irqrestore(&zfcp_data.config_lock, flags); | 269 | read_unlock_irqrestore(&zfcp_data.config_lock, flags); |
270 | } | 270 | } |
271 | 271 | ||
272 | /** | 272 | /** |
273 | * zfcp_erp_adapter_shutdown - Shutdown adapter. | 273 | * zfcp_erp_adapter_shutdown - Shutdown adapter. |
274 | * @adapter: Adapter to shut down. | 274 | * @adapter: Adapter to shut down. |
275 | * @clear: Status flags to clear. | 275 | * @clear: Status flags to clear. |
276 | * @id: Id for debug trace event. | 276 | * @id: Id for debug trace event. |
277 | * @ref: Reference for debug trace event. | 277 | * @ref: Reference for debug trace event. |
278 | */ | 278 | */ |
279 | void zfcp_erp_adapter_shutdown(struct zfcp_adapter *adapter, int clear, | 279 | void zfcp_erp_adapter_shutdown(struct zfcp_adapter *adapter, int clear, |
280 | u8 id, void *ref) | 280 | u8 id, void *ref) |
281 | { | 281 | { |
282 | int flags = ZFCP_STATUS_COMMON_RUNNING | ZFCP_STATUS_COMMON_ERP_FAILED; | 282 | int flags = ZFCP_STATUS_COMMON_RUNNING | ZFCP_STATUS_COMMON_ERP_FAILED; |
283 | zfcp_erp_adapter_reopen(adapter, clear | flags, id, ref); | 283 | zfcp_erp_adapter_reopen(adapter, clear | flags, id, ref); |
284 | } | 284 | } |
285 | 285 | ||
286 | /** | 286 | /** |
287 | * zfcp_erp_port_shutdown - Shutdown port | 287 | * zfcp_erp_port_shutdown - Shutdown port |
288 | * @port: Port to shut down. | 288 | * @port: Port to shut down. |
289 | * @clear: Status flags to clear. | 289 | * @clear: Status flags to clear. |
290 | * @id: Id for debug trace event. | 290 | * @id: Id for debug trace event. |
291 | * @ref: Reference for debug trace event. | 291 | * @ref: Reference for debug trace event. |
292 | */ | 292 | */ |
293 | void zfcp_erp_port_shutdown(struct zfcp_port *port, int clear, u8 id, void *ref) | 293 | void zfcp_erp_port_shutdown(struct zfcp_port *port, int clear, u8 id, void *ref) |
294 | { | 294 | { |
295 | int flags = ZFCP_STATUS_COMMON_RUNNING | ZFCP_STATUS_COMMON_ERP_FAILED; | 295 | int flags = ZFCP_STATUS_COMMON_RUNNING | ZFCP_STATUS_COMMON_ERP_FAILED; |
296 | zfcp_erp_port_reopen(port, clear | flags, id, ref); | 296 | zfcp_erp_port_reopen(port, clear | flags, id, ref); |
297 | } | 297 | } |
298 | 298 | ||
299 | /** | 299 | /** |
300 | * zfcp_erp_unit_shutdown - Shutdown unit | 300 | * zfcp_erp_unit_shutdown - Shutdown unit |
301 | * @unit: Unit to shut down. | 301 | * @unit: Unit to shut down. |
302 | * @clear: Status flags to clear. | 302 | * @clear: Status flags to clear. |
303 | * @id: Id for debug trace event. | 303 | * @id: Id for debug trace event. |
304 | * @ref: Reference for debug trace event. | 304 | * @ref: Reference for debug trace event. |
305 | */ | 305 | */ |
306 | void zfcp_erp_unit_shutdown(struct zfcp_unit *unit, int clear, u8 id, void *ref) | 306 | void zfcp_erp_unit_shutdown(struct zfcp_unit *unit, int clear, u8 id, void *ref) |
307 | { | 307 | { |
308 | int flags = ZFCP_STATUS_COMMON_RUNNING | ZFCP_STATUS_COMMON_ERP_FAILED; | 308 | int flags = ZFCP_STATUS_COMMON_RUNNING | ZFCP_STATUS_COMMON_ERP_FAILED; |
309 | zfcp_erp_unit_reopen(unit, clear | flags, id, ref); | 309 | zfcp_erp_unit_reopen(unit, clear | flags, id, ref); |
310 | } | 310 | } |
311 | 311 | ||
312 | static void zfcp_erp_port_block(struct zfcp_port *port, int clear) | 312 | static void zfcp_erp_port_block(struct zfcp_port *port, int clear) |
313 | { | 313 | { |
314 | zfcp_erp_modify_port_status(port, 17, NULL, | 314 | zfcp_erp_modify_port_status(port, 17, NULL, |
315 | ZFCP_STATUS_COMMON_UNBLOCKED | clear, | 315 | ZFCP_STATUS_COMMON_UNBLOCKED | clear, |
316 | ZFCP_CLEAR); | 316 | ZFCP_CLEAR); |
317 | } | 317 | } |
318 | 318 | ||
319 | static void _zfcp_erp_port_forced_reopen(struct zfcp_port *port, | 319 | static void _zfcp_erp_port_forced_reopen(struct zfcp_port *port, |
320 | int clear, u8 id, void *ref) | 320 | int clear, u8 id, void *ref) |
321 | { | 321 | { |
322 | zfcp_erp_port_block(port, clear); | 322 | zfcp_erp_port_block(port, clear); |
323 | 323 | ||
324 | if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED) | 324 | if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED) |
325 | return; | 325 | return; |
326 | 326 | ||
327 | zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_PORT_FORCED, | 327 | zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_PORT_FORCED, |
328 | port->adapter, port, NULL, id, ref); | 328 | port->adapter, port, NULL, id, ref); |
329 | } | 329 | } |
330 | 330 | ||
331 | /** | 331 | /** |
332 | * zfcp_erp_port_forced_reopen - Forced close of port and open again | 332 | * zfcp_erp_port_forced_reopen - Forced close of port and open again |
333 | * @port: Port to force close and to reopen. | 333 | * @port: Port to force close and to reopen. |
334 | * @id: Id for debug trace event. | 334 | * @id: Id for debug trace event. |
335 | * @ref: Reference for debug trace event. | 335 | * @ref: Reference for debug trace event. |
336 | */ | 336 | */ |
337 | void zfcp_erp_port_forced_reopen(struct zfcp_port *port, int clear, u8 id, | 337 | void zfcp_erp_port_forced_reopen(struct zfcp_port *port, int clear, u8 id, |
338 | void *ref) | 338 | void *ref) |
339 | { | 339 | { |
340 | unsigned long flags; | 340 | unsigned long flags; |
341 | struct zfcp_adapter *adapter = port->adapter; | 341 | struct zfcp_adapter *adapter = port->adapter; |
342 | 342 | ||
343 | read_lock_irqsave(&zfcp_data.config_lock, flags); | 343 | read_lock_irqsave(&zfcp_data.config_lock, flags); |
344 | write_lock(&adapter->erp_lock); | 344 | write_lock(&adapter->erp_lock); |
345 | _zfcp_erp_port_forced_reopen(port, clear, id, ref); | 345 | _zfcp_erp_port_forced_reopen(port, clear, id, ref); |
346 | write_unlock(&adapter->erp_lock); | 346 | write_unlock(&adapter->erp_lock); |
347 | read_unlock_irqrestore(&zfcp_data.config_lock, flags); | 347 | read_unlock_irqrestore(&zfcp_data.config_lock, flags); |
348 | } | 348 | } |
349 | 349 | ||
350 | static int _zfcp_erp_port_reopen(struct zfcp_port *port, int clear, u8 id, | 350 | static int _zfcp_erp_port_reopen(struct zfcp_port *port, int clear, u8 id, |
351 | void *ref) | 351 | void *ref) |
352 | { | 352 | { |
353 | zfcp_erp_port_block(port, clear); | 353 | zfcp_erp_port_block(port, clear); |
354 | 354 | ||
355 | if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED) { | 355 | if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED) { |
356 | /* ensure propagation of failed status to new devices */ | 356 | /* ensure propagation of failed status to new devices */ |
357 | zfcp_erp_port_failed(port, 14, NULL); | 357 | zfcp_erp_port_failed(port, 14, NULL); |
358 | return -EIO; | 358 | return -EIO; |
359 | } | 359 | } |
360 | 360 | ||
361 | return zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_PORT, | 361 | return zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_PORT, |
362 | port->adapter, port, NULL, id, ref); | 362 | port->adapter, port, NULL, id, ref); |
363 | } | 363 | } |
364 | 364 | ||
365 | /** | 365 | /** |
366 | * zfcp_erp_port_reopen - trigger remote port recovery | 366 | * zfcp_erp_port_reopen - trigger remote port recovery |
367 | * @port: port to recover | 367 | * @port: port to recover |
368 | * @clear_mask: flags in port status to be cleared | 368 | * @clear_mask: flags in port status to be cleared |
369 | * | 369 | * |
370 | * Returns 0 if recovery has been triggered, < 0 if not. | 370 | * Returns 0 if recovery has been triggered, < 0 if not. |
371 | */ | 371 | */ |
372 | int zfcp_erp_port_reopen(struct zfcp_port *port, int clear, u8 id, void *ref) | 372 | int zfcp_erp_port_reopen(struct zfcp_port *port, int clear, u8 id, void *ref) |
373 | { | 373 | { |
374 | unsigned long flags; | 374 | unsigned long flags; |
375 | int retval; | 375 | int retval; |
376 | struct zfcp_adapter *adapter = port->adapter; | 376 | struct zfcp_adapter *adapter = port->adapter; |
377 | 377 | ||
378 | read_lock_irqsave(&zfcp_data.config_lock, flags); | 378 | read_lock_irqsave(&zfcp_data.config_lock, flags); |
379 | write_lock(&adapter->erp_lock); | 379 | write_lock(&adapter->erp_lock); |
380 | retval = _zfcp_erp_port_reopen(port, clear, id, ref); | 380 | retval = _zfcp_erp_port_reopen(port, clear, id, ref); |
381 | write_unlock(&adapter->erp_lock); | 381 | write_unlock(&adapter->erp_lock); |
382 | read_unlock_irqrestore(&zfcp_data.config_lock, flags); | 382 | read_unlock_irqrestore(&zfcp_data.config_lock, flags); |
383 | 383 | ||
384 | return retval; | 384 | return retval; |
385 | } | 385 | } |
386 | 386 | ||
387 | static void zfcp_erp_unit_block(struct zfcp_unit *unit, int clear_mask) | 387 | static void zfcp_erp_unit_block(struct zfcp_unit *unit, int clear_mask) |
388 | { | 388 | { |
389 | zfcp_erp_modify_unit_status(unit, 19, NULL, | 389 | zfcp_erp_modify_unit_status(unit, 19, NULL, |
390 | ZFCP_STATUS_COMMON_UNBLOCKED | clear_mask, | 390 | ZFCP_STATUS_COMMON_UNBLOCKED | clear_mask, |
391 | ZFCP_CLEAR); | 391 | ZFCP_CLEAR); |
392 | } | 392 | } |
393 | 393 | ||
394 | static void _zfcp_erp_unit_reopen(struct zfcp_unit *unit, int clear, u8 id, | 394 | static void _zfcp_erp_unit_reopen(struct zfcp_unit *unit, int clear, u8 id, |
395 | void *ref) | 395 | void *ref) |
396 | { | 396 | { |
397 | struct zfcp_adapter *adapter = unit->port->adapter; | 397 | struct zfcp_adapter *adapter = unit->port->adapter; |
398 | 398 | ||
399 | zfcp_erp_unit_block(unit, clear); | 399 | zfcp_erp_unit_block(unit, clear); |
400 | 400 | ||
401 | if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_ERP_FAILED) | 401 | if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_ERP_FAILED) |
402 | return; | 402 | return; |
403 | 403 | ||
404 | zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_UNIT, | 404 | zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_UNIT, |
405 | adapter, unit->port, unit, id, ref); | 405 | adapter, unit->port, unit, id, ref); |
406 | } | 406 | } |
407 | 407 | ||
408 | /** | 408 | /** |
409 | * zfcp_erp_unit_reopen - initiate reopen of a unit | 409 | * zfcp_erp_unit_reopen - initiate reopen of a unit |
410 | * @unit: unit to be reopened | 410 | * @unit: unit to be reopened |
411 | * @clear_mask: specifies flags in unit status to be cleared | 411 | * @clear_mask: specifies flags in unit status to be cleared |
412 | * Return: 0 on success, < 0 on error | 412 | * Return: 0 on success, < 0 on error |
413 | */ | 413 | */ |
414 | void zfcp_erp_unit_reopen(struct zfcp_unit *unit, int clear, u8 id, void *ref) | 414 | void zfcp_erp_unit_reopen(struct zfcp_unit *unit, int clear, u8 id, void *ref) |
415 | { | 415 | { |
416 | unsigned long flags; | 416 | unsigned long flags; |
417 | struct zfcp_port *port = unit->port; | 417 | struct zfcp_port *port = unit->port; |
418 | struct zfcp_adapter *adapter = port->adapter; | 418 | struct zfcp_adapter *adapter = port->adapter; |
419 | 419 | ||
420 | read_lock_irqsave(&zfcp_data.config_lock, flags); | 420 | read_lock_irqsave(&zfcp_data.config_lock, flags); |
421 | write_lock(&adapter->erp_lock); | 421 | write_lock(&adapter->erp_lock); |
422 | _zfcp_erp_unit_reopen(unit, clear, id, ref); | 422 | _zfcp_erp_unit_reopen(unit, clear, id, ref); |
423 | write_unlock(&adapter->erp_lock); | 423 | write_unlock(&adapter->erp_lock); |
424 | read_unlock_irqrestore(&zfcp_data.config_lock, flags); | 424 | read_unlock_irqrestore(&zfcp_data.config_lock, flags); |
425 | } | 425 | } |
426 | 426 | ||
427 | static int status_change_set(unsigned long mask, atomic_t *status) | 427 | static int status_change_set(unsigned long mask, atomic_t *status) |
428 | { | 428 | { |
429 | return (atomic_read(status) ^ mask) & mask; | 429 | return (atomic_read(status) ^ mask) & mask; |
430 | } | 430 | } |
431 | 431 | ||
432 | static int status_change_clear(unsigned long mask, atomic_t *status) | 432 | static int status_change_clear(unsigned long mask, atomic_t *status) |
433 | { | 433 | { |
434 | return atomic_read(status) & mask; | 434 | return atomic_read(status) & mask; |
435 | } | 435 | } |
436 | 436 | ||
437 | static void zfcp_erp_adapter_unblock(struct zfcp_adapter *adapter) | 437 | static void zfcp_erp_adapter_unblock(struct zfcp_adapter *adapter) |
438 | { | 438 | { |
439 | if (status_change_set(ZFCP_STATUS_COMMON_UNBLOCKED, &adapter->status)) | 439 | if (status_change_set(ZFCP_STATUS_COMMON_UNBLOCKED, &adapter->status)) |
440 | zfcp_rec_dbf_event_adapter(16, NULL, adapter); | 440 | zfcp_rec_dbf_event_adapter(16, NULL, adapter); |
441 | atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &adapter->status); | 441 | atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &adapter->status); |
442 | } | 442 | } |
443 | 443 | ||
444 | static void zfcp_erp_port_unblock(struct zfcp_port *port) | 444 | static void zfcp_erp_port_unblock(struct zfcp_port *port) |
445 | { | 445 | { |
446 | if (status_change_set(ZFCP_STATUS_COMMON_UNBLOCKED, &port->status)) | 446 | if (status_change_set(ZFCP_STATUS_COMMON_UNBLOCKED, &port->status)) |
447 | zfcp_rec_dbf_event_port(18, NULL, port); | 447 | zfcp_rec_dbf_event_port(18, NULL, port); |
448 | atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &port->status); | 448 | atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &port->status); |
449 | } | 449 | } |
450 | 450 | ||
451 | static void zfcp_erp_unit_unblock(struct zfcp_unit *unit) | 451 | static void zfcp_erp_unit_unblock(struct zfcp_unit *unit) |
452 | { | 452 | { |
453 | if (status_change_set(ZFCP_STATUS_COMMON_UNBLOCKED, &unit->status)) | 453 | if (status_change_set(ZFCP_STATUS_COMMON_UNBLOCKED, &unit->status)) |
454 | zfcp_rec_dbf_event_unit(20, NULL, unit); | 454 | zfcp_rec_dbf_event_unit(20, NULL, unit); |
455 | atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &unit->status); | 455 | atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &unit->status); |
456 | } | 456 | } |
457 | 457 | ||
458 | static void zfcp_erp_action_to_running(struct zfcp_erp_action *erp_action) | 458 | static void zfcp_erp_action_to_running(struct zfcp_erp_action *erp_action) |
459 | { | 459 | { |
460 | list_move(&erp_action->list, &erp_action->adapter->erp_running_head); | 460 | list_move(&erp_action->list, &erp_action->adapter->erp_running_head); |
461 | zfcp_rec_dbf_event_action(145, erp_action); | 461 | zfcp_rec_dbf_event_action(145, erp_action); |
462 | } | 462 | } |
463 | 463 | ||
464 | static void zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action *act) | 464 | static void zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action *act) |
465 | { | 465 | { |
466 | struct zfcp_adapter *adapter = act->adapter; | 466 | struct zfcp_adapter *adapter = act->adapter; |
467 | 467 | ||
468 | if (!act->fsf_req) | 468 | if (!act->fsf_req) |
469 | return; | 469 | return; |
470 | 470 | ||
471 | spin_lock(&adapter->req_list_lock); | 471 | spin_lock(&adapter->req_list_lock); |
472 | if (zfcp_reqlist_find_safe(adapter, act->fsf_req) && | 472 | if (zfcp_reqlist_find_safe(adapter, act->fsf_req) && |
473 | act->fsf_req->erp_action == act) { | 473 | act->fsf_req->erp_action == act) { |
474 | if (act->status & (ZFCP_STATUS_ERP_DISMISSED | | 474 | if (act->status & (ZFCP_STATUS_ERP_DISMISSED | |
475 | ZFCP_STATUS_ERP_TIMEDOUT)) { | 475 | ZFCP_STATUS_ERP_TIMEDOUT)) { |
476 | act->fsf_req->status |= ZFCP_STATUS_FSFREQ_DISMISSED; | 476 | act->fsf_req->status |= ZFCP_STATUS_FSFREQ_DISMISSED; |
477 | zfcp_rec_dbf_event_action(142, act); | 477 | zfcp_rec_dbf_event_action(142, act); |
478 | act->fsf_req->erp_action = NULL; | 478 | act->fsf_req->erp_action = NULL; |
479 | } | 479 | } |
480 | if (act->status & ZFCP_STATUS_ERP_TIMEDOUT) | 480 | if (act->status & ZFCP_STATUS_ERP_TIMEDOUT) |
481 | zfcp_rec_dbf_event_action(143, act); | 481 | zfcp_rec_dbf_event_action(143, act); |
482 | if (act->fsf_req->status & (ZFCP_STATUS_FSFREQ_COMPLETED | | 482 | if (act->fsf_req->status & (ZFCP_STATUS_FSFREQ_COMPLETED | |
483 | ZFCP_STATUS_FSFREQ_DISMISSED)) | 483 | ZFCP_STATUS_FSFREQ_DISMISSED)) |
484 | act->fsf_req = NULL; | 484 | act->fsf_req = NULL; |
485 | } else | 485 | } else |
486 | act->fsf_req = NULL; | 486 | act->fsf_req = NULL; |
487 | spin_unlock(&adapter->req_list_lock); | 487 | spin_unlock(&adapter->req_list_lock); |
488 | } | 488 | } |
489 | 489 | ||
490 | /** | 490 | /** |
491 | * zfcp_erp_notify - Trigger ERP action. | 491 | * zfcp_erp_notify - Trigger ERP action. |
492 | * @erp_action: ERP action to continue. | 492 | * @erp_action: ERP action to continue. |
493 | * @set_mask: ERP action status flags to set. | 493 | * @set_mask: ERP action status flags to set. |
494 | */ | 494 | */ |
495 | void zfcp_erp_notify(struct zfcp_erp_action *erp_action, unsigned long set_mask) | 495 | void zfcp_erp_notify(struct zfcp_erp_action *erp_action, unsigned long set_mask) |
496 | { | 496 | { |
497 | struct zfcp_adapter *adapter = erp_action->adapter; | 497 | struct zfcp_adapter *adapter = erp_action->adapter; |
498 | unsigned long flags; | 498 | unsigned long flags; |
499 | 499 | ||
500 | write_lock_irqsave(&adapter->erp_lock, flags); | 500 | write_lock_irqsave(&adapter->erp_lock, flags); |
501 | if (zfcp_erp_action_exists(erp_action) == ZFCP_ERP_ACTION_RUNNING) { | 501 | if (zfcp_erp_action_exists(erp_action) == ZFCP_ERP_ACTION_RUNNING) { |
502 | erp_action->status |= set_mask; | 502 | erp_action->status |= set_mask; |
503 | zfcp_erp_action_ready(erp_action); | 503 | zfcp_erp_action_ready(erp_action); |
504 | } | 504 | } |
505 | write_unlock_irqrestore(&adapter->erp_lock, flags); | 505 | write_unlock_irqrestore(&adapter->erp_lock, flags); |
506 | } | 506 | } |
507 | 507 | ||
508 | /** | 508 | /** |
509 | * zfcp_erp_timeout_handler - Trigger ERP action from timed out ERP request | 509 | * zfcp_erp_timeout_handler - Trigger ERP action from timed out ERP request |
510 | * @data: ERP action (from timer data) | 510 | * @data: ERP action (from timer data) |
511 | */ | 511 | */ |
512 | void zfcp_erp_timeout_handler(unsigned long data) | 512 | void zfcp_erp_timeout_handler(unsigned long data) |
513 | { | 513 | { |
514 | struct zfcp_erp_action *act = (struct zfcp_erp_action *) data; | 514 | struct zfcp_erp_action *act = (struct zfcp_erp_action *) data; |
515 | zfcp_erp_notify(act, ZFCP_STATUS_ERP_TIMEDOUT); | 515 | zfcp_erp_notify(act, ZFCP_STATUS_ERP_TIMEDOUT); |
516 | } | 516 | } |
517 | 517 | ||
518 | static void zfcp_erp_memwait_handler(unsigned long data) | 518 | static void zfcp_erp_memwait_handler(unsigned long data) |
519 | { | 519 | { |
520 | zfcp_erp_notify((struct zfcp_erp_action *)data, 0); | 520 | zfcp_erp_notify((struct zfcp_erp_action *)data, 0); |
521 | } | 521 | } |
522 | 522 | ||
523 | static void zfcp_erp_strategy_memwait(struct zfcp_erp_action *erp_action) | 523 | static void zfcp_erp_strategy_memwait(struct zfcp_erp_action *erp_action) |
524 | { | 524 | { |
525 | init_timer(&erp_action->timer); | 525 | init_timer(&erp_action->timer); |
526 | erp_action->timer.function = zfcp_erp_memwait_handler; | 526 | erp_action->timer.function = zfcp_erp_memwait_handler; |
527 | erp_action->timer.data = (unsigned long) erp_action; | 527 | erp_action->timer.data = (unsigned long) erp_action; |
528 | erp_action->timer.expires = jiffies + HZ; | 528 | erp_action->timer.expires = jiffies + HZ; |
529 | add_timer(&erp_action->timer); | 529 | add_timer(&erp_action->timer); |
530 | } | 530 | } |
531 | 531 | ||
532 | static void _zfcp_erp_port_reopen_all(struct zfcp_adapter *adapter, | 532 | static void _zfcp_erp_port_reopen_all(struct zfcp_adapter *adapter, |
533 | int clear, u8 id, void *ref) | 533 | int clear, u8 id, void *ref) |
534 | { | 534 | { |
535 | struct zfcp_port *port; | 535 | struct zfcp_port *port; |
536 | 536 | ||
537 | list_for_each_entry(port, &adapter->port_list_head, list) | 537 | list_for_each_entry(port, &adapter->port_list_head, list) |
538 | _zfcp_erp_port_reopen(port, clear, id, ref); | 538 | _zfcp_erp_port_reopen(port, clear, id, ref); |
539 | } | 539 | } |
540 | 540 | ||
541 | static void _zfcp_erp_unit_reopen_all(struct zfcp_port *port, int clear, u8 id, | 541 | static void _zfcp_erp_unit_reopen_all(struct zfcp_port *port, int clear, u8 id, |
542 | void *ref) | 542 | void *ref) |
543 | { | 543 | { |
544 | struct zfcp_unit *unit; | 544 | struct zfcp_unit *unit; |
545 | 545 | ||
546 | list_for_each_entry(unit, &port->unit_list_head, list) | 546 | list_for_each_entry(unit, &port->unit_list_head, list) |
547 | _zfcp_erp_unit_reopen(unit, clear, id, ref); | 547 | _zfcp_erp_unit_reopen(unit, clear, id, ref); |
548 | } | 548 | } |
549 | 549 | ||
550 | static void zfcp_erp_strategy_followup_actions(struct zfcp_erp_action *act) | 550 | static void zfcp_erp_strategy_followup_actions(struct zfcp_erp_action *act) |
551 | { | 551 | { |
552 | struct zfcp_adapter *adapter = act->adapter; | 552 | struct zfcp_adapter *adapter = act->adapter; |
553 | struct zfcp_port *port = act->port; | 553 | struct zfcp_port *port = act->port; |
554 | struct zfcp_unit *unit = act->unit; | 554 | struct zfcp_unit *unit = act->unit; |
555 | u32 status = act->status; | 555 | u32 status = act->status; |
556 | 556 | ||
557 | /* initiate follow-up actions depending on success of finished action */ | 557 | /* initiate follow-up actions depending on success of finished action */ |
558 | switch (act->action) { | 558 | switch (act->action) { |
559 | 559 | ||
560 | case ZFCP_ERP_ACTION_REOPEN_ADAPTER: | 560 | case ZFCP_ERP_ACTION_REOPEN_ADAPTER: |
561 | if (status == ZFCP_ERP_SUCCEEDED) | 561 | if (status == ZFCP_ERP_SUCCEEDED) |
562 | _zfcp_erp_port_reopen_all(adapter, 0, 70, NULL); | 562 | _zfcp_erp_port_reopen_all(adapter, 0, 70, NULL); |
563 | else | 563 | else |
564 | _zfcp_erp_adapter_reopen(adapter, 0, 71, NULL); | 564 | _zfcp_erp_adapter_reopen(adapter, 0, 71, NULL); |
565 | break; | 565 | break; |
566 | 566 | ||
567 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: | 567 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: |
568 | if (status == ZFCP_ERP_SUCCEEDED) | 568 | if (status == ZFCP_ERP_SUCCEEDED) |
569 | _zfcp_erp_port_reopen(port, 0, 72, NULL); | 569 | _zfcp_erp_port_reopen(port, 0, 72, NULL); |
570 | else | 570 | else |
571 | _zfcp_erp_adapter_reopen(adapter, 0, 73, NULL); | 571 | _zfcp_erp_adapter_reopen(adapter, 0, 73, NULL); |
572 | break; | 572 | break; |
573 | 573 | ||
574 | case ZFCP_ERP_ACTION_REOPEN_PORT: | 574 | case ZFCP_ERP_ACTION_REOPEN_PORT: |
575 | if (status == ZFCP_ERP_SUCCEEDED) | 575 | if (status == ZFCP_ERP_SUCCEEDED) |
576 | _zfcp_erp_unit_reopen_all(port, 0, 74, NULL); | 576 | _zfcp_erp_unit_reopen_all(port, 0, 74, NULL); |
577 | else | 577 | else |
578 | _zfcp_erp_port_forced_reopen(port, 0, 75, NULL); | 578 | _zfcp_erp_port_forced_reopen(port, 0, 75, NULL); |
579 | break; | 579 | break; |
580 | 580 | ||
581 | case ZFCP_ERP_ACTION_REOPEN_UNIT: | 581 | case ZFCP_ERP_ACTION_REOPEN_UNIT: |
582 | if (status != ZFCP_ERP_SUCCEEDED) | 582 | if (status != ZFCP_ERP_SUCCEEDED) |
583 | _zfcp_erp_port_reopen(unit->port, 0, 76, NULL); | 583 | _zfcp_erp_port_reopen(unit->port, 0, 76, NULL); |
584 | break; | 584 | break; |
585 | } | 585 | } |
586 | } | 586 | } |
587 | 587 | ||
588 | static void zfcp_erp_wakeup(struct zfcp_adapter *adapter) | 588 | static void zfcp_erp_wakeup(struct zfcp_adapter *adapter) |
589 | { | 589 | { |
590 | unsigned long flags; | 590 | unsigned long flags; |
591 | 591 | ||
592 | read_lock_irqsave(&zfcp_data.config_lock, flags); | 592 | read_lock_irqsave(&zfcp_data.config_lock, flags); |
593 | read_lock(&adapter->erp_lock); | 593 | read_lock(&adapter->erp_lock); |
594 | if (list_empty(&adapter->erp_ready_head) && | 594 | if (list_empty(&adapter->erp_ready_head) && |
595 | list_empty(&adapter->erp_running_head)) { | 595 | list_empty(&adapter->erp_running_head)) { |
596 | atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING, | 596 | atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING, |
597 | &adapter->status); | 597 | &adapter->status); |
598 | wake_up(&adapter->erp_done_wqh); | 598 | wake_up(&adapter->erp_done_wqh); |
599 | } | 599 | } |
600 | read_unlock(&adapter->erp_lock); | 600 | read_unlock(&adapter->erp_lock); |
601 | read_unlock_irqrestore(&zfcp_data.config_lock, flags); | 601 | read_unlock_irqrestore(&zfcp_data.config_lock, flags); |
602 | } | 602 | } |
603 | 603 | ||
604 | static int zfcp_erp_adapter_strategy_open_qdio(struct zfcp_erp_action *act) | 604 | static int zfcp_erp_adapter_strategy_open_qdio(struct zfcp_erp_action *act) |
605 | { | 605 | { |
606 | if (zfcp_qdio_open(act->adapter)) | 606 | if (zfcp_qdio_open(act->adapter)) |
607 | return ZFCP_ERP_FAILED; | 607 | return ZFCP_ERP_FAILED; |
608 | init_waitqueue_head(&act->adapter->request_wq); | 608 | init_waitqueue_head(&act->adapter->request_wq); |
609 | atomic_set_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &act->adapter->status); | 609 | atomic_set_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &act->adapter->status); |
610 | return ZFCP_ERP_SUCCEEDED; | 610 | return ZFCP_ERP_SUCCEEDED; |
611 | } | 611 | } |
612 | 612 | ||
613 | static void zfcp_erp_enqueue_ptp_port(struct zfcp_adapter *adapter) | 613 | static void zfcp_erp_enqueue_ptp_port(struct zfcp_adapter *adapter) |
614 | { | 614 | { |
615 | struct zfcp_port *port; | 615 | struct zfcp_port *port; |
616 | port = zfcp_port_enqueue(adapter, adapter->peer_wwpn, 0, | 616 | port = zfcp_port_enqueue(adapter, adapter->peer_wwpn, 0, |
617 | adapter->peer_d_id); | 617 | adapter->peer_d_id); |
618 | if (IS_ERR(port)) /* error or port already attached */ | 618 | if (IS_ERR(port)) /* error or port already attached */ |
619 | return; | 619 | return; |
620 | _zfcp_erp_port_reopen(port, 0, 150, NULL); | 620 | _zfcp_erp_port_reopen(port, 0, 150, NULL); |
621 | } | 621 | } |
622 | 622 | ||
623 | static int zfcp_erp_adapter_strat_fsf_xconf(struct zfcp_erp_action *erp_action) | 623 | static int zfcp_erp_adapter_strat_fsf_xconf(struct zfcp_erp_action *erp_action) |
624 | { | 624 | { |
625 | int retries; | 625 | int retries; |
626 | int sleep = 1; | 626 | int sleep = 1; |
627 | struct zfcp_adapter *adapter = erp_action->adapter; | 627 | struct zfcp_adapter *adapter = erp_action->adapter; |
628 | 628 | ||
629 | atomic_clear_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK, &adapter->status); | 629 | atomic_clear_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK, &adapter->status); |
630 | 630 | ||
631 | for (retries = 7; retries; retries--) { | 631 | for (retries = 7; retries; retries--) { |
632 | atomic_clear_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT, | 632 | atomic_clear_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT, |
633 | &adapter->status); | 633 | &adapter->status); |
634 | write_lock_irq(&adapter->erp_lock); | 634 | write_lock_irq(&adapter->erp_lock); |
635 | zfcp_erp_action_to_running(erp_action); | 635 | zfcp_erp_action_to_running(erp_action); |
636 | write_unlock_irq(&adapter->erp_lock); | 636 | write_unlock_irq(&adapter->erp_lock); |
637 | if (zfcp_fsf_exchange_config_data(erp_action)) { | 637 | if (zfcp_fsf_exchange_config_data(erp_action)) { |
638 | atomic_clear_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT, | 638 | atomic_clear_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT, |
639 | &adapter->status); | 639 | &adapter->status); |
640 | return ZFCP_ERP_FAILED; | 640 | return ZFCP_ERP_FAILED; |
641 | } | 641 | } |
642 | 642 | ||
643 | zfcp_rec_dbf_event_thread_lock(6, adapter); | 643 | zfcp_rec_dbf_event_thread_lock(6, adapter); |
644 | down(&adapter->erp_ready_sem); | 644 | down(&adapter->erp_ready_sem); |
645 | zfcp_rec_dbf_event_thread_lock(7, adapter); | 645 | zfcp_rec_dbf_event_thread_lock(7, adapter); |
646 | if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) | 646 | if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) |
647 | break; | 647 | break; |
648 | 648 | ||
649 | if (!(atomic_read(&adapter->status) & | 649 | if (!(atomic_read(&adapter->status) & |
650 | ZFCP_STATUS_ADAPTER_HOST_CON_INIT)) | 650 | ZFCP_STATUS_ADAPTER_HOST_CON_INIT)) |
651 | break; | 651 | break; |
652 | 652 | ||
653 | ssleep(sleep); | 653 | ssleep(sleep); |
654 | sleep *= 2; | 654 | sleep *= 2; |
655 | } | 655 | } |
656 | 656 | ||
657 | atomic_clear_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT, | 657 | atomic_clear_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT, |
658 | &adapter->status); | 658 | &adapter->status); |
659 | 659 | ||
660 | if (!(atomic_read(&adapter->status) & ZFCP_STATUS_ADAPTER_XCONFIG_OK)) | 660 | if (!(atomic_read(&adapter->status) & ZFCP_STATUS_ADAPTER_XCONFIG_OK)) |
661 | return ZFCP_ERP_FAILED; | 661 | return ZFCP_ERP_FAILED; |
662 | 662 | ||
663 | if (fc_host_port_type(adapter->scsi_host) == FC_PORTTYPE_PTP) | 663 | if (fc_host_port_type(adapter->scsi_host) == FC_PORTTYPE_PTP) |
664 | zfcp_erp_enqueue_ptp_port(adapter); | 664 | zfcp_erp_enqueue_ptp_port(adapter); |
665 | 665 | ||
666 | return ZFCP_ERP_SUCCEEDED; | 666 | return ZFCP_ERP_SUCCEEDED; |
667 | } | 667 | } |
668 | 668 | ||
669 | static int zfcp_erp_adapter_strategy_open_fsf_xport(struct zfcp_erp_action *act) | 669 | static int zfcp_erp_adapter_strategy_open_fsf_xport(struct zfcp_erp_action *act) |
670 | { | 670 | { |
671 | int ret; | 671 | int ret; |
672 | struct zfcp_adapter *adapter = act->adapter; | 672 | struct zfcp_adapter *adapter = act->adapter; |
673 | 673 | ||
674 | write_lock_irq(&adapter->erp_lock); | 674 | write_lock_irq(&adapter->erp_lock); |
675 | zfcp_erp_action_to_running(act); | 675 | zfcp_erp_action_to_running(act); |
676 | write_unlock_irq(&adapter->erp_lock); | 676 | write_unlock_irq(&adapter->erp_lock); |
677 | 677 | ||
678 | ret = zfcp_fsf_exchange_port_data(act); | 678 | ret = zfcp_fsf_exchange_port_data(act); |
679 | if (ret == -EOPNOTSUPP) | 679 | if (ret == -EOPNOTSUPP) |
680 | return ZFCP_ERP_SUCCEEDED; | 680 | return ZFCP_ERP_SUCCEEDED; |
681 | if (ret) | 681 | if (ret) |
682 | return ZFCP_ERP_FAILED; | 682 | return ZFCP_ERP_FAILED; |
683 | 683 | ||
684 | zfcp_rec_dbf_event_thread_lock(8, adapter); | 684 | zfcp_rec_dbf_event_thread_lock(8, adapter); |
685 | down(&adapter->erp_ready_sem); | 685 | down(&adapter->erp_ready_sem); |
686 | zfcp_rec_dbf_event_thread_lock(9, adapter); | 686 | zfcp_rec_dbf_event_thread_lock(9, adapter); |
687 | if (act->status & ZFCP_STATUS_ERP_TIMEDOUT) | 687 | if (act->status & ZFCP_STATUS_ERP_TIMEDOUT) |
688 | return ZFCP_ERP_FAILED; | 688 | return ZFCP_ERP_FAILED; |
689 | 689 | ||
690 | return ZFCP_ERP_SUCCEEDED; | 690 | return ZFCP_ERP_SUCCEEDED; |
691 | } | 691 | } |
692 | 692 | ||
693 | static int zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *act) | 693 | static int zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *act) |
694 | { | 694 | { |
695 | if (zfcp_erp_adapter_strat_fsf_xconf(act) == ZFCP_ERP_FAILED) | 695 | if (zfcp_erp_adapter_strat_fsf_xconf(act) == ZFCP_ERP_FAILED) |
696 | return ZFCP_ERP_FAILED; | 696 | return ZFCP_ERP_FAILED; |
697 | 697 | ||
698 | if (zfcp_erp_adapter_strategy_open_fsf_xport(act) == ZFCP_ERP_FAILED) | 698 | if (zfcp_erp_adapter_strategy_open_fsf_xport(act) == ZFCP_ERP_FAILED) |
699 | return ZFCP_ERP_FAILED; | 699 | return ZFCP_ERP_FAILED; |
700 | 700 | ||
701 | atomic_set(&act->adapter->stat_miss, 16); | 701 | atomic_set(&act->adapter->stat_miss, 16); |
702 | if (zfcp_status_read_refill(act->adapter)) | 702 | if (zfcp_status_read_refill(act->adapter)) |
703 | return ZFCP_ERP_FAILED; | 703 | return ZFCP_ERP_FAILED; |
704 | 704 | ||
705 | return ZFCP_ERP_SUCCEEDED; | 705 | return ZFCP_ERP_SUCCEEDED; |
706 | } | 706 | } |
707 | 707 | ||
708 | static int zfcp_erp_adapter_strategy_generic(struct zfcp_erp_action *act, | 708 | static int zfcp_erp_adapter_strategy_generic(struct zfcp_erp_action *act, |
709 | int close) | 709 | int close) |
710 | { | 710 | { |
711 | int retval = ZFCP_ERP_SUCCEEDED; | 711 | int retval = ZFCP_ERP_SUCCEEDED; |
712 | struct zfcp_adapter *adapter = act->adapter; | 712 | struct zfcp_adapter *adapter = act->adapter; |
713 | 713 | ||
714 | if (close) | 714 | if (close) |
715 | goto close_only; | 715 | goto close_only; |
716 | 716 | ||
717 | retval = zfcp_erp_adapter_strategy_open_qdio(act); | 717 | retval = zfcp_erp_adapter_strategy_open_qdio(act); |
718 | if (retval != ZFCP_ERP_SUCCEEDED) | 718 | if (retval != ZFCP_ERP_SUCCEEDED) |
719 | goto failed_qdio; | 719 | goto failed_qdio; |
720 | 720 | ||
721 | retval = zfcp_erp_adapter_strategy_open_fsf(act); | 721 | retval = zfcp_erp_adapter_strategy_open_fsf(act); |
722 | if (retval != ZFCP_ERP_SUCCEEDED) | 722 | if (retval != ZFCP_ERP_SUCCEEDED) |
723 | goto failed_openfcp; | 723 | goto failed_openfcp; |
724 | 724 | ||
725 | atomic_set_mask(ZFCP_STATUS_COMMON_OPEN, &act->adapter->status); | 725 | atomic_set_mask(ZFCP_STATUS_COMMON_OPEN, &act->adapter->status); |
726 | 726 | ||
727 | return ZFCP_ERP_SUCCEEDED; | 727 | return ZFCP_ERP_SUCCEEDED; |
728 | 728 | ||
729 | close_only: | 729 | close_only: |
730 | atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, | 730 | atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, |
731 | &act->adapter->status); | 731 | &act->adapter->status); |
732 | 732 | ||
733 | failed_openfcp: | 733 | failed_openfcp: |
734 | /* close queues to ensure that buffers are not accessed by adapter */ | 734 | /* close queues to ensure that buffers are not accessed by adapter */ |
735 | zfcp_qdio_close(adapter); | 735 | zfcp_qdio_close(adapter); |
736 | zfcp_fsf_req_dismiss_all(adapter); | 736 | zfcp_fsf_req_dismiss_all(adapter); |
737 | adapter->fsf_req_seq_no = 0; | 737 | adapter->fsf_req_seq_no = 0; |
738 | /* all ports and units are closed */ | 738 | /* all ports and units are closed */ |
739 | zfcp_erp_modify_adapter_status(adapter, 24, NULL, | 739 | zfcp_erp_modify_adapter_status(adapter, 24, NULL, |
740 | ZFCP_STATUS_COMMON_OPEN, ZFCP_CLEAR); | 740 | ZFCP_STATUS_COMMON_OPEN, ZFCP_CLEAR); |
741 | failed_qdio: | 741 | failed_qdio: |
742 | atomic_clear_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK | | 742 | atomic_clear_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK | |
743 | ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, | 743 | ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, |
744 | &act->adapter->status); | 744 | &act->adapter->status); |
745 | return retval; | 745 | return retval; |
746 | } | 746 | } |
747 | 747 | ||
748 | static int zfcp_erp_adapter_strategy(struct zfcp_erp_action *act) | 748 | static int zfcp_erp_adapter_strategy(struct zfcp_erp_action *act) |
749 | { | 749 | { |
750 | int retval; | 750 | int retval; |
751 | 751 | ||
752 | zfcp_erp_adapter_strategy_generic(act, 1); /* close */ | 752 | zfcp_erp_adapter_strategy_generic(act, 1); /* close */ |
753 | if (act->status & ZFCP_STATUS_ERP_CLOSE_ONLY) | 753 | if (act->status & ZFCP_STATUS_ERP_CLOSE_ONLY) |
754 | return ZFCP_ERP_EXIT; | 754 | return ZFCP_ERP_EXIT; |
755 | 755 | ||
756 | retval = zfcp_erp_adapter_strategy_generic(act, 0); /* open */ | 756 | retval = zfcp_erp_adapter_strategy_generic(act, 0); /* open */ |
757 | 757 | ||
758 | if (retval == ZFCP_ERP_FAILED) | 758 | if (retval == ZFCP_ERP_FAILED) |
759 | ssleep(8); | 759 | ssleep(8); |
760 | 760 | ||
761 | return retval; | 761 | return retval; |
762 | } | 762 | } |
763 | 763 | ||
764 | static int zfcp_erp_port_forced_strategy_close(struct zfcp_erp_action *act) | 764 | static int zfcp_erp_port_forced_strategy_close(struct zfcp_erp_action *act) |
765 | { | 765 | { |
766 | int retval; | 766 | int retval; |
767 | 767 | ||
768 | retval = zfcp_fsf_close_physical_port(act); | 768 | retval = zfcp_fsf_close_physical_port(act); |
769 | if (retval == -ENOMEM) | 769 | if (retval == -ENOMEM) |
770 | return ZFCP_ERP_NOMEM; | 770 | return ZFCP_ERP_NOMEM; |
771 | act->step = ZFCP_ERP_STEP_PHYS_PORT_CLOSING; | 771 | act->step = ZFCP_ERP_STEP_PHYS_PORT_CLOSING; |
772 | if (retval) | 772 | if (retval) |
773 | return ZFCP_ERP_FAILED; | 773 | return ZFCP_ERP_FAILED; |
774 | 774 | ||
775 | return ZFCP_ERP_CONTINUES; | 775 | return ZFCP_ERP_CONTINUES; |
776 | } | 776 | } |
777 | 777 | ||
778 | static void zfcp_erp_port_strategy_clearstati(struct zfcp_port *port) | 778 | static void zfcp_erp_port_strategy_clearstati(struct zfcp_port *port) |
779 | { | 779 | { |
780 | atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED, &port->status); | 780 | atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED, &port->status); |
781 | } | 781 | } |
782 | 782 | ||
783 | static int zfcp_erp_port_forced_strategy(struct zfcp_erp_action *erp_action) | 783 | static int zfcp_erp_port_forced_strategy(struct zfcp_erp_action *erp_action) |
784 | { | 784 | { |
785 | struct zfcp_port *port = erp_action->port; | 785 | struct zfcp_port *port = erp_action->port; |
786 | int status = atomic_read(&port->status); | 786 | int status = atomic_read(&port->status); |
787 | 787 | ||
788 | switch (erp_action->step) { | 788 | switch (erp_action->step) { |
789 | case ZFCP_ERP_STEP_UNINITIALIZED: | 789 | case ZFCP_ERP_STEP_UNINITIALIZED: |
790 | zfcp_erp_port_strategy_clearstati(port); | 790 | zfcp_erp_port_strategy_clearstati(port); |
791 | if ((status & ZFCP_STATUS_PORT_PHYS_OPEN) && | 791 | if ((status & ZFCP_STATUS_PORT_PHYS_OPEN) && |
792 | (status & ZFCP_STATUS_COMMON_OPEN)) | 792 | (status & ZFCP_STATUS_COMMON_OPEN)) |
793 | return zfcp_erp_port_forced_strategy_close(erp_action); | 793 | return zfcp_erp_port_forced_strategy_close(erp_action); |
794 | else | 794 | else |
795 | return ZFCP_ERP_FAILED; | 795 | return ZFCP_ERP_FAILED; |
796 | 796 | ||
797 | case ZFCP_ERP_STEP_PHYS_PORT_CLOSING: | 797 | case ZFCP_ERP_STEP_PHYS_PORT_CLOSING: |
798 | if (status & ZFCP_STATUS_PORT_PHYS_OPEN) | 798 | if (status & ZFCP_STATUS_PORT_PHYS_OPEN) |
799 | return ZFCP_ERP_SUCCEEDED; | 799 | return ZFCP_ERP_SUCCEEDED; |
800 | } | 800 | } |
801 | return ZFCP_ERP_FAILED; | 801 | return ZFCP_ERP_FAILED; |
802 | } | 802 | } |
803 | 803 | ||
804 | static int zfcp_erp_port_strategy_close(struct zfcp_erp_action *erp_action) | 804 | static int zfcp_erp_port_strategy_close(struct zfcp_erp_action *erp_action) |
805 | { | 805 | { |
806 | int retval; | 806 | int retval; |
807 | 807 | ||
808 | retval = zfcp_fsf_close_port(erp_action); | 808 | retval = zfcp_fsf_close_port(erp_action); |
809 | if (retval == -ENOMEM) | 809 | if (retval == -ENOMEM) |
810 | return ZFCP_ERP_NOMEM; | 810 | return ZFCP_ERP_NOMEM; |
811 | erp_action->step = ZFCP_ERP_STEP_PORT_CLOSING; | 811 | erp_action->step = ZFCP_ERP_STEP_PORT_CLOSING; |
812 | if (retval) | 812 | if (retval) |
813 | return ZFCP_ERP_FAILED; | 813 | return ZFCP_ERP_FAILED; |
814 | return ZFCP_ERP_CONTINUES; | 814 | return ZFCP_ERP_CONTINUES; |
815 | } | 815 | } |
816 | 816 | ||
817 | static int zfcp_erp_port_strategy_open_port(struct zfcp_erp_action *erp_action) | 817 | static int zfcp_erp_port_strategy_open_port(struct zfcp_erp_action *erp_action) |
818 | { | 818 | { |
819 | int retval; | 819 | int retval; |
820 | 820 | ||
821 | retval = zfcp_fsf_open_port(erp_action); | 821 | retval = zfcp_fsf_open_port(erp_action); |
822 | if (retval == -ENOMEM) | 822 | if (retval == -ENOMEM) |
823 | return ZFCP_ERP_NOMEM; | 823 | return ZFCP_ERP_NOMEM; |
824 | erp_action->step = ZFCP_ERP_STEP_PORT_OPENING; | 824 | erp_action->step = ZFCP_ERP_STEP_PORT_OPENING; |
825 | if (retval) | 825 | if (retval) |
826 | return ZFCP_ERP_FAILED; | 826 | return ZFCP_ERP_FAILED; |
827 | return ZFCP_ERP_CONTINUES; | 827 | return ZFCP_ERP_CONTINUES; |
828 | } | 828 | } |
829 | 829 | ||
830 | static int zfcp_erp_open_ptp_port(struct zfcp_erp_action *act) | 830 | static int zfcp_erp_open_ptp_port(struct zfcp_erp_action *act) |
831 | { | 831 | { |
832 | struct zfcp_adapter *adapter = act->adapter; | 832 | struct zfcp_adapter *adapter = act->adapter; |
833 | struct zfcp_port *port = act->port; | 833 | struct zfcp_port *port = act->port; |
834 | 834 | ||
835 | if (port->wwpn != adapter->peer_wwpn) { | 835 | if (port->wwpn != adapter->peer_wwpn) { |
836 | zfcp_erp_port_failed(port, 25, NULL); | 836 | zfcp_erp_port_failed(port, 25, NULL); |
837 | return ZFCP_ERP_FAILED; | 837 | return ZFCP_ERP_FAILED; |
838 | } | 838 | } |
839 | port->d_id = adapter->peer_d_id; | 839 | port->d_id = adapter->peer_d_id; |
840 | return zfcp_erp_port_strategy_open_port(act); | 840 | return zfcp_erp_port_strategy_open_port(act); |
841 | } | 841 | } |
842 | 842 | ||
843 | void zfcp_erp_port_strategy_open_lookup(struct work_struct *work) | 843 | void zfcp_erp_port_strategy_open_lookup(struct work_struct *work) |
844 | { | 844 | { |
845 | int retval; | 845 | int retval; |
846 | struct zfcp_port *port = container_of(work, struct zfcp_port, | 846 | struct zfcp_port *port = container_of(work, struct zfcp_port, |
847 | gid_pn_work); | 847 | gid_pn_work); |
848 | 848 | ||
849 | retval = zfcp_fc_ns_gid_pn(&port->erp_action); | 849 | retval = zfcp_fc_ns_gid_pn(&port->erp_action); |
850 | if (retval == -ENOMEM) | 850 | if (retval == -ENOMEM) |
851 | zfcp_erp_notify(&port->erp_action, ZFCP_ERP_NOMEM); | 851 | zfcp_erp_notify(&port->erp_action, ZFCP_ERP_NOMEM); |
852 | port->erp_action.step = ZFCP_ERP_STEP_NAMESERVER_LOOKUP; | 852 | port->erp_action.step = ZFCP_ERP_STEP_NAMESERVER_LOOKUP; |
853 | if (retval) | 853 | if (retval) |
854 | zfcp_erp_notify(&port->erp_action, ZFCP_ERP_FAILED); | 854 | zfcp_erp_notify(&port->erp_action, ZFCP_ERP_FAILED); |
855 | 855 | ||
856 | } | 856 | } |
857 | 857 | ||
858 | static int zfcp_erp_port_strategy_open_common(struct zfcp_erp_action *act) | 858 | static int zfcp_erp_port_strategy_open_common(struct zfcp_erp_action *act) |
859 | { | 859 | { |
860 | struct zfcp_adapter *adapter = act->adapter; | 860 | struct zfcp_adapter *adapter = act->adapter; |
861 | struct zfcp_port *port = act->port; | 861 | struct zfcp_port *port = act->port; |
862 | int p_status = atomic_read(&port->status); | 862 | int p_status = atomic_read(&port->status); |
863 | 863 | ||
864 | switch (act->step) { | 864 | switch (act->step) { |
865 | case ZFCP_ERP_STEP_UNINITIALIZED: | 865 | case ZFCP_ERP_STEP_UNINITIALIZED: |
866 | case ZFCP_ERP_STEP_PHYS_PORT_CLOSING: | 866 | case ZFCP_ERP_STEP_PHYS_PORT_CLOSING: |
867 | case ZFCP_ERP_STEP_PORT_CLOSING: | 867 | case ZFCP_ERP_STEP_PORT_CLOSING: |
868 | if (fc_host_port_type(adapter->scsi_host) == FC_PORTTYPE_PTP) | 868 | if (fc_host_port_type(adapter->scsi_host) == FC_PORTTYPE_PTP) |
869 | return zfcp_erp_open_ptp_port(act); | 869 | return zfcp_erp_open_ptp_port(act); |
870 | if (!port->d_id) { | 870 | if (!port->d_id) { |
871 | queue_work(zfcp_data.work_queue, &port->gid_pn_work); | 871 | queue_work(zfcp_data.work_queue, &port->gid_pn_work); |
872 | return ZFCP_ERP_CONTINUES; | 872 | return ZFCP_ERP_CONTINUES; |
873 | } | 873 | } |
874 | case ZFCP_ERP_STEP_NAMESERVER_LOOKUP: | 874 | case ZFCP_ERP_STEP_NAMESERVER_LOOKUP: |
875 | if (!port->d_id) | 875 | if (!port->d_id) |
876 | return ZFCP_ERP_FAILED; | 876 | return ZFCP_ERP_FAILED; |
877 | return zfcp_erp_port_strategy_open_port(act); | 877 | return zfcp_erp_port_strategy_open_port(act); |
878 | 878 | ||
879 | case ZFCP_ERP_STEP_PORT_OPENING: | 879 | case ZFCP_ERP_STEP_PORT_OPENING: |
880 | /* D_ID might have changed during open */ | 880 | /* D_ID might have changed during open */ |
881 | if (p_status & ZFCP_STATUS_COMMON_OPEN) { | 881 | if (p_status & ZFCP_STATUS_COMMON_OPEN) { |
882 | if (port->d_id) | 882 | if (port->d_id) |
883 | return ZFCP_ERP_SUCCEEDED; | 883 | return ZFCP_ERP_SUCCEEDED; |
884 | else { | 884 | else { |
885 | act->step = ZFCP_ERP_STEP_PORT_CLOSING; | 885 | act->step = ZFCP_ERP_STEP_PORT_CLOSING; |
886 | return ZFCP_ERP_CONTINUES; | 886 | return ZFCP_ERP_CONTINUES; |
887 | } | 887 | } |
888 | /* fall through otherwise */ | 888 | /* fall through otherwise */ |
889 | } | 889 | } |
890 | } | 890 | } |
891 | return ZFCP_ERP_FAILED; | 891 | return ZFCP_ERP_FAILED; |
892 | } | 892 | } |
893 | 893 | ||
894 | static int zfcp_erp_port_strategy(struct zfcp_erp_action *erp_action) | 894 | static int zfcp_erp_port_strategy(struct zfcp_erp_action *erp_action) |
895 | { | 895 | { |
896 | struct zfcp_port *port = erp_action->port; | 896 | struct zfcp_port *port = erp_action->port; |
897 | 897 | ||
898 | if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_NOESC) | 898 | if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_NOESC) |
899 | goto close_init_done; | 899 | goto close_init_done; |
900 | 900 | ||
901 | switch (erp_action->step) { | 901 | switch (erp_action->step) { |
902 | case ZFCP_ERP_STEP_UNINITIALIZED: | 902 | case ZFCP_ERP_STEP_UNINITIALIZED: |
903 | zfcp_erp_port_strategy_clearstati(port); | 903 | zfcp_erp_port_strategy_clearstati(port); |
904 | if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_OPEN) | 904 | if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_OPEN) |
905 | return zfcp_erp_port_strategy_close(erp_action); | 905 | return zfcp_erp_port_strategy_close(erp_action); |
906 | break; | 906 | break; |
907 | 907 | ||
908 | case ZFCP_ERP_STEP_PORT_CLOSING: | 908 | case ZFCP_ERP_STEP_PORT_CLOSING: |
909 | if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_OPEN) | 909 | if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_OPEN) |
910 | return ZFCP_ERP_FAILED; | 910 | return ZFCP_ERP_FAILED; |
911 | break; | 911 | break; |
912 | } | 912 | } |
913 | 913 | ||
914 | close_init_done: | 914 | close_init_done: |
915 | if (erp_action->status & ZFCP_STATUS_ERP_CLOSE_ONLY) | 915 | if (erp_action->status & ZFCP_STATUS_ERP_CLOSE_ONLY) |
916 | return ZFCP_ERP_EXIT; | 916 | return ZFCP_ERP_EXIT; |
917 | 917 | ||
918 | return zfcp_erp_port_strategy_open_common(erp_action); | 918 | return zfcp_erp_port_strategy_open_common(erp_action); |
919 | } | 919 | } |
920 | 920 | ||
921 | static void zfcp_erp_unit_strategy_clearstati(struct zfcp_unit *unit) | 921 | static void zfcp_erp_unit_strategy_clearstati(struct zfcp_unit *unit) |
922 | { | 922 | { |
923 | atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED | | 923 | atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED | |
924 | ZFCP_STATUS_UNIT_SHARED | | 924 | ZFCP_STATUS_UNIT_SHARED | |
925 | ZFCP_STATUS_UNIT_READONLY, | 925 | ZFCP_STATUS_UNIT_READONLY, |
926 | &unit->status); | 926 | &unit->status); |
927 | } | 927 | } |
928 | 928 | ||
929 | static int zfcp_erp_unit_strategy_close(struct zfcp_erp_action *erp_action) | 929 | static int zfcp_erp_unit_strategy_close(struct zfcp_erp_action *erp_action) |
930 | { | 930 | { |
931 | int retval = zfcp_fsf_close_unit(erp_action); | 931 | int retval = zfcp_fsf_close_unit(erp_action); |
932 | if (retval == -ENOMEM) | 932 | if (retval == -ENOMEM) |
933 | return ZFCP_ERP_NOMEM; | 933 | return ZFCP_ERP_NOMEM; |
934 | erp_action->step = ZFCP_ERP_STEP_UNIT_CLOSING; | 934 | erp_action->step = ZFCP_ERP_STEP_UNIT_CLOSING; |
935 | if (retval) | 935 | if (retval) |
936 | return ZFCP_ERP_FAILED; | 936 | return ZFCP_ERP_FAILED; |
937 | return ZFCP_ERP_CONTINUES; | 937 | return ZFCP_ERP_CONTINUES; |
938 | } | 938 | } |
939 | 939 | ||
940 | static int zfcp_erp_unit_strategy_open(struct zfcp_erp_action *erp_action) | 940 | static int zfcp_erp_unit_strategy_open(struct zfcp_erp_action *erp_action) |
941 | { | 941 | { |
942 | int retval = zfcp_fsf_open_unit(erp_action); | 942 | int retval = zfcp_fsf_open_unit(erp_action); |
943 | if (retval == -ENOMEM) | 943 | if (retval == -ENOMEM) |
944 | return ZFCP_ERP_NOMEM; | 944 | return ZFCP_ERP_NOMEM; |
945 | erp_action->step = ZFCP_ERP_STEP_UNIT_OPENING; | 945 | erp_action->step = ZFCP_ERP_STEP_UNIT_OPENING; |
946 | if (retval) | 946 | if (retval) |
947 | return ZFCP_ERP_FAILED; | 947 | return ZFCP_ERP_FAILED; |
948 | return ZFCP_ERP_CONTINUES; | 948 | return ZFCP_ERP_CONTINUES; |
949 | } | 949 | } |
950 | 950 | ||
951 | static int zfcp_erp_unit_strategy(struct zfcp_erp_action *erp_action) | 951 | static int zfcp_erp_unit_strategy(struct zfcp_erp_action *erp_action) |
952 | { | 952 | { |
953 | struct zfcp_unit *unit = erp_action->unit; | 953 | struct zfcp_unit *unit = erp_action->unit; |
954 | 954 | ||
955 | switch (erp_action->step) { | 955 | switch (erp_action->step) { |
956 | case ZFCP_ERP_STEP_UNINITIALIZED: | 956 | case ZFCP_ERP_STEP_UNINITIALIZED: |
957 | zfcp_erp_unit_strategy_clearstati(unit); | 957 | zfcp_erp_unit_strategy_clearstati(unit); |
958 | if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_OPEN) | 958 | if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_OPEN) |
959 | return zfcp_erp_unit_strategy_close(erp_action); | 959 | return zfcp_erp_unit_strategy_close(erp_action); |
960 | /* already closed, fall through */ | 960 | /* already closed, fall through */ |
961 | case ZFCP_ERP_STEP_UNIT_CLOSING: | 961 | case ZFCP_ERP_STEP_UNIT_CLOSING: |
962 | if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_OPEN) | 962 | if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_OPEN) |
963 | return ZFCP_ERP_FAILED; | 963 | return ZFCP_ERP_FAILED; |
964 | if (erp_action->status & ZFCP_STATUS_ERP_CLOSE_ONLY) | 964 | if (erp_action->status & ZFCP_STATUS_ERP_CLOSE_ONLY) |
965 | return ZFCP_ERP_EXIT; | 965 | return ZFCP_ERP_EXIT; |
966 | return zfcp_erp_unit_strategy_open(erp_action); | 966 | return zfcp_erp_unit_strategy_open(erp_action); |
967 | 967 | ||
968 | case ZFCP_ERP_STEP_UNIT_OPENING: | 968 | case ZFCP_ERP_STEP_UNIT_OPENING: |
969 | if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_OPEN) | 969 | if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_OPEN) |
970 | return ZFCP_ERP_SUCCEEDED; | 970 | return ZFCP_ERP_SUCCEEDED; |
971 | } | 971 | } |
972 | return ZFCP_ERP_FAILED; | 972 | return ZFCP_ERP_FAILED; |
973 | } | 973 | } |
974 | 974 | ||
975 | static int zfcp_erp_strategy_check_unit(struct zfcp_unit *unit, int result) | 975 | static int zfcp_erp_strategy_check_unit(struct zfcp_unit *unit, int result) |
976 | { | 976 | { |
977 | switch (result) { | 977 | switch (result) { |
978 | case ZFCP_ERP_SUCCEEDED : | 978 | case ZFCP_ERP_SUCCEEDED : |
979 | atomic_set(&unit->erp_counter, 0); | 979 | atomic_set(&unit->erp_counter, 0); |
980 | zfcp_erp_unit_unblock(unit); | 980 | zfcp_erp_unit_unblock(unit); |
981 | break; | 981 | break; |
982 | case ZFCP_ERP_FAILED : | 982 | case ZFCP_ERP_FAILED : |
983 | atomic_inc(&unit->erp_counter); | 983 | atomic_inc(&unit->erp_counter); |
984 | if (atomic_read(&unit->erp_counter) > ZFCP_MAX_ERPS) { | 984 | if (atomic_read(&unit->erp_counter) > ZFCP_MAX_ERPS) { |
985 | dev_err(&unit->port->adapter->ccw_device->dev, | 985 | dev_err(&unit->port->adapter->ccw_device->dev, |
986 | "ERP failed for unit 0x%016Lx on " | 986 | "ERP failed for unit 0x%016Lx on " |
987 | "port 0x%016Lx\n", | 987 | "port 0x%016Lx\n", |
988 | (unsigned long long)unit->fcp_lun, | 988 | (unsigned long long)unit->fcp_lun, |
989 | (unsigned long long)unit->port->wwpn); | 989 | (unsigned long long)unit->port->wwpn); |
990 | zfcp_erp_unit_failed(unit, 21, NULL); | 990 | zfcp_erp_unit_failed(unit, 21, NULL); |
991 | } | 991 | } |
992 | break; | 992 | break; |
993 | } | 993 | } |
994 | 994 | ||
995 | if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_ERP_FAILED) { | 995 | if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_ERP_FAILED) { |
996 | zfcp_erp_unit_block(unit, 0); | 996 | zfcp_erp_unit_block(unit, 0); |
997 | result = ZFCP_ERP_EXIT; | 997 | result = ZFCP_ERP_EXIT; |
998 | } | 998 | } |
999 | return result; | 999 | return result; |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | static int zfcp_erp_strategy_check_port(struct zfcp_port *port, int result) | 1002 | static int zfcp_erp_strategy_check_port(struct zfcp_port *port, int result) |
1003 | { | 1003 | { |
1004 | switch (result) { | 1004 | switch (result) { |
1005 | case ZFCP_ERP_SUCCEEDED : | 1005 | case ZFCP_ERP_SUCCEEDED : |
1006 | atomic_set(&port->erp_counter, 0); | 1006 | atomic_set(&port->erp_counter, 0); |
1007 | zfcp_erp_port_unblock(port); | 1007 | zfcp_erp_port_unblock(port); |
1008 | break; | 1008 | break; |
1009 | 1009 | ||
1010 | case ZFCP_ERP_FAILED : | 1010 | case ZFCP_ERP_FAILED : |
1011 | if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_NOESC) { | 1011 | if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_NOESC) { |
1012 | zfcp_erp_port_block(port, 0); | 1012 | zfcp_erp_port_block(port, 0); |
1013 | result = ZFCP_ERP_EXIT; | 1013 | result = ZFCP_ERP_EXIT; |
1014 | } | 1014 | } |
1015 | atomic_inc(&port->erp_counter); | 1015 | atomic_inc(&port->erp_counter); |
1016 | if (atomic_read(&port->erp_counter) > ZFCP_MAX_ERPS) { | 1016 | if (atomic_read(&port->erp_counter) > ZFCP_MAX_ERPS) { |
1017 | dev_err(&port->adapter->ccw_device->dev, | 1017 | dev_err(&port->adapter->ccw_device->dev, |
1018 | "ERP failed for remote port 0x%016Lx\n", | 1018 | "ERP failed for remote port 0x%016Lx\n", |
1019 | (unsigned long long)port->wwpn); | 1019 | (unsigned long long)port->wwpn); |
1020 | zfcp_erp_port_failed(port, 22, NULL); | 1020 | zfcp_erp_port_failed(port, 22, NULL); |
1021 | } | 1021 | } |
1022 | break; | 1022 | break; |
1023 | } | 1023 | } |
1024 | 1024 | ||
1025 | if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED) { | 1025 | if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED) { |
1026 | zfcp_erp_port_block(port, 0); | 1026 | zfcp_erp_port_block(port, 0); |
1027 | result = ZFCP_ERP_EXIT; | 1027 | result = ZFCP_ERP_EXIT; |
1028 | } | 1028 | } |
1029 | return result; | 1029 | return result; |
1030 | } | 1030 | } |
1031 | 1031 | ||
1032 | static int zfcp_erp_strategy_check_adapter(struct zfcp_adapter *adapter, | 1032 | static int zfcp_erp_strategy_check_adapter(struct zfcp_adapter *adapter, |
1033 | int result) | 1033 | int result) |
1034 | { | 1034 | { |
1035 | switch (result) { | 1035 | switch (result) { |
1036 | case ZFCP_ERP_SUCCEEDED : | 1036 | case ZFCP_ERP_SUCCEEDED : |
1037 | atomic_set(&adapter->erp_counter, 0); | 1037 | atomic_set(&adapter->erp_counter, 0); |
1038 | zfcp_erp_adapter_unblock(adapter); | 1038 | zfcp_erp_adapter_unblock(adapter); |
1039 | break; | 1039 | break; |
1040 | 1040 | ||
1041 | case ZFCP_ERP_FAILED : | 1041 | case ZFCP_ERP_FAILED : |
1042 | atomic_inc(&adapter->erp_counter); | 1042 | atomic_inc(&adapter->erp_counter); |
1043 | if (atomic_read(&adapter->erp_counter) > ZFCP_MAX_ERPS) { | 1043 | if (atomic_read(&adapter->erp_counter) > ZFCP_MAX_ERPS) { |
1044 | dev_err(&adapter->ccw_device->dev, | 1044 | dev_err(&adapter->ccw_device->dev, |
1045 | "ERP cannot recover an error " | 1045 | "ERP cannot recover an error " |
1046 | "on the FCP device\n"); | 1046 | "on the FCP device\n"); |
1047 | zfcp_erp_adapter_failed(adapter, 23, NULL); | 1047 | zfcp_erp_adapter_failed(adapter, 23, NULL); |
1048 | } | 1048 | } |
1049 | break; | 1049 | break; |
1050 | } | 1050 | } |
1051 | 1051 | ||
1052 | if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_ERP_FAILED) { | 1052 | if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_ERP_FAILED) { |
1053 | zfcp_erp_adapter_block(adapter, 0); | 1053 | zfcp_erp_adapter_block(adapter, 0); |
1054 | result = ZFCP_ERP_EXIT; | 1054 | result = ZFCP_ERP_EXIT; |
1055 | } | 1055 | } |
1056 | return result; | 1056 | return result; |
1057 | } | 1057 | } |
1058 | 1058 | ||
1059 | static int zfcp_erp_strategy_check_target(struct zfcp_erp_action *erp_action, | 1059 | static int zfcp_erp_strategy_check_target(struct zfcp_erp_action *erp_action, |
1060 | int result) | 1060 | int result) |
1061 | { | 1061 | { |
1062 | struct zfcp_adapter *adapter = erp_action->adapter; | 1062 | struct zfcp_adapter *adapter = erp_action->adapter; |
1063 | struct zfcp_port *port = erp_action->port; | 1063 | struct zfcp_port *port = erp_action->port; |
1064 | struct zfcp_unit *unit = erp_action->unit; | 1064 | struct zfcp_unit *unit = erp_action->unit; |
1065 | 1065 | ||
1066 | switch (erp_action->action) { | 1066 | switch (erp_action->action) { |
1067 | 1067 | ||
1068 | case ZFCP_ERP_ACTION_REOPEN_UNIT: | 1068 | case ZFCP_ERP_ACTION_REOPEN_UNIT: |
1069 | result = zfcp_erp_strategy_check_unit(unit, result); | 1069 | result = zfcp_erp_strategy_check_unit(unit, result); |
1070 | break; | 1070 | break; |
1071 | 1071 | ||
1072 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: | 1072 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: |
1073 | case ZFCP_ERP_ACTION_REOPEN_PORT: | 1073 | case ZFCP_ERP_ACTION_REOPEN_PORT: |
1074 | result = zfcp_erp_strategy_check_port(port, result); | 1074 | result = zfcp_erp_strategy_check_port(port, result); |
1075 | break; | 1075 | break; |
1076 | 1076 | ||
1077 | case ZFCP_ERP_ACTION_REOPEN_ADAPTER: | 1077 | case ZFCP_ERP_ACTION_REOPEN_ADAPTER: |
1078 | result = zfcp_erp_strategy_check_adapter(adapter, result); | 1078 | result = zfcp_erp_strategy_check_adapter(adapter, result); |
1079 | break; | 1079 | break; |
1080 | } | 1080 | } |
1081 | return result; | 1081 | return result; |
1082 | } | 1082 | } |
1083 | 1083 | ||
1084 | static int zfcp_erp_strat_change_det(atomic_t *target_status, u32 erp_status) | 1084 | static int zfcp_erp_strat_change_det(atomic_t *target_status, u32 erp_status) |
1085 | { | 1085 | { |
1086 | int status = atomic_read(target_status); | 1086 | int status = atomic_read(target_status); |
1087 | 1087 | ||
1088 | if ((status & ZFCP_STATUS_COMMON_RUNNING) && | 1088 | if ((status & ZFCP_STATUS_COMMON_RUNNING) && |
1089 | (erp_status & ZFCP_STATUS_ERP_CLOSE_ONLY)) | 1089 | (erp_status & ZFCP_STATUS_ERP_CLOSE_ONLY)) |
1090 | return 1; /* take it online */ | 1090 | return 1; /* take it online */ |
1091 | 1091 | ||
1092 | if (!(status & ZFCP_STATUS_COMMON_RUNNING) && | 1092 | if (!(status & ZFCP_STATUS_COMMON_RUNNING) && |
1093 | !(erp_status & ZFCP_STATUS_ERP_CLOSE_ONLY)) | 1093 | !(erp_status & ZFCP_STATUS_ERP_CLOSE_ONLY)) |
1094 | return 1; /* take it offline */ | 1094 | return 1; /* take it offline */ |
1095 | 1095 | ||
1096 | return 0; | 1096 | return 0; |
1097 | } | 1097 | } |
1098 | 1098 | ||
1099 | static int zfcp_erp_strategy_statechange(struct zfcp_erp_action *act, int ret) | 1099 | static int zfcp_erp_strategy_statechange(struct zfcp_erp_action *act, int ret) |
1100 | { | 1100 | { |
1101 | int action = act->action; | 1101 | int action = act->action; |
1102 | struct zfcp_adapter *adapter = act->adapter; | 1102 | struct zfcp_adapter *adapter = act->adapter; |
1103 | struct zfcp_port *port = act->port; | 1103 | struct zfcp_port *port = act->port; |
1104 | struct zfcp_unit *unit = act->unit; | 1104 | struct zfcp_unit *unit = act->unit; |
1105 | u32 erp_status = act->status; | 1105 | u32 erp_status = act->status; |
1106 | 1106 | ||
1107 | switch (action) { | 1107 | switch (action) { |
1108 | case ZFCP_ERP_ACTION_REOPEN_ADAPTER: | 1108 | case ZFCP_ERP_ACTION_REOPEN_ADAPTER: |
1109 | if (zfcp_erp_strat_change_det(&adapter->status, erp_status)) { | 1109 | if (zfcp_erp_strat_change_det(&adapter->status, erp_status)) { |
1110 | _zfcp_erp_adapter_reopen(adapter, | 1110 | _zfcp_erp_adapter_reopen(adapter, |
1111 | ZFCP_STATUS_COMMON_ERP_FAILED, | 1111 | ZFCP_STATUS_COMMON_ERP_FAILED, |
1112 | 67, NULL); | 1112 | 67, NULL); |
1113 | return ZFCP_ERP_EXIT; | 1113 | return ZFCP_ERP_EXIT; |
1114 | } | 1114 | } |
1115 | break; | 1115 | break; |
1116 | 1116 | ||
1117 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: | 1117 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: |
1118 | case ZFCP_ERP_ACTION_REOPEN_PORT: | 1118 | case ZFCP_ERP_ACTION_REOPEN_PORT: |
1119 | if (zfcp_erp_strat_change_det(&port->status, erp_status)) { | 1119 | if (zfcp_erp_strat_change_det(&port->status, erp_status)) { |
1120 | _zfcp_erp_port_reopen(port, | 1120 | _zfcp_erp_port_reopen(port, |
1121 | ZFCP_STATUS_COMMON_ERP_FAILED, | 1121 | ZFCP_STATUS_COMMON_ERP_FAILED, |
1122 | 68, NULL); | 1122 | 68, NULL); |
1123 | return ZFCP_ERP_EXIT; | 1123 | return ZFCP_ERP_EXIT; |
1124 | } | 1124 | } |
1125 | break; | 1125 | break; |
1126 | 1126 | ||
1127 | case ZFCP_ERP_ACTION_REOPEN_UNIT: | 1127 | case ZFCP_ERP_ACTION_REOPEN_UNIT: |
1128 | if (zfcp_erp_strat_change_det(&unit->status, erp_status)) { | 1128 | if (zfcp_erp_strat_change_det(&unit->status, erp_status)) { |
1129 | _zfcp_erp_unit_reopen(unit, | 1129 | _zfcp_erp_unit_reopen(unit, |
1130 | ZFCP_STATUS_COMMON_ERP_FAILED, | 1130 | ZFCP_STATUS_COMMON_ERP_FAILED, |
1131 | 69, NULL); | 1131 | 69, NULL); |
1132 | return ZFCP_ERP_EXIT; | 1132 | return ZFCP_ERP_EXIT; |
1133 | } | 1133 | } |
1134 | break; | 1134 | break; |
1135 | } | 1135 | } |
1136 | return ret; | 1136 | return ret; |
1137 | } | 1137 | } |
1138 | 1138 | ||
1139 | static void zfcp_erp_action_dequeue(struct zfcp_erp_action *erp_action) | 1139 | static void zfcp_erp_action_dequeue(struct zfcp_erp_action *erp_action) |
1140 | { | 1140 | { |
1141 | struct zfcp_adapter *adapter = erp_action->adapter; | 1141 | struct zfcp_adapter *adapter = erp_action->adapter; |
1142 | 1142 | ||
1143 | adapter->erp_total_count--; | 1143 | adapter->erp_total_count--; |
1144 | if (erp_action->status & ZFCP_STATUS_ERP_LOWMEM) { | 1144 | if (erp_action->status & ZFCP_STATUS_ERP_LOWMEM) { |
1145 | adapter->erp_low_mem_count--; | 1145 | adapter->erp_low_mem_count--; |
1146 | erp_action->status &= ~ZFCP_STATUS_ERP_LOWMEM; | 1146 | erp_action->status &= ~ZFCP_STATUS_ERP_LOWMEM; |
1147 | } | 1147 | } |
1148 | 1148 | ||
1149 | list_del(&erp_action->list); | 1149 | list_del(&erp_action->list); |
1150 | zfcp_rec_dbf_event_action(144, erp_action); | 1150 | zfcp_rec_dbf_event_action(144, erp_action); |
1151 | 1151 | ||
1152 | switch (erp_action->action) { | 1152 | switch (erp_action->action) { |
1153 | case ZFCP_ERP_ACTION_REOPEN_UNIT: | 1153 | case ZFCP_ERP_ACTION_REOPEN_UNIT: |
1154 | atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE, | 1154 | atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE, |
1155 | &erp_action->unit->status); | 1155 | &erp_action->unit->status); |
1156 | break; | 1156 | break; |
1157 | 1157 | ||
1158 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: | 1158 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: |
1159 | case ZFCP_ERP_ACTION_REOPEN_PORT: | 1159 | case ZFCP_ERP_ACTION_REOPEN_PORT: |
1160 | atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE, | 1160 | atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE, |
1161 | &erp_action->port->status); | 1161 | &erp_action->port->status); |
1162 | break; | 1162 | break; |
1163 | 1163 | ||
1164 | case ZFCP_ERP_ACTION_REOPEN_ADAPTER: | 1164 | case ZFCP_ERP_ACTION_REOPEN_ADAPTER: |
1165 | atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE, | 1165 | atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE, |
1166 | &erp_action->adapter->status); | 1166 | &erp_action->adapter->status); |
1167 | break; | 1167 | break; |
1168 | } | 1168 | } |
1169 | } | 1169 | } |
1170 | 1170 | ||
1171 | struct zfcp_erp_add_work { | 1171 | struct zfcp_erp_add_work { |
1172 | struct zfcp_unit *unit; | 1172 | struct zfcp_unit *unit; |
1173 | struct work_struct work; | 1173 | struct work_struct work; |
1174 | }; | 1174 | }; |
1175 | 1175 | ||
1176 | static void zfcp_erp_scsi_scan(struct work_struct *work) | 1176 | static void zfcp_erp_scsi_scan(struct work_struct *work) |
1177 | { | 1177 | { |
1178 | struct zfcp_erp_add_work *p = | 1178 | struct zfcp_erp_add_work *p = |
1179 | container_of(work, struct zfcp_erp_add_work, work); | 1179 | container_of(work, struct zfcp_erp_add_work, work); |
1180 | struct zfcp_unit *unit = p->unit; | 1180 | struct zfcp_unit *unit = p->unit; |
1181 | struct fc_rport *rport = unit->port->rport; | 1181 | struct fc_rport *rport = unit->port->rport; |
1182 | 1182 | ||
1183 | if (rport && rport->port_state == FC_PORTSTATE_ONLINE) | 1183 | if (rport && rport->port_state == FC_PORTSTATE_ONLINE) |
1184 | scsi_scan_target(&rport->dev, 0, rport->scsi_target_id, | 1184 | scsi_scan_target(&rport->dev, 0, rport->scsi_target_id, |
1185 | scsilun_to_int((struct scsi_lun *)&unit->fcp_lun), 0); | 1185 | scsilun_to_int((struct scsi_lun *)&unit->fcp_lun), 0); |
1186 | atomic_clear_mask(ZFCP_STATUS_UNIT_SCSI_WORK_PENDING, &unit->status); | 1186 | atomic_clear_mask(ZFCP_STATUS_UNIT_SCSI_WORK_PENDING, &unit->status); |
1187 | zfcp_unit_put(unit); | 1187 | zfcp_unit_put(unit); |
1188 | wake_up(&unit->port->adapter->erp_done_wqh); | 1188 | wake_up(&unit->port->adapter->erp_done_wqh); |
1189 | kfree(p); | 1189 | kfree(p); |
1190 | } | 1190 | } |
1191 | 1191 | ||
1192 | static void zfcp_erp_schedule_work(struct zfcp_unit *unit) | 1192 | static void zfcp_erp_schedule_work(struct zfcp_unit *unit) |
1193 | { | 1193 | { |
1194 | struct zfcp_erp_add_work *p; | 1194 | struct zfcp_erp_add_work *p; |
1195 | 1195 | ||
1196 | p = kzalloc(sizeof(*p), GFP_KERNEL); | 1196 | p = kzalloc(sizeof(*p), GFP_KERNEL); |
1197 | if (!p) { | 1197 | if (!p) { |
1198 | dev_err(&unit->port->adapter->ccw_device->dev, | 1198 | dev_err(&unit->port->adapter->ccw_device->dev, |
1199 | "Registering unit 0x%016Lx on port 0x%016Lx failed\n", | 1199 | "Registering unit 0x%016Lx on port 0x%016Lx failed\n", |
1200 | (unsigned long long)unit->fcp_lun, | 1200 | (unsigned long long)unit->fcp_lun, |
1201 | (unsigned long long)unit->port->wwpn); | 1201 | (unsigned long long)unit->port->wwpn); |
1202 | return; | 1202 | return; |
1203 | } | 1203 | } |
1204 | 1204 | ||
1205 | zfcp_unit_get(unit); | 1205 | zfcp_unit_get(unit); |
1206 | atomic_set_mask(ZFCP_STATUS_UNIT_SCSI_WORK_PENDING, &unit->status); | 1206 | atomic_set_mask(ZFCP_STATUS_UNIT_SCSI_WORK_PENDING, &unit->status); |
1207 | INIT_WORK(&p->work, zfcp_erp_scsi_scan); | 1207 | INIT_WORK(&p->work, zfcp_erp_scsi_scan); |
1208 | p->unit = unit; | 1208 | p->unit = unit; |
1209 | queue_work(zfcp_data.work_queue, &p->work); | 1209 | queue_work(zfcp_data.work_queue, &p->work); |
1210 | } | 1210 | } |
1211 | 1211 | ||
1212 | static void zfcp_erp_rport_register(struct zfcp_port *port) | 1212 | static void zfcp_erp_rport_register(struct zfcp_port *port) |
1213 | { | 1213 | { |
1214 | struct fc_rport_identifiers ids; | 1214 | struct fc_rport_identifiers ids; |
1215 | ids.node_name = port->wwnn; | 1215 | ids.node_name = port->wwnn; |
1216 | ids.port_name = port->wwpn; | 1216 | ids.port_name = port->wwpn; |
1217 | ids.port_id = port->d_id; | 1217 | ids.port_id = port->d_id; |
1218 | ids.roles = FC_RPORT_ROLE_FCP_TARGET; | 1218 | ids.roles = FC_RPORT_ROLE_FCP_TARGET; |
1219 | port->rport = fc_remote_port_add(port->adapter->scsi_host, 0, &ids); | 1219 | port->rport = fc_remote_port_add(port->adapter->scsi_host, 0, &ids); |
1220 | if (!port->rport) { | 1220 | if (!port->rport) { |
1221 | dev_err(&port->adapter->ccw_device->dev, | 1221 | dev_err(&port->adapter->ccw_device->dev, |
1222 | "Registering port 0x%016Lx failed\n", | 1222 | "Registering port 0x%016Lx failed\n", |
1223 | (unsigned long long)port->wwpn); | 1223 | (unsigned long long)port->wwpn); |
1224 | return; | 1224 | return; |
1225 | } | 1225 | } |
1226 | 1226 | ||
1227 | scsi_target_unblock(&port->rport->dev); | 1227 | scsi_target_unblock(&port->rport->dev); |
1228 | port->rport->maxframe_size = port->maxframe_size; | 1228 | port->rport->maxframe_size = port->maxframe_size; |
1229 | port->rport->supported_classes = port->supported_classes; | 1229 | port->rport->supported_classes = port->supported_classes; |
1230 | } | 1230 | } |
1231 | 1231 | ||
1232 | static void zfcp_erp_rports_del(struct zfcp_adapter *adapter) | 1232 | static void zfcp_erp_rports_del(struct zfcp_adapter *adapter) |
1233 | { | 1233 | { |
1234 | struct zfcp_port *port; | 1234 | struct zfcp_port *port; |
1235 | list_for_each_entry(port, &adapter->port_list_head, list) { | 1235 | list_for_each_entry(port, &adapter->port_list_head, list) { |
1236 | if (!port->rport) | 1236 | if (!port->rport) |
1237 | continue; | 1237 | continue; |
1238 | fc_remote_port_delete(port->rport); | 1238 | fc_remote_port_delete(port->rport); |
1239 | port->rport = NULL; | 1239 | port->rport = NULL; |
1240 | } | 1240 | } |
1241 | } | 1241 | } |
1242 | 1242 | ||
1243 | static void zfcp_erp_action_cleanup(struct zfcp_erp_action *act, int result) | 1243 | static void zfcp_erp_action_cleanup(struct zfcp_erp_action *act, int result) |
1244 | { | 1244 | { |
1245 | struct zfcp_adapter *adapter = act->adapter; | 1245 | struct zfcp_adapter *adapter = act->adapter; |
1246 | struct zfcp_port *port = act->port; | 1246 | struct zfcp_port *port = act->port; |
1247 | struct zfcp_unit *unit = act->unit; | 1247 | struct zfcp_unit *unit = act->unit; |
1248 | 1248 | ||
1249 | switch (act->action) { | 1249 | switch (act->action) { |
1250 | case ZFCP_ERP_ACTION_REOPEN_UNIT: | 1250 | case ZFCP_ERP_ACTION_REOPEN_UNIT: |
1251 | if ((result == ZFCP_ERP_SUCCEEDED) && | 1251 | if ((result == ZFCP_ERP_SUCCEEDED) && |
1252 | !unit->device && port->rport) { | 1252 | !unit->device && port->rport) { |
1253 | atomic_set_mask(ZFCP_STATUS_UNIT_REGISTERED, | ||
1254 | &unit->status); | ||
1255 | if (!(atomic_read(&unit->status) & | 1253 | if (!(atomic_read(&unit->status) & |
1256 | ZFCP_STATUS_UNIT_SCSI_WORK_PENDING)) | 1254 | ZFCP_STATUS_UNIT_SCSI_WORK_PENDING)) |
1257 | zfcp_erp_schedule_work(unit); | 1255 | zfcp_erp_schedule_work(unit); |
1258 | } | 1256 | } |
1259 | zfcp_unit_put(unit); | 1257 | zfcp_unit_put(unit); |
1260 | break; | 1258 | break; |
1261 | 1259 | ||
1262 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: | 1260 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: |
1263 | case ZFCP_ERP_ACTION_REOPEN_PORT: | 1261 | case ZFCP_ERP_ACTION_REOPEN_PORT: |
1264 | if ((result == ZFCP_ERP_SUCCEEDED) && !port->rport) | 1262 | if ((result == ZFCP_ERP_SUCCEEDED) && !port->rport) |
1265 | zfcp_erp_rport_register(port); | 1263 | zfcp_erp_rport_register(port); |
1266 | if ((result != ZFCP_ERP_SUCCEEDED) && port->rport) { | 1264 | if ((result != ZFCP_ERP_SUCCEEDED) && port->rport) { |
1267 | fc_remote_port_delete(port->rport); | 1265 | fc_remote_port_delete(port->rport); |
1268 | port->rport = NULL; | 1266 | port->rport = NULL; |
1269 | } | 1267 | } |
1270 | zfcp_port_put(port); | 1268 | zfcp_port_put(port); |
1271 | break; | 1269 | break; |
1272 | 1270 | ||
1273 | case ZFCP_ERP_ACTION_REOPEN_ADAPTER: | 1271 | case ZFCP_ERP_ACTION_REOPEN_ADAPTER: |
1274 | if (result != ZFCP_ERP_SUCCEEDED) { | 1272 | if (result != ZFCP_ERP_SUCCEEDED) { |
1275 | unregister_service_level(&adapter->service_level); | 1273 | unregister_service_level(&adapter->service_level); |
1276 | zfcp_erp_rports_del(adapter); | 1274 | zfcp_erp_rports_del(adapter); |
1277 | } else { | 1275 | } else { |
1278 | register_service_level(&adapter->service_level); | 1276 | register_service_level(&adapter->service_level); |
1279 | schedule_work(&adapter->scan_work); | 1277 | schedule_work(&adapter->scan_work); |
1280 | } | 1278 | } |
1281 | zfcp_adapter_put(adapter); | 1279 | zfcp_adapter_put(adapter); |
1282 | break; | 1280 | break; |
1283 | } | 1281 | } |
1284 | } | 1282 | } |
1285 | 1283 | ||
1286 | static int zfcp_erp_strategy_do_action(struct zfcp_erp_action *erp_action) | 1284 | static int zfcp_erp_strategy_do_action(struct zfcp_erp_action *erp_action) |
1287 | { | 1285 | { |
1288 | switch (erp_action->action) { | 1286 | switch (erp_action->action) { |
1289 | case ZFCP_ERP_ACTION_REOPEN_ADAPTER: | 1287 | case ZFCP_ERP_ACTION_REOPEN_ADAPTER: |
1290 | return zfcp_erp_adapter_strategy(erp_action); | 1288 | return zfcp_erp_adapter_strategy(erp_action); |
1291 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: | 1289 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: |
1292 | return zfcp_erp_port_forced_strategy(erp_action); | 1290 | return zfcp_erp_port_forced_strategy(erp_action); |
1293 | case ZFCP_ERP_ACTION_REOPEN_PORT: | 1291 | case ZFCP_ERP_ACTION_REOPEN_PORT: |
1294 | return zfcp_erp_port_strategy(erp_action); | 1292 | return zfcp_erp_port_strategy(erp_action); |
1295 | case ZFCP_ERP_ACTION_REOPEN_UNIT: | 1293 | case ZFCP_ERP_ACTION_REOPEN_UNIT: |
1296 | return zfcp_erp_unit_strategy(erp_action); | 1294 | return zfcp_erp_unit_strategy(erp_action); |
1297 | } | 1295 | } |
1298 | return ZFCP_ERP_FAILED; | 1296 | return ZFCP_ERP_FAILED; |
1299 | } | 1297 | } |
1300 | 1298 | ||
1301 | static int zfcp_erp_strategy(struct zfcp_erp_action *erp_action) | 1299 | static int zfcp_erp_strategy(struct zfcp_erp_action *erp_action) |
1302 | { | 1300 | { |
1303 | int retval; | 1301 | int retval; |
1304 | struct zfcp_adapter *adapter = erp_action->adapter; | 1302 | struct zfcp_adapter *adapter = erp_action->adapter; |
1305 | unsigned long flags; | 1303 | unsigned long flags; |
1306 | 1304 | ||
1307 | read_lock_irqsave(&zfcp_data.config_lock, flags); | 1305 | read_lock_irqsave(&zfcp_data.config_lock, flags); |
1308 | write_lock(&adapter->erp_lock); | 1306 | write_lock(&adapter->erp_lock); |
1309 | 1307 | ||
1310 | zfcp_erp_strategy_check_fsfreq(erp_action); | 1308 | zfcp_erp_strategy_check_fsfreq(erp_action); |
1311 | 1309 | ||
1312 | if (erp_action->status & ZFCP_STATUS_ERP_DISMISSED) { | 1310 | if (erp_action->status & ZFCP_STATUS_ERP_DISMISSED) { |
1313 | zfcp_erp_action_dequeue(erp_action); | 1311 | zfcp_erp_action_dequeue(erp_action); |
1314 | retval = ZFCP_ERP_DISMISSED; | 1312 | retval = ZFCP_ERP_DISMISSED; |
1315 | goto unlock; | 1313 | goto unlock; |
1316 | } | 1314 | } |
1317 | 1315 | ||
1318 | zfcp_erp_action_to_running(erp_action); | 1316 | zfcp_erp_action_to_running(erp_action); |
1319 | 1317 | ||
1320 | /* no lock to allow for blocking operations */ | 1318 | /* no lock to allow for blocking operations */ |
1321 | write_unlock(&adapter->erp_lock); | 1319 | write_unlock(&adapter->erp_lock); |
1322 | read_unlock_irqrestore(&zfcp_data.config_lock, flags); | 1320 | read_unlock_irqrestore(&zfcp_data.config_lock, flags); |
1323 | retval = zfcp_erp_strategy_do_action(erp_action); | 1321 | retval = zfcp_erp_strategy_do_action(erp_action); |
1324 | read_lock_irqsave(&zfcp_data.config_lock, flags); | 1322 | read_lock_irqsave(&zfcp_data.config_lock, flags); |
1325 | write_lock(&adapter->erp_lock); | 1323 | write_lock(&adapter->erp_lock); |
1326 | 1324 | ||
1327 | if (erp_action->status & ZFCP_STATUS_ERP_DISMISSED) | 1325 | if (erp_action->status & ZFCP_STATUS_ERP_DISMISSED) |
1328 | retval = ZFCP_ERP_CONTINUES; | 1326 | retval = ZFCP_ERP_CONTINUES; |
1329 | 1327 | ||
1330 | switch (retval) { | 1328 | switch (retval) { |
1331 | case ZFCP_ERP_NOMEM: | 1329 | case ZFCP_ERP_NOMEM: |
1332 | if (!(erp_action->status & ZFCP_STATUS_ERP_LOWMEM)) { | 1330 | if (!(erp_action->status & ZFCP_STATUS_ERP_LOWMEM)) { |
1333 | ++adapter->erp_low_mem_count; | 1331 | ++adapter->erp_low_mem_count; |
1334 | erp_action->status |= ZFCP_STATUS_ERP_LOWMEM; | 1332 | erp_action->status |= ZFCP_STATUS_ERP_LOWMEM; |
1335 | } | 1333 | } |
1336 | if (adapter->erp_total_count == adapter->erp_low_mem_count) | 1334 | if (adapter->erp_total_count == adapter->erp_low_mem_count) |
1337 | _zfcp_erp_adapter_reopen(adapter, 0, 66, NULL); | 1335 | _zfcp_erp_adapter_reopen(adapter, 0, 66, NULL); |
1338 | else { | 1336 | else { |
1339 | zfcp_erp_strategy_memwait(erp_action); | 1337 | zfcp_erp_strategy_memwait(erp_action); |
1340 | retval = ZFCP_ERP_CONTINUES; | 1338 | retval = ZFCP_ERP_CONTINUES; |
1341 | } | 1339 | } |
1342 | goto unlock; | 1340 | goto unlock; |
1343 | 1341 | ||
1344 | case ZFCP_ERP_CONTINUES: | 1342 | case ZFCP_ERP_CONTINUES: |
1345 | if (erp_action->status & ZFCP_STATUS_ERP_LOWMEM) { | 1343 | if (erp_action->status & ZFCP_STATUS_ERP_LOWMEM) { |
1346 | --adapter->erp_low_mem_count; | 1344 | --adapter->erp_low_mem_count; |
1347 | erp_action->status &= ~ZFCP_STATUS_ERP_LOWMEM; | 1345 | erp_action->status &= ~ZFCP_STATUS_ERP_LOWMEM; |
1348 | } | 1346 | } |
1349 | goto unlock; | 1347 | goto unlock; |
1350 | } | 1348 | } |
1351 | 1349 | ||
1352 | retval = zfcp_erp_strategy_check_target(erp_action, retval); | 1350 | retval = zfcp_erp_strategy_check_target(erp_action, retval); |
1353 | zfcp_erp_action_dequeue(erp_action); | 1351 | zfcp_erp_action_dequeue(erp_action); |
1354 | retval = zfcp_erp_strategy_statechange(erp_action, retval); | 1352 | retval = zfcp_erp_strategy_statechange(erp_action, retval); |
1355 | if (retval == ZFCP_ERP_EXIT) | 1353 | if (retval == ZFCP_ERP_EXIT) |
1356 | goto unlock; | 1354 | goto unlock; |
1357 | zfcp_erp_strategy_followup_actions(erp_action); | 1355 | zfcp_erp_strategy_followup_actions(erp_action); |
1358 | 1356 | ||
1359 | unlock: | 1357 | unlock: |
1360 | write_unlock(&adapter->erp_lock); | 1358 | write_unlock(&adapter->erp_lock); |
1361 | read_unlock_irqrestore(&zfcp_data.config_lock, flags); | 1359 | read_unlock_irqrestore(&zfcp_data.config_lock, flags); |
1362 | 1360 | ||
1363 | if (retval != ZFCP_ERP_CONTINUES) | 1361 | if (retval != ZFCP_ERP_CONTINUES) |
1364 | zfcp_erp_action_cleanup(erp_action, retval); | 1362 | zfcp_erp_action_cleanup(erp_action, retval); |
1365 | 1363 | ||
1366 | return retval; | 1364 | return retval; |
1367 | } | 1365 | } |
1368 | 1366 | ||
1369 | static int zfcp_erp_thread(void *data) | 1367 | static int zfcp_erp_thread(void *data) |
1370 | { | 1368 | { |
1371 | struct zfcp_adapter *adapter = (struct zfcp_adapter *) data; | 1369 | struct zfcp_adapter *adapter = (struct zfcp_adapter *) data; |
1372 | struct list_head *next; | 1370 | struct list_head *next; |
1373 | struct zfcp_erp_action *act; | 1371 | struct zfcp_erp_action *act; |
1374 | unsigned long flags; | 1372 | unsigned long flags; |
1375 | int ignore; | 1373 | int ignore; |
1376 | 1374 | ||
1377 | daemonize("zfcperp%s", dev_name(&adapter->ccw_device->dev)); | 1375 | daemonize("zfcperp%s", dev_name(&adapter->ccw_device->dev)); |
1378 | /* Block all signals */ | 1376 | /* Block all signals */ |
1379 | siginitsetinv(¤t->blocked, 0); | 1377 | siginitsetinv(¤t->blocked, 0); |
1380 | atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status); | 1378 | atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status); |
1381 | wake_up(&adapter->erp_thread_wqh); | 1379 | wake_up(&adapter->erp_thread_wqh); |
1382 | 1380 | ||
1383 | while (!(atomic_read(&adapter->status) & | 1381 | while (!(atomic_read(&adapter->status) & |
1384 | ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL)) { | 1382 | ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL)) { |
1385 | write_lock_irqsave(&adapter->erp_lock, flags); | 1383 | write_lock_irqsave(&adapter->erp_lock, flags); |
1386 | next = adapter->erp_ready_head.next; | 1384 | next = adapter->erp_ready_head.next; |
1387 | write_unlock_irqrestore(&adapter->erp_lock, flags); | 1385 | write_unlock_irqrestore(&adapter->erp_lock, flags); |
1388 | 1386 | ||
1389 | if (next != &adapter->erp_ready_head) { | 1387 | if (next != &adapter->erp_ready_head) { |
1390 | act = list_entry(next, struct zfcp_erp_action, list); | 1388 | act = list_entry(next, struct zfcp_erp_action, list); |
1391 | 1389 | ||
1392 | /* there is more to come after dismission, no notify */ | 1390 | /* there is more to come after dismission, no notify */ |
1393 | if (zfcp_erp_strategy(act) != ZFCP_ERP_DISMISSED) | 1391 | if (zfcp_erp_strategy(act) != ZFCP_ERP_DISMISSED) |
1394 | zfcp_erp_wakeup(adapter); | 1392 | zfcp_erp_wakeup(adapter); |
1395 | } | 1393 | } |
1396 | 1394 | ||
1397 | zfcp_rec_dbf_event_thread_lock(4, adapter); | 1395 | zfcp_rec_dbf_event_thread_lock(4, adapter); |
1398 | ignore = down_interruptible(&adapter->erp_ready_sem); | 1396 | ignore = down_interruptible(&adapter->erp_ready_sem); |
1399 | zfcp_rec_dbf_event_thread_lock(5, adapter); | 1397 | zfcp_rec_dbf_event_thread_lock(5, adapter); |
1400 | } | 1398 | } |
1401 | 1399 | ||
1402 | atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status); | 1400 | atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status); |
1403 | wake_up(&adapter->erp_thread_wqh); | 1401 | wake_up(&adapter->erp_thread_wqh); |
1404 | 1402 | ||
1405 | return 0; | 1403 | return 0; |
1406 | } | 1404 | } |
1407 | 1405 | ||
1408 | /** | 1406 | /** |
1409 | * zfcp_erp_thread_setup - Start ERP thread for adapter | 1407 | * zfcp_erp_thread_setup - Start ERP thread for adapter |
1410 | * @adapter: Adapter to start the ERP thread for | 1408 | * @adapter: Adapter to start the ERP thread for |
1411 | * | 1409 | * |
1412 | * Returns 0 on success or error code from kernel_thread() | 1410 | * Returns 0 on success or error code from kernel_thread() |
1413 | */ | 1411 | */ |
1414 | int zfcp_erp_thread_setup(struct zfcp_adapter *adapter) | 1412 | int zfcp_erp_thread_setup(struct zfcp_adapter *adapter) |
1415 | { | 1413 | { |
1416 | int retval; | 1414 | int retval; |
1417 | 1415 | ||
1418 | atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status); | 1416 | atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status); |
1419 | retval = kernel_thread(zfcp_erp_thread, adapter, SIGCHLD); | 1417 | retval = kernel_thread(zfcp_erp_thread, adapter, SIGCHLD); |
1420 | if (retval < 0) { | 1418 | if (retval < 0) { |
1421 | dev_err(&adapter->ccw_device->dev, | 1419 | dev_err(&adapter->ccw_device->dev, |
1422 | "Creating an ERP thread for the FCP device failed.\n"); | 1420 | "Creating an ERP thread for the FCP device failed.\n"); |
1423 | return retval; | 1421 | return retval; |
1424 | } | 1422 | } |
1425 | wait_event(adapter->erp_thread_wqh, | 1423 | wait_event(adapter->erp_thread_wqh, |
1426 | atomic_read(&adapter->status) & | 1424 | atomic_read(&adapter->status) & |
1427 | ZFCP_STATUS_ADAPTER_ERP_THREAD_UP); | 1425 | ZFCP_STATUS_ADAPTER_ERP_THREAD_UP); |
1428 | return 0; | 1426 | return 0; |
1429 | } | 1427 | } |
1430 | 1428 | ||
1431 | /** | 1429 | /** |
1432 | * zfcp_erp_thread_kill - Stop ERP thread. | 1430 | * zfcp_erp_thread_kill - Stop ERP thread. |
1433 | * @adapter: Adapter where the ERP thread should be stopped. | 1431 | * @adapter: Adapter where the ERP thread should be stopped. |
1434 | * | 1432 | * |
1435 | * The caller of this routine ensures that the specified adapter has | 1433 | * The caller of this routine ensures that the specified adapter has |
1436 | * been shut down and that this operation has been completed. Thus, | 1434 | * been shut down and that this operation has been completed. Thus, |
1437 | * there are no pending erp_actions which would need to be handled | 1435 | * there are no pending erp_actions which would need to be handled |
1438 | * here. | 1436 | * here. |
1439 | */ | 1437 | */ |
1440 | void zfcp_erp_thread_kill(struct zfcp_adapter *adapter) | 1438 | void zfcp_erp_thread_kill(struct zfcp_adapter *adapter) |
1441 | { | 1439 | { |
1442 | atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL, &adapter->status); | 1440 | atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL, &adapter->status); |
1443 | up(&adapter->erp_ready_sem); | 1441 | up(&adapter->erp_ready_sem); |
1444 | zfcp_rec_dbf_event_thread_lock(3, adapter); | 1442 | zfcp_rec_dbf_event_thread_lock(3, adapter); |
1445 | 1443 | ||
1446 | wait_event(adapter->erp_thread_wqh, | 1444 | wait_event(adapter->erp_thread_wqh, |
1447 | !(atomic_read(&adapter->status) & | 1445 | !(atomic_read(&adapter->status) & |
1448 | ZFCP_STATUS_ADAPTER_ERP_THREAD_UP)); | 1446 | ZFCP_STATUS_ADAPTER_ERP_THREAD_UP)); |
1449 | 1447 | ||
1450 | atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL, | 1448 | atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL, |
1451 | &adapter->status); | 1449 | &adapter->status); |
1452 | } | 1450 | } |
1453 | 1451 | ||
1454 | /** | 1452 | /** |
1455 | * zfcp_erp_adapter_failed - Set adapter status to failed. | 1453 | * zfcp_erp_adapter_failed - Set adapter status to failed. |
1456 | * @adapter: Failed adapter. | 1454 | * @adapter: Failed adapter. |
1457 | * @id: Event id for debug trace. | 1455 | * @id: Event id for debug trace. |
1458 | * @ref: Reference for debug trace. | 1456 | * @ref: Reference for debug trace. |
1459 | */ | 1457 | */ |
1460 | void zfcp_erp_adapter_failed(struct zfcp_adapter *adapter, u8 id, void *ref) | 1458 | void zfcp_erp_adapter_failed(struct zfcp_adapter *adapter, u8 id, void *ref) |
1461 | { | 1459 | { |
1462 | zfcp_erp_modify_adapter_status(adapter, id, ref, | 1460 | zfcp_erp_modify_adapter_status(adapter, id, ref, |
1463 | ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET); | 1461 | ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET); |
1464 | } | 1462 | } |
1465 | 1463 | ||
1466 | /** | 1464 | /** |
1467 | * zfcp_erp_port_failed - Set port status to failed. | 1465 | * zfcp_erp_port_failed - Set port status to failed. |
1468 | * @port: Failed port. | 1466 | * @port: Failed port. |
1469 | * @id: Event id for debug trace. | 1467 | * @id: Event id for debug trace. |
1470 | * @ref: Reference for debug trace. | 1468 | * @ref: Reference for debug trace. |
1471 | */ | 1469 | */ |
1472 | void zfcp_erp_port_failed(struct zfcp_port *port, u8 id, void *ref) | 1470 | void zfcp_erp_port_failed(struct zfcp_port *port, u8 id, void *ref) |
1473 | { | 1471 | { |
1474 | zfcp_erp_modify_port_status(port, id, ref, | 1472 | zfcp_erp_modify_port_status(port, id, ref, |
1475 | ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET); | 1473 | ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET); |
1476 | } | 1474 | } |
1477 | 1475 | ||
1478 | /** | 1476 | /** |
1479 | * zfcp_erp_unit_failed - Set unit status to failed. | 1477 | * zfcp_erp_unit_failed - Set unit status to failed. |
1480 | * @unit: Failed unit. | 1478 | * @unit: Failed unit. |
1481 | * @id: Event id for debug trace. | 1479 | * @id: Event id for debug trace. |
1482 | * @ref: Reference for debug trace. | 1480 | * @ref: Reference for debug trace. |
1483 | */ | 1481 | */ |
1484 | void zfcp_erp_unit_failed(struct zfcp_unit *unit, u8 id, void *ref) | 1482 | void zfcp_erp_unit_failed(struct zfcp_unit *unit, u8 id, void *ref) |
1485 | { | 1483 | { |
1486 | zfcp_erp_modify_unit_status(unit, id, ref, | 1484 | zfcp_erp_modify_unit_status(unit, id, ref, |
1487 | ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET); | 1485 | ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET); |
1488 | } | 1486 | } |
1489 | 1487 | ||
1490 | /** | 1488 | /** |
1491 | * zfcp_erp_wait - wait for completion of error recovery on an adapter | 1489 | * zfcp_erp_wait - wait for completion of error recovery on an adapter |
1492 | * @adapter: adapter for which to wait for completion of its error recovery | 1490 | * @adapter: adapter for which to wait for completion of its error recovery |
1493 | */ | 1491 | */ |
1494 | void zfcp_erp_wait(struct zfcp_adapter *adapter) | 1492 | void zfcp_erp_wait(struct zfcp_adapter *adapter) |
1495 | { | 1493 | { |
1496 | wait_event(adapter->erp_done_wqh, | 1494 | wait_event(adapter->erp_done_wqh, |
1497 | !(atomic_read(&adapter->status) & | 1495 | !(atomic_read(&adapter->status) & |
1498 | ZFCP_STATUS_ADAPTER_ERP_PENDING)); | 1496 | ZFCP_STATUS_ADAPTER_ERP_PENDING)); |
1499 | } | 1497 | } |
1500 | 1498 | ||
1501 | /** | 1499 | /** |
1502 | * zfcp_erp_modify_adapter_status - change adapter status bits | 1500 | * zfcp_erp_modify_adapter_status - change adapter status bits |
1503 | * @adapter: adapter to change the status | 1501 | * @adapter: adapter to change the status |
1504 | * @id: id for the debug trace | 1502 | * @id: id for the debug trace |
1505 | * @ref: reference for the debug trace | 1503 | * @ref: reference for the debug trace |
1506 | * @mask: status bits to change | 1504 | * @mask: status bits to change |
1507 | * @set_or_clear: ZFCP_SET or ZFCP_CLEAR | 1505 | * @set_or_clear: ZFCP_SET or ZFCP_CLEAR |
1508 | * | 1506 | * |
1509 | * Changes in common status bits are propagated to attached ports and units. | 1507 | * Changes in common status bits are propagated to attached ports and units. |
1510 | */ | 1508 | */ |
1511 | void zfcp_erp_modify_adapter_status(struct zfcp_adapter *adapter, u8 id, | 1509 | void zfcp_erp_modify_adapter_status(struct zfcp_adapter *adapter, u8 id, |
1512 | void *ref, u32 mask, int set_or_clear) | 1510 | void *ref, u32 mask, int set_or_clear) |
1513 | { | 1511 | { |
1514 | struct zfcp_port *port; | 1512 | struct zfcp_port *port; |
1515 | u32 common_mask = mask & ZFCP_COMMON_FLAGS; | 1513 | u32 common_mask = mask & ZFCP_COMMON_FLAGS; |
1516 | 1514 | ||
1517 | if (set_or_clear == ZFCP_SET) { | 1515 | if (set_or_clear == ZFCP_SET) { |
1518 | if (status_change_set(mask, &adapter->status)) | 1516 | if (status_change_set(mask, &adapter->status)) |
1519 | zfcp_rec_dbf_event_adapter(id, ref, adapter); | 1517 | zfcp_rec_dbf_event_adapter(id, ref, adapter); |
1520 | atomic_set_mask(mask, &adapter->status); | 1518 | atomic_set_mask(mask, &adapter->status); |
1521 | } else { | 1519 | } else { |
1522 | if (status_change_clear(mask, &adapter->status)) | 1520 | if (status_change_clear(mask, &adapter->status)) |
1523 | zfcp_rec_dbf_event_adapter(id, ref, adapter); | 1521 | zfcp_rec_dbf_event_adapter(id, ref, adapter); |
1524 | atomic_clear_mask(mask, &adapter->status); | 1522 | atomic_clear_mask(mask, &adapter->status); |
1525 | if (mask & ZFCP_STATUS_COMMON_ERP_FAILED) | 1523 | if (mask & ZFCP_STATUS_COMMON_ERP_FAILED) |
1526 | atomic_set(&adapter->erp_counter, 0); | 1524 | atomic_set(&adapter->erp_counter, 0); |
1527 | } | 1525 | } |
1528 | 1526 | ||
1529 | if (common_mask) | 1527 | if (common_mask) |
1530 | list_for_each_entry(port, &adapter->port_list_head, list) | 1528 | list_for_each_entry(port, &adapter->port_list_head, list) |
1531 | zfcp_erp_modify_port_status(port, id, ref, common_mask, | 1529 | zfcp_erp_modify_port_status(port, id, ref, common_mask, |
1532 | set_or_clear); | 1530 | set_or_clear); |
1533 | } | 1531 | } |
1534 | 1532 | ||
1535 | /** | 1533 | /** |
1536 | * zfcp_erp_modify_port_status - change port status bits | 1534 | * zfcp_erp_modify_port_status - change port status bits |
1537 | * @port: port to change the status bits | 1535 | * @port: port to change the status bits |
1538 | * @id: id for the debug trace | 1536 | * @id: id for the debug trace |
1539 | * @ref: reference for the debug trace | 1537 | * @ref: reference for the debug trace |
1540 | * @mask: status bits to change | 1538 | * @mask: status bits to change |
1541 | * @set_or_clear: ZFCP_SET or ZFCP_CLEAR | 1539 | * @set_or_clear: ZFCP_SET or ZFCP_CLEAR |
1542 | * | 1540 | * |
1543 | * Changes in common status bits are propagated to attached units. | 1541 | * Changes in common status bits are propagated to attached units. |
1544 | */ | 1542 | */ |
1545 | void zfcp_erp_modify_port_status(struct zfcp_port *port, u8 id, void *ref, | 1543 | void zfcp_erp_modify_port_status(struct zfcp_port *port, u8 id, void *ref, |
1546 | u32 mask, int set_or_clear) | 1544 | u32 mask, int set_or_clear) |
1547 | { | 1545 | { |
1548 | struct zfcp_unit *unit; | 1546 | struct zfcp_unit *unit; |
1549 | u32 common_mask = mask & ZFCP_COMMON_FLAGS; | 1547 | u32 common_mask = mask & ZFCP_COMMON_FLAGS; |
1550 | 1548 | ||
1551 | if (set_or_clear == ZFCP_SET) { | 1549 | if (set_or_clear == ZFCP_SET) { |
1552 | if (status_change_set(mask, &port->status)) | 1550 | if (status_change_set(mask, &port->status)) |
1553 | zfcp_rec_dbf_event_port(id, ref, port); | 1551 | zfcp_rec_dbf_event_port(id, ref, port); |
1554 | atomic_set_mask(mask, &port->status); | 1552 | atomic_set_mask(mask, &port->status); |
1555 | } else { | 1553 | } else { |
1556 | if (status_change_clear(mask, &port->status)) | 1554 | if (status_change_clear(mask, &port->status)) |
1557 | zfcp_rec_dbf_event_port(id, ref, port); | 1555 | zfcp_rec_dbf_event_port(id, ref, port); |
1558 | atomic_clear_mask(mask, &port->status); | 1556 | atomic_clear_mask(mask, &port->status); |
1559 | if (mask & ZFCP_STATUS_COMMON_ERP_FAILED) | 1557 | if (mask & ZFCP_STATUS_COMMON_ERP_FAILED) |
1560 | atomic_set(&port->erp_counter, 0); | 1558 | atomic_set(&port->erp_counter, 0); |
1561 | } | 1559 | } |
1562 | 1560 | ||
1563 | if (common_mask) | 1561 | if (common_mask) |
1564 | list_for_each_entry(unit, &port->unit_list_head, list) | 1562 | list_for_each_entry(unit, &port->unit_list_head, list) |
1565 | zfcp_erp_modify_unit_status(unit, id, ref, common_mask, | 1563 | zfcp_erp_modify_unit_status(unit, id, ref, common_mask, |
1566 | set_or_clear); | 1564 | set_or_clear); |
1567 | } | 1565 | } |
1568 | 1566 | ||
1569 | /** | 1567 | /** |
1570 | * zfcp_erp_modify_unit_status - change unit status bits | 1568 | * zfcp_erp_modify_unit_status - change unit status bits |
1571 | * @unit: unit to change the status bits | 1569 | * @unit: unit to change the status bits |
1572 | * @id: id for the debug trace | 1570 | * @id: id for the debug trace |
1573 | * @ref: reference for the debug trace | 1571 | * @ref: reference for the debug trace |
1574 | * @mask: status bits to change | 1572 | * @mask: status bits to change |
1575 | * @set_or_clear: ZFCP_SET or ZFCP_CLEAR | 1573 | * @set_or_clear: ZFCP_SET or ZFCP_CLEAR |
1576 | */ | 1574 | */ |
1577 | void zfcp_erp_modify_unit_status(struct zfcp_unit *unit, u8 id, void *ref, | 1575 | void zfcp_erp_modify_unit_status(struct zfcp_unit *unit, u8 id, void *ref, |
1578 | u32 mask, int set_or_clear) | 1576 | u32 mask, int set_or_clear) |
1579 | { | 1577 | { |
1580 | if (set_or_clear == ZFCP_SET) { | 1578 | if (set_or_clear == ZFCP_SET) { |
1581 | if (status_change_set(mask, &unit->status)) | 1579 | if (status_change_set(mask, &unit->status)) |
1582 | zfcp_rec_dbf_event_unit(id, ref, unit); | 1580 | zfcp_rec_dbf_event_unit(id, ref, unit); |
1583 | atomic_set_mask(mask, &unit->status); | 1581 | atomic_set_mask(mask, &unit->status); |
1584 | } else { | 1582 | } else { |
1585 | if (status_change_clear(mask, &unit->status)) | 1583 | if (status_change_clear(mask, &unit->status)) |
1586 | zfcp_rec_dbf_event_unit(id, ref, unit); | 1584 | zfcp_rec_dbf_event_unit(id, ref, unit); |
1587 | atomic_clear_mask(mask, &unit->status); | 1585 | atomic_clear_mask(mask, &unit->status); |
1588 | if (mask & ZFCP_STATUS_COMMON_ERP_FAILED) { | 1586 | if (mask & ZFCP_STATUS_COMMON_ERP_FAILED) { |
1589 | atomic_set(&unit->erp_counter, 0); | 1587 | atomic_set(&unit->erp_counter, 0); |
1590 | } | 1588 | } |
1591 | } | 1589 | } |
1592 | } | 1590 | } |
1593 | 1591 | ||
1594 | /** | 1592 | /** |
1595 | * zfcp_erp_port_boxed - Mark port as "boxed" and start ERP | 1593 | * zfcp_erp_port_boxed - Mark port as "boxed" and start ERP |
1596 | * @port: The "boxed" port. | 1594 | * @port: The "boxed" port. |
1597 | * @id: The debug trace id. | 1595 | * @id: The debug trace id. |
1598 | * @id: Reference for the debug trace. | 1596 | * @id: Reference for the debug trace. |
1599 | */ | 1597 | */ |
1600 | void zfcp_erp_port_boxed(struct zfcp_port *port, u8 id, void *ref) | 1598 | void zfcp_erp_port_boxed(struct zfcp_port *port, u8 id, void *ref) |
1601 | { | 1599 | { |
1602 | unsigned long flags; | 1600 | unsigned long flags; |
1603 | 1601 | ||
1604 | read_lock_irqsave(&zfcp_data.config_lock, flags); | 1602 | read_lock_irqsave(&zfcp_data.config_lock, flags); |
1605 | zfcp_erp_modify_port_status(port, id, ref, | 1603 | zfcp_erp_modify_port_status(port, id, ref, |
1606 | ZFCP_STATUS_COMMON_ACCESS_BOXED, ZFCP_SET); | 1604 | ZFCP_STATUS_COMMON_ACCESS_BOXED, ZFCP_SET); |
1607 | read_unlock_irqrestore(&zfcp_data.config_lock, flags); | 1605 | read_unlock_irqrestore(&zfcp_data.config_lock, flags); |
1608 | zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED, id, ref); | 1606 | zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED, id, ref); |
1609 | } | 1607 | } |
1610 | 1608 | ||
1611 | /** | 1609 | /** |
1612 | * zfcp_erp_unit_boxed - Mark unit as "boxed" and start ERP | 1610 | * zfcp_erp_unit_boxed - Mark unit as "boxed" and start ERP |
1613 | * @port: The "boxed" unit. | 1611 | * @port: The "boxed" unit. |
1614 | * @id: The debug trace id. | 1612 | * @id: The debug trace id. |
1615 | * @id: Reference for the debug trace. | 1613 | * @id: Reference for the debug trace. |
1616 | */ | 1614 | */ |
1617 | void zfcp_erp_unit_boxed(struct zfcp_unit *unit, u8 id, void *ref) | 1615 | void zfcp_erp_unit_boxed(struct zfcp_unit *unit, u8 id, void *ref) |
1618 | { | 1616 | { |
1619 | zfcp_erp_modify_unit_status(unit, id, ref, | 1617 | zfcp_erp_modify_unit_status(unit, id, ref, |
1620 | ZFCP_STATUS_COMMON_ACCESS_BOXED, ZFCP_SET); | 1618 | ZFCP_STATUS_COMMON_ACCESS_BOXED, ZFCP_SET); |
1621 | zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED, id, ref); | 1619 | zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED, id, ref); |
1622 | } | 1620 | } |
1623 | 1621 | ||
1624 | /** | 1622 | /** |
1625 | * zfcp_erp_port_access_denied - Adapter denied access to port. | 1623 | * zfcp_erp_port_access_denied - Adapter denied access to port. |
1626 | * @port: port where access has been denied | 1624 | * @port: port where access has been denied |
1627 | * @id: id for debug trace | 1625 | * @id: id for debug trace |
1628 | * @ref: reference for debug trace | 1626 | * @ref: reference for debug trace |
1629 | * | 1627 | * |
1630 | * Since the adapter has denied access, stop using the port and the | 1628 | * Since the adapter has denied access, stop using the port and the |
1631 | * attached units. | 1629 | * attached units. |
1632 | */ | 1630 | */ |
1633 | void zfcp_erp_port_access_denied(struct zfcp_port *port, u8 id, void *ref) | 1631 | void zfcp_erp_port_access_denied(struct zfcp_port *port, u8 id, void *ref) |
1634 | { | 1632 | { |
1635 | unsigned long flags; | 1633 | unsigned long flags; |
1636 | 1634 | ||
1637 | read_lock_irqsave(&zfcp_data.config_lock, flags); | 1635 | read_lock_irqsave(&zfcp_data.config_lock, flags); |
1638 | zfcp_erp_modify_port_status(port, id, ref, | 1636 | zfcp_erp_modify_port_status(port, id, ref, |
1639 | ZFCP_STATUS_COMMON_ERP_FAILED | | 1637 | ZFCP_STATUS_COMMON_ERP_FAILED | |
1640 | ZFCP_STATUS_COMMON_ACCESS_DENIED, ZFCP_SET); | 1638 | ZFCP_STATUS_COMMON_ACCESS_DENIED, ZFCP_SET); |
1641 | read_unlock_irqrestore(&zfcp_data.config_lock, flags); | 1639 | read_unlock_irqrestore(&zfcp_data.config_lock, flags); |
1642 | } | 1640 | } |
1643 | 1641 | ||
1644 | /** | 1642 | /** |
1645 | * zfcp_erp_unit_access_denied - Adapter denied access to unit. | 1643 | * zfcp_erp_unit_access_denied - Adapter denied access to unit. |
1646 | * @unit: unit where access has been denied | 1644 | * @unit: unit where access has been denied |
1647 | * @id: id for debug trace | 1645 | * @id: id for debug trace |
1648 | * @ref: reference for debug trace | 1646 | * @ref: reference for debug trace |
1649 | * | 1647 | * |
1650 | * Since the adapter has denied access, stop using the unit. | 1648 | * Since the adapter has denied access, stop using the unit. |
1651 | */ | 1649 | */ |
1652 | void zfcp_erp_unit_access_denied(struct zfcp_unit *unit, u8 id, void *ref) | 1650 | void zfcp_erp_unit_access_denied(struct zfcp_unit *unit, u8 id, void *ref) |
1653 | { | 1651 | { |
1654 | zfcp_erp_modify_unit_status(unit, id, ref, | 1652 | zfcp_erp_modify_unit_status(unit, id, ref, |
1655 | ZFCP_STATUS_COMMON_ERP_FAILED | | 1653 | ZFCP_STATUS_COMMON_ERP_FAILED | |
1656 | ZFCP_STATUS_COMMON_ACCESS_DENIED, ZFCP_SET); | 1654 | ZFCP_STATUS_COMMON_ACCESS_DENIED, ZFCP_SET); |
1657 | } | 1655 | } |
1658 | 1656 | ||
1659 | static void zfcp_erp_unit_access_changed(struct zfcp_unit *unit, u8 id, | 1657 | static void zfcp_erp_unit_access_changed(struct zfcp_unit *unit, u8 id, |
1660 | void *ref) | 1658 | void *ref) |
1661 | { | 1659 | { |
1662 | int status = atomic_read(&unit->status); | 1660 | int status = atomic_read(&unit->status); |
1663 | if (!(status & (ZFCP_STATUS_COMMON_ACCESS_DENIED | | 1661 | if (!(status & (ZFCP_STATUS_COMMON_ACCESS_DENIED | |
1664 | ZFCP_STATUS_COMMON_ACCESS_BOXED))) | 1662 | ZFCP_STATUS_COMMON_ACCESS_BOXED))) |
1665 | return; | 1663 | return; |
1666 | 1664 | ||
1667 | zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED, id, ref); | 1665 | zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED, id, ref); |
1668 | } | 1666 | } |
1669 | 1667 | ||
1670 | static void zfcp_erp_port_access_changed(struct zfcp_port *port, u8 id, | 1668 | static void zfcp_erp_port_access_changed(struct zfcp_port *port, u8 id, |
1671 | void *ref) | 1669 | void *ref) |
1672 | { | 1670 | { |
1673 | struct zfcp_unit *unit; | 1671 | struct zfcp_unit *unit; |
1674 | int status = atomic_read(&port->status); | 1672 | int status = atomic_read(&port->status); |
1675 | 1673 | ||
1676 | if (!(status & (ZFCP_STATUS_COMMON_ACCESS_DENIED | | 1674 | if (!(status & (ZFCP_STATUS_COMMON_ACCESS_DENIED | |
1677 | ZFCP_STATUS_COMMON_ACCESS_BOXED))) { | 1675 | ZFCP_STATUS_COMMON_ACCESS_BOXED))) { |
1678 | list_for_each_entry(unit, &port->unit_list_head, list) | 1676 | list_for_each_entry(unit, &port->unit_list_head, list) |
1679 | zfcp_erp_unit_access_changed(unit, id, ref); | 1677 | zfcp_erp_unit_access_changed(unit, id, ref); |
1680 | return; | 1678 | return; |
1681 | } | 1679 | } |
1682 | 1680 | ||
1683 | zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED, id, ref); | 1681 | zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED, id, ref); |
1684 | } | 1682 | } |
1685 | 1683 | ||
1686 | /** | 1684 | /** |
1687 | * zfcp_erp_adapter_access_changed - Process change in adapter ACT | 1685 | * zfcp_erp_adapter_access_changed - Process change in adapter ACT |
1688 | * @adapter: Adapter where the Access Control Table (ACT) changed | 1686 | * @adapter: Adapter where the Access Control Table (ACT) changed |
1689 | * @id: Id for debug trace | 1687 | * @id: Id for debug trace |
1690 | * @ref: Reference for debug trace | 1688 | * @ref: Reference for debug trace |
1691 | */ | 1689 | */ |
1692 | void zfcp_erp_adapter_access_changed(struct zfcp_adapter *adapter, u8 id, | 1690 | void zfcp_erp_adapter_access_changed(struct zfcp_adapter *adapter, u8 id, |
1693 | void *ref) | 1691 | void *ref) |
1694 | { | 1692 | { |
1695 | struct zfcp_port *port; | 1693 | struct zfcp_port *port; |
1696 | unsigned long flags; | 1694 | unsigned long flags; |
1697 | 1695 | ||
1698 | if (adapter->connection_features & FSF_FEATURE_NPIV_MODE) | 1696 | if (adapter->connection_features & FSF_FEATURE_NPIV_MODE) |
1699 | return; | 1697 | return; |
1700 | 1698 | ||
1701 | read_lock_irqsave(&zfcp_data.config_lock, flags); | 1699 | read_lock_irqsave(&zfcp_data.config_lock, flags); |
1702 | list_for_each_entry(port, &adapter->port_list_head, list) | 1700 | list_for_each_entry(port, &adapter->port_list_head, list) |
1703 | zfcp_erp_port_access_changed(port, id, ref); | 1701 | zfcp_erp_port_access_changed(port, id, ref); |
1704 | read_unlock_irqrestore(&zfcp_data.config_lock, flags); | 1702 | read_unlock_irqrestore(&zfcp_data.config_lock, flags); |
1705 | } | 1703 | } |
1706 | 1704 |
drivers/s390/scsi/zfcp_scsi.c
1 | /* | 1 | /* |
2 | * zfcp device driver | 2 | * zfcp device driver |
3 | * | 3 | * |
4 | * Interface to Linux SCSI midlayer. | 4 | * Interface to Linux SCSI midlayer. |
5 | * | 5 | * |
6 | * Copyright IBM Corporation 2002, 2008 | 6 | * Copyright IBM Corporation 2002, 2008 |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #define KMSG_COMPONENT "zfcp" | 9 | #define KMSG_COMPONENT "zfcp" |
10 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt | 10 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt |
11 | 11 | ||
12 | #include "zfcp_ext.h" | 12 | #include "zfcp_ext.h" |
13 | #include <asm/atomic.h> | 13 | #include <asm/atomic.h> |
14 | 14 | ||
15 | /* Find start of Sense Information in FCP response unit*/ | 15 | /* Find start of Sense Information in FCP response unit*/ |
16 | char *zfcp_get_fcp_sns_info_ptr(struct fcp_rsp_iu *fcp_rsp_iu) | 16 | char *zfcp_get_fcp_sns_info_ptr(struct fcp_rsp_iu *fcp_rsp_iu) |
17 | { | 17 | { |
18 | char *fcp_sns_info_ptr; | 18 | char *fcp_sns_info_ptr; |
19 | 19 | ||
20 | fcp_sns_info_ptr = (unsigned char *) &fcp_rsp_iu[1]; | 20 | fcp_sns_info_ptr = (unsigned char *) &fcp_rsp_iu[1]; |
21 | if (fcp_rsp_iu->validity.bits.fcp_rsp_len_valid) | 21 | if (fcp_rsp_iu->validity.bits.fcp_rsp_len_valid) |
22 | fcp_sns_info_ptr += fcp_rsp_iu->fcp_rsp_len; | 22 | fcp_sns_info_ptr += fcp_rsp_iu->fcp_rsp_len; |
23 | 23 | ||
24 | return fcp_sns_info_ptr; | 24 | return fcp_sns_info_ptr; |
25 | } | 25 | } |
26 | 26 | ||
27 | static void zfcp_scsi_slave_destroy(struct scsi_device *sdpnt) | 27 | static void zfcp_scsi_slave_destroy(struct scsi_device *sdpnt) |
28 | { | 28 | { |
29 | struct zfcp_unit *unit = (struct zfcp_unit *) sdpnt->hostdata; | 29 | struct zfcp_unit *unit = (struct zfcp_unit *) sdpnt->hostdata; |
30 | atomic_clear_mask(ZFCP_STATUS_UNIT_REGISTERED, &unit->status); | ||
31 | unit->device = NULL; | 30 | unit->device = NULL; |
32 | zfcp_erp_unit_failed(unit, 12, NULL); | 31 | zfcp_erp_unit_failed(unit, 12, NULL); |
33 | zfcp_unit_put(unit); | 32 | zfcp_unit_put(unit); |
34 | } | 33 | } |
35 | 34 | ||
36 | static int zfcp_scsi_slave_configure(struct scsi_device *sdp) | 35 | static int zfcp_scsi_slave_configure(struct scsi_device *sdp) |
37 | { | 36 | { |
38 | if (sdp->tagged_supported) | 37 | if (sdp->tagged_supported) |
39 | scsi_adjust_queue_depth(sdp, MSG_SIMPLE_TAG, 32); | 38 | scsi_adjust_queue_depth(sdp, MSG_SIMPLE_TAG, 32); |
40 | else | 39 | else |
41 | scsi_adjust_queue_depth(sdp, 0, 1); | 40 | scsi_adjust_queue_depth(sdp, 0, 1); |
42 | return 0; | 41 | return 0; |
43 | } | 42 | } |
44 | 43 | ||
45 | static void zfcp_scsi_command_fail(struct scsi_cmnd *scpnt, int result) | 44 | static void zfcp_scsi_command_fail(struct scsi_cmnd *scpnt, int result) |
46 | { | 45 | { |
47 | set_host_byte(scpnt, result); | 46 | set_host_byte(scpnt, result); |
48 | if ((scpnt->device != NULL) && (scpnt->device->host != NULL)) | 47 | if ((scpnt->device != NULL) && (scpnt->device->host != NULL)) |
49 | zfcp_scsi_dbf_event_result("fail", 4, | 48 | zfcp_scsi_dbf_event_result("fail", 4, |
50 | (struct zfcp_adapter*) scpnt->device->host->hostdata[0], | 49 | (struct zfcp_adapter*) scpnt->device->host->hostdata[0], |
51 | scpnt, NULL); | 50 | scpnt, NULL); |
52 | /* return directly */ | 51 | /* return directly */ |
53 | scpnt->scsi_done(scpnt); | 52 | scpnt->scsi_done(scpnt); |
54 | } | 53 | } |
55 | 54 | ||
56 | static int zfcp_scsi_queuecommand(struct scsi_cmnd *scpnt, | 55 | static int zfcp_scsi_queuecommand(struct scsi_cmnd *scpnt, |
57 | void (*done) (struct scsi_cmnd *)) | 56 | void (*done) (struct scsi_cmnd *)) |
58 | { | 57 | { |
59 | struct zfcp_unit *unit; | 58 | struct zfcp_unit *unit; |
60 | struct zfcp_adapter *adapter; | 59 | struct zfcp_adapter *adapter; |
61 | int status; | 60 | int status; |
62 | int ret; | 61 | int ret; |
63 | 62 | ||
64 | /* reset the status for this request */ | 63 | /* reset the status for this request */ |
65 | scpnt->result = 0; | 64 | scpnt->result = 0; |
66 | scpnt->host_scribble = NULL; | 65 | scpnt->host_scribble = NULL; |
67 | scpnt->scsi_done = done; | 66 | scpnt->scsi_done = done; |
68 | 67 | ||
69 | /* | 68 | /* |
70 | * figure out adapter and target device | 69 | * figure out adapter and target device |
71 | * (stored there by zfcp_scsi_slave_alloc) | 70 | * (stored there by zfcp_scsi_slave_alloc) |
72 | */ | 71 | */ |
73 | adapter = (struct zfcp_adapter *) scpnt->device->host->hostdata[0]; | 72 | adapter = (struct zfcp_adapter *) scpnt->device->host->hostdata[0]; |
74 | unit = scpnt->device->hostdata; | 73 | unit = scpnt->device->hostdata; |
75 | 74 | ||
76 | BUG_ON(!adapter || (adapter != unit->port->adapter)); | 75 | BUG_ON(!adapter || (adapter != unit->port->adapter)); |
77 | BUG_ON(!scpnt->scsi_done); | 76 | BUG_ON(!scpnt->scsi_done); |
78 | 77 | ||
79 | if (unlikely(!unit)) { | 78 | if (unlikely(!unit)) { |
80 | zfcp_scsi_command_fail(scpnt, DID_NO_CONNECT); | 79 | zfcp_scsi_command_fail(scpnt, DID_NO_CONNECT); |
81 | return 0; | 80 | return 0; |
82 | } | 81 | } |
83 | 82 | ||
84 | status = atomic_read(&unit->status); | 83 | status = atomic_read(&unit->status); |
85 | if (unlikely((status & ZFCP_STATUS_COMMON_ERP_FAILED) || | 84 | if (unlikely((status & ZFCP_STATUS_COMMON_ERP_FAILED) || |
86 | !(status & ZFCP_STATUS_COMMON_RUNNING))) { | 85 | !(status & ZFCP_STATUS_COMMON_RUNNING))) { |
87 | zfcp_scsi_command_fail(scpnt, DID_ERROR); | 86 | zfcp_scsi_command_fail(scpnt, DID_ERROR); |
88 | return 0;; | 87 | return 0;; |
89 | } | 88 | } |
90 | 89 | ||
91 | ret = zfcp_fsf_send_fcp_command_task(adapter, unit, scpnt, 0, | 90 | ret = zfcp_fsf_send_fcp_command_task(adapter, unit, scpnt, 0, |
92 | ZFCP_REQ_AUTO_CLEANUP); | 91 | ZFCP_REQ_AUTO_CLEANUP); |
93 | if (unlikely(ret == -EBUSY)) | 92 | if (unlikely(ret == -EBUSY)) |
94 | return SCSI_MLQUEUE_DEVICE_BUSY; | 93 | return SCSI_MLQUEUE_DEVICE_BUSY; |
95 | else if (unlikely(ret < 0)) | 94 | else if (unlikely(ret < 0)) |
96 | return SCSI_MLQUEUE_HOST_BUSY; | 95 | return SCSI_MLQUEUE_HOST_BUSY; |
97 | 96 | ||
98 | return ret; | 97 | return ret; |
99 | } | 98 | } |
100 | 99 | ||
101 | static struct zfcp_unit *zfcp_unit_lookup(struct zfcp_adapter *adapter, | 100 | static struct zfcp_unit *zfcp_unit_lookup(struct zfcp_adapter *adapter, |
102 | int channel, unsigned int id, | 101 | int channel, unsigned int id, |
103 | unsigned int lun) | 102 | unsigned int lun) |
104 | { | 103 | { |
105 | struct zfcp_port *port; | 104 | struct zfcp_port *port; |
106 | struct zfcp_unit *unit; | 105 | struct zfcp_unit *unit; |
107 | int scsi_lun; | 106 | int scsi_lun; |
108 | 107 | ||
109 | list_for_each_entry(port, &adapter->port_list_head, list) { | 108 | list_for_each_entry(port, &adapter->port_list_head, list) { |
110 | if (!port->rport || (id != port->rport->scsi_target_id)) | 109 | if (!port->rport || (id != port->rport->scsi_target_id)) |
111 | continue; | 110 | continue; |
112 | list_for_each_entry(unit, &port->unit_list_head, list) { | 111 | list_for_each_entry(unit, &port->unit_list_head, list) { |
113 | scsi_lun = scsilun_to_int( | 112 | scsi_lun = scsilun_to_int( |
114 | (struct scsi_lun *)&unit->fcp_lun); | 113 | (struct scsi_lun *)&unit->fcp_lun); |
115 | if (lun == scsi_lun) | 114 | if (lun == scsi_lun) |
116 | return unit; | 115 | return unit; |
117 | } | 116 | } |
118 | } | 117 | } |
119 | 118 | ||
120 | return NULL; | 119 | return NULL; |
121 | } | 120 | } |
122 | 121 | ||
123 | static int zfcp_scsi_slave_alloc(struct scsi_device *sdp) | 122 | static int zfcp_scsi_slave_alloc(struct scsi_device *sdp) |
124 | { | 123 | { |
125 | struct zfcp_adapter *adapter; | 124 | struct zfcp_adapter *adapter; |
126 | struct zfcp_unit *unit; | 125 | struct zfcp_unit *unit; |
127 | unsigned long flags; | 126 | unsigned long flags; |
128 | int retval = -ENXIO; | 127 | int retval = -ENXIO; |
129 | 128 | ||
130 | adapter = (struct zfcp_adapter *) sdp->host->hostdata[0]; | 129 | adapter = (struct zfcp_adapter *) sdp->host->hostdata[0]; |
131 | if (!adapter) | 130 | if (!adapter) |
132 | goto out; | 131 | goto out; |
133 | 132 | ||
134 | read_lock_irqsave(&zfcp_data.config_lock, flags); | 133 | read_lock_irqsave(&zfcp_data.config_lock, flags); |
135 | unit = zfcp_unit_lookup(adapter, sdp->channel, sdp->id, sdp->lun); | 134 | unit = zfcp_unit_lookup(adapter, sdp->channel, sdp->id, sdp->lun); |
136 | if (unit && | 135 | if (unit) { |
137 | (atomic_read(&unit->status) & ZFCP_STATUS_UNIT_REGISTERED)) { | ||
138 | sdp->hostdata = unit; | 136 | sdp->hostdata = unit; |
139 | unit->device = sdp; | 137 | unit->device = sdp; |
140 | zfcp_unit_get(unit); | 138 | zfcp_unit_get(unit); |
141 | retval = 0; | 139 | retval = 0; |
142 | } | 140 | } |
143 | read_unlock_irqrestore(&zfcp_data.config_lock, flags); | 141 | read_unlock_irqrestore(&zfcp_data.config_lock, flags); |
144 | out: | 142 | out: |
145 | return retval; | 143 | return retval; |
146 | } | 144 | } |
147 | 145 | ||
148 | static int zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt) | 146 | static int zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt) |
149 | { | 147 | { |
150 | struct Scsi_Host *scsi_host; | 148 | struct Scsi_Host *scsi_host; |
151 | struct zfcp_adapter *adapter; | 149 | struct zfcp_adapter *adapter; |
152 | struct zfcp_unit *unit; | 150 | struct zfcp_unit *unit; |
153 | struct zfcp_fsf_req *fsf_req; | 151 | struct zfcp_fsf_req *fsf_req; |
154 | unsigned long flags; | 152 | unsigned long flags; |
155 | unsigned long old_req_id = (unsigned long) scpnt->host_scribble; | 153 | unsigned long old_req_id = (unsigned long) scpnt->host_scribble; |
156 | int retval = SUCCESS; | 154 | int retval = SUCCESS; |
157 | 155 | ||
158 | scsi_host = scpnt->device->host; | 156 | scsi_host = scpnt->device->host; |
159 | adapter = (struct zfcp_adapter *) scsi_host->hostdata[0]; | 157 | adapter = (struct zfcp_adapter *) scsi_host->hostdata[0]; |
160 | unit = scpnt->device->hostdata; | 158 | unit = scpnt->device->hostdata; |
161 | 159 | ||
162 | /* avoid race condition between late normal completion and abort */ | 160 | /* avoid race condition between late normal completion and abort */ |
163 | write_lock_irqsave(&adapter->abort_lock, flags); | 161 | write_lock_irqsave(&adapter->abort_lock, flags); |
164 | 162 | ||
165 | /* Check whether corresponding fsf_req is still pending */ | 163 | /* Check whether corresponding fsf_req is still pending */ |
166 | spin_lock(&adapter->req_list_lock); | 164 | spin_lock(&adapter->req_list_lock); |
167 | fsf_req = zfcp_reqlist_find(adapter, old_req_id); | 165 | fsf_req = zfcp_reqlist_find(adapter, old_req_id); |
168 | spin_unlock(&adapter->req_list_lock); | 166 | spin_unlock(&adapter->req_list_lock); |
169 | if (!fsf_req) { | 167 | if (!fsf_req) { |
170 | write_unlock_irqrestore(&adapter->abort_lock, flags); | 168 | write_unlock_irqrestore(&adapter->abort_lock, flags); |
171 | zfcp_scsi_dbf_event_abort("lte1", adapter, scpnt, NULL, 0); | 169 | zfcp_scsi_dbf_event_abort("lte1", adapter, scpnt, NULL, 0); |
172 | return retval; | 170 | return retval; |
173 | } | 171 | } |
174 | fsf_req->data = NULL; | 172 | fsf_req->data = NULL; |
175 | 173 | ||
176 | /* don't access old fsf_req after releasing the abort_lock */ | 174 | /* don't access old fsf_req after releasing the abort_lock */ |
177 | write_unlock_irqrestore(&adapter->abort_lock, flags); | 175 | write_unlock_irqrestore(&adapter->abort_lock, flags); |
178 | 176 | ||
179 | fsf_req = zfcp_fsf_abort_fcp_command(old_req_id, adapter, unit, 0); | 177 | fsf_req = zfcp_fsf_abort_fcp_command(old_req_id, adapter, unit, 0); |
180 | if (!fsf_req) { | 178 | if (!fsf_req) { |
181 | zfcp_scsi_dbf_event_abort("nres", adapter, scpnt, NULL, | 179 | zfcp_scsi_dbf_event_abort("nres", adapter, scpnt, NULL, |
182 | old_req_id); | 180 | old_req_id); |
183 | retval = FAILED; | 181 | retval = FAILED; |
184 | return retval; | 182 | return retval; |
185 | } | 183 | } |
186 | 184 | ||
187 | __wait_event(fsf_req->completion_wq, | 185 | __wait_event(fsf_req->completion_wq, |
188 | fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED); | 186 | fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED); |
189 | 187 | ||
190 | if (fsf_req->status & ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED) { | 188 | if (fsf_req->status & ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED) { |
191 | zfcp_scsi_dbf_event_abort("okay", adapter, scpnt, fsf_req, 0); | 189 | zfcp_scsi_dbf_event_abort("okay", adapter, scpnt, fsf_req, 0); |
192 | } else if (fsf_req->status & ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED) { | 190 | } else if (fsf_req->status & ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED) { |
193 | zfcp_scsi_dbf_event_abort("lte2", adapter, scpnt, fsf_req, 0); | 191 | zfcp_scsi_dbf_event_abort("lte2", adapter, scpnt, fsf_req, 0); |
194 | } else { | 192 | } else { |
195 | zfcp_scsi_dbf_event_abort("fail", adapter, scpnt, fsf_req, 0); | 193 | zfcp_scsi_dbf_event_abort("fail", adapter, scpnt, fsf_req, 0); |
196 | retval = FAILED; | 194 | retval = FAILED; |
197 | } | 195 | } |
198 | zfcp_fsf_req_free(fsf_req); | 196 | zfcp_fsf_req_free(fsf_req); |
199 | 197 | ||
200 | return retval; | 198 | return retval; |
201 | } | 199 | } |
202 | 200 | ||
203 | static int zfcp_task_mgmt_function(struct zfcp_unit *unit, u8 tm_flags, | 201 | static int zfcp_task_mgmt_function(struct zfcp_unit *unit, u8 tm_flags, |
204 | struct scsi_cmnd *scpnt) | 202 | struct scsi_cmnd *scpnt) |
205 | { | 203 | { |
206 | struct zfcp_adapter *adapter = unit->port->adapter; | 204 | struct zfcp_adapter *adapter = unit->port->adapter; |
207 | struct zfcp_fsf_req *fsf_req; | 205 | struct zfcp_fsf_req *fsf_req; |
208 | int retval = SUCCESS; | 206 | int retval = SUCCESS; |
209 | 207 | ||
210 | /* issue task management function */ | 208 | /* issue task management function */ |
211 | fsf_req = zfcp_fsf_send_fcp_ctm(adapter, unit, tm_flags, 0); | 209 | fsf_req = zfcp_fsf_send_fcp_ctm(adapter, unit, tm_flags, 0); |
212 | if (!fsf_req) { | 210 | if (!fsf_req) { |
213 | zfcp_scsi_dbf_event_devreset("nres", tm_flags, unit, scpnt); | 211 | zfcp_scsi_dbf_event_devreset("nres", tm_flags, unit, scpnt); |
214 | return FAILED; | 212 | return FAILED; |
215 | } | 213 | } |
216 | 214 | ||
217 | __wait_event(fsf_req->completion_wq, | 215 | __wait_event(fsf_req->completion_wq, |
218 | fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED); | 216 | fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED); |
219 | 217 | ||
220 | /* | 218 | /* |
221 | * check completion status of task management function | 219 | * check completion status of task management function |
222 | */ | 220 | */ |
223 | if (fsf_req->status & ZFCP_STATUS_FSFREQ_TMFUNCFAILED) { | 221 | if (fsf_req->status & ZFCP_STATUS_FSFREQ_TMFUNCFAILED) { |
224 | zfcp_scsi_dbf_event_devreset("fail", tm_flags, unit, scpnt); | 222 | zfcp_scsi_dbf_event_devreset("fail", tm_flags, unit, scpnt); |
225 | retval = FAILED; | 223 | retval = FAILED; |
226 | } else if (fsf_req->status & ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP) { | 224 | } else if (fsf_req->status & ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP) { |
227 | zfcp_scsi_dbf_event_devreset("nsup", tm_flags, unit, scpnt); | 225 | zfcp_scsi_dbf_event_devreset("nsup", tm_flags, unit, scpnt); |
228 | retval = FAILED; | 226 | retval = FAILED; |
229 | } else | 227 | } else |
230 | zfcp_scsi_dbf_event_devreset("okay", tm_flags, unit, scpnt); | 228 | zfcp_scsi_dbf_event_devreset("okay", tm_flags, unit, scpnt); |
231 | 229 | ||
232 | zfcp_fsf_req_free(fsf_req); | 230 | zfcp_fsf_req_free(fsf_req); |
233 | 231 | ||
234 | return retval; | 232 | return retval; |
235 | } | 233 | } |
236 | 234 | ||
237 | static int zfcp_scsi_eh_device_reset_handler(struct scsi_cmnd *scpnt) | 235 | static int zfcp_scsi_eh_device_reset_handler(struct scsi_cmnd *scpnt) |
238 | { | 236 | { |
239 | struct zfcp_unit *unit = scpnt->device->hostdata; | 237 | struct zfcp_unit *unit = scpnt->device->hostdata; |
240 | 238 | ||
241 | if (!unit) { | 239 | if (!unit) { |
242 | WARN_ON(1); | 240 | WARN_ON(1); |
243 | return SUCCESS; | 241 | return SUCCESS; |
244 | } | 242 | } |
245 | return zfcp_task_mgmt_function(unit, FCP_LOGICAL_UNIT_RESET, scpnt); | 243 | return zfcp_task_mgmt_function(unit, FCP_LOGICAL_UNIT_RESET, scpnt); |
246 | } | 244 | } |
247 | 245 | ||
248 | static int zfcp_scsi_eh_target_reset_handler(struct scsi_cmnd *scpnt) | 246 | static int zfcp_scsi_eh_target_reset_handler(struct scsi_cmnd *scpnt) |
249 | { | 247 | { |
250 | struct zfcp_unit *unit = scpnt->device->hostdata; | 248 | struct zfcp_unit *unit = scpnt->device->hostdata; |
251 | 249 | ||
252 | if (!unit) { | 250 | if (!unit) { |
253 | WARN_ON(1); | 251 | WARN_ON(1); |
254 | return SUCCESS; | 252 | return SUCCESS; |
255 | } | 253 | } |
256 | return zfcp_task_mgmt_function(unit, FCP_TARGET_RESET, scpnt); | 254 | return zfcp_task_mgmt_function(unit, FCP_TARGET_RESET, scpnt); |
257 | } | 255 | } |
258 | 256 | ||
259 | static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt) | 257 | static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt) |
260 | { | 258 | { |
261 | struct zfcp_unit *unit; | 259 | struct zfcp_unit *unit; |
262 | struct zfcp_adapter *adapter; | 260 | struct zfcp_adapter *adapter; |
263 | 261 | ||
264 | unit = scpnt->device->hostdata; | 262 | unit = scpnt->device->hostdata; |
265 | adapter = unit->port->adapter; | 263 | adapter = unit->port->adapter; |
266 | zfcp_erp_adapter_reopen(adapter, 0, 141, scpnt); | 264 | zfcp_erp_adapter_reopen(adapter, 0, 141, scpnt); |
267 | zfcp_erp_wait(adapter); | 265 | zfcp_erp_wait(adapter); |
268 | 266 | ||
269 | return SUCCESS; | 267 | return SUCCESS; |
270 | } | 268 | } |
271 | 269 | ||
272 | int zfcp_adapter_scsi_register(struct zfcp_adapter *adapter) | 270 | int zfcp_adapter_scsi_register(struct zfcp_adapter *adapter) |
273 | { | 271 | { |
274 | struct ccw_dev_id dev_id; | 272 | struct ccw_dev_id dev_id; |
275 | 273 | ||
276 | if (adapter->scsi_host) | 274 | if (adapter->scsi_host) |
277 | return 0; | 275 | return 0; |
278 | 276 | ||
279 | ccw_device_get_id(adapter->ccw_device, &dev_id); | 277 | ccw_device_get_id(adapter->ccw_device, &dev_id); |
280 | /* register adapter as SCSI host with mid layer of SCSI stack */ | 278 | /* register adapter as SCSI host with mid layer of SCSI stack */ |
281 | adapter->scsi_host = scsi_host_alloc(&zfcp_data.scsi_host_template, | 279 | adapter->scsi_host = scsi_host_alloc(&zfcp_data.scsi_host_template, |
282 | sizeof (struct zfcp_adapter *)); | 280 | sizeof (struct zfcp_adapter *)); |
283 | if (!adapter->scsi_host) { | 281 | if (!adapter->scsi_host) { |
284 | dev_err(&adapter->ccw_device->dev, | 282 | dev_err(&adapter->ccw_device->dev, |
285 | "Registering the FCP device with the " | 283 | "Registering the FCP device with the " |
286 | "SCSI stack failed\n"); | 284 | "SCSI stack failed\n"); |
287 | return -EIO; | 285 | return -EIO; |
288 | } | 286 | } |
289 | 287 | ||
290 | /* tell the SCSI stack some characteristics of this adapter */ | 288 | /* tell the SCSI stack some characteristics of this adapter */ |
291 | adapter->scsi_host->max_id = 1; | 289 | adapter->scsi_host->max_id = 1; |
292 | adapter->scsi_host->max_lun = 1; | 290 | adapter->scsi_host->max_lun = 1; |
293 | adapter->scsi_host->max_channel = 0; | 291 | adapter->scsi_host->max_channel = 0; |
294 | adapter->scsi_host->unique_id = dev_id.devno; | 292 | adapter->scsi_host->unique_id = dev_id.devno; |
295 | adapter->scsi_host->max_cmd_len = 255; | 293 | adapter->scsi_host->max_cmd_len = 255; |
296 | adapter->scsi_host->transportt = zfcp_data.scsi_transport_template; | 294 | adapter->scsi_host->transportt = zfcp_data.scsi_transport_template; |
297 | 295 | ||
298 | adapter->scsi_host->hostdata[0] = (unsigned long) adapter; | 296 | adapter->scsi_host->hostdata[0] = (unsigned long) adapter; |
299 | 297 | ||
300 | if (scsi_add_host(adapter->scsi_host, &adapter->ccw_device->dev)) { | 298 | if (scsi_add_host(adapter->scsi_host, &adapter->ccw_device->dev)) { |
301 | scsi_host_put(adapter->scsi_host); | 299 | scsi_host_put(adapter->scsi_host); |
302 | return -EIO; | 300 | return -EIO; |
303 | } | 301 | } |
304 | 302 | ||
305 | return 0; | 303 | return 0; |
306 | } | 304 | } |
307 | 305 | ||
308 | void zfcp_adapter_scsi_unregister(struct zfcp_adapter *adapter) | 306 | void zfcp_adapter_scsi_unregister(struct zfcp_adapter *adapter) |
309 | { | 307 | { |
310 | struct Scsi_Host *shost; | 308 | struct Scsi_Host *shost; |
311 | struct zfcp_port *port; | 309 | struct zfcp_port *port; |
312 | 310 | ||
313 | shost = adapter->scsi_host; | 311 | shost = adapter->scsi_host; |
314 | if (!shost) | 312 | if (!shost) |
315 | return; | 313 | return; |
316 | 314 | ||
317 | read_lock_irq(&zfcp_data.config_lock); | 315 | read_lock_irq(&zfcp_data.config_lock); |
318 | list_for_each_entry(port, &adapter->port_list_head, list) | 316 | list_for_each_entry(port, &adapter->port_list_head, list) |
319 | if (port->rport) | 317 | if (port->rport) |
320 | port->rport = NULL; | 318 | port->rport = NULL; |
321 | 319 | ||
322 | read_unlock_irq(&zfcp_data.config_lock); | 320 | read_unlock_irq(&zfcp_data.config_lock); |
323 | fc_remove_host(shost); | 321 | fc_remove_host(shost); |
324 | scsi_remove_host(shost); | 322 | scsi_remove_host(shost); |
325 | scsi_host_put(shost); | 323 | scsi_host_put(shost); |
326 | adapter->scsi_host = NULL; | 324 | adapter->scsi_host = NULL; |
327 | 325 | ||
328 | return; | 326 | return; |
329 | } | 327 | } |
330 | 328 | ||
331 | static struct fc_host_statistics* | 329 | static struct fc_host_statistics* |
332 | zfcp_init_fc_host_stats(struct zfcp_adapter *adapter) | 330 | zfcp_init_fc_host_stats(struct zfcp_adapter *adapter) |
333 | { | 331 | { |
334 | struct fc_host_statistics *fc_stats; | 332 | struct fc_host_statistics *fc_stats; |
335 | 333 | ||
336 | if (!adapter->fc_stats) { | 334 | if (!adapter->fc_stats) { |
337 | fc_stats = kmalloc(sizeof(*fc_stats), GFP_KERNEL); | 335 | fc_stats = kmalloc(sizeof(*fc_stats), GFP_KERNEL); |
338 | if (!fc_stats) | 336 | if (!fc_stats) |
339 | return NULL; | 337 | return NULL; |
340 | adapter->fc_stats = fc_stats; /* freed in adater_dequeue */ | 338 | adapter->fc_stats = fc_stats; /* freed in adater_dequeue */ |
341 | } | 339 | } |
342 | memset(adapter->fc_stats, 0, sizeof(*adapter->fc_stats)); | 340 | memset(adapter->fc_stats, 0, sizeof(*adapter->fc_stats)); |
343 | return adapter->fc_stats; | 341 | return adapter->fc_stats; |
344 | } | 342 | } |
345 | 343 | ||
346 | static void zfcp_adjust_fc_host_stats(struct fc_host_statistics *fc_stats, | 344 | static void zfcp_adjust_fc_host_stats(struct fc_host_statistics *fc_stats, |
347 | struct fsf_qtcb_bottom_port *data, | 345 | struct fsf_qtcb_bottom_port *data, |
348 | struct fsf_qtcb_bottom_port *old) | 346 | struct fsf_qtcb_bottom_port *old) |
349 | { | 347 | { |
350 | fc_stats->seconds_since_last_reset = | 348 | fc_stats->seconds_since_last_reset = |
351 | data->seconds_since_last_reset - old->seconds_since_last_reset; | 349 | data->seconds_since_last_reset - old->seconds_since_last_reset; |
352 | fc_stats->tx_frames = data->tx_frames - old->tx_frames; | 350 | fc_stats->tx_frames = data->tx_frames - old->tx_frames; |
353 | fc_stats->tx_words = data->tx_words - old->tx_words; | 351 | fc_stats->tx_words = data->tx_words - old->tx_words; |
354 | fc_stats->rx_frames = data->rx_frames - old->rx_frames; | 352 | fc_stats->rx_frames = data->rx_frames - old->rx_frames; |
355 | fc_stats->rx_words = data->rx_words - old->rx_words; | 353 | fc_stats->rx_words = data->rx_words - old->rx_words; |
356 | fc_stats->lip_count = data->lip - old->lip; | 354 | fc_stats->lip_count = data->lip - old->lip; |
357 | fc_stats->nos_count = data->nos - old->nos; | 355 | fc_stats->nos_count = data->nos - old->nos; |
358 | fc_stats->error_frames = data->error_frames - old->error_frames; | 356 | fc_stats->error_frames = data->error_frames - old->error_frames; |
359 | fc_stats->dumped_frames = data->dumped_frames - old->dumped_frames; | 357 | fc_stats->dumped_frames = data->dumped_frames - old->dumped_frames; |
360 | fc_stats->link_failure_count = data->link_failure - old->link_failure; | 358 | fc_stats->link_failure_count = data->link_failure - old->link_failure; |
361 | fc_stats->loss_of_sync_count = data->loss_of_sync - old->loss_of_sync; | 359 | fc_stats->loss_of_sync_count = data->loss_of_sync - old->loss_of_sync; |
362 | fc_stats->loss_of_signal_count = | 360 | fc_stats->loss_of_signal_count = |
363 | data->loss_of_signal - old->loss_of_signal; | 361 | data->loss_of_signal - old->loss_of_signal; |
364 | fc_stats->prim_seq_protocol_err_count = | 362 | fc_stats->prim_seq_protocol_err_count = |
365 | data->psp_error_counts - old->psp_error_counts; | 363 | data->psp_error_counts - old->psp_error_counts; |
366 | fc_stats->invalid_tx_word_count = | 364 | fc_stats->invalid_tx_word_count = |
367 | data->invalid_tx_words - old->invalid_tx_words; | 365 | data->invalid_tx_words - old->invalid_tx_words; |
368 | fc_stats->invalid_crc_count = data->invalid_crcs - old->invalid_crcs; | 366 | fc_stats->invalid_crc_count = data->invalid_crcs - old->invalid_crcs; |
369 | fc_stats->fcp_input_requests = | 367 | fc_stats->fcp_input_requests = |
370 | data->input_requests - old->input_requests; | 368 | data->input_requests - old->input_requests; |
371 | fc_stats->fcp_output_requests = | 369 | fc_stats->fcp_output_requests = |
372 | data->output_requests - old->output_requests; | 370 | data->output_requests - old->output_requests; |
373 | fc_stats->fcp_control_requests = | 371 | fc_stats->fcp_control_requests = |
374 | data->control_requests - old->control_requests; | 372 | data->control_requests - old->control_requests; |
375 | fc_stats->fcp_input_megabytes = data->input_mb - old->input_mb; | 373 | fc_stats->fcp_input_megabytes = data->input_mb - old->input_mb; |
376 | fc_stats->fcp_output_megabytes = data->output_mb - old->output_mb; | 374 | fc_stats->fcp_output_megabytes = data->output_mb - old->output_mb; |
377 | } | 375 | } |
378 | 376 | ||
379 | static void zfcp_set_fc_host_stats(struct fc_host_statistics *fc_stats, | 377 | static void zfcp_set_fc_host_stats(struct fc_host_statistics *fc_stats, |
380 | struct fsf_qtcb_bottom_port *data) | 378 | struct fsf_qtcb_bottom_port *data) |
381 | { | 379 | { |
382 | fc_stats->seconds_since_last_reset = data->seconds_since_last_reset; | 380 | fc_stats->seconds_since_last_reset = data->seconds_since_last_reset; |
383 | fc_stats->tx_frames = data->tx_frames; | 381 | fc_stats->tx_frames = data->tx_frames; |
384 | fc_stats->tx_words = data->tx_words; | 382 | fc_stats->tx_words = data->tx_words; |
385 | fc_stats->rx_frames = data->rx_frames; | 383 | fc_stats->rx_frames = data->rx_frames; |
386 | fc_stats->rx_words = data->rx_words; | 384 | fc_stats->rx_words = data->rx_words; |
387 | fc_stats->lip_count = data->lip; | 385 | fc_stats->lip_count = data->lip; |
388 | fc_stats->nos_count = data->nos; | 386 | fc_stats->nos_count = data->nos; |
389 | fc_stats->error_frames = data->error_frames; | 387 | fc_stats->error_frames = data->error_frames; |
390 | fc_stats->dumped_frames = data->dumped_frames; | 388 | fc_stats->dumped_frames = data->dumped_frames; |
391 | fc_stats->link_failure_count = data->link_failure; | 389 | fc_stats->link_failure_count = data->link_failure; |
392 | fc_stats->loss_of_sync_count = data->loss_of_sync; | 390 | fc_stats->loss_of_sync_count = data->loss_of_sync; |
393 | fc_stats->loss_of_signal_count = data->loss_of_signal; | 391 | fc_stats->loss_of_signal_count = data->loss_of_signal; |
394 | fc_stats->prim_seq_protocol_err_count = data->psp_error_counts; | 392 | fc_stats->prim_seq_protocol_err_count = data->psp_error_counts; |
395 | fc_stats->invalid_tx_word_count = data->invalid_tx_words; | 393 | fc_stats->invalid_tx_word_count = data->invalid_tx_words; |
396 | fc_stats->invalid_crc_count = data->invalid_crcs; | 394 | fc_stats->invalid_crc_count = data->invalid_crcs; |
397 | fc_stats->fcp_input_requests = data->input_requests; | 395 | fc_stats->fcp_input_requests = data->input_requests; |
398 | fc_stats->fcp_output_requests = data->output_requests; | 396 | fc_stats->fcp_output_requests = data->output_requests; |
399 | fc_stats->fcp_control_requests = data->control_requests; | 397 | fc_stats->fcp_control_requests = data->control_requests; |
400 | fc_stats->fcp_input_megabytes = data->input_mb; | 398 | fc_stats->fcp_input_megabytes = data->input_mb; |
401 | fc_stats->fcp_output_megabytes = data->output_mb; | 399 | fc_stats->fcp_output_megabytes = data->output_mb; |
402 | } | 400 | } |
403 | 401 | ||
404 | static struct fc_host_statistics *zfcp_get_fc_host_stats(struct Scsi_Host *host) | 402 | static struct fc_host_statistics *zfcp_get_fc_host_stats(struct Scsi_Host *host) |
405 | { | 403 | { |
406 | struct zfcp_adapter *adapter; | 404 | struct zfcp_adapter *adapter; |
407 | struct fc_host_statistics *fc_stats; | 405 | struct fc_host_statistics *fc_stats; |
408 | struct fsf_qtcb_bottom_port *data; | 406 | struct fsf_qtcb_bottom_port *data; |
409 | int ret; | 407 | int ret; |
410 | 408 | ||
411 | adapter = (struct zfcp_adapter *)host->hostdata[0]; | 409 | adapter = (struct zfcp_adapter *)host->hostdata[0]; |
412 | fc_stats = zfcp_init_fc_host_stats(adapter); | 410 | fc_stats = zfcp_init_fc_host_stats(adapter); |
413 | if (!fc_stats) | 411 | if (!fc_stats) |
414 | return NULL; | 412 | return NULL; |
415 | 413 | ||
416 | data = kzalloc(sizeof(*data), GFP_KERNEL); | 414 | data = kzalloc(sizeof(*data), GFP_KERNEL); |
417 | if (!data) | 415 | if (!data) |
418 | return NULL; | 416 | return NULL; |
419 | 417 | ||
420 | ret = zfcp_fsf_exchange_port_data_sync(adapter, data); | 418 | ret = zfcp_fsf_exchange_port_data_sync(adapter, data); |
421 | if (ret) { | 419 | if (ret) { |
422 | kfree(data); | 420 | kfree(data); |
423 | return NULL; | 421 | return NULL; |
424 | } | 422 | } |
425 | 423 | ||
426 | if (adapter->stats_reset && | 424 | if (adapter->stats_reset && |
427 | ((jiffies/HZ - adapter->stats_reset) < | 425 | ((jiffies/HZ - adapter->stats_reset) < |
428 | data->seconds_since_last_reset)) | 426 | data->seconds_since_last_reset)) |
429 | zfcp_adjust_fc_host_stats(fc_stats, data, | 427 | zfcp_adjust_fc_host_stats(fc_stats, data, |
430 | adapter->stats_reset_data); | 428 | adapter->stats_reset_data); |
431 | else | 429 | else |
432 | zfcp_set_fc_host_stats(fc_stats, data); | 430 | zfcp_set_fc_host_stats(fc_stats, data); |
433 | 431 | ||
434 | kfree(data); | 432 | kfree(data); |
435 | return fc_stats; | 433 | return fc_stats; |
436 | } | 434 | } |
437 | 435 | ||
438 | static void zfcp_reset_fc_host_stats(struct Scsi_Host *shost) | 436 | static void zfcp_reset_fc_host_stats(struct Scsi_Host *shost) |
439 | { | 437 | { |
440 | struct zfcp_adapter *adapter; | 438 | struct zfcp_adapter *adapter; |
441 | struct fsf_qtcb_bottom_port *data; | 439 | struct fsf_qtcb_bottom_port *data; |
442 | int ret; | 440 | int ret; |
443 | 441 | ||
444 | adapter = (struct zfcp_adapter *)shost->hostdata[0]; | 442 | adapter = (struct zfcp_adapter *)shost->hostdata[0]; |
445 | data = kzalloc(sizeof(*data), GFP_KERNEL); | 443 | data = kzalloc(sizeof(*data), GFP_KERNEL); |
446 | if (!data) | 444 | if (!data) |
447 | return; | 445 | return; |
448 | 446 | ||
449 | ret = zfcp_fsf_exchange_port_data_sync(adapter, data); | 447 | ret = zfcp_fsf_exchange_port_data_sync(adapter, data); |
450 | if (ret) | 448 | if (ret) |
451 | kfree(data); | 449 | kfree(data); |
452 | else { | 450 | else { |
453 | adapter->stats_reset = jiffies/HZ; | 451 | adapter->stats_reset = jiffies/HZ; |
454 | kfree(adapter->stats_reset_data); | 452 | kfree(adapter->stats_reset_data); |
455 | adapter->stats_reset_data = data; /* finally freed in | 453 | adapter->stats_reset_data = data; /* finally freed in |
456 | adapter_dequeue */ | 454 | adapter_dequeue */ |
457 | } | 455 | } |
458 | } | 456 | } |
459 | 457 | ||
460 | static void zfcp_get_host_port_state(struct Scsi_Host *shost) | 458 | static void zfcp_get_host_port_state(struct Scsi_Host *shost) |
461 | { | 459 | { |
462 | struct zfcp_adapter *adapter = | 460 | struct zfcp_adapter *adapter = |
463 | (struct zfcp_adapter *)shost->hostdata[0]; | 461 | (struct zfcp_adapter *)shost->hostdata[0]; |
464 | int status = atomic_read(&adapter->status); | 462 | int status = atomic_read(&adapter->status); |
465 | 463 | ||
466 | if ((status & ZFCP_STATUS_COMMON_RUNNING) && | 464 | if ((status & ZFCP_STATUS_COMMON_RUNNING) && |
467 | !(status & ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED)) | 465 | !(status & ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED)) |
468 | fc_host_port_state(shost) = FC_PORTSTATE_ONLINE; | 466 | fc_host_port_state(shost) = FC_PORTSTATE_ONLINE; |
469 | else if (status & ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED) | 467 | else if (status & ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED) |
470 | fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN; | 468 | fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN; |
471 | else if (status & ZFCP_STATUS_COMMON_ERP_FAILED) | 469 | else if (status & ZFCP_STATUS_COMMON_ERP_FAILED) |
472 | fc_host_port_state(shost) = FC_PORTSTATE_ERROR; | 470 | fc_host_port_state(shost) = FC_PORTSTATE_ERROR; |
473 | else | 471 | else |
474 | fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN; | 472 | fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN; |
475 | } | 473 | } |
476 | 474 | ||
477 | static void zfcp_set_rport_dev_loss_tmo(struct fc_rport *rport, u32 timeout) | 475 | static void zfcp_set_rport_dev_loss_tmo(struct fc_rport *rport, u32 timeout) |
478 | { | 476 | { |
479 | rport->dev_loss_tmo = timeout; | 477 | rport->dev_loss_tmo = timeout; |
480 | } | 478 | } |
481 | 479 | ||
482 | struct fc_function_template zfcp_transport_functions = { | 480 | struct fc_function_template zfcp_transport_functions = { |
483 | .show_starget_port_id = 1, | 481 | .show_starget_port_id = 1, |
484 | .show_starget_port_name = 1, | 482 | .show_starget_port_name = 1, |
485 | .show_starget_node_name = 1, | 483 | .show_starget_node_name = 1, |
486 | .show_rport_supported_classes = 1, | 484 | .show_rport_supported_classes = 1, |
487 | .show_rport_maxframe_size = 1, | 485 | .show_rport_maxframe_size = 1, |
488 | .show_rport_dev_loss_tmo = 1, | 486 | .show_rport_dev_loss_tmo = 1, |
489 | .show_host_node_name = 1, | 487 | .show_host_node_name = 1, |
490 | .show_host_port_name = 1, | 488 | .show_host_port_name = 1, |
491 | .show_host_permanent_port_name = 1, | 489 | .show_host_permanent_port_name = 1, |
492 | .show_host_supported_classes = 1, | 490 | .show_host_supported_classes = 1, |
493 | .show_host_supported_speeds = 1, | 491 | .show_host_supported_speeds = 1, |
494 | .show_host_maxframe_size = 1, | 492 | .show_host_maxframe_size = 1, |
495 | .show_host_serial_number = 1, | 493 | .show_host_serial_number = 1, |
496 | .get_fc_host_stats = zfcp_get_fc_host_stats, | 494 | .get_fc_host_stats = zfcp_get_fc_host_stats, |
497 | .reset_fc_host_stats = zfcp_reset_fc_host_stats, | 495 | .reset_fc_host_stats = zfcp_reset_fc_host_stats, |
498 | .set_rport_dev_loss_tmo = zfcp_set_rport_dev_loss_tmo, | 496 | .set_rport_dev_loss_tmo = zfcp_set_rport_dev_loss_tmo, |
499 | .get_host_port_state = zfcp_get_host_port_state, | 497 | .get_host_port_state = zfcp_get_host_port_state, |
500 | .show_host_port_state = 1, | 498 | .show_host_port_state = 1, |
501 | /* no functions registered for following dynamic attributes but | 499 | /* no functions registered for following dynamic attributes but |
502 | directly set by LLDD */ | 500 | directly set by LLDD */ |
503 | .show_host_port_type = 1, | 501 | .show_host_port_type = 1, |
504 | .show_host_speed = 1, | 502 | .show_host_speed = 1, |
505 | .show_host_port_id = 1, | 503 | .show_host_port_id = 1, |
506 | .disable_target_scan = 1, | 504 | .disable_target_scan = 1, |
507 | }; | 505 | }; |
508 | 506 | ||
509 | struct zfcp_data zfcp_data = { | 507 | struct zfcp_data zfcp_data = { |
510 | .scsi_host_template = { | 508 | .scsi_host_template = { |
511 | .name = "zfcp", | 509 | .name = "zfcp", |
512 | .module = THIS_MODULE, | 510 | .module = THIS_MODULE, |
513 | .proc_name = "zfcp", | 511 | .proc_name = "zfcp", |
514 | .slave_alloc = zfcp_scsi_slave_alloc, | 512 | .slave_alloc = zfcp_scsi_slave_alloc, |
515 | .slave_configure = zfcp_scsi_slave_configure, | 513 | .slave_configure = zfcp_scsi_slave_configure, |
516 | .slave_destroy = zfcp_scsi_slave_destroy, | 514 | .slave_destroy = zfcp_scsi_slave_destroy, |
517 | .queuecommand = zfcp_scsi_queuecommand, | 515 | .queuecommand = zfcp_scsi_queuecommand, |
518 | .eh_abort_handler = zfcp_scsi_eh_abort_handler, | 516 | .eh_abort_handler = zfcp_scsi_eh_abort_handler, |
519 | .eh_device_reset_handler = zfcp_scsi_eh_device_reset_handler, | 517 | .eh_device_reset_handler = zfcp_scsi_eh_device_reset_handler, |
520 | .eh_target_reset_handler = zfcp_scsi_eh_target_reset_handler, | 518 | .eh_target_reset_handler = zfcp_scsi_eh_target_reset_handler, |
521 | .eh_host_reset_handler = zfcp_scsi_eh_host_reset_handler, | 519 | .eh_host_reset_handler = zfcp_scsi_eh_host_reset_handler, |
522 | .can_queue = 4096, | 520 | .can_queue = 4096, |
523 | .this_id = -1, | 521 | .this_id = -1, |
524 | .sg_tablesize = ZFCP_MAX_SBALES_PER_REQ, | 522 | .sg_tablesize = ZFCP_MAX_SBALES_PER_REQ, |
525 | .cmd_per_lun = 1, | 523 | .cmd_per_lun = 1, |
526 | .use_clustering = 1, | 524 | .use_clustering = 1, |
527 | .sdev_attrs = zfcp_sysfs_sdev_attrs, | 525 | .sdev_attrs = zfcp_sysfs_sdev_attrs, |
528 | .max_sectors = (ZFCP_MAX_SBALES_PER_REQ * 8), | 526 | .max_sectors = (ZFCP_MAX_SBALES_PER_REQ * 8), |
529 | .shost_attrs = zfcp_sysfs_shost_attrs, | 527 | .shost_attrs = zfcp_sysfs_shost_attrs, |
530 | }, | 528 | }, |
531 | }; | 529 | }; |
532 | 530 |