9 #define KMSG_COMPONENT "zfcp"
10 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
12 #include <linux/module.h>
13 #include <linux/types.h>
14 #include <linux/slab.h>
23 static unsigned int default_depth = 32;
27 static bool enable_dif;
31 static bool allow_lun_scan = 1;
33 MODULE_PARM_DESC(allow_lun_scan,
"For NPIV, scan and attach all storage LUNs");
54 static void zfcp_scsi_slave_destroy(
struct scsi_device *sdev)
66 static int zfcp_scsi_slave_configure(
struct scsi_device *sdp)
77 set_host_byte(scpnt, result);
78 zfcp_dbf_scsi_fail_send(scpnt);
93 scsi_result = fc_remote_port_chkready(rport);
95 scpnt->
result = scsi_result;
96 zfcp_dbf_scsi_fail_send(scpnt);
104 ZFCP_STATUS_COMMON_ERP_FAILED)) {
107 zfcp_scsi_command_fail(scpnt,
DID_ERROR);
131 static int zfcp_scsi_slave_alloc(
struct scsi_device *sdev)
149 if (!unit && !(allow_lun_scan && npiv)) {
155 zfcp_sdev->
latencies.write.channel.min = 0xFFFFFFFF;
156 zfcp_sdev->
latencies.write.fabric.min = 0xFFFFFFFF;
157 zfcp_sdev->
latencies.read.channel.min = 0xFFFFFFFF;
158 zfcp_sdev->
latencies.read.fabric.min = 0xFFFFFFFF;
159 zfcp_sdev->
latencies.cmd.channel.min = 0xFFFFFFFF;
160 zfcp_sdev->
latencies.cmd.fabric.min = 0xFFFFFFFF;
170 static int zfcp_scsi_eh_abort_handler(
struct scsi_cmnd *scpnt)
177 unsigned long old_reqid = (
unsigned long) scpnt->
host_scribble;
185 old_req = zfcp_reqlist_find(adapter->
req_list, old_reqid);
188 zfcp_dbf_scsi_abort(
"abrt_or", scpnt,
NULL);
204 zfcp_dbf_scsi_abort(
"abrt_bl", scpnt,
NULL);
209 zfcp_dbf_scsi_abort(
"abrt_ru", scpnt,
NULL);
214 zfcp_dbf_scsi_abort(
"abrt_ar", scpnt,
NULL);
228 zfcp_dbf_scsi_abort(dbf_tag, scpnt, abrt_req);
233 static int zfcp_task_mgmt_function(
struct scsi_cmnd *scpnt,
u8 tm_flags)
253 zfcp_dbf_scsi_devreset(
"nres", scpnt, tm_flags);
263 zfcp_dbf_scsi_devreset(
"fail", scpnt, tm_flags);
266 zfcp_dbf_scsi_devreset(
"okay", scpnt, tm_flags);
272 static int zfcp_scsi_eh_device_reset_handler(
struct scsi_cmnd *scpnt)
277 static int zfcp_scsi_eh_target_reset_handler(
struct scsi_cmnd *scpnt)
282 static int zfcp_scsi_eh_host_reset_handler(
struct scsi_cmnd *scpnt)
302 .queuecommand = zfcp_scsi_queuecommand,
303 .eh_abort_handler = zfcp_scsi_eh_abort_handler,
304 .eh_device_reset_handler = zfcp_scsi_eh_device_reset_handler,
305 .eh_target_reset_handler = zfcp_scsi_eh_target_reset_handler,
306 .eh_host_reset_handler = zfcp_scsi_eh_host_reset_handler,
307 .slave_alloc = zfcp_scsi_slave_alloc,
308 .slave_configure = zfcp_scsi_slave_configure,
309 .slave_destroy = zfcp_scsi_slave_destroy,
310 .change_queue_depth = zfcp_scsi_change_queue_depth,
340 "Registering the FCP device with the "
341 "SCSI stack failed\n");
347 adapter->
scsi_host->max_lun = 0xFFFFFFFF;
468 fc_stats = zfcp_init_fc_host_stats(adapter);
485 zfcp_adjust_fc_host_stats(fc_stats, data,
488 zfcp_set_fc_host_stats(fc_stats, data);
494 static void zfcp_reset_fc_host_stats(
struct Scsi_Host *shost)
516 static void zfcp_get_host_port_state(
struct Scsi_Host *shost)
527 else if (status & ZFCP_STATUS_COMMON_ERP_FAILED)
533 static void zfcp_set_rport_dev_loss_tmo(
struct fc_rport *rport,
u32 timeout)
548 static void zfcp_scsi_terminate_rport_io(
struct fc_rport *rport)
563 static void zfcp_scsi_rport_register(
struct zfcp_port *port)
571 ids.node_name = port->
wwnn;
572 ids.port_name = port->
wwpn;
573 ids.port_id = port->
d_id;
579 "Registering port 0x%016Lx failed\n",
580 (
unsigned long long)port->
wwpn);
592 static void zfcp_scsi_rport_block(
struct zfcp_port *port)
642 zfcp_scsi_rport_register(port);
645 zfcp_scsi_rport_block(port);
658 unsigned int mask = 0;
659 unsigned int data_div;
669 if (enable_dif && data_div &&
678 scsi_host_set_prot(shost, mask);
699 .show_starget_port_id = 1,
700 .show_starget_port_name = 1,
701 .show_starget_node_name = 1,
702 .show_rport_supported_classes = 1,
703 .show_rport_maxframe_size = 1,
704 .show_rport_dev_loss_tmo = 1,
705 .show_host_node_name = 1,
706 .show_host_port_name = 1,
707 .show_host_permanent_port_name = 1,
708 .show_host_supported_classes = 1,
709 .show_host_supported_fc4s = 1,
710 .show_host_supported_speeds = 1,
711 .show_host_maxframe_size = 1,
712 .show_host_serial_number = 1,
713 .get_fc_host_stats = zfcp_get_fc_host_stats,
714 .reset_fc_host_stats = zfcp_reset_fc_host_stats,
715 .set_rport_dev_loss_tmo = zfcp_set_rport_dev_loss_tmo,
716 .get_host_port_state = zfcp_get_host_port_state,
717 .terminate_rport_io = zfcp_scsi_terminate_rport_io,
718 .show_host_port_state = 1,
719 .show_host_active_fc4s = 1,
724 .show_host_port_type = 1,
725 .show_host_symbolic_name = 1,
726 .show_host_speed = 1,
727 .show_host_port_id = 1,