FreeBSD kernel CAM code
nvme_xpt.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/endian.h>
#include <sys/systm.h>
#include <sys/types.h>
#include <sys/malloc.h>
#include <sys/kernel.h>
#include <sys/time.h>
#include <sys/conf.h>
#include <sys/fcntl.h>
#include <sys/sbuf.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/sysctl.h>
#include <cam/cam.h>
#include <cam/cam_ccb.h>
#include <cam/cam_queue.h>
#include <cam/cam_periph.h>
#include <cam/cam_sim.h>
#include <cam/cam_xpt.h>
#include <cam/cam_xpt_sim.h>
#include <cam/cam_xpt_periph.h>
#include <cam/cam_xpt_internal.h>
#include <cam/cam_debug.h>
#include <cam/scsi/scsi_all.h>
#include <cam/scsi/scsi_message.h>
#include <cam/nvme/nvme_all.h>
#include <machine/stdarg.h>
#include "opt_cam.h"
Include dependency graph for nvme_xpt.c:

Go to the source code of this file.

Data Structures

struct  nvme_quirk_entry
 
struct  nvme_probe_softc
 

Macros

#define CAM_QUIRK_MAXTAGS   1
 
#define NVME_PROBE_SET_ACTION(softc, newaction)
 
#define NVME_XPT_XPORT(x, X)
 

Enumerations

enum  nvme_probe_action { NVME_PROBE_IDENTIFY_CD , NVME_PROBE_IDENTIFY_NS , NVME_PROBE_DONE , NVME_PROBE_INVALID }
 
enum  nvme_probe_flags { NVME_PROBE_NO_ANNOUNCE = 0x04 }
 

Functions

 __FBSDID ("$FreeBSD$")
 
 PERIPHDRIVER_DECLARE (nvme_probe, nvme_probe_driver)
 
static cam_status nvme_probe_register (struct cam_periph *periph, void *arg)
 
static void nvme_probe_schedule (struct cam_periph *nvme_probe_periph)
 
static void nvme_probe_start (struct cam_periph *periph, union ccb *start_ccb)
 
static void nvme_probe_done (struct cam_periph *periph, union ccb *done_ccb)
 
static void nvme_probe_cleanup (struct cam_periph *periph)
 
static void nvme_scan_lun (struct cam_periph *periph, struct cam_path *path, cam_flags flags, union ccb *ccb)
 
static struct cam_ednvme_alloc_device (struct cam_eb *bus, struct cam_et *target, lun_id_t lun_id)
 
static void nvme_device_transport (struct cam_path *path)
 
static void nvme_dev_async (u_int32_t async_code, struct cam_eb *bus, struct cam_et *target, struct cam_ed *device, void *async_arg)
 
static void nvme_action (union ccb *start_ccb)
 
static void nvme_announce_periph (struct cam_periph *periph)
 
static void nvme_proto_announce (struct cam_ed *device)
 
static void nvme_proto_denounce (struct cam_ed *device)
 
static void nvme_proto_debug_out (union ccb *ccb)
 
 NVME_XPT_XPORT (nvme, NVME)
 
 CAM_XPT_PROTO (nvme_proto)
 
static void nvme_dev_advinfo (union ccb *start_ccb)
 

Variables

static periph_init_t nvme_probe_periph_init
 
static struct periph_driver nvme_probe_driver
 
static char * nvme_probe_action_text []
 
static struct nvme_quirk_entry nvme_quirk_table []
 
static const int nvme_quirk_table_size
 
static struct xpt_xport_ops nvme_xport_ops
 
static struct xpt_proto_ops nvme_proto_ops
 
static struct xpt_proto nvme_proto
 

Macro Definition Documentation

◆ CAM_QUIRK_MAXTAGS

#define CAM_QUIRK_MAXTAGS   1

Definition at line 68 of file nvme_xpt.c.

◆ NVME_PROBE_SET_ACTION

