1 /* SPDX-License-Identifier: GPL-2.0 */
2 #include <linux/types.h>
3 #include <linux/device.h>
4 #include <target/target_core_base.h> /* struct se_cmd */
5 
6 #define TCM_LOOP_VERSION		"v2.1-rc2"
7 #define TL_WWN_ADDR_LEN			256
8 #define TL_TPGS_PER_HBA			32
9 
10 struct tcm_loop_cmd {
11 	/* State of Linux/SCSI CDB+Data descriptor */
12 	u32 sc_cmd_state;
13 	/* Tagged command queueing */
14 	u32 sc_cmd_tag;
15 	/* Pointer to the CDB+Data descriptor from Linux/SCSI subsystem */
16 	struct scsi_cmnd *sc;
17 	/* The TCM I/O descriptor that is accessed via container_of() */
18 	struct se_cmd tl_se_cmd;
19 	struct work_struct work;
20 	struct completion tmr_done;
21 	/* Sense buffer that will be mapped into outgoing status */
22 	unsigned char tl_sense_buf[TRANSPORT_SENSE_BUFFER];
23 };
24 
25 struct tcm_loop_nexus {
26 	/*
27 	 * Pointer to TCM session for I_T Nexus
28 	 */
29 	struct se_session *se_sess;
30 };
31 
32 #define TCM_TRANSPORT_ONLINE 0
33 #define TCM_TRANSPORT_OFFLINE 1
34 
35 struct tcm_loop_tpg {
36 	unsigned short tl_tpgt;
37 	unsigned short tl_transport_status;
38 	enum target_prot_type tl_fabric_prot_type;
39 	atomic_t tl_tpg_port_count;
40 	struct se_portal_group tl_se_tpg;
41 	struct tcm_loop_hba *tl_hba;
42 	struct tcm_loop_nexus *tl_nexus;
43 };
44 
45 struct tcm_loop_hba {
46 	u8 tl_proto_id;
47 	unsigned char tl_wwn_address[TL_WWN_ADDR_LEN];
48 	struct se_hba_s *se_hba;
49 	struct se_lun *tl_hba_lun;
50 	struct se_port *tl_hba_lun_sep;
51 	struct device dev;
52 	struct Scsi_Host *sh;
53 	struct tcm_loop_tpg tl_hba_tpgs[TL_TPGS_PER_HBA];
54 	struct se_wwn tl_hba_wwn;
55 };
56