xref: /linux/drivers/scsi/qla2xxx/tcm_qla2xxx.h (revision b889fcf63cb62e7fdb7816565e28f44dbe4a76a5)
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 /* lenth of ASCII NPIV 'WWPN+WWNN' including pad */
8 #define TCM_QLA2XXX_NPIV_NAMELEN 66
9 
10 #include "qla_target.h"
11 
12 struct tcm_qla2xxx_nacl {
13 	/* From libfc struct fc_rport->port_id */
14 	u32 nport_id;
15 	/* Binary World Wide unique Node Name for remote FC Initiator Nport */
16 	u64 nport_wwnn;
17 	/* ASCII formatted WWPN for FC Initiator Nport */
18 	char nport_name[TCM_QLA2XXX_NAMELEN];
19 	/* Pointer to qla_tgt_sess */
20 	struct qla_tgt_sess *qla_tgt_sess;
21 	/* Pointer to TCM FC nexus */
22 	struct se_session *nport_nexus;
23 	/* Returned by tcm_qla2xxx_make_nodeacl() */
24 	struct se_node_acl se_node_acl;
25 };
26 
27 struct tcm_qla2xxx_tpg_attrib {
28 	int generate_node_acls;
29 	int cache_dynamic_acls;
30 	int demo_mode_write_protect;
31 	int prod_mode_write_protect;
32 };
33 
34 struct tcm_qla2xxx_tpg {
35 	/* FC lport target portal group tag for TCM */
36 	u16 lport_tpgt;
37 	/* Atomic bit to determine TPG active status */
38 	atomic_t lport_tpg_enabled;
39 	/* Pointer back to tcm_qla2xxx_lport */
40 	struct tcm_qla2xxx_lport *lport;
41 	/* Used by tcm_qla2xxx_tpg_attrib_cit */
42 	struct tcm_qla2xxx_tpg_attrib tpg_attrib;
43 	/* Returned by tcm_qla2xxx_make_tpg() */
44 	struct se_portal_group se_tpg;
45 };
46 
47 #define QLA_TPG_ATTRIB(tpg)	(&(tpg)->tpg_attrib)
48 
49 struct tcm_qla2xxx_fc_loopid {
50 	struct se_node_acl *se_nacl;
51 };
52 
53 struct tcm_qla2xxx_lport {
54 	/* SCSI protocol the lport is providing */
55 	u8 lport_proto_id;
56 	/* Binary World Wide unique Port Name for FC Target Lport */
57 	u64 lport_wwpn;
58 	/* Binary World Wide unique Port Name for FC NPIV Target Lport */
59 	u64 lport_npiv_wwpn;
60 	/* Binary World Wide unique Node Name for FC NPIV Target Lport */
61 	u64 lport_npiv_wwnn;
62 	/* ASCII formatted WWPN for FC Target Lport */
63 	char lport_name[TCM_QLA2XXX_NAMELEN];
64 	/* ASCII formatted naa WWPN for VPD page 83 etc */
65 	char lport_naa_name[TCM_QLA2XXX_NAMELEN];
66 	/* ASCII formatted WWPN+WWNN for NPIV FC Target Lport */
67 	char lport_npiv_name[TCM_QLA2XXX_NPIV_NAMELEN];
68 	/* map for fc_port pointers in 24-bit FC Port ID space */
69 	struct btree_head32 lport_fcport_map;
70 	/* vmalloc-ed memory for fc_port pointers for 16-bit FC loop ID */
71 	struct tcm_qla2xxx_fc_loopid *lport_loopid_map;
72 	/* Pointer to struct scsi_qla_host from qla2xxx LLD */
73 	struct scsi_qla_host *qla_vha;
74 	/* Pointer to struct scsi_qla_host for NPIV VP from qla2xxx LLD */
75 	struct scsi_qla_host *qla_npiv_vp;
76 	/* Pointer to struct qla_tgt pointer */
77 	struct qla_tgt lport_qla_tgt;
78 	/* Pointer to struct fc_vport for NPIV vport from libfc */
79 	struct fc_vport *npiv_vport;
80 	/* Pointer to TPG=1 for non NPIV mode */
81 	struct tcm_qla2xxx_tpg *tpg_1;
82 	/* Returned by tcm_qla2xxx_make_lport() */
83 	struct se_wwn lport_wwn;
84 };
85