1 #include <target/target_core_base.h>
2 #include <linux/btree.h>
3 
4 #define TCM_QLA2XXX_VERSION	"v0.1"
5 /* length of ASCII WWPNs including pad */
6 #define TCM_QLA2XXX_NAMELEN	32
7 /*
8  * Number of pre-allocated per-session tags, based upon the worst-case
9  * per port number of iocbs
10  */
11 #define TCM_QLA2XXX_DEFAULT_TAGS 2088
12 
13 #include "qla_target.h"
14 
15 struct tcm_qla2xxx_nacl {
16 	/* From libfc struct fc_rport->port_id */
17 	u32 nport_id;
18 	/* Binary World Wide unique Node Name for remote FC Initiator Nport */
19 	u64 nport_wwnn;
20 	/* ASCII formatted WWPN for FC Initiator Nport */
21 	char nport_name[TCM_QLA2XXX_NAMELEN];
22 	/* Pointer to qla_tgt_sess */
23 	struct qla_tgt_sess *qla_tgt_sess;
24 	/* Pointer to TCM FC nexus */
25 	struct se_session *nport_nexus;
26 	/* Returned by tcm_qla2xxx_make_nodeacl() */
27 	struct se_node_acl se_node_acl;
28 };
29 
30 struct tcm_qla2xxx_tpg_attrib {
31 	int generate_node_acls;
32 	int cache_dynamic_acls;
33 	int demo_mode_write_protect;
34 	int prod_mode_write_protect;
35 	int demo_mode_login_only;
36 };
37 
38 struct tcm_qla2xxx_tpg {
39 	/* FC lport target portal group tag for TCM */
40 	u16 lport_tpgt;
41 	/* Atomic bit to determine TPG active status */
42 	atomic_t lport_tpg_enabled;
43 	/* Pointer back to tcm_qla2xxx_lport */
44 	struct tcm_qla2xxx_lport *lport;
45 	/* Used by tcm_qla2xxx_tpg_attrib_cit */
46 	struct tcm_qla2xxx_tpg_attrib tpg_attrib;
47 	/* Returned by tcm_qla2xxx_make_tpg() */
48 	struct se_portal_group se_tpg;
49 	/* Items for dealing with configfs_depend_item */
50 	struct completion tpg_base_comp;
51 	struct work_struct tpg_base_work;
52 };
53 
54 struct tcm_qla2xxx_fc_loopid {
55 	struct se_node_acl *se_nacl;
56 };
57 
58 struct tcm_qla2xxx_lport {
59 	/* SCSI protocol the lport is providing */
60 	u8 lport_proto_id;
61 	/* Binary World Wide unique Port Name for FC Target Lport */
62 	u64 lport_wwpn;
63 	/* Binary World Wide unique Port Name for FC NPIV Target Lport */
64 	u64 lport_npiv_wwpn;
65 	/* Binary World Wide unique Node Name for FC NPIV Target Lport */
66 	u64 lport_npiv_wwnn;
67 	/* ASCII formatted WWPN for FC Target Lport */
68 	char lport_name[TCM_QLA2XXX_NAMELEN];
69 	/* ASCII formatted naa WWPN for VPD page 83 etc */
70 	char lport_naa_name[TCM_QLA2XXX_NAMELEN];
71 	/* map for fc_port pointers in 24-bit FC Port ID space */
72 	struct btree_head32 lport_fcport_map;
73 	/* vmalloc-ed memory for fc_port pointers for 16-bit FC loop ID */
74 	struct tcm_qla2xxx_fc_loopid *lport_loopid_map;
75 	/* Pointer to struct scsi_qla_host from qla2xxx LLD */
76 	struct scsi_qla_host *qla_vha;
77 	/* Pointer to struct qla_tgt pointer */
78 	struct qla_tgt lport_qla_tgt;
79 	/* Pointer to TPG=1 for non NPIV mode */
80 	struct tcm_qla2xxx_tpg *tpg_1;
81 	/* Returned by tcm_qla2xxx_make_lport() */
82 	struct se_wwn lport_wwn;
83 };
84