xref: /freebsd/sys/dev/ntb/ntb_if.m (revision d8a0fe102c0cfdfcd5b818f850eff09d8536c9bc)
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# $FreeBSD$
27#
28
29#include <sys/bus.h>
30#include <machine/bus.h>
31
32INTERFACE ntb;
33
34HEADER {
35	enum ntb_speed {
36		NTB_SPEED_AUTO = -1,
37		NTB_SPEED_NONE = 0,
38		NTB_SPEED_GEN1 = 1,
39		NTB_SPEED_GEN2 = 2,
40		NTB_SPEED_GEN3 = 3,
41		NTB_SPEED_GEN4 = 4,
42	};
43
44	enum ntb_width {
45		NTB_WIDTH_AUTO = -1,
46		NTB_WIDTH_NONE = 0,
47		NTB_WIDTH_1 = 1,
48		NTB_WIDTH_2 = 2,
49		NTB_WIDTH_4 = 4,
50		NTB_WIDTH_8 = 8,
51		NTB_WIDTH_12 = 12,
52		NTB_WIDTH_16 = 16,
53		NTB_WIDTH_32 = 32,
54	};
55
56	typedef void (*ntb_db_callback)(void *data, uint32_t vector);
57	typedef void (*ntb_event_callback)(void *data);
58	struct ntb_ctx_ops {
59		ntb_event_callback	link_event;
60		ntb_db_callback		db_event;
61	};
62};
63
64METHOD bool link_is_up {
65	device_t	 ntb;
66	enum ntb_speed	*speed;
67	enum ntb_width	*width;
68};
69
70METHOD int link_enable {
71	device_t	 ntb;
72	enum ntb_speed	 speed;
73	enum ntb_width	 width;
74};
75
76METHOD int link_disable {
77	device_t	 ntb;
78};
79
80METHOD bool link_enabled {
81	device_t	 ntb;
82};
83
84METHOD int set_ctx {
85	device_t	 ntb;
86	void		*ctx;
87	const struct ntb_ctx_ops *ctx_ops;
88};
89
90METHOD void * get_ctx {
91	device_t	 ntb;
92	const struct ntb_ctx_ops **ctx_ops;
93};
94
95METHOD void clear_ctx {
96	device_t	 ntb;
97};
98
99METHOD uint8_t mw_count {
100	device_t	 ntb;
101};
102
103METHOD int mw_get_range {
104	device_t	 ntb;
105	unsigned	 mw_idx;
106	vm_paddr_t	*base;
107	caddr_t		*vbase;
108	size_t		*size;
109	size_t		*align;
110	size_t		*align_size;
111	bus_addr_t	*plimit;
112};
113
114METHOD int mw_set_trans {
115	device_t	 ntb;
116	unsigned	 mw_idx;
117	bus_addr_t	 addr;
118	size_t		 size;
119};
120
121METHOD int mw_clear_trans {
122	device_t	 ntb;
123	unsigned	 mw_idx;
124};
125
126METHOD int mw_get_wc {
127	device_t	 ntb;
128	unsigned	 mw_idx;
129	vm_memattr_t	*mode;
130};
131
132METHOD int mw_set_wc {
133	device_t	 ntb;
134	unsigned	 mw_idx;
135	vm_memattr_t	 mode;
136};
137
138METHOD uint8_t spad_count {
139	device_t	 ntb;
140};
141
142METHOD void spad_clear {
143	device_t	 ntb;
144};
145
146METHOD int spad_write {
147	device_t	 ntb;
148	unsigned int	 idx;
149	uint32_t	 val;
150};
151
152METHOD int spad_read {
153	device_t	 ntb;
154	unsigned int	 idx;
155	uint32_t	 *val;
156};
157
158METHOD int peer_spad_write {
159	device_t	 ntb;
160	unsigned int	 idx;
161	uint32_t	 val;
162};
163
164METHOD int peer_spad_read {
165	device_t	 ntb;
166	unsigned int	 idx;
167	uint32_t	*val;
168};
169
170METHOD uint64_t db_valid_mask {
171	device_t	 ntb;
172};
173
174METHOD int db_vector_count {
175	device_t	 ntb;
176};
177
178METHOD uint64_t db_vector_mask {
179	device_t	 ntb;
180	uint32_t	 vector;
181};
182
183METHOD int peer_db_addr {
184	device_t	 ntb;
185	bus_addr_t	*db_addr;
186	vm_size_t	*db_size;
187};
188
189METHOD void db_clear {
190	device_t	 ntb;
191	uint64_t	 bits;
192};
193
194METHOD void db_clear_mask {
195	device_t	 ntb;
196	uint64_t	 bits;
197};
198
199METHOD uint64_t db_read {
200	device_t	 ntb;
201};
202
203METHOD void db_set_mask {
204	device_t	 ntb;
205	uint64_t	 bits;
206};
207
208METHOD void peer_db_set {
209	device_t	 ntb;
210	uint64_t	 bits;
211};
212