Motr  M0
klnet_core.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2012-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
23 #pragma once
24 
25 #ifndef __MOTR_NET_KLNET_CORE_H__
26 #define __MOTR_NET_KLNET_CORE_H__
27 
28 #include "lib/semaphore.h"
29 #include "lib/tlist.h"
30 #include "net/lnet/lnet_core.h"
31 
32 #include <linux/spinlock.h>
33 
34 /* LUSTRE_VERSION_CODE, OBD_OCD_VERSION */
35 #if M0_LUSTRE_VERSION < 2110
36 #include <lustre_ver.h>
37 #else
38 #include <lustre/lustre_ver.h>
39 #include <lustre/lustre_idl.h>
40 #endif
41 
49 #if LUSTRE_VERSION_CODE > OBD_OCD_VERSION(2, 10, 51, 0)
50 typedef struct lnet_eq lnet_eq_t;
51 typedef struct lnet_event lnet_event_t;
52 typedef struct lnet_handle_eq lnet_handle_eq_t;
53 typedef struct lnet_handle_md lnet_handle_md_t;
54 typedef struct lnet_handle_me lnet_handle_me_t;
55 typedef struct lnet_libhandle lnet_libhandle_t;
56 typedef struct lnet_libmd lnet_libmd_t;
57 typedef struct lnet_md lnet_md_t;
58 typedef struct lnet_me lnet_me_t;
59 typedef struct lnet_msg lnet_msg_t;
60 typedef struct lnet_process_id lnet_process_id_t;
61 typedef enum lnet_event_kind lnet_event_kind_t;
62 #endif
63 
64 enum {
75 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 2, 54, 0)
77 #else
79 #endif
80 
83 };
84 
85 struct nlx_kcore_ops;
86 
92  uint64_t kd_magic;
93 
96 
99 
102 
108 
114 };
115 
121  uint64_t ktm_magic;
122 
125 
128 
131 
137 
140 
145  spinlock_t ktm_bevq_lock;
146 
148  wait_queue_head_t ktm_wq;
149 
151  lnet_handle_eq_t ktm_eqh;
152  unsigned _debug_;
153 };
154 
160  uint64_t kb_magic;
161 
164 
167 
170 
177 
183 
186 
188  lnet_kiov_t *kb_kiov;
189 
191  size_t kb_kiov_len;
192 
198 
204 
206  lnet_handle_md_t kb_mdh;
207 
210 
214  unsigned kb_ooo_mlength;
215 
220 
224  unsigned kb_ooo_offset;
225 };
226 
233  uint64_t kbe_magic;
234 
237 
240 };
241 
242 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 54, 0)
243 #define LNetInvalidateMDHandle(h) LNetInvalidateHandle(h)
244 #define LNetMDHandleIsInvalid(h) LNetHandleIsInvalid(h)
245 #else
246 #define LNetHandleIsEqual(h1, h2) ((h1).cookie == (h2).cookie)
247 #define LNetHandleIsInvalid(h) ((h).cookie == LNET_WIRE_HANDLE_COOKIE_NONE)
248 #endif
249 
258  struct nlx_core_buffer *cb,
259  struct nlx_kcore_buffer *kb);
260 
261 
276  struct nlx_core_domain *cd);
283  void (*ko_dom_fini)(struct nlx_kcore_domain *kd,
284  struct nlx_core_domain *cd);
285 
295  nlx_core_opaque_ptr_t buffer_id,
296  struct nlx_core_buffer *cb,
297  struct nlx_kcore_buffer *kb);
298 
304  void (*ko_buf_deregister)(struct nlx_core_buffer *cb,
305  struct nlx_kcore_buffer *kb);
306 
321  struct nlx_core_transfer_mc *ctm,
322  struct nlx_kcore_transfer_mc *ktm);
323 
330  void (*ko_tm_stop)(struct nlx_core_transfer_mc *ctm,
331  struct nlx_kcore_transfer_mc *ktm);
332 
338 
344 
350 
356 
362 
368 
375  struct nlx_kcore_buffer *kb);
376 
384  struct nlx_kcore_transfer_mc *ktm,
386 };
387 
388 static void nlx_core_kmem_loc_set(struct nlx_core_kmem_loc *loc,
389  struct page* pg, uint32_t off);
390 
391 static bool nlx_kcore_domain_invariant(const struct nlx_kcore_domain *kd);
392 static bool nlx_kcore_buffer_invariant(const struct nlx_kcore_buffer *kcb);
394  const struct nlx_kcore_buffer_event *kbe);
395 static bool nlx_kcore_tm_invariant(const struct nlx_kcore_transfer_mc *kctm);
396 static int nlx_kcore_kcore_dom_init(struct nlx_kcore_domain *kd);
397 static void nlx_kcore_kcore_dom_fini(struct nlx_kcore_domain *kd);
398 static int nlx_kcore_buffer_kla_to_kiov(struct nlx_kcore_buffer *kb,
399  const struct m0_bufvec *bvec);
400 static int nlx_kcore_buffer_uva_to_kiov(struct nlx_kcore_buffer *kb,
401  const struct m0_bufvec *bvec);
402 static bool nlx_kcore_kiov_invariant(const lnet_kiov_t *k, size_t len);
403 
404 #define NLX_PAGE_OFFSET(addr) ((addr) & ~PAGE_MASK)
405  /* KLNetCore */
407 
408 #endif /* __MOTR_NET_KLNET_CORE_H__ */
409 
410 /*
411  * Local variables:
412  * c-indentation-style: "K&R"
413  * c-basic-offset: 8
414  * tab-width: 8
415  * fill-column: 79
416  * scroll-step: 1
417  * End:
418  */
struct nlx_core_kmem_loc kd_cd_loc
Definition: klnet_core.h:95
size_t kb_kiov_len
Definition: klnet_core.h:191
unsigned kb_kiov_orig_len
Definition: klnet_core.h:203
int(* nlx_kcore_queue_op_t)(struct nlx_kcore_transfer_mc *ktm, struct nlx_core_buffer *cb, struct nlx_kcore_buffer *kb)
Definition: klnet_core.h:257
nlx_kcore_queue_op_t ko_buf_passive_recv
Definition: klnet_core.h:361
nlx_kcore_queue_op_t ko_buf_msg_send
Definition: klnet_core.h:343
lnet_handle_eq_t ktm_eqh
Definition: klnet_core.h:151
uint64_t m0_time_t
Definition: time.h:37
wait_queue_head_t ktm_wq
Definition: klnet_core.h:148
unsigned kb_ooo_mlength
Definition: klnet_core.h:214
static bool nlx_kcore_buffer_invariant(const struct nlx_kcore_buffer *kcb)
nlx_core_opaque_ptr_t kb_buffer_id
Definition: klnet_core.h:176
void(* ko_dom_fini)(struct nlx_kcore_domain *kd, struct nlx_core_domain *cd)
Definition: klnet_core.h:283
lnet_handle_md_t kb_mdh
Definition: klnet_core.h:206
uint64_t kb_magic
Definition: klnet_core.h:160
static int nlx_kcore_buffer_uva_to_kiov(struct nlx_kcore_buffer *kb, const struct m0_bufvec *bvec)
Definition: klnet_vec.c:236
size_t kb_kiov_adj_idx
Definition: klnet_core.h:197
struct m0_tlink ktm_drv_linkage
Definition: klnet_core.h:130
int(* ko_buf_register)(struct nlx_kcore_domain *kd, nlx_core_opaque_ptr_t buffer_id, struct nlx_core_buffer *cb, struct nlx_kcore_buffer *kb)
Definition: klnet_core.h:294
void(* ko_tm_stop)(struct nlx_core_transfer_mc *ctm, struct nlx_kcore_transfer_mc *ktm)
Definition: klnet_core.h:330
uint64_t nlx_core_opaque_ptr_t
nlx_kcore_queue_op_t ko_buf_msg_recv
Definition: klnet_core.h:337
static int nlx_kcore_buffer_kla_to_kiov(struct nlx_kcore_buffer *kb, const struct m0_bufvec *bvec)
Definition: klnet_vec.c:133
int(* ko_buf_event_wait)(struct nlx_core_transfer_mc *ctm, struct nlx_kcore_transfer_mc *ktm, m0_time_t timeout)
Definition: klnet_core.h:383
static bool nlx_kcore_tm_invariant(const struct nlx_kcore_transfer_mc *kctm)
int(* ko_tm_start)(struct nlx_kcore_domain *kd, struct nlx_core_transfer_mc *ctm, struct nlx_kcore_transfer_mc *ktm)
Definition: klnet_core.h:320
static bool nlx_kcore_domain_invariant(const struct nlx_kcore_domain *kd)
uint64_t kd_magic
Definition: klnet_core.h:92
void(* ko_buf_deregister)(struct nlx_core_buffer *cb, struct nlx_kcore_buffer *kb)
Definition: klnet_core.h:304
nlx_kcore_queue_op_t ko_buf_passive_send
Definition: klnet_core.h:367
Definition: tlist.h:251
static struct m0_bufvec bvec
Definition: xcode.c:169
unsigned kb_ooo_offset
Definition: klnet_core.h:224
spinlock_t ktm_bevq_lock
Definition: klnet_core.h:145
nlx_kcore_queue_op_t ko_buf_active_send
Definition: klnet_core.h:355
struct nlx_core_ep_addr ktm_addr
Definition: klnet_core.h:139
lnet_kiov_t * kb_kiov
Definition: klnet_core.h:188
struct nlx_kcore_transfer_mc * kb_ktm
Definition: klnet_core.h:166
struct m0_mutex kd_drv_mutex
Definition: klnet_core.h:98
static uint32_t timeout
Definition: console.c:52
struct m0_tlink ktm_tm_linkage
Definition: klnet_core.h:127
struct nlx_kcore_ops * kd_drv_ops
Definition: klnet_core.h:101
int(* ko_buf_del)(struct nlx_kcore_transfer_mc *ktm, struct nlx_kcore_buffer *kb)
Definition: klnet_core.h:374
m0_time_t kb_add_time
Definition: klnet_core.h:185
struct m0_tl kd_drv_tms
Definition: klnet_core.h:107
m0_net_queue_type
Definition: net.h:591
struct nlx_core_kmem_loc kb_cb_loc
Definition: klnet_core.h:163
static bool nlx_kcore_kiov_invariant(const lnet_kiov_t *k, size_t len)
static void nlx_core_kmem_loc_set(struct nlx_core_kmem_loc *loc, struct page *pg, uint32_t off)
static int nlx_kcore_kcore_dom_init(struct nlx_kcore_domain *kd)
static bool nlx_kcore_buffer_event_invariant(const struct nlx_kcore_buffer_event *kbe)
struct nlx_core_kmem_loc kbe_bev_loc
Definition: klnet_core.h:236
struct m0_tlink kbe_drv_linkage
Definition: klnet_core.h:239
enum m0_net_queue_type kb_qtype
Definition: klnet_core.h:182
struct m0_tl ktm_drv_bevs
Definition: klnet_core.h:136
int(* ko_dom_init)(struct nlx_kcore_domain *kd, struct nlx_core_domain *cd)
Definition: klnet_core.h:275
struct nlx_core_kmem_loc ktm_ctm_loc
Definition: klnet_core.h:124
Definition: mutex.h:47
static void nlx_kcore_kcore_dom_fini(struct nlx_kcore_domain *kd)
nlx_kcore_queue_op_t ko_buf_active_recv
Definition: klnet_core.h:349
struct m0_tlink kb_drv_linkage
Definition: klnet_core.h:169
Definition: vec.h:145
struct m0_tl kd_drv_bufs
Definition: klnet_core.h:113