Motr  M0
mem_xprt_pvt.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_PVT_H__
26 #define __MOTR_NET_BULK_MEM_XPRT_PVT_H__
27 
28 #include "lib/errno.h"
29 #include "net/net_internal.h"
31 
38 enum {
43 };
44 
48 struct mem_desc {
50  struct sockaddr_in md_passive;
56  int64_t md_buf_id;
57 };
58 
59 /* forward references to other static functions */
60 static bool mem_dom_invariant(const struct m0_net_domain *dom);
61 static bool mem_ep_invariant(const struct m0_net_end_point *ep);
62 static bool mem_buffer_invariant(const struct m0_net_buffer *nb);
63 static bool mem_tm_invariant(const struct m0_net_transfer_mc *tm);
64 static int mem_ep_create(struct m0_net_end_point **epp,
65  struct m0_net_transfer_mc *tm,
66  const struct sockaddr_in *sa,
67  uint32_t id);
68 static bool mem_eps_are_equal(const struct m0_net_end_point *ep1,
69  const struct m0_net_end_point *ep2);
70 static bool mem_ep_equals_addr(const struct m0_net_end_point *ep,
71  const struct sockaddr_in *sa);
72 static int mem_desc_create(struct m0_net_buf_desc *desc,
73  struct m0_net_transfer_mc *tm,
74  enum m0_net_queue_type qt,
75  m0_bcount_t buflen,
76  int64_t buf_id);
77 static int mem_desc_decode(struct m0_net_buf_desc *desc,
78  struct mem_desc **p_md);
79 static bool mem_desc_equal(struct m0_net_buf_desc *d1,
80  struct m0_net_buf_desc *d2);
81 static m0_bcount_t mem_buffer_length(const struct m0_net_buffer *nb);
82 static bool mem_buffer_in_bounds(const struct m0_net_buffer *nb);
83 static int mem_copy_buffer(struct m0_net_buffer *dest_nb,
84  struct m0_net_buffer *src_nb,
85  m0_bcount_t num_bytes);
86 static void mem_wi_add(struct m0_net_bulk_mem_work_item *wi,
87  struct m0_net_bulk_mem_tm_pvt *tp);
88 static void mem_post_error(struct m0_net_transfer_mc *tm, int status);
90 
96 static inline int mem_bmo_ep_create(struct m0_net_end_point **epp,
97  struct m0_net_transfer_mc *tm,
98  const struct sockaddr_in *sa,
99  uint32_t id)
100 {
102  return dp->xd_ops->bmo_ep_create(epp, tm, sa, id);
103 }
104 
110 static inline bool mem_bmo_buffer_in_bounds(const struct m0_net_buffer *nb)
111 {
113  return dp->xd_ops->bmo_buffer_in_bounds(nb);
114 }
115 
121 static int mem_bmo_desc_create(struct m0_net_buf_desc *desc,
122  struct m0_net_transfer_mc *tm,
123  enum m0_net_queue_type qt,
124  m0_bcount_t buflen,
125  int64_t buf_id)
126 {
128  return dp->xd_ops->bmo_desc_create(desc, tm, qt, buflen, buf_id);
129 }
130 
135 #endif /* __MOTR_NET_BULK_MEM_XPRT_PVT_H__ */
136 
137 /*
138  * Local variables:
139  * c-indentation-style: "K&R"
140  * c-basic-offset: 8
141  * tab-width: 8
142  * fill-column: 79
143  * scroll-step: 1
144  * End:
145  */
static int mem_desc_decode(struct m0_net_buf_desc *desc, struct mem_desc **p_md)
static bool mem_bmo_buffer_in_bounds(const struct m0_net_buffer *nb)
Definition: mem_xprt_pvt.h:110
static int mem_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)
static bool mem_tm_invariant(const struct m0_net_transfer_mc *tm)
static bool mem_desc_equal(struct m0_net_buf_desc *d1, struct m0_net_buf_desc *d2)
static int mem_copy_buffer(struct m0_net_buffer *dest_nb, struct m0_net_buffer *src_nb, m0_bcount_t num_bytes)
static void mem_wi_add(struct m0_net_bulk_mem_work_item *wi, struct m0_net_bulk_mem_tm_pvt *tp)
static void mem_wi_post_buffer_event(struct m0_net_bulk_mem_work_item *wi)
struct m0_net_domain * ntm_dom
Definition: net.h:853
uint64_t m0_bcount_t
Definition: types.h:77
static bool mem_buffer_in_bounds(const struct m0_net_buffer *nb)
static int mem_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_pvt.h:121
Definition: sock.c:754
static void mem_post_error(struct m0_net_transfer_mc *tm, int status)
m0_bcount_t md_len
Definition: mem_xprt_pvt.h:54
void * nd_xprt_private
Definition: net.h:393
struct sockaddr_in md_passive
Definition: mem_xprt_pvt.h:50
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
static bool mem_eps_are_equal(const struct m0_net_end_point *ep1, const struct m0_net_end_point *ep2)
struct m0_net_domain * nb_dom
Definition: net.h:1351
static bool mem_ep_equals_addr(const struct m0_net_end_point *ep, const struct sockaddr_in *sa)
enum m0_net_queue_type md_qt
Definition: mem_xprt_pvt.h:52
static m0_bcount_t mem_buffer_length(const struct m0_net_buffer *nb)
static bool mem_dom_invariant(const struct m0_net_domain *dom)
static int mem_ep_create(struct m0_net_end_point **epp, struct m0_net_transfer_mc *tm, const struct sockaddr_in *sa, uint32_t id)
Definition: queue.c:27
m0_net_queue_type
Definition: net.h:591
const struct m0_net_bulk_mem_ops * xd_ops
Definition: mem_xprt.h:338
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
static bool mem_buffer_invariant(const struct m0_net_buffer *nb)
static bool mem_ep_invariant(const struct m0_net_end_point *ep)
bool(* bmo_buffer_in_bounds)(const struct m0_net_buffer *nb)
Definition: mem_xprt.h:311
static int mem_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_pvt.h:96
int64_t md_buf_id
Definition: mem_xprt_pvt.h:56