.. | .. |
---|
128 | 128 | set_host_byte(sc, DID_ERROR); |
---|
129 | 129 | goto out_done; |
---|
130 | 130 | } |
---|
131 | | - if (scsi_bidi_cmnd(sc)) { |
---|
132 | | - struct scsi_data_buffer *sdb = scsi_in(sc); |
---|
133 | | - |
---|
134 | | - sgl_bidi = sdb->table.sgl; |
---|
135 | | - sgl_bidi_count = sdb->table.nents; |
---|
136 | | - se_cmd->se_cmd_flags |= SCF_BIDI; |
---|
137 | | - |
---|
138 | | - } |
---|
139 | 131 | |
---|
140 | 132 | transfer_length = scsi_transfer_length(sc); |
---|
141 | 133 | if (!scsi_prot_sg_count(sc) && |
---|
.. | .. |
---|
304 | 296 | return FAILED; |
---|
305 | 297 | } |
---|
306 | 298 | |
---|
307 | | -static int tcm_loop_slave_alloc(struct scsi_device *sd) |
---|
308 | | -{ |
---|
309 | | - blk_queue_flag_set(QUEUE_FLAG_BIDI, sd->request_queue); |
---|
310 | | - return 0; |
---|
311 | | -} |
---|
312 | | - |
---|
313 | 299 | static struct scsi_host_template tcm_loop_driver_template = { |
---|
314 | 300 | .show_info = tcm_loop_show_info, |
---|
315 | 301 | .proc_name = "tcm_loopback", |
---|
.. | .. |
---|
324 | 310 | .sg_tablesize = 256, |
---|
325 | 311 | .cmd_per_lun = 1024, |
---|
326 | 312 | .max_sectors = 0xFFFF, |
---|
327 | | - .use_clustering = DISABLE_CLUSTERING, |
---|
328 | | - .slave_alloc = tcm_loop_slave_alloc, |
---|
| 313 | + .dma_boundary = PAGE_SIZE - 1, |
---|
329 | 314 | .module = THIS_MODULE, |
---|
330 | 315 | .track_queue_depth = 1, |
---|
331 | 316 | }; |
---|
.. | .. |
---|
409 | 394 | ret = device_register(&tl_hba->dev); |
---|
410 | 395 | if (ret) { |
---|
411 | 396 | pr_err("device_register() failed for tl_hba->dev: %d\n", ret); |
---|
| 397 | + put_device(&tl_hba->dev); |
---|
412 | 398 | return -ENODEV; |
---|
413 | 399 | } |
---|
414 | 400 | |
---|
.. | .. |
---|
458 | 444 | root_device_unregister(tcm_loop_primary); |
---|
459 | 445 | |
---|
460 | 446 | pr_debug("Releasing TCM Loop Core BUS\n"); |
---|
461 | | -} |
---|
462 | | - |
---|
463 | | -static char *tcm_loop_get_fabric_name(void) |
---|
464 | | -{ |
---|
465 | | - return "loopback"; |
---|
466 | 447 | } |
---|
467 | 448 | |
---|
468 | 449 | static inline struct tcm_loop_tpg *tl_tpg(struct se_portal_group *se_tpg) |
---|
.. | .. |
---|
565 | 546 | return 0; |
---|
566 | 547 | } |
---|
567 | 548 | |
---|
568 | | -static int tcm_loop_write_pending_status(struct se_cmd *se_cmd) |
---|
569 | | -{ |
---|
570 | | - return 0; |
---|
571 | | -} |
---|
572 | | - |
---|
573 | | -static int tcm_loop_queue_data_in(struct se_cmd *se_cmd) |
---|
| 549 | +static int tcm_loop_queue_data_or_status(const char *func, |
---|
| 550 | + struct se_cmd *se_cmd, u8 scsi_status) |
---|
574 | 551 | { |
---|
575 | 552 | struct tcm_loop_cmd *tl_cmd = container_of(se_cmd, |
---|
576 | 553 | struct tcm_loop_cmd, tl_se_cmd); |
---|
577 | 554 | struct scsi_cmnd *sc = tl_cmd->sc; |
---|
578 | 555 | |
---|
579 | 556 | pr_debug("%s() called for scsi_cmnd: %p cdb: 0x%02x\n", |
---|
580 | | - __func__, sc, sc->cmnd[0]); |
---|
581 | | - |
---|
582 | | - sc->result = SAM_STAT_GOOD; |
---|
583 | | - set_host_byte(sc, DID_OK); |
---|
584 | | - if ((se_cmd->se_cmd_flags & SCF_OVERFLOW_BIT) || |
---|
585 | | - (se_cmd->se_cmd_flags & SCF_UNDERFLOW_BIT)) |
---|
586 | | - scsi_set_resid(sc, se_cmd->residual_count); |
---|
587 | | - sc->scsi_done(sc); |
---|
588 | | - return 0; |
---|
589 | | -} |
---|
590 | | - |
---|
591 | | -static int tcm_loop_queue_status(struct se_cmd *se_cmd) |
---|
592 | | -{ |
---|
593 | | - struct tcm_loop_cmd *tl_cmd = container_of(se_cmd, |
---|
594 | | - struct tcm_loop_cmd, tl_se_cmd); |
---|
595 | | - struct scsi_cmnd *sc = tl_cmd->sc; |
---|
596 | | - |
---|
597 | | - pr_debug("%s() called for scsi_cmnd: %p cdb: 0x%02x\n", |
---|
598 | | - __func__, sc, sc->cmnd[0]); |
---|
| 557 | + func, sc, sc->cmnd[0]); |
---|
599 | 558 | |
---|
600 | 559 | if (se_cmd->sense_buffer && |
---|
601 | 560 | ((se_cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) || |
---|
.. | .. |
---|
606 | 565 | sc->result = SAM_STAT_CHECK_CONDITION; |
---|
607 | 566 | set_driver_byte(sc, DRIVER_SENSE); |
---|
608 | 567 | } else |
---|
609 | | - sc->result = se_cmd->scsi_status; |
---|
| 568 | + sc->result = scsi_status; |
---|
610 | 569 | |
---|
611 | 570 | set_host_byte(sc, DID_OK); |
---|
612 | 571 | if ((se_cmd->se_cmd_flags & SCF_OVERFLOW_BIT) || |
---|
.. | .. |
---|
614 | 573 | scsi_set_resid(sc, se_cmd->residual_count); |
---|
615 | 574 | sc->scsi_done(sc); |
---|
616 | 575 | return 0; |
---|
| 576 | +} |
---|
| 577 | + |
---|
| 578 | +static int tcm_loop_queue_data_in(struct se_cmd *se_cmd) |
---|
| 579 | +{ |
---|
| 580 | + return tcm_loop_queue_data_or_status(__func__, se_cmd, SAM_STAT_GOOD); |
---|
| 581 | +} |
---|
| 582 | + |
---|
| 583 | +static int tcm_loop_queue_status(struct se_cmd *se_cmd) |
---|
| 584 | +{ |
---|
| 585 | + return tcm_loop_queue_data_or_status(__func__, |
---|
| 586 | + se_cmd, se_cmd->scsi_status); |
---|
617 | 587 | } |
---|
618 | 588 | |
---|
619 | 589 | static void tcm_loop_queue_tm_rsp(struct se_cmd *se_cmd) |
---|
.. | .. |
---|
1103 | 1073 | */ |
---|
1104 | 1074 | ret = tcm_loop_setup_hba_bus(tl_hba, tcm_loop_hba_no_cnt); |
---|
1105 | 1075 | if (ret) |
---|
1106 | | - goto out; |
---|
| 1076 | + return ERR_PTR(ret); |
---|
1107 | 1077 | |
---|
1108 | 1078 | sh = tl_hba->sh; |
---|
1109 | 1079 | tcm_loop_hba_no_cnt++; |
---|
.. | .. |
---|
1149 | 1119 | |
---|
1150 | 1120 | static const struct target_core_fabric_ops loop_ops = { |
---|
1151 | 1121 | .module = THIS_MODULE, |
---|
1152 | | - .name = "loopback", |
---|
1153 | | - .get_fabric_name = tcm_loop_get_fabric_name, |
---|
| 1122 | + .fabric_name = "loopback", |
---|
1154 | 1123 | .tpg_get_wwn = tcm_loop_get_endpoint_wwn, |
---|
1155 | 1124 | .tpg_get_tag = tcm_loop_get_tag, |
---|
1156 | 1125 | .tpg_check_demo_mode = tcm_loop_check_demo_mode, |
---|
.. | .. |
---|
1165 | 1134 | .release_cmd = tcm_loop_release_cmd, |
---|
1166 | 1135 | .sess_get_index = tcm_loop_sess_get_index, |
---|
1167 | 1136 | .write_pending = tcm_loop_write_pending, |
---|
1168 | | - .write_pending_status = tcm_loop_write_pending_status, |
---|
1169 | 1137 | .set_default_node_attributes = tcm_loop_set_default_node_attributes, |
---|
1170 | 1138 | .get_cmd_state = tcm_loop_get_cmd_state, |
---|
1171 | 1139 | .queue_data_in = tcm_loop_queue_data_in, |
---|