aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/infiniband/core/sysfs.c120
-rw-r--r--include/rdma/ib_verbs.h53
2 files changed, 173 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:
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 74c24b908908..10ebaaae0161 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -226,6 +226,57 @@ static inline int ib_width_enum_to_int(enum ib_port_width width)
226 } 226 }
227} 227}
228 228
229struct ib_protocol_stats {
230 /* TBD... */
231};
232
233struct iw_protocol_stats {
234 u64 ipInReceives;
235 u64 ipInHdrErrors;
236 u64 ipInTooBigErrors;
237 u64 ipInNoRoutes;
238 u64 ipInAddrErrors;
239 u64 ipInUnknownProtos;
240 u64 ipInTruncatedPkts;
241 u64 ipInDiscards;
242 u64 ipInDelivers;
243 u64 ipOutForwDatagrams;
244 u64 ipOutRequests;
245 u64 ipOutDiscards;
246 u64 ipOutNoRoutes;
247 u64 ipReasmTimeout;
248 u64 ipReasmReqds;
249 u64 ipReasmOKs;
250 u64 ipReasmFails;
251 u64 ipFragOKs;
252 u64 ipFragFails;
253 u64 ipFragCreates;
254 u64 ipInMcastPkts;
255 u64 ipOutMcastPkts;
256 u64 ipInBcastPkts;
257 u64 ipOutBcastPkts;
258
259 u64 tcpRtoAlgorithm;
260 u64 tcpRtoMin;
261 u64 tcpRtoMax;
262 u64 tcpMaxConn;
263 u64 tcpActiveOpens;
264 u64 tcpPassiveOpens;
265 u64 tcpAttemptFails;
266 u64 tcpEstabResets;
267 u64 tcpCurrEstab;
268 u64 tcpInSegs;
269 u64 tcpOutSegs;
270 u64 tcpRetransSegs;
271 u64 tcpInErrs;
272 u64 tcpOutRsts;
273};
274
275union rdma_protocol_stats {
276 struct ib_protocol_stats ib;
277 struct iw_protocol_stats iw;
278};
279
229struct ib_port_attr { 280struct ib_port_attr {
230 enum ib_port_state state; 281 enum ib_port_state state;
231 enum ib_mtu max_mtu; 282 enum ib_mtu max_mtu;
@@ -943,6 +994,8 @@ struct ib_device {
943 994
944 struct iw_cm_verbs *iwcm; 995 struct iw_cm_verbs *iwcm;
945 996
997 int (*get_protocol_stats)(struct ib_device *device,
998 union rdma_protocol_stats *stats);
946 int (*query_device)(struct ib_device *device, 999 int (*query_device)(struct ib_device *device,
947 struct ib_device_attr *device_attr); 1000 struct ib_device_attr *device_attr);
948 int (*query_port)(struct ib_device *device, 1001 int (*query_port)(struct ib_device *device,