blob: 3a7875575616e3eec27443a0db7ef9882fcc2528 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* ------------------------------------------------------------
2 * ibmvscsi.h
3 * (C) Copyright IBM Corporation 1994, 2003
4 * Authors: Colin DeVilbiss (devilbis@us.ibm.com)
5 * Santiago Leon (santil@us.ibm.com)
6 * Dave Boutcher (sleddog@us.ibm.com)
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 * USA
22 *
23 * ------------------------------------------------------------
24 * Emulation of a SCSI host adapter for Virtual I/O devices
25 *
26 * This driver allows the Linux SCSI peripheral drivers to directly
27 * access devices in the hosting partition, either on an iSeries
28 * hypervisor system or a converged hypervisor system.
29 */
30#ifndef IBMVSCSI_H
31#define IBMVSCSI_H
32#include <linux/types.h>
33#include <linux/list.h>
34#include <linux/completion.h>
35#include <linux/interrupt.h>
Bryant G. Ly88a678b2016-06-28 17:05:35 -050036#include <scsi/viosrp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
38struct scsi_cmnd;
39struct Scsi_Host;
40
41/* Number of indirect bufs...the list of these has to fit in the
42 * additional data of the srp_cmd struct along with the indirect
43 * descriptor
44 */
45#define MAX_INDIRECT_BUFS 10
46
Robert Jenningsa897ff22007-03-28 12:45:46 -050047#define IBMVSCSI_MAX_REQUESTS_DEFAULT 100
Robert Jennings7912a0a2008-07-24 04:35:27 +100048#define IBMVSCSI_CMDS_PER_LUN_DEFAULT 16
49#define IBMVSCSI_MAX_SECTORS_DEFAULT 256 /* 32 * 8 = default max I/O 32 pages */
Brian King742d25b2007-05-29 15:46:14 -050050#define IBMVSCSI_MAX_CMDS_PER_LUN 64
Laurent Vivier3467a142015-11-09 17:49:09 +010051#define IBMVSCSI_MAX_LUN 32
Robert Jenningsa897ff22007-03-28 12:45:46 -050052
Linus Torvalds1da177e2005-04-16 15:20:36 -070053/* ------------------------------------------------------------
54 * Data Structures
55 */
56/* an RPA command/response transport queue */
57struct crq_queue {
58 struct viosrp_crq *msgs;
59 int size, cur;
60 dma_addr_t msg_token;
61 spinlock_t lock;
62};
63
64/* a unit of work for the hosting partition */
65struct srp_event_struct {
66 union viosrp_iu *xfer_iu;
67 struct scsi_cmnd *cmnd;
68 struct list_head list;
69 void (*done) (struct srp_event_struct *);
70 struct viosrp_crq crq;
71 struct ibmvscsi_host_data *hostdata;
72 atomic_t free;
73 union viosrp_iu iu;
74 void (*cmnd_done) (struct scsi_cmnd *);
75 struct completion comp;
Brian King3d0e91f2007-06-13 17:12:26 -050076 struct timer_list timer;
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 union viosrp_iu *sync_srp;
FUJITA Tomonorief265672006-03-26 03:57:14 +090078 struct srp_direct_buf *ext_list;
James Bottomley4dddbc22005-09-06 17:11:54 -050079 dma_addr_t ext_list_token;
Linus Torvalds1da177e2005-04-16 15:20:36 -070080};
81
82/* a pool of event structs for use */
83struct event_pool {
84 struct srp_event_struct *events;
85 u32 size;
86 int next;
87 union viosrp_iu *iu_storage;
88 dma_addr_t iu_token;
89};
90
91/* all driver data associated with a host adapter */
92struct ibmvscsi_host_data {
Tyrel Datwyler32d6e4b2016-12-07 16:04:35 -060093 struct list_head host_list;
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 atomic_t request_limit;
Brian King126c5cc2009-06-08 16:19:08 -050095 int client_migrated;
Brian King0f33ece2010-06-17 13:56:00 -050096 int reset_crq;
97 int reenable_crq;
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 struct device *dev;
99 struct event_pool pool;
100 struct crq_queue queue;
101 struct tasklet_struct srp_task;
102 struct list_head sent;
103 struct Scsi_Host *host;
Brian King0f33ece2010-06-17 13:56:00 -0500104 struct task_struct *work_thread;
105 wait_queue_head_t work_wait_q;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106 struct mad_adapter_info_data madapter_info;
Brian King126c5cc2009-06-08 16:19:08 -0500107 struct capabilities caps;
108 dma_addr_t caps_addr;
109 dma_addr_t adapter_info_addr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110};
111
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112#endif /* IBMVSCSI_H */