Author: imp
Date: Fri Jun 10 06:04:53 2016
New Revision: 301778
URL: https://svnweb.freebsd.org/changeset/base/301778

Log:
  Commit the bits of nda that were missed. This should fix the build.
  
  Approved by: re@

Modified:
  head/etc/mtree/BSD.include.dist
  head/include/Makefile
  head/sys/cam/cam_ccb.h
  head/sys/cam/nvme/nvme_xpt.c
  head/sys/conf/files
  head/sys/dev/nvme/nvme.h
  head/sys/dev/nvme/nvme_ctrlr.c
  head/sys/dev/nvme/nvme_ns_cmd.c
  head/sys/dev/nvme/nvme_private.h

Modified: head/etc/mtree/BSD.include.dist
==============================================================================
--- head/etc/mtree/BSD.include.dist     Fri Jun 10 05:21:52 2016        
(r301777)
+++ head/etc/mtree/BSD.include.dist     Fri Jun 10 06:04:53 2016        
(r301778)
@@ -90,6 +90,8 @@
     cam
         ata
         ..
+        nvme
+        ..
         scsi
         ..
     ..

Modified: head/include/Makefile
==============================================================================
--- head/include/Makefile       Fri Jun 10 05:21:52 2016        (r301777)
+++ head/include/Makefile       Fri Jun 10 06:04:53 2016        (r301778)
@@ -42,7 +42,7 @@ LHDRS=        aio.h errno.h fcntl.h linker_set.
 LDIRS= bsm cam geom net net80211 netgraph netinet netinet6 \
        netipsec netnatm netsmb nfs nfsclient nfsserver sys vm
 
-LSUBDIRS=      cam/ata cam/scsi \
+LSUBDIRS=      cam/ata cam/nvme cam/scsi \
        dev/acpica dev/agp dev/an dev/bktr dev/ciss dev/filemon dev/firewire \
        dev/hwpmc \
        dev/ic dev/iicbus dev/io dev/lmc dev/mfi dev/nvme \

Modified: head/sys/cam/cam_ccb.h
==============================================================================
--- head/sys/cam/cam_ccb.h      Fri Jun 10 05:21:52 2016        (r301777)
+++ head/sys/cam/cam_ccb.h      Fri Jun 10 06:04:53 2016        (r301778)
@@ -359,6 +359,8 @@ struct ccb_getdev {
        u_int8_t  serial_num[252];
        u_int8_t  inq_flags;
        u_int8_t  serial_num_len;
+       const struct nvme_controller_data       *nvme_cdata;
+       const struct nvme_namespace_data        *nvme_data;
 };
 
 /* Device Statistics CCB */
