1c4f07c60SJack Wang // SPDX-License-Identifier: GPL-2.0-or-later
2c4f07c60SJack Wang /*
3c4f07c60SJack Wang * RDMA Transport Layer
4c4f07c60SJack Wang *
5c4f07c60SJack Wang * Copyright (c) 2014 - 2018 ProfitBricks GmbH. All rights reserved.
6c4f07c60SJack Wang * Copyright (c) 2018 - 2019 1&1 IONOS Cloud GmbH. All rights reserved.
7c4f07c60SJack Wang * Copyright (c) 2019 - 2020 1&1 IONOS SE. All rights reserved.
8c4f07c60SJack Wang */
9c4f07c60SJack Wang #undef pr_fmt
10c4f07c60SJack Wang #define pr_fmt(fmt) KBUILD_MODNAME " L" __stringify(__LINE__) ": " fmt
11c4f07c60SJack Wang
12c4f07c60SJack Wang #include "rtrs-srv.h"
13c4f07c60SJack Wang
rtrs_srv_reset_rdma_stats(struct rtrs_srv_stats * stats,bool enable)14c4f07c60SJack Wang int rtrs_srv_reset_rdma_stats(struct rtrs_srv_stats *stats, bool enable)
15c4f07c60SJack Wang {
16c4f07c60SJack Wang if (enable) {
17*f4e13571SSantosh Kumar Pradhan int cpu;
18*f4e13571SSantosh Kumar Pradhan struct rtrs_srv_stats_rdma_stats *r;
19c4f07c60SJack Wang
20*f4e13571SSantosh Kumar Pradhan for_each_possible_cpu(cpu) {
21*f4e13571SSantosh Kumar Pradhan r = per_cpu_ptr(stats->rdma_stats, cpu);
22c4f07c60SJack Wang memset(r, 0, sizeof(*r));
23*f4e13571SSantosh Kumar Pradhan }
24*f4e13571SSantosh Kumar Pradhan
25c4f07c60SJack Wang return 0;
26c4f07c60SJack Wang }
27c4f07c60SJack Wang
28c4f07c60SJack Wang return -EINVAL;
29c4f07c60SJack Wang }
30c4f07c60SJack Wang
rtrs_srv_stats_rdma_to_str(struct rtrs_srv_stats * stats,char * page)3180ad07f7SMd Haris Iqbal ssize_t rtrs_srv_stats_rdma_to_str(struct rtrs_srv_stats *stats, char *page)
32c4f07c60SJack Wang {
33*f4e13571SSantosh Kumar Pradhan int cpu;
34*f4e13571SSantosh Kumar Pradhan struct rtrs_srv_stats_rdma_stats sum;
35*f4e13571SSantosh Kumar Pradhan struct rtrs_srv_stats_rdma_stats *r;
36c4f07c60SJack Wang
37*f4e13571SSantosh Kumar Pradhan memset(&sum, 0, sizeof(sum));
38*f4e13571SSantosh Kumar Pradhan
39*f4e13571SSantosh Kumar Pradhan for_each_possible_cpu(cpu) {
40*f4e13571SSantosh Kumar Pradhan r = per_cpu_ptr(stats->rdma_stats, cpu);
41*f4e13571SSantosh Kumar Pradhan
42*f4e13571SSantosh Kumar Pradhan sum.dir[READ].cnt += r->dir[READ].cnt;
43*f4e13571SSantosh Kumar Pradhan sum.dir[READ].size_total += r->dir[READ].size_total;
44*f4e13571SSantosh Kumar Pradhan sum.dir[WRITE].cnt += r->dir[WRITE].cnt;
45*f4e13571SSantosh Kumar Pradhan sum.dir[WRITE].size_total += r->dir[WRITE].size_total;
46*f4e13571SSantosh Kumar Pradhan }
47*f4e13571SSantosh Kumar Pradhan
48*f4e13571SSantosh Kumar Pradhan return sysfs_emit(page, "%llu %llu %llu %llu\n",
49*f4e13571SSantosh Kumar Pradhan sum.dir[READ].cnt, sum.dir[READ].size_total,
50*f4e13571SSantosh Kumar Pradhan sum.dir[WRITE].cnt, sum.dir[WRITE].size_total);
51c4f07c60SJack Wang }
52