1 /*
2  * Copyright (c) 2020 Intel Corporation.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef ZEPHYR_DRIVERS_VIRTUALIZATION_VIRT_IVSHMEM_H_
8 #define ZEPHYR_DRIVERS_VIRTUALIZATION_VIRT_IVSHMEM_H_
9 
10 #include <drivers/pcie/pcie.h>
11 #include <drivers/pcie/msi.h>
12 
13 #define IVSHMEM_VENDOR_ID		0x1AF4
14 #define IVSHMEM_DEVICE_ID		0x1110
15 
16 #define IVSHMEM_PCIE_REG_BAR_IDX	0
17 #define IVSHMEM_PCIE_SHMEM_BAR_IDX	2
18 
19 struct ivshmem_param {
20 	const struct device *dev;
21 	struct k_poll_signal *signal;
22 	uint8_t vector;
23 };
24 
25 struct ivshmem {
26 	DEVICE_MMIO_RAM;
27 	pcie_bdf_t bdf;
28 	uint32_t dev_ven_id;
29 	uintptr_t shmem;
30 	size_t size;
31 #ifdef CONFIG_IVSHMEM_DOORBELL
32 	msi_vector_t vectors[CONFIG_IVSHMEM_MSI_X_VECTORS];
33 	struct ivshmem_param params[CONFIG_IVSHMEM_MSI_X_VECTORS];
34 	uint16_t n_vectors;
35 #endif
36 };
37 
38 struct ivshmem_reg {
39 	uint32_t int_mask;
40 	uint32_t int_status;
41 	uint32_t iv_position;
42 	uint32_t doorbell;
43 };
44 
45 #define IVSHMEM_GEN_DOORBELL(i, v) ((i << 16) | (v & 0xFFFF))
46 
47 #endif /* ZEPHYR_DRIVERS_VIRTUALIZATION_VIRT_IVSHMEM_H_ */
48