Damjan Marion | 1ba0fa4 | 2018-03-04 17:19:08 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018 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 | #ifndef included_vlib_linux_vfio_h |
| 17 | #define included_vlib_linux_vfio_h |
| 18 | |
| 19 | typedef struct |
| 20 | { |
| 21 | int group; |
| 22 | int fd; |
| 23 | int refcnt; |
| 24 | } linux_pci_vfio_iommu_group_t; |
| 25 | |
| 26 | typedef struct |
| 27 | { |
Damjan Marion | 1ba0fa4 | 2018-03-04 17:19:08 +0100 | [diff] [blame] | 28 | int container_fd; |
Damjan Marion | 1ba0fa4 | 2018-03-04 17:19:08 +0100 | [diff] [blame] | 29 | |
| 30 | /* VFIO */ |
| 31 | int iommu_mode; |
| 32 | |
| 33 | /* pool of IOMMU groups */ |
| 34 | linux_pci_vfio_iommu_group_t *iommu_groups; |
| 35 | |
| 36 | /* iommu group pool index by group id hash */ |
| 37 | uword *iommu_pool_index_by_group; |
| 38 | |
Damjan Marion | 68b4da6 | 2018-09-30 18:26:20 +0200 | [diff] [blame] | 39 | clib_bitmap_t *physmem_pages_mapped; |
| 40 | |
Damjan Marion | 7d42653 | 2018-09-27 14:54:49 +0200 | [diff] [blame] | 41 | /* logging */ |
| 42 | vlib_log_class_t log_default; |
Damjan Marion | 1ba0fa4 | 2018-03-04 17:19:08 +0100 | [diff] [blame] | 43 | } linux_vfio_main_t; |
| 44 | |
| 45 | extern linux_vfio_main_t vfio_main; |
| 46 | |
| 47 | clib_error_t *linux_vfio_init (vlib_main_t * vm); |
Damjan Marion | 68b4da6 | 2018-09-30 18:26:20 +0200 | [diff] [blame] | 48 | clib_error_t *vfio_map_physmem_page (vlib_main_t * vm, void *addr); |
Damjan Marion | 1ba0fa4 | 2018-03-04 17:19:08 +0100 | [diff] [blame] | 49 | clib_error_t *linux_vfio_group_get_device_fd (vlib_pci_addr_t * addr, |
Damjan Marion | 2322798 | 2018-10-22 13:38:57 +0200 | [diff] [blame] | 50 | int *fd, int *is_noiommu); |
Damjan Marion | 1ba0fa4 | 2018-03-04 17:19:08 +0100 | [diff] [blame] | 51 | |
| 52 | |
| 53 | #endif /* included_vlib_linux_vfio_h */ |
| 54 | |
| 55 | /* |
| 56 | * fd.io coding-style-patch-verification: ON |
| 57 | * |
| 58 | * Local Variables: |
| 59 | * eval: (c-set-style "gnu") |
| 60 | * End: |
| 61 | */ |