mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 01:03:55 -06:00
x86_iommu: move vtd_generate_msi_message in common file
The vtd_generate_msi_message() in intel-iommu is used to construct a MSI Message from IRQ. A similar function will be needed when we add interrupt remapping support in amd-iommu. Moving the function in common file to avoid the code duplication. Rename it to x86_iommu_irq_to_msi_message(). There is no logic changes in the code flow. Signed-off-by: Brijesh Singh <brijesh.singh@amd.com> Suggested-by: Peter Xu <peterx@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Cc: Peter Xu <peterx@redhat.com> Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Richard Henderson <rth@twiddle.net> Cc: Eduardo Habkost <ehabkost@redhat.com> Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com> Cc: Tom Lendacky <Thomas.Lendacky@amd.com> Cc: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
50662ce16d
commit
35c2450191
4 changed files with 94 additions and 87 deletions
|
@ -2716,7 +2716,7 @@ static int vtd_irte_get(IntelIOMMUState *iommu, uint16_t index,
|
|||
|
||||
/* Fetch IRQ information of specific IR index */
|
||||
static int vtd_remap_irq_get(IntelIOMMUState *iommu, uint16_t index,
|
||||
VTDIrq *irq, uint16_t sid)
|
||||
X86IOMMUIrq *irq, uint16_t sid)
|
||||
{
|
||||
VTD_IR_TableEntry irte = {};
|
||||
int ret = 0;
|
||||
|
@ -2745,30 +2745,6 @@ static int vtd_remap_irq_get(IntelIOMMUState *iommu, uint16_t index,
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Generate one MSI message from VTDIrq info */
|
||||
static void vtd_generate_msi_message(VTDIrq *irq, MSIMessage *msg_out)
|
||||
{
|
||||
VTD_MSIMessage msg = {};
|
||||
|
||||
/* Generate address bits */
|
||||
msg.dest_mode = irq->dest_mode;
|
||||
msg.redir_hint = irq->redir_hint;
|
||||
msg.dest = irq->dest;
|
||||
msg.__addr_hi = irq->dest & 0xffffff00;
|
||||
msg.__addr_head = cpu_to_le32(0xfee);
|
||||
/* Keep this from original MSI address bits */
|
||||
msg.__not_used = irq->msi_addr_last_bits;
|
||||
|
||||
/* Generate data bits */
|
||||
msg.vector = irq->vector;
|
||||
msg.delivery_mode = irq->delivery_mode;
|
||||
msg.level = 1;
|
||||
msg.trigger_mode = irq->trigger_mode;
|
||||
|
||||
msg_out->address = msg.msi_addr;
|
||||
msg_out->data = msg.msi_data;
|
||||
}
|
||||
|
||||
/* Interrupt remapping for MSI/MSI-X entry */
|
||||
static int vtd_interrupt_remap_msi(IntelIOMMUState *iommu,
|
||||
MSIMessage *origin,
|
||||
|
@ -2778,7 +2754,7 @@ static int vtd_interrupt_remap_msi(IntelIOMMUState *iommu,
|
|||
int ret = 0;
|
||||
VTD_IR_MSIAddress addr;
|
||||
uint16_t index;
|
||||
VTDIrq irq = {};
|
||||
X86IOMMUIrq irq = {};
|
||||
|
||||
assert(origin && translated);
|
||||
|
||||
|
@ -2857,8 +2833,8 @@ static int vtd_interrupt_remap_msi(IntelIOMMUState *iommu,
|
|||
*/
|
||||
irq.msi_addr_last_bits = addr.addr.__not_care;
|
||||
|
||||
/* Translate VTDIrq to MSI message */
|
||||
vtd_generate_msi_message(&irq, translated);
|
||||
/* Translate X86IOMMUIrq to MSI message */
|
||||
x86_iommu_irq_to_msi_message(&irq, translated);
|
||||
|
||||
out:
|
||||
trace_vtd_ir_remap_msi(origin->address, origin->data,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue