]>
Commit | Line | Data |
---|---|---|
3699d92a KP |
1 | /* |
2 | * Copyright (c) 2010 Cisco Systems, Inc. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms and conditions of the GNU General Public License, | |
6 | * version 2, as published by the Free Software Foundation. | |
7 | * | |
8 | * This program is distributed in the hope it will be useful, but WITHOUT | |
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
11 | * more details. | |
12 | * | |
13 | * You should have received a copy of the GNU General Public License along with | |
14 | * this program; if not, write to the Free Software Foundation, Inc., | |
15 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | |
16 | */ | |
17 | #ifndef __TCM_FC_H__ | |
18 | #define __TCM_FC_H__ | |
19 | ||
9765b1f3 | 20 | #define FT_VERSION "0.4" |
3699d92a KP |
21 | |
22 | #define FT_NAMELEN 32 /* length of ASCII WWPNs including pad */ | |
23 | #define FT_TPG_NAMELEN 32 /* max length of TPG name */ | |
24 | #define FT_LUN_NAMELEN 32 /* max length of LUN name */ | |
5f544cfa | 25 | #define TCM_FC_DEFAULT_TAGS 512 /* tags used for per-session preallocation */ |
3699d92a | 26 | |
3699d92a KP |
27 | struct ft_transport_id { |
28 | __u8 format; | |
29 | __u8 __resvd1[7]; | |
30 | __u8 wwpn[8]; | |
31 | __u8 __resvd2[8]; | |
32 | } __attribute__((__packed__)); | |
33 | ||
34 | /* | |
35 | * Session (remote port). | |
36 | */ | |
37 | struct ft_sess { | |
38 | u32 port_id; /* for hash lookup use only */ | |
39 | u32 params; | |
40 | u16 max_frame; /* maximum frame size */ | |
41 | u64 port_name; /* port name for transport ID */ | |
42 | struct ft_tport *tport; | |
43 | struct se_session *se_sess; | |
44 | struct hlist_node hash; /* linkage in ft_sess_hash table */ | |
45 | struct rcu_head rcu; | |
46 | struct kref kref; /* ref for hash and outstanding I/Os */ | |
47 | }; | |
48 | ||
49 | /* | |
50 | * Hash table of sessions per local port. | |
51 | * Hash lookup by remote port FC_ID. | |
52 | */ | |
53 | #define FT_SESS_HASH_BITS 6 | |
54 | #define FT_SESS_HASH_SIZE (1 << FT_SESS_HASH_BITS) | |
55 | ||
56 | /* | |
57 | * Per local port data. | |
58 | * This is created only after a TPG exists that allows target function | |
59 | * for the local port. If the TPG exists, this is allocated when | |
60 | * we're notified that the local port has been created, or when | |
61 | * the first PRLI provider callback is received. | |
62 | */ | |
63 | struct ft_tport { | |
64 | struct fc_lport *lport; | |
65 | struct ft_tpg *tpg; /* NULL if TPG deleted before tport */ | |
66 | u32 sess_count; /* number of sessions in hash */ | |
67 | struct rcu_head rcu; | |
68 | struct hlist_head hash[FT_SESS_HASH_SIZE]; /* list of sessions */ | |
69 | }; | |
70 | ||
71 | /* | |
72 | * Node ID and authentication. | |
73 | */ | |
74 | struct ft_node_auth { | |
75 | u64 port_name; | |
76 | u64 node_name; | |
77 | }; | |
78 | ||
79 | /* | |
80 | * Node ACL for FC remote port session. | |
81 | */ | |
82 | struct ft_node_acl { | |
83 | struct ft_node_auth node_auth; | |
84 | struct se_node_acl se_node_acl; | |
85 | }; | |
86 | ||
87 | struct ft_lun { | |
88 | u32 index; | |
89 | char name[FT_LUN_NAMELEN]; | |
90 | }; | |
91 | ||
92 | /* | |
93 | * Target portal group (local port). | |
94 | */ | |
95 | struct ft_tpg { | |
96 | u32 index; | |
97 | struct ft_lport_acl *lport_acl; | |
98 | struct ft_tport *tport; /* active tport or NULL */ | |
99 | struct list_head list; /* linkage in ft_lport_acl tpg_list */ | |
100 | struct list_head lun_list; /* head of LUNs */ | |
101 | struct se_portal_group se_tpg; | |
58fc73d1 | 102 | struct workqueue_struct *workqueue; |
3699d92a KP |
103 | }; |
104 | ||
105 | struct ft_lport_acl { | |
106 | u64 wwpn; | |
107 | char name[FT_NAMELEN]; | |
108 | struct list_head list; | |
109 | struct list_head tpg_list; | |
110 | struct se_wwn fc_lport_wwn; | |
111 | }; | |
112 | ||
3699d92a KP |
113 | /* |
114 | * Commands | |
115 | */ | |
116 | struct ft_cmd { | |
3699d92a KP |
117 | struct ft_sess *sess; /* session held for cmd */ |
118 | struct fc_seq *seq; /* sequence in exchange mgr */ | |
119 | struct se_cmd se_cmd; /* Local TCM I/O descriptor */ | |
120 | struct fc_frame *req_frame; | |
3699d92a | 121 | u32 write_data_len; /* data received on writes */ |
58fc73d1 | 122 | struct work_struct work; |
3699d92a KP |
123 | /* Local sense buffer */ |
124 | unsigned char ft_sense_buffer[TRANSPORT_SENSE_BUFFER]; | |
125 | u32 was_ddp_setup:1; /* Set only if ddp is setup */ | |
e1c40382 | 126 | u32 aborted:1; /* Set if aborted by reset or timeout */ |
3699d92a KP |
127 | struct scatterlist *sg; /* Set only if DDP is setup */ |
128 | u32 sg_cnt; /* No. of item in scatterlist */ | |
129 | }; | |
130 | ||
131 | extern struct list_head ft_lport_list; | |
132 | extern struct mutex ft_lport_lock; | |
133 | extern struct fc4_prov ft_prov; | |
134 | extern struct target_fabric_configfs *ft_configfs; | |
1fa8f450 | 135 | extern unsigned int ft_debug_logging; |
3699d92a KP |
136 | |
137 | /* | |
138 | * Fabric methods. | |
139 | */ | |
140 | ||
141 | /* | |
142 | * Session ops. | |
143 | */ | |
144 | void ft_sess_put(struct ft_sess *); | |
145 | int ft_sess_shutdown(struct se_session *); | |
146 | void ft_sess_close(struct se_session *); | |
3699d92a KP |
147 | u32 ft_sess_get_index(struct se_session *); |
148 | u32 ft_sess_get_port_name(struct se_session *, unsigned char *, u32); | |
3699d92a KP |
149 | |
150 | void ft_lport_add(struct fc_lport *, void *); | |
151 | void ft_lport_del(struct fc_lport *, void *); | |
152 | int ft_lport_notify(struct notifier_block *, unsigned long, void *); | |
153 | ||
154 | /* | |
155 | * IO methods. | |
156 | */ | |
88dd9e26 | 157 | int ft_check_stop_free(struct se_cmd *); |
3699d92a KP |
158 | void ft_release_cmd(struct se_cmd *); |
159 | int ft_queue_status(struct se_cmd *); | |
160 | int ft_queue_data_in(struct se_cmd *); | |
161 | int ft_write_pending(struct se_cmd *); | |
162 | int ft_write_pending_status(struct se_cmd *); | |
163 | u32 ft_get_task_tag(struct se_cmd *); | |
164 | int ft_get_cmd_state(struct se_cmd *); | |
b79fafac | 165 | void ft_queue_tm_resp(struct se_cmd *); |
3699d92a KP |
166 | |
167 | /* | |
168 | * other internal functions. | |
169 | */ | |
3699d92a KP |
170 | void ft_recv_req(struct ft_sess *, struct fc_frame *); |
171 | struct ft_tpg *ft_lport_find_tpg(struct fc_lport *); | |
172 | struct ft_node_acl *ft_acl_get(struct ft_tpg *, struct fc_rport_priv *); | |
173 | ||
174 | void ft_recv_write_data(struct ft_cmd *, struct fc_frame *); | |
175 | void ft_dump_cmd(struct ft_cmd *, const char *caller); | |
176 | ||
177 | ssize_t ft_format_wwn(char *, size_t, u64); | |
178 | ||
dcd998cc KP |
179 | /* |
180 | * Underlying HW specific helper function | |
181 | */ | |
182 | void ft_invl_hw_context(struct ft_cmd *); | |
183 | ||
3699d92a | 184 | #endif /* __TCM_FC_H__ */ |