2022-06-03 19:15:11 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
2016-12-05 17:20:20 +00:00
|
|
|
* Copyright (c) Intel Corporation.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SPDK_ENV_INTERNAL_H
|
|
|
|
#define SPDK_ENV_INTERNAL_H
|
|
|
|
|
2017-05-02 18:18:25 +00:00
|
|
|
#include "spdk/stdinc.h"
|
|
|
|
|
2016-12-05 17:20:20 +00:00
|
|
|
#include "spdk/env.h"
|
|
|
|
|
|
|
|
#include <rte_config.h>
|
2017-04-29 02:16:32 +00:00
|
|
|
#include <rte_version.h>
|
2016-12-05 17:20:20 +00:00
|
|
|
#include <rte_eal.h>
|
|
|
|
|
2020-11-30 12:51:35 +00:00
|
|
|
#if RTE_VERSION < RTE_VERSION_NUM(19, 11, 0, 0)
|
|
|
|
#error RTE_VERSION is too old! Minimum 19.11 is required.
|
2018-11-18 00:05:41 +00:00
|
|
|
#endif
|
|
|
|
|
2018-01-25 03:36:50 +00:00
|
|
|
/* x86-64 and ARM userspace virtual addresses use only the low 48 bits [0..47],
|
|
|
|
* which is enough to cover 256 TB.
|
2017-08-24 21:20:12 +00:00
|
|
|
*/
|
2018-01-25 03:36:50 +00:00
|
|
|
#define SHIFT_256TB 48 /* (1 << 48) == 256 TB */
|
|
|
|
#define MASK_256TB ((1ULL << SHIFT_256TB) - 1)
|
2017-08-24 21:20:12 +00:00
|
|
|
|
|
|
|
#define SHIFT_1GB 30 /* (1 << 30) == 1 GB */
|
|
|
|
#define MASK_1GB ((1ULL << SHIFT_1GB) - 1)
|
|
|
|
|
2022-09-22 00:48:23 +00:00
|
|
|
int pci_env_init(void);
|
2020-05-08 06:03:22 +00:00
|
|
|
void pci_env_reinit(void);
|
2020-05-26 09:54:02 +00:00
|
|
|
void pci_env_fini(void);
|
2020-04-07 07:32:40 +00:00
|
|
|
int mem_map_init(bool legacy_mem);
|
|
|
|
int vtophys_init(void);
|
2017-02-21 22:42:50 +00:00
|
|
|
|
2022-08-03 20:28:23 +00:00
|
|
|
int vtophys_iommu_map_dma_bar(uint64_t vaddr, uint64_t iova, uint64_t size);
|
|
|
|
int vtophys_iommu_unmap_dma_bar(uint64_t vaddr);
|
|
|
|
|
2022-09-15 13:22:08 +00:00
|
|
|
struct rte_pci_device;
|
|
|
|
|
2017-12-06 21:52:56 +00:00
|
|
|
/**
|
2018-03-30 23:51:26 +00:00
|
|
|
* Report a DMA-capable PCI device to the vtophys translation code.
|
|
|
|
* Increases the refcount of active DMA-capable devices managed by SPDK.
|
2017-12-06 21:52:56 +00:00
|
|
|
* This must be called after a `rte_pci_device` is created.
|
|
|
|
*/
|
2020-04-07 07:32:40 +00:00
|
|
|
void vtophys_pci_device_added(struct rte_pci_device *pci_device);
|
2017-12-06 21:52:56 +00:00
|
|
|
|
|
|
|
/**
|
2018-03-30 23:51:26 +00:00
|
|
|
* Report the removal of a DMA-capable PCI device to the vtophys translation code.
|
|
|
|
* Decreases the refcount of active DMA-capable devices managed by SPDK.
|
2017-12-06 21:52:56 +00:00
|
|
|
* This must be called before a `rte_pci_device` is destroyed.
|
|
|
|
*/
|
2020-04-07 07:32:40 +00:00
|
|
|
void vtophys_pci_device_removed(struct rte_pci_device *pci_device);
|
2017-12-06 21:52:56 +00:00
|
|
|
|
2016-12-05 17:20:20 +00:00
|
|
|
#endif
|