Author: scottl
Date: Wed Apr 19 15:04:52 2017
New Revision: 317143
URL: https://svnweb.freebsd.org/changeset/base/317143
Log:
Add infrastructure to the ATA and SCSI transports that supports
using a driver-supplied sbuf for printing device discovery
announcements. This helps ensure that messages to the console
will be properly serialized (through sbuf_putbuf) and not be
truncated and interleaved with other messages. The
infrastructure mirrors the existing xpt_announce_periph()
entry point and is opt-in for now. No content or formatting
changes are visible to the operator other than the new coherency.
While here, eliminate the stack usage of the temporary
announcement buffer in some of the drivers. It's moved to the
softc for now, but future work will eliminate it entirely by
making the code flow more linear. Future work will also address
locking so that the sbufs can be dynamically sized.
The scsi_da, scs_cd, scsi_ses, and ata_da drivers are converted
at this point, other drivers can be converted at a later date.
A tunable+sysctl, kern.cam.announce_nosbuf, exists for testing
purposes but will be removed later.
TODO:
Eliminate all of the code duplication and temporary buffers. The
old printf-based methods will be retired, and xpt_announce_periph()
will just be a wrapper that uses a dynamically sized sbuf. This
requires that the register and deregister paths be made malloc-safe,
which they aren't currently.
Sponsored by: Netflix
Modified:
head/sys/cam/ata/ata_all.c
head/sys/cam/ata/ata_all.h
head/sys/cam/ata/ata_da.c
head/sys/cam/ata/ata_xpt.c
head/sys/cam/cam_periph.c
head/sys/cam/cam_xpt.c
head/sys/cam/cam_xpt_internal.h
head/sys/cam/cam_xpt_periph.h
head/sys/cam/scsi/scsi_all.c
head/sys/cam/scsi/scsi_all.h
head/sys/cam/scsi/scsi_cd.c
head/sys/cam/scsi/scsi_da.c
head/sys/cam/scsi/scsi_enc.c
head/sys/cam/scsi/scsi_enc_internal.h
head/sys/cam/scsi/scsi_xpt.c
Modified: head/sys/cam/ata/ata_all.c
==
--- head/sys/cam/ata/ata_all.c Wed Apr 19 14:49:18 2017(r317142)
+++ head/sys/cam/ata/ata_all.c Wed Apr 19 15:04:52 2017(r317143)
@@ -382,12 +382,10 @@ void
ata_print_ident(struct ata_params *ident_data)
{
const char *proto;
- char product[48], revision[16], ata[12], sata[12];
+ char ata[12], sata[12];
+
+ ata_print_ident_short(ident_data);
- cam_strvis(product, ident_data->model, sizeof(ident_data->model),
- sizeof(product));
- cam_strvis(revision, ident_data->revision, sizeof(ident_data->revision),
- sizeof(revision));
proto = (ident_data->config == ATA_PROTO_CFA) ? "CFA" :
(ident_data->config & ATA_PROTO_ATAPI) ? "ATAPI" : "ATA";
if (ata_version(ident_data->version_major) == 0) {
@@ -412,7 +410,55 @@ ata_print_ident(struct ata_params *ident
snprintf(sata, sizeof(sata), " SATA");
} else
sata[0] = 0;
- printf("<%s %s> %s%s device\n", product, revision, ata, sata);
+ printf(" %s%s device\n", ata, sata);
+}
+
+void
+ata_print_ident_sbuf(struct ata_params *ident_data, struct sbuf *sb)
+{
+ const char *proto, *sata;
+ int version;
+
+ ata_print_ident_short_sbuf(ident_data, sb);
+ sbuf_printf(sb, " ");
+
+ proto = (ident_data->config == ATA_PROTO_CFA) ? "CFA" :
+ (ident_data->config & ATA_PROTO_ATAPI) ? "ATAPI" : "ATA";
+ version = ata_version(ident_data->version_major);
+
+ switch (version) {
+ case 0:
+ sbuf_printf(sb, "%s", proto);
+ break;
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ sbuf_printf(sb, "%s-%d", proto, version);
+ break;
+ case 8:
+ sbuf_printf(sb, "%s8-ACS", proto);
+ break;
+ default:
+ sbuf_printf(sb, "ACS-%d %s", version - 7, proto);
+ break;
+ }
+
+ if (ident_data->satacapabilities && ident_data->satacapabilities !=
0x) {
+ if (ident_data->satacapabilities & ATA_SATA_GEN3)
+ sata = " SATA 3.x";
+ else if (ident_data->satacapabilities & ATA_SATA_GEN2)
+ sata = " SATA 2.x";
+ else if (ident_data->satacapabilities & ATA_SATA_GEN1)
+ sata = " SATA 1.x";
+ else
+ sata = " SATA";
+ } else
+ sata = "";
+ sbuf_printf(sb, "%s device\n", sata);
}
void
@@ -428,18 +474,38 @@ ata_print_ident_short(struct ata_params
}
void
+ata_print_ident_short_sbuf(struct ata_params *ident_data, struct sbuf *sb)
+{
+
+ sbuf_printf(sb, "<");
+ cam_strvis_sbuf(sb, ident_data->model, sizeof(ident_data->model), 0);
+