xref: /linux/drivers/target/target_core_xcopy.h (revision 8a922b7728a93d837954315c98b84f6b78de0c4f)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #include <target/target_core_base.h>
3 
4 #define XCOPY_HDR_LEN			16
5 #define XCOPY_TARGET_DESC_LEN		32
6 #define XCOPY_SEGMENT_DESC_LEN		28
7 #define XCOPY_NAA_IEEE_REGEX_LEN	16
8 #define XCOPY_MAX_BYTES			16777216 /* 16 MB */
9 
10 /*
11  * SPC4r37 6.4.6.1
12  * Table 150 — CSCD descriptor ID values
13  */
14 #define XCOPY_CSCD_DESC_ID_LIST_OFF_MAX	0x07FF
15 
16 enum xcopy_origin_list {
17 	XCOL_SOURCE_RECV_OP = 0x01,
18 	XCOL_DEST_RECV_OP = 0x02,
19 };
20 
21 struct xcopy_op {
22 	int op_origin;
23 
24 	struct se_cmd *xop_se_cmd;
25 	struct se_device *src_dev;
26 	unsigned char src_tid_wwn[XCOPY_NAA_IEEE_REGEX_LEN];
27 	struct se_device *dst_dev;
28 	unsigned char dst_tid_wwn[XCOPY_NAA_IEEE_REGEX_LEN];
29 	unsigned char local_dev_wwn[XCOPY_NAA_IEEE_REGEX_LEN];
30 	struct percpu_ref *remote_lun_ref;
31 
32 	sector_t src_lba;
33 	sector_t dst_lba;
34 	unsigned short stdi;
35 	unsigned short dtdi;
36 	unsigned short nolb;
37 
38 	u32 xop_data_bytes;
39 	u32 xop_data_nents;
40 	struct scatterlist *xop_data_sg;
41 	struct work_struct xop_work;
42 };
43 
44 /*
45  * Receive Copy Results Sevice Actions
46  */
47 #define RCR_SA_COPY_STATUS		0x00
48 #define RCR_SA_RECEIVE_DATA		0x01
49 #define RCR_SA_OPERATING_PARAMETERS	0x03
50 #define RCR_SA_FAILED_SEGMENT_DETAILS	0x04
51 
52 /*
53  * Receive Copy Results defs for Operating Parameters
54  */
55 #define RCR_OP_MAX_TARGET_DESC_COUNT	0x2
56 #define RCR_OP_MAX_SG_DESC_COUNT	0x1
57 #define RCR_OP_MAX_DESC_LIST_LEN	1024
58 #define RCR_OP_MAX_SEGMENT_LEN		268435456 /* 256 MB */
59 #define RCR_OP_TOTAL_CONCURR_COPIES	0x1 /* Must be <= 16384 */
60 #define RCR_OP_MAX_CONCURR_COPIES	0x1 /* Must be <= 255 */
61 #define RCR_OP_DATA_SEG_GRAN_LOG2	9 /* 512 bytes in log 2 */
62 #define RCR_OP_INLINE_DATA_GRAN_LOG2	9 /* 512 bytes in log 2 */
63 #define RCR_OP_HELD_DATA_GRAN_LOG2	9 /* 512 bytes in log 2 */
64 
65 extern int target_xcopy_setup_pt(void);
66 extern void target_xcopy_release_pt(void);
67 extern sense_reason_t target_do_xcopy(struct se_cmd *);
68 extern sense_reason_t target_do_receive_copy_results(struct se_cmd *);
69