From owner-svn-src-all@freebsd.org Sun Apr 10 05:07:00 2016 Return-Path: Delivered-To: svn-src-all@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 2BF6FB08468; Sun, 10 Apr 2016 05:07:00 +0000 (UTC) (envelope-from jhb@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 E462212F3; Sun, 10 Apr 2016 05:06:59 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u3A56xjE057126; Sun, 10 Apr 2016 05:06:59 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u3A56wF8057123; Sun, 10 Apr 2016 05:06:58 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201604100506.u3A56wF8057123@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Sun, 10 Apr 2016 05:06:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r297777 - in head/sys: dev/cxgbe dev/cxgbe/tom modules/cxgbe/if_cxgbe X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.21 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: Sun, 10 Apr 2016 05:07:00 -0000 Author: jhb Date: Sun Apr 10 05:06:58 2016 New Revision: 297777 URL: https://svnweb.freebsd.org/changeset/base/297777 Log: Add a 'show t4 tcb ' command to dump a TCB from DDB. This allows the contents of a TCB to be extracted from a T4/T5 card in DDB after a panic. Modified: head/sys/dev/cxgbe/t4_main.c head/sys/dev/cxgbe/tom/t4_ddp.c head/sys/modules/cxgbe/if_cxgbe/Makefile Modified: head/sys/dev/cxgbe/t4_main.c ============================================================================== --- head/sys/dev/cxgbe/t4_main.c Sun Apr 10 05:05:02 2016 (r297776) +++ head/sys/dev/cxgbe/t4_main.c Sun Apr 10 05:06:58 2016 (r297777) @@ -28,6 +28,7 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_ddb.h" #include "opt_inet.h" #include "opt_inet6.h" #include "opt_rss.h" @@ -63,6 +64,10 @@ __FBSDID("$FreeBSD$"); #include #include #endif +#ifdef DDB +#include +#include +#endif #include "common/common.h" #include "common/t4_msg.h" @@ -9163,6 +9168,86 @@ tweak_tunables(void) t4_intr_types &= INTR_MSIX | INTR_MSI | INTR_INTX; } +#ifdef DDB +static void +t4_dump_tcb(struct adapter *sc, int tid) +{ + uint32_t base, i, j, off, pf, reg, save, tcb_addr, win_pos; + + reg = PCIE_MEM_ACCESS_REG(A_PCIE_MEM_ACCESS_OFFSET, 2); + save = t4_read_reg(sc, reg); + base = sc->memwin[2].mw_base; + + /* Dump TCB for the tid */ + tcb_addr = t4_read_reg(sc, A_TP_CMM_TCB_BASE); + tcb_addr += tid * TCB_SIZE; + + if (is_t4(sc)) { + pf = 0; + win_pos = tcb_addr & ~0xf; /* start must be 16B aligned */ + } else { + pf = V_PFNUM(sc->pf); + win_pos = tcb_addr & ~0x7f; /* start must be 128B aligned */ + } + t4_write_reg(sc, reg, win_pos | pf); + t4_read_reg(sc, reg); + + off = tcb_addr - win_pos; + for (i = 0; i < 4; i++) { + uint32_t buf[8]; + for (j = 0; j < 8; j++, off += 4) + buf[j] = htonl(t4_read_reg(sc, base + off)); + + db_printf("%08x %08x %08x %08x %08x %08x %08x %08x\n", + buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], + buf[7]); + } + + t4_write_reg(sc, reg, save); + t4_read_reg(sc, reg); +} + +static struct command_table db_t4_table = LIST_HEAD_INITIALIZER(db_t4_table); +_DB_SET(_show, t4, NULL, db_show_table, 0, &db_t4_table); + +DB_FUNC(tcb, db_show_t4tcb, db_t4_table, CS_OWN, NULL) +{ + device_t dev; + int radix, tid, t; + bool valid; + + valid = false; + radix = db_radix; + db_radix = 10; + t = db_read_token(); + if (t == tIDENT) { + dev = device_lookup_by_name(db_tok_string); + t = db_read_token(); + if (t == tNUMBER) { + tid = db_tok_number; + valid = true; + } + } + db_radix = radix; + db_skip_to_eol(); + if (!valid) { + db_printf("usage: show t4 tcb \n"); + return; + } + + if (dev == NULL) { + db_printf("device not found\n"); + return; + } + if (tid < 0) { + db_printf("invalid tid\n"); + return; + } + + t4_dump_tcb(device_get_softc(dev), tid); +} +#endif + static struct sx mlu; /* mod load unload */ SX_SYSINIT(cxgbe_mlu, &mlu, "cxgbe mod load/unload"); Modified: head/sys/dev/cxgbe/tom/t4_ddp.c ============================================================================== --- head/sys/dev/cxgbe/tom/t4_ddp.c Sun Apr 10 05:05:02 2016 (r297776) +++ head/sys/dev/cxgbe/tom/t4_ddp.c Sun Apr 10 05:06:58 2016 (r297777) @@ -80,31 +80,6 @@ static struct mbuf *get_ddp_mbuf(int len /* XXX: must match A_ULP_RX_TDDP_PSZ */ static int t4_ddp_pgsz[] = {4096, 4096 << 2, 4096 << 4, 4096 << 6}; -#if 0 -static void -t4_dump_tcb(struct adapter *sc, int tid) -{ - uint32_t tcb_base, off, i, j; - - /* Dump TCB for the tid */ - tcb_base = t4_read_reg(sc, A_TP_CMM_TCB_BASE); - t4_write_reg(sc, PCIE_MEM_ACCESS_REG(A_PCIE_MEM_ACCESS_OFFSET, 2), - tcb_base + tid * TCB_SIZE); - t4_read_reg(sc, PCIE_MEM_ACCESS_REG(A_PCIE_MEM_ACCESS_OFFSET, 2)); - off = 0; - printf("\n"); - for (i = 0; i < 4; i++) { - uint32_t buf[8]; - for (j = 0; j < 8; j++, off += 4) - buf[j] = htonl(t4_read_reg(sc, MEMWIN2_BASE + off)); - - printf("%08x %08x %08x %08x %08x %08x %08x %08x\n", - buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], - buf[7]); - } -} -#endif - #define MAX_DDP_BUFFER_SIZE (M_TCB_RX_DDP_BUF0_LEN) static int alloc_ppods(struct tom_data *td, int n, u_int *ppod_addr) Modified: head/sys/modules/cxgbe/if_cxgbe/Makefile ============================================================================== --- head/sys/modules/cxgbe/if_cxgbe/Makefile Sun Apr 10 05:05:02 2016 (r297776) +++ head/sys/modules/cxgbe/if_cxgbe/Makefile Sun Apr 10 05:06:58 2016 (r297777) @@ -8,6 +8,7 @@ CXGBE= ${.CURDIR}/../../../dev/cxgbe KMOD= if_cxgbe SRCS= bus_if.h SRCS+= device_if.h +SRCS+= opt_ddb.h SRCS+= opt_inet.h SRCS+= opt_inet6.h SRCS+= opt_ofed.h