2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2011-2015 LSI Corp.
5 * Copyright (c) 2013-2015 Avago Technologies
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD
34 struct mps_fw_event_work;
37 SLIST_ENTRY(mpssas_lun) lun_link;
39 uint8_t eedp_formatted;
40 uint32_t eedp_block_size;
43 struct mpssas_target {
51 #define MPSSAS_TARGET_INABORT (1 << 0)
52 #define MPSSAS_TARGET_INRESET (1 << 1)
53 #define MPSSAS_TARGET_INDIAGRESET (1 << 2)
54 #define MPSSAS_TARGET_INREMOVAL (1 << 3)
55 #define MPS_TARGET_FLAGS_RAID_COMPONENT (1 << 4)
56 #define MPS_TARGET_FLAGS_VOLUME (1 << 5)
57 #define MPS_TARGET_IS_SATA_SSD (1 << 6)
58 #define MPSSAS_TARGET_INRECOVERY (MPSSAS_TARGET_INABORT | \
59 MPSSAS_TARGET_INRESET | MPSSAS_TARGET_INCHIPRESET)
62 SLIST_HEAD(, mpssas_lun) luns;
63 TAILQ_HEAD(, mps_command) commands;
64 struct mps_command *tm;
65 TAILQ_HEAD(, mps_command) timedout_commands;
66 uint16_t exp_dev_handle;
69 uint16_t parent_handle;
70 uint64_t parent_sasaddr;
71 uint32_t parent_devinfo;
74 unsigned int outstanding;
75 unsigned int timeouts;
77 unsigned int logical_unit_resets;
78 unsigned int target_resets;
79 uint8_t stop_at_shutdown;
86 #define MPSSAS_IN_DISCOVERY (1 << 0)
87 #define MPSSAS_IN_STARTUP (1 << 1)
88 #define MPSSAS_DISCOVERY_TIMEOUT_PENDING (1 << 2)
89 #define MPSSAS_QUEUE_FROZEN (1 << 3)
90 #define MPSSAS_SHUTDOWN (1 << 4)
92 struct mpssas_target *targets;
93 struct cam_devq *devq;
95 struct cam_path *path;
96 struct intr_config_hook sas_ich;
97 struct callout discovery_callout;
98 struct mps_event_handle *mpssas_eh;
100 u_int startup_refcount;
101 struct proc *sysctl_proc;
103 struct taskqueue *ev_tq;
105 TAILQ_HEAD(, mps_fw_event_work) ev_queue;
108 MALLOC_DECLARE(M_MPSSAS);
111 * Abstracted so that the driver can be backwards and forwards compatible
112 * with future versions of CAM that will provide this functionality.
114 #define MPS_SET_LUN(lun, ccblun) \
115 mpssas_set_lun(lun, ccblun)
118 mpssas_set_lun(uint8_t *lun, u_int ccblun)
122 newlun = (uint64_t *)lun;
124 if (ccblun <= 0xff) {
125 /* Peripheral device address method, LUN is 0 to 255 */
127 } else if (ccblun <= 0x3fff) {
128 /* Flat space address method, LUN is <= 16383 */
129 scsi_ulto2b(ccblun, lun);
131 } else if (ccblun <= 0xffffff) {
132 /* Extended flat space address method, LUN is <= 16777215 */
133 scsi_ulto3b(ccblun, &lun[1]);
134 /* Extended Flat space address method */
136 /* Length = 1, i.e. LUN is 3 bytes long */
138 /* Extended Address Method */
148 mpssas_set_ccbstatus(union ccb *ccb, int status)
150 ccb->ccb_h.status &= ~CAM_STATUS_MASK;
151 ccb->ccb_h.status |= status;
155 mpssas_get_ccbstatus(union ccb *ccb)
157 return (ccb->ccb_h.status & CAM_STATUS_MASK);
160 #define MPS_SET_SINGLE_LUN(req, lun) \
162 bzero((req)->LUN, 8); \
163 (req)->LUN[1] = lun; \
166 void mpssas_rescan_target(struct mps_softc *sc, struct mpssas_target *targ);
167 void mpssas_discovery_end(struct mpssas_softc *sassc);
168 void mpssas_prepare_for_tm(struct mps_softc *sc, struct mps_command *tm,
169 struct mpssas_target *target, lun_id_t lun_id);
170 void mpssas_startup_increment(struct mpssas_softc *sassc);
171 void mpssas_startup_decrement(struct mpssas_softc *sassc);
173 void mpssas_firmware_event_work(void *arg, int pending);
174 int mpssas_check_id(struct mpssas_softc *sassc, int id);