aboutsummaryrefslogtreecommitdiffstats
path: root/include/target/target_core_base.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/target/target_core_base.h')
-rw-r--r--include/target/target_core_base.h111
1 files changed, 32 insertions, 79 deletions
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index aaccc5f5fc9f..128ce46fa48a 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -73,9 +73,8 @@
73/* 73/*
74 * struct se_device->dev_flags 74 * struct se_device->dev_flags
75 */ 75 */
76#define DF_READ_ONLY 0x00000001 76#define DF_SPC2_RESERVATIONS 0x00000001
77#define DF_SPC2_RESERVATIONS 0x00000002 77#define DF_SPC2_RESERVATIONS_WITH_ISID 0x00000002
78#define DF_SPC2_RESERVATIONS_WITH_ISID 0x00000004
79 78
80/* struct se_dev_attrib sanity values */ 79/* struct se_dev_attrib sanity values */
81/* Default max_unmap_lba_count */ 80/* Default max_unmap_lba_count */
@@ -141,25 +140,14 @@ enum transport_tpg_type_table {
141 TRANSPORT_TPG_TYPE_DISCOVERY = 1, 140 TRANSPORT_TPG_TYPE_DISCOVERY = 1,
142}; 141};
143 142
144/* struct se_task->task_flags */
145enum se_task_flags {
146 TF_ACTIVE = (1 << 0),
147 TF_SENT = (1 << 1),
148 TF_REQUEST_STOP = (1 << 2),
149 TF_HAS_SENSE = (1 << 3),
150};
151
152/* Special transport agnostic struct se_cmd->t_states */ 143/* Special transport agnostic struct se_cmd->t_states */
153enum transport_state_table { 144enum transport_state_table {
154 TRANSPORT_NO_STATE = 0, 145 TRANSPORT_NO_STATE = 0,
155 TRANSPORT_NEW_CMD = 1, 146 TRANSPORT_NEW_CMD = 1,
156 TRANSPORT_WRITE_PENDING = 3, 147 TRANSPORT_WRITE_PENDING = 3,
157 TRANSPORT_PROCESS_WRITE = 4,
158 TRANSPORT_PROCESSING = 5, 148 TRANSPORT_PROCESSING = 5,
159 TRANSPORT_COMPLETE = 6, 149 TRANSPORT_COMPLETE = 6,
160 TRANSPORT_PROCESS_TMR = 9,
161 TRANSPORT_ISTATE_PROCESSING = 11, 150 TRANSPORT_ISTATE_PROCESSING = 11,
162 TRANSPORT_NEW_CMD_MAP = 16,
163 TRANSPORT_COMPLETE_QF_WP = 18, 151 TRANSPORT_COMPLETE_QF_WP = 18,
164 TRANSPORT_COMPLETE_QF_OK = 19, 152 TRANSPORT_COMPLETE_QF_OK = 19,
165}; 153};
@@ -169,25 +157,20 @@ enum se_cmd_flags_table {
169 SCF_SUPPORTED_SAM_OPCODE = 0x00000001, 157 SCF_SUPPORTED_SAM_OPCODE = 0x00000001,
170 SCF_TRANSPORT_TASK_SENSE = 0x00000002, 158 SCF_TRANSPORT_TASK_SENSE = 0x00000002,
171 SCF_EMULATED_TASK_SENSE = 0x00000004, 159 SCF_EMULATED_TASK_SENSE = 0x00000004,
172 SCF_SCSI_DATA_SG_IO_CDB = 0x00000008, 160 SCF_SCSI_DATA_CDB = 0x00000008,
173 SCF_SCSI_CONTROL_SG_IO_CDB = 0x00000010, 161 SCF_SCSI_TMR_CDB = 0x00000010,
174 SCF_SCSI_NON_DATA_CDB = 0x00000020, 162 SCF_SCSI_CDB_EXCEPTION = 0x00000020,
175 SCF_SCSI_TMR_CDB = 0x00000040, 163 SCF_SCSI_RESERVATION_CONFLICT = 0x00000040,
176 SCF_SCSI_CDB_EXCEPTION = 0x00000080, 164 SCF_FUA = 0x00000080,
177 SCF_SCSI_RESERVATION_CONFLICT = 0x00000100, 165 SCF_SE_LUN_CMD = 0x00000100,
178 SCF_FUA = 0x00000200, 166 SCF_BIDI = 0x00000400,
179 SCF_SE_LUN_CMD = 0x00000800, 167 SCF_SENT_CHECK_CONDITION = 0x00000800,
180 SCF_SE_ALLOW_EOO = 0x00001000, 168 SCF_OVERFLOW_BIT = 0x00001000,
181 SCF_BIDI = 0x00002000, 169 SCF_UNDERFLOW_BIT = 0x00002000,
182 SCF_SENT_CHECK_CONDITION = 0x00004000, 170 SCF_SENT_DELAYED_TAS = 0x00004000,
183 SCF_OVERFLOW_BIT = 0x00008000, 171 SCF_ALUA_NON_OPTIMIZED = 0x00008000,
184 SCF_UNDERFLOW_BIT = 0x00010000, 172 SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC = 0x00020000,
185 SCF_SENT_DELAYED_TAS = 0x00020000, 173 SCF_ACK_KREF = 0x00040000,
186 SCF_ALUA_NON_OPTIMIZED = 0x00040000,
187 SCF_DELAYED_CMD_FROM_SAM_ATTR = 0x00080000,
188 SCF_UNUSED = 0x00100000,
189 SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC = 0x00200000,
190 SCF_ACK_KREF = 0x00400000,
191}; 174};
192 175
193/* struct se_dev_entry->lun_flags and struct se_lun->lun_access */ 176/* struct se_dev_entry->lun_flags and struct se_lun->lun_access */
@@ -229,11 +212,13 @@ enum tcm_sense_reason_table {
229 TCM_CHECK_CONDITION_UNIT_ATTENTION = 0x0e, 212 TCM_CHECK_CONDITION_UNIT_ATTENTION = 0x0e,
230 TCM_CHECK_CONDITION_NOT_READY = 0x0f, 213 TCM_CHECK_CONDITION_NOT_READY = 0x0f,
231 TCM_RESERVATION_CONFLICT = 0x10, 214 TCM_RESERVATION_CONFLICT = 0x10,
215 TCM_ADDRESS_OUT_OF_RANGE = 0x11,
232}; 216};
233 217
234enum target_sc_flags_table { 218enum target_sc_flags_table {
235 TARGET_SCF_BIDI_OP = 0x01, 219 TARGET_SCF_BIDI_OP = 0x01,
236 TARGET_SCF_ACK_KREF = 0x02, 220 TARGET_SCF_ACK_KREF = 0x02,
221 TARGET_SCF_UNKNOWN_SIZE = 0x04,
237}; 222};
238 223
239/* fabric independent task management function values */ 224/* fabric independent task management function values */
@@ -338,6 +323,7 @@ struct t10_alua_tg_pt_gp {
338 int tg_pt_gp_alua_access_type; 323 int tg_pt_gp_alua_access_type;
339 int tg_pt_gp_nonop_delay_msecs; 324 int tg_pt_gp_nonop_delay_msecs;
340 int tg_pt_gp_trans_delay_msecs; 325 int tg_pt_gp_trans_delay_msecs;
326 int tg_pt_gp_implict_trans_secs;
341 int tg_pt_gp_pref; 327 int tg_pt_gp_pref;
342 int tg_pt_gp_write_metadata; 328 int tg_pt_gp_write_metadata;
343 /* Used by struct t10_alua_tg_pt_gp->tg_pt_gp_md_buf_len */ 329 /* Used by struct t10_alua_tg_pt_gp->tg_pt_gp_md_buf_len */
@@ -478,30 +464,6 @@ struct t10_reservation {
478 struct t10_reservation_ops pr_ops; 464 struct t10_reservation_ops pr_ops;
479}; 465};
480 466
481struct se_queue_obj {
482 atomic_t queue_cnt;
483 spinlock_t cmd_queue_lock;
484 struct list_head qobj_list;
485 wait_queue_head_t thread_wq;
486};
487
488struct se_task {
489 unsigned long long task_lba;
490 u32 task_sectors;
491 u32 task_size;
492 struct se_cmd *task_se_cmd;
493 struct scatterlist *task_sg;
494 u32 task_sg_nents;
495 u16 task_flags;
496 u8 task_scsi_status;
497 enum dma_data_direction task_data_direction;
498 struct list_head t_list;
499 struct list_head t_execute_list;
500 struct list_head t_state_list;
501 bool t_state_active;
502 struct completion task_stop_comp;
503};
504
505struct se_tmr_req { 467struct se_tmr_req {
506 /* Task Management function to be performed */ 468 /* Task Management function to be performed */
507 u8 function; 469 u8 function;
@@ -510,11 +472,8 @@ struct se_tmr_req {
510 int call_transport; 472 int call_transport;
511 /* Reference to ITT that Task Mgmt should be performed */ 473 /* Reference to ITT that Task Mgmt should be performed */
512 u32 ref_task_tag; 474 u32 ref_task_tag;
513 /* 64-bit encoded SAM LUN from $FABRIC_MOD TMR header */
514 u64 ref_task_lun;
515 void *fabric_tmr_ptr; 475 void *fabric_tmr_ptr;
516 struct se_cmd *task_cmd; 476 struct se_cmd *task_cmd;
517 struct se_cmd *ref_cmd;
518 struct se_device *tmr_dev; 477 struct se_device *tmr_dev;
519 struct se_lun *tmr_lun; 478 struct se_lun *tmr_lun;
520 struct list_head tmr_list; 479 struct list_head tmr_list;
@@ -538,6 +497,7 @@ struct se_cmd {
538 /* Used to signal cmd->se_tfo->check_release_cmd() usage per cmd */ 497 /* Used to signal cmd->se_tfo->check_release_cmd() usage per cmd */
539 unsigned check_release:1; 498 unsigned check_release:1;
540 unsigned cmd_wait_set:1; 499 unsigned cmd_wait_set:1;
500 unsigned unknown_data_length:1;
541 /* See se_cmd_flags_table */ 501 /* See se_cmd_flags_table */
542 u32 se_cmd_flags; 502 u32 se_cmd_flags;
543 u32 se_ordered_id; 503 u32 se_ordered_id;
@@ -560,23 +520,17 @@ struct se_cmd {
560 /* Only used for internal passthrough and legacy TCM fabric modules */ 520 /* Only used for internal passthrough and legacy TCM fabric modules */
561 struct se_session *se_sess; 521 struct se_session *se_sess;
562 struct se_tmr_req *se_tmr_req; 522 struct se_tmr_req *se_tmr_req;
563 struct list_head se_queue_node;
564 struct list_head se_cmd_list; 523 struct list_head se_cmd_list;
565 struct completion cmd_wait_comp; 524 struct completion cmd_wait_comp;
566 struct kref cmd_kref; 525 struct kref cmd_kref;
567 struct target_core_fabric_ops *se_tfo; 526 struct target_core_fabric_ops *se_tfo;
568 int (*execute_task)(struct se_task *); 527 int (*execute_cmd)(struct se_cmd *);
569 void (*transport_complete_callback)(struct se_cmd *); 528 void (*transport_complete_callback)(struct se_cmd *);
570 529
571 unsigned char *t_task_cdb; 530 unsigned char *t_task_cdb;
572 unsigned char __t_task_cdb[TCM_MAX_COMMAND_SIZE]; 531 unsigned char __t_task_cdb[TCM_MAX_COMMAND_SIZE];
573 unsigned long long t_task_lba; 532 unsigned long long t_task_lba;
574 u32 t_tasks_sg_chained_no;
575 atomic_t t_fe_count; 533 atomic_t t_fe_count;
576 atomic_t t_se_count;
577 atomic_t t_task_cdbs_left;
578 atomic_t t_task_cdbs_ex_left;
579 atomic_t t_task_cdbs_sent;
580 unsigned int transport_state; 534 unsigned int transport_state;
581#define CMD_T_ABORTED (1 << 0) 535#define CMD_T_ABORTED (1 << 0)
582#define CMD_T_ACTIVE (1 << 1) 536#define CMD_T_ACTIVE (1 << 1)
@@ -588,11 +542,12 @@ struct se_cmd {
588#define CMD_T_LUN_STOP (1 << 7) 542#define CMD_T_LUN_STOP (1 << 7)
589#define CMD_T_LUN_FE_STOP (1 << 8) 543#define CMD_T_LUN_FE_STOP (1 << 8)
590#define CMD_T_DEV_ACTIVE (1 << 9) 544#define CMD_T_DEV_ACTIVE (1 << 9)
545#define CMD_T_REQUEST_STOP (1 << 10)
546#define CMD_T_BUSY (1 << 11)
591 spinlock_t t_state_lock; 547 spinlock_t t_state_lock;
592 struct completion t_transport_stop_comp; 548 struct completion t_transport_stop_comp;
593 struct completion transport_lun_fe_stop_comp; 549 struct completion transport_lun_fe_stop_comp;
594 struct completion transport_lun_stop_comp; 550 struct completion transport_lun_stop_comp;
595 struct scatterlist *t_tasks_sg_chained;
596 551
597 struct work_struct work; 552 struct work_struct work;
598 553
@@ -602,10 +557,14 @@ struct se_cmd {
602 struct scatterlist *t_bidi_data_sg; 557 struct scatterlist *t_bidi_data_sg;
603 unsigned int t_bidi_data_nents; 558 unsigned int t_bidi_data_nents;
604 559
605 /* Used for BIDI READ */ 560 struct list_head state_list;
606 struct list_head t_task_list; 561 bool state_active;
607 u32 t_task_list_num; 562
563 /* old task stop completion, consider merging with some of the above */
564 struct completion task_stop_comp;
608 565
566 /* backend private data */
567 void *priv;
609}; 568};
610 569
611struct se_ua { 570struct se_ua {
@@ -655,7 +614,6 @@ struct se_session {
655 struct list_head sess_list; 614 struct list_head sess_list;
656 struct list_head sess_acl_list; 615 struct list_head sess_acl_list;
657 struct list_head sess_cmd_list; 616 struct list_head sess_cmd_list;
658 struct list_head sess_wait_list;
659 spinlock_t sess_cmd_lock; 617 spinlock_t sess_cmd_lock;
660 struct kref sess_kref; 618 struct kref sess_kref;
661}; 619};
@@ -731,7 +689,6 @@ struct se_dev_attrib {
731 u32 hw_block_size; 689 u32 hw_block_size;
732 u32 block_size; 690 u32 block_size;
733 u32 hw_max_sectors; 691 u32 hw_max_sectors;
734 u32 max_sectors;
735 u32 fabric_max_sectors; 692 u32 fabric_max_sectors;
736 u32 optimal_sectors; 693 u32 optimal_sectors;
737 u32 hw_queue_depth; 694 u32 hw_queue_depth;
@@ -803,13 +760,11 @@ struct se_device {
803 /* Active commands on this virtual SE device */ 760 /* Active commands on this virtual SE device */
804 atomic_t simple_cmds; 761 atomic_t simple_cmds;
805 atomic_t dev_ordered_id; 762 atomic_t dev_ordered_id;
806 atomic_t execute_tasks;
807 atomic_t dev_ordered_sync; 763 atomic_t dev_ordered_sync;
808 atomic_t dev_qf_count; 764 atomic_t dev_qf_count;
809 struct se_obj dev_obj; 765 struct se_obj dev_obj;
810 struct se_obj dev_access_obj; 766 struct se_obj dev_access_obj;
811 struct se_obj dev_export_obj; 767 struct se_obj dev_export_obj;
812 struct se_queue_obj dev_queue_obj;
813 spinlock_t delayed_cmd_lock; 768 spinlock_t delayed_cmd_lock;
814 spinlock_t execute_task_lock; 769 spinlock_t execute_task_lock;
815 spinlock_t dev_reservation_lock; 770 spinlock_t dev_reservation_lock;
@@ -825,12 +780,10 @@ struct se_device {
825 struct t10_pr_registration *dev_pr_res_holder; 780 struct t10_pr_registration *dev_pr_res_holder;
826 struct list_head dev_sep_list; 781 struct list_head dev_sep_list;
827 struct list_head dev_tmr_list; 782 struct list_head dev_tmr_list;
828 /* Pointer to descriptor for processing thread */ 783 struct workqueue_struct *tmr_wq;
829 struct task_struct *process_thread;
830 struct work_struct qf_work_queue; 784 struct work_struct qf_work_queue;
831 struct list_head delayed_cmd_list; 785 struct list_head delayed_cmd_list;
832 struct list_head execute_task_list; 786 struct list_head state_list;
833 struct list_head state_task_list;
834 struct list_head qf_cmd_list; 787 struct list_head qf_cmd_list;
835 /* Pointer to associated SE HBA */ 788 /* Pointer to associated SE HBA */
836 struct se_hba *se_hba; 789 struct se_hba *se_hba;