2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2020-2023, Broadcom Inc. All rights reserved.
5 * Support: <fbsd-storage-driver.pdl@broadcom.com>
7 * Authors: Sumit Saxena <sumit.saxena@broadcom.com>
8 * Chandrakanth Patil <chandrakanth.patil@broadcom.com>
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are
14 * 1. Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright notice,
17 * this list of conditions and the following disclaimer in the documentation and/or other
18 * materials provided with the distribution.
19 * 3. Neither the name of the Broadcom Inc. nor the names of its contributors
20 * may be used to endorse or promote products derived from this software without
21 * specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
35 * The views and conclusions contained in the software and documentation are
36 * those of the authors and should not be interpreted as representing
37 * official policies,either expressed or implied, of the FreeBSD Project.
39 * Mail to: Broadcom Inc 1320 Ridder Park Dr, San Jose, CA 95131
41 * Broadcom Inc. (Broadcom) MPI3MR Adapter FreeBSD
45 struct mpi3mr_fw_event_work;
47 struct mpi3mr_throttle_group_info {
54 mpi3mr_atomic_t pend_large_data_sz;
57 struct mpi3mr_tgt_dev_sassata {
62 struct mpi3mr_tgt_dev_pcie {
71 struct mpi3mr_tgt_dev_volume {
76 struct mpi3mr_throttle_group_info *tg;
79 typedef union _mpi3mr_form_spec_inf {
80 struct mpi3mr_tgt_dev_sassata sassata_inf;
81 struct mpi3mr_tgt_dev_pcie pcie_inf;
82 struct mpi3mr_tgt_dev_volume vol_inf;
83 } mpi3mr_form_spec_inf;
85 struct mpi3mr_target {
90 volatile uint8_t is_hidden;
91 volatile uint8_t dev_removed;
93 mpi3mr_atomic_t block_io;
94 uint8_t exposed_to_os;
97 mpi3mr_form_spec_inf dev_spec;
99 uint16_t exp_dev_handle;
102 uint16_t parent_handle;
103 uint64_t parent_sasaddr;
104 uint32_t parent_devinfo;
105 mpi3mr_atomic_t outstanding;
106 uint8_t scsi_req_desc_type;
107 TAILQ_ENTRY(mpi3mr_target) tgt_next;
110 uint8_t encl_level_valid;
112 char connector_name[4];
115 uint16_t encl_handle;
118 #define MPI3MRSAS_TARGET_INREMOVAL (1 << 3)
119 uint8_t io_throttle_enabled;
121 struct mpi3mr_throttle_group_info *throttle_group;
123 enum mpi3mr_target_state state;
126 struct mpi3mr_cam_softc {
127 struct mpi3mr_softc *sc;
129 #define MPI3MRSAS_IN_DISCOVERY (1 << 0)
130 #define MPI3MRSAS_IN_STARTUP (1 << 1)
131 #define MPI3MRSAS_DISCOVERY_TIMEOUT_PENDING (1 << 2)
132 #define MPI3MRSAS_QUEUE_FROZEN (1 << 3)
133 #define MPI3MRSAS_SHUTDOWN (1 << 4)
135 struct cam_devq *devq;
137 struct cam_path *path;
138 struct intr_config_hook sas_ich;
139 struct callout discovery_callout;
140 struct mpi3mr_event_handle *mpi3mr_eh;
142 u_int startup_refcount;
143 struct proc *sysctl_proc;
144 struct taskqueue *ev_tq;
146 TAILQ_HEAD(, mpi3mr_fw_event_work) ev_queue;
147 TAILQ_HEAD(, mpi3mr_target) tgt_list;
150 MALLOC_DECLARE(M_MPI3MRSAS);
153 mpi3mr_set_ccbstatus(union ccb *ccb, int status)
155 ccb->ccb_h.status &= ~CAM_STATUS_MASK;
156 ccb->ccb_h.status |= status;
160 mpi3mr_get_ccbstatus(union ccb *ccb)
162 return (ccb->ccb_h.status & CAM_STATUS_MASK);
165 static __inline void mpi3mr_print_cdb(union ccb *ccb)
167 struct ccb_scsiio *csio;
168 struct mpi3mr_cam_softc *cam_sc;
172 sim = xpt_path_sim(ccb->ccb_h.path);
173 cam_sc = cam_sim_softc(sim);
177 mpi3mr_dprint(cam_sc->sc, MPI3MR_INFO, "tgtID: %d CDB: ", csio->ccb_h.target_id);
178 for (i = 0; i < csio->cdb_len; i++)
179 printf("%x ", csio->cdb_io.cdb_bytes[i]);
184 void mpi3mr_rescan_target(struct mpi3mr_softc *sc, struct mpi3mr_target *targ);
185 void mpi3mr_discovery_end(struct mpi3mr_cam_softc *sassc);
186 void mpi3mr_prepare_for_tm(struct mpi3mr_softc *sc, struct mpi3mr_cmd *tm,
187 struct mpi3mr_target *target, lun_id_t lun_id);
188 void mpi3mr_startup_increment(struct mpi3mr_cam_softc *sassc);
189 void mpi3mr_startup_decrement(struct mpi3mr_cam_softc *sassc);
191 void mpi3mr_firmware_event_work(void *arg, int pending);
192 int mpi3mr_check_id(struct mpi3mr_cam_softc *sassc, int id);
194 mpi3mr_cam_attach(struct mpi3mr_softc *sc);
196 mpi3mr_cam_detach(struct mpi3mr_softc *sc);
198 mpi3mr_evt_handler(struct mpi3mr_softc *sc, uintptr_t data,
199 MPI3_EVENT_NOTIFICATION_REPLY *event);