blob: 682636d3b060bbb3e92af242a9bc38397db53d42 [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001// SPDX-License-Identifier: GPL-2.0-or-later
David Howells17926a72007-04-26 15:48:28 -07002/* /proc/net/ support for AF_RXRPC
3 *
4 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
David Howells17926a72007-04-26 15:48:28 -07006 */
7
8#include <linux/module.h>
9#include <net/sock.h>
10#include <net/af_rxrpc.h>
11#include "ar-internal.h"
12
David Howellsbba304d2016-06-27 10:32:02 +010013static const char *const rxrpc_conn_states[RXRPC_CONN__NR_STATES] = {
14 [RXRPC_CONN_UNUSED] = "Unused ",
David Howells9d35d882022-10-19 09:45:43 +010015 [RXRPC_CONN_CLIENT_UNSECURED] = "ClUnsec ",
David Howellsbba304d2016-06-27 10:32:02 +010016 [RXRPC_CONN_CLIENT] = "Client ",
David Howells00e90712016-09-08 11:10:12 +010017 [RXRPC_CONN_SERVICE_PREALLOC] = "SvPrealc",
David Howellsbba304d2016-06-27 10:32:02 +010018 [RXRPC_CONN_SERVICE_UNSECURED] = "SvUnsec ",
19 [RXRPC_CONN_SERVICE_CHALLENGING] = "SvChall ",
20 [RXRPC_CONN_SERVICE] = "SvSecure",
David Howellsa00ce282022-10-20 09:56:36 +010021 [RXRPC_CONN_ABORTED] = "Aborted ",
David Howells17926a72007-04-26 15:48:28 -070022};
23
David Howells17926a72007-04-26 15:48:28 -070024/*
25 * generate a list of extant and dead calls in /proc/net/rxrpc_calls
26 */
27static void *rxrpc_call_seq_start(struct seq_file *seq, loff_t *_pos)
David Howells88f2a8252018-03-30 21:05:17 +010028 __acquires(rcu)
David Howells17926a72007-04-26 15:48:28 -070029{
David Howells2baec2c2017-05-24 17:02:32 +010030 struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
31
David Howells8d94aa32016-09-07 09:19:31 +010032 rcu_read_lock();
David Howellsad25f5c2022-05-21 08:45:28 +010033 return seq_list_start_head_rcu(&rxnet->calls, *_pos);
David Howells17926a72007-04-26 15:48:28 -070034}
35
36static void *rxrpc_call_seq_next(struct seq_file *seq, void *v, loff_t *pos)
37{
David Howells2baec2c2017-05-24 17:02:32 +010038 struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
39
David Howellsad25f5c2022-05-21 08:45:28 +010040 return seq_list_next_rcu(v, &rxnet->calls, pos);
David Howells17926a72007-04-26 15:48:28 -070041}
42
43static void rxrpc_call_seq_stop(struct seq_file *seq, void *v)
David Howells88f2a8252018-03-30 21:05:17 +010044 __releases(rcu)
David Howells17926a72007-04-26 15:48:28 -070045{
David Howells8d94aa32016-09-07 09:19:31 +010046 rcu_read_unlock();
David Howells17926a72007-04-26 15:48:28 -070047}
48
49static int rxrpc_call_seq_show(struct seq_file *seq, void *v)
50{
David Howellsdf5d8bf2016-08-24 14:31:43 +010051 struct rxrpc_local *local;
David Howells17926a72007-04-26 15:48:28 -070052 struct rxrpc_call *call;
David Howells2baec2c2017-05-24 17:02:32 +010053 struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
David Howells96b40592022-10-27 11:25:55 +010054 enum rxrpc_call_state state;
Wei Yongjun770b26d2018-08-02 09:13:33 +010055 unsigned long timeout = 0;
David Howellsa4ea4c42022-03-31 23:55:08 +010056 rxrpc_seq_t acks_hard_ack;
David Howells75b54cb2016-09-13 08:49:05 +010057 char lbuff[50], rbuff[50];
David Howells17926a72007-04-26 15:48:28 -070058
David Howells2baec2c2017-05-24 17:02:32 +010059 if (v == &rxnet->calls) {
David Howells17926a72007-04-26 15:48:28 -070060 seq_puts(seq,
David Howells75b54cb2016-09-13 08:49:05 +010061 "Proto Local "
62 " Remote "
David Howells17926a72007-04-26 15:48:28 -070063 " SvID ConnID CallID End Use State Abort "
David Howells5086d9a2022-11-11 13:47:35 +000064 " DebugId TxSeq TW RxSeq RW RxSerial CW RxTimo\n");
David Howells17926a72007-04-26 15:48:28 -070065 return 0;
66 }
67
68 call = list_entry(v, struct rxrpc_call, link);
David Howells17926a72007-04-26 15:48:28 -070069
David Howellsf3441d42022-10-20 21:58:36 +010070 local = call->local;
71 if (local)
72 sprintf(lbuff, "%pISpc", &local->srx.transport);
David Howellsf4e7da82016-06-17 11:07:55 +010073 else
David Howellsf3441d42022-10-20 21:58:36 +010074 strcpy(lbuff, "no_local");
75
76 sprintf(rbuff, "%pISpc", &call->dest_srx.transport);
David Howells17926a72007-04-26 15:48:28 -070077
David Howells96b40592022-10-27 11:25:55 +010078 state = rxrpc_call_state(call);
79 if (state != RXRPC_CALL_SERVER_PREALLOC) {
David Howells887763b2018-07-23 17:18:36 +010080 timeout = READ_ONCE(call->expect_rx_by);
David Howells887763b2018-07-23 17:18:36 +010081 timeout -= jiffies;
82 }
83
David Howellsa4ea4c42022-03-31 23:55:08 +010084 acks_hard_ack = READ_ONCE(call->acks_hard_ack);
David Howells17926a72007-04-26 15:48:28 -070085 seq_printf(seq,
David Howells75b54cb2016-09-13 08:49:05 +010086 "UDP %-47.47s %-47.47s %4x %08x %08x %s %3u"
David Howells5086d9a2022-11-11 13:47:35 +000087 " %-8.8s %08x %08x %08x %02x %08x %02x %08x %02x %06lx\n",
David Howells17926a72007-04-26 15:48:28 -070088 lbuff,
89 rbuff,
David Howellsf3441d42022-10-20 21:58:36 +010090 call->dest_srx.srx_service,
David Howells0d12f8a2016-03-04 15:53:46 +000091 call->cid,
92 call->call_id,
David Howellsdabe5a72016-08-23 15:27:24 +010093 rxrpc_is_service_call(call) ? "Svc" : "Clt",
David Howellsa05754292022-05-21 08:45:22 +010094 refcount_read(&call->ref),
David Howells96b40592022-10-27 11:25:55 +010095 rxrpc_call_states[state],
David Howellsf5c17aa2016-08-30 09:49:28 +010096 call->abort_code,
David Howells32f71aa2020-05-02 13:38:23 +010097 call->debug_id,
David Howellsa4ea4c42022-03-31 23:55:08 +010098 acks_hard_ack, READ_ONCE(call->tx_top) - acks_hard_ack,
David Howells5bbf95332022-10-17 11:44:22 +010099 call->ackr_window, call->ackr_wtop - call->ackr_window,
David Howells6b97bd72018-07-23 17:18:36 +0100100 call->rx_serial,
David Howells5086d9a2022-11-11 13:47:35 +0000101 call->cong_cwnd,
David Howells887763b2018-07-23 17:18:36 +0100102 timeout);
David Howells17926a72007-04-26 15:48:28 -0700103
104 return 0;
105}
106
Christoph Hellwigc3506372018-04-10 19:42:55 +0200107const struct seq_operations rxrpc_call_seq_ops = {
David Howells17926a72007-04-26 15:48:28 -0700108 .start = rxrpc_call_seq_start,
109 .next = rxrpc_call_seq_next,
110 .stop = rxrpc_call_seq_stop,
111 .show = rxrpc_call_seq_show,
112};
113
David Howells17926a72007-04-26 15:48:28 -0700114/*
115 * generate a list of extant virtual connections in /proc/net/rxrpc_conns
116 */
117static void *rxrpc_connection_seq_start(struct seq_file *seq, loff_t *_pos)
David Howells88f2a8252018-03-30 21:05:17 +0100118 __acquires(rxnet->conn_lock)
David Howells17926a72007-04-26 15:48:28 -0700119{
David Howells2baec2c2017-05-24 17:02:32 +0100120 struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
121
122 read_lock(&rxnet->conn_lock);
123 return seq_list_start_head(&rxnet->conn_proc_list, *_pos);
David Howells17926a72007-04-26 15:48:28 -0700124}
125
126static void *rxrpc_connection_seq_next(struct seq_file *seq, void *v,
127 loff_t *pos)
128{
David Howells2baec2c2017-05-24 17:02:32 +0100129 struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
130
131 return seq_list_next(v, &rxnet->conn_proc_list, pos);
David Howells17926a72007-04-26 15:48:28 -0700132}
133
134static void rxrpc_connection_seq_stop(struct seq_file *seq, void *v)
David Howells88f2a8252018-03-30 21:05:17 +0100135 __releases(rxnet->conn_lock)
David Howells17926a72007-04-26 15:48:28 -0700136{
David Howells2baec2c2017-05-24 17:02:32 +0100137 struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
138
139 read_unlock(&rxnet->conn_lock);
David Howells17926a72007-04-26 15:48:28 -0700140}
141
142static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
143{
144 struct rxrpc_connection *conn;
David Howells2baec2c2017-05-24 17:02:32 +0100145 struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
David Howellsa00ce282022-10-20 09:56:36 +0100146 const char *state;
David Howells75b54cb2016-09-13 08:49:05 +0100147 char lbuff[50], rbuff[50];
David Howells17926a72007-04-26 15:48:28 -0700148
David Howells2baec2c2017-05-24 17:02:32 +0100149 if (v == &rxnet->conn_proc_list) {
David Howells17926a72007-04-26 15:48:28 -0700150 seq_puts(seq,
David Howells75b54cb2016-09-13 08:49:05 +0100151 "Proto Local "
152 " Remote "
David Howells3cec0552022-11-25 12:43:50 +0000153 " SvID ConnID End Ref Act State Key "
David Howells245500d2020-07-01 11:15:32 +0100154 " Serial ISerial CallId0 CallId1 CallId2 CallId3\n"
David Howells17926a72007-04-26 15:48:28 -0700155 );
156 return 0;
157 }
158
David Howells4d028b22016-08-24 07:30:52 +0100159 conn = list_entry(v, struct rxrpc_connection, proc_link);
David Howells00e90712016-09-08 11:10:12 +0100160 if (conn->state == RXRPC_CONN_SERVICE_PREALLOC) {
161 strcpy(lbuff, "no_local");
162 strcpy(rbuff, "no_connection");
163 goto print;
164 }
David Howells17926a72007-04-26 15:48:28 -0700165
David Howells2cc80082022-10-19 13:49:02 +0100166 sprintf(lbuff, "%pISpc", &conn->local->srx.transport);
David Howells2cc80082022-10-19 13:49:02 +0100167 sprintf(rbuff, "%pISpc", &conn->peer->srx.transport);
David Howells00e90712016-09-08 11:10:12 +0100168print:
David Howellsa00ce282022-10-20 09:56:36 +0100169 state = rxrpc_is_conn_aborted(conn) ?
170 rxrpc_call_completions[conn->completion] :
171 rxrpc_conn_states[conn->state];
David Howells17926a72007-04-26 15:48:28 -0700172 seq_printf(seq,
David Howells3cec0552022-11-25 12:43:50 +0000173 "UDP %-47.47s %-47.47s %4x %08x %s %3u %3d"
David Howells6b97bd72018-07-23 17:18:36 +0100174 " %s %08x %08x %08x %08x %08x %08x %08x\n",
David Howells17926a72007-04-26 15:48:28 -0700175 lbuff,
176 rbuff,
David Howells68d6d1a2017-06-05 14:30:49 +0100177 conn->service_id,
David Howells19ffa012016-04-04 14:00:36 +0100178 conn->proto.cid,
David Howells19ffa012016-04-04 14:00:36 +0100179 rxrpc_conn_is_service(conn) ? "Svc" : "Clt",
David Howellsa05754292022-05-21 08:45:22 +0100180 refcount_read(&conn->ref),
David Howells3cec0552022-11-25 12:43:50 +0000181 atomic_read(&conn->active),
David Howellsa00ce282022-10-20 09:56:36 +0100182 state,
David Howells2cc80082022-10-19 13:49:02 +0100183 key_serial(conn->key),
David Howells17926a72007-04-26 15:48:28 -0700184 atomic_read(&conn->serial),
David Howells6b97bd72018-07-23 17:18:36 +0100185 conn->hi_serial,
186 conn->channels[0].call_id,
187 conn->channels[1].call_id,
188 conn->channels[2].call_id,
189 conn->channels[3].call_id);
David Howells17926a72007-04-26 15:48:28 -0700190
191 return 0;
192}
193
Christoph Hellwigc3506372018-04-10 19:42:55 +0200194const struct seq_operations rxrpc_connection_seq_ops = {
David Howells17926a72007-04-26 15:48:28 -0700195 .start = rxrpc_connection_seq_start,
196 .next = rxrpc_connection_seq_next,
197 .stop = rxrpc_connection_seq_stop,
198 .show = rxrpc_connection_seq_show,
199};
David Howellsbc0e7cf2018-10-15 11:31:03 +0100200
201/*
202 * generate a list of extant virtual peers in /proc/net/rxrpc/peers
203 */
204static int rxrpc_peer_seq_show(struct seq_file *seq, void *v)
205{
206 struct rxrpc_peer *peer;
207 time64_t now;
208 char lbuff[50], rbuff[50];
209
210 if (v == SEQ_START_TOKEN) {
211 seq_puts(seq,
212 "Proto Local "
213 " Remote "
David Howells1fc4fa22022-10-03 18:49:11 +0100214 " Use SST MTU LastUse RTT RTO\n"
David Howellsbc0e7cf2018-10-15 11:31:03 +0100215 );
216 return 0;
217 }
218
219 peer = list_entry(v, struct rxrpc_peer, hash_link);
220
221 sprintf(lbuff, "%pISpc", &peer->local->srx.transport);
222
223 sprintf(rbuff, "%pISpc", &peer->srx.transport);
224
225 now = ktime_get_seconds();
226 seq_printf(seq,
227 "UDP %-47.47s %-47.47s %3u"
David Howellsc410bf012020-05-11 14:54:34 +0100228 " %3u %5u %6llus %8u %8u\n",
David Howellsbc0e7cf2018-10-15 11:31:03 +0100229 lbuff,
230 rbuff,
David Howellsa05754292022-05-21 08:45:22 +0100231 refcount_read(&peer->ref),
David Howells1fc4fa22022-10-03 18:49:11 +0100232 peer->cong_ssthresh,
David Howellsbc0e7cf2018-10-15 11:31:03 +0100233 peer->mtu,
234 now - peer->last_tx_at,
David Howellsc410bf012020-05-11 14:54:34 +0100235 peer->srtt_us >> 3,
236 jiffies_to_usecs(peer->rto_j));
David Howellsbc0e7cf2018-10-15 11:31:03 +0100237
238 return 0;
239}
240
241static void *rxrpc_peer_seq_start(struct seq_file *seq, loff_t *_pos)
242 __acquires(rcu)
243{
244 struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
245 unsigned int bucket, n;
246 unsigned int shift = 32 - HASH_BITS(rxnet->peer_hash);
247 void *p;
248
249 rcu_read_lock();
250
251 if (*_pos >= UINT_MAX)
252 return NULL;
253
254 n = *_pos & ((1U << shift) - 1);
255 bucket = *_pos >> shift;
256 for (;;) {
257 if (bucket >= HASH_SIZE(rxnet->peer_hash)) {
258 *_pos = UINT_MAX;
259 return NULL;
260 }
261 if (n == 0) {
262 if (bucket == 0)
263 return SEQ_START_TOKEN;
264 *_pos += 1;
265 n++;
266 }
267
268 p = seq_hlist_start_rcu(&rxnet->peer_hash[bucket], n - 1);
269 if (p)
270 return p;
271 bucket++;
272 n = 1;
273 *_pos = (bucket << shift) | n;
274 }
275}
276
277static void *rxrpc_peer_seq_next(struct seq_file *seq, void *v, loff_t *_pos)
278{
279 struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
280 unsigned int bucket, n;
281 unsigned int shift = 32 - HASH_BITS(rxnet->peer_hash);
282 void *p;
283
284 if (*_pos >= UINT_MAX)
285 return NULL;
286
287 bucket = *_pos >> shift;
288
289 p = seq_hlist_next_rcu(v, &rxnet->peer_hash[bucket], _pos);
290 if (p)
291 return p;
292
293 for (;;) {
294 bucket++;
295 n = 1;
296 *_pos = (bucket << shift) | n;
297
298 if (bucket >= HASH_SIZE(rxnet->peer_hash)) {
299 *_pos = UINT_MAX;
300 return NULL;
301 }
302 if (n == 0) {
303 *_pos += 1;
304 n++;
305 }
306
307 p = seq_hlist_start_rcu(&rxnet->peer_hash[bucket], n - 1);
308 if (p)
309 return p;
310 }
311}
312
313static void rxrpc_peer_seq_stop(struct seq_file *seq, void *v)
314 __releases(rcu)
315{
316 rcu_read_unlock();
317}
318
319
320const struct seq_operations rxrpc_peer_seq_ops = {
321 .start = rxrpc_peer_seq_start,
322 .next = rxrpc_peer_seq_next,
323 .stop = rxrpc_peer_seq_stop,
324 .show = rxrpc_peer_seq_show,
325};
David Howells33912c22022-05-21 08:45:15 +0100326
327/*
328 * Generate a list of extant virtual local endpoints in /proc/net/rxrpc/locals
329 */
330static int rxrpc_local_seq_show(struct seq_file *seq, void *v)
331{
332 struct rxrpc_local *local;
333 char lbuff[50];
334
335 if (v == SEQ_START_TOKEN) {
336 seq_puts(seq,
337 "Proto Local "
David Howellsa275da62022-10-10 08:45:20 +0100338 " Use Act RxQ\n");
David Howells33912c22022-05-21 08:45:15 +0100339 return 0;
340 }
341
342 local = hlist_entry(v, struct rxrpc_local, link);
343
344 sprintf(lbuff, "%pISpc", &local->srx.transport);
345
346 seq_printf(seq,
David Howellsa275da62022-10-10 08:45:20 +0100347 "UDP %-47.47s %3u %3u %3u\n",
David Howells33912c22022-05-21 08:45:15 +0100348 lbuff,
David Howellsa05754292022-05-21 08:45:22 +0100349 refcount_read(&local->ref),
David Howellsa275da62022-10-10 08:45:20 +0100350 atomic_read(&local->active_users),
351 local->rx_queue.qlen);
David Howells33912c22022-05-21 08:45:15 +0100352
353 return 0;
354}
355
356static void *rxrpc_local_seq_start(struct seq_file *seq, loff_t *_pos)
357 __acquires(rcu)
358{
359 struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
360 unsigned int n;
361
362 rcu_read_lock();
363
364 if (*_pos >= UINT_MAX)
365 return NULL;
366
367 n = *_pos;
368 if (n == 0)
369 return SEQ_START_TOKEN;
370
371 return seq_hlist_start_rcu(&rxnet->local_endpoints, n - 1);
372}
373
374static void *rxrpc_local_seq_next(struct seq_file *seq, void *v, loff_t *_pos)
375{
376 struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
377
378 if (*_pos >= UINT_MAX)
379 return NULL;
380
381 return seq_hlist_next_rcu(v, &rxnet->local_endpoints, _pos);
382}
383
384static void rxrpc_local_seq_stop(struct seq_file *seq, void *v)
385 __releases(rcu)
386{
387 rcu_read_unlock();
388}
389
390const struct seq_operations rxrpc_local_seq_ops = {
391 .start = rxrpc_local_seq_start,
392 .next = rxrpc_local_seq_next,
393 .stop = rxrpc_local_seq_stop,
394 .show = rxrpc_local_seq_show,
395};
David Howellsb0154242022-05-11 14:01:25 +0100396
397/*
398 * Display stats in /proc/net/rxrpc/stats
399 */
400int rxrpc_stats_show(struct seq_file *seq, void *v)
401{
402 struct rxrpc_net *rxnet = rxrpc_net(seq_file_single_net(seq));
403
404 seq_printf(seq,
David Howells32cf8ed2022-11-11 13:47:35 +0000405 "Data : send=%u sendf=%u fail=%u\n",
David Howellsb0154242022-05-11 14:01:25 +0100406 atomic_read(&rxnet->stat_tx_data_send),
David Howells32cf8ed2022-11-11 13:47:35 +0000407 atomic_read(&rxnet->stat_tx_data_send_frag),
408 atomic_read(&rxnet->stat_tx_data_send_fail));
David Howellsb0154242022-05-11 14:01:25 +0100409 seq_printf(seq,
David Howells32cf8ed2022-11-11 13:47:35 +0000410 "Data-Tx : nr=%u retrans=%u uf=%u cwr=%u\n",
David Howellsb0154242022-05-11 14:01:25 +0100411 atomic_read(&rxnet->stat_tx_data),
David Howells32cf8ed2022-11-11 13:47:35 +0000412 atomic_read(&rxnet->stat_tx_data_retrans),
413 atomic_read(&rxnet->stat_tx_data_underflow),
414 atomic_read(&rxnet->stat_tx_data_cwnd_reset));
David Howellsb0154242022-05-11 14:01:25 +0100415 seq_printf(seq,
416 "Data-Rx : nr=%u reqack=%u jumbo=%u\n",
417 atomic_read(&rxnet->stat_rx_data),
418 atomic_read(&rxnet->stat_rx_data_reqack),
419 atomic_read(&rxnet->stat_rx_data_jumbo));
420 seq_printf(seq,
David Howellsf2a676d2022-05-11 14:01:25 +0100421 "Ack : fill=%u send=%u skip=%u\n",
422 atomic_read(&rxnet->stat_tx_ack_fill),
423 atomic_read(&rxnet->stat_tx_ack_send),
424 atomic_read(&rxnet->stat_tx_ack_skip));
425 seq_printf(seq,
426 "Ack-Tx : req=%u dup=%u oos=%u exw=%u nos=%u png=%u prs=%u dly=%u idl=%u\n",
427 atomic_read(&rxnet->stat_tx_acks[RXRPC_ACK_REQUESTED]),
428 atomic_read(&rxnet->stat_tx_acks[RXRPC_ACK_DUPLICATE]),
429 atomic_read(&rxnet->stat_tx_acks[RXRPC_ACK_OUT_OF_SEQUENCE]),
430 atomic_read(&rxnet->stat_tx_acks[RXRPC_ACK_EXCEEDS_WINDOW]),
431 atomic_read(&rxnet->stat_tx_acks[RXRPC_ACK_NOSPACE]),
432 atomic_read(&rxnet->stat_tx_acks[RXRPC_ACK_PING]),
433 atomic_read(&rxnet->stat_tx_acks[RXRPC_ACK_PING_RESPONSE]),
434 atomic_read(&rxnet->stat_tx_acks[RXRPC_ACK_DELAY]),
435 atomic_read(&rxnet->stat_tx_acks[RXRPC_ACK_IDLE]));
436 seq_printf(seq,
437 "Ack-Rx : req=%u dup=%u oos=%u exw=%u nos=%u png=%u prs=%u dly=%u idl=%u\n",
438 atomic_read(&rxnet->stat_rx_acks[RXRPC_ACK_REQUESTED]),
439 atomic_read(&rxnet->stat_rx_acks[RXRPC_ACK_DUPLICATE]),
440 atomic_read(&rxnet->stat_rx_acks[RXRPC_ACK_OUT_OF_SEQUENCE]),
441 atomic_read(&rxnet->stat_rx_acks[RXRPC_ACK_EXCEEDS_WINDOW]),
442 atomic_read(&rxnet->stat_rx_acks[RXRPC_ACK_NOSPACE]),
443 atomic_read(&rxnet->stat_rx_acks[RXRPC_ACK_PING]),
444 atomic_read(&rxnet->stat_rx_acks[RXRPC_ACK_PING_RESPONSE]),
445 atomic_read(&rxnet->stat_rx_acks[RXRPC_ACK_DELAY]),
446 atomic_read(&rxnet->stat_rx_acks[RXRPC_ACK_IDLE]));
447 seq_printf(seq,
David Howellsf7fa5242022-08-18 11:52:36 +0100448 "Why-Req-A: acklost=%u already=%u mrtt=%u ortt=%u\n",
449 atomic_read(&rxnet->stat_why_req_ack[rxrpc_reqack_ack_lost]),
450 atomic_read(&rxnet->stat_why_req_ack[rxrpc_reqack_already_on]),
451 atomic_read(&rxnet->stat_why_req_ack[rxrpc_reqack_more_rtt]),
452 atomic_read(&rxnet->stat_why_req_ack[rxrpc_reqack_old_rtt]));
453 seq_printf(seq,
454 "Why-Req-A: nolast=%u retx=%u slows=%u smtxw=%u\n",
455 atomic_read(&rxnet->stat_why_req_ack[rxrpc_reqack_no_srv_last]),
456 atomic_read(&rxnet->stat_why_req_ack[rxrpc_reqack_retrans]),
457 atomic_read(&rxnet->stat_why_req_ack[rxrpc_reqack_slow_start]),
458 atomic_read(&rxnet->stat_why_req_ack[rxrpc_reqack_small_txwin]));
459 seq_printf(seq,
David Howellsa4ea4c42022-03-31 23:55:08 +0100460 "Buffers : txb=%u rxb=%u\n",
David Howells02a19352022-04-05 21:16:32 +0100461 atomic_read(&rxrpc_nr_txbuf),
David Howellsb0154242022-05-11 14:01:25 +0100462 atomic_read(&rxrpc_n_rx_skbs));
David Howellsa275da62022-10-10 08:45:20 +0100463 seq_printf(seq,
464 "IO-thread: loops=%u\n",
465 atomic_read(&rxnet->stat_io_loop));
David Howellsb0154242022-05-11 14:01:25 +0100466 return 0;
467}
468
469/*
470 * Clear stats if /proc/net/rxrpc/stats is written to.
471 */
472int rxrpc_stats_clear(struct file *file, char *buf, size_t size)
473{
474 struct seq_file *m = file->private_data;
475 struct rxrpc_net *rxnet = rxrpc_net(seq_file_single_net(m));
476
477 if (size > 1 || (size == 1 && buf[0] != '\n'))
478 return -EINVAL;
479
480 atomic_set(&rxnet->stat_tx_data, 0);
481 atomic_set(&rxnet->stat_tx_data_retrans, 0);
David Howells32cf8ed2022-11-11 13:47:35 +0000482 atomic_set(&rxnet->stat_tx_data_underflow, 0);
483 atomic_set(&rxnet->stat_tx_data_cwnd_reset, 0);
David Howellsb0154242022-05-11 14:01:25 +0100484 atomic_set(&rxnet->stat_tx_data_send, 0);
485 atomic_set(&rxnet->stat_tx_data_send_frag, 0);
David Howells32cf8ed2022-11-11 13:47:35 +0000486 atomic_set(&rxnet->stat_tx_data_send_fail, 0);
David Howellsb0154242022-05-11 14:01:25 +0100487 atomic_set(&rxnet->stat_rx_data, 0);
488 atomic_set(&rxnet->stat_rx_data_reqack, 0);
489 atomic_set(&rxnet->stat_rx_data_jumbo, 0);
David Howellsf2a676d2022-05-11 14:01:25 +0100490
491 atomic_set(&rxnet->stat_tx_ack_fill, 0);
492 atomic_set(&rxnet->stat_tx_ack_send, 0);
493 atomic_set(&rxnet->stat_tx_ack_skip, 0);
494 memset(&rxnet->stat_tx_acks, 0, sizeof(rxnet->stat_tx_acks));
495 memset(&rxnet->stat_rx_acks, 0, sizeof(rxnet->stat_rx_acks));
David Howellsf7fa5242022-08-18 11:52:36 +0100496
497 memset(&rxnet->stat_why_req_ack, 0, sizeof(rxnet->stat_why_req_ack));
David Howellsa275da62022-10-10 08:45:20 +0100498
499 atomic_set(&rxnet->stat_io_loop, 0);
David Howellsb0154242022-05-11 14:01:25 +0100500 return size;
501}