Lines Matching +full:break +full:- +full:control
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
32 * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl_util.c#2 $
99 ctl_scsi_tur(union ctl_io *io, ctl_tag_type tag_type, uint8_t control)
106 io->io_hdr.io_type = CTL_IO_SCSI;
107 ctsio = &io->scsiio;
108 cdb = (struct scsi_test_unit_ready *)ctsio->cdb;
110 cdb->opcode = TEST_UNIT_READY;
111 cdb->control = control;
112 io->io_hdr.flags = CTL_FLAG_DATA_NONE;
113 ctsio->tag_type = tag_type;
114 ctsio->cdb_len = sizeof(*cdb);
115 ctsio->ext_data_len = 0;
116 ctsio->ext_data_ptr = NULL;
117 ctsio->ext_sg_entries = 0;
118 ctsio->ext_data_filled = 0;
119 ctsio->sense_len = SSD_FULL_SIZE;
125 uint8_t control)
132 io->io_hdr.io_type = CTL_IO_SCSI;
133 ctsio = &io->scsiio;
134 cdb = (struct scsi_inquiry *)ctsio->cdb;
136 cdb->opcode = INQUIRY;
137 cdb->byte2 = byte2;
138 cdb->page_code = page_code;
139 cdb->control = control;
140 scsi_ulto2b(data_len, cdb->length);
141 io->io_hdr.io_type = CTL_IO_SCSI;
142 io->io_hdr.flags = CTL_FLAG_DATA_IN;
143 ctsio->tag_type = tag_type;
144 ctsio->cdb_len = sizeof(*cdb);
145 ctsio->ext_data_len = data_len;
146 ctsio->ext_data_ptr = data_ptr;
147 ctsio->ext_sg_entries = 0;
148 ctsio->ext_data_filled = 0;
149 ctsio->sense_len = SSD_FULL_SIZE;
155 uint8_t control)
162 io->io_hdr.io_type = CTL_IO_SCSI;
163 ctsio = &io->scsiio;
164 cdb = (struct scsi_request_sense *)ctsio->cdb;
166 cdb->opcode = REQUEST_SENSE;
167 cdb->byte2 = byte2;
168 cdb->control = control;
169 cdb->length = data_len;
170 io->io_hdr.io_type = CTL_IO_SCSI;
171 io->io_hdr.flags = CTL_FLAG_DATA_IN;
172 ctsio->tag_type = tag_type;
173 ctsio->cdb_len = sizeof(*cdb);
174 ctsio->ext_data_ptr = data_ptr;
175 ctsio->ext_data_len = data_len;
176 ctsio->ext_sg_entries = 0;
177 ctsio->ext_data_filled = 0;
178 ctsio->sense_len = SSD_FULL_SIZE;
184 uint8_t control)
191 io->io_hdr.io_type = CTL_IO_SCSI;
192 ctsio = &io->scsiio;
193 cdb = (struct scsi_report_luns *)ctsio->cdb;
195 cdb->opcode = REPORT_LUNS;
196 cdb->select_report = select_report;
197 scsi_ulto4b(data_len, cdb->length);
198 cdb->control = control;
199 io->io_hdr.io_type = CTL_IO_SCSI;
200 io->io_hdr.flags = CTL_FLAG_DATA_IN;
201 ctsio->tag_type = tag_type;
202 ctsio->cdb_len = sizeof(*cdb);
203 ctsio->ext_data_ptr = data_ptr;
204 ctsio->ext_data_len = data_len;
205 ctsio->ext_sg_entries = 0;
206 ctsio->ext_data_filled = 0;
207 ctsio->sense_len = SSD_FULL_SIZE;
214 ctl_tag_type tag_type, uint8_t control)
221 io->io_hdr.io_type = CTL_IO_SCSI;
222 ctsio = &io->scsiio;
223 cdb = (struct scsi_write_buffer *)ctsio->cdb;
226 cdb->opcode = READ_BUFFER;
228 cdb->opcode = WRITE_BUFFER;
230 cdb->byte2 = mode & RWB_MODE;
231 cdb->buffer_id = buffer_id;
232 scsi_ulto3b(buffer_offset, cdb->offset);
233 scsi_ulto3b(data_len, cdb->length);
234 cdb->control = control;
235 io->io_hdr.io_type = CTL_IO_SCSI;
237 io->io_hdr.flags = CTL_FLAG_DATA_IN;
239 io->io_hdr.flags = CTL_FLAG_DATA_OUT;
240 ctsio->tag_type = tag_type;
241 ctsio->cdb_len = sizeof(*cdb);
242 ctsio->ext_data_ptr = data_ptr;
243 ctsio->ext_data_len = data_len;
244 ctsio->ext_sg_entries = 0;
245 ctsio->ext_data_filled = 0;
246 ctsio->sense_len = SSD_FULL_SIZE;
253 uint8_t control)
259 io->io_hdr.io_type = CTL_IO_SCSI;
260 ctsio = &io->scsiio;
267 * having an array larger than 2TB) and for compatibility -- e.g.
277 * Note that according to SBC-2, the target should return 256
283 cdb = (struct scsi_rw_6 *)ctsio->cdb;
285 cdb->opcode = (read_op) ? READ_6 : WRITE_6;
286 scsi_ulto3b(lba, cdb->addr);
287 cdb->length = num_blocks & 0xff;
288 cdb->control = control;
290 ctsio->cdb_len = sizeof(*cdb);
297 cdb = (struct scsi_rw_10 *)ctsio->cdb;
299 cdb->opcode = (read_op) ? READ_10 : WRITE_10;
300 cdb->byte2 = byte2;
301 scsi_ulto4b(lba, cdb->addr);
302 cdb->reserved = 0;
303 scsi_ulto2b(num_blocks, cdb->length);
304 cdb->control = control;
306 ctsio->cdb_len = sizeof(*cdb);
312 cdb = (struct scsi_rw_12 *)ctsio->cdb;
314 cdb->opcode = (read_op) ? READ_12 : WRITE_12;
315 cdb->byte2 = byte2;
316 scsi_ulto4b(lba, cdb->addr);
317 scsi_ulto4b(num_blocks, cdb->length);
318 cdb->reserved = 0;
319 cdb->control = control;
321 ctsio->cdb_len = sizeof(*cdb);
325 cdb = (struct scsi_rw_16 *)ctsio->cdb;
327 cdb->opcode = (read_op) ? READ_16 : WRITE_16;
328 cdb->byte2 = byte2;
329 scsi_u64to8b(lba, cdb->addr);
330 scsi_ulto4b(num_blocks, cdb->length);
331 cdb->reserved = 0;
332 cdb->control = control;
334 ctsio->cdb_len = sizeof(*cdb);
337 io->io_hdr.io_type = CTL_IO_SCSI;
339 io->io_hdr.flags = CTL_FLAG_DATA_IN;
341 io->io_hdr.flags = CTL_FLAG_DATA_OUT;
342 ctsio->tag_type = tag_type;
343 ctsio->ext_data_ptr = data_ptr;
344 ctsio->ext_data_len = data_len;
345 ctsio->ext_sg_entries = 0;
346 ctsio->ext_data_filled = 0;
347 ctsio->sense_len = SSD_FULL_SIZE;
353 ctl_tag_type tag_type, uint8_t control)
360 io->io_hdr.io_type = CTL_IO_SCSI;
361 ctsio = &io->scsiio;
362 ctsio->cdb_len = sizeof(*cdb);
363 cdb = (struct scsi_write_same_16 *)ctsio->cdb;
364 cdb->opcode = WRITE_SAME_16;
365 cdb->byte2 = byte2;
366 scsi_u64to8b(lba, cdb->addr);
367 scsi_ulto4b(num_blocks, cdb->length);
368 cdb->group = 0;
369 cdb->control = control;
371 io->io_hdr.io_type = CTL_IO_SCSI;
372 io->io_hdr.flags = CTL_FLAG_DATA_OUT;
373 ctsio->tag_type = tag_type;
374 ctsio->ext_data_ptr = data_ptr;
375 ctsio->ext_data_len = data_len;
376 ctsio->ext_sg_entries = 0;
377 ctsio->ext_data_filled = 0;
378 ctsio->sense_len = SSD_FULL_SIZE;
384 ctl_tag_type tag_type, uint8_t control)
390 io->io_hdr.io_type = CTL_IO_SCSI;
391 cdb = (struct scsi_read_capacity *)io->scsiio.cdb;
393 cdb->opcode = READ_CAPACITY;
395 cdb->byte2 = SRC_RELADR;
397 cdb->pmi = SRC_PMI;
398 scsi_ulto4b(addr, cdb->addr);
399 cdb->control = control;
400 io->io_hdr.io_type = CTL_IO_SCSI;
401 io->io_hdr.flags = CTL_FLAG_DATA_IN;
402 io->scsiio.tag_type = tag_type;
403 io->scsiio.ext_data_ptr = data_ptr;
404 io->scsiio.ext_data_len = data_len;
405 io->scsiio.ext_sg_entries = 0;
406 io->scsiio.ext_data_filled = 0;
407 io->scsiio.sense_len = SSD_FULL_SIZE;
413 int pmi, ctl_tag_type tag_type, uint8_t control)
419 io->io_hdr.io_type = CTL_IO_SCSI;
420 cdb = (struct scsi_read_capacity_16 *)io->scsiio.cdb;
422 cdb->opcode = SERVICE_ACTION_IN;
423 cdb->service_action = SRC16_SERVICE_ACTION;
425 cdb->reladr |= SRC16_RELADR;
427 cdb->reladr |= SRC16_PMI;
428 scsi_u64to8b(addr, cdb->addr);
429 scsi_ulto4b(data_len, cdb->alloc_len);
430 cdb->control = control;
432 io->io_hdr.io_type = CTL_IO_SCSI;
433 io->io_hdr.flags = CTL_FLAG_DATA_IN;
434 io->scsiio.tag_type = tag_type;
435 io->scsiio.ext_data_ptr = data_ptr;
436 io->scsiio.ext_data_len = data_len;
437 io->scsiio.ext_sg_entries = 0;
438 io->scsiio.ext_data_filled = 0;
439 io->scsiio.sense_len = SSD_FULL_SIZE;
446 ctl_tag_type tag_type, uint8_t control)
455 cdb = (struct scsi_mode_sense_6 *)io->scsiio.cdb;
457 cdb->opcode = MODE_SENSE_6;
459 cdb->byte2 |= SMS_DBD;
460 cdb->page = page_code | pc;
461 cdb->subpage = subpage;
462 cdb->length = data_len;
463 cdb->control = control;
467 cdb = (struct scsi_mode_sense_10 *)io->scsiio.cdb;
469 cdb->opcode = MODE_SENSE_10;
471 cdb->byte2 |= SMS_DBD;
473 cdb->byte2 |= SMS10_LLBAA;
474 cdb->page = page_code | pc;
475 cdb->subpage = subpage;
476 scsi_ulto2b(data_len, cdb->length);
477 cdb->control = control;
480 io->io_hdr.io_type = CTL_IO_SCSI;
481 io->io_hdr.flags = CTL_FLAG_DATA_IN;
482 io->scsiio.tag_type = tag_type;
483 io->scsiio.ext_data_ptr = data_ptr;
484 io->scsiio.ext_data_len = data_len;
485 io->scsiio.ext_sg_entries = 0;
486 io->scsiio.ext_data_filled = 0;
487 io->scsiio.sense_len = SSD_FULL_SIZE;
492 int power_conditions, ctl_tag_type tag_type, uint8_t control)
496 cdb = (struct scsi_start_stop_unit *)io->scsiio.cdb;
500 cdb->opcode = START_STOP_UNIT;
502 cdb->byte2 |= SSS_IMMED;
503 cdb->how = power_conditions;
505 cdb->how |= SSS_LOEJ;
507 cdb->how |= SSS_START;
508 cdb->control = control;
509 io->io_hdr.io_type = CTL_IO_SCSI;
510 io->io_hdr.flags = CTL_FLAG_DATA_NONE;
511 io->scsiio.tag_type = tag_type;
512 io->scsiio.ext_data_ptr = NULL;
513 io->scsiio.ext_data_len = 0;
514 io->scsiio.ext_sg_entries = 0;
515 io->scsiio.ext_data_filled = 0;
516 io->scsiio.sense_len = SSD_FULL_SIZE;
523 uint8_t control)
532 cdb = (struct scsi_sync_cache *)io->scsiio.cdb;
534 cdb->opcode = SYNCHRONIZE_CACHE;
536 cdb->byte2 |= SSC_RELADR;
539 cdb->byte2 |= SSC_IMMED;
541 scsi_ulto4b(starting_lba, cdb->begin_lba);
542 scsi_ulto2b(block_count, cdb->lb_count);
543 cdb->control = control;
547 cdb = (struct scsi_sync_cache_16 *)io->scsiio.cdb;
549 cdb->opcode = SYNCHRONIZE_CACHE_16;
551 cdb->byte2 |= SSC_RELADR;
554 cdb->byte2 |= SSC_IMMED;
556 scsi_u64to8b(starting_lba, cdb->begin_lba);
557 scsi_ulto4b(block_count, cdb->lb_count);
558 cdb->control = control;
560 io->io_hdr.io_type = CTL_IO_SCSI;
561 io->io_hdr.flags = CTL_FLAG_DATA_NONE;
562 io->scsiio.tag_type = tag_type;
563 io->scsiio.ext_data_ptr = NULL;
564 io->scsiio.ext_data_len = 0;
565 io->scsiio.ext_sg_entries = 0;
566 io->scsiio.ext_data_filled = 0;
567 io->scsiio.sense_len = SSD_FULL_SIZE;
573 ctl_tag_type tag_type, uint8_t control)
580 cdb = (struct scsi_per_res_in *)io->scsiio.cdb;
581 cdb->opcode = PERSISTENT_RES_IN;
582 cdb->action = action;
583 scsi_ulto2b(data_len, cdb->length);
584 cdb->control = control;
586 io->io_hdr.io_type = CTL_IO_SCSI;
587 io->io_hdr.flags = CTL_FLAG_DATA_IN;
588 io->scsiio.tag_type = tag_type;
589 io->scsiio.ext_data_ptr = data_ptr;
590 io->scsiio.ext_data_len = data_len;
591 io->scsiio.ext_sg_entries = 0;
592 io->scsiio.ext_data_filled = 0;
593 io->scsiio.sense_len = SSD_FULL_SIZE;
600 ctl_tag_type tag_type, uint8_t control)
608 cdb = (struct scsi_per_res_out *)io->scsiio.cdb;
611 cdb->opcode = PERSISTENT_RES_OUT;
613 cdb->action = 6;
615 cdb->action = action;
619 cdb->scope_type = 1;
620 break;
622 cdb->scope_type = 3;
623 break;
625 cdb->scope_type = 5;
626 break;
628 cdb->scope_type = 6;
629 break;
631 cdb->scope_type = 7;
632 break;
634 cdb->scope_type = 8;
635 break;
637 scsi_ulto4b(data_len, cdb->length);
638 cdb->control = control;
640 scsi_u64to8b(key, params->res_key.key);
641 scsi_u64to8b(sa_key, params->serv_act_res_key);
643 io->io_hdr.io_type = CTL_IO_SCSI;
644 io->io_hdr.flags = CTL_FLAG_DATA_OUT;
645 io->scsiio.tag_type = tag_type;
646 io->scsiio.ext_data_ptr = data_ptr;
647 io->scsiio.ext_data_len = data_len;
648 io->scsiio.ext_sg_entries = 0;
649 io->scsiio.ext_data_filled = 0;
650 io->scsiio.sense_len = SSD_FULL_SIZE;
656 uint8_t action, ctl_tag_type tag_type, uint8_t control)
662 cdb = (struct scsi_maintenance_in *)io->scsiio.cdb;
663 cdb->opcode = MAINTENANCE_IN;
664 cdb->byte2 = action;
665 scsi_ulto4b(data_len, cdb->length);
666 cdb->control = control;
668 io->io_hdr.io_type = CTL_IO_SCSI;
669 io->io_hdr.flags = CTL_FLAG_DATA_IN;
670 io->scsiio.tag_type = tag_type;
671 io->scsiio.ext_data_ptr = data_ptr;
672 io->scsiio.ext_data_len = data_len;
673 io->scsiio.ext_sg_entries = 0;
674 io->scsiio.ext_data_filled = 0;
675 io->scsiio.sense_len = SSD_FULL_SIZE;
688 io->io_hdr.nexus.initid = initid;
708 pool_ref = io->io_hdr.pool;
710 io->io_hdr.pool = pool_ref;
721 if (taskio->task_action == ctl_task_table[i].task_action) {
735 ctl_scsi_path_string(&io->io_hdr, path_str, sizeof(path_str));
737 switch (io->io_hdr.io_type) {
740 ctl_scsi_command_string(&io->scsiio, NULL, sb);
742 io->scsiio.tag_num, io->scsiio.tag_type,
743 io->scsiio.priority);
744 break;
747 task_desc = ctl_scsi_task_string(&io->taskio);
750 io->taskio.task_action, io->taskio.task_action);
753 switch (io->taskio.task_action) {
756 io->taskio.tag_num, io->taskio.tag_type);
757 break;
760 break;
762 break;
766 ctl_nvme_command_string(&io->nvmeio, sb);
767 sbuf_printf(sb, " CID: 0x%x\n", le16toh(io->nvmeio.cmd.cid));
768 break;
770 break;
787 if ((io->io_hdr.status & CTL_STATUS_MASK) ==
790 break;
794 ctl_scsi_path_string(&io->io_hdr, path_str, sizeof(path_str));
799 io->io_hdr.status);
801 sbuf_printf(sb, "CTL Status: %s\n", status_desc->description);
803 switch (io->io_hdr.io_type) {
805 if ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_SCSI_ERROR) {
808 ctl_scsi_status_string(&io->scsiio));
810 if (io->scsiio.scsi_status == SCSI_STATUS_CHECK_COND)
811 ctl_scsi_sense_sbuf(&io->scsiio, inq_data,
814 break;
817 if ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_NVME_ERROR) {
820 ctl_nvme_status_string(&io->nvmeio, sb);
823 break;
825 break;
880 switch (io->io_hdr.io_type) {
882 tag_num = io->scsiio.tag_num;
883 break;
886 tag_num = le16toh(io->nvmeio.cmd.cid);
887 break;
891 if (io->io_hdr.flags & CTL_FLAG_BUS_ADDR)
895 ctl_scsi_path_string(&io->io_hdr, path_str, sizeof(path_str));