2 * Copyright (c) 2010 Cisco Systems, Inc.
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.
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
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.
20 #define FT_VERSION "0.4"
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 */
26 struct ft_transport_id
{
31 } __attribute__((__packed__
));
34 * Session (remote port).
37 u32 port_id
; /* for hash lookup use only */
39 u16 max_frame
; /* maximum frame size */
40 u64 port_name
; /* port name for transport ID */
41 struct ft_tport
*tport
;
42 struct se_session
*se_sess
;
43 struct hlist_node hash
; /* linkage in ft_sess_hash table */
45 struct kref kref
; /* ref for hash and outstanding I/Os */
49 * Hash table of sessions per local port.
50 * Hash lookup by remote port FC_ID.
52 #define FT_SESS_HASH_BITS 6
53 #define FT_SESS_HASH_SIZE (1 << FT_SESS_HASH_BITS)
56 * Per local port data.
57 * This is created only after a TPG exists that allows target function
58 * for the local port. If the TPG exists, this is allocated when
59 * we're notified that the local port has been created, or when
60 * the first PRLI provider callback is received.
63 struct fc_lport
*lport
;
64 struct ft_tpg
*tpg
; /* NULL if TPG deleted before tport */
65 u32 sess_count
; /* number of sessions in hash */
67 struct hlist_head hash
[FT_SESS_HASH_SIZE
]; /* list of sessions */
71 * Node ID and authentication.
79 * Node ACL for FC remote port session.
82 struct ft_node_auth node_auth
;
83 struct se_node_acl se_node_acl
;
88 char name
[FT_LUN_NAMELEN
];
92 * Target portal group (local port).
96 struct ft_lport_acl
*lport_acl
;
97 struct ft_tport
*tport
; /* active tport or NULL */
98 struct list_head list
; /* linkage in ft_lport_acl tpg_list */
99 struct list_head lun_list
; /* head of LUNs */
100 struct se_portal_group se_tpg
;
101 struct workqueue_struct
*workqueue
;
104 struct ft_lport_acl
{
106 char name
[FT_NAMELEN
];
107 struct list_head list
;
108 struct list_head tpg_list
;
109 struct se_wwn fc_lport_wwn
;
116 struct ft_sess
*sess
; /* session held for cmd */
117 struct fc_seq
*seq
; /* sequence in exchange mgr */
118 struct se_cmd se_cmd
; /* Local TCM I/O descriptor */
119 struct fc_frame
*req_frame
;
120 u32 write_data_len
; /* data received on writes */
121 struct work_struct work
;
122 /* Local sense buffer */
123 unsigned char ft_sense_buffer
[TRANSPORT_SENSE_BUFFER
];
124 u32 was_ddp_setup
:1; /* Set only if ddp is setup */
125 u32 aborted
:1; /* Set if aborted by reset or timeout */
126 struct scatterlist
*sg
; /* Set only if DDP is setup */
127 u32 sg_cnt
; /* No. of item in scatterlist */
130 extern struct list_head ft_lport_list
;
131 extern struct mutex ft_lport_lock
;
132 extern struct fc4_prov ft_prov
;
133 extern struct target_fabric_configfs
*ft_configfs
;
134 extern unsigned int ft_debug_logging
;
143 void ft_sess_put(struct ft_sess
*);
144 int ft_sess_shutdown(struct se_session
*);
145 void ft_sess_close(struct se_session
*);
146 u32
ft_sess_get_index(struct se_session
*);
147 u32
ft_sess_get_port_name(struct se_session
*, unsigned char *, u32
);
149 void ft_lport_add(struct fc_lport
*, void *);
150 void ft_lport_del(struct fc_lport
*, void *);
151 int ft_lport_notify(struct notifier_block
*, unsigned long, void *);
156 int ft_check_stop_free(struct se_cmd
*);
157 void ft_release_cmd(struct se_cmd
*);
158 int ft_queue_status(struct se_cmd
*);
159 int ft_queue_data_in(struct se_cmd
*);
160 int ft_write_pending(struct se_cmd
*);
161 int ft_write_pending_status(struct se_cmd
*);
162 u32
ft_get_task_tag(struct se_cmd
*);
163 int ft_get_cmd_state(struct se_cmd
*);
164 void ft_queue_tm_resp(struct se_cmd
*);
167 * other internal functions.
169 void ft_recv_req(struct ft_sess
*, struct fc_frame
*);
170 struct ft_tpg
*ft_lport_find_tpg(struct fc_lport
*);
171 struct ft_node_acl
*ft_acl_get(struct ft_tpg
*, struct fc_rport_priv
*);
173 void ft_recv_write_data(struct ft_cmd
*, struct fc_frame
*);
174 void ft_dump_cmd(struct ft_cmd
*, const char *caller
);
176 ssize_t
ft_format_wwn(char *, size_t, u64
);
179 * Underlying HW specific helper function
181 void ft_invl_hw_context(struct ft_cmd
*);
183 #endif /* __TCM_FC_H__ */