Motr  M0
mem_xprt.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_BULK_MEM_XPRT_H__
26 #define __MOTR_NET_BULK_MEM_XPRT_H__
27 
28 #include "lib/atomic.h"
29 #include "lib/thread.h"
30 
31 #ifdef __KERNEL__
32 #include <linux/in.h>
33 #include <linux/inet.h>
34 
35 /* The kernel does not define these types */
36 typedef __be32 in_addr_t;
37 typedef __be16 in_port_t;
38 
39 #else
40 #include <sys/socket.h>
41 #include <netinet/in.h>
42 #include <arpa/inet.h>
43 #endif
44 
45 #include "motr/magic.h"
46 #include "net/bulk_mem.h"
47 
107 
127 
129 };
130 
147 };
148 
159 
164 
167 
173  int32_t xwi_status;
174 
177 
180 };
181 
188 
191 
195  int64_t xb_buf_id;
196 };
197 
201 static inline struct m0_net_bulk_mem_buffer_pvt *
203 {
204  return nb->nb_xprt_private;
205 }
206 
225 };
226 
230 static inline struct m0_net_bulk_mem_tm_pvt *
232 {
233  return tm->ntm_xprt_private;
234 }
235 
241  uint64_t xep_magic;
242 
244  struct sockaddr_in xep_sa;
245 
249  uint32_t xep_service_id;
250 
253 
256 };
257 
261 static inline struct m0_net_bulk_mem_end_point *
263 {
265 }
266 
273  struct m0_net_bulk_mem_work_item *wi);
274 
282 
285  struct m0_net_transfer_mc *tm,
286  const struct sockaddr_in *sa,
287  uint32_t id);
288 
290  struct m0_net_bulk_mem_end_point *(*bmo_ep_alloc)(void);
291 
294 
298  void (*bmo_ep_release)(struct m0_ref *ref);
299 
304  void (*bmo_ep_get)(struct m0_net_end_point *ep);
305 
308  struct m0_net_bulk_mem_tm_pvt *tp);
309 
311  bool (*bmo_buffer_in_bounds)(const struct m0_net_buffer *nb);
312 
315  struct m0_net_transfer_mc *tm,
316  enum m0_net_queue_type qt,
317  m0_bcount_t buflen,
318  int64_t buf_id);
319 
321  void (*bmo_post_error)(struct m0_net_transfer_mc *tm,
322  int status);
323 
326 };
327 
336 
339 
344 
349 
356 
363 
369 };
370 
374 static inline struct m0_net_bulk_mem_domain_pvt *
376 {
377  return dom->nd_xprt_private;
378 }
379 
385 static inline struct m0_net_buffer *
387 {
390  return bp->xb_buffer;
391 }
392 
398 static inline struct m0_net_bulk_mem_work_item *
400 {
402  return &bp->xb_wi;
403 }
404 
410 static inline in_addr_t mem_ep_addr(struct m0_net_end_point *ep)
411 {
412  struct m0_net_bulk_mem_end_point *mep =
414  return mep->xep_sa.sin_addr.s_addr;
415 }
416 
422 static inline in_port_t mem_ep_port(struct m0_net_end_point *ep)
423 {
424  struct m0_net_bulk_mem_end_point *mep =
426  return mep->xep_sa.sin_port;
427 }
428 
434 static inline uint32_t mem_ep_sid(struct m0_net_end_point *ep)
435 {
436  struct m0_net_bulk_mem_end_point *mep =
438  return mep->xep_service_id;
439 }
440 
446 static inline bool mem_sa_eq(const struct sockaddr_in *sa1,
447  const struct sockaddr_in *sa2)
448 {
449  return sa1->sin_addr.s_addr == sa2->sin_addr.s_addr &&
450  sa1->sin_port == sa2->sin_port;
451 }
452 
453 M0_INTERNAL int m0_mem_xprt_init(void);
454 M0_INTERNAL void m0_mem_xprt_fini(void);
455 
460 #endif /* __MOTR_NET_BULK_MEM_XPRT_H__ */
461 
462 /*
463  * Local variables:
464  * c-indentation-style: "K&R"
465  * c-basic-offset: 8
466  * tab-width: 8
467  * fill-column: 79
468  * scroll-step: 1
469  * End:
470  */
struct m0_list_link xwi_link
Definition: mem_xprt.h:158
static bool mem_sa_eq(const struct sockaddr_in *sa1, const struct sockaddr_in *sa2)
Definition: mem_xprt.h:446
uint64_t id
Definition: cob.h:2380
Definition: cond.h:99
struct m0_cond xtm_work_list_cv
Definition: mem_xprt.h:218
struct m0_net_buffer * xb_buffer
Definition: mem_xprt.h:187
enum m0_net_bulk_mem_tm_state xtm_state
Definition: mem_xprt.h:214
static struct m0_net_buffer * mem_wi_to_buffer(struct m0_net_bulk_mem_work_item *wi)
Definition: mem_xprt.h:386
struct m0_list_link xd_dom_linkage
Definition: mem_xprt.h:355
void(* bmo_wi_post_buffer_event)(struct m0_net_bulk_mem_work_item *wi)
Definition: mem_xprt.h:325
struct m0_thread * xtm_worker_threads
Definition: mem_xprt.h:222
enum m0_net_bulk_mem_work_opcode xwi_op
Definition: mem_xprt.h:163
enum m0_net_bulk_mem_tm_state xwi_next_state
Definition: mem_xprt.h:166
M0_INTERNAL int m0_mem_xprt_init(void)
Definition: mem_xprt_xo.c:47
uint64_t m0_bcount_t
Definition: types.h:77
struct m0_list xtm_work_list
Definition: mem_xprt.h:216
struct m0_net_end_point * xwi_nbe_ep
Definition: mem_xprt.h:179
#define container_of(ptr, type, member)
Definition: misc.h:33
static in_port_t mem_ep_port(struct m0_net_end_point *ep)
Definition: mem_xprt.h:422
Definition: sock.c:887
Definition: sock.c:754
static struct m0_net_bulk_mem_end_point * mem_ep_to_pvt(const struct m0_net_end_point *ep)
Definition: mem_xprt.h:262
void * ntm_xprt_private
Definition: net.h:886
Definition: refs.h:34
m0_bcount_t xwi_nbe_length
Definition: mem_xprt.h:176
void(* bmo_ep_release)(struct m0_ref *ref)
Definition: mem_xprt.h:298
void(* bmo_post_error)(struct m0_net_transfer_mc *tm, int status)
Definition: mem_xprt.h:321
int(* bmo_ep_create)(struct m0_net_end_point **epp, struct m0_net_transfer_mc *tm, const struct sockaddr_in *sa, uint32_t id)
Definition: mem_xprt.h:284
static struct m0_stob_domain * dom
Definition: storage.c:38
void(* bmo_ep_free)(struct m0_net_bulk_mem_end_point *mep)
Definition: mem_xprt.h:293
void(* bmo_ep_get)(struct m0_net_end_point *ep)
Definition: mem_xprt.h:304
static in_addr_t mem_ep_addr(struct m0_net_end_point *ep)
Definition: mem_xprt.h:410
struct m0_net_bulk_mem_work_item xb_wi
Definition: mem_xprt.h:190
static struct m0_net_bulk_mem_work_item * mem_buffer_to_wi(struct m0_net_buffer *buf)
Definition: mem_xprt.h:399
void(* bmo_wi_add)(struct m0_net_bulk_mem_work_item *wi, struct m0_net_bulk_mem_tm_pvt *tp)
Definition: mem_xprt.h:307
static struct m0_net_bulk_mem_buffer_pvt * mem_buffer_to_pvt(const struct m0_net_buffer *nb)
Definition: mem_xprt.h:202
m0_net_bulk_mem_work_fn_t bmo_work_fn[M0_NET_XOP_NR]
Definition: mem_xprt.h:281
Definition: list.h:72
M0_INTERNAL void m0_mem_xprt_fini(void)
Definition: mem_xprt_xo.c:59
static uint32_t mem_ep_sid(struct m0_net_end_point *ep)
Definition: mem_xprt.h:434
char * ep
Definition: sw.h:132
Definition: queue.c:27
m0_net_queue_type
Definition: net.h:591
uint32_t xtm_callback_counter
Definition: mem_xprt.h:220
const struct m0_net_bulk_mem_ops * xd_ops
Definition: mem_xprt.h:338
struct sockaddr_in xep_sa
Definition: mem_xprt.h:244
int(* bmo_desc_create)(struct m0_net_buf_desc *desc, struct m0_net_transfer_mc *tm, enum m0_net_queue_type qt, m0_bcount_t buflen, int64_t buf_id)
Definition: mem_xprt.h:314
struct m0_net_domain * xd_dom
Definition: mem_xprt.h:335
m0_net_bulk_mem_tm_state
Definition: mem_xprt.h:139
m0_net_bulk_mem_work_opcode
Definition: mem_xprt.h:112
static struct bulkio_params * bp
Definition: bulkio_ut.c:44
struct m0_net_end_point xep_ep
Definition: mem_xprt.h:252
static struct m0_net_bulk_mem_domain_pvt * mem_dom_to_pvt(const struct m0_net_domain *dom)
Definition: mem_xprt.h:375
char xep_addr[M0_NET_BULK_MEM_XEP_ADDR_LEN]
Definition: mem_xprt.h:255
static struct m0_net_bulk_mem_tm_pvt * mem_tm_to_pvt(const struct m0_net_transfer_mc *tm)
Definition: mem_xprt.h:231
bool(* bmo_buffer_in_bounds)(const struct m0_net_buffer *nb)
Definition: mem_xprt.h:311
struct m0_net_transfer_mc * xtm_tm
Definition: mem_xprt.h:212
void * nb_xprt_private
Definition: net.h:1461
void(* m0_net_bulk_mem_work_fn_t)(struct m0_net_transfer_mc *tm, struct m0_net_bulk_mem_work_item *wi)
Definition: mem_xprt.h:272