Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Jan 2013 00:24:01 +0000 (UTC)
From:      Navdeep Parhar <np@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r245441 - head/sys/dev/cxgbe/tom
Message-ID:  <201301150024.r0F0O1xK090429@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: np
Date: Tue Jan 15 00:24:01 2013
New Revision: 245441
URL: http://svnweb.freebsd.org/changeset/base/245441

Log:
  cxgbe/tom: Miscellaneous updates for TOE+IPv6 support (more to follow).
  
  - Teach find_best_mtu_idx() to deal with IPv6 endpoints.
  
  - Install correct protosw in offloaded TCP/IPv6 sockets when DDP is
    enabled.
  
  - Move set_tcp_ddp_ulp_mode to t4_tom.c so that t4_tom.h can be included
    without having to drag in t4_msg.h too.  This was bothering the iWARP
    driver for some reason.
  
  MFC after:	1 week

Modified:
  head/sys/dev/cxgbe/tom/t4_tom.c
  head/sys/dev/cxgbe/tom/t4_tom.h

Modified: head/sys/dev/cxgbe/tom/t4_tom.c
==============================================================================
--- head/sys/dev/cxgbe/tom/t4_tom.c	Tue Jan 15 00:12:34 2013	(r245440)
+++ head/sys/dev/cxgbe/tom/t4_tom.c	Tue Jan 15 00:24:01 2013	(r245441)
@@ -29,6 +29,7 @@
 __FBSDID("$FreeBSD$");
 
 #include "opt_inet.h"
+#include "opt_inet6.h"
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -43,6 +44,7 @@ __FBSDID("$FreeBSD$");
 #include <netinet/in.h>
 #include <netinet/in_pcb.h>
 #include <netinet/ip.h>
+#include <netinet/ip6.h>
 #include <netinet/tcp_var.h>
 #define TCPSTATES
 #include <netinet/tcp_fsm.h>
@@ -58,6 +60,9 @@ __FBSDID("$FreeBSD$");
 static struct protosw ddp_protosw;
 static struct pr_usrreqs ddp_usrreqs;
 
+static struct protosw ddp6_protosw;
+static struct pr_usrreqs ddp6_usrreqs;
+
 /* Module ops */
 static int t4_tom_mod_load(void);
 static int t4_tom_mod_unload(void);
@@ -170,8 +175,12 @@ offload_socket(struct socket *so, struct
 	sb = &so->so_rcv;
 	SOCKBUF_LOCK(sb);
 	sb->sb_flags |= SB_NOCOALESCE;
-	if (toep->ulp_mode == ULP_MODE_TCPDDP)
-		so->so_proto = &ddp_protosw;
+	if (toep->ulp_mode == ULP_MODE_TCPDDP) {
+		if (inp->inp_vflag & INP_IPV6)
+			so->so_proto = &ddp6_protosw;
+		else
+			so->so_proto = &ddp_protosw;
+	}
 	SOCKBUF_UNLOCK(sb);
 
 	/* Update TCP PCB */
@@ -394,7 +403,7 @@ int
 find_best_mtu_idx(struct adapter *sc, struct in_conninfo *inc, int pmss)
 {
 	unsigned short *mtus = &sc->params.mtus[0];
-	int i = 0, mss;
+	int i, mss, n;
 
 	KASSERT(inc != NULL || pmss > 0,
 	    ("%s: at least one of inc/pmss must be specified", __func__));
@@ -403,8 +412,13 @@ find_best_mtu_idx(struct adapter *sc, st
 	if (pmss > 0 && mss > pmss)
 		mss = pmss;
 
-	while (i < NMTUS - 1 && mtus[i + 1] <= mss + 40)
-		++i;
+	if (inc->inc_flags & INC_ISIPV6)
+		n = sizeof(struct ip6_hdr) + sizeof(struct tcphdr);
+	else
+		n = sizeof(struct ip) + sizeof(struct tcphdr);
+
+	for (i = 0; i < NMTUS - 1 && mtus[i + 1] <= mss + n; i++)
+		continue;
 
 	return (i);
 }
@@ -513,6 +527,15 @@ select_ntuple(struct port_info *pi, stru
 	return (htobe32(ntuple));
 }
 
+void
+set_tcpddp_ulp_mode(struct toepcb *toep)
+{
+
+	toep->ulp_mode = ULP_MODE_TCPDDP;
+	toep->ddp_flags = DDP_OK;
+	toep->ddp_score = DDP_LOW_SCORE;
+}
+
 static int
 alloc_tid_tabs(struct tid_info *t)
 {
@@ -698,17 +721,24 @@ static int
 t4_tom_mod_load(void)
 {
 	int rc;
-	struct protosw *tcp_protosw;
+	struct protosw *tcp_protosw, *tcp6_protosw;
 
 	tcp_protosw = pffindproto(PF_INET, IPPROTO_TCP, SOCK_STREAM);
 	if (tcp_protosw == NULL)
 		return (ENOPROTOOPT);
-
 	bcopy(tcp_protosw, &ddp_protosw, sizeof(ddp_protosw));
 	bcopy(tcp_protosw->pr_usrreqs, &ddp_usrreqs, sizeof(ddp_usrreqs));
 	ddp_usrreqs.pru_soreceive = t4_soreceive_ddp;
 	ddp_protosw.pr_usrreqs = &ddp_usrreqs;
 
+	tcp6_protosw = pffindproto(PF_INET6, IPPROTO_TCP, SOCK_STREAM);
+	if (tcp6_protosw == NULL)
+		return (ENOPROTOOPT);
+	bcopy(tcp6_protosw, &ddp6_protosw, sizeof(ddp6_protosw));
+	bcopy(tcp6_protosw->pr_usrreqs, &ddp6_usrreqs, sizeof(ddp6_usrreqs));
+	ddp6_usrreqs.pru_soreceive = t4_soreceive_ddp;
+	ddp6_protosw.pr_usrreqs = &ddp6_usrreqs;
+
 	rc = t4_register_uld(&tom_uld_info);
 	if (rc != 0)
 		t4_tom_mod_unload();

Modified: head/sys/dev/cxgbe/tom/t4_tom.h
==============================================================================
--- head/sys/dev/cxgbe/tom/t4_tom.h	Tue Jan 15 00:12:34 2013	(r245440)
+++ head/sys/dev/cxgbe/tom/t4_tom.h	Tue Jan 15 00:24:01 2013	(r245441)
@@ -140,15 +140,6 @@ struct flowc_tx_params {
 #define	DDP_LOW_SCORE	1
 #define	DDP_HIGH_SCORE	3
 
-static inline void
-set_tcpddp_ulp_mode(struct toepcb *toep)
-{
-
-	toep->ulp_mode = ULP_MODE_TCPDDP;
-	toep->ddp_flags = DDP_OK;
-	toep->ddp_score = DDP_LOW_SCORE;
-}
-
 /*
  * Compressed state for embryonic connections for a listener.  Barely fits in
  * 64B, try not to grow it further.
@@ -234,6 +225,7 @@ int select_rcv_wscale(void);
 uint64_t calc_opt0(struct socket *, struct port_info *, struct l2t_entry *,
     int, int, int, int);
 uint32_t select_ntuple(struct port_info *, struct l2t_entry *, uint32_t);
+void set_tcpddp_ulp_mode(struct toepcb *);
 
 /* t4_connect.c */
 void t4_init_connect_cpl_handlers(struct adapter *);



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