pci_if.m revision 331111
1#- 2# Copyright (c) 1998 Doug Rabson 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: stable/11/sys/dev/pci/pci_if.m 331111 2018-03-17 20:20:29Z bryanv $ 27# 28 29#include <sys/bus.h> 30#include <dev/pci/pcivar.h> 31 32INTERFACE pci; 33 34CODE { 35 static int 36 null_msi_count(device_t dev, device_t child) 37 { 38 return (0); 39 } 40 41 static int 42 null_msix_bar(device_t dev, device_t child) 43 { 44 return (-1); 45 } 46 47 static device_t 48 null_create_iov_child(device_t bus, device_t pf, uint16_t rid, 49 uint16_t vid, uint16_t did) 50 { 51 device_printf(bus, "PCI_IOV not implemented on this bus.\n"); 52 return (NULL); 53 } 54 55 static int 56 compat_iov_attach(device_t bus, device_t dev, struct nvlist *pf_schema, 57 struct nvlist *vf_schema) 58 { 59 return (PCI_IOV_ATTACH_NAME(bus, dev, pf_schema, vf_schema, 60 device_get_nameunit(dev))); 61 } 62}; 63 64HEADER { 65 struct nvlist; 66 67 enum pci_id_type { 68 PCI_ID_RID, 69 PCI_ID_MSI, 70 }; 71} 72 73 74METHOD u_int32_t read_config { 75 device_t dev; 76 device_t child; 77 int reg; 78 int width; 79}; 80 81METHOD void write_config { 82 device_t dev; 83 device_t child; 84 int reg; 85 u_int32_t val; 86 int width; 87}; 88 89METHOD int get_powerstate { 90 device_t dev; 91 device_t child; 92}; 93 94METHOD int set_powerstate { 95 device_t dev; 96 device_t child; 97 int state; 98}; 99 100METHOD int get_vpd_ident { 101 device_t dev; 102 device_t child; 103 const char **identptr; 104}; 105 106METHOD int get_vpd_readonly { 107 device_t dev; 108 device_t child; 109 const char *kw; 110 const char **vptr; 111}; 112 113METHOD int enable_busmaster { 114 device_t dev; 115 device_t child; 116}; 117 118METHOD int disable_busmaster { 119 device_t dev; 120 device_t child; 121}; 122 123METHOD int enable_io { 124 device_t dev; 125 device_t child; 126 int space; 127}; 128 129METHOD int disable_io { 130 device_t dev; 131 device_t child; 132 int space; 133}; 134 135METHOD int assign_interrupt { 136 device_t dev; 137 device_t child; 138}; 139 140METHOD int find_cap { 141 device_t dev; 142 device_t child; 143 int capability; 144 int *capreg; 145}; 146 147METHOD int find_next_cap { 148 device_t dev; 149 device_t child; 150 int capability; 151 int start; 152 int *capreg; 153}; 154 155METHOD int find_extcap { 156 device_t dev; 157 device_t child; 158 int capability; 159 int *capreg; 160}; 161 162METHOD int find_next_extcap { 163 device_t dev; 164 device_t child; 165 int capability; 166 int start; 167 int *capreg; 168}; 169 170METHOD int find_htcap { 171 device_t dev; 172 device_t child; 173 int capability; 174 int *capreg; 175}; 176 177METHOD int find_next_htcap { 178 device_t dev; 179 device_t child; 180 int capability; 181 int start; 182 int *capreg; 183}; 184 185METHOD int alloc_msi { 186 device_t dev; 187 device_t child; 188 int *count; 189}; 190 191METHOD int alloc_msix { 192 device_t dev; 193 device_t child; 194 int *count; 195}; 196 197METHOD void enable_msi { 198 device_t dev; 199 device_t child; 200 uint64_t address; 201 uint16_t data; 202}; 203 204METHOD void enable_msix { 205 device_t dev; 206 device_t child; 207 u_int index; 208 uint64_t address; 209 uint32_t data; 210}; 211 212METHOD void disable_msi { 213 device_t dev; 214 device_t child; 215}; 216 217METHOD int remap_msix { 218 device_t dev; 219 device_t child; 220 int count; 221 const u_int *vectors; 222}; 223 224METHOD int release_msi { 225 device_t dev; 226 device_t child; 227}; 228 229METHOD int msi_count { 230 device_t dev; 231 device_t child; 232} DEFAULT null_msi_count; 233 234METHOD int msix_count { 235 device_t dev; 236 device_t child; 237} DEFAULT null_msi_count; 238 239METHOD int msix_pba_bar { 240 device_t dev; 241 device_t child; 242} DEFAULT null_msix_bar; 243 244METHOD int msix_table_bar { 245 device_t dev; 246 device_t child; 247} DEFAULT null_msix_bar; 248 249METHOD int get_id { 250 device_t dev; 251 device_t child; 252 enum pci_id_type type; 253 uintptr_t *id; 254}; 255 256METHOD struct pci_devinfo * alloc_devinfo { 257 device_t dev; 258}; 259 260METHOD void child_added { 261 device_t dev; 262 device_t child; 263}; 264 265METHOD int iov_attach { 266 device_t dev; 267 device_t child; 268 struct nvlist *pf_schema; 269 struct nvlist *vf_schema; 270} DEFAULT compat_iov_attach; 271 272METHOD int iov_attach_name { 273 device_t dev; 274 device_t child; 275 struct nvlist *pf_schema; 276 struct nvlist *vf_schema; 277 const char *name; 278}; 279 280METHOD int iov_detach { 281 device_t dev; 282 device_t child; 283}; 284 285METHOD device_t create_iov_child { 286 device_t bus; 287 device_t pf; 288 uint16_t rid; 289 uint16_t vid; 290 uint16_t did; 291} DEFAULT null_create_iov_child; 292