Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (c) 2010 Cisco Systems, Inc.
0004  */
0005 #ifndef __TCM_FC_H__
0006 #define __TCM_FC_H__
0007 
0008 #include <linux/types.h>
0009 #include <target/target_core_base.h>
0010 
0011 #define FT_VERSION "0.4"
0012 
0013 #define FT_NAMELEN 32       /* length of ASCII WWPNs including pad */
0014 #define FT_TPG_NAMELEN 32   /* max length of TPG name */
0015 #define FT_LUN_NAMELEN 32   /* max length of LUN name */
0016 #define TCM_FC_DEFAULT_TAGS 512 /* tags used for per-session preallocation */
0017 
0018 struct ft_transport_id {
0019     __u8    format;
0020     __u8    __resvd1[7];
0021     __u8    wwpn[8];
0022     __u8    __resvd2[8];
0023 } __attribute__((__packed__));
0024 
0025 /*
0026  * Session (remote port).
0027  */
0028 struct ft_sess {
0029     u32 port_id;            /* for hash lookup use only */
0030     u32 params;
0031     u16 max_frame;          /* maximum frame size */
0032     u64 port_name;          /* port name for transport ID */
0033     struct ft_tport *tport;
0034     struct se_session *se_sess;
0035     struct hlist_node hash;     /* linkage in ft_sess_hash table */
0036     struct rcu_head rcu;
0037     struct kref kref;       /* ref for hash and outstanding I/Os */
0038 };
0039 
0040 /*
0041  * Hash table of sessions per local port.
0042  * Hash lookup by remote port FC_ID.
0043  */
0044 #define FT_SESS_HASH_BITS   6
0045 #define FT_SESS_HASH_SIZE   (1 << FT_SESS_HASH_BITS)
0046 
0047 /*
0048  * Per local port data.
0049  * This is created only after a TPG exists that allows target function
0050  * for the local port.  If the TPG exists, this is allocated when
0051  * we're notified that the local port has been created, or when
0052  * the first PRLI provider callback is received.
0053  */
0054 struct ft_tport {
0055     struct fc_lport *lport;
0056     struct ft_tpg *tpg;     /* NULL if TPG deleted before tport */
0057     u32 sess_count;     /* number of sessions in hash */
0058     struct rcu_head rcu;
0059     struct hlist_head hash[FT_SESS_HASH_SIZE];  /* list of sessions */
0060 };
0061 
0062 /*
0063  * Node ID and authentication.
0064  */
0065 struct ft_node_auth {
0066     u64 port_name;
0067     u64 node_name;
0068 };
0069 
0070 /*
0071  * Node ACL for FC remote port session.
0072  */
0073 struct ft_node_acl {
0074     struct se_node_acl se_node_acl;
0075     struct ft_node_auth node_auth;
0076 };
0077 
0078 struct ft_lun {
0079     u32 index;
0080     char name[FT_LUN_NAMELEN];
0081 };
0082 
0083 /*
0084  * Target portal group (local port).
0085  */
0086 struct ft_tpg {
0087     u32 index;
0088     struct ft_lport_wwn *lport_wwn;
0089     struct ft_tport *tport;     /* active tport or NULL */
0090     struct list_head lun_list;  /* head of LUNs */
0091     struct se_portal_group se_tpg;
0092     struct workqueue_struct *workqueue;
0093 };
0094 
0095 struct ft_lport_wwn {
0096     u64 wwpn;
0097     char name[FT_NAMELEN];
0098     struct list_head ft_wwn_node;
0099     struct ft_tpg *tpg;
0100     struct se_wwn se_wwn;
0101 };
0102 
0103 /*
0104  * Commands
0105  */
0106 struct ft_cmd {
0107     struct ft_sess *sess;       /* session held for cmd */
0108     struct fc_seq *seq;     /* sequence in exchange mgr */
0109     struct se_cmd se_cmd;       /* Local TCM I/O descriptor */
0110     struct fc_frame *req_frame;
0111     u32 write_data_len;     /* data received on writes */
0112     struct work_struct work;
0113     /* Local sense buffer */
0114     unsigned char ft_sense_buffer[TRANSPORT_SENSE_BUFFER];
0115     u32 was_ddp_setup:1;        /* Set only if ddp is setup */
0116     u32 aborted:1;          /* Set if aborted by reset or timeout */
0117     struct scatterlist *sg;     /* Set only if DDP is setup */
0118     u32 sg_cnt;         /* No. of item in scatterlist */
0119 };
0120 
0121 extern struct mutex ft_lport_lock;
0122 extern struct fc4_prov ft_prov;
0123 extern unsigned int ft_debug_logging;
0124 
0125 /*
0126  * Fabric methods.
0127  */
0128 
0129 /*
0130  * Session ops.
0131  */
0132 void ft_sess_put(struct ft_sess *);
0133 void ft_sess_close(struct se_session *);
0134 u32 ft_sess_get_index(struct se_session *);
0135 u32 ft_sess_get_port_name(struct se_session *, unsigned char *, u32);
0136 
0137 void ft_lport_add(struct fc_lport *, void *);
0138 void ft_lport_del(struct fc_lport *, void *);
0139 int ft_lport_notify(struct notifier_block *, unsigned long, void *);
0140 
0141 /*
0142  * IO methods.
0143  */
0144 int ft_check_stop_free(struct se_cmd *);
0145 void ft_release_cmd(struct se_cmd *);
0146 int ft_queue_status(struct se_cmd *);
0147 int ft_queue_data_in(struct se_cmd *);
0148 int ft_write_pending(struct se_cmd *);
0149 int ft_get_cmd_state(struct se_cmd *);
0150 void ft_queue_tm_resp(struct se_cmd *);
0151 void ft_aborted_task(struct se_cmd *);
0152 
0153 /*
0154  * other internal functions.
0155  */
0156 void ft_recv_req(struct ft_sess *, struct fc_frame *);
0157 struct ft_tpg *ft_lport_find_tpg(struct fc_lport *);
0158 
0159 void ft_recv_write_data(struct ft_cmd *, struct fc_frame *);
0160 void ft_dump_cmd(struct ft_cmd *, const char *caller);
0161 
0162 ssize_t ft_format_wwn(char *, size_t, u64);
0163 
0164 /*
0165  * Underlying HW specific helper function
0166  */
0167 void ft_invl_hw_context(struct ft_cmd *);
0168 
0169 #endif /* __TCM_FC_H__ */