2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-23 20:53:53 +08:00
linux-next/drivers/target/target_core_xcopy.h

63 lines
1.7 KiB
C
Raw Normal View History

target: Add support for EXTENDED_COPY copy offload emulation This patch adds support for EXTENDED_COPY emulation from SPC-3, that enables full copy offload target support within both a single virtual backend device, and across multiple virtual backend devices. It also functions independent of target fabric, and supports copy offload across multiple target fabric ports. This implemenation supports both EXTENDED_COPY PUSH and PULL models of operation, so the actual CDB may be received on either source or desination logical unit. For Target Descriptors, it currently supports the NAA IEEE Registered Extended designator (type 0xe4), which allows the reference of target ports to occur independent of fabric type using EVPD 0x83 WWNs. For Segment Descriptors, it currently supports copy from block to block (0x02) mode. It also honors any present SCSI reservations of the destination target port. Note that only Supports No List Identifier (SNLID=1) mode is supported. Also included is basic RECEIVE_COPY_RESULTS with service action type OPERATING PARAMETERS (0x03) required for SNLID=1 operation. v3 changes: - Fix incorrect return type in target_do_receive_copy_results() (Fengguang) v2 changes: - Use target_alloc_sgl() instead of transport_generic_get_mem() - Convert debug output to use pr_debug() - Convert target_xcopy_parse_target_descriptors() NAA IEEN WWN dump to use 0x%16phN format specification - Drop unnecessary xcopy_pt_cmd->xpt_passthrough_wsem, and associated usage in xcopy_pt_write_pending() and target_xcopy_issue_pt_cmd() - Add check for unsupported EXTENDED_COPY(LID4) service action bits in target_do_xcopy() Cc: Christoph Hellwig <hch@lst.de> Cc: Hannes Reinecke <hare@suse.de> Cc: Martin Petersen <martin.petersen@oracle.com> Cc: Chris Mason <chris.mason@fusionio.com> Cc: Roland Dreier <roland@purestorage.com> Cc: Zach Brown <zab@redhat.com> Cc: James Bottomley <JBottomley@Parallels.com> Cc: Nicholas Bellinger <nab@linux-iscsi.org> Signed-off-by: Nicholas Bellinger <nab@daterainc.com>
2013-08-21 06:38:55 +08:00
#define XCOPY_TARGET_DESC_LEN 32
#define XCOPY_SEGMENT_DESC_LEN 28
#define XCOPY_NAA_IEEE_REGEX_LEN 16
#define XCOPY_MAX_SECTORS 1024
enum xcopy_origin_list {
XCOL_SOURCE_RECV_OP = 0x01,
XCOL_DEST_RECV_OP = 0x02,
};
struct xcopy_pt_cmd;
struct xcopy_op {
int op_origin;
struct se_cmd *xop_se_cmd;
struct se_device *src_dev;
unsigned char src_tid_wwn[XCOPY_NAA_IEEE_REGEX_LEN];
struct se_device *dst_dev;
unsigned char dst_tid_wwn[XCOPY_NAA_IEEE_REGEX_LEN];
unsigned char local_dev_wwn[XCOPY_NAA_IEEE_REGEX_LEN];
sector_t src_lba;
sector_t dst_lba;
unsigned short stdi;
unsigned short dtdi;
unsigned short nolb;
unsigned int dbl;
struct xcopy_pt_cmd *src_pt_cmd;
struct xcopy_pt_cmd *dst_pt_cmd;
u32 xop_data_nents;
struct scatterlist *xop_data_sg;
struct work_struct xop_work;
};
/*
* Receive Copy Results Sevice Actions
*/
#define RCR_SA_COPY_STATUS 0x00
#define RCR_SA_RECEIVE_DATA 0x01
#define RCR_SA_OPERATING_PARAMETERS 0x03
#define RCR_SA_FAILED_SEGMENT_DETAILS 0x04
/*
* Receive Copy Results defs for Operating Parameters
*/
#define RCR_OP_MAX_TARGET_DESC_COUNT 0x2
#define RCR_OP_MAX_SG_DESC_COUNT 0x1
#define RCR_OP_MAX_DESC_LIST_LEN 1024
#define RCR_OP_MAX_SEGMENT_LEN 268435456 /* 256 MB */
#define RCR_OP_TOTAL_CONCURR_COPIES 0x1 /* Must be <= 16384 */
#define RCR_OP_MAX_CONCURR_COPIES 0x1 /* Must be <= 255 */
#define RCR_OP_DATA_SEG_GRAN_LOG2 9 /* 512 bytes in log 2 */
#define RCR_OP_INLINE_DATA_GRAN_LOG2 9 /* 512 bytes in log 2 */
#define RCR_OP_HELD_DATA_GRAN_LOG2 9 /* 512 bytes in log 2 */
extern int target_xcopy_setup_pt(void);
extern void target_xcopy_release_pt(void);
extern sense_reason_t target_do_xcopy(struct se_cmd *);
extern sense_reason_t target_do_receive_copy_results(struct se_cmd *);