David Howells | 8e688d9 | 2016-04-07 17:23:16 +0100 | [diff] [blame] | 1 | /* Miscellaneous bits |
| 2 | * |
| 3 | * Copyright (C) 2016 Red Hat, Inc. All Rights Reserved. |
| 4 | * Written by David Howells (dhowells@redhat.com) |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public Licence |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the Licence, or (at your option) any later version. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/kernel.h> |
| 13 | #include <net/sock.h> |
| 14 | #include <net/af_rxrpc.h> |
| 15 | #include "ar-internal.h" |
| 16 | |
| 17 | /* |
David Howells | 0e119b4 | 2016-06-10 22:30:37 +0100 | [diff] [blame] | 18 | * The maximum listening backlog queue size that may be set on a socket by |
| 19 | * listen(). |
| 20 | */ |
| 21 | unsigned int rxrpc_max_backlog __read_mostly = 10; |
| 22 | |
| 23 | /* |
David Howells | 8e688d9 | 2016-04-07 17:23:16 +0100 | [diff] [blame] | 24 | * How long to wait before scheduling ACK generation after seeing a |
| 25 | * packet with RXRPC_REQUEST_ACK set (in jiffies). |
| 26 | */ |
| 27 | unsigned int rxrpc_requested_ack_delay = 1; |
| 28 | |
| 29 | /* |
| 30 | * How long to wait before scheduling an ACK with subtype DELAY (in jiffies). |
| 31 | * |
| 32 | * We use this when we've received new data packets. If those packets aren't |
| 33 | * all consumed within this time we will send a DELAY ACK if an ACK was not |
| 34 | * requested to let the sender know it doesn't need to resend. |
| 35 | */ |
| 36 | unsigned int rxrpc_soft_ack_delay = 1 * HZ; |
| 37 | |
| 38 | /* |
| 39 | * How long to wait before scheduling an ACK with subtype IDLE (in jiffies). |
| 40 | * |
| 41 | * We use this when we've consumed some previously soft-ACK'd packets when |
| 42 | * further packets aren't immediately received to decide when to send an IDLE |
| 43 | * ACK let the other end know that it can free up its Tx buffer space. |
| 44 | */ |
| 45 | unsigned int rxrpc_idle_ack_delay = 0.5 * HZ; |
| 46 | |
| 47 | /* |
| 48 | * Receive window size in packets. This indicates the maximum number of |
| 49 | * unconsumed received packets we're willing to retain in memory. Once this |
| 50 | * limit is hit, we should generate an EXCEEDS_WINDOW ACK and discard further |
| 51 | * packets. |
| 52 | */ |
David Howells | 75e42126 | 2016-09-13 22:36:22 +0100 | [diff] [blame] | 53 | unsigned int rxrpc_rx_window_size = RXRPC_INIT_RX_WINDOW_SIZE; |
| 54 | #if (RXRPC_RXTX_BUFF_SIZE - 1) < RXRPC_INIT_RX_WINDOW_SIZE |
| 55 | #error Need to reduce RXRPC_INIT_RX_WINDOW_SIZE |
| 56 | #endif |
David Howells | 8e688d9 | 2016-04-07 17:23:16 +0100 | [diff] [blame] | 57 | |
| 58 | /* |
| 59 | * Maximum Rx MTU size. This indicates to the sender the size of jumbo packet |
| 60 | * made by gluing normal packets together that we're willing to handle. |
| 61 | */ |
| 62 | unsigned int rxrpc_rx_mtu = 5692; |
| 63 | |
| 64 | /* |
| 65 | * The maximum number of fragments in a received jumbo packet that we tell the |
| 66 | * sender that we're willing to handle. |
| 67 | */ |
| 68 | unsigned int rxrpc_rx_jumbo_max = 4; |
| 69 | |
David Howells | 0b58b8a | 2016-09-02 22:39:45 +0100 | [diff] [blame] | 70 | /* |
| 71 | * Time till packet resend (in jiffies). |
| 72 | */ |
| 73 | unsigned int rxrpc_resend_timeout = 4 * HZ; |
| 74 | |
David Howells | 5b3e87f | 2016-04-07 17:23:23 +0100 | [diff] [blame] | 75 | const char *const rxrpc_pkts[] = { |
David Howells | 8e688d9 | 2016-04-07 17:23:16 +0100 | [diff] [blame] | 76 | "?00", |
| 77 | "DATA", "ACK", "BUSY", "ABORT", "ACKALL", "CHALL", "RESP", "DEBUG", |
| 78 | "?09", "?10", "?11", "?12", "VERSION", "?14", "?15" |
| 79 | }; |
| 80 | |
| 81 | const s8 rxrpc_ack_priority[] = { |
| 82 | [0] = 0, |
| 83 | [RXRPC_ACK_DELAY] = 1, |
| 84 | [RXRPC_ACK_REQUESTED] = 2, |
| 85 | [RXRPC_ACK_IDLE] = 3, |
David Howells | 8e83134 | 2016-09-22 00:29:31 +0100 | [diff] [blame^] | 86 | [RXRPC_ACK_DUPLICATE] = 4, |
| 87 | [RXRPC_ACK_OUT_OF_SEQUENCE] = 5, |
| 88 | [RXRPC_ACK_EXCEEDS_WINDOW] = 6, |
| 89 | [RXRPC_ACK_NOSPACE] = 7, |
| 90 | [RXRPC_ACK_PING_RESPONSE] = 8, |
| 91 | [RXRPC_ACK_PING] = 9, |
David Howells | 8e688d9 | 2016-04-07 17:23:16 +0100 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | const char *rxrpc_acks(u8 reason) |
| 95 | { |
| 96 | static const char *const str[] = { |
| 97 | "---", "REQ", "DUP", "OOS", "WIN", "MEM", "PNG", "PNR", "DLY", |
| 98 | "IDL", "-?-" |
| 99 | }; |
| 100 | |
| 101 | if (reason >= ARRAY_SIZE(str)) |
| 102 | reason = ARRAY_SIZE(str) - 1; |
| 103 | return str[reason]; |
| 104 | } |
David Howells | 363deea | 2016-09-17 10:49:14 +0100 | [diff] [blame] | 105 | |
David Howells | 71f3ca4 | 2016-09-17 10:49:14 +0100 | [diff] [blame] | 106 | const char rxrpc_skb_traces[rxrpc_skb__nr_trace][7] = { |
| 107 | [rxrpc_skb_rx_cleaned] = "Rx CLN", |
| 108 | [rxrpc_skb_rx_freed] = "Rx FRE", |
| 109 | [rxrpc_skb_rx_got] = "Rx GOT", |
| 110 | [rxrpc_skb_rx_lost] = "Rx *L*", |
| 111 | [rxrpc_skb_rx_received] = "Rx RCV", |
| 112 | [rxrpc_skb_rx_purged] = "Rx PUR", |
| 113 | [rxrpc_skb_rx_rotated] = "Rx ROT", |
| 114 | [rxrpc_skb_rx_seen] = "Rx SEE", |
| 115 | [rxrpc_skb_tx_cleaned] = "Tx CLN", |
| 116 | [rxrpc_skb_tx_freed] = "Tx FRE", |
| 117 | [rxrpc_skb_tx_got] = "Tx GOT", |
| 118 | [rxrpc_skb_tx_lost] = "Tx *L*", |
| 119 | [rxrpc_skb_tx_new] = "Tx NEW", |
| 120 | [rxrpc_skb_tx_rotated] = "Tx ROT", |
| 121 | [rxrpc_skb_tx_seen] = "Tx SEE", |
| 122 | }; |
| 123 | |
David Howells | 363deea | 2016-09-17 10:49:14 +0100 | [diff] [blame] | 124 | const char rxrpc_conn_traces[rxrpc_conn__nr_trace][4] = { |
| 125 | [rxrpc_conn_new_client] = "NWc", |
| 126 | [rxrpc_conn_new_service] = "NWs", |
| 127 | [rxrpc_conn_queued] = "QUE", |
| 128 | [rxrpc_conn_seen] = "SEE", |
| 129 | [rxrpc_conn_got] = "GOT", |
| 130 | [rxrpc_conn_put_client] = "PTc", |
| 131 | [rxrpc_conn_put_service] = "PTs", |
| 132 | }; |
| 133 | |
| 134 | const char rxrpc_client_traces[rxrpc_client__nr_trace][7] = { |
| 135 | [rxrpc_client_activate_chans] = "Activa", |
| 136 | [rxrpc_client_alloc] = "Alloc ", |
| 137 | [rxrpc_client_chan_activate] = "ChActv", |
| 138 | [rxrpc_client_chan_disconnect] = "ChDisc", |
| 139 | [rxrpc_client_chan_pass] = "ChPass", |
| 140 | [rxrpc_client_chan_unstarted] = "ChUnst", |
| 141 | [rxrpc_client_cleanup] = "Clean ", |
| 142 | [rxrpc_client_count] = "Count ", |
| 143 | [rxrpc_client_discard] = "Discar", |
| 144 | [rxrpc_client_duplicate] = "Duplic", |
| 145 | [rxrpc_client_exposed] = "Expose", |
| 146 | [rxrpc_client_replace] = "Replac", |
| 147 | [rxrpc_client_to_active] = "->Actv", |
| 148 | [rxrpc_client_to_culled] = "->Cull", |
| 149 | [rxrpc_client_to_idle] = "->Idle", |
| 150 | [rxrpc_client_to_inactive] = "->Inac", |
| 151 | [rxrpc_client_to_waiting] = "->Wait", |
| 152 | [rxrpc_client_uncount] = "Uncoun", |
| 153 | }; |
David Howells | a124fe3 | 2016-09-17 10:49:13 +0100 | [diff] [blame] | 154 | |
| 155 | const char rxrpc_transmit_traces[rxrpc_transmit__nr_trace][4] = { |
| 156 | [rxrpc_transmit_wait] = "WAI", |
| 157 | [rxrpc_transmit_queue] = "QUE", |
| 158 | [rxrpc_transmit_queue_reqack] = "QRA", |
| 159 | [rxrpc_transmit_queue_last] = "QLS", |
| 160 | [rxrpc_transmit_rotate] = "ROT", |
| 161 | [rxrpc_transmit_end] = "END", |
| 162 | }; |
David Howells | 58dc63c | 2016-09-17 10:49:13 +0100 | [diff] [blame] | 163 | |
| 164 | const char rxrpc_receive_traces[rxrpc_receive__nr_trace][4] = { |
| 165 | [rxrpc_receive_incoming] = "INC", |
| 166 | [rxrpc_receive_queue] = "QUE", |
| 167 | [rxrpc_receive_queue_last] = "QLS", |
| 168 | [rxrpc_receive_front] = "FRN", |
| 169 | [rxrpc_receive_rotate] = "ROT", |
| 170 | [rxrpc_receive_end] = "END", |
| 171 | }; |
David Howells | 8499790 | 2016-09-17 11:13:31 +0100 | [diff] [blame] | 172 | |
| 173 | const char rxrpc_recvmsg_traces[rxrpc_recvmsg__nr_trace][5] = { |
| 174 | [rxrpc_recvmsg_enter] = "ENTR", |
| 175 | [rxrpc_recvmsg_wait] = "WAIT", |
| 176 | [rxrpc_recvmsg_dequeue] = "DEQU", |
| 177 | [rxrpc_recvmsg_hole] = "HOLE", |
| 178 | [rxrpc_recvmsg_next] = "NEXT", |
| 179 | [rxrpc_recvmsg_cont] = "CONT", |
| 180 | [rxrpc_recvmsg_full] = "FULL", |
| 181 | [rxrpc_recvmsg_data_return] = "DATA", |
| 182 | [rxrpc_recvmsg_terminal] = "TERM", |
| 183 | [rxrpc_recvmsg_to_be_accepted] = "TBAC", |
| 184 | [rxrpc_recvmsg_return] = "RETN", |
| 185 | }; |
David Howells | cf1a647 | 2016-09-22 00:41:53 +0100 | [diff] [blame] | 186 | |
| 187 | const char rxrpc_rtt_tx_traces[rxrpc_rtt_tx__nr_trace][5] = { |
| 188 | [rxrpc_rtt_tx_ping] = "PING", |
| 189 | }; |
| 190 | |
| 191 | const char rxrpc_rtt_rx_traces[rxrpc_rtt_rx__nr_trace][5] = { |
| 192 | [rxrpc_rtt_rx_ping_response] = "PONG", |
| 193 | }; |