Print this page
MFV: illumos-gate@48d370f1e98a10b1bdf160dd83a49e0f49f6c1b7
9809 nvme driver should attach to all NVMe 1.x devices
9810 Update parts of NVMe headers for newer specs
9811 nvmeadm(1M) should have ctf
Reviewed by: Hans Rosenfeld <hans.rosenfeld@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Yuri Pankov <yuripv@yuripv.net>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Reviewed by: Andy Fiddaman <omnios@citrus-it.co.uk>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Robert Mustacchi <rm@joyent.com>
NEX-7237 nvme CSTS register definition is wrong
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Dan Fields <dan.fields@nexenta.com>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com>
NEX-4431 want NVMe management utility
Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
NEX-2182 need driver for Intel NVM Express (nvme) (preview)
Reviewed by: Dan Fields <dan.fields@nexenta.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/nvme/nvme_reg.h
          +++ new/usr/src/uts/common/io/nvme/nvme_reg.h
↓ open down ↓ 3 lines elided ↑ open up ↑
   4    4   * You may only use this file in accordance with the terms of version
   5    5   * 1.0 of the CDDL.
   6    6   *
   7    7   * A full copy of the text of the CDDL should have accompanied this
   8    8   * source.  A copy of the CDDL is also available via the Internet at
   9    9   * http://www.illumos.org/license/CDDL.
  10   10   */
  11   11  
  12   12  /*
  13   13   * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
       14 + * Copyright (c) 2018, Joyent, Inc.
  14   15   */
  15   16  
  16   17  /*
  17   18   * NVMe hardware interface
  18   19   */
  19   20  
  20   21  #ifndef _NVME_REG_H
  21   22  #define _NVME_REG_H
  22   23  
  23   24  #include <sys/nvme.h>
