Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Mar 2012 18:45:12 GMT
From:      Andre Oppermann <andre@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 207322 for review
Message-ID:  <201203031845.q23IjCKR016086@skunkworks.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@207322?ac=10

Change 207322 by andre@andre_t61 on 2012/03/03 18:44:59

	Make it easier to pass window and lenth information around.

Affected files ...

.. //depot/projects/tcp_new/netinet/tcp_output.c#21 edit

Differences ...

==== //depot/projects/tcp_new/netinet/tcp_output.c#21 (text+ko) ====

@@ -101,6 +101,15 @@
 SYSCTL_INT(_net_inet_tcp, OID_AUTO, sendbuf_max, CTLFLAG_RW,
     &tcp_autosndbuf_max, 0, "Max size of automatic send buffer");
 
+struct tcp_output_state {
+	int duna;
+	int swnd;
+	int cwnd;
+	int dlen;
+	int slen;
+	tcp_win len;
+}
+
 static int	ip_optlen(struct inpcb *inp);
 static int	tcp_retransmit(struct tcpcb *tp, struct socket *so,
 		    struct tcpopt *to, u_char *opt, int *len,
@@ -142,12 +151,12 @@
 tcp_output(struct tcpcb *tp)
 {
 	int flags, error, optlen = 0;
-	tcp_win len;
-	int duna, swnd, cwnd, dlen, slen, inflight, rwin, off;
+	int inflight, rwin, off;
 	int tcp_min_idle = 1;		/* XXXAO */
 	struct inpcb *inp = tp->t_inpcb;
 	struct socket *so = inp->inp_socket;
 	struct tcphdr ths, *th = &ths;
+	struct tcp_output_state d;
 	struct tcpopt to;
 	u_char opt[TCP_MAXOLEN];
 #ifdef TCP_SIGNATURE
@@ -207,12 +216,12 @@
 	 *          snd_una  snd_nxt
 	 *
 	 */
-	duna = SEQ_DELTA(tp->snd_una, tp->snd_nxt);
-	swnd = imax(0, tp->snd_wnd - duna);
-	cwnd = imax(0, tp->snd_cwnd - duna);
-	dlen = so->so_snd.sb_cc - duna;
-	slen = min(dlen, swnd);
-	len = min(slen, cwnd);
+	d.duna = SEQ_DELTA(tp->snd_una, tp->snd_nxt);
+	d.swnd = imax(0, tp->snd_wnd - duna);
+	d.cwnd = imax(0, tp->snd_cwnd - duna);
+	d.dlen = so->so_snd.sb_cc - duna;
+	d.slen = min(dlen, swnd);
+	d.len = min(slen, cwnd);
 
 	/*
 	 * Conservative approximation of data still travelling in the network.
@@ -258,7 +267,7 @@
 		 * Limited transmit. Clamp the amount of data sent 
 		 */
 		if (tp->snd_dupack > 0 && tp->snd_dupack < 3) {
-			len = min(tp->snd_mss, min(slen, len + 2 * tp->snd_mss));
+			d.len = min(tp->snd_mss, min(d.slen, d.len + 2 * tp->snd_mss));
 			tp->t_flags |= TF_ACKNOW;
 		}
 		break;
@@ -275,9 +284,9 @@
 		 * not when the application did a write.
 		 */
 		if (tp->t_flags & TF_SACKPERMIT)
-			error = tcp_retransmit_sack(tp, so, &to, &opt[0], optlen, &len, rwin, duna, dlen, slen, len, flags);
+			error = tcp_retransmit_sack(tp, so, &to, &opt[0], optlen, &d, flags);
 		else
-			error = tcp_retransmit(tp, so, &to, &opt[0], optlen, &len, rwin, dlen, slen, flags);
+			error = tcp_retransmit(tp, so, &to, &opt[0], optlen, &d, flags);
 		if (error)
 			return (error);
 		break;
@@ -290,12 +299,12 @@
 		 *
 		 * XXXAO: Make sure to send ACKs and our window updates anyways.
 		 */
-		if (swnd == 0 && dlen > 0 && (tp->t_flags & TF_FORCEDATA)) {
-			len = 1;
+		if (d.swnd == 0 && d.dlen > 0 && (tp->t_flags & TF_FORCEDATA)) {
+			d.len = 1;
 			goto send;
 		} else
-			len = 0;
-		if (swnd == 0 && duna > tp->snd_wnd) {
+			d.len = 0;
+		if (d.swnd == 0 && d.duna > tp->snd_wnd) {
 			/*
 			 * Window shrank after we sent into it.
 			 * If window shrank to 0,
@@ -321,9 +330,9 @@
 	 * and neither ACKs, window updates, etc. if there
 	 * is no data pending.
 	 */
-	if (len > 0 && (tp->t_flags & TF_PACE)) {
-		len = tcp_snd_pace(tp, len);
-		if (len == 0)
+	if (d.len > 0 && (tp->t_flags & TF_PACE)) {
+		d.len = tcp_snd_pace(tp, len);
+		if (d.len == 0)
 			return (0);		/* next token is pending */
 	}
 
@@ -349,7 +358,7 @@
 		 * if the window is big enough.  Do not care about nagle
 		 * and others.  Otherwise things will go their normal way.
 		 */
-		if (len <= dlen)
+		if (d.len <= d.dlen)
 			goto send;
 	}
 
@@ -372,7 +381,7 @@
 	 */
 	if ((tp->t_flags & TF_DUPACK) && tp->rcv_trqlen > 0) {
 		if (!(tp->t_flags & TF_SACK_PERMIT))
-			len = 0;
+			d.len = 0;
 		goto send;
 	}
 
@@ -426,7 +435,7 @@
 	 *
 	 * XXXAO: mss - options!
 	 */
-	if (len) {
+	if (d.len) {
 		/*
 		 * Always send if there is no outstanding data in flight.
 		 */
@@ -444,14 +453,14 @@
 		/*
 		 * Always send if we have more than one MSS worth of data.
 		 */
-		if (len >= tp->snd_mss)
+		if (d.len >= tp->snd_mss)
 			goto send;
 
 		/*
 		 * For small windows send if we have half a window worth
 		 * of data.
 		 */
-		if (tp->snd_maxwnd > 0 && len >= tp->snd_maxwnd / 2)
+		if (tp->snd_maxwnd > 0 && d.len >= tp->snd_maxwnd / 2)
 			goto send;
 	}
 
@@ -503,7 +512,7 @@
 	 */
 	if (tp->rcv_advwin < rwin && !(tp->t_flags & TF_DELACK) &&
 	    !TCPS_HAVERCVDFIN(tp->t_state))
-		if (rwin >= 2 * tp->rcv_advwin)
+		if (d.rwin >= 2 * tp->rcv_advwin)
 			goto send;
 
 	/*
@@ -533,7 +542,7 @@
 	 * to change if some reincarnation of T/TCP comes up again.
 	 */
 	if (flags & TH_SYN) {
-		len = 0;
+		d.len = 0;
 		flags &= ~TH_FIN;
 	}
 
@@ -563,7 +572,7 @@
 
 	/* Send off the data. */
 	SOCKBUF_LOCK(&so->so_snd);
-	error = tcp_send_segments(tp, &ths, opt, off, &len, optlen);
+	error = tcp_send_segments(tp, &ths, opt, off, &d.len, optlen);
 	SOCKBUF_UNLOCK(&so->so_snd);
 
 	/*
@@ -574,14 +583,14 @@
 	 *
 	 * XXXAO: Avoid unconditional writes to the tcpcb.
 	 */
-	if (len > 0) {
+	if (d.len > 0) {
 		/*
 		 * Advance snd_nxt over sequence space of this segment.
 		 */
 		if (tp->snd_rxmit == tp->snd_nxt)
-			tp->snd_nxt += len;
+			tp->snd_nxt += d.len;
 		else
-			tp->snd_rxmit += len;
+			tp->snd_rxmit += d.len;
 	}
 
 	if (error == 0) {
@@ -594,7 +603,7 @@
 		}
 	}
 
-	if (len > 0 || error == 0) {
+	if (d.len > 0 || error == 0) {
 		/*
 		 * Integrate SYN into sequence space.
 		 */
@@ -648,7 +657,7 @@
 			tp->t_flags &= ~TF_RXWIN0SENT;
 	}
 
-	if (len > 0 && error == 0) {
+	if (d.len > 0 && error == 0) {
 		if ((tp->t_flags & TF_FORCEDATA) == 0 || 
 		    !tcp_timer_active(tp, TT_PERSIST))
 
@@ -765,14 +774,14 @@
 	 *
 	 * XXXAO: Account for TSO.
 	 */
-	if ((tp->t_flags & TF_FORCEDATA) && len == 1) {
+	if ((tp->t_flags & TF_FORCEDATA) && d.len == 1) {
 		tcpstat.tcps_sndprobe++;
 	//} else if (SEQ_LT(tp->snd_nxt, tp->snd_max)) {
 	//	tcpstat.tcps_sndrexmitpack++;
 	//	tcpstat.tcps_sndrexmitbyte += len;
 	} else {
 		tcpstat.tcps_sndpack++;
-		tcpstat.tcps_sndbyte += len;
+		tcpstat.tcps_sndbyte += d.len;
 	}
 	tcpstat.tcps_sndtotal++;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201203031845.q23IjCKR016086>