hv: vtd: add two paramters for dmar_assign_irte

idx_in:
- If the caller of dmar_assign_irte passes a valid IRTE index, it will
be resued;
- If the caller of dmar_assign_irte passes INVALID_IRTE_ID as IRTE index,
the function will allocate a new IRTE.

idx_out:
This paramter return the actual index of IRTE used. The caller need to
check whether the return value is valid or not.

Also this patch adds an internal function alloc_irte.
The function takes count as input paramter to allocate continuous IRTEs.
The count can only be 1, 2, 4, 8, 16 or 32.
This is prepared for multiple MSI vector support.

Tracked-On: #4831
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Binbin Wu
2020-05-09 08:23:37 +00:00
committed by wenlingz
parent 9c52b353fa
commit 2fe4280cfa
4 changed files with 98 additions and 56 deletions

View File

@@ -11,6 +11,7 @@
#include <platform_acpi_info.h>
#define INVALID_DRHD_INDEX 0xFFFFFFFFU
#define INVALID_IRTE_ID 0xFFFFU
/*
* Intel IOMMU register specification per version 1.0 public spec.
@@ -675,13 +676,15 @@ int32_t init_iommu(void);
*
* @param[in] intr_src filled with type of interrupt source and the source
* @param[in] irte filled with info about interrupt deliverymode, destination and destination mode
* @param[in] index into Interrupt Remapping Table
* @param[in] idx_in if this value is INVALID_IRTE_ID, a new IRTE will be allocated, otherwise, use the IRTE directly.
* @param[out] idx_out return the actual IRTE index used, need to check whether the returned value is valid or not.
*
* @retval -EINVAL if corresponding DMAR is not present
* @retval 0 otherwise
* @retval -EINVAL if corresponding DMAR is not preset
* @retval 0 on success, caller should check whether the returned start index is valid or not.
*
*/
int32_t dmar_assign_irte(const struct intr_source *intr_src, union dmar_ir_entry *irte, uint16_t index);
int32_t dmar_assign_irte(const struct intr_source *intr_src, union dmar_ir_entry *irte,
uint16_t idx_in, uint16_t *idx_out);
/**
* @brief Free RTE for Interrupt Remapping Table.