hv: assign: clean up HV_DEBUG usage related to shell
remove the usage of HV_DEBUG related to shell command in assign.c Tracked-On: #861 Signed-off-by: Shiqing Gao <shiqing.gao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
f21e36f43b
commit
b1047224aa
|
@ -789,114 +789,3 @@ void ptdev_remove_msix_remapping(const struct acrn_vm *vm, uint16_t virt_bdf,
|
|||
spinlock_release(&ptdev_lock);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HV_DEBUG
|
||||
#define PTDEV_INVALID_PIN 0xffU
|
||||
static void get_entry_info(const struct ptdev_remapping_info *entry, char *type,
|
||||
uint32_t *irq, uint32_t *vector, uint64_t *dest, bool *lvl_tm,
|
||||
uint8_t *pin, uint8_t *vpin, uint32_t *bdf, uint32_t *vbdf)
|
||||
{
|
||||
if (is_entry_active(entry)) {
|
||||
if (entry->intr_type == PTDEV_INTR_MSI) {
|
||||
(void)strcpy_s(type, 16U, "MSI");
|
||||
*dest = (entry->msi.pmsi_addr & 0xFF000U) >> CPU_PAGE_SHIFT;
|
||||
if ((entry->msi.pmsi_data & APIC_TRIGMOD_LEVEL) != 0U) {
|
||||
*lvl_tm = true;
|
||||
} else {
|
||||
*lvl_tm = false;
|
||||
}
|
||||
*pin = PTDEV_INVALID_PIN;
|
||||
*vpin = PTDEV_INVALID_PIN;
|
||||
*bdf = entry->phys_sid.msi_id.bdf;
|
||||
*vbdf = entry->virt_sid.msi_id.bdf;
|
||||
} else {
|
||||
uint32_t phys_irq = entry->allocated_pirq;
|
||||
union ioapic_rte rte;
|
||||
|
||||
if (entry->virt_sid.intx_id.src == PTDEV_VPIN_IOAPIC) {
|
||||
(void)strcpy_s(type, 16U, "IOAPIC");
|
||||
} else {
|
||||
(void)strcpy_s(type, 16U, "PIC");
|
||||
}
|
||||
ioapic_get_rte(phys_irq, &rte);
|
||||
*dest = rte.full >> IOAPIC_RTE_DEST_SHIFT;
|
||||
if ((rte.full & IOAPIC_RTE_TRGRLVL) != 0UL) {
|
||||
*lvl_tm = true;
|
||||
} else {
|
||||
*lvl_tm = false;
|
||||
}
|
||||
*pin = entry->phys_sid.intx_id.pin;
|
||||
*vpin = entry->virt_sid.intx_id.pin;
|
||||
*bdf = 0U;
|
||||
*vbdf = 0U;
|
||||
}
|
||||
*irq = entry->allocated_pirq;
|
||||
*vector = irq_to_vector(entry->allocated_pirq);
|
||||
} else {
|
||||
(void)strcpy_s(type, 16U, "NONE");
|
||||
*irq = IRQ_INVALID;
|
||||
*vector = 0U;
|
||||
*dest = 0UL;
|
||||
*lvl_tm = 0;
|
||||
*pin = -1;
|
||||
*vpin = -1;
|
||||
*bdf = 0U;
|
||||
*vbdf = 0U;
|
||||
}
|
||||
}
|
||||
|
||||
void get_ptdev_info(char *str_arg, size_t str_max)
|
||||
{
|
||||
char *str = str_arg;
|
||||
struct ptdev_remapping_info *entry;
|
||||
uint16_t idx;
|
||||
size_t len, size = str_max;
|
||||
uint32_t irq, vector;
|
||||
char type[16];
|
||||
uint64_t dest;
|
||||
bool lvl_tm;
|
||||
uint8_t pin, vpin;
|
||||
uint32_t bdf, vbdf;
|
||||
|
||||
len = snprintf(str, size, "\r\nVM\tTYPE\tIRQ\tVEC\tDEST\tTM\tPIN\tVPIN\tBDF\tVBDF");
|
||||
if (len >= size) {
|
||||
goto overflow;
|
||||
}
|
||||
size -= len;
|
||||
str += len;
|
||||
|
||||
for (idx = 0U; idx < CONFIG_MAX_PT_IRQ_ENTRIES; idx++) {
|
||||
entry = &ptdev_irq_entries[idx];
|
||||
if (is_entry_active(entry)) {
|
||||
get_entry_info(entry, type, &irq, &vector,
|
||||
&dest, &lvl_tm, &pin, &vpin,
|
||||
&bdf, &vbdf);
|
||||
len = snprintf(str, size, "\r\n%d\t%s\t%d\t0x%X\t0x%X",
|
||||
entry->vm->vm_id, type, irq, vector, dest);
|
||||
if (len >= size) {
|
||||
goto overflow;
|
||||
}
|
||||
size -= len;
|
||||
str += len;
|
||||
|
||||
len = snprintf(str, size, "\t%s\t%hhu\t%hhu\t%x:%x.%x\t%x:%x.%x",
|
||||
is_entry_active(entry) ? (lvl_tm ? "level" : "edge") : "none",
|
||||
pin, vpin, (bdf & 0xff00U) >> 8U,
|
||||
(bdf & 0xf8U) >> 3U, bdf & 0x7U,
|
||||
(vbdf & 0xff00U) >> 8U,
|
||||
(vbdf & 0xf8U) >> 3U, vbdf & 0x7U);
|
||||
if (len >= size) {
|
||||
goto overflow;
|
||||
}
|
||||
size -= len;
|
||||
str += len;
|
||||
}
|
||||
}
|
||||
|
||||
snprintf(str, size, "\r\n");
|
||||
return;
|
||||
|
||||
overflow:
|
||||
printf("buffer size could not be enough! please check!\n");
|
||||
}
|
||||
#endif /* HV_DEBUG */
|
||||
|
|
|
@ -908,6 +908,115 @@ static int shell_show_cpu_int(__unused int argc, __unused char **argv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#define PTDEV_INVALID_PIN 0xffU
|
||||
static void get_entry_info(const struct ptdev_remapping_info *entry, char *type,
|
||||
uint32_t *irq, uint32_t *vector, uint64_t *dest, bool *lvl_tm,
|
||||
uint8_t *pin, uint8_t *vpin, uint32_t *bdf, uint32_t *vbdf)
|
||||
{
|
||||
if (is_entry_active(entry)) {
|
||||
if (entry->intr_type == PTDEV_INTR_MSI) {
|
||||
(void)strcpy_s(type, 16U, "MSI");
|
||||
*dest = (entry->msi.pmsi_addr & 0xFF000U) >> CPU_PAGE_SHIFT;
|
||||
if ((entry->msi.pmsi_data & APIC_TRIGMOD_LEVEL) != 0U) {
|
||||
*lvl_tm = true;
|
||||
} else {
|
||||
*lvl_tm = false;
|
||||
}
|
||||
*pin = PTDEV_INVALID_PIN;
|
||||
*vpin = PTDEV_INVALID_PIN;
|
||||
*bdf = entry->phys_sid.msi_id.bdf;
|
||||
*vbdf = entry->virt_sid.msi_id.bdf;
|
||||
} else {
|
||||
uint32_t phys_irq = entry->allocated_pirq;
|
||||
union ioapic_rte rte;
|
||||
|
||||
if (entry->virt_sid.intx_id.src == PTDEV_VPIN_IOAPIC) {
|
||||
(void)strcpy_s(type, 16U, "IOAPIC");
|
||||
} else {
|
||||
(void)strcpy_s(type, 16U, "PIC");
|
||||
}
|
||||
ioapic_get_rte(phys_irq, &rte);
|
||||
*dest = rte.full >> IOAPIC_RTE_DEST_SHIFT;
|
||||
if ((rte.full & IOAPIC_RTE_TRGRLVL) != 0UL) {
|
||||
*lvl_tm = true;
|
||||
} else {
|
||||
*lvl_tm = false;
|
||||
}
|
||||
*pin = entry->phys_sid.intx_id.pin;
|
||||
*vpin = entry->virt_sid.intx_id.pin;
|
||||
*bdf = 0U;
|
||||
*vbdf = 0U;
|
||||
}
|
||||
*irq = entry->allocated_pirq;
|
||||
*vector = irq_to_vector(entry->allocated_pirq);
|
||||
} else {
|
||||
(void)strcpy_s(type, 16U, "NONE");
|
||||
*irq = IRQ_INVALID;
|
||||
*vector = 0U;
|
||||
*dest = 0UL;
|
||||
*lvl_tm = 0;
|
||||
*pin = -1;
|
||||
*vpin = -1;
|
||||
*bdf = 0U;
|
||||
*vbdf = 0U;
|
||||
}
|
||||
}
|
||||
|
||||
static void get_ptdev_info(char *str_arg, size_t str_max)
|
||||
{
|
||||
char *str = str_arg;
|
||||
struct ptdev_remapping_info *entry;
|
||||
uint16_t idx;
|
||||
size_t len, size = str_max;
|
||||
uint32_t irq, vector;
|
||||
char type[16];
|
||||
uint64_t dest;
|
||||
bool lvl_tm;
|
||||
uint8_t pin, vpin;
|
||||
uint32_t bdf, vbdf;
|
||||
|
||||
len = snprintf(str, size, "\r\nVM\tTYPE\tIRQ\tVEC\tDEST\tTM\tPIN\tVPIN\tBDF\tVBDF");
|
||||
if (len >= size) {
|
||||
goto overflow;
|
||||
}
|
||||
size -= len;
|
||||
str += len;
|
||||
|
||||
for (idx = 0U; idx < CONFIG_MAX_PT_IRQ_ENTRIES; idx++) {
|
||||
entry = &ptdev_irq_entries[idx];
|
||||
if (is_entry_active(entry)) {
|
||||
get_entry_info(entry, type, &irq, &vector,
|
||||
&dest, &lvl_tm, &pin, &vpin,
|
||||
&bdf, &vbdf);
|
||||
len = snprintf(str, size, "\r\n%d\t%s\t%d\t0x%X\t0x%X",
|
||||
entry->vm->vm_id, type, irq, vector, dest);
|
||||
if (len >= size) {
|
||||
goto overflow;
|
||||
}
|
||||
size -= len;
|
||||
str += len;
|
||||
|
||||
len = snprintf(str, size, "\t%s\t%hhu\t%hhu\t%x:%x.%x\t%x:%x.%x",
|
||||
is_entry_active(entry) ? (lvl_tm ? "level" : "edge") : "none",
|
||||
pin, vpin, (bdf & 0xff00U) >> 8U,
|
||||
(bdf & 0xf8U) >> 3U, bdf & 0x7U,
|
||||
(vbdf & 0xff00U) >> 8U,
|
||||
(vbdf & 0xf8U) >> 3U, vbdf & 0x7U);
|
||||
if (len >= size) {
|
||||
goto overflow;
|
||||
}
|
||||
size -= len;
|
||||
str += len;
|
||||
}
|
||||
}
|
||||
|
||||
snprintf(str, size, "\r\n");
|
||||
return;
|
||||
|
||||
overflow:
|
||||
printf("buffer size could not be enough! please check!\n");
|
||||
}
|
||||
|
||||
static int shell_show_ptdev_info(__unused int argc, __unused char **argv)
|
||||
{
|
||||
get_ptdev_info(shell_log_buf, SHELL_LOG_BUF_SIZE);
|
||||
|
|
|
@ -77,17 +77,11 @@ void ptdev_init(void);
|
|||
void ptdev_release_all_entries(const struct acrn_vm *vm);
|
||||
|
||||
struct ptdev_remapping_info *ptdev_dequeue_softirq(struct acrn_vm *vm);
|
||||
struct ptdev_remapping_info *alloc_entry(struct acrn_vm *vm,
|
||||
uint32_t intr_type);
|
||||
struct ptdev_remapping_info *alloc_entry(struct acrn_vm *vm, uint32_t intr_type);
|
||||
void release_entry(struct ptdev_remapping_info *entry);
|
||||
int32_t ptdev_activate_entry(struct ptdev_remapping_info *entry, uint32_t phys_irq);
|
||||
void ptdev_deactivate_entry(struct ptdev_remapping_info *entry);
|
||||
|
||||
#ifdef HV_DEBUG
|
||||
void get_ptdev_info(char *str_arg, size_t str_max);
|
||||
#endif /* HV_DEBUG */
|
||||
|
||||
uint32_t get_vm_ptdev_intr_data(const struct acrn_vm *target_vm, uint64_t *buffer,
|
||||
uint32_t buffer_cnt);
|
||||
uint32_t get_vm_ptdev_intr_data(const struct acrn_vm *target_vm, uint64_t *buffer, uint32_t buffer_cnt);
|
||||
|
||||
#endif /* PTDEV_H */
|
||||
|
|
Loading…
Reference in New Issue