aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/scsi/zfcp_scsi.c
diff options
context:
space:
mode:
authorSwen Schillig <swen@vnet.ibm.com>2008-07-02 04:56:38 -0400
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-07-12 09:22:35 -0400
commit60221920706a01bef89af2577f9a90a8eeb4e662 (patch)
treef8b38412351e8be78c6f24524d963a08032fb2a1 /drivers/s390/scsi/zfcp_scsi.c
parent317e6b6519b5a34263a33f150ed57ad468b26a64 (diff)
[SCSI] zfcp: consolidate sysfs things into one file.
zfcp was using three files to deal with sysfs representation for adapters, ports and units. The consolidation into one file prevents code-duplication and eases maintainability. Signed-off-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>
Diffstat (limited to 'drivers/s390/scsi/zfcp_scsi.c')
-rw-r--r--drivers/s390/scsi/zfcp_scsi.c206
1 files changed, 1 insertions, 205 deletions
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index f8594a2e3f5c..e6d8ea8051af 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -520,209 +520,6 @@ struct fc_function_template zfcp_transport_functions = {
520 .disable_target_scan = 1, 520 .disable_target_scan = 1,
521}; 521};
522 522
523#define ZFCP_DEFINE_LATENCY_ATTR(_name) \
524static ssize_t \
525zfcp_sysfs_unit_##_name##_latency_show(struct device *dev, \
526 struct device_attribute *attr, \
527 char *buf) { \
528 struct scsi_device *sdev = to_scsi_device(dev); \
529 struct zfcp_unit *unit = sdev->hostdata; \
530 struct zfcp_latencies *lat = &unit->latencies; \
531 struct zfcp_adapter *adapter = unit->port->adapter; \
532 unsigned long flags; \
533 unsigned long long fsum, fmin, fmax, csum, cmin, cmax, cc; \
534 \
535 spin_lock_irqsave(&lat->lock, flags); \
536 fsum = lat->_name.fabric.sum * adapter->timer_ticks; \
537 fmin = lat->_name.fabric.min * adapter->timer_ticks; \
538 fmax = lat->_name.fabric.max * adapter->timer_ticks; \
539 csum = lat->_name.channel.sum * adapter->timer_ticks; \
540 cmin = lat->_name.channel.min * adapter->timer_ticks; \
541 cmax = lat->_name.channel.max * adapter->timer_ticks; \
542 cc = lat->_name.counter; \
543 spin_unlock_irqrestore(&lat->lock, flags); \
544 \
545 do_div(fsum, 1000); \
546 do_div(fmin, 1000); \
547 do_div(fmax, 1000); \
548 do_div(csum, 1000); \
549 do_div(cmin, 1000); \
550 do_div(cmax, 1000); \
551 \
552 return sprintf(buf, "%llu %llu %llu %llu %llu %llu %llu\n", \
553 fmin, fmax, fsum, cmin, cmax, csum, cc); \
554} \
555static ssize_t \
556zfcp_sysfs_unit_##_name##_latency_store(struct device *dev, \
557 struct device_attribute *attr, \
558 const char *buf, size_t count) \
559{ \
560 struct scsi_device *sdev = to_scsi_device(dev); \
561 struct zfcp_unit *unit = sdev->hostdata; \
562 struct zfcp_latencies *lat = &unit->latencies; \
563 unsigned long flags; \
564 \
565 spin_lock_irqsave(&lat->lock, flags); \
566 lat->_name.fabric.sum = 0; \
567 lat->_name.fabric.min = 0xFFFFFFFF; \
568 lat->_name.fabric.max = 0; \
569 lat->_name.channel.sum = 0; \
570 lat->_name.channel.min = 0xFFFFFFFF; \
571 lat->_name.channel.max = 0; \
572 lat->_name.counter = 0; \
573 spin_unlock_irqrestore(&lat->lock, flags); \
574 \
575 return (ssize_t) count; \
576} \
577static DEVICE_ATTR(_name##_latency, S_IWUSR | S_IRUGO, \
578 zfcp_sysfs_unit_##_name##_latency_show, \
579 zfcp_sysfs_unit_##_name##_latency_store);
580
581ZFCP_DEFINE_LATENCY_ATTR(read);
582ZFCP_DEFINE_LATENCY_ATTR(write);
583ZFCP_DEFINE_LATENCY_ATTR(cmd);
584
585#define ZFCP_DEFINE_SCSI_ATTR(_name, _format, _value) \
586static ssize_t zfcp_sysfs_scsi_##_name##_show(struct device *dev, struct device_attribute *attr, \
587 char *buf) \
588{ \
589 struct scsi_device *sdev; \
590 struct zfcp_unit *unit; \
591 \
592 sdev = to_scsi_device(dev); \
593 unit = sdev->hostdata; \
594 return sprintf(buf, _format, _value); \
595} \
596 \
597static DEVICE_ATTR(_name, S_IRUGO, zfcp_sysfs_scsi_##_name##_show, NULL);
598
599ZFCP_DEFINE_SCSI_ATTR(hba_id, "%s\n",
600 unit->port->adapter->ccw_device->dev.bus_id);
601ZFCP_DEFINE_SCSI_ATTR(wwpn, "0x%016llx\n", unit->port->wwpn);
602ZFCP_DEFINE_SCSI_ATTR(fcp_lun, "0x%016llx\n", unit->fcp_lun);
603
604static struct device_attribute *zfcp_sysfs_sdev_attrs[] = {
605 &dev_attr_fcp_lun,
606 &dev_attr_wwpn,
607 &dev_attr_hba_id,
608 &dev_attr_read_latency,
609 &dev_attr_write_latency,
610 &dev_attr_cmd_latency,
611 NULL
612};
613
614static ssize_t zfcp_sysfs_adapter_util_show(struct device *dev,
615 struct device_attribute *attr,
616 char *buf)
617{
618 struct Scsi_Host *scsi_host = dev_to_shost(dev);
619 struct fsf_qtcb_bottom_port *qtcb_port;
620 struct zfcp_adapter *adapter;
621 int retval;
622
623 adapter = (struct zfcp_adapter *) scsi_host->hostdata[0];
624 if (!(adapter->adapter_features & FSF_FEATURE_MEASUREMENT_DATA))
625 return -EOPNOTSUPP;
626
627 qtcb_port = kzalloc(sizeof(struct fsf_qtcb_bottom_port), GFP_KERNEL);
628 if (!qtcb_port)
629 return -ENOMEM;
630
631 retval = zfcp_fsf_exchange_port_data_sync(adapter, qtcb_port);
632 if (!retval)
633 retval = sprintf(buf, "%u %u %u\n", qtcb_port->cp_util,
634 qtcb_port->cb_util, qtcb_port->a_util);
635 kfree(qtcb_port);
636 return retval;
637}
638
639static int zfcp_sysfs_adapter_ex_config(struct device *dev,
640 struct fsf_statistics_info *stat_inf)
641{
642 struct Scsi_Host *scsi_host = dev_to_shost(dev);
643 struct fsf_qtcb_bottom_config *qtcb_config;
644 struct zfcp_adapter *adapter;
645 int retval;
646
647 adapter = (struct zfcp_adapter *) scsi_host->hostdata[0];
648 if (!(adapter->adapter_features & FSF_FEATURE_MEASUREMENT_DATA))
649 return -EOPNOTSUPP;
650
651 qtcb_config = kzalloc(sizeof(struct fsf_qtcb_bottom_config),
652 GFP_KERNEL);
653 if (!qtcb_config)
654 return -ENOMEM;
655
656 retval = zfcp_fsf_exchange_config_data_sync(adapter, qtcb_config);
657 if (!retval)
658 *stat_inf = qtcb_config->stat_info;
659
660 kfree(qtcb_config);
661 return retval;
662}
663
664static ssize_t zfcp_sysfs_adapter_request_show(struct device *dev,
665 struct device_attribute *attr,
666 char *buf)
667{
668 struct fsf_statistics_info stat_info;
669 int retval;
670
671 retval = zfcp_sysfs_adapter_ex_config(dev, &stat_info);
672 if (retval)
673 return retval;
674
675 return sprintf(buf, "%llu %llu %llu\n",
676 (unsigned long long) stat_info.input_req,
677 (unsigned long long) stat_info.output_req,
678 (unsigned long long) stat_info.control_req);
679}
680
681static ssize_t zfcp_sysfs_adapter_mb_show(struct device *dev,
682 struct device_attribute *attr,
683 char *buf)
684{
685 struct fsf_statistics_info stat_info;
686 int retval;
687
688 retval = zfcp_sysfs_adapter_ex_config(dev, &stat_info);
689 if (retval)
690 return retval;
691
692 return sprintf(buf, "%llu %llu\n",
693 (unsigned long long) stat_info.input_mb,
694 (unsigned long long) stat_info.output_mb);
695}
696
697static ssize_t zfcp_sysfs_adapter_sec_active_show(struct device *dev,
698 struct device_attribute *attr,
699 char *buf)
700{
701 struct fsf_statistics_info stat_info;
702 int retval;
703
704 retval = zfcp_sysfs_adapter_ex_config(dev, &stat_info);
705 if (retval)
706 return retval;
707
708 return sprintf(buf, "%llu\n",
709 (unsigned long long) stat_info.seconds_act);
710}
711
712static DEVICE_ATTR(utilization, S_IRUGO, zfcp_sysfs_adapter_util_show, NULL);
713static DEVICE_ATTR(requests, S_IRUGO, zfcp_sysfs_adapter_request_show, NULL);
714static DEVICE_ATTR(megabytes, S_IRUGO, zfcp_sysfs_adapter_mb_show, NULL);
715static DEVICE_ATTR(seconds_active, S_IRUGO,
716 zfcp_sysfs_adapter_sec_active_show, NULL);
717
718static struct device_attribute *zfcp_a_stats_attrs[] = {
719 &dev_attr_utilization,
720 &dev_attr_requests,
721 &dev_attr_megabytes,
722 &dev_attr_seconds_active,
723 NULL
724};
725
726struct zfcp_data zfcp_data = { 523struct zfcp_data zfcp_data = {
727 .scsi_host_template = { 524 .scsi_host_template = {
728 .name = "zfcp", 525 .name = "zfcp",
@@ -743,7 +540,6 @@ struct zfcp_data zfcp_data = {
743 .use_clustering = 1, 540 .use_clustering = 1,
744 .sdev_attrs = zfcp_sysfs_sdev_attrs, 541 .sdev_attrs = zfcp_sysfs_sdev_attrs,
745 .max_sectors = (ZFCP_MAX_SBALES_PER_REQ * 8), 542 .max_sectors = (ZFCP_MAX_SBALES_PER_REQ * 8),
746 .shost_attrs = zfcp_a_stats_attrs, 543 .shost_attrs = zfcp_sysfs_shost_attrs,
747 }, 544 },
748}; 545};
749