tcm_fc.h revision 5f544cfac956971099e906f94568bc3fd1a7108a
13699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil/* 23699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * Copyright (c) 2010 Cisco Systems, Inc. 33699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * 43699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * This program is free software; you can redistribute it and/or modify it 53699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * under the terms and conditions of the GNU General Public License, 63699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * version 2, as published by the Free Software Foundation. 73699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * 83699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * This program is distributed in the hope it will be useful, but WITHOUT 93699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 103699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 113699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * more details. 123699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * 133699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * You should have received a copy of the GNU General Public License along with 143699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * this program; if not, write to the Free Software Foundation, Inc., 153699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 163699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil */ 173699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil#ifndef __TCM_FC_H__ 183699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil#define __TCM_FC_H__ 193699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil 209765b1f327951e643a97f43924d1fbeb4e90ffbaNicholas Bellinger#define FT_VERSION "0.4" 213699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil 223699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil#define FT_NAMELEN 32 /* length of ASCII WWPNs including pad */ 233699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil#define FT_TPG_NAMELEN 32 /* max length of TPG name */ 243699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil#define FT_LUN_NAMELEN 32 /* max length of LUN name */ 255f544cfac956971099e906f94568bc3fd1a7108aNicholas Bellinger#define TCM_FC_DEFAULT_TAGS 512 /* tags used for per-session preallocation */ 263699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil 273699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilstruct ft_transport_id { 283699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil __u8 format; 293699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil __u8 __resvd1[7]; 303699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil __u8 wwpn[8]; 313699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil __u8 __resvd2[8]; 323699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil} __attribute__((__packed__)); 333699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil 343699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil/* 353699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * Session (remote port). 363699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil */ 373699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilstruct ft_sess { 383699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil u32 port_id; /* for hash lookup use only */ 393699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil u32 params; 403699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil u16 max_frame; /* maximum frame size */ 413699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil u64 port_name; /* port name for transport ID */ 423699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil struct ft_tport *tport; 433699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil struct se_session *se_sess; 443699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil struct hlist_node hash; /* linkage in ft_sess_hash table */ 453699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil struct rcu_head rcu; 463699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil struct kref kref; /* ref for hash and outstanding I/Os */ 473699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil}; 483699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil 493699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil/* 503699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * Hash table of sessions per local port. 513699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * Hash lookup by remote port FC_ID. 523699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil */ 533699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil#define FT_SESS_HASH_BITS 6 543699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil#define FT_SESS_HASH_SIZE (1 << FT_SESS_HASH_BITS) 553699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil 563699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil/* 573699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * Per local port data. 583699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * This is created only after a TPG exists that allows target function 593699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * for the local port. If the TPG exists, this is allocated when 603699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * we're notified that the local port has been created, or when 613699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * the first PRLI provider callback is received. 623699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil */ 633699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilstruct ft_tport { 643699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil struct fc_lport *lport; 653699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil struct ft_tpg *tpg; /* NULL if TPG deleted before tport */ 663699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil u32 sess_count; /* number of sessions in hash */ 673699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil struct rcu_head rcu; 683699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil struct hlist_head hash[FT_SESS_HASH_SIZE]; /* list of sessions */ 693699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil}; 703699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil 713699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil/* 723699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * Node ID and authentication. 733699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil */ 743699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilstruct ft_node_auth { 753699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil u64 port_name; 763699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil u64 node_name; 773699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil}; 783699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil 793699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil/* 803699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * Node ACL for FC remote port session. 813699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil */ 823699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilstruct ft_node_acl { 833699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil struct ft_node_auth node_auth; 843699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil struct se_node_acl se_node_acl; 853699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil}; 863699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil 873699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilstruct ft_lun { 883699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil u32 index; 893699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil char name[FT_LUN_NAMELEN]; 903699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil}; 913699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil 923699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil/* 933699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * Target portal group (local port). 943699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil */ 953699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilstruct ft_tpg { 963699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil u32 index; 973699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil struct ft_lport_acl *lport_acl; 983699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil struct ft_tport *tport; /* active tport or NULL */ 993699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil struct list_head list; /* linkage in ft_lport_acl tpg_list */ 1003699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil struct list_head lun_list; /* head of LUNs */ 1013699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil struct se_portal_group se_tpg; 10258fc73d10f3e92bfcd1e9a8391eb3e49b68df8e5Christoph Hellwig struct workqueue_struct *workqueue; 1033699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil}; 1043699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil 1053699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilstruct ft_lport_acl { 1063699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil u64 wwpn; 1073699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil char name[FT_NAMELEN]; 1083699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil struct list_head list; 1093699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil struct list_head tpg_list; 1103699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil struct se_wwn fc_lport_wwn; 1113699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil}; 1123699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil 1133699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil/* 1143699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * Commands 1153699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil */ 1163699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilstruct ft_cmd { 1173699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil struct ft_sess *sess; /* session held for cmd */ 1183699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil struct fc_seq *seq; /* sequence in exchange mgr */ 1193699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil struct se_cmd se_cmd; /* Local TCM I/O descriptor */ 1203699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil struct fc_frame *req_frame; 1213699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil u32 write_data_len; /* data received on writes */ 12258fc73d10f3e92bfcd1e9a8391eb3e49b68df8e5Christoph Hellwig struct work_struct work; 1233699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil /* Local sense buffer */ 1243699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil unsigned char ft_sense_buffer[TRANSPORT_SENSE_BUFFER]; 1253699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil u32 was_ddp_setup:1; /* Set only if ddp is setup */ 126e1c4038282c7586c3544542b37872c434669d3acMark Rustad u32 aborted:1; /* Set if aborted by reset or timeout */ 1273699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil struct scatterlist *sg; /* Set only if DDP is setup */ 1283699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil u32 sg_cnt; /* No. of item in scatterlist */ 1293699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil}; 1303699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil 1313699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilextern struct list_head ft_lport_list; 1323699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilextern struct mutex ft_lport_lock; 1333699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilextern struct fc4_prov ft_prov; 1343699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilextern struct target_fabric_configfs *ft_configfs; 1351fa8f4504130adc34a071a29170f570102136835Mark Rustadextern unsigned int ft_debug_logging; 1363699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil 1373699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil/* 1383699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * Fabric methods. 1393699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil */ 1403699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil 1413699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil/* 1423699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * Session ops. 1433699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil */ 1443699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilvoid ft_sess_put(struct ft_sess *); 1453699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilint ft_sess_shutdown(struct se_session *); 1463699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilvoid ft_sess_close(struct se_session *); 1473699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilu32 ft_sess_get_index(struct se_session *); 1483699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilu32 ft_sess_get_port_name(struct se_session *, unsigned char *, u32); 1493699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil 1503699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilvoid ft_lport_add(struct fc_lport *, void *); 1513699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilvoid ft_lport_del(struct fc_lport *, void *); 1523699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilint ft_lport_notify(struct notifier_block *, unsigned long, void *); 1533699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil 1543699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil/* 1553699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * IO methods. 1563699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil */ 15788dd9e26d6d3e743f9c7e4562b94b2ad3c2994d3Nicholas Bellingerint ft_check_stop_free(struct se_cmd *); 1583699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilvoid ft_release_cmd(struct se_cmd *); 1593699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilint ft_queue_status(struct se_cmd *); 1603699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilint ft_queue_data_in(struct se_cmd *); 1613699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilint ft_write_pending(struct se_cmd *); 1623699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilint ft_write_pending_status(struct se_cmd *); 1633699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilu32 ft_get_task_tag(struct se_cmd *); 1643699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilint ft_get_cmd_state(struct se_cmd *); 165b79fafac70fc9bbe640b8193ed772eb850efdfe6Joern Engelvoid ft_queue_tm_resp(struct se_cmd *); 1663699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil 1673699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil/* 1683699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil * other internal functions. 1693699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil */ 1703699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilvoid ft_recv_req(struct ft_sess *, struct fc_frame *); 1713699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilstruct ft_tpg *ft_lport_find_tpg(struct fc_lport *); 1723699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilstruct ft_node_acl *ft_acl_get(struct ft_tpg *, struct fc_rport_priv *); 1733699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil 1743699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilvoid ft_recv_write_data(struct ft_cmd *, struct fc_frame *); 1753699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilvoid ft_dump_cmd(struct ft_cmd *, const char *caller); 1763699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil 1773699d92a4d7b649bde67dff3cc681400992e0254Kiran Patilssize_t ft_format_wwn(char *, size_t, u64); 1783699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil 179dcd998ccdbf74a7d8fe0f0a44e85da1ed5975946Kiran Patil/* 180dcd998ccdbf74a7d8fe0f0a44e85da1ed5975946Kiran Patil * Underlying HW specific helper function 181dcd998ccdbf74a7d8fe0f0a44e85da1ed5975946Kiran Patil */ 182dcd998ccdbf74a7d8fe0f0a44e85da1ed5975946Kiran Patilvoid ft_invl_hw_context(struct ft_cmd *); 183dcd998ccdbf74a7d8fe0f0a44e85da1ed5975946Kiran Patil 1843699d92a4d7b649bde67dff3cc681400992e0254Kiran Patil#endif /* __TCM_FC_H__ */ 185