Commit 038d9446 authored by Christof Schmitt's avatar Christof Schmitt Committed by James Bottomley

[SCSI] zfcp: Add information to symbolic port name when running in NPIV mode

Query the FC symbolic port name for reporting in the fc_host sysfs and
enable the symbolic_name attribute in the fc_host sysfs. When running
in NPIV mode, extend the symbolic port name with the devno and the
hostname. This allows better identification of Linux systems for SAN
and storage administrators.
Signed-off-by: default avatarChristof Schmitt <christof.schmitt@de.ibm.com>
Signed-off-by: default avatarSteffen Maier <maier@linux.vnet.ibm.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent 22fd411a
...@@ -362,6 +362,7 @@ struct zfcp_adapter *zfcp_adapter_enqueue(struct ccw_device *ccw_device) ...@@ -362,6 +362,7 @@ struct zfcp_adapter *zfcp_adapter_enqueue(struct ccw_device *ccw_device)
INIT_WORK(&adapter->stat_work, _zfcp_status_read_scheduler); INIT_WORK(&adapter->stat_work, _zfcp_status_read_scheduler);
INIT_WORK(&adapter->scan_work, zfcp_fc_scan_ports); INIT_WORK(&adapter->scan_work, zfcp_fc_scan_ports);
INIT_WORK(&adapter->ns_up_work, zfcp_fc_sym_name_update);
if (zfcp_qdio_setup(adapter)) if (zfcp_qdio_setup(adapter))
goto failed; goto failed;
...@@ -427,6 +428,7 @@ void zfcp_adapter_unregister(struct zfcp_adapter *adapter) ...@@ -427,6 +428,7 @@ void zfcp_adapter_unregister(struct zfcp_adapter *adapter)
cancel_work_sync(&adapter->scan_work); cancel_work_sync(&adapter->scan_work);
cancel_work_sync(&adapter->stat_work); cancel_work_sync(&adapter->stat_work);
cancel_work_sync(&adapter->ns_up_work);
zfcp_destroy_adapter_work_queue(adapter); zfcp_destroy_adapter_work_queue(adapter);
zfcp_fc_wka_ports_force_offline(adapter->gs); zfcp_fc_wka_ports_force_offline(adapter->gs);
......
...@@ -189,6 +189,7 @@ struct zfcp_adapter { ...@@ -189,6 +189,7 @@ struct zfcp_adapter {
struct fsf_qtcb_bottom_port *stats_reset_data; struct fsf_qtcb_bottom_port *stats_reset_data;
unsigned long stats_reset; unsigned long stats_reset;
struct work_struct scan_work; struct work_struct scan_work;
struct work_struct ns_up_work;
struct service_level service_level; struct service_level service_level;
struct workqueue_struct *work_queue; struct workqueue_struct *work_queue;
struct device_dma_parameters dma_parms; struct device_dma_parameters dma_parms;
......
...@@ -1231,8 +1231,10 @@ static void zfcp_erp_action_cleanup(struct zfcp_erp_action *act, int result) ...@@ -1231,8 +1231,10 @@ static void zfcp_erp_action_cleanup(struct zfcp_erp_action *act, int result)
if (result == ZFCP_ERP_SUCCEEDED) { if (result == ZFCP_ERP_SUCCEEDED) {
register_service_level(&adapter->service_level); register_service_level(&adapter->service_level);
queue_work(adapter->work_queue, &adapter->scan_work); queue_work(adapter->work_queue, &adapter->scan_work);
queue_work(adapter->work_queue, &adapter->ns_up_work);
} else } else
unregister_service_level(&adapter->service_level); unregister_service_level(&adapter->service_level);
kref_put(&adapter->ref, zfcp_adapter_release); kref_put(&adapter->ref, zfcp_adapter_release);
break; break;
} }
......
...@@ -96,6 +96,7 @@ extern int zfcp_fc_gs_setup(struct zfcp_adapter *); ...@@ -96,6 +96,7 @@ extern int zfcp_fc_gs_setup(struct zfcp_adapter *);
extern void zfcp_fc_gs_destroy(struct zfcp_adapter *); extern void zfcp_fc_gs_destroy(struct zfcp_adapter *);
extern int zfcp_fc_exec_bsg_job(struct fc_bsg_job *); extern int zfcp_fc_exec_bsg_job(struct fc_bsg_job *);
extern int zfcp_fc_timeout_bsg_job(struct fc_bsg_job *); extern int zfcp_fc_timeout_bsg_job(struct fc_bsg_job *);
extern void zfcp_fc_sym_name_update(struct work_struct *);
/* zfcp_fsf.c */ /* zfcp_fsf.c */
extern struct kmem_cache *zfcp_fsf_qtcb_cache; extern struct kmem_cache *zfcp_fsf_qtcb_cache;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/utsname.h>
#include <scsi/fc/fc_els.h> #include <scsi/fc/fc_els.h>
#include <scsi/libfc.h> #include <scsi/libfc.h>
#include "zfcp_ext.h" #include "zfcp_ext.h"
...@@ -696,6 +697,125 @@ void zfcp_fc_scan_ports(struct work_struct *work) ...@@ -696,6 +697,125 @@ void zfcp_fc_scan_ports(struct work_struct *work)
zfcp_fc_wka_port_put(&adapter->gs->ds); zfcp_fc_wka_port_put(&adapter->gs->ds);
} }
static int zfcp_fc_gspn(struct zfcp_adapter *adapter,
struct zfcp_fc_req *fc_req)
{
DECLARE_COMPLETION_ONSTACK(completion);
char devno[] = "DEVNO:";
struct zfcp_fsf_ct_els *ct_els = &fc_req->ct_els;
struct zfcp_fc_gspn_req *gspn_req = &fc_req->u.gspn.req;
struct zfcp_fc_gspn_rsp *gspn_rsp = &fc_req->u.gspn.rsp;
int ret;
zfcp_fc_ct_ns_init(&gspn_req->ct_hdr, FC_NS_GSPN_ID,
FC_SYMBOLIC_NAME_SIZE);
hton24(gspn_req->gspn.fp_fid, fc_host_port_id(adapter->scsi_host));
sg_init_one(&fc_req->sg_req, gspn_req, sizeof(*gspn_req));
sg_init_one(&fc_req->sg_rsp, gspn_rsp, sizeof(*gspn_rsp));
ct_els->handler = zfcp_fc_complete;
ct_els->handler_data = &completion;
ct_els->req = &fc_req->sg_req;
ct_els->resp = &fc_req->sg_rsp;
ret = zfcp_fsf_send_ct(&adapter->gs->ds, ct_els, NULL,
ZFCP_FC_CTELS_TMO);
if (ret)
return ret;
wait_for_completion(&completion);
if (ct_els->status)
return ct_els->status;
if (fc_host_port_type(adapter->scsi_host) == FC_PORTTYPE_NPIV &&
!(strstr(gspn_rsp->gspn.fp_name, devno)))
snprintf(fc_host_symbolic_name(adapter->scsi_host),
FC_SYMBOLIC_NAME_SIZE, "%s%s %s NAME: %s",
gspn_rsp->gspn.fp_name, devno,
dev_name(&adapter->ccw_device->dev),
init_utsname()->nodename);
else
strlcpy(fc_host_symbolic_name(adapter->scsi_host),
gspn_rsp->gspn.fp_name, FC_SYMBOLIC_NAME_SIZE);
return 0;
}
static void zfcp_fc_rspn(struct zfcp_adapter *adapter,
struct zfcp_fc_req *fc_req)
{
DECLARE_COMPLETION_ONSTACK(completion);
struct Scsi_Host *shost = adapter->scsi_host;
struct zfcp_fsf_ct_els *ct_els = &fc_req->ct_els;
struct zfcp_fc_rspn_req *rspn_req = &fc_req->u.rspn.req;
struct fc_ct_hdr *rspn_rsp = &fc_req->u.rspn.rsp;
int ret, len;
zfcp_fc_ct_ns_init(&rspn_req->ct_hdr, FC_NS_RSPN_ID,
FC_SYMBOLIC_NAME_SIZE);
hton24(rspn_req->rspn.fr_fid.fp_fid, fc_host_port_id(shost));
len = strlcpy(rspn_req->rspn.fr_name, fc_host_symbolic_name(shost),
FC_SYMBOLIC_NAME_SIZE);
rspn_req->rspn.fr_name_len = len;
sg_init_one(&fc_req->sg_req, rspn_req, sizeof(*rspn_req));
sg_init_one(&fc_req->sg_rsp, rspn_rsp, sizeof(*rspn_rsp));
ct_els->handler = zfcp_fc_complete;
ct_els->handler_data = &completion;
ct_els->req = &fc_req->sg_req;
ct_els->resp = &fc_req->sg_rsp;
ret = zfcp_fsf_send_ct(&adapter->gs->ds, ct_els, NULL,
ZFCP_FC_CTELS_TMO);
if (!ret)
wait_for_completion(&completion);
}
/**
* zfcp_fc_sym_name_update - Retrieve and update the symbolic port name
* @work: ns_up_work of the adapter where to update the symbolic port name
*
* Retrieve the current symbolic port name that may have been set by
* the hardware using the GSPN request and update the fc_host
* symbolic_name sysfs attribute. When running in NPIV mode (and hence
* the port name is unique for this system), update the symbolic port
* name to add Linux specific information and update the FC nameserver
* using the RSPN request.
*/
void zfcp_fc_sym_name_update(struct work_struct *work)
{
struct zfcp_adapter *adapter = container_of(work, struct zfcp_adapter,
ns_up_work);
int ret;
struct zfcp_fc_req *fc_req;
if (fc_host_port_type(adapter->scsi_host) != FC_PORTTYPE_NPORT &&
fc_host_port_type(adapter->scsi_host) != FC_PORTTYPE_NPIV)
return;
fc_req = kmem_cache_zalloc(zfcp_fc_req_cache, GFP_KERNEL);
if (!fc_req)
return;
ret = zfcp_fc_wka_port_get(&adapter->gs->ds);
if (ret)
goto out_free;
ret = zfcp_fc_gspn(adapter, fc_req);
if (ret || fc_host_port_type(adapter->scsi_host) != FC_PORTTYPE_NPIV)
goto out_ds_put;
memset(fc_req, 0, sizeof(*fc_req));
zfcp_fc_rspn(adapter, fc_req);
out_ds_put:
zfcp_fc_wka_port_put(&adapter->gs->ds);
out_free:
kmem_cache_free(zfcp_fc_req_cache, fc_req);
}
static void zfcp_fc_ct_els_job_handler(void *data) static void zfcp_fc_ct_els_job_handler(void *data)
{ {
struct fc_bsg_job *job = data; struct fc_bsg_job *job = data;
......
...@@ -83,6 +83,40 @@ struct zfcp_fc_gpn_ft_req { ...@@ -83,6 +83,40 @@ struct zfcp_fc_gpn_ft_req {
struct fc_ns_gid_ft gpn_ft; struct fc_ns_gid_ft gpn_ft;
} __packed; } __packed;
/**
* struct zfcp_fc_gspn_req - container for ct header plus GSPN_ID request
* @ct_hdr: FC GS common transport header
* @gspn: GSPN_ID request
*/
struct zfcp_fc_gspn_req {
struct fc_ct_hdr ct_hdr;
struct fc_gid_pn_resp gspn;
} __packed;
/**
* struct zfcp_fc_gspn_rsp - container for ct header plus GSPN_ID response
* @ct_hdr: FC GS common transport header
* @gspn: GSPN_ID response
* @name: The name string of the GSPN_ID response
*/
struct zfcp_fc_gspn_rsp {
struct fc_ct_hdr ct_hdr;
struct fc_gspn_resp gspn;
char name[FC_SYMBOLIC_NAME_SIZE];
} __packed;
/**
* struct zfcp_fc_rspn_req - container for ct header plus RSPN_ID request
* @ct_hdr: FC GS common transport header
* @rspn: RSPN_ID request
* @name: The name string of the RSPN_ID request
*/
struct zfcp_fc_rspn_req {
struct fc_ct_hdr ct_hdr;
struct fc_ns_rspn rspn;
char name[FC_SYMBOLIC_NAME_SIZE];
} __packed;
/** /**
* struct zfcp_fc_req - Container for FC ELS and CT requests sent from zfcp * struct zfcp_fc_req - Container for FC ELS and CT requests sent from zfcp
* @ct_els: data required for issuing fsf command * @ct_els: data required for issuing fsf command
...@@ -107,6 +141,14 @@ struct zfcp_fc_req { ...@@ -107,6 +141,14 @@ struct zfcp_fc_req {
struct scatterlist sg_rsp2[ZFCP_FC_GPN_FT_NUM_BUFS - 1]; struct scatterlist sg_rsp2[ZFCP_FC_GPN_FT_NUM_BUFS - 1];
struct zfcp_fc_gpn_ft_req req; struct zfcp_fc_gpn_ft_req req;
} gpn_ft; } gpn_ft;
struct {
struct zfcp_fc_gspn_req req;
struct zfcp_fc_gspn_rsp rsp;
} gspn;
struct {
struct zfcp_fc_rspn_req req;
struct fc_ct_hdr rsp;
} rspn;
} u; } u;
}; };
......
...@@ -720,6 +720,7 @@ struct fc_function_template zfcp_transport_functions = { ...@@ -720,6 +720,7 @@ struct fc_function_template zfcp_transport_functions = {
/* no functions registered for following dynamic attributes but /* no functions registered for following dynamic attributes but
directly set by LLDD */ directly set by LLDD */
.show_host_port_type = 1, .show_host_port_type = 1,
.show_host_symbolic_name = 1,
.show_host_speed = 1, .show_host_speed = 1,
.show_host_port_id = 1, .show_host_port_id = 1,
.dd_bsg_size = sizeof(struct zfcp_fsf_ct_els), .dd_bsg_size = sizeof(struct zfcp_fsf_ct_els),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment