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