Motr  M0
ping.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_LNET_PING_H__
26 #define __MOTR_NET_LNET_PING_H__
27 
28 #include "lib/bitmap.h" /* m0_bitmap */
29 
30 struct nlx_ping_ctx;
31 struct nlx_ping_ops {
32  int (*pf)(const char *format, ...)
33  __attribute__ ((format (printf, 1, 2)));
34  void (*pqs)(struct nlx_ping_ctx *ctx, bool reset);
35 };
36 
40 struct nlx_ping_ctx {
41  const struct nlx_ping_ops *pc_ops;
42  const struct m0_net_xprt *pc_xprt;
44  const char *pc_network;/* "addr@interface" */
45  uint32_t pc_pid;
46  uint32_t pc_portal;
47  int32_t pc_tmid; /* initialized to < 0 */
48  const char *pc_rnetwork;
49  uint32_t pc_rpid;
50  uint32_t pc_rportal;
51  int32_t pc_rtmid;
52  int32_t pc_status;
53  uint32_t pc_nr_bufs;
54  uint32_t pc_nr_recv_bufs;
55  uint32_t pc_segments;
56  uint32_t pc_seg_size;
57  uint32_t pc_seg_shift;
60  uint64_t pc_bulk_size;
66  struct m0_cond pc_cond;
68  const char *pc_ident;
69  const char *pc_compare_buf;
75  bool pc_ready;
76  char **pc_interfaces;
84  uint64_t pc_blocked_count;
85  uint64_t pc_worked_count;
89 };
90 
92  const struct nlx_ping_ops *ops;
93  int loops;
94  unsigned int nr_bufs;
95  int client_id;
96  uint64_t bulk_size;
100  const char *client_network;
101  uint32_t client_pid;
102  uint32_t client_portal;
103  int32_t client_tmid;
104  const char *server_network;
105  uint32_t server_pid;
106  uint32_t server_portal;
107  int32_t server_tmid;
108  int debug;
109  int verbose;
110 };
111 
112 enum {
117 
123 
126 
133 
134  PING_MSG_OVERHEAD = 2, /* Msg type byte + '\0' */
135 
136  PING_DEF_MIN_RECV_SIZE = 100, /* empirical observation: 58 */
137 
138  ONE_MILLION = 1000000ULL,
139  SEC_PER_HR = 60 * 60,
141 };
142 
143 /* Debug printf macro */
144 #ifdef __KERNEL__
145 #define PING_ERR(fmt, ...) printk(KERN_ERR fmt , ## __VA_ARGS__)
146 #else
147 #include <stdio.h>
148 #define PING_ERR(fmt, ...) fprintf(stderr, fmt , ## __VA_ARGS__)
149 #endif
150 
151 #define PING_OUT(ctx, num, fmt, ...) \
152 do { \
153  if ((ctx)->pc_verbose >= num) \
154  (ctx)->pc_ops->pf(fmt , ## __VA_ARGS__);\
155 } while (0)
156 
158  struct nlx_ping_ctx *sctx);
161 
162 void nlx_ping_print_qstats_tm(struct nlx_ping_ctx *ctx, bool reset);
163 int nlx_ping_print_qstats_total(const char *ident,
164  const struct nlx_ping_ops *ops);
165 uint64_t nlx_ping_parse_uint64(const char *s);
166 void nlx_ping_init(void);
167 void nlx_ping_fini(void);
168 
169 #endif /* __MOTR_NET_LNET_PING_H__ */
170 
171 /*
172  * Local variables:
173  * c-indentation-style: "K&R"
174  * c-basic-offset: 8
175  * tab-width: 8
176  * fill-column: 79
177  * scroll-step: 1
178  * End:
179  */
uint32_t pc_rpid
Definition: ping.h:49
uint32_t pc_rportal
Definition: ping.h:50
Definition: cond.h:99
struct m0_cond pc_cond
Definition: ping.h:66
int pc_server_bulk_delay
Definition: ping.h:72
static struct m0_thread server_thread
void nlx_ping_fini(void)
Definition: ping.c:1921
void nlx_ping_init(void)
Definition: ping.c:1916
int32_t server_tmid
Definition: ping.h:107
const char * pc_compare_buf
Definition: ping.h:69
struct m0_net_domain pc_dom
Definition: ping.h:43
uint32_t pc_nr_bufs
Definition: ping.h:53
int(* pf)(const char *format,...) __attribute__((format(printf
Definition: ping.h:32
const struct nlx_ping_ops * pc_ops
Definition: ping.h:41
enum m0_md_lustre_logrec_type __attribute__
Definition: balloc.c:2745
uint32_t pc_seg_shift
Definition: ping.h:57
const char * pc_ident
Definition: ping.h:68
uint32_t pc_portal
Definition: ping.h:46
uint32_t server_pid
Definition: ping.h:105
int pc_msg_timeout
Definition: ping.h:71
void nlx_ping_server_spawn(struct m0_thread *server_thread, struct nlx_ping_ctx *sctx)
Definition: ping.c:1496
int32_t client_tmid
Definition: ping.h:103
const struct nlx_ping_ops * ops
Definition: ping.h:92
const char * server_network
Definition: ping.h:104
uint64_t bulk_size
Definition: ping.h:96
const char * client_network
Definition: ping.h:100
uint32_t client_pid
Definition: ping.h:101
struct m0_chan pc_wq_chan
Definition: ping.h:78
struct m0_net_transfer_mc pc_tm
Definition: ping.h:64
int32_t pc_rtmid
Definition: ping.h:51
const char * pc_network
Definition: ping.h:44
const char * pc_rnetwork
Definition: ping.h:48
struct m0_atomic64 pc_errors
Definition: ping.h:86
bool pc_sync_events
Definition: ping.h:77
static struct m0_rpc_server_ctx sctx
Definition: console.c:88
uint64_t pc_blocked_count
Definition: ping.h:84
void nlx_ping_print_qstats_tm(struct nlx_ping_ctx *ctx, bool reset)
Definition: ping.c:136
int pc_max_recv_msgs
Definition: ping.h:59
struct m0_clink pc_net_clink
Definition: ping.h:82
int32_t pc_tmid
Definition: ping.h:47
Definition: chan.h:229
unsigned int nr_bufs
Definition: ping.h:94
struct m0_atomic64 pc_retries
Definition: ping.h:87
uint64_t pc_net_signal_count
Definition: ping.h:83
uint64_t pc_worked_count
Definition: ping.h:85
static struct fdmi_ctx ctx
Definition: main.c:80
char ** pc_interfaces
Definition: ping.h:76
uint64_t pc_wq_signal_count
Definition: ping.h:80
struct m0_net_buffer * pc_nbs
Definition: ping.h:61
Definition: list.h:72
const struct m0_net_buffer_callbacks * pc_buf_callbacks
Definition: ping.h:62
format
Definition: hist.py:128
int pc_bulk_timeout
Definition: ping.h:70
uint32_t pc_nr_recv_bufs
Definition: ping.h:54
uint32_t client_portal
Definition: ping.h:102
bool pc_ready
Definition: ping.h:75
int nlx_ping_print_qstats_total(const char *ident, const struct nlx_ping_ops *ops)
Definition: ping.c:151
void nlx_ping_server_should_stop(struct nlx_ping_ctx *ctx)
Definition: ping.c:1485
Definition: common.h:34
uint32_t pc_segments
Definition: ping.h:55
struct m0_clink pc_wq_clink
Definition: ping.h:79
void nlx_ping_client(struct nlx_ping_client_params *params)
Definition: ping.c:1837
int pc_verbose
Definition: ping.h:88
uint64_t pc_bulk_size
Definition: ping.h:60
uint64_t nlx_ping_parse_uint64(const char *s)
Definition: ping.c:171
int pc_tm_debug
Definition: ping.h:74
struct m0_chan pc_net_chan
Definition: ping.h:81
uint32_t server_portal
Definition: ping.h:106
struct m0_bitmap pc_nbbm
Definition: ping.h:63
int32_t pc_status
Definition: ping.h:52
int(*) void(* pqs)(struct nlx_ping_ctx *ctx, bool reset)
Definition: ping.h:34
Definition: nucleus.c:42
struct m0_fom_ops ops
Definition: io_foms.c:623
int pc_min_recv_size
Definition: ping.h:58
Definition: mutex.h:47
static struct m0_addb2_source * s
Definition: consumer.c:39
const struct m0_net_xprt * pc_xprt
Definition: ping.h:42
int pc_dom_debug
Definition: ping.h:73
struct m0_mutex pc_mutex
Definition: ping.h:65
uint32_t pc_pid
Definition: ping.h:45
uint32_t pc_seg_size
Definition: ping.h:56
struct m0_list pc_work_queue
Definition: ping.h:67