git: 6f76d493864b - main - nvme: Remove duplicate completion printing routine
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 07 Aug 2023 22:45:37 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=6f76d493864b976d1eaea22eba59407319f6e327
commit 6f76d493864b976d1eaea22eba59407319f6e327
Author: Warner Losh <imp@FreeBSD.org>
AuthorDate: 2023-08-07 22:34:25 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-08-07 22:44:30 +0000
nvme: Remove duplicate completion printing routine
Both nvme_dump_completion and nvme_qpair_print_completion print
completions. The latter is better. Recode the two instances of
nvme_dump_completion to use nvme_qpair_print_completion and delete the
former. No sense having two nearly identical routines. A future commit
will convert this to sbuf.
Sponsored by: Netflix
Reviewed by: chuck
Differential Revision: https://reviews.freebsd.org/D41308
---
sys/dev/nvme/nvme.c | 21 ---------------------
sys/dev/nvme/nvme_private.h | 3 ++-
sys/dev/nvme/nvme_qpair.c | 13 +++++++------
sys/dev/nvme/nvme_sysctl.c | 2 +-
4 files changed, 10 insertions(+), 29 deletions(-)
diff --git a/sys/dev/nvme/nvme.c b/sys/dev/nvme/nvme.c
index 316cd8934036..22d197dc9367 100644
--- a/sys/dev/nvme/nvme.c
+++ b/sys/dev/nvme/nvme.c
@@ -95,27 +95,6 @@ nvme_dump_command(struct nvme_command *cmd)
le32toh(cmd->cdw13), le32toh(cmd->cdw14), le32toh(cmd->cdw15));
}
-void
-nvme_dump_completion(struct nvme_completion *cpl)
-{
- uint8_t p, sc, sct, crd, m, dnr;
- uint16_t status;
-
- status = le16toh(cpl->status);
-
- p = NVME_STATUS_GET_P(status);
- sc = NVME_STATUS_GET_SC(status);
- sct = NVME_STATUS_GET_SCT(status);
- crd = NVME_STATUS_GET_CRD( status);
- m = NVME_STATUS_GET_M(status);
- dnr = NVME_STATUS_GET_DNR(status);
-
- printf("cdw0:%08x sqhd:%04x sqid:%04x "
- "cid:%04x p:%x sc:%02x sct:%x crd:%x m:%x dnr:%x\n",
- le32toh(cpl->cdw0), le16toh(cpl->sqhd), le16toh(cpl->sqid),
- cpl->cid, p, sc, sct, crd, m, dnr);
-}
-
int
nvme_attach(device_t dev)
{
diff --git a/sys/dev/nvme/nvme_private.h b/sys/dev/nvme/nvme_private.h
index 370bd0dccf20..95915902642e 100644
--- a/sys/dev/nvme/nvme_private.h
+++ b/sys/dev/nvme/nvme_private.h
@@ -444,7 +444,8 @@ void nvme_ns_destruct(struct nvme_namespace *ns);
void nvme_sysctl_initialize_ctrlr(struct nvme_controller *ctrlr);
void nvme_dump_command(struct nvme_command *cmd);
-void nvme_dump_completion(struct nvme_completion *cpl);
+void nvme_qpair_print_completion(struct nvme_qpair *qpair,
+ struct nvme_completion *cpl);
int nvme_attach(device_t dev);
int nvme_shutdown(device_t dev);
diff --git a/sys/dev/nvme/nvme_qpair.c b/sys/dev/nvme/nvme_qpair.c
index dffbaba8deca..a09be6bba7d9 100644
--- a/sys/dev/nvme/nvme_qpair.c
+++ b/sys/dev/nvme/nvme_qpair.c
@@ -341,21 +341,22 @@ get_status_string(uint16_t sct, uint16_t sc)
return (entry->str);
}
-static void
+void
nvme_qpair_print_completion(struct nvme_qpair *qpair,
struct nvme_completion *cpl)
{
- uint8_t sct, sc, crd, m, dnr;
+ uint8_t sct, sc, crd, m, dnr, p;
sct = NVME_STATUS_GET_SCT(cpl->status);
sc = NVME_STATUS_GET_SC(cpl->status);
crd = NVME_STATUS_GET_CRD(cpl->status);
m = NVME_STATUS_GET_M(cpl->status);
dnr = NVME_STATUS_GET_DNR(cpl->status);
+ p = NVME_STATUS_GET_P(cpl->status);
- nvme_printf(qpair->ctrlr, "%s (%02x/%02x) crd:%x m:%x dnr:%x "
+ nvme_printf(qpair->ctrlr, "%s (%02x/%02x) crd:%x m:%x dnr:%x p:%d "
"sqid:%d cid:%d cdw0:%x\n",
- get_status_string(sct, sc), sct, sc, crd, m, dnr,
+ get_status_string(sct, sc), sct, sc, crd, m, dnr, p,
cpl->sqid, cpl->cid, cpl->cdw0);
}
@@ -654,8 +655,8 @@ nvme_qpair_process_completions(struct nvme_qpair *qpair)
nvme_printf(qpair->ctrlr,
"cpl (cid = %u) does not map to outstanding cmd\n",
cpl.cid);
- /* nvme_dump_completion expects device endianess */
- nvme_dump_completion(&qpair->cpl[qpair->cq_head]);
+ nvme_qpair_print_completion(qpair,
+ &qpair->cpl[qpair->cq_head]);
KASSERT(0, ("received completion for unknown cmd"));
}
diff --git a/sys/dev/nvme/nvme_sysctl.c b/sys/dev/nvme/nvme_sysctl.c
index c238c86af5a2..a48dad04d90f 100644
--- a/sys/dev/nvme/nvme_sysctl.c
+++ b/sys/dev/nvme/nvme_sysctl.c
@@ -65,7 +65,7 @@ nvme_dump_queue(struct nvme_qpair *qpair)
for (i = 0; i < qpair->num_entries; i++) {
cpl = &qpair->cpl[i];
printf("%05d: ", i);
- nvme_dump_completion(cpl);
+ nvme_qpair_print_completion(qpair, cpl);
}
printf("Submission queue:\n");