Marc Zyngier | de29faa | 2016-12-19 19:25:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016,2017 ARM Limited, All Rights Reserved. |
| 3 | * Author: Marc Zyngier <marc.zyngier@arm.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | |
| 18 | #ifndef __LINUX_IRQCHIP_ARM_GIC_V4_H |
| 19 | #define __LINUX_IRQCHIP_ARM_GIC_V4_H |
| 20 | |
| 21 | struct its_vpe; |
| 22 | |
Marc Zyngier | ab60491 | 2017-10-08 18:48:06 +0100 | [diff] [blame] | 23 | /* |
| 24 | * Maximum number of ITTs when GITS_TYPER.VMOVP == 0, using the |
| 25 | * ITSList mechanism to perform inter-ITS synchronization. |
| 26 | */ |
| 27 | #define GICv4_ITS_LIST_MAX 16 |
| 28 | |
Marc Zyngier | de29faa | 2016-12-19 19:25:00 +0000 | [diff] [blame] | 29 | /* Embedded in kvm.arch */ |
| 30 | struct its_vm { |
| 31 | struct fwnode_handle *fwnode; |
| 32 | struct irq_domain *domain; |
| 33 | struct page *vprop_page; |
| 34 | struct its_vpe **vpes; |
| 35 | int nr_vpes; |
| 36 | irq_hw_number_t db_lpi_base; |
| 37 | unsigned long *db_bitmap; |
| 38 | int nr_db_lpis; |
Marc Zyngier | 2247e1b | 2017-10-08 18:50:36 +0100 | [diff] [blame] | 39 | u32 vlpi_count[GICv4_ITS_LIST_MAX]; |
Marc Zyngier | de29faa | 2016-12-19 19:25:00 +0000 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | /* Embedded in kvm_vcpu.arch */ |
| 43 | struct its_vpe { |
| 44 | struct page *vpt_page; |
| 45 | struct its_vm *its_vm; |
| 46 | /* Doorbell interrupt */ |
| 47 | int irq; |
| 48 | irq_hw_number_t vpe_db_lpi; |
Marc Zyngier | 20b3d54 | 2016-12-20 15:23:22 +0000 | [diff] [blame] | 49 | /* VPE proxy mapping */ |
| 50 | int vpe_proxy_event; |
Marc Zyngier | de29faa | 2016-12-19 19:25:00 +0000 | [diff] [blame] | 51 | /* |
| 52 | * This collection ID is used to indirect the target |
| 53 | * redistributor for this VPE. The ID itself isn't involved in |
| 54 | * programming of the ITS. |
| 55 | */ |
| 56 | u16 col_idx; |
| 57 | /* Unique (system-wide) VPE identifier */ |
| 58 | u16 vpe_id; |
| 59 | /* Implementation Defined Area Invalid */ |
| 60 | bool idai; |
| 61 | /* Pending VLPIs on schedule out? */ |
| 62 | bool pending_last; |
| 63 | }; |
| 64 | |
| 65 | /* |
| 66 | * struct its_vlpi_map: structure describing the mapping of a |
| 67 | * VLPI. Only to be interpreted in the context of a physical interrupt |
| 68 | * it complements. To be used as the vcpu_info passed to |
| 69 | * irq_set_vcpu_affinity(). |
| 70 | * |
| 71 | * @vm: Pointer to the GICv4 notion of a VM |
| 72 | * @vpe: Pointer to the GICv4 notion of a virtual CPU (VPE) |
| 73 | * @vintid: Virtual LPI number |
Marc Zyngier | d4d7b4a | 2017-10-26 10:44:07 +0100 | [diff] [blame] | 74 | * @properties: Priority and enable bits (as written in the prop table) |
Marc Zyngier | de29faa | 2016-12-19 19:25:00 +0000 | [diff] [blame] | 75 | * @db_enabled: Is the VPE doorbell to be generated? |
| 76 | */ |
| 77 | struct its_vlpi_map { |
| 78 | struct its_vm *vm; |
| 79 | struct its_vpe *vpe; |
| 80 | u32 vintid; |
Marc Zyngier | d4d7b4a | 2017-10-26 10:44:07 +0100 | [diff] [blame] | 81 | u8 properties; |
Marc Zyngier | de29faa | 2016-12-19 19:25:00 +0000 | [diff] [blame] | 82 | bool db_enabled; |
| 83 | }; |
| 84 | |
| 85 | enum its_vcpu_info_cmd_type { |
| 86 | MAP_VLPI, |
| 87 | GET_VLPI, |
| 88 | PROP_UPDATE_VLPI, |
| 89 | PROP_UPDATE_AND_INV_VLPI, |
| 90 | SCHEDULE_VPE, |
| 91 | DESCHEDULE_VPE, |
| 92 | INVALL_VPE, |
| 93 | }; |
| 94 | |
| 95 | struct its_cmd_info { |
| 96 | enum its_vcpu_info_cmd_type cmd_type; |
| 97 | union { |
| 98 | struct its_vlpi_map *map; |
| 99 | u8 config; |
| 100 | }; |
| 101 | }; |
| 102 | |
Marc Zyngier | 7de5c0a | 2016-12-20 15:27:52 +0000 | [diff] [blame] | 103 | int its_alloc_vcpu_irqs(struct its_vm *vm); |
| 104 | void its_free_vcpu_irqs(struct its_vm *vm); |
Marc Zyngier | eab8431 | 2016-12-20 15:31:02 +0000 | [diff] [blame] | 105 | int its_schedule_vpe(struct its_vpe *vpe, bool on); |
| 106 | int its_invall_vpe(struct its_vpe *vpe); |
Marc Zyngier | f2eac75 | 2016-12-21 21:50:32 +0000 | [diff] [blame] | 107 | int its_map_vlpi(int irq, struct its_vlpi_map *map); |
| 108 | int its_get_vlpi(int irq, struct its_vlpi_map *map); |
| 109 | int its_unmap_vlpi(int irq); |
| 110 | int its_prop_update_vlpi(int irq, u8 config, bool inv); |
Marc Zyngier | 7de5c0a | 2016-12-20 15:27:52 +0000 | [diff] [blame] | 111 | |
Marc Zyngier | 47f9d0b | 2017-11-13 16:21:33 +0000 | [diff] [blame] | 112 | struct irq_domain_ops; |
Marc Zyngier | 3d63cb5 | 2016-12-20 15:31:54 +0000 | [diff] [blame] | 113 | int its_init_v4(struct irq_domain *domain, const struct irq_domain_ops *ops); |
| 114 | |
Marc Zyngier | de29faa | 2016-12-19 19:25:00 +0000 | [diff] [blame] | 115 | #endif |