/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (c) 2021 HiSilicon Ltd. */
#ifndef HISI_ACC_VFIO_PCI_H
#define HISI_ACC_VFIO_PCI_H
#include <linux/hisi_acc_qm.h>
#define MB_POLL_PERIOD_US 10
#define MB_POLL_TIMEOUT_US 1000
#define QM_CACHE_WB_START 0 x204
#define QM_CACHE_WB_DONE 0 x208
#define QM_MB_CMD_PAUSE_QM 0 xe
#define QM_ABNORMAL_INT_STATUS 0 x100008
#define QM_IFC_INT_STATUS 0 x0028
#define SEC_CORE_INT_STATUS 0 x301008
#define HPRE_HAC_INT_STATUS 0 x301800
#define HZIP_CORE_INT_STATUS 0 x3010AC
#define QM_VFT_CFG_RDY 0 x10006c
#define QM_VFT_CFG_OP_WR 0 x100058
#define QM_VFT_CFG_TYPE 0 x10005c
#define QM_VFT_CFG 0 x100060
#define QM_VFT_CFG_OP_ENABLE 0 x100054
#define QM_VFT_CFG_DATA_L 0 x100064
#define QM_VFT_CFG_DATA_H 0 x100068
#define ERROR_CHECK_TIMEOUT 100
#define CHECK_DELAY_TIME 100
#define QM_SQC_VFT_BASE_SHIFT_V2 28
#define QM_SQC_VFT_BASE_MASK_V2 GENMASK(15 , 0 )
#define QM_SQC_VFT_NUM_SHIFT_V2 45
#define QM_SQC_VFT_NUM_MASK_V2 GENMASK(9 , 0 )
#define QM_MB_CMD_NOT_READY 0 xffffffff
/* RW regs */
#define QM_REGS_MAX_LEN 7
#define QM_REG_ADDR_OFFSET 0 x0004
#define QM_XQC_ADDR_OFFSET 32 U
#define QM_XQC_ADDR_LOW 0 x1
#define QM_XQC_ADDR_HIGH 0 x2
#define QM_VF_AEQ_INT_MASK 0 x0004
#define QM_VF_EQ_INT_MASK 0 x000c
#define QM_IFC_INT_SOURCE_V 0 x0020
#define QM_IFC_INT_MASK 0 x0024
#define QM_IFC_INT_SET_V 0 x002c
#define QM_QUE_ISO_CFG_V 0 x0030
#define QM_PAGE_SIZE 0 x0034
#define QM_EQC_DW0 0 X8000
#define QM_AEQC_DW0 0 X8020
#define ACC_DRV_MAJOR_VER 1
#define ACC_DRV_MINOR_VER 0
#define ACC_DEV_MAGIC_V1 0 XCDCDCDCDFEEDAACC
#define ACC_DEV_MAGIC_V2 0 xAACCFEEDDECADEDE
struct acc_vf_data {
#define QM_MATCH_SIZE offsetofend(struct acc_vf_data, qm_rsv_state)
/* QM match information */
u64 acc_magic;
u32 qp_num;
u32 dev_id;
u32 que_iso_cfg;
u32 qp_base;
u32 vf_qm_state;
/* QM reserved match information */
u16 major_ver;
u16 minor_ver;
u32 qm_rsv_state[2 ];
/* QM RW regs */
u32 aeq_int_mask;
u32 eq_int_mask;
u32 ifc_int_source;
u32 ifc_int_mask;
u32 ifc_int_set;
u32 page_size;
/* QM_EQC_DW has 7 regs */
u32 qm_eqc_dw[7 ];
/* QM_AEQC_DW has 7 regs */
u32 qm_aeqc_dw[7 ];
/* QM reserved 5 regs */
u32 qm_rsv_regs[5 ];
u32 padding;
/* QM memory init information */
u64 eqe_dma;
u64 aeqe_dma;
u64 sqc_dma;
u64 cqc_dma;
};
struct hisi_acc_vf_migration_file {
struct file *filp;
struct mutex lock;
bool disabled;
struct hisi_acc_vf_core_device *hisi_acc_vdev;
struct acc_vf_data vf_data;
size_t total_length;
};
struct hisi_acc_vf_core_device {
struct vfio_pci_core_device core_device;
u8 match_done;
/*
* io_base is only valid when dev_opened is true ,
* which is protected by open_mutex .
*/
bool dev_opened;
/* Ensure the accuracy of dev_opened operation */
struct mutex open_mutex;
/* For migration state */
struct mutex state_mutex;
enum vfio_device_mig_state mig_state;
struct pci_dev *pf_dev;
struct pci_dev *vf_dev;
struct hisi_qm *pf_qm;
struct hisi_qm vf_qm;
/*
* vf_qm_state represents the QM_VF_STATE register value .
* It is set by Guest driver for the ACC VF dev indicating
* the driver has loaded and configured the dev correctly .
*/
u32 vf_qm_state;
int vf_id;
struct hisi_acc_vf_migration_file *resuming_migf;
struct hisi_acc_vf_migration_file *saving_migf;
/*
* It holds migration data corresponding to the last migration
* and is used by the debugfs interface to report it .
*/
struct hisi_acc_vf_migration_file *debug_migf;
};
#endif /* HISI_ACC_VFIO_PCI_H */
Messung V0.5 in Prozent C=95 H=91 G=92
¤ Dauer der Verarbeitung: 0.2 Sekunden
¤
*© Formatika GbR, Deutschland