2 * Copyright (c) 2011 LSI Corp.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * LSI MPT-Fusion Host Adapter FreeBSD
28 * $FreeBSD: src/sys/dev/mps/mps_sas.h,v 1.1 2012/01/26 18:17:21 ken Exp $
31 struct mps_fw_event_work;
34 SLIST_ENTRY(mpssas_lun) lun_link;
36 uint8_t eedp_formatted;
37 uint32_t eedp_block_size;
40 struct mpssas_target {
48 #define MPSSAS_TARGET_INABORT (1 << 0)
49 #define MPSSAS_TARGET_INRESET (1 << 1)
50 #define MPSSAS_TARGET_INDIAGRESET (1 << 2)
51 #define MPSSAS_TARGET_INREMOVAL (1 << 3)
52 #define MPSSAS_TARGET_INRECOVERY (MPSSAS_TARGET_INABORT | \
53 MPSSAS_TARGET_INRESET | MPSSAS_TARGET_INCHIPRESET)
54 #define MPSSAS_TARGET_ADD (1 << 29)
55 #define MPSSAS_TARGET_REMOVE (1 << 30)
57 SLIST_HEAD(, mpssas_lun) luns;
58 TAILQ_HEAD(, mps_command) commands;
59 struct mps_command *tm;
60 TAILQ_HEAD(, mps_command) timedout_commands;
61 uint16_t exp_dev_handle;
64 uint16_t parent_handle;
65 uint64_t parent_sasaddr;
66 uint32_t parent_devinfo;
67 struct sysctl_ctx_list sysctl_ctx;
68 struct sysctl_oid *sysctl_tree;
69 TAILQ_ENTRY(mpssas_target) sysctl_link;
72 unsigned int outstanding;
73 unsigned int timeouts;
75 unsigned int logical_unit_resets;
76 unsigned int target_resets;
82 #define MPSSAS_IN_DISCOVERY (1 << 0)
83 #define MPSSAS_IN_STARTUP (1 << 1)
84 #define MPSSAS_DISCOVERY_TIMEOUT_PENDING (1 << 2)
85 #define MPSSAS_QUEUE_FROZEN (1 << 3)
86 #define MPSSAS_SHUTDOWN (1 << 4)
87 #define MPSSAS_SCANTHREAD (1 << 5)
88 struct mpssas_target *targets;
89 struct cam_devq *devq;
91 struct cam_path *path;
92 struct intr_config_hook sas_ich;
93 struct callout discovery_callout;
94 u_int discovery_timeouts;
95 struct mps_event_handle *mpssas_eh;
97 u_int startup_refcount;
99 struct proc *sysctl_proc;
101 TAILQ_HEAD(, ccb_hdr) ccb_scanq;
102 struct thread *rescan_thread;
104 struct taskqueue *ev_tq;
106 TAILQ_HEAD(, mps_fw_event_work) ev_queue;
109 MALLOC_DECLARE(M_MPSSAS);
112 * Abstracted so that the driver can be backwards and forwards compatible
113 * with future versions of CAM that will provide this functionality.
115 #define MPS_SET_LUN(lun, ccblun) \
116 mpssas_set_lun(lun, ccblun)
119 mpssas_set_lun(uint8_t *lun, u_int ccblun)
123 newlun = (uint64_t *)lun;
125 if (ccblun <= 0xff) {
126 /* Peripheral device address method, LUN is 0 to 255 */
128 } else if (ccblun <= 0x3fff) {
129 /* Flat space address method, LUN is <= 16383 */
130 scsi_ulto2b(ccblun, lun);
132 } else if (ccblun <= 0xffffff) {
133 /* Extended flat space address method, LUN is <= 16777215 */
134 scsi_ulto3b(ccblun, &lun[1]);
135 /* Extended Flat space address method */
137 /* Length = 1, i.e. LUN is 3 bytes long */
139 /* Extended Address Method */
148 #define MPS_SET_SINGLE_LUN(req, lun) \
150 bzero((req)->LUN, 8); \
151 (req)->LUN[1] = lun; \
154 void mpssas_rescan_target(struct mps_softc *sc, struct mpssas_target *targ);
155 void mpssas_discovery_end(struct mpssas_softc *sassc);
156 void mpssas_startup_increment(struct mpssas_softc *sassc);
157 void mpssas_startup_decrement(struct mpssas_softc *sassc);
159 struct mps_command * mpssas_alloc_tm(struct mps_softc *sc);
160 void mpssas_free_tm(struct mps_softc *sc, struct mps_command *tm);
161 void mpssas_firmware_event_work(void *arg, int pending);