Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 43e68392 authored by Stephen Hemminger's avatar Stephen Hemminger Committed by David S. Miller
Browse files

[TCP] TCP Yeah: cleanup



Eliminate need for full 6/4/64 divide to compute queue.
Variable maxqueue was really a constant.
Fix indentation.

Signed-off-by: default avatarStephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c5f5877c
Loading
Loading
Loading
Loading
+23 −19
Original line number Original line Diff line number Diff line
@@ -142,8 +142,8 @@ static void tcp_yeah_cong_avoid(struct sock *sk, u32 ack,
		 */
		 */


		if (yeah->cntRTT > 2) {
		if (yeah->cntRTT > 2) {
			u32 rtt;
			u32 rtt, queue;
			u32 queue, maxqueue;
			u64 bw;


			/* We have enough RTT samples, so, using the Vegas
			/* We have enough RTT samples, so, using the Vegas
			 * algorithm, we determine if we should increase or
			 * algorithm, we determine if we should increase or
@@ -158,20 +158,25 @@ static void tcp_yeah_cong_avoid(struct sock *sk, u32 ack,
			 */
			 */
			rtt = yeah->minRTT;
			rtt = yeah->minRTT;


			queue = (u32)div64_64((u64)tp->snd_cwnd * (rtt - yeah->baseRTT), rtt);
			/* Compute excess number of packets above bandwidth

			 * Avoid doing full 64 bit divide.
			maxqueue = TCP_YEAH_ALPHA;
			 */
			bw = tp->snd_cwnd;
			bw *= rtt - yeah->baseRTT;
			do_div(bw, rtt);
			queue = bw;


			if (queue > maxqueue ||
			if (queue > TCP_YEAH_ALPHA ||
			    rtt - yeah->baseRTT > (yeah->baseRTT / TCP_YEAH_PHY)) {
			    rtt - yeah->baseRTT > (yeah->baseRTT / TCP_YEAH_PHY)) {

				if (queue > TCP_YEAH_ALPHA
				if (queue > maxqueue && tp->snd_cwnd > yeah->reno_count) {
				    && tp->snd_cwnd > yeah->reno_count) {
					u32 reduction = min(queue / TCP_YEAH_GAMMA ,
					u32 reduction = min(queue / TCP_YEAH_GAMMA ,
							    tp->snd_cwnd >> TCP_YEAH_EPSILON);
							    tp->snd_cwnd >> TCP_YEAH_EPSILON);


					tp->snd_cwnd -= reduction;
					tp->snd_cwnd -= reduction;


					tp->snd_cwnd = max( tp->snd_cwnd, yeah->reno_count);
					tp->snd_cwnd = max(tp->snd_cwnd,
							   yeah->reno_count);


					tp->snd_ssthresh = tp->snd_cwnd;
					tp->snd_ssthresh = tp->snd_cwnd;
				}
				}
@@ -181,9 +186,8 @@ static void tcp_yeah_cong_avoid(struct sock *sk, u32 ack,
				else
				else
					yeah->reno_count++;
					yeah->reno_count++;


				yeah->doing_reno_now =
				yeah->doing_reno_now = min(yeah->doing_reno_now + 1,
					           min_t( u32, yeah->doing_reno_now + 1 , 0xffffff);
							   0xffffffU);

			} else {
			} else {
				yeah->fast_count++;
				yeah->fast_count++;