xref: /spdk/lib/env_dpdk/env_internal.h (revision 588dfe314bb83d86effdf67ec42837b11c2620bf)
1 /*   SPDX-License-Identifier: BSD-3-Clause
2  *   Copyright (C) 2016 Intel Corporation.
3  *   All rights reserved.
4  */
5 
6 #ifndef SPDK_ENV_INTERNAL_H
7 #define SPDK_ENV_INTERNAL_H
8 
9 #include "spdk/stdinc.h"
10 
11 #include "spdk/env.h"
12 
13 #include <rte_config.h>
14 #include <rte_version.h>
15 #include <rte_eal.h>
16 
17 #if RTE_VERSION < RTE_VERSION_NUM(19, 11, 0, 0)
18 #error RTE_VERSION is too old! Minimum 19.11 is required.
19 #endif
20 
21 /* x86-64 and ARM userspace virtual addresses use only the low 48 bits [0..47],
22  * which is enough to cover 256 TB.
23  */
24 #define SHIFT_256TB	48 /* (1 << 48) == 256 TB */
25 #define MASK_256TB	((1ULL << SHIFT_256TB) - 1)
26 
27 #define SHIFT_1GB	30 /* (1 << 30) == 1 GB */
28 #define MASK_1GB	((1ULL << SHIFT_1GB) - 1)
29 
30 int pci_env_init(void);
31 void pci_env_reinit(void);
32 void pci_env_fini(void);
33 int mem_map_init(bool legacy_mem);
34 int vtophys_init(void);
35 
36 int vtophys_iommu_map_dma_bar(uint64_t vaddr, uint64_t iova, uint64_t size);
37 int vtophys_iommu_unmap_dma_bar(uint64_t vaddr);
38 
39 struct rte_pci_device;
40 
41 /**
42  * Report a DMA-capable PCI device to the vtophys translation code.
43  * Increases the refcount of active DMA-capable devices managed by SPDK.
44  * This must be called after a `rte_pci_device` is created.
45  */
46 void vtophys_pci_device_added(struct rte_pci_device *pci_device);
47 
48 /**
49  * Report the removal of a DMA-capable PCI device to the vtophys translation code.
50  * Decreases the refcount of active DMA-capable devices managed by SPDK.
51  * This must be called before a `rte_pci_device` is destroyed.
52  */
53 void vtophys_pci_device_removed(struct rte_pci_device *pci_device);
54 
55 #endif
56