Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[linux.git] / drivers / target / loopback / tcm_loop.c
index 1b41e6776152a446b5fda48a1db3fd4594083b99..c886ad1c39fb357ddb6e72a384474bdc89b01278 100644 (file)
@@ -212,12 +212,17 @@ static void tcm_loop_submission_work(struct work_struct *work)
                se_cmd->se_cmd_flags |= SCF_BIDI;
 
        }
+
+       if (!scsi_prot_sg_count(sc) && scsi_get_prot_op(sc) != SCSI_PROT_NORMAL)
+               se_cmd->prot_pto = true;
+
        rc = target_submit_cmd_map_sgls(se_cmd, tl_nexus->se_sess, sc->cmnd,
                        &tl_cmd->tl_sense_buf[0], tl_cmd->sc->device->lun,
                        scsi_bufflen(sc), tcm_loop_sam_attr(sc),
                        sc->sc_data_direction, 0,
                        scsi_sglist(sc), scsi_sg_count(sc),
-                       sgl_bidi, sgl_bidi_count);
+                       sgl_bidi, sgl_bidi_count,
+                       scsi_prot_sglist(sc), scsi_prot_sg_count(sc));
        if (rc < 0) {
                set_host_byte(sc, DID_NO_CONNECT);
                goto out_done;
@@ -462,7 +467,7 @@ static int tcm_loop_driver_probe(struct device *dev)
 {
        struct tcm_loop_hba *tl_hba;
        struct Scsi_Host *sh;
-       int error;
+       int error, host_prot;
 
        tl_hba = to_tcm_loop_hba(dev);
 
@@ -486,6 +491,13 @@ static int tcm_loop_driver_probe(struct device *dev)
        sh->max_channel = 0;
        sh->max_cmd_len = TL_SCSI_MAX_CMD_LEN;
 
+       host_prot = SHOST_DIF_TYPE1_PROTECTION | SHOST_DIF_TYPE2_PROTECTION |
+                   SHOST_DIF_TYPE3_PROTECTION | SHOST_DIX_TYPE1_PROTECTION |
+                   SHOST_DIX_TYPE2_PROTECTION | SHOST_DIX_TYPE3_PROTECTION;
+
+       scsi_host_set_prot(sh, host_prot);
+       scsi_host_set_guard(sh, SHOST_DIX_GUARD_CRC);
+
        error = scsi_add_host(sh, &tl_hba->dev);
        if (error) {
                pr_err("%s: scsi_add_host failed\n", __func__);
@@ -907,6 +919,11 @@ static void tcm_loop_queue_tm_rsp(struct se_cmd *se_cmd)
        wake_up(&tl_tmr->tl_tmr_wait);
 }
 
+static void tcm_loop_aborted_task(struct se_cmd *se_cmd)
+{
+       return;
+}
+
 static char *tcm_loop_dump_proto_id(struct tcm_loop_hba *tl_hba)
 {
        switch (tl_hba->tl_proto_id) {
@@ -1001,7 +1018,7 @@ static int tcm_loop_make_nexus(
        /*
         * Initialize the struct se_session pointer
         */
-       tl_nexus->se_sess = transport_init_session();
+       tl_nexus->se_sess = transport_init_session(TARGET_PROT_ALL);
        if (IS_ERR(tl_nexus->se_sess)) {
                ret = PTR_ERR(tl_nexus->se_sess);
                goto out;
@@ -1228,7 +1245,7 @@ static struct configfs_attribute *tcm_loop_tpg_attrs[] = {
 
 /* Start items for tcm_loop_naa_cit */
 
-struct se_portal_group *tcm_loop_make_naa_tpg(
+static struct se_portal_group *tcm_loop_make_naa_tpg(
        struct se_wwn *wwn,
        struct config_group *group,
        const char *name)
@@ -1273,7 +1290,7 @@ struct se_portal_group *tcm_loop_make_naa_tpg(
        return &tl_tpg->tl_se_tpg;
 }
 
-void tcm_loop_drop_naa_tpg(
+static void tcm_loop_drop_naa_tpg(
        struct se_portal_group *se_tpg)
 {
        struct se_wwn *wwn = se_tpg->se_tpg_wwn;
@@ -1305,7 +1322,7 @@ void tcm_loop_drop_naa_tpg(
 
 /* Start items for tcm_loop_cit */
 
-struct se_wwn *tcm_loop_make_scsi_hba(
+static struct se_wwn *tcm_loop_make_scsi_hba(
        struct target_fabric_configfs *tf,
        struct config_group *group,
        const char *name)
@@ -1375,7 +1392,7 @@ out:
        return ERR_PTR(ret);
 }
 
-void tcm_loop_drop_scsi_hba(
+static void tcm_loop_drop_scsi_hba(
        struct se_wwn *wwn)
 {
        struct tcm_loop_hba *tl_hba = container_of(wwn,
@@ -1475,6 +1492,7 @@ static int tcm_loop_register_configfs(void)
        fabric->tf_ops.queue_data_in = &tcm_loop_queue_data_in;
        fabric->tf_ops.queue_status = &tcm_loop_queue_status;
        fabric->tf_ops.queue_tm_rsp = &tcm_loop_queue_tm_rsp;
+       fabric->tf_ops.aborted_task = &tcm_loop_aborted_task;
 
        /*
         * Setup function pointers for generic logic in target_core_fabric_configfs.c