Skip to content

Commit ce65e5b

Browse files
author
Nicholas Bellinger
committed
target: Add DIF related base definitions
This patch adds DIF related definitions to target_core_base.h that includes enums for target_prot_op + target_prot_type + target_prot_version + target_guard_type + target_pi_error. Also included is struct se_dif_v1_tuple, along with changes to struct se_cmd, struct se_dev_attrib, and struct se_device. Also, add new se_subsystem_api->[init,format,free]_prot() callers used by target core code to setup backend specific protection information after the device has been configured. Enums taken from Sagi Grimberg's original patch. v2 changes: - Drop guard_type related definitions - Update target_prot_op + target_prot_ho definitions (Sagi) - Drop SCF_PROT + pi_prot_version flag - Add se_subsystem_api->format_prot() (Sagi) - Add hw_pi_prot_type device attribute Cc: Martin K. Petersen <martin.petersen@oracle.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Hannes Reinecke <hare@suse.de> Cc: Sagi Grimberg <sagig@mellanox.com> Cc: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
1 parent f82f320 commit ce65e5b

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

‎include/target/target_core_backend.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ struct se_subsystem_api {
4141
unsigned int (*get_io_opt)(struct se_device *);
4242
unsigned char *(*get_sense_buffer)(struct se_cmd *);
4343
bool (*get_write_cache)(struct se_device *);
44+
int (*init_prot)(struct se_device *);
45+
int (*format_prot)(struct se_device *);
46+
void (*free_prot)(struct se_device *);
4447
};
4548

4649
struct sbc_ops {

‎include/target/target_core_base.h‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,34 @@ struct se_tmr_req {
435435
struct list_head tmr_list;
436436
};
437437

438+
enum target_prot_op {
439+
TARGET_PROT_NORMAL = 0,
440+
TARGET_PROT_DIN_INSERT,
441+
TARGET_PROT_DOUT_INSERT,
442+
TARGET_PROT_DIN_STRIP,
443+
TARGET_PROT_DOUT_STRIP,
444+
TARGET_PROT_DIN_PASS,
445+
TARGET_PROT_DOUT_PASS,
446+
};
447+
448+
enum target_prot_ho {
449+
PROT_SEPERATED,
450+
PROT_INTERLEAVED,
451+
};
452+
453+
enum target_prot_type {
454+
TARGET_DIF_TYPE0_PROT,
455+
TARGET_DIF_TYPE1_PROT,
456+
TARGET_DIF_TYPE2_PROT,
457+
TARGET_DIF_TYPE3_PROT,
458+
};
459+
460+
struct se_dif_v1_tuple {
461+
__be16 guard_tag;
462+
__be16 app_tag;
463+
__be32 ref_tag;
464+
};
465+
438466
struct se_cmd {
439467
/* SAM response code being sent to initiator */
440468
u8 scsi_status;
@@ -519,6 +547,17 @@ struct se_cmd {
519547

520548
/* Used for lun->lun_ref counting */
521549
bool lun_ref_active;
550+
551+
/* DIF related members */
552+
enum target_prot_op prot_op;
553+
enum target_prot_type prot_type;
554+
u32 prot_length;
555+
u32 reftag_seed;
556+
struct scatterlist *t_prot_sg;
557+
unsigned int t_prot_nents;
558+
enum target_prot_ho prot_handover;
559+
sense_reason_t pi_err;
560+
u32 block_num;
522561
};
523562

524563
struct se_ua {
@@ -629,6 +668,9 @@ struct se_dev_attrib {
629668
int emulate_tpws;
630669
int emulate_caw;
631670
int emulate_3pc;
671+
int pi_prot_format;
672+
enum target_prot_type pi_prot_type;
673+
enum target_prot_type hw_pi_prot_type;
632674
int enforce_pr_isids;
633675
int is_nonrot;
634676
int emulate_rest_reord;
@@ -759,6 +801,8 @@ struct se_device {
759801
/* Linked list for struct se_hba struct se_device list */
760802
struct list_head dev_list;
761803
struct se_lun xcopy_lun;
804+
/* Protection Information */
805+
int prot_length;
762806
};
763807

764808
struct se_hba {

0 commit comments

Comments
 (0)