Index: usr.sbin/bhyve/pci_nvme.c =================================================================== --- usr.sbin/bhyve/pci_nvme.c +++ usr.sbin/bhyve/pci_nvme.c @@ -351,6 +351,10 @@ struct nvme_feature_obj *, struct nvme_command *, struct nvme_completion *); +static void nvme_feature_temperature_threshold(struct pci_nvme_softc *, + struct nvme_feature_obj *, + struct nvme_command *, + struct nvme_completion *); static void nvme_feature_num_queues(struct pci_nvme_softc *, struct nvme_feature_obj *, struct nvme_command *, @@ -619,6 +623,8 @@ sc->feat[0].get = nvme_feature_invalid_cb; sc->feat[NVME_FEAT_LBA_RANGE_TYPE].namespace_specific = true; + sc->feat[NVME_FEAT_TEMPERATURE_THRESHOLD].get = + nvme_feature_temperature_threshold; sc->feat[NVME_FEAT_ERROR_RECOVERY].namespace_specific = true; sc->feat[NVME_FEAT_NUMBER_OF_QUEUES].set = nvme_feature_num_queues; sc->feat[NVME_FEAT_INTERRUPT_VECTOR_CONFIGURATION].set = @@ -1326,6 +1332,27 @@ } +static void +nvme_feature_temperature_threshold(struct pci_nvme_softc *sc, + struct nvme_feature_obj *feat, + struct nvme_command *command, + struct nvme_completion *compl) +{ + uint8_t thsel; /* Threshold Type Select */ + + thsel = (command->cdw11 >> 20) & 0x03; + + switch (thsel) { + case 0x00: /* Over Temperature Threshold */ + feat->cdw11 = sc->ctrldata.wctemp; + break; + case 0x01: /* Under Temperature Threshold */ + feat->cdw11 = sc->ctrldata.wctemp - 100; + break; + default: + pci_nvme_status_genc(&compl->status, NVME_SC_INVALID_FIELD); + } +} static void nvme_feature_num_queues(struct pci_nvme_softc *sc, struct nvme_feature_obj *feat,