xref: /linux/drivers/scsi/mpi3mr/mpi/mpi30_init.h (revision a4eb44a6435d6d8f9e642407a4a06f65eb90ca04)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  *  Copyright 2016-2021 Broadcom Inc. All rights reserved.
4  *
5  */
6 #ifndef MPI30_INIT_H
7 #define MPI30_INIT_H     1
8 struct mpi3_scsi_io_cdb_eedp32 {
9 	u8                 cdb[20];
10 	__be32          primary_reference_tag;
11 	__le16             primary_application_tag;
12 	__le16             primary_application_tag_mask;
13 	__le32             transfer_length;
14 };
15 
16 union mpi3_scsi_io_cdb_union {
17 	u8                         cdb32[32];
18 	struct mpi3_scsi_io_cdb_eedp32 eedp32;
19 	struct mpi3_sge_common         sge;
20 };
21 
22 struct mpi3_scsi_io_request {
23 	__le16                     host_tag;
24 	u8                         ioc_use_only02;
25 	u8                         function;
26 	__le16                     ioc_use_only04;
27 	u8                         ioc_use_only06;
28 	u8                         msg_flags;
29 	__le16                     change_count;
30 	__le16                     dev_handle;
31 	__le32                     flags;
32 	__le32                     skip_count;
33 	__le32                     data_length;
34 	u8                         lun[8];
35 	union mpi3_scsi_io_cdb_union  cdb;
36 	union mpi3_sge_union          sgl[4];
37 };
38 
39 #define MPI3_SCSIIO_MSGFLAGS_METASGL_VALID                  (0x80)
40 #define MPI3_SCSIIO_MSGFLAGS_DIVERT_TO_FIRMWARE             (0x40)
41 #define MPI3_SCSIIO_FLAGS_LARGE_CDB                         (0x60000000)
42 #define MPI3_SCSIIO_FLAGS_CDB_16_OR_LESS                    (0x00000000)
43 #define MPI3_SCSIIO_FLAGS_CDB_GREATER_THAN_16               (0x20000000)
44 #define MPI3_SCSIIO_FLAGS_CDB_IN_SEPARATE_BUFFER            (0x40000000)
45 #define MPI3_SCSIIO_FLAGS_TASKATTRIBUTE_MASK                (0x07000000)
46 #define MPI3_SCSIIO_FLAGS_TASKATTRIBUTE_SIMPLEQ             (0x00000000)
47 #define MPI3_SCSIIO_FLAGS_TASKATTRIBUTE_HEADOFQ             (0x01000000)
48 #define MPI3_SCSIIO_FLAGS_TASKATTRIBUTE_ORDEREDQ            (0x02000000)
49 #define MPI3_SCSIIO_FLAGS_TASKATTRIBUTE_ACAQ                (0x04000000)
50 #define MPI3_SCSIIO_FLAGS_CMDPRI_MASK                       (0x00f00000)
51 #define MPI3_SCSIIO_FLAGS_CMDPRI_SHIFT                      (20)
52 #define MPI3_SCSIIO_FLAGS_DATADIRECTION_MASK                (0x000c0000)
53 #define MPI3_SCSIIO_FLAGS_DATADIRECTION_NO_DATA_TRANSFER    (0x00000000)
54 #define MPI3_SCSIIO_FLAGS_DATADIRECTION_WRITE               (0x00040000)
55 #define MPI3_SCSIIO_FLAGS_DATADIRECTION_READ                (0x00080000)
56 #define MPI3_SCSIIO_FLAGS_DMAOPERATION_MASK                 (0x00030000)
57 #define MPI3_SCSIIO_FLAGS_DMAOPERATION_HOST_PI              (0x00010000)
58 #define MPI3_SCSIIO_METASGL_INDEX                           (3)
59 struct mpi3_scsi_io_reply {
60 	__le16                     host_tag;
61 	u8                         ioc_use_only02;
62 	u8                         function;
63 	__le16                     ioc_use_only04;
64 	u8                         ioc_use_only06;
65 	u8                         msg_flags;
66 	__le16                     ioc_use_only08;
67 	__le16                     ioc_status;
68 	__le32                     ioc_log_info;
69 	u8                         scsi_status;
70 	u8                         scsi_state;
71 	__le16                     dev_handle;
72 	__le32                     transfer_count;
73 	__le32                     sense_count;
74 	__le32                     response_data;
75 	__le16                     task_tag;
76 	__le16                     scsi_status_qualifier;
77 	__le32                     eedp_error_offset;
78 	__le16                     eedp_observed_app_tag;
79 	__le16                     eedp_observed_guard;
80 	__le32                     eedp_observed_ref_tag;
81 	__le64                     sense_data_buffer_address;
82 };
83 
84 #define MPI3_SCSIIO_REPLY_MSGFLAGS_REFTAG_OBSERVED_VALID        (0x01)
85 #define MPI3_SCSIIO_REPLY_MSGFLAGS_APPTAG_OBSERVED_VALID        (0x02)
86 #define MPI3_SCSIIO_REPLY_MSGFLAGS_GUARD_OBSERVED_VALID         (0x04)
87 #define MPI3_SCSI_STATUS_GOOD                   (0x00)
88 #define MPI3_SCSI_STATUS_CHECK_CONDITION        (0x02)
89 #define MPI3_SCSI_STATUS_CONDITION_MET          (0x04)
90 #define MPI3_SCSI_STATUS_BUSY                   (0x08)
91 #define MPI3_SCSI_STATUS_INTERMEDIATE           (0x10)
92 #define MPI3_SCSI_STATUS_INTERMEDIATE_CONDMET   (0x14)
93 #define MPI3_SCSI_STATUS_RESERVATION_CONFLICT   (0x18)
94 #define MPI3_SCSI_STATUS_COMMAND_TERMINATED     (0x22)
95 #define MPI3_SCSI_STATUS_TASK_SET_FULL          (0x28)
96 #define MPI3_SCSI_STATUS_ACA_ACTIVE             (0x30)
97 #define MPI3_SCSI_STATUS_TASK_ABORTED           (0x40)
98 #define MPI3_SCSI_STATE_SENSE_MASK              (0x03)
99 #define MPI3_SCSI_STATE_SENSE_VALID             (0x00)
100 #define MPI3_SCSI_STATE_SENSE_FAILED            (0x01)
101 #define MPI3_SCSI_STATE_SENSE_BUFF_Q_EMPTY      (0x02)
102 #define MPI3_SCSI_STATE_SENSE_NOT_AVAILABLE     (0x03)
103 #define MPI3_SCSI_STATE_NO_SCSI_STATUS          (0x04)
104 #define MPI3_SCSI_STATE_TERMINATED              (0x08)
105 #define MPI3_SCSI_STATE_RESPONSE_DATA_VALID     (0x10)
106 #define MPI3_SCSI_RSP_RESPONSECODE_MASK         (0x000000ff)
107 #define MPI3_SCSI_RSP_RESPONSECODE_SHIFT        (0)
108 #define MPI3_SCSI_RSP_ARI2_MASK                 (0x0000ff00)
109 #define MPI3_SCSI_RSP_ARI2_SHIFT                (8)
110 #define MPI3_SCSI_RSP_ARI1_MASK                 (0x00ff0000)
111 #define MPI3_SCSI_RSP_ARI1_SHIFT                (16)
112 #define MPI3_SCSI_RSP_ARI0_MASK                 (0xff000000)
113 #define MPI3_SCSI_RSP_ARI0_SHIFT                (24)
114 #define MPI3_SCSI_TASKTAG_UNKNOWN               (0xffff)
115 struct mpi3_scsi_task_mgmt_request {
116 	__le16                     host_tag;
117 	u8                         ioc_use_only02;
118 	u8                         function;
119 	__le16                     ioc_use_only04;
120 	u8                         ioc_use_only06;
121 	u8                         msg_flags;
122 	__le16                     change_count;
123 	__le16                     dev_handle;
124 	__le16                     task_host_tag;
125 	u8                         task_type;
126 	u8                         reserved0f;
127 	__le16                     task_request_queue_id;
128 	__le16                     reserved12;
129 	__le32                     reserved14;
130 	u8                         lun[8];
131 };
132 
133 #define MPI3_SCSITASKMGMT_MSGFLAGS_DO_NOT_SEND_TASK_IU      (0x08)
134 #define MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK               (0x01)
135 #define MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK_SET           (0x02)
136 #define MPI3_SCSITASKMGMT_TASKTYPE_TARGET_RESET             (0x03)
137 #define MPI3_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET       (0x05)
138 #define MPI3_SCSITASKMGMT_TASKTYPE_CLEAR_TASK_SET           (0x06)
139 #define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_TASK               (0x07)
140 #define MPI3_SCSITASKMGMT_TASKTYPE_CLEAR_ACA                (0x08)
141 #define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_TASK_SET           (0x09)
142 #define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_ASYNC_EVENT        (0x0a)
143 #define MPI3_SCSITASKMGMT_TASKTYPE_I_T_NEXUS_RESET          (0x0b)
144 struct mpi3_scsi_task_mgmt_reply {
145 	__le16                     host_tag;
146 	u8                         ioc_use_only02;
147 	u8                         function;
148 	__le16                     ioc_use_only04;
149 	u8                         ioc_use_only06;
150 	u8                         msg_flags;
151 	__le16                     ioc_use_only08;
152 	__le16                     ioc_status;
153 	__le32                     ioc_log_info;
154 	__le32                     termination_count;
155 	__le32                     response_data;
156 	__le32                     reserved18;
157 };
158 
159 #define MPI3_SCSITASKMGMT_RSPCODE_TM_COMPLETE                (0x00)
160 #define MPI3_SCSITASKMGMT_RSPCODE_INVALID_FRAME              (0x02)
161 #define MPI3_SCSITASKMGMT_RSPCODE_TM_FUNCTION_NOT_SUPPORTED  (0x04)
162 #define MPI3_SCSITASKMGMT_RSPCODE_TM_FAILED                  (0x05)
163 #define MPI3_SCSITASKMGMT_RSPCODE_TM_SUCCEEDED               (0x08)
164 #define MPI3_SCSITASKMGMT_RSPCODE_TM_INVALID_LUN             (0x09)
165 #define MPI3_SCSITASKMGMT_RSPCODE_TM_OVERLAPPED_TAG          (0x0a)
166 #define MPI3_SCSITASKMGMT_RSPCODE_IO_QUEUED_ON_IOC           (0x80)
167 #define MPI3_SCSITASKMGMT_RSPCODE_TM_NVME_DENIED             (0x81)
168 #endif
169