20 #include <linux/module.h>
22 #include <linux/utsname.h>
24 #include <linux/slab.h>
26 #include <linux/types.h>
27 #include <linux/string.h>
29 #include <linux/ctype.h>
30 #include <linux/hash.h>
34 #include <asm/unaligned.h>
35 #include <scsi/scsi.h>
48 static void ft_sess_delete_all(
struct ft_tport *);
61 lockdep_is_held(&ft_lport_lock));
62 if (tport && tport->
tpg)
92 static void ft_tport_delete(
struct ft_tport *tport)
97 ft_sess_delete_all(tport);
117 ft_tport_create(lport);
132 ft_tport_delete(tport);
180 head = &tport->
hash[ft_sess_hash(port_id)];
181 hlist_for_each_entry_rcu(sess, pos, head,
hash) {
182 if (sess->
port_id == port_id) {
183 kref_get(&sess->
kref);
185 pr_debug(
"port_id %x found %p\n", port_id, sess);
191 pr_debug(
"port_id %x not found\n", port_id);
206 head = &tport->
hash[ft_sess_hash(port_id)];
207 hlist_for_each_entry_rcu(sess, pos, head,
hash)
208 if (sess->port_id == port_id)
216 if (IS_ERR(sess->se_sess)) {
223 kref_init(&sess->
kref);
224 hlist_add_head_rcu(&sess->
hash, head);
227 pr_debug(
"port_id %x sess %p\n", port_id, sess);
238 static void ft_sess_unhash(
struct ft_sess *sess)
242 hlist_del_rcu(&sess->
hash);
259 head = &tport->
hash[ft_sess_hash(port_id)];
260 hlist_for_each_entry_rcu(sess, pos, head,
hash) {
261 if (sess->
port_id == port_id) {
262 ft_sess_unhash(sess);
273 static void ft_sess_delete_all(
struct ft_tport *tport)
279 for (head = tport->
hash;
281 hlist_for_each_entry_rcu(sess, pos, head,
hash) {
282 ft_sess_unhash(sess);
321 ft_sess_unhash(sess);
337 unsigned char *
buf,
u32 len)
385 sess = ft_sess_create(tport, rdata->
ids.port_id, acl);
422 ret = ft_prli_locked(rdata, spp_len, rspp, spp);
424 pr_debug(
"port_id %x flags %x ret %x\n",
429 static void ft_sess_rcu_free(
struct rcu_head *rcu)
437 static void ft_sess_free(
struct kref *
kref)
449 kref_put(&sess->
kref, ft_sess_free);
459 lockdep_is_held(&ft_lport_lock));
465 sess = ft_sess_delete(tport, rdata->
ids.port_id);
484 u32 sid = fc_frame_sid(fp);
488 sess = ft_sess_get(lport, sid);
490 pr_debug(
"sid %x sess lookup failed\n", sid);