From owner-svn-src-all@FreeBSD.ORG Sat Jun 23 22:12:28 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5B961106564A; Sat, 23 Jun 2012 22:12:28 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2DAFD8FC18; Sat, 23 Jun 2012 22:12:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5NMCSkv067616; Sat, 23 Jun 2012 22:12:28 GMT (envelope-from np@svn.freebsd.org) Received: (from np@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5NMCRwR067614; Sat, 23 Jun 2012 22:12:27 GMT (envelope-from np@svn.freebsd.org) Message-Id: <201206232212.q5NMCRwR067614@svn.freebsd.org> From: Navdeep Parhar Date: Sat, 23 Jun 2012 22:12:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237512 - head/sys/dev/cxgbe X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jun 2012 22:12:28 -0000 Author: np Date: Sat Jun 23 22:12:27 2012 New Revision: 237512 URL: http://svn.freebsd.org/changeset/base/237512 Log: Better way to determine the status page length and rx pad boundary. Modified: head/sys/dev/cxgbe/t4_sge.c Modified: head/sys/dev/cxgbe/t4_sge.c ============================================================================== --- head/sys/dev/cxgbe/t4_sge.c Sat Jun 23 21:29:53 2012 (r237511) +++ head/sys/dev/cxgbe/t4_sge.c Sat Jun 23 22:12:27 2012 (r237512) @@ -70,12 +70,8 @@ enum { FL_PKTSHIFT = 2 }; -#define FL_ALIGN min(CACHE_LINE_SIZE, 32) -#if CACHE_LINE_SIZE > 64 -#define SPG_LEN 128 -#else -#define SPG_LEN 64 -#endif +static int fl_pad = CACHE_LINE_SIZE; +static int spg_len = 64; /* Used to track coalesced tx work request */ struct txpkts { @@ -167,6 +163,10 @@ static int handle_fw_rpl(struct sge_iq * static int sysctl_uint16(SYSCTL_HANDLER_ARGS); +#if defined(__i386__) || defined(__amd64__) +extern u_int cpu_clflush_line_size; +#endif + /* * Called on MOD_LOAD and fills up fl_buf_info[]. */ @@ -188,6 +188,11 @@ t4_sge_modload(void) FL_BUF_TYPE(i) = m_gettype(bufsize[i]); FL_BUF_ZONE(i) = m_getzone(bufsize[i]); } + +#if defined(__i386__) || defined(__amd64__) + fl_pad = max(cpu_clflush_line_size, 32); + spg_len = cpu_clflush_line_size > 64 ? 128 : 64; +#endif } /** @@ -209,8 +214,8 @@ t4_sge_init(struct adapter *sc) V_INGPADBOUNDARY(M_INGPADBOUNDARY) | F_EGRSTATUSPAGESIZE; ctrl_val = V_PKTSHIFT(FL_PKTSHIFT) | F_RXPKTCPLMODE | - V_INGPADBOUNDARY(ilog2(FL_ALIGN) - 5) | - V_EGRSTATUSPAGESIZE(SPG_LEN == 128); + V_INGPADBOUNDARY(ilog2(fl_pad) - 5) | + V_EGRSTATUSPAGESIZE(spg_len == 128); hpsize = V_HOSTPAGESIZEPF0(PAGE_SHIFT - 10) | V_HOSTPAGESIZEPF1(PAGE_SHIFT - 10) | @@ -1372,8 +1377,8 @@ t4_update_fl_bufsize(struct ifnet *ifp) int i, bufsize; /* large enough for a frame even when VLAN extraction is disabled */ - bufsize = FL_PKTSHIFT + ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN + - ifp->if_mtu; + 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; @@ -1570,7 +1575,7 @@ alloc_iq_fl(struct port_info *pi, struct return (rc); /* Allocate space for one software descriptor per buffer. */ - fl->cap = (fl->qsize - SPG_LEN / RX_FL_ESIZE) * 8; + fl->cap = (fl->qsize - spg_len / RX_FL_ESIZE) * 8; FL_LOCK(fl); rc = alloc_fl_sdesc(fl); FL_UNLOCK(fl); @@ -2070,7 +2075,7 @@ alloc_eq(struct adapter *sc, struct port if (rc) return (rc); - eq->cap = eq->qsize - SPG_LEN / EQ_ESIZE; + eq->cap = eq->qsize - spg_len / EQ_ESIZE; eq->spg = (void *)&eq->desc[eq->cap]; eq->avail = eq->cap - 1; /* one less to avoid cidx = pidx */ eq->pidx = eq->cidx = 0;