Skip to content

Commit 787f78a

Browse files
Jack Wangjgunthorpe
authored andcommitted
RDMA/rtrs: server: private header with server structs and functions
This header describes main structs and functions used by rtrs-server module, mainly for accepting rtrs sessions, creating/destroying sysfs entries, accounting statistics on server side. Link: https://lore.kernel.org/r/20200511135131.27580-10-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 215378b commit 787f78a

File tree

1 file changed

+148
-0
lines changed

1 file changed

+148
-0
lines changed
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
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+
10+
#ifndef RTRS_SRV_H
11+
#define RTRS_SRV_H
12+
13+
#include <linux/device.h>
14+
#include <linux/refcount.h>
15+
#include "rtrs-pri.h"
16+
17+
/*
18+
* enum rtrs_srv_state - Server states.
19+
*/
20+
enum rtrs_srv_state {
21+
RTRS_SRV_CONNECTING,
22+
RTRS_SRV_CONNECTED,
23+
RTRS_SRV_CLOSING,
24+
RTRS_SRV_CLOSED,
25+
};
26+
27+
/* stats for Read and write operation.
28+
* see Documentation/ABI/testing/sysfs-class-rtrs-server for details
29+
*/
30+
struct rtrs_srv_stats_rdma_stats {
31+
struct {
32+
atomic64_t cnt;
33+
atomic64_t size_total;
34+
} dir[2];
35+
};
36+
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;
41+
};
42+
43+
struct rtrs_srv_con {
44+
struct rtrs_con c;
45+
atomic_t wr_cnt;
46+
atomic_t sq_wr_avail;
47+
struct list_head rsp_wr_wait_list;
48+
spinlock_t rsp_wr_wait_lock;
49+
};
50+
51+
/* IO context in rtrs_srv, each io has one */
52+
struct rtrs_srv_op {
53+
struct rtrs_srv_con *con;
54+
u32 msg_id;
55+
u8 dir;
56+
struct rtrs_msg_rdma_read *rd_msg;
57+
struct ib_rdma_wr tx_wr;
58+
struct ib_sge tx_sg;
59+
struct list_head wait_list;
60+
int status;
61+
};
62+
63+
/*
64+
* server side memory region context, when always_invalidate=Y, we need
65+
* queue_depth of memory regrion to invalidate each memory region.
66+
*/
67+
struct rtrs_srv_mr {
68+
struct ib_mr *mr;
69+
struct sg_table sgt;
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 */
74+
};
75+
76+
struct rtrs_srv_sess {
77+
struct rtrs_sess s;
78+
struct rtrs_srv *srv;
79+
struct work_struct close_work;
80+
enum rtrs_srv_state state;
81+
spinlock_t state_lock;
82+
int cur_cq_vector;
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;
87+
unsigned int mrs_num;
88+
dma_addr_t *dma_addr;
89+
bool established;
90+
unsigned int mem_bits;
91+
struct kobject kobj;
92+
struct rtrs_srv_stats *stats;
93+
};
94+
95+
struct rtrs_srv {
96+
struct list_head paths_list;
97+
int paths_up;
98+
struct mutex paths_ev_mutex;
99+
size_t paths_num;
100+
struct mutex paths_mutex;
101+
uuid_t paths_uuid;
102+
refcount_t refcount;
103+
struct rtrs_srv_ctx *ctx;
104+
struct list_head ctx_list;
105+
void *priv;
106+
size_t queue_depth;
107+
struct page **chunks;
108+
struct device dev;
109+
unsigned int dev_ref;
110+
struct kobject *kobj_paths;
111+
};
112+
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;
119+
};
120+
121+
extern struct class *rtrs_dev_class;
122+
123+
void close_sess(struct rtrs_srv_sess *sess);
124+
125+
static inline void rtrs_srv_update_rdma_stats(struct rtrs_srv_stats *s,
126+
size_t size, int d)
127+
{
128+
atomic64_inc(&s->rdma_stats.dir[d].cnt);
129+
atomic64_add(size, &s->rdma_stats.dir[d].size_total);
130+
}
131+
132+
/* functions which are implemented in rtrs-srv-stats.c */
133+
int rtrs_srv_reset_rdma_stats(struct rtrs_srv_stats *stats, bool enable);
134+
ssize_t rtrs_srv_stats_rdma_to_str(struct rtrs_srv_stats *stats,
135+
char *page, size_t len);
136+
int rtrs_srv_reset_wc_completion_stats(struct rtrs_srv_stats *stats,
137+
bool enable);
138+
int rtrs_srv_stats_wc_completion_to_str(struct rtrs_srv_stats *stats, char *buf,
139+
size_t len);
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);
143+
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);
147+
148+
#endif /* RTRS_SRV_H */

0 commit comments

Comments
 (0)