aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core
diff options
context:
space:
mode:
authorSteve Wise <swise@opengridcomputing.com>2008-07-15 02:48:48 -0400
committerRoland Dreier <rolandd@cisco.com>2008-07-15 02:48:48 -0400
commit7f624d023b5fb150831e02c1e4c0f2619ade72c2 (patch)
tree9618a7eaa601855c3ab7763a3c31ee2fc16364ee /drivers/infiniband/core
parenta7d834c4bc6be73e8f83eaa5072fac3c5549f7f2 (diff)
RDMA/core: Add iWARP protocol statistics attributes in sysfs
This patch adds a sysfs attribute group called "proto_stats" under /sys/class/infiniband/$device/ and populates this group with protocol statistics if they exist for a given device. Currently, only iWARP stats are defined, but the code is designed to allow InfiniBand protocol stats if they become available. These stats are per-device and more importantly -not- per port. Details: - Add union rdma_protocol_stats in ib_verbs.h. This union allows defining transport-specific stats. Currently only iwarp stats are defined. - Add struct iw_protocol_stats to define the current set of iwarp protocol stats. - Add new ib_device method called get_proto_stats() to return protocol statistics. - Add logic in core/sysfs.c to create iwarp protocol stats attributes if the device is an RNIC and has a get_proto_stats() method. Signed-off-by: Steve Wise <swise@opengridcomputing.com> Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/core')
-rw-r--r--drivers/infiniband/core/sysfs.c120
1 files changed, 120 insertions, 0 deletions
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 36a0ef97c6a5..4d1042115598 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -663,6 +663,120 @@ static struct class ib_class = {
663 .dev_uevent = ib_device_uevent, 663 .dev_uevent = ib_device_uevent,
664}; 664};
665 665
666/* Show a given an attribute in the statistics group */
667static ssize_t show_protocol_stat(const struct device *device,
668 struct device_attribute *attr, char *buf,
669 unsigned offset)
670{
671 struct ib_device *dev = container_of(device, struct ib_device, dev);
672 union rdma_protocol_stats stats;
673 ssize_t ret;
674
675 ret = dev->get_protocol_stats(dev, &stats);
676 if (ret)
677 return ret;
678
679 return sprintf(buf, "%llu\n",
680 (unsigned long long) ((u64 *) &stats)[offset]);
681}
682
683/* generate a read-only iwarp statistics attribute */
684#define IW_STATS_ENTRY(name) \
685static ssize_t show_##name(struct device *device, \
686 struct device_attribute *attr, char *buf) \
687{ \
688 return show_protocol_stat(device, attr, buf, \
689 offsetof(struct iw_protocol_stats, name) / \
690 sizeof (u64)); \
691} \
692static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
693
694IW_STATS_ENTRY(ipInReceives);
695IW_STATS_ENTRY(ipInHdrErrors);
696IW_STATS_ENTRY(ipInTooBigErrors);
697IW_STATS_ENTRY(ipInNoRoutes);
698IW_STATS_ENTRY(ipInAddrErrors);
699IW_STATS_ENTRY(ipInUnknownProtos);
700IW_STATS_ENTRY(ipInTruncatedPkts);
701IW_STATS_ENTRY(ipInDiscards);
702IW_STATS_ENTRY(ipInDelivers);
703IW_STATS_ENTRY(ipOutForwDatagrams);
704IW_STATS_ENTRY(ipOutRequests);
705IW_STATS_ENTRY(ipOutDiscards);
706IW_STATS_ENTRY(ipOutNoRoutes);
707IW_STATS_ENTRY(ipReasmTimeout);
708IW_STATS_ENTRY(ipReasmReqds);
709IW_STATS_ENTRY(ipReasmOKs);
710IW_STATS_ENTRY(ipReasmFails);
711IW_STATS_ENTRY(ipFragOKs);
712IW_STATS_ENTRY(ipFragFails);
713IW_STATS_ENTRY(ipFragCreates);
714IW_STATS_ENTRY(ipInMcastPkts);
715IW_STATS_ENTRY(ipOutMcastPkts);
716IW_STATS_ENTRY(ipInBcastPkts);
717IW_STATS_ENTRY(ipOutBcastPkts);
718IW_STATS_ENTRY(tcpRtoAlgorithm);
719IW_STATS_ENTRY(tcpRtoMin);
720IW_STATS_ENTRY(tcpRtoMax);
721IW_STATS_ENTRY(tcpMaxConn);
722IW_STATS_ENTRY(tcpActiveOpens);
723IW_STATS_ENTRY(tcpPassiveOpens);
724IW_STATS_ENTRY(tcpAttemptFails);
725IW_STATS_ENTRY(tcpEstabResets);
726IW_STATS_ENTRY(tcpCurrEstab);
727IW_STATS_ENTRY(tcpInSegs);
728IW_STATS_ENTRY(tcpOutSegs);
729IW_STATS_ENTRY(tcpRetransSegs);
730IW_STATS_ENTRY(tcpInErrs);
731IW_STATS_ENTRY(tcpOutRsts);
732
733static struct attribute *iw_proto_stats_attrs[] = {
734 &dev_attr_ipInReceives.attr,
735 &dev_attr_ipInHdrErrors.attr,
736 &dev_attr_ipInTooBigErrors.attr,
737 &dev_attr_ipInNoRoutes.attr,
738 &dev_attr_ipInAddrErrors.attr,
739 &dev_attr_ipInUnknownProtos.attr,
740 &dev_attr_ipInTruncatedPkts.attr,
741 &dev_attr_ipInDiscards.attr,
742 &dev_attr_ipInDelivers.attr,
743 &dev_attr_ipOutForwDatagrams.attr,
744 &dev_attr_ipOutRequests.attr,
745 &dev_attr_ipOutDiscards.attr,
746 &dev_attr_ipOutNoRoutes.attr,
747 &dev_attr_ipReasmTimeout.attr,
748 &dev_attr_ipReasmReqds.attr,
749 &dev_attr_ipReasmOKs.attr,
750 &dev_attr_ipReasmFails.attr,
751 &dev_attr_ipFragOKs.attr,
752 &dev_attr_ipFragFails.attr,
753 &dev_attr_ipFragCreates.attr,
754 &dev_attr_ipInMcastPkts.attr,
755 &dev_attr_ipOutMcastPkts.attr,
756 &dev_attr_ipInBcastPkts.attr,
757 &dev_attr_ipOutBcastPkts.attr,
758 &dev_attr_tcpRtoAlgorithm.attr,
759 &dev_attr_tcpRtoMin.attr,
760 &dev_attr_tcpRtoMax.attr,
761 &dev_attr_tcpMaxConn.attr,
762 &dev_attr_tcpActiveOpens.attr,
763 &dev_attr_tcpPassiveOpens.attr,
764 &dev_attr_tcpAttemptFails.attr,
765 &dev_attr_tcpEstabResets.attr,
766 &dev_attr_tcpCurrEstab.attr,
767 &dev_attr_tcpInSegs.attr,
768 &dev_attr_tcpOutSegs.attr,
769 &dev_attr_tcpRetransSegs.attr,
770 &dev_attr_tcpInErrs.attr,
771 &dev_attr_tcpOutRsts.attr,
772 NULL
773};
774
775static struct attribute_group iw_stats_group = {
776 .name = "proto_stats",
777 .attrs = iw_proto_stats_attrs,
778};
779
666int ib_device_register_sysfs(struct ib_device *device) 780int ib_device_register_sysfs(struct ib_device *device)
667{ 781{
668 struct device *class_dev = &device->dev; 782 struct device *class_dev = &device->dev;
@@ -705,6 +819,12 @@ int ib_device_register_sysfs(struct ib_device *device)
705 } 819 }
706 } 820 }
707 821
822 if (device->node_type == RDMA_NODE_RNIC && device->get_protocol_stats) {
823 ret = sysfs_create_group(&class_dev->kobj, &iw_stats_group);
824 if (ret)
825 goto err_put;
826 }
827
708 return 0; 828 return 0;
709 829
710err_put: 830err_put: