Motr  M0
bulk.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_RPC_BULK_H__
26 #define __MOTR_RPC_BULK_H__
27 
124 #include "lib/vec.h"
125 #include "lib/tlist.h"
126 #include "lib/mutex.h"
127 #include "lib/chan.h"
128 #include "net/net.h"
129 #include "xcode/xcode.h" /* M0_XCA_ENUM */
130 
131 struct m0_rpc_conn;
132 
139 } M0_XCA_ENUM;
140 
144 enum {
161 
166 };
167 
175  uint64_t bb_magic;
186  uint64_t bb_flags;
187 };
188 
211 M0_INTERNAL int m0_rpc_bulk_buf_add(struct m0_rpc_bulk *rbulk,
212  uint32_t segs_nr, m0_bcount_t length,
213  struct m0_net_domain *netdom,
214  struct m0_net_buffer *nb,
215  struct m0_rpc_bulk_buf **out);
216 
229 M0_INTERNAL int m0_rpc_bulk_buf_databuf_add(struct m0_rpc_bulk_buf *rbuf,
230  void *buf,
233  struct m0_net_domain *netdom);
234 
247 struct m0_rpc_bulk {
249  uint64_t rb_magic;
258  struct m0_chan rb_chan;
266  int32_t rb_rc;
267  uint64_t rb_id;
268 };
269 
276 M0_INTERNAL void m0_rpc_bulk_init(struct m0_rpc_bulk *rbulk);
277 
284 M0_INTERNAL void m0_rpc_bulk_buflist_empty(struct m0_rpc_bulk *rbulk);
285 
290 M0_INTERNAL void m0_rpc_bulk_fini(struct m0_rpc_bulk *rbulk);
291 
300  M0_RPC_BULK_STORE = (1 << 0),
306  M0_RPC_BULK_LOAD = (1 << 1),
307 } M0_XCA_ENUM;
308 
320 M0_INTERNAL void m0_rpc_bulk_qtype(struct m0_rpc_bulk *rbulk,
321  enum m0_net_queue_type q);
322 
339 M0_INTERNAL int
340 m0_rpc_bulk_store(struct m0_rpc_bulk *rbulk,
341  const struct m0_rpc_conn *conn,
342  struct m0_net_buf_desc_data *to_desc,
343  const struct m0_net_buffer_callbacks *bulk_cb);
344 
362 M0_INTERNAL int
363 m0_rpc_bulk_load(struct m0_rpc_bulk *rbulk,
364  const struct m0_rpc_conn *conn,
365  struct m0_net_buf_desc_data *from_desc,
366  const struct m0_net_buffer_callbacks *bulk_cb);
367 
380 M0_INTERNAL void m0_rpc_bulk_store_del(struct m0_rpc_bulk *rbulk);
381 
387 M0_INTERNAL size_t m0_rpc_bulk_store_del_unqueued(struct m0_rpc_bulk *rbulk);
388 
389 M0_INTERNAL void m0_rpc_bulk_default_cb(const struct m0_net_buffer_event *evt);
390 
391 extern const struct m0_net_buffer_callbacks m0_rpc__buf_bulk_cb;
392 
393 M0_INTERNAL size_t m0_rpc_bulk_buf_length(struct m0_rpc_bulk *rbulk);
394 
395 M0_INTERNAL bool m0_rpc_bulk_is_empty(struct m0_rpc_bulk *rbulk);
396 
401 #endif
402 
403 /*
404  * Local variables:
405  * c-indentation-style: "K&R"
406  * c-basic-offset: 8
407  * tab-width: 8
408  * fill-column: 80
409  * scroll-step: 1
410  * End:
411  */
M0_INTERNAL void m0_rpc_bulk_init(struct m0_rpc_bulk *rbulk)
Definition: bulk.c:247
struct m0_tlink bb_link
Definition: bulk.h:182
static struct m0_semaphore q
Definition: rwlock.c:55
struct m0_rpc_bulk * bb_rbulk
Definition: bulk.h:184
M0_INTERNAL void m0_rpc_bulk_fini(struct m0_rpc_bulk *rbulk)
Definition: bulk.c:263
m0_rpc_bulk_op_type
Definition: bulk.h:295
M0_INTERNAL void m0_rpc_bulk_default_cb(const struct m0_net_buffer_event *evt)
Definition: bulk.c:140
struct m0_chan rb_chan
Definition: bulk.h:258
const struct m0_net_buffer_callbacks m0_rpc__buf_bulk_cb
Definition: bulk.c:238
uint64_t m0_bindex_t
Definition: types.h:80
uint64_t m0_bcount_t
Definition: types.h:77
M0_INTERNAL int m0_rpc_bulk_load(struct m0_rpc_bulk *rbulk, const struct m0_rpc_conn *conn, struct m0_net_buf_desc_data *from_desc, const struct m0_net_buffer_callbacks *bulk_cb)
Definition: bulk.c:530
Definition: sock.c:887
static m0_bcount_t count
Definition: xcode.c:167
static void bulk_cb(struct m0_net_test_network_ctx *ctx, const uint32_t buf_index, enum m0_net_queue_type q, const struct m0_net_buffer_event *ev)
Definition: network.c:212
struct m0_net_buffer * bb_nbuf
Definition: bulk.h:177
M0_INTERNAL int m0_rpc_bulk_buf_add(struct m0_rpc_bulk *rbulk, uint32_t segs_nr, m0_bcount_t length, struct m0_net_domain *netdom, struct m0_net_buffer *nb, struct m0_rpc_bulk_buf **out)
Definition: bulk.c:291
int32_t rb_rc
Definition: bulk.h:266
M0_INTERNAL int m0_rpc_bulk_store(struct m0_rpc_bulk *rbulk, const struct m0_rpc_conn *conn, struct m0_net_buf_desc_data *to_desc, const struct m0_net_buffer_callbacks *bulk_cb)
Definition: bulk.c:520
uint64_t bb_flags
Definition: bulk.h:186
Definition: tlist.h:251
M0_INTERNAL bool m0_rpc_bulk_is_empty(struct m0_rpc_bulk *rbulk)
Definition: bulk.c:539
Definition: vec.h:512
struct m0_0vec bb_zerovec
Definition: bulk.h:179
uint64_t bb_magic
Definition: bulk.h:175
Definition: chan.h:229
struct m0_rpc_conn conn
Definition: fsync.c:96
M0_INTERNAL void m0_rpc_bulk_buflist_empty(struct m0_rpc_bulk *rbulk)
Definition: bulk.c:279
uint64_t rb_id
Definition: bulk.h:267
M0_INTERNAL void m0_rpc_bulk_store_del(struct m0_rpc_bulk *rbulk)
Definition: bulk.c:215
m0_net_queue_type
Definition: net.h:591
m0_rpc_bulk_op_states
Definition: bulk.h:136
uint64_t rb_magic
Definition: bulk.h:249
M0_INTERNAL size_t m0_rpc_bulk_buf_length(struct m0_rpc_bulk *rbulk)
Definition: bulk.c:550
m0_bcount_t rb_bytes
Definition: bulk.h:260
struct m0_tl rb_buflist
Definition: bulk.h:256
#define out(...)
Definition: gen.c:41
M0_INTERNAL void m0_rpc_bulk_qtype(struct m0_rpc_bulk *rbulk, enum m0_net_queue_type q)
Definition: bulk.c:372
Definition: mutex.h:47
M0_INTERNAL int m0_rpc_bulk_buf_databuf_add(struct m0_rpc_bulk_buf *rbuf, void *buf, m0_bcount_t count, m0_bindex_t index, struct m0_net_domain *netdom)
Definition: bulk.c:331
enum m0_rpc_bulk_op_states M0_XCA_ENUM
struct m0_mutex rb_mutex
Definition: bulk.h:251
M0_INTERNAL size_t m0_rpc_bulk_store_del_unqueued(struct m0_rpc_bulk *rbulk)
Definition: bulk.c:190