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