Lines Matching +full:cam +full:- +full:if

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 #include <cam/cam.h>
44 #include <cam/scsi/scsi_all.h>
45 #include <cam/scsi/scsi_da.h>
46 #include <cam/ctl/ctl_io.h>
47 #include <cam/ctl/ctl.h>
48 #include <cam/ctl/ctl_frontend.h>
49 #include <cam/ctl/ctl_util.h>
50 #include <cam/ctl/ctl_backend.h>
51 #include <cam/ctl/ctl_ioctl.h>
52 #include <cam/ctl/ctl_ha.h>
53 #include <cam/ctl/ctl_private.h>
54 #include <cam/ctl/ctl_debug.h>
55 #include <cam/ctl/ctl_scsi_all.h>
56 #include <cam/ctl/ctl_tpc.h>
57 #include <cam/ctl/ctl_error.h>
89 port = &tsoftc->port; in tpcl_init()
90 port->frontend = &tpcl_frontend; in tpcl_init()
91 port->port_type = CTL_PORT_INTERNAL; in tpcl_init()
92 port->num_requested_ctl_io = 100; in tpcl_init()
93 port->port_name = "tpc"; in tpcl_init()
94 port->fe_datamove = tpcl_datamove; in tpcl_init()
95 port->fe_done = tpcl_done; in tpcl_init()
96 port->targ_port = -1; in tpcl_init()
97 port->max_initiators = 1; in tpcl_init()
99 if ((error = ctl_port_register(port)) != 0) { in tpcl_init()
105 port->init_devid = malloc(sizeof(struct ctl_devid) + len, in tpcl_init()
107 port->init_devid->len = len; in tpcl_init()
108 tid = (struct scsi_transportid_spi *)port->init_devid->data; in tpcl_init()
109 tid->format_protocol = SCSI_TRN_SPI_FORMAT_DEFAULT | SCSI_PROTO_SPI; in tpcl_init()
110 scsi_ulto2b(0, tid->scsi_addr); in tpcl_init()
111 scsi_ulto2b(port->targ_port, tid->rel_trgt_port_id); in tpcl_init()
121 struct ctl_port *port = &tsoftc->port; in tpcl_shutdown()
125 if ((error = ctl_port_deregister(port)) != 0) in tpcl_shutdown()
144 ctsio = &io->scsiio; in tpcl_datamove()
147 * If this is the case, we're probably doing a BBR read and don't in tpcl_datamove()
149 * bit-bucket the data. in tpcl_datamove()
151 if (ctsio->ext_data_ptr == NULL) in tpcl_datamove()
155 * To simplify things here, if we have a single buffer, stick it in in tpcl_datamove()
158 if (ctsio->ext_sg_entries > 0) { in tpcl_datamove()
161 ext_sglist = (struct ctl_sg_entry *)ctsio->ext_data_ptr; in tpcl_datamove()
162 ext_sg_entries = ctsio->ext_sg_entries; in tpcl_datamove()
167 if ((len_seen + ext_sglist[i].len) >= in tpcl_datamove()
168 ctsio->ext_data_filled) { in tpcl_datamove()
170 ext_offset = ctsio->ext_data_filled - len_seen; in tpcl_datamove()
177 ext_sglist->addr = ctsio->ext_data_ptr; in tpcl_datamove()
178 ext_sglist->len = ctsio->ext_data_len; in tpcl_datamove()
181 ext_offset = ctsio->ext_data_filled; in tpcl_datamove()
184 if (ctsio->kern_sg_entries > 0) { in tpcl_datamove()
185 kern_sglist = (struct ctl_sg_entry *)ctsio->kern_data_ptr; in tpcl_datamove()
186 kern_sg_entries = ctsio->kern_sg_entries; in tpcl_datamove()
189 kern_sglist->addr = ctsio->kern_data_ptr; in tpcl_datamove()
190 kern_sglist->len = ctsio->kern_data_len; in tpcl_datamove()
200 len_to_copy = min(ext_sglist[i].len - ext_watermark, in tpcl_datamove()
201 kern_sglist[j].len - kern_watermark); in tpcl_datamove()
205 if (io->io_hdr.flags & CTL_FLAG_BUS_ADDR) { in tpcl_datamove()
210 #if 0 in tpcl_datamove()
217 if ((ctsio->io_hdr.flags & CTL_FLAG_DATA_MASK) == in tpcl_datamove()
232 ctsio->ext_data_filled += len_to_copy; in tpcl_datamove()
233 ctsio->kern_data_resid -= len_to_copy; in tpcl_datamove()
236 if (ext_sglist[i].len == ext_watermark) { in tpcl_datamove()
242 if (kern_sglist[j].len == kern_watermark) { in tpcl_datamove()
251 __func__, ctsio->ext_data_len, ctsio->kern_data_len)); in tpcl_datamove()
273 if (cscd->type_code != EC_CSCD_ID || in tpcl_resolve()
274 (cscd->luidt_pdt & EC_LUIDT_MASK) != EC_LUIDT_LUN || in tpcl_resolve()
275 (cscd->luidt_pdt & EC_NUL) != 0) in tpcl_resolve()
279 mtx_lock(&softc->ctl_lock); in tpcl_resolve()
280 if (init_port >= 0) in tpcl_resolve()
281 port = softc->ctl_ports[init_port]; in tpcl_resolve()
284 STAILQ_FOREACH(lun, &softc->lun_list, links) { in tpcl_resolve()
285 if (port != NULL && in tpcl_resolve()
286 ctl_lun_map_to_port(port, lun->lun) == UINT32_MAX) in tpcl_resolve()
288 if (lun->lun_devid == NULL) in tpcl_resolve()
290 if (scsi_devid_match(lun->lun_devid->data, in tpcl_resolve()
291 lun->lun_devid->len, &cscdid->codeset, in tpcl_resolve()
292 cscdid->length + 4) == 0) { in tpcl_resolve()
293 lunid = lun->lun; in tpcl_resolve()
294 if (ss) in tpcl_resolve()
295 *ss = lun->be_lun->blocksize; in tpcl_resolve()
296 if (ps) in tpcl_resolve()
297 *ps = lun->be_lun->blocksize << in tpcl_resolve()
298 lun->be_lun->pblockexp; in tpcl_resolve()
299 if (pso) in tpcl_resolve()
300 *pso = lun->be_lun->blocksize * in tpcl_resolve()
301 lun->be_lun->pblockoff; in tpcl_resolve()
305 mtx_unlock(&softc->ctl_lock); in tpcl_resolve()
314 return (ctl_alloc_io(tsoftc->port.ctl_pool_ref)); in tpcl_alloc_io()
322 io->io_hdr.nexus.initid = 0; in tpcl_queue()
323 io->io_hdr.nexus.targ_port = tsoftc->port.targ_port; in tpcl_queue()
324 io->io_hdr.nexus.targ_lun = lun; in tpcl_queue()
325 io->scsiio.tag_num = atomic_fetchadd_int(&tsoftc->cur_tag_num, 1); in tpcl_queue()
326 io->scsiio.ext_data_filled = 0; in tpcl_queue()