xref: /freebsd/sys/dev/ntb/ntb_if.m (revision a4e5e0106ac7145f56eb39a691e302cabb4635be)
1#-
2# Copyright (c) 2016 Alexander Motin <mav@FreeBSD.org>
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8# 1. Redistributions of source code must retain the above copyright
9#    notice, this list of conditions and the following disclaimer.
10# 2. Redistributions in binary form must reproduce the above copyright
11#    notice, this list of conditions and the following disclaimer in the
12#    documentation and/or other materials provided with the distribution.
13#
14# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24# SUCH DAMAGE.
25#
26#
27
28#include <sys/bus.h>
29#include <machine/bus.h>
30
31INTERFACE ntb;
32
33HEADER {
34	enum ntb_speed {
35		NTB_SPEED_AUTO = -1,
36		NTB_SPEED_NONE = 0,
37		NTB_SPEED_GEN1 = 1,
38		NTB_SPEED_GEN2 = 2,
39		NTB_SPEED_GEN3 = 3,
40		NTB_SPEED_GEN4 = 4,
41	};
42
43	enum ntb_width {
44		NTB_WIDTH_AUTO = -1,
45		NTB_WIDTH_NONE = 0,
46		NTB_WIDTH_1 = 1,
47		NTB_WIDTH_2 = 2,
48		NTB_WIDTH_4 = 4,
49		NTB_WIDTH_8 = 8,
50		NTB_WIDTH_12 = 12,
51		NTB_WIDTH_16 = 16,
52		NTB_WIDTH_32 = 32,
53	};
54
55	typedef void (*ntb_db_callback)(void *data, uint32_t vector);
56	typedef void (*ntb_event_callback)(void *data);
57	struct ntb_ctx_ops {
58		ntb_event_callback	link_event;
59		ntb_db_callback		db_event;
60	};
61};
62
63METHOD int port_number {
64	device_t	ntb;
65};
66
67METHOD int peer_port_count {
68	device_t	ntb;
69};
70
71METHOD int peer_port_number {
72	device_t	ntb;
73	int		pidx;
74};
75
76METHOD int peer_port_idx {
77	device_t	ntb;
78	int		port;
79};
80
81METHOD bool link_is_up {
82	device_t	 ntb;
83	enum ntb_speed	*speed;
84	enum ntb_width	*width;
85};
86
87METHOD int link_enable {
88	device_t	 ntb;
89	enum ntb_speed	 speed;
90	enum ntb_width	 width;
91};
92
93METHOD int link_disable {
94	device_t	 ntb;
95};
96
97METHOD bool link_enabled {
98	device_t	 ntb;
99};
100
101METHOD int set_ctx {
102	device_t	 ntb;
103	void		*ctx;
104	const struct ntb_ctx_ops *ctx_ops;
105};
106
107METHOD void * get_ctx {
108	device_t	 ntb;
109	const struct ntb_ctx_ops **ctx_ops;
110};
111
112METHOD void clear_ctx {
113	device_t	 ntb;
114};
115
116METHOD uint8_t mw_count {
117	device_t	 ntb;
118};
119
120METHOD int mw_get_range {
121	device_t	 ntb;
122	unsigned	 mw_idx;
123	vm_paddr_t	*base;
124	caddr_t		*vbase;
125	size_t		*size;
126	size_t		*align;
127	size_t		*align_size;
128	bus_addr_t	*plimit;
129};
130
131METHOD int mw_set_trans {
132	device_t	 ntb;
133	unsigned	 mw_idx;
134	bus_addr_t	 addr;
135	size_t		 size;
136};
137
138METHOD int mw_clear_trans {
139	device_t	 ntb;
140	unsigned	 mw_idx;
141};
142
143METHOD int mw_get_wc {
144	device_t	 ntb;
145	unsigned	 mw_idx;
146	vm_memattr_t	*mode;
147};
148
149METHOD int mw_set_wc {
150	device_t	 ntb;
151	unsigned	 mw_idx;
152	vm_memattr_t	 mode;
153};
154
155METHOD uint8_t spad_count {
156	device_t	 ntb;
157};
158
159METHOD void spad_clear {
160	device_t	 ntb;
161};
162
163METHOD int spad_write {
164	device_t	 ntb;
165	unsigned int	 idx;
166	uint32_t	 val;
167};
168
169METHOD int spad_read {
170	device_t	 ntb;
171	unsigned int	 idx;
172	uint32_t	 *val;
173};
174
175METHOD int peer_spad_write {
176	device_t	 ntb;
177	unsigned int	 idx;
178	uint32_t	 val;
179};
180
181METHOD int peer_spad_read {
182	device_t	 ntb;
183	unsigned int	 idx;
184	uint32_t	*val;
185};
186
187METHOD uint64_t db_valid_mask {
188	device_t	 ntb;
189};
190
191METHOD int db_vector_count {
192	device_t	 ntb;
193};
194
195METHOD uint64_t db_vector_mask {
196	device_t	 ntb;
197	uint32_t	 vector;
198};
199
200METHOD int peer_db_addr {
201	device_t	 ntb;
202	bus_addr_t	*db_addr;
203	vm_size_t	*db_size;
204};
205
206METHOD void db_clear {
207	device_t	 ntb;
208	uint64_t	 bits;
209};
210
211METHOD void db_clear_mask {
212	device_t	 ntb;
213	uint64_t	 bits;
214};
215
216METHOD uint64_t db_read {
217	device_t	 ntb;
218};
219
220METHOD void db_set_mask {
221	device_t	 ntb;
222	uint64_t	 bits;
223};
224
225METHOD void peer_db_set {
226	device_t	 ntb;
227	uint64_t	 bits;
228};
229