From 972959d11a76b08dad6865ca875e3ac12f8c1d12 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Wed, 10 Nov 2010 19:34:22 +0000 Subject: [PATCH] Patch from Uri Yanai fixing compilation for kernels below 2.6.28 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@2659 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- qla2x00t/qla2x00-target/README | 8 ++++++++ qla2x00t/qla2x00-target/qla2x00t.c | 15 +++++++++++++++ qla2x00t/qla2x_tgt.h | 7 +++++++ qla2x00t/qla_os.c | 8 ++++++++ 4 files changed, 38 insertions(+) diff --git a/qla2x00t/qla2x00-target/README b/qla2x00t/qla2x00-target/README index 68310f994..50ab932db 100644 --- a/qla2x00t/qla2x00-target/README +++ b/qla2x00t/qla2x00-target/README @@ -47,6 +47,14 @@ Before installation make sure that the link "/lib/modules/`you_kernel_version`/build" points to the source code for your currently running kernel. +If your kernel version is <2.6.28, then you should consider applying +kernel patch scst_fc_vport_create.patch from the "kernel" subdirectory. +Without it, creating and removing NPIV targets using SCST sysfs +interface will be disabled. NOTE: you will still be able to create and +remove NPIV targets using the standard Linux interface (i.e. echoing +wwpn:wwnn into /sys/class/fc_host/hostX/vport_create and +/sys/class/fc_host/hostX/vport_delete). + Then you should replace (or link) by the initiator driver from this package "qla2xxx" subdirectory in kernel_source/drivers/scsi/ of the currently running kernel and using your favorite kernel configuration diff --git a/qla2x00t/qla2x00-target/qla2x00t.c b/qla2x00t/qla2x00-target/qla2x00t.c index fd88fdc7f..c64c04ceb 100644 --- a/qla2x00t/qla2x00-target/qla2x00t.c +++ b/qla2x00t/qla2x00-target/qla2x00t.c @@ -169,8 +169,15 @@ static const struct attribute *q2t_tgt_attrs[] = { static int q2t_enable_tgt(struct scst_tgt *tgt, bool enable); static bool q2t_is_tgt_enabled(struct scst_tgt *tgt); +#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)) || \ + defined(FC_VPORT_CREATE_DEFINED)) static ssize_t q2t_add_vtarget(const char *target_name, char *params); static ssize_t q2t_del_vtarget(const char *target_name); +#else +#warning "Patch scst_fc_vport_create was not applied on\ + your kernel. Adding NPIV targets using SCST sysfs interface will be disabled." +#endif /*((LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)) || \ + defined(FC_VPORT_CREATE_DEFINED))*/ /* * Global Variables @@ -210,8 +217,12 @@ static struct scst_tgt_template tgt2x_template = { .enable_target = q2t_enable_tgt, .is_target_enabled = q2t_is_tgt_enabled, #ifndef CONFIG_SCST_PROC +#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)) || \ + defined(FC_VPORT_CREATE_DEFINED)) .add_target = q2t_add_vtarget, .del_target = q2t_del_vtarget, +#endif /*((LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)) || \ + defined(FC_VPORT_CREATE_DEFINED))*/ .add_target_parameters = "node_name, parent_host", .tgtt_attrs = q2t_attrs, .tgt_attrs = q2t_tgt_attrs, @@ -5626,6 +5637,8 @@ static int q2t_parse_wwn(const char *ns, u64 *nm) return 0; } +#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)) || \ + defined(FC_VPORT_CREATE_DEFINED)) static ssize_t q2t_add_vtarget(const char *target_name, char *params) { int res; @@ -5739,6 +5752,8 @@ out: TRACE_EXIT_RES(res); return res; } +#endif /*((LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)) || \ + defined(FC_VPORT_CREATE_DEFINED))*/ static int q2t_get_initiator_port_transport_id(struct scst_session *scst_sess, uint8_t **transport_id) diff --git a/qla2x00t/qla2x_tgt.h b/qla2x00t/qla2x_tgt.h index 2bccdd597..139d35114 100644 --- a/qla2x00t/qla2x_tgt.h +++ b/qla2x00t/qla2x_tgt.h @@ -26,6 +26,8 @@ #ifndef __QLA2X_TGT_H #define __QLA2X_TGT_H +#include + extern request_t *qla2x00_req_pkt(scsi_qla_host_t *ha); #ifdef CONFIG_SCSI_QLA2XXX_TARGET @@ -126,9 +128,14 @@ qla2x00_send_enable_lun(scsi_qla_host_t *ha, bool enable) } extern void qla2xxx_add_targets(void); +#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)) || \ + defined(FC_VPORT_CREATE_DEFINED)) extern size_t qla2xxx_add_vtarget(u64 *port_name, u64 *node_name, u64 *parent_host); extern size_t qla2xxx_del_vtarget(u64 *port_name); +#endif /*((LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)) || \ + defined(FC_VPORT_CREATE_DEFINED))*/ + #endif /* CONFIG_SCSI_QLA2XXX_TARGET */ #endif /* __QLA2X_TGT_H */ diff --git a/qla2x00t/qla_os.c b/qla2x00t/qla_os.c index ef1474a8b..e6222525d 100644 --- a/qla2x00t/qla_os.c +++ b/qla2x00t/qla_os.c @@ -1666,6 +1666,8 @@ qla2xxx_add_targets(void) } EXPORT_SYMBOL(qla2xxx_add_targets); +#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)) || \ + defined(FC_VPORT_CREATE_DEFINED)) size_t qla2xxx_add_vtarget(u64 *port_name, u64 *node_name, u64 *parent_host) { struct Scsi_Host *shost = NULL; @@ -1737,6 +1739,12 @@ size_t qla2xxx_del_vtarget(u64 *port_name) return fc_vport_terminate(vport); } EXPORT_SYMBOL(qla2xxx_del_vtarget); +#else + +#warning "Patch scst_fc_vport_create was not applied on\ + your kernel. Adding NPIV targets using SCST sysfs interface will be disabled." +#endif /*((LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)) || \ + defined(FC_VPORT_CREATE_DEFINED))*/ #endif /* CONFIG_SCSI_QLA2XXX_TARGET */