summaryrefslogtreecommitdiff
path: root/net/smc/smc_stats.c
diff options
context:
space:
mode:
authorGuvenc Gulce <guvenc@linux.ibm.com>2021-06-16 16:52:55 +0200
committerDavid S. Miller <davem@davemloft.net>2021-06-16 12:54:02 -0700
commite0e4b8fa533858532f1b9ea9c6a4660d09beb37a (patch)
treedc04b676e1642f2333f69ad513152c0b999fecaa /net/smc/smc_stats.c
parentfb0a1dacf2bef929bf047c5434bfb976ac6a93e6 (diff)
net/smc: Add SMC statistics support
Add the ability to collect SMC statistics information. Per-cpu variables are used to collect the statistic information for better performance and for reducing concurrency pitfalls. The code that is collecting statistic data is implemented in macros to increase code reuse and readability. Signed-off-by: Guvenc Gulce <guvenc@linux.ibm.com> Signed-off-by: Karsten Graul <kgraul@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/smc/smc_stats.c')
-rw-r--r--net/smc/smc_stats.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/net/smc/smc_stats.c b/net/smc/smc_stats.c
new file mode 100644
index 000000000000..76e938388520
--- /dev/null
+++ b/net/smc/smc_stats.c
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Shared Memory Communications over RDMA (SMC-R) and RoCE
+ *
+ * SMC statistics netlink routines
+ *
+ * Copyright IBM Corp. 2021
+ *
+ * Author(s): Guvenc Gulce
+ */
+#include <linux/init.h>
+#include <linux/mutex.h>
+#include <linux/percpu.h>
+#include <linux/ctype.h>
+#include "smc_stats.h"
+
+/* serialize fallback reason statistic gathering */
+DEFINE_MUTEX(smc_stat_fback_rsn);
+struct smc_stats __percpu *smc_stats; /* per cpu counters for SMC */
+struct smc_stats_reason fback_rsn;
+
+int __init smc_stats_init(void)
+{
+ memset(&fback_rsn, 0, sizeof(fback_rsn));
+ smc_stats = alloc_percpu(struct smc_stats);
+ if (!smc_stats)
+ return -ENOMEM;
+
+ return 0;
+}
+
+void smc_stats_exit(void)
+{
+ free_percpu(smc_stats);
+}