Created
September 5, 2022 15:25
-
-
Save szaydel/48c8e9a7300fcd3dc1636a0a317c41ce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/sbin/dtrace -Cs | |
#include <sys/scsi/scsi_pkt.h> /* command completion defines */ | |
#pragma D option quiet | |
#define SD_TO_DEVINFO(un) ((struct dev_info *)((un)->un_sd->sd_dev)) | |
#define DEV_NAME(un) \ | |
stringof(`devnamesp[SD_TO_DEVINFO(un)->devi_major].dn_name) /* ` */ | |
#define DEV_INST(un) (SD_TO_DEVINFO(un)->devi_instance) | |
#define SD_GET_XBUF(bp) ((struct sd_xbuf *)((bp)->b_private)) | |
#define SD_GET_UN(bp) ((SD_GET_XBUF(bp))->xb_un) | |
#define PKT_REASON(pktp) (pktp->pkt_reason) | |
string rnames[25]; | |
BEGIN { | |
rnames[CMD_CMPLT] = "completed"; | |
rnames[CMD_INCOMPLETE] = "incomplete"; | |
rnames[CMD_DMA_DERR] = "dma direction error"; | |
rnames[CMD_TRAN_ERR] = "unspecified xfer error"; | |
rnames[CMD_RESET] = "target hard reset"; | |
rnames[CMD_ABORTED] = "command transport aborted"; | |
rnames[CMD_TIMEOUT] = "command timed out"; | |
rnames[CMD_DATA_OVR] = "data overrun"; | |
rnames[CMD_CMD_OVR] = "command overrun"; | |
rnames[CMD_STS_OVR] = "status overrun"; | |
rnames[CMD_TERMINATED] = "command transport terminated"; | |
rnames[CMD_TLR_OFF] = "do not support TLR"; | |
} | |
:sd:sdintr:entry { | |
this->bp = (struct buf *)args[0]->pkt_private; | |
this->un = SD_GET_UN(this->bp); | |
this->un_ncmds_in_driver = this->un->un_ncmds_in_driver; | |
this->un_ncmds_in_transport = this->un->un_ncmds_in_transport; | |
this->devname = DEV_NAME(this->un); | |
this->inst = DEV_INST(this->un); | |
@in_drv[this->devname, this->inst] \ | |
= quantize(this->un_ncmds_in_driver); | |
@in_tran[this->devname, this->inst] \ | |
= quantize(this->un_ncmds_in_transport); | |
this->reason_str = rnames[PKT_REASON(args[0])] == "" ? | |
"unspecified": | |
rnames[PKT_REASON(args[0])]; | |
@reason[this->devname, this->inst, this->reason_str] \ | |
= count(); | |
} | |
END { | |
printa("\tin-driver (%s%d) %@d\n", @in_drv); | |
printa("\tin-transport (%s%d) %@d\n", @in_tran); | |
printf("device \treason \tcount\n"); | |
printf("------ \t------ \t-----\n"); | |
printa("%s%-8d\t%-8s\t%-8@d\n", @reason); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment