aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/scsi/zfcp_def.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/s390/scsi/zfcp_def.h')
-rw-r--r--drivers/s390/scsi/zfcp_def.h341
1 files changed, 46 insertions, 295 deletions
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h
index bda8c77b22da..67f45fc62f53 100644
--- a/drivers/s390/scsi/zfcp_def.h
+++ b/drivers/s390/scsi/zfcp_def.h
@@ -1,22 +1,9 @@
1/* 1/*
2 * This file is part of the zfcp device driver for 2 * zfcp device driver
3 * FCP adapters for IBM System z9 and zSeries.
4 * 3 *
5 * (C) Copyright IBM Corp. 2002, 2006 4 * Global definitions for the zfcp device driver.
6 * 5 *
7 * This program is free software; you can redistribute it and/or modify 6 * Copyright IBM Corporation 2002, 2008
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 7 */
21 8
22#ifndef ZFCP_DEF_H 9#ifndef ZFCP_DEF_H
@@ -26,7 +13,6 @@
26 13
27#include <linux/init.h> 14#include <linux/init.h>
28#include <linux/moduleparam.h> 15#include <linux/moduleparam.h>
29#include <linux/miscdevice.h>
30#include <linux/major.h> 16#include <linux/major.h>
31#include <linux/blkdev.h> 17#include <linux/blkdev.h>
32#include <linux/delay.h> 18#include <linux/delay.h>
@@ -53,9 +39,6 @@
53 39
54/********************* GENERAL DEFINES *********************************/ 40/********************* GENERAL DEFINES *********************************/
55 41
56/* zfcp version number, it consists of major, minor, and patch-level number */
57#define ZFCP_VERSION "4.8.0"
58
59/** 42/**
60 * zfcp_sg_to_address - determine kernel address from struct scatterlist 43 * zfcp_sg_to_address - determine kernel address from struct scatterlist
61 * @list: struct scatterlist 44 * @list: struct scatterlist
@@ -93,11 +76,6 @@ zfcp_address_to_sg(void *address, struct scatterlist *list, unsigned int size)
93#define ZFCP_DEVICE_MODEL 0x03 76#define ZFCP_DEVICE_MODEL 0x03
94#define ZFCP_DEVICE_MODEL_PRIV 0x04 77#define ZFCP_DEVICE_MODEL_PRIV 0x04
95 78
96/* allow as many chained SBALs as are supported by hardware */
97#define ZFCP_MAX_SBALS_PER_REQ FSF_MAX_SBALS_PER_REQ
98#define ZFCP_MAX_SBALS_PER_CT_REQ FSF_MAX_SBALS_PER_REQ
99#define ZFCP_MAX_SBALS_PER_ELS_REQ FSF_MAX_SBALS_PER_ELS_REQ
100
101/* DMQ bug workaround: don't use last SBALE */ 79/* DMQ bug workaround: don't use last SBALE */
102#define ZFCP_MAX_SBALES_PER_SBAL (QDIO_MAX_ELEMENTS_PER_BUFFER - 1) 80#define ZFCP_MAX_SBALES_PER_SBAL (QDIO_MAX_ELEMENTS_PER_BUFFER - 1)
103 81
@@ -106,42 +84,17 @@ zfcp_address_to_sg(void *address, struct scatterlist *list, unsigned int size)
106 84
107/* max. number of (data buffer) SBALEs in largest SBAL chain */ 85/* max. number of (data buffer) SBALEs in largest SBAL chain */
108#define ZFCP_MAX_SBALES_PER_REQ \ 86#define ZFCP_MAX_SBALES_PER_REQ \
109 (ZFCP_MAX_SBALS_PER_REQ * ZFCP_MAX_SBALES_PER_SBAL - 2) 87 (FSF_MAX_SBALS_PER_REQ * ZFCP_MAX_SBALES_PER_SBAL - 2)
110 /* request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */ 88 /* request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */
111 89
112#define ZFCP_MAX_SECTORS (ZFCP_MAX_SBALES_PER_REQ * 8) 90#define ZFCP_MAX_SECTORS (ZFCP_MAX_SBALES_PER_REQ * 8)
113 /* max. number of (data buffer) SBALEs in largest SBAL chain 91 /* max. number of (data buffer) SBALEs in largest SBAL chain
114 multiplied with number of sectors per 4k block */ 92 multiplied with number of sectors per 4k block */
115 93
116/* FIXME(tune): free space should be one max. SBAL chain plus what? */
117#define ZFCP_QDIO_PCI_INTERVAL (QDIO_MAX_BUFFERS_PER_Q \
118 - (ZFCP_MAX_SBALS_PER_REQ + 4))
119
120#define ZFCP_SBAL_TIMEOUT (5*HZ)
121
122#define ZFCP_TYPE2_RECOVERY_TIME 8 /* seconds */
123
124/* queue polling (values in microseconds) */
125#define ZFCP_MAX_INPUT_THRESHOLD 5000 /* FIXME: tune */
126#define ZFCP_MAX_OUTPUT_THRESHOLD 1000 /* FIXME: tune */
127#define ZFCP_MIN_INPUT_THRESHOLD 1 /* ignored by QDIO layer */
128#define ZFCP_MIN_OUTPUT_THRESHOLD 1 /* ignored by QDIO layer */
129
130#define QDIO_SCSI_QFMT 1 /* 1 for FSF */
131#define QBUFF_PER_PAGE (PAGE_SIZE / sizeof(struct qdio_buffer))
132
133/********************* FSF SPECIFIC DEFINES *********************************/ 94/********************* FSF SPECIFIC DEFINES *********************************/
134 95
135#define ZFCP_ULP_INFO_VERSION 26
136#define ZFCP_QTCB_VERSION FSF_QTCB_CURRENT_VERSION
137/* ATTENTION: value must not be used by hardware */ 96/* ATTENTION: value must not be used by hardware */
138#define FSF_QTCB_UNSOLICITED_STATUS 0x6305 97#define FSF_QTCB_UNSOLICITED_STATUS 0x6305
139#define ZFCP_STATUS_READ_FAILED_THRESHOLD 3
140#define ZFCP_STATUS_READS_RECOM FSF_STATUS_READS_RECOM
141
142/* Do 1st retry in 1 second, then double the timeout for each following retry */
143#define ZFCP_EXCHANGE_CONFIG_DATA_FIRST_SLEEP 1
144#define ZFCP_EXCHANGE_CONFIG_DATA_RETRIES 7
145 98
146/* timeout value for "default timer" for fsf requests */ 99/* timeout value for "default timer" for fsf requests */
147#define ZFCP_FSF_REQUEST_TIMEOUT (60*HZ) 100#define ZFCP_FSF_REQUEST_TIMEOUT (60*HZ)
@@ -153,17 +106,9 @@ typedef unsigned long long fcp_lun_t;
153/* data length field may be at variable position in FCP-2 FCP_CMND IU */ 106/* data length field may be at variable position in FCP-2 FCP_CMND IU */
154typedef unsigned int fcp_dl_t; 107typedef unsigned int fcp_dl_t;
155 108
156#define ZFCP_FC_SERVICE_CLASS_DEFAULT FSF_CLASS_3
157
158/* timeout for name-server lookup (in seconds) */ 109/* timeout for name-server lookup (in seconds) */
159#define ZFCP_NS_GID_PN_TIMEOUT 10 110#define ZFCP_NS_GID_PN_TIMEOUT 10
160 111
161/* largest SCSI command we can process */
162/* FCP-2 (FCP_CMND IU) allows up to (255-3+16) */
163#define ZFCP_MAX_SCSI_CMND_LENGTH 255
164/* maximum number of commands in LUN queue (tagged queueing) */
165#define ZFCP_CMND_PER_LUN 32
166
167/* task attribute values in FCP-2 FCP_CMND IU */ 112/* task attribute values in FCP-2 FCP_CMND IU */
168#define SIMPLE_Q 0 113#define SIMPLE_Q 0
169#define HEAD_OF_Q 1 114#define HEAD_OF_Q 1
@@ -224,9 +169,9 @@ struct fcp_rsp_iu {
224#define RSP_CODE_TASKMAN_FAILED 5 169#define RSP_CODE_TASKMAN_FAILED 5
225 170
226/* see fc-fs */ 171/* see fc-fs */
227#define LS_RSCN 0x61040000 172#define LS_RSCN 0x61
228#define LS_LOGO 0x05000000 173#define LS_LOGO 0x05
229#define LS_PLOGI 0x03000000 174#define LS_PLOGI 0x03
230 175
231struct fcp_rscn_head { 176struct fcp_rscn_head {
232 u8 command; 177 u8 command;
@@ -266,7 +211,6 @@ struct fcp_logo {
266 * FC-FS stuff 211 * FC-FS stuff
267 */ 212 */
268#define R_A_TOV 10 /* seconds */ 213#define R_A_TOV 10 /* seconds */
269#define ZFCP_ELS_TIMEOUT (2 * R_A_TOV)
270 214
271#define ZFCP_LS_RLS 0x0f 215#define ZFCP_LS_RLS 0x0f
272#define ZFCP_LS_ADISC 0x52 216#define ZFCP_LS_ADISC 0x52
@@ -311,7 +255,10 @@ struct zfcp_rc_entry {
311#define ZFCP_CT_DIRECTORY_SERVICE 0xFC 255#define ZFCP_CT_DIRECTORY_SERVICE 0xFC
312#define ZFCP_CT_NAME_SERVER 0x02 256#define ZFCP_CT_NAME_SERVER 0x02
313#define ZFCP_CT_SYNCHRONOUS 0x00 257#define ZFCP_CT_SYNCHRONOUS 0x00
258#define ZFCP_CT_SCSI_FCP 0x08
259#define ZFCP_CT_UNABLE_TO_PERFORM_CMD 0x09
314#define ZFCP_CT_GID_PN 0x0121 260#define ZFCP_CT_GID_PN 0x0121
261#define ZFCP_CT_GPN_FT 0x0172
315#define ZFCP_CT_MAX_SIZE 0x1020 262#define ZFCP_CT_MAX_SIZE 0x1020
316#define ZFCP_CT_ACCEPT 0x8002 263#define ZFCP_CT_ACCEPT 0x8002
317#define ZFCP_CT_REJECT 0x8001 264#define ZFCP_CT_REJECT 0x8001
@@ -321,107 +268,6 @@ struct zfcp_rc_entry {
321 */ 268 */
322#define ZFCP_CT_TIMEOUT (3 * R_A_TOV) 269#define ZFCP_CT_TIMEOUT (3 * R_A_TOV)
323 270
324/******************** LOGGING MACROS AND DEFINES *****************************/
325
326/*
327 * Logging may be applied on certain kinds of driver operations
328 * independently. Additionally, different log-levels are supported for
329 * each of these areas.
330 */
331
332#define ZFCP_NAME "zfcp"
333
334/* independent log areas */
335#define ZFCP_LOG_AREA_OTHER 0
336#define ZFCP_LOG_AREA_SCSI 1
337#define ZFCP_LOG_AREA_FSF 2
338#define ZFCP_LOG_AREA_CONFIG 3
339#define ZFCP_LOG_AREA_CIO 4
340#define ZFCP_LOG_AREA_QDIO 5
341#define ZFCP_LOG_AREA_ERP 6
342#define ZFCP_LOG_AREA_FC 7
343
344/* log level values*/
345#define ZFCP_LOG_LEVEL_NORMAL 0
346#define ZFCP_LOG_LEVEL_INFO 1
347#define ZFCP_LOG_LEVEL_DEBUG 2
348#define ZFCP_LOG_LEVEL_TRACE 3
349
350/*
351 * this allows removal of logging code by the preprocessor
352 * (the most detailed log level still to be compiled in is specified,
353 * higher log levels are removed)
354 */
355#define ZFCP_LOG_LEVEL_LIMIT ZFCP_LOG_LEVEL_TRACE
356
357/* get "loglevel" nibble assignment */
358#define ZFCP_GET_LOG_VALUE(zfcp_lognibble) \
359 ((atomic_read(&zfcp_data.loglevel) >> (zfcp_lognibble<<2)) & 0xF)
360
361/* set "loglevel" nibble */
362#define ZFCP_SET_LOG_NIBBLE(value, zfcp_lognibble) \
363 (value << (zfcp_lognibble << 2))
364
365/* all log-level defaults are combined to generate initial log-level */
366#define ZFCP_LOG_LEVEL_DEFAULTS \
367 (ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_OTHER) | \
368 ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_SCSI) | \
369 ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_FSF) | \
370 ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_CONFIG) | \
371 ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_CIO) | \
372 ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_QDIO) | \
373 ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_ERP) | \
374 ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_FC))
375
376/* check whether we have the right level for logging */
377#define ZFCP_LOG_CHECK(level) \
378 ((ZFCP_GET_LOG_VALUE(ZFCP_LOG_AREA)) >= level)
379
380/* logging routine for zfcp */
381#define _ZFCP_LOG(fmt, args...) \
382 printk(KERN_ERR ZFCP_NAME": %s(%d): " fmt, __func__, \
383 __LINE__ , ##args)
384
385#define ZFCP_LOG(level, fmt, args...) \
386do { \
387 if (ZFCP_LOG_CHECK(level)) \
388 _ZFCP_LOG(fmt, ##args); \
389} while (0)
390
391#if ZFCP_LOG_LEVEL_LIMIT < ZFCP_LOG_LEVEL_NORMAL
392# define ZFCP_LOG_NORMAL(fmt, args...) do { } while (0)
393#else
394# define ZFCP_LOG_NORMAL(fmt, args...) \
395do { \
396 if (ZFCP_LOG_CHECK(ZFCP_LOG_LEVEL_NORMAL)) \
397 printk(KERN_ERR ZFCP_NAME": " fmt, ##args); \
398} while (0)
399#endif
400
401#if ZFCP_LOG_LEVEL_LIMIT < ZFCP_LOG_LEVEL_INFO
402# define ZFCP_LOG_INFO(fmt, args...) do { } while (0)
403#else
404# define ZFCP_LOG_INFO(fmt, args...) \
405do { \
406 if (ZFCP_LOG_CHECK(ZFCP_LOG_LEVEL_INFO)) \
407 printk(KERN_ERR ZFCP_NAME": " fmt, ##args); \
408} while (0)
409#endif
410
411#if ZFCP_LOG_LEVEL_LIMIT < ZFCP_LOG_LEVEL_DEBUG
412# define ZFCP_LOG_DEBUG(fmt, args...) do { } while (0)
413#else
414# define ZFCP_LOG_DEBUG(fmt, args...) \
415 ZFCP_LOG(ZFCP_LOG_LEVEL_DEBUG, fmt , ##args)
416#endif
417
418#if ZFCP_LOG_LEVEL_LIMIT < ZFCP_LOG_LEVEL_TRACE
419# define ZFCP_LOG_TRACE(fmt, args...) do { } while (0)
420#else
421# define ZFCP_LOG_TRACE(fmt, args...) \
422 ZFCP_LOG(ZFCP_LOG_LEVEL_TRACE, fmt , ##args)
423#endif
424
425/*************** ADAPTER/PORT/UNIT AND FSF_REQ STATUS FLAGS ******************/ 271/*************** ADAPTER/PORT/UNIT AND FSF_REQ STATUS FLAGS ******************/
426 272
427/* 273/*
@@ -441,6 +287,7 @@ do { \
441#define ZFCP_STATUS_COMMON_ERP_INUSE 0x01000000 287#define ZFCP_STATUS_COMMON_ERP_INUSE 0x01000000
442#define ZFCP_STATUS_COMMON_ACCESS_DENIED 0x00800000 288#define ZFCP_STATUS_COMMON_ACCESS_DENIED 0x00800000
443#define ZFCP_STATUS_COMMON_ACCESS_BOXED 0x00400000 289#define ZFCP_STATUS_COMMON_ACCESS_BOXED 0x00400000
290#define ZFCP_STATUS_COMMON_NOESC 0x00200000
444 291
445/* adapter status */ 292/* adapter status */
446#define ZFCP_STATUS_ADAPTER_QDIOUP 0x00000002 293#define ZFCP_STATUS_ADAPTER_QDIOUP 0x00000002
@@ -496,77 +343,6 @@ do { \
496#define ZFCP_STATUS_FSFREQ_RETRY 0x00000800 343#define ZFCP_STATUS_FSFREQ_RETRY 0x00000800
497#define ZFCP_STATUS_FSFREQ_DISMISSED 0x00001000 344#define ZFCP_STATUS_FSFREQ_DISMISSED 0x00001000
498 345
499/*********************** ERROR RECOVERY PROCEDURE DEFINES ********************/
500
501#define ZFCP_MAX_ERPS 3
502
503#define ZFCP_ERP_FSFREQ_TIMEOUT (30 * HZ)
504#define ZFCP_ERP_MEMWAIT_TIMEOUT HZ
505
506#define ZFCP_STATUS_ERP_TIMEDOUT 0x10000000
507#define ZFCP_STATUS_ERP_CLOSE_ONLY 0x01000000
508#define ZFCP_STATUS_ERP_DISMISSING 0x00100000
509#define ZFCP_STATUS_ERP_DISMISSED 0x00200000
510#define ZFCP_STATUS_ERP_LOWMEM 0x00400000
511
512#define ZFCP_ERP_STEP_UNINITIALIZED 0x00000000
513#define ZFCP_ERP_STEP_FSF_XCONFIG 0x00000001
514#define ZFCP_ERP_STEP_PHYS_PORT_CLOSING 0x00000010
515#define ZFCP_ERP_STEP_PORT_CLOSING 0x00000100
516#define ZFCP_ERP_STEP_NAMESERVER_OPEN 0x00000200
517#define ZFCP_ERP_STEP_NAMESERVER_LOOKUP 0x00000400
518#define ZFCP_ERP_STEP_PORT_OPENING 0x00000800
519#define ZFCP_ERP_STEP_UNIT_CLOSING 0x00001000
520#define ZFCP_ERP_STEP_UNIT_OPENING 0x00002000
521
522/* Ordered by escalation level (necessary for proper erp-code operation) */
523#define ZFCP_ERP_ACTION_REOPEN_ADAPTER 0x4
524#define ZFCP_ERP_ACTION_REOPEN_PORT_FORCED 0x3
525#define ZFCP_ERP_ACTION_REOPEN_PORT 0x2
526#define ZFCP_ERP_ACTION_REOPEN_UNIT 0x1
527
528#define ZFCP_ERP_ACTION_RUNNING 0x1
529#define ZFCP_ERP_ACTION_READY 0x2
530
531#define ZFCP_ERP_SUCCEEDED 0x0
532#define ZFCP_ERP_FAILED 0x1
533#define ZFCP_ERP_CONTINUES 0x2
534#define ZFCP_ERP_EXIT 0x3
535#define ZFCP_ERP_DISMISSED 0x4
536#define ZFCP_ERP_NOMEM 0x5
537
538
539/******************** CFDC SPECIFIC STUFF *****************************/
540
541/* Firewall data channel sense data record */
542struct zfcp_cfdc_sense_data {
543 u32 signature; /* Request signature */
544 u32 devno; /* FCP adapter device number */
545 u32 command; /* Command code */
546 u32 fsf_status; /* FSF request status and status qualifier */
547 u8 fsf_status_qual[FSF_STATUS_QUALIFIER_SIZE];
548 u8 payloads[256]; /* Access conflicts list */
549 u8 control_file[0]; /* Access control table */
550};
551
552#define ZFCP_CFDC_SIGNATURE 0xCFDCACDF
553
554#define ZFCP_CFDC_CMND_DOWNLOAD_NORMAL 0x00010001
555#define ZFCP_CFDC_CMND_DOWNLOAD_FORCE 0x00010101
556#define ZFCP_CFDC_CMND_FULL_ACCESS 0x00000201
557#define ZFCP_CFDC_CMND_RESTRICTED_ACCESS 0x00000401
558#define ZFCP_CFDC_CMND_UPLOAD 0x00010002
559
560#define ZFCP_CFDC_DOWNLOAD 0x00000001
561#define ZFCP_CFDC_UPLOAD 0x00000002
562#define ZFCP_CFDC_WITH_CONTROL_FILE 0x00010000
563
564#define ZFCP_CFDC_DEV_NAME "zfcp_cfdc"
565#define ZFCP_CFDC_DEV_MAJOR MISC_MAJOR
566#define ZFCP_CFDC_DEV_MINOR MISC_DYNAMIC_MINOR
567
568#define ZFCP_CFDC_MAX_CONTROL_FILE_SIZE 127 * 1024
569
570/************************* STRUCTURE DEFINITIONS *****************************/ 346/************************* STRUCTURE DEFINITIONS *****************************/
571 347
572struct zfcp_fsf_req; 348struct zfcp_fsf_req;
@@ -623,7 +399,6 @@ typedef void (*zfcp_send_ct_handler_t)(unsigned long);
623 * @resp_count: number of elements in response scatter-gather list 399 * @resp_count: number of elements in response scatter-gather list
624 * @handler: handler function (called for response to the request) 400 * @handler: handler function (called for response to the request)
625 * @handler_data: data passed to handler function 401 * @handler_data: data passed to handler function
626 * @pool: pointer to memory pool for ct request structure
627 * @timeout: FSF timeout for this request 402 * @timeout: FSF timeout for this request
628 * @completion: completion for synchronization purposes 403 * @completion: completion for synchronization purposes
629 * @status: used to pass error status to calling function 404 * @status: used to pass error status to calling function
@@ -636,7 +411,6 @@ struct zfcp_send_ct {
636 unsigned int resp_count; 411 unsigned int resp_count;
637 zfcp_send_ct_handler_t handler; 412 zfcp_send_ct_handler_t handler;
638 unsigned long handler_data; 413 unsigned long handler_data;
639 mempool_t *pool;
640 int timeout; 414 int timeout;
641 struct completion *completion; 415 struct completion *completion;
642 int status; 416 int status;
@@ -685,13 +459,13 @@ struct zfcp_send_els {
685}; 459};
686 460
687struct zfcp_qdio_queue { 461struct zfcp_qdio_queue {
688 struct qdio_buffer *buffer[QDIO_MAX_BUFFERS_PER_Q]; /* SBALs */ 462 struct qdio_buffer *sbal[QDIO_MAX_BUFFERS_PER_Q]; /* SBALs */
689 u8 free_index; /* index of next free bfr 463 u8 first; /* index of next free bfr
690 in queue (free_count>0) */ 464 in queue (free_count>0) */
691 atomic_t free_count; /* number of free buffers 465 atomic_t count; /* number of free buffers
692 in queue */ 466 in queue */
693 rwlock_t queue_lock; /* lock for operations on queue */ 467 spinlock_t lock; /* lock for operations on queue */
694 int distance_from_int; /* SBALs used since PCI indication 468 int pci_batch; /* SBALs since PCI indication
695 was last set */ 469 was last set */
696}; 470};
697 471
@@ -708,6 +482,24 @@ struct zfcp_erp_action {
708 struct timer_list timer; 482 struct timer_list timer;
709}; 483};
710 484
485struct fsf_latency_record {
486 u32 min;
487 u32 max;
488 u64 sum;
489};
490
491struct latency_cont {
492 struct fsf_latency_record channel;
493 struct fsf_latency_record fabric;
494 u64 counter;
495};
496
497struct zfcp_latencies {
498 struct latency_cont read;
499 struct latency_cont write;
500 struct latency_cont cmd;
501 spinlock_t lock;
502};
711 503
712struct zfcp_adapter { 504struct zfcp_adapter {
713 struct list_head list; /* list of adapters */ 505 struct list_head list; /* list of adapters */
@@ -723,24 +515,25 @@ struct zfcp_adapter {
723 u32 adapter_features; /* FCP channel features */ 515 u32 adapter_features; /* FCP channel features */
724 u32 connection_features; /* host connection features */ 516 u32 connection_features; /* host connection features */
725 u32 hardware_version; /* of FCP channel */ 517 u32 hardware_version; /* of FCP channel */
518 u16 timer_ticks; /* time int for a tick */
726 struct Scsi_Host *scsi_host; /* Pointer to mid-layer */ 519 struct Scsi_Host *scsi_host; /* Pointer to mid-layer */
727 struct list_head port_list_head; /* remote port list */ 520 struct list_head port_list_head; /* remote port list */
728 struct list_head port_remove_lh; /* head of ports to be 521 struct list_head port_remove_lh; /* head of ports to be
729 removed */ 522 removed */
730 u32 ports; /* number of remote ports */ 523 u32 ports; /* number of remote ports */
731 atomic_t reqs_active; /* # active FSF reqs */
732 unsigned long req_no; /* unique FSF req number */ 524 unsigned long req_no; /* unique FSF req number */
733 struct list_head *req_list; /* list of pending reqs */ 525 struct list_head *req_list; /* list of pending reqs */
734 spinlock_t req_list_lock; /* request list lock */ 526 spinlock_t req_list_lock; /* request list lock */
735 struct zfcp_qdio_queue request_queue; /* request queue */ 527 struct zfcp_qdio_queue req_q; /* request queue */
736 u32 fsf_req_seq_no; /* FSF cmnd seq number */ 528 u32 fsf_req_seq_no; /* FSF cmnd seq number */
737 wait_queue_head_t request_wq; /* can be used to wait for 529 wait_queue_head_t request_wq; /* can be used to wait for
738 more avaliable SBALs */ 530 more avaliable SBALs */
739 struct zfcp_qdio_queue response_queue; /* response queue */ 531 struct zfcp_qdio_queue resp_q; /* response queue */
740 rwlock_t abort_lock; /* Protects against SCSI 532 rwlock_t abort_lock; /* Protects against SCSI
741 stack abort/command 533 stack abort/command
742 completion races */ 534 completion races */
743 u16 status_read_failed; /* # failed status reads */ 535 atomic_t stat_miss; /* # missing status reads*/
536 struct work_struct stat_work;
744 atomic_t status; /* status of this adapter */ 537 atomic_t status; /* status of this adapter */
745 struct list_head erp_ready_head; /* error recovery for this 538 struct list_head erp_ready_head; /* error recovery for this
746 adapter/devices */ 539 adapter/devices */
@@ -774,13 +567,9 @@ struct zfcp_adapter {
774 struct fc_host_statistics *fc_stats; 567 struct fc_host_statistics *fc_stats;
775 struct fsf_qtcb_bottom_port *stats_reset_data; 568 struct fsf_qtcb_bottom_port *stats_reset_data;
776 unsigned long stats_reset; 569 unsigned long stats_reset;
570 struct work_struct scan_work;
777}; 571};
778 572
779/*
780 * the struct device sysfs_device must be at the beginning of this structure.
781 * pointer to struct device is used to free port structure in release function
782 * of the device. don't change!
783 */
784struct zfcp_port { 573struct zfcp_port {
785 struct device sysfs_device; /* sysfs device */ 574 struct device sysfs_device; /* sysfs device */
786 struct fc_rport *rport; /* rport of fc transport class */ 575 struct fc_rport *rport; /* rport of fc transport class */
@@ -804,10 +593,6 @@ struct zfcp_port {
804 u32 supported_classes; 593 u32 supported_classes;
805}; 594};
806 595
807/* the struct device sysfs_device must be at the beginning of this structure.
808 * pointer to struct device is used to free unit structure in release function
809 * of the device. don't change!
810 */
811struct zfcp_unit { 596struct zfcp_unit {
812 struct device sysfs_device; /* sysfs device */ 597 struct device sysfs_device; /* sysfs device */
813 struct list_head list; /* list of logical units */ 598 struct list_head list; /* list of logical units */
@@ -822,6 +607,7 @@ struct zfcp_unit {
822 struct scsi_device *device; /* scsi device struct pointer */ 607 struct scsi_device *device; /* scsi device struct pointer */
823 struct zfcp_erp_action erp_action; /* pending error recovery */ 608 struct zfcp_erp_action erp_action; /* pending error recovery */
824 atomic_t erp_counter; 609 atomic_t erp_counter;
610 struct zfcp_latencies latencies;
825}; 611};
826 612
827/* FSF request */ 613/* FSF request */
@@ -831,19 +617,19 @@ struct zfcp_fsf_req {
831 struct zfcp_adapter *adapter; /* adapter request belongs to */ 617 struct zfcp_adapter *adapter; /* adapter request belongs to */
832 u8 sbal_number; /* nr of SBALs free for use */ 618 u8 sbal_number; /* nr of SBALs free for use */
833 u8 sbal_first; /* first SBAL for this request */ 619 u8 sbal_first; /* first SBAL for this request */
834 u8 sbal_last; /* last possible SBAL for 620 u8 sbal_last; /* last SBAL for this request */
621 u8 sbal_limit; /* last possible SBAL for
835 this reuest */ 622 this reuest */
836 u8 sbal_curr; /* current SBAL during creation
837 of request */
838 u8 sbale_curr; /* current SBALE during creation 623 u8 sbale_curr; /* current SBALE during creation
839 of request */ 624 of request */
625 u8 sbal_response; /* SBAL used in interrupt */
840 wait_queue_head_t completion_wq; /* can be used by a routine 626 wait_queue_head_t completion_wq; /* can be used by a routine
841 to wait for completion */ 627 to wait for completion */
842 volatile u32 status; /* status of this request */ 628 volatile u32 status; /* status of this request */
843 u32 fsf_command; /* FSF Command copy */ 629 u32 fsf_command; /* FSF Command copy */
844 struct fsf_qtcb *qtcb; /* address of associated QTCB */ 630 struct fsf_qtcb *qtcb; /* address of associated QTCB */
845 u32 seq_no; /* Sequence number of request */ 631 u32 seq_no; /* Sequence number of request */
846 unsigned long data; /* private data of request */ 632 void *data; /* private data of request */
847 struct timer_list timer; /* used for erp or scsi er */ 633 struct timer_list timer; /* used for erp or scsi er */
848 struct zfcp_erp_action *erp_action; /* used if this request is 634 struct zfcp_erp_action *erp_action; /* used if this request is
849 issued on behalf of erp */ 635 issued on behalf of erp */
@@ -851,10 +637,9 @@ struct zfcp_fsf_req {
851 from emergency pool */ 637 from emergency pool */
852 unsigned long long issued; /* request sent time (STCK) */ 638 unsigned long long issued; /* request sent time (STCK) */
853 struct zfcp_unit *unit; 639 struct zfcp_unit *unit;
640 void (*handler)(struct zfcp_fsf_req *);
854}; 641};
855 642
856typedef void zfcp_fsf_req_handler_t(struct zfcp_fsf_req*);
857
858/* driver data */ 643/* driver data */
859struct zfcp_data { 644struct zfcp_data {
860 struct scsi_host_template scsi_host_template; 645 struct scsi_host_template scsi_host_template;
@@ -873,29 +658,11 @@ struct zfcp_data {
873 char init_busid[BUS_ID_SIZE]; 658 char init_busid[BUS_ID_SIZE];
874 wwn_t init_wwpn; 659 wwn_t init_wwpn;
875 fcp_lun_t init_fcp_lun; 660 fcp_lun_t init_fcp_lun;
876 char *driver_version;
877 struct kmem_cache *fsf_req_qtcb_cache; 661 struct kmem_cache *fsf_req_qtcb_cache;
878 struct kmem_cache *sr_buffer_cache; 662 struct kmem_cache *sr_buffer_cache;
879 struct kmem_cache *gid_pn_cache; 663 struct kmem_cache *gid_pn_cache;
880}; 664};
881 665
882/**
883 * struct zfcp_sg_list - struct describing a scatter-gather list
884 * @sg: pointer to array of (struct scatterlist)
885 * @count: number of elements in scatter-gather list
886 */
887struct zfcp_sg_list {
888 struct scatterlist *sg;
889 unsigned int count;
890};
891
892/* number of elements for various memory pools */
893#define ZFCP_POOL_FSF_REQ_ERP_NR 1
894#define ZFCP_POOL_FSF_REQ_SCSI_NR 1
895#define ZFCP_POOL_FSF_REQ_ABORT_NR 1
896#define ZFCP_POOL_STATUS_READ_NR ZFCP_STATUS_READS_RECOM
897#define ZFCP_POOL_DATA_GID_PN_NR 1
898
899/* struct used by memory pools for fsf_requests */ 666/* struct used by memory pools for fsf_requests */
900struct zfcp_fsf_req_qtcb { 667struct zfcp_fsf_req_qtcb {
901 struct zfcp_fsf_req fsf_req; 668 struct zfcp_fsf_req fsf_req;
@@ -905,7 +672,6 @@ struct zfcp_fsf_req_qtcb {
905/********************** ZFCP SPECIFIC DEFINES ********************************/ 672/********************** ZFCP SPECIFIC DEFINES ********************************/
906 673
907#define ZFCP_REQ_AUTO_CLEANUP 0x00000002 674#define ZFCP_REQ_AUTO_CLEANUP 0x00000002
908#define ZFCP_WAIT_FOR_SBAL 0x00000004
909#define ZFCP_REQ_NO_QTCB 0x00000008 675#define ZFCP_REQ_NO_QTCB 0x00000008
910 676
911#define ZFCP_SET 0x00000100 677#define ZFCP_SET 0x00000100
@@ -916,12 +682,6 @@ struct zfcp_fsf_req_qtcb {
916 ((atomic_read(target) & mask) == mask) 682 ((atomic_read(target) & mask) == mask)
917#endif 683#endif
918 684
919extern void _zfcp_hex_dump(char *, int);
920#define ZFCP_HEX_DUMP(level, addr, count) \
921 if (ZFCP_LOG_CHECK(level)) { \
922 _zfcp_hex_dump(addr, count); \
923 }
924
925#define zfcp_get_busid_by_adapter(adapter) (adapter->ccw_device->dev.bus_id) 685#define zfcp_get_busid_by_adapter(adapter) (adapter->ccw_device->dev.bus_id)
926#define zfcp_get_busid_by_port(port) (zfcp_get_busid_by_adapter(port->adapter)) 686#define zfcp_get_busid_by_port(port) (zfcp_get_busid_by_adapter(port->adapter))
927#define zfcp_get_busid_by_unit(unit) (zfcp_get_busid_by_port(unit->port)) 687#define zfcp_get_busid_by_unit(unit) (zfcp_get_busid_by_port(unit->port))
@@ -934,15 +694,6 @@ static inline int zfcp_reqlist_hash(unsigned long req_id)
934 return req_id % REQUEST_LIST_SIZE; 694 return req_id % REQUEST_LIST_SIZE;
935} 695}
936 696
937static inline void zfcp_reqlist_add(struct zfcp_adapter *adapter,
938 struct zfcp_fsf_req *fsf_req)
939{
940 unsigned int idx;
941
942 idx = zfcp_reqlist_hash(fsf_req->req_id);
943 list_add_tail(&fsf_req->list, &adapter->req_list[idx]);
944}
945
946static inline void zfcp_reqlist_remove(struct zfcp_adapter *adapter, 697static inline void zfcp_reqlist_remove(struct zfcp_adapter *adapter,
947 struct zfcp_fsf_req *fsf_req) 698 struct zfcp_fsf_req *fsf_req)
948{ 699{