Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /* DataCenter TCP (DCTCP) congestion control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * http://simula.stanford.edu/~alizade/Site/DCTCP.html
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * This is an implementation of DCTCP over Reno, an enhancement to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * TCP congestion control algorithm designed for data centers. DCTCP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * leverages Explicit Congestion Notification (ECN) in the network to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * provide multi-bit feedback to the end hosts. DCTCP's goal is to meet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * the following three data center transport requirements:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *  - High burst tolerance (incast due to partition/aggregate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *  - Low latency (short flows, queries)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *  - High throughput (continuous data updates, large file transfers)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *    with commodity shallow buffered switches
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * The algorithm is described in detail in the following two papers:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * 1) Mohammad Alizadeh, Albert Greenberg, David A. Maltz, Jitendra Padhye,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  *    Parveen Patel, Balaji Prabhakar, Sudipta Sengupta, and Murari Sridharan:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  *      "Data Center TCP (DCTCP)", Data Center Networks session
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  *      Proc. ACM SIGCOMM, New Delhi, 2010.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  *   http://simula.stanford.edu/~alizade/Site/DCTCP_files/dctcp-final.pdf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * 2) Mohammad Alizadeh, Adel Javanmard, and Balaji Prabhakar:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  *      "Analysis of DCTCP: Stability, Convergence, and Fairness"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  *      Proc. ACM SIGMETRICS, San Jose, 2011.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  *   http://simula.stanford.edu/~alizade/Site/DCTCP_files/dctcp_analysis-full.pdf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * Initial prototype from Abdul Kabbani, Masato Yasuda and Mohammad Alizadeh.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  * Authors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  *	Daniel Borkmann <dborkman@redhat.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  *	Florian Westphal <fw@strlen.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  *	Glenn Judd <glenn.judd@morganstanley.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #include <net/tcp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #include <linux/inet_diag.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #include "tcp_dctcp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #define DCTCP_MAX_ALPHA	1024U
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) struct dctcp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	u32 old_delivered;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	u32 old_delivered_ce;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	u32 prior_rcv_nxt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	u32 dctcp_alpha;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	u32 next_seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	u32 ce_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	u32 loss_cwnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) static unsigned int dctcp_shift_g __read_mostly = 4; /* g = 1/2^4 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) module_param(dctcp_shift_g, uint, 0644);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) MODULE_PARM_DESC(dctcp_shift_g, "parameter g for updating dctcp_alpha");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) static unsigned int dctcp_alpha_on_init __read_mostly = DCTCP_MAX_ALPHA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) module_param(dctcp_alpha_on_init, uint, 0644);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) MODULE_PARM_DESC(dctcp_alpha_on_init, "parameter for initial alpha value");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) static struct tcp_congestion_ops dctcp_reno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) static void dctcp_reset(const struct tcp_sock *tp, struct dctcp *ca)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	ca->next_seq = tp->snd_nxt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	ca->old_delivered = tp->delivered;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	ca->old_delivered_ce = tp->delivered_ce;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) static void dctcp_init(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	const struct tcp_sock *tp = tcp_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	if ((tp->ecn_flags & TCP_ECN_OK) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	    (sk->sk_state == TCP_LISTEN ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	     sk->sk_state == TCP_CLOSE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		struct dctcp *ca = inet_csk_ca(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		ca->prior_rcv_nxt = tp->rcv_nxt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		ca->dctcp_alpha = min(dctcp_alpha_on_init, DCTCP_MAX_ALPHA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		ca->loss_cwnd = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		ca->ce_state = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		dctcp_reset(tp, ca);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	/* No ECN support? Fall back to Reno. Also need to clear
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	 * ECT from sk since it is set during 3WHS for DCTCP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	inet_csk(sk)->icsk_ca_ops = &dctcp_reno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	INET_ECN_dontxmit(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) static u32 dctcp_ssthresh(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	struct dctcp *ca = inet_csk_ca(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	struct tcp_sock *tp = tcp_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	ca->loss_cwnd = tp->snd_cwnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	return max(tp->snd_cwnd - ((tp->snd_cwnd * ca->dctcp_alpha) >> 11U), 2U);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) static void dctcp_update_alpha(struct sock *sk, u32 flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	const struct tcp_sock *tp = tcp_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	struct dctcp *ca = inet_csk_ca(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	/* Expired RTT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	if (!before(tp->snd_una, ca->next_seq)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		u32 delivered_ce = tp->delivered_ce - ca->old_delivered_ce;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		u32 alpha = ca->dctcp_alpha;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		/* alpha = (1 - g) * alpha + g * F */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		alpha -= min_not_zero(alpha, alpha >> dctcp_shift_g);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		if (delivered_ce) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 			u32 delivered = tp->delivered - ca->old_delivered;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 			/* If dctcp_shift_g == 1, a 32bit value would overflow
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 			 * after 8 M packets.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 			delivered_ce <<= (10 - dctcp_shift_g);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 			delivered_ce /= max(1U, delivered);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 			alpha = min(alpha + delivered_ce, DCTCP_MAX_ALPHA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		/* dctcp_alpha can be read from dctcp_get_info() without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		 * synchro, so we ask compiler to not use dctcp_alpha
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		 * as a temporary variable in prior operations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		WRITE_ONCE(ca->dctcp_alpha, alpha);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		dctcp_reset(tp, ca);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) static void dctcp_react_to_loss(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	struct dctcp *ca = inet_csk_ca(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	struct tcp_sock *tp = tcp_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	ca->loss_cwnd = tp->snd_cwnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	tp->snd_ssthresh = max(tp->snd_cwnd >> 1U, 2U);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) static void dctcp_state(struct sock *sk, u8 new_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	if (new_state == TCP_CA_Recovery &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	    new_state != inet_csk(sk)->icsk_ca_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		dctcp_react_to_loss(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	/* We handle RTO in dctcp_cwnd_event to ensure that we perform only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	 * one loss-adjustment per RTT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) static void dctcp_cwnd_event(struct sock *sk, enum tcp_ca_event ev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	struct dctcp *ca = inet_csk_ca(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	switch (ev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	case CA_EVENT_ECN_IS_CE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	case CA_EVENT_ECN_NO_CE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		dctcp_ece_ack_update(sk, ev, &ca->prior_rcv_nxt, &ca->ce_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	case CA_EVENT_LOSS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		dctcp_react_to_loss(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		/* Don't care for the rest. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) static size_t dctcp_get_info(struct sock *sk, u32 ext, int *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 			     union tcp_cc_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	const struct dctcp *ca = inet_csk_ca(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	const struct tcp_sock *tp = tcp_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	/* Fill it also in case of VEGASINFO due to req struct limits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	 * We can still correctly retrieve it later.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	if (ext & (1 << (INET_DIAG_DCTCPINFO - 1)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	    ext & (1 << (INET_DIAG_VEGASINFO - 1))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		memset(&info->dctcp, 0, sizeof(info->dctcp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		if (inet_csk(sk)->icsk_ca_ops != &dctcp_reno) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 			info->dctcp.dctcp_enabled = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 			info->dctcp.dctcp_ce_state = (u16) ca->ce_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 			info->dctcp.dctcp_alpha = ca->dctcp_alpha;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 			info->dctcp.dctcp_ab_ecn = tp->mss_cache *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 						   (tp->delivered_ce - ca->old_delivered_ce);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 			info->dctcp.dctcp_ab_tot = tp->mss_cache *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 						   (tp->delivered - ca->old_delivered);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 		*attr = INET_DIAG_DCTCPINFO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		return sizeof(info->dctcp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) static u32 dctcp_cwnd_undo(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	const struct dctcp *ca = inet_csk_ca(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	return max(tcp_sk(sk)->snd_cwnd, ca->loss_cwnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) static struct tcp_congestion_ops dctcp __read_mostly = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	.init		= dctcp_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	.in_ack_event   = dctcp_update_alpha,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	.cwnd_event	= dctcp_cwnd_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	.ssthresh	= dctcp_ssthresh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	.cong_avoid	= tcp_reno_cong_avoid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	.undo_cwnd	= dctcp_cwnd_undo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	.set_state	= dctcp_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	.get_info	= dctcp_get_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	.flags		= TCP_CONG_NEEDS_ECN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	.owner		= THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	.name		= "dctcp",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) static struct tcp_congestion_ops dctcp_reno __read_mostly = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	.ssthresh	= tcp_reno_ssthresh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	.cong_avoid	= tcp_reno_cong_avoid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	.undo_cwnd	= tcp_reno_undo_cwnd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	.get_info	= dctcp_get_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	.owner		= THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	.name		= "dctcp-reno",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) static int __init dctcp_register(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	BUILD_BUG_ON(sizeof(struct dctcp) > ICSK_CA_PRIV_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	return tcp_register_congestion_control(&dctcp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) static void __exit dctcp_unregister(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	tcp_unregister_congestion_control(&dctcp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) module_init(dctcp_register);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) module_exit(dctcp_unregister);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) MODULE_AUTHOR("Daniel Borkmann <dborkman@redhat.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) MODULE_AUTHOR("Florian Westphal <fw@strlen.de>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) MODULE_AUTHOR("Glenn Judd <glenn.judd@morganstanley.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) MODULE_LICENSE("GPL v2");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) MODULE_DESCRIPTION("DataCenter TCP (DCTCP)");