Commit c4f07c60 authored by Jack Wang's avatar Jack Wang Committed by Jason Gunthorpe

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.comSigned-off-by: default avatarDanil Kipnis <danil.kipnis@cloud.ionos.com>
Signed-off-by: default avatarJack Wang <jinpu.wang@cloud.ionos.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 9cb83748
// 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;
struct rtrs_srv_sess *sess = stats->sess;
return scnprintf(page, len, "%lld %lld %lld %lld %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),
atomic_read(&sess->ids_inflight));
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment