12874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later 28c3e34a4SDavid Howells /* /proc/net/ support for AF_RXRPC 38c3e34a4SDavid Howells * 48c3e34a4SDavid Howells * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. 58c3e34a4SDavid Howells * Written by David Howells (dhowells@redhat.com) 68c3e34a4SDavid Howells */ 78c3e34a4SDavid Howells 88c3e34a4SDavid Howells #include <linux/module.h> 98c3e34a4SDavid Howells #include <net/sock.h> 108c3e34a4SDavid Howells #include <net/af_rxrpc.h> 118c3e34a4SDavid Howells #include "ar-internal.h" 128c3e34a4SDavid Howells 13bba304dbSDavid Howells static const char *const rxrpc_conn_states[RXRPC_CONN__NR_STATES] = { 148c3e34a4SDavid Howells [RXRPC_CONN_UNUSED] = "Unused ", 158c3e34a4SDavid Howells [RXRPC_CONN_CLIENT] = "Client ", 1600e90712SDavid Howells [RXRPC_CONN_SERVICE_PREALLOC] = "SvPrealc", 17bba304dbSDavid Howells [RXRPC_CONN_SERVICE_UNSECURED] = "SvUnsec ", 18bba304dbSDavid Howells [RXRPC_CONN_SERVICE_CHALLENGING] = "SvChall ", 19bba304dbSDavid Howells [RXRPC_CONN_SERVICE] = "SvSecure", 208c3e34a4SDavid Howells [RXRPC_CONN_REMOTELY_ABORTED] = "RmtAbort", 218c3e34a4SDavid Howells [RXRPC_CONN_LOCALLY_ABORTED] = "LocAbort", 228c3e34a4SDavid Howells }; 238c3e34a4SDavid Howells 248c3e34a4SDavid Howells /* 258c3e34a4SDavid Howells * generate a list of extant and dead calls in /proc/net/rxrpc_calls 268c3e34a4SDavid Howells */ 278c3e34a4SDavid Howells static void *rxrpc_call_seq_start(struct seq_file *seq, loff_t *_pos) 2888f2a825SDavid Howells __acquires(rcu) 298c3e34a4SDavid Howells { 302baec2c3SDavid Howells struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq)); 312baec2c3SDavid Howells 328d94aa38SDavid Howells rcu_read_lock(); 33ad25f5cbSDavid Howells return seq_list_start_head_rcu(&rxnet->calls, *_pos); 348c3e34a4SDavid Howells } 358c3e34a4SDavid Howells 368c3e34a4SDavid Howells static void *rxrpc_call_seq_next(struct seq_file *seq, void *v, loff_t *pos) 378c3e34a4SDavid Howells { 382baec2c3SDavid Howells struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq)); 392baec2c3SDavid Howells 40ad25f5cbSDavid Howells return seq_list_next_rcu(v, &rxnet->calls, pos); 418c3e34a4SDavid Howells } 428c3e34a4SDavid Howells 438c3e34a4SDavid Howells static void rxrpc_call_seq_stop(struct seq_file *seq, void *v) 4488f2a825SDavid Howells __releases(rcu) 458c3e34a4SDavid Howells { 468d94aa38SDavid Howells rcu_read_unlock(); 478c3e34a4SDavid Howells } 488c3e34a4SDavid Howells 498c3e34a4SDavid Howells static int rxrpc_call_seq_show(struct seq_file *seq, void *v) 508c3e34a4SDavid Howells { 51df5d8bf7SDavid Howells struct rxrpc_local *local; 52df5d8bf7SDavid Howells struct rxrpc_sock *rx; 53df5d8bf7SDavid Howells struct rxrpc_peer *peer; 548c3e34a4SDavid Howells struct rxrpc_call *call; 552baec2c3SDavid Howells struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq)); 56770b26deSWei Yongjun unsigned long timeout = 0; 57a4ea4c47SDavid Howells rxrpc_seq_t acks_hard_ack; 5875b54cb5SDavid Howells char lbuff[50], rbuff[50]; 595d7edbc9SDavid Howells u64 wtmp; 608c3e34a4SDavid Howells 612baec2c3SDavid Howells if (v == &rxnet->calls) { 628c3e34a4SDavid Howells seq_puts(seq, 6375b54cb5SDavid Howells "Proto Local " 6475b54cb5SDavid Howells " Remote " 658c3e34a4SDavid Howells " SvID ConnID CallID End Use State Abort " 6632f71aa4SDavid Howells " DebugId TxSeq TW RxSeq RW RxSerial RxTimo\n"); 678c3e34a4SDavid Howells return 0; 688c3e34a4SDavid Howells } 698c3e34a4SDavid Howells 708c3e34a4SDavid Howells call = list_entry(v, struct rxrpc_call, link); 718c3e34a4SDavid Howells 728d94aa38SDavid Howells rx = rcu_dereference(call->socket); 73df5d8bf7SDavid Howells if (rx) { 74df5d8bf7SDavid Howells local = READ_ONCE(rx->local); 75df5d8bf7SDavid Howells if (local) 7675b54cb5SDavid Howells sprintf(lbuff, "%pISpc", &local->srx.transport); 77df5d8bf7SDavid Howells else 78df5d8bf7SDavid Howells strcpy(lbuff, "no_local"); 79df5d8bf7SDavid Howells } else { 80df5d8bf7SDavid Howells strcpy(lbuff, "no_socket"); 81df5d8bf7SDavid Howells } 828c3e34a4SDavid Howells 83df5d8bf7SDavid Howells peer = call->peer; 84df5d8bf7SDavid Howells if (peer) 8575b54cb5SDavid Howells sprintf(rbuff, "%pISpc", &peer->srx.transport); 86f4e7da8cSDavid Howells else 87f4e7da8cSDavid Howells strcpy(rbuff, "no_connection"); 888c3e34a4SDavid Howells 89887763bbSDavid Howells if (call->state != RXRPC_CALL_SERVER_PREALLOC) { 90887763bbSDavid Howells timeout = READ_ONCE(call->expect_rx_by); 91887763bbSDavid Howells timeout -= jiffies; 92887763bbSDavid Howells } 93887763bbSDavid Howells 94a4ea4c47SDavid Howells acks_hard_ack = READ_ONCE(call->acks_hard_ack); 955d7edbc9SDavid Howells wtmp = atomic64_read_acquire(&call->ackr_window); 968c3e34a4SDavid Howells seq_printf(seq, 9775b54cb5SDavid Howells "UDP %-47.47s %-47.47s %4x %08x %08x %s %3u" 9832f71aa4SDavid Howells " %-8.8s %08x %08x %08x %02x %08x %02x %08x %06lx\n", 998c3e34a4SDavid Howells lbuff, 1008c3e34a4SDavid Howells rbuff, 101f4e7da8cSDavid Howells call->service_id, 1028c3e34a4SDavid Howells call->cid, 1038c3e34a4SDavid Howells call->call_id, 104dabe5a79SDavid Howells rxrpc_is_service_call(call) ? "Svc" : "Clt", 105a0575429SDavid Howells refcount_read(&call->ref), 1068c3e34a4SDavid Howells rxrpc_call_states[call->state], 107f5c17aaeSDavid Howells call->abort_code, 10832f71aa4SDavid Howells call->debug_id, 109a4ea4c47SDavid Howells acks_hard_ack, READ_ONCE(call->tx_top) - acks_hard_ack, 1105d7edbc9SDavid Howells lower_32_bits(wtmp), upper_32_bits(wtmp) - lower_32_bits(wtmp), 1116b97bd7aSDavid Howells call->rx_serial, 112887763bbSDavid Howells timeout); 1138c3e34a4SDavid Howells 1148c3e34a4SDavid Howells return 0; 1158c3e34a4SDavid Howells } 1168c3e34a4SDavid Howells 117c3506372SChristoph Hellwig const struct seq_operations rxrpc_call_seq_ops = { 1188c3e34a4SDavid Howells .start = rxrpc_call_seq_start, 1198c3e34a4SDavid Howells .next = rxrpc_call_seq_next, 1208c3e34a4SDavid Howells .stop = rxrpc_call_seq_stop, 1218c3e34a4SDavid Howells .show = rxrpc_call_seq_show, 1228c3e34a4SDavid Howells }; 1238c3e34a4SDavid Howells 1248c3e34a4SDavid Howells /* 1258c3e34a4SDavid Howells * generate a list of extant virtual connections in /proc/net/rxrpc_conns 1268c3e34a4SDavid Howells */ 1278c3e34a4SDavid Howells static void *rxrpc_connection_seq_start(struct seq_file *seq, loff_t *_pos) 12888f2a825SDavid Howells __acquires(rxnet->conn_lock) 1298c3e34a4SDavid Howells { 1302baec2c3SDavid Howells struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq)); 1312baec2c3SDavid Howells 1322baec2c3SDavid Howells read_lock(&rxnet->conn_lock); 1332baec2c3SDavid Howells return seq_list_start_head(&rxnet->conn_proc_list, *_pos); 1348c3e34a4SDavid Howells } 1358c3e34a4SDavid Howells 1368c3e34a4SDavid Howells static void *rxrpc_connection_seq_next(struct seq_file *seq, void *v, 1378c3e34a4SDavid Howells loff_t *pos) 1388c3e34a4SDavid Howells { 1392baec2c3SDavid Howells struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq)); 1402baec2c3SDavid Howells 1412baec2c3SDavid Howells return seq_list_next(v, &rxnet->conn_proc_list, pos); 1428c3e34a4SDavid Howells } 1438c3e34a4SDavid Howells 1448c3e34a4SDavid Howells static void rxrpc_connection_seq_stop(struct seq_file *seq, void *v) 14588f2a825SDavid Howells __releases(rxnet->conn_lock) 1468c3e34a4SDavid Howells { 1472baec2c3SDavid Howells struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq)); 1482baec2c3SDavid Howells 1492baec2c3SDavid Howells read_unlock(&rxnet->conn_lock); 1508c3e34a4SDavid Howells } 1518c3e34a4SDavid Howells 1528c3e34a4SDavid Howells static int rxrpc_connection_seq_show(struct seq_file *seq, void *v) 1538c3e34a4SDavid Howells { 1548c3e34a4SDavid Howells struct rxrpc_connection *conn; 1552baec2c3SDavid Howells struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq)); 15675b54cb5SDavid Howells char lbuff[50], rbuff[50]; 1578c3e34a4SDavid Howells 1582baec2c3SDavid Howells if (v == &rxnet->conn_proc_list) { 1598c3e34a4SDavid Howells seq_puts(seq, 16075b54cb5SDavid Howells "Proto Local " 16175b54cb5SDavid Howells " Remote " 162a1399f8bSDavid Howells " SvID ConnID End Use State Key " 163245500d8SDavid Howells " Serial ISerial CallId0 CallId1 CallId2 CallId3\n" 1648c3e34a4SDavid Howells ); 1658c3e34a4SDavid Howells return 0; 1668c3e34a4SDavid Howells } 1678c3e34a4SDavid Howells 1684d028b2cSDavid Howells conn = list_entry(v, struct rxrpc_connection, proc_link); 16900e90712SDavid Howells if (conn->state == RXRPC_CONN_SERVICE_PREALLOC) { 17000e90712SDavid Howells strcpy(lbuff, "no_local"); 17100e90712SDavid Howells strcpy(rbuff, "no_connection"); 17200e90712SDavid Howells goto print; 17300e90712SDavid Howells } 1748c3e34a4SDavid Howells 175*2cc80086SDavid Howells sprintf(lbuff, "%pISpc", &conn->local->srx.transport); 1768c3e34a4SDavid Howells 177*2cc80086SDavid Howells sprintf(rbuff, "%pISpc", &conn->peer->srx.transport); 17800e90712SDavid Howells print: 1798c3e34a4SDavid Howells seq_printf(seq, 18075b54cb5SDavid Howells "UDP %-47.47s %-47.47s %4x %08x %s %3u" 1816b97bd7aSDavid Howells " %s %08x %08x %08x %08x %08x %08x %08x\n", 1828c3e34a4SDavid Howells lbuff, 1838c3e34a4SDavid Howells rbuff, 18468d6d1aeSDavid Howells conn->service_id, 18519ffa01cSDavid Howells conn->proto.cid, 18619ffa01cSDavid Howells rxrpc_conn_is_service(conn) ? "Svc" : "Clt", 187a0575429SDavid Howells refcount_read(&conn->ref), 1888c3e34a4SDavid Howells rxrpc_conn_states[conn->state], 189*2cc80086SDavid Howells key_serial(conn->key), 1908c3e34a4SDavid Howells atomic_read(&conn->serial), 1916b97bd7aSDavid Howells conn->hi_serial, 1926b97bd7aSDavid Howells conn->channels[0].call_id, 1936b97bd7aSDavid Howells conn->channels[1].call_id, 1946b97bd7aSDavid Howells conn->channels[2].call_id, 1956b97bd7aSDavid Howells conn->channels[3].call_id); 1968c3e34a4SDavid Howells 1978c3e34a4SDavid Howells return 0; 1988c3e34a4SDavid Howells } 1998c3e34a4SDavid Howells 200c3506372SChristoph Hellwig const struct seq_operations rxrpc_connection_seq_ops = { 2018c3e34a4SDavid Howells .start = rxrpc_connection_seq_start, 2028c3e34a4SDavid Howells .next = rxrpc_connection_seq_next, 2038c3e34a4SDavid Howells .stop = rxrpc_connection_seq_stop, 2048c3e34a4SDavid Howells .show = rxrpc_connection_seq_show, 2058c3e34a4SDavid Howells }; 206bc0e7cf4SDavid Howells 207bc0e7cf4SDavid Howells /* 208bc0e7cf4SDavid Howells * generate a list of extant virtual peers in /proc/net/rxrpc/peers 209bc0e7cf4SDavid Howells */ 210bc0e7cf4SDavid Howells static int rxrpc_peer_seq_show(struct seq_file *seq, void *v) 211bc0e7cf4SDavid Howells { 212bc0e7cf4SDavid Howells struct rxrpc_peer *peer; 213bc0e7cf4SDavid Howells time64_t now; 214bc0e7cf4SDavid Howells char lbuff[50], rbuff[50]; 215bc0e7cf4SDavid Howells 216bc0e7cf4SDavid Howells if (v == SEQ_START_TOKEN) { 217bc0e7cf4SDavid Howells seq_puts(seq, 218bc0e7cf4SDavid Howells "Proto Local " 219bc0e7cf4SDavid Howells " Remote " 2201fc4fa2aSDavid Howells " Use SST MTU LastUse RTT RTO\n" 221bc0e7cf4SDavid Howells ); 222bc0e7cf4SDavid Howells return 0; 223bc0e7cf4SDavid Howells } 224bc0e7cf4SDavid Howells 225bc0e7cf4SDavid Howells peer = list_entry(v, struct rxrpc_peer, hash_link); 226bc0e7cf4SDavid Howells 227bc0e7cf4SDavid Howells sprintf(lbuff, "%pISpc", &peer->local->srx.transport); 228bc0e7cf4SDavid Howells 229bc0e7cf4SDavid Howells sprintf(rbuff, "%pISpc", &peer->srx.transport); 230bc0e7cf4SDavid Howells 231bc0e7cf4SDavid Howells now = ktime_get_seconds(); 232bc0e7cf4SDavid Howells seq_printf(seq, 233bc0e7cf4SDavid Howells "UDP %-47.47s %-47.47s %3u" 234c410bf01SDavid Howells " %3u %5u %6llus %8u %8u\n", 235bc0e7cf4SDavid Howells lbuff, 236bc0e7cf4SDavid Howells rbuff, 237a0575429SDavid Howells refcount_read(&peer->ref), 2381fc4fa2aSDavid Howells peer->cong_ssthresh, 239bc0e7cf4SDavid Howells peer->mtu, 240bc0e7cf4SDavid Howells now - peer->last_tx_at, 241c410bf01SDavid Howells peer->srtt_us >> 3, 242c410bf01SDavid Howells jiffies_to_usecs(peer->rto_j)); 243bc0e7cf4SDavid Howells 244bc0e7cf4SDavid Howells return 0; 245bc0e7cf4SDavid Howells } 246bc0e7cf4SDavid Howells 247bc0e7cf4SDavid Howells static void *rxrpc_peer_seq_start(struct seq_file *seq, loff_t *_pos) 248bc0e7cf4SDavid Howells __acquires(rcu) 249bc0e7cf4SDavid Howells { 250bc0e7cf4SDavid Howells struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq)); 251bc0e7cf4SDavid Howells unsigned int bucket, n; 252bc0e7cf4SDavid Howells unsigned int shift = 32 - HASH_BITS(rxnet->peer_hash); 253bc0e7cf4SDavid Howells void *p; 254bc0e7cf4SDavid Howells 255bc0e7cf4SDavid Howells rcu_read_lock(); 256bc0e7cf4SDavid Howells 257bc0e7cf4SDavid Howells if (*_pos >= UINT_MAX) 258bc0e7cf4SDavid Howells return NULL; 259bc0e7cf4SDavid Howells 260bc0e7cf4SDavid Howells n = *_pos & ((1U << shift) - 1); 261bc0e7cf4SDavid Howells bucket = *_pos >> shift; 262bc0e7cf4SDavid Howells for (;;) { 263bc0e7cf4SDavid Howells if (bucket >= HASH_SIZE(rxnet->peer_hash)) { 264bc0e7cf4SDavid Howells *_pos = UINT_MAX; 265bc0e7cf4SDavid Howells return NULL; 266bc0e7cf4SDavid Howells } 267bc0e7cf4SDavid Howells if (n == 0) { 268bc0e7cf4SDavid Howells if (bucket == 0) 269bc0e7cf4SDavid Howells return SEQ_START_TOKEN; 270bc0e7cf4SDavid Howells *_pos += 1; 271bc0e7cf4SDavid Howells n++; 272bc0e7cf4SDavid Howells } 273bc0e7cf4SDavid Howells 274bc0e7cf4SDavid Howells p = seq_hlist_start_rcu(&rxnet->peer_hash[bucket], n - 1); 275bc0e7cf4SDavid Howells if (p) 276bc0e7cf4SDavid Howells return p; 277bc0e7cf4SDavid Howells bucket++; 278bc0e7cf4SDavid Howells n = 1; 279bc0e7cf4SDavid Howells *_pos = (bucket << shift) | n; 280bc0e7cf4SDavid Howells } 281bc0e7cf4SDavid Howells } 282bc0e7cf4SDavid Howells 283bc0e7cf4SDavid Howells static void *rxrpc_peer_seq_next(struct seq_file *seq, void *v, loff_t *_pos) 284bc0e7cf4SDavid Howells { 285bc0e7cf4SDavid Howells struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq)); 286bc0e7cf4SDavid Howells unsigned int bucket, n; 287bc0e7cf4SDavid Howells unsigned int shift = 32 - HASH_BITS(rxnet->peer_hash); 288bc0e7cf4SDavid Howells void *p; 289bc0e7cf4SDavid Howells 290bc0e7cf4SDavid Howells if (*_pos >= UINT_MAX) 291bc0e7cf4SDavid Howells return NULL; 292bc0e7cf4SDavid Howells 293bc0e7cf4SDavid Howells bucket = *_pos >> shift; 294bc0e7cf4SDavid Howells 295bc0e7cf4SDavid Howells p = seq_hlist_next_rcu(v, &rxnet->peer_hash[bucket], _pos); 296bc0e7cf4SDavid Howells if (p) 297bc0e7cf4SDavid Howells return p; 298bc0e7cf4SDavid Howells 299bc0e7cf4SDavid Howells for (;;) { 300bc0e7cf4SDavid Howells bucket++; 301bc0e7cf4SDavid Howells n = 1; 302bc0e7cf4SDavid Howells *_pos = (bucket << shift) | n; 303bc0e7cf4SDavid Howells 304bc0e7cf4SDavid Howells if (bucket >= HASH_SIZE(rxnet->peer_hash)) { 305bc0e7cf4SDavid Howells *_pos = UINT_MAX; 306bc0e7cf4SDavid Howells return NULL; 307bc0e7cf4SDavid Howells } 308bc0e7cf4SDavid Howells if (n == 0) { 309bc0e7cf4SDavid Howells *_pos += 1; 310bc0e7cf4SDavid Howells n++; 311bc0e7cf4SDavid Howells } 312bc0e7cf4SDavid Howells 313bc0e7cf4SDavid Howells p = seq_hlist_start_rcu(&rxnet->peer_hash[bucket], n - 1); 314bc0e7cf4SDavid Howells if (p) 315bc0e7cf4SDavid Howells return p; 316bc0e7cf4SDavid Howells } 317bc0e7cf4SDavid Howells } 318bc0e7cf4SDavid Howells 319bc0e7cf4SDavid Howells static void rxrpc_peer_seq_stop(struct seq_file *seq, void *v) 320bc0e7cf4SDavid Howells __releases(rcu) 321bc0e7cf4SDavid Howells { 322bc0e7cf4SDavid Howells rcu_read_unlock(); 323bc0e7cf4SDavid Howells } 324bc0e7cf4SDavid Howells 325bc0e7cf4SDavid Howells 326bc0e7cf4SDavid Howells const struct seq_operations rxrpc_peer_seq_ops = { 327bc0e7cf4SDavid Howells .start = rxrpc_peer_seq_start, 328bc0e7cf4SDavid Howells .next = rxrpc_peer_seq_next, 329bc0e7cf4SDavid Howells .stop = rxrpc_peer_seq_stop, 330bc0e7cf4SDavid Howells .show = rxrpc_peer_seq_show, 331bc0e7cf4SDavid Howells }; 33233912c26SDavid Howells 33333912c26SDavid Howells /* 33433912c26SDavid Howells * Generate a list of extant virtual local endpoints in /proc/net/rxrpc/locals 33533912c26SDavid Howells */ 33633912c26SDavid Howells static int rxrpc_local_seq_show(struct seq_file *seq, void *v) 33733912c26SDavid Howells { 33833912c26SDavid Howells struct rxrpc_local *local; 33933912c26SDavid Howells char lbuff[50]; 34033912c26SDavid Howells 34133912c26SDavid Howells if (v == SEQ_START_TOKEN) { 34233912c26SDavid Howells seq_puts(seq, 34333912c26SDavid Howells "Proto Local " 34433912c26SDavid Howells " Use Act\n"); 34533912c26SDavid Howells return 0; 34633912c26SDavid Howells } 34733912c26SDavid Howells 34833912c26SDavid Howells local = hlist_entry(v, struct rxrpc_local, link); 34933912c26SDavid Howells 35033912c26SDavid Howells sprintf(lbuff, "%pISpc", &local->srx.transport); 35133912c26SDavid Howells 35233912c26SDavid Howells seq_printf(seq, 35333912c26SDavid Howells "UDP %-47.47s %3u %3u\n", 35433912c26SDavid Howells lbuff, 355a0575429SDavid Howells refcount_read(&local->ref), 35633912c26SDavid Howells atomic_read(&local->active_users)); 35733912c26SDavid Howells 35833912c26SDavid Howells return 0; 35933912c26SDavid Howells } 36033912c26SDavid Howells 36133912c26SDavid Howells static void *rxrpc_local_seq_start(struct seq_file *seq, loff_t *_pos) 36233912c26SDavid Howells __acquires(rcu) 36333912c26SDavid Howells { 36433912c26SDavid Howells struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq)); 36533912c26SDavid Howells unsigned int n; 36633912c26SDavid Howells 36733912c26SDavid Howells rcu_read_lock(); 36833912c26SDavid Howells 36933912c26SDavid Howells if (*_pos >= UINT_MAX) 37033912c26SDavid Howells return NULL; 37133912c26SDavid Howells 37233912c26SDavid Howells n = *_pos; 37333912c26SDavid Howells if (n == 0) 37433912c26SDavid Howells return SEQ_START_TOKEN; 37533912c26SDavid Howells 37633912c26SDavid Howells return seq_hlist_start_rcu(&rxnet->local_endpoints, n - 1); 37733912c26SDavid Howells } 37833912c26SDavid Howells 37933912c26SDavid Howells static void *rxrpc_local_seq_next(struct seq_file *seq, void *v, loff_t *_pos) 38033912c26SDavid Howells { 38133912c26SDavid Howells struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq)); 38233912c26SDavid Howells 38333912c26SDavid Howells if (*_pos >= UINT_MAX) 38433912c26SDavid Howells return NULL; 38533912c26SDavid Howells 38633912c26SDavid Howells return seq_hlist_next_rcu(v, &rxnet->local_endpoints, _pos); 38733912c26SDavid Howells } 38833912c26SDavid Howells 38933912c26SDavid Howells static void rxrpc_local_seq_stop(struct seq_file *seq, void *v) 39033912c26SDavid Howells __releases(rcu) 39133912c26SDavid Howells { 39233912c26SDavid Howells rcu_read_unlock(); 39333912c26SDavid Howells } 39433912c26SDavid Howells 39533912c26SDavid Howells const struct seq_operations rxrpc_local_seq_ops = { 39633912c26SDavid Howells .start = rxrpc_local_seq_start, 39733912c26SDavid Howells .next = rxrpc_local_seq_next, 39833912c26SDavid Howells .stop = rxrpc_local_seq_stop, 39933912c26SDavid Howells .show = rxrpc_local_seq_show, 40033912c26SDavid Howells }; 401b0154246SDavid Howells 402b0154246SDavid Howells /* 403b0154246SDavid Howells * Display stats in /proc/net/rxrpc/stats 404b0154246SDavid Howells */ 405b0154246SDavid Howells int rxrpc_stats_show(struct seq_file *seq, void *v) 406b0154246SDavid Howells { 407b0154246SDavid Howells struct rxrpc_net *rxnet = rxrpc_net(seq_file_single_net(seq)); 408b0154246SDavid Howells 409b0154246SDavid Howells seq_printf(seq, 410b0154246SDavid Howells "Data : send=%u sendf=%u\n", 411b0154246SDavid Howells atomic_read(&rxnet->stat_tx_data_send), 412b0154246SDavid Howells atomic_read(&rxnet->stat_tx_data_send_frag)); 413b0154246SDavid Howells seq_printf(seq, 414b0154246SDavid Howells "Data-Tx : nr=%u retrans=%u\n", 415b0154246SDavid Howells atomic_read(&rxnet->stat_tx_data), 416b0154246SDavid Howells atomic_read(&rxnet->stat_tx_data_retrans)); 417b0154246SDavid Howells seq_printf(seq, 418b0154246SDavid Howells "Data-Rx : nr=%u reqack=%u jumbo=%u\n", 419b0154246SDavid Howells atomic_read(&rxnet->stat_rx_data), 420b0154246SDavid Howells atomic_read(&rxnet->stat_rx_data_reqack), 421b0154246SDavid Howells atomic_read(&rxnet->stat_rx_data_jumbo)); 422b0154246SDavid Howells seq_printf(seq, 423f2a676d1SDavid Howells "Ack : fill=%u send=%u skip=%u\n", 424f2a676d1SDavid Howells atomic_read(&rxnet->stat_tx_ack_fill), 425f2a676d1SDavid Howells atomic_read(&rxnet->stat_tx_ack_send), 426f2a676d1SDavid Howells atomic_read(&rxnet->stat_tx_ack_skip)); 427f2a676d1SDavid Howells seq_printf(seq, 428f2a676d1SDavid Howells "Ack-Tx : req=%u dup=%u oos=%u exw=%u nos=%u png=%u prs=%u dly=%u idl=%u\n", 429f2a676d1SDavid Howells atomic_read(&rxnet->stat_tx_acks[RXRPC_ACK_REQUESTED]), 430f2a676d1SDavid Howells atomic_read(&rxnet->stat_tx_acks[RXRPC_ACK_DUPLICATE]), 431f2a676d1SDavid Howells atomic_read(&rxnet->stat_tx_acks[RXRPC_ACK_OUT_OF_SEQUENCE]), 432f2a676d1SDavid Howells atomic_read(&rxnet->stat_tx_acks[RXRPC_ACK_EXCEEDS_WINDOW]), 433f2a676d1SDavid Howells atomic_read(&rxnet->stat_tx_acks[RXRPC_ACK_NOSPACE]), 434f2a676d1SDavid Howells atomic_read(&rxnet->stat_tx_acks[RXRPC_ACK_PING]), 435f2a676d1SDavid Howells atomic_read(&rxnet->stat_tx_acks[RXRPC_ACK_PING_RESPONSE]), 436f2a676d1SDavid Howells atomic_read(&rxnet->stat_tx_acks[RXRPC_ACK_DELAY]), 437f2a676d1SDavid Howells atomic_read(&rxnet->stat_tx_acks[RXRPC_ACK_IDLE])); 438f2a676d1SDavid Howells seq_printf(seq, 439f2a676d1SDavid Howells "Ack-Rx : req=%u dup=%u oos=%u exw=%u nos=%u png=%u prs=%u dly=%u idl=%u\n", 440f2a676d1SDavid Howells atomic_read(&rxnet->stat_rx_acks[RXRPC_ACK_REQUESTED]), 441f2a676d1SDavid Howells atomic_read(&rxnet->stat_rx_acks[RXRPC_ACK_DUPLICATE]), 442f2a676d1SDavid Howells atomic_read(&rxnet->stat_rx_acks[RXRPC_ACK_OUT_OF_SEQUENCE]), 443f2a676d1SDavid Howells atomic_read(&rxnet->stat_rx_acks[RXRPC_ACK_EXCEEDS_WINDOW]), 444f2a676d1SDavid Howells atomic_read(&rxnet->stat_rx_acks[RXRPC_ACK_NOSPACE]), 445f2a676d1SDavid Howells atomic_read(&rxnet->stat_rx_acks[RXRPC_ACK_PING]), 446f2a676d1SDavid Howells atomic_read(&rxnet->stat_rx_acks[RXRPC_ACK_PING_RESPONSE]), 447f2a676d1SDavid Howells atomic_read(&rxnet->stat_rx_acks[RXRPC_ACK_DELAY]), 448f2a676d1SDavid Howells atomic_read(&rxnet->stat_rx_acks[RXRPC_ACK_IDLE])); 449f2a676d1SDavid Howells seq_printf(seq, 450f7fa5242SDavid Howells "Why-Req-A: acklost=%u already=%u mrtt=%u ortt=%u\n", 451f7fa5242SDavid Howells atomic_read(&rxnet->stat_why_req_ack[rxrpc_reqack_ack_lost]), 452f7fa5242SDavid Howells atomic_read(&rxnet->stat_why_req_ack[rxrpc_reqack_already_on]), 453f7fa5242SDavid Howells atomic_read(&rxnet->stat_why_req_ack[rxrpc_reqack_more_rtt]), 454f7fa5242SDavid Howells atomic_read(&rxnet->stat_why_req_ack[rxrpc_reqack_old_rtt])); 455f7fa5242SDavid Howells seq_printf(seq, 456f7fa5242SDavid Howells "Why-Req-A: nolast=%u retx=%u slows=%u smtxw=%u\n", 457f7fa5242SDavid Howells atomic_read(&rxnet->stat_why_req_ack[rxrpc_reqack_no_srv_last]), 458f7fa5242SDavid Howells atomic_read(&rxnet->stat_why_req_ack[rxrpc_reqack_retrans]), 459f7fa5242SDavid Howells atomic_read(&rxnet->stat_why_req_ack[rxrpc_reqack_slow_start]), 460f7fa5242SDavid Howells atomic_read(&rxnet->stat_why_req_ack[rxrpc_reqack_small_txwin])); 461f7fa5242SDavid Howells seq_printf(seq, 462a4ea4c47SDavid Howells "Buffers : txb=%u rxb=%u\n", 46302a19356SDavid Howells atomic_read(&rxrpc_nr_txbuf), 464b0154246SDavid Howells atomic_read(&rxrpc_n_rx_skbs)); 465b0154246SDavid Howells return 0; 466b0154246SDavid Howells } 467b0154246SDavid Howells 468b0154246SDavid Howells /* 469b0154246SDavid Howells * Clear stats if /proc/net/rxrpc/stats is written to. 470b0154246SDavid Howells */ 471b0154246SDavid Howells int rxrpc_stats_clear(struct file *file, char *buf, size_t size) 472b0154246SDavid Howells { 473b0154246SDavid Howells struct seq_file *m = file->private_data; 474b0154246SDavid Howells struct rxrpc_net *rxnet = rxrpc_net(seq_file_single_net(m)); 475b0154246SDavid Howells 476b0154246SDavid Howells if (size > 1 || (size == 1 && buf[0] != '\n')) 477b0154246SDavid Howells return -EINVAL; 478b0154246SDavid Howells 479b0154246SDavid Howells atomic_set(&rxnet->stat_tx_data, 0); 480b0154246SDavid Howells atomic_set(&rxnet->stat_tx_data_retrans, 0); 481b0154246SDavid Howells atomic_set(&rxnet->stat_tx_data_send, 0); 482b0154246SDavid Howells atomic_set(&rxnet->stat_tx_data_send_frag, 0); 483b0154246SDavid Howells atomic_set(&rxnet->stat_rx_data, 0); 484b0154246SDavid Howells atomic_set(&rxnet->stat_rx_data_reqack, 0); 485b0154246SDavid Howells atomic_set(&rxnet->stat_rx_data_jumbo, 0); 486f2a676d1SDavid Howells 487f2a676d1SDavid Howells atomic_set(&rxnet->stat_tx_ack_fill, 0); 488f2a676d1SDavid Howells atomic_set(&rxnet->stat_tx_ack_send, 0); 489f2a676d1SDavid Howells atomic_set(&rxnet->stat_tx_ack_skip, 0); 490f2a676d1SDavid Howells memset(&rxnet->stat_tx_acks, 0, sizeof(rxnet->stat_tx_acks)); 491f2a676d1SDavid Howells memset(&rxnet->stat_rx_acks, 0, sizeof(rxnet->stat_rx_acks)); 492f7fa5242SDavid Howells 493f7fa5242SDavid Howells memset(&rxnet->stat_why_req_ack, 0, sizeof(rxnet->stat_why_req_ack)); 494b0154246SDavid Howells return size; 495b0154246SDavid Howells } 496