misc.c 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. #include <linux/kernel.h>
  12. #include <net/sock.h>
  13. #include <net/af_rxrpc.h>
  14. #include "ar-internal.h"
  15. /*
  16. * The maximum listening backlog queue size that may be set on a socket by
  17. * listen().
  18. */
  19. unsigned int rxrpc_max_backlog __read_mostly = 10;
  20. /*
  21. * Maximum lifetime of a call (in mx).
  22. */
  23. unsigned int rxrpc_max_call_lifetime = 60 * 1000;
  24. /*
  25. * How long to wait before scheduling ACK generation after seeing a
  26. * packet with RXRPC_REQUEST_ACK set (in ms).
  27. */
  28. unsigned int rxrpc_requested_ack_delay = 1;
  29. /*
  30. * How long to wait before scheduling an ACK with subtype DELAY (in ms).
  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 * 1000;
  37. /*
  38. * How long to wait before scheduling an ACK with subtype IDLE (in ms).
  39. *
  40. * We use this when we've consumed some previously soft-ACK'd packets when
  41. * further packets aren't immediately received to decide when to send an IDLE
  42. * ACK let the other end know that it can free up its Tx buffer space.
  43. */
  44. unsigned int rxrpc_idle_ack_delay = 0.5 * 1000;
  45. /*
  46. * Receive window size in packets. This indicates the maximum number of
  47. * unconsumed received packets we're willing to retain in memory. Once this
  48. * limit is hit, we should generate an EXCEEDS_WINDOW ACK and discard further
  49. * packets.
  50. */
  51. unsigned int rxrpc_rx_window_size = RXRPC_INIT_RX_WINDOW_SIZE;
  52. #if (RXRPC_RXTX_BUFF_SIZE - 1) < RXRPC_INIT_RX_WINDOW_SIZE
  53. #error Need to reduce RXRPC_INIT_RX_WINDOW_SIZE
  54. #endif
  55. /*
  56. * Maximum Rx MTU size. This indicates to the sender the size of jumbo packet
  57. * made by gluing normal packets together that we're willing to handle.
  58. */
  59. unsigned int rxrpc_rx_mtu = 5692;
  60. /*
  61. * The maximum number of fragments in a received jumbo packet that we tell the
  62. * sender that we're willing to handle.
  63. */
  64. unsigned int rxrpc_rx_jumbo_max = 4;
  65. /*
  66. * Time till packet resend (in milliseconds).
  67. */
  68. unsigned int rxrpc_resend_timeout = 4 * 1000;
  69. const char *const rxrpc_pkts[] = {
  70. "?00",
  71. "DATA", "ACK", "BUSY", "ABORT", "ACKALL", "CHALL", "RESP", "DEBUG",
  72. "?09", "?10", "?11", "?12", "VERSION", "?14", "?15"
  73. };
  74. const s8 rxrpc_ack_priority[] = {
  75. [0] = 0,
  76. [RXRPC_ACK_DELAY] = 1,
  77. [RXRPC_ACK_REQUESTED] = 2,
  78. [RXRPC_ACK_IDLE] = 3,
  79. [RXRPC_ACK_DUPLICATE] = 4,
  80. [RXRPC_ACK_OUT_OF_SEQUENCE] = 5,
  81. [RXRPC_ACK_EXCEEDS_WINDOW] = 6,
  82. [RXRPC_ACK_NOSPACE] = 7,
  83. [RXRPC_ACK_PING_RESPONSE] = 8,
  84. };
  85. const char rxrpc_ack_names[RXRPC_ACK__INVALID + 1][4] = {
  86. "---", "REQ", "DUP", "OOS", "WIN", "MEM", "PNG", "PNR", "DLY",
  87. "IDL", "-?-"
  88. };
  89. const char rxrpc_skb_traces[rxrpc_skb__nr_trace][7] = {
  90. [rxrpc_skb_rx_cleaned] = "Rx CLN",
  91. [rxrpc_skb_rx_freed] = "Rx FRE",
  92. [rxrpc_skb_rx_got] = "Rx GOT",
  93. [rxrpc_skb_rx_lost] = "Rx *L*",
  94. [rxrpc_skb_rx_received] = "Rx RCV",
  95. [rxrpc_skb_rx_purged] = "Rx PUR",
  96. [rxrpc_skb_rx_rotated] = "Rx ROT",
  97. [rxrpc_skb_rx_seen] = "Rx SEE",
  98. [rxrpc_skb_tx_cleaned] = "Tx CLN",
  99. [rxrpc_skb_tx_freed] = "Tx FRE",
  100. [rxrpc_skb_tx_got] = "Tx GOT",
  101. [rxrpc_skb_tx_new] = "Tx NEW",
  102. [rxrpc_skb_tx_rotated] = "Tx ROT",
  103. [rxrpc_skb_tx_seen] = "Tx SEE",
  104. };
  105. const 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. const char rxrpc_client_traces[rxrpc_client__nr_trace][7] = {
  115. [rxrpc_client_activate_chans] = "Activa",
  116. [rxrpc_client_alloc] = "Alloc ",
  117. [rxrpc_client_chan_activate] = "ChActv",
  118. [rxrpc_client_chan_disconnect] = "ChDisc",
  119. [rxrpc_client_chan_pass] = "ChPass",
  120. [rxrpc_client_chan_unstarted] = "ChUnst",
  121. [rxrpc_client_cleanup] = "Clean ",
  122. [rxrpc_client_count] = "Count ",
  123. [rxrpc_client_discard] = "Discar",
  124. [rxrpc_client_duplicate] = "Duplic",
  125. [rxrpc_client_exposed] = "Expose",
  126. [rxrpc_client_replace] = "Replac",
  127. [rxrpc_client_to_active] = "->Actv",
  128. [rxrpc_client_to_culled] = "->Cull",
  129. [rxrpc_client_to_idle] = "->Idle",
  130. [rxrpc_client_to_inactive] = "->Inac",
  131. [rxrpc_client_to_waiting] = "->Wait",
  132. [rxrpc_client_uncount] = "Uncoun",
  133. };
  134. const char rxrpc_transmit_traces[rxrpc_transmit__nr_trace][4] = {
  135. [rxrpc_transmit_wait] = "WAI",
  136. [rxrpc_transmit_queue] = "QUE",
  137. [rxrpc_transmit_queue_last] = "QLS",
  138. [rxrpc_transmit_rotate] = "ROT",
  139. [rxrpc_transmit_rotate_last] = "RLS",
  140. [rxrpc_transmit_await_reply] = "AWR",
  141. [rxrpc_transmit_end] = "END",
  142. };
  143. const char rxrpc_receive_traces[rxrpc_receive__nr_trace][4] = {
  144. [rxrpc_receive_incoming] = "INC",
  145. [rxrpc_receive_queue] = "QUE",
  146. [rxrpc_receive_queue_last] = "QLS",
  147. [rxrpc_receive_front] = "FRN",
  148. [rxrpc_receive_rotate] = "ROT",
  149. [rxrpc_receive_end] = "END",
  150. };
  151. const char rxrpc_recvmsg_traces[rxrpc_recvmsg__nr_trace][5] = {
  152. [rxrpc_recvmsg_enter] = "ENTR",
  153. [rxrpc_recvmsg_wait] = "WAIT",
  154. [rxrpc_recvmsg_dequeue] = "DEQU",
  155. [rxrpc_recvmsg_hole] = "HOLE",
  156. [rxrpc_recvmsg_next] = "NEXT",
  157. [rxrpc_recvmsg_cont] = "CONT",
  158. [rxrpc_recvmsg_full] = "FULL",
  159. [rxrpc_recvmsg_data_return] = "DATA",
  160. [rxrpc_recvmsg_terminal] = "TERM",
  161. [rxrpc_recvmsg_to_be_accepted] = "TBAC",
  162. [rxrpc_recvmsg_return] = "RETN",
  163. };
  164. const char rxrpc_rtt_tx_traces[rxrpc_rtt_tx__nr_trace][5] = {
  165. [rxrpc_rtt_tx_ping] = "PING",
  166. [rxrpc_rtt_tx_data] = "DATA",
  167. };
  168. const char rxrpc_rtt_rx_traces[rxrpc_rtt_rx__nr_trace][5] = {
  169. [rxrpc_rtt_rx_ping_response] = "PONG",
  170. [rxrpc_rtt_rx_requested_ack] = "RACK",
  171. };
  172. const char rxrpc_timer_traces[rxrpc_timer__nr_trace][8] = {
  173. [rxrpc_timer_begin] = "Begin ",
  174. [rxrpc_timer_expired] = "*EXPR*",
  175. [rxrpc_timer_init_for_reply] = "IniRpl",
  176. [rxrpc_timer_init_for_send_reply] = "SndRpl",
  177. [rxrpc_timer_set_for_ack] = "SetAck",
  178. [rxrpc_timer_set_for_ping] = "SetPng",
  179. [rxrpc_timer_set_for_send] = "SetTx ",
  180. [rxrpc_timer_set_for_resend] = "SetRTx",
  181. };
  182. const char rxrpc_propose_ack_traces[rxrpc_propose_ack__nr_trace][8] = {
  183. [rxrpc_propose_ack_client_tx_end] = "ClTxEnd",
  184. [rxrpc_propose_ack_input_data] = "DataIn ",
  185. [rxrpc_propose_ack_ping_for_lost_ack] = "LostAck",
  186. [rxrpc_propose_ack_ping_for_lost_reply] = "LostRpl",
  187. [rxrpc_propose_ack_ping_for_params] = "Params ",
  188. [rxrpc_propose_ack_processing_op] = "ProcOp ",
  189. [rxrpc_propose_ack_respond_to_ack] = "Rsp2Ack",
  190. [rxrpc_propose_ack_respond_to_ping] = "Rsp2Png",
  191. [rxrpc_propose_ack_retry_tx] = "RetryTx",
  192. [rxrpc_propose_ack_rotate_rx] = "RxAck ",
  193. [rxrpc_propose_ack_terminal_ack] = "ClTerm ",
  194. };
  195. const char *const rxrpc_propose_ack_outcomes[rxrpc_propose_ack__nr_outcomes] = {
  196. [rxrpc_propose_ack_use] = "",
  197. [rxrpc_propose_ack_update] = " Update",
  198. [rxrpc_propose_ack_subsume] = " Subsume",
  199. };
  200. const char rxrpc_congest_modes[NR__RXRPC_CONGEST_MODES][10] = {
  201. [RXRPC_CALL_SLOW_START] = "SlowStart",
  202. [RXRPC_CALL_CONGEST_AVOIDANCE] = "CongAvoid",
  203. [RXRPC_CALL_PACKET_LOSS] = "PktLoss ",
  204. [RXRPC_CALL_FAST_RETRANSMIT] = "FastReTx ",
  205. };
  206. const char rxrpc_congest_changes[rxrpc_congest__nr_change][9] = {
  207. [rxrpc_cong_begin_retransmission] = " Retrans",
  208. [rxrpc_cong_cleared_nacks] = " Cleared",
  209. [rxrpc_cong_new_low_nack] = " NewLowN",
  210. [rxrpc_cong_no_change] = "",
  211. [rxrpc_cong_progress] = " Progres",
  212. [rxrpc_cong_retransmit_again] = " ReTxAgn",
  213. [rxrpc_cong_rtt_window_end] = " RttWinE",
  214. [rxrpc_cong_saw_nack] = " SawNack",
  215. };