[go: nahoru, domu]

141fa2adabc0a750a40d6fe86d5ce2f75fb3ad287Swen Schillig/*
2553448f6c4838a1e4bed2bc9301c748278d7d9ceChristof Schmitt * zfcp device driver
31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
4553448f6c4838a1e4bed2bc9301c748278d7d9ceChristof Schmitt * Global definitions for the zfcp device driver.
541fa2adabc0a750a40d6fe86d5ce2f75fb3ad287Swen Schillig *
6a53c8fab3f87c995c30ac226a03af95361243144Heiko Carstens * Copyright IBM Corp. 2002, 2010
741fa2adabc0a750a40d6fe86d5ce2f75fb3ad287Swen Schillig */
81da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
91da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifndef ZFCP_DEF_H
101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ZFCP_DEF_H
111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*************************** INCLUDES *****************************************/
131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/init.h>
151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/moduleparam.h>
161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/major.h>
171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/blkdev.h>
181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/delay.h>
191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/timer.h>
20dd52e0eaf891cd85bf2ca057c15ed6bfd76db4e6Heiko Carstens#include <linux/slab.h>
21dd52e0eaf891cd85bf2ca057c15ed6bfd76db4e6Heiko Carstens#include <linux/mempool.h>
22dd52e0eaf891cd85bf2ca057c15ed6bfd76db4e6Heiko Carstens#include <linux/syscalls.h>
23f1346372f9c73154727bf2cadb7f78126597efd2FUJITA Tomonori#include <linux/scatterlist.h>
24dd52e0eaf891cd85bf2ca057c15ed6bfd76db4e6Heiko Carstens#include <linux/ioctl.h>
259d544f2b9bd4a0f7ba2784cc47e3591667a7b8d4Sven Schuetz#include <scsi/fc/fc_fs.h>
269d544f2b9bd4a0f7ba2784cc47e3591667a7b8d4Sven Schuetz#include <scsi/fc/fc_gs.h>
271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <scsi/scsi.h>
281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <scsi/scsi_tcq.h>
291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <scsi/scsi_cmnd.h>
301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <scsi/scsi_device.h>
311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <scsi/scsi_host.h>
321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <scsi/scsi_transport.h>
331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <scsi/scsi_transport_fc.h>
349d544f2b9bd4a0f7ba2784cc47e3591667a7b8d4Sven Schuetz#include <scsi/scsi_bsg_fc.h>
351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <asm/ccwdev.h>
361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <asm/debug.h>
371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <asm/ebcdic.h>
38bd43a42b7e9880f426ed715f18bb4f963b7352afChristof Schmitt#include <asm/sysinfo.h>
39dd52e0eaf891cd85bf2ca057c15ed6bfd76db4e6Heiko Carstens#include "zfcp_fsf.h"
402d1e547f7523514d1da449bcf08645fe13579378Sven Schuetz#include "zfcp_fc.h"
4134c2b712992540ca436e97432ffc57c84c8f8c18Christof Schmitt#include "zfcp_qdio.h"
421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
43b6bd2fb92a7bb9f1f3feecd9945c21e6c227dd51Christof Schmittstruct zfcp_reqlist;
441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4506506d00ec1a0d7d3b1dff59185af355ce29ac0aAndreas Herrmann/********************* SCSI SPECIFIC DEFINES *********************************/
46f6c0e7a7b3b6db15146877c0cef43b413af5b76eAndreas Herrmann#define ZFCP_SCSI_ER_TIMEOUT                    (10*HZ)
471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/********************* FSF SPECIFIC DEFINES *********************************/
491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* ATTENTION: value must not be used by hardware */
511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define FSF_QTCB_UNSOLICITED_STATUS		0x6305
5222753fa514aad02342e647ad13048caa282d9238Andreas Herrmann
531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* timeout value for "default timer" for fsf requests */
542abbe866c8eb0296e3f5343bcf73e5371522a738Andreas Herrmann#define ZFCP_FSF_REQUEST_TIMEOUT (60*HZ)
551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*************** ADAPTER/PORT/UNIT AND FSF_REQ STATUS FLAGS ******************/
571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
5841fa2adabc0a750a40d6fe86d5ce2f75fb3ad287Swen Schillig/*
5941fa2adabc0a750a40d6fe86d5ce2f75fb3ad287Swen Schillig * Note, the leftmost status byte is common among adapter, port
601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * and unit
611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */
621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ZFCP_COMMON_FLAGS			0xfff00000
631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* common status bits */
651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ZFCP_STATUS_COMMON_RUNNING		0x40000000
661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ZFCP_STATUS_COMMON_ERP_FAILED		0x20000000
671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ZFCP_STATUS_COMMON_UNBLOCKED		0x10000000
681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ZFCP_STATUS_COMMON_OPEN                 0x04000000
691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ZFCP_STATUS_COMMON_ERP_INUSE		0x01000000
701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ZFCP_STATUS_COMMON_ACCESS_DENIED	0x00800000
71d736a27b7efbc835c7b83db5c1bbd41edbadf32eAndreas Herrmann#define ZFCP_STATUS_COMMON_ACCESS_BOXED		0x00400000
72cc8c282963bd258a5bf49d3aa52675a4ae6d31f6Swen Schillig#define ZFCP_STATUS_COMMON_NOESC		0x00200000
731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* adapter status */
7586a9668a8d29ea711613e1cb37efa68e7c4db564Swen Schillig#define ZFCP_STATUS_ADAPTER_MB_ACT		0x00000001
761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ZFCP_STATUS_ADAPTER_QDIOUP		0x00000002
77339f4f4eab80caa6cf0d39fb057ad6ddb84ba91eChristof Schmitt#define ZFCP_STATUS_ADAPTER_SIOSL_ISSUED	0x00000004
781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ZFCP_STATUS_ADAPTER_XCONFIG_OK		0x00000008
791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ZFCP_STATUS_ADAPTER_HOST_CON_INIT	0x00000010
80cb45214960bc989af8b911ebd77da541c797717dSteffen Maier#define ZFCP_STATUS_ADAPTER_SUSPENDED		0x00000040
811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ZFCP_STATUS_ADAPTER_ERP_PENDING		0x00000100
821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED	0x00000200
83dcc18f48a2f1a44c5e8848f30d0cf53a8066c62aChristof Schmitt#define ZFCP_STATUS_ADAPTER_DATA_DIV_ENABLED	0x00000400
841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* remote port status */
861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ZFCP_STATUS_PORT_PHYS_OPEN		0x00000001
8714e242ea55a8b807dc1fb7654941caf68a20cd81Christof Schmitt#define ZFCP_STATUS_PORT_LINK_TEST		0x00000002
881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* FSF request status (this does not have a common part) */
901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ZFCP_STATUS_FSFREQ_ERROR		0x00000008
911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ZFCP_STATUS_FSFREQ_CLEANUP		0x00000010
921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED	0x00000040
931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED       0x00000080
941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ZFCP_STATUS_FSFREQ_TMFUNCFAILED         0x00000200
951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ZFCP_STATUS_FSFREQ_DISMISSED            0x00001000
961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/************************* STRUCTURE DEFINITIONS *****************************/
981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct zfcp_fsf_req;
1001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* holds various memory pools of an adapter */
1021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct zfcp_adapter_mempool {
103a4623c467ff76f9258555d44d68371e10c5406c2Swen Schillig	mempool_t *erp_req;
104799b76d09aeee558d18c1f5b93e63f58f1d1fc11Christof Schmitt	mempool_t *gid_pn_req;
105a4623c467ff76f9258555d44d68371e10c5406c2Swen Schillig	mempool_t *scsi_req;
106a4623c467ff76f9258555d44d68371e10c5406c2Swen Schillig	mempool_t *scsi_abort;
107a4623c467ff76f9258555d44d68371e10c5406c2Swen Schillig	mempool_t *status_read_req;
108c7b279ae51942c14529bf2806685e9c658f28611Christof Schmitt	mempool_t *sr_data;
109dbf5dfe9dbcecf159139eec25ad256738cbc3715Christof Schmitt	mempool_t *gid_pn;
110a4623c467ff76f9258555d44d68371e10c5406c2Swen Schillig	mempool_t *qtcb_pool;
1111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
1121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct zfcp_erp_action {
1141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct list_head list;
1151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int action;	              /* requested action code */
1161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct zfcp_adapter *adapter; /* device which should be recovered */
1171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct zfcp_port *port;
118b62a8d9b45b971a67a0f8413338c230e3117dff5Christof Schmitt	struct scsi_device *sdev;
11944cc76f2d154aa24340354b4711a0fe7f8f08adcSwen Schillig	u32		status;	      /* recovery status */
1201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u32 step;	              /* active step of this erp action */
121e60a6d69f1f84c2ef1cc63aefaadfe7ae9f12934Christof Schmitt	unsigned long		fsf_req_id;
1221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct timer_list timer;
1231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
1241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
125c9615858a81d2424c78b10a2f689ba24b156937cChristof Schmittstruct fsf_latency_record {
126c9615858a81d2424c78b10a2f689ba24b156937cChristof Schmitt	u32 min;
127c9615858a81d2424c78b10a2f689ba24b156937cChristof Schmitt	u32 max;
128c9615858a81d2424c78b10a2f689ba24b156937cChristof Schmitt	u64 sum;
129c9615858a81d2424c78b10a2f689ba24b156937cChristof Schmitt};
130c9615858a81d2424c78b10a2f689ba24b156937cChristof Schmitt
131c9615858a81d2424c78b10a2f689ba24b156937cChristof Schmittstruct latency_cont {
132c9615858a81d2424c78b10a2f689ba24b156937cChristof Schmitt	struct fsf_latency_record channel;
133c9615858a81d2424c78b10a2f689ba24b156937cChristof Schmitt	struct fsf_latency_record fabric;
134c9615858a81d2424c78b10a2f689ba24b156937cChristof Schmitt	u64 counter;
135c9615858a81d2424c78b10a2f689ba24b156937cChristof Schmitt};
136c9615858a81d2424c78b10a2f689ba24b156937cChristof Schmitt
137c9615858a81d2424c78b10a2f689ba24b156937cChristof Schmittstruct zfcp_latencies {
138c9615858a81d2424c78b10a2f689ba24b156937cChristof Schmitt	struct latency_cont read;
139c9615858a81d2424c78b10a2f689ba24b156937cChristof Schmitt	struct latency_cont write;
140c9615858a81d2424c78b10a2f689ba24b156937cChristof Schmitt	struct latency_cont cmd;
141c9615858a81d2424c78b10a2f689ba24b156937cChristof Schmitt	spinlock_t lock;
142c9615858a81d2424c78b10a2f689ba24b156937cChristof Schmitt};
1431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct zfcp_adapter {
145f3450c7b917201bb49d67032e9f60d5125675d6aSwen Schillig	struct kref		ref;
1467ba58c9cc16d296290fe645acb11db2b01276544Swen Schillig	u64			peer_wwnn;	   /* P2P peer WWNN */
1477ba58c9cc16d296290fe645acb11db2b01276544Swen Schillig	u64			peer_wwpn;	   /* P2P peer WWPN */
14813e1e1f08c1c098c7574c1fa72bd8c67792dc89bAndreas Herrmann	u32			peer_d_id;	   /* P2P peer D_ID */
1491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct ccw_device       *ccw_device;	   /* S/390 ccw device */
150564e1c86c810f9ccfe4300afa402815e3db4886dSwen Schillig	struct zfcp_qdio	*qdio;
1511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u32			hydra_version;	   /* Hydra version */
1521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u32			fsf_lic_version;
153aef4a983090fa590481a86d9690dc3fa6bb121faMaxim Shchetynin	u32			adapter_features;  /* FCP channel features */
154aef4a983090fa590481a86d9690dc3fa6bb121faMaxim Shchetynin	u32			connection_features; /* host connection features */
1551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        u32			hardware_version;  /* of FCP channel */
156c9615858a81d2424c78b10a2f689ba24b156937cChristof Schmitt	u16			timer_ticks;       /* time int for a tick */
1571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct Scsi_Host	*scsi_host;	   /* Pointer to mid-layer */
158ecf0c7721b104c0ce9c8ca534c911f6310cf92a8Swen Schillig	struct list_head	port_list;	   /* remote port list */
159ecf0c7721b104c0ce9c8ca534c911f6310cf92a8Swen Schillig	rwlock_t		port_list_lock;    /* port list lock */
160fea9d6c7bcd8ff1d60ff74f27ba483b3820b18a3Volker Sameske	unsigned long		req_no;		   /* unique FSF req number */
161b6bd2fb92a7bb9f1f3feecd9945c21e6c227dd51Christof Schmitt	struct zfcp_reqlist	*req_list;
1621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u32			fsf_req_seq_no;	   /* FSF cmnd seq number */
1631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	rwlock_t		abort_lock;        /* Protects against SCSI
1641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds						      stack abort/command
1651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds						      completion races */
166d26ab06ede83287f99067fee3034c5455a75faf9Swen Schillig	atomic_t		stat_miss;	   /* # missing status reads*/
16764deb6efdc5504ce97b5c1c6f281fffbc150bd93Christof Schmitt	unsigned int		stat_read_buf_num;
168d26ab06ede83287f99067fee3034c5455a75faf9Swen Schillig	struct work_struct	stat_work;
1691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	atomic_t		status;	           /* status of this adapter */
1701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct list_head	erp_ready_head;	   /* error recovery for this
1711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds						      adapter/devices */
172347c6a965dc110c91a77f65181fc011ee257a4a6Christof Schmitt	wait_queue_head_t	erp_ready_wq;
1731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct list_head	erp_running_head;
1741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	rwlock_t		erp_lock;
1751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	wait_queue_head_t	erp_done_wqh;
1761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct zfcp_erp_action	erp_action;	   /* pending error recovery */
1771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        atomic_t                erp_counter;
1781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u32			erp_total_count;   /* total nr of enqueued erp
1791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds						      actions */
1801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u32			erp_low_mem_count; /* nr of erp actions waiting
1811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds						      for memory */
182347c6a965dc110c91a77f65181fc011ee257a4a6Christof Schmitt	struct task_struct	*erp_thread;
183bd0072ecc449fb2ea8f6a2c9f6ff308f3ae0b078Christof Schmitt	struct zfcp_fc_wka_ports *gs;		   /* generic services */
184d46f384a89c2378cb7858747faa1935db17e22a8Christof Schmitt	struct zfcp_dbf		*dbf;		   /* debug traces */
1851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct zfcp_adapter_mempool	pool;      /* Adapter memory pools */
186f6cd94b126aa78ebaa21075df3b9577fbf995968Andreas Herrmann	struct fc_host_statistics *fc_stats;
187f6cd94b126aa78ebaa21075df3b9577fbf995968Andreas Herrmann	struct fsf_qtcb_bottom_port *stats_reset_data;
188f6cd94b126aa78ebaa21075df3b9577fbf995968Andreas Herrmann	unsigned long		stats_reset;
189cc8c282963bd258a5bf49d3aa52675a4ae6d31f6Swen Schillig	struct work_struct	scan_work;
190038d9446a9e601d7972926ca69fee10eeda6f3c7Christof Schmitt	struct work_struct	ns_up_work;
191bd43a42b7e9880f426ed715f18bb4f963b7352afChristof Schmitt	struct service_level	service_level;
1924544683a4b1d4e65ccca8c736bac56a195a5206bSwen Schillig	struct workqueue_struct	*work_queue;
193683229845f1780b10041ee7a1043fc8f10061455Christof Schmitt	struct device_dma_parameters dma_parms;
1942d1e547f7523514d1da449bcf08645fe13579378Sven Schuetz	struct zfcp_fc_events events;
1951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
1961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct zfcp_port {
198615f59e0daaf56e43dcaaf3ea228967d9bc21584Christof Schmitt	struct device          dev;
1993859f6a248cbdfbe7b41663f3a2b51f48e30b281Andreas Herrmann	struct fc_rport        *rport;         /* rport of fc transport class */
2001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct list_head       list;	       /* list of remote ports */
2011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct zfcp_adapter    *adapter;       /* adapter used to access port */
202ecf0c7721b104c0ce9c8ca534c911f6310cf92a8Swen Schillig	struct list_head	unit_list;	/* head of logical unit list */
203ecf0c7721b104c0ce9c8ca534c911f6310cf92a8Swen Schillig	rwlock_t		unit_list_lock; /* unit list lock */
204d99b601b63386f3395dc26a699ae703a273d9982Steffen Maier	atomic_t		units;	       /* zfcp_unit count */
2051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	atomic_t	       status;	       /* status of this remote port */
2067ba58c9cc16d296290fe645acb11db2b01276544Swen Schillig	u64		       wwnn;	       /* WWNN if known */
2077ba58c9cc16d296290fe645acb11db2b01276544Swen Schillig	u64		       wwpn;	       /* WWPN */
20813e1e1f08c1c098c7574c1fa72bd8c67792dc89bAndreas Herrmann	u32		       d_id;	       /* D_ID */
2091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	u32		       handle;	       /* handle assigned by FSF */
2101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct zfcp_erp_action erp_action;     /* pending error recovery */
2111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        atomic_t               erp_counter;
21275bfc2837bbcc329193d51e8b7115184b78beae0Ralph Wuerthner	u32                    maxframe_size;
21375bfc2837bbcc329193d51e8b7115184b78beae0Ralph Wuerthner	u32                    supported_classes;
2145ab944f97e09a3d52951fe903eed9a7b88d810b2Swen Schillig	struct work_struct     gid_pn_work;
2158fdf30d5429605a4c30cc515c73e5eab140035deChristof Schmitt	struct work_struct     test_link_work;
216a2fa0aede07c9488239dcac1eae58233181c355aChristof Schmitt	struct work_struct     rport_work;
217a2fa0aede07c9488239dcac1eae58233181c355aChristof Schmitt	enum { RPORT_NONE, RPORT_ADD, RPORT_DEL }  rport_task;
2181bf3ff02ca6247b2d7c9ebda93002392bf60a61dChristof Schmitt	unsigned int		starget_id;
2191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
2201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
221b62a8d9b45b971a67a0f8413338c230e3117dff5Christof Schmitt/**
222b62a8d9b45b971a67a0f8413338c230e3117dff5Christof Schmitt * struct zfcp_unit - LUN configured via zfcp sysfs
223b62a8d9b45b971a67a0f8413338c230e3117dff5Christof Schmitt * @dev: struct device for sysfs representation and reference counting
224b62a8d9b45b971a67a0f8413338c230e3117dff5Christof Schmitt * @list: entry in LUN/unit list per zfcp_port
225b62a8d9b45b971a67a0f8413338c230e3117dff5Christof Schmitt * @port: reference to zfcp_port where this LUN is configured
226b62a8d9b45b971a67a0f8413338c230e3117dff5Christof Schmitt * @fcp_lun: 64 bit LUN value
227b62a8d9b45b971a67a0f8413338c230e3117dff5Christof Schmitt * @scsi_work: for running scsi_scan_target
228b62a8d9b45b971a67a0f8413338c230e3117dff5Christof Schmitt *
229b62a8d9b45b971a67a0f8413338c230e3117dff5Christof Schmitt * This is the representation of a LUN that has been configured for
230b62a8d9b45b971a67a0f8413338c230e3117dff5Christof Schmitt * usage. The main data here is the 64 bit LUN value, data for
231b62a8d9b45b971a67a0f8413338c230e3117dff5Christof Schmitt * running I/O and recovery is in struct zfcp_scsi_dev.
232b62a8d9b45b971a67a0f8413338c230e3117dff5Christof Schmitt */
2331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct zfcp_unit {
234b62a8d9b45b971a67a0f8413338c230e3117dff5Christof Schmitt	struct device		dev;
235b62a8d9b45b971a67a0f8413338c230e3117dff5Christof Schmitt	struct list_head	list;
236b62a8d9b45b971a67a0f8413338c230e3117dff5Christof Schmitt	struct zfcp_port	*port;
237b62a8d9b45b971a67a0f8413338c230e3117dff5Christof Schmitt	u64			fcp_lun;
23892d5193b467c68e8432d6878980621c787e735afSwen Schillig	struct work_struct	scsi_work;
2391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
2401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
24142428f747a8a0db9c6de03e105932316defad65dSwen Schillig/**
24257c237731b92fadc7d44824276313ec330b1989bChristof Schmitt * struct zfcp_scsi_dev - zfcp data per SCSI device
24357c237731b92fadc7d44824276313ec330b1989bChristof Schmitt * @status: zfcp internal status flags
24457c237731b92fadc7d44824276313ec330b1989bChristof Schmitt * @lun_handle: handle from "open lun" for issuing FSF requests
24557c237731b92fadc7d44824276313ec330b1989bChristof Schmitt * @erp_action: zfcp erp data for opening and recovering this LUN
24657c237731b92fadc7d44824276313ec330b1989bChristof Schmitt * @erp_counter: zfcp erp counter for this LUN
24757c237731b92fadc7d44824276313ec330b1989bChristof Schmitt * @latencies: FSF channel and fabric latencies
24857c237731b92fadc7d44824276313ec330b1989bChristof Schmitt * @port: zfcp_port where this LUN belongs to
24957c237731b92fadc7d44824276313ec330b1989bChristof Schmitt */
25057c237731b92fadc7d44824276313ec330b1989bChristof Schmittstruct zfcp_scsi_dev {
25157c237731b92fadc7d44824276313ec330b1989bChristof Schmitt	atomic_t		status;
25257c237731b92fadc7d44824276313ec330b1989bChristof Schmitt	u32			lun_handle;
25357c237731b92fadc7d44824276313ec330b1989bChristof Schmitt	struct zfcp_erp_action	erp_action;
25457c237731b92fadc7d44824276313ec330b1989bChristof Schmitt	atomic_t		erp_counter;
25557c237731b92fadc7d44824276313ec330b1989bChristof Schmitt	struct zfcp_latencies	latencies;
25657c237731b92fadc7d44824276313ec330b1989bChristof Schmitt	struct zfcp_port	*port;
25757c237731b92fadc7d44824276313ec330b1989bChristof Schmitt};
25857c237731b92fadc7d44824276313ec330b1989bChristof Schmitt
25957c237731b92fadc7d44824276313ec330b1989bChristof Schmitt/**
26057c237731b92fadc7d44824276313ec330b1989bChristof Schmitt * sdev_to_zfcp - Access zfcp LUN data for SCSI device
26157c237731b92fadc7d44824276313ec330b1989bChristof Schmitt * @sdev: scsi_device where to get the zfcp_scsi_dev pointer
26257c237731b92fadc7d44824276313ec330b1989bChristof Schmitt */
26357c237731b92fadc7d44824276313ec330b1989bChristof Schmittstatic inline struct zfcp_scsi_dev *sdev_to_zfcp(struct scsi_device *sdev)
26457c237731b92fadc7d44824276313ec330b1989bChristof Schmitt{
26557c237731b92fadc7d44824276313ec330b1989bChristof Schmitt	return scsi_transport_device_data(sdev);
26657c237731b92fadc7d44824276313ec330b1989bChristof Schmitt}
26757c237731b92fadc7d44824276313ec330b1989bChristof Schmitt
26857c237731b92fadc7d44824276313ec330b1989bChristof Schmitt/**
26957c237731b92fadc7d44824276313ec330b1989bChristof Schmitt * zfcp_scsi_dev_lun - Return SCSI device LUN as 64 bit FCP LUN
27057c237731b92fadc7d44824276313ec330b1989bChristof Schmitt * @sdev: SCSI device where to get the LUN from
27157c237731b92fadc7d44824276313ec330b1989bChristof Schmitt */
27257c237731b92fadc7d44824276313ec330b1989bChristof Schmittstatic inline u64 zfcp_scsi_dev_lun(struct scsi_device *sdev)
27357c237731b92fadc7d44824276313ec330b1989bChristof Schmitt{
27457c237731b92fadc7d44824276313ec330b1989bChristof Schmitt	u64 fcp_lun;
27557c237731b92fadc7d44824276313ec330b1989bChristof Schmitt
27657c237731b92fadc7d44824276313ec330b1989bChristof Schmitt	int_to_scsilun(sdev->lun, (struct scsi_lun *)&fcp_lun);
27757c237731b92fadc7d44824276313ec330b1989bChristof Schmitt	return fcp_lun;
27857c237731b92fadc7d44824276313ec330b1989bChristof Schmitt}
27957c237731b92fadc7d44824276313ec330b1989bChristof Schmitt
28057c237731b92fadc7d44824276313ec330b1989bChristof Schmitt/**
28142428f747a8a0db9c6de03e105932316defad65dSwen Schillig * struct zfcp_fsf_req - basic FSF request structure
28242428f747a8a0db9c6de03e105932316defad65dSwen Schillig * @list: list of FSF requests
28342428f747a8a0db9c6de03e105932316defad65dSwen Schillig * @req_id: unique request ID
28442428f747a8a0db9c6de03e105932316defad65dSwen Schillig * @adapter: adapter this request belongs to
28534c2b712992540ca436e97432ffc57c84c8f8c18Christof Schmitt * @qdio_req: qdio queue related values
28642428f747a8a0db9c6de03e105932316defad65dSwen Schillig * @completion: used to signal the completion of the request
28742428f747a8a0db9c6de03e105932316defad65dSwen Schillig * @status: status of the request
28842428f747a8a0db9c6de03e105932316defad65dSwen Schillig * @fsf_command: FSF command issued
28942428f747a8a0db9c6de03e105932316defad65dSwen Schillig * @qtcb: associated QTCB
29042428f747a8a0db9c6de03e105932316defad65dSwen Schillig * @seq_no: sequence number of this request
29142428f747a8a0db9c6de03e105932316defad65dSwen Schillig * @data: private data
29242428f747a8a0db9c6de03e105932316defad65dSwen Schillig * @timer: timer data of this request
29342428f747a8a0db9c6de03e105932316defad65dSwen Schillig * @erp_action: reference to erp action if request issued on behalf of ERP
29442428f747a8a0db9c6de03e105932316defad65dSwen Schillig * @pool: reference to memory pool if used for this request
29542428f747a8a0db9c6de03e105932316defad65dSwen Schillig * @issued: time when request was send (STCK)
29642428f747a8a0db9c6de03e105932316defad65dSwen Schillig * @handler: handler which should be called to process response
29742428f747a8a0db9c6de03e105932316defad65dSwen Schillig */
2981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct zfcp_fsf_req {
29942428f747a8a0db9c6de03e105932316defad65dSwen Schillig	struct list_head	list;
30042428f747a8a0db9c6de03e105932316defad65dSwen Schillig	unsigned long		req_id;
30142428f747a8a0db9c6de03e105932316defad65dSwen Schillig	struct zfcp_adapter	*adapter;
30234c2b712992540ca436e97432ffc57c84c8f8c18Christof Schmitt	struct zfcp_qdio_req	qdio_req;
30342428f747a8a0db9c6de03e105932316defad65dSwen Schillig	struct completion	completion;
30442428f747a8a0db9c6de03e105932316defad65dSwen Schillig	u32			status;
30542428f747a8a0db9c6de03e105932316defad65dSwen Schillig	u32			fsf_command;
30642428f747a8a0db9c6de03e105932316defad65dSwen Schillig	struct fsf_qtcb		*qtcb;
30742428f747a8a0db9c6de03e105932316defad65dSwen Schillig	u32			seq_no;
30842428f747a8a0db9c6de03e105932316defad65dSwen Schillig	void			*data;
30942428f747a8a0db9c6de03e105932316defad65dSwen Schillig	struct timer_list	timer;
31042428f747a8a0db9c6de03e105932316defad65dSwen Schillig	struct zfcp_erp_action	*erp_action;
31142428f747a8a0db9c6de03e105932316defad65dSwen Schillig	mempool_t		*pool;
31242428f747a8a0db9c6de03e105932316defad65dSwen Schillig	unsigned long long	issued;
313c41f8cbddd4e0e72951e0575165dea8ea26f1c4bSwen Schillig	void			(*handler)(struct zfcp_fsf_req *);
3141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
3151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
31686a9668a8d29ea711613e1cb37efa68e7c4db564Swen Schilligstatic inline
31786a9668a8d29ea711613e1cb37efa68e7c4db564Swen Schilligint zfcp_adapter_multi_buffer_active(struct zfcp_adapter *adapter)
31886a9668a8d29ea711613e1cb37efa68e7c4db564Swen Schillig{
31986a9668a8d29ea711613e1cb37efa68e7c4db564Swen Schillig	return atomic_read(&adapter->status) & ZFCP_STATUS_ADAPTER_MB_ACT;
32086a9668a8d29ea711613e1cb37efa68e7c4db564Swen Schillig}
32186a9668a8d29ea711613e1cb37efa68e7c4db564Swen Schillig
3221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif /* ZFCP_DEF_H */
323