18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * RDMA Transport Layer
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (c) 2014 - 2018 ProfitBricks GmbH. All rights reserved.
68c2ecf20Sopenharmony_ci * Copyright (c) 2018 - 2019 1&1 IONOS Cloud GmbH. All rights reserved.
78c2ecf20Sopenharmony_ci * Copyright (c) 2019 - 2020 1&1 IONOS SE. All rights reserved.
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci#undef pr_fmt
108c2ecf20Sopenharmony_ci#define pr_fmt(fmt) KBUILD_MODNAME " L" __stringify(__LINE__) ": " fmt
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include "rtrs-srv.h"
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ciint rtrs_srv_reset_rdma_stats(struct rtrs_srv_stats *stats, bool enable)
158c2ecf20Sopenharmony_ci{
168c2ecf20Sopenharmony_ci	if (enable) {
178c2ecf20Sopenharmony_ci		struct rtrs_srv_stats_rdma_stats *r = &stats->rdma_stats;
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci		memset(r, 0, sizeof(*r));
208c2ecf20Sopenharmony_ci		return 0;
218c2ecf20Sopenharmony_ci	}
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci	return -EINVAL;
248c2ecf20Sopenharmony_ci}
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_cissize_t rtrs_srv_stats_rdma_to_str(struct rtrs_srv_stats *stats,
278c2ecf20Sopenharmony_ci				    char *page, size_t len)
288c2ecf20Sopenharmony_ci{
298c2ecf20Sopenharmony_ci	struct rtrs_srv_stats_rdma_stats *r = &stats->rdma_stats;
308c2ecf20Sopenharmony_ci	struct rtrs_srv_sess *sess = stats->sess;
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci	return scnprintf(page, len, "%lld %lld %lld %lld %u\n",
338c2ecf20Sopenharmony_ci			 (s64)atomic64_read(&r->dir[READ].cnt),
348c2ecf20Sopenharmony_ci			 (s64)atomic64_read(&r->dir[READ].size_total),
358c2ecf20Sopenharmony_ci			 (s64)atomic64_read(&r->dir[WRITE].cnt),
368c2ecf20Sopenharmony_ci			 (s64)atomic64_read(&r->dir[WRITE].size_total),
378c2ecf20Sopenharmony_ci			 atomic_read(&sess->ids_inflight));
388c2ecf20Sopenharmony_ci}
39