summaryrefslogtreecommitdiff
path: root/drivers/infiniband/ulp/rtrs/rtrs-srv-stats.c
blob: 12c374b5eb6e89dd898ea5291de7d501e93fc85c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * RDMA Transport Layer
 *
 * Copyright (c) 2014 - 2018 ProfitBricks GmbH. All rights reserved.
 * Copyright (c) 2018 - 2019 1&1 IONOS Cloud GmbH. All rights reserved.
 * Copyright (c) 2019 - 2020 1&1 IONOS SE. All rights reserved.
 */
#undef pr_fmt
#define pr_fmt(fmt) KBUILD_MODNAME " L" __stringify(__LINE__) ": " fmt

#include "rtrs-srv.h"

int rtrs_srv_reset_rdma_stats(struct rtrs_srv_stats *stats, bool enable)
{
	if (enable) {
		struct rtrs_srv_stats_rdma_stats *r = &stats->rdma_stats;

		memset(r, 0, sizeof(*r));
		return 0;
	}

	return -EINVAL;
}

ssize_t rtrs_srv_stats_rdma_to_str(struct rtrs_srv_stats *stats,
				    char *page, size_t len)
{
	struct rtrs_srv_stats_rdma_stats *r = &stats->rdma_stats;

	return sysfs_emit(page, "%lld %lld %lld %lldn %u\n",
			  (s64)atomic64_read(&r->dir[READ].cnt),
			  (s64)atomic64_read(&r->dir[READ].size_total),
			  (s64)atomic64_read(&r->dir[WRITE].cnt),
			  (s64)atomic64_read(&r->dir[WRITE].size_total), 0);
}