@@ -619,6 +621,11 @@ struct ccb_pathinq_settings_fc {
 struct ccb_pathinq_settings_sas {
        u_int32_t bitrate;      /* Mbps */
 };
+
+struct ccb_pathinq_settings_nvme {
+       uint16_t nsid;          /* Namespace ID for this path */
+};
+
 #define        PATHINQ_SETTINGS_SIZE   128
 
 struct ccb_pathinq {
@@ -649,6 +656,7 @@ struct ccb_pathinq {
                struct ccb_pathinq_settings_spi spi;
                struct ccb_pathinq_settings_fc fc;
                struct ccb_pathinq_settings_sas sas;
+               struct ccb_pathinq_settings_nvme nvme;
                char ccb_pathinq_settings_opaque[PATHINQ_SETTINGS_SIZE];
        } xport_specific;
        u_int           maxio;          /* Max supported I/O size, in bytes. */
@@ -975,6 +983,18 @@ struct ccb_trans_settings_sata {
 #define        CTS_SATA_CAPS_D_APST            0x00020000
 };
 
+struct ccb_trans_settings_nvme 
+{
+       u_int           valid;          /* Which fields to honor */
+#define CTS_NVME_VALID_SPEC    0x01
+#define CTS_NVME_VALID_CAPS    0x02
+       u_int           spec_major;     /* Major version of spec supported */
+       u_int           spec_minor;     /* Minor verison of spec supported */
+       u_int           spec_tiny;      /* Tiny version of spec supported */
+       u_int           max_xfer;       /* Max transfer size (0 -> unlimited */
+       u_int           caps;
+};
+       
 /* Get/Set transfer rate/width/disconnection/tag queueing settings */
 struct ccb_trans_settings {
        struct    ccb_hdr ccb_h;
@@ -987,6 +1007,7 @@ struct ccb_trans_settings {
                u_int  valid;   /* Which fields to honor */
                struct ccb_trans_settings_ata ata;
                struct ccb_trans_settings_scsi scsi;
+               struct ccb_trans_settings_nvme nvme;
        } proto_specific;
        union {
                u_int  valid;   /* Which fields to honor */
@@ -995,6 +1016,7 @@ struct ccb_trans_settings {
                struct ccb_trans_settings_sas sas;
                struct ccb_trans_settings_pata ata;
                struct ccb_trans_settings_sata sata;
+               struct ccb_trans_settings_nvme nvme;
        } xport_specific;
 };
 

Modified: head/sys/cam/nvme/nvme_xpt.c
==============================================================================
--- head/sys/cam/nvme/nvme_xpt.c        Fri Jun 10 05:21:52 2016        
(r301777)
+++ head/sys/cam/nvme/nvme_xpt.c        Fri Jun 10 06:04:53 2016        
(r301778)
@@ -137,7 +137,7 @@ static cam_status   nvme_probe_register(st
 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_cleanup(struct cam_periph *periph);
-static void     nvme_find_quirk(struct cam_ed *device);
+//static void   nvme_find_quirk(struct cam_ed *device);
 static void     nvme_scan_lun(struct cam_periph *periph,
                               struct cam_path *path, cam_flags flags,
                               union ccb *ccb);
@@ -312,6 +312,7 @@ nvme_probe_cleanup(struct cam_periph *pe
        free(periph->softc, M_CAMXPT);
 }
 
+#if 0
 /* XXX should be used, don't delete */
 static void
 nvme_find_quirk(struct cam_ed *device)
@@ -334,6 +335,7 @@ nvme_find_quirk(struct cam_ed *device)
                device->maxtags = quirk->maxtags;
        }
 }
+#endif
 
 static void
 nvme_scan_lun(struct cam_periph *periph, struct cam_path *path,

Modified: head/sys/conf/files
==============================================================================
--- head/sys/conf/files Fri Jun 10 05:21:52 2016        (r301777)
+++ head/sys/conf/files Fri Jun 10 06:04:53 2016        (r301778)
@@ -87,7 +87,7 @@ cam/ata/ata_all.c             optional scbus
 cam/ata/ata_xpt.c              optional scbus
 cam/ata/ata_pmp.c              optional scbus
 cam/nvme/nvme_all.c            optional scbus nvme 
-cam/nvme/nvme_da.c             optional scbus nvme da
+cam/nvme/nvme_da.c             optional scbus nvme da !nvd
 cam/nvme/nvme_xpt.c            optional scbus nvme
 cam/scsi/scsi_xpt.c            optional scbus
 cam/scsi/scsi_all.c            optional scbus

Modified: head/sys/dev/nvme/nvme.h
==============================================================================
--- head/sys/dev/nvme/nvme.h    Fri Jun 10 05:21:52 2016        (r301777)
+++ head/sys/dev/nvme/nvme.h    Fri Jun 10 06:04:53 2016        (r301778)
@@ -47,7 +47,8 @@
  */
 #define NVME_GLOBAL_NAMESPACE_TAG      ((uint32_t)0xFFFFFFFF)
 
-#define NVME_MAX_XFER_SIZE             MAXPHYS
+/* Cap nvme to 1MB transfers driver explodes with larger sizes */
+#define NVME_MAX_XFER_SIZE             (MAXPHYS < (1<<20) ? MAXPHYS : (1<<20))
 
 union cap_lo_register {
        uint32_t        raw;
@@ -903,6 +904,52 @@ uint32_t   nvme_ns_get_stripesize(struct n
 int    nvme_ns_bio_process(struct nvme_namespace *ns, struct bio *bp,
                            nvme_cb_fn_t cb_fn);
 
+/* Command building helper functions -- shared with CAM */
+static inline
+void   nvme_ns_flush_cmd(struct nvme_command *cmd, uint16_t nsid)
+{
+
+       cmd->opc = NVME_OPC_FLUSH;
+       cmd->nsid = nsid;
+}
+
+static inline
+void   nvme_ns_rw_cmd(struct nvme_command *cmd, uint32_t rwcmd, uint16_t nsid,
+    uint64_t lba, uint32_t count)
+{
+       cmd->opc = rwcmd;
+       cmd->nsid = nsid;
+       *(uint64_t *)&cmd->cdw10 = lba;
+       cmd->cdw12 = count-1;
+       cmd->cdw13 = 0;
+       cmd->cdw14 = 0;
+       cmd->cdw15 = 0;
+}
+
+static inline
+void   nvme_ns_write_cmd(struct nvme_command *cmd, uint16_t nsid,
+    uint64_t lba, uint32_t count)
+{
+       nvme_ns_rw_cmd(cmd, NVME_OPC_WRITE, nsid, lba, count);
+}
+
+static inline
+void   nvme_ns_read_cmd(struct nvme_command *cmd, uint16_t nsid,
+    uint64_t lba, uint32_t count)
+{
+       nvme_ns_rw_cmd(cmd, NVME_OPC_READ, nsid, lba, count);
+}
+
+static inline
+void   nvme_ns_trim_cmd(struct nvme_command *cmd, uint16_t nsid,
+    uint32_t num_ranges)
+{
+       cmd->opc = NVME_OPC_DATASET_MANAGEMENT;
+       cmd->nsid = nsid;
+       cmd->cdw10 = num_ranges - 1;
+       cmd->cdw11 = NVME_DSM_ATTR_DEALLOCATE;
+}
+
 #endif /* _KERNEL */
 
 #endif /* __NVME_H__ */

Modified: head/sys/dev/nvme/nvme_ctrlr.c
==============================================================================
--- head/sys/dev/nvme/nvme_ctrlr.c      Fri Jun 10 05:21:52 2016        
(r301777)
+++ head/sys/dev/nvme/nvme_ctrlr.c      Fri Jun 10 06:04:53 2016        
(r301778)
@@ -27,6 +27,8 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include "opt_cam.h"
+
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/buf.h>
@@ -801,7 +803,7 @@ nvme_ctrlr_reset_task(void *arg, int pen
        atomic_cmpset_32(&ctrlr->is_resetting, 1, 0);
 }
 
-static void
+void
 nvme_ctrlr_intx_handler(void *arg)
 {
        struct nvme_controller *ctrlr = arg;

Modified: head/sys/dev/nvme/nvme_ns_cmd.c
==============================================================================
--- head/sys/dev/nvme/nvme_ns_cmd.c     Fri Jun 10 05:21:52 2016        
(r301777)
+++ head/sys/dev/nvme/nvme_ns_cmd.c     Fri Jun 10 06:04:53 2016        
(r301778)
@@ -34,20 +34,14 @@ nvme_ns_cmd_read(struct nvme_namespace *
     uint32_t lba_count, nvme_cb_fn_t cb_fn, void *cb_arg)
 {
        struct nvme_request     *req;
-       struct nvme_command     *cmd;
 
        req = nvme_allocate_request_vaddr(payload,
            lba_count*nvme_ns_get_sector_size(ns), cb_fn, cb_arg);
 
        if (req == NULL)
                return (ENOMEM);
-       cmd = &req->cmd;
-       cmd->opc = NVME_OPC_READ;
-       cmd->nsid = ns->id;
 
-       /* TODO: create a read command data structure */
-       *(uint64_t *)&cmd->cdw10 = lba;
-       cmd->cdw12 = lba_count-1;
+       nvme_ns_read_cmd(&req->cmd, ns->id, lba, lba_count);
 
        nvme_ctrlr_submit_io_request(ns->ctrlr, req);
 
@@ -59,7 +53,6 @@ nvme_ns_cmd_read_bio(struct nvme_namespa
     nvme_cb_fn_t cb_fn, void *cb_arg)
 {
        struct nvme_request     *req;
-       struct nvme_command     *cmd;
        uint64_t                lba;
        uint64_t                lba_count;
 
@@ -67,16 +60,10 @@ nvme_ns_cmd_read_bio(struct nvme_namespa
 
        if (req == NULL)
                return (ENOMEM);
-       cmd = &req->cmd;
-       cmd->opc = NVME_OPC_READ;
-       cmd->nsid = ns->id;
 
        lba = bp->bio_offset / nvme_ns_get_sector_size(ns);
        lba_count = bp->bio_bcount / nvme_ns_get_sector_size(ns);
-
-       /* TODO: create a read command data structure */
-       *(uint64_t *)&cmd->cdw10 = lba;
-       cmd->cdw12 = lba_count-1;
+       nvme_ns_read_cmd(&req->cmd, ns->id, lba, lba_count);
 
        nvme_ctrlr_submit_io_request(ns->ctrlr, req);
 
@@ -88,7 +75,6 @@ nvme_ns_cmd_write(struct nvme_namespace 
     uint32_t lba_count, nvme_cb_fn_t cb_fn, void *cb_arg)
 {
        struct nvme_request     *req;
-       struct nvme_command     *cmd;
 
        req = nvme_allocate_request_vaddr(payload,
            lba_count*nvme_ns_get_sector_size(ns), cb_fn, cb_arg);
@@ -96,13 +82,7 @@ nvme_ns_cmd_write(struct nvme_namespace 
        if (req == NULL)
                return (ENOMEM);
 
-       cmd = &req->cmd;
-       cmd->opc = NVME_OPC_WRITE;
-       cmd->nsid = ns->id;
-
-       /* TODO: create a write command data structure */
-       *(uint64_t *)&cmd->cdw10 = lba;
-       cmd->cdw12 = lba_count-1;
+       nvme_ns_write_cmd(&req->cmd, ns->id, lba, lba_count);
 
        nvme_ctrlr_submit_io_request(ns->ctrlr, req);
 
@@ -114,7 +94,6 @@ nvme_ns_cmd_write_bio(struct nvme_namesp
     nvme_cb_fn_t cb_fn, void *cb_arg)
 {
        struct nvme_request     *req;
-       struct nvme_command     *cmd;
        uint64_t                lba;
        uint64_t                lba_count;
 
@@ -122,16 +101,9 @@ nvme_ns_cmd_write_bio(struct nvme_namesp
 
        if (req == NULL)
                return (ENOMEM);
-       cmd = &req->cmd;
-       cmd->opc = NVME_OPC_WRITE;
-       cmd->nsid = ns->id;
-
        lba = bp->bio_offset / nvme_ns_get_sector_size(ns);
        lba_count = bp->bio_bcount / nvme_ns_get_sector_size(ns);
-
-       /* TODO: create a write command data structure */
-       *(uint64_t *)&cmd->cdw10 = lba;
-       cmd->cdw12 = lba_count-1;
+       nvme_ns_write_cmd(&req->cmd, ns->id, lba, lba_count);
 
        nvme_ctrlr_submit_io_request(ns->ctrlr, req);
 
@@ -168,17 +140,13 @@ int
 nvme_ns_cmd_flush(struct nvme_namespace *ns, nvme_cb_fn_t cb_fn, void *cb_arg)
 {
        struct nvme_request     *req;
-       struct nvme_command     *cmd;
 
        req = nvme_allocate_request_null(cb_fn, cb_arg);
 
        if (req == NULL)
                return (ENOMEM);
 
-       cmd = &req->cmd;
-       cmd->opc = NVME_OPC_FLUSH;
-       cmd->nsid = ns->id;
-
+       nvme_ns_flush_cmd(&req->cmd, ns->id);
        nvme_ctrlr_submit_io_request(ns->ctrlr, req);
 
        return (0);

Modified: head/sys/dev/nvme/nvme_private.h
==============================================================================
--- head/sys/dev/nvme/nvme_private.h    Fri Jun 10 05:21:52 2016        
(r301777)
+++ head/sys/dev/nvme/nvme_private.h    Fri Jun 10 06:04:53 2016        
(r301778)
@@ -245,6 +245,10 @@ struct nvme_controller {
 
        struct mtx              lock;
 
+       struct cam_sim          *sim;
+       struct cam_path         *path;
+       int                     cam_ref;
+
        uint32_t                ready_timeout_in_ms;
 
        bus_space_tag_t         bus_tag;
@@ -528,4 +532,6 @@ void        nvme_notify_async_consumers(struct 
 void   nvme_notify_fail_consumers(struct nvme_controller *ctrlr);
 void   nvme_notify_new_controller(struct nvme_controller *ctrlr);
 
+void   nvme_ctrlr_intx_handler(void *arg);
+
 #endif /* __NVME_PRIVATE_H__ */
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to