xref: /openbmc/linux/drivers/target/loopback/tcm_loop.h (revision 3703b2c5d041a68095cdd22380c23ce27d449ad7)
1*3703b2c5SNicholas Bellinger #define TCM_LOOP_VERSION		"v2.1-rc1"
2*3703b2c5SNicholas Bellinger #define TL_WWN_ADDR_LEN			256
3*3703b2c5SNicholas Bellinger #define TL_TPGS_PER_HBA			32
4*3703b2c5SNicholas Bellinger /*
5*3703b2c5SNicholas Bellinger  * Defaults for struct scsi_host_template tcm_loop_driver_template
6*3703b2c5SNicholas Bellinger  *
7*3703b2c5SNicholas Bellinger  * We use large can_queue and cmd_per_lun here and let TCM enforce
8*3703b2c5SNicholas Bellinger  * the underlying se_device_t->queue_depth.
9*3703b2c5SNicholas Bellinger  */
10*3703b2c5SNicholas Bellinger #define TL_SCSI_CAN_QUEUE		1024
11*3703b2c5SNicholas Bellinger #define TL_SCSI_CMD_PER_LUN		1024
12*3703b2c5SNicholas Bellinger #define TL_SCSI_MAX_SECTORS		1024
13*3703b2c5SNicholas Bellinger #define TL_SCSI_SG_TABLESIZE		256
14*3703b2c5SNicholas Bellinger /*
15*3703b2c5SNicholas Bellinger  * Used in tcm_loop_driver_probe() for struct Scsi_Host->max_cmd_len
16*3703b2c5SNicholas Bellinger  */
17*3703b2c5SNicholas Bellinger #define TL_SCSI_MAX_CMD_LEN		32
18*3703b2c5SNicholas Bellinger 
19*3703b2c5SNicholas Bellinger #ifdef CONFIG_LOOPBACK_TARGET_CDB_DEBUG
20*3703b2c5SNicholas Bellinger # define TL_CDB_DEBUG(x...)		printk(KERN_INFO x)
21*3703b2c5SNicholas Bellinger #else
22*3703b2c5SNicholas Bellinger # define TL_CDB_DEBUG(x...)
23*3703b2c5SNicholas Bellinger #endif
24*3703b2c5SNicholas Bellinger 
25*3703b2c5SNicholas Bellinger struct tcm_loop_cmd {
26*3703b2c5SNicholas Bellinger 	/* State of Linux/SCSI CDB+Data descriptor */
27*3703b2c5SNicholas Bellinger 	u32 sc_cmd_state;
28*3703b2c5SNicholas Bellinger 	/* Pointer to the CDB+Data descriptor from Linux/SCSI subsystem */
29*3703b2c5SNicholas Bellinger 	struct scsi_cmnd *sc;
30*3703b2c5SNicholas Bellinger 	struct list_head *tl_cmd_list;
31*3703b2c5SNicholas Bellinger 	/* The TCM I/O descriptor that is accessed via container_of() */
32*3703b2c5SNicholas Bellinger 	struct se_cmd tl_se_cmd;
33*3703b2c5SNicholas Bellinger 	/* Sense buffer that will be mapped into outgoing status */
34*3703b2c5SNicholas Bellinger 	unsigned char tl_sense_buf[TRANSPORT_SENSE_BUFFER];
35*3703b2c5SNicholas Bellinger };
36*3703b2c5SNicholas Bellinger 
37*3703b2c5SNicholas Bellinger struct tcm_loop_tmr {
38*3703b2c5SNicholas Bellinger 	atomic_t tmr_complete;
39*3703b2c5SNicholas Bellinger 	wait_queue_head_t tl_tmr_wait;
40*3703b2c5SNicholas Bellinger };
41*3703b2c5SNicholas Bellinger 
42*3703b2c5SNicholas Bellinger struct tcm_loop_nexus {
43*3703b2c5SNicholas Bellinger 	int it_nexus_active;
44*3703b2c5SNicholas Bellinger 	/*
45*3703b2c5SNicholas Bellinger 	 * Pointer to Linux/SCSI HBA from linux/include/scsi_host.h
46*3703b2c5SNicholas Bellinger 	 */
47*3703b2c5SNicholas Bellinger 	struct scsi_host *sh;
48*3703b2c5SNicholas Bellinger 	/*
49*3703b2c5SNicholas Bellinger 	 * Pointer to TCM session for I_T Nexus
50*3703b2c5SNicholas Bellinger 	 */
51*3703b2c5SNicholas Bellinger 	struct se_session *se_sess;
52*3703b2c5SNicholas Bellinger };
53*3703b2c5SNicholas Bellinger 
54*3703b2c5SNicholas Bellinger struct tcm_loop_nacl {
55*3703b2c5SNicholas Bellinger 	struct se_node_acl se_node_acl;
56*3703b2c5SNicholas Bellinger };
57*3703b2c5SNicholas Bellinger 
58*3703b2c5SNicholas Bellinger struct tcm_loop_tpg {
59*3703b2c5SNicholas Bellinger 	unsigned short tl_tpgt;
60*3703b2c5SNicholas Bellinger 	atomic_t tl_tpg_port_count;
61*3703b2c5SNicholas Bellinger 	struct se_portal_group tl_se_tpg;
62*3703b2c5SNicholas Bellinger 	struct tcm_loop_hba *tl_hba;
63*3703b2c5SNicholas Bellinger };
64*3703b2c5SNicholas Bellinger 
65*3703b2c5SNicholas Bellinger struct tcm_loop_hba {
66*3703b2c5SNicholas Bellinger 	u8 tl_proto_id;
67*3703b2c5SNicholas Bellinger 	unsigned char tl_wwn_address[TL_WWN_ADDR_LEN];
68*3703b2c5SNicholas Bellinger 	struct se_hba_s *se_hba;
69*3703b2c5SNicholas Bellinger 	struct se_lun *tl_hba_lun;
70*3703b2c5SNicholas Bellinger 	struct se_port *tl_hba_lun_sep;
71*3703b2c5SNicholas Bellinger 	struct se_device_s *se_dev_hba_ptr;
72*3703b2c5SNicholas Bellinger 	struct tcm_loop_nexus *tl_nexus;
73*3703b2c5SNicholas Bellinger 	struct device dev;
74*3703b2c5SNicholas Bellinger 	struct Scsi_Host *sh;
75*3703b2c5SNicholas Bellinger 	struct tcm_loop_tpg tl_hba_tpgs[TL_TPGS_PER_HBA];
76*3703b2c5SNicholas Bellinger 	struct se_wwn tl_hba_wwn;
77*3703b2c5SNicholas Bellinger };
78