diff --git a/sys/dev/nvme/nvme.h b/sys/dev/nvme/nvme.h --- a/sys/dev/nvme/nvme.h +++ b/sys/dev/nvme/nvme.h @@ -643,6 +643,14 @@ #define NVME_FEAT_SET_FID_SHIFT (0) #define NVME_FEAT_SET_FID_MASK (0xff) +/* Async Events */ +#define NVME_ASYNC_EVENT_TYPE_SHIFT (0) +#define NVME_ASYNC_EVENT_TYPE_MASK (0x7) +#define NVME_ASYNC_EVENT_INFO_SHIFT (8) +#define NVME_ASYNC_EVENT_INFO_MASK (0xff) +#define NVME_ASYNC_EVENT_LOG_PAGE_ID_SHIFT (16) +#define NVME_ASYNC_EVENT_LOG_PAGE_ID_MASK (0xff) + /* Helper macro to combine *_MASK and *_SHIFT defines */ #define NVMEM(name) (name##_MASK << name##_SHIFT) diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c --- a/sys/dev/nvme/nvme_ctrlr.c +++ b/sys/dev/nvme/nvme_ctrlr.c @@ -783,10 +783,11 @@ } /* Associated log page is in bits 23:16 of completion entry dw0. */ - aer->log_page_id = (cpl->cdw0 & 0xFF0000) >> 16; + aer->log_page_id = NVMEV(NVME_ASYNC_EVENT_LOG_PAGE_ID, cpl->cdw0); nvme_printf(aer->ctrlr, "async event occurred (type 0x%x, info 0x%02x," - " page 0x%02x)\n", (cpl->cdw0 & 0x07), (cpl->cdw0 & 0xFF00) >> 8, + " page 0x%02x)\n", NVMEV(NVME_ASYNC_EVENT_TYPE, cpl->cdw0), + NVMEV(NVME_ASYNC_EVENT_INFO, cpl->cdw0), aer->log_page_id); if (is_log_page_id_valid(aer->log_page_id)) {