1 /* SPDX-License-Identifier: GPL-2.0-or-later */
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.
13 #include <linux/device.h>
14 #include <linux/refcount.h>
18 * enum rtrs_srv_state - Server states.
27 /* stats for Read and write operation.
28 * see Documentation/ABI/testing/sysfs-class-rtrs-server for details
30 struct rtrs_srv_stats_rdma_stats {
33 atomic64_t size_total;
37 struct rtrs_srv_stats {
38 struct kobject kobj_stats;
39 struct rtrs_srv_stats_rdma_stats rdma_stats;
40 struct rtrs_srv_sess *sess;
47 struct list_head rsp_wr_wait_list;
48 spinlock_t rsp_wr_wait_lock;
51 /* IO context in rtrs_srv, each io has one */
53 struct rtrs_srv_con *con;
56 struct rtrs_msg_rdma_read *rd_msg;
57 struct ib_rdma_wr tx_wr;
59 struct list_head wait_list;
64 * server side memory region context, when always_invalidate=Y, we need
65 * queue_depth of memory regrion to invalidate each memory region.
70 struct ib_cqe inv_cqe; /* only for always_invalidate=true */
71 u32 msg_id; /* only for always_invalidate=true */
72 u32 msg_off; /* only for always_invalidate=true */
73 struct rtrs_iu *iu; /* send buffer for new rkey msg */
76 struct rtrs_srv_sess {
79 struct work_struct close_work;
80 enum rtrs_srv_state state;
81 spinlock_t state_lock;
83 struct rtrs_srv_op **ops_ids;
84 atomic_t ids_inflight;
85 wait_queue_head_t ids_waitq;
86 struct rtrs_srv_mr *mrs;
90 unsigned int mem_bits;
92 struct rtrs_srv_stats *stats;
96 struct list_head paths_list;
98 struct mutex paths_ev_mutex;
100 struct mutex paths_mutex;
103 struct rtrs_srv_ctx *ctx;
104 struct list_head ctx_list;
107 struct page **chunks;
109 unsigned int dev_ref;
110 struct kobject *kobj_paths;
113 struct rtrs_srv_ctx {
114 struct rtrs_srv_ops ops;
115 struct rdma_cm_id *cm_id_ip;
116 struct rdma_cm_id *cm_id_ib;
117 struct mutex srv_mutex;
118 struct list_head srv_list;
121 struct rtrs_srv_ib_ctx {
122 struct rtrs_srv_ctx *srv_ctx;
124 struct mutex ib_dev_mutex;
128 extern struct class *rtrs_dev_class;
130 void close_sess(struct rtrs_srv_sess *sess);
132 static inline void rtrs_srv_update_rdma_stats(struct rtrs_srv_stats *s,
135 atomic64_inc(&s->rdma_stats.dir[d].cnt);
136 atomic64_add(size, &s->rdma_stats.dir[d].size_total);
139 /* functions which are implemented in rtrs-srv-stats.c */
140 int rtrs_srv_reset_rdma_stats(struct rtrs_srv_stats *stats, bool enable);
141 ssize_t rtrs_srv_stats_rdma_to_str(struct rtrs_srv_stats *stats,
142 char *page, size_t len);
143 int rtrs_srv_reset_wc_completion_stats(struct rtrs_srv_stats *stats,
145 int rtrs_srv_stats_wc_completion_to_str(struct rtrs_srv_stats *stats, char *buf,
147 int rtrs_srv_reset_all_stats(struct rtrs_srv_stats *stats, bool enable);
148 ssize_t rtrs_srv_reset_all_help(struct rtrs_srv_stats *stats,
149 char *page, size_t len);
151 /* functions which are implemented in rtrs-srv-sysfs.c */
152 int rtrs_srv_create_sess_files(struct rtrs_srv_sess *sess);
153 void rtrs_srv_destroy_sess_files(struct rtrs_srv_sess *sess);
155 #endif /* RTRS_SRV_H */