svn commit: r239594 - in user/np/stable_9_toe: sbin/ifconfig sys/amd64/conf sys/conf sys/contrib/rdma sys/contrib/rdma/krping sys/dev/cxgb/ulp/tom sys/dev/cxgbe sys/dev/cxgbe/common sys/dev/cxgbe/f...

Navdeep Parhar np at FreeBSD.org
Wed Aug 22 21:15:00 UTC 2012


Author: np
Date: Wed Aug 22 21:14:59 2012
New Revision: 239594
URL: http://svn.freebsd.org/changeset/base/239594

Log:
  Fully up-to-date backport/MFC of TOE to stable/9.  I'll promptly push any
  fixes that I make to HEAD to this workspace too.

Added:
  user/np/stable_9_toe/sys/dev/cxgbe/tom/t4_ddp.c
     - copied, changed from r239344, head/sys/dev/cxgbe/tom/t4_ddp.c
  user/np/stable_9_toe/sys/modules/toecore/
     - copied from r237263, head/sys/modules/toecore/
  user/np/stable_9_toe/sys/netinet/toecore.c
     - copied, changed from r237263, head/sys/netinet/toecore.c
  user/np/stable_9_toe/sys/netinet/toecore.h
     - copied, changed from r237263, head/sys/netinet/toecore.h
Deleted:
  user/np/stable_9_toe/sys/netinet/toedev.h
Modified:
  user/np/stable_9_toe/sbin/ifconfig/ifconfig.c
  user/np/stable_9_toe/sys/amd64/conf/GENERIC
  user/np/stable_9_toe/sys/conf/NOTES
  user/np/stable_9_toe/sys/conf/files
  user/np/stable_9_toe/sys/conf/options
  user/np/stable_9_toe/sys/contrib/rdma/krping/krping.c
  user/np/stable_9_toe/sys/contrib/rdma/krping/krping.h
  user/np/stable_9_toe/sys/contrib/rdma/krping/krping_dev.c
  user/np/stable_9_toe/sys/contrib/rdma/rdma_addr.c
  user/np/stable_9_toe/sys/contrib/rdma/rdma_cache.c
  user/np/stable_9_toe/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c
  user/np/stable_9_toe/sys/dev/cxgb/ulp/tom/cxgb_listen.c
  user/np/stable_9_toe/sys/dev/cxgb/ulp/tom/cxgb_toepcb.h
  user/np/stable_9_toe/sys/dev/cxgbe/adapter.h
  user/np/stable_9_toe/sys/dev/cxgbe/common/t4_hw.h
  user/np/stable_9_toe/sys/dev/cxgbe/common/t4_msg.h
  user/np/stable_9_toe/sys/dev/cxgbe/firmware/t4fw_cfg.txt
  user/np/stable_9_toe/sys/dev/cxgbe/offload.h
  user/np/stable_9_toe/sys/dev/cxgbe/t4_main.c
  user/np/stable_9_toe/sys/dev/cxgbe/t4_sge.c
  user/np/stable_9_toe/sys/dev/cxgbe/tom/t4_connect.c
  user/np/stable_9_toe/sys/dev/cxgbe/tom/t4_cpl_io.c
  user/np/stable_9_toe/sys/dev/cxgbe/tom/t4_listen.c
  user/np/stable_9_toe/sys/dev/cxgbe/tom/t4_tom.c
  user/np/stable_9_toe/sys/dev/cxgbe/tom/t4_tom.h
  user/np/stable_9_toe/sys/i386/conf/GENERIC
  user/np/stable_9_toe/sys/i386/conf/XEN
  user/np/stable_9_toe/sys/modules/Makefile
  user/np/stable_9_toe/sys/modules/cxgb/Makefile
  user/np/stable_9_toe/sys/modules/cxgbe/Makefile
  user/np/stable_9_toe/sys/modules/cxgbe/tom/Makefile
  user/np/stable_9_toe/sys/modules/rdma/krping/Makefile
  user/np/stable_9_toe/sys/net/if_var.h
  user/np/stable_9_toe/sys/net/if_vlan.c
  user/np/stable_9_toe/sys/netinet/if_ether.c
  user/np/stable_9_toe/sys/netinet/if_ether.h
  user/np/stable_9_toe/sys/netinet/in.c
  user/np/stable_9_toe/sys/netinet/tcp_input.c
  user/np/stable_9_toe/sys/netinet/tcp_offload.c
  user/np/stable_9_toe/sys/netinet/tcp_offload.h
  user/np/stable_9_toe/sys/netinet/tcp_output.c
  user/np/stable_9_toe/sys/netinet/tcp_subr.c
  user/np/stable_9_toe/sys/netinet/tcp_syncache.c
  user/np/stable_9_toe/sys/netinet/tcp_syncache.h
  user/np/stable_9_toe/sys/netinet/tcp_timer.c
  user/np/stable_9_toe/sys/netinet/tcp_usrreq.c
  user/np/stable_9_toe/sys/netinet/tcp_var.h
  user/np/stable_9_toe/sys/ofed/drivers/infiniband/core/cma.c
  user/np/stable_9_toe/sys/ofed/drivers/infiniband/core/iwcm.c
  user/np/stable_9_toe/sys/ofed/include/linux/net.h
  user/np/stable_9_toe/sys/ofed/include/net/netevent.h
  user/np/stable_9_toe/sys/ofed/include/rdma/iw_cm.h
  user/np/stable_9_toe/usr.bin/netstat/inet.c
  user/np/stable_9_toe/usr.bin/sockstat/sockstat.c
Directory Properties:
  user/np/stable_9_toe/sbin/ifconfig/   (props changed)
  user/np/stable_9_toe/sys/   (props changed)
  user/np/stable_9_toe/sys/conf/   (props changed)
  user/np/stable_9_toe/sys/dev/   (props changed)
  user/np/stable_9_toe/sys/modules/   (props changed)
  user/np/stable_9_toe/usr.bin/netstat/   (props changed)
  user/np/stable_9_toe/usr.bin/sockstat/   (props changed)