#define NVME_PROBE_SET_ACTION (   softc,
  newaction 
)
Value:
do { \
char **text; \
CAM_DEBUG((softc)->periph->path, CAM_DEBUG_PROBE, \
("Probe %s to %s\n", text[(softc)->action], \
text[(newaction)])); \
(softc)->action = (newaction); \
} while(0)
@ CAM_DEBUG_PROBE
Definition: cam_debug.h:46
static char * nvme_probe_action_text[]
Definition: nvme_xpt.c:92

Definition at line 99 of file nvme_xpt.c.

◆ NVME_XPT_XPORT

#define NVME_XPT_XPORT (   x,
 
)
Value:
static struct xpt_xport nvme_xport_ ## x = { \
.xport = XPORT_ ## X, \
.name = #x, \
}; \
CAM_XPT_XPORT(nvme_xport_ ## x);
static struct xpt_xport_ops nvme_xport_ops
Definition: nvme_xpt.c:164
cam_xport xport
struct xpt_xport_ops * ops

Definition at line 170 of file nvme_xpt.c.

Enumeration Type Documentation

◆ nvme_probe_action

Enumerator
NVME_PROBE_IDENTIFY_CD 
NVME_PROBE_IDENTIFY_NS 
NVME_PROBE_DONE 
NVME_PROBE_INVALID 

Definition at line 85 of file nvme_xpt.c.

◆ nvme_probe_flags

Enumerator
NVME_PROBE_NO_ANNOUNCE 

Definition at line 109 of file nvme_xpt.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ CAM_XPT_PROTO()

CAM_XPT_PROTO ( nvme_proto  )

◆ nvme_action()

static void nvme_action ( union ccb start_ccb)
static

◆ nvme_alloc_device()

static struct cam_ed * nvme_alloc_device ( struct cam_eb bus,
struct cam_et target,
lun_id_t  lun_id 
)
static

◆ nvme_announce_periph()

◆ nvme_dev_advinfo()

◆ nvme_dev_async()

static void nvme_dev_async ( u_int32_t  async_code,
struct cam_eb bus,
struct cam_et target,
struct cam_ed device,
void *  async_arg 
)
static

Definition at line 767 of file nvme_xpt.c.

References AC_LOST_DEVICE, CAM_DEV_UNCONFIGURED, CAM_LUN_WILDCARD, CAM_TARGET_WILDCARD, cam_ed::flags, cam_ed::lun_id, cam_et::target_id, and xpt_release_device().

Here is the call graph for this function:

◆ nvme_device_transport()

static void nvme_device_transport ( struct cam_path path)
static

◆ nvme_probe_cleanup()

static void nvme_probe_cleanup ( struct cam_periph periph)
static

Definition at line 494 of file nvme_xpt.c.

References cam_periph::softc.

Referenced by nvme_scan_lun().

Here is the caller graph for this function:

◆ nvme_probe_done()

static void nvme_probe_done ( struct cam_periph periph,
union ccb done_ccb 
)
static

Definition at line 305 of file nvme_xpt.c.

References AC_FOUND_DEVICE, AC_LOST_DEVICE, nvme_probe_softc::action, CAM_DEBUG, CAM_DEBUG_PROBE, CAM_DEBUG_TRACE, CAM_DEV_QFRZN, CAM_DEV_UNCONFIGURED, cam_periph_error(), cam_periph_invalidate(), cam_periph_release_locked(), cam_release_devq(), CAM_REQ_CMP, CAM_REQ_CMP_ERR, CAM_STATUS_MASK, cam_strvis_flag(), CAM_STRVIS_FLAG_NONASCII_SPC, ccb::ccb_h, cam_path::device, scsi_vpd_device_id::device, cam_ed::device_id, cam_ed::device_id_len, cam_ed::flags, ccb_hdr::func_code, scsi_vpd_id_descriptor::id_type, scsi_vpd_id_descriptor::identifier, scsi_vpd_device_id::length, scsi_vpd_id_descriptor::length, cam_ed::nvme_cdata, cam_ed::nvme_data, nvme_device_transport(), NVME_PROBE_DONE, NVME_PROBE_IDENTIFY_CD, NVME_PROBE_IDENTIFY_NS, NVME_PROBE_INVALID, nvme_probe_schedule(), NVME_PROBE_SET_ACTION, scsi_vpd_device_id::page_code, ccb_hdr::path, cam_periph::path, ccb_hdr::pinfo, cam_pinfo::priority, scsi_vpd_id_descriptor::proto_codeset, nvme_probe_softc::restart, scsi_ulto2b(), cam_ed::serial_num, cam_ed::serial_num_len, SF_NO_RECOVERY, SF_NO_RETRY, SID_QUAL_LU_CONNECTED, cam_periph::softc, ccb_hdr::status, SVPD_DEVICE_ID, SVPD_DEVICE_ID_HDR_LEN, SVPD_ID_ASSOC_LUN, SVPD_ID_CODESET_BINARY, SVPD_ID_TYPE_EUI64, T_DIRECT, xpt_acquire_device(), xpt_action(), xpt_async(), xpt_done(), XPT_GDEV_TYPE, xpt_print(), xpt_release_ccb(), xpt_release_devq(), and xpt_schedule().

Referenced by nvme_probe_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nvme_probe_register()

static cam_status nvme_probe_register ( struct cam_periph periph,
void *  arg 
)
static

Definition at line 200 of file nvme_xpt.c.

References nvme_probe_softc::action, CAM_DEBUG, CAM_DEBUG_PROBE, cam_periph_acquire(), CAM_REQ_CMP, CAM_REQ_CMP_ERR, ccb::ccb_h, nvme_probe_softc::flags, NVME_PROBE_INVALID, nvme_probe_schedule(), cam_periph::path, nvme_probe_softc::periph, and cam_periph::softc.

Referenced by nvme_scan_lun().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nvme_probe_schedule()

static void nvme_probe_schedule ( struct cam_periph nvme_probe_periph)
static

Definition at line 238 of file nvme_xpt.c.

References CAM_EXPECT_INQ_CHANGE, CAM_PRIORITY_XPT, ccb, ccb::crcn, ccb_rescan::flags, nvme_probe_softc::flags, NVME_PROBE_IDENTIFY_CD, NVME_PROBE_NO_ANNOUNCE, NVME_PROBE_SET_ACTION, cam_periph::softc, and xpt_schedule().

Referenced by nvme_probe_done(), and nvme_probe_register().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nvme_probe_start()

static void nvme_probe_start ( struct cam_periph periph,
union ccb start_ccb 
)
static

◆ nvme_proto_announce()

static void nvme_proto_announce ( struct cam_ed device)
static

Definition at line 824 of file nvme_xpt.c.

References cam_ed::nvme_cdata, cam_ed::nvme_data, and nvme_print_ident().

Referenced by nvme_proto_denounce().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nvme_proto_debug_out()

static void nvme_proto_debug_out ( union ccb ccb)
static

Definition at line 843 of file nvme_xpt.c.

References CAM_DEBUG, CAM_DEBUG_CDB, ccb::ccb_h, ccb_nvmeio::cmd, ccb_hdr::func_code, nvme_cmd_string(), nvme_op_string(), ccb::nvmeio, ccb_hdr::path, XPT_NVME_ADMIN, and XPT_NVME_IO.

Here is the call graph for this function:

◆ nvme_proto_denounce()

static void nvme_proto_denounce ( struct cam_ed device)
static

Definition at line 836 of file nvme_xpt.c.

References nvme_proto_announce().

Here is the call graph for this function:

◆ nvme_scan_lun()

static void nvme_scan_lun ( struct cam_periph periph,
struct cam_path path,
cam_flags  flags,
union ccb ccb 
)
static

◆ NVME_XPT_XPORT()

NVME_XPT_XPORT ( nvme  ,
NVME   
)

◆ PERIPHDRIVER_DECLARE()

PERIPHDRIVER_DECLARE ( nvme_probe  ,
nvme_probe_driver   
)

Variable Documentation

◆ nvme_probe_action_text

char* nvme_probe_action_text[]
static
Initial value:
= {
"NVME_PROBE_IDENTIFY_CD",
"NVME_PROBE_IDENTIFY_NS",
"NVME_PROBE_DONE",
"NVME_PROBE_INVALID"
}

Definition at line 92 of file nvme_xpt.c.

◆ nvme_probe_driver

struct periph_driver nvme_probe_driver
static
Initial value:
=
{
nvme_probe_periph_init, "nvme_probe",
TAILQ_HEAD_INITIALIZER(nvme_probe_driver.units), 0,
}
#define CAM_PERIPH_DRV_EARLY
Definition: cam_periph.h:99
static periph_init_t nvme_probe_periph_init
Definition: nvme_xpt.c:74
static struct periph_driver nvme_probe_driver
Definition: nvme_xpt.c:76

Definition at line 76 of file nvme_xpt.c.

◆ nvme_probe_periph_init

static void nvme_probe_periph_init ( void  )
static

Definition at line 74 of file nvme_xpt.c.

◆ nvme_proto

struct xpt_proto nvme_proto
static
Initial value:
= {
.proto = PROTO_NVME,
.name = "nvme",
.ops = &nvme_proto_ops,
}
@ PROTO_NVME
Definition: cam_ccb.h:284
static struct xpt_proto_ops nvme_proto_ops
Definition: nvme_xpt.c:182

Definition at line 187 of file nvme_xpt.c.

◆ nvme_proto_ops

struct xpt_proto_ops nvme_proto_ops
static
Initial value:
= {
.announce = nvme_proto_announce,
.denounce = nvme_proto_denounce,
.debug_out = nvme_proto_debug_out,
}
static void nvme_proto_announce(struct cam_ed *device)
Definition: nvme_xpt.c:824
static void nvme_proto_debug_out(union ccb *ccb)
Definition: nvme_xpt.c:843
static void nvme_proto_denounce(struct cam_ed *device)
Definition: nvme_xpt.c:836

Definition at line 182 of file nvme_xpt.c.

◆ nvme_quirk_table

struct nvme_quirk_entry nvme_quirk_table[]
static
Initial value:
=
{
{
.quirks = 0, .mintags = 0, .maxtags = 0
},
}

Definition at line 125 of file nvme_xpt.c.

Referenced by nvme_alloc_device().

◆ nvme_quirk_table_size

const int nvme_quirk_table_size
static
Initial value:
=
static struct nvme_quirk_entry nvme_quirk_table[]
Definition: nvme_xpt.c:125

Definition at line 136 of file nvme_xpt.c.

Referenced by nvme_alloc_device().

◆ nvme_xport_ops

struct xpt_xport_ops nvme_xport_ops
static
Initial value:
= {
.alloc_device = nvme_alloc_device,
.action = nvme_action,
.async = nvme_dev_async,
.announce = nvme_announce_periph,
}
static void nvme_action(union ccb *start_ccb)
Definition: nvme_xpt.c:740
static struct cam_ed * nvme_alloc_device(struct cam_eb *bus, struct cam_et *target, lun_id_t lun_id)
Definition: nvme_xpt.c:593
static void nvme_dev_async(u_int32_t async_code, struct cam_eb *bus, struct cam_et *target, struct cam_ed *device, void *async_arg)
Definition: nvme_xpt.c:767
static void nvme_announce_periph(struct cam_periph *periph)
Definition: nvme_xpt.c:786

Definition at line 164 of file nvme_xpt.c.