2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2009 Silicon Graphics International Corp.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions, and the following disclaimer,
12 * without modification.
13 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
14 * substantially similar to the "NO WARRANTY" disclaimer below
15 * ("Disclaimer") and any redistribution must be conditioned upon
16 * including a substantially similar Disclaimer requirement for further
17 * binary redistribution.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGES.
32 * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl_frontend_cam_sim.c#4 $
35 * CTL frontend to CAM SIM interface. This allows access to CTL LUNs via
36 * the da(4) and pass(4) drivers from inside the system.
38 * Author: Ken Merry <ken@FreeBSD.org>
41 #include <sys/cdefs.h>
42 __FBSDID("$FreeBSD$");
44 #include <sys/param.h>
45 #include <sys/systm.h>
46 #include <sys/kernel.h>
47 #include <sys/types.h>
48 #include <sys/malloc.h>
50 #include <sys/sysctl.h>
51 #include <machine/atomic.h>
52 #include <machine/bus.h>
56 #include <cam/cam_ccb.h>
57 #include <cam/cam_sim.h>
58 #include <cam/cam_xpt_sim.h>
59 #include <cam/cam_xpt.h>
60 #include <cam/cam_periph.h>
61 #include <cam/scsi/scsi_all.h>
62 #include <cam/scsi/scsi_message.h>
63 #include <cam/ctl/ctl_io.h>
64 #include <cam/ctl/ctl.h>
65 #include <cam/ctl/ctl_frontend.h>
66 #include <cam/ctl/ctl_debug.h>
68 #define io_ptr spriv_ptr1
78 struct cam_devq *devq;
79 struct cam_path *path;
87 * We can't handle CCBs with these flags. For the most part, we just don't
88 * handle physical addresses yet. That would require mapping things in
89 * order to do the copy.
91 #define CFCS_BAD_CCB_FLAGS (CAM_DATA_ISPHYS | CAM_CDB_PHYS | CAM_SENSE_PTR | \
94 static int cfcs_init(void);
95 static int cfcs_shutdown(void);
96 static void cfcs_poll(struct cam_sim *sim);
97 static void cfcs_online(void *arg);
98 static void cfcs_offline(void *arg);
99 static void cfcs_datamove(union ctl_io *io);
100 static void cfcs_done(union ctl_io *io);
101 void cfcs_action(struct cam_sim *sim, union ccb *ccb);
103 struct cfcs_softc cfcs_softc;
105 * This is primarily intended to allow for error injection to test the CAM
106 * sense data and sense residual handling code. This sets the maximum
107 * amount of SCSI sense data that we will report to CAM.
109 static int cfcs_max_sense = sizeof(struct scsi_sense_data);
111 SYSCTL_NODE(_kern_cam, OID_AUTO, ctl2cam, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
112 "CAM Target Layer SIM frontend");
113 SYSCTL_INT(_kern_cam_ctl2cam, OID_AUTO, max_sense, CTLFLAG_RW,
114 &cfcs_max_sense, 0, "Maximum sense data size");
116 static struct ctl_frontend cfcs_frontend =
120 .shutdown = cfcs_shutdown,
122 CTL_FRONTEND_DECLARE(ctlcfcs, cfcs_frontend);
127 struct cfcs_softc *softc;
128 struct ctl_port *port;
132 bzero(softc, sizeof(*softc));
135 port->frontend = &cfcs_frontend;
136 port->port_type = CTL_PORT_INTERNAL;
137 /* XXX KDM what should the real number be here? */
138 port->num_requested_ctl_io = 4096;
139 snprintf(softc->port_name, sizeof(softc->port_name), "camsim");
140 port->port_name = softc->port_name;
141 port->port_online = cfcs_online;
142 port->port_offline = cfcs_offline;
143 port->onoff_arg = softc;
144 port->fe_datamove = cfcs_datamove;
145 port->fe_done = cfcs_done;
146 port->targ_port = -1;
148 retval = ctl_port_register(port);
150 printf("%s: ctl_port_register() failed with error %d!\n",
156 * If the CTL frontend didn't tell us what our WWNN/WWPN is, go
157 * ahead and set something random.
159 if (port->wwnn == 0) {
160 uint64_t random_bits;
162 arc4rand(&random_bits, sizeof(random_bits), 0);
163 softc->wwnn = (random_bits & 0x0000000fffffff00ULL) |
164 /* Company ID */ 0x5000000000000000ULL |
165 /* NL-Port */ 0x0300;
166 softc->wwpn = softc->wwnn + port->targ_port + 1;
167 ctl_port_set_wwns(port, true, softc->wwnn, true, softc->wwpn);
169 softc->wwnn = port->wwnn;
170 softc->wwpn = port->wwpn;
173 softc->devq = cam_simq_alloc(port->num_requested_ctl_io);
174 if (softc->devq == NULL) {
175 printf("%s: error allocating devq\n", __func__);
180 softc->sim = cam_sim_alloc(cfcs_action, cfcs_poll, softc->port_name,
181 softc, /*unit*/ 0, NULL, 1,
182 port->num_requested_ctl_io, softc->devq);
183 if (softc->sim == NULL) {
184 printf("%s: error allocating SIM\n", __func__);
189 if (xpt_bus_register(softc->sim, NULL, 0) != CAM_SUCCESS) {
190 printf("%s: error registering SIM\n", __func__);
195 if (xpt_create_path(&softc->path, /*periph*/NULL,
196 cam_sim_path(softc->sim),
198 CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
199 printf("%s: error creating path\n", __func__);
200 xpt_bus_deregister(cam_sim_path(softc->sim));
209 cam_sim_free(softc->sim, /*free_devq*/ TRUE);
210 else if (softc->devq)
211 cam_simq_free(softc->devq);
218 struct cfcs_softc *softc = &cfcs_softc;
219 struct ctl_port *port = &softc->port;
222 ctl_port_offline(port);
224 xpt_free_path(softc->path);
225 xpt_bus_deregister(cam_sim_path(softc->sim));
226 cam_sim_free(softc->sim, /*free_devq*/ TRUE);
228 if ((error = ctl_port_deregister(port)) != 0)
229 printf("%s: cam_sim port deregistration failed\n", __func__);
234 cfcs_poll(struct cam_sim *sim)
240 cfcs_onoffline(void *arg, int online)
242 struct cfcs_softc *softc = (struct cfcs_softc *)arg;
245 softc->online = online;
247 ccb = xpt_alloc_ccb_nowait();
249 printf("%s: unable to allocate CCB for rescan\n", __func__);
253 if (xpt_create_path(&ccb->ccb_h.path, NULL,
254 cam_sim_path(softc->sim), CAM_TARGET_WILDCARD,
255 CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
256 printf("%s: can't allocate path for rescan\n", __func__);
264 cfcs_online(void *arg)
266 cfcs_onoffline(arg, /*online*/ 1);
270 cfcs_offline(void *arg)
272 cfcs_onoffline(arg, /*online*/ 0);
276 * This function is very similar to ctl_ioctl_do_datamove(). Is there a
277 * way to combine the functionality?
279 * XXX KDM may need to move this into a thread. We're doing a bcopy in the
280 * caller's context, which will usually be the backend. That may not be a
284 cfcs_datamove(union ctl_io *io)
287 bus_dma_segment_t cam_sg_entry, *cam_sglist;
288 struct ctl_sg_entry ctl_sg_entry, *ctl_sglist;
289 int cam_sg_count, ctl_sg_count, cam_sg_start;
292 int ctl_watermark, cam_watermark;
295 ccb = io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr;
298 * Note that we have a check in cfcs_action() to make sure that any
299 * CCBs with "bad" flags are returned with CAM_REQ_INVALID. This
300 * is just to make sure no one removes that check without updating
301 * this code to provide the additional functionality necessary to
302 * support those modes of operation.
304 KASSERT(((ccb->ccb_h.flags & CFCS_BAD_CCB_FLAGS) == 0), ("invalid "
305 "CAM flags %#x", (ccb->ccb_h.flags & CFCS_BAD_CCB_FLAGS)));
308 * Simplify things on both sides by putting single buffers into a
309 * single entry S/G list.
311 switch ((ccb->ccb_h.flags & CAM_DATA_MASK)) {
315 cam_sglist = (bus_dma_segment_t *)ccb->csio.data_ptr;
316 cam_sg_count = ccb->csio.sglist_cnt;
317 cam_sg_start = cam_sg_count;
320 for (i = 0, len_seen = 0; i < cam_sg_count; i++) {
321 if ((len_seen + cam_sglist[i].ds_len) >=
322 io->scsiio.kern_rel_offset) {
324 cam_sg_offset = io->scsiio.kern_rel_offset -
328 len_seen += cam_sglist[i].ds_len;
333 cam_sglist = &cam_sg_entry;
334 cam_sglist[0].ds_len = ccb->csio.dxfer_len;
335 cam_sglist[0].ds_addr = (bus_addr_t)(uintptr_t)ccb->csio.data_ptr;
338 cam_sg_offset = io->scsiio.kern_rel_offset;
341 panic("Invalid CAM flags %#x", ccb->ccb_h.flags);
344 if (io->scsiio.kern_sg_entries > 0) {
345 ctl_sglist = (struct ctl_sg_entry *)io->scsiio.kern_data_ptr;
346 ctl_sg_count = io->scsiio.kern_sg_entries;
348 ctl_sglist = &ctl_sg_entry;
349 ctl_sglist->addr = io->scsiio.kern_data_ptr;
350 ctl_sglist->len = io->scsiio.kern_data_len;
355 cam_watermark = cam_sg_offset;
356 for (i = cam_sg_start, j = 0;
357 i < cam_sg_count && j < ctl_sg_count;) {
358 uint8_t *cam_ptr, *ctl_ptr;
360 len_to_copy = MIN(cam_sglist[i].ds_len - cam_watermark,
361 ctl_sglist[j].len - ctl_watermark);
363 cam_ptr = (uint8_t *)(uintptr_t)cam_sglist[i].ds_addr;
364 cam_ptr = cam_ptr + cam_watermark;
365 if (io->io_hdr.flags & CTL_FLAG_BUS_ADDR) {
369 panic("need to implement bus address support");
371 kern_ptr = bus_to_virt(kern_sglist[j].addr);
374 ctl_ptr = (uint8_t *)ctl_sglist[j].addr;
375 ctl_ptr = ctl_ptr + ctl_watermark;
377 if ((io->io_hdr.flags & CTL_FLAG_DATA_MASK) ==
379 CTL_DEBUG_PRINT(("%s: copying %d bytes to CAM\n",
380 __func__, len_to_copy));
381 CTL_DEBUG_PRINT(("%s: from %p to %p\n", ctl_ptr,
383 bcopy(ctl_ptr, cam_ptr, len_to_copy);
385 CTL_DEBUG_PRINT(("%s: copying %d bytes from CAM\n",
386 __func__, len_to_copy));
387 CTL_DEBUG_PRINT(("%s: from %p to %p\n", cam_ptr,
389 bcopy(cam_ptr, ctl_ptr, len_to_copy);
392 io->scsiio.ext_data_filled += len_to_copy;
393 io->scsiio.kern_data_resid -= len_to_copy;
395 cam_watermark += len_to_copy;
396 if (cam_sglist[i].ds_len == cam_watermark) {
401 ctl_watermark += len_to_copy;
402 if (ctl_sglist[j].len == ctl_watermark) {
408 if ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_SUCCESS) {
409 io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr = NULL;
410 io->io_hdr.flags |= CTL_FLAG_STATUS_SENT;
411 ccb->csio.resid = ccb->csio.dxfer_len -
412 io->scsiio.ext_data_filled;
413 ccb->ccb_h.status &= ~CAM_STATUS_MASK;
414 ccb->ccb_h.status |= CAM_REQ_CMP;
418 io->scsiio.be_move_done(io);
422 cfcs_done(union ctl_io *io)
426 ccb = io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr;
433 * At this point we should have status. If we don't, that's a bug.
435 KASSERT(((io->io_hdr.status & CTL_STATUS_MASK) != CTL_STATUS_NONE),
436 ("invalid CTL status %#x", io->io_hdr.status));
439 * Translate CTL status to CAM status.
441 if (ccb->ccb_h.func_code == XPT_SCSI_IO) {
442 ccb->csio.resid = ccb->csio.dxfer_len -
443 io->scsiio.ext_data_filled;
445 ccb->ccb_h.status &= ~CAM_STATUS_MASK;
446 switch (io->io_hdr.status & CTL_STATUS_MASK) {
448 ccb->ccb_h.status |= CAM_REQ_CMP;
451 ccb->ccb_h.status |= CAM_SCSI_STATUS_ERROR | CAM_AUTOSNS_VALID;
452 ccb->csio.scsi_status = io->scsiio.scsi_status;
453 bcopy(&io->scsiio.sense_data, &ccb->csio.sense_data,
454 min(io->scsiio.sense_len, ccb->csio.sense_len));
455 if (ccb->csio.sense_len > io->scsiio.sense_len)
456 ccb->csio.sense_resid = ccb->csio.sense_len -
457 io->scsiio.sense_len;
459 ccb->csio.sense_resid = 0;
460 if ((ccb->csio.sense_len - ccb->csio.sense_resid) >
462 ccb->csio.sense_resid = ccb->csio.sense_len -
466 case CTL_CMD_ABORTED:
467 ccb->ccb_h.status |= CAM_REQ_ABORTED;
471 ccb->ccb_h.status |= CAM_REQ_CMP_ERR;
475 if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP &&
476 (ccb->ccb_h.status & CAM_DEV_QFRZN) == 0) {
477 xpt_freeze_devq(ccb->ccb_h.path, 1);
478 ccb->ccb_h.status |= CAM_DEV_QFRZN;
484 cfcs_action(struct cam_sim *sim, union ccb *ccb)
486 struct cfcs_softc *softc;
489 softc = (struct cfcs_softc *)cam_sim_softc(sim);
491 switch (ccb->ccb_h.func_code) {
494 struct ccb_scsiio *csio;
499 * Catch CCB flags, like physical address flags, that
500 * indicate situations we currently can't handle.
502 if (ccb->ccb_h.flags & CFCS_BAD_CCB_FLAGS) {
503 ccb->ccb_h.status = CAM_REQ_INVALID;
504 printf("%s: bad CCB flags %#x (all flags %#x)\n",
505 __func__, ccb->ccb_h.flags & CFCS_BAD_CCB_FLAGS,
512 * If we aren't online, there are no devices to see.
514 if (softc->online == 0) {
515 ccb->ccb_h.status = CAM_DEV_NOT_THERE;
520 io = ctl_alloc_io_nowait(softc->port.ctl_pool_ref);
522 printf("%s: can't allocate ctl_io\n", __func__);
523 ccb->ccb_h.status = CAM_BUSY | CAM_DEV_QFRZN;
524 xpt_freeze_devq(ccb->ccb_h.path, 1);
529 /* Save pointers on both sides */
530 io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr = ccb;
531 ccb->ccb_h.io_ptr = io;
534 * Only SCSI I/O comes down this path, resets, etc. come
535 * down via the XPT_RESET_BUS/LUN CCBs below.
537 io->io_hdr.io_type = CTL_IO_SCSI;
538 io->io_hdr.nexus.initid = 1;
539 io->io_hdr.nexus.targ_port = softc->port.targ_port;
540 io->io_hdr.nexus.targ_lun = ctl_decode_lun(
541 CAM_EXTLUN_BYTE_SWIZZLE(ccb->ccb_h.target_lun));
543 * This tag scheme isn't the best, since we could in theory
544 * have a very long-lived I/O and tag collision, especially
545 * in a high I/O environment. But it should work well
546 * enough for now. Since we're using unsigned ints,
547 * they'll just wrap around.
549 io->scsiio.tag_num = atomic_fetchadd_32(&softc->cur_tag_num, 1);
550 csio->tag_id = io->scsiio.tag_num;
551 switch (csio->tag_action) {
552 case CAM_TAG_ACTION_NONE:
553 io->scsiio.tag_type = CTL_TAG_UNTAGGED;
555 case MSG_SIMPLE_TASK:
556 io->scsiio.tag_type = CTL_TAG_SIMPLE;
558 case MSG_HEAD_OF_QUEUE_TASK:
559 io->scsiio.tag_type = CTL_TAG_HEAD_OF_QUEUE;
561 case MSG_ORDERED_TASK:
562 io->scsiio.tag_type = CTL_TAG_ORDERED;
565 io->scsiio.tag_type = CTL_TAG_ACA;
568 io->scsiio.tag_type = CTL_TAG_UNTAGGED;
569 printf("%s: unhandled tag type %#x!!\n", __func__,
573 if (csio->cdb_len > sizeof(io->scsiio.cdb)) {
574 printf("%s: WARNING: CDB len %d > ctl_io space %zd\n",
575 __func__, csio->cdb_len, sizeof(io->scsiio.cdb));
577 io->scsiio.cdb_len = min(csio->cdb_len, sizeof(io->scsiio.cdb));
578 bcopy(scsiio_cdb_ptr(csio), io->scsiio.cdb, io->scsiio.cdb_len);
580 ccb->ccb_h.status |= CAM_SIM_QUEUED;
582 if (err != CTL_RETVAL_COMPLETE) {
583 printf("%s: func %d: error %d returned by "
584 "ctl_queue()!\n", __func__,
585 ccb->ccb_h.func_code, err);
587 ccb->ccb_h.status = CAM_REQ_INVALID;
595 union ccb *abort_ccb;
597 abort_ccb = ccb->cab.abort_ccb;
599 if (abort_ccb->ccb_h.func_code != XPT_SCSI_IO) {
600 ccb->ccb_h.status = CAM_REQ_INVALID;
605 * If we aren't online, there are no devices to talk to.
607 if (softc->online == 0) {
608 ccb->ccb_h.status = CAM_DEV_NOT_THERE;
613 io = ctl_alloc_io_nowait(softc->port.ctl_pool_ref);
615 ccb->ccb_h.status = CAM_BUSY | CAM_DEV_QFRZN;
616 xpt_freeze_devq(ccb->ccb_h.path, 1);
622 /* Save pointers on both sides */
623 io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr = ccb;
624 ccb->ccb_h.io_ptr = io;
626 io->io_hdr.io_type = CTL_IO_TASK;
627 io->io_hdr.nexus.initid = 1;
628 io->io_hdr.nexus.targ_port = softc->port.targ_port;
629 io->io_hdr.nexus.targ_lun = ctl_decode_lun(
630 CAM_EXTLUN_BYTE_SWIZZLE(ccb->ccb_h.target_lun));
631 io->taskio.task_action = CTL_TASK_ABORT_TASK;
632 io->taskio.tag_num = abort_ccb->csio.tag_id;
633 switch (abort_ccb->csio.tag_action) {
634 case CAM_TAG_ACTION_NONE:
635 io->taskio.tag_type = CTL_TAG_UNTAGGED;
637 case MSG_SIMPLE_TASK:
638 io->taskio.tag_type = CTL_TAG_SIMPLE;
640 case MSG_HEAD_OF_QUEUE_TASK:
641 io->taskio.tag_type = CTL_TAG_HEAD_OF_QUEUE;
643 case MSG_ORDERED_TASK:
644 io->taskio.tag_type = CTL_TAG_ORDERED;
647 io->taskio.tag_type = CTL_TAG_ACA;
650 io->taskio.tag_type = CTL_TAG_UNTAGGED;
651 printf("%s: unhandled tag type %#x!!\n", __func__,
652 abort_ccb->csio.tag_action);
656 if (err != CTL_RETVAL_COMPLETE) {
657 printf("%s func %d: error %d returned by "
658 "ctl_queue()!\n", __func__,
659 ccb->ccb_h.func_code, err);
664 case XPT_GET_TRAN_SETTINGS: {
665 struct ccb_trans_settings *cts;
666 struct ccb_trans_settings_scsi *scsi;
667 struct ccb_trans_settings_fc *fc;
670 scsi = &cts->proto_specific.scsi;
671 fc = &cts->xport_specific.fc;
674 cts->protocol = PROTO_SCSI;
675 cts->protocol_version = SCSI_REV_SPC2;
676 cts->transport = XPORT_FC;
677 cts->transport_version = 0;
679 scsi->valid = CTS_SCSI_VALID_TQ;
680 scsi->flags = CTS_SCSI_FLAGS_TAG_ENB;
681 fc->valid = CTS_FC_VALID_SPEED;
682 fc->bitrate = 800000;
683 fc->wwnn = softc->wwnn;
684 fc->wwpn = softc->wwpn;
685 fc->port = softc->port.targ_port;
686 fc->valid |= CTS_FC_VALID_WWNN | CTS_FC_VALID_WWPN |
688 ccb->ccb_h.status = CAM_REQ_CMP;
691 case XPT_SET_TRAN_SETTINGS:
692 /* XXX KDM should we actually do something here? */
693 ccb->ccb_h.status = CAM_REQ_CMP;
696 case XPT_RESET_DEV: {
700 * If we aren't online, there are no devices to talk to.
702 if (softc->online == 0) {
703 ccb->ccb_h.status = CAM_DEV_NOT_THERE;
708 io = ctl_alloc_io_nowait(softc->port.ctl_pool_ref);
710 ccb->ccb_h.status = CAM_BUSY | CAM_DEV_QFRZN;
711 xpt_freeze_devq(ccb->ccb_h.path, 1);
717 /* Save pointers on both sides */
718 if (ccb->ccb_h.func_code == XPT_RESET_DEV)
719 io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr = ccb;
720 ccb->ccb_h.io_ptr = io;
722 io->io_hdr.io_type = CTL_IO_TASK;
723 io->io_hdr.nexus.initid = 1;
724 io->io_hdr.nexus.targ_port = softc->port.targ_port;
725 io->io_hdr.nexus.targ_lun = ctl_decode_lun(
726 CAM_EXTLUN_BYTE_SWIZZLE(ccb->ccb_h.target_lun));
727 if (ccb->ccb_h.func_code == XPT_RESET_BUS)
728 io->taskio.task_action = CTL_TASK_BUS_RESET;
730 io->taskio.task_action = CTL_TASK_LUN_RESET;
733 if (err != CTL_RETVAL_COMPLETE) {
734 printf("%s func %d: error %d returned by "
735 "ctl_queue()!\n", __func__,
736 ccb->ccb_h.func_code, err);
741 case XPT_CALC_GEOMETRY:
742 cam_calc_geometry(&ccb->ccg, 1);
746 struct ccb_pathinq *cpi;
750 cpi->version_num = 0;
751 cpi->hba_inquiry = PI_TAG_ABLE;
752 cpi->target_sprt = 0;
753 cpi->hba_misc = PIM_EXTLUNS;
754 cpi->hba_eng_cnt = 0;
757 /* Do we really have a limit? */
758 cpi->maxio = 1024 * 1024;
759 cpi->async_flags = 0;
761 cpi->initiator_id = 1;
763 strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
764 strlcpy(cpi->hba_vid, "FreeBSD", HBA_IDLEN);
765 strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
766 cpi->unit_number = 0;
768 cpi->base_transfer_speed = 800000;
769 cpi->protocol = PROTO_SCSI;
770 cpi->protocol_version = SCSI_REV_SPC2;
772 * Pretend to be Fibre Channel.
774 cpi->transport = XPORT_FC;
775 cpi->transport_version = 0;
776 cpi->xport_specific.fc.wwnn = softc->wwnn;
777 cpi->xport_specific.fc.wwpn = softc->wwpn;
778 cpi->xport_specific.fc.port = softc->port.targ_port;
779 cpi->xport_specific.fc.bitrate = 8 * 1000 * 1000;
780 cpi->ccb_h.status = CAM_REQ_CMP;
784 ccb->ccb_h.status = CAM_PROVIDE_FAIL;
785 printf("%s: unsupported CCB type %#x\n", __func__,
786 ccb->ccb_h.func_code);