From owner-svn-src-head@freebsd.org Tue Aug 2 23:54:22 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D6D66BAD2DC; Tue, 2 Aug 2016 23:54:22 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B2E2813AF; Tue, 2 Aug 2016 23:54:22 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u72NsLke084900; Tue, 2 Aug 2016 23:54:21 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u72NsLf9084898; Tue, 2 Aug 2016 23:54:21 GMT (envelope-from np@FreeBSD.org) Message-Id: <201608022354.u72NsLf9084898@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Tue, 2 Aug 2016 23:54:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r303688 - head/sys/dev/cxgbe/tom X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Aug 2016 23:54:22 -0000 Author: np Date: Tue Aug 2 23:54:21 2016 New Revision: 303688 URL: https://svnweb.freebsd.org/changeset/base/303688 Log: cxgbe/t4_tom: Read the chip's DDP page sizes and save them in a per-adapter data structure. This replaces a global array with hardcoded page sizes. Sponsored by: Chelsio Communications Modified: head/sys/dev/cxgbe/tom/t4_ddp.c head/sys/dev/cxgbe/tom/t4_tom.h Modified: head/sys/dev/cxgbe/tom/t4_ddp.c ============================================================================== --- head/sys/dev/cxgbe/tom/t4_ddp.c Tue Aug 2 23:46:32 2016 (r303687) +++ head/sys/dev/cxgbe/tom/t4_ddp.c Tue Aug 2 23:54:21 2016 (r303688) @@ -88,9 +88,6 @@ static void t4_aio_cancel_queued(struct #define PPOD_SZ(n) ((n) * sizeof(struct pagepod)) #define PPOD_SIZE (PPOD_SZ(1)) -/* XXX: must match A_ULP_RX_TDDP_PSZ */ -static int t4_ddp_pgsz[] = {4096, 4096 << 2, 4096 << 4, 4096 << 6}; - static TAILQ_HEAD(, pageset) ddp_orphan_pagesets; static struct mtx ddp_orphan_pagesets_lock; static struct task ddp_orphan_task; @@ -908,13 +905,13 @@ alloc_page_pods(struct tom_data *td, str } hcf = calculate_hcf(hcf, seglen); - if (hcf < t4_ddp_pgsz[1]) { + if (hcf < td->ddp_pgsz[1]) { idx = 0; goto have_pgsz; /* give up, short circuit */ } } - if (hcf % t4_ddp_pgsz[0] != 0) { + if (hcf % td->ddp_pgsz[0] != 0) { /* hmmm. This could only happen when PAGE_SIZE < 4K */ KASSERT(PAGE_SIZE < 4096, ("%s: PAGE_SIZE %d, hcf %d", __func__, PAGE_SIZE, hcf)); @@ -923,17 +920,17 @@ alloc_page_pods(struct tom_data *td, str return (0); } - for (idx = nitems(t4_ddp_pgsz) - 1; idx > 0; idx--) { - if (hcf % t4_ddp_pgsz[idx] == 0) + for (idx = nitems(td->ddp_pgsz) - 1; idx > 0; idx--) { + if (hcf % td->ddp_pgsz[idx] == 0) break; } have_pgsz: MPASS(idx <= M_PPOD_PGSZ); - nppods = pages_to_nppods(ps->npages, t4_ddp_pgsz[idx]); + nppods = pages_to_nppods(ps->npages, td->ddp_pgsz[idx]); if (alloc_ppods(td, nppods, &ppod_addr) != 0) { CTR4(KTR_CXGBE, "%s: no pods, nppods %d, npages %d, pgsz %d", - __func__, nppods, ps->npages, t4_ddp_pgsz[idx]); + __func__, nppods, ps->npages, td->ddp_pgsz[idx]); return (0); } @@ -944,7 +941,7 @@ have_pgsz: CTR5(KTR_CXGBE, "New page pods. " "ps %p, ddp_pgsz %d, ppod 0x%x, npages %d, nppods %d", - ps, t4_ddp_pgsz[idx], ppod, ps->npages, ps->nppods); + ps, td->ddp_pgsz[idx], ppod, ps->npages, ps->nppods); return (1); } @@ -958,6 +955,7 @@ write_page_pods(struct adapter *sc, stru struct ulp_mem_io *ulpmc; struct ulptx_idata *ulpsc; struct pagepod *ppod; + struct tom_data *td = sc->tom_softc; int i, j, k, n, chunk, len, ddp_pgsz, idx; u_int ppod_addr; uint32_t cmd; @@ -970,7 +968,7 @@ write_page_pods(struct adapter *sc, stru cmd |= htobe32(F_ULP_MEMIO_ORDER); else cmd |= htobe32(F_T5_ULP_MEMIO_IMM); - ddp_pgsz = t4_ddp_pgsz[G_PPOD_PGSZ(ps->tag)]; + ddp_pgsz = td->ddp_pgsz[G_PPOD_PGSZ(ps->tag)]; ppod_addr = ps->ppod_addr; for (i = 0; i < ps->nppods; ppod_addr += chunk) { @@ -1069,6 +1067,23 @@ prep_pageset(struct adapter *sc, struct void t4_init_ddp(struct adapter *sc, struct tom_data *td) { + int i; + uint32_t r; + + r = t4_read_reg(sc, A_ULP_RX_TDDP_PSZ); + td->ddp_pgsz[0] = 4096 << G_HPZ0(r); + td->ddp_pgsz[1] = 4096 << G_HPZ1(r); + td->ddp_pgsz[2] = 4096 << G_HPZ2(r); + td->ddp_pgsz[3] = 4096 << G_HPZ3(r); + + /* + * The SGL -> page pod algorithm requires the sizes to be in increasing + * order. + */ + for (i = 1; i < nitems(td->ddp_pgsz); i++) { + if (td->ddp_pgsz[i] <= td->ddp_pgsz[i - 1]) + return; + } td->ppod_start = sc->vres.ddp.start; td->ppod_arena = vmem_create("DDP page pods", sc->vres.ddp.start, Modified: head/sys/dev/cxgbe/tom/t4_tom.h ============================================================================== --- head/sys/dev/cxgbe/tom/t4_tom.h Tue Aug 2 23:46:32 2016 (r303687) +++ head/sys/dev/cxgbe/tom/t4_tom.h Tue Aug 2 23:54:21 2016 (r303688) @@ -240,6 +240,7 @@ struct tom_data { int lctx_count; /* # of lctx in the hash table */ u_int ppod_start; + u_int ddp_pgsz[4]; vmem_t *ppod_arena; struct mtx clip_table_lock;