blob: db5f1d54fc9031f2b1a3326b14f7ebff4e5af3a5 [file] [log] [blame]
David Howells8e688d92016-04-07 17:23:16 +01001/* 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 Howells0e119b42016-06-10 22:30:37 +010018 * The maximum listening backlog queue size that may be set on a socket by
19 * listen().
20 */
21unsigned int rxrpc_max_backlog __read_mostly = 10;
22
23/*
David Howells8e688d92016-04-07 17:23:16 +010024 * How long to wait before scheduling ACK generation after seeing a
25 * packet with RXRPC_REQUEST_ACK set (in jiffies).
26 */
27unsigned 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 */
36unsigned 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 */
45unsigned 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 Howells75e42122016-09-13 22:36:22 +010053unsigned 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 Howells8e688d92016-04-07 17:23:16 +010057
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 */
62unsigned 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 */
68unsigned int rxrpc_rx_jumbo_max = 4;
69
David Howells0b58b8a2016-09-02 22:39:45 +010070/*
71 * Time till packet resend (in jiffies).
72 */
73unsigned int rxrpc_resend_timeout = 4 * HZ;
74
David Howells5b3e87f2016-04-07 17:23:23 +010075const char *const rxrpc_pkts[] = {
David Howells8e688d92016-04-07 17:23:16 +010076 "?00",
77 "DATA", "ACK", "BUSY", "ABORT", "ACKALL", "CHALL", "RESP", "DEBUG",
78 "?09", "?10", "?11", "?12", "VERSION", "?14", "?15"
79};
80
81const s8 rxrpc_ack_priority[] = {
82 [0] = 0,
83 [RXRPC_ACK_DELAY] = 1,
84 [RXRPC_ACK_REQUESTED] = 2,
85 [RXRPC_ACK_IDLE] = 3,
86 [RXRPC_ACK_PING_RESPONSE] = 4,
87 [RXRPC_ACK_DUPLICATE] = 5,
88 [RXRPC_ACK_OUT_OF_SEQUENCE] = 6,
89 [RXRPC_ACK_EXCEEDS_WINDOW] = 7,
90 [RXRPC_ACK_NOSPACE] = 8,
91};
92
93const char *rxrpc_acks(u8 reason)
94{
95 static const char *const str[] = {
96 "---", "REQ", "DUP", "OOS", "WIN", "MEM", "PNG", "PNR", "DLY",
97 "IDL", "-?-"
98 };
99
100 if (reason >= ARRAY_SIZE(str))
101 reason = ARRAY_SIZE(str) - 1;
102 return str[reason];
103}
David Howells363deea2016-09-17 10:49:14 +0100104
105const char rxrpc_conn_traces[rxrpc_conn__nr_trace][4] = {
106 [rxrpc_conn_new_client] = "NWc",
107 [rxrpc_conn_new_service] = "NWs",
108 [rxrpc_conn_queued] = "QUE",
109 [rxrpc_conn_seen] = "SEE",
110 [rxrpc_conn_got] = "GOT",
111 [rxrpc_conn_put_client] = "PTc",
112 [rxrpc_conn_put_service] = "PTs",
113};
114
115const char rxrpc_client_traces[rxrpc_client__nr_trace][7] = {
116 [rxrpc_client_activate_chans] = "Activa",
117 [rxrpc_client_alloc] = "Alloc ",
118 [rxrpc_client_chan_activate] = "ChActv",
119 [rxrpc_client_chan_disconnect] = "ChDisc",
120 [rxrpc_client_chan_pass] = "ChPass",
121 [rxrpc_client_chan_unstarted] = "ChUnst",
122 [rxrpc_client_cleanup] = "Clean ",
123 [rxrpc_client_count] = "Count ",
124 [rxrpc_client_discard] = "Discar",
125 [rxrpc_client_duplicate] = "Duplic",
126 [rxrpc_client_exposed] = "Expose",
127 [rxrpc_client_replace] = "Replac",
128 [rxrpc_client_to_active] = "->Actv",
129 [rxrpc_client_to_culled] = "->Cull",
130 [rxrpc_client_to_idle] = "->Idle",
131 [rxrpc_client_to_inactive] = "->Inac",
132 [rxrpc_client_to_waiting] = "->Wait",
133 [rxrpc_client_uncount] = "Uncoun",
134};
David Howellsa124fe32016-09-17 10:49:13 +0100135
136const char rxrpc_transmit_traces[rxrpc_transmit__nr_trace][4] = {
137 [rxrpc_transmit_wait] = "WAI",
138 [rxrpc_transmit_queue] = "QUE",
139 [rxrpc_transmit_queue_reqack] = "QRA",
140 [rxrpc_transmit_queue_last] = "QLS",
141 [rxrpc_transmit_rotate] = "ROT",
142 [rxrpc_transmit_end] = "END",
143};
David Howells58dc63c2016-09-17 10:49:13 +0100144
145const char rxrpc_receive_traces[rxrpc_receive__nr_trace][4] = {
146 [rxrpc_receive_incoming] = "INC",
147 [rxrpc_receive_queue] = "QUE",
148 [rxrpc_receive_queue_last] = "QLS",
149 [rxrpc_receive_front] = "FRN",
150 [rxrpc_receive_rotate] = "ROT",
151 [rxrpc_receive_end] = "END",
152};