1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * ZTE DingHai Ethernet driver - PF header 4 * Copyright (c) 2022-2026, ZTE Corporation. 5 */ 6 7 #ifndef __ZXDH_EN_PF_H__ 8 #define __ZXDH_EN_PF_H__ 9 10 #include <linux/types.h> 11 12 #define ZXDH_PF_VENDOR_ID 0x1cf2 13 #define ZXDH_PF_DEVICE_ID 0x8040 14 #define ZXDH_VF_DEVICE_ID 0x8041 15 16 /* Common configuration */ 17 #define ZXDH_PCI_CAP_COMMON_CFG 1 18 /* Notifications */ 19 #define ZXDH_PCI_CAP_NOTIFY_CFG 2 20 /* ISR access */ 21 #define ZXDH_PCI_CAP_ISR_CFG 3 22 /* Device specific configuration */ 23 #define ZXDH_PCI_CAP_DEVICE_CFG 4 24 /* PCI configuration access */ 25 #define ZXDH_PCI_CAP_PCI_CFG 5 26 27 #define ZXDH_PF_MAX_BAR_VAL 0x5 28 #define ZXDH_PF_ALIGN4 4 29 #define ZXDH_PF_ALIGN2 2 30 #define ZXDH_PF_MAP_MINLEN2 2 31 32 struct zxdh_core_dev { 33 struct device *device; 34 struct pci_dev *pdev; 35 struct devlink *devlink; 36 void *priv; 37 }; 38 39 struct zxdh_pf_dev { 40 struct zxdh_pf_pci_common_cfg __iomem *common; 41 /* Device-specific data (non-legacy mode) */ 42 /* Base of vq notifications (non-legacy mode). */ 43 void __iomem *device; 44 void __iomem *notify_base; 45 /* Physical base of vq notifications */ 46 resource_size_t notify_pa; 47 /* So we can sanity-check accesses. */ 48 size_t notify_len; 49 size_t device_len; 50 /* Capability for when we need to map notifications per-vq. */ 51 s32 notify_map_cap; 52 u32 notify_offset_multiplier; 53 /* Multiply queue_notify_off by this value. (non-legacy mode). */ 54 s32 modern_bars; 55 void __iomem *pci_ioremap_addr[6]; 56 u32 dev_cfg_bar_off; 57 }; 58 59 void *zxdh_core_alloc_priv(struct zxdh_core_dev *zxdh_dev, size_t size); 60 void zxdh_core_free_priv(struct zxdh_core_dev *zxdh_dev); 61 void zxdh_pf_pci_close(struct zxdh_core_dev *zxdh_dev); 62 int zxdh_pf_pci_find_capability(struct pci_dev *pdev, u8 cfg_type, 63 u32 ioresource_types, int *bars); 64 void __iomem *zxdh_pf_map_capability(struct zxdh_core_dev *zxdh_dev, int off, 65 size_t minlen, u32 align, 66 u32 start, u32 size, 67 size_t *len, resource_size_t *pa, 68 u32 *bar_off); 69 int zxdh_pf_common_cfg_init(struct zxdh_core_dev *zxdh_dev); 70 int zxdh_pf_notify_cfg_init(struct zxdh_core_dev *zxdh_dev); 71 int zxdh_pf_device_cfg_init(struct zxdh_core_dev *zxdh_dev); 72 void zxdh_pf_modern_cfg_uninit(struct zxdh_core_dev *zxdh_dev); 73 int zxdh_pf_modern_cfg_init(struct zxdh_core_dev *zxdh_dev); 74 75 #endif /* __ZXDH_EN_PF_H__ */ 76