diff options
-rw-r--r-- | drivers/infiniband/core/sysfs.c | 120 | ||||
-rw-r--r-- | include/rdma/ib_verbs.h | 53 |
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 */ | ||
667 | static 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) \ | ||
685 | static 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 | } \ | ||
692 | static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL) | ||
693 | |||
694 | IW_STATS_ENTRY(ipInReceives); | ||
695 | IW_STATS_ENTRY(ipInHdrErrors); | ||
696 | IW_STATS_ENTRY(ipInTooBigErrors); | ||
697 | IW_STATS_ENTRY(ipInNoRoutes); | ||
698 | IW_STATS_ENTRY(ipInAddrErrors); | ||
699 | IW_STATS_ENTRY(ipInUnknownProtos); | ||
700 | IW_STATS_ENTRY(ipInTruncatedPkts); | ||
701 | IW_STATS_ENTRY(ipInDiscards); | ||
702 | IW_STATS_ENTRY(ipInDelivers); | ||
703 | IW_STATS_ENTRY(ipOutForwDatagrams); | ||
704 | IW_STATS_ENTRY(ipOutRequests); | ||
705 | IW_STATS_ENTRY(ipOutDiscards); | ||
706 | IW_STATS_ENTRY(ipOutNoRoutes); | ||
707 | IW_STATS_ENTRY(ipReasmTimeout); | ||
708 | IW_STATS_ENTRY(ipReasmReqds); | ||
709 | IW_STATS_ENTRY(ipReasmOKs); | ||
710 | IW_STATS_ENTRY(ipReasmFails); | ||
711 | IW_STATS_ENTRY(ipFragOKs); | ||
712 | IW_STATS_ENTRY(ipFragFails); | ||
713 | IW_STATS_ENTRY(ipFragCreates); | ||
714 | IW_STATS_ENTRY(ipInMcastPkts); | ||
715 | IW_STATS_ENTRY(ipOutMcastPkts); | ||
716 | IW_STATS_ENTRY(ipInBcastPkts); | ||
717 | IW_STATS_ENTRY(ipOutBcastPkts); | ||
718 | IW_STATS_ENTRY(tcpRtoAlgorithm); | ||
719 | IW_STATS_ENTRY(tcpRtoMin); | ||
720 | IW_STATS_ENTRY(tcpRtoMax); | ||
721 | IW_STATS_ENTRY(tcpMaxConn); | ||
722 | IW_STATS_ENTRY(tcpActiveOpens); | ||
723 | IW_STATS_ENTRY(tcpPassiveOpens); | ||
724 | IW_STATS_ENTRY(tcpAttemptFails); | ||
725 | IW_STATS_ENTRY(tcpEstabResets); | ||
726 | IW_STATS_ENTRY(tcpCurrEstab); | ||
727 | IW_STATS_ENTRY(tcpInSegs); | ||
728 | IW_STATS_ENTRY(tcpOutSegs); | ||
729 | IW_STATS_ENTRY(tcpRetransSegs); | ||
730 | IW_STATS_ENTRY(tcpInErrs); | ||
731 | IW_STATS_ENTRY(tcpOutRsts); | ||
732 | |||
733 | static 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 | |||
775 | static struct attribute_group iw_stats_group = { | ||
776 | .name = "proto_stats", | ||
777 | .attrs = iw_proto_stats_attrs, | ||
778 | }; | ||
779 | |||
666 | int ib_device_register_sysfs(struct ib_device *device) | 780 | int 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 | ||
710 | err_put: | 830 | err_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 | ||
229 | struct ib_protocol_stats { | ||
230 | /* TBD... */ | ||
231 | }; | ||
232 | |||
233 | struct 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 | |||
275 | union rdma_protocol_stats { | ||
276 | struct ib_protocol_stats ib; | ||
277 | struct iw_protocol_stats iw; | ||
278 | }; | ||
279 | |||
229 | struct ib_port_attr { | 280 | struct 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, |