1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  *  Copyright 2016-2022 Broadcom Inc. All rights reserved.
4  */
5 #ifndef MPI30_INIT_H
6 #define MPI30_INIT_H     1
7 struct mpi3_scsi_io_cdb_eedp32 {
8 	u8                 cdb[20];
9 	__be32             primary_reference_tag;
10 	__le16             primary_application_tag;
11 	__le16             primary_application_tag_mask;
12 	__le32             transfer_length;
13 };
14 
15 union mpi3_scsi_io_cdb_union {
16 	u8                         cdb32[32];
17 	struct mpi3_scsi_io_cdb_eedp32 eedp32;
18 	struct mpi3_sge_common         sge;
19 };
20 
21 struct mpi3_scsi_io_request {
22 	__le16                     host_tag;
23 	u8                         ioc_use_only02;
24 	u8                         function;
25 	__le16                     ioc_use_only04;
26 	u8                         ioc_use_only06;
27 	u8                         msg_flags;
28 	__le16                     change_count;
29 	__le16                     dev_handle;
30 	__le32                     flags;
31 	__le32                     skip_count;
32 	__le32                     data_length;
33 	u8                         lun[8];
34 	union mpi3_scsi_io_cdb_union  cdb;
35 	union mpi3_sge_union          sgl[4];
36 };
37 
38 #define MPI3_SCSIIO_MSGFLAGS_METASGL_VALID                  (0x80)
39 #define MPI3_SCSIIO_MSGFLAGS_DIVERT_TO_FIRMWARE             (0x40)
40 #define MPI3_SCSIIO_FLAGS_LARGE_CDB                         (0x60000000)
41 #define MPI3_SCSIIO_FLAGS_CDB_16_OR_LESS                    (0x00000000)
42 #define MPI3_SCSIIO_FLAGS_CDB_GREATER_THAN_16               (0x20000000)
43 #define MPI3_SCSIIO_FLAGS_CDB_IN_SEPARATE_BUFFER            (0x40000000)
44 #define MPI3_SCSIIO_FLAGS_TASKATTRIBUTE_MASK                (0x07000000)
45 #define MPI3_SCSIIO_FLAGS_TASKATTRIBUTE_SIMPLEQ             (0x00000000)
46 #define MPI3_SCSIIO_FLAGS_TASKATTRIBUTE_HEADOFQ             (0x01000000)
47 #define MPI3_SCSIIO_FLAGS_TASKATTRIBUTE_ORDEREDQ            (0x02000000)
48 #define MPI3_SCSIIO_FLAGS_TASKATTRIBUTE_ACAQ                (0x04000000)
49 #define MPI3_SCSIIO_FLAGS_CMDPRI_MASK                       (0x00f00000)
50 #define MPI3_SCSIIO_FLAGS_CMDPRI_SHIFT                      (20)
51 #define MPI3_SCSIIO_FLAGS_DATADIRECTION_MASK                (0x000c0000)
52 #define MPI3_SCSIIO_FLAGS_DATADIRECTION_NO_DATA_TRANSFER    (0x00000000)
53 #define MPI3_SCSIIO_FLAGS_DATADIRECTION_WRITE               (0x00040000)
54 #define MPI3_SCSIIO_FLAGS_DATADIRECTION_READ                (0x00080000)
55 #define MPI3_SCSIIO_FLAGS_DMAOPERATION_MASK                 (0x00030000)
56 #define MPI3_SCSIIO_FLAGS_DMAOPERATION_HOST_PI              (0x00010000)
57 #define MPI3_SCSIIO_FLAGS_DIVERT_REASON_MASK                (0x000000f0)
58 #define MPI3_SCSIIO_FLAGS_DIVERT_REASON_IO_THROTTLING       (0x00000010)
59 #define MPI3_SCSIIO_FLAGS_DIVERT_REASON_PROD_SPECIFIC       (0x00000080)
60 #define MPI3_SCSIIO_METASGL_INDEX                           (3)
61 struct mpi3_scsi_io_reply {
62 	__le16                     host_tag;
63 	u8                         ioc_use_only02;
64 	u8                         function;
65 	__le16                     ioc_use_only04;
66 	u8                         ioc_use_only06;
67 	u8                         msg_flags;
68 	__le16                     ioc_use_only08;
69 	__le16                     ioc_status;
70 	__le32                     ioc_log_info;
71 	u8                         scsi_status;
72 	u8                         scsi_state;
73 	__le16                     dev_handle;
74 	__le32                     transfer_count;
75 	__le32                     sense_count;
76 	__le32                     response_data;
77 	__le16                     task_tag;
78 	__le16                     scsi_status_qualifier;
79 	__le32                     eedp_error_offset;
80 	__le16                     eedp_observed_app_tag;
81 	__le16                     eedp_observed_guard;
82 	__le32                     eedp_observed_ref_tag;
83 	__le64                     sense_data_buffer_address;
84 };
85 
86 #define MPI3_SCSIIO_REPLY_MSGFLAGS_REFTAG_OBSERVED_VALID        (0x01)
87 #define MPI3_SCSIIO_REPLY_MSGFLAGS_APPTAG_OBSERVED_VALID        (0x02)
88 #define MPI3_SCSIIO_REPLY_MSGFLAGS_GUARD_OBSERVED_VALID         (0x04)
89 #define MPI3_SCSI_STATUS_GOOD                   (0x00)
90 #define MPI3_SCSI_STATUS_CHECK_CONDITION        (0x02)
91 #define MPI3_SCSI_STATUS_CONDITION_MET          (0x04)
92 #define MPI3_SCSI_STATUS_BUSY                   (0x08)
93 #define MPI3_SCSI_STATUS_INTERMEDIATE           (0x10)
94 #define MPI3_SCSI_STATUS_INTERMEDIATE_CONDMET   (0x14)
95 #define MPI3_SCSI_STATUS_RESERVATION_CONFLICT   (0x18)
96 #define MPI3_SCSI_STATUS_COMMAND_TERMINATED     (0x22)
97 #define MPI3_SCSI_STATUS_TASK_SET_FULL          (0x28)
98 #define MPI3_SCSI_STATUS_ACA_ACTIVE             (0x30)
99 #define MPI3_SCSI_STATUS_TASK_ABORTED           (0x40)
100 #define MPI3_SCSI_STATE_SENSE_MASK              (0x03)
101 #define MPI3_SCSI_STATE_SENSE_VALID             (0x00)
102 #define MPI3_SCSI_STATE_SENSE_FAILED            (0x01)
103 #define MPI3_SCSI_STATE_SENSE_BUFF_Q_EMPTY      (0x02)
104 #define MPI3_SCSI_STATE_SENSE_NOT_AVAILABLE     (0x03)
105 #define MPI3_SCSI_STATE_NO_SCSI_STATUS          (0x04)
106 #define MPI3_SCSI_STATE_TERMINATED              (0x08)
107 #define MPI3_SCSI_STATE_RESPONSE_DATA_VALID     (0x10)
108 #define MPI3_SCSI_RSP_RESPONSECODE_MASK         (0x000000ff)
109 #define MPI3_SCSI_RSP_RESPONSECODE_SHIFT        (0)
110 #define MPI3_SCSI_RSP_ARI2_MASK                 (0x0000ff00)
111 #define MPI3_SCSI_RSP_ARI2_SHIFT                (8)
112 #define MPI3_SCSI_RSP_ARI1_MASK                 (0x00ff0000)
113 #define MPI3_SCSI_RSP_ARI1_SHIFT                (16)
114 #define MPI3_SCSI_RSP_ARI0_MASK                 (0xff000000)
115 #define MPI3_SCSI_RSP_ARI0_SHIFT                (24)
116 #define MPI3_SCSI_TASKTAG_UNKNOWN               (0xffff)
117 #endif
118