diff -r bb6c700d1cd4 -r 443c9ae1e8eb sys/cam/cam_sim.c --- a/sys/cam/cam_sim.c Wed Mar 18 19:39:18 2009 +0100 +++ b/sys/cam/cam_sim.c Wed Mar 18 20:16:08 2009 +0100 @@ -40,6 +40,12 @@ #include #include #include + +#include "opt_ddb.h" + +#ifdef DDB +#include +#endif #define CAM_PATH_ANY (u_int32_t)-1 @@ -144,3 +150,47 @@ { sim->path_id = path_id; } + +#ifdef DDB +/* + * Description + */ +DB_SHOW_COMMAND(cam_sim, db_show_cam_sim) +{ + if (!have_addr) { + db_printf("show cam_sim \n"); + return; + } + char buf[512] = { '\0' }; + struct cam_sim *sim = (struct cam_sim *)addr; + db_printf("sim_name: %s\n", sim->sim_name); + if (sim->path_id==CAM_XPT_PATH_ID) + db_printf("path_id: *\n"); + else + db_printf("path_id: %u\n", sim->path_id); + if (sim->bus_id==CAM_BUS_WILDCARD) + db_printf("bus_id: *\n"); + else + db_printf("bus_id: %u\n", sim->bus_id); + db_printf("unit_number: %u\n", sim->unit_number); + db_printf("max_tagged_dev_openings: %d\n", sim->max_tagged_dev_openings); + db_printf("max_dev_openings: %d\n", sim->max_dev_openings); + u_int32_t flags = sim->flags; +#define CAM_SIM_FLAG(flag) do { \ + if (flags & (flag)) { \ + if (buf[0] != '\0') \ + strlcat(buf, ", ", sizeof(buf)); \ + strlcat(buf, (#flag) + 4, sizeof(buf)); \ + flags &= ~(flag); \ + } \ +} while (0) + CAM_SIM_FLAG(CAM_SIM_REL_TIMEOUT_PENDING); + CAM_SIM_FLAG(CAM_SIM_MPSAFE); + CAM_SIM_FLAG(CAM_SIM_ON_DONEQ); + db_printf("flags: %s\n", buf); +#undef CAM_SIM_FLAG + db_printf("max_ccbs: %d\n", sim->max_ccbs); + db_printf("ccb_count: %d\n", sim->ccb_count); +} +#endif + diff -r bb6c700d1cd4 -r 443c9ae1e8eb sys/cam/cam_xpt.c --- a/sys/cam/cam_xpt.c Wed Mar 18 19:39:18 2009 +0100 +++ b/sys/cam/cam_xpt.c Wed Mar 18 20:16:08 2009 +0100 @@ -48,6 +48,11 @@ #include #include #include + +#include "opt_ddb.h" +#ifdef DDB +#include +#endif #ifdef PC98 #include /* geometry translation */ @@ -7320,3 +7325,379 @@ } } +#ifdef DDB +/* + * Some sort of description + */ +DB_SHOW_COMMAND(xpt_cam_eb, db_show_xpt_cam_eb) +{ + struct cam_eb *bus = NULL; + if (!have_addr) { + mtx_lock(&xsoftc.xpt_topo_lock); + db_printf("busses:\n"); + TAILQ_FOREACH(bus, &xsoftc.xpt_busses, links){ + db_printf(" %p\n", bus); + if (db_pager_quit) + break; + } + mtx_unlock(&xsoftc.xpt_topo_lock); + db_printf("\nMore info: show xpt_cam_eb \n"); + return; + } + bus = (struct cam_eb *)addr; + if (bus->path_id == CAM_BUS_WILDCARD) + db_printf("path_id: *\n"); + else + db_printf("path_id: %u\n", bus->path_id); + db_printf("sim: %p\nflags: %u\ngeneration: %u\nrefcount: %u\n", + bus->sim, bus->flags, bus->generation, bus->refcount); + db_printf("last_reset: %ju sec + %#lr usec\n", (uintmax_t)bus->last_reset.tv_sec, + bus->last_reset.tv_usec); + db_printf("targets:\n"); + struct cam_et *target = NULL; + TAILQ_FOREACH(target, &bus->et_entries, links){ + if (target->target_id == CAM_TARGET_WILDCARD) + db_printf(" %p target_id: *\n", target); + else + db_printf(" %p target_id: %u\n", target, target->target_id); + if (db_pager_quit) + break; + } +} + +DB_SHOW_COMMAND(xpt_cam_et, db_show_xpt_cam_et) +{ + if (!have_addr) { + db_printf("usage: show xpt_cam_et \n"); + return; + } + struct cam_et *target = (struct cam_et *)addr; + if (target->target_id == CAM_TARGET_WILDCARD) + db_printf("target_id: *\n"); + else + db_printf("target_id: %u\n", target->target_id); + db_printf("bus: %p\n", target->bus); + db_printf("refcount: %u\n", target->refcount); + db_printf("generation: %u\n", target->generation); + db_printf("last_reset: %ju sec + %#lr usec\n", + (uintmax_t) target->last_reset.tv_sec, target->last_reset.tv_usec); + db_printf("devices:\n"); + struct cam_ed *device = NULL; + TAILQ_FOREACH(device, &target->ed_entries, links) + { + db_printf(" %p\n", device); + if (db_pager_quit) + break; + } +} + +static +void qinfo_print(struct cam_ed_qinfo *q) { + db_printf(" pinfo (priority: "); + if (q->pinfo.priority == CAM_PRIORITY_NONE) + db_printf("NONE, "); + else + db_printf("%u, ", q->pinfo.priority); + db_printf("generation: %u, ", q->pinfo.generation); + db_printf("index: "); + if (q->pinfo.index == CAM_UNQUEUED_INDEX) + db_printf("UNQUEUED INDEX)\n"); + else if (q->pinfo.index == CAM_ACTIVE_INDEX) + db_printf("ACTIVE INDEX)\n"); + else if (q->pinfo.index == CAM_DONEQ_INDEX) + db_printf("CAM_DONEQ_INDEX)\n"); + else + db_printf("%u)\n", q->pinfo.index); + + db_printf(" device: %p\n", q->device); +} + +static +void scsi_inquiry_data_print(struct scsi_inquiry_data* inquiry) { + u_int8_t type = SID_TYPE(inquiry); + u_int8_t qual = SID_QUAL(inquiry); + db_printf(" type: %u", type); + char buf[1024] = { '\0' }; + u_int32_t flags = qual; +#define SID_QUAL_FLAG(flag) do { \ + if (flags & (flag)) { \ + if (buf[0] != '\0') \ + strlcat(buf, ", ", sizeof(buf)); \ + strlcat(buf, (#flag) + 4, sizeof(buf)); \ + flags &= ~(flag); \ + } \ +} while (0) + SID_QUAL_FLAG(SID_QUAL_LU_CONNECTED); + SID_QUAL_FLAG(SID_QUAL_LU_OFFLINE); + SID_QUAL_FLAG(SID_QUAL_RSVD); + SID_QUAL_FLAG(SID_QUAL_BAD_LU); +#undef SID_QUAL_FLAG + db_printf(" qual: (%u) %s\n", qual, buf); + if (SID_QUAL_IS_VENDOR_UNIQUE(inquiry)) + db_printf(" VENDOR IS UNIQUE\n"); + else + db_printf(" VENDOR IS NOT UNIQUE\n"); + + db_printf(" dev_qual2: %u\n", inquiry->dev_qual2); + if (SID_IS_REMOVABLE(inquiry)) + db_printf(" DEVICE IS REMOVABLE\n"); + else + db_printf(" DEVICE IS NOT REMOVABLE\n"); + db_printf(" version: "); + u_int8_t ansi_rev = SID_ANSI_REV(inquiry); + if (ansi_rev == SCSI_REV_0) + db_printf("SCSI_REV_0"); + else if (ansi_rev == SCSI_REV_CCS) + db_printf("SCSI_REV_CCS"); + else if (ansi_rev == SCSI_REV_2) + db_printf("SCSI_REV_2"); + else if (ansi_rev == SCSI_REV_SPC) + db_printf("SCSI_REV_SPC"); + else if (ansi_rev == SCSI_REV_SPC2) + db_printf("SCSI_REV_SPC2"); + db_printf("\n"); + db_printf(" response_format: "); + if (inquiry->response_format == SID_AENC) + db_printf("SID_AENC"); + else if (inquiry->response_format == SID_TrmIOP) + db_printf("SID_TrmIOP"); + else + db_printf("?????? (%u)\n", inquiry->response_format); + db_printf("\n"); + db_printf(" additional_length: %u\n", inquiry->additional_length); + db_printf(" reserved: %u\n", inquiry->reserved); + buf[0] = '\0'; + flags = inquiry->spc2_flags; +#define SPC2_SID_FLAG(flag) do { \ + if (flags & (flag)) { \ + if (buf[0] != '\0') \ + strlcat(buf, ", ", sizeof(buf)); \ + strlcat(buf, (#flag) + 4, sizeof(buf)); \ + flags &= ~(flag); \ + } \ +} while (0) + SPC2_SID_FLAG(SPC2_SID_MChngr); + SPC2_SID_FLAG(SPC2_SID_MultiP); + SPC2_SID_FLAG(SPC2_SID_EncServ); + SPC2_SID_FLAG(SPC2_SID_BQueue); +#undef SPC2_FLAG + db_printf(" spc2_flags: %s\n", buf); + buf[0] = '\0'; + flags = inquiry->flags; +#define SID_FLAG(flag) do { \ + if (flags & (flag)) { \ + if (buf[0] != '\0') \ + strlcat(buf, ", ", sizeof(buf)); \ + strlcat(buf, (#flag) + 4, sizeof(buf)); \ + flags &= ~(flag); \ + } \ +} while (0) + SID_FLAG(SID_SftRe); + SID_FLAG(SID_CmdQue); + SID_FLAG(SID_Linked); + SID_FLAG(SID_Sync); + SID_FLAG(SID_WBus16); + SID_FLAG(SID_WBus32); + SID_FLAG(SID_RelAdr); +#undef SID_FLAG + db_printf(" flags: %s\n", buf); + db_printf(" vendor: %s\n", inquiry->vendor); + db_printf(" product: %s\n", inquiry->product); + db_printf(" revision: %s\n", inquiry->revision); + //XXX:How print vendor_specific0? + db_printf(" spi3data: %u\n", inquiry->spi3data); + db_printf(" reserved2: %u\n", inquiry->reserved2); + + //TODO: Version descriptor + + //XXX:How print vendor_specific1? +} + +DB_SHOW_COMMAND(xpt_cam_ed, db_show_xpt_cam_ed) +{ + if (!have_addr) { + db_printf("usage: show xpt_cam_ed \n"); + return; + } + char buf[1024] = { '\0' }; + u_int32_t flags; + struct cam_ed *device = (struct cam_ed *)addr; + db_printf("alloc_ccb_entry: "); + qinfo_print(&device->alloc_ccb_entry); + db_printf("send_ccb_entry: "); + qinfo_print(&device->send_ccb_entry); + db_printf("target: %p\n", device->target); + db_printf("sim: %p\n", device->sim); + if (device->lun_id == CAM_LUN_WILDCARD) + db_printf("lun_id: *\n"); + else + db_printf("lun_id: %u\n", device->lun_id); + + //TODO: print struct camq drvq; + //TODO: print struct cam_ccbq ccbq; + //TODO: print struct async_list asyncs; + db_printf("generation: %u\n", device->generation); + db_printf("owner: %p\n", device->owner); + buf[0] = '\0'; + flags = device->quirk->inq_pat.media_type; +#define SIP_MEDIA_FLAG(flag) do { \ + if (flags & (flag)) { \ + if (buf[0] != '\0') \ + strlcat(buf, ", ", sizeof(buf)); \ + strlcat(buf, (#flag) + 4, sizeof(buf)); \ + flags &= ~(flag); \ + } \ +} while (0) + SIP_MEDIA_FLAG(SIP_MEDIA_REMOVABLE); + SIP_MEDIA_FLAG(SIP_MEDIA_FIXED); +#undef SP_MEDIA_FLAG + db_printf("quirk: ( inq_pat: ( type: %u, media_type: %s\n", + device->quirk->inq_pat.type, buf); + db_printf("vendor: %s, product: %s\n", device->quirk->inq_pat.vendor, + device->quirk->inq_pat.product); + db_printf("revision: %s )\n", device->quirk->inq_pat.revision); + buf[0] = '\0'; + flags = device->quirk->quirks; +#define CAM_QUIRK_FLAG(flag) do { \ + if (flags & (flag)) { \ + if (buf[0] != '\0') \ + strlcat(buf, ", ", sizeof(buf)); \ + strlcat(buf, (#flag) + 4, sizeof(buf)); \ + flags &= ~(flag); \ + } \ +} while (0) + CAM_QUIRK_FLAG(CAM_QUIRK_NOLUNS); + CAM_QUIRK_FLAG(CAM_QUIRK_NOSERIAL); + CAM_QUIRK_FLAG(CAM_QUIRK_HILUNS); + CAM_QUIRK_FLAG(CAM_QUIRK_NOHILUNS); +#undef CAM_QUIRK_FLAG + db_printf("quirks: (%u) %s\n", device->quirk->quirks, buf); + db_printf("mintags: %u, maxtags: %u\n", device->quirk->mintags, + device->quirk->maxtags); + db_printf("protocol: "); + if (device->protocol == PROTO_UNKNOWN) + db_printf("UNKNOWN\n"); + else if (device->protocol == PROTO_UNSPECIFIED) + db_printf("UNSPECIFIED\n"); + else if (device->protocol == PROTO_SCSI) + db_printf("SCSI\n"); + else if (device->protocol == PROTO_ATA) + db_printf("ATA\n"); + else if (device->protocol == PROTO_ATAPI) + db_printf("ATAPI\n"); + else + db_printf("?????? (%u)\n", (u_int32_t) device->protocol); + db_printf("protocol_version: "); + if (device->protocol_version == PROTO_VERSION_UNKNOWN) + db_printf("UNKNOWN\n"); + else if (device->protocol_version == PROTO_VERSION_UNSPECIFIED) + db_printf("UNSPECIFIED\n"); + else + db_printf("%u\n", device->protocol_version); + db_printf("protocol: "); + if (device->transport == XPORT_UNKNOWN) + db_printf("UNKNOWN\n"); + else if (device->transport == XPORT_UNSPECIFIED) + db_printf("UNSPECIFIED\n"); + else if (device->transport == XPORT_SPI) + db_printf("SPI\n"); + else if (device->transport == XPORT_FC) + db_printf("FC\n"); + else if (device->transport == XPORT_SSA) + db_printf("SSA\n"); + else if (device->transport == XPORT_USB) + db_printf("USB\n"); + else if (device->transport == XPORT_ATA) + db_printf("ATA\n"); + else if (device->transport == XPORT_SAS) + db_printf("SAS\n"); + else + db_printf("????? (%u)\n", (u_int32_t) device->transport); + db_printf("transport_version: "); + if (device->transport_version == XPORT_VERSION_UNKNOWN) + db_printf("UNKNOWN\n"); + else if (device->transport_version == XPORT_VERSION_UNSPECIFIED) + db_printf("UNSPECIFIED\n"); + else + db_printf("%u\n", device->transport_version); + db_printf("scsi_inquiry_data: (\n"); + scsi_inquiry_data_print(&device->inq_data); + db_printf(")\n"); + buf[0] = '\0'; + flags = device->inq_flags; +#define SID_FLAG(flag) do { \ + if (flags & (flag)) { \ + if (buf[0] != '\0') \ + strlcat(buf, ", ", sizeof(buf)); \ + strlcat(buf, (#flag) + 4, sizeof(buf)); \ + flags &= ~(flag); \ + } \ +} while (0) + SID_FLAG(SID_SftRe); + SID_FLAG(SID_CmdQue); + SID_FLAG(SID_Linked); + SID_FLAG(SID_Sync); + SID_FLAG(SID_WBus16); + SID_FLAG(SID_WBus32); + SID_FLAG(SID_RelAdr); +#undef SID_FLAG + db_printf("inq_flags: (%u) %s\n", device->inq_flags, buf); + buf[0] = '\0'; + flags = device->queue_flags; +#define SCP_QUEUE_FLAG(flag) do { \ + if (flags & (flag)) { \ + if (buf[0] != '\0') \ + strlcat(buf, ", ", sizeof(buf)); \ + strlcat(buf, (#flag) + 4, sizeof(buf)); \ + flags &= ~(flag); \ + } \ +} while (0) + SCP_QUEUE_FLAG(SCP_QUEUE_ALG_MASK); + SCP_QUEUE_FLAG(SCP_QUEUE_ALG_RESTRICTED); + SCP_QUEUE_FLAG(SCP_QUEUE_ALG_UNRESTRICTED); + SCP_QUEUE_FLAG(SCP_QUEUE_ERR); + SCP_QUEUE_FLAG(SCP_QUEUE_DQUE); +#undef SCP_QUEUE_FLAG + db_printf("queue_flags: (%u) %s\n", device->queue_flags, buf); + db_printf("serial_num: "); + for (int i=0; iserial_num_len; ++i) + db_printf("%u", device->serial_num[i]); + db_printf("\n"); + db_printf("qfrozen_cnt: %u\n", device->qfrozen_cnt); + buf[0] = '\0'; + flags = device->flags; +#define CAM_DEV_FLAG(flag) do { \ + if (flags & (flag)) { \ + if (buf[0] != '\0') \ + strlcat(buf, ", ", sizeof(buf)); \ + strlcat(buf, (#flag) + 4, sizeof(buf)); \ + flags &= ~(flag); \ + } \ +} while (0) + CAM_DEV_FLAG(CAM_DEV_UNCONFIGURED); + CAM_DEV_FLAG(CAM_DEV_REL_TIMEOUT_PENDING); + CAM_DEV_FLAG(CAM_DEV_REL_ON_COMPLETE); + CAM_DEV_FLAG(CAM_DEV_REL_ON_QUEUE_EMPTY); + CAM_DEV_FLAG(CAM_DEV_RESIZE_QUEUE_NEEDED); + CAM_DEV_FLAG(CAM_DEV_TAG_AFTER_COUNT); + CAM_DEV_FLAG(CAM_DEV_INQUIRY_DATA_VALID); + CAM_DEV_FLAG(CAM_DEV_IN_DV); + CAM_DEV_FLAG(CAM_DEV_DV_HIT_BOTTOM); +#undef CAM_DEV_FLAG + db_printf("flags: (%u) %s\n", device->flags, buf); + db_printf("tag_delay_count: %u\n", device->tag_delay_count); + db_printf("tag_saved_openings: %u\n", device->tag_saved_openings); + db_printf("refcount: %u\n", device->refcount); + + //TODO: print struct callout callout; + db_printf("periphs:\n"); + struct cam_periph *periph; + for (periph = SLIST_FIRST(&device->periphs); periph != NULL; + periph = SLIST_NEXT(periph, periph_links)) { + db_printf(" %p %s\n", periph, periph->periph_name); + if (db_pager_quit) + break; + } +} +#endif /* DDB */ +