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 int port_number { 65 device_t ntb; 66}; 67 68METHOD int peer_port_count { 69 device_t ntb; 70}; 71 72METHOD int peer_port_number { 73 device_t ntb; 74 int pidx; 75}; 76 77METHOD int peer_port_idx { 78 device_t ntb; 79 int port; 80}; 81 82METHOD bool link_is_up { 83 device_t ntb; 84 enum ntb_speed *speed; 85 enum ntb_width *width; 86}; 87 88METHOD int link_enable { 89 device_t ntb; 90 enum ntb_speed speed; 91 enum ntb_width width; 92}; 93 94METHOD int link_disable { 95 device_t ntb; 96}; 97 98METHOD bool link_enabled { 99 device_t ntb; 100}; 101 102METHOD int set_ctx { 103 device_t ntb; 104 void *ctx; 105 const struct ntb_ctx_ops *ctx_ops; 106}; 107 108METHOD void * get_ctx { 109 device_t ntb; 110 const struct ntb_ctx_ops **ctx_ops; 111}; 112 113METHOD void clear_ctx { 114 device_t ntb; 115}; 116 117METHOD uint8_t mw_count { 118 device_t ntb; 119}; 120 121METHOD int mw_get_range { 122 device_t ntb; 123 unsigned mw_idx; 124 vm_paddr_t *base; 125 caddr_t *vbase; 126 size_t *size; 127 size_t *align; 128 size_t *align_size; 129 bus_addr_t *plimit; 130}; 131 132METHOD int mw_set_trans { 133 device_t ntb; 134 unsigned mw_idx; 135 bus_addr_t addr; 136 size_t size; 137}; 138 139METHOD int mw_clear_trans { 140 device_t ntb; 141 unsigned mw_idx; 142}; 143 144METHOD int mw_get_wc { 145 device_t ntb; 146 unsigned mw_idx; 147 vm_memattr_t *mode; 148}; 149 150METHOD int mw_set_wc { 151 device_t ntb; 152 unsigned mw_idx; 153 vm_memattr_t mode; 154}; 155 156METHOD uint8_t spad_count { 157 device_t ntb; 158}; 159 160METHOD void spad_clear { 161 device_t ntb; 162}; 163 164METHOD int spad_write { 165 device_t ntb; 166 unsigned int idx; 167 uint32_t val; 168}; 169 170METHOD int spad_read { 171 device_t ntb; 172 unsigned int idx; 173 uint32_t *val; 174}; 175 176METHOD int peer_spad_write { 177 device_t ntb; 178 unsigned int idx; 179 uint32_t val; 180}; 181 182METHOD int peer_spad_read { 183 device_t ntb; 184 unsigned int idx; 185 uint32_t *val; 186}; 187 188METHOD uint64_t db_valid_mask { 189 device_t ntb; 190}; 191 192METHOD int db_vector_count { 193 device_t ntb; 194}; 195 196METHOD uint64_t db_vector_mask { 197 device_t ntb; 198 uint32_t vector; 199}; 200 201METHOD int peer_db_addr { 202 device_t ntb; 203 bus_addr_t *db_addr; 204 vm_size_t *db_size; 205}; 206 207METHOD void db_clear { 208 device_t ntb; 209 uint64_t bits; 210}; 211 212METHOD void db_clear_mask { 213 device_t ntb; 214 uint64_t bits; 215}; 216 217METHOD uint64_t db_read { 218 device_t ntb; 219}; 220 221METHOD void db_set_mask { 222 device_t ntb; 223 uint64_t bits; 224}; 225 226METHOD void peer_db_set { 227 device_t ntb; 228 uint64_t bits; 229}; 230