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;
45 struct list_head rsp_wr_wait_list;
46 spinlock_t rsp_wr_wait_lock;
49 /* IO context in rtrs_srv, each io has one */
51 struct rtrs_srv_con *con;
54 struct rtrs_msg_rdma_read *rd_msg;
55 struct ib_rdma_wr tx_wr;
57 struct list_head wait_list;
62 * server side memory region context, when always_invalidate=Y, we need
63 * queue_depth of memory region to invalidate each memory region.
68 struct ib_cqe inv_cqe; /* only for always_invalidate=true */
69 u32 msg_id; /* only for always_invalidate=true */
70 u32 msg_off; /* only for always_invalidate=true */
71 struct rtrs_iu *iu; /* send buffer for new rkey msg */
74 struct rtrs_srv_sess {
77 struct work_struct close_work;
78 enum rtrs_srv_state state;
79 spinlock_t state_lock;
81 struct rtrs_srv_op **ops_ids;
82 struct percpu_ref ids_inflight_ref;
83 struct completion complete_done;
84 struct rtrs_srv_mr *mrs;
88 unsigned int mem_bits;
90 struct rtrs_srv_stats *stats;
94 struct list_head paths_list;
96 struct mutex paths_ev_mutex;
98 struct mutex paths_mutex;
101 struct rtrs_srv_ctx *ctx;
102 struct list_head ctx_list;
105 struct page **chunks;
107 unsigned int dev_ref;
108 struct kobject *kobj_paths;
111 struct rtrs_srv_ctx {
112 struct rtrs_srv_ops ops;
113 struct rdma_cm_id *cm_id_ip;
114 struct rdma_cm_id *cm_id_ib;
115 struct mutex srv_mutex;
116 struct list_head srv_list;
119 struct rtrs_srv_ib_ctx {
120 struct rtrs_srv_ctx *srv_ctx;
122 struct mutex ib_dev_mutex;
126 extern struct class *rtrs_dev_class;
128 void close_sess(struct rtrs_srv_sess *sess);
130 static inline void rtrs_srv_update_rdma_stats(struct rtrs_srv_stats *s,
133 atomic64_inc(&s->rdma_stats.dir[d].cnt);
134 atomic64_add(size, &s->rdma_stats.dir[d].size_total);
137 /* functions which are implemented in rtrs-srv-stats.c */
138 int rtrs_srv_reset_rdma_stats(struct rtrs_srv_stats *stats, bool enable);
139 ssize_t rtrs_srv_stats_rdma_to_str(struct rtrs_srv_stats *stats, char *page);
140 int rtrs_srv_reset_all_stats(struct rtrs_srv_stats *stats, bool enable);
141 ssize_t rtrs_srv_reset_all_help(struct rtrs_srv_stats *stats,
142 char *page, size_t len);
144 /* functions which are implemented in rtrs-srv-sysfs.c */
145 int rtrs_srv_create_sess_files(struct rtrs_srv_sess *sess);
146 void rtrs_srv_destroy_sess_files(struct rtrs_srv_sess *sess);
148 #endif /* RTRS_SRV_H */