Damjan Marion | a42cd34 | 2016-04-13 18:03:20 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 Cisco and/or its affiliates. |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | /* |
| 16 | * pci.h: PCI definitions. |
| 17 | * |
| 18 | * Copyright (c) 2008 Eliot Dresselhaus |
| 19 | * |
| 20 | * Permission is hereby granted, free of charge, to any person obtaining |
| 21 | * a copy of this software and associated documentation files (the |
| 22 | * "Software"), to deal in the Software without restriction, including |
| 23 | * without limitation the rights to use, copy, modify, merge, publish, |
| 24 | * distribute, sublicense, and/or sell copies of the Software, and to |
| 25 | * permit persons to whom the Software is furnished to do so, subject to |
| 26 | * the following conditions: |
| 27 | * |
| 28 | * The above copyright notice and this permission notice shall be |
| 29 | * included in all copies or substantial portions of the Software. |
| 30 | * |
| 31 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 32 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 33 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 34 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 35 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 36 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 37 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 38 | */ |
| 39 | |
| 40 | #ifndef included_vlib_pci_h |
| 41 | #define included_vlib_pci_h |
| 42 | |
| 43 | #include <vlib/vlib.h> |
| 44 | #include <vlib/pci/pci_config.h> |
| 45 | |
Damjan Marion | cef87f1 | 2017-10-05 15:32:41 +0200 | [diff] [blame] | 46 | /* *INDENT-OFF* */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 47 | typedef CLIB_PACKED (union |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 48 | { |
Damjan Marion | cef87f1 | 2017-10-05 15:32:41 +0200 | [diff] [blame] | 49 | struct |
| 50 | { |
| 51 | u16 domain; |
| 52 | u8 bus; |
| 53 | u8 slot: 5; |
| 54 | u8 function:3; |
| 55 | }; |
| 56 | u32 as_u32; |
| 57 | }) vlib_pci_addr_t; |
| 58 | /* *INDENT-ON* */ |
Damjan Marion | a42cd34 | 2016-04-13 18:03:20 +0200 | [diff] [blame] | 59 | |
Damjan Marion | cef87f1 | 2017-10-05 15:32:41 +0200 | [diff] [blame] | 60 | typedef struct vlib_pci_device_info |
| 61 | { |
Damjan Marion | 20ba164 | 2018-03-26 15:35:33 +0200 | [diff] [blame] | 62 | u32 flags; |
| 63 | #define VLIB_PCI_DEVICE_INFO_F_NOIOMMU (1 << 0); |
| 64 | |
Damjan Marion | cef87f1 | 2017-10-05 15:32:41 +0200 | [diff] [blame] | 65 | /* addr */ |
| 66 | vlib_pci_addr_t addr; |
Damjan Marion | 5a206ea | 2016-05-12 22:11:03 +0200 | [diff] [blame] | 67 | |
| 68 | /* Numa Node */ |
| 69 | int numa_node; |
| 70 | |
Damjan Marion | b1b1a14 | 2016-08-23 00:53:22 +0200 | [diff] [blame] | 71 | /* Device data */ |
| 72 | u16 device_class; |
| 73 | u16 vendor_id; |
| 74 | u16 device_id; |
| 75 | |
Damjan Marion | 5a206ea | 2016-05-12 22:11:03 +0200 | [diff] [blame] | 76 | /* Vital Product Data */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 77 | u8 *product_name; |
| 78 | u8 *vpd_r; |
| 79 | u8 *vpd_w; |
Damjan Marion | 5a206ea | 2016-05-12 22:11:03 +0200 | [diff] [blame] | 80 | |
Damjan Marion | cef87f1 | 2017-10-05 15:32:41 +0200 | [diff] [blame] | 81 | /* Driver name */ |
| 82 | u8 *driver_name; |
Damjan Marion | 5a206ea | 2016-05-12 22:11:03 +0200 | [diff] [blame] | 83 | |
Damjan Marion | cef87f1 | 2017-10-05 15:32:41 +0200 | [diff] [blame] | 84 | /* First 64 bytes of configuration space. */ |
| 85 | union |
| 86 | { |
| 87 | pci_config_type0_regs_t config0; |
| 88 | pci_config_type1_regs_t config1; |
| 89 | u8 config_data[256]; |
| 90 | }; |
| 91 | |
| 92 | /* IOMMU Group */ |
| 93 | int iommu_group; |
| 94 | |
| 95 | } vlib_pci_device_info_t; |
| 96 | |
| 97 | typedef u32 vlib_pci_dev_handle_t; |
| 98 | |
Damjan Marion | 2322798 | 2018-10-22 13:38:57 +0200 | [diff] [blame] | 99 | vlib_pci_device_info_t *vlib_pci_get_device_info (vlib_main_t * vm, |
| 100 | vlib_pci_addr_t * addr, |
Damjan Marion | cef87f1 | 2017-10-05 15:32:41 +0200 | [diff] [blame] | 101 | clib_error_t ** error); |
| 102 | vlib_pci_addr_t *vlib_pci_get_all_dev_addrs (); |
Damjan Marion | 2322798 | 2018-10-22 13:38:57 +0200 | [diff] [blame] | 103 | vlib_pci_addr_t *vlib_pci_get_addr (vlib_main_t * vm, |
| 104 | vlib_pci_dev_handle_t h); |
Damjan Marion | d2bfb78 | 2019-01-07 20:56:04 +0100 | [diff] [blame] | 105 | u32 vlib_pci_get_numa_node (vlib_main_t * vm, vlib_pci_dev_handle_t h); |
Mohsin Kazmi | a402b83 | 2019-01-25 15:57:24 +0000 | [diff] [blame] | 106 | u32 vlib_pci_get_num_msix_interrupts (vlib_main_t * vm, |
| 107 | vlib_pci_dev_handle_t h); |
| 108 | |
Damjan Marion | 2322798 | 2018-10-22 13:38:57 +0200 | [diff] [blame] | 109 | uword vlib_pci_get_private_data (vlib_main_t * vm, vlib_pci_dev_handle_t h); |
| 110 | void vlib_pci_set_private_data (vlib_main_t * vm, vlib_pci_dev_handle_t h, |
| 111 | uword private_data); |
Damjan Marion | cef87f1 | 2017-10-05 15:32:41 +0200 | [diff] [blame] | 112 | |
| 113 | static inline void |
| 114 | vlib_pci_free_device_info (vlib_pci_device_info_t * di) |
| 115 | { |
| 116 | if (!di) |
| 117 | return; |
| 118 | vec_free (di->product_name); |
| 119 | vec_free (di->vpd_r); |
| 120 | vec_free (di->vpd_w); |
| 121 | vec_free (di->driver_name); |
| 122 | clib_mem_free (di); |
| 123 | } |
Damjan Marion | a42cd34 | 2016-04-13 18:03:20 +0200 | [diff] [blame] | 124 | |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 125 | typedef struct |
| 126 | { |
Damjan Marion | a42cd34 | 2016-04-13 18:03:20 +0200 | [diff] [blame] | 127 | u16 vendor_id, device_id; |
| 128 | } pci_device_id_t; |
| 129 | |
Damjan Marion | 2322798 | 2018-10-22 13:38:57 +0200 | [diff] [blame] | 130 | typedef void (pci_intx_handler_function_t) (vlib_main_t * vm, |
| 131 | vlib_pci_dev_handle_t handle); |
| 132 | typedef void (pci_msix_handler_function_t) (vlib_main_t * vm, |
| 133 | vlib_pci_dev_handle_t handle, |
Damjan Marion | 599a16b | 2018-03-04 19:35:23 +0100 | [diff] [blame] | 134 | u16 line); |
| 135 | |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 136 | typedef struct _pci_device_registration |
| 137 | { |
Damjan Marion | a42cd34 | 2016-04-13 18:03:20 +0200 | [diff] [blame] | 138 | /* Driver init function. */ |
Damjan Marion | cef87f1 | 2017-10-05 15:32:41 +0200 | [diff] [blame] | 139 | clib_error_t *(*init_function) (vlib_main_t * vm, |
| 140 | vlib_pci_dev_handle_t handle); |
Damjan Marion | a42cd34 | 2016-04-13 18:03:20 +0200 | [diff] [blame] | 141 | |
Damjan Marion | 5a206ea | 2016-05-12 22:11:03 +0200 | [diff] [blame] | 142 | /* Interrupt handler */ |
Damjan Marion | 599a16b | 2018-03-04 19:35:23 +0100 | [diff] [blame] | 143 | pci_intx_handler_function_t *interrupt_handler; |
Damjan Marion | a42cd34 | 2016-04-13 18:03:20 +0200 | [diff] [blame] | 144 | |
| 145 | /* List of registrations */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 146 | struct _pci_device_registration *next_registration; |
Damjan Marion | a42cd34 | 2016-04-13 18:03:20 +0200 | [diff] [blame] | 147 | |
| 148 | /* Vendor/device ids supported by this driver. */ |
| 149 | pci_device_id_t supported_devices[]; |
| 150 | } pci_device_registration_t; |
| 151 | |
Damjan Marion | 5a206ea | 2016-05-12 22:11:03 +0200 | [diff] [blame] | 152 | /* Pool of PCI devices. */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 153 | typedef struct |
| 154 | { |
| 155 | vlib_main_t *vlib_main; |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 156 | pci_device_registration_t *pci_device_registrations; |
Damjan Marion | 2322798 | 2018-10-22 13:38:57 +0200 | [diff] [blame] | 157 | /* logging */ |
| 158 | vlib_log_class_t log_default; |
Damjan Marion | 5a206ea | 2016-05-12 22:11:03 +0200 | [diff] [blame] | 159 | } vlib_pci_main_t; |
| 160 | |
| 161 | extern vlib_pci_main_t pci_main; |
| 162 | |
Damjan Marion | a42cd34 | 2016-04-13 18:03:20 +0200 | [diff] [blame] | 163 | #define PCI_REGISTER_DEVICE(x,...) \ |
| 164 | __VA_ARGS__ pci_device_registration_t x; \ |
| 165 | static void __vlib_add_pci_device_registration_##x (void) \ |
| 166 | __attribute__((__constructor__)) ; \ |
| 167 | static void __vlib_add_pci_device_registration_##x (void) \ |
| 168 | { \ |
Damjan Marion | 5a206ea | 2016-05-12 22:11:03 +0200 | [diff] [blame] | 169 | vlib_pci_main_t * pm = &pci_main; \ |
| 170 | x.next_registration = pm->pci_device_registrations; \ |
| 171 | pm->pci_device_registrations = &x; \ |
Damjan Marion | a42cd34 | 2016-04-13 18:03:20 +0200 | [diff] [blame] | 172 | } \ |
Damjan Marion | 72d2c4f | 2018-04-05 21:32:29 +0200 | [diff] [blame] | 173 | static void __vlib_rm_pci_device_registration_##x (void) \ |
| 174 | __attribute__((__destructor__)) ; \ |
| 175 | static void __vlib_rm_pci_device_registration_##x (void) \ |
| 176 | { \ |
| 177 | vlib_pci_main_t * pm = &pci_main; \ |
| 178 | VLIB_REMOVE_FROM_LINKED_LIST (pm->pci_device_registrations, \ |
| 179 | &x, next_registration); \ |
| 180 | } \ |
Damjan Marion | 5a206ea | 2016-05-12 22:11:03 +0200 | [diff] [blame] | 181 | __VA_ARGS__ pci_device_registration_t x |
Damjan Marion | a42cd34 | 2016-04-13 18:03:20 +0200 | [diff] [blame] | 182 | |
Damjan Marion | 2322798 | 2018-10-22 13:38:57 +0200 | [diff] [blame] | 183 | clib_error_t *vlib_pci_bind_to_uio (vlib_main_t * vm, vlib_pci_addr_t * addr, |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 184 | char *uio_driver_name); |
Damjan Marion | a42cd34 | 2016-04-13 18:03:20 +0200 | [diff] [blame] | 185 | |
| 186 | /* Configuration space read/write. */ |
Damjan Marion | 2322798 | 2018-10-22 13:38:57 +0200 | [diff] [blame] | 187 | clib_error_t *vlib_pci_read_write_config (vlib_main_t * vm, |
| 188 | vlib_pci_dev_handle_t handle, |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 189 | vlib_read_or_write_t read_or_write, |
Damjan Marion | 2322798 | 2018-10-22 13:38:57 +0200 | [diff] [blame] | 190 | uword address, void *data, |
| 191 | u32 n_bytes); |
Damjan Marion | a42cd34 | 2016-04-13 18:03:20 +0200 | [diff] [blame] | 192 | |
Mohsin Kazmi | 95276ca | 2018-09-28 11:45:01 +0200 | [diff] [blame] | 193 | /* io space read/write. */ |
| 194 | clib_error_t *vlib_pci_read_write_io (vlib_main_t * vm, |
| 195 | vlib_pci_dev_handle_t handle, |
| 196 | vlib_read_or_write_t read_or_write, |
| 197 | uword address, void *data, u32 n_bytes); |
| 198 | |
| 199 | |
| 200 | #define _(t, x) \ |
Damjan Marion | a42cd34 | 2016-04-13 18:03:20 +0200 | [diff] [blame] | 201 | static inline clib_error_t * \ |
Mohsin Kazmi | 95276ca | 2018-09-28 11:45:01 +0200 | [diff] [blame] | 202 | vlib_pci_read_##x##_##t (vlib_main_t *vm, vlib_pci_dev_handle_t h, \ |
Damjan Marion | 5a206ea | 2016-05-12 22:11:03 +0200 | [diff] [blame] | 203 | uword address, t * data) \ |
Damjan Marion | a42cd34 | 2016-04-13 18:03:20 +0200 | [diff] [blame] | 204 | { \ |
Mohsin Kazmi | 95276ca | 2018-09-28 11:45:01 +0200 | [diff] [blame] | 205 | return vlib_pci_read_write_##x (vm, h, VLIB_READ,address, data, \ |
Damjan Marion | 5a206ea | 2016-05-12 22:11:03 +0200 | [diff] [blame] | 206 | sizeof (data[0])); \ |
Damjan Marion | a42cd34 | 2016-04-13 18:03:20 +0200 | [diff] [blame] | 207 | } |
| 208 | |
Mohsin Kazmi | 95276ca | 2018-09-28 11:45:01 +0200 | [diff] [blame] | 209 | _(u32, config); |
| 210 | _(u16, config); |
| 211 | _(u8, config); |
| 212 | |
| 213 | _(u32, io); |
| 214 | _(u16, io); |
| 215 | _(u8, io); |
Damjan Marion | a42cd34 | 2016-04-13 18:03:20 +0200 | [diff] [blame] | 216 | |
| 217 | #undef _ |
| 218 | |
Mohsin Kazmi | 95276ca | 2018-09-28 11:45:01 +0200 | [diff] [blame] | 219 | #define _(t, x) \ |
Damjan Marion | a42cd34 | 2016-04-13 18:03:20 +0200 | [diff] [blame] | 220 | static inline clib_error_t * \ |
Mohsin Kazmi | 95276ca | 2018-09-28 11:45:01 +0200 | [diff] [blame] | 221 | vlib_pci_write_##x##_##t (vlib_main_t *vm, vlib_pci_dev_handle_t h, \ |
Damjan Marion | 2322798 | 2018-10-22 13:38:57 +0200 | [diff] [blame] | 222 | uword address, t * data) \ |
Damjan Marion | a42cd34 | 2016-04-13 18:03:20 +0200 | [diff] [blame] | 223 | { \ |
Mohsin Kazmi | 95276ca | 2018-09-28 11:45:01 +0200 | [diff] [blame] | 224 | return vlib_pci_read_write_##x (vm, h, VLIB_WRITE, \ |
Damjan Marion | a42cd34 | 2016-04-13 18:03:20 +0200 | [diff] [blame] | 225 | address, data, sizeof (data[0])); \ |
| 226 | } |
| 227 | |
Mohsin Kazmi | 95276ca | 2018-09-28 11:45:01 +0200 | [diff] [blame] | 228 | _(u32, config); |
| 229 | _(u16, config); |
| 230 | _(u8, config); |
| 231 | |
| 232 | _(u32, io); |
| 233 | _(u16, io); |
| 234 | _(u8, io); |
Damjan Marion | a42cd34 | 2016-04-13 18:03:20 +0200 | [diff] [blame] | 235 | |
| 236 | #undef _ |
| 237 | |
Damjan Marion | 5a206ea | 2016-05-12 22:11:03 +0200 | [diff] [blame] | 238 | static inline clib_error_t * |
Damjan Marion | 2322798 | 2018-10-22 13:38:57 +0200 | [diff] [blame] | 239 | vlib_pci_intr_enable (vlib_main_t * vm, vlib_pci_dev_handle_t h) |
Damjan Marion | 5a206ea | 2016-05-12 22:11:03 +0200 | [diff] [blame] | 240 | { |
| 241 | u16 command; |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 242 | clib_error_t *err; |
Damjan Marion | 5a206ea | 2016-05-12 22:11:03 +0200 | [diff] [blame] | 243 | |
Damjan Marion | 2322798 | 2018-10-22 13:38:57 +0200 | [diff] [blame] | 244 | err = vlib_pci_read_config_u16 (vm, h, 4, &command); |
Damjan Marion | 5a206ea | 2016-05-12 22:11:03 +0200 | [diff] [blame] | 245 | |
| 246 | if (err) |
| 247 | return err; |
| 248 | |
| 249 | command &= ~PCI_COMMAND_INTX_DISABLE; |
| 250 | |
Damjan Marion | 2322798 | 2018-10-22 13:38:57 +0200 | [diff] [blame] | 251 | return vlib_pci_write_config_u16 (vm, h, 4, &command); |
Damjan Marion | 5a206ea | 2016-05-12 22:11:03 +0200 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | static inline clib_error_t * |
Damjan Marion | 2322798 | 2018-10-22 13:38:57 +0200 | [diff] [blame] | 255 | vlib_pci_intr_disable (vlib_main_t * vm, vlib_pci_dev_handle_t h) |
Damjan Marion | 5a206ea | 2016-05-12 22:11:03 +0200 | [diff] [blame] | 256 | { |
| 257 | u16 command; |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 258 | clib_error_t *err; |
Damjan Marion | 5a206ea | 2016-05-12 22:11:03 +0200 | [diff] [blame] | 259 | |
Damjan Marion | 2322798 | 2018-10-22 13:38:57 +0200 | [diff] [blame] | 260 | err = vlib_pci_read_config_u16 (vm, h, 4, &command); |
Damjan Marion | 5a206ea | 2016-05-12 22:11:03 +0200 | [diff] [blame] | 261 | |
| 262 | if (err) |
| 263 | return err; |
| 264 | |
| 265 | command |= PCI_COMMAND_INTX_DISABLE; |
| 266 | |
Damjan Marion | 2322798 | 2018-10-22 13:38:57 +0200 | [diff] [blame] | 267 | return vlib_pci_write_config_u16 (vm, h, 4, &command); |
Damjan Marion | 5a206ea | 2016-05-12 22:11:03 +0200 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | static inline clib_error_t * |
Damjan Marion | 2322798 | 2018-10-22 13:38:57 +0200 | [diff] [blame] | 271 | vlib_pci_bus_master_enable (vlib_main_t * vm, vlib_pci_dev_handle_t h) |
Damjan Marion | 5a206ea | 2016-05-12 22:11:03 +0200 | [diff] [blame] | 272 | { |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 273 | clib_error_t *err; |
Damjan Marion | 5a206ea | 2016-05-12 22:11:03 +0200 | [diff] [blame] | 274 | u16 command; |
| 275 | |
| 276 | /* Set bus master enable (BME) */ |
Damjan Marion | 2322798 | 2018-10-22 13:38:57 +0200 | [diff] [blame] | 277 | err = vlib_pci_read_config_u16 (vm, h, 4, &command); |
Damjan Marion | 5a206ea | 2016-05-12 22:11:03 +0200 | [diff] [blame] | 278 | |
| 279 | if (err) |
| 280 | return err; |
| 281 | |
Damjan Marion | 191a1a4 | 2017-07-10 15:38:21 +0200 | [diff] [blame] | 282 | if (command & PCI_COMMAND_BUS_MASTER) |
Damjan Marion | 5a206ea | 2016-05-12 22:11:03 +0200 | [diff] [blame] | 283 | return 0; |
| 284 | |
| 285 | command |= PCI_COMMAND_BUS_MASTER; |
| 286 | |
Damjan Marion | 2322798 | 2018-10-22 13:38:57 +0200 | [diff] [blame] | 287 | return vlib_pci_write_config_u16 (vm, h, 4, &command); |
Damjan Marion | 5a206ea | 2016-05-12 22:11:03 +0200 | [diff] [blame] | 288 | } |
Damjan Marion | a42cd34 | 2016-04-13 18:03:20 +0200 | [diff] [blame] | 289 | |
Damjan Marion | 2322798 | 2018-10-22 13:38:57 +0200 | [diff] [blame] | 290 | clib_error_t *vlib_pci_device_open (vlib_main_t * vm, vlib_pci_addr_t * addr, |
Damjan Marion | f313b74 | 2018-03-05 14:08:33 +0100 | [diff] [blame] | 291 | pci_device_id_t ids[], |
| 292 | vlib_pci_dev_handle_t * handle); |
Damjan Marion | 2322798 | 2018-10-22 13:38:57 +0200 | [diff] [blame] | 293 | void vlib_pci_device_close (vlib_main_t * vm, vlib_pci_dev_handle_t h); |
| 294 | clib_error_t *vlib_pci_map_region (vlib_main_t * vm, vlib_pci_dev_handle_t h, |
| 295 | u32 resource, void **result); |
| 296 | clib_error_t *vlib_pci_map_region_fixed (vlib_main_t * vm, |
| 297 | vlib_pci_dev_handle_t h, |
Damjan Marion | 2060db8 | 2018-03-04 17:37:15 +0100 | [diff] [blame] | 298 | u32 resource, u8 * addr, |
| 299 | void **result); |
Mohsin Kazmi | 95276ca | 2018-09-28 11:45:01 +0200 | [diff] [blame] | 300 | clib_error_t *vlib_pci_io_region (vlib_main_t * vm, vlib_pci_dev_handle_t h, |
| 301 | u32 resource); |
Damjan Marion | 2322798 | 2018-10-22 13:38:57 +0200 | [diff] [blame] | 302 | clib_error_t *vlib_pci_register_intx_handler (vlib_main_t * vm, |
| 303 | vlib_pci_dev_handle_t h, |
Damjan Marion | d5ded2d | 2018-03-05 10:18:50 +0100 | [diff] [blame] | 304 | pci_intx_handler_function_t * |
| 305 | intx_handler); |
Damjan Marion | 2322798 | 2018-10-22 13:38:57 +0200 | [diff] [blame] | 306 | clib_error_t *vlib_pci_register_msix_handler (vlib_main_t * vm, |
| 307 | vlib_pci_dev_handle_t h, |
Damjan Marion | 599a16b | 2018-03-04 19:35:23 +0100 | [diff] [blame] | 308 | u32 start, u32 count, |
| 309 | pci_msix_handler_function_t * |
| 310 | msix_handler); |
Damjan Marion | 2322798 | 2018-10-22 13:38:57 +0200 | [diff] [blame] | 311 | clib_error_t *vlib_pci_enable_msix_irq (vlib_main_t * vm, |
| 312 | vlib_pci_dev_handle_t h, u16 start, |
Damjan Marion | 599a16b | 2018-03-04 19:35:23 +0100 | [diff] [blame] | 313 | u16 count); |
Damjan Marion | 2322798 | 2018-10-22 13:38:57 +0200 | [diff] [blame] | 314 | clib_error_t *vlib_pci_disable_msix_irq (vlib_main_t * vm, |
| 315 | vlib_pci_dev_handle_t h, u16 start, |
Damjan Marion | 599a16b | 2018-03-04 19:35:23 +0100 | [diff] [blame] | 316 | u16 count); |
Damjan Marion | 68b4da6 | 2018-09-30 18:26:20 +0200 | [diff] [blame] | 317 | clib_error_t *vlib_pci_map_dma (vlib_main_t * vm, vlib_pci_dev_handle_t h, |
| 318 | void *ptr); |
| 319 | |
| 320 | int vlib_pci_supports_virtual_addr_dma (vlib_main_t * vm, |
| 321 | vlib_pci_dev_handle_t h); |
Damjan Marion | 599a16b | 2018-03-04 19:35:23 +0100 | [diff] [blame] | 322 | |
Damjan Marion | 5a206ea | 2016-05-12 22:11:03 +0200 | [diff] [blame] | 323 | unformat_function_t unformat_vlib_pci_addr; |
| 324 | format_function_t format_vlib_pci_addr; |
Damjan Marion | 5a206ea | 2016-05-12 22:11:03 +0200 | [diff] [blame] | 325 | format_function_t format_vlib_pci_link_speed; |
Damjan Marion | 7d22161 | 2016-12-26 11:39:42 +0100 | [diff] [blame] | 326 | format_function_t format_vlib_pci_vpd; |
Damjan Marion | a42cd34 | 2016-04-13 18:03:20 +0200 | [diff] [blame] | 327 | |
| 328 | #endif /* included_vlib_pci_h */ |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 329 | |
| 330 | /* |
| 331 | * fd.io coding-style-patch-verification: ON |
| 332 | * |
| 333 | * Local Variables: |
| 334 | * eval: (c-set-style "gnu") |
| 335 | * End: |
| 336 | */ |