Modified: user/np/stable_9_toe/sbin/ifconfig/ifconfig.c
==============================================================================
--- user/np/stable_9_toe/sbin/ifconfig/ifconfig.c	Wed Aug 22 20:56:53 2012	(r239593)
+++ user/np/stable_9_toe/sbin/ifconfig/ifconfig.c	Wed Aug 22 21:14:59 2012	(r239594)
@@ -910,7 +910,7 @@ unsetifdescr(const char *val, int value,
 #define	IFCAPBITS \
 "\020\1RXCSUM\2TXCSUM\3NETCONS\4VLAN_MTU\5VLAN_HWTAGGING\6JUMBO_MTU\7POLLING" \
 "\10VLAN_HWCSUM\11TSO4\12TSO6\13LRO\14WOL_UCAST\15WOL_MCAST\16WOL_MAGIC" \
-"\21VLAN_HWFILTER\23VLAN_HWTSO\24LINKSTATE\25NETMAP" \
+"\17TOE4\20TOE6\21VLAN_HWFILTER\23VLAN_HWTSO\24LINKSTATE\25NETMAP" \
 "\26RXCSUM_IPV6\27TXCSUM_IPV6"
 
 /*
@@ -1189,6 +1189,8 @@ static struct cmd basic_cmds[] = {
 	DEF_CMD("-tso4",	-IFCAP_TSO4,	setifcap),
 	DEF_CMD("tso",		IFCAP_TSO,	setifcap),
 	DEF_CMD("-tso",		-IFCAP_TSO,	setifcap),
+	DEF_CMD("toe",		IFCAP_TOE,	setifcap),
+	DEF_CMD("-toe",		-IFCAP_TOE,	setifcap),
 	DEF_CMD("lro",		IFCAP_LRO,	setifcap),
 	DEF_CMD("-lro",		-IFCAP_LRO,	setifcap),
 	DEF_CMD("wol",		IFCAP_WOL,	setifcap),

Modified: user/np/stable_9_toe/sys/amd64/conf/GENERIC
==============================================================================
--- user/np/stable_9_toe/sys/amd64/conf/GENERIC	Wed Aug 22 20:56:53 2012	(r239593)
+++ user/np/stable_9_toe/sys/amd64/conf/GENERIC	Wed Aug 22 21:14:59 2012	(r239594)
@@ -27,6 +27,7 @@ options 	SCHED_ULE		# ULE scheduler
 options 	PREEMPTION		# Enable kernel thread preemption
 options 	INET			# InterNETworking
 options 	INET6			# IPv6 communications protocols
+options 	TCP_OFFLOAD		# TCP offload
 options 	SCTP			# Stream Control Transmission Protocol
 options 	FFS			# Berkeley Fast Filesystem
 options 	SOFTUPDATES		# Enable FFS soft updates support

Modified: user/np/stable_9_toe/sys/conf/NOTES
==============================================================================
--- user/np/stable_9_toe/sys/conf/NOTES	Wed Aug 22 20:56:53 2012	(r239593)
+++ user/np/stable_9_toe/sys/conf/NOTES	Wed Aug 22 21:14:59 2012	(r239594)
@@ -545,6 +545,8 @@ options 	INET6			#IPv6 communications pr
 
 options 	ROUTETABLES=2		# max 16. 1 is back compatible.
 
+options 	TCP_OFFLOAD		# TCP offload support.
+
 # In order to enable IPSEC you MUST also add device crypto to 
 # your kernel configuration
 options 	IPSEC			#IP security (requires device crypto)

Modified: user/np/stable_9_toe/sys/conf/files
==============================================================================
--- user/np/stable_9_toe/sys/conf/files	Wed Aug 22 20:56:53 2012	(r239593)
+++ user/np/stable_9_toe/sys/conf/files	Wed Aug 22 21:14:59 2012	(r239594)
@@ -2855,7 +2855,7 @@ netinet/tcp_hostcache.c		optional inet |
 netinet/tcp_input.c		optional inet | inet6
 netinet/tcp_lro.c		optional inet | inet6
 netinet/tcp_output.c		optional inet | inet6
-netinet/tcp_offload.c		optional inet | inet6
+netinet/tcp_offload.c		optional tcp_offload inet | tcp_offload inet6
 netinet/tcp_reass.c		optional inet | inet6
 netinet/tcp_sack.c		optional inet | inet6
 netinet/tcp_subr.c		optional inet | inet6

Modified: user/np/stable_9_toe/sys/conf/options
==============================================================================
--- user/np/stable_9_toe/sys/conf/options	Wed Aug 22 20:56:53 2012	(r239593)
+++ user/np/stable_9_toe/sys/conf/options	Wed Aug 22 21:14:59 2012	(r239594)
@@ -430,7 +430,7 @@ RADIX_MPATH		opt_mpath.h
 ROUTETABLES		opt_route.h
 SLIP_IFF_OPTS		opt_slip.h
 TCPDEBUG
-TCP_OFFLOAD_DISABLE	opt_inet.h #Disable code to dispatch tcp offloading
+TCP_OFFLOAD		opt_inet.h # Enable code to dispatch TCP offloading
 TCP_SIGNATURE		opt_inet.h
 VLAN_ARRAY		opt_vlan.h
 XBONEHACK

Modified: user/np/stable_9_toe/sys/contrib/rdma/krping/krping.c
==============================================================================
--- user/np/stable_9_toe/sys/contrib/rdma/krping/krping.c	Wed Aug 22 20:56:53 2012	(r239593)
+++ user/np/stable_9_toe/sys/contrib/rdma/krping/krping.c	Wed Aug 22 21:14:59 2012	(r239594)
@@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/socket.h>
-#include <sys/module.h>
 #include <sys/endian.h>
 #include <sys/limits.h>
 #include <sys/proc.h>
@@ -53,11 +52,13 @@ __FBSDID("$FreeBSD$");
 #include <sys/queue.h>
 #include <sys/taskqueue.h>
 #include <sys/syslog.h>
+#include <netinet/in.h>
 
 #include <vm/vm.h>
 #include <vm/pmap.h>
 
-#include <contrib/rdma/rdma_cm.h>
+#include <linux/types.h>
+#include <rdma/rdma_cm.h>
 
 #include "getopt.h"
 #include "krping.h"
@@ -83,6 +84,7 @@ static const struct krping_option krping
 	{"bw", OPT_NOPARAM, 'B'},
 	{"tx-depth", OPT_INT, 't'},
   	{"poll", OPT_NOPARAM, 'P'},
+  	{"memlimit", OPT_INT, 'm'},
 	{NULL, 0, 0}
 };
 
@@ -254,10 +256,14 @@ static void krping_cq_event_handler(stru
 		ib_req_notify_cq(cb->cq, IB_CQ_NEXT_COMP);
 	while ((ret = ib_poll_cq(cb->cq, 1, &wc)) == 1) {
 		if (wc.status) {
-			if (wc.status != IB_WC_WR_FLUSH_ERR)
-				log(LOG_ERR, "cq completion failed status %d\n",
+			if (wc.status == IB_WC_WR_FLUSH_ERR) {
+				DEBUG_LOG("cq flushed\n");
+				continue;
+			} else {
+				log(LOG_CRIT, "cq completion failed status %d\n",
 					wc.status);
-			goto error;
+				goto error;
+			}
 		}
 
 		switch (wc.opcode) {
@@ -432,8 +438,17 @@ static int krping_setup_buffers(struct k
 		}
 	}
 
-	cb->rdma_buf = contigmalloc(cb->size, M_DEVBUF, M_WAITOK, 0, -1UL,
-		PAGE_SIZE, 0);
+	/* RNIC adapters have a limit upto which it can register physical memory
+	 * If DMA-MR memory mode is set then normally driver registers maximum
+	 * supported memory. After that if contigmalloc allocates memory beyond the
+	 * specified RNIC limit then Krping may not work.
+	 */
+	if (cb->use_dmamr && cb->memlimit)
+		cb->rdma_buf = contigmalloc(cb->size, M_DEVBUF, M_WAITOK, 0, cb->memlimit,
+					    PAGE_SIZE, 0);
+	else 
+		cb->rdma_buf = contigmalloc(cb->size, M_DEVBUF, M_WAITOK, 0, -1UL,
+					    PAGE_SIZE, 0);
 
 	if (!cb->rdma_buf) {
 		log(LOG_ERR, "rdma_buf malloc failed\n");
@@ -458,8 +473,12 @@ static int krping_setup_buffers(struct k
 	}
 
 	if (!cb->server || cb->wlat || cb->rlat || cb->bw) {
-		cb->start_buf = contigmalloc(cb->size, M_DEVBUF, M_WAITOK,
-			0, -1UL, PAGE_SIZE, 0);
+		if (cb->use_dmamr && cb->memlimit)
+			cb->start_buf = contigmalloc(cb->size, M_DEVBUF, M_WAITOK,
+						     0, cb->memlimit, PAGE_SIZE, 0);
+		else
+			cb->start_buf = contigmalloc(cb->size, M_DEVBUF, M_WAITOK,
+						     0, -1UL, PAGE_SIZE, 0);
 		if (!cb->start_buf) {
 			log(LOG_ERR, "start_buf malloc failed\n");
 			ret = ENOMEM;
@@ -1636,6 +1655,8 @@ int krping_doit(char *cmd)
 	cb->state = IDLE;
 	cb->size = 64;
 	cb->txdepth = RPING_SQ_DEPTH;
+	cb->use_dmamr = 1;
+	cb->memlimit = 0;
 	mtx_init(&cb->lock, "krping mtx", NULL, MTX_DUPOK|MTX_DEF);
 
 	while ((op = krping_getopt("krping", &cmd, krping_opts, NULL, &optarg,
@@ -1713,6 +1734,15 @@ int krping_doit(char *cmd)
 		case 'd':
 			debug++;
 			break;
+		case 'm':
+                        cb->memlimit = optint;
+                        if (cb->memlimit < 1) {
+                                log(LOG_ERR, "Invalid memory limit %ju\n",
+				    cb->memlimit);
+                                ret = EINVAL;
+                        } else
+                                DEBUG_LOG(PFX "memory limit %d\n", (int)optint);
+                        break;
 		default:
 			log(LOG_ERR, "unknown opt %s\n", optarg);
 			ret = EINVAL;

Modified: user/np/stable_9_toe/sys/contrib/rdma/krping/krping.h
==============================================================================
--- user/np/stable_9_toe/sys/contrib/rdma/krping/krping.h	Wed Aug 22 20:56:53 2012	(r239593)
+++ user/np/stable_9_toe/sys/contrib/rdma/krping/krping.h	Wed Aug 22 21:14:59 2012	(r239594)
@@ -1,7 +1,7 @@
 /*
  * $FreeBSD$
  */
-#include <contrib/rdma/ib_verbs.h>
+#include <rdma/ib_verbs.h>
 #include <netinet/in.h>
 
 /*
@@ -92,6 +92,8 @@ struct krping_cb {
 	int count;			/* ping count */
 	int size;			/* ping data size */
 	int validate;			/* validate ping data */
+	uint64_t memlimit;		/* limit of the physical memory that
+					   can be registered with dma_mr mode */
 
 	/* CM stuff */
 	struct rdma_cm_id *cm_id;	/* connection on client side,*/

Modified: user/np/stable_9_toe/sys/contrib/rdma/krping/krping_dev.c
==============================================================================
--- user/np/stable_9_toe/sys/contrib/rdma/krping/krping_dev.c	Wed Aug 22 20:56:53 2012	(r239593)
+++ user/np/stable_9_toe/sys/contrib/rdma/krping/krping_dev.c	Wed Aug 22 21:14:59 2012	(r239594)
@@ -14,7 +14,6 @@
 __FBSDID("$FreeBSD$");
 
 #include <sys/types.h>
-#include <sys/module.h>
 #include <sys/systm.h>  /* uprintf */
 #include <sys/errno.h>
 #include <sys/param.h>  /* defines used in kernel.h */
@@ -51,6 +50,9 @@ typedef struct s_krping {
 /* vars */
 static struct cdev *krping_dev;
 
+#undef MODULE_VERSION
+#include <sys/module.h>
+
 static int
 krping_loader(struct module *m, int what, void *arg)
 {
@@ -175,6 +177,4 @@ krping_write(struct cdev *dev, struct ui
 	return(err);
 }
 
-MODULE_DEPEND(krping, rdma_core, 1, 1, 1);
-MODULE_DEPEND(krping, rdma_cma, 1, 1, 1);
 DEV_MODULE(krping,krping_loader,NULL);

Modified: user/np/stable_9_toe/sys/contrib/rdma/rdma_addr.c
==============================================================================
--- user/np/stable_9_toe/sys/contrib/rdma/rdma_addr.c	Wed Aug 22 20:56:53 2012	(r239593)
+++ user/np/stable_9_toe/sys/contrib/rdma/rdma_addr.c	Wed Aug 22 21:14:59 2012	(r239594)
@@ -117,7 +117,8 @@ int rdma_copy_addr(struct rdma_dev_addr 
 		     const unsigned char *dst_dev_addr)
 {
 	dev_addr->dev_type = RDMA_NODE_RNIC;
-	memcpy(dev_addr->src_dev_addr, IF_LLADDR(dev), MAX_ADDR_LEN);
+	memset(dev_addr->src_dev_addr, 0, MAX_ADDR_LEN);
+	memcpy(dev_addr->src_dev_addr, IF_LLADDR(dev), dev->if_addrlen);
 	memcpy(dev_addr->broadcast, dev->if_broadcastaddr, MAX_ADDR_LEN);
 	if (dst_dev_addr)
 		memcpy(dev_addr->dst_dev_addr, dst_dev_addr, MAX_ADDR_LEN);
@@ -207,7 +208,7 @@ static int addr_resolve_remote(struct so
 		goto put;
 	}
  	ret = arpresolve(iproute.ro_rt->rt_ifp, iproute.ro_rt, NULL, 
-		rt_key(iproute.ro_rt), dmac, &lle);
+		(struct sockaddr *)dst_in, dmac, &lle);
 	if (ret) {
 		goto put;
 	}

Modified: user/np/stable_9_toe/sys/contrib/rdma/rdma_cache.c
==============================================================================
--- user/np/stable_9_toe/sys/contrib/rdma/rdma_cache.c	Wed Aug 22 20:56:53 2012	(r239593)
+++ user/np/stable_9_toe/sys/contrib/rdma/rdma_cache.c	Wed Aug 22 21:14:59 2012	(r239594)
@@ -132,7 +132,7 @@ int ib_find_cached_gid(struct ib_device 
 	for (p = 0; p <= end_port(device) - start_port(device); ++p) {
 		cache = device->cache.gid_cache[p];
 		for (i = 0; i < cache->table_len; ++i) {
-			if (!memcmp(gid, &cache->table[i], 6)) { /* XXX */
+			if (!memcmp(gid, &cache->table[i], sizeof *gid)) {
 				*port_num = p + start_port(device);
 				if (index)
 					*index = i;

Modified: user/np/stable_9_toe/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c
==============================================================================
--- user/np/stable_9_toe/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c	Wed Aug 22 20:56:53 2012	(r239593)
+++ user/np/stable_9_toe/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c	Wed Aug 22 21:14:59 2012	(r239594)
@@ -880,10 +880,10 @@ act_open_rpl_status_to_errno(int status)
 	case CPL_ERR_CONN_TIMEDOUT:
 		return (ETIMEDOUT);
 	case CPL_ERR_TCAM_FULL:
-		return (ENOMEM);
+		return (EAGAIN);
 	case CPL_ERR_CONN_EXIST:
 		log(LOG_ERR, "ACTIVE_OPEN_RPL: 4-tuple in use\n");
-		return (EADDRINUSE);
+		return (EAGAIN);
 	default:
 		return (EIO);
 	}
@@ -912,8 +912,7 @@ do_act_open_rpl(struct sge_qset *qs, str
 	unsigned int atid = G_TID(ntohl(rpl->atid));
 	struct toepcb *toep = lookup_atid(&td->tid_maps, atid);
 	struct inpcb *inp = toep->tp_inp;
-	struct tcpcb *tp = intotcpcb(inp);
-	int s = rpl->status;
+	int s = rpl->status, rc;
 
 	CTR3(KTR_CXGB, "%s: atid %u, status %u ", __func__, atid, s);
 
@@ -923,17 +922,14 @@ do_act_open_rpl(struct sge_qset *qs, str
 	if (act_open_has_tid(s))
 		queue_tid_release(tod, GET_TID(rpl));
 
-	if (s == CPL_ERR_TCAM_FULL || s == CPL_ERR_CONN_EXIST) {
-		INP_WLOCK(inp);
-		toe_connect_failed(tod, tp, EAGAIN);
-		toepcb_release(toep);	/* unlocks inp */
-	} else {
+	rc = act_open_rpl_status_to_errno(s);
+	if (rc != EAGAIN)
 		INP_INFO_WLOCK(&V_tcbinfo);
-		INP_WLOCK(inp);
-		toe_connect_failed(tod, tp, act_open_rpl_status_to_errno(s));
-		toepcb_release(toep);	/* unlocks inp */
+	INP_WLOCK(inp);
+	toe_connect_failed(tod, inp, rc);
+	toepcb_release(toep);	/* unlocks inp */
+	if (rc != EAGAIN)
 		INP_INFO_WUNLOCK(&V_tcbinfo);
-	}
 
 	m_freem(m);
 	return (0);

Modified: user/np/stable_9_toe/sys/dev/cxgb/ulp/tom/cxgb_listen.c
==============================================================================
--- user/np/stable_9_toe/sys/dev/cxgb/ulp/tom/cxgb_listen.c	Wed Aug 22 20:56:53 2012	(r239593)
+++ user/np/stable_9_toe/sys/dev/cxgb/ulp/tom/cxgb_listen.c	Wed Aug 22 21:14:59 2012	(r239594)
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
 #include <netinet/ip.h>
 #include <netinet/in_pcb.h>
 #include <netinet/in_var.h>
+#include <netinet/tcp_timer.h>
 #include <netinet/tcp_var.h>
 #define TCPSTATES
 #include <netinet/tcp_fsm.h>
@@ -759,6 +760,15 @@ reset:
 		goto reset;
 	}
 
+	if (__predict_false(!(synqe->flags & TP_SYNQE_EXPANDED))) {
+		struct inpcb *new_inp = sotoinpcb(so);
+
+		INP_WLOCK(new_inp);
+		tcp_timer_activate(intotcpcb(new_inp), TT_KEEP, 0);
+		t3_offload_socket(tod, synqe, so);
+		INP_WUNLOCK(new_inp);
+	}
+
 	/* Remove the synq entry and release its reference on the lctx */
 	TAILQ_REMOVE(&lctx->synq, synqe, link);
 	inp = release_lctx(td, lctx);
@@ -1136,5 +1146,6 @@ t3_offload_socket(struct toedev *tod, vo
 	offload_socket(so, toep);
 	make_established(so, cpl->snd_isn, cpl->rcv_isn, cpl->tcp_opt);
 	update_tid(td, toep, synqe->tid);
+	synqe->flags |= TP_SYNQE_EXPANDED;
 }
 #endif

Modified: user/np/stable_9_toe/sys/dev/cxgb/ulp/tom/cxgb_toepcb.h
==============================================================================
--- user/np/stable_9_toe/sys/dev/cxgb/ulp/tom/cxgb_toepcb.h	Wed Aug 22 20:56:53 2012	(r239593)
+++ user/np/stable_9_toe/sys/dev/cxgb/ulp/tom/cxgb_toepcb.h	Wed Aug 22 21:14:59 2012	(r239594)
@@ -44,6 +44,7 @@
 #define TP_IS_A_SYNQ_ENTRY	(1 << 9)
 #define TP_ABORT_RPL_SENT	(1 << 10)
 #define TP_SEND_FIN          	(1 << 11)
+#define TP_SYNQE_EXPANDED	(1 << 12)
 
 struct toepcb {
 	TAILQ_ENTRY(toepcb) link; /* toep_list */

Modified: user/np/stable_9_toe/sys/dev/cxgbe/adapter.h
==============================================================================
--- user/np/stable_9_toe/sys/dev/cxgbe/adapter.h	Wed Aug 22 20:56:53 2012	(r239593)
+++ user/np/stable_9_toe/sys/dev/cxgbe/adapter.h	Wed Aug 22 21:14:59 2012	(r239594)
@@ -135,6 +135,7 @@ enum {
 #else
 	FL_BUF_SIZES = 3,	/* cluster, jumbo9k, jumbo16k */
 #endif
+	OFLD_BUF_SIZE = MJUM16BYTES,	/* size of fl buffer for TOE rxq */
 
 	CTRL_EQ_QSIZE = 128,
 
@@ -143,6 +144,12 @@ enum {
 	TX_WR_FLITS = SGE_MAX_WR_LEN / 8
 };
 
+#ifdef T4_PKT_TIMESTAMP
+#define RX_COPY_THRESHOLD (MINCLSIZE - 8)
+#else
+#define RX_COPY_THRESHOLD MINCLSIZE
+#endif
+
 enum {
 	/* adapter intr_type */
 	INTR_INTX	= (1 << 0),
@@ -510,6 +517,7 @@ struct rss_header;
 typedef int (*cpl_handler_t)(struct sge_iq *, const struct rss_header *,
     struct mbuf *);
 typedef int (*an_handler_t)(struct sge_iq *, const struct rsp_ctrl *);
+typedef int (*fw_msg_handler_t)(struct adapter *, const __be64 *);
 
 struct adapter {
 	SLIST_ENTRY(adapter) link;
@@ -582,7 +590,8 @@ struct adapter {
 	struct callout sfl_callout;
 
 	an_handler_t an_handler __aligned(CACHE_LINE_SIZE);
-	cpl_handler_t cpl_handler[256];
+	fw_msg_handler_t fw_msg_handler[4];	/* NUM_FW6_TYPES */
+	cpl_handler_t cpl_handler[0xef];	/* NUM_CPL_CMDS */
 };
 
 #define ADAPTER_LOCK(sc)		mtx_lock(&(sc)->sc_lock)
@@ -741,6 +750,8 @@ void t4_os_link_changed(struct adapter *
 void t4_iterate(void (*)(struct adapter *, void *), void *);
 int t4_register_cpl_handler(struct adapter *, int, cpl_handler_t);
 int t4_register_an_handler(struct adapter *, an_handler_t);
+int t4_register_fw_msg_handler(struct adapter *, int, fw_msg_handler_t);
+int t4_filter_rpl(struct sge_iq *, const struct rss_header *, struct mbuf *);
 
 /* t4_sge.c */
 void t4_sge_modload(void);

Modified: user/np/stable_9_toe/sys/dev/cxgbe/common/t4_hw.h
==============================================================================
--- user/np/stable_9_toe/sys/dev/cxgbe/common/t4_hw.h	Wed Aug 22 20:56:53 2012	(r239593)
+++ user/np/stable_9_toe/sys/dev/cxgbe/common/t4_hw.h	Wed Aug 22 21:14:59 2012	(r239594)
@@ -161,10 +161,12 @@ struct pagepod {
 #define S_PPOD_TAG    6
 #define M_PPOD_TAG    0xFFFFFF
 #define V_PPOD_TAG(x) ((x) << S_PPOD_TAG)
+#define G_PPOD_TAG(x) (((x) >> S_PPOD_TAG) & M_PPOD_TAG)
 
 #define S_PPOD_PGSZ    30
 #define M_PPOD_PGSZ    0x3
 #define V_PPOD_PGSZ(x) ((x) << S_PPOD_PGSZ)
+#define G_PPOD_PGSZ(x) (((x) >> S_PPOD_PGSZ) & M_PPOD_PGSZ)
 
 #define S_PPOD_TID    32
 #define M_PPOD_TID    0xFFFFFF

Modified: user/np/stable_9_toe/sys/dev/cxgbe/common/t4_msg.h
==============================================================================
--- user/np/stable_9_toe/sys/dev/cxgbe/common/t4_msg.h	Wed Aug 22 20:56:53 2012	(r239593)
+++ user/np/stable_9_toe/sys/dev/cxgbe/common/t4_msg.h	Wed Aug 22 21:14:59 2012	(r239594)
@@ -792,6 +792,14 @@ struct cpl_set_tcb_field {
 	__be64 val;
 };
 
+struct cpl_set_tcb_field_core {
+	union opcode_tid ot;
+	__be16 reply_ctrl;
+	__be16 word_cookie;
+	__be64 mask;
+	__be64 val;
+};
+
 /* cpl_set_tcb_field.word_cookie fields */
 #define S_WORD    0
 #define M_WORD    0x1F
@@ -1376,6 +1384,11 @@ struct cpl_rx_data_ack {
 	__be32 credit_dack;
 };
 
+struct cpl_rx_data_ack_core {
+	union opcode_tid ot;
+	__be32 credit_dack;
+};
+
 /* cpl_rx_data_ack.ack_seq fields */
 #define S_RX_CREDITS    0
 #define M_RX_CREDITS    0x3FFFFFF
@@ -2281,6 +2294,8 @@ enum {
 	FW6_TYPE_WR_RPL = 1,
 	FW6_TYPE_CQE = 2,
 	FW6_TYPE_OFLD_CONNECTION_WR_RPL = 3,
+
+	NUM_FW6_TYPES
 };
 
 struct cpl_fw6_msg_ofld_connection_wr_rpl {

Modified: user/np/stable_9_toe/sys/dev/cxgbe/firmware/t4fw_cfg.txt
==============================================================================
--- user/np/stable_9_toe/sys/dev/cxgbe/firmware/t4fw_cfg.txt	Wed Aug 22 20:56:53 2012	(r239593)
+++ user/np/stable_9_toe/sys/dev/cxgbe/firmware/t4fw_cfg.txt	Wed Aug 22 21:14:59 2012	(r239594)
@@ -20,7 +20,7 @@
 	filterMode = fragmentation, mpshittype, protocol, vlan, port, fcoe
 
 	# TP rx and tx payload memory (% of the total EDRAM + DDR3).
-	tp_pmrx = 40
+	tp_pmrx = 38
 	tp_pmtx = 60
 	tp_pmrx_pagesize = 64K
 	tp_pmtx_pagesize = 64K
@@ -67,7 +67,8 @@
 	# driver will mask off features it won't use
 	protocol = ofld
 
-	tp_l2t = 100
+	tp_l2t = 4096
+	tp_ddp = 2
 
 	# TCAM has 8K cells; each region must start at a multiple of 128 cell.
 	# Each entry in these categories takes 4 cells each.  nhash will use the
@@ -136,7 +137,7 @@
 
 [fini]
 	version = 0x1
-	checksum = 0xdb5813f9
+	checksum = 0x162df193
 #
 # $FreeBSD$
 #

Modified: user/np/stable_9_toe/sys/dev/cxgbe/offload.h
==============================================================================
--- user/np/stable_9_toe/sys/dev/cxgbe/offload.h	Wed Aug 22 20:56:53 2012	(r239593)
+++ user/np/stable_9_toe/sys/dev/cxgbe/offload.h	Wed Aug 22 21:14:59 2012	(r239594)
@@ -31,13 +31,16 @@
 #ifndef __T4_OFFLOAD_H__
 #define __T4_OFFLOAD_H__
 
-#define INIT_ULPTX_WR(w, wrlen, atomic, tid) do { \
-	(w)->wr.wr_hi = htonl(V_FW_WR_OP(FW_ULPTX_WR) | V_FW_WR_ATOMIC(atomic)); \
-	(w)->wr.wr_mid = htonl(V_FW_WR_LEN16(DIV_ROUND_UP(wrlen, 16)) | \
+#define INIT_ULPTX_WRH(w, wrlen, atomic, tid) do { \
+	(w)->wr_hi = htonl(V_FW_WR_OP(FW_ULPTX_WR) | V_FW_WR_ATOMIC(atomic)); \
+	(w)->wr_mid = htonl(V_FW_WR_LEN16(DIV_ROUND_UP(wrlen, 16)) | \
 			       V_FW_WR_FLOWID(tid)); \
-	(w)->wr.wr_lo = cpu_to_be64(0); \
+	(w)->wr_lo = cpu_to_be64(0); \
 } while (0)
 
+#define INIT_ULPTX_WR(w, wrlen, atomic, tid) \
+    INIT_ULPTX_WRH(&((w)->wr), wrlen, atomic, tid)
+
 #define INIT_TP_WR(w, tid) do { \
 	(w)->wr.wr_hi = htonl(V_FW_WR_OP(FW_TP_WR) | \
                               V_FW_WR_IMMDLEN(sizeof(*w) - sizeof(w->wr))); \

Modified: user/np/stable_9_toe/sys/dev/cxgbe/t4_main.c
==============================================================================
--- user/np/stable_9_toe/sys/dev/cxgbe/t4_main.c	Wed Aug 22 20:56:53 2012	(r239593)
+++ user/np/stable_9_toe/sys/dev/cxgbe/t4_main.c	Wed Aug 22 21:14:59 2012	(r239594)
@@ -306,6 +306,7 @@ static void cxgbe_vlan_config(void *, st
 static int cpl_not_handled(struct sge_iq *, const struct rss_header *,
     struct mbuf *);
 static int an_not_handled(struct sge_iq *, const struct rsp_ctrl *);
+static int fw_msg_not_handled(struct adapter *, const __be64 *);
 static int t4_sysctls(struct adapter *);
 static int cxgbe_sysctls(struct port_info *);
 static int sysctl_int_array(SYSCTL_HANDLER_ARGS);
@@ -345,8 +346,6 @@ static int del_filter(struct adapter *, 
 static void clear_filter(struct filter_entry *);
 static int set_filter_wr(struct adapter *, int);
 static int del_filter_wr(struct adapter *, int);
-static int filter_rpl(struct sge_iq *, const struct rss_header *,
-    struct mbuf *);
 static int get_sge_context(struct adapter *, struct t4_sge_context *);
 static int read_card_mem(struct adapter *, struct t4_mem_range *);
 #ifdef TCP_OFFLOAD
@@ -381,6 +380,10 @@ CTASSERT(offsetof(struct sge_ofld_rxq, i
 CTASSERT(offsetof(struct sge_ofld_rxq, fl) == offsetof(struct sge_rxq, fl));
 #endif
 
+/* No easy way to include t4_msg.h before adapter.h so we check this way */
+CTASSERT(ARRAY_SIZE(((struct adapter *)0)->cpl_handler) == NUM_CPL_CMDS);
+CTASSERT(ARRAY_SIZE(((struct adapter *)0)->fw_msg_handler) == NUM_FW6_TYPES);
+
 static int
 t4_probe(device_t dev)
 {
@@ -458,7 +461,9 @@ t4_attach(device_t dev)
 	sc->an_handler = an_not_handled;
 	for (i = 0; i < ARRAY_SIZE(sc->cpl_handler); i++)
 		sc->cpl_handler[i] = cpl_not_handled;
-	t4_register_cpl_handler(sc, CPL_SET_TCB_RPL, filter_rpl);
+	for (i = 0; i < ARRAY_SIZE(sc->fw_msg_handler); i++)
+		sc->fw_msg_handler[i] = fw_msg_not_handled;
+	t4_register_cpl_handler(sc, CPL_SET_TCB_RPL, t4_filter_rpl);
 
 	/* Prepare the adapter for operation */
 	rc = -t4_prep_adapter(sc);
@@ -510,18 +515,24 @@ t4_attach(device_t dev)
 		goto done; /* error message displayed already */
 
 	if (sc->flags & MASTER_PF) {
+		uint16_t indsz = min(RX_COPY_THRESHOLD - 1, M_INDICATESIZE);
 
 		/* final tweaks to some settings */
 
 		t4_load_mtus(sc, sc->params.mtus, sc->params.a_wnd,
 		    sc->params.b_wnd);
-		t4_write_reg(sc, A_ULP_RX_TDDP_PSZ, V_HPZ0(PAGE_SHIFT - 12));
+		/* 4K, 16K, 64K, 256K DDP "page sizes" */
+		t4_write_reg(sc, A_ULP_RX_TDDP_PSZ, V_HPZ0(0) | V_HPZ1(2) |
+		    V_HPZ2(4) | V_HPZ3(6));
+		t4_set_reg_field(sc, A_ULP_RX_CTL, F_TDDPTAGTCB, F_TDDPTAGTCB);
 		t4_set_reg_field(sc, A_TP_PARA_REG3, F_TUNNELCNGDROP0 |
-		    F_TUNNELCNGDROP1 | F_TUNNELCNGDROP2 | F_TUNNELCNGDROP3, 0);
+		    F_TUNNELCNGDROP1 | F_TUNNELCNGDROP2 | F_TUNNELCNGDROP3,
+		    F_TUNNELCNGDROP0 | F_TUNNELCNGDROP1 | F_TUNNELCNGDROP2 |
+		    F_TUNNELCNGDROP3);
 		t4_set_reg_field(sc, A_TP_PARA_REG5,
 		    V_INDICATESIZE(M_INDICATESIZE) |
 		    F_REARMDDPOFFSET | F_RESETDDPOFFSET,
-		    V_INDICATESIZE(M_INDICATESIZE) |
+		    V_INDICATESIZE(indsz) |
 		    F_REARMDDPOFFSET | F_RESETDDPOFFSET);
 	} else {
 		/*
@@ -2942,7 +2953,8 @@ cxgbe_tick(void *arg)
 	ifp->if_omcasts = s->tx_mcast_frames - s->tx_pause;
 	ifp->if_imcasts = s->rx_mcast_frames - s->rx_pause;
 	ifp->if_iqdrops = s->rx_ovflow0 + s->rx_ovflow1 + s->rx_ovflow2 +
-	    s->rx_ovflow3;
+	    s->rx_ovflow3 + s->rx_trunc0 + s->rx_trunc1 + s->rx_trunc2 +
+	    s->rx_trunc3;
 
 	drops = s->tx_drop;
 	for_each_txq(pi, i, txq)
@@ -2977,7 +2989,7 @@ cpl_not_handled(struct sge_iq *iq, const
 	panic("%s: opcode 0x%02x on iq %p with payload %p",
 	    __func__, rss->opcode, iq, m);
 #else
-	log(LOG_ERR, "%s: opcode 0x%02x on iq %p with payload %p",
+	log(LOG_ERR, "%s: opcode 0x%02x on iq %p with payload %p\n",
 	    __func__, rss->opcode, iq, m);
 	m_freem(m);
 #endif
@@ -3006,7 +3018,7 @@ an_not_handled(struct sge_iq *iq, const 
 #ifdef INVARIANTS
 	panic("%s: async notification on iq %p (ctrl %p)", __func__, iq, ctrl);
 #else
-	log(LOG_ERR, "%s: async notification on iq %p (ctrl %p)",
+	log(LOG_ERR, "%s: async notification on iq %p (ctrl %p)\n",
 	    __func__, iq, ctrl);
 #endif
 	return (EDOOFUS);
@@ -3025,6 +3037,35 @@ t4_register_an_handler(struct adapter *s
 }
 
 static int
+fw_msg_not_handled(struct adapter *sc, const __be64 *rpl)
+{
+	__be64 *r = __DECONST(__be64 *, rpl);
+	struct cpl_fw6_msg *cpl = member2struct(cpl_fw6_msg, data, r);
+
+#ifdef INVARIANTS
+	panic("%s: fw_msg type %d", __func__, cpl->type);
+#else
+	log(LOG_ERR, "%s: fw_msg type %d\n", __func__, cpl->type);
+#endif
+	return (EDOOFUS);
+}
+
+int
+t4_register_fw_msg_handler(struct adapter *sc, int type, fw_msg_handler_t h)
+{
+	uintptr_t *loc, new;
+
+	if (type >= ARRAY_SIZE(sc->fw_msg_handler))
+		return (EINVAL);
+
+	new = h ? (uintptr_t)h : (uintptr_t)fw_msg_not_handled;
+	loc = (uintptr_t *) &sc->fw_msg_handler[type];
+	atomic_store_rel_ptr(loc, new);
+
+	return (0);
+}
+
+static int
 t4_sysctls(struct adapter *sc)
 {
 	struct sysctl_ctx_list *ctx;
@@ -3191,10 +3232,13 @@ t4_sysctls(struct adapter *sc)
 		sc->tt.ddp = 0;
 		SYSCTL_ADD_INT(ctx, children, OID_AUTO, "ddp", CTLFLAG_RW,
 		    &sc->tt.ddp, 0, "DDP allowed");
-		sc->tt.indsz = M_INDICATESIZE;
+
+		sc->tt.indsz = G_INDICATESIZE(t4_read_reg(sc, A_TP_PARA_REG5));
 		SYSCTL_ADD_INT(ctx, children, OID_AUTO, "indsz", CTLFLAG_RW,
 		    &sc->tt.indsz, 0, "DDP max indicate size allowed");
-		sc->tt.ddp_thres = 3*4096;
+
+		sc->tt.ddp_thres =
+		    G_RXCOALESCESIZE(t4_read_reg(sc, A_TP_PARA_REG2));
 		SYSCTL_ADD_INT(ctx, children, OID_AUTO, "ddp_thres", CTLFLAG_RW,
 		    &sc->tt.ddp_thres, 0, "DDP threshold");
 	}
@@ -4961,8 +5005,8 @@ del_filter_wr(struct adapter *sc, int fi
 	return (0);
 }
 
-static int
-filter_rpl(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m)
+int
+t4_filter_rpl(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m)
 {
 	struct adapter *sc = iq->adapter;
 	const struct cpl_set_tcb_rpl *rpl = (const void *)(rss + 1);

Modified: user/np/stable_9_toe/sys/dev/cxgbe/t4_sge.c
==============================================================================
--- user/np/stable_9_toe/sys/dev/cxgbe/t4_sge.c	Wed Aug 22 20:56:53 2012	(r239593)
+++ user/np/stable_9_toe/sys/dev/cxgbe/t4_sge.c	Wed Aug 22 21:14:59 2012	(r239594)
@@ -68,12 +68,37 @@ static struct fl_buf_info fl_buf_info[FL
 #define FL_BUF_TYPE(x)	(fl_buf_info[x].type)
 #define FL_BUF_ZONE(x)	(fl_buf_info[x].zone)
 
-enum {
-	FL_PKTSHIFT = 2
-};
+/*
+ * Ethernet frames are DMA'd at this byte offset into the freelist buffer.
+ * 0-7 are valid values.
+ */
+static int fl_pktshift = 2;
+TUNABLE_INT("hw.cxgbe.fl_pktshift", &fl_pktshift);
 
-static int fl_pad = CACHE_LINE_SIZE;
-static int spg_len = 64;
+/*
+ * Pad ethernet payload up to this boundary.
+ * -1: driver should figure out a good value.
+ *  Any power of 2, from 32 to 4096 (both inclusive) is a valid value.
+ */
+static int fl_pad = -1;
+TUNABLE_INT("hw.cxgbe.fl_pad", &fl_pad);
+
+/*
+ * Status page length.
+ * -1: driver should figure out a good value.
+ *  64 or 128 are the only other valid values.
+ */
+static int spg_len = -1;
+TUNABLE_INT("hw.cxgbe.spg_len", &spg_len);
+
+/*
+ * Congestion drops.
+ * -1: no congestion feedback (not recommended).
+ *  0: backpressure the channel instead of dropping packets right away.
+ *  1: no backpressure, drop packets for the congested queue immediately.
+ */
+static int cong_drop = 0;
+TUNABLE_INT("hw.cxgbe.cong_drop", &cong_drop);
 
 /* Used to track coalesced tx work request */
 struct txpkts {
@@ -160,7 +185,7 @@ static void write_eqflush_wr(struct sge_
 static __be64 get_flit(bus_dma_segment_t *, int, int);
 static int handle_sge_egr_update(struct sge_iq *, const struct rss_header *,
     struct mbuf *);
-static int handle_fw_rpl(struct sge_iq *, const struct rss_header *,
+static int handle_fw_msg(struct sge_iq *, const struct rss_header *,
     struct mbuf *);
 
 static int sysctl_uint16(SYSCTL_HANDLER_ARGS);
@@ -170,7 +195,8 @@ extern u_int cpu_clflush_line_size;
 #endif
 
 /*
- * Called on MOD_LOAD and fills up fl_buf_info[].
+ * Called on MOD_LOAD.  Fills up fl_buf_info[] and validates/calculates the SGE
+ * tunables.
  */
 void
 t4_sge_modload(void)
@@ -191,10 +217,49 @@ t4_sge_modload(void)
 		FL_BUF_ZONE(i) = m_getzone(bufsize[i]);
 	}
 
+	if (fl_pktshift < 0 || fl_pktshift > 7) {
+		printf("Invalid hw.cxgbe.fl_pktshift value (%d),"
+		    " using 2 instead.\n", fl_pktshift);
+		fl_pktshift = 2;
+	}
+
+	if (fl_pad < 32 || fl_pad > 4096 || !powerof2(fl_pad)) {
+		int pad;
+
 #if defined(__i386__) || defined(__amd64__)
-	fl_pad = max(cpu_clflush_line_size, 32);
-	spg_len = cpu_clflush_line_size > 64 ? 128 : 64;
+		pad = max(cpu_clflush_line_size, 32);
+#else
+		pad = max(CACHE_LINE_SIZE, 32);
 #endif
+		pad = min(pad, 4096);
+
+		if (fl_pad != -1) {
+			printf("Invalid hw.cxgbe.fl_pad value (%d),"
+			    " using %d instead.\n", fl_pad, pad);
+		}
+		fl_pad = pad;
+	}
+
+	if (spg_len != 64 && spg_len != 128) {
+		int len;
+
+#if defined(__i386__) || defined(__amd64__)
+		len = cpu_clflush_line_size > 64 ? 128 : 64;
+#else
+		len = 64;
+#endif
+		if (spg_len != -1) {
+			printf("Invalid hw.cxgbe.spg_len value (%d),"
+			    " using %d instead.\n", spg_len, len);
+		}
+		spg_len = len;
+	}
+
+	if (cong_drop < -1 || cong_drop > 1) {
+		printf("Invalid hw.cxgbe.cong_drop value (%d),"
+		    " using 0 instead.\n", cong_drop);
+		cong_drop = 0;
+	}
 }
 
 /**
@@ -215,7 +280,7 @@ t4_sge_init(struct adapter *sc)
 	ctrl_mask = V_PKTSHIFT(M_PKTSHIFT) | F_RXPKTCPLMODE |
 	    V_INGPADBOUNDARY(M_INGPADBOUNDARY) |
 	    F_EGRSTATUSPAGESIZE;
-	ctrl_val = V_PKTSHIFT(FL_PKTSHIFT) | F_RXPKTCPLMODE |
+	ctrl_val = V_PKTSHIFT(fl_pktshift) | F_RXPKTCPLMODE |
 	    V_INGPADBOUNDARY(ilog2(fl_pad) - 5) |
 	    V_EGRSTATUSPAGESIZE(spg_len == 128);
 
@@ -296,11 +361,13 @@ t4_sge_init(struct adapter *sc)
 	sc->sge.timer_val[4] = G_TIMERVALUE4(v) / core_ticks_per_usec(sc);
 	sc->sge.timer_val[5] = G_TIMERVALUE5(v) / core_ticks_per_usec(sc);
 
-	t4_register_cpl_handler(sc, CPL_FW4_MSG, handle_fw_rpl);
-	t4_register_cpl_handler(sc, CPL_FW6_MSG, handle_fw_rpl);
+	t4_register_cpl_handler(sc, CPL_FW4_MSG, handle_fw_msg);
+	t4_register_cpl_handler(sc, CPL_FW6_MSG, handle_fw_msg);
 	t4_register_cpl_handler(sc, CPL_SGE_EGR_UPDATE, handle_sge_egr_update);
 	t4_register_cpl_handler(sc, CPL_RX_PKT, t4_eth_rx);
 
+	t4_register_fw_msg_handler(sc, FW6_TYPE_CMD_RPL, t4_handle_fw_rpl);
+
 	return (rc);
 }
 
@@ -477,6 +544,18 @@ port_intr_iq(struct port_info *pi, int i
 	return (iq);
 }
 
+static inline int
+mtu_to_bufsize(int mtu)
+{
+	int bufsize;
+
+	/* large enough for a frame even when VLAN extraction is disabled */
+	bufsize = ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN + mtu;
+	bufsize = roundup(bufsize + fl_pktshift, fl_pad);
+
+	return (bufsize);
+}
+
 int
 t4_setup_port_queues(struct port_info *pi)
 {
@@ -493,6 +572,7 @@ t4_setup_port_queues(struct port_info *p
 	struct adapter *sc = pi->adapter;
 	struct sysctl_oid *oid = device_get_sysctl_tree(pi->dev);
 	struct sysctl_oid_list *children = SYSCTL_CHILDREN(oid);
+	int bufsize = mtu_to_bufsize(pi->ifp->if_mtu);
 
 	oid = SYSCTL_ADD_NODE(&pi->ctx, children, OID_AUTO, "rxq", CTLFLAG_RD,
 	    NULL, "rx queues");
@@ -522,7 +602,7 @@ t4_setup_port_queues(struct port_info *p
 
 		snprintf(name, sizeof(name), "%s rxq%d-fl",
 		    device_get_nameunit(pi->dev), i);
-		init_fl(&rxq->fl, pi->qsize_rxq / 8, pi->ifp->if_mtu, name);
+		init_fl(&rxq->fl, pi->qsize_rxq / 8, bufsize, name);
 
 		if (sc->flags & INTR_DIRECT
 #ifdef TCP_OFFLOAD
@@ -547,7 +627,7 @@ t4_setup_port_queues(struct port_info *p
 
 		snprintf(name, sizeof(name), "%s ofld_rxq%d-fl",
 		    device_get_nameunit(pi->dev), i);
-		init_fl(&ofld_rxq->fl, pi->qsize_rxq / 8, MJUM16BYTES, name);
+		init_fl(&ofld_rxq->fl, pi->qsize_rxq / 8, OFLD_BUF_SIZE, name);
 
 		if (sc->flags & INTR_DIRECT ||
 		    (sc->intr_count > 1 && pi->nofldrxq > pi->nrxq)) {
@@ -942,13 +1022,6 @@ service_iq(struct sge_iq *iq, int budget
 	return (0);
 }
 
-
-#ifdef T4_PKT_TIMESTAMP
-#define RX_COPY_THRESHOLD (MINCLSIZE - 8)
-#else
-#define RX_COPY_THRESHOLD MINCLSIZE
-#endif
-
 static struct mbuf *
 get_fl_payload(struct adapter *sc, struct sge_fl *fl, uint32_t len_newbuf,
     int *fl_bufs_used)
@@ -1050,9 +1123,9 @@ t4_eth_rx(struct sge_iq *iq, const struc
 	KASSERT(m0 != NULL, ("%s: no payload with opcode %02x", __func__,
 	    rss->opcode));
 
-	m0->m_pkthdr.len -= FL_PKTSHIFT;
-	m0->m_len -= FL_PKTSHIFT;
-	m0->m_data += FL_PKTSHIFT;
+	m0->m_pkthdr.len -= fl_pktshift;
+	m0->m_len -= fl_pktshift;
+	m0->m_data += fl_pktshift;
 
 	m0->m_pkthdr.rcvif = ifp;
 	m0->m_flags |= M_FLOWID;
@@ -1386,11 +1459,8 @@ t4_update_fl_bufsize(struct ifnet *ifp)
 	struct port_info *pi = ifp->if_softc;
 	struct sge_rxq *rxq;
 	struct sge_fl *fl;
-	int i, bufsize;
+	int i, bufsize = mtu_to_bufsize(ifp->if_mtu);
 
-	/* large enough for a frame even when VLAN extraction is disabled */
-	bufsize = ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN + ifp->if_mtu;
-	bufsize = roundup(bufsize + FL_PKTSHIFT, fl_pad);
 	for_each_rxq(pi, i, rxq) {
 		fl = &rxq->fl;
 
@@ -1793,6 +1863,18 @@ free_mgmtq(struct adapter *sc)
 	return free_wrq(sc, &sc->sge.mgmtq);
 }
 
+static inline int
+tnl_cong(struct port_info *pi)
+{
+
+	if (cong_drop == -1)
+		return (-1);
+	else if (cong_drop == 1)
+		return (0);
+	else
+		return (1 << pi->tx_chan);
+}
+
 static int
 alloc_rxq(struct port_info *pi, struct sge_rxq *rxq, int intr_idx, int idx,
     struct sysctl_oid *oid)
@@ -1801,7 +1883,7 @@ alloc_rxq(struct port_info *pi, struct s
 	struct sysctl_oid_list *children;
 	char name[16];
 
-	rc = alloc_iq_fl(pi, &rxq->iq, &rxq->fl, intr_idx, 1 << pi->tx_chan);
+	rc = alloc_iq_fl(pi, &rxq->iq, &rxq->fl, intr_idx, tnl_cong(pi));
 	if (rc != 0)
 		return (rc);
 
@@ -3433,17 +3515,15 @@ handle_sge_egr_update(struct sge_iq *iq,
 }
 
 static int
-handle_fw_rpl(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m)
+handle_fw_msg(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m)
 {
+	struct adapter *sc = iq->adapter;
 	const struct cpl_fw6_msg *cpl = (const void *)(rss + 1);
 
 	KASSERT(m == NULL, ("%s: payload with opcode %02x", __func__,
 	    rss->opcode));
 
-	if (cpl->type == FW6_TYPE_CMD_RPL)
-		t4_handle_fw_rpl(iq->adapter, cpl->data);
-
-	return (0);
+	return (sc->fw_msg_handler[cpl->type](sc, &cpl->data[0]));
 }
 
 static int

Modified: user/np/stable_9_toe/sys/dev/cxgbe/tom/t4_connect.c
==============================================================================
--- user/np/stable_9_toe/sys/dev/cxgbe/tom/t4_connect.c	Wed Aug 22 20:56:53 2012	(r239593)
+++ user/np/stable_9_toe/sys/dev/cxgbe/tom/t4_connect.c	Wed Aug 22 21:14:59 2012	(r239594)
@@ -167,10 +167,10 @@ act_open_rpl_status_to_errno(int status)
 	case CPL_ERR_CONN_TIMEDOUT:
 		return (ETIMEDOUT);
 	case CPL_ERR_TCAM_FULL:
-		return (ENOMEM);
+		return (EAGAIN);
 	case CPL_ERR_CONN_EXIST:
 		log(LOG_ERR, "ACTIVE_OPEN_RPL: 4-tuple in use\n");
-		return (EADDRINUSE);
+		return (EAGAIN);
 	default:
 		return (EIO);
 	}
@@ -186,8 +186,8 @@ do_act_open_rpl(struct sge_iq *iq, const
 	unsigned int status = G_AOPEN_STATUS(be32toh(cpl->atid_status));
 	struct toepcb *toep = lookup_atid(sc, atid);
 	struct inpcb *inp = toep->inp;
-	struct tcpcb *tp = intotcpcb(inp);
 	struct toedev *tod = &toep->td->tod;
+	int rc;
 
 	KASSERT(m == NULL, ("%s: wasn't expecting payload", __func__));
 	KASSERT(toep->tid == atid, ("%s: toep tid/atid mismatch", __func__));
@@ -204,17 +204,14 @@ do_act_open_rpl(struct sge_iq *iq, const
 	if (status && act_open_has_tid(status))
 		release_tid(sc, GET_TID(cpl), toep->ctrlq);
 
-	if (status == CPL_ERR_TCAM_FULL) {
-		INP_WLOCK(inp);
-		toe_connect_failed(tod, tp, EAGAIN);
-		final_cpl_received(toep);	/* unlocks inp */
-	} else {
+	rc = act_open_rpl_status_to_errno(status);
+	if (rc != EAGAIN)
 		INP_INFO_WLOCK(&V_tcbinfo);
-		INP_WLOCK(inp);
-		toe_connect_failed(tod, tp, act_open_rpl_status_to_errno(status));
-		final_cpl_received(toep);	/* unlocks inp */
+	INP_WLOCK(inp);
+	toe_connect_failed(tod, inp, rc);
+	final_cpl_received(toep);	/* unlocks inp */
+	if (rc != EAGAIN)
 		INP_INFO_WUNLOCK(&V_tcbinfo);
-	}
 
 	return (0);
 }
@@ -247,10 +244,14 @@ calc_opt2a(struct socket *so)
 	opt2 |= F_RX_COALESCE_VALID | V_RX_COALESCE(M_RX_COALESCE);
 	opt2 |= F_RSS_QUEUE_VALID | V_RSS_QUEUE(toep->ofld_rxq->iq.abs_id);
 
+#ifdef USE_DDP_RX_FLOW_CONTROL
+	if (toep->ulp_mode == ULP_MODE_TCPDDP)
+		opt2 |= F_RX_FC_VALID | F_RX_FC_DDP;
+#endif
+
 	return (htobe32(opt2));
 }
 
-
 void
 t4_init_connect_cpl_handlers(struct adapter *sc)

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-user mailing list