History log of /freebsd-current/sys/cam/nvme/nvme_xpt.c
Revision Date Author Comments
# 07c6a62b 02-May-2024 John Baldwin <jhb@FreeBSD.org>

cam: Add a XPORT_NVMF for NVMe over Fabrics sims

Reviewed by: ken, imp
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D44713


# 519b24f0 22-Nov-2023 Alexander Motin <mav@FreeBSD.org>

CAM: Replace random sbuf_printf() with cheaper cat/putc.


# fd9a4a67 06-Nov-2023 Warner Losh <imp@FreeBSD.org>

cam: Minor opt_cam.h cleanup

sys/cam/cam.h includes opt_cam.h, so none of the clients need to do
this. cam.h does all the right dancing to conditionally include
opt_cam.h only when it makes sense. It generally only matters when
cam_debug.h is included (it must be included before that). Many of the
stray opt_cam.h includes were after cam_debug.h which would be a problem
were it not included in cam/cam.h. The other users of CAM options that
aren't debug all already include cam/cam.h.

Also trim unneeded sys/cdefs.h files from the files touched.

Sponsored by: Netflix


# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# b2c44f1f 01-Aug-2023 John Baldwin <jhb@FreeBSD.org>

cam: Remove non-sbuf announce/denounce proto and xport ops

Reviewed by: mav, imp
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D41264


# 7eb53897 01-Aug-2023 John Baldwin <jhb@FreeBSD.org>

cam mmc_xpt/nvme_xpt: Add _sbuf variants of {an,de}nounce xport and proto ops

Reviewed by: imp
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D41261


# 0be27bde 01-Aug-2023 John Baldwin <jhb@FreeBSD.org>

cam/nvme: Remove spurious newline during periph detach announcement

Other protocol denounce routines use a "short" variant of announce
that does not include a trailing newline.

Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D41176


# 7f85b11c 24-Jul-2023 Warner Losh <imp@FreeBSD.org>

cam/nvme: Migrate to modern uintXX_t from u_intXX_t

As per https://lists.freebsd.org/archives/freebsd-scsi/2023-July/000257.html
move to the modern uintXX_t.

MFC After: 3 days
Sponsored by: Netflix


# af296130 26-Jun-2023 John Baldwin <jhb@FreeBSD.org>

nvme_xpt: Tidy nvme_announce_periph for fabrics support.

- Read the version from cts.protocol_version.

- Only check xport_specific.nvme for PCI-e info for XPORT_NVME.

Reviewed by: chuck, imp
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D40618


# 891c6986 07-Oct-2022 Warner Losh <imp@FreeBSD.org>

cam: Use FreeBSD standard copyright

For CAM, move to the FreeBSD standard copyright rather than the 'put it
at the front' variation. This variaiton has been flagged as potentially
problematic in other contexts. Since this variation wasn't a conscious
decision on our part, use the standard license from src/COPYRIGHT.
Also, remove the -FreeBSD suffix in SPDX-License-Identifier. It's
obsolete at SPDX and even the original text didn't match it.

MFC After: 3 days
Sponsored by: Netflix


# 3090d504 24-Jan-2022 Kenneth D. Merry <ken@FreeBSD.org>

Fix non-printable characters in NVMe model and serial numbers.

The NVMe 1.4 spec simply says that Model and Serial numbers are
ASCII strings. Unlike SCSI, it doesn't prohibit non-printable
characters or say that the strings should be padded with spaces.

Since 2014, we have had cam_strvis_sbuf(), which gives additional
options for handling non-ASCII characters. That behavior hasn't
been available for non-sbuf consumers, so users of cam_strvis()
were left with having octal ASCII codes inserted.

So, to avoid having garbage or octal chracters in the strings, use
cam_strvis_sbuf() to create a new function, cam_strvis_flag(), and
re-implement cam_strvis() using cam_strvis_flag().

Now, for the NVMe drives, we can use cam_strvis_flag with the
CAM_STRVIS_FLAG_NONASCII_SPC flag. This transforms non-printable
characters into spaces.

sys/cam/cam.c:
Add a new function, cam_strvis_flag(), that creates an sbuf
on the stack with the user's destination buffer, and calls
cam_strvis_sbuf() with the given flag argument.

Re-implement cam_strvis() to call cam_strvis_flag with the
CAM_STRVIS_FLAG_NONASCII_ESC argument. This should be the
equivalent of the old cam_strvis() function, except for the
overhead of creating the sbuf and calling sbuf_putc/printf.

sys/cam/cam.h:
Declaration for cam_strvis_flag.

sys/cam/nvme/nvme_all.c:
In nvme_print_ident, use the NONASCII_SPC flag with
cam_strvis_flag().

sys/cam/nvme/nvme_da.c:
In ndaregister(), use cam_strvis_flag() with the
NONASCII_SPC flag for the disk description and serial
number we report to GEOM.

