This emulator is implemented according to NVMe specification 1.0, and didn't covered all. However, I tested using newfs and nvmecontrol perf manually; These ware cleared.
Unit Tests Skipped
I can't speak to the NVMe emulation itself (I know almost nothing about the protocol and nothing about Bhyve HW emu interfaces). Maybe Warner can.
indentation looks off here. is it just phabricator?
don't need trailing slash
style nit: static FILE *dbg; (asterisk goes on the right side of the space)
style nit: Should be tab indents throughout (can't tell if that's just Phab making it look like 4 spaces or actually 4 spaces).
I did a very quick one time scan down the code just to see what was here, these are my comments about it.
None of the functions have block start comments stating what that function does.
File is missing a copyright, and a $FreeBSD$, where did this code come from? Who wrote it?
style nit, extra blank line
Why is this code here and all commented out?
Leon Dang has also been working on NVMe emulation, and his version works with Linux, Windows and UEFI boot. I'll post that code for review since it is a bit more recent and tested. In the meantime, that version can be seen at www.freebsd.org/~grehan/pci_nvme.c
(There is also a version of UEFI with NVMe support compiled in at www.freebsd.org/~grehan/BHYVE_NVMe.fd.xz )
Overall, it is exciting to see this work being done. I realize the code is in its early stages and has asserts to help catch "the important" code paths, but it might be good to remove some of the asserts and have the commands set standard NVMe errors where appropriate.
style(9): Values in return statements should be enclosed in parentheses.
Indentation problem here and for several lines
It would be good to set the subclass and programming interface values. I.e.:
PCIR_SUBCLASS to 08h and
Note that both the values above have #defines in pcireg.h
style(9) (I think) nit; No return needed for void functions.