Motr  M0
conn.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_CONN_H__
26 #define __MOTR_RPC_CONN_H__
27 
28 #include "lib/tlist.h"
29 #include "lib/time.h" /* m0_time_t */
30 #include "sm/sm.h"
31 #include "rpc/onwire.h" /* m0_rpc_sender_uuid */
32 #include "fid/fid.h" /* m0_fid */
33 
34 /* Imports */
35 struct m0_rpc_machine;
36 struct m0_rpc_service;
37 struct m0_rpc_chan;
38 struct m0_net_end_point;
39 struct m0_conf_obj;
40 
41 /* Exports */
42 struct m0_rpc_conn;
43 
56 
62 
68 
74 
82 
89 
94 };
95 
100  RCF_SENDER_END = 1 << 0,
101  RCF_RECV_END = 1 << 1,
104 };
105 
267 struct m0_rpc_conn {
269  uint64_t c_sender_id;
270 
273 
275  uint64_t c_flags;
276 
279 
282 
284  uint64_t c_ha_attempts;
285 
292 
298  struct m0_tlink c_link;
299 
301  uint64_t c_nr_sessions;
302 
309 
315 
318 
322  struct m0_sm c_sm;
323 
330  struct m0_sm_ast c_ast;
331 
334 
336  uint64_t c_magic;
337 
340 
343 
346 
351 };
352 
372 M0_INTERNAL int m0_rpc_conn_init(struct m0_rpc_conn *conn,
373  struct m0_fid *svc_obj,
374  struct m0_net_end_point *ep,
375  struct m0_rpc_machine *machine,
376  uint64_t max_rpcs_in_flight);
377 
378 M0_INTERNAL void m0_rpc_conn_reset(struct m0_rpc_conn *conn);
379 
389 M0_INTERNAL int m0_rpc_conn_establish(struct m0_rpc_conn *conn,
390  m0_time_t abs_timeout);
391 
404 M0_INTERNAL int m0_rpc_conn_establish_sync(struct m0_rpc_conn *conn,
405  m0_time_t abs_timeout);
406 
417 M0_INTERNAL int m0_rpc_conn_create(struct m0_rpc_conn *conn,
418  struct m0_fid *svc_fid,
419  struct m0_net_end_point *ep,
420  struct m0_rpc_machine *rpc_machine,
421  uint64_t max_rpcs_in_flight,
422  m0_time_t abs_timeout);
423 
437 M0_INTERNAL int m0_rpc_conn_terminate(struct m0_rpc_conn *conn,
438  m0_time_t abs_timeout);
439 
453 M0_INTERNAL int m0_rpc_conn_terminate_sync(struct m0_rpc_conn *conn,
454  m0_time_t abs_timeout);
455 
463 M0_INTERNAL void m0_rpc_conn_fini(struct m0_rpc_conn *conn);
464 
470 int m0_rpc_conn_destroy(struct m0_rpc_conn *conn, m0_time_t abs_timeout);
471 
484 M0_INTERNAL int m0_rpc_conn_timedwait(struct m0_rpc_conn *conn,
485  uint64_t states,
486  const m0_time_t abs_timeout);
487 
494 M0_INTERNAL int m0_rpc_conn_ha_subscribe(struct m0_rpc_conn *conn,
495  struct m0_fid *svc_fid);
496 
501 M0_INTERNAL void m0_rpc_conn_ha_unsubscribe(struct m0_rpc_conn *conn);
502 
510  int dir);
511 
512 M0_INTERNAL const char *m0_rpc_conn_addr(const struct m0_rpc_conn *conn);
513 
519 M0_INTERNAL bool m0_rpc_conn_is_known_dead(const struct m0_rpc_conn *conn);
520 
521 M0_INTERNAL struct m0_conf_obj *m0_rpc_conn2svc(const struct m0_rpc_conn *conn);
522 
528 M0_INTERNAL void m0_rpc_conn_ha_cfg_set(struct m0_rpc_conn *conn,
529  const struct m0_rpc_conn_ha_cfg *cfg);
530 
531 M0_INTERNAL const char *m0_rpc_conn_state_to_str(enum m0_rpc_conn_state state);
532 
540 M0_INTERNAL void m0_rpc_conn_sessions_cancel(struct m0_rpc_conn *conn);
541 
543 #endif /* __MOTR_RPC_CONN_H__ */
M0_INTERNAL int m0_rpc_machine_conn_list_dump(struct m0_rpc_machine *machine, int dir)
Definition: conn.c:1276
M0_INTERNAL bool m0_rpc_conn_is_known_dead(const struct m0_rpc_conn *conn)
Definition: conn.c:1311
uint64_t c_nr_sessions
Definition: conn.h:301
uint64_t m0_time_t
Definition: time.h:37
struct m0_clink c_conf_exp_clink
Definition: conn.h:342
Definition: sm.h:504
struct m0_tl c_item_sources
Definition: conn.h:314
struct m0_rpc_chan * c_rpcchan
Definition: conn.h:317
M0_INTERNAL int m0_rpc_conn_timedwait(struct m0_rpc_conn *conn, uint64_t states, const m0_time_t timeout)
Definition: conn.c:700
M0_INTERNAL int m0_rpc_conn_terminate(struct m0_rpc_conn *conn, m0_time_t abs_timeout)
Definition: conn.c:1009
struct m0_clink c_conf_ready_clink
Definition: conn.h:345
struct m0_sm c_sm
Definition: conn.h:322
Definition: sock.c:754
M0_INTERNAL const char * m0_rpc_conn_addr(const struct m0_rpc_conn *conn)
Definition: conn.c:1306
const struct m0_rpc_conn_ha_cfg * c_ha_cfg
Definition: conn.h:281
struct m0_rpc_machine * c_rpc_machine
Definition: conn.h:278
M0_INTERNAL int m0_rpc_conn_establish_sync(struct m0_rpc_conn *conn, m0_time_t abs_timeout)
Definition: conn.c:836
M0_INTERNAL int m0_rpc_conn_create(struct m0_rpc_conn *conn, struct m0_fid *svc_fid, struct m0_net_end_point *ep, struct m0_rpc_machine *rpc_machine, uint64_t max_rpcs_in_flight, m0_time_t abs_timeout)
Definition: conn.c:809
uint64_t c_sender_id
Definition: conn.h:269
M0_INTERNAL int m0_rpc_conn_ha_subscribe(struct m0_rpc_conn *conn, struct m0_fid *svc_fid)
Definition: conn.c:585
uint64_t c_flags
Definition: conn.h:275
M0_INTERNAL const char * m0_rpc_conn_state_to_str(enum m0_rpc_conn_state state)
Definition: conn.c:1532
bool c_ast_in_progress
Definition: conn.h:333
Definition: tlist.h:251
uint64_t c_magic
Definition: conn.h:336
int m0_rpc_conn_destroy(struct m0_rpc_conn *conn, m0_time_t abs_timeout)
Definition: conn.c:974
M0_INTERNAL int m0_rpc_conn_terminate_sync(struct m0_rpc_conn *conn, m0_time_t abs_timeout)
Definition: conn.c:988
struct m0_rpc_conn conn
Definition: fsync.c:96
struct m0_rpc_machine machine
Definition: mdstore.c:58
struct m0_uint128 c_uuid
Definition: conn.h:272
struct m0_tl c_sessions
Definition: conn.h:308
struct m0_sm_ast c_ast
Definition: conn.h:330
M0_INTERNAL void m0_rpc_conn_ha_cfg_set(struct m0_rpc_conn *conn, const struct m0_rpc_conn_ha_cfg *cfg)
Definition: conn.c:1523
struct m0_fid c_svc_fid
Definition: conn.h:350
Definition: fid.h:38
uint64_t c_ha_attempts
Definition: conn.h:284
m0_rpc_conn_flags
Definition: conn.h:99
struct m0_sm_timer c_ha_timer
Definition: conn.h:291
Definition: sm.h:301
M0_INTERNAL int m0_rpc_conn_establish(struct m0_rpc_conn *conn, m0_time_t abs_timeout)
Definition: conn.c:857
struct m0_clink c_ha_clink
Definition: conn.h:339
M0_INTERNAL struct m0_conf_obj * m0_rpc_conn2svc(const struct m0_rpc_conn *conn)
Definition: conn.c:349
M0_INTERNAL int m0_rpc_conn_init(struct m0_rpc_conn *conn, struct m0_fid *svc_fid, struct m0_net_end_point *ep, struct m0_rpc_machine *machine, uint64_t max_rpcs_in_flight)
Definition: conn.c:293
struct m0_tlink c_link
Definition: conn.h:298
M0_INTERNAL void m0_rpc_conn_ha_unsubscribe(struct m0_rpc_conn *conn)
Definition: conn.c:632
struct inode * dir
Definition: dir.c:1028
M0_INTERNAL void m0_rpc_conn_sessions_cancel(struct m0_rpc_conn *conn)
Definition: conn.c:1324
M0_INTERNAL void m0_rpc_conn_reset(struct m0_rpc_conn *conn)
Definition: conn.c:452
static struct m0_rpc_machine rpc_machine
Definition: service_ut.c:63
M0_INTERNAL void m0_rpc_conn_fini(struct m0_rpc_conn *conn)
Definition: conn.c:558
static struct m0_sm_state_descr states[C_NR]
Definition: sm.c:512
m0_rpc_conn_state
Definition: conn.h:50