Motr  M0
at.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2016-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_AT_H__
26 #define __MOTR_RPC_AT_H__
27 
28 #include "lib/types.h"
29 #include "lib/buf.h" /* m0_buf */
30 #include "lib/buf_xc.h" /* m0_buf_xc */
31 #include "net/net_otw_types.h" /* m0_net_buf_desc_data */
32 #include "net/net_otw_types_xc.h" /* m0_net_buf_desc_data */
33 #include "xcode/xcode_attr.h"
34 #include "lib/assert.h" /* M0_BASSERT */
35 
36 
209 /* Import */
210 struct m0_fom;
211 struct m0_rpc_conn;
212 struct rpc_at_bulk;
213 
221 };
222 
223 enum {
225 };
226 
236  int32_t abr_rc;
237 
239  uint64_t abr_len;
240 } M0_XCA_RECORD M0_XCA_DOMAIN(rpc);
241 
243  /* This field is not used, it's neccessary for proper alignment only. */
247 } M0_XCA_RECORD M0_XCA_DOMAIN(rpc);
248 
251  uint32_t ab_type;
252  union {
253  struct m0_buf ab_buf
255 
256  struct m0_net_buf_desc_data ab_send
258 
259  struct m0_net_buf_desc_data ab_recv
261 
262  struct m0_rpc_at_bulk_rep ab_rep
264 
273  struct m0_rpc_at_extra ab_extra
275  } u;
276 } M0_XCA_UNION M0_XCA_DOMAIN(rpc);
277 
278 /* Checks that ab_extra is properly placed in union. */
279 M0_BASSERT(sizeof((struct m0_rpc_at_buf *) 0)->u ==
280  sizeof(struct m0_rpc_at_extra));
281 M0_BASSERT(offsetof(struct m0_rpc_at_buf, u.ab_extra.abr_bulk) >=
282  sizeof((struct m0_rpc_at_buf *) 0)->u.ab_buf);
283 M0_BASSERT(offsetof(struct m0_rpc_at_buf, u.ab_extra.abr_bulk) >=
284  sizeof((struct m0_rpc_at_buf *) 0)->u.ab_send);
285 M0_BASSERT(offsetof(struct m0_rpc_at_buf, u.ab_extra.abr_bulk) >=
286  sizeof((struct m0_rpc_at_buf *) 0)->u.ab_recv);
287 M0_BASSERT(offsetof(struct m0_rpc_at_buf, u.ab_extra.abr_bulk) >=
288  sizeof((struct m0_rpc_at_buf *) 0)->u.ab_rep);
289 
296 M0_INTERNAL void m0_rpc_at_init(struct m0_rpc_at_buf *ab);
297 
304 M0_INTERNAL void m0_rpc_at_fini(struct m0_rpc_at_buf *ab);
305 
313 M0_INTERNAL int m0_rpc_at_add(struct m0_rpc_at_buf *ab,
314  const struct m0_buf *buf,
315  const struct m0_rpc_conn *conn);
316 
330 M0_INTERNAL int m0_rpc_at_load(struct m0_rpc_at_buf *ab, struct m0_fom *fom,
331  int next_phase);
332 
343 M0_INTERNAL int m0_rpc_at_get(const struct m0_rpc_at_buf *ab,
344  struct m0_buf *buf);
345 
346 
356 M0_INTERNAL int m0_rpc_at_recv(struct m0_rpc_at_buf *ab,
357  const struct m0_rpc_conn *conn,
358  uint32_t len,
359  bool force_bulk);
360 
370 M0_INTERNAL int m0_rpc_at_reply(struct m0_rpc_at_buf *in,
371  struct m0_rpc_at_buf *out,
372  struct m0_buf *repbuf,
373  struct m0_fom *fom,
374  int next_phase);
375 
381 M0_INTERNAL int m0_rpc_at_reply_rc(struct m0_rpc_at_buf *out);
382 
390 M0_INTERNAL int m0_rpc_at_rep_get(struct m0_rpc_at_buf *sent,
391  struct m0_rpc_at_buf *rcvd,
392  struct m0_buf *out);
393 
401 M0_INTERNAL int m0_rpc_at_rep2inline(struct m0_rpc_at_buf *sent,
402  struct m0_rpc_at_buf *rcvd);
403 
411 M0_INTERNAL bool m0_rpc_at_rep_is_bulk(const struct m0_rpc_at_buf *rcvd,
412  uint64_t *len);
413 
422 M0_INTERNAL bool m0_rpc_at_is_set(const struct m0_rpc_at_buf *ab);
423 
432 M0_INTERNAL void m0_rpc_at_detach(struct m0_rpc_at_buf *ab);
433 
442 M0_INTERNAL uint64_t m0_rpc_at_len(const struct m0_rpc_at_buf *ab);
443 
446 #endif /* __MOTR_RPC_AT_H__ */
447 
448 /*
449  * Local variables:
450  * c-indentation-style: "K&R"
451  * c-basic-offset: 8
452  * tab-width: 8
453  * fill-column: 80
454  * scroll-step: 1
455  * End:
456  */
457 /*
458  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
459  */
int32_t abr_rc
Definition: at.h:236
M0_INTERNAL void m0_rpc_at_init(struct m0_rpc_at_buf *ab)
Definition: at.c:433
M0_INTERNAL bool m0_rpc_at_is_set(const struct m0_rpc_at_buf *ab)
Definition: at.c:492
union @448 u
struct m0_net_buf_desc_data abr_desc
Definition: at.h:244
M0_INTERNAL int m0_rpc_at_add(struct m0_rpc_at_buf *ab, const struct m0_buf *buf, const struct m0_rpc_conn *conn)
Definition: at.c:462
m0_rpc_at_type
Definition: at.h:214
M0_INTERNAL int m0_rpc_at_load(struct m0_rpc_at_buf *ab, struct m0_fom *fom, int next_phase)
Definition: at.c:414
#define M0_XCA_TAG(value)
Definition: xcode_attr.h:57
Definition: at.c:49
Definition: sock.c:887
M0_INTERNAL int m0_rpc_at_reply(struct m0_rpc_at_buf *in, struct m0_rpc_at_buf *out, struct m0_buf *repbuf, struct m0_fom *fom, int next_phase)
Definition: at.c:528
M0_INTERNAL int m0_rpc_at_rep_get(struct m0_rpc_at_buf *sent, struct m0_rpc_at_buf *rcvd, struct m0_buf *out)
Definition: at.c:606
Definition: buf.h:37
M0_INTERNAL bool m0_rpc_at_rep_is_bulk(const struct m0_rpc_at_buf *rcvd, uint64_t *len)
Definition: at.c:651
M0_BASSERT(sizeof((struct m0_rpc_at_buf *) 0) ->u==sizeof(struct m0_rpc_at_extra))
M0_INTERNAL int m0_rpc_at_get(const struct m0_rpc_at_buf *ab, struct m0_buf *buf)
Definition: at.c:399
M0_INTERNAL int m0_rpc_at_reply_rc(struct m0_rpc_at_buf *out)
Definition: at.c:583
union m0_rpc_at_buf::@447 u
Definition: dump.c:103
struct m0_rpc_conn conn
Definition: fsync.c:96
struct m0_buf abr_user_buf
Definition: at.h:246
Definition: fom.h:481
uint64_t abr_len
Definition: at.h:239
M0_INTERNAL uint64_t m0_rpc_at_len(const struct m0_rpc_at_buf *ab)
Definition: at.c:709
M0_INTERNAL void m0_rpc_at_fini(struct m0_rpc_at_buf *ab)
Definition: at.c:441
#define out(...)
Definition: gen.c:41
struct m0_rpc_at_bulk_rep M0_XCA_DOMAIN(rpc)
M0_INTERNAL int m0_rpc_at_rep2inline(struct m0_rpc_at_buf *sent, struct m0_rpc_at_buf *rcvd)
Definition: at.c:663
#define offsetof(typ, memb)
Definition: misc.h:29
M0_INTERNAL void m0_rpc_at_detach(struct m0_rpc_at_buf *ab)
Definition: at.c:694
M0_INTERNAL int m0_rpc_at_recv(struct m0_rpc_at_buf *ab, const struct m0_rpc_conn *conn, uint32_t len, bool force_bulk)
Definition: at.c:508
uint32_t ab_type
Definition: at.h:251
struct rpc_at_bulk * abr_bulk
Definition: at.h:245