Skip to content

Commit c4f07c6

Browse files
jinpuwangjgunthorpe
authored andcommitted
RDMA/rtrs: server: statistics functions
This introduces set of functions used on server side to account statistics of RDMA data sent/received. Link: https://lore.kernel.org/r/20200511135131.27580-12-danil.kipnis@cloud.ionos.com Signed-off-by: Danil Kipnis <danil.kipnis@cloud.ionos.com> Signed-off-by: Jack Wang <jinpu.wang@cloud.ionos.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
1 parent 9cb8374 commit c4f07c6

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
/*
3+
* RDMA Transport Layer
4+
*
5+
* Copyright (c) 2014 - 2018 ProfitBricks GmbH. All rights reserved.
6+
* Copyright (c) 2018 - 2019 1&1 IONOS Cloud GmbH. All rights reserved.
7+
* Copyright (c) 2019 - 2020 1&1 IONOS SE. All rights reserved.
8+
*/
9+
#undef pr_fmt
10+
#define pr_fmt(fmt) KBUILD_MODNAME " L" __stringify(__LINE__) ": " fmt
11+
12+
#include "rtrs-srv.h"
13+
14+
int rtrs_srv_reset_rdma_stats(struct rtrs_srv_stats *stats, bool enable)
15+
{
16+
if (enable) {
17+
struct rtrs_srv_stats_rdma_stats *r = &stats->rdma_stats;
18+
19+
memset(r, 0, sizeof(*r));
20+
return 0;
21+
}
22+
23+
return -EINVAL;
24+
}
25+
26+
ssize_t rtrs_srv_stats_rdma_to_str(struct rtrs_srv_stats *stats,
27+
char *page, size_t len)
28+
{
29+
struct rtrs_srv_stats_rdma_stats *r = &stats->rdma_stats;
30+
struct rtrs_srv_sess *sess = stats->sess;
31+
32+
return scnprintf(page, len, "%lld %lld %lld %lld %u\n",
33+
(s64)atomic64_read(&r->dir[READ].cnt),
34+
(s64)atomic64_read(&r->dir[READ].size_total),
35+
(s64)atomic64_read(&r->dir[WRITE].cnt),
36+
(s64)atomic64_read(&r->dir[WRITE].size_total),
37+
atomic_read(&sess->ids_inflight));
38+
}

0 commit comments

Comments
 (0)