Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* ------------------------------------------------------------ |
| 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> |
| 36 | #include "viosrp.h" |
| 37 | |
| 38 | struct scsi_cmnd; |
| 39 | struct 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 | |
| 47 | /* ------------------------------------------------------------ |
| 48 | * Data Structures |
| 49 | */ |
| 50 | /* an RPA command/response transport queue */ |
| 51 | struct crq_queue { |
| 52 | struct viosrp_crq *msgs; |
| 53 | int size, cur; |
| 54 | dma_addr_t msg_token; |
| 55 | spinlock_t lock; |
| 56 | }; |
| 57 | |
| 58 | /* a unit of work for the hosting partition */ |
| 59 | struct srp_event_struct { |
| 60 | union viosrp_iu *xfer_iu; |
| 61 | struct scsi_cmnd *cmnd; |
| 62 | struct list_head list; |
| 63 | void (*done) (struct srp_event_struct *); |
| 64 | struct viosrp_crq crq; |
| 65 | struct ibmvscsi_host_data *hostdata; |
| 66 | atomic_t free; |
| 67 | union viosrp_iu iu; |
| 68 | void (*cmnd_done) (struct scsi_cmnd *); |
| 69 | struct completion comp; |
| 70 | union viosrp_iu *sync_srp; |
FUJITA Tomonori | ef26567 | 2006-03-26 03:57:14 +0900 | [diff] [blame] | 71 | struct srp_direct_buf *ext_list; |
James Bottomley | 4dddbc2 | 2005-09-06 17:11:54 -0500 | [diff] [blame] | 72 | dma_addr_t ext_list_token; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | /* a pool of event structs for use */ |
| 76 | struct event_pool { |
| 77 | struct srp_event_struct *events; |
| 78 | u32 size; |
| 79 | int next; |
| 80 | union viosrp_iu *iu_storage; |
| 81 | dma_addr_t iu_token; |
| 82 | }; |
| 83 | |
| 84 | /* all driver data associated with a host adapter */ |
| 85 | struct ibmvscsi_host_data { |
| 86 | atomic_t request_limit; |
| 87 | struct device *dev; |
| 88 | struct event_pool pool; |
| 89 | struct crq_queue queue; |
| 90 | struct tasklet_struct srp_task; |
| 91 | struct list_head sent; |
| 92 | struct Scsi_Host *host; |
| 93 | struct mad_adapter_info_data madapter_info; |
| 94 | }; |
| 95 | |
| 96 | /* routines for managing a command/response queue */ |
| 97 | int ibmvscsi_init_crq_queue(struct crq_queue *queue, |
| 98 | struct ibmvscsi_host_data *hostdata, |
| 99 | int max_requests); |
| 100 | void ibmvscsi_release_crq_queue(struct crq_queue *queue, |
| 101 | struct ibmvscsi_host_data *hostdata, |
| 102 | int max_requests); |
Dave C Boutcher | bb58596 | 2005-11-15 09:53:00 -0600 | [diff] [blame] | 103 | int ibmvscsi_reset_crq_queue(struct crq_queue *queue, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | struct ibmvscsi_host_data *hostdata); |
| 105 | |
Dave C Boutcher | 2b541f8 | 2006-01-19 13:34:44 -0600 | [diff] [blame] | 106 | int ibmvscsi_reenable_crq_queue(struct crq_queue *queue, |
| 107 | struct ibmvscsi_host_data *hostdata); |
| 108 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | void ibmvscsi_handle_crq(struct viosrp_crq *crq, |
| 110 | struct ibmvscsi_host_data *hostdata); |
| 111 | int ibmvscsi_send_crq(struct ibmvscsi_host_data *hostdata, |
| 112 | u64 word1, u64 word2); |
| 113 | |
| 114 | #endif /* IBMVSCSI_H */ |