blob: cb000c9833bbcee0bf687cc5f31eccf90769ae0b [file] [log] [blame]
Swen Schillig41fa2ad2007-09-07 09:15:31 +02001/*
Christof Schmitt553448f2008-06-10 18:20:58 +02002 * zfcp device driver
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
Christof Schmitt553448f2008-06-10 18:20:58 +02004 * Interface to Linux SCSI midlayer.
Swen Schillig41fa2ad2007-09-07 09:15:31 +02005 *
Christof Schmitt615f59e2010-02-17 11:18:56 +01006 * Copyright IBM Corporation 2002, 2010
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 */
8
Christof Schmittecf39d42008-12-25 13:39:53 +01009#define KMSG_COMPONENT "zfcp"
10#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
11
Christof Schmitt4318e082009-11-24 16:54:08 +010012#include <linux/types.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090013#include <linux/slab.h>
Christof Schmitt4318e082009-11-24 16:54:08 +010014#include <scsi/fc/fc_fcp.h>
Felix Beckef3eb712010-07-16 15:37:42 +020015#include <scsi/scsi_eh.h>
Christof Schmitt5f852be2007-05-08 11:16:52 +020016#include <asm/atomic.h>
Christof Schmittdcd20e22009-08-18 15:43:08 +020017#include "zfcp_ext.h"
18#include "zfcp_dbf.h"
Christof Schmitt7c7dc192009-11-24 16:54:13 +010019#include "zfcp_fc.h"
Christof Schmittb6bd2fb2010-02-17 11:18:50 +010020#include "zfcp_reqlist.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
Christof Schmitta40a1ba2009-05-15 13:18:16 +020022static unsigned int default_depth = 32;
23module_param_named(queue_depth, default_depth, uint, 0600);
24MODULE_PARM_DESC(queue_depth, "Default queue depth for new SCSI devices");
25
Felix Beckef3eb712010-07-16 15:37:42 +020026static bool enable_dif;
27
28#ifdef CONFIG_ZFCP_DIF
29module_param_named(dif, enable_dif, bool, 0600);
30MODULE_PARM_DESC(dif, "Enable DIF/DIX data integrity support");
31#endif
32
Mike Christiee881a172009-10-15 17:46:39 -070033static int zfcp_scsi_change_queue_depth(struct scsi_device *sdev, int depth,
34 int reason)
Christof Schmitta40a1ba2009-05-15 13:18:16 +020035{
Christof Schmitt42e62a72009-10-15 17:47:11 -070036 switch (reason) {
37 case SCSI_QDEPTH_DEFAULT:
38 scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), depth);
39 break;
40 case SCSI_QDEPTH_QFULL:
41 scsi_track_queue_full(sdev, depth);
42 break;
43 case SCSI_QDEPTH_RAMP_UP:
44 scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), depth);
45 break;
46 default:
Mike Christiee881a172009-10-15 17:46:39 -070047 return -EOPNOTSUPP;
Christof Schmitt42e62a72009-10-15 17:47:11 -070048 }
Christof Schmitta40a1ba2009-05-15 13:18:16 +020049 return sdev->queue_depth;
50}
51
Andreas Herrmannf6c0e7a2006-08-02 11:05:52 +020052static void zfcp_scsi_slave_destroy(struct scsi_device *sdpnt)
Linus Torvalds1da177e2005-04-16 15:20:36 -070053{
54 struct zfcp_unit *unit = (struct zfcp_unit *) sdpnt->hostdata;
Christof Schmitt26816f12008-11-04 16:35:05 +010055 unit->device = NULL;
Christof Schmitt615f59e2010-02-17 11:18:56 +010056 put_device(&unit->dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070057}
58
Martin Petermannf76af7d72008-07-02 10:56:36 +020059static int zfcp_scsi_slave_configure(struct scsi_device *sdp)
Linus Torvalds1da177e2005-04-16 15:20:36 -070060{
61 if (sdp->tagged_supported)
Christof Schmitta40a1ba2009-05-15 13:18:16 +020062 scsi_adjust_queue_depth(sdp, MSG_SIMPLE_TAG, default_depth);
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 else
64 scsi_adjust_queue_depth(sdp, 0, 1);
65 return 0;
66}
67
Martin Petermannf76af7d72008-07-02 10:56:36 +020068static void zfcp_scsi_command_fail(struct scsi_cmnd *scpnt, int result)
Linus Torvalds1da177e2005-04-16 15:20:36 -070069{
Swen Schillig57717102009-08-18 15:43:21 +020070 struct zfcp_adapter *adapter =
71 (struct zfcp_adapter *) scpnt->device->host->hostdata[0];
Christof Schmitt22ed1302010-02-17 11:18:53 +010072
Martin Petermannfeac6a02008-07-02 10:56:35 +020073 set_host_byte(scpnt, result);
Christof Schmittab725282010-02-17 11:18:57 +010074 zfcp_dbf_scsi_fail_send(adapter->dbf, scpnt);
Linus Torvalds1da177e2005-04-16 15:20:36 -070075 scpnt->scsi_done(scpnt);
76}
77
Martin Petermannf76af7d72008-07-02 10:56:36 +020078static int zfcp_scsi_queuecommand(struct scsi_cmnd *scpnt,
79 void (*done) (struct scsi_cmnd *))
Linus Torvalds1da177e2005-04-16 15:20:36 -070080{
81 struct zfcp_unit *unit;
82 struct zfcp_adapter *adapter;
Christof Schmitta2fa0ae2009-03-02 13:09:08 +010083 int status, scsi_result, ret;
84 struct fc_rport *rport = starget_to_rport(scsi_target(scpnt->device));
Linus Torvalds1da177e2005-04-16 15:20:36 -070085
86 /* reset the status for this request */
87 scpnt->result = 0;
88 scpnt->host_scribble = NULL;
89 scpnt->scsi_done = done;
90
91 /*
92 * figure out adapter and target device
93 * (stored there by zfcp_scsi_slave_alloc)
94 */
95 adapter = (struct zfcp_adapter *) scpnt->device->host->hostdata[0];
Martin Petermannf76af7d72008-07-02 10:56:36 +020096 unit = scpnt->device->hostdata;
Linus Torvalds1da177e2005-04-16 15:20:36 -070097
Christof Schmitta2fa0ae2009-03-02 13:09:08 +010098 scsi_result = fc_remote_port_chkready(rport);
99 if (unlikely(scsi_result)) {
100 scpnt->result = scsi_result;
Christof Schmittab725282010-02-17 11:18:57 +0100101 zfcp_dbf_scsi_fail_send(adapter->dbf, scpnt);
Christof Schmitta2fa0ae2009-03-02 13:09:08 +0100102 scpnt->scsi_done(scpnt);
103 return 0;
104 }
105
Martin Petermannf76af7d72008-07-02 10:56:36 +0200106 status = atomic_read(&unit->status);
Christof Schmitt88302712009-11-24 16:54:07 +0100107 if (unlikely(status & ZFCP_STATUS_COMMON_ERP_FAILED) &&
108 !(atomic_read(&unit->port->status) &
109 ZFCP_STATUS_COMMON_ERP_FAILED)) {
110 /* only unit access denied, but port is good
111 * not covered by FC transport, have to fail here */
Martin Petermannf76af7d72008-07-02 10:56:36 +0200112 zfcp_scsi_command_fail(scpnt, DID_ERROR);
Joe Perchesa419aef2009-08-18 11:18:35 -0700113 return 0;
Martin Petermannf76af7d72008-07-02 10:56:36 +0200114 }
115
Christof Schmitt88302712009-11-24 16:54:07 +0100116 if (unlikely(!(status & ZFCP_STATUS_COMMON_UNBLOCKED))) {
117 /* This could be either
118 * open unit pending: this is temporary, will result in
119 * open unit or ERP_FAILED, so retry command
120 * call to rport_delete pending: mimic retry from
121 * fc_remote_port_chkready until rport is BLOCKED
122 */
123 zfcp_scsi_command_fail(scpnt, DID_IMM_RETRY);
124 return 0;
125 }
126
Christof Schmitt63caf362009-03-02 13:09:00 +0100127 ret = zfcp_fsf_send_fcp_command_task(unit, scpnt);
Martin Petermannf76af7d72008-07-02 10:56:36 +0200128 if (unlikely(ret == -EBUSY))
Swen Schilligf7a65e92008-11-27 11:44:07 +0100129 return SCSI_MLQUEUE_DEVICE_BUSY;
Martin Petermannf76af7d72008-07-02 10:56:36 +0200130 else if (unlikely(ret < 0))
131 return SCSI_MLQUEUE_HOST_BUSY;
132
133 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134}
135
Martin Petermannf76af7d72008-07-02 10:56:36 +0200136static struct zfcp_unit *zfcp_unit_lookup(struct zfcp_adapter *adapter,
Swen Schilligecf0c772009-11-24 16:53:58 +0100137 unsigned int id, u64 lun)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138{
Swen Schilligecf0c772009-11-24 16:53:58 +0100139 unsigned long flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 struct zfcp_port *port;
Swen Schilligecf0c772009-11-24 16:53:58 +0100141 struct zfcp_unit *unit = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142
Swen Schilligecf0c772009-11-24 16:53:58 +0100143 read_lock_irqsave(&adapter->port_list_lock, flags);
144 list_for_each_entry(port, &adapter->port_list, list) {
Andreas Herrmann3859f6a2005-08-27 11:07:54 -0700145 if (!port->rport || (id != port->rport->scsi_target_id))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 continue;
Swen Schilligecf0c772009-11-24 16:53:58 +0100147 unit = zfcp_get_unit_by_lun(port, lun);
148 if (unit)
149 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 }
Swen Schilligecf0c772009-11-24 16:53:58 +0100151 read_unlock_irqrestore(&adapter->port_list_lock, flags);
Martin Petermannf76af7d72008-07-02 10:56:36 +0200152
Swen Schilligecf0c772009-11-24 16:53:58 +0100153 return unit;
Martin Petermannf76af7d72008-07-02 10:56:36 +0200154}
155
156static int zfcp_scsi_slave_alloc(struct scsi_device *sdp)
157{
158 struct zfcp_adapter *adapter;
159 struct zfcp_unit *unit;
Swen Schilligecf0c772009-11-24 16:53:58 +0100160 u64 lun;
Martin Petermannf76af7d72008-07-02 10:56:36 +0200161
162 adapter = (struct zfcp_adapter *) sdp->host->hostdata[0];
163 if (!adapter)
164 goto out;
165
Swen Schilligecf0c772009-11-24 16:53:58 +0100166 int_to_scsilun(sdp->lun, (struct scsi_lun *)&lun);
167 unit = zfcp_unit_lookup(adapter, sdp->id, lun);
Christof Schmitt86f8a1b2009-03-02 13:08:55 +0100168 if (unit) {
Martin Petermannf76af7d72008-07-02 10:56:36 +0200169 sdp->hostdata = unit;
170 unit->device = sdp;
Swen Schilligecf0c772009-11-24 16:53:58 +0100171 return 0;
Martin Petermannf76af7d72008-07-02 10:56:36 +0200172 }
Martin Petermannf76af7d72008-07-02 10:56:36 +0200173out:
Swen Schilligecf0c772009-11-24 16:53:58 +0100174 return -ENXIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175}
176
Heiko Carstens2b67fc42007-02-05 21:16:47 +0100177static int zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178{
Christof Schmitt63caf362009-03-02 13:09:00 +0100179 struct Scsi_Host *scsi_host = scpnt->device->host;
180 struct zfcp_adapter *adapter =
181 (struct zfcp_adapter *) scsi_host->hostdata[0];
182 struct zfcp_unit *unit = scpnt->device->hostdata;
183 struct zfcp_fsf_req *old_req, *abrt_req;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 unsigned long flags;
Christof Schmitta11a52b2009-07-13 15:06:14 +0200185 unsigned long old_reqid = (unsigned long) scpnt->host_scribble;
Christof Schmitta1dbfdd2010-03-24 16:50:31 +0100186 int retval = SUCCESS, ret;
Christof Schmitt63caf362009-03-02 13:09:00 +0100187 int retry = 3;
Christof Schmitta11a52b2009-07-13 15:06:14 +0200188 char *dbf_tag;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189
Andreas Herrmann059c97d2005-09-13 21:47:52 +0200190 /* avoid race condition between late normal completion and abort */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 write_lock_irqsave(&adapter->abort_lock, flags);
192
Christof Schmittb6bd2fb2010-02-17 11:18:50 +0100193 old_req = zfcp_reqlist_find(adapter->req_list, old_reqid);
Christof Schmitt63caf362009-03-02 13:09:00 +0100194 if (!old_req) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195 write_unlock_irqrestore(&adapter->abort_lock, flags);
Swen Schillig57717102009-08-18 15:43:21 +0200196 zfcp_dbf_scsi_abort("lte1", adapter->dbf, scpnt, NULL,
197 old_reqid);
Christof Schmittc6936e72009-04-17 15:08:11 +0200198 return FAILED; /* completion could be in progress */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199 }
Christof Schmitt63caf362009-03-02 13:09:00 +0100200 old_req->data = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201
Andreas Herrmann4eff4a32006-09-18 22:29:20 +0200202 /* don't access old fsf_req after releasing the abort_lock */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 write_unlock_irqrestore(&adapter->abort_lock, flags);
Andreas Herrmann4eff4a32006-09-18 22:29:20 +0200204
Christof Schmitt63caf362009-03-02 13:09:00 +0100205 while (retry--) {
Christof Schmitta11a52b2009-07-13 15:06:14 +0200206 abrt_req = zfcp_fsf_abort_fcp_command(old_reqid, unit);
Christof Schmitt63caf362009-03-02 13:09:00 +0100207 if (abrt_req)
208 break;
209
210 zfcp_erp_wait(adapter);
Christof Schmitta1dbfdd2010-03-24 16:50:31 +0100211 ret = fc_block_scsi_eh(scpnt);
212 if (ret)
213 return ret;
Christof Schmitt63caf362009-03-02 13:09:00 +0100214 if (!(atomic_read(&adapter->status) &
215 ZFCP_STATUS_COMMON_RUNNING)) {
Swen Schillig57717102009-08-18 15:43:21 +0200216 zfcp_dbf_scsi_abort("nres", adapter->dbf, scpnt, NULL,
217 old_reqid);
Christof Schmitt63caf362009-03-02 13:09:00 +0100218 return SUCCESS;
219 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220 }
Christof Schmitt63caf362009-03-02 13:09:00 +0100221 if (!abrt_req)
222 return FAILED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223
Swen Schillig058b8642009-08-18 15:43:14 +0200224 wait_for_completion(&abrt_req->completion);
Andreas Herrmann059c97d2005-09-13 21:47:52 +0200225
Christof Schmitt63caf362009-03-02 13:09:00 +0100226 if (abrt_req->status & ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED)
Christof Schmitta11a52b2009-07-13 15:06:14 +0200227 dbf_tag = "okay";
Christof Schmitt63caf362009-03-02 13:09:00 +0100228 else if (abrt_req->status & ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED)
Christof Schmitta11a52b2009-07-13 15:06:14 +0200229 dbf_tag = "lte2";
Christof Schmitt63caf362009-03-02 13:09:00 +0100230 else {
Christof Schmitta11a52b2009-07-13 15:06:14 +0200231 dbf_tag = "fail";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232 retval = FAILED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233 }
Swen Schillig57717102009-08-18 15:43:21 +0200234 zfcp_dbf_scsi_abort(dbf_tag, adapter->dbf, scpnt, abrt_req, old_reqid);
Christof Schmitt63caf362009-03-02 13:09:00 +0100235 zfcp_fsf_req_free(abrt_req);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 return retval;
237}
238
Christof Schmitt63caf362009-03-02 13:09:00 +0100239static int zfcp_task_mgmt_function(struct scsi_cmnd *scpnt, u8 tm_flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240{
Christof Schmitt63caf362009-03-02 13:09:00 +0100241 struct zfcp_unit *unit = scpnt->device->hostdata;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 struct zfcp_adapter *adapter = unit->port->adapter;
Swen Schillig564e1c82009-08-18 15:43:19 +0200243 struct zfcp_fsf_req *fsf_req = NULL;
Christof Schmitta1dbfdd2010-03-24 16:50:31 +0100244 int retval = SUCCESS, ret;
Christof Schmitt63caf362009-03-02 13:09:00 +0100245 int retry = 3;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246
Christof Schmitt63caf362009-03-02 13:09:00 +0100247 while (retry--) {
248 fsf_req = zfcp_fsf_send_fcp_ctm(unit, tm_flags);
249 if (fsf_req)
250 break;
251
252 zfcp_erp_wait(adapter);
Christof Schmitta1dbfdd2010-03-24 16:50:31 +0100253 ret = fc_block_scsi_eh(scpnt);
254 if (ret)
255 return ret;
256
Christof Schmitt63caf362009-03-02 13:09:00 +0100257 if (!(atomic_read(&adapter->status) &
258 ZFCP_STATUS_COMMON_RUNNING)) {
Swen Schillig57717102009-08-18 15:43:21 +0200259 zfcp_dbf_scsi_devreset("nres", tm_flags, unit, scpnt);
Christof Schmitt63caf362009-03-02 13:09:00 +0100260 return SUCCESS;
261 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262 }
Christof Schmitt63caf362009-03-02 13:09:00 +0100263 if (!fsf_req)
264 return FAILED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265
Swen Schillig058b8642009-08-18 15:43:14 +0200266 wait_for_completion(&fsf_req->completion);
Andreas Herrmann77eb1692005-09-13 21:48:33 +0200267
Maxim Shchetynin8a36e452005-09-13 21:50:38 +0200268 if (fsf_req->status & ZFCP_STATUS_FSFREQ_TMFUNCFAILED) {
Swen Schillig57717102009-08-18 15:43:21 +0200269 zfcp_dbf_scsi_devreset("fail", tm_flags, unit, scpnt);
Martin Petermannf76af7d72008-07-02 10:56:36 +0200270 retval = FAILED;
Maxim Shchetynin8a36e452005-09-13 21:50:38 +0200271 } else
Swen Schillig57717102009-08-18 15:43:21 +0200272 zfcp_dbf_scsi_devreset("okay", tm_flags, unit, scpnt);
Andreas Herrmann77eb1692005-09-13 21:48:33 +0200273
274 zfcp_fsf_req_free(fsf_req);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275 return retval;
276}
277
Martin Petermannf76af7d72008-07-02 10:56:36 +0200278static int zfcp_scsi_eh_device_reset_handler(struct scsi_cmnd *scpnt)
279{
Christof Schmitt4318e082009-11-24 16:54:08 +0100280 return zfcp_task_mgmt_function(scpnt, FCP_TMF_LUN_RESET);
Martin Petermannf76af7d72008-07-02 10:56:36 +0200281}
282
283static int zfcp_scsi_eh_target_reset_handler(struct scsi_cmnd *scpnt)
284{
Christof Schmitt4318e082009-11-24 16:54:08 +0100285 return zfcp_task_mgmt_function(scpnt, FCP_TMF_TGT_RESET);
Martin Petermannf76af7d72008-07-02 10:56:36 +0200286}
287
Heiko Carstens2b67fc42007-02-05 21:16:47 +0100288static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289{
Christof Schmitt63caf362009-03-02 13:09:00 +0100290 struct zfcp_unit *unit = scpnt->device->hostdata;
291 struct zfcp_adapter *adapter = unit->port->adapter;
Christof Schmitta1dbfdd2010-03-24 16:50:31 +0100292 int ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293
Swen Schillig5ffd51a2009-03-02 13:09:04 +0100294 zfcp_erp_adapter_reopen(adapter, 0, "schrh_1", scpnt);
Andreas Herrmann81654282006-09-18 22:30:36 +0200295 zfcp_erp_wait(adapter);
Christof Schmitta1dbfdd2010-03-24 16:50:31 +0100296 ret = fc_block_scsi_eh(scpnt);
297 if (ret)
298 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299
Andreas Herrmann810f1e3e2005-09-13 21:49:52 +0200300 return SUCCESS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301}
302
Martin Petermannf76af7d72008-07-02 10:56:36 +0200303int zfcp_adapter_scsi_register(struct zfcp_adapter *adapter)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304{
Martin Petermannf76af7d72008-07-02 10:56:36 +0200305 struct ccw_dev_id dev_id;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306
Michael Loehr9f287452007-05-09 11:01:24 +0200307 if (adapter->scsi_host)
Martin Petermannf76af7d72008-07-02 10:56:36 +0200308 return 0;
Michael Loehr9f287452007-05-09 11:01:24 +0200309
Martin Petermannf76af7d72008-07-02 10:56:36 +0200310 ccw_device_get_id(adapter->ccw_device, &dev_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 /* register adapter as SCSI host with mid layer of SCSI stack */
312 adapter->scsi_host = scsi_host_alloc(&zfcp_data.scsi_host_template,
313 sizeof (struct zfcp_adapter *));
314 if (!adapter->scsi_host) {
Christof Schmitt553448f2008-06-10 18:20:58 +0200315 dev_err(&adapter->ccw_device->dev,
Christof Schmittff3b24f2008-10-01 12:42:15 +0200316 "Registering the FCP device with the "
317 "SCSI stack failed\n");
Martin Petermannf76af7d72008-07-02 10:56:36 +0200318 return -EIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320
321 /* tell the SCSI stack some characteristics of this adapter */
322 adapter->scsi_host->max_id = 1;
323 adapter->scsi_host->max_lun = 1;
324 adapter->scsi_host->max_channel = 0;
Martin Petermannf76af7d72008-07-02 10:56:36 +0200325 adapter->scsi_host->unique_id = dev_id.devno;
Christof Schmitt4318e082009-11-24 16:54:08 +0100326 adapter->scsi_host->max_cmd_len = 16; /* in struct fcp_cmnd */
Heiko Carstensdd52e0e2006-09-18 22:28:49 +0200327 adapter->scsi_host->transportt = zfcp_data.scsi_transport_template;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329 adapter->scsi_host->hostdata[0] = (unsigned long) adapter;
330
331 if (scsi_add_host(adapter->scsi_host, &adapter->ccw_device->dev)) {
332 scsi_host_put(adapter->scsi_host);
Martin Petermannf76af7d72008-07-02 10:56:36 +0200333 return -EIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 }
Martin Petermannf76af7d72008-07-02 10:56:36 +0200335
336 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337}
338
Martin Petermannf76af7d72008-07-02 10:56:36 +0200339void zfcp_adapter_scsi_unregister(struct zfcp_adapter *adapter)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340{
341 struct Scsi_Host *shost;
Andreas Herrmann13e1e1f2005-09-19 16:56:17 +0200342 struct zfcp_port *port;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343
344 shost = adapter->scsi_host;
345 if (!shost)
346 return;
Martin Petermannf76af7d72008-07-02 10:56:36 +0200347
Swen Schilligecf0c772009-11-24 16:53:58 +0100348 read_lock_irq(&adapter->port_list_lock);
349 list_for_each_entry(port, &adapter->port_list, list)
Swen Schilligf3450c72009-11-24 16:53:59 +0100350 port->rport = NULL;
Swen Schilligecf0c772009-11-24 16:53:58 +0100351 read_unlock_irq(&adapter->port_list_lock);
Martin Petermannf76af7d72008-07-02 10:56:36 +0200352
Andreas Herrmann3859f6a2005-08-27 11:07:54 -0700353 fc_remove_host(shost);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 scsi_remove_host(shost);
355 scsi_host_put(shost);
356 adapter->scsi_host = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357
358 return;
359}
360
Andreas Herrmannf6cd94b2006-01-05 09:59:34 +0100361static struct fc_host_statistics*
362zfcp_init_fc_host_stats(struct zfcp_adapter *adapter)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363{
Andreas Herrmannf6cd94b2006-01-05 09:59:34 +0100364 struct fc_host_statistics *fc_stats;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365
Andreas Herrmannf6cd94b2006-01-05 09:59:34 +0100366 if (!adapter->fc_stats) {
367 fc_stats = kmalloc(sizeof(*fc_stats), GFP_KERNEL);
368 if (!fc_stats)
369 return NULL;
Swen Schilligf3450c72009-11-24 16:53:59 +0100370 adapter->fc_stats = fc_stats; /* freed in adapter_release */
Andreas Herrmannf6cd94b2006-01-05 09:59:34 +0100371 }
372 memset(adapter->fc_stats, 0, sizeof(*adapter->fc_stats));
373 return adapter->fc_stats;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374}
375
Martin Petermannf76af7d72008-07-02 10:56:36 +0200376static void zfcp_adjust_fc_host_stats(struct fc_host_statistics *fc_stats,
377 struct fsf_qtcb_bottom_port *data,
378 struct fsf_qtcb_bottom_port *old)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379{
Martin Petermannf76af7d72008-07-02 10:56:36 +0200380 fc_stats->seconds_since_last_reset =
381 data->seconds_since_last_reset - old->seconds_since_last_reset;
Andreas Herrmannf6cd94b2006-01-05 09:59:34 +0100382 fc_stats->tx_frames = data->tx_frames - old->tx_frames;
383 fc_stats->tx_words = data->tx_words - old->tx_words;
384 fc_stats->rx_frames = data->rx_frames - old->rx_frames;
385 fc_stats->rx_words = data->rx_words - old->rx_words;
386 fc_stats->lip_count = data->lip - old->lip;
387 fc_stats->nos_count = data->nos - old->nos;
388 fc_stats->error_frames = data->error_frames - old->error_frames;
389 fc_stats->dumped_frames = data->dumped_frames - old->dumped_frames;
390 fc_stats->link_failure_count = data->link_failure - old->link_failure;
391 fc_stats->loss_of_sync_count = data->loss_of_sync - old->loss_of_sync;
Martin Petermannf76af7d72008-07-02 10:56:36 +0200392 fc_stats->loss_of_signal_count =
393 data->loss_of_signal - old->loss_of_signal;
394 fc_stats->prim_seq_protocol_err_count =
395 data->psp_error_counts - old->psp_error_counts;
396 fc_stats->invalid_tx_word_count =
397 data->invalid_tx_words - old->invalid_tx_words;
Andreas Herrmannf6cd94b2006-01-05 09:59:34 +0100398 fc_stats->invalid_crc_count = data->invalid_crcs - old->invalid_crcs;
Martin Petermannf76af7d72008-07-02 10:56:36 +0200399 fc_stats->fcp_input_requests =
400 data->input_requests - old->input_requests;
401 fc_stats->fcp_output_requests =
402 data->output_requests - old->output_requests;
403 fc_stats->fcp_control_requests =
404 data->control_requests - old->control_requests;
Andreas Herrmannf6cd94b2006-01-05 09:59:34 +0100405 fc_stats->fcp_input_megabytes = data->input_mb - old->input_mb;
406 fc_stats->fcp_output_megabytes = data->output_mb - old->output_mb;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407}
408
Martin Petermannf76af7d72008-07-02 10:56:36 +0200409static void zfcp_set_fc_host_stats(struct fc_host_statistics *fc_stats,
410 struct fsf_qtcb_bottom_port *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411{
Andreas Herrmannf6cd94b2006-01-05 09:59:34 +0100412 fc_stats->seconds_since_last_reset = data->seconds_since_last_reset;
413 fc_stats->tx_frames = data->tx_frames;
414 fc_stats->tx_words = data->tx_words;
415 fc_stats->rx_frames = data->rx_frames;
416 fc_stats->rx_words = data->rx_words;
417 fc_stats->lip_count = data->lip;
418 fc_stats->nos_count = data->nos;
419 fc_stats->error_frames = data->error_frames;
420 fc_stats->dumped_frames = data->dumped_frames;
421 fc_stats->link_failure_count = data->link_failure;
422 fc_stats->loss_of_sync_count = data->loss_of_sync;
423 fc_stats->loss_of_signal_count = data->loss_of_signal;
424 fc_stats->prim_seq_protocol_err_count = data->psp_error_counts;
425 fc_stats->invalid_tx_word_count = data->invalid_tx_words;
426 fc_stats->invalid_crc_count = data->invalid_crcs;
427 fc_stats->fcp_input_requests = data->input_requests;
428 fc_stats->fcp_output_requests = data->output_requests;
429 fc_stats->fcp_control_requests = data->control_requests;
430 fc_stats->fcp_input_megabytes = data->input_mb;
431 fc_stats->fcp_output_megabytes = data->output_mb;
432}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433
Martin Petermannf76af7d72008-07-02 10:56:36 +0200434static struct fc_host_statistics *zfcp_get_fc_host_stats(struct Scsi_Host *host)
Andreas Herrmannf6cd94b2006-01-05 09:59:34 +0100435{
436 struct zfcp_adapter *adapter;
437 struct fc_host_statistics *fc_stats;
438 struct fsf_qtcb_bottom_port *data;
439 int ret;
440
Martin Petermannf76af7d72008-07-02 10:56:36 +0200441 adapter = (struct zfcp_adapter *)host->hostdata[0];
Andreas Herrmannf6cd94b2006-01-05 09:59:34 +0100442 fc_stats = zfcp_init_fc_host_stats(adapter);
443 if (!fc_stats)
444 return NULL;
445
Andreas Herrmannec4081c2006-05-22 18:17:30 +0200446 data = kzalloc(sizeof(*data), GFP_KERNEL);
Andreas Herrmannf6cd94b2006-01-05 09:59:34 +0100447 if (!data)
448 return NULL;
Andreas Herrmannf6cd94b2006-01-05 09:59:34 +0100449
Swen Schillig564e1c82009-08-18 15:43:19 +0200450 ret = zfcp_fsf_exchange_port_data_sync(adapter->qdio, data);
Andreas Herrmannf6cd94b2006-01-05 09:59:34 +0100451 if (ret) {
452 kfree(data);
Martin Petermannf76af7d72008-07-02 10:56:36 +0200453 return NULL;
Andreas Herrmannf6cd94b2006-01-05 09:59:34 +0100454 }
455
456 if (adapter->stats_reset &&
457 ((jiffies/HZ - adapter->stats_reset) <
Martin Petermannf76af7d72008-07-02 10:56:36 +0200458 data->seconds_since_last_reset))
Andreas Herrmannf6cd94b2006-01-05 09:59:34 +0100459 zfcp_adjust_fc_host_stats(fc_stats, data,
460 adapter->stats_reset_data);
Martin Petermannf76af7d72008-07-02 10:56:36 +0200461 else
Andreas Herrmannf6cd94b2006-01-05 09:59:34 +0100462 zfcp_set_fc_host_stats(fc_stats, data);
463
464 kfree(data);
465 return fc_stats;
466}
467
Martin Petermannf76af7d72008-07-02 10:56:36 +0200468static void zfcp_reset_fc_host_stats(struct Scsi_Host *shost)
Andreas Herrmannf6cd94b2006-01-05 09:59:34 +0100469{
470 struct zfcp_adapter *adapter;
Martin Petermannf76af7d72008-07-02 10:56:36 +0200471 struct fsf_qtcb_bottom_port *data;
Andreas Herrmannf6cd94b2006-01-05 09:59:34 +0100472 int ret;
473
474 adapter = (struct zfcp_adapter *)shost->hostdata[0];
Andreas Herrmannec4081c2006-05-22 18:17:30 +0200475 data = kzalloc(sizeof(*data), GFP_KERNEL);
Andreas Herrmannf6cd94b2006-01-05 09:59:34 +0100476 if (!data)
477 return;
Andreas Herrmannf6cd94b2006-01-05 09:59:34 +0100478
Swen Schillig564e1c82009-08-18 15:43:19 +0200479 ret = zfcp_fsf_exchange_port_data_sync(adapter->qdio, data);
Martin Petermannf76af7d72008-07-02 10:56:36 +0200480 if (ret)
Heiko Carstens83f6d6d2007-08-08 10:47:02 +0200481 kfree(data);
Martin Petermannf76af7d72008-07-02 10:56:36 +0200482 else {
Andreas Herrmannf6cd94b2006-01-05 09:59:34 +0100483 adapter->stats_reset = jiffies/HZ;
Martin Petermannf76af7d72008-07-02 10:56:36 +0200484 kfree(adapter->stats_reset_data);
Andreas Herrmannf6cd94b2006-01-05 09:59:34 +0100485 adapter->stats_reset_data = data; /* finally freed in
Swen Schilligf3450c72009-11-24 16:53:59 +0100486 adapter_release */
Andreas Herrmannf6cd94b2006-01-05 09:59:34 +0100487 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488}
489
Sven Schuetz85a82392008-06-10 18:20:59 +0200490static void zfcp_get_host_port_state(struct Scsi_Host *shost)
491{
492 struct zfcp_adapter *adapter =
493 (struct zfcp_adapter *)shost->hostdata[0];
494 int status = atomic_read(&adapter->status);
495
496 if ((status & ZFCP_STATUS_COMMON_RUNNING) &&
497 !(status & ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED))
498 fc_host_port_state(shost) = FC_PORTSTATE_ONLINE;
499 else if (status & ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED)
500 fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN;
501 else if (status & ZFCP_STATUS_COMMON_ERP_FAILED)
502 fc_host_port_state(shost) = FC_PORTSTATE_ERROR;
503 else
504 fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN;
505}
506
Andreas Herrmann338151e2006-05-22 18:25:56 +0200507static void zfcp_set_rport_dev_loss_tmo(struct fc_rport *rport, u32 timeout)
508{
509 rport->dev_loss_tmo = timeout;
510}
511
Christof Schmitta2fa0ae2009-03-02 13:09:08 +0100512/**
Christof Schmitta2fa0ae2009-03-02 13:09:08 +0100513 * zfcp_scsi_terminate_rport_io - Terminate all I/O on a rport
514 * @rport: The FC rport where to teminate I/O
515 *
516 * Abort all pending SCSI commands for a port by closing the
Christof Schmitt835dc292010-07-08 09:53:08 +0200517 * port. Using a reopen avoids a conflict with a shutdown
518 * overwriting a reopen. The "forced" ensures that a disappeared port
519 * is not opened again as valid due to the cached plogi data in
520 * non-NPIV mode.
Christof Schmitta2fa0ae2009-03-02 13:09:08 +0100521 */
522static void zfcp_scsi_terminate_rport_io(struct fc_rport *rport)
523{
Christof Schmitt70932932009-04-17 15:08:15 +0200524 struct zfcp_port *port;
Swen Schilligea945ff2009-08-18 15:43:24 +0200525 struct Scsi_Host *shost = rport_to_shost(rport);
526 struct zfcp_adapter *adapter =
527 (struct zfcp_adapter *)shost->hostdata[0];
Christof Schmitta2fa0ae2009-03-02 13:09:08 +0100528
Swen Schilligea945ff2009-08-18 15:43:24 +0200529 port = zfcp_get_port_by_wwpn(adapter, rport->port_name);
Christof Schmitt70932932009-04-17 15:08:15 +0200530
531 if (port) {
Christof Schmitt835dc292010-07-08 09:53:08 +0200532 zfcp_erp_port_forced_reopen(port, 0, "sctrpi1", NULL);
Christof Schmitt615f59e2010-02-17 11:18:56 +0100533 put_device(&port->dev);
Christof Schmitt70932932009-04-17 15:08:15 +0200534 }
Christof Schmitta2fa0ae2009-03-02 13:09:08 +0100535}
536
Christof Schmitt5a7de552010-07-08 09:53:07 +0200537static void zfcp_scsi_queue_unit_register(struct zfcp_port *port)
538{
539 struct zfcp_unit *unit;
540
541 read_lock_irq(&port->unit_list_lock);
542 list_for_each_entry(unit, &port->unit_list, list) {
543 get_device(&unit->dev);
544 if (scsi_queue_work(port->adapter->scsi_host,
545 &unit->scsi_work) <= 0)
546 put_device(&unit->dev);
547 }
548 read_unlock_irq(&port->unit_list_lock);
549}
550
Christof Schmitta2fa0ae2009-03-02 13:09:08 +0100551static void zfcp_scsi_rport_register(struct zfcp_port *port)
552{
553 struct fc_rport_identifiers ids;
554 struct fc_rport *rport;
555
Christof Schmitt379d6bf2009-07-13 15:06:11 +0200556 if (port->rport)
557 return;
558
Christof Schmitta2fa0ae2009-03-02 13:09:08 +0100559 ids.node_name = port->wwnn;
560 ids.port_name = port->wwpn;
561 ids.port_id = port->d_id;
562 ids.roles = FC_RPORT_ROLE_FCP_TARGET;
563
564 rport = fc_remote_port_add(port->adapter->scsi_host, 0, &ids);
565 if (!rport) {
566 dev_err(&port->adapter->ccw_device->dev,
567 "Registering port 0x%016Lx failed\n",
568 (unsigned long long)port->wwpn);
569 return;
570 }
571
Christof Schmitta2fa0ae2009-03-02 13:09:08 +0100572 rport->maxframe_size = port->maxframe_size;
573 rport->supported_classes = port->supported_classes;
574 port->rport = rport;
Christof Schmitt1bf3ff02010-07-16 15:37:35 +0200575 port->starget_id = rport->scsi_target_id;
Christof Schmitt5a7de552010-07-08 09:53:07 +0200576
577 zfcp_scsi_queue_unit_register(port);
Christof Schmitta2fa0ae2009-03-02 13:09:08 +0100578}
579
580static void zfcp_scsi_rport_block(struct zfcp_port *port)
581{
Christof Schmitt70932932009-04-17 15:08:15 +0200582 struct fc_rport *rport = port->rport;
583
Christof Schmitt379d6bf2009-07-13 15:06:11 +0200584 if (rport) {
Christof Schmitt70932932009-04-17 15:08:15 +0200585 fc_remote_port_delete(rport);
Christof Schmitt379d6bf2009-07-13 15:06:11 +0200586 port->rport = NULL;
587 }
Christof Schmitta2fa0ae2009-03-02 13:09:08 +0100588}
589
590void zfcp_scsi_schedule_rport_register(struct zfcp_port *port)
591{
Christof Schmitt615f59e2010-02-17 11:18:56 +0100592 get_device(&port->dev);
Christof Schmitta2fa0ae2009-03-02 13:09:08 +0100593 port->rport_task = RPORT_ADD;
594
Swen Schillig45446832009-08-18 15:43:17 +0200595 if (!queue_work(port->adapter->work_queue, &port->rport_work))
Christof Schmitt615f59e2010-02-17 11:18:56 +0100596 put_device(&port->dev);
Christof Schmitta2fa0ae2009-03-02 13:09:08 +0100597}
598
599void zfcp_scsi_schedule_rport_block(struct zfcp_port *port)
600{
Christof Schmitt615f59e2010-02-17 11:18:56 +0100601 get_device(&port->dev);
Christof Schmitta2fa0ae2009-03-02 13:09:08 +0100602 port->rport_task = RPORT_DEL;
603
Swen Schillig45446832009-08-18 15:43:17 +0200604 if (port->rport && queue_work(port->adapter->work_queue,
605 &port->rport_work))
Swen Schilliga67417a2009-08-18 15:43:06 +0200606 return;
607
Christof Schmitt615f59e2010-02-17 11:18:56 +0100608 put_device(&port->dev);
Christof Schmitta2fa0ae2009-03-02 13:09:08 +0100609}
610
611void zfcp_scsi_schedule_rports_block(struct zfcp_adapter *adapter)
612{
Swen Schilligecf0c772009-11-24 16:53:58 +0100613 unsigned long flags;
Christof Schmitta2fa0ae2009-03-02 13:09:08 +0100614 struct zfcp_port *port;
615
Swen Schilligecf0c772009-11-24 16:53:58 +0100616 read_lock_irqsave(&adapter->port_list_lock, flags);
617 list_for_each_entry(port, &adapter->port_list, list)
Christof Schmitta2fa0ae2009-03-02 13:09:08 +0100618 zfcp_scsi_schedule_rport_block(port);
Swen Schilligecf0c772009-11-24 16:53:58 +0100619 read_unlock_irqrestore(&adapter->port_list_lock, flags);
Christof Schmitta2fa0ae2009-03-02 13:09:08 +0100620}
621
622void zfcp_scsi_rport_work(struct work_struct *work)
623{
624 struct zfcp_port *port = container_of(work, struct zfcp_port,
625 rport_work);
626
627 while (port->rport_task) {
628 if (port->rport_task == RPORT_ADD) {
629 port->rport_task = RPORT_NONE;
630 zfcp_scsi_rport_register(port);
631 } else {
632 port->rport_task = RPORT_NONE;
633 zfcp_scsi_rport_block(port);
634 }
635 }
636
Christof Schmitt615f59e2010-02-17 11:18:56 +0100637 put_device(&port->dev);
Christof Schmitta2fa0ae2009-03-02 13:09:08 +0100638}
639
Christof Schmitt5a7de552010-07-08 09:53:07 +0200640/**
641 * zfcp_scsi_scan - Register LUN with SCSI midlayer
642 * @unit: The LUN/unit to register
643 */
644void zfcp_scsi_scan(struct zfcp_unit *unit)
Swen Schillig92d51932009-04-17 15:08:04 +0200645{
Christof Schmitt5a7de552010-07-08 09:53:07 +0200646 struct fc_rport *rport = unit->port->rport;
Swen Schillig92d51932009-04-17 15:08:04 +0200647
648 if (rport && rport->port_state == FC_PORTSTATE_ONLINE)
649 scsi_scan_target(&rport->dev, 0, rport->scsi_target_id,
650 scsilun_to_int((struct scsi_lun *)
651 &unit->fcp_lun), 0);
Christof Schmitt5a7de552010-07-08 09:53:07 +0200652}
Swen Schillig92d51932009-04-17 15:08:04 +0200653
Christof Schmitt5a7de552010-07-08 09:53:07 +0200654void zfcp_scsi_scan_work(struct work_struct *work)
655{
656 struct zfcp_unit *unit = container_of(work, struct zfcp_unit,
657 scsi_work);
658
659 zfcp_scsi_scan(unit);
Christof Schmitt615f59e2010-02-17 11:18:56 +0100660 put_device(&unit->dev);
Swen Schillig92d51932009-04-17 15:08:04 +0200661}
662
Felix Beckef3eb712010-07-16 15:37:42 +0200663/**
664 * zfcp_scsi_set_prot - Configure DIF/DIX support in scsi_host
665 * @adapter: The adapter where to configure DIF/DIX for the SCSI host
666 */
667void zfcp_scsi_set_prot(struct zfcp_adapter *adapter)
668{
669 unsigned int mask = 0;
670 unsigned int data_div;
671 struct Scsi_Host *shost = adapter->scsi_host;
672
673 data_div = atomic_read(&adapter->status) &
674 ZFCP_STATUS_ADAPTER_DATA_DIV_ENABLED;
675
676 if (enable_dif &&
677 adapter->adapter_features & FSF_FEATURE_DIF_PROT_TYPE1)
678 mask |= SHOST_DIF_TYPE1_PROTECTION;
679
680 if (enable_dif && data_div &&
681 adapter->adapter_features & FSF_FEATURE_DIX_PROT_TCPIP) {
682 mask |= SHOST_DIX_TYPE1_PROTECTION;
683 scsi_host_set_guard(shost, SHOST_DIX_GUARD_IP);
684 shost->sg_tablesize = ZFCP_QDIO_MAX_SBALES_PER_REQ / 2;
685 shost->max_sectors = ZFCP_QDIO_MAX_SBALES_PER_REQ * 8 / 2;
686 }
687
688 scsi_host_set_prot(shost, mask);
689}
690
691/**
692 * zfcp_scsi_dif_sense_error - Report DIF/DIX error as driver sense error
693 * @scmd: The SCSI command to report the error for
694 * @ascq: The ASCQ to put in the sense buffer
695 *
696 * See the error handling in sd_done for the sense codes used here.
697 * Set DID_SOFT_ERROR to retry the request, if possible.
698 */
699void zfcp_scsi_dif_sense_error(struct scsi_cmnd *scmd, int ascq)
700{
701 scsi_build_sense_buffer(1, scmd->sense_buffer,
702 ILLEGAL_REQUEST, 0x10, ascq);
703 set_driver_byte(scmd, DRIVER_SENSE);
704 scmd->result |= SAM_STAT_CHECK_CONDITION;
705 set_host_byte(scmd, DID_SOFT_ERROR);
706}
707
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708struct fc_function_template zfcp_transport_functions = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 .show_starget_port_id = 1,
710 .show_starget_port_name = 1,
711 .show_starget_node_name = 1,
Andreas Herrmann3859f6a2005-08-27 11:07:54 -0700712 .show_rport_supported_classes = 1,
Ralph Wuerthner75bfc282006-05-22 18:24:33 +0200713 .show_rport_maxframe_size = 1,
Andreas Herrmann338151e2006-05-22 18:25:56 +0200714 .show_rport_dev_loss_tmo = 1,
Andreas Herrmann3859f6a2005-08-27 11:07:54 -0700715 .show_host_node_name = 1,
716 .show_host_port_name = 1,
Andreas Herrmannad757cd2006-01-13 02:26:11 +0100717 .show_host_permanent_port_name = 1,
Andreas Herrmann3859f6a2005-08-27 11:07:54 -0700718 .show_host_supported_classes = 1,
Christof Schmitt0fdd2132009-11-24 16:54:17 +0100719 .show_host_supported_fc4s = 1,
Andreas Herrmannad757cd2006-01-13 02:26:11 +0100720 .show_host_supported_speeds = 1,
Andreas Herrmann13e1e1f2005-09-19 16:56:17 +0200721 .show_host_maxframe_size = 1,
Andreas Herrmann3859f6a2005-08-27 11:07:54 -0700722 .show_host_serial_number = 1,
Andreas Herrmannf6cd94b2006-01-05 09:59:34 +0100723 .get_fc_host_stats = zfcp_get_fc_host_stats,
724 .reset_fc_host_stats = zfcp_reset_fc_host_stats,
Andreas Herrmann338151e2006-05-22 18:25:56 +0200725 .set_rport_dev_loss_tmo = zfcp_set_rport_dev_loss_tmo,
Sven Schuetz85a82392008-06-10 18:20:59 +0200726 .get_host_port_state = zfcp_get_host_port_state,
Christof Schmitta2fa0ae2009-03-02 13:09:08 +0100727 .terminate_rport_io = zfcp_scsi_terminate_rport_io,
Sven Schuetz85a82392008-06-10 18:20:59 +0200728 .show_host_port_state = 1,
Christof Schmitt0fdd2132009-11-24 16:54:17 +0100729 .show_host_active_fc4s = 1,
Christof Schmitt7c7dc192009-11-24 16:54:13 +0100730 .bsg_request = zfcp_fc_exec_bsg_job,
Swen Schillig491ca442010-01-14 17:19:01 +0100731 .bsg_timeout = zfcp_fc_timeout_bsg_job,
Andreas Herrmannf6cd94b2006-01-05 09:59:34 +0100732 /* no functions registered for following dynamic attributes but
733 directly set by LLDD */
Andreas Herrmannad757cd2006-01-13 02:26:11 +0100734 .show_host_port_type = 1,
Andreas Herrmann13e1e1f2005-09-19 16:56:17 +0200735 .show_host_speed = 1,
736 .show_host_port_id = 1,
Swen Schillig52ef11a2007-08-28 09:31:09 +0200737 .disable_target_scan = 1,
Christof Schmitt7c7dc192009-11-24 16:54:13 +0100738 .dd_bsg_size = sizeof(struct zfcp_fsf_ct_els),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739};
740
Martin Petermannf76af7d72008-07-02 10:56:36 +0200741struct zfcp_data zfcp_data = {
742 .scsi_host_template = {
743 .name = "zfcp",
744 .module = THIS_MODULE,
745 .proc_name = "zfcp",
Christof Schmitta40a1ba2009-05-15 13:18:16 +0200746 .change_queue_depth = zfcp_scsi_change_queue_depth,
Martin Petermannf76af7d72008-07-02 10:56:36 +0200747 .slave_alloc = zfcp_scsi_slave_alloc,
748 .slave_configure = zfcp_scsi_slave_configure,
749 .slave_destroy = zfcp_scsi_slave_destroy,
750 .queuecommand = zfcp_scsi_queuecommand,
751 .eh_abort_handler = zfcp_scsi_eh_abort_handler,
752 .eh_device_reset_handler = zfcp_scsi_eh_device_reset_handler,
753 .eh_target_reset_handler = zfcp_scsi_eh_target_reset_handler,
754 .eh_host_reset_handler = zfcp_scsi_eh_host_reset_handler,
755 .can_queue = 4096,
756 .this_id = -1,
Swen Schillig01b04752010-07-16 15:37:37 +0200757 .sg_tablesize = ZFCP_QDIO_MAX_SBALES_PER_REQ,
Martin Petermannf76af7d72008-07-02 10:56:36 +0200758 .cmd_per_lun = 1,
759 .use_clustering = 1,
760 .sdev_attrs = zfcp_sysfs_sdev_attrs,
Swen Schillig01b04752010-07-16 15:37:37 +0200761 .max_sectors = (ZFCP_QDIO_MAX_SBALES_PER_REQ * 8),
Christof Schmitt68322982010-04-30 18:09:33 +0200762 .dma_boundary = ZFCP_QDIO_SBALE_LEN - 1,
Swen Schillig60221922008-07-02 10:56:38 +0200763 .shost_attrs = zfcp_sysfs_shost_attrs,
Martin Petermannf76af7d72008-07-02 10:56:36 +0200764 },
765};