1b4d0d230SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
25873c083SDavid Howells /* sysctls for configuring RxRPC operating parameters
35873c083SDavid Howells *
45873c083SDavid Howells * Copyright (C) 2014 Red Hat, Inc. All Rights Reserved.
55873c083SDavid Howells * Written by David Howells (dhowells@redhat.com)
65873c083SDavid Howells */
75873c083SDavid Howells
85873c083SDavid Howells #include <linux/sysctl.h>
95873c083SDavid Howells #include <net/sock.h>
105873c083SDavid Howells #include <net/af_rxrpc.h>
115873c083SDavid Howells #include "ar-internal.h"
125873c083SDavid Howells
135873c083SDavid Howells static struct ctl_table_header *rxrpc_sysctl_reg_table;
14dad8aff7SDavid Howells static const unsigned int four = 4;
1588e22159SDavid Howells static const unsigned int max_backlog = RXRPC_BACKLOG_MAX - 1;
16dad8aff7SDavid Howells static const unsigned int n_65535 = 65535;
175d7edbc9SDavid Howells static const unsigned int n_max_acks = 255;
18*153f90a0SDavid Howells static const unsigned long one_ms = 1;
19*153f90a0SDavid Howells static const unsigned long max_ms = 1000;
20a158bdd3SDavid Howells static const unsigned long one_jiffy = 1;
21a158bdd3SDavid Howells static const unsigned long max_jiffies = MAX_JIFFY_OFFSET;
22af094824SDavid Howells #ifdef CONFIG_AF_RXRPC_INJECT_RX_DELAY
23af094824SDavid Howells static const unsigned long max_500 = 500;
24af094824SDavid Howells #endif
255873c083SDavid Howells
265873c083SDavid Howells /*
275873c083SDavid Howells * RxRPC operating parameters.
285873c083SDavid Howells *
299f72374cSMauro Carvalho Chehab * See Documentation/networking/rxrpc.rst and the variable definitions for more
305873c083SDavid Howells * information on the individual parameters.
315873c083SDavid Howells */
325873c083SDavid Howells static struct ctl_table rxrpc_sysctl_table[] = {
33*153f90a0SDavid Howells /* Values measured in milliseconds */
345873c083SDavid Howells {
355873c083SDavid Howells .procname = "soft_ack_delay",
365873c083SDavid Howells .data = &rxrpc_soft_ack_delay,
37a158bdd3SDavid Howells .maxlen = sizeof(unsigned long),
385873c083SDavid Howells .mode = 0644,
39*153f90a0SDavid Howells .proc_handler = proc_doulongvec_minmax,
40*153f90a0SDavid Howells .extra1 = (void *)&one_ms,
41*153f90a0SDavid Howells .extra2 = (void *)&max_ms,
425873c083SDavid Howells },
435873c083SDavid Howells {
445873c083SDavid Howells .procname = "idle_ack_delay",
455873c083SDavid Howells .data = &rxrpc_idle_ack_delay,
46a158bdd3SDavid Howells .maxlen = sizeof(unsigned long),
475873c083SDavid Howells .mode = 0644,
48*153f90a0SDavid Howells .proc_handler = proc_doulongvec_minmax,
49*153f90a0SDavid Howells .extra1 = (void *)&one_ms,
50*153f90a0SDavid Howells .extra2 = (void *)&max_ms,
515873c083SDavid Howells },
5245025bceSDavid Howells {
5345025bceSDavid Howells .procname = "idle_conn_expiry",
5445025bceSDavid Howells .data = &rxrpc_conn_idle_client_expiry,
55a158bdd3SDavid Howells .maxlen = sizeof(unsigned long),
5645025bceSDavid Howells .mode = 0644,
57a158bdd3SDavid Howells .proc_handler = proc_doulongvec_ms_jiffies_minmax,
58a158bdd3SDavid Howells .extra1 = (void *)&one_jiffy,
59a158bdd3SDavid Howells .extra2 = (void *)&max_jiffies,
6045025bceSDavid Howells },
6145025bceSDavid Howells {
6245025bceSDavid Howells .procname = "idle_conn_fast_expiry",
6345025bceSDavid Howells .data = &rxrpc_conn_idle_client_fast_expiry,
64a158bdd3SDavid Howells .maxlen = sizeof(unsigned long),
6545025bceSDavid Howells .mode = 0644,
66a158bdd3SDavid Howells .proc_handler = proc_doulongvec_ms_jiffies_minmax,
67a158bdd3SDavid Howells .extra1 = (void *)&one_jiffy,
68a158bdd3SDavid Howells .extra2 = (void *)&max_jiffies,
6945025bceSDavid Howells },
705873c083SDavid Howells
71af094824SDavid Howells /* Values used in milliseconds */
72af094824SDavid Howells #ifdef CONFIG_AF_RXRPC_INJECT_RX_DELAY
73af094824SDavid Howells {
74af094824SDavid Howells .procname = "inject_rx_delay",
75af094824SDavid Howells .data = &rxrpc_inject_rx_delay,
76af094824SDavid Howells .maxlen = sizeof(unsigned long),
77af094824SDavid Howells .mode = 0644,
78af094824SDavid Howells .proc_handler = proc_doulongvec_minmax,
79af094824SDavid Howells .extra1 = (void *)SYSCTL_LONG_ZERO,
80af094824SDavid Howells .extra2 = (void *)&max_500,
81af094824SDavid Howells },
82af094824SDavid Howells #endif
83af094824SDavid Howells
8445025bceSDavid Howells /* Non-time values */
855873c083SDavid Howells {
8645025bceSDavid Howells .procname = "reap_client_conns",
8745025bceSDavid Howells .data = &rxrpc_reap_client_connections,
88dad8aff7SDavid Howells .maxlen = sizeof(unsigned int),
895873c083SDavid Howells .mode = 0644,
905873c083SDavid Howells .proc_handler = proc_dointvec_minmax,
91eec4844fSMatteo Croce .extra1 = (void *)SYSCTL_ONE,
92245500d8SDavid Howells .extra2 = (void *)&n_65535,
935873c083SDavid Howells },
94817913d8SDavid Howells {
950e119b41SDavid Howells .procname = "max_backlog",
960e119b41SDavid Howells .data = &rxrpc_max_backlog,
970e119b41SDavid Howells .maxlen = sizeof(unsigned int),
980e119b41SDavid Howells .mode = 0644,
990e119b41SDavid Howells .proc_handler = proc_dointvec_minmax,
1000e119b41SDavid Howells .extra1 = (void *)&four,
10188e22159SDavid Howells .extra2 = (void *)&max_backlog,
1020e119b41SDavid Howells },
1030e119b41SDavid Howells {
104817913d8SDavid Howells .procname = "rx_window_size",
105817913d8SDavid Howells .data = &rxrpc_rx_window_size,
106dad8aff7SDavid Howells .maxlen = sizeof(unsigned int),
107817913d8SDavid Howells .mode = 0644,
108817913d8SDavid Howells .proc_handler = proc_dointvec_minmax,
109eec4844fSMatteo Croce .extra1 = (void *)SYSCTL_ONE,
110817913d8SDavid Howells .extra2 = (void *)&n_max_acks,
111817913d8SDavid Howells },
112817913d8SDavid Howells {
113817913d8SDavid Howells .procname = "rx_mtu",
114817913d8SDavid Howells .data = &rxrpc_rx_mtu,
115dad8aff7SDavid Howells .maxlen = sizeof(unsigned int),
116817913d8SDavid Howells .mode = 0644,
117817913d8SDavid Howells .proc_handler = proc_dointvec_minmax,
118eec4844fSMatteo Croce .extra1 = (void *)SYSCTL_ONE,
119ee6fe085SDavid Howells .extra2 = (void *)&n_65535,
120817913d8SDavid Howells },
121817913d8SDavid Howells {
122817913d8SDavid Howells .procname = "rx_jumbo_max",
123817913d8SDavid Howells .data = &rxrpc_rx_jumbo_max,
124dad8aff7SDavid Howells .maxlen = sizeof(unsigned int),
125817913d8SDavid Howells .mode = 0644,
126817913d8SDavid Howells .proc_handler = proc_dointvec_minmax,
127eec4844fSMatteo Croce .extra1 = (void *)SYSCTL_ONE,
128817913d8SDavid Howells .extra2 = (void *)&four,
129817913d8SDavid Howells },
1305873c083SDavid Howells };
1315873c083SDavid Howells
rxrpc_sysctl_init(void)1325873c083SDavid Howells int __init rxrpc_sysctl_init(void)
1335873c083SDavid Howells {
1345873c083SDavid Howells rxrpc_sysctl_reg_table = register_net_sysctl(&init_net, "net/rxrpc",
1355873c083SDavid Howells rxrpc_sysctl_table);
1365873c083SDavid Howells if (!rxrpc_sysctl_reg_table)
1375873c083SDavid Howells return -ENOMEM;
1385873c083SDavid Howells return 0;
1395873c083SDavid Howells }
1405873c083SDavid Howells
rxrpc_sysctl_exit(void)1415873c083SDavid Howells void rxrpc_sysctl_exit(void)
1425873c083SDavid Howells {
1435873c083SDavid Howells if (rxrpc_sysctl_reg_table)
1445873c083SDavid Howells unregister_net_sysctl_table(rxrpc_sysctl_reg_table);
1455873c083SDavid Howells }
146