xref: /linux/drivers/target/loopback/tcm_loop.h (revision 1130b499)
1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
28dcf07beSBart Van Assche #include <linux/types.h>
38dcf07beSBart Van Assche #include <linux/device.h>
48dcf07beSBart Van Assche #include <target/target_core_base.h> /* struct se_cmd */
58dcf07beSBart Van Assche 
69765b1f3SNicholas Bellinger #define TCM_LOOP_VERSION		"v2.1-rc2"
73703b2c5SNicholas Bellinger #define TL_WWN_ADDR_LEN			256
83703b2c5SNicholas Bellinger #define TL_TPGS_PER_HBA			32
92e88efd3SChristoph Hellwig 
103703b2c5SNicholas Bellinger struct tcm_loop_cmd {
113703b2c5SNicholas Bellinger 	/* State of Linux/SCSI CDB+Data descriptor */
123703b2c5SNicholas Bellinger 	u32 sc_cmd_state;
13969871cdSHannes Reinecke 	/* Tagged command queueing */
14969871cdSHannes Reinecke 	u32 sc_cmd_tag;
153703b2c5SNicholas Bellinger 	/* Pointer to the CDB+Data descriptor from Linux/SCSI subsystem */
163703b2c5SNicholas Bellinger 	struct scsi_cmnd *sc;
173703b2c5SNicholas Bellinger 	/* The TCM I/O descriptor that is accessed via container_of() */
183703b2c5SNicholas Bellinger 	struct se_cmd tl_se_cmd;
19d17203c4SBart Van Assche 	struct completion tmr_done;
204d3895d5SBart Van Assche 	/* Sense buffer that will be mapped into outgoing status */
214d3895d5SBart Van Assche 	unsigned char tl_sense_buf[TRANSPORT_SENSE_BUFFER];
223703b2c5SNicholas Bellinger };
233703b2c5SNicholas Bellinger 
243703b2c5SNicholas Bellinger struct tcm_loop_nexus {
253703b2c5SNicholas Bellinger 	/*
263703b2c5SNicholas Bellinger 	 * Pointer to TCM session for I_T Nexus
273703b2c5SNicholas Bellinger 	 */
283703b2c5SNicholas Bellinger 	struct se_session *se_sess;
293703b2c5SNicholas Bellinger };
303703b2c5SNicholas Bellinger 
31fb2b2844SHannes Reinecke #define TCM_TRANSPORT_ONLINE 0
32fb2b2844SHannes Reinecke #define TCM_TRANSPORT_OFFLINE 1
33fb2b2844SHannes Reinecke 
343703b2c5SNicholas Bellinger struct tcm_loop_tpg {
353703b2c5SNicholas Bellinger 	unsigned short tl_tpgt;
36fb2b2844SHannes Reinecke 	unsigned short tl_transport_status;
37436f4a0aSNicholas Bellinger 	enum target_prot_type tl_fabric_prot_type;
383703b2c5SNicholas Bellinger 	atomic_t tl_tpg_port_count;
393703b2c5SNicholas Bellinger 	struct se_portal_group tl_se_tpg;
403703b2c5SNicholas Bellinger 	struct tcm_loop_hba *tl_hba;
41506787a2SHannes Reinecke 	struct tcm_loop_nexus *tl_nexus;
423703b2c5SNicholas Bellinger };
433703b2c5SNicholas Bellinger 
443703b2c5SNicholas Bellinger struct tcm_loop_hba {
453703b2c5SNicholas Bellinger 	u8 tl_proto_id;
463703b2c5SNicholas Bellinger 	unsigned char tl_wwn_address[TL_WWN_ADDR_LEN];
473703b2c5SNicholas Bellinger 	struct se_hba_s *se_hba;
483703b2c5SNicholas Bellinger 	struct se_lun *tl_hba_lun;
493703b2c5SNicholas Bellinger 	struct se_port *tl_hba_lun_sep;
503703b2c5SNicholas Bellinger 	struct device dev;
513703b2c5SNicholas Bellinger 	struct Scsi_Host *sh;
523703b2c5SNicholas Bellinger 	struct tcm_loop_tpg tl_hba_tpgs[TL_TPGS_PER_HBA];
533703b2c5SNicholas Bellinger 	struct se_wwn tl_hba_wwn;
543703b2c5SNicholas Bellinger };
55