FreeBSD kernel CAM code
|
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/bio.h>
#include <sys/sysctl.h>
#include <sys/taskqueue.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/conf.h>
#include <sys/devicestat.h>
#include <sys/eventhandler.h>
#include <sys/malloc.h>
#include <sys/cons.h>
#include <sys/proc.h>
#include <sys/reboot.h>
#include <sys/sbuf.h>
#include <geom/geom.h>
#include <geom/geom_disk.h>
#include <cam/cam.h>
#include <cam/cam_ccb.h>
#include <cam/cam_periph.h>
#include <cam/cam_xpt_periph.h>
#include <cam/cam_sim.h>
#include <cam/cam_iosched.h>
#include <cam/nvme/nvme_all.h>
Go to the source code of this file.
Data Structures | |
struct | nda_softc |
struct | nda_trim_request |
Macros | |
#define | NDA_FLAG_STRING |
#define | NDA_Q_BIT_STRING |
#define | ccb_state ccb_h.ppriv_field0 |
#define | ccb_bp ccb_h.ppriv_ptr1 /* For NDA_CCB_BUFFER_IO */ |
#define | ccb_trim ccb_h.ppriv_ptr1 /* For NDA_CCB_TRIM */ |
#define | NDA_DEFAULT_SEND_ORDERED 1 |
#define | NDA_DEFAULT_TIMEOUT 30 /* Timeout in seconds */ |
#define | NDA_DEFAULT_RETRY 4 |
#define | NDA_MAX_TRIM_ENTRIES (NVME_MAX_DSM_TRIM / sizeof(struct nvme_dsm_range))/* Number of DSM trims to use, max 256 */ |
Enumerations | |
enum | nda_state { NDA_STATE_NORMAL } |
enum | nda_flags { NDA_FLAG_OPEN = 0x0001 , NDA_FLAG_DIRTY = 0x0002 , NDA_FLAG_SCTX_INIT = 0x0004 } |
enum | nda_quirks { NDA_Q_4K = 0x01 , NDA_Q_NONE = 0x00 } |
enum | nda_ccb_state { NDA_CCB_BUFFER_IO = 0x01 , NDA_CCB_DUMP = 0x02 , NDA_CCB_TRIM = 0x03 , NDA_CCB_PASS = 0x04 , NDA_CCB_TYPE_MASK = 0x0F } |
Functions | |
__FBSDID ("$FreeBSD$") | |
_Static_assert (NVME_MAX_DSM_TRIM % sizeof(struct nvme_dsm_range)==0, "NVME_MAX_DSM_TRIM must be an integral number of ranges") | |
static void | ndaasync (void *callback_arg, u_int32_t code, struct cam_path *path, void *arg) |
static void | ndasysctlinit (void *context, int pending) |
static int | ndaflagssysctl (SYSCTL_HANDLER_ARGS) |
static void | ndadone (struct cam_periph *periph, union ccb *done_ccb) |
static int | ndaerror (union ccb *ccb, u_int32_t cam_flags, u_int32_t sense_flags) |
static void | ndashutdown (void *arg, int howto) |
static void | ndasuspend (void *arg) |
static | SYSCTL_NODE (_kern_cam, OID_AUTO, nda, CTLFLAG_RD|CTLFLAG_MPSAFE, 0, "CAM Direct Access Disk driver") |
SYSCTL_INT (_kern_cam_nda, OID_AUTO, max_trim, CTLFLAG_RDTUN, &nda_max_trim_entries, NDA_MAX_TRIM_ENTRIES, "Maximum number of BIO_DELETE to send down as a DSM TRIM.") | |
SYSCTL_INT (_kern_cam_nda, OID_AUTO, enable_biospeedup, CTLFLAG_RDTUN, &nda_enable_biospeedup, 0, "Enable BIO_SPEEDUP processing.") | |
SYSCTL_INT (_kern_cam_nda, OID_AUTO, nvd_compat, CTLFLAG_RDTUN, &nda_nvd_compat, 1, "Enable creation of nvd aliases.") | |
PERIPHDRIVER_DECLARE (nda, ndadriver) | |
static | MALLOC_DEFINE (M_NVMEDA, "nvme_da", "nvme_da buffers") |
static void | nda_nvme_flush (struct nda_softc *softc, struct ccb_nvmeio *nvmeio) |
static void | nda_nvme_trim (struct nda_softc *softc, struct ccb_nvmeio *nvmeio, void *payload, uint32_t num_ranges) |
static void | nda_nvme_write (struct nda_softc *softc, struct ccb_nvmeio *nvmeio, void *payload, uint64_t lba, uint32_t len, uint32_t count) |
static void | nda_nvme_rw_bio (struct nda_softc *softc, struct ccb_nvmeio *nvmeio, struct bio *bp, uint32_t rwcmd) |
static int | ndaopen (struct disk *dp) |
static int | ndaclose (struct disk *dp) |
static void | ndaschedule (struct cam_periph *periph) |
static int | ndaioctl (struct disk *dp, u_long cmd, void *data, int fflag, struct thread *td) |
static void | ndastrategy (struct bio *bp) |
static int | ndadump (void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t length) |
static void | ndadiskgonecb (struct disk *dp) |
static void | ndaoninvalidate (struct cam_periph *periph) |
static void | ndacleanup (struct cam_periph *periph) |
static int | ndagetattr (struct bio *bp) |
static cam_status | ndaregister (struct cam_periph *periph, void *arg) |
static void | ndastart (struct cam_periph *periph, union ccb *start_ccb) |
static void | ndaflush (void) |
Variables | |
static disk_ioctl_t | ndaioctl |
static disk_strategy_t | ndastrategy |
static dumper_t | ndadump |
static periph_init_t | ndainit |
static periph_ctor_t | ndaregister |
static periph_dtor_t | ndacleanup |
static periph_start_t | ndastart |
static periph_oninv_t | ndaoninvalidate |
static int | nda_send_ordered = NDA_DEFAULT_SEND_ORDERED |
static int | nda_default_timeout = NDA_DEFAULT_TIMEOUT |
static int | nda_max_trim_entries = NDA_MAX_TRIM_ENTRIES |
static int | nda_enable_biospeedup = 1 |
static int | nda_nvd_compat = 1 |
static int | nda_rotating_media = 0 |
static struct periph_driver | ndadriver |
#define ccb_bp ccb_h.ppriv_ptr1 /* For NDA_CCB_BUFFER_IO */ |
#define ccb_state ccb_h.ppriv_field0 |
#define ccb_trim ccb_h.ppriv_ptr1 /* For NDA_CCB_TRIM */ |
#define NDA_FLAG_STRING |
#define NDA_MAX_TRIM_ENTRIES (NVME_MAX_DSM_TRIM / sizeof(struct nvme_dsm_range))/* Number of DSM trims to use, max 256 */ |
enum nda_ccb_state |
enum nda_flags |
enum nda_quirks |
__FBSDID | ( | "$FreeBSD$" | ) |
_Static_assert | ( | NVME_MAX_DSM_TRIM % | sizeofstruct nvme_dsm_range = =0 , |
"NVME_MAX_DSM_TRIM must be an integral number of ranges" | |||
) |
|
static |
|
static |
Definition at line 221 of file nvme_da.c.
References CAM_DIR_NONE, cam_fill_nvmeio(), ccb_nvmeio::cmd, nda_default_timeout, ndadone(), and nda_softc::nsid.
Referenced by ndaclose(), ndadump(), ndaflush(), and ndastart().
|
static |
Definition at line 262 of file nvme_da.c.
References CAM_DATA_BIO, CAM_DIR_IN, CAM_DIR_OUT, cam_fill_nvmeio(), ccb_nvmeio::cmd, nda_softc::disk, periph_driver::flags, nda_default_timeout, ndadone(), and nda_softc::nsid.
Referenced by ndastart().
|
static |
Definition at line 234 of file nvme_da.c.
References CAM_DIR_OUT, cam_fill_nvmeio(), ccb_nvmeio::cmd, nda_default_timeout, ndadone(), and nda_softc::nsid.
Referenced by ndastart().
|
static |
Definition at line 248 of file nvme_da.c.
References CAM_DIR_OUT, cam_fill_nvmeio(), ccb_nvmeio::cmd, nda_default_timeout, ndadone(), and nda_softc::nsid.
Referenced by ndadump().
|
static |
Definition at line 644 of file nvme_da.c.
References AC_ADVINFO_CHANGED, AC_FOUND_DEVICE, AC_LOST_DEVICE, cam_periph_alloc(), cam_periph_async(), CAM_PERIPH_BIO, CAM_REQ_CMP, CAM_REQ_INPROG, CDAI_TYPE_PHYS_PATH, nda_softc::disk, ndaasync(), ndacleanup, ndaoninvalidate, ndaregister, ndastart, PROTO_NVME, ccb_getdev::protocol, and cam_periph::softc.
Referenced by ndaasync(), ndaoninvalidate(), and ndaregister().
|
static |
Definition at line 614 of file nvme_da.c.
References nda_softc::cam_iosched, cam_iosched_fini(), cam_periph_lock, cam_periph_unlock, nda_softc::disk, nda_softc::flags, NDA_FLAG_SCTX_INIT, cam_periph::path, cam_periph::softc, nda_softc::sysctl_ctx, and xpt_print().
|
static |
Definition at line 321 of file nvme_da.c.
References CAM_DEBUG, CAM_DEBUG_PERIPH, CAM_DEBUG_TRACE, cam_periph_getccb(), cam_periph_hold(), CAM_PERIPH_INVALID, cam_periph_lock, cam_periph_release(), cam_periph_runccb(), cam_periph_sleep, cam_periph_unhold(), cam_periph_unlock, CAM_PRIORITY_NORMAL, ccb, cam_periph::flags, NDA_FLAG_DIRTY, nda_nvme_flush(), ndaerror(), ccb::nvmeio, cam_periph::path, cam_periph::softc, xpt_print(), and xpt_release_ccb().
Referenced by ndaregister().
|
static |
Definition at line 579 of file nvme_da.c.
References cam_periph_release().
Referenced by ndaregister().
|
static |
Definition at line 1153 of file nvme_da.c.
References CAM_DEBUG, CAM_DEBUG_TRACE, CAM_DEV_QFRZN, nda_softc::cam_iosched, cam_iosched_bio_complete(), cam_periph_lock, cam_periph_unlock, cam_release_devq(), CAM_REQ_CMP, CAM_STATUS_MASK, ccb::ccb_h, NDA_CCB_BUFFER_IO, NDA_CCB_DUMP, NDA_CCB_PASS, NDA_CCB_TRIM, NDA_CCB_TYPE_MASK, ndaerror(), ndaschedule(), ccb::nvmeio, nda_softc::outstanding_cmds, ccb_hdr::path, cam_periph::softc, nda_softc::state, ccb_hdr::status, TAILQ_HEAD(), and xpt_release_ccb().
Referenced by nda_nvme_flush(), nda_nvme_rw_bio(), nda_nvme_trim(), nda_nvme_write(), and ndaioctl().
|
static |
Definition at line 502 of file nvme_da.c.
References cam_periph_error(), CAM_PERIPH_INVALID, cam_periph_runccb(), CAM_PRIORITY_NORMAL, ccb_nvmeio::ccb_h, nda_softc::disk, cam_periph::flags, NDA_CCB_DUMP, nda_nvme_flush(), nda_nvme_write(), cam_periph::path, SF_NO_RECOVERY, SF_NO_RETRY, cam_periph::softc, xpt_print(), and xpt_setup_ccb().
|
static |
Definition at line 1270 of file nvme_da.c.
References CAM_ATA_STATUS_ERROR, CAM_CMD_TIMEOUT, CAM_DATA_RUN_ERR, cam_periph_error(), CAM_REQ_ABORTED, CAM_REQ_CMP_ERR, CAM_REQ_TERMIO, CAM_STATUS_MASK, CAM_UNREC_HBA_ERROR, ccb::ccb_h, ccb_hdr::path, cam_periph::softc, ccb_hdr::status, and xpt_path_periph().
Referenced by ndaclose(), ndadone(), and ndaflush().
|
static |
Definition at line 801 of file nvme_da.c.
References nda_softc::flags, and NDA_FLAG_STRING.
Referenced by ndasysctlinit().
|
static |
Definition at line 1308 of file nvme_da.c.
References CAM_PERIPH_FOREACH, cam_periph_getccb(), cam_periph_lock, cam_periph_owned, cam_periph_runccb(), cam_periph_unlock, CAM_PRIORITY_NORMAL, ccb, nda_softc::disk, nda_softc::flags, NDA_FLAG_OPEN, nda_nvme_flush(), ndadriver, ndadump, ndaerror(), ccb::nvmeio, cam_periph::path, SF_NO_RECOVERY, SF_NO_RETRY, cam_periph::softc, xpt_print(), and xpt_release_ccb().
Referenced by ndashutdown(), and ndasuspend().
|
static |
Definition at line 819 of file nvme_da.c.
References cam_periph_lock, cam_periph_unlock, nda_enable_biospeedup, cam_periph::path, and xpt_getattr().
Referenced by ndaregister().
|
static |
Definition at line 374 of file nvme_da.c.
References CAM_DATA_VADDR, CAM_DIR_IN, CAM_DIR_OUT, cam_fill_nvmeio(), cam_periph_lock, cam_periph_mapmem(), cam_periph_runccb(), cam_periph_unlock, cam_periph_unmapmem(), CAM_PRIORITY_NORMAL, CAM_REQ_CMP, CAM_RETRY_SELTO, ccb, ccb::ccb_h, ccb_nvmeio::cmd, ccb_pathinq_settings_nvme::dev_name, NDA_CCB_PASS, nda_default_timeout, ndadone(), ccb_pathinq_settings_nvme::nsid, ccb_pathinq::nvme, ccb::nvmeio, cam_periph::path, SF_NO_PRINT, SF_RETRY_UA, ccb_hdr::status, ccb_pathinq::xport_specific, xpt_alloc_ccb(), xpt_path_inq(), xpt_release_ccb(), and xpt_setup_ccb().
|
static |
Definition at line 589 of file nvme_da.c.
References nda_softc::cam_iosched, cam_iosched_flush(), nda_softc::disk, ndaasync(), cam_periph::path, cam_periph::softc, and xpt_register_async().
|
static |
Definition at line 291 of file nvme_da.c.
References CAM_DEBUG, CAM_DEBUG_PERIPH, CAM_DEBUG_TRACE, cam_periph_acquire(), cam_periph_hold(), cam_periph_lock, cam_periph_release(), cam_periph_unhold(), cam_periph_unlock, nda_softc::flags, NDA_FLAG_OPEN, cam_periph::path, and cam_periph::softc.
Referenced by ndaregister().
|
static |
Definition at line 838 of file nvme_da.c.
References AC_ADVINFO_CHANGED, AC_LOST_DEVICE, nda_softc::cam_iosched, cam_iosched_init(), cam_iosched_set_sort_queue(), cam_periph_acquire(), cam_periph_hold(), cam_periph_lock, cam_periph_unhold(), cam_periph_unlock, CAM_REQ_CMP, CAM_REQ_CMP_ERR, cam_sim_pollable(), cam_strvis_flag(), CAM_STRVIS_FLAG_NONASCII_SPC, ccb_pathinq::dev_name, nda_softc::disk, ccb_pathinq::hba_device, ccb_pathinq::hba_misc, ccb_pathinq::hba_subdevice, ccb_pathinq::hba_subvendor, ccb_pathinq::hba_vendor, ccb_pathinq::maxio, nda_nvd_compat, NDA_Q_BIT_STRING, NDA_Q_NONE, NDA_STATE_NORMAL, ndaasync(), ndaclose(), ndadiskgonecb(), ndadump, ndagetattr(), ndaioctl, ndaopen(), ndastrategy, ndasysctlinit(), nda_softc::nsid, nvme_get_identify_cntrl(), nvme_get_identify_ns(), cam_periph::path, cam_periph::periph_name, PIM_UNMAPPED, nda_softc::quirks, cam_periph::sim, cam_periph::softc, nda_softc::state, nda_softc::sysctl_task, ccb_pathinq::transport, ccb_pathinq::unit_number, cam_periph::unit_number, nda_softc::unmappedio, XPORT_DEVSTAT_TYPE, xpt_announce_periph(), xpt_announce_quirks(), xpt_path_inq(), xpt_path_lun_id(), xpt_print(), and xpt_register_async().
|
static |
Definition at line 363 of file nvme_da.c.
References nda_softc::cam_iosched, cam_iosched_schedule(), NDA_STATE_NORMAL, cam_periph::softc, and nda_softc::state.
Referenced by ndadone(), ndastart(), and ndastrategy().
|
static |
Definition at line 1354 of file nvme_da.c.
References ndaflush().
|
static |
Definition at line 1004 of file nvme_da.c.
References CAM_DEBUG, CAM_DEBUG_TRACE, nda_softc::cam_iosched, cam_iosched_next_bio(), cam_iosched_next_trim(), cam_periph_lock, cam_periph_unlock, CAM_UNLOCKED, ccb::ccb_h, nda_softc::disk, nda_trim_request::dsm, ccb_hdr::flags, nda_softc::flags, NDA_CCB_BUFFER_IO, NDA_CCB_TRIM, NDA_FLAG_DIRTY, nda_max_trim_entries, nda_nvme_flush(), nda_nvme_rw_bio(), nda_nvme_trim(), NDA_STATE_NORMAL, ndaschedule(), ccb::nvmeio, nda_softc::outstanding_cmds, cam_periph::path, nda_softc::refcount, cam_periph::softc, nda_softc::state, nda_softc::trim_count, nda_softc::trim_lbas, nda_softc::trim_ranges, xpt_action(), and xpt_release_ccb().
|
static |
Definition at line 463 of file nvme_da.c.
References CAM_DEBUG, CAM_DEBUG_TRACE, cam_iosched_queue_work(), CAM_PERIPH_INVALID, cam_periph_lock, cam_periph_unlock, cam_periph::flags, ndaschedule(), cam_periph::path, and cam_periph::softc.
|
static |
Definition at line 1361 of file nvme_da.c.
References ndaflush().
|
static |
Definition at line 702 of file nvme_da.c.
References nda_softc::cam_iosched, cam_iosched_sysctl_init(), CAM_PERIPH_INVALID, cam_periph_invalidate_sysctl(), cam_periph_release(), nda_softc::deletes, cam_periph::flags, nda_softc::flags, NDA_FLAG_SCTX_INIT, nda_rotating_media, ndaflagssysctl(), cam_periph::softc, nda_softc::sysctl_ctx, nda_softc::sysctl_tree, nda_softc::trim_count, nda_softc::trim_lbas, nda_softc::trim_ranges, cam_periph::unit_number, and nda_softc::unmappedio.
Referenced by ndaregister().
PERIPHDRIVER_DECLARE | ( | nda | , |
ndadriver | |||
) |
SYSCTL_INT | ( | _kern_cam_nda | , |
OID_AUTO | , | ||
enable_biospeedup | , | ||
CTLFLAG_RDTUN | , | ||
& | nda_enable_biospeedup, | ||
0 | , | ||
"Enable BIO_SPEEDUP processing." | |||
) |
SYSCTL_INT | ( | _kern_cam_nda | , |
OID_AUTO | , | ||
max_trim | , | ||
CTLFLAG_RDTUN | , | ||
& | nda_max_trim_entries, | ||
NDA_MAX_TRIM_ENTRIES | , | ||
"Maximum number of BIO_DELETE to send down as a DSM TRIM." | |||
) |
SYSCTL_INT | ( | _kern_cam_nda | , |
OID_AUTO | , | ||
nvd_compat | , | ||
CTLFLAG_RDTUN | , | ||
& | nda_nvd_compat, | ||
1 | , | ||
"Enable creation of nvd aliases." | |||
) |
|
static |
|
static |
Definition at line 185 of file nvme_da.c.
Referenced by nda_nvme_flush(), nda_nvme_rw_bio(), nda_nvme_trim(), nda_nvme_write(), and ndaioctl().
|
static |
Definition at line 187 of file nvme_da.c.
Referenced by ndagetattr().
|
static |
Definition at line 186 of file nvme_da.c.
Referenced by ndastart().
|
static |
Definition at line 188 of file nvme_da.c.
Referenced by ndaregister().
|
static |
Definition at line 201 of file nvme_da.c.
Referenced by ndasysctlinit().
|
static |
|
static |
Definition at line 157 of file nvme_da.c.
Referenced by ndaasync().
|
static |
Definition at line 203 of file nvme_da.c.
Referenced by ndaflush().
|
static |
Definition at line 150 of file nvme_da.c.
Referenced by ndaflush(), and ndaregister().
|
static |
Definition at line 148 of file nvme_da.c.
Referenced by ndaregister().
|
static |
Definition at line 159 of file nvme_da.c.
Referenced by ndaasync().
|
static |
Definition at line 156 of file nvme_da.c.
Referenced by ndaasync().
|
static |
Definition at line 158 of file nvme_da.c.
Referenced by ndaasync().
|
static |
Definition at line 149 of file nvme_da.c.
Referenced by ndaregister().