1991554f2SKenneth D. Merry /*-
2991554f2SKenneth D. Merry * Copyright (c) 2009 Yahoo! Inc.
3a2c14879SStephen McConnell * Copyright (c) 2011-2015 LSI Corp.
47a2a6a1aSStephen McConnell * Copyright (c) 2013-2016 Avago Technologies
546b23587SKashyap D Desai * Copyright 2000-2020 Broadcom Inc.
6991554f2SKenneth D. Merry * All rights reserved.
7991554f2SKenneth D. Merry *
8991554f2SKenneth D. Merry * Redistribution and use in source and binary forms, with or without
9991554f2SKenneth D. Merry * modification, are permitted provided that the following conditions
10991554f2SKenneth D. Merry * are met:
11991554f2SKenneth D. Merry * 1. Redistributions of source code must retain the above copyright
12991554f2SKenneth D. Merry * notice, this list of conditions and the following disclaimer.
13991554f2SKenneth D. Merry * 2. Redistributions in binary form must reproduce the above copyright
14991554f2SKenneth D. Merry * notice, this list of conditions and the following disclaimer in the
15991554f2SKenneth D. Merry * documentation and/or other materials provided with the distribution.
16991554f2SKenneth D. Merry *
17991554f2SKenneth D. Merry * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18991554f2SKenneth D. Merry * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19991554f2SKenneth D. Merry * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20991554f2SKenneth D. Merry * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21991554f2SKenneth D. Merry * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22991554f2SKenneth D. Merry * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23991554f2SKenneth D. Merry * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24991554f2SKenneth D. Merry * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25991554f2SKenneth D. Merry * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26991554f2SKenneth D. Merry * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27991554f2SKenneth D. Merry * SUCH DAMAGE.
28991554f2SKenneth D. Merry *
2946b23587SKashyap D Desai * Broadcom Inc. (LSI) MPT-Fusion Host Adapter FreeBSD
30991554f2SKenneth D. Merry */
31991554f2SKenneth D. Merry
32991554f2SKenneth D. Merry #ifndef _MPRVAR_H
33991554f2SKenneth D. Merry #define _MPRVAR_H
34991554f2SKenneth D. Merry
35e2e050c8SConrad Meyer #include <sys/lock.h>
36e2e050c8SConrad Meyer #include <sys/mutex.h>
37e2e050c8SConrad Meyer
381f480062SKashyap D Desai #define MPR_DRIVER_VERSION "23.00.00.00-fbsd"
39991554f2SKenneth D. Merry
40991554f2SKenneth D. Merry #define MPR_DB_MAX_WAIT 2500
41991554f2SKenneth D. Merry
423c5ac992SScott Long #define MPR_REQ_FRAMES 2048
433c5ac992SScott Long #define MPR_PRI_REQ_FRAMES 128
44991554f2SKenneth D. Merry #define MPR_EVT_REPLY_FRAMES 32
45991554f2SKenneth D. Merry #define MPR_REPLY_FRAMES MPR_REQ_FRAMES
46731308d0SAlexander Motin #define MPR_CHAIN_FRAMES 16384
4732b0a21eSStephen McConnell #define MPR_MAXIO_PAGES (-1)
48991554f2SKenneth D. Merry #define MPR_SENSE_LEN SSD_FULL_SIZE
493c5ac992SScott Long #define MPR_MSI_MAX 1
503c5ac992SScott Long #define MPR_MSIX_MAX 96
51991554f2SKenneth D. Merry #define MPR_SGE64_SIZE 12
52991554f2SKenneth D. Merry #define MPR_SGE32_SIZE 8
53991554f2SKenneth D. Merry #define MPR_SGC_SIZE 8
542bbc5fcbSStephen McConnell #define MPR_DEFAULT_CHAIN_SEG_SIZE 8
552bbc5fcbSStephen McConnell #define MPR_MAX_CHAIN_ELEMENT_SIZE 16
56991554f2SKenneth D. Merry
5767feec50SStephen McConnell /*
5867feec50SStephen McConnell * PCIe NVMe Specific defines
5967feec50SStephen McConnell */
6067feec50SStephen McConnell //SLM-for now just use the same value as a SAS disk
6167feec50SStephen McConnell #define NVME_QDEPTH MPR_REQ_FRAMES
6267feec50SStephen McConnell #define PRP_ENTRY_SIZE 8
6367feec50SStephen McConnell #define NVME_CMD_PRP1_OFFSET 24 /* PRP1 offset in NVMe cmd */
6467feec50SStephen McConnell #define NVME_CMD_PRP2_OFFSET 32 /* PRP2 offset in NVMe cmd */
6567feec50SStephen McConnell #define NVME_ERROR_RESPONSE_SIZE 16 /* Max NVME Error Response */
6667feec50SStephen McConnell #define HOST_PAGE_SIZE_4K 12
6767feec50SStephen McConnell
68991554f2SKenneth D. Merry #define MPR_FUNCTRACE(sc) \
69991554f2SKenneth D. Merry mpr_dprint((sc), MPR_TRACE, "%s\n", __func__)
70991554f2SKenneth D. Merry
71991554f2SKenneth D. Merry #define CAN_SLEEP 1
72991554f2SKenneth D. Merry #define NO_SLEEP 0
73991554f2SKenneth D. Merry
74991554f2SKenneth D. Merry #define MPR_PERIODIC_DELAY 1 /* 1 second heartbeat/watchdog check */
75a2c14879SStephen McConnell #define MPR_ATA_ID_TIMEOUT 5 /* 5 second timeout for SATA ID cmd */
76327f2e6cSStephen McConnell #define MPR_MISSING_CHECK_DELAY 10 /* 10 seconds between missing check */
77991554f2SKenneth D. Merry
78991554f2SKenneth D. Merry #define IFAULT_IOP_OVER_TEMP_THRESHOLD_EXCEEDED 0x2810
79991554f2SKenneth D. Merry
80991554f2SKenneth D. Merry #define MPR_SCSI_RI_INVALID_FRAME (0x00000002)
81991554f2SKenneth D. Merry
82a2c14879SStephen McConnell #define DEFAULT_SPINUP_WAIT 3 /* seconds to wait for spinup */
83a2c14879SStephen McConnell
84991554f2SKenneth D. Merry #include <sys/endian.h>
85991554f2SKenneth D. Merry
86991554f2SKenneth D. Merry /*
87991554f2SKenneth D. Merry * host mapping related macro definitions
88991554f2SKenneth D. Merry */
89991554f2SKenneth D. Merry #define MPR_MAPTABLE_BAD_IDX 0xFFFFFFFF
90991554f2SKenneth D. Merry #define MPR_DPM_BAD_IDX 0xFFFF
91991554f2SKenneth D. Merry #define MPR_ENCTABLE_BAD_IDX 0xFF
92991554f2SKenneth D. Merry #define MPR_MAX_MISSING_COUNT 0x0F
93991554f2SKenneth D. Merry #define MPR_DEV_RESERVED 0x20000000
94991554f2SKenneth D. Merry #define MPR_MAP_IN_USE 0x10000000
95991554f2SKenneth D. Merry #define MPR_MAP_BAD_ID 0xFFFFFFFF
96991554f2SKenneth D. Merry
97991554f2SKenneth D. Merry typedef uint8_t u8;
98991554f2SKenneth D. Merry typedef uint16_t u16;
99991554f2SKenneth D. Merry typedef uint32_t u32;
100991554f2SKenneth D. Merry typedef uint64_t u64;
101991554f2SKenneth D. Merry
10289d1c21fSKashyap D Desai typedef struct _MPI2_CONFIG_PAGE_MAN_11
10389d1c21fSKashyap D Desai {
10489d1c21fSKashyap D Desai MPI2_CONFIG_PAGE_HEADER Header; /* 0x00 */
10589d1c21fSKashyap D Desai U8 FlashTime; /* 0x04 */
10689d1c21fSKashyap D Desai U8 NVTime; /* 0x05 */
10789d1c21fSKashyap D Desai U16 Flag; /* 0x06 */
10889d1c21fSKashyap D Desai U8 RFIoTimeout; /* 0x08 */
10989d1c21fSKashyap D Desai U8 EEDPTagMode; /* 0x09 */
11089d1c21fSKashyap D Desai U8 AWTValue; /* 0x0A */
11189d1c21fSKashyap D Desai U8 Reserve1; /* 0x0B */
11289d1c21fSKashyap D Desai U8 MaxCmdFrames; /* 0x0C */
11389d1c21fSKashyap D Desai U8 Reserve2; /* 0x0D */
11489d1c21fSKashyap D Desai U16 AddlFlags; /* 0x0E */
11589d1c21fSKashyap D Desai U32 SysRefClk; /* 0x10 */
11689d1c21fSKashyap D Desai U64 Reserve3[3]; /* 0x14 */
11789d1c21fSKashyap D Desai U16 AddlFlags2; /* 0x2C */
11889d1c21fSKashyap D Desai U8 AddlFlags3; /* 0x2E */
11989d1c21fSKashyap D Desai U8 Reserve4; /* 0x2F */
12089d1c21fSKashyap D Desai U64 opDebugEnable; /* 0x30 */
12189d1c21fSKashyap D Desai U64 PlDebugEnable; /* 0x38 */
12289d1c21fSKashyap D Desai U64 IrDebugEnable; /* 0x40 */
12389d1c21fSKashyap D Desai U32 BoardPowerRequirement; /* 0x48 */
12489d1c21fSKashyap D Desai U8 NVMeAbortTO; /* 0x4C */
12589d1c21fSKashyap D Desai U8 Reserve5; /* 0x4D */
12689d1c21fSKashyap D Desai U16 Reserve6; /* 0x4E */
12789d1c21fSKashyap D Desai U32 Reserve7[3]; /* 0x50 */
12889d1c21fSKashyap D Desai } MPI2_CONFIG_PAGE_MAN_11,
12989d1c21fSKashyap D Desai MPI2_POINTER PTR_MPI2_CONFIG_PAGE_MAN_11,
13089d1c21fSKashyap D Desai Mpi2ManufacturingPage11_t, MPI2_POINTER pMpi2ManufacturingPage11_t;
13189d1c21fSKashyap D Desai
13289d1c21fSKashyap D Desai #define MPI2_MAN_PG11_ADDLFLAGS2_CUSTOM_TM_HANDLING_MASK (0x0010)
13389d1c21fSKashyap D Desai
134991554f2SKenneth D. Merry /**
135991554f2SKenneth D. Merry * struct dev_mapping_table - device mapping information
136991554f2SKenneth D. Merry * @physical_id: SAS address for drives or WWID for RAID volumes
137991554f2SKenneth D. Merry * @device_info: bitfield provides detailed info about the device
138991554f2SKenneth D. Merry * @phy_bits: bitfields indicating controller phys
139991554f2SKenneth D. Merry * @dpm_entry_num: index of this device in device persistent map table
140991554f2SKenneth D. Merry * @dev_handle: device handle for the device pointed by this entry
141991554f2SKenneth D. Merry * @id: target id
142991554f2SKenneth D. Merry * @missing_count: number of times the device not detected by driver
143991554f2SKenneth D. Merry * @hide_flag: Hide this physical disk/not (foreign configuration)
144991554f2SKenneth D. Merry * @init_complete: Whether the start of the day checks completed or not
145991554f2SKenneth D. Merry * @TLR_bits: Turn TLR support on or off
146991554f2SKenneth D. Merry */
147991554f2SKenneth D. Merry struct dev_mapping_table {
148991554f2SKenneth D. Merry u64 physical_id;
149991554f2SKenneth D. Merry u32 device_info;
150991554f2SKenneth D. Merry u32 phy_bits;
151991554f2SKenneth D. Merry u16 dpm_entry_num;
152991554f2SKenneth D. Merry u16 dev_handle;
153327f2e6cSStephen McConnell u16 reserved1;
154991554f2SKenneth D. Merry u16 id;
155991554f2SKenneth D. Merry u8 missing_count;
156991554f2SKenneth D. Merry u8 init_complete;
157991554f2SKenneth D. Merry u8 TLR_bits;
158991554f2SKenneth D. Merry u8 reserved2;
159991554f2SKenneth D. Merry };
160991554f2SKenneth D. Merry
161991554f2SKenneth D. Merry /**
162991554f2SKenneth D. Merry * struct enc_mapping_table - mapping information about an enclosure
163991554f2SKenneth D. Merry * @enclosure_id: Logical ID of this enclosure
164991554f2SKenneth D. Merry * @start_index: index to the entry in dev_mapping_table
165991554f2SKenneth D. Merry * @phy_bits: bitfields indicating controller phys
166991554f2SKenneth D. Merry * @dpm_entry_num: index of this enclosure in device persistent map table
167991554f2SKenneth D. Merry * @enc_handle: device handle for the enclosure pointed by this entry
168991554f2SKenneth D. Merry * @num_slots: number of slots in the enclosure
169991554f2SKenneth D. Merry * @start_slot: Starting slot id
170991554f2SKenneth D. Merry * @missing_count: number of times the device not detected by driver
171991554f2SKenneth D. Merry * @removal_flag: used to mark the device for removal
172991554f2SKenneth D. Merry * @skip_search: used as a flag to include/exclude enclosure for search
173991554f2SKenneth D. Merry * @init_complete: Whether the start of the day checks completed or not
174991554f2SKenneth D. Merry */
175991554f2SKenneth D. Merry struct enc_mapping_table {
176991554f2SKenneth D. Merry u64 enclosure_id;
177991554f2SKenneth D. Merry u32 start_index;
178991554f2SKenneth D. Merry u32 phy_bits;
179991554f2SKenneth D. Merry u16 dpm_entry_num;
180991554f2SKenneth D. Merry u16 enc_handle;
181991554f2SKenneth D. Merry u16 num_slots;
182991554f2SKenneth D. Merry u16 start_slot;
183991554f2SKenneth D. Merry u8 missing_count;
184991554f2SKenneth D. Merry u8 removal_flag;
185991554f2SKenneth D. Merry u8 skip_search;
186991554f2SKenneth D. Merry u8 init_complete;
187991554f2SKenneth D. Merry };
188991554f2SKenneth D. Merry
189991554f2SKenneth D. Merry /**
190991554f2SKenneth D. Merry * struct map_removal_table - entries to be removed from mapping table
191991554f2SKenneth D. Merry * @dpm_entry_num: index of this device in device persistent map table
192991554f2SKenneth D. Merry * @dev_handle: device handle for the device pointed by this entry
193991554f2SKenneth D. Merry */
194991554f2SKenneth D. Merry struct map_removal_table{
195991554f2SKenneth D. Merry u16 dpm_entry_num;
196991554f2SKenneth D. Merry u16 dev_handle;
197991554f2SKenneth D. Merry };
198991554f2SKenneth D. Merry
199991554f2SKenneth D. Merry typedef struct mpr_fw_diagnostic_buffer {
200991554f2SKenneth D. Merry size_t size;
201991554f2SKenneth D. Merry uint8_t extended_type;
202991554f2SKenneth D. Merry uint8_t buffer_type;
203991554f2SKenneth D. Merry uint8_t force_release;
204991554f2SKenneth D. Merry uint32_t product_specific[23];
205991554f2SKenneth D. Merry uint8_t immediate;
206991554f2SKenneth D. Merry uint8_t enabled;
207991554f2SKenneth D. Merry uint8_t valid_data;
208991554f2SKenneth D. Merry uint8_t owned_by_firmware;
209991554f2SKenneth D. Merry uint32_t unique_id;
210991554f2SKenneth D. Merry } mpr_fw_diagnostic_buffer_t;
211991554f2SKenneth D. Merry
212991554f2SKenneth D. Merry struct mpr_softc;
213991554f2SKenneth D. Merry struct mpr_command;
214991554f2SKenneth D. Merry struct mprsas_softc;
215991554f2SKenneth D. Merry union ccb;
216991554f2SKenneth D. Merry struct mprsas_target;
217991554f2SKenneth D. Merry struct mpr_column_map;
218991554f2SKenneth D. Merry
219991554f2SKenneth D. Merry MALLOC_DECLARE(M_MPR);
220991554f2SKenneth D. Merry
221991554f2SKenneth D. Merry typedef void mpr_evt_callback_t(struct mpr_softc *, uintptr_t,
222991554f2SKenneth D. Merry MPI2_EVENT_NOTIFICATION_REPLY *reply);
223991554f2SKenneth D. Merry typedef void mpr_command_callback_t(struct mpr_softc *, struct mpr_command *cm);
224991554f2SKenneth D. Merry
225991554f2SKenneth D. Merry struct mpr_chain {
226991554f2SKenneth D. Merry TAILQ_ENTRY(mpr_chain) chain_link;
227991554f2SKenneth D. Merry void *chain;
228991554f2SKenneth D. Merry uint64_t chain_busaddr;
229991554f2SKenneth D. Merry };
230991554f2SKenneth D. Merry
23167feec50SStephen McConnell struct mpr_prp_page {
23267feec50SStephen McConnell TAILQ_ENTRY(mpr_prp_page) prp_page_link;
23367feec50SStephen McConnell uint64_t *prp_page;
23467feec50SStephen McConnell uint64_t prp_page_busaddr;
23567feec50SStephen McConnell };
23667feec50SStephen McConnell
237991554f2SKenneth D. Merry /*
238991554f2SKenneth D. Merry * This needs to be at least 2 to support SMP passthrough.
239991554f2SKenneth D. Merry */
240991554f2SKenneth D. Merry #define MPR_IOVEC_COUNT 2
241991554f2SKenneth D. Merry
242991554f2SKenneth D. Merry struct mpr_command {
243991554f2SKenneth D. Merry TAILQ_ENTRY(mpr_command) cm_link;
244991554f2SKenneth D. Merry TAILQ_ENTRY(mpr_command) cm_recovery;
245991554f2SKenneth D. Merry struct mpr_softc *cm_sc;
246991554f2SKenneth D. Merry union ccb *cm_ccb;
247991554f2SKenneth D. Merry void *cm_data;
248991554f2SKenneth D. Merry u_int cm_length;
249991554f2SKenneth D. Merry u_int cm_out_len;
250991554f2SKenneth D. Merry struct uio cm_uio;
251991554f2SKenneth D. Merry struct iovec cm_iovec[MPR_IOVEC_COUNT];
252991554f2SKenneth D. Merry u_int cm_max_segs;
253991554f2SKenneth D. Merry u_int cm_sglsize;
254991554f2SKenneth D. Merry void *cm_sge;
255991554f2SKenneth D. Merry uint8_t *cm_req;
256991554f2SKenneth D. Merry uint8_t *cm_reply;
257991554f2SKenneth D. Merry uint32_t cm_reply_data;
258991554f2SKenneth D. Merry mpr_command_callback_t *cm_complete;
259991554f2SKenneth D. Merry void *cm_complete_data;
260991554f2SKenneth D. Merry struct mprsas_target *cm_targ;
261991554f2SKenneth D. Merry MPI2_REQUEST_DESCRIPTOR_UNION cm_desc;
262991554f2SKenneth D. Merry u_int cm_lun;
263991554f2SKenneth D. Merry u_int cm_flags;
264991554f2SKenneth D. Merry #define MPR_CM_FLAGS_POLLED (1 << 0)
265991554f2SKenneth D. Merry #define MPR_CM_FLAGS_COMPLETE (1 << 1)
266991554f2SKenneth D. Merry #define MPR_CM_FLAGS_SGE_SIMPLE (1 << 2)
267991554f2SKenneth D. Merry #define MPR_CM_FLAGS_DATAOUT (1 << 3)
268991554f2SKenneth D. Merry #define MPR_CM_FLAGS_DATAIN (1 << 4)
269991554f2SKenneth D. Merry #define MPR_CM_FLAGS_WAKEUP (1 << 5)
270991554f2SKenneth D. Merry #define MPR_CM_FLAGS_USE_UIO (1 << 6)
271991554f2SKenneth D. Merry #define MPR_CM_FLAGS_SMP_PASS (1 << 7)
272991554f2SKenneth D. Merry #define MPR_CM_FLAGS_CHAIN_FAILED (1 << 8)
273991554f2SKenneth D. Merry #define MPR_CM_FLAGS_ERROR_MASK MPR_CM_FLAGS_CHAIN_FAILED
274991554f2SKenneth D. Merry #define MPR_CM_FLAGS_USE_CCB (1 << 9)
275a2c14879SStephen McConnell #define MPR_CM_FLAGS_SATA_ID_TIMEOUT (1 << 10)
2768fe7bf06SWarner Losh #define MPR_CM_FLAGS_ON_RECOVERY (1 << 12)
2778fe7bf06SWarner Losh #define MPR_CM_FLAGS_TIMEDOUT (1 << 13)
278991554f2SKenneth D. Merry u_int cm_state;
279991554f2SKenneth D. Merry #define MPR_CM_STATE_FREE 0
280991554f2SKenneth D. Merry #define MPR_CM_STATE_BUSY 1
2818fe7bf06SWarner Losh #define MPR_CM_STATE_INQUEUE 2
282991554f2SKenneth D. Merry bus_dmamap_t cm_dmamap;
283991554f2SKenneth D. Merry struct scsi_sense_data *cm_sense;
28467feec50SStephen McConnell uint64_t *nvme_error_response;
285991554f2SKenneth D. Merry TAILQ_HEAD(, mpr_chain) cm_chain_list;
28667feec50SStephen McConnell TAILQ_HEAD(, mpr_prp_page) cm_prp_page_list;
287991554f2SKenneth D. Merry uint32_t cm_req_busaddr;
28867feec50SStephen McConnell bus_addr_t cm_sense_busaddr;
289991554f2SKenneth D. Merry struct callout cm_callout;
29086312e46SConrad Meyer mpr_command_callback_t *cm_timeout_handler;
291991554f2SKenneth D. Merry };
292991554f2SKenneth D. Merry
293991554f2SKenneth D. Merry struct mpr_column_map {
294991554f2SKenneth D. Merry uint16_t dev_handle;
295991554f2SKenneth D. Merry uint8_t phys_disk_num;
296991554f2SKenneth D. Merry };
297991554f2SKenneth D. Merry
298991554f2SKenneth D. Merry struct mpr_event_handle {
299991554f2SKenneth D. Merry TAILQ_ENTRY(mpr_event_handle) eh_list;
300991554f2SKenneth D. Merry mpr_evt_callback_t *callback;
301991554f2SKenneth D. Merry void *data;
302991554f2SKenneth D. Merry uint8_t mask[16];
303991554f2SKenneth D. Merry };
304991554f2SKenneth D. Merry
305e2997a03SKenneth D. Merry struct mpr_busdma_context {
306e2997a03SKenneth D. Merry int completed;
307e2997a03SKenneth D. Merry int abandoned;
308e2997a03SKenneth D. Merry int error;
309e2997a03SKenneth D. Merry bus_addr_t *addr;
310e2997a03SKenneth D. Merry struct mpr_softc *softc;
311e2997a03SKenneth D. Merry bus_dmamap_t buffer_dmamap;
312e2997a03SKenneth D. Merry bus_dma_tag_t buffer_dmat;
313e2997a03SKenneth D. Merry };
314e2997a03SKenneth D. Merry
315bec09074SScott Long struct mpr_queue {
316bec09074SScott Long struct mpr_softc *sc;
317bec09074SScott Long int qnum;
318bec09074SScott Long MPI2_REPLY_DESCRIPTORS_UNION *post_queue;
319bec09074SScott Long int replypostindex;
320bec09074SScott Long #ifdef notyet
321bec09074SScott Long ck_ring_buffer_t *ringmem;
322bec09074SScott Long ck_ring_buffer_t *chainmem;
323bec09074SScott Long ck_ring_t req_ring;
324bec09074SScott Long ck_ring_t chain_ring;
325bec09074SScott Long #endif
326bec09074SScott Long bus_dma_tag_t buffer_dmat;
327bec09074SScott Long int io_cmds_highwater;
328bec09074SScott Long int chain_free_lowwater;
329bec09074SScott Long int chain_alloc_fail;
330bec09074SScott Long struct resource *irq;
331bec09074SScott Long void *intrhand;
332bec09074SScott Long int irq_rid;
333bec09074SScott Long };
334bec09074SScott Long
335991554f2SKenneth D. Merry struct mpr_softc {
336991554f2SKenneth D. Merry device_t mpr_dev;
337991554f2SKenneth D. Merry struct cdev *mpr_cdev;
338991554f2SKenneth D. Merry u_int mpr_flags;
339991554f2SKenneth D. Merry #define MPR_FLAGS_INTX (1 << 0)
340991554f2SKenneth D. Merry #define MPR_FLAGS_MSI (1 << 1)
341991554f2SKenneth D. Merry #define MPR_FLAGS_BUSY (1 << 2)
342991554f2SKenneth D. Merry #define MPR_FLAGS_SHUTDOWN (1 << 3)
343991554f2SKenneth D. Merry #define MPR_FLAGS_DIAGRESET (1 << 4)
344991554f2SKenneth D. Merry #define MPR_FLAGS_ATTACH_DONE (1 << 5)
34567feec50SStephen McConnell #define MPR_FLAGS_GEN35_IOC (1 << 6)
3466d4ffcb4SKenneth D. Merry #define MPR_FLAGS_REALLOCATED (1 << 7)
347f36649b7SKashyap D Desai #define MPR_FLAGS_SEA_IOC (1 << 8)
348991554f2SKenneth D. Merry u_int mpr_debug;
349252b2b4fSScott Long int msi_msgs;
35096410703SScott Long u_int reqframesz;
35196410703SScott Long u_int replyframesz;
35267feec50SStephen McConnell u_int atomic_desc_capable;
353991554f2SKenneth D. Merry int tm_cmds_active;
354991554f2SKenneth D. Merry int io_cmds_active;
355991554f2SKenneth D. Merry int io_cmds_highwater;
356991554f2SKenneth D. Merry int chain_free;
357991554f2SKenneth D. Merry int max_chains;
35832b0a21eSStephen McConnell int max_io_pages;
35967feec50SStephen McConnell u_int maxio;
360991554f2SKenneth D. Merry int chain_free_lowwater;
3612bbc5fcbSStephen McConnell uint32_t chain_frame_size;
36267feec50SStephen McConnell int prp_buffer_size;
36367feec50SStephen McConnell int prp_pages_free;
36467feec50SStephen McConnell int prp_pages_free_lowwater;
365a2c14879SStephen McConnell u_int enable_ssu;
366a2c14879SStephen McConnell int spinup_wait_time;
3674ab1cdc5SScott Long int use_phynum;
368175ad3d0SKenneth D. Merry int dump_reqs_alltypes;
369991554f2SKenneth D. Merry uint64_t chain_alloc_fail;
37067feec50SStephen McConnell uint64_t prp_page_alloc_fail;
371991554f2SKenneth D. Merry struct sysctl_ctx_list sysctl_ctx;
372991554f2SKenneth D. Merry struct sysctl_oid *sysctl_tree;
373991554f2SKenneth D. Merry char fw_version[16];
37469e85eb8SScott Long char msg_version[8];
375991554f2SKenneth D. Merry struct mpr_command *commands;
376991554f2SKenneth D. Merry struct mpr_chain *chains;
37767feec50SStephen McConnell struct mpr_prp_page *prps;
378991554f2SKenneth D. Merry struct callout periodic;
379327f2e6cSStephen McConnell struct callout device_check_callout;
380bec09074SScott Long struct mpr_queue *queues;
381991554f2SKenneth D. Merry
382991554f2SKenneth D. Merry struct mprsas_softc *sassc;
383991554f2SKenneth D. Merry TAILQ_HEAD(, mpr_command) req_list;
384991554f2SKenneth D. Merry TAILQ_HEAD(, mpr_command) high_priority_req_list;
385991554f2SKenneth D. Merry TAILQ_HEAD(, mpr_chain) chain_list;
38667feec50SStephen McConnell TAILQ_HEAD(, mpr_prp_page) prp_page_list;
387991554f2SKenneth D. Merry TAILQ_HEAD(, mpr_command) tm_list;
388991554f2SKenneth D. Merry int replypostindex;
389991554f2SKenneth D. Merry int replyfreeindex;
390991554f2SKenneth D. Merry
391991554f2SKenneth D. Merry struct resource *mpr_regs_resource;
392991554f2SKenneth D. Merry bus_space_handle_t mpr_bhandle;
393991554f2SKenneth D. Merry bus_space_tag_t mpr_btag;
394991554f2SKenneth D. Merry int mpr_regs_rid;
395991554f2SKenneth D. Merry
396991554f2SKenneth D. Merry bus_dma_tag_t mpr_parent_dmat;
397991554f2SKenneth D. Merry bus_dma_tag_t buffer_dmat;
398991554f2SKenneth D. Merry
399991554f2SKenneth D. Merry MPI2_IOC_FACTS_REPLY *facts;
400991554f2SKenneth D. Merry int num_reqs;
40162a09ee9SAlexander Motin int num_prireqs;
402991554f2SKenneth D. Merry int num_replies;
4034f5d6573SAlexander Motin int num_chains;
404991554f2SKenneth D. Merry int fqdepth; /* Free queue */
405991554f2SKenneth D. Merry int pqdepth; /* Post queue */
406991554f2SKenneth D. Merry
407991554f2SKenneth D. Merry uint8_t event_mask[16];
408991554f2SKenneth D. Merry TAILQ_HEAD(, mpr_event_handle) event_list;
409991554f2SKenneth D. Merry struct mpr_event_handle *mpr_log_eh;
410991554f2SKenneth D. Merry
411991554f2SKenneth D. Merry struct mtx mpr_mtx;
412991554f2SKenneth D. Merry struct intr_config_hook mpr_ich;
413991554f2SKenneth D. Merry
414991554f2SKenneth D. Merry uint8_t *req_frames;
415991554f2SKenneth D. Merry bus_addr_t req_busaddr;
416991554f2SKenneth D. Merry bus_dma_tag_t req_dmat;
417991554f2SKenneth D. Merry bus_dmamap_t req_map;
418991554f2SKenneth D. Merry
419991554f2SKenneth D. Merry uint8_t *reply_frames;
420991554f2SKenneth D. Merry bus_addr_t reply_busaddr;
421991554f2SKenneth D. Merry bus_dma_tag_t reply_dmat;
422991554f2SKenneth D. Merry bus_dmamap_t reply_map;
423991554f2SKenneth D. Merry
424991554f2SKenneth D. Merry struct scsi_sense_data *sense_frames;
425991554f2SKenneth D. Merry bus_addr_t sense_busaddr;
426991554f2SKenneth D. Merry bus_dma_tag_t sense_dmat;
427991554f2SKenneth D. Merry bus_dmamap_t sense_map;
428991554f2SKenneth D. Merry
429991554f2SKenneth D. Merry uint8_t *chain_frames;
430991554f2SKenneth D. Merry bus_dma_tag_t chain_dmat;
431991554f2SKenneth D. Merry bus_dmamap_t chain_map;
432991554f2SKenneth D. Merry
43367feec50SStephen McConnell uint8_t *prp_pages;
43467feec50SStephen McConnell bus_addr_t prp_page_busaddr;
43567feec50SStephen McConnell bus_dma_tag_t prp_page_dmat;
43667feec50SStephen McConnell bus_dmamap_t prp_page_map;
43767feec50SStephen McConnell
438991554f2SKenneth D. Merry MPI2_REPLY_DESCRIPTORS_UNION *post_queue;
439991554f2SKenneth D. Merry bus_addr_t post_busaddr;
440991554f2SKenneth D. Merry uint32_t *free_queue;
441991554f2SKenneth D. Merry bus_addr_t free_busaddr;
442991554f2SKenneth D. Merry bus_dma_tag_t queues_dmat;
443991554f2SKenneth D. Merry bus_dmamap_t queues_map;
444991554f2SKenneth D. Merry
445991554f2SKenneth D. Merry uint8_t *fw_diag_buffer;
446991554f2SKenneth D. Merry bus_addr_t fw_diag_busaddr;
447991554f2SKenneth D. Merry bus_dma_tag_t fw_diag_dmat;
448991554f2SKenneth D. Merry bus_dmamap_t fw_diag_map;
449991554f2SKenneth D. Merry
450991554f2SKenneth D. Merry uint8_t ir_firmware;
451991554f2SKenneth D. Merry
452991554f2SKenneth D. Merry /* static config pages */
453991554f2SKenneth D. Merry Mpi2IOCPage8_t ioc_pg8;
454991554f2SKenneth D. Merry Mpi2IOUnitPage8_t iounit_pg8;
455991554f2SKenneth D. Merry
456991554f2SKenneth D. Merry /* host mapping support */
457991554f2SKenneth D. Merry struct dev_mapping_table *mapping_table;
458991554f2SKenneth D. Merry struct enc_mapping_table *enclosure_table;
459991554f2SKenneth D. Merry struct map_removal_table *removal_table;
460991554f2SKenneth D. Merry uint8_t *dpm_entry_used;
461991554f2SKenneth D. Merry uint8_t *dpm_flush_entry;
462991554f2SKenneth D. Merry Mpi2DriverMappingPage0_t *dpm_pg0;
463991554f2SKenneth D. Merry uint16_t max_devices;
464991554f2SKenneth D. Merry uint16_t max_enclosures;
465991554f2SKenneth D. Merry uint16_t max_expanders;
466991554f2SKenneth D. Merry uint8_t max_volumes;
467991554f2SKenneth D. Merry uint8_t num_enc_table_entries;
468991554f2SKenneth D. Merry uint8_t num_rsvd_entries;
469991554f2SKenneth D. Merry uint16_t max_dpm_entries;
470991554f2SKenneth D. Merry uint8_t is_dpm_enable;
471991554f2SKenneth D. Merry uint8_t track_mapping_events;
472991554f2SKenneth D. Merry uint32_t pending_map_events;
473991554f2SKenneth D. Merry
474991554f2SKenneth D. Merry /* FW diag Buffer List */
475991554f2SKenneth D. Merry mpr_fw_diagnostic_buffer_t
476991554f2SKenneth D. Merry fw_diag_buffer_list[MPI2_DIAG_BUF_TYPE_COUNT];
477991554f2SKenneth D. Merry
478991554f2SKenneth D. Merry /* Event Recording IOCTL support */
479991554f2SKenneth D. Merry uint32_t events_to_record[4];
480991554f2SKenneth D. Merry mpr_event_entry_t recorded_events[MPR_EVENT_QUEUE_SIZE];
481991554f2SKenneth D. Merry uint8_t event_index;
482991554f2SKenneth D. Merry uint32_t event_number;
483991554f2SKenneth D. Merry
484991554f2SKenneth D. Merry /* EEDP and TLR support */
485991554f2SKenneth D. Merry uint8_t eedp_enabled;
486991554f2SKenneth D. Merry uint8_t control_TLR;
487991554f2SKenneth D. Merry
488991554f2SKenneth D. Merry /* Shutdown Event Handler */
489991554f2SKenneth D. Merry eventhandler_tag shutdown_eh;
490991554f2SKenneth D. Merry
491991554f2SKenneth D. Merry /* To track topo events during reset */
492991554f2SKenneth D. Merry #define MPR_DIAG_RESET_TIMEOUT 300000
493991554f2SKenneth D. Merry uint8_t wait_for_port_enable;
494991554f2SKenneth D. Merry uint8_t port_enable_complete;
495991554f2SKenneth D. Merry uint8_t msleep_fake_chan;
496991554f2SKenneth D. Merry
497991554f2SKenneth D. Merry /* StartStopUnit command handling at shutdown */
498991554f2SKenneth D. Merry uint32_t SSU_refcount;
499991554f2SKenneth D. Merry uint8_t SSU_started;
500991554f2SKenneth D. Merry
5013c5ac992SScott Long /* Configuration tunables */
5023c5ac992SScott Long u_int disable_msix;
5033c5ac992SScott Long u_int disable_msi;
5043c5ac992SScott Long u_int max_msix;
5053c5ac992SScott Long u_int max_reqframes;
5063c5ac992SScott Long u_int max_prireqframes;
5073c5ac992SScott Long u_int max_replyframes;
5083c5ac992SScott Long u_int max_evtframes;
509991554f2SKenneth D. Merry char exclude_ids[80];
5103c5ac992SScott Long
511991554f2SKenneth D. Merry struct timeval lastfail;
51289d1c21fSKashyap D Desai uint8_t custom_nvme_tm_handling;
51389d1c21fSKashyap D Desai uint8_t nvme_abort_timeout;
514991554f2SKenneth D. Merry };
515991554f2SKenneth D. Merry
516991554f2SKenneth D. Merry struct mpr_config_params {
517991554f2SKenneth D. Merry MPI2_CONFIG_EXT_PAGE_HEADER_UNION hdr;
518991554f2SKenneth D. Merry u_int action;
519991554f2SKenneth D. Merry u_int page_address; /* Attributes, not a phys address */
520991554f2SKenneth D. Merry u_int status;
521991554f2SKenneth D. Merry void *buffer;
522991554f2SKenneth D. Merry u_int length;
523991554f2SKenneth D. Merry int timeout;
524991554f2SKenneth D. Merry void (*callback)(struct mpr_softc *, struct mpr_config_params *);
525991554f2SKenneth D. Merry void *cbdata;
526991554f2SKenneth D. Merry };
527991554f2SKenneth D. Merry
528991554f2SKenneth D. Merry struct scsi_read_capacity_eedp
529991554f2SKenneth D. Merry {
530991554f2SKenneth D. Merry uint8_t addr[8];
531991554f2SKenneth D. Merry uint8_t length[4];
532991554f2SKenneth D. Merry uint8_t protect;
533991554f2SKenneth D. Merry };
534991554f2SKenneth D. Merry
535991554f2SKenneth D. Merry static __inline uint32_t
mpr_regread(struct mpr_softc * sc,uint32_t offset)536991554f2SKenneth D. Merry mpr_regread(struct mpr_softc *sc, uint32_t offset)
537991554f2SKenneth D. Merry {
53834213becSKashyap D Desai uint32_t ret_val, i = 0;
53934213becSKashyap D Desai do {
54034213becSKashyap D Desai ret_val =
54134213becSKashyap D Desai bus_space_read_4(sc->mpr_btag, sc->mpr_bhandle, offset);
54234213becSKashyap D Desai } while((sc->mpr_flags & MPR_FLAGS_SEA_IOC) &&
54334213becSKashyap D Desai (ret_val == 0) && (++i < 3));
54434213becSKashyap D Desai
54534213becSKashyap D Desai return ret_val;
546991554f2SKenneth D. Merry }
547991554f2SKenneth D. Merry
548991554f2SKenneth D. Merry static __inline void
mpr_regwrite(struct mpr_softc * sc,uint32_t offset,uint32_t val)549991554f2SKenneth D. Merry mpr_regwrite(struct mpr_softc *sc, uint32_t offset, uint32_t val)
550991554f2SKenneth D. Merry {
551991554f2SKenneth D. Merry bus_space_write_4(sc->mpr_btag, sc->mpr_bhandle, offset, val);
552991554f2SKenneth D. Merry }
553991554f2SKenneth D. Merry
554991554f2SKenneth D. Merry /* free_queue must have Little Endian address
555991554f2SKenneth D. Merry * TODO- cm_reply_data is unwanted. We can remove it.
556991554f2SKenneth D. Merry * */
557991554f2SKenneth D. Merry static __inline void
mpr_free_reply(struct mpr_softc * sc,uint32_t busaddr)558991554f2SKenneth D. Merry mpr_free_reply(struct mpr_softc *sc, uint32_t busaddr)
559991554f2SKenneth D. Merry {
560991554f2SKenneth D. Merry if (++sc->replyfreeindex >= sc->fqdepth)
561991554f2SKenneth D. Merry sc->replyfreeindex = 0;
562991554f2SKenneth D. Merry sc->free_queue[sc->replyfreeindex] = htole32(busaddr);
563991554f2SKenneth D. Merry mpr_regwrite(sc, MPI2_REPLY_FREE_HOST_INDEX_OFFSET, sc->replyfreeindex);
564991554f2SKenneth D. Merry }
565991554f2SKenneth D. Merry
566991554f2SKenneth D. Merry static __inline struct mpr_chain *
mpr_alloc_chain(struct mpr_softc * sc)567991554f2SKenneth D. Merry mpr_alloc_chain(struct mpr_softc *sc)
568991554f2SKenneth D. Merry {
569991554f2SKenneth D. Merry struct mpr_chain *chain;
570991554f2SKenneth D. Merry
571991554f2SKenneth D. Merry if ((chain = TAILQ_FIRST(&sc->chain_list)) != NULL) {
572991554f2SKenneth D. Merry TAILQ_REMOVE(&sc->chain_list, chain, chain_link);
573991554f2SKenneth D. Merry sc->chain_free--;
574991554f2SKenneth D. Merry if (sc->chain_free < sc->chain_free_lowwater)
575991554f2SKenneth D. Merry sc->chain_free_lowwater = sc->chain_free;
576d0be3479SScott Long } else
577991554f2SKenneth D. Merry sc->chain_alloc_fail++;
578991554f2SKenneth D. Merry return (chain);
579991554f2SKenneth D. Merry }
580991554f2SKenneth D. Merry
581991554f2SKenneth D. Merry static __inline void
mpr_free_chain(struct mpr_softc * sc,struct mpr_chain * chain)582991554f2SKenneth D. Merry mpr_free_chain(struct mpr_softc *sc, struct mpr_chain *chain)
583991554f2SKenneth D. Merry {
584991554f2SKenneth D. Merry #if 0
585991554f2SKenneth D. Merry bzero(chain->chain, 128);
586991554f2SKenneth D. Merry #endif
587991554f2SKenneth D. Merry sc->chain_free++;
588991554f2SKenneth D. Merry TAILQ_INSERT_TAIL(&sc->chain_list, chain, chain_link);
589991554f2SKenneth D. Merry }
590991554f2SKenneth D. Merry
59167feec50SStephen McConnell static __inline struct mpr_prp_page *
mpr_alloc_prp_page(struct mpr_softc * sc)59267feec50SStephen McConnell mpr_alloc_prp_page(struct mpr_softc *sc)
59367feec50SStephen McConnell {
59467feec50SStephen McConnell struct mpr_prp_page *prp_page;
59567feec50SStephen McConnell
59667feec50SStephen McConnell if ((prp_page = TAILQ_FIRST(&sc->prp_page_list)) != NULL) {
59767feec50SStephen McConnell TAILQ_REMOVE(&sc->prp_page_list, prp_page, prp_page_link);
59867feec50SStephen McConnell sc->prp_pages_free--;
59967feec50SStephen McConnell if (sc->prp_pages_free < sc->prp_pages_free_lowwater)
60067feec50SStephen McConnell sc->prp_pages_free_lowwater = sc->prp_pages_free;
60167feec50SStephen McConnell } else
60267feec50SStephen McConnell sc->prp_page_alloc_fail++;
60367feec50SStephen McConnell return (prp_page);
60467feec50SStephen McConnell }
60567feec50SStephen McConnell
60667feec50SStephen McConnell static __inline void
mpr_free_prp_page(struct mpr_softc * sc,struct mpr_prp_page * prp_page)60767feec50SStephen McConnell mpr_free_prp_page(struct mpr_softc *sc, struct mpr_prp_page *prp_page)
60867feec50SStephen McConnell {
60967feec50SStephen McConnell sc->prp_pages_free++;
61067feec50SStephen McConnell TAILQ_INSERT_TAIL(&sc->prp_page_list, prp_page, prp_page_link);
61167feec50SStephen McConnell }
61267feec50SStephen McConnell
613991554f2SKenneth D. Merry static __inline void
mpr_free_command(struct mpr_softc * sc,struct mpr_command * cm)614991554f2SKenneth D. Merry mpr_free_command(struct mpr_softc *sc, struct mpr_command *cm)
615991554f2SKenneth D. Merry {
616991554f2SKenneth D. Merry struct mpr_chain *chain, *chain_temp;
61767feec50SStephen McConnell struct mpr_prp_page *prp_page, *prp_page_temp;
618991554f2SKenneth D. Merry
619175ad3d0SKenneth D. Merry KASSERT(cm->cm_state == MPR_CM_STATE_BUSY,
620175ad3d0SKenneth D. Merry ("state not busy, state = %u\n", cm->cm_state));
621f0779b04SScott Long
622991554f2SKenneth D. Merry if (cm->cm_reply != NULL)
623991554f2SKenneth D. Merry mpr_free_reply(sc, cm->cm_reply_data);
624991554f2SKenneth D. Merry cm->cm_reply = NULL;
625991554f2SKenneth D. Merry cm->cm_flags = 0;
626991554f2SKenneth D. Merry cm->cm_complete = NULL;
627991554f2SKenneth D. Merry cm->cm_complete_data = NULL;
628991554f2SKenneth D. Merry cm->cm_ccb = NULL;
629991554f2SKenneth D. Merry cm->cm_targ = NULL;
630991554f2SKenneth D. Merry cm->cm_max_segs = 0;
631991554f2SKenneth D. Merry cm->cm_lun = 0;
632991554f2SKenneth D. Merry cm->cm_state = MPR_CM_STATE_FREE;
633991554f2SKenneth D. Merry cm->cm_data = NULL;
634991554f2SKenneth D. Merry cm->cm_length = 0;
635991554f2SKenneth D. Merry cm->cm_out_len = 0;
636991554f2SKenneth D. Merry cm->cm_sglsize = 0;
637991554f2SKenneth D. Merry cm->cm_sge = NULL;
638991554f2SKenneth D. Merry
639991554f2SKenneth D. Merry TAILQ_FOREACH_SAFE(chain, &cm->cm_chain_list, chain_link, chain_temp) {
640991554f2SKenneth D. Merry TAILQ_REMOVE(&cm->cm_chain_list, chain, chain_link);
641991554f2SKenneth D. Merry mpr_free_chain(sc, chain);
642991554f2SKenneth D. Merry }
64367feec50SStephen McConnell TAILQ_FOREACH_SAFE(prp_page, &cm->cm_prp_page_list, prp_page_link,
64467feec50SStephen McConnell prp_page_temp) {
64567feec50SStephen McConnell TAILQ_REMOVE(&cm->cm_prp_page_list, prp_page, prp_page_link);
64667feec50SStephen McConnell mpr_free_prp_page(sc, prp_page);
64767feec50SStephen McConnell }
648991554f2SKenneth D. Merry TAILQ_INSERT_TAIL(&sc->req_list, cm, cm_link);
649991554f2SKenneth D. Merry }
650991554f2SKenneth D. Merry
651991554f2SKenneth D. Merry static __inline struct mpr_command *
mpr_alloc_command(struct mpr_softc * sc)652991554f2SKenneth D. Merry mpr_alloc_command(struct mpr_softc *sc)
653991554f2SKenneth D. Merry {
654991554f2SKenneth D. Merry struct mpr_command *cm;
655991554f2SKenneth D. Merry
656991554f2SKenneth D. Merry cm = TAILQ_FIRST(&sc->req_list);
657991554f2SKenneth D. Merry if (cm == NULL)
658991554f2SKenneth D. Merry return (NULL);
659991554f2SKenneth D. Merry
660f0779b04SScott Long KASSERT(cm->cm_state == MPR_CM_STATE_FREE,
661175ad3d0SKenneth D. Merry ("mpr: Allocating busy command, state = %u\n", cm->cm_state));
662f0779b04SScott Long
663991554f2SKenneth D. Merry TAILQ_REMOVE(&sc->req_list, cm, cm_link);
664991554f2SKenneth D. Merry cm->cm_state = MPR_CM_STATE_BUSY;
66586312e46SConrad Meyer cm->cm_timeout_handler = NULL;
666991554f2SKenneth D. Merry return (cm);
667991554f2SKenneth D. Merry }
668991554f2SKenneth D. Merry
669*e3c5965cSAlexander Motin void mprsas_prepare_remove_retry(struct mprsas_softc *sassc);
670*e3c5965cSAlexander Motin
671991554f2SKenneth D. Merry static __inline void
mpr_free_high_priority_command(struct mpr_softc * sc,struct mpr_command * cm)672991554f2SKenneth D. Merry mpr_free_high_priority_command(struct mpr_softc *sc, struct mpr_command *cm)
673991554f2SKenneth D. Merry {
674991554f2SKenneth D. Merry struct mpr_chain *chain, *chain_temp;
675991554f2SKenneth D. Merry
676175ad3d0SKenneth D. Merry KASSERT(cm->cm_state == MPR_CM_STATE_BUSY,
677175ad3d0SKenneth D. Merry ("state not busy, state = %u\n", cm->cm_state));
678f0779b04SScott Long
679991554f2SKenneth D. Merry if (cm->cm_reply != NULL)
680991554f2SKenneth D. Merry mpr_free_reply(sc, cm->cm_reply_data);
681991554f2SKenneth D. Merry cm->cm_reply = NULL;
682991554f2SKenneth D. Merry cm->cm_flags = 0;
683991554f2SKenneth D. Merry cm->cm_complete = NULL;
684991554f2SKenneth D. Merry cm->cm_complete_data = NULL;
685991554f2SKenneth D. Merry cm->cm_ccb = NULL;
686991554f2SKenneth D. Merry cm->cm_targ = NULL;
687991554f2SKenneth D. Merry cm->cm_lun = 0;
688991554f2SKenneth D. Merry cm->cm_state = MPR_CM_STATE_FREE;
689991554f2SKenneth D. Merry TAILQ_FOREACH_SAFE(chain, &cm->cm_chain_list, chain_link, chain_temp) {
690991554f2SKenneth D. Merry TAILQ_REMOVE(&cm->cm_chain_list, chain, chain_link);
691991554f2SKenneth D. Merry mpr_free_chain(sc, chain);
692991554f2SKenneth D. Merry }
693991554f2SKenneth D. Merry TAILQ_INSERT_TAIL(&sc->high_priority_req_list, cm, cm_link);
694*e3c5965cSAlexander Motin
695*e3c5965cSAlexander Motin if (sc->sassc)
696*e3c5965cSAlexander Motin mprsas_prepare_remove_retry(sc->sassc);
697991554f2SKenneth D. Merry }
698991554f2SKenneth D. Merry
699991554f2SKenneth D. Merry static __inline struct mpr_command *
mpr_alloc_high_priority_command(struct mpr_softc * sc)700991554f2SKenneth D. Merry mpr_alloc_high_priority_command(struct mpr_softc *sc)
701991554f2SKenneth D. Merry {
702991554f2SKenneth D. Merry struct mpr_command *cm;
703991554f2SKenneth D. Merry
704991554f2SKenneth D. Merry cm = TAILQ_FIRST(&sc->high_priority_req_list);
705991554f2SKenneth D. Merry if (cm == NULL)
706991554f2SKenneth D. Merry return (NULL);
707991554f2SKenneth D. Merry
708f0779b04SScott Long KASSERT(cm->cm_state == MPR_CM_STATE_FREE,
709175ad3d0SKenneth D. Merry ("mpr: Allocating busy command, state = %u\n", cm->cm_state));
710f0779b04SScott Long
711991554f2SKenneth D. Merry TAILQ_REMOVE(&sc->high_priority_req_list, cm, cm_link);
712991554f2SKenneth D. Merry cm->cm_state = MPR_CM_STATE_BUSY;
71386312e46SConrad Meyer cm->cm_timeout_handler = NULL;
714b7f1ee79SScott Long cm->cm_desc.HighPriority.RequestFlags =
715b7f1ee79SScott Long MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY;
716991554f2SKenneth D. Merry return (cm);
717991554f2SKenneth D. Merry }
718991554f2SKenneth D. Merry
719991554f2SKenneth D. Merry static __inline void
mpr_lock(struct mpr_softc * sc)720991554f2SKenneth D. Merry mpr_lock(struct mpr_softc *sc)
721991554f2SKenneth D. Merry {
722991554f2SKenneth D. Merry mtx_lock(&sc->mpr_mtx);
723991554f2SKenneth D. Merry }
724991554f2SKenneth D. Merry
725991554f2SKenneth D. Merry static __inline void
mpr_unlock(struct mpr_softc * sc)726991554f2SKenneth D. Merry mpr_unlock(struct mpr_softc *sc)
727991554f2SKenneth D. Merry {
728991554f2SKenneth D. Merry mtx_unlock(&sc->mpr_mtx);
729991554f2SKenneth D. Merry }
730991554f2SKenneth D. Merry
731991554f2SKenneth D. Merry #define MPR_INFO (1 << 0) /* Basic info */
732991554f2SKenneth D. Merry #define MPR_FAULT (1 << 1) /* Hardware faults */
733991554f2SKenneth D. Merry #define MPR_EVENT (1 << 2) /* Event data from the controller */
734991554f2SKenneth D. Merry #define MPR_LOG (1 << 3) /* Log data from the controller */
735991554f2SKenneth D. Merry #define MPR_RECOVERY (1 << 4) /* Command error recovery tracing */
736991554f2SKenneth D. Merry #define MPR_ERROR (1 << 5) /* Parameter errors, programming bugs */
737991554f2SKenneth D. Merry #define MPR_INIT (1 << 6) /* Things related to system init */
738991554f2SKenneth D. Merry #define MPR_XINFO (1 << 7) /* More detailed/noisy info */
739991554f2SKenneth D. Merry #define MPR_USER (1 << 8) /* Trace user-generated commands */
740991554f2SKenneth D. Merry #define MPR_MAPPING (1 << 9) /* Trace device mappings */
741991554f2SKenneth D. Merry #define MPR_TRACE (1 << 10) /* Function-by-function trace */
742991554f2SKenneth D. Merry
743a2c14879SStephen McConnell #define MPR_SSU_DISABLE_SSD_DISABLE_HDD 0
744a2c14879SStephen McConnell #define MPR_SSU_ENABLE_SSD_DISABLE_HDD 1
745a2c14879SStephen McConnell #define MPR_SSU_DISABLE_SSD_ENABLE_HDD 2
746a2c14879SStephen McConnell #define MPR_SSU_ENABLE_SSD_ENABLE_HDD 3
747a2c14879SStephen McConnell
748991554f2SKenneth D. Merry #define mpr_printf(sc, args...) \
749991554f2SKenneth D. Merry device_printf((sc)->mpr_dev, ##args)
750991554f2SKenneth D. Merry
751c11c484fSScott Long #define mpr_print_field(sc, msg, args...) \
752c11c484fSScott Long printf("\t" msg, ##args)
753c11c484fSScott Long
754991554f2SKenneth D. Merry #define mpr_vprintf(sc, args...) \
755991554f2SKenneth D. Merry do { \
756991554f2SKenneth D. Merry if (bootverbose) \
757991554f2SKenneth D. Merry mpr_printf(sc, ##args); \
758991554f2SKenneth D. Merry } while (0)
759991554f2SKenneth D. Merry
760991554f2SKenneth D. Merry #define mpr_dprint(sc, level, msg, args...) \
761991554f2SKenneth D. Merry do { \
7627a2a6a1aSStephen McConnell if ((sc)->mpr_debug & (level)) \
763991554f2SKenneth D. Merry device_printf((sc)->mpr_dev, msg, ##args); \
764991554f2SKenneth D. Merry } while (0)
765991554f2SKenneth D. Merry
766991554f2SKenneth D. Merry #define MPR_PRINTFIELD_START(sc, tag...) \
767c11c484fSScott Long mpr_printf((sc), ##tag); \
768c11c484fSScott Long mpr_print_field((sc), ":\n")
769991554f2SKenneth D. Merry #define MPR_PRINTFIELD_END(sc, tag) \
770c11c484fSScott Long mpr_printf((sc), tag "\n")
771991554f2SKenneth D. Merry #define MPR_PRINTFIELD(sc, facts, attr, fmt) \
772c11c484fSScott Long mpr_print_field((sc), #attr ": " #fmt "\n", (facts)->attr)
77371900a79SAlfredo Dal'Ava Junior #define MPR_PRINTFIELD_16(sc, facts, attr, fmt) \
77471900a79SAlfredo Dal'Ava Junior mpr_print_field((sc), #attr ": " #fmt "\n", le16toh((facts)->attr))
77571900a79SAlfredo Dal'Ava Junior #define MPR_PRINTFIELD_32(sc, facts, attr, fmt) \
77671900a79SAlfredo Dal'Ava Junior mpr_print_field((sc), #attr ": " #fmt "\n", le32toh((facts)->attr))
777991554f2SKenneth D. Merry
778991554f2SKenneth D. Merry static __inline void
mpr_from_u64(uint64_t data,U64 * mpr)779991554f2SKenneth D. Merry mpr_from_u64(uint64_t data, U64 *mpr)
780991554f2SKenneth D. Merry {
781991554f2SKenneth D. Merry (mpr)->High = htole32((uint32_t)((data) >> 32));
782991554f2SKenneth D. Merry (mpr)->Low = htole32((uint32_t)((data) & 0xffffffff));
783991554f2SKenneth D. Merry }
784991554f2SKenneth D. Merry
785991554f2SKenneth D. Merry static __inline uint64_t
mpr_to_u64(U64 * data)786991554f2SKenneth D. Merry mpr_to_u64(U64 *data)
787991554f2SKenneth D. Merry {
788991554f2SKenneth D. Merry return (((uint64_t)le32toh(data->High) << 32) | le32toh(data->Low));
789991554f2SKenneth D. Merry }
790991554f2SKenneth D. Merry
791991554f2SKenneth D. Merry static __inline void
mpr_mask_intr(struct mpr_softc * sc)792991554f2SKenneth D. Merry mpr_mask_intr(struct mpr_softc *sc)
793991554f2SKenneth D. Merry {
794991554f2SKenneth D. Merry uint32_t mask;
795991554f2SKenneth D. Merry
796991554f2SKenneth D. Merry mask = mpr_regread(sc, MPI2_HOST_INTERRUPT_MASK_OFFSET);
797991554f2SKenneth D. Merry mask |= MPI2_HIM_REPLY_INT_MASK;
798991554f2SKenneth D. Merry mpr_regwrite(sc, MPI2_HOST_INTERRUPT_MASK_OFFSET, mask);
799991554f2SKenneth D. Merry }
800991554f2SKenneth D. Merry
801991554f2SKenneth D. Merry static __inline void
mpr_unmask_intr(struct mpr_softc * sc)802991554f2SKenneth D. Merry mpr_unmask_intr(struct mpr_softc *sc)
803991554f2SKenneth D. Merry {
804991554f2SKenneth D. Merry uint32_t mask;
805991554f2SKenneth D. Merry
806991554f2SKenneth D. Merry mask = mpr_regread(sc, MPI2_HOST_INTERRUPT_MASK_OFFSET);
807991554f2SKenneth D. Merry mask &= ~MPI2_HIM_REPLY_INT_MASK;
808991554f2SKenneth D. Merry mpr_regwrite(sc, MPI2_HOST_INTERRUPT_MASK_OFFSET, mask);
809991554f2SKenneth D. Merry }
810991554f2SKenneth D. Merry
811991554f2SKenneth D. Merry int mpr_pci_setup_interrupts(struct mpr_softc *sc);
812bec09074SScott Long void mpr_pci_free_interrupts(struct mpr_softc *sc);
813991554f2SKenneth D. Merry int mpr_pci_restore(struct mpr_softc *sc);
814991554f2SKenneth D. Merry
815252b2b4fSScott Long void mpr_get_tunables(struct mpr_softc *sc);
816991554f2SKenneth D. Merry int mpr_attach(struct mpr_softc *sc);
817991554f2SKenneth D. Merry int mpr_free(struct mpr_softc *sc);
818991554f2SKenneth D. Merry void mpr_intr(void *);
819991554f2SKenneth D. Merry void mpr_intr_msi(void *);
820991554f2SKenneth D. Merry void mpr_intr_locked(void *);
821991554f2SKenneth D. Merry int mpr_register_events(struct mpr_softc *, uint8_t *, mpr_evt_callback_t *,
822991554f2SKenneth D. Merry void *, struct mpr_event_handle **);
823991554f2SKenneth D. Merry int mpr_restart(struct mpr_softc *);
8247a2a6a1aSStephen McConnell int mpr_update_events(struct mpr_softc *, struct mpr_event_handle *, uint8_t *);
825991554f2SKenneth D. Merry int mpr_deregister_events(struct mpr_softc *, struct mpr_event_handle *);
82667feec50SStephen McConnell void mpr_build_nvme_prp(struct mpr_softc *sc, struct mpr_command *cm,
82767feec50SStephen McConnell Mpi26NVMeEncapsulatedRequest_t *nvme_encap_request, void *data,
82867feec50SStephen McConnell uint32_t data_in_sz, uint32_t data_out_sz);
829991554f2SKenneth D. Merry int mpr_push_sge(struct mpr_command *, MPI2_SGE_SIMPLE64 *, size_t, int);
830991554f2SKenneth D. Merry int mpr_push_ieee_sge(struct mpr_command *, void *, int);
831991554f2SKenneth D. Merry int mpr_add_dmaseg(struct mpr_command *, vm_paddr_t, size_t, u_int, int);
832991554f2SKenneth D. Merry int mpr_attach_sas(struct mpr_softc *sc);
833991554f2SKenneth D. Merry int mpr_detach_sas(struct mpr_softc *sc);
834991554f2SKenneth D. Merry int mpr_read_config_page(struct mpr_softc *, struct mpr_config_params *);
835991554f2SKenneth D. Merry int mpr_write_config_page(struct mpr_softc *, struct mpr_config_params *);
836991554f2SKenneth D. Merry void mpr_memaddr_cb(void *, bus_dma_segment_t *, int , int );
837e2997a03SKenneth D. Merry void mpr_memaddr_wait_cb(void *, bus_dma_segment_t *, int , int );
838991554f2SKenneth D. Merry void mpr_init_sge(struct mpr_command *cm, void *req, void *sge);
839991554f2SKenneth D. Merry int mpr_attach_user(struct mpr_softc *);
840991554f2SKenneth D. Merry void mpr_detach_user(struct mpr_softc *);
841991554f2SKenneth D. Merry void mprsas_record_event(struct mpr_softc *sc,
842991554f2SKenneth D. Merry MPI2_EVENT_NOTIFICATION_REPLY *event_reply);
843991554f2SKenneth D. Merry
844991554f2SKenneth D. Merry int mpr_map_command(struct mpr_softc *sc, struct mpr_command *cm);
8456d4ffcb4SKenneth D. Merry int mpr_wait_command(struct mpr_softc *sc, struct mpr_command **cm, int timeout,
8467a2a6a1aSStephen McConnell int sleep_flag);
8476d4ffcb4SKenneth D. Merry int mpr_request_polled(struct mpr_softc *sc, struct mpr_command **cm);
848991554f2SKenneth D. Merry
849991554f2SKenneth D. Merry int mpr_config_get_bios_pg3(struct mpr_softc *sc, Mpi2ConfigReply_t
850991554f2SKenneth D. Merry *mpi_reply, Mpi2BiosPage3_t *config_page);
851991554f2SKenneth D. Merry int mpr_config_get_raid_volume_pg0(struct mpr_softc *sc, Mpi2ConfigReply_t
852991554f2SKenneth D. Merry *mpi_reply, Mpi2RaidVolPage0_t *config_page, u32 page_address);
853991554f2SKenneth D. Merry int mpr_config_get_ioc_pg8(struct mpr_softc *sc, Mpi2ConfigReply_t *,
854991554f2SKenneth D. Merry Mpi2IOCPage8_t *);
855991554f2SKenneth D. Merry int mpr_config_get_iounit_pg8(struct mpr_softc *sc,
856991554f2SKenneth D. Merry Mpi2ConfigReply_t *mpi_reply, Mpi2IOUnitPage8_t *config_page);
857991554f2SKenneth D. Merry int mpr_config_get_sas_device_pg0(struct mpr_softc *, Mpi2ConfigReply_t *,
858991554f2SKenneth D. Merry Mpi2SasDevicePage0_t *, u32 , u16 );
85967feec50SStephen McConnell int mpr_config_get_pcie_device_pg0(struct mpr_softc *sc, Mpi2ConfigReply_t
86067feec50SStephen McConnell *mpi_reply, Mpi26PCIeDevicePage0_t *config_page, u32 form, u16 handle);
86167feec50SStephen McConnell int mpr_config_get_pcie_device_pg2(struct mpr_softc *sc, Mpi2ConfigReply_t
86267feec50SStephen McConnell *mpi_reply, Mpi26PCIeDevicePage2_t *config_page, u32 form, u16 handle);
863991554f2SKenneth D. Merry int mpr_config_get_dpm_pg0(struct mpr_softc *, Mpi2ConfigReply_t *,
864991554f2SKenneth D. Merry Mpi2DriverMappingPage0_t *, u16 );
865991554f2SKenneth D. Merry int mpr_config_get_raid_volume_pg1(struct mpr_softc *sc,
866991554f2SKenneth D. Merry Mpi2ConfigReply_t *mpi_reply, Mpi2RaidVolPage1_t *config_page, u32 form,
867991554f2SKenneth D. Merry u16 handle);
868991554f2SKenneth D. Merry int mpr_config_get_volume_wwid(struct mpr_softc *sc, u16 volume_handle,
869991554f2SKenneth D. Merry u64 *wwid);
870991554f2SKenneth D. Merry int mpr_config_get_raid_pd_pg0(struct mpr_softc *sc,
871991554f2SKenneth D. Merry Mpi2ConfigReply_t *mpi_reply, Mpi2RaidPhysDiskPage0_t *config_page,
872991554f2SKenneth D. Merry u32 page_address);
87389d1c21fSKashyap D Desai int mpr_config_get_man_pg11(struct mpr_softc *sc, Mpi2ConfigReply_t *mpi_reply,
87489d1c21fSKashyap D Desai Mpi2ManufacturingPage11_t *config_page);
875acc173a6SWarner Losh void mprsas_ir_shutdown(struct mpr_softc *sc, int howto);
876991554f2SKenneth D. Merry
877991554f2SKenneth D. Merry int mpr_reinit(struct mpr_softc *sc);
878991554f2SKenneth D. Merry void mprsas_handle_reinit(struct mpr_softc *sc);
879991554f2SKenneth D. Merry
880991554f2SKenneth D. Merry void mpr_base_static_config_pages(struct mpr_softc *sc);
881991554f2SKenneth D. Merry
882991554f2SKenneth D. Merry int mpr_mapping_initialize(struct mpr_softc *);
883991554f2SKenneth D. Merry void mpr_mapping_topology_change_event(struct mpr_softc *,
884991554f2SKenneth D. Merry Mpi2EventDataSasTopologyChangeList_t *);
88567feec50SStephen McConnell void mpr_mapping_pcie_topology_change_event(struct mpr_softc *sc,
88667feec50SStephen McConnell Mpi26EventDataPCIeTopologyChangeList_t *event_data);
887991554f2SKenneth D. Merry void mpr_mapping_free_memory(struct mpr_softc *sc);
888991554f2SKenneth D. Merry int mpr_config_set_dpm_pg0(struct mpr_softc *, Mpi2ConfigReply_t *,
889991554f2SKenneth D. Merry Mpi2DriverMappingPage0_t *, u16 );
890991554f2SKenneth D. Merry void mpr_mapping_exit(struct mpr_softc *);
891327f2e6cSStephen McConnell void mpr_mapping_check_devices(void *);
892991554f2SKenneth D. Merry int mpr_mapping_allocate_memory(struct mpr_softc *sc);
893327f2e6cSStephen McConnell unsigned int mpr_mapping_get_tid(struct mpr_softc *, uint64_t , u16);
894327f2e6cSStephen McConnell unsigned int mpr_mapping_get_tid_from_handle(struct mpr_softc *sc,
895991554f2SKenneth D. Merry u16 handle);
896327f2e6cSStephen McConnell unsigned int mpr_mapping_get_raid_tid(struct mpr_softc *sc, u64 wwid,
897327f2e6cSStephen McConnell u16 volHandle);
898327f2e6cSStephen McConnell unsigned int mpr_mapping_get_raid_tid_from_handle(struct mpr_softc *sc,
899991554f2SKenneth D. Merry u16 volHandle);
900991554f2SKenneth D. Merry void mpr_mapping_enclosure_dev_status_change_event(struct mpr_softc *,
901991554f2SKenneth D. Merry Mpi2EventDataSasEnclDevStatusChange_t *event_data);
902991554f2SKenneth D. Merry void mpr_mapping_ir_config_change_event(struct mpr_softc *sc,
903991554f2SKenneth D. Merry Mpi2EventDataIrConfigChangeList_t *event_data);
904991554f2SKenneth D. Merry
905991554f2SKenneth D. Merry void mprsas_evt_handler(struct mpr_softc *sc, uintptr_t data,
906991554f2SKenneth D. Merry MPI2_EVENT_NOTIFICATION_REPLY *event);
907991554f2SKenneth D. Merry void mprsas_prepare_remove(struct mprsas_softc *sassc, uint16_t handle);
9087a2a6a1aSStephen McConnell void mprsas_prepare_volume_remove(struct mprsas_softc *sassc, uint16_t handle);
909991554f2SKenneth D. Merry int mprsas_startup(struct mpr_softc *sc);
9107a2a6a1aSStephen McConnell struct mprsas_target * mprsas_find_target_by_handle(struct mprsas_softc *, int,
9117a2a6a1aSStephen McConnell uint16_t);
912a2c14879SStephen McConnell void mprsas_realloc_targets(struct mpr_softc *sc, int maxtargets);
913a2c14879SStephen McConnell struct mpr_command * mprsas_alloc_tm(struct mpr_softc *sc);
914a2c14879SStephen McConnell void mprsas_free_tm(struct mpr_softc *sc, struct mpr_command *tm);
915a2c14879SStephen McConnell void mprsas_release_simq_reinit(struct mprsas_softc *sassc);
916a2c14879SStephen McConnell int mprsas_send_reset(struct mpr_softc *sc, struct mpr_command *tm,
917a2c14879SStephen McConnell uint8_t type);
918991554f2SKenneth D. Merry
919991554f2SKenneth D. Merry SYSCTL_DECL(_hw_mpr);
920991554f2SKenneth D. Merry
921991554f2SKenneth D. Merry /* Compatibility shims for different OS versions */
922991554f2SKenneth D. Merry #if defined(CAM_PRIORITY_XPT)
923991554f2SKenneth D. Merry #define MPR_PRIORITY_XPT CAM_PRIORITY_XPT
924991554f2SKenneth D. Merry #else
925991554f2SKenneth D. Merry #define MPR_PRIORITY_XPT 5
926991554f2SKenneth D. Merry #endif
927991554f2SKenneth D. Merry
92867feec50SStephen McConnell /* Definitions for SCSI unmap translation to NVMe DSM command */
92967feec50SStephen McConnell
93067feec50SStephen McConnell /* UNMAP block descriptor structure */
93167feec50SStephen McConnell struct unmap_blk_desc {
93267feec50SStephen McConnell uint64_t slba;
93367feec50SStephen McConnell uint32_t nlb;
93467feec50SStephen McConnell uint32_t resv;
93567feec50SStephen McConnell };
93667feec50SStephen McConnell
93767feec50SStephen McConnell /* UNMAP command's data */
93867feec50SStephen McConnell struct unmap_parm_list {
93967feec50SStephen McConnell uint16_t unmap_data_len;
94067feec50SStephen McConnell uint16_t unmap_blk_desc_data_len;
94167feec50SStephen McConnell uint32_t resv;
94267feec50SStephen McConnell struct unmap_blk_desc desc[0];
94367feec50SStephen McConnell };
94467feec50SStephen McConnell
94567feec50SStephen McConnell /* SCSI ADDITIONAL SENSE Codes */
94667feec50SStephen McConnell #define FIXED_SENSE_DATA 0x70
94767feec50SStephen McConnell #define SCSI_ASC_NO_SENSE 0x00
94867feec50SStephen McConnell #define SCSI_ASC_PERIPHERAL_DEV_WRITE_FAULT 0x03
94967feec50SStephen McConnell #define SCSI_ASC_LUN_NOT_READY 0x04
95067feec50SStephen McConnell #define SCSI_ASC_WARNING 0x0B
95167feec50SStephen McConnell #define SCSI_ASC_LOG_BLOCK_GUARD_CHECK_FAILED 0x10
95267feec50SStephen McConnell #define SCSI_ASC_LOG_BLOCK_APPTAG_CHECK_FAILED 0x10
95367feec50SStephen McConnell #define SCSI_ASC_LOG_BLOCK_REFTAG_CHECK_FAILED 0x10
95467feec50SStephen McConnell #define SCSI_ASC_UNRECOVERED_READ_ERROR 0x11
95567feec50SStephen McConnell #define SCSI_ASC_MISCOMPARE_DURING_VERIFY 0x1D
95667feec50SStephen McConnell #define SCSI_ASC_ACCESS_DENIED_INVALID_LUN_ID 0x20
95767feec50SStephen McConnell #define SCSI_ASC_ILLEGAL_COMMAND 0x20
95867feec50SStephen McConnell #define SCSI_ASC_ILLEGAL_BLOCK 0x21
95967feec50SStephen McConnell #define SCSI_ASC_INVALID_CDB 0x24
96067feec50SStephen McConnell #define SCSI_ASC_INVALID_LUN 0x25
96167feec50SStephen McConnell #define SCSI_ASC_INVALID_PARAMETER 0x26
96267feec50SStephen McConnell #define SCSI_ASC_FORMAT_COMMAND_FAILED 0x31
96367feec50SStephen McConnell #define SCSI_ASC_INTERNAL_TARGET_FAILURE 0x44
96467feec50SStephen McConnell
96567feec50SStephen McConnell /* SCSI ADDITIONAL SENSE Code Qualifiers */
96667feec50SStephen McConnell #define SCSI_ASCQ_CAUSE_NOT_REPORTABLE 0x00
96767feec50SStephen McConnell #define SCSI_ASCQ_FORMAT_COMMAND_FAILED 0x01
96867feec50SStephen McConnell #define SCSI_ASCQ_LOG_BLOCK_GUARD_CHECK_FAILED 0x01
96967feec50SStephen McConnell #define SCSI_ASCQ_LOG_BLOCK_APPTAG_CHECK_FAILED 0x02
97067feec50SStephen McConnell #define SCSI_ASCQ_LOG_BLOCK_REFTAG_CHECK_FAILED 0x03
97167feec50SStephen McConnell #define SCSI_ASCQ_FORMAT_IN_PROGRESS 0x04
97267feec50SStephen McConnell #define SCSI_ASCQ_POWER_LOSS_EXPECTED 0x08
97367feec50SStephen McConnell #define SCSI_ASCQ_INVALID_LUN_ID 0x09
97467feec50SStephen McConnell
975991554f2SKenneth D. Merry #endif
976