From nobody Thu Jan 8 06:24:38 2026 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 4dmvyH0v8Hz5hsfZ for ; Thu, 08 Jan 2026 06:24:39 +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 "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dmvyG5LsFz3SGC for ; Thu, 08 Jan 2026 06:24:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767853478; 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=hXB9mlbRui4SOaTaQ8i3IcIbHUyvlPFce69NxQIj7Gw=; b=Bc1JjbUHh06U81zcOqklP1EI1rgSVczqmutey97apZSOIlOzOvRQa28k2sxu9JsKKeZ49c kSNVW0qdYB3mXc6sA9/usHgqfgSWcMsQF+GzfBNeZMteNvIQiNZe+ynS/VqP3eVJGDKSpB BotIclMiomh/xB81FFCNGiMDSXzMundKKTpb8ECSdsfmoGbcW4coVAmC5XIkRyiORy2DgU 1xBlPCxh75aXr/CN6N0Gk0mq/0Ys4aemss+9pfYordQiQZiOZcigNlk58juMA99ZnA7tOj qkhTemsKIr0T+lJ20x7tlzZj6rwLVFfhiYmJ64ZH5eoehDcJW3z/2molapPS0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767853478; 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=hXB9mlbRui4SOaTaQ8i3IcIbHUyvlPFce69NxQIj7Gw=; b=VyLgHhQ/okGnlbmzvp0CcVr0WE85dlWlxKqlS323jMWKpp/XgM/4j3cBv/Nimw/Oy+C2d9 1KVC9aXlWwU0jAX6P8HQ4pA4+ZlGOtEWSNw/+oQAFM2k2WSRAJmagxibYTYVrLqG1EFvZN 9jiG3ZtO7yMw8sG8oI8kSwTd7GU8iA3HMavfzC11k5+gfQ7HJuFEiK0cm1AVIbfANZkOiN HPb5n/DmMdyGJJtZEo+Ywj3+oZjCjnvCp/75mjyU3kbyYGN24RZzKzb6pPcF2oGQp2DMKn NDo35KwI81vevFpSQzd75z5kA2cDQzc65+sG9N53I67OVpMeLrLPivMp+I8clw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1767853478; a=rsa-sha256; cv=none; b=Gmv5TdsPeYnUOgtap6Jt7yvCe1Z6ZyGEXMWbrZZPidnD1qDjKTXRkmlSreg8oG28aC+ORC 0mfsV0uNsV8fMceMWWW8hB8P44gPElKMMGv5b+K+Y1K8FJAs4TwZFpNG5NoKW3+wjn6DYR G3V119IrJUfxzrSG9qMInkoohLtW2FNpASCAGfn0MEmeCH52ITA9C7L+8V6M/i5sLHuzgx CdZc8e2TRNb0iwknHrn66aBOF1WGXFl5Lthsz7oP6afKd6+3KScXH9CcVh7putZxjur62L eFGFUNScbOpTngPe6jGUa8X2wYjGEF20xOoGnABxbclZhSde1syCL9zkptQ+JQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dmvyG4fzJzBpQ for ; Thu, 08 Jan 2026 06:24:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 36269 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 08 Jan 2026 06:24:38 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: cd1aa5f9917c - main - tools/cam: Start to add the testing tools for CAM 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: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cd1aa5f9917cc7de255e854954c818e5ef3e9c9b Auto-Submitted: auto-generated Date: Thu, 08 Jan 2026 06:24:38 +0000 Message-Id: <695f4da6.36269.3bd4f8ad@gitrepo.freebsd.org> The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=cd1aa5f9917cc7de255e854954c818e5ef3e9c9b commit cd1aa5f9917cc7de255e854954c818e5ef3e9c9b Author: Warner Losh AuthorDate: 2026-01-08 06:20:34 +0000 Commit: Warner Losh CommitDate: 2026-01-08 06:20:34 +0000 tools/cam: Start to add the testing tools for CAM Create a directory for testing tools arond CAM. These are snippets of what will eventually be camio. At the moment, it was written using fbt traces. This is OK, but fragile, so they need to be re-written with the cam provider. cam_all_but_scsi.d is the first step. It shows how to do this with the new cam dtrace provider. Sponsored by: Netflix Reviewed by: adrian Differential Revision: https://reviews.freebsd.org/D54472 --- tools/cam/README | 9 +++++ tools/cam/cam_all_but_scsi.d | 89 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) diff --git a/tools/cam/README b/tools/cam/README new file mode 100644 index 000000000000..fd93ccd15e1f --- /dev/null +++ b/tools/cam/README @@ -0,0 +1,9 @@ +This directory has snippets of what will eventually become camio. This program +can take an expression for the types of things to trace, and then custom write a +dtrace script to do that. + +camio is a d-traced tcpdump-like program for examining CAM traffic (and +therefore I/O and other traffic to storage media) that written during covid, but +with fbp providers that recent clang optimizations make unuseable, hence the +shift to the cam provider, but retooling them and finishing the grammar will +take some time (but these scripts are useful today). diff --git a/tools/cam/cam_all_but_scsi.d b/tools/cam/cam_all_but_scsi.d new file mode 100644 index 000000000000..a20d7fa0cba9 --- /dev/null +++ b/tools/cam/cam_all_but_scsi.d @@ -0,0 +1,89 @@ +#!/usr/sbin/dtrace -s + +/* Sample use of the cam dtrace provider */ + +/* + * Trace all the non I/O commands flowing through CAM + */ + +dtrace:::BEGIN +{ +} + +/* + * There's two choke points in CAM. We can intercept the request on the way down + * in xpt_action, just before it's sent to the SIM. This can be a good place to + * see what's going on before it happens. However, most I/O happens quite + * quickly, this isn't much of an advantage. The other place is on completion + * when the transaction is finally done. The retry mechanism is built into the + * periph driver, which is responsible for submitting the request. + * + * cam::xpt_action is a single logical point that handles both xpt_action and + * xpt_action_direct. Thie example hooks into it. The style is funky because + * D doesn't have looping or generalized if constructs. + * + * The 'trace' context local variable controls printing of different types + * of results. This is all controlled by camio.lua. + */ + + +/* + * CAM queues a CCB to the SIM in xpt_action. Save interesting bits + * for later winnowing. + */ +/* fbt::xpt_action_default:entry */ +cam::xpt:action +{ + this->ccb = ((union ccb *)arg0); + this->func = this->ccb->ccb_h.func_code & 0xff; + this->periph = this->ccb->ccb_h.path->periph; + this->bus = this->ccb->ccb_h.path->bus; + this->target = this->ccb->ccb_h.path->target; + this->device = this->ccb->ccb_h.path->device; + this->trace = 1; +} + +/* + * Omit the I/O CCBs. Go ahead and pass the other semi I/O enclosure + * commands, though. + */ +cam::xpt:action +/this->func == XPT_SCSI_IO || this->func == XPT_NVME_IO || this->func == XPT_NVME_ADMIN || this->func == XPT_ATA_IO/ +{ + this->trace = 0; +} + +/* + * Print out the non I/O and non ASYNC commands here. + */ +cam::xpt:action +/this->trace && this->func != XPT_ASYNC/ +{ + printf("(%s%d:%s%d:%d:%d:%d): %s", + this->periph == NULL ? "noperiph" : stringof(this->periph->periph_name), + this->periph == NULL ? 0 : this->periph->unit_number, + this->bus == NULL ? "nobus" : this->bus->sim->sim_name, + this->bus == NULL ? 0 : this->bus->sim->unit_number, + this->bus == NULL ? 0 : this->bus->sim->bus_id, + this->target == NULL ? 0 : this->target->target_id, + this->device == NULL ? 0 : this->device->lun_id, + xpt_action_string[this->func]); +} + +/* + * For async calls, print out the async message type. + */ +cam::xpt:action +/this->trace && this->func == XPT_ASYNC/ +{ + printf("(%s%d:%s%d:%d:%d:%d): %s %s", + this->periph == NULL ? "noperiph" : stringof(this->periph->periph_name), + this->periph == NULL ? 0 : this->periph->unit_number, + this->bus == NULL ? "nobus" : this->bus->sim->sim_name, + this->bus == NULL ? 0 : this->bus->sim->unit_number, + this->bus == NULL ? 0 : this->bus->sim->bus_id, + this->target == NULL ? 0 : this->target->target_id, + this->device == NULL ? 0 : this->device->lun_id, + xpt_action_string[this->func], + xpt_async_string[this->ccb->casync.async_code]); +}