// SPDX-License-Identifier: GPL-2.0-or-later/* * SCSI Primary Commands (SPC) parsing and emulation. * * (c) Copyright 2002-2013 Datera, Inc. * * Nicholas A. Bellinger <nab@kernel.org> */#include<linux/kernel.h>#include<linux/module.h>#include<asm/unaligned.h>#include<scsi/scsi_proto.h>#include<scsi/scsi_common.h>#include<scsi/scsi_tcq.h>#include<target/target_core_base.h>#include<target/target_core_backend.h>#include<target/target_core_fabric.h>#include"target_core_internal.h"#include"target_core_alua.h"#include"target_core_pr.h"#include"target_core_ua.h"#include"target_core_xcopy.h"staticvoidspc_fill_alua_data(structse_lun*lun,unsignedchar*buf){structt10_alua_tg_pt_gp*tg_pt_gp;/* * Set SCCS for MAINTENANCE_IN + REPORT_TARGET_PORT_GROUPS. */buf[5]=0x80;/* * Set TPGS field for explicit and/or implicit ALUA access type * and opteration. * * See spc4r17 section 6.4.2 Table 135 */spin_lock(&lun->lun_tg_pt_gp_lock);tg_pt_gp=lun->lun_tg_pt_gp;if(tg_pt_gp)buf[5]|=tg_pt_gp->tg_pt_gp_alua_access_type;spin_unlock(&lun->lun_tg_pt_gp_lock);}staticu16spc_find_scsi_transport_vd(intproto_id){switch(proto_id){caseSCSI_PROTOCOL_FCP:returnSCSI_VERSION_DESCRIPTOR_FCP4;caseSCSI_PROTOCOL_ISCSI:returnSCSI_VERSION_DESCRIPTOR_ISCSI;caseSCSI_PROTOCOL_SAS:returnSCSI_VERSION_DESCRIPTOR_SAS3;caseSCSI_PROTOCOL_SBP