nvme_data_struct 分析

来源:互联网 发布:孔明棋算法 编辑:程序博客网 时间:2024/06/01 20:46
typedef struct {    /* 07:00 Opcode */    uint8_t opcode;    /**      * 09:08      * Fused Operation     * 00 - Normal operation     * 00 - Fused operation, first command     * 00 - Fused operation, second command     * 11 - reserved     */    uint8_t fused : 2;    /* 13:10 Reserved */    uint8_t reserved : 4;    /**      * 15:14     * PRP or SGL for Data Transfer     * 00 - PRP  (Dword aligned)     * 01 - SGLs (Byte  aligned)     * 10 - SGLs (Qword aligned)     * 11 - reserved     */    uint8_t  psid : 2;    /* 31:16 Command Identifier (uid | sq_id)    uint16_t cid;} nvme_command_sq_dw0_t;typdef struct {    /* dw0 */    uint32_t dw0;    /* dw1 */    uint8_t nsid[3];    /* dw2 dw3 */    uint8_t reserved1[8];    /* dw4 dw5 Metadata Pointer */    uint64_t mptr;    /* dw6-dw9 Data Pointer */    union {        struct {            uint64_t prp1;            uint64_t prp2;        } prp_entry;        uint64_t sgl_entry[2];    } dptr;    /* dw10-dw15 Data Pointer */    uint32_t dw[6];} nvme_command_sq_common_t;typedef struct {    /* dw0 */    uint32_t dw0;    /* dw1 */    uint8_t nsid[3];    /* dw2 dw3 */    uint8_t reserved1[8];    /* dw4 dw5 Metadata Pointer */    uint64_t mptr;    /* dw6-dw9 Data Pointer */    union {        struct {            uint64_t prp1;            uint64_t prp2;        } prp_entry;        uint64_t sgl_entry[2];    } dptr;    /* dw10 Number of Dwords in Data Transfer */    uint32_t ndt;    /* dw11 Number of Dwords in Metadata Transfer */    uint32_t ndm;    /* dw12-dw15 Data Pointer */    uint32_t dw[4];} nvme_command_sq_vendor_t;typedef struct {    /* dw0 */    uint32_t cmd_specific;    /* dw1 */    uint32_t reserved;    /* dw2 */    struct {        /* SQ Identifier */        uint16_t sqid;        /* SQ Head Pointer */        uint16_t sqhd;    } dw2;    /* dw3 */    struct {        /* Command Identifier */        uint16_t cid;        /* Phase Tag */        uint8_t phase_flag : 1;        /* Status Field */        /**          * status code          * 0x00 ~ 0x7F : Applicable to Admin Command Set, or across multiple command sets         * 0x80 ~ 0xBF : I/O Command Set Specific status codes         * 0xC0 ~ 0xFF : Vendor Specific status codes         */        uint8_t status_code;        /**         * status code type          * 0 - Generic Command Status         * 1 - Command Specific Status         * 2 - Media and Data Integrity Errors         * 3 ~ 6 reserved          * 7 - Vendor Specific         */        uint8_t status_code_type : 3;        /* Reserved */        uint8_t reserved : 2;        /* more: Error Information log that may be retrieved with the Get Log Page command */        uint8_t more : 1;        /* Do Not Retry */        uint8_t dnr : 1;    } dw3;} nvme_command_cq_t;/**  * bit7 - 0 * +----------------+----------+--------------+ * |Generic Command | function | Data Transfer| * +----------------+----------+--------------+ * |       07       | 06 : 02  |    01 :00    | * +----------------+-------------------------+ *  * Data Transfer:  * 00b - no data * 01b - host to controller * 10b - controller to host * 11b - bidirectional * * opcode = gen << 7 | func << 2 | data_transfer    * 1. Generic command      0x00 - 0x7F * 2. IO spec command      0x80 - 0xBF * 3. Vendor spec command  0xC0 - 0xFF */typedef enum {    /* Generic command : 0x00 - 0x7F */    NVME_ADMIN_CMD_OPCODE_DEL_IO_SQ  =      0x00,    NVME_ADMIN_CMD_OPCODE_CREATE_IO_SQ    /* IO spec command : 0x80 - 0xBF */    /* Vendor spec command : 0xC0 - 0xFF */} nvme_admin_command_opcode_t;
原创粉丝点击