mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-21 00:38:28 +00:00
HV: move common stuff from assign.c
Move common stuff, like ptdev entry and softirq, to new ptdev.c Signed-off-by: Edwin Zhai <edwin.zhai@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -7,66 +7,13 @@
|
||||
#ifndef ASSIGN_H
|
||||
#define ASSIGN_H
|
||||
|
||||
enum ptdev_intr_type {
|
||||
PTDEV_INTR_MSI,
|
||||
PTDEV_INTR_INTX,
|
||||
PTDEV_INTR_INV,
|
||||
};
|
||||
|
||||
enum ptdev_vpin_source {
|
||||
PTDEV_VPIN_IOAPIC,
|
||||
PTDEV_VPIN_PIC,
|
||||
};
|
||||
|
||||
/* entry per guest virt vector */
|
||||
struct ptdev_msi_info {
|
||||
uint32_t vmsi_addr; /* virt msi_addr */
|
||||
uint32_t vmsi_data; /* virt msi_data */
|
||||
uint16_t vmsi_ctl; /* virt msi_ctl */
|
||||
uint32_t pmsi_addr; /* phys msi_addr */
|
||||
uint32_t pmsi_data; /* phys msi_data */
|
||||
int msix; /* 0-MSI, 1-MSIX */
|
||||
int msix_entry_index; /* MSI: 0, MSIX: index of vector table*/
|
||||
int virt_vector;
|
||||
int phys_vector;
|
||||
};
|
||||
|
||||
/* entry per guest vioapic pin */
|
||||
struct ptdev_intx_info {
|
||||
enum ptdev_vpin_source vpin_src;
|
||||
uint8_t virt_pin;
|
||||
uint8_t phys_pin;
|
||||
};
|
||||
|
||||
/* 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 ptdev_remapping_info {
|
||||
struct vm *vm;
|
||||
uint16_t virt_bdf; /* PCI bus:slot.func*/
|
||||
uint16_t phys_bdf; /* PCI bus:slot.func*/
|
||||
uint32_t active; /* 1=active, 0=inactive and to free*/
|
||||
enum ptdev_intr_type type;
|
||||
struct dev_handler_node *node;
|
||||
struct list_head softirq_node;
|
||||
struct list_head entry_node;
|
||||
|
||||
union {
|
||||
struct ptdev_msi_info msi;
|
||||
struct ptdev_intx_info intx;
|
||||
} ptdev_intr_info;
|
||||
};
|
||||
#include <ptdev.h>
|
||||
|
||||
void ptdev_intx_ack(struct vm *vm, int virt_pin,
|
||||
enum ptdev_vpin_source vpin_src);
|
||||
int ptdev_msix_remap(struct vm *vm, uint16_t virt_bdf,
|
||||
struct ptdev_msi_info *info);
|
||||
int ptdev_intx_pin_remap(struct vm *vm, struct ptdev_intx_info *info);
|
||||
void ptdev_softirq(int cpu);
|
||||
void ptdev_init(void);
|
||||
void ptdev_release_all_entries(struct vm *vm);
|
||||
int ptdev_add_intx_remapping(struct vm *vm, uint16_t virt_bdf,
|
||||
uint16_t phys_bdf, uint8_t virt_pin, uint8_t phys_pin, bool pic_pin);
|
||||
void ptdev_remove_intx_remapping(struct vm *vm, uint8_t virt_pin, bool pic_pin);
|
||||
@@ -74,6 +21,5 @@ int ptdev_add_msix_remapping(struct vm *vm, uint16_t virt_bdf,
|
||||
uint16_t phys_bdf, int vector_count);
|
||||
void ptdev_remove_msix_remapping(struct vm *vm, uint16_t virt_bdf,
|
||||
int vector_count);
|
||||
int get_ptdev_info(char *str, int str_max);
|
||||
|
||||
#endif /* ASSIGN_H */
|
||||
|
84
hypervisor/include/common/ptdev.h
Normal file
84
hypervisor/include/common/ptdev.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef PTDEV_H
|
||||
#define PTDEV_H
|
||||
|
||||
#define ACTIVE_FLAG 0x1 /* any non zero should be okay */
|
||||
|
||||
enum ptdev_intr_type {
|
||||
PTDEV_INTR_MSI,
|
||||
PTDEV_INTR_INTX,
|
||||
PTDEV_INTR_INV,
|
||||
};
|
||||
|
||||
enum ptdev_vpin_source {
|
||||
PTDEV_VPIN_IOAPIC,
|
||||
PTDEV_VPIN_PIC,
|
||||
};
|
||||
|
||||
/* entry per guest virt vector */
|
||||
struct ptdev_msi_info {
|
||||
uint32_t vmsi_addr; /* virt msi_addr */
|
||||
uint32_t vmsi_data; /* virt msi_data */
|
||||
uint16_t vmsi_ctl; /* virt msi_ctl */
|
||||
uint32_t pmsi_addr; /* phys msi_addr */
|
||||
uint32_t pmsi_data; /* phys msi_data */
|
||||
int msix; /* 0-MSI, 1-MSIX */
|
||||
int msix_entry_index; /* MSI: 0, MSIX: index of vector table*/
|
||||
int virt_vector;
|
||||
int phys_vector;
|
||||
};
|
||||
|
||||
/* entry per guest vioapic pin */
|
||||
struct ptdev_intx_info {
|
||||
enum ptdev_vpin_source vpin_src;
|
||||
uint8_t virt_pin;
|
||||
uint8_t phys_pin;
|
||||
};
|
||||
|
||||
/* 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 ptdev_remapping_info {
|
||||
struct vm *vm;
|
||||
uint16_t virt_bdf; /* PCI bus:slot.func*/
|
||||
uint16_t phys_bdf; /* PCI bus:slot.func*/
|
||||
uint32_t active; /* 1=active, 0=inactive and to free*/
|
||||
enum ptdev_intr_type type;
|
||||
struct dev_handler_node *node;
|
||||
struct list_head softirq_node;
|
||||
struct list_head entry_node;
|
||||
|
||||
union {
|
||||
struct ptdev_msi_info msi;
|
||||
struct ptdev_intx_info intx;
|
||||
} ptdev_intr_info;
|
||||
};
|
||||
|
||||
extern struct list_head softirq_dev_entry_list;
|
||||
extern struct list_head ptdev_list;
|
||||
extern spinlock_t ptdev_lock;
|
||||
extern struct ptdev_remapping_info invalid_entry;
|
||||
extern spinlock_t softirq_dev_lock;
|
||||
|
||||
void ptdev_softirq(int cpu);
|
||||
void ptdev_init(void);
|
||||
void ptdev_release_all_entries(struct vm *vm);
|
||||
int get_ptdev_info(char *str, int str_max);
|
||||
|
||||
struct ptdev_remapping_info *ptdev_dequeue_softirq(void);
|
||||
struct ptdev_remapping_info *alloc_entry(struct vm *vm,
|
||||
enum ptdev_intr_type type);
|
||||
void release_entry(struct ptdev_remapping_info *entry);
|
||||
struct ptdev_remapping_info *ptdev_activate_entry(
|
||||
struct ptdev_remapping_info *entry,
|
||||
int phys_irq, bool lowpri);
|
||||
void ptdev_deactivate_entry(struct ptdev_remapping_info *entry);
|
||||
|
||||
#endif /* PTDEV_H */
|
Reference in New Issue
Block a user