acrn-hypervisor/hypervisor/include/common/ptdev.h

86 lines
2.4 KiB
C
Raw Normal View History

/*
* Copyright (C) 2018 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef PTDEV_H
#define PTDEV_H
#define ACTIVE_FLAG 0x1U /* any non zero should be okay */
#define PTDEV_INTR_MSI (1U << 0U)
#define PTDEV_INTR_INTX (1U << 1U)
#define INVALID_PTDEV_ENTRY_ID 0xffffU
#define PTDEV_VPIN_IOAPIC 0x0U
#define PTDEV_VPIN_PIC 0x1U
#define DEFINE_MSI_SID(name, a, b) \
union source_id (name) = {.msi_id = {.bdf = (a), .entry_nr = (b)} }
#define DEFINE_IOAPIC_SID(name, a, b) \
union source_id (name) = {.intx_id = {.pin = (a), .src = (b)} }
union source_id {
uint32_t value;
struct {
uint16_t bdf;
uint16_t entry_nr;
} msi_id;
struct {
uint8_t pin;
uint8_t src;
uint16_t reserved;
} intx_id;
};
/* entry per guest virt vector */
struct ptirq_msi_info {
uint64_t vmsi_addr; /* virt msi_addr */
uint32_t vmsi_data; /* virt msi_data */
uint64_t pmsi_addr; /* phys msi_addr */
uint32_t pmsi_data; /* phys msi_data */
int32_t is_msix; /* 0-MSI, 1-MSIX */
};
/* entry per each allocated irq/vector
* it represents a pass-thru device's remapping data entry which collecting
* information related with its vm and msi/intx mapping & interaction nodes
* with interrupt handler and softirq.
*/
struct ptirq_remapping_info {
uint16_t ptdev_entry_id;
uint32_t intr_type;
union source_id phys_sid;
union source_id virt_sid;
struct acrn_vm *vm;
uint32_t active; /* 1=active, 0=inactive and to free*/
uint32_t allocated_pirq;
uint32_t polarity; /* 0=active high, 1=active low*/
struct list_head softirq_node;
struct ptirq_msi_info msi;
uint64_t intr_count;
struct hv_timer intr_delay_timer; /* used for delay intr injection */
};
extern struct ptirq_remapping_info ptirq_entries[CONFIG_MAX_PT_IRQ_ENTRIES];
extern spinlock_t ptdev_lock;
bool is_entry_active(const struct ptirq_remapping_info *entry);
hv:Rename ptdev to ptirq for some APIs -- Rename the fowllowing APIs: ptdev_intx_pin_remap --> ptirq_intx_pin_remap ptdev_msix_remap --> ptirq_msix_remap ptdev_add_intx_remapping --> ptirq_add_intx_remapping ptdev_remove_intx_remapping --> ptirq_remove_intx_remapping ptdev_add_msix_remapping --> ptirq_add_msix_remapping ptdev_remove_msix_remapping --> ptirq_remove_msix_remapping ptdev_intx_ack --> ptirq_intx_ack ptdev_lookup_entry_by_sid --> ptirq_lookup_entry_by_sid ptdev_lookup_entry_by_vpin --> ptirq_lookup_entry_by_vpin ptdev_build_physical_msi --> ptirq_build_physical_msi ptdev_build_physical_rte --> ptirq_build_physical_rte alloc_entry --> ptirq_alloc_entry release_entry --> ptirq_release_one_entry ptdev_activate_entry --> ptirq_activate_entry ptdev_deactivate_entry --> ptirq_deactivate_entry ptdev_intr_handle_irq --> ptirq_handle_intx ptdev_softirq --> ptirq_softirq ptdev_enqueue_softirq --> ptirq_enqueue_softirq ptdev_dequeue_softirq --> ptirq_dequeue_softirq get_vm_ptdev_intr_data --> ptirq_get_intr_data alloc_ptdev_entry_id --> ptirq_alloc_entry_id ptdev_intr_delay_callback --> ptirq_intr_delay_callback ptdev_dequeue_softirq --> ptirq_dequeue_softirq ptdev_interrupt_handler --> ptirq_interrupt_handler -- Merge 'ptdev_release_all_entries' and 'release_all_entries' to 'ptirq_release_all_entries' v2-->v3: Rename ptirq_release_one_entry to ptirq_release_entry v1-->v2: still use ptdev_init instead of ptirq_init Tracked-On: #861 Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-29 16:42:45 +08:00
void ptirq_softirq(uint16_t pcpu_id);
void ptdev_init(void);
void ptdev_release_all_entries(const struct acrn_vm *vm);
hv:Rename ptdev to ptirq for some APIs -- Rename the fowllowing APIs: ptdev_intx_pin_remap --> ptirq_intx_pin_remap ptdev_msix_remap --> ptirq_msix_remap ptdev_add_intx_remapping --> ptirq_add_intx_remapping ptdev_remove_intx_remapping --> ptirq_remove_intx_remapping ptdev_add_msix_remapping --> ptirq_add_msix_remapping ptdev_remove_msix_remapping --> ptirq_remove_msix_remapping ptdev_intx_ack --> ptirq_intx_ack ptdev_lookup_entry_by_sid --> ptirq_lookup_entry_by_sid ptdev_lookup_entry_by_vpin --> ptirq_lookup_entry_by_vpin ptdev_build_physical_msi --> ptirq_build_physical_msi ptdev_build_physical_rte --> ptirq_build_physical_rte alloc_entry --> ptirq_alloc_entry release_entry --> ptirq_release_one_entry ptdev_activate_entry --> ptirq_activate_entry ptdev_deactivate_entry --> ptirq_deactivate_entry ptdev_intr_handle_irq --> ptirq_handle_intx ptdev_softirq --> ptirq_softirq ptdev_enqueue_softirq --> ptirq_enqueue_softirq ptdev_dequeue_softirq --> ptirq_dequeue_softirq get_vm_ptdev_intr_data --> ptirq_get_intr_data alloc_ptdev_entry_id --> ptirq_alloc_entry_id ptdev_intr_delay_callback --> ptirq_intr_delay_callback ptdev_dequeue_softirq --> ptirq_dequeue_softirq ptdev_interrupt_handler --> ptirq_interrupt_handler -- Merge 'ptdev_release_all_entries' and 'release_all_entries' to 'ptirq_release_all_entries' v2-->v3: Rename ptirq_release_one_entry to ptirq_release_entry v1-->v2: still use ptdev_init instead of ptirq_init Tracked-On: #861 Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-29 16:42:45 +08:00
struct ptirq_remapping_info *ptirq_dequeue_softirq(struct acrn_vm *vm);
struct ptirq_remapping_info *ptirq_alloc_entry(struct acrn_vm *vm, uint32_t intr_type);
void ptirq_release_entry(struct ptirq_remapping_info *entry);
int32_t ptirq_activate_entry(struct ptirq_remapping_info *entry, uint32_t phys_irq);
void ptirq_deactivate_entry(struct ptirq_remapping_info *entry);
hv:Rename ptdev to ptirq for some APIs -- Rename the fowllowing APIs: ptdev_intx_pin_remap --> ptirq_intx_pin_remap ptdev_msix_remap --> ptirq_msix_remap ptdev_add_intx_remapping --> ptirq_add_intx_remapping ptdev_remove_intx_remapping --> ptirq_remove_intx_remapping ptdev_add_msix_remapping --> ptirq_add_msix_remapping ptdev_remove_msix_remapping --> ptirq_remove_msix_remapping ptdev_intx_ack --> ptirq_intx_ack ptdev_lookup_entry_by_sid --> ptirq_lookup_entry_by_sid ptdev_lookup_entry_by_vpin --> ptirq_lookup_entry_by_vpin ptdev_build_physical_msi --> ptirq_build_physical_msi ptdev_build_physical_rte --> ptirq_build_physical_rte alloc_entry --> ptirq_alloc_entry release_entry --> ptirq_release_one_entry ptdev_activate_entry --> ptirq_activate_entry ptdev_deactivate_entry --> ptirq_deactivate_entry ptdev_intr_handle_irq --> ptirq_handle_intx ptdev_softirq --> ptirq_softirq ptdev_enqueue_softirq --> ptirq_enqueue_softirq ptdev_dequeue_softirq --> ptirq_dequeue_softirq get_vm_ptdev_intr_data --> ptirq_get_intr_data alloc_ptdev_entry_id --> ptirq_alloc_entry_id ptdev_intr_delay_callback --> ptirq_intr_delay_callback ptdev_dequeue_softirq --> ptirq_dequeue_softirq ptdev_interrupt_handler --> ptirq_interrupt_handler -- Merge 'ptdev_release_all_entries' and 'release_all_entries' to 'ptirq_release_all_entries' v2-->v3: Rename ptirq_release_one_entry to ptirq_release_entry v1-->v2: still use ptdev_init instead of ptirq_init Tracked-On: #861 Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-29 16:42:45 +08:00
uint32_t ptirq_get_intr_data(const struct acrn_vm *target_vm, uint64_t *buffer, uint32_t buffer_cnt);
#endif /* PTDEV_H */