^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /* ------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * ibmvscsi.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * (C) Copyright IBM Corporation 1994, 2003
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Authors: Colin DeVilbiss (devilbis@us.ibm.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Santiago Leon (santil@us.ibm.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Dave Boutcher (sleddog@us.ibm.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * ------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * Emulation of a SCSI host adapter for Virtual I/O devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * This driver allows the Linux SCSI peripheral drivers to directly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * access devices in the hosting partition, either on an iSeries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * hypervisor system or a converged hypervisor system.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #ifndef IBMVSCSI_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define IBMVSCSI_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/completion.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <scsi/viosrp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) struct scsi_cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) struct Scsi_Host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) /* Number of indirect bufs...the list of these has to fit in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * additional data of the srp_cmd struct along with the indirect
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define MAX_INDIRECT_BUFS 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define IBMVSCSI_MAX_REQUESTS_DEFAULT 100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define IBMVSCSI_CMDS_PER_LUN_DEFAULT 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #define IBMVSCSI_MAX_SECTORS_DEFAULT 256 /* 32 * 8 = default max I/O 32 pages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define IBMVSCSI_MAX_CMDS_PER_LUN 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #define IBMVSCSI_MAX_LUN 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) /* ------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * Data Structures
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) /* an RPA command/response transport queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) struct crq_queue {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) struct viosrp_crq *msgs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) int size, cur;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) dma_addr_t msg_token;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) spinlock_t lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) /* a unit of work for the hosting partition */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) struct srp_event_struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) union viosrp_iu *xfer_iu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct scsi_cmnd *cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) void (*done) (struct srp_event_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) struct viosrp_crq crq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) struct ibmvscsi_host_data *hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) atomic_t free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) union viosrp_iu iu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) void (*cmnd_done) (struct scsi_cmnd *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) struct completion comp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) struct timer_list timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) union viosrp_iu *sync_srp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) struct srp_direct_buf *ext_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) dma_addr_t ext_list_token;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) /* a pool of event structs for use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) struct event_pool {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) struct srp_event_struct *events;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) u32 size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) int next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) union viosrp_iu *iu_storage;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) dma_addr_t iu_token;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) enum ibmvscsi_host_action {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) IBMVSCSI_HOST_ACTION_NONE = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) IBMVSCSI_HOST_ACTION_RESET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) IBMVSCSI_HOST_ACTION_REENABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) IBMVSCSI_HOST_ACTION_UNBLOCK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) /* all driver data associated with a host adapter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) struct ibmvscsi_host_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) struct list_head host_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) atomic_t request_limit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) int client_migrated;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) enum ibmvscsi_host_action action;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) struct device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) struct event_pool pool;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) struct crq_queue queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) struct tasklet_struct srp_task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) struct list_head sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) struct Scsi_Host *host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) struct task_struct *work_thread;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) wait_queue_head_t work_wait_q;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) struct mad_adapter_info_data madapter_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) struct capabilities caps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) dma_addr_t caps_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) dma_addr_t adapter_info_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #endif /* IBMVSCSI_H */