Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 10 Dec 2007 05:46:54 GMT
From:      Kip Macy <kmacy@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 130585 for review
Message-ID:  <200712100546.lBA5ks6A089494@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=130585

Change 130585 by kmacy@kmacy:storage:toestack on 2007/12/10 05:46:06

	restructure to take advantage of padding
	- remove syncache event handler and toepcb out of 
	  in_conninfo in to syncache entry
	- add extra syncache function to pass values in directly
	- remove padding already accounted for in the tcpcb

Affected files ...

.. //depot/projects/toestack/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c#32 edit
.. //depot/projects/toestack/sys/netinet/in_pcb.h#5 edit
.. //depot/projects/toestack/sys/netinet/tcp_ofld.h#8 edit
.. //depot/projects/toestack/sys/netinet/tcp_syncache.c#11 edit
.. //depot/projects/toestack/sys/netinet/tcp_syncache.h#2 edit
.. //depot/projects/toestack/sys/netinet/tcp_var.h#8 edit

Differences ...

==== //depot/projects/toestack/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c#32 (text+ko) ====

@@ -143,6 +143,8 @@
 static void t3_send_reset(struct socket *so);
 static void send_abort_rpl(struct mbuf *m, struct toedev *tdev, int rst_status);
 static inline void free_atid(struct t3cdev *cdev, unsigned int tid);
+static void handle_syncache_event(int event, void *arg);
+
 
 static inline int
 is_t3a(const struct toedev *dev)
@@ -613,6 +615,8 @@
 	.tu_send = cxgb_toe_send,
 	.tu_rcvd = cxgb_toe_rcvd,
 	.tu_detach = cxgb_toe_detach,
+	.tu_detach = cxgb_toe_detach,
+	.tu_syncache_event = handle_syncache_event,
 };
 
 
@@ -2505,8 +2509,6 @@
 	inc.inc_len = 0;
 	inc.inc_faddr.s_addr = req->peer_ip;
 	inc.inc_laddr.s_addr = req->local_ip;
-	inc.inc_ext = toep;
-	inc.inc_eh = handle_syncache_event;
 
 	DPRINTF("syncache add of %d:%d %d:%d\n",
 	    ntohl(req->local_ip), ntohs(req->local_port),
@@ -2522,7 +2524,7 @@
 
 	INP_INFO_WLOCK(&tcbinfo);
 	INP_LOCK(inp);
-	syncache_add(&inc, &to, &th, inp, &lso, NULL);
+	syncache_offload_add(&inc, &to, &th, inp, &lso, &cxgb_toe_usrreqs, toep);
 }
 
 
@@ -2860,9 +2862,6 @@
 	inc.inc_faddr.s_addr = req->peer_ip;
 	inc.inc_laddr.s_addr = req->local_ip;
 	
-	inc.inc_ext = toep;
-	inc.inc_eh = handle_syncache_event;
-
 	mss  = td->mtus[G_TCPOPT_MSS(opt)] - 40;
 	wsf  = G_TCPOPT_WSCALE_OK(opt);
 	ts   = G_TCPOPT_TSTAMP(opt);

==== //depot/projects/toestack/sys/netinet/in_pcb.h#5 (text+ko) ====

@@ -106,8 +106,6 @@
 	u_int16_t	inc_pad;	/* XXX alignment for in_endpoints */
 	/* protocol dependent part */
 	struct	in_endpoints inc_ie;
-	sc_eh_t		inc_eh;		/* syncache event handler - timeout or already present */
-	void		*inc_ext;	/* external TCP connection state */
 };
 #define inc_isipv6	inc_flags	/* temp compatability */
 #define	inc_fport	inc_ie.ie_fport

==== //depot/projects/toestack/sys/netinet/tcp_ofld.h#8 (text+ko) ====

@@ -156,6 +156,7 @@
 	int (*tu_disconnect)(struct tcpcb *tp);
 	int (*tu_abort)(struct tcpcb *tp);
 	void (*tu_detach)(struct tcpcb *tp);
+	void (*tu_syncache_event)(int event, void *toep);
 
 };
 

==== //depot/projects/toestack/sys/netinet/tcp_syncache.c#11 (text+ko) ====

@@ -78,6 +78,7 @@
 #include <netinet/tcp_timer.h>
 #include <netinet/tcp_var.h>
 #include <netinet/tcp_syncache.h>
+#include <netinet/tcp_ofld.h>
 #ifdef INET6
 #include <netinet6/tcp6_var.h>
 #endif
