9
9
#include <net/sock.h>
10
10
#include <net/tcp.h>
12
#define TARGET_CORE_MOD_VERSION "v4.0.0-rc7-ml"
13
#define SHUTDOWN_SIGS (sigmask(SIGKILL)|sigmask(SIGINT)|sigmask(SIGABRT))
12
#define TARGET_CORE_MOD_VERSION "v4.1.0-rc1-ml"
15
/* Used by transport_generic_allocate_iovecs() */
16
#define TRANSPORT_IOV_DATA_BUFFER 5
17
14
/* Maximum Number of LUNs per Target Portal Group */
15
/* Don't raise above 511 or REPORT_LUNS needs to handle >1 page */
18
16
#define TRANSPORT_MAX_LUNS_PER_TPG 256
20
18
* By default we use 32-byte CDBs in TCM Core and subsystem plugin code.
76
74
/* Used for generate timer flags */
77
enum timer_flags_table {
78
TF_REQUEST_STOP = (1 << 2),
82
81
/* Special transport agnostic struct se_cmd->t_states */
83
82
enum transport_state_table {
84
83
TRANSPORT_NO_STATE = 0,
85
84
TRANSPORT_NEW_CMD = 1,
86
TRANSPORT_DEFERRED_CMD = 2,
87
85
TRANSPORT_WRITE_PENDING = 3,
88
86
TRANSPORT_PROCESS_WRITE = 4,
89
87
TRANSPORT_PROCESSING = 5,
90
TRANSPORT_COMPLETE_OK = 6,
91
TRANSPORT_COMPLETE_FAILURE = 7,
92
TRANSPORT_COMPLETE_TIMEOUT = 8,
88
TRANSPORT_COMPLETE = 6,
93
89
TRANSPORT_PROCESS_TMR = 9,
94
TRANSPORT_TMR_COMPLETE = 10,
95
90
TRANSPORT_ISTATE_PROCESSING = 11,
96
TRANSPORT_ISTATE_PROCESSED = 12,
98
TRANSPORT_REMOVE = 14,
100
91
TRANSPORT_NEW_CMD_MAP = 16,
101
TRANSPORT_FREE_CMD_INTR = 17,
92
TRANSPORT_COMPLETE_QF_WP = 18,
93
TRANSPORT_COMPLETE_QF_OK = 19,
104
96
/* Used for struct se_cmd->se_cmd_flags */
108
100
SCF_EMULATED_TASK_SENSE = 0x00000004,
109
101
SCF_SCSI_DATA_SG_IO_CDB = 0x00000008,
110
102
SCF_SCSI_CONTROL_SG_IO_CDB = 0x00000010,
111
SCF_SCSI_CONTROL_NONSG_IO_CDB = 0x00000020,
112
103
SCF_SCSI_NON_DATA_CDB = 0x00000040,
113
104
SCF_SCSI_CDB_EXCEPTION = 0x00000080,
114
105
SCF_SCSI_RESERVATION_CONFLICT = 0x00000100,
115
SCF_CMD_PASSTHROUGH_NOALLOC = 0x00000200,
116
106
SCF_SE_CMD_FAILED = 0x00000400,
117
107
SCF_SE_LUN_CMD = 0x00000800,
118
108
SCF_SE_ALLOW_EOO = 0x00001000,
119
SCF_SE_DISABLE_ONLINE_CHECK = 0x00002000,
120
109
SCF_SENT_CHECK_CONDITION = 0x00004000,
121
110
SCF_OVERFLOW_BIT = 0x00008000,
122
111
SCF_UNDERFLOW_BIT = 0x00010000,
123
112
SCF_SENT_DELAYED_TAS = 0x00020000,
124
113
SCF_ALUA_NON_OPTIMIZED = 0x00040000,
125
114
SCF_DELAYED_CMD_FROM_SAM_ATTR = 0x00080000,
126
SCF_PASSTHROUGH_SG_TO_MEM = 0x00100000,
127
SCF_PASSTHROUGH_CONTIG_TO_SG = 0x00200000,
115
SCF_UNUSED = 0x00100000,
128
116
SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC = 0x00400000,
129
SCF_EMULATE_SYNC_CACHE = 0x00800000,
130
SCF_EMULATE_CDB_ASYNC = 0x01000000,
131
SCF_EMULATE_SYNC_UNMAP = 0x02000000
134
119
/* struct se_dev_entry->lun_flags and struct se_lun->lun_access */
408
388
wait_queue_head_t thread_wq;
409
389
} ____cacheline_aligned;
412
* Used one per struct se_cmd to hold all extra struct se_task
413
* metadata. This structure is setup and allocated in
414
* drivers/target/target_core_transport.c:__transport_alloc_se_cmd()
416
struct se_transport_task {
417
unsigned char *t_task_cdb;
418
unsigned char __t_task_cdb[TCM_MAX_COMMAND_SIZE];
419
unsigned long long t_task_lba;
428
u32 t_tasks_se_bidi_num;
429
u32 t_tasks_sg_chained_no;
432
atomic_t t_task_cdbs_left;
433
atomic_t t_task_cdbs_ex_left;
434
atomic_t t_task_cdbs_timeout_left;
435
atomic_t t_task_cdbs_sent;
436
atomic_t t_transport_aborted;
437
atomic_t t_transport_active;
438
atomic_t t_transport_complete;
439
atomic_t t_transport_queue_active;
440
atomic_t t_transport_sent;
441
atomic_t t_transport_stop;
442
atomic_t t_transport_timeout;
443
atomic_t transport_dev_active;
444
atomic_t transport_lun_active;
445
atomic_t transport_lun_fe_stop;
446
atomic_t transport_lun_stop;
447
spinlock_t t_state_lock;
448
struct completion t_transport_stop_comp;
449
struct completion transport_lun_fe_stop_comp;
450
struct completion transport_lun_stop_comp;
451
struct scatterlist *t_tasks_sg_chained;
452
struct scatterlist t_tasks_sg_bounce;
455
* Used for pre-registered fabric SGL passthrough WRITE and READ
456
* with the special SCF_PASSTHROUGH_CONTIG_TO_SG case for TCM_Loop
457
* and other HW target mode fabric modules.
459
struct scatterlist *t_task_pt_sgl;
460
struct list_head *t_mem_list;
461
/* Used for BIDI READ */
462
struct list_head *t_mem_bidi_list;
463
struct list_head t_task_list;
464
} ____cacheline_aligned;
467
unsigned char task_sense;
468
struct scatterlist *task_sg;
469
struct scatterlist *task_sg_bidi;
472
int task_error_status;
473
int task_state_flags;
475
392
unsigned long long task_lba;
395
struct se_cmd *task_se_cmd;
396
struct scatterlist *task_sg;
401
int task_error_status;
481
402
enum dma_data_direction task_data_direction;
482
struct se_cmd *task_se_cmd;
483
struct se_device *se_dev;
403
atomic_t task_state_active;
404
struct list_head t_list;
405
struct list_head t_execute_list;
406
struct list_head t_state_list;
484
407
struct completion task_stop_comp;
485
atomic_t task_active;
486
atomic_t task_execute_queue;
487
atomic_t task_timeout;
490
atomic_t task_state_active;
491
struct timer_list task_timer;
492
struct se_device *se_obj_ptr;
493
struct list_head t_list;
494
struct list_head t_execute_list;
495
struct list_head t_state_list;
496
408
} ____cacheline_aligned;
498
#define TASK_CMD(task) ((task)->task_se_cmd)
499
#define TASK_DEV(task) ((task)->se_dev)
502
411
/* SAM response code being sent to initiator */
529
439
/* Persistent Reservation key */
531
atomic_t transport_sent;
532
441
/* Used for sense data */
533
442
void *sense_buffer;
534
struct list_head se_delayed_list;
535
struct list_head se_ordered_list;
536
struct list_head se_lun_list;
443
struct list_head se_delayed_node;
444
struct list_head se_ordered_node;
445
struct list_head se_lun_node;
446
struct list_head se_qf_node;
537
447
struct se_device *se_dev;
538
448
struct se_dev_entry *se_deve;
539
449
struct se_device *se_obj_ptr;
542
452
/* Only used for internal passthrough and legacy TCM fabric modules */
543
453
struct se_session *se_sess;
544
454
struct se_tmr_req *se_tmr_req;
545
/* t_task is setup to t_task_backstore in transport_init_se_cmd() */
546
struct se_transport_task *t_task;
547
struct se_transport_task t_task_backstore;
455
struct list_head se_queue_node;
456
struct list_head se_cmd_list;
457
struct completion cmd_wait_comp;
548
458
struct target_core_fabric_ops *se_tfo;
549
int (*transport_emulate_cdb)(struct se_cmd *);
550
void (*transport_split_cdb)(unsigned long long, u32 *, unsigned char *);
551
void (*transport_wait_for_tasks)(struct se_cmd *, int, int);
459
int (*execute_task)(struct se_task *);
552
460
void (*transport_complete_callback)(struct se_cmd *);
462
unsigned char *t_task_cdb;
463
unsigned char __t_task_cdb[TCM_MAX_COMMAND_SIZE];
464
unsigned long long t_task_lba;
468
u32 t_tasks_sg_chained_no;
471
atomic_t t_task_cdbs_left;
472
atomic_t t_task_cdbs_ex_left;
473
atomic_t t_task_cdbs_sent;
474
atomic_t t_transport_aborted;
475
atomic_t t_transport_active;
476
atomic_t t_transport_complete;
477
atomic_t t_transport_queue_active;
478
atomic_t t_transport_sent;
479
atomic_t t_transport_stop;
480
atomic_t transport_dev_active;
481
atomic_t transport_lun_active;
482
atomic_t transport_lun_fe_stop;
483
atomic_t transport_lun_stop;
484
spinlock_t t_state_lock;
485
struct completion t_transport_stop_comp;
486
struct completion transport_lun_fe_stop_comp;
487
struct completion transport_lun_stop_comp;
488
struct scatterlist *t_tasks_sg_chained;
490
struct work_struct work;
493
* Used for pre-registered fabric SGL passthrough WRITE and READ
494
* with the special SCF_PASSTHROUGH_CONTIG_TO_SG case for TCM_Loop
495
* and other HW target mode fabric modules.
497
struct scatterlist *t_task_pt_sgl;
498
u32 t_task_pt_sgl_num;
500
struct scatterlist *t_data_sg;
501
unsigned int t_data_nents;
502
struct scatterlist *t_bidi_data_sg;
503
unsigned int t_bidi_data_nents;
505
/* Used for BIDI READ */
506
struct list_head t_task_list;
553
509
} ____cacheline_aligned;
555
#define T_TASK(cmd) ((cmd)->t_task)
556
#define CMD_TFO(cmd) ((cmd)->se_tfo)
558
511
struct se_tmr_req {
559
512
/* Task Management function to be preformed */
609
562
} ____cacheline_aligned;
611
564
struct se_session {
565
int sess_tearing_down:1;
612
566
u64 sess_bin_isid;
613
567
struct se_node_acl *se_node_acl;
614
568
struct se_portal_group *se_tpg;
615
569
void *fabric_sess_ptr;
616
570
struct list_head sess_list;
617
571
struct list_head sess_acl_list;
572
struct list_head sess_cmd_list;
573
struct list_head sess_wait_list;
574
spinlock_t sess_cmd_lock;
618
575
} ____cacheline_aligned;
620
#define SE_SESS(cmd) ((cmd)->se_sess)
621
#define SE_NODE_ACL(sess) ((sess)->se_node_acl)
623
577
struct se_device;
624
578
struct se_transform_info;
625
579
struct scatterlist;
727
680
/* T10 Inquiry and VPD WWN Information */
728
681
struct t10_wwn t10_wwn;
729
682
/* T10 SPC-2 + SPC-3 Reservations */
730
struct t10_reservation_template t10_reservation;
683
struct t10_reservation t10_pr;
731
684
spinlock_t se_dev_lock;
732
685
void *se_dev_su_ptr;
733
struct list_head g_se_dev_list;
686
struct list_head se_dev_node;
734
687
struct config_group se_dev_group;
735
688
/* For T10 Reservations */
736
689
struct config_group se_dev_pr_group;
780
728
atomic_t dev_status_thr_count;
781
729
atomic_t dev_hoq_count;
782
730
atomic_t dev_ordered_sync;
731
atomic_t dev_qf_count;
783
732
struct se_obj dev_obj;
784
733
struct se_obj dev_access_obj;
785
734
struct se_obj dev_export_obj;
786
struct se_queue_obj *dev_queue_obj;
787
struct se_queue_obj *dev_status_queue_obj;
735
struct se_queue_obj dev_queue_obj;
788
736
spinlock_t delayed_cmd_lock;
789
737
spinlock_t ordered_cmd_lock;
790
738
spinlock_t execute_task_lock;
809
758
struct task_struct *process_thread;
810
759
pid_t process_thread_pid;
811
760
struct task_struct *dev_mgmt_thread;
761
struct work_struct qf_work_queue;
812
762
struct list_head delayed_cmd_list;
813
763
struct list_head ordered_cmd_list;
814
764
struct list_head execute_task_list;
815
765
struct list_head state_task_list;
766
struct list_head qf_cmd_list;
816
767
/* Pointer to associated SE HBA */
817
768
struct se_hba *se_hba;
818
769
struct se_subsystem_dev *se_sub_dev;
837
783
/* Virtual iSCSI devices attached. */
840
atomic_t load_balance_queue;
841
atomic_t left_queue_depth;
842
/* Maximum queue depth the HBA can handle. */
843
atomic_t max_queue_depth;
844
786
/* Pointer to transport specific host structure. */
846
788
/* Linked list for struct se_device */
847
789
struct list_head hba_dev_list;
848
struct list_head hba_list;
790
struct list_head hba_node;
849
791
spinlock_t device_lock;
850
spinlock_t hba_queue_lock;
851
792
struct config_group hba_group;
852
793
struct mutex hba_access_mutex;
853
794
struct se_subsystem_api *transport;
854
795
} ____cacheline_aligned;
856
#define SE_HBA(dev) ((dev)->se_hba)
858
797
struct se_port_stat_grps {
859
798
struct config_group stat_group;
860
799
struct config_group scsi_port_group;
958
892
struct config_group fabric_stat_group;
959
893
} ____cacheline_aligned;
962
u16 alua_lu_gps_counter;
963
int g_sub_api_initialized;
965
u32 alua_lu_gps_count;
966
u32 g_hba_id_counter;
967
struct config_group target_core_hbagroup;
968
struct config_group alua_group;
969
struct config_group alua_lu_gps_group;
970
struct list_head g_lu_gps_list;
971
struct list_head g_se_tpg_list;
972
struct list_head g_hba_list;
973
struct list_head g_se_dev_list;
974
struct se_hba *g_lun0_hba;
975
struct se_subsystem_dev *g_lun0_su_dev;
976
struct se_device *g_lun0_dev;
977
struct t10_alua_lu_gp *default_lu_gp;
978
spinlock_t g_device_lock;
980
spinlock_t se_tpg_lock;
981
spinlock_t lu_gps_lock;
982
spinlock_t plugin_class_lock;
983
} ____cacheline_aligned;
985
895
#endif /* TARGET_CORE_BASE_H */