From nobody Mon Oct 21 18:55:05 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XXPd56LgMz5ZdVh; Mon, 21 Oct 2024 18:55:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XXPd55QhJz4Q4Z; Mon, 21 Oct 2024 18:55:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729536905; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AeBLDMQGVuJkj4NrKNqSNU+OzfiP7F8qckMDRTaGFxE=; b=MN0J2GsJz+nNHmfgPi8QO4INnc0gYwmWwxEHXgDUPaaH29zUAk4M8T2AVIn3BAOSwVCE84 wOCM+701Jmf7wcbiSFzhmAQTBcyuTDxs7cTki0nuWgVjwV+fKSMDvvvdQ1PEFcLMNXTuZb X4vBxOOWXugTFCrjcACrNCvc2EXQBWGX42wmvpHWG2WLUHsm/9rxLTtZ9PkfqNcnVr/wQL Nw7wGlf34SeORR49MFMUsyJHm1AoVhaKvQFGrZpU8rDUTad8qcZQ8LmTahPHwSv3qiD8Eh Fuv1XoCpUBHjR79+rmufX8PEHrOuR0JUrtmhcFMbDgPGXw+B4u/cy6ftch3mIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729536905; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AeBLDMQGVuJkj4NrKNqSNU+OzfiP7F8qckMDRTaGFxE=; b=hI3vFb8UXr01Qy6NLpT92IMOc5iSL3n7gvVKFnZRMXoSiM3r4SO0r9OEhZQsLr7Bw/9F4e pW+EEUIlHLodQXWqYE6bpCIlfiVpcGTOBT6KrxvWfePOyyoZD+pu8WF5lrK3INpIj9iKde b7dQcY/53yDioiVT4AwPOtQBHJWEN/WBwT4LuWtwnLVtlWLoNlLGi1m9gPfd9Ncob3ECVu 3R7vimi+eSCnUkWfTANnLGa5F0GK+R05N+1iuVxW9qwIDKNtP32y4hF7ouCUEy3wdCxKip NonDcxWZWZnKIcSenbOZPxnLz7oLvaavqgOcpifIKZieYMrTkT5j/VVVLrMpWw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729536905; a=rsa-sha256; cv=none; b=JMHe9IHuucXb5TqfHy8QPuVN5x9Cbld7kjZzJxM0dBORkmm/xi9CjEjxsEqjczjMJH720q C2K5xGFpaqp7PonMRFW0qg/5DIHNQvpyyJVL66cGEBXvgjmNCKs75GJYBGTemt2fWJgvaQ E7VLL1D60FJKpkjOMxB11NA4mqb9hhXVZoYLhJRXXT2GeSoGqZNyB9Isk/DtO080TNEMy1 H0ofvvhgj+fQo3rINR7Lsmi5KNQwxXzRiGdUHtxMlcgYrwTO1dhcj/TVsBjWwrQQOn2oRl ZG2DylhmABiq9Whw/s52SgbzqZzCIxjd3qdQjL914rtnO5eIjqxGaxKjV0rvtg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XXPd54vQrzj1p; Mon, 21 Oct 2024 18:55:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49LIt5jC073260; Mon, 21 Oct 2024 18:55:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49LIt5mo073257; Mon, 21 Oct 2024 18:55:05 GMT (envelope-from git) Date: Mon, 21 Oct 2024 18:55:05 GMT Message-Id: <202410211855.49LIt5mo073257@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: e42a182bb7f6 - stable/14 - cxgbe: Add a 'show t4 memdump' DDB command List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: e42a182bb7f69d53ea35dfe22e16a1944c280066 Auto-Submitted: auto-generated The branch stable/14 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=e42a182bb7f69d53ea35dfe22e16a1944c280066 commit e42a182bb7f69d53ea35dfe22e16a1944c280066 Author: John Baldwin AuthorDate: 2024-07-03 15:05:11 +0000 Commit: Navdeep Parhar CommitDate: 2024-10-21 18:49:27 +0000 cxgbe: Add a 'show t4 memdump' DDB command Reviewed by: np Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D45187 (cherry picked from commit 1edf61f395d98a5abb7d6f38e5e64722b4ddf351) --- sys/dev/cxgbe/t4_main.c | 76 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 66 insertions(+), 10 deletions(-) diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 769d4778a8d2..3829ea6501cb 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -12939,30 +12939,26 @@ tweak_tunables(void) #ifdef DDB static void -t4_dump_tcb(struct adapter *sc, int tid) +t4_dump_mem(struct adapter *sc, u_int addr, u_int len) { - uint32_t base, i, j, off, pf, reg, save, tcb_addr, win_pos; + uint32_t base, j, off, pf, reg, save, 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 */ + win_pos = addr & ~0xf; /* start must be 16B aligned */ } else { pf = V_PFNUM(sc->pf); - win_pos = tcb_addr & ~0x7f; /* start must be 128B aligned */ + win_pos = addr & ~0x7f; /* start must be 128B aligned */ } + off = addr - win_pos; t4_write_reg(sc, reg, win_pos | pf); t4_read_reg(sc, reg); - off = tcb_addr - win_pos; - for (i = 0; i < 4; i++) { + while (len > 0 && !db_pager_quit) { uint32_t buf[8]; for (j = 0; j < 8; j++, off += 4) buf[j] = htonl(t4_read_reg(sc, base + off)); @@ -12970,12 +12966,27 @@ t4_dump_tcb(struct adapter *sc, int tid) 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]); + if (len <= sizeof(buf)) + len = 0; + else + len -= sizeof(buf); } t4_write_reg(sc, reg, save); t4_read_reg(sc, reg); } +static void +t4_dump_tcb(struct adapter *sc, int tid) +{ + uint32_t tcb_addr; + + /* Dump TCB for the tid */ + tcb_addr = t4_read_reg(sc, A_TP_CMM_TCB_BASE); + tcb_addr += tid * TCB_SIZE; + t4_dump_mem(sc, tcb_addr, TCB_SIZE); +} + static void t4_dump_devlog(struct adapter *sc) { @@ -13107,6 +13118,51 @@ DB_TABLE_COMMAND_FLAGS(show_t4, tcb, db_show_t4tcb, CS_OWN) t4_dump_tcb(device_get_softc(dev), tid); } + +DB_TABLE_COMMAND_FLAGS(show_t4, memdump, db_show_memdump, CS_OWN) +{ + device_t dev; + int radix, 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) { + addr = db_tok_number; + t = db_read_token(); + if (t == tNUMBER) { + count = db_tok_number; + valid = true; + } + } + } + db_radix = radix; + db_skip_to_eol(); + if (!valid) { + db_printf("usage: show t4 memdump \n"); + return; + } + + if (dev == NULL) { + db_printf("device not found\n"); + return; + } + if (addr < 0) { + db_printf("invalid address\n"); + return; + } + if (count <= 0) { + db_printf("invalid length\n"); + return; + } + + t4_dump_mem(device_get_softc(dev), addr, count); +} #endif static eventhandler_tag vxlan_start_evtag;