summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/io/scsi/adapters/pvscsi/pvscsi_var.h
blob: ec68ef1471f710d8c10797598fa9e0aefe597ba9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
 * This file and its contents are supplied under the terms of the
 * Common Development and Distribution License ("CDDL"), version 1.0.
 * You may only use this file in accordance with the terms of version
 * 1.0 of the CDDL.
 *
 * A full copy of the text of the CDDL should have accompanied this
 * source.  A copy of the CDDL is also available via the Internet at
 * http://www.illumos.org/license/CDDL.
 */

/*
 * Copyright 2016 Nexenta Systems, Inc.
 * Copyright 2022 RackTop Systems, Inc.
 */

#ifndef	_PVSCSI_VAR_H_
#define	_PVSCSI_VAR_H_

typedef struct pvscsi_dma_buf {
	ddi_dma_handle_t dmah;
	caddr_t		addr;
	uint64_t	pa;
	ddi_acc_handle_t acch;
} pvscsi_dma_buf_t;

#define	PVSCSI_MAX_IO_PAGES	256
#define	PVSCSI_MAX_IO_SIZE	(PVSCSI_MAX_IO_PAGES * PAGE_SIZE)
#define	PVSCSI_MAX_SG_SIZE	(PVSCSI_MAX_IO_PAGES + 1)

typedef struct pvscsi_cmd {
	struct scsi_pkt		*pkt;
	struct scsi_arq_status	cmd_scb;
	uint8_t			cdb[SCSI_CDB_SIZE];
	size_t			cdblen;
	uint8_t			tag;
	uint8_t			scsi_status;
	uint32_t		host_status;
	uint64_t		transferred;
	boolean_t		poll;
	int			target;
	int			lun;
	uint32_t		ctx;
	list_node_t		queue_node;
	clock_t			timeout;
	clock_t			start;
	struct pvscsi_softc	*pvs;
	struct pvscsi_cmd	*next_cmd;

	ddi_dma_handle_t	sgl_dmah;
	ddi_acc_handle_t	sgl_acch;
	uint64_t		sgl_pa;
	struct PVSCSISGElement	*sgl;

	uint64_t		arq_pa;
	uint8_t			arq_sense[SENSE_LENGTH];
	ddi_dma_handle_t	arq_dmah;

	uint32_t		dma_dir;

	uint8_t			done;
	uint8_t			expired;
} pvscsi_cmd_t;

typedef struct pvscsi_msg {
	struct pvscsi_softc	*pvs;
	int			type;
	int			target;
	int			lun;
} pvscsi_msg_t;

typedef struct pvscsi_device {
	list_node_t		node;
	struct pvscsi_softc	*pvs;
	int			target;
	int			lun;
} pvscsi_device_t;

typedef struct pvscsi_softc {
	dev_info_t		*dip;
	scsi_hba_tran_t		*tran;
	scsi_hba_tgtmap_t	*tgtmap;
	pvscsi_dma_buf_t	state_buf;
	pvscsi_dma_buf_t	req_ring_buf;
	uint_t			req_pages;
	uint_t			req_depth;
	pvscsi_dma_buf_t	cmp_ring_buf;
	uint_t			cmp_pages;
	pvscsi_dma_buf_t	msg_ring_buf;
	uint_t			msg_pages;
	ddi_acc_handle_t	mmio_handle;
	caddr_t			mmio_base;
	int			intr_cnt;
	int			intr_pri;
	int			intr_type;
	uint32_t		max_targets;
	ddi_intr_handle_t	intr_handles[PVSCSI_MAX_INTRS];
	list_t			cmd_queue;
	list_t			devices;
	kmutex_t		lock;
	ddi_taskq_t		*tq;
	timeout_id_t		timeout;
	boolean_t		detach;
} pvscsi_softc_t;

#define	REQ_RING(pvs) \
	((struct PVSCSIRingReqDesc *)((pvs)->req_ring_buf.addr))

#define	CMP_RING(pvs) \
	((struct PVSCSIRingCmpDesc *)((pvs)->cmp_ring_buf.addr))

#define	MSG_RING(pvs) \
	((struct PVSCSIRingMsgDesc *)((pvs)->msg_ring_buf.addr))

#define	RINGS_STATE(pvs) \
	((struct PVSCSIRingsState *)((pvs)->state_buf.addr))

#define	PVSCSI_MAXTGTS	16

#define	PAGE_SIZE	4096
#define	PAGE_SHIFT	12

#define	PVSCSI_DEFAULT_NUM_PAGES_PER_RING	8
#define	PVSCSI_DEFAULT_NUM_PAGES_MSG_RING	1

#endif	/* _PVSCSI_VAR_H_ */