↓ open down ↓ 16 lines elided ↑ open up ↑
  40   41  #define NVME_REG_CAP    0x0             /* Controller Capabilities */
  41   42  #define NVME_REG_VS     0x8             /* Version */
  42   43  #define NVME_REG_INTMS  0xc             /* Interrupt Mask Set */
  43   44  #define NVME_REG_INTMC  0x10            /* Interrupt Mask Clear */
  44   45  #define NVME_REG_CC     0x14            /* Controller Configuration */
  45   46  #define NVME_REG_CSTS   0x1c            /* Controller Status */
  46   47  #define NVME_REG_NSSR   0x20            /* NVM Subsystem Reset */
  47   48  #define NVME_REG_AQA    0x24            /* Admin Queue Attributes */
  48   49  #define NVME_REG_ASQ    0x28            /* Admin Submission Queue */
  49   50  #define NVME_REG_ACQ    0x30            /* Admin Completion Qeueu */
       51 +#define NVME_REG_CMBLOC 0x38            /* Controller Memory Buffer Location */
       52 +#define NVME_REG_CMBSZ  0x3C            /* Controller Memory Buffer Size */
       53 +#define NVME_REG_BPINFO 0x40            /* Boot Partition Information */
       54 +#define NVME_REG_BPRSEL 0x44            /* Boot Partition Read Select */
       55 +#define NVME_REG_BPMBL  0x48            /* Boot Partition Memory Buffer Loc */
  50   56  #define NVME_REG_SQTDBL(nvme, n) \
  51   57          (0x1000 + ((2 * (n)) * nvme->n_doorbell_stride))
  52   58  #define NVME_REG_CQHDBL(nvme, n) \
  53   59          (0x1000 + ((2 * (n) + 1) * nvme->n_doorbell_stride))
  54   60  
  55   61  #define  NVME_CAP_CSS_NVM       1       /* NVM Command Set */
  56   62  #define  NVME_CAP_AMS_WRR       1       /* Weighted Round-Robin */
  57   63  
  58   64  /* CAP -- Controller Capabilities */
  59   65  typedef union {
  60   66          struct {
  61   67                  uint16_t cap_mqes;      /* Maximum Queue Entries Supported */
  62   68                  uint8_t cap_cqr:1;      /* Contiguous Queues Required */
  63   69                  uint8_t cap_ams:2;      /* Arbitration Mechanisms Supported */
  64   70                  uint8_t cap_rsvd1:5;
  65   71                  uint8_t cap_to;         /* Timeout */
  66   72                  uint16_t cap_dstrd:4;   /* Doorbell Stride */
  67   73                  uint16_t cap_nssrs:1;   /* NVM Subsystem Reset Supported */
  68   74                  uint16_t cap_css:8;     /* Command Sets Supported */
  69      -                uint16_t cap_rsvd2:3;
       75 +                uint16_t cap_rsvd2:2;
       76 +                uint8_t cap_bps:1;      /* Boot Partition Support */
  70   77                  uint8_t cap_mpsmin:4;   /* Memory Page Size Minimum */
  71   78                  uint8_t cap_mpsmax:4;   /* Memory Page Size Maximum */
  72   79                  uint8_t cap_rsvd3;
  73   80          } b;
  74   81          uint64_t r;
  75   82  } nvme_reg_cap_t;
  76   83  
  77   84  /* VS -- Version */
  78   85  typedef union {
  79   86          struct {
↓ open down ↓ 26 lines elided ↑ open up ↑
 106  113  /* CSTS -- Controller Status */
 107  114  #define NVME_CSTS_SHN_OCCURING  1       /* Shutdown Processing Occuring */
 108  115  #define NVME_CSTS_SHN_COMPLETE  2       /* Shutdown Processing Complete */
 109  116  
 110  117  typedef union {
 111  118          struct {
 112  119                  uint32_t csts_rdy:1;    /* Ready */
 113  120                  uint32_t csts_cfs:1;    /* Controller Fatal Status */
 114  121                  uint32_t csts_shst:2;   /* Shutdown Status */
 115  122                  uint32_t csts_nssro:1;  /* NVM Subsystem Reset Occured */
 116      -                uint32_t csts_rsvd:27;
      123 +                uint32_t csts_pp:1;     /* Processing Paused */
      124 +                uint32_t csts_rsvd:26;
 117  125          } b;
 118  126          uint32_t r;
 119  127  } nvme_reg_csts_t;
 120  128  
 121  129  /* NSSR -- NVM Subsystem Reset */
 122  130  #define NVME_NSSR_NSSRC 0x4e564d65      /* NSSR magic value */
 123  131  typedef uint32_t nvme_reg_nssr_t;
 124  132  
 125  133  /* AQA -- Admin Queue Attributes */
 126  134  typedef union {
↓ open down ↓ 11 lines elided ↑ open up ↑
 138  146   * probably a specification bug. The full 64bit regs are used as base address,
 139  147   * and the lower bits must be zero to ensure alignment on the page size
 140  148   * specified in CC.MPS.
 141  149   */
 142  150  /* ASQ -- Admin Submission Queue Base Address */
 143  151  typedef uint64_t nvme_reg_asq_t;        /* Admin Submission Queue Base */
 144  152  
 145  153  /* ACQ -- Admin Completion Queue Base Address */
 146  154  typedef uint64_t nvme_reg_acq_t;        /* Admin Completion Queue Base */
 147  155  
      156 +/* CMBLOC - Controller Memory Buffer Location */
      157 +typedef union {
      158 +        struct {
      159 +                uint32_t cmbloc_bir:3;          /* Base Indicator Register */
      160 +                uint32_t cmbloc_rsvd:9;
      161 +                uint32_t cmbloc_ofst:20;        /* Offset */
      162 +        } b;
      163 +        uint32_t r;
      164 +} nvme_reg_cmbloc_t;
      165 +
      166 +/* CMBSZ - Controller Memory Buffer Size */
      167 +typedef union {
      168 +        struct {
      169 +                uint32_t cmbsz_sqs:1;   /* Submission Queue Support */
      170 +                uint32_t cmbsz_cqs:1;   /* Completion Queue Support */
      171 +                uint32_t cmbsz_lists:1; /* PRP SGL List Support */
      172 +                uint32_t cmbsz_rds:1;   /* Read Data Support */
      173 +                uint32_t cmbsz_wds:1;   /* Write Data Support */
      174 +                uint32_t cmbsz_rsvd:3;
      175 +                uint32_t cmbsz_szu:4;   /* Size Units */
      176 +                uint32_t cmbsz_sz:20;   /* Size */
      177 +        } b;
      178 +        uint32_t r;
      179 +} nvme_reg_cmbsz_t;
      180 +
      181 +/* BPINFO - Boot Partition Information */
      182 +typedef union {
      183 +        struct {
      184 +                uint32_t bpinfo_bpsz:15;        /* Boot Partition Size */
      185 +                uint32_t bpinfo_rsvd:9;
      186 +                uint32_t bpinfo_brs:2;          /* Boot Read Status */
      187 +                uint32_t bpinfo_rsvd2:5;
      188 +                uint32_t bpinfo_abpid:1;        /* Active Boot Partition ID */
      189 +        } b;
      190 +        uint32_t r;
      191 +} nvme_reg_bpinfo_t;
      192 +
      193 +/* BPRSEL - Boot Partition Read Select */
      194 +typedef union {
      195 +        struct {
      196 +                uint32_t bprsel_bprsz:10;       /* Boot Partition Read Size */
      197 +                uint32_t bprsel_bprof:20;       /* Boot Partition Read Offset */
      198 +                uint32_t bprsel_rsvd:1;
      199 +                uint32_t bprsel_bpid:1;         /* Boot Partition Identifier */
      200 +        } b;
      201 +        uint32_t r;
      202 +} nvme_reg_bprsel_t;
      203 +
      204 +/* BPMBL - Boot Partition Memory Location Buffer Location */
      205 +typedef uint64_t nvme_reg_bpbml_t;      /* Memory Buffer Base Address */
      206 +
 148  207  /* SQyTDBL -- Submission Queue y Tail Doorbell */
 149  208  typedef union {
 150  209          struct {
 151  210                  uint16_t sqtdbl_sqt;    /* Submission Queue Tail */
 152  211                  uint16_t sqtdbl_rsvd;
 153  212          } b;
 154  213          uint32_t r;
 155  214  } nvme_reg_sqtdbl_t;
 156  215  
 157  216  /* CQyHDBL -- Completion Queue y Head Doorbell */
↓ open down ↓ 54 lines elided ↑ open up ↑
 212  271  #define NVME_OPC_DELETE_SQUEUE  0x0
 213  272  #define NVME_OPC_CREATE_SQUEUE  0x1
 214  273  #define NVME_OPC_GET_LOG_PAGE   0x2
 215  274  #define NVME_OPC_DELETE_CQUEUE  0x4
 216  275  #define NVME_OPC_CREATE_CQUEUE  0x5
 217  276  #define NVME_OPC_IDENTIFY       0x6
 218  277  #define NVME_OPC_ABORT          0x8
 219  278  #define NVME_OPC_SET_FEATURES   0x9
 220  279  #define NVME_OPC_GET_FEATURES   0xa
 221  280  #define NVME_OPC_ASYNC_EVENT    0xc
      281 +#define NVME_OPC_NS_MGMT        0xd     /* 1.2 */
 222  282  #define NVME_OPC_FW_ACTIVATE    0x10
 223  283  #define NVME_OPC_FW_IMAGE_LOAD  0x11
      284 +#define NVME_OPC_SELF_TEST      0x14    /* 1.3 */
      285 +#define NVME_OPC_NS_ATTACH      0x15    /* 1.2 */
      286 +#define NVME_OPC_KEEP_ALIVE     0x18    /* 1.3 */
      287 +#define NVME_OPC_DIRECTIVE_SEND 0x19    /* 1.3 */
      288 +#define NVME_OPC_DIRECTIVE_RECV 0x1A    /* 1.3 */
      289 +#define NVME_OPC_VIRT_MGMT      0x1C    /* 1.3 */
      290 +#define NVME_OPC_NVMEMI_SEND    0x1D    /* 1.3 */
      291 +#define NVME_OPC_NVMEMI_RECV    0x1E    /* 1.3 */
      292 +#define NVME_OPC_DB_CONFIG      0x7C    /* 1.3 */
 224  293  
 225  294  /* NVMe NVM command set specific admin command opcodes */
 226  295  #define NVME_OPC_NVM_FORMAT     0x80
 227  296  #define NVME_OPC_NVM_SEC_SEND   0x81
 228  297  #define NVME_OPC_NVM_SEC_RECV   0x82
 229  298  
 230  299  /* NVMe NVM command opcodes */
 231  300  #define NVME_OPC_NVM_FLUSH      0x0
 232  301  #define NVME_OPC_NVM_WRITE      0x1
 233  302  #define NVME_OPC_NVM_READ       0x2
↓ open down ↓ 110 lines elided ↑ open up ↑
 344  413          } b;
 345  414          uint32_t r;
 346  415  } nvme_async_event_t;
 347  416  
 348  417  /*
 349  418   * NVMe Create Completion/Submission Queue
 350  419   */
 351  420  typedef union {
 352  421          struct {
 353  422                  uint16_t q_qid;                 /* Queue Identifier */
 354      -                uint16_t q_qsize;               /* Queue Size */
      423 +                uint16_t q_qsize;               /* Queue Size */
 355  424          } b;
 356  425          uint32_t r;
 357  426  } nvme_create_queue_dw10_t;
 358  427  
 359  428  typedef union {
 360  429          struct {
 361  430                  uint16_t cq_pc:1;               /* Physically Contiguous */
 362  431                  uint16_t cq_ien:1;              /* Interrupts Enabled */
 363  432                  uint16_t cq_rsvd:14;
 364  433                  uint16_t cq_iv;                 /* Interrupt Vector */
↓ open down ↓ 13 lines elided ↑ open up ↑
 378  447  
 379  448  /*
 380  449   * NVMe Identify
 381  450   */
 382  451  
 383  452  /* NVMe Identify parameters (cdw10) */
 384  453  #define NVME_IDENTIFY_NSID      0x0     /* Identify Namespace */
 385  454  #define NVME_IDENTIFY_CTRL      0x1     /* Identify Controller */
 386  455  #define NVME_IDENTIFY_LIST      0x2     /* Identify List Namespaces */
 387  456  
      457 +#define NVME_IDENTIFY_NSID_ALLOC_LIST   0x10    /* List Allocated NSID */
      458 +#define NVME_IDENTIFY_NSID_ALLOC        0x11    /* Identify Allocated NSID */
      459 +#define NVME_IDENTIFY_NSID_CTRL_LIST    0x12    /* List Controllers on NSID */
      460 +#define NVME_IDENTIFY_CTRL_LIST         0x13    /* Controller List */
      461 +#define NVME_IDENTIFY_PRIMARY_CAPS      0x14    /* Primary Controller Caps */
 388  462  
 389  463  /*
 390  464   * NVMe Abort Command
 391  465   */
 392  466  typedef union {
 393  467          struct {
 394  468                  uint16_t ac_sqid;       /* Submission Queue ID */
 395  469                  uint16_t ac_cid;        /* Command ID */
 396  470          } b;
 397  471          uint32_t r;
↓ open down ↓ 24 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX