Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SCSI] fc_transport: add target driver support

This adds minimum target driver support like the srp transport does:

- fc_remote_port_{rolechg,delete} calls
scsi_tgt_it_nexus_{create,destroy} for target drivers.

- add callbacks to notify target drivers of the nexus and tmf
operation results to fc_function_template.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>

authored by

FUJITA Tomonori and committed by
James Bottomley
7525236d 5dc2b89e

+66
+7
drivers/scsi/Kconfig
··· 272 272 each attached FiberChannel device to sysfs, say Y. 273 273 Otherwise, say N. 274 274 275 + config SCSI_FC_TGT_ATTRS 276 + bool "SCSI target support for FiberChannel Transport Attributes" 277 + depends on SCSI_FC_ATTRS 278 + depends on SCSI_TGT = y || SCSI_TGT = SCSI_FC_ATTRS 279 + help 280 + If you want to use SCSI target mode drivers enable this option. 281 + 275 282 config SCSI_ISCSI_ATTRS 276 283 tristate "iSCSI Transport Attributes" 277 284 depends on SCSI && NET
+29
drivers/scsi/scsi_transport_fc.c
··· 36 36 #include <net/netlink.h> 37 37 #include <scsi/scsi_netlink_fc.h> 38 38 #include "scsi_priv.h" 39 + #include "scsi_transport_fc_internal.h" 39 40 40 41 static int fc_queue_work(struct Scsi_Host *, struct work_struct *); 41 42 static void fc_vport_sched_delete(struct work_struct *work); ··· 1957 1956 return 0; 1958 1957 } 1959 1958 1959 + static int fc_tsk_mgmt_response(struct Scsi_Host *shost, u64 nexus, u64 tm_id, 1960 + int result) 1961 + { 1962 + struct fc_internal *i = to_fc_internal(shost->transportt); 1963 + return i->f->tsk_mgmt_response(shost, nexus, tm_id, result); 1964 + } 1965 + 1966 + static int fc_it_nexus_response(struct Scsi_Host *shost, u64 nexus, int result) 1967 + { 1968 + struct fc_internal *i = to_fc_internal(shost->transportt); 1969 + return i->f->it_nexus_response(shost, nexus, result); 1970 + } 1971 + 1960 1972 struct scsi_transport_template * 1961 1973 fc_attach_transport(struct fc_function_template *ft) 1962 1974 { ··· 2012 1998 i->t.eh_timed_out = fc_timed_out; 2013 1999 2014 2000 i->t.user_scan = fc_user_scan; 2001 + 2002 + /* target-mode drivers' functions */ 2003 + i->t.tsk_mgmt_response = fc_tsk_mgmt_response; 2004 + i->t.it_nexus_response = fc_it_nexus_response; 2015 2005 2016 2006 /* 2017 2007 * Setup SCSI Target Attributes. ··· 2774 2756 2775 2757 spin_unlock_irqrestore(shost->host_lock, flags); 2776 2758 2759 + if (rport->roles & FC_PORT_ROLE_FCP_INITIATOR && 2760 + shost->active_mode & MODE_TARGET) 2761 + fc_tgt_it_nexus_destroy(shost, (unsigned long)rport); 2762 + 2777 2763 scsi_target_block(&rport->dev); 2778 2764 2779 2765 /* see if we need to kill io faster than waiting for device loss */ ··· 2818 2796 struct fc_host_attrs *fc_host = shost_to_fc_host(shost); 2819 2797 unsigned long flags; 2820 2798 int create = 0; 2799 + int ret; 2821 2800 2822 2801 spin_lock_irqsave(shost->host_lock, flags); 2823 2802 if (roles & FC_PORT_ROLE_FCP_TARGET) { ··· 2827 2804 create = 1; 2828 2805 } else if (!(rport->roles & FC_PORT_ROLE_FCP_TARGET)) 2829 2806 create = 1; 2807 + } else if (shost->active_mode & MODE_TARGET) { 2808 + ret = fc_tgt_it_nexus_create(shost, (unsigned long)rport, 2809 + (char *)&rport->node_name); 2810 + if (ret) 2811 + printk(KERN_ERR "FC Remore Port tgt nexus failed %d\n", 2812 + ret); 2830 2813 } 2831 2814 2832 2815 rport->roles = roles;
+26
drivers/scsi/scsi_transport_fc_internal.h
··· 1 + #include <scsi/scsi_tgt.h> 2 + 3 + #ifdef CONFIG_SCSI_FC_TGT_ATTRS 4 + static inline int fc_tgt_it_nexus_create(struct Scsi_Host *shost, u64 itn_id, 5 + char *initiator) 6 + { 7 + return scsi_tgt_it_nexus_create(shost, itn_id, initiator); 8 + } 9 + 10 + static inline int fc_tgt_it_nexus_destroy(struct Scsi_Host *shost, u64 itn_id) 11 + { 12 + return scsi_tgt_it_nexus_destroy(shost, itn_id); 13 + } 14 + #else 15 + static inline int fc_tgt_it_nexus_create(struct Scsi_Host *shost, u64 itn_id, 16 + char *initiator) 17 + { 18 + return 0; 19 + } 20 + 21 + static inline int fc_tgt_it_nexus_destroy(struct Scsi_Host *shost, u64 itn_id) 22 + { 23 + return 0; 24 + } 25 + 26 + #endif
+4
include/scsi/scsi_transport_fc.h
··· 589 589 int (*vport_disable)(struct fc_vport *, bool); 590 590 int (*vport_delete)(struct fc_vport *); 591 591 592 + /* target-mode drivers' functions */ 593 + int (* tsk_mgmt_response)(struct Scsi_Host *, u64, u64, int); 594 + int (* it_nexus_response)(struct Scsi_Host *, u64, int); 595 + 592 596 /* allocation lengths for host-specific data */ 593 597 u32 dd_fcrport_size; 594 598 u32 dd_fcvport_size;