sys/cam/nvme/nvme_xpt.c:
In nvme_probe_done(), use cam_strvis_flag with the
NONASCII_SPC flag when storing the drive serial number
in the CAM EDT.

MFC after: 1 week
Sponsored by: Spectra Logic
Differential Revision: https://reviews.freebsd.org/D33973


# 6637b746 23-Nov-2021 Warner Losh <imp@FreeBSD.org>

cam: Remove all the write-only variables

Delete all the write only variables in CAM. At worst, the only behavior
change would be to prevent core dumps from chasing NULL pointers (though
I think in all these cases the pointers can't be NULL).

Sponsored by: Netflix


# 431ddd94 21-May-2019 Young Xiao <92siuyang@gmail.com>

Fix potential NULL pointer dereference of device physical path

In ata_dev_advinfo() and nvme_dev_advinfo(), if the physical path is
being stored and there is a malloc failure (malloc(9) is called with
M_NOWAIT), we could wind up in a situation where the device's
physpath_len is set to the length the user provided, but the physpath
itself is NULL.

If another context then comes in to fetch the physical path value, we
would wind up trying to memcpy a NULL pointer into the caller's buffer.

So, set the physpath_len to 0 when we free the physpath on entry into
the store case for the physical path. Reset the length to a non-zero
value only after we've successfully malloced a buffer to hold it.

This code mirrors scsi_xpt.c does already as well.

Signed-off-by: Young Xiao <92siuyang@gmail.com>
Reviewed by: imp
PR: 238014


# ec5325db 10-Apr-2021 Edward Tomasz Napierala <trasz@FreeBSD.org>

cam: make sure to clear even more CCBs allocated on the stack

This is my second pass, this time over all of CAM except
for the SCSI target bits. There should be no functional
changes.

Reviewed By: imp
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D29549


# 27dcd3d9 01-Sep-2020 Mateusz Guzik <mjg@FreeBSD.org>

cam: clean up empty lines in .c and .h files


# 654f53ab 12-Aug-2020 Alexander Motin <mav@FreeBSD.org>

Fill device serial_num and device_id in NVMe XPT.

It allows to report GEOM::lunid for nda(4) same as for nvd(4). Since
NVMe now allows multiple LUs (namespaces) with multiple paths unique
LU identification is important. The serial_num field is filled same
as before with the controller serial number, while device_id is based
on namespace GUID and/or EUI64 fields as recommended by "NVM Express:
SCSI Translation Reference" and matching nvd(4) at the end.

MFC after: 1 week


# 9982b3ee 16-May-2020 Conrad Meyer <cem@FreeBSD.org>

cam: ANSIfy 0-argument function definitions

No functional change.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D24854


# 6a216c0b 29-Aug-2019 Alexander Motin <mav@FreeBSD.org>

Take proper lock in ses_setphyspath_callback().

XPT_DEV_ADVINFO call should be protected by the lock of the specific
device it is addressed to, not the lock of SES device. In some weird
case, probably with hardware violating standards, it sometimes caused
NULL dereference due to race.

To protect from it further, add lock assertion to *_dev_advinfo().

MFC after: 1 week
Sponsored by: iXsystems, Inc.


# b1f14710 07-Jun-2019 Chuck Tuffli <chuck@FreeBSD.org>

Fix nda(4) PCIe link status output

Differentiate between PCI Express Endpoint devices and Root Complex
Integrated Endpoints in the nda driver. The Link Status and Capability
registers are not valid for Integrated Endpoints and should not be
displayed. The bhyve emulated NVMe device will advertise as being an
Integrated Endpoint.

Reviewed by: imp
Approved byL imp (mentor)
Differential Revision: https://reviews.freebsd.org/D20282


# 9c91a265 22-May-2019 Alexander Motin <mav@FreeBSD.org>

Fix condition broken at r345815.

Reported by: danfe
MFC after: 3 days


# e40d8dbb 02-Apr-2019 Alexander Motin <mav@FreeBSD.org>

Make cam_error_print() decode NVMe commands.

MFC after: 2 weeks


# b0af0605 04-Jul-2018 Andriy Gapon <avg@FreeBSD.org>

remove unneeded inclusion of sys/interrupt.h from several files

It's likely that the header was needed in the past for swi(9).
But now that code does not use swi(9) or any other interfaces defined
in sys/interrupt.h.

MFC after: 1 week


# f439e3a4 24-May-2018 Alexander Motin <mav@FreeBSD.org>

Refactor NVMe CAM integration.

- Remove layering violation, when NVMe SIM code accessed CAM internal
device structures to set pointers on controller and namespace data.
Instead make NVMe XPT probe fetch the data directly from hardware.
- Cleanup NVMe SIM code, fixing support for multiple namespaces per
controller (reporting them as LUNs) and adding controller detach support
and run-time namespace change notifications.
- Add initial support for namespace change async events. So far only
in CAM mode, but it allows run-time namespace arrival and departure.
- Add missing nvme_notify_fail_consumers() call on controller detach.
Together with previous changes this allows NVMe device detach/unplug.

Non-CAM mode still requires a lot of love to stay on par, but at least
CAM mode code should not stay in the way so much, becoming much more
self-sufficient.

Reviewed by: imp
MFC after: 1 month
Sponsored by: iXsystems, Inc.


# 041f49ae 09-May-2018 Warner Losh <imp@FreeBSD.org>

Remove the 'All Rights Reserved' clause from some of the stuff I've
done for Netflix, since I'm in the neighborhood.


# 99e7a4ad 05-Feb-2018 Scott Long <scottl@FreeBSD.org>

Return a C errno for cam_periph_acquire().

There's no compelling reason to return a cam_status type for this
function and doing so only creates confusion with normal C
coding practices. It's technically an API change, but the periph API
isn't widely used. No efffective change to operation.

Reviewed by: imp, mav, ken
Sponsored by: Netflix
Differential Revision: D14063


# f24882ec 16-Jan-2018 Pedro F. Giffuni <pfg@FreeBSD.org>

SPDX: finish tagging sys/cam.


# 876f6a6a 09-Jan-2018 Scott Long <scottl@FreeBSD.org>

Release the held refcount on the probe periph when probing is
done, now that r327741 lets this happen.

Obtained from: Netflix


# 762a7f4f 06-Dec-2017 Warner Losh <imp@FreeBSD.org>

Define xpt_path_inq.

This provides a nice wrarpper around the XPT_PATH_INQ ccb creation and
calling.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D13387


# 5e8a39f6 13-Nov-2017 Warner Losh <imp@FreeBSD.org>

Properly decode NVMe state of the drive and print out the information
in the attach to more closely match what SCSI and ATA attached
storage provides.

Sponsored by: Netflix


# 4e3b2744 13-Nov-2017 Warner Losh <imp@FreeBSD.org>

Provide link speed data in XPT_GET_TRAN_SETTINGS. Provide full version
information for that and XPT_PATH_INQ. Provide macros to encode/decode
major/minor versions. Read the link speed and lane count to compute
the base_transfer_speed for XPT_PATH_INQ.

Sponsored by: Netflix


# 9f8ed7e4 29-Aug-2017 Warner Losh <imp@FreeBSD.org>

Fix NVMe's use of XPT_GDEV_TYPE

This patch changes the way XPT_GDEV_TYPE works for NVMe. The current
ccb_getdev structure includes pointers to the NVMe Identify Controller
and Namespace structures, but these are kernel virtual addresses which
are not accessible from user space.

As an alternative, the patch changes the pointers into padding in
ccb_getdev and adds two new types to ccb_dev_advinfo to retrieve the
Identify Controller (CDAI_TYPE_NVME_CNTRL) and Namespace
(CDAI_TYPE_NVME_NS) data structures.

Reviewed By: rpokala, imp
Differential Revision: https://reviews.freebsd.org/D10466
Submitted by: Chuck Tuffli


# 08f13879 28-Jul-2016 Warner Losh <imp@FreeBSD.org>

Move protocol specific stuff into a linker set object that's
per-protocol. This reduces the number scsi symbols references by
cam_xpt significantly, and eliminates all ata / nvme symbols. There's
still some NVME / ATA specific code for dealing with XPT_NVME_IO and
XPT_ATA_IO respectively, and a bunch of scsi-specific code, but this
is progress.

Differential Revision: https://reviews.freebsd.org/D7289


# ded2b706 28-Jul-2016 Warner Losh <imp@FreeBSD.org>

Switch to linker sets to find the xport callback object. This
eliminates the need to special case everything in cam_xpt for new
transports. It is now a failure to not have a transport object when
registering the bus as well. You can still, however, create a
transport that's unspecified (XPT_)

Differential Revision: https://reviews.freebsd.org/D7289


# 964fee41 25-Jul-2016 Warner Losh <imp@FreeBSD.org>

Remove some extraneous printfs.


# e0ce51cb 20-Jul-2016 Warner Losh <imp@FreeBSD.org>

Remove some bogus comments and printfs. Also, we can't
cam_periph_releaes_locked() at the end of nvme_probe_start because we
hit an assertion which may be bogus. Instead, leak a periph until we
sort it out. Since these devices don't arrive and depart often, so
this is the lessor of two evils.

MFC after: 1 week


# f24c011b 10-Jun-2016 Warner Losh <imp@FreeBSD.org>

Commit the bits of nda that were missed. This should fix the build.

Approved by: re@


# baabaca3 09-Jun-2016 Warner Losh <imp@FreeBSD.org>

New NVMe front end (nda).