xref: /spdk/lib/env_dpdk/env_internal.h (revision 4a9209bf1db1fc02a00f683aeb3c2754fe8ef99b)
1 /*   SPDX-License-Identifier: BSD-3-Clause
2  *   Copyright (c) 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 void 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 struct rte_pci_device;
37 
38 uint64_t dpdk_pci_device_vtophys(struct rte_pci_device *dev, uint64_t vaddr);
39 
40 /**
41  * Report a DMA-capable PCI device to the vtophys translation code.
42  * Increases the refcount of active DMA-capable devices managed by SPDK.
43  * This must be called after a `rte_pci_device` is created.
44  */
45 void vtophys_pci_device_added(struct rte_pci_device *pci_device);
46 
47 /**
48  * Report the removal of a DMA-capable PCI device to the vtophys translation code.
49  * Decreases the refcount of active DMA-capable devices managed by SPDK.
50  * This must be called before a `rte_pci_device` is destroyed.
51  */
52 void vtophys_pci_device_removed(struct rte_pci_device *pci_device);
53 
54 #endif
55