18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/* ------------------------------------------------------------
38c2ecf20Sopenharmony_ci * ibmvscsi.h
48c2ecf20Sopenharmony_ci * (C) Copyright IBM Corporation 1994, 2003
58c2ecf20Sopenharmony_ci * Authors: Colin DeVilbiss (devilbis@us.ibm.com)
68c2ecf20Sopenharmony_ci *          Santiago Leon (santil@us.ibm.com)
78c2ecf20Sopenharmony_ci *          Dave Boutcher (sleddog@us.ibm.com)
88c2ecf20Sopenharmony_ci *
98c2ecf20Sopenharmony_ci * ------------------------------------------------------------
108c2ecf20Sopenharmony_ci * Emulation of a SCSI host adapter for Virtual I/O devices
118c2ecf20Sopenharmony_ci *
128c2ecf20Sopenharmony_ci * This driver allows the Linux SCSI peripheral drivers to directly
138c2ecf20Sopenharmony_ci * access devices in the hosting partition, either on an iSeries
148c2ecf20Sopenharmony_ci * hypervisor system or a converged hypervisor system.
158c2ecf20Sopenharmony_ci */
168c2ecf20Sopenharmony_ci#ifndef IBMVSCSI_H
178c2ecf20Sopenharmony_ci#define IBMVSCSI_H
188c2ecf20Sopenharmony_ci#include <linux/types.h>
198c2ecf20Sopenharmony_ci#include <linux/list.h>
208c2ecf20Sopenharmony_ci#include <linux/completion.h>
218c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
228c2ecf20Sopenharmony_ci#include <scsi/viosrp.h>
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_cistruct scsi_cmnd;
258c2ecf20Sopenharmony_cistruct Scsi_Host;
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci/* Number of indirect bufs...the list of these has to fit in the
288c2ecf20Sopenharmony_ci * additional data of the srp_cmd struct along with the indirect
298c2ecf20Sopenharmony_ci * descriptor
308c2ecf20Sopenharmony_ci */
318c2ecf20Sopenharmony_ci#define MAX_INDIRECT_BUFS 10
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#define IBMVSCSI_MAX_REQUESTS_DEFAULT 100
348c2ecf20Sopenharmony_ci#define IBMVSCSI_CMDS_PER_LUN_DEFAULT 16
358c2ecf20Sopenharmony_ci#define IBMVSCSI_MAX_SECTORS_DEFAULT 256 /* 32 * 8 = default max I/O 32 pages */
368c2ecf20Sopenharmony_ci#define IBMVSCSI_MAX_CMDS_PER_LUN 64
378c2ecf20Sopenharmony_ci#define IBMVSCSI_MAX_LUN 32
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci/* ------------------------------------------------------------
408c2ecf20Sopenharmony_ci * Data Structures
418c2ecf20Sopenharmony_ci */
428c2ecf20Sopenharmony_ci/* an RPA command/response transport queue */
438c2ecf20Sopenharmony_cistruct crq_queue {
448c2ecf20Sopenharmony_ci	struct viosrp_crq *msgs;
458c2ecf20Sopenharmony_ci	int size, cur;
468c2ecf20Sopenharmony_ci	dma_addr_t msg_token;
478c2ecf20Sopenharmony_ci	spinlock_t lock;
488c2ecf20Sopenharmony_ci};
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci/* a unit of work for the hosting partition */
518c2ecf20Sopenharmony_cistruct srp_event_struct {
528c2ecf20Sopenharmony_ci	union viosrp_iu *xfer_iu;
538c2ecf20Sopenharmony_ci	struct scsi_cmnd *cmnd;
548c2ecf20Sopenharmony_ci	struct list_head list;
558c2ecf20Sopenharmony_ci	void (*done) (struct srp_event_struct *);
568c2ecf20Sopenharmony_ci	struct viosrp_crq crq;
578c2ecf20Sopenharmony_ci	struct ibmvscsi_host_data *hostdata;
588c2ecf20Sopenharmony_ci	atomic_t free;
598c2ecf20Sopenharmony_ci	union viosrp_iu iu;
608c2ecf20Sopenharmony_ci	void (*cmnd_done) (struct scsi_cmnd *);
618c2ecf20Sopenharmony_ci	struct completion comp;
628c2ecf20Sopenharmony_ci	struct timer_list timer;
638c2ecf20Sopenharmony_ci	union viosrp_iu *sync_srp;
648c2ecf20Sopenharmony_ci	struct srp_direct_buf *ext_list;
658c2ecf20Sopenharmony_ci	dma_addr_t ext_list_token;
668c2ecf20Sopenharmony_ci};
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci/* a pool of event structs for use */
698c2ecf20Sopenharmony_cistruct event_pool {
708c2ecf20Sopenharmony_ci	struct srp_event_struct *events;
718c2ecf20Sopenharmony_ci	u32 size;
728c2ecf20Sopenharmony_ci	int next;
738c2ecf20Sopenharmony_ci	union viosrp_iu *iu_storage;
748c2ecf20Sopenharmony_ci	dma_addr_t iu_token;
758c2ecf20Sopenharmony_ci};
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_cienum ibmvscsi_host_action {
788c2ecf20Sopenharmony_ci	IBMVSCSI_HOST_ACTION_NONE = 0,
798c2ecf20Sopenharmony_ci	IBMVSCSI_HOST_ACTION_RESET,
808c2ecf20Sopenharmony_ci	IBMVSCSI_HOST_ACTION_REENABLE,
818c2ecf20Sopenharmony_ci	IBMVSCSI_HOST_ACTION_UNBLOCK,
828c2ecf20Sopenharmony_ci};
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci/* all driver data associated with a host adapter */
858c2ecf20Sopenharmony_cistruct ibmvscsi_host_data {
868c2ecf20Sopenharmony_ci	struct list_head host_list;
878c2ecf20Sopenharmony_ci	atomic_t request_limit;
888c2ecf20Sopenharmony_ci	int client_migrated;
898c2ecf20Sopenharmony_ci	enum ibmvscsi_host_action action;
908c2ecf20Sopenharmony_ci	struct device *dev;
918c2ecf20Sopenharmony_ci	struct event_pool pool;
928c2ecf20Sopenharmony_ci	struct crq_queue queue;
938c2ecf20Sopenharmony_ci	struct tasklet_struct srp_task;
948c2ecf20Sopenharmony_ci	struct list_head sent;
958c2ecf20Sopenharmony_ci	struct Scsi_Host *host;
968c2ecf20Sopenharmony_ci	struct task_struct *work_thread;
978c2ecf20Sopenharmony_ci	wait_queue_head_t work_wait_q;
988c2ecf20Sopenharmony_ci	struct mad_adapter_info_data madapter_info;
998c2ecf20Sopenharmony_ci	struct capabilities caps;
1008c2ecf20Sopenharmony_ci	dma_addr_t caps_addr;
1018c2ecf20Sopenharmony_ci	dma_addr_t adapter_info_addr;
1028c2ecf20Sopenharmony_ci};
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci#endif				/* IBMVSCSI_H */
105