18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#include <target/target_core_base.h>
38c2ecf20Sopenharmony_ci#include <linux/btree.h>
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci/* length of ASCII WWPNs including pad */
68c2ecf20Sopenharmony_ci#define TCM_QLA2XXX_NAMELEN	32
78c2ecf20Sopenharmony_ci/*
88c2ecf20Sopenharmony_ci * Number of pre-allocated per-session tags, based upon the worst-case
98c2ecf20Sopenharmony_ci * per port number of iocbs
108c2ecf20Sopenharmony_ci */
118c2ecf20Sopenharmony_ci#define TCM_QLA2XXX_DEFAULT_TAGS 2088
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include "qla_target.h"
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_cistruct tcm_qla2xxx_nacl {
168c2ecf20Sopenharmony_ci	struct se_node_acl se_node_acl;
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci	/* From libfc struct fc_rport->port_id */
198c2ecf20Sopenharmony_ci	u32 nport_id;
208c2ecf20Sopenharmony_ci	/* Binary World Wide unique Node Name for remote FC Initiator Nport */
218c2ecf20Sopenharmony_ci	u64 nport_wwnn;
228c2ecf20Sopenharmony_ci	/* ASCII formatted WWPN for FC Initiator Nport */
238c2ecf20Sopenharmony_ci	char nport_name[TCM_QLA2XXX_NAMELEN];
248c2ecf20Sopenharmony_ci	/* Pointer to fc_port */
258c2ecf20Sopenharmony_ci	struct fc_port *fc_port;
268c2ecf20Sopenharmony_ci	/* Pointer to TCM FC nexus */
278c2ecf20Sopenharmony_ci	struct se_session *nport_nexus;
288c2ecf20Sopenharmony_ci};
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_cistruct tcm_qla2xxx_tpg_attrib {
318c2ecf20Sopenharmony_ci	int generate_node_acls;
328c2ecf20Sopenharmony_ci	int cache_dynamic_acls;
338c2ecf20Sopenharmony_ci	int demo_mode_write_protect;
348c2ecf20Sopenharmony_ci	int prod_mode_write_protect;
358c2ecf20Sopenharmony_ci	int demo_mode_login_only;
368c2ecf20Sopenharmony_ci	int fabric_prot_type;
378c2ecf20Sopenharmony_ci	int jam_host;
388c2ecf20Sopenharmony_ci};
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_cistruct tcm_qla2xxx_tpg {
418c2ecf20Sopenharmony_ci	/* FC lport target portal group tag for TCM */
428c2ecf20Sopenharmony_ci	u16 lport_tpgt;
438c2ecf20Sopenharmony_ci	/* Atomic bit to determine TPG active status */
448c2ecf20Sopenharmony_ci	atomic_t lport_tpg_enabled;
458c2ecf20Sopenharmony_ci	/* Pointer back to tcm_qla2xxx_lport */
468c2ecf20Sopenharmony_ci	struct tcm_qla2xxx_lport *lport;
478c2ecf20Sopenharmony_ci	/* Used by tcm_qla2xxx_tpg_attrib_cit */
488c2ecf20Sopenharmony_ci	struct tcm_qla2xxx_tpg_attrib tpg_attrib;
498c2ecf20Sopenharmony_ci	/* Returned by tcm_qla2xxx_make_tpg() */
508c2ecf20Sopenharmony_ci	struct se_portal_group se_tpg;
518c2ecf20Sopenharmony_ci};
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_cistruct tcm_qla2xxx_fc_loopid {
548c2ecf20Sopenharmony_ci	struct se_node_acl *se_nacl;
558c2ecf20Sopenharmony_ci};
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_cistruct tcm_qla2xxx_lport {
588c2ecf20Sopenharmony_ci	/* Binary World Wide unique Port Name for FC Target Lport */
598c2ecf20Sopenharmony_ci	u64 lport_wwpn;
608c2ecf20Sopenharmony_ci	/* Binary World Wide unique Port Name for FC NPIV Target Lport */
618c2ecf20Sopenharmony_ci	u64 lport_npiv_wwpn;
628c2ecf20Sopenharmony_ci	/* Binary World Wide unique Node Name for FC NPIV Target Lport */
638c2ecf20Sopenharmony_ci	u64 lport_npiv_wwnn;
648c2ecf20Sopenharmony_ci	/* ASCII formatted WWPN for FC Target Lport */
658c2ecf20Sopenharmony_ci	char lport_name[TCM_QLA2XXX_NAMELEN];
668c2ecf20Sopenharmony_ci	/* ASCII formatted naa WWPN for VPD page 83 etc */
678c2ecf20Sopenharmony_ci	char lport_naa_name[TCM_QLA2XXX_NAMELEN];
688c2ecf20Sopenharmony_ci	/* map for fc_port pointers in 24-bit FC Port ID space */
698c2ecf20Sopenharmony_ci	struct btree_head32 lport_fcport_map;
708c2ecf20Sopenharmony_ci	/* vmalloc-ed memory for fc_port pointers for 16-bit FC loop ID */
718c2ecf20Sopenharmony_ci	struct tcm_qla2xxx_fc_loopid *lport_loopid_map;
728c2ecf20Sopenharmony_ci	/* Pointer to struct scsi_qla_host from qla2xxx LLD */
738c2ecf20Sopenharmony_ci	struct scsi_qla_host *qla_vha;
748c2ecf20Sopenharmony_ci	/* Pointer to struct qla_tgt pointer */
758c2ecf20Sopenharmony_ci	struct qla_tgt lport_qla_tgt;
768c2ecf20Sopenharmony_ci	/* Pointer to TPG=1 for non NPIV mode */
778c2ecf20Sopenharmony_ci	struct tcm_qla2xxx_tpg *tpg_1;
788c2ecf20Sopenharmony_ci	/* Returned by tcm_qla2xxx_make_lport() */
798c2ecf20Sopenharmony_ci	struct se_wwn lport_wwn;
808c2ecf20Sopenharmony_ci};
81