[SCSI] zfcp: remove invalid reference to list iterator variable
[deliverable/linux.git] / drivers / s390 / scsi / zfcp_sysfs.c
CommitLineData
60221920
SS
1/*
2 * zfcp device driver
3 *
4 * sysfs attributes.
5 *
a53c8fab 6 * Copyright IBM Corp. 2008, 2010
60221920
SS
7 */
8
ecf39d42
CS
9#define KMSG_COMPONENT "zfcp"
10#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
11
5a0e3ad6 12#include <linux/slab.h>
60221920
SS
13#include "zfcp_ext.h"
14
15#define ZFCP_DEV_ATTR(_feat, _name, _mode, _show, _store) \
16struct device_attribute dev_attr_##_feat##_##_name = __ATTR(_name, _mode,\
17 _show, _store)
18#define ZFCP_DEFINE_ATTR(_feat_def, _feat, _name, _format, _value) \
19static ssize_t zfcp_sysfs_##_feat##_##_name##_show(struct device *dev, \
20 struct device_attribute *at,\
21 char *buf) \
22{ \
615f59e0 23 struct _feat_def *_feat = container_of(dev, struct _feat_def, dev); \
60221920
SS
24 \
25 return sprintf(buf, _format, _value); \
26} \
27static ZFCP_DEV_ATTR(_feat, _name, S_IRUGO, \
28 zfcp_sysfs_##_feat##_##_name##_show, NULL);
29
de3dc572
SS
30#define ZFCP_DEFINE_A_ATTR(_name, _format, _value) \
31static ssize_t zfcp_sysfs_adapter_##_name##_show(struct device *dev, \
32 struct device_attribute *at,\
33 char *buf) \
34{ \
35 struct ccw_device *cdev = to_ccwdev(dev); \
36 struct zfcp_adapter *adapter = zfcp_ccw_adapter_by_cdev(cdev); \
37 int i; \
38 \
39 if (!adapter) \
40 return -ENODEV; \
41 \
42 i = sprintf(buf, _format, _value); \
43 zfcp_ccw_adapter_put(adapter); \
44 return i; \
45} \
46static ZFCP_DEV_ATTR(adapter, _name, S_IRUGO, \
47 zfcp_sysfs_adapter_##_name##_show, NULL);
48
49ZFCP_DEFINE_A_ATTR(status, "0x%08x\n", atomic_read(&adapter->status));
50ZFCP_DEFINE_A_ATTR(peer_wwnn, "0x%016llx\n",
51 (unsigned long long) adapter->peer_wwnn);
52ZFCP_DEFINE_A_ATTR(peer_wwpn, "0x%016llx\n",
53 (unsigned long long) adapter->peer_wwpn);
54ZFCP_DEFINE_A_ATTR(peer_d_id, "0x%06x\n", adapter->peer_d_id);
55ZFCP_DEFINE_A_ATTR(card_version, "0x%04x\n", adapter->hydra_version);
56ZFCP_DEFINE_A_ATTR(lic_version, "0x%08x\n", adapter->fsf_lic_version);
57ZFCP_DEFINE_A_ATTR(hardware_version, "0x%08x\n", adapter->hardware_version);
58ZFCP_DEFINE_A_ATTR(in_recovery, "%d\n", (atomic_read(&adapter->status) &
59 ZFCP_STATUS_COMMON_ERP_INUSE) != 0);
60221920
SS
60
61ZFCP_DEFINE_ATTR(zfcp_port, port, status, "0x%08x\n",
62 atomic_read(&port->status));
63ZFCP_DEFINE_ATTR(zfcp_port, port, in_recovery, "%d\n",
64 (atomic_read(&port->status) &
65 ZFCP_STATUS_COMMON_ERP_INUSE) != 0);
66ZFCP_DEFINE_ATTR(zfcp_port, port, access_denied, "%d\n",
67 (atomic_read(&port->status) &
68 ZFCP_STATUS_COMMON_ACCESS_DENIED) != 0);
69
70ZFCP_DEFINE_ATTR(zfcp_unit, unit, status, "0x%08x\n",
b62a8d9b 71 zfcp_unit_sdev_status(unit));
60221920 72ZFCP_DEFINE_ATTR(zfcp_unit, unit, in_recovery, "%d\n",
b62a8d9b 73 (zfcp_unit_sdev_status(unit) &
60221920
SS
74 ZFCP_STATUS_COMMON_ERP_INUSE) != 0);
75ZFCP_DEFINE_ATTR(zfcp_unit, unit, access_denied, "%d\n",
b62a8d9b 76 (zfcp_unit_sdev_status(unit) &
60221920
SS
77 ZFCP_STATUS_COMMON_ACCESS_DENIED) != 0);
78ZFCP_DEFINE_ATTR(zfcp_unit, unit, access_shared, "%d\n",
b62a8d9b
CS
79 (zfcp_unit_sdev_status(unit) &
80 ZFCP_STATUS_LUN_SHARED) != 0);
60221920 81ZFCP_DEFINE_ATTR(zfcp_unit, unit, access_readonly, "%d\n",
b62a8d9b
CS
82 (zfcp_unit_sdev_status(unit) &
83 ZFCP_STATUS_LUN_READONLY) != 0);
60221920 84
e4b9857f
CS
85static ssize_t zfcp_sysfs_port_failed_show(struct device *dev,
86 struct device_attribute *attr,
87 char *buf)
88{
89 struct zfcp_port *port = container_of(dev, struct zfcp_port, dev);
60221920 90
e4b9857f
CS
91 if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED)
92 return sprintf(buf, "1\n");
93
94 return sprintf(buf, "0\n");
95}
96
97static ssize_t zfcp_sysfs_port_failed_store(struct device *dev,
98 struct device_attribute *attr,
99 const char *buf, size_t count)
100{
101 struct zfcp_port *port = container_of(dev, struct zfcp_port, dev);
102 unsigned long val;
103
104 if (strict_strtoul(buf, 0, &val) || val != 0)
105 return -EINVAL;
106
edaed859 107 zfcp_erp_set_port_status(port, ZFCP_STATUS_COMMON_RUNNING);
ea4a3a6a 108 zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED, "sypfai2");
e4b9857f
CS
109 zfcp_erp_wait(port->adapter);
110
111 return count;
112}
113static ZFCP_DEV_ATTR(port, failed, S_IWUSR | S_IRUGO,
114 zfcp_sysfs_port_failed_show,
115 zfcp_sysfs_port_failed_store);
116
117static ssize_t zfcp_sysfs_unit_failed_show(struct device *dev,
118 struct device_attribute *attr,
119 char *buf)
120{
121 struct zfcp_unit *unit = container_of(dev, struct zfcp_unit, dev);
b62a8d9b
CS
122 struct scsi_device *sdev;
123 unsigned int status, failed = 1;
124
125 sdev = zfcp_unit_sdev(unit);
126 if (sdev) {
127 status = atomic_read(&sdev_to_zfcp(sdev)->status);
128 failed = status & ZFCP_STATUS_COMMON_ERP_FAILED ? 1 : 0;
129 scsi_device_put(sdev);
130 }
e4b9857f 131
b62a8d9b 132 return sprintf(buf, "%d\n", failed);
e4b9857f
CS
133}
134
135static ssize_t zfcp_sysfs_unit_failed_store(struct device *dev,
136 struct device_attribute *attr,
137 const char *buf, size_t count)
138{
139 struct zfcp_unit *unit = container_of(dev, struct zfcp_unit, dev);
140 unsigned long val;
b62a8d9b 141 struct scsi_device *sdev;
e4b9857f
CS
142
143 if (strict_strtoul(buf, 0, &val) || val != 0)
144 return -EINVAL;
145
b62a8d9b
CS
146 sdev = zfcp_unit_sdev(unit);
147 if (sdev) {
edaed859 148 zfcp_erp_set_lun_status(sdev, ZFCP_STATUS_COMMON_RUNNING);
b62a8d9b 149 zfcp_erp_lun_reopen(sdev, ZFCP_STATUS_COMMON_ERP_FAILED,
ea4a3a6a 150 "syufai2");
b62a8d9b
CS
151 zfcp_erp_wait(unit->port->adapter);
152 } else
153 zfcp_unit_scsi_scan(unit);
e4b9857f
CS
154
155 return count;
156}
157static ZFCP_DEV_ATTR(unit, failed, S_IWUSR | S_IRUGO,
158 zfcp_sysfs_unit_failed_show,
159 zfcp_sysfs_unit_failed_store);
60221920 160
de3dc572
SS
161static ssize_t zfcp_sysfs_adapter_failed_show(struct device *dev,
162 struct device_attribute *attr,
163 char *buf)
164{
165 struct ccw_device *cdev = to_ccwdev(dev);
166 struct zfcp_adapter *adapter = zfcp_ccw_adapter_by_cdev(cdev);
167 int i;
168
169 if (!adapter)
170 return -ENODEV;
171
172 if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_ERP_FAILED)
173 i = sprintf(buf, "1\n");
174 else
175 i = sprintf(buf, "0\n");
176
177 zfcp_ccw_adapter_put(adapter);
178 return i;
179}
180
181static ssize_t zfcp_sysfs_adapter_failed_store(struct device *dev,
182 struct device_attribute *attr,
183 const char *buf, size_t count)
184{
185 struct ccw_device *cdev = to_ccwdev(dev);
186 struct zfcp_adapter *adapter = zfcp_ccw_adapter_by_cdev(cdev);
187 unsigned long val;
188 int retval = 0;
189
190 if (!adapter)
191 return -ENODEV;
192
de3dc572
SS
193 if (strict_strtoul(buf, 0, &val) || val != 0) {
194 retval = -EINVAL;
195 goto out;
196 }
197
edaed859 198 zfcp_erp_set_adapter_status(adapter, ZFCP_STATUS_COMMON_RUNNING);
de3dc572 199 zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED,
ea4a3a6a 200 "syafai2");
de3dc572
SS
201 zfcp_erp_wait(adapter);
202out:
203 zfcp_ccw_adapter_put(adapter);
204 return retval ? retval : (ssize_t) count;
205}
206static ZFCP_DEV_ATTR(adapter, failed, S_IWUSR | S_IRUGO,
207 zfcp_sysfs_adapter_failed_show,
208 zfcp_sysfs_adapter_failed_store);
209
60221920
SS
210static ssize_t zfcp_sysfs_port_rescan_store(struct device *dev,
211 struct device_attribute *attr,
212 const char *buf, size_t count)
213{
de3dc572
SS
214 struct ccw_device *cdev = to_ccwdev(dev);
215 struct zfcp_adapter *adapter = zfcp_ccw_adapter_by_cdev(cdev);
60221920 216
de3dc572
SS
217 if (!adapter)
218 return -ENODEV;
219
9eae07ef
SS
220 /* sync the user-space- with the kernel-invocation of scan_work */
221 queue_work(adapter->work_queue, &adapter->scan_work);
222 flush_work(&adapter->scan_work);
de3dc572 223 zfcp_ccw_adapter_put(adapter);
6b183334 224
9eae07ef 225 return (ssize_t) count;
60221920
SS
226}
227static ZFCP_DEV_ATTR(adapter, port_rescan, S_IWUSR, NULL,
228 zfcp_sysfs_port_rescan_store);
229
230static ssize_t zfcp_sysfs_port_remove_store(struct device *dev,
231 struct device_attribute *attr,
232 const char *buf, size_t count)
233{
de3dc572
SS
234 struct ccw_device *cdev = to_ccwdev(dev);
235 struct zfcp_adapter *adapter = zfcp_ccw_adapter_by_cdev(cdev);
60221920 236 struct zfcp_port *port;
7ba58c9c 237 u64 wwpn;
6b183334 238 int retval = -EINVAL;
60221920 239
de3dc572
SS
240 if (!adapter)
241 return -ENODEV;
242
6b183334 243 if (strict_strtoull(buf, 0, (unsigned long long *) &wwpn))
60221920 244 goto out;
60221920 245
60221920 246 port = zfcp_get_port_by_wwpn(adapter, wwpn);
6b183334 247 if (!port)
60221920 248 goto out;
6b183334
SS
249 else
250 retval = 0;
f3450c7b
SS
251
252 write_lock_irq(&adapter->port_list_lock);
253 list_del(&port->list);
254 write_unlock_irq(&adapter->port_list_lock);
255
615f59e0 256 put_device(&port->dev);
f3450c7b 257
ea4a3a6a 258 zfcp_erp_port_shutdown(port, 0, "syprs_1");
615f59e0 259 zfcp_device_unregister(&port->dev, &zfcp_sysfs_port_attrs);
60221920 260 out:
de3dc572 261 zfcp_ccw_adapter_put(adapter);
60221920
SS
262 return retval ? retval : (ssize_t) count;
263}
264static ZFCP_DEV_ATTR(adapter, port_remove, S_IWUSR, NULL,
265 zfcp_sysfs_port_remove_store);
266
267static struct attribute *zfcp_adapter_attrs[] = {
268 &dev_attr_adapter_failed.attr,
269 &dev_attr_adapter_in_recovery.attr,
270 &dev_attr_adapter_port_remove.attr,
271 &dev_attr_adapter_port_rescan.attr,
272 &dev_attr_adapter_peer_wwnn.attr,
273 &dev_attr_adapter_peer_wwpn.attr,
274 &dev_attr_adapter_peer_d_id.attr,
275 &dev_attr_adapter_card_version.attr,
276 &dev_attr_adapter_lic_version.attr,
277 &dev_attr_adapter_status.attr,
278 &dev_attr_adapter_hardware_version.attr,
279 NULL
280};
281
282struct attribute_group zfcp_sysfs_adapter_attrs = {
283 .attrs = zfcp_adapter_attrs,
284};
285
286static ssize_t zfcp_sysfs_unit_add_store(struct device *dev,
287 struct device_attribute *attr,
288 const char *buf, size_t count)
289{
615f59e0 290 struct zfcp_port *port = container_of(dev, struct zfcp_port, dev);
7ba58c9c 291 u64 fcp_lun;
60221920 292
7ba58c9c 293 if (strict_strtoull(buf, 0, (unsigned long long *) &fcp_lun))
1daa4eb5 294 return -EINVAL;
60221920 295
1daa4eb5
CS
296 if (zfcp_unit_add(port, fcp_lun))
297 return -EINVAL;
60221920 298
1daa4eb5 299 return count;
60221920
SS
300}
301static DEVICE_ATTR(unit_add, S_IWUSR, NULL, zfcp_sysfs_unit_add_store);
302
303static ssize_t zfcp_sysfs_unit_remove_store(struct device *dev,
304 struct device_attribute *attr,
305 const char *buf, size_t count)
306{
615f59e0 307 struct zfcp_port *port = container_of(dev, struct zfcp_port, dev);
7ba58c9c 308 u64 fcp_lun;
60221920 309
6b183334 310 if (strict_strtoull(buf, 0, (unsigned long long *) &fcp_lun))
1daa4eb5 311 return -EINVAL;
60221920 312
1daa4eb5
CS
313 if (zfcp_unit_remove(port, fcp_lun))
314 return -EINVAL;
ecf0c772 315
1daa4eb5 316 return count;
60221920
SS
317}
318static DEVICE_ATTR(unit_remove, S_IWUSR, NULL, zfcp_sysfs_unit_remove_store);
319
5ab944f9 320static struct attribute *zfcp_port_attrs[] = {
60221920
SS
321 &dev_attr_unit_add.attr,
322 &dev_attr_unit_remove.attr,
323 &dev_attr_port_failed.attr,
324 &dev_attr_port_in_recovery.attr,
325 &dev_attr_port_status.attr,
326 &dev_attr_port_access_denied.attr,
327 NULL
328};
329
330/**
331 * zfcp_sysfs_port_attrs - sysfs attributes for all other ports
332 */
333struct attribute_group zfcp_sysfs_port_attrs = {
5ab944f9 334 .attrs = zfcp_port_attrs,
60221920
SS
335};
336
337static struct attribute *zfcp_unit_attrs[] = {
338 &dev_attr_unit_failed.attr,
339 &dev_attr_unit_in_recovery.attr,
340 &dev_attr_unit_status.attr,
341 &dev_attr_unit_access_denied.attr,
342 &dev_attr_unit_access_shared.attr,
343 &dev_attr_unit_access_readonly.attr,
344 NULL
345};
346
347struct attribute_group zfcp_sysfs_unit_attrs = {
348 .attrs = zfcp_unit_attrs,
349};
350
351#define ZFCP_DEFINE_LATENCY_ATTR(_name) \
352static ssize_t \
353zfcp_sysfs_unit_##_name##_latency_show(struct device *dev, \
354 struct device_attribute *attr, \
355 char *buf) { \
356 struct scsi_device *sdev = to_scsi_device(dev); \
b62a8d9b
CS
357 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); \
358 struct zfcp_latencies *lat = &zfcp_sdev->latencies; \
359 struct zfcp_adapter *adapter = zfcp_sdev->port->adapter; \
60221920
SS
360 unsigned long long fsum, fmin, fmax, csum, cmin, cmax, cc; \
361 \
49f0f01c 362 spin_lock_bh(&lat->lock); \
60221920
SS
363 fsum = lat->_name.fabric.sum * adapter->timer_ticks; \
364 fmin = lat->_name.fabric.min * adapter->timer_ticks; \
365 fmax = lat->_name.fabric.max * adapter->timer_ticks; \
366 csum = lat->_name.channel.sum * adapter->timer_ticks; \
367 cmin = lat->_name.channel.min * adapter->timer_ticks; \
368 cmax = lat->_name.channel.max * adapter->timer_ticks; \
369 cc = lat->_name.counter; \
49f0f01c 370 spin_unlock_bh(&lat->lock); \
60221920
SS
371 \
372 do_div(fsum, 1000); \
373 do_div(fmin, 1000); \
374 do_div(fmax, 1000); \
375 do_div(csum, 1000); \
376 do_div(cmin, 1000); \
377 do_div(cmax, 1000); \
378 \
379 return sprintf(buf, "%llu %llu %llu %llu %llu %llu %llu\n", \
380 fmin, fmax, fsum, cmin, cmax, csum, cc); \
381} \
382static ssize_t \
383zfcp_sysfs_unit_##_name##_latency_store(struct device *dev, \
384 struct device_attribute *attr, \
385 const char *buf, size_t count) \
386{ \
387 struct scsi_device *sdev = to_scsi_device(dev); \
b62a8d9b
CS
388 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); \
389 struct zfcp_latencies *lat = &zfcp_sdev->latencies; \
60221920
SS
390 unsigned long flags; \
391 \
392 spin_lock_irqsave(&lat->lock, flags); \
393 lat->_name.fabric.sum = 0; \
394 lat->_name.fabric.min = 0xFFFFFFFF; \
395 lat->_name.fabric.max = 0; \
396 lat->_name.channel.sum = 0; \
397 lat->_name.channel.min = 0xFFFFFFFF; \
398 lat->_name.channel.max = 0; \
399 lat->_name.counter = 0; \
400 spin_unlock_irqrestore(&lat->lock, flags); \
401 \
402 return (ssize_t) count; \
403} \
404static DEVICE_ATTR(_name##_latency, S_IWUSR | S_IRUGO, \
405 zfcp_sysfs_unit_##_name##_latency_show, \
406 zfcp_sysfs_unit_##_name##_latency_store);
407
408ZFCP_DEFINE_LATENCY_ATTR(read);
409ZFCP_DEFINE_LATENCY_ATTR(write);
410ZFCP_DEFINE_LATENCY_ATTR(cmd);
411
412#define ZFCP_DEFINE_SCSI_ATTR(_name, _format, _value) \
413static ssize_t zfcp_sysfs_scsi_##_name##_show(struct device *dev, \
414 struct device_attribute *attr,\
415 char *buf) \
416{ \
b62a8d9b
CS
417 struct scsi_device *sdev = to_scsi_device(dev); \
418 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); \
419 struct zfcp_port *port = zfcp_sdev->port; \
60221920
SS
420 \
421 return sprintf(buf, _format, _value); \
422} \
423static DEVICE_ATTR(_name, S_IRUGO, zfcp_sysfs_scsi_##_name##_show, NULL);
424
425ZFCP_DEFINE_SCSI_ATTR(hba_id, "%s\n",
b62a8d9b 426 dev_name(&port->adapter->ccw_device->dev));
7ba58c9c 427ZFCP_DEFINE_SCSI_ATTR(wwpn, "0x%016llx\n",
b62a8d9b 428 (unsigned long long) port->wwpn);
e4b9857f
CS
429
430static ssize_t zfcp_sysfs_scsi_fcp_lun_show(struct device *dev,
431 struct device_attribute *attr,
432 char *buf)
433{
434 struct scsi_device *sdev = to_scsi_device(dev);
e4b9857f 435
b62a8d9b 436 return sprintf(buf, "0x%016llx\n", zfcp_scsi_dev_lun(sdev));
e4b9857f
CS
437}
438static DEVICE_ATTR(fcp_lun, S_IRUGO, zfcp_sysfs_scsi_fcp_lun_show, NULL);
60221920
SS
439
440struct device_attribute *zfcp_sysfs_sdev_attrs[] = {
441 &dev_attr_fcp_lun,
442 &dev_attr_wwpn,
443 &dev_attr_hba_id,
444 &dev_attr_read_latency,
445 &dev_attr_write_latency,
446 &dev_attr_cmd_latency,
447 NULL
448};
449
450static ssize_t zfcp_sysfs_adapter_util_show(struct device *dev,
451 struct device_attribute *attr,
452 char *buf)
453{
454 struct Scsi_Host *scsi_host = dev_to_shost(dev);
455 struct fsf_qtcb_bottom_port *qtcb_port;
456 struct zfcp_adapter *adapter;
457 int retval;
458
459 adapter = (struct zfcp_adapter *) scsi_host->hostdata[0];
460 if (!(adapter->adapter_features & FSF_FEATURE_MEASUREMENT_DATA))
461 return -EOPNOTSUPP;
462
463 qtcb_port = kzalloc(sizeof(struct fsf_qtcb_bottom_port), GFP_KERNEL);
464 if (!qtcb_port)
465 return -ENOMEM;
466
564e1c86 467 retval = zfcp_fsf_exchange_port_data_sync(adapter->qdio, qtcb_port);
60221920
SS
468 if (!retval)
469 retval = sprintf(buf, "%u %u %u\n", qtcb_port->cp_util,
470 qtcb_port->cb_util, qtcb_port->a_util);
471 kfree(qtcb_port);
472 return retval;
473}
474static DEVICE_ATTR(utilization, S_IRUGO, zfcp_sysfs_adapter_util_show, NULL);
475
476static int zfcp_sysfs_adapter_ex_config(struct device *dev,
477 struct fsf_statistics_info *stat_inf)
478{
479 struct Scsi_Host *scsi_host = dev_to_shost(dev);
480 struct fsf_qtcb_bottom_config *qtcb_config;
481 struct zfcp_adapter *adapter;
482 int retval;
483
484 adapter = (struct zfcp_adapter *) scsi_host->hostdata[0];
485 if (!(adapter->adapter_features & FSF_FEATURE_MEASUREMENT_DATA))
486 return -EOPNOTSUPP;
487
488 qtcb_config = kzalloc(sizeof(struct fsf_qtcb_bottom_config),
489 GFP_KERNEL);
490 if (!qtcb_config)
491 return -ENOMEM;
492
564e1c86 493 retval = zfcp_fsf_exchange_config_data_sync(adapter->qdio, qtcb_config);
60221920
SS
494 if (!retval)
495 *stat_inf = qtcb_config->stat_info;
496
497 kfree(qtcb_config);
498 return retval;
499}
500
501#define ZFCP_SHOST_ATTR(_name, _format, _arg...) \
502static ssize_t zfcp_sysfs_adapter_##_name##_show(struct device *dev, \
503 struct device_attribute *attr,\
504 char *buf) \
505{ \
506 struct fsf_statistics_info stat_info; \
507 int retval; \
508 \
509 retval = zfcp_sysfs_adapter_ex_config(dev, &stat_info); \
510 if (retval) \
511 return retval; \
512 \
513 return sprintf(buf, _format, ## _arg); \
514} \
515static DEVICE_ATTR(_name, S_IRUGO, zfcp_sysfs_adapter_##_name##_show, NULL);
516
517ZFCP_SHOST_ATTR(requests, "%llu %llu %llu\n",
518 (unsigned long long) stat_info.input_req,
519 (unsigned long long) stat_info.output_req,
520 (unsigned long long) stat_info.control_req);
521
522ZFCP_SHOST_ATTR(megabytes, "%llu %llu\n",
523 (unsigned long long) stat_info.input_mb,
524 (unsigned long long) stat_info.output_mb);
525
526ZFCP_SHOST_ATTR(seconds_active, "%llu\n",
527 (unsigned long long) stat_info.seconds_act);
528
2450d3e7
SR
529static ssize_t zfcp_sysfs_adapter_q_full_show(struct device *dev,
530 struct device_attribute *attr,
531 char *buf)
532{
533 struct Scsi_Host *scsi_host = class_to_shost(dev);
564e1c86
SS
534 struct zfcp_qdio *qdio =
535 ((struct zfcp_adapter *) scsi_host->hostdata[0])->qdio;
acf7b861
CS
536 u64 util;
537
564e1c86
SS
538 spin_lock_bh(&qdio->stat_lock);
539 util = qdio->req_q_util;
540 spin_unlock_bh(&qdio->stat_lock);
2450d3e7 541
564e1c86 542 return sprintf(buf, "%d %llu\n", atomic_read(&qdio->req_q_full),
acf7b861 543 (unsigned long long)util);
2450d3e7
SR
544}
545static DEVICE_ATTR(queue_full, S_IRUGO, zfcp_sysfs_adapter_q_full_show, NULL);
546
60221920
SS
547struct device_attribute *zfcp_sysfs_shost_attrs[] = {
548 &dev_attr_utilization,
549 &dev_attr_requests,
550 &dev_attr_megabytes,
551 &dev_attr_seconds_active,
2450d3e7 552 &dev_attr_queue_full,
60221920
SS
553 NULL
554};
This page took 0.375119 seconds and 5 git commands to generate.