175f8c1f6SNicholas Bellinger #include <target/target_core_base.h>
275f8c1f6SNicholas Bellinger #include <linux/btree.h>
375f8c1f6SNicholas Bellinger 
475f8c1f6SNicholas Bellinger #define TCM_QLA2XXX_VERSION	"v0.1"
575f8c1f6SNicholas Bellinger /* length of ASCII WWPNs including pad */
675f8c1f6SNicholas Bellinger #define TCM_QLA2XXX_NAMELEN	32
775f8c1f6SNicholas Bellinger /* lenth of ASCII NPIV 'WWPN+WWNN' including pad */
875f8c1f6SNicholas Bellinger #define TCM_QLA2XXX_NPIV_NAMELEN 66
975f8c1f6SNicholas Bellinger 
1075f8c1f6SNicholas Bellinger #include "qla_target.h"
1175f8c1f6SNicholas Bellinger 
1275f8c1f6SNicholas Bellinger struct tcm_qla2xxx_nacl {
1375f8c1f6SNicholas Bellinger 	/* From libfc struct fc_rport->port_id */
1475f8c1f6SNicholas Bellinger 	u32 nport_id;
1575f8c1f6SNicholas Bellinger 	/* Binary World Wide unique Node Name for remote FC Initiator Nport */
1675f8c1f6SNicholas Bellinger 	u64 nport_wwnn;
1775f8c1f6SNicholas Bellinger 	/* ASCII formatted WWPN for FC Initiator Nport */
1875f8c1f6SNicholas Bellinger 	char nport_name[TCM_QLA2XXX_NAMELEN];
1975f8c1f6SNicholas Bellinger 	/* Pointer to qla_tgt_sess */
2075f8c1f6SNicholas Bellinger 	struct qla_tgt_sess *qla_tgt_sess;
2175f8c1f6SNicholas Bellinger 	/* Pointer to TCM FC nexus */
2275f8c1f6SNicholas Bellinger 	struct se_session *nport_nexus;
2375f8c1f6SNicholas Bellinger 	/* Returned by tcm_qla2xxx_make_nodeacl() */
2475f8c1f6SNicholas Bellinger 	struct se_node_acl se_node_acl;
2575f8c1f6SNicholas Bellinger };
2675f8c1f6SNicholas Bellinger 
2775f8c1f6SNicholas Bellinger struct tcm_qla2xxx_tpg_attrib {
2875f8c1f6SNicholas Bellinger 	int generate_node_acls;
2975f8c1f6SNicholas Bellinger 	int cache_dynamic_acls;
3075f8c1f6SNicholas Bellinger 	int demo_mode_write_protect;
3175f8c1f6SNicholas Bellinger 	int prod_mode_write_protect;
3275f8c1f6SNicholas Bellinger };
3375f8c1f6SNicholas Bellinger 
3475f8c1f6SNicholas Bellinger struct tcm_qla2xxx_tpg {
3575f8c1f6SNicholas Bellinger 	/* FC lport target portal group tag for TCM */
3675f8c1f6SNicholas Bellinger 	u16 lport_tpgt;
3775f8c1f6SNicholas Bellinger 	/* Atomic bit to determine TPG active status */
3875f8c1f6SNicholas Bellinger 	atomic_t lport_tpg_enabled;
3975f8c1f6SNicholas Bellinger 	/* Pointer back to tcm_qla2xxx_lport */
4075f8c1f6SNicholas Bellinger 	struct tcm_qla2xxx_lport *lport;
4175f8c1f6SNicholas Bellinger 	/* Used by tcm_qla2xxx_tpg_attrib_cit */
4275f8c1f6SNicholas Bellinger 	struct tcm_qla2xxx_tpg_attrib tpg_attrib;
4375f8c1f6SNicholas Bellinger 	/* Returned by tcm_qla2xxx_make_tpg() */
4475f8c1f6SNicholas Bellinger 	struct se_portal_group se_tpg;
4575f8c1f6SNicholas Bellinger };
4675f8c1f6SNicholas Bellinger 
4775f8c1f6SNicholas Bellinger #define QLA_TPG_ATTRIB(tpg)	(&(tpg)->tpg_attrib)
4875f8c1f6SNicholas Bellinger 
4975f8c1f6SNicholas Bellinger struct tcm_qla2xxx_fc_loopid {
5075f8c1f6SNicholas Bellinger 	struct se_node_acl *se_nacl;
5175f8c1f6SNicholas Bellinger };
5275f8c1f6SNicholas Bellinger 
5375f8c1f6SNicholas Bellinger struct tcm_qla2xxx_lport {
5475f8c1f6SNicholas Bellinger 	/* SCSI protocol the lport is providing */
5575f8c1f6SNicholas Bellinger 	u8 lport_proto_id;
5675f8c1f6SNicholas Bellinger 	/* Binary World Wide unique Port Name for FC Target Lport */
5775f8c1f6SNicholas Bellinger 	u64 lport_wwpn;
5875f8c1f6SNicholas Bellinger 	/* Binary World Wide unique Port Name for FC NPIV Target Lport */
5975f8c1f6SNicholas Bellinger 	u64 lport_npiv_wwpn;
6075f8c1f6SNicholas Bellinger 	/* Binary World Wide unique Node Name for FC NPIV Target Lport */
6175f8c1f6SNicholas Bellinger 	u64 lport_npiv_wwnn;
6275f8c1f6SNicholas Bellinger 	/* ASCII formatted WWPN for FC Target Lport */
6375f8c1f6SNicholas Bellinger 	char lport_name[TCM_QLA2XXX_NAMELEN];
6475f8c1f6SNicholas Bellinger 	/* ASCII formatted WWPN+WWNN for NPIV FC Target Lport */
6575f8c1f6SNicholas Bellinger 	char lport_npiv_name[TCM_QLA2XXX_NPIV_NAMELEN];
6675f8c1f6SNicholas Bellinger 	/* map for fc_port pointers in 24-bit FC Port ID space */
6775f8c1f6SNicholas Bellinger 	struct btree_head32 lport_fcport_map;
6875f8c1f6SNicholas Bellinger 	/* vmalloc-ed memory for fc_port pointers for 16-bit FC loop ID */
6975f8c1f6SNicholas Bellinger 	struct tcm_qla2xxx_fc_loopid *lport_loopid_map;
7075f8c1f6SNicholas Bellinger 	/* Pointer to struct scsi_qla_host from qla2xxx LLD */
7175f8c1f6SNicholas Bellinger 	struct scsi_qla_host *qla_vha;
7275f8c1f6SNicholas Bellinger 	/* Pointer to struct scsi_qla_host for NPIV VP from qla2xxx LLD */
7375f8c1f6SNicholas Bellinger 	struct scsi_qla_host *qla_npiv_vp;
7475f8c1f6SNicholas Bellinger 	/* Pointer to struct qla_tgt pointer */
7575f8c1f6SNicholas Bellinger 	struct qla_tgt lport_qla_tgt;
7675f8c1f6SNicholas Bellinger 	/* Pointer to struct fc_vport for NPIV vport from libfc */
7775f8c1f6SNicholas Bellinger 	struct fc_vport *npiv_vport;
7875f8c1f6SNicholas Bellinger 	/* Pointer to TPG=1 for non NPIV mode */
7975f8c1f6SNicholas Bellinger 	struct tcm_qla2xxx_tpg *tpg_1;
8075f8c1f6SNicholas Bellinger 	/* Returned by tcm_qla2xxx_make_lport() */
8175f8c1f6SNicholas Bellinger 	struct se_wwn lport_wwn;
8275f8c1f6SNicholas Bellinger };
83