2 * Copyright (c) 2014, LSI Corp.
5 * Support: freebsdraid@lsi.com
7 * Redistribution and use in source and binary forms, with or without
8 * 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
15 * the documentation and/or other materials provided with the
17 * 3. Neither the name of the <ORGANIZATION> nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
34 * $FreeBSD: head/sys/dev/mrsas/mrsas_cam.c 265555 2014-05-07 16:16:49Z ambrisko $
37 #include <dev/raid/mrsas/mrsas.h>
39 #include <bus/cam/cam.h>
40 #include <bus/cam/cam_ccb.h>
41 #include <bus/cam/cam_sim.h>
42 #include <bus/cam/cam_xpt_sim.h>
43 #include <bus/cam/cam_debug.h>
44 #include <bus/cam/cam_periph.h>
45 #include <bus/cam/cam_xpt_periph.h>
47 #include <bus/cam/scsi/scsi_all.h>
48 #include <bus/cam/scsi/scsi_message.h>
49 #include <sys/taskqueue.h>
55 int mrsas_cam_attach(struct mrsas_softc *sc);
56 //int mrsas_ldio_inq(union ccb *ccb);
57 int mrsas_ldio_inq(struct cam_sim *sim, union ccb *ccb);
58 int mrsas_bus_scan(struct mrsas_softc *sc);
59 int mrsas_bus_scan_sim(struct mrsas_softc *sc, struct cam_sim *sim);
60 int mrsas_map_request(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd);
61 int mrsas_build_ldio(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
63 int mrsas_build_dcdb(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
64 union ccb *ccb, struct cam_sim *sim);
65 int mrsas_setup_io(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
66 union ccb *ccb, u_int32_t device_id,
67 MRSAS_RAID_SCSI_IO_REQUEST *io_request);
68 void mrsas_xpt_freeze(struct mrsas_softc *sc);
69 void mrsas_xpt_release(struct mrsas_softc *sc);
70 void mrsas_cam_detach(struct mrsas_softc *sc);
71 void mrsas_release_mpt_cmd(struct mrsas_mpt_cmd *cmd);
72 void mrsas_unmap_request(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd);
73 void mrsas_cmd_done(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd);
74 void mrsas_fire_cmd(struct mrsas_softc *sc, u_int32_t req_desc_lo,
75 u_int32_t req_desc_hi);
76 void mrsas_set_pd_lba(MRSAS_RAID_SCSI_IO_REQUEST *io_request, u_int8_t cdb_len,
77 struct IO_REQUEST_INFO *io_info, union ccb *ccb,
78 MR_FW_RAID_MAP_ALL *local_map_ptr, u_int32_t ref_tag,
79 u_int32_t ld_block_size);
80 static void mrsas_freeze_simq(struct mrsas_mpt_cmd *cmd, struct cam_sim *sim);
81 static void mrsas_poll(struct cam_sim *sim);
82 static void mrsas_action(struct cam_sim *sim, union ccb *ccb);
83 static void mrsas_scsiio_timeout(void *data);
84 static void mrsas_data_load_cb(void *arg, bus_dma_segment_t *segs,
86 static int32_t mrsas_startio(struct mrsas_softc *sc, struct cam_sim *sim,
88 static void mrsas_rescan_callback(struct cam_periph *, union ccb *);
89 struct mrsas_mpt_cmd * mrsas_get_mpt_cmd(struct mrsas_softc *sc);
90 MRSAS_REQUEST_DESCRIPTOR_UNION *mrsas_get_request_desc(struct mrsas_softc *sc,
93 extern u_int16_t MR_TargetIdToLdGet(u_int32_t ldTgtId, MR_FW_RAID_MAP_ALL *map);
94 extern u_int32_t MR_LdBlockSizeGet(u_int32_t ldTgtId, MR_FW_RAID_MAP_ALL *map,
95 struct mrsas_softc *sc);
96 extern void mrsas_isr(void *arg);
97 extern void mrsas_aen_handler(struct mrsas_softc *sc);
98 extern u_int8_t MR_BuildRaidContext(struct mrsas_softc *sc,
99 struct IO_REQUEST_INFO *io_info,RAID_CONTEXT *pRAID_Context,
100 MR_FW_RAID_MAP_ALL *map);
101 extern u_int16_t MR_LdSpanArrayGet(u_int32_t ld, u_int32_t span,
102 MR_FW_RAID_MAP_ALL *map);
103 extern u_int16_t mrsas_get_updated_dev_handle(PLD_LOAD_BALANCE_INFO lbInfo,
104 struct IO_REQUEST_INFO *io_info);
105 extern u_int8_t megasas_get_best_arm(PLD_LOAD_BALANCE_INFO lbInfo, u_int8_t arm,
106 u_int64_t block, u_int32_t count);
110 * mrsas_cam_attach: Main entry to CAM subsystem
111 * input: Adapter instance soft state
113 * This function is called from mrsas_attach() during initialization
114 * to perform SIM allocations and XPT bus registration. If the kernel
115 * version is 7.4 or earlier, it would also initiate a bus scan.
117 int mrsas_cam_attach(struct mrsas_softc *sc)
119 struct cam_devq *devq;
122 mrsas_cam_depth = sc->max_fw_cmds - MRSAS_INTERNAL_CMDS;
124 if ((devq = cam_simq_alloc(mrsas_cam_depth)) == NULL) {
125 device_printf(sc->mrsas_dev, "Cannot allocate SIM queue\n");
131 * Create SIM for bus 0 and register, also create path
133 sc->sim_0 = cam_sim_alloc(mrsas_action, mrsas_poll, "mrsas", sc,
134 device_get_unit(sc->mrsas_dev), &sc->sim_lock, mrsas_cam_depth,
135 mrsas_cam_depth, devq);
136 if (sc->sim_0 == NULL){
137 device_printf(sc->mrsas_dev, "Cannot register SIM\n");
138 cam_simq_release(devq);
141 /* Initialize taskqueue for Event Handling */
142 TASK_INIT(&sc->ev_task, 0, (void *)mrsas_aen_handler, sc);
143 sc->ev_tq = taskqueue_create("mrsas_taskq", M_NOWAIT | M_ZERO,
144 taskqueue_thread_enqueue, &sc->ev_tq);
146 /* Run the task queue with lowest priority */
147 taskqueue_start_threads(&sc->ev_tq, 1, 255, -1, "%s taskq",
148 device_get_nameunit(sc->mrsas_dev));
149 lockmgr(&sc->sim_lock, LK_EXCLUSIVE);
150 if (xpt_bus_register(sc->sim_0, 0) != CAM_SUCCESS)
152 cam_sim_free(sc->sim_0);
153 cam_simq_release(devq);
154 lockmgr(&sc->sim_lock, LK_RELEASE);
157 if (xpt_create_path(&sc->path_0, NULL, cam_sim_path(sc->sim_0),
159 CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
160 xpt_bus_deregister(cam_sim_path(sc->sim_0));
161 cam_sim_free(sc->sim_0);
162 cam_simq_release(devq);
163 lockmgr(&sc->sim_lock, LK_RELEASE);
166 lockmgr(&sc->sim_lock, LK_RELEASE);
169 * Create SIM for bus 1 and register, also create path
171 sc->sim_1 = cam_sim_alloc(mrsas_action, mrsas_poll, "mrsas", sc,
172 device_get_unit(sc->mrsas_dev), &sc->sim_lock, mrsas_cam_depth,
173 mrsas_cam_depth, devq);
174 cam_simq_release(devq);
175 if (sc->sim_1 == NULL){
176 device_printf(sc->mrsas_dev, "Cannot register SIM\n");
180 lockmgr(&sc->sim_lock, LK_EXCLUSIVE);
181 if (xpt_bus_register(sc->sim_1, 1) != CAM_SUCCESS){
182 cam_sim_free(sc->sim_1);
183 lockmgr(&sc->sim_lock, LK_RELEASE);
186 if (xpt_create_path(&sc->path_1, NULL, cam_sim_path(sc->sim_1),
188 CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
189 xpt_bus_deregister(cam_sim_path(sc->sim_1));
190 cam_sim_free(sc->sim_1);
191 lockmgr(&sc->sim_lock, LK_RELEASE);
194 lockmgr(&sc->sim_lock, LK_RELEASE);
196 if (mrsas_bus_scan(sc)){
197 device_printf(sc->mrsas_dev, "Error in bus scan.\n");
204 * mrsas_cam_detach: De-allocates and teardown CAM
205 * input: Adapter instance soft state
207 * De-registers and frees the paths and SIMs.
209 void mrsas_cam_detach(struct mrsas_softc *sc)
211 if (sc->ev_tq != NULL)
212 taskqueue_free(sc->ev_tq);
213 lockmgr(&sc->sim_lock, LK_EXCLUSIVE);
215 xpt_free_path(sc->path_0);
217 xpt_bus_deregister(cam_sim_path(sc->sim_0));
218 cam_sim_free(sc->sim_0);
221 xpt_free_path(sc->path_1);
223 xpt_bus_deregister(cam_sim_path(sc->sim_1));
224 cam_sim_free(sc->sim_1);
226 lockmgr(&sc->sim_lock, LK_RELEASE);
230 * mrsas_action: SIM callback entry point
231 * input: pointer to SIM
232 * pointer to CAM Control Block
234 * This function processes CAM subsystem requests. The type of request is
235 * stored in ccb->ccb_h.func_code. The preprocessor #ifdef is necessary
236 * because ccb->cpi.maxio is not supported for FreeBSD version 7.4 or
239 static void mrsas_action(struct cam_sim *sim, union ccb *ccb)
241 struct mrsas_softc *sc = (struct mrsas_softc *)cam_sim_softc(sim);
242 struct ccb_hdr *ccb_h = &(ccb->ccb_h);
245 switch (ccb->ccb_h.func_code) {
248 device_id = ccb_h->target_id;
251 * bus 0 is LD, bus 1 is for system-PD
253 if (cam_sim_bus(sim) == 1 &&
254 sc->pd_list[device_id].driveState != MR_PD_STATE_SYSTEM) {
255 ccb->ccb_h.status |= CAM_DEV_NOT_THERE;
259 if (mrsas_startio(sc, sim, ccb)){
260 ccb->ccb_h.status |= CAM_REQ_INVALID;
268 ccb->ccb_h.status = CAM_UA_ABORT;
277 case XPT_GET_TRAN_SETTINGS:
279 ccb->cts.protocol = PROTO_SCSI;
280 ccb->cts.protocol_version = SCSI_REV_2;
281 ccb->cts.transport = XPORT_SPI;
282 ccb->cts.transport_version = 2;
283 ccb->cts.xport_specific.spi.valid = CTS_SPI_VALID_DISC;
284 ccb->cts.xport_specific.spi.flags = CTS_SPI_FLAGS_DISC_ENB;
285 ccb->cts.proto_specific.scsi.valid = CTS_SCSI_VALID_TQ;
286 ccb->cts.proto_specific.scsi.flags = CTS_SCSI_FLAGS_TAG_ENB;
287 ccb->ccb_h.status = CAM_REQ_CMP;
291 case XPT_SET_TRAN_SETTINGS:
293 ccb->ccb_h.status = CAM_FUNC_NOTAVAIL;
297 case XPT_CALC_GEOMETRY:
299 cam_calc_geometry(&ccb->ccg, 1);
305 ccb->cpi.version_num = 1;
306 ccb->cpi.hba_inquiry = 0;
307 ccb->cpi.target_sprt = 0;
308 ccb->cpi.hba_misc = 0;
309 ccb->cpi.hba_eng_cnt = 0;
310 ccb->cpi.max_lun = MRSAS_SCSI_MAX_LUNS;
311 ccb->cpi.unit_number = cam_sim_unit(sim);
312 ccb->cpi.bus_id = cam_sim_bus(sim);
313 ccb->cpi.initiator_id = MRSAS_SCSI_INITIATOR_ID;
314 ccb->cpi.base_transfer_speed = 150000;
315 strncpy(ccb->cpi.sim_vid, "FreeBSD", SIM_IDLEN);
316 strncpy(ccb->cpi.hba_vid, "LSI", HBA_IDLEN);
317 strncpy(ccb->cpi.dev_name, cam_sim_name(sim), DEV_IDLEN);
318 ccb->cpi.transport = XPORT_SPI;
319 ccb->cpi.transport_version = 2;
320 ccb->cpi.protocol = PROTO_SCSI;
321 ccb->cpi.protocol_version = SCSI_REV_2;
322 if (ccb->cpi.bus_id == 0)
323 ccb->cpi.max_target = MRSAS_MAX_LD-1;
325 ccb->cpi.max_target = MRSAS_MAX_PD-1;
326 ccb->cpi.maxio = MRSAS_MAX_IO_SIZE;
327 ccb->ccb_h.status = CAM_REQ_CMP;
333 ccb->ccb_h.status = CAM_REQ_INVALID;
341 * mrsas_scsiio_timeout Callback function for IO timed out
342 * input: mpt command context
344 * This function will execute after timeout value
345 * provided by ccb header from CAM layer, if timer expires.
346 * Driver will run timer for all DCDM and LDIO comming from CAM layer.
347 * This function is callback function for IO timeout and it runs in
348 * no-sleep context. Set do_timedout_reset in Adapter context so that
349 * it will execute OCR/Kill adpter from ocr_thread context.
352 mrsas_scsiio_timeout(void *data)
354 struct mrsas_mpt_cmd *cmd;
355 struct mrsas_softc *sc;
357 cmd = (struct mrsas_mpt_cmd *)data;
360 if (cmd->ccb_ptr == NULL) {
361 kprintf("command timeout with NULL ccb\n");
365 /* Below callout is dummy entry so that it will be
366 * cancelled from mrsas_cmd_done(). Now Controller will
367 * go to OCR/Kill Adapter based on OCR enable/disable
368 * property of Controller from ocr_thread context.
370 callout_reset(&cmd->cm_callout, (600000 * hz) / 1000,
371 mrsas_scsiio_timeout, cmd);
372 sc->do_timedout_reset = 1;
373 if(sc->ocr_thread_active)
374 wakeup(&sc->ocr_chan);
378 * mrsas_startio: SCSI IO entry point
379 * input: Adapter instance soft state
380 * pointer to CAM Control Block
382 * This function is the SCSI IO entry point and it initiates IO processing.
383 * It copies the IO and depending if the IO is read/write or inquiry, it would
384 * call mrsas_build_ldio() or mrsas_build_dcdb(), respectively. It returns
385 * 0 if the command is sent to firmware successfully, otherwise it returns 1.
387 static int32_t mrsas_startio(struct mrsas_softc *sc, struct cam_sim *sim,
390 struct mrsas_mpt_cmd *cmd;
391 struct ccb_hdr *ccb_h = &(ccb->ccb_h);
392 struct ccb_scsiio *csio = &(ccb->csio);
393 MRSAS_REQUEST_DESCRIPTOR_UNION *req_desc;
395 if ((csio->cdb_io.cdb_bytes[0]) == SYNCHRONIZE_CACHE){
396 ccb->ccb_h.status = CAM_REQ_CMP;
401 ccb_h->status |= CAM_SIM_QUEUED;
402 cmd = mrsas_get_mpt_cmd(sc);
405 ccb_h->status |= CAM_REQUEUE_REQ;
410 if ((ccb_h->flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
411 if(ccb_h->flags & CAM_DIR_IN)
412 cmd->flags |= MRSAS_DIR_IN;
413 if(ccb_h->flags & CAM_DIR_OUT)
414 cmd->flags |= MRSAS_DIR_OUT;
417 cmd->flags = MRSAS_DIR_NONE; /* no data */
419 /* For FreeBSD 10.0 and higher */
420 #if 0 /* XXX (__FreeBSD_version >= 1000000) */
422 * * XXX We don't yet support physical addresses here.
424 switch ((ccb->ccb_h.flags & CAM_DATA_MASK)) {
426 case CAM_DATA_SG_PADDR:
427 kprintf("%s: physical addresses not supported\n",
429 mrsas_release_mpt_cmd(cmd);
430 ccb_h->status = CAM_REQ_INVALID;
431 ccb_h->status &= ~CAM_SIM_QUEUED;
434 kprintf("%s: scatter gather is not supported\n",
436 mrsas_release_mpt_cmd(cmd);
437 ccb_h->status = CAM_REQ_INVALID;
440 if (csio->dxfer_len > MRSAS_MAX_IO_SIZE) {
441 mrsas_release_mpt_cmd(cmd);
442 ccb_h->status = CAM_REQ_TOO_BIG;
445 cmd->length = csio->dxfer_len;
447 cmd->data = csio->data_ptr;
450 ccb->ccb_h.status = CAM_REQ_INVALID;
454 if (!(ccb_h->flags & CAM_DATA_PHYS)) { //Virtual data address
455 if (!(ccb_h->flags & CAM_SCATTER_VALID)) {
456 if (csio->dxfer_len > MRSAS_MAX_IO_SIZE) {
457 mrsas_release_mpt_cmd(cmd);
458 ccb_h->status = CAM_REQ_TOO_BIG;
461 cmd->length = csio->dxfer_len;
463 cmd->data = csio->data_ptr;
466 mrsas_release_mpt_cmd(cmd);
467 ccb_h->status = CAM_REQ_INVALID;
471 else { //Data addresses are physical.
472 mrsas_release_mpt_cmd(cmd);
473 ccb_h->status = CAM_REQ_INVALID;
474 ccb_h->status &= ~CAM_SIM_QUEUED;
481 req_desc = mrsas_get_request_desc(sc, (cmd->index)-1);
483 device_printf(sc->mrsas_dev, "Cannot get request_descriptor.\n");
486 memset(req_desc, 0, sizeof(MRSAS_REQUEST_DESCRIPTOR_UNION));
487 cmd->request_desc = req_desc;
489 if (ccb_h->flags & CAM_CDB_POINTER)
490 bcopy(csio->cdb_io.cdb_ptr, cmd->io_request->CDB.CDB32, csio->cdb_len);
492 bcopy(csio->cdb_io.cdb_bytes, cmd->io_request->CDB.CDB32, csio->cdb_len);
493 lockmgr(&sc->raidmap_lock, LK_EXCLUSIVE);
495 if (mrsas_ldio_inq(sim, ccb)) {
496 if (mrsas_build_ldio(sc, cmd, ccb)){
497 device_printf(sc->mrsas_dev, "Build LDIO failed.\n");
498 lockmgr(&sc->raidmap_lock, LK_RELEASE);
503 if (mrsas_build_dcdb(sc, cmd, ccb, sim)) {
504 device_printf(sc->mrsas_dev, "Build DCDB failed.\n");
505 lockmgr(&sc->raidmap_lock, LK_RELEASE);
509 lockmgr(&sc->raidmap_lock, LK_RELEASE);
511 if (cmd->flags == MRSAS_DIR_IN) //from device
512 cmd->io_request->Control |= MPI2_SCSIIO_CONTROL_READ;
513 else if (cmd->flags == MRSAS_DIR_OUT) //to device
514 cmd->io_request->Control |= MPI2_SCSIIO_CONTROL_WRITE;
516 cmd->io_request->SGLFlags = MPI2_SGE_FLAGS_64_BIT_ADDRESSING;
517 cmd->io_request->SGLOffset0 = offsetof(MRSAS_RAID_SCSI_IO_REQUEST, SGL)/4;
518 cmd->io_request->SenseBufferLowAddress = cmd->sense_phys_addr;
519 cmd->io_request->SenseBufferLength = MRSAS_SCSI_SENSE_BUFFERSIZE;
521 req_desc = cmd->request_desc;
522 req_desc->SCSIIO.SMID = cmd->index;
525 * Start timer for IO timeout. Default timeout value is 90 second.
527 callout_reset(&cmd->cm_callout, (sc->mrsas_io_timeout * hz) / 1000,
528 mrsas_scsiio_timeout, cmd);
529 atomic_inc(&sc->fw_outstanding);
531 if(atomic_read(&sc->fw_outstanding) > sc->io_cmds_highwater)
532 sc->io_cmds_highwater++;
534 mrsas_fire_cmd(sc, req_desc->addr.u.low, req_desc->addr.u.high);
543 * mrsas_ldio_inq: Determines if IO is read/write or inquiry
544 * input: pointer to CAM Control Block
546 * This function determines if the IO is read/write or inquiry. It returns a
547 * 1 if the IO is read/write and 0 if it is inquiry.
549 int mrsas_ldio_inq(struct cam_sim *sim, union ccb *ccb)
551 struct ccb_scsiio *csio = &(ccb->csio);
553 if (cam_sim_bus(sim) == 1)
556 switch (csio->cdb_io.cdb_bytes[0]) {
572 * mrsas_get_mpt_cmd: Get a cmd from free command pool
573 * input: Adapter instance soft state
575 * This function removes an MPT command from the command free list and
578 struct mrsas_mpt_cmd* mrsas_get_mpt_cmd(struct mrsas_softc *sc)
580 struct mrsas_mpt_cmd *cmd = NULL;
582 lockmgr(&sc->mpt_cmd_pool_lock, LK_EXCLUSIVE);
583 if (!TAILQ_EMPTY(&sc->mrsas_mpt_cmd_list_head)){
584 cmd = TAILQ_FIRST(&sc->mrsas_mpt_cmd_list_head);
585 TAILQ_REMOVE(&sc->mrsas_mpt_cmd_list_head, cmd, next);
587 memset((uint8_t *)cmd->io_request, 0, MRSAS_MPI2_RAID_DEFAULT_IO_FRAME_SIZE);
592 cmd->load_balance = 0;
594 lockmgr(&sc->mpt_cmd_pool_lock, LK_RELEASE);
600 * mrsas_release_mpt_cmd: Return a cmd to free command pool
601 * input: Command packet for return to free command pool
603 * This function returns an MPT command to the free command list.
605 void mrsas_release_mpt_cmd(struct mrsas_mpt_cmd *cmd)
607 struct mrsas_softc *sc = cmd->sc;
609 lockmgr(&sc->mpt_cmd_pool_lock, LK_EXCLUSIVE);
610 cmd->sync_cmd_idx = (u_int32_t)MRSAS_ULONG_MAX;
611 TAILQ_INSERT_TAIL(&(sc->mrsas_mpt_cmd_list_head), cmd, next);
612 lockmgr(&sc->mpt_cmd_pool_lock, LK_RELEASE);
618 * mrsas_get_request_desc: Get request descriptor from array
619 * input: Adapter instance soft state
622 * This function returns a pointer to the request descriptor.
624 MRSAS_REQUEST_DESCRIPTOR_UNION *
625 mrsas_get_request_desc(struct mrsas_softc *sc, u_int16_t index)
629 if (index >= sc->max_fw_cmds) {
630 device_printf(sc->mrsas_dev, "Invalid SMID (0x%x)request for desc\n", index);
633 p = sc->req_desc + sizeof(MRSAS_REQUEST_DESCRIPTOR_UNION) * index;
635 return (MRSAS_REQUEST_DESCRIPTOR_UNION *)p;
639 * mrsas_build_ldio: Builds an LDIO command
640 * input: Adapter instance soft state
641 * Pointer to command packet
644 * This function builds the LDIO command packet. It returns 0 if the
645 * command is built successfully, otherwise it returns a 1.
647 int mrsas_build_ldio(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
650 struct ccb_hdr *ccb_h = &(ccb->ccb_h);
651 struct ccb_scsiio *csio = &(ccb->csio);
653 MRSAS_RAID_SCSI_IO_REQUEST *io_request;
655 device_id = ccb_h->target_id;
657 io_request = cmd->io_request;
658 io_request->RaidContext.VirtualDiskTgtId = device_id;
659 io_request->RaidContext.status = 0;
660 io_request->RaidContext.exStatus = 0;
662 /* just the cdb len, other flags zero, and ORed-in later for FP */
663 io_request->IoFlags = csio->cdb_len;
665 if (mrsas_setup_io(sc, cmd, ccb, device_id, io_request) != SUCCESS)
666 device_printf(sc->mrsas_dev, "Build ldio or fpio error\n");
668 io_request->DataLength = cmd->length;
670 if (mrsas_map_request(sc, cmd) == SUCCESS) {
671 if (cmd->sge_count > MRSAS_MAX_SGL) {
672 device_printf(sc->mrsas_dev, "Error: sge_count (0x%x) exceeds"
673 "max (0x%x) allowed\n", cmd->sge_count, sc->max_num_sge);
676 io_request->RaidContext.numSGE = cmd->sge_count;
679 device_printf(sc->mrsas_dev, "Data map/load failed.\n");
686 * mrsas_setup_io: Set up data including Fast Path I/O
687 * input: Adapter instance soft state
688 * Pointer to command packet
691 * This function builds the DCDB inquiry command. It returns 0 if the
692 * command is built successfully, otherwise it returns a 1.
694 int mrsas_setup_io(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
695 union ccb *ccb, u_int32_t device_id,
696 MRSAS_RAID_SCSI_IO_REQUEST *io_request)
698 struct ccb_hdr *ccb_h = &(ccb->ccb_h);
699 struct ccb_scsiio *csio = &(ccb->csio);
700 struct IO_REQUEST_INFO io_info;
701 MR_FW_RAID_MAP_ALL *map_ptr;
702 u_int8_t fp_possible;
703 u_int32_t start_lba_hi, start_lba_lo, ld_block_size;
704 u_int32_t datalength = 0;
711 * READ_6 (0x08) or WRITE_6 (0x0A) cdb
713 if (csio->cdb_len == 6) {
714 datalength = (u_int32_t)csio->cdb_io.cdb_bytes[4];
715 start_lba_lo = ((u_int32_t) csio->cdb_io.cdb_bytes[1] << 16) |
716 ((u_int32_t) csio->cdb_io.cdb_bytes[2] << 8) |
717 (u_int32_t) csio->cdb_io.cdb_bytes[3];
718 start_lba_lo &= 0x1FFFFF;
721 * READ_10 (0x28) or WRITE_6 (0x2A) cdb
723 else if (csio->cdb_len == 10) {
724 datalength = (u_int32_t)csio->cdb_io.cdb_bytes[8] |
725 ((u_int32_t)csio->cdb_io.cdb_bytes[7] << 8);
726 start_lba_lo = ((u_int32_t) csio->cdb_io.cdb_bytes[2] << 24) |
727 ((u_int32_t) csio->cdb_io.cdb_bytes[3] << 16) |
728 (u_int32_t) csio->cdb_io.cdb_bytes[4] << 8 |
729 ((u_int32_t) csio->cdb_io.cdb_bytes[5]);
732 * READ_12 (0xA8) or WRITE_12 (0xAA) cdb
734 else if (csio->cdb_len == 12) {
735 datalength = (u_int32_t)csio->cdb_io.cdb_bytes[6] << 24 |
736 ((u_int32_t)csio->cdb_io.cdb_bytes[7] << 16) |
737 ((u_int32_t)csio->cdb_io.cdb_bytes[8] << 8) |
738 ((u_int32_t)csio->cdb_io.cdb_bytes[9]);
739 start_lba_lo = ((u_int32_t) csio->cdb_io.cdb_bytes[2] << 24) |
740 ((u_int32_t) csio->cdb_io.cdb_bytes[3] << 16) |
741 (u_int32_t) csio->cdb_io.cdb_bytes[4] << 8 |
742 ((u_int32_t) csio->cdb_io.cdb_bytes[5]);
745 * READ_16 (0x88) or WRITE_16 (0xx8A) cdb
747 else if (csio->cdb_len == 16) {
748 datalength = (u_int32_t)csio->cdb_io.cdb_bytes[10] << 24 |
749 ((u_int32_t)csio->cdb_io.cdb_bytes[11] << 16) |
750 ((u_int32_t)csio->cdb_io.cdb_bytes[12] << 8) |
751 ((u_int32_t)csio->cdb_io.cdb_bytes[13]);
752 start_lba_lo = ((u_int32_t) csio->cdb_io.cdb_bytes[6] << 24) |
753 ((u_int32_t) csio->cdb_io.cdb_bytes[7] << 16) |
754 (u_int32_t) csio->cdb_io.cdb_bytes[8] << 8 |
755 ((u_int32_t) csio->cdb_io.cdb_bytes[9]);
756 start_lba_hi = ((u_int32_t) csio->cdb_io.cdb_bytes[2] << 24) |
757 ((u_int32_t) csio->cdb_io.cdb_bytes[3] << 16) |
758 (u_int32_t) csio->cdb_io.cdb_bytes[4] << 8 |
759 ((u_int32_t) csio->cdb_io.cdb_bytes[5]);
762 memset(&io_info, 0, sizeof(struct IO_REQUEST_INFO));
763 io_info.ldStartBlock = ((u_int64_t)start_lba_hi << 32) | start_lba_lo;
764 io_info.numBlocks = datalength;
765 io_info.ldTgtId = device_id;
767 switch (ccb_h->flags & CAM_DIR_MASK) {
776 mrsas_dprint(sc, MRSAS_TRACE, "From %s : DMA Flag is %d \n", __func__, ccb_h->flags & CAM_DIR_MASK);
780 map_ptr = sc->raidmap_mem[(sc->map_id & 1)];
781 ld_block_size = MR_LdBlockSizeGet(device_id, map_ptr, sc);
783 if ((MR_TargetIdToLdGet(device_id, map_ptr) >= MAX_LOGICAL_DRIVES) ||
784 (!sc->fast_path_io)) {
785 io_request->RaidContext.regLockFlags = 0;
790 if (MR_BuildRaidContext(sc, &io_info, &io_request->RaidContext, map_ptr))
791 fp_possible = io_info.fpOkForIo;
795 mrsas_set_pd_lba(io_request, csio->cdb_len, &io_info, ccb, map_ptr,
796 start_lba_lo, ld_block_size);
797 io_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST;
798 cmd->request_desc->SCSIIO.RequestFlags =
799 (MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY
800 << MRSAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
801 if ((sc->device_id == MRSAS_INVADER) || (sc->device_id == MRSAS_FURY)) {
802 if (io_request->RaidContext.regLockFlags == REGION_TYPE_UNUSED)
803 cmd->request_desc->SCSIIO.RequestFlags = (MRSAS_REQ_DESCRIPT_FLAGS_NO_LOCK << MRSAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
804 io_request->RaidContext.Type = MPI2_TYPE_CUDA;
805 io_request->RaidContext.nseg = 0x1;
806 io_request->IoFlags |= MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH;
807 io_request->RaidContext.regLockFlags |= (MR_RL_FLAGS_GRANT_DESTINATION_CUDA | MR_RL_FLAGS_SEQ_NUM_ENABLE);
809 if ((sc->load_balance_info[device_id].loadBalanceFlag) && (io_info.isRead)) {
810 io_info.devHandle = mrsas_get_updated_dev_handle(&sc->load_balance_info[device_id],
812 cmd->load_balance = MRSAS_LOAD_BALANCE_FLAG;
815 cmd->load_balance = 0;
816 cmd->request_desc->SCSIIO.DevHandle = io_info.devHandle;
817 io_request->DevHandle = io_info.devHandle;
821 io_request->RaidContext.timeoutValue = map_ptr->raidMap.fpPdIoTimeoutSec;
822 cmd->request_desc->SCSIIO.RequestFlags =
823 (MRSAS_REQ_DESCRIPT_FLAGS_LD_IO << MRSAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
824 if ((sc->device_id == MRSAS_INVADER) || (sc->device_id == MRSAS_FURY)) {
825 if (io_request->RaidContext.regLockFlags == REGION_TYPE_UNUSED)
826 cmd->request_desc->SCSIIO.RequestFlags = (MRSAS_REQ_DESCRIPT_FLAGS_NO_LOCK << MRSAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
827 io_request->RaidContext.Type = MPI2_TYPE_CUDA;
828 io_request->RaidContext.regLockFlags |= (MR_RL_FLAGS_GRANT_DESTINATION_CPU0 | MR_RL_FLAGS_SEQ_NUM_ENABLE);
829 io_request->RaidContext.nseg = 0x1;
831 io_request->Function = MRSAS_MPI2_FUNCTION_LD_IO_REQUEST;
832 io_request->DevHandle = device_id;
838 * mrsas_build_dcdb: Builds an DCDB command
839 * input: Adapter instance soft state
840 * Pointer to command packet
843 * This function builds the DCDB inquiry command. It returns 0 if the
844 * command is built successfully, otherwise it returns a 1.
846 int mrsas_build_dcdb(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
847 union ccb *ccb, struct cam_sim *sim)
849 struct ccb_hdr *ccb_h = &(ccb->ccb_h);
851 MR_FW_RAID_MAP_ALL *map_ptr;
852 MRSAS_RAID_SCSI_IO_REQUEST *io_request;
854 io_request = cmd->io_request;
855 device_id = ccb_h->target_id;
856 map_ptr = sc->raidmap_mem[(sc->map_id & 1)];
858 /* Check if this is for system PD */
859 if (cam_sim_bus(sim) == 1 &&
860 sc->pd_list[device_id].driveState == MR_PD_STATE_SYSTEM) {
861 io_request->Function = 0;
862 io_request->DevHandle = map_ptr->raidMap.devHndlInfo[device_id].curDevHdl;
863 io_request->RaidContext.timeoutValue = map_ptr->raidMap.fpPdIoTimeoutSec;
864 io_request->RaidContext.regLockFlags = 0;
865 io_request->RaidContext.regLockRowLBA = 0;
866 io_request->RaidContext.regLockLength = 0;
867 io_request->RaidContext.RAIDFlags = MR_RAID_FLAGS_IO_SUB_TYPE_SYSTEM_PD <<
868 MR_RAID_CTX_RAID_FLAGS_IO_SUB_TYPE_SHIFT;
869 if ((sc->device_id == MRSAS_INVADER) || (sc->device_id == MRSAS_FURY))
870 io_request->IoFlags |= MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH;
871 cmd->request_desc->SCSIIO.RequestFlags =
872 (MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY <<
873 MRSAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
874 cmd->request_desc->SCSIIO.DevHandle =
875 map_ptr->raidMap.devHndlInfo[device_id].curDevHdl;
878 io_request->Function = MRSAS_MPI2_FUNCTION_LD_IO_REQUEST;
879 io_request->DevHandle = device_id;
880 cmd->request_desc->SCSIIO.RequestFlags =
881 (MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO << MRSAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
884 io_request->RaidContext.VirtualDiskTgtId = device_id;
885 io_request->LUN[1] = ccb_h->target_lun & 0xF;
886 io_request->DataLength = cmd->length;
888 if (mrsas_map_request(sc, cmd) == SUCCESS) {
889 if (cmd->sge_count > sc->max_num_sge) {
890 device_printf(sc->mrsas_dev, "Error: sge_count (0x%x) exceeds"
891 "max (0x%x) allowed\n", cmd->sge_count, sc->max_num_sge);
894 io_request->RaidContext.numSGE = cmd->sge_count;
897 device_printf(sc->mrsas_dev, "Data map/load failed.\n");
904 * mrsas_map_request: Map and load data
905 * input: Adapter instance soft state
906 * Pointer to command packet
908 * For data from OS, map and load the data buffer into bus space. The
909 * SG list is built in the callback. If the bus dmamap load is not
910 * successful, cmd->error_code will contain the error code and a 1 is
913 int mrsas_map_request(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd)
915 u_int32_t retcode = 0;
917 int flag = BUS_DMA_NOWAIT;
919 sim = xpt_path_sim(cmd->ccb_ptr->ccb_h.path);
921 if (cmd->data != NULL) {
922 lockmgr(&sc->io_lock, LK_EXCLUSIVE);
923 /* Map data buffer into bus space */
924 retcode = bus_dmamap_load(sc->data_tag, cmd->data_dmamap, cmd->data,
925 cmd->length, mrsas_data_load_cb, cmd, flag);
926 lockmgr(&sc->io_lock, LK_RELEASE);
928 device_printf(sc->mrsas_dev, "bus_dmamap_load(): retcode = %d\n", retcode);
929 if (retcode == EINPROGRESS) {
930 device_printf(sc->mrsas_dev, "request load in progress\n");
931 mrsas_freeze_simq(cmd, sim);
940 * mrsas_unmap_request: Unmap and unload data
941 * input: Adapter instance soft state
942 * Pointer to command packet
944 * This function unmaps and unloads data from OS.
946 void mrsas_unmap_request(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd)
948 if (cmd->data != NULL) {
949 if (cmd->flags & MRSAS_DIR_IN)
950 bus_dmamap_sync(sc->data_tag, cmd->data_dmamap, BUS_DMASYNC_POSTREAD);
951 if (cmd->flags & MRSAS_DIR_OUT)
952 bus_dmamap_sync(sc->data_tag, cmd->data_dmamap, BUS_DMASYNC_POSTWRITE);
953 lockmgr(&sc->io_lock, LK_EXCLUSIVE);
954 bus_dmamap_unload(sc->data_tag, cmd->data_dmamap);
955 lockmgr(&sc->io_lock, LK_RELEASE);
960 * mrsas_data_load_cb: Callback entry point
961 * input: Pointer to command packet as argument
966 * This is the callback function of the bus dma map load. It builds
970 mrsas_data_load_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error)
972 struct mrsas_mpt_cmd *cmd = (struct mrsas_mpt_cmd *)arg;
973 struct mrsas_softc *sc = cmd->sc;
974 MRSAS_RAID_SCSI_IO_REQUEST *io_request;
975 pMpi25IeeeSgeChain64_t sgl_ptr;
976 int i=0, sg_processed=0;
980 cmd->error_code = error;
981 device_printf(sc->mrsas_dev, "mrsas_data_load_cb: error=%d\n", error);
982 if (error == EFBIG) {
983 cmd->ccb_ptr->ccb_h.status = CAM_REQ_TOO_BIG;
988 if (cmd->flags & MRSAS_DIR_IN)
989 bus_dmamap_sync(cmd->sc->data_tag, cmd->data_dmamap,
990 BUS_DMASYNC_PREREAD);
991 if (cmd->flags & MRSAS_DIR_OUT)
992 bus_dmamap_sync(cmd->sc->data_tag, cmd->data_dmamap,
993 BUS_DMASYNC_PREWRITE);
994 if (nseg > sc->max_num_sge) {
995 device_printf(sc->mrsas_dev, "SGE count is too large or 0.\n");
999 io_request = cmd->io_request;
1000 sgl_ptr = (pMpi25IeeeSgeChain64_t)&io_request->SGL;
1002 if ((sc->device_id == MRSAS_INVADER) || (sc->device_id == MRSAS_FURY)) {
1003 pMpi25IeeeSgeChain64_t sgl_ptr_end = sgl_ptr;
1004 sgl_ptr_end += sc->max_sge_in_main_msg - 1;
1005 sgl_ptr_end->Flags = 0;
1009 for (i=0; i < nseg; i++) {
1010 sgl_ptr->Address = segs[i].ds_addr;
1011 sgl_ptr->Length = segs[i].ds_len;
1013 if ((sc->device_id == MRSAS_INVADER) || (sc->device_id == MRSAS_FURY)) {
1015 sgl_ptr->Flags = IEEE_SGE_FLAGS_END_OF_LIST;
1018 sg_processed = i + 1;
1020 * Prepare chain element
1022 if ((sg_processed == (sc->max_sge_in_main_msg - 1)) &&
1023 (nseg > sc->max_sge_in_main_msg)) {
1024 pMpi25IeeeSgeChain64_t sg_chain;
1025 if ((sc->device_id == MRSAS_INVADER) || (sc->device_id == MRSAS_FURY)) {
1026 if ((cmd->io_request->IoFlags & MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH)
1027 != MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH)
1028 cmd->io_request->ChainOffset = sc->chain_offset_io_request;
1030 cmd->io_request->ChainOffset = 0;
1032 cmd->io_request->ChainOffset = sc->chain_offset_io_request;
1034 if ((sc->device_id == MRSAS_INVADER) || (sc->device_id == MRSAS_FURY))
1035 sg_chain->Flags = IEEE_SGE_FLAGS_CHAIN_ELEMENT;
1037 sg_chain->Flags = (IEEE_SGE_FLAGS_CHAIN_ELEMENT | MPI2_IEEE_SGE_FLAGS_IOCPLBNTA_ADDR);
1038 sg_chain->Length = (sizeof(MPI2_SGE_IO_UNION) * (nseg - sg_processed));
1039 sg_chain->Address = cmd->chain_frame_phys_addr;
1040 sgl_ptr = (pMpi25IeeeSgeChain64_t)cmd->chain_frame;
1044 cmd->sge_count = nseg;
1048 * mrsas_freeze_simq: Freeze SIM queue
1049 * input: Pointer to command packet
1052 * This function freezes the sim queue.
1054 static void mrsas_freeze_simq(struct mrsas_mpt_cmd *cmd, struct cam_sim *sim)
1056 union ccb *ccb = (union ccb *)(cmd->ccb_ptr);
1058 xpt_freeze_simq(sim, 1);
1059 ccb->ccb_h.status |= CAM_RELEASE_SIMQ;
1060 ccb->ccb_h.status |= CAM_REQUEUE_REQ;
1063 void mrsas_xpt_freeze(struct mrsas_softc *sc) {
1064 xpt_freeze_simq(sc->sim_0, 1);
1065 xpt_freeze_simq(sc->sim_1, 1);
1068 void mrsas_xpt_release(struct mrsas_softc *sc) {
1069 xpt_release_simq(sc->sim_0, 1);
1070 xpt_release_simq(sc->sim_1, 1);
1074 * mrsas_cmd_done: Perform remaining command completion
1075 * input: Adapter instance soft state
1076 * Pointer to command packet
1078 * This function calls ummap request and releases the MPT command.
1080 void mrsas_cmd_done(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd)
1082 callout_stop(&cmd->cm_callout);
1083 mrsas_unmap_request(sc, cmd);
1084 lockmgr(&sc->sim_lock, LK_EXCLUSIVE);
1085 xpt_done(cmd->ccb_ptr);
1086 cmd->ccb_ptr = NULL;
1087 lockmgr(&sc->sim_lock, LK_RELEASE);
1088 mrsas_release_mpt_cmd(cmd);
1092 * mrsas_poll: Polling entry point
1093 * input: Pointer to SIM
1095 * This is currently a stub function.
1097 static void mrsas_poll(struct cam_sim *sim)
1099 struct mrsas_softc *sc = (struct mrsas_softc *)cam_sim_softc(sim);
1100 mrsas_isr((void *) sc);
1104 mrsas_rescan_callback(struct cam_periph *periph, union ccb *ccb)
1106 xpt_free_path(ccb->ccb_h.path);
1111 * mrsas_bus_scan: Perform bus scan
1112 * input: Adapter instance soft state
1114 * This mrsas_bus_scan function is needed for FreeBSD 7.x. Also, it should
1115 * not be called in FreeBSD 8.x and later versions, where the bus scan is
1118 int mrsas_bus_scan(struct mrsas_softc *sc)
1123 lockmgr(&sc->sim_lock, LK_EXCLUSIVE);
1124 if ((ccb_0 = xpt_alloc_ccb()) == NULL) {
1125 lockmgr(&sc->sim_lock, LK_RELEASE);
1129 if ((ccb_1 = xpt_alloc_ccb()) == NULL) {
1130 xpt_free_ccb(ccb_0);
1131 lockmgr(&sc->sim_lock, LK_RELEASE);
1135 if (xpt_create_path(&ccb_0->ccb_h.path, xpt_periph, cam_sim_path(sc->sim_0),
1136 CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP){
1137 xpt_free_ccb(ccb_0);
1138 xpt_free_ccb(ccb_1);
1139 lockmgr(&sc->sim_lock, LK_RELEASE);
1143 if (xpt_create_path(&ccb_1->ccb_h.path, xpt_periph, cam_sim_path(sc->sim_1),
1144 CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP){
1145 xpt_free_ccb(ccb_0);
1146 xpt_free_ccb(ccb_1);
1147 lockmgr(&sc->sim_lock, LK_RELEASE);
1151 xpt_setup_ccb(&ccb_0->ccb_h, ccb_0->ccb_h.path, 5/*priority (low)*/);
1152 ccb_0->ccb_h.func_code = XPT_SCAN_BUS;
1153 ccb_0->ccb_h.cbfcnp = mrsas_rescan_callback;
1154 ccb_0->crcn.flags = CAM_FLAG_NONE;
1155 xpt_action(ccb_0); /* scan is now in progress */
1157 xpt_setup_ccb(&ccb_1->ccb_h, ccb_1->ccb_h.path, 5/*priority (low)*/);
1158 ccb_1->ccb_h.func_code = XPT_SCAN_BUS;
1159 ccb_1->ccb_h.cbfcnp = mrsas_rescan_callback;
1160 ccb_1->crcn.flags = CAM_FLAG_NONE;
1161 xpt_action(ccb_1); /* scan is now in progress */
1163 lockmgr(&sc->sim_lock, LK_RELEASE);
1169 * mrsas_bus_scan_sim: Perform bus scan per SIM
1170 * input: Adapter instance soft state
1171 * This function will be called from Event handler
1172 * on LD creation/deletion, JBOD on/off.
1174 int mrsas_bus_scan_sim(struct mrsas_softc *sc, struct cam_sim *sim)
1178 lockmgr(&sc->sim_lock, LK_EXCLUSIVE);
1179 if ((ccb = xpt_alloc_ccb()) == NULL) {
1180 lockmgr(&sc->sim_lock, LK_RELEASE);
1183 if (xpt_create_path(&ccb->ccb_h.path, xpt_periph, cam_sim_path(sim),
1184 CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP){
1186 lockmgr(&sc->sim_lock, LK_RELEASE);
1189 xpt_setup_ccb(&ccb->ccb_h, ccb->ccb_h.path, 5/*priority (low)*/);
1190 ccb->ccb_h.func_code = XPT_SCAN_BUS;
1191 ccb->ccb_h.cbfcnp = mrsas_rescan_callback;
1192 ccb->crcn.flags = CAM_FLAG_NONE;
1193 xpt_action(ccb); /* scan is now in progress */
1195 lockmgr(&sc->sim_lock, LK_RELEASE);