@@ -136,7 +137,8 @@
 #define SCF_SIGNATURE	0x20			/* send MD5 digests */
 #define SCF_SACK	0x80			/* send SACK option */
 #ifndef DISABLE_TCP_OFFLOAD
-	void		*sc_pspare[2];		/* toepcb / toe_usrreqs */
+	struct toe_usrreqs *sc_tu;		/* TOE operations */
+	void 		*sc_toepcb;		/* TOE protocol block */
 #endif			
 #ifdef MAC
 	struct label	*sc_label;		/* MAC label reference */
@@ -361,8 +363,8 @@
 	sch->sch_length--;
 
 #ifndef DISABLE_TCP_OFFLOAD
-		if (sc->sc_inc.inc_eh && sc->sc_inc.inc_ext)
-			sc->sc_inc.inc_eh(SC_DROP, sc->sc_inc.inc_ext);
+	if (sc->sc_tu)
+		sc->sc_tu->tu_syncache_event(SC_DROP, sc->sc_toepcb);
 #endif		    
 	syncache_free(sc);
 	tcp_syncache.cache_count--;
@@ -880,7 +882,7 @@
 	 * Segment validation:
 	 * ACK must match our initial sequence number + 1 (the SYN|ACK).
 	 */
-	if (th->th_ack != sc->sc_iss + 1 && sc->sc_inc.inc_eh == NULL) {
+	if (th->th_ack != sc->sc_iss + 1 && sc->sc_toepcb == NULL) {
 		if ((s = tcp_log_addrs(inc, th, NULL, NULL)))
 			log(LOG_DEBUG, "%s; %s: ACK %u != ISS+1 %u, segment "
 			    "rejected\n", s, __func__, th->th_ack, sc->sc_iss);
@@ -891,29 +893,13 @@
 	 * number + 1 (the SYN) because we didn't ACK any data that
 	 * may have come with the SYN.
 	 */
-	if (th->th_seq != sc->sc_irs + 1 && sc->sc_inc.inc_eh == NULL) {
+	if (th->th_seq != sc->sc_irs + 1 && sc->sc_toepcb == NULL) {
 		if ((s = tcp_log_addrs(inc, th, NULL, NULL)))
 			log(LOG_DEBUG, "%s; %s: SEQ %u != IRS+1 %u, segment "
 			    "rejected\n", s, __func__, th->th_seq, sc->sc_irs);
 		goto failed;
 	}
-#if 0
-	/*
-	 * If timestamps were present in the SYN and we accepted
-	 * them in our SYN|ACK we require them to be present from
-	 * now on.  And vice versa.
-	 *
-	 * Unfortunately, during testing of 7.0 some users found
-	 * network devices that violate this constraint, so it must
-	 * be disabled.
-	 */
-	if ((sc->sc_flags & SCF_TIMESTAMP) && !(to->to_flags & TOF_TS)) {
-		if ((s = tcp_log_addrs(inc, th, NULL, NULL)))
-			log(LOG_DEBUG, "%s; %s: Timestamp missing, "
-			    "segment rejected\n", s, __func__);
-		goto failed;
-	}
-#endif
+
 	if (!(sc->sc_flags & SCF_TIMESTAMP) && (to->to_flags & TOF_TS)) {
 		if ((s = tcp_log_addrs(inc, th, NULL, NULL)))
 			log(LOG_DEBUG, "%s; %s: Timestamp not expected, "
@@ -924,7 +910,8 @@
 	 * If timestamps were negotiated the reflected timestamp
 	 * must be equal to what we actually sent in the SYN|ACK.
 	 */
-	if ((to->to_flags & TOF_TS) && to->to_tsecr != sc->sc_ts && sc->sc_inc.inc_eh == NULL) {
+	if ((to->to_flags & TOF_TS) && to->to_tsecr != sc->sc_ts &&
+	    sc->sc_toepcb == NULL) {
 		if ((s = tcp_log_addrs(inc, th, NULL, NULL)))
 			log(LOG_DEBUG, "%s; %s: TSECR %u != TS %u, "
 			    "segment rejected\n",
@@ -964,9 +951,10 @@
  * consume all available buffer space if it were ACKed.  By not ACKing
  * the data, we avoid this DoS scenario.
  */
-void
-syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
-    struct inpcb *inp, struct socket **lsop, struct mbuf *m)
+static void
+_syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
+    struct inpcb *inp, struct socket **lsop, struct mbuf *m,
+    struct toe_usrreqs *tu, void *toepcb)
 {
 	struct tcpcb *tp;
 	struct socket *so;
@@ -1045,8 +1033,9 @@
 	SCH_LOCK_ASSERT(sch);
 	if (sc != NULL) {
 #ifndef DISABLE_TCP_OFFLOAD
-		if (sc->sc_inc.inc_eh && sc->sc_inc.inc_ext)
-			sc->sc_inc.inc_eh(SC_ENTRY_PRESENT, sc->sc_inc.inc_ext);
+		if (sc->sc_tu)
+			sc->sc_tu->tu_syncache_event(SC_ENTRY_PRESENT,
+			    sc->sc_toepcb);
 #endif		    
 		tcpstat.tcps_sc_dupsyn++;
 		if (ipopts) {
@@ -1082,7 +1071,7 @@
 			    s, __func__);
 			free(s, M_TCPLOG);
 		}
-		if ((inc->inc_eh == NULL) && syncache_respond(sc) == 0) {
+		if ((sc->sc_toepcb == NULL) && syncache_respond(sc) == 0) {
 			sc->sc_rxmits = 0;
 			syncache_timeout(sc, sch, 1);
 			tcpstat.tcps_sndacks++;
@@ -1115,7 +1104,7 @@
 			}
 		}
 	}
-
+	
 	/*
 	 * Fill in the syncache values.
 	 */
@@ -1131,7 +1120,10 @@
 		sc->sc_ip_tos = ip_tos;
 		sc->sc_ip_ttl = ip_ttl;
 	}
-
+#ifndef DISABLE_TCP_OFFLOAD	
+	sc->sc_tu = tu;
+	sc->sc_toepcb = toepcb;
+#endif
 	sc->sc_irs = th->th_seq;
 	sc->sc_iss = arc4random();
 	sc->sc_flags = 0;
@@ -1223,7 +1215,7 @@
 	/*
 	 * Do a standard 3-way handshake.
 	 */
-	if (inc->inc_ext != NULL || syncache_respond(sc) == 0) {
+	if (sc->sc_toepcb || syncache_respond(sc) == 0) {
 		if (tcp_syncookies && tcp_syncookiesonly && sc != &scs)
 			syncache_free(sc);
 		else if (sc != &scs)
@@ -1404,6 +1396,21 @@
 	return (error);
 }
 
+void
+syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
+    struct inpcb *inp, struct socket **lsop, struct mbuf *m)
+{
+	_syncache_add(inc, to, th, inp, lsop, m, NULL, NULL);
+}
+
+void
+syncache_offload_add(struct in_conninfo *inc, struct tcpopt *to,
+    struct tcphdr *th, struct inpcb *inp, struct socket **lsop,
+    struct toe_usrreqs *tu, void *toepcb)
+{
+	_syncache_add(inc, to, th, inp, lsop, NULL, tu, toepcb);
+}
+
 /*
  * The purpose of SYN cookies is to avoid keeping track of all SYN's we
  * receive and to be able to handle SYN floods from bogus source addresses

==== //depot/projects/toestack/sys/netinet/tcp_syncache.h#2 (text+ko) ====

@@ -40,6 +40,9 @@
 	     struct tcphdr *, struct socket **, struct mbuf *);
 void	 syncache_add(struct in_conninfo *, struct tcpopt *,
 	     struct tcphdr *, struct inpcb *, struct socket **, struct mbuf *);
+void	 syncache_offload_add(struct in_conninfo *, struct tcpopt *,
+             struct tcphdr *, struct inpcb *, struct socket **,
+             struct toe_usrreqs *tu, void *toepcb);
 void	 syncache_chkrst(struct in_conninfo *, struct tcphdr *);
 void	 syncache_badack(struct in_conninfo *);
 int	 syncache_pcbcount(void);

==== //depot/projects/toestack/sys/netinet/tcp_var.h#8 (text+ko) ====

@@ -207,10 +207,10 @@
 	int	t_rttlow;		/* smallest observerved RTT */
 	u_int32_t	rfbuf_ts;	/* recv buffer autoscaling timestamp */
 	int	rfbuf_cnt;		/* recv buffer autoscaling byte count */
-	void	*t_pspare[5];		/* toe usrreqs / toepcb * / congestion algo / vimage / 1 general use */ 
 	struct toe_usrreqs *t_tu;       /* offload operations vector */
 	void *t_toe;
 	char *t_cong_control;		/* congestion control algorithm  name*/
+	void	*t_pspare[2];		/* vimage / 1 general use */ 
 };
 
 #define IN_FASTRECOVERY(tp)	(tp->t_flags & TF_FASTRECOVERY)



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