1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation
8 #include "ifpga_defines.h"
9 #include "opae_ifpga_hw_api.h"
11 /** List of private feateues */
12 TAILQ_HEAD(ifpga_feature_list, feature);
14 enum ifpga_feature_state {
15 IFPGA_FEATURE_UNUSED = 0,
16 IFPGA_FEATURE_ATTACHED,
24 struct feature_irq_ctx {
30 TAILQ_ENTRY(feature)next;
31 enum ifpga_feature_state state;
32 enum feature_type type;
41 struct feature_irq_ctx *ctx;
44 void *parent; /* to parent hw data structure */
46 struct feature_ops *ops;/* callback to this private feature */
47 unsigned int vec_start;
52 int (*init)(struct feature *feature);
53 void (*uinit)(struct feature *feature);
54 int (*get_prop)(struct feature *feature, struct feature_prop *prop);
55 int (*set_prop)(struct feature *feature, struct feature_prop *prop);
56 int (*set_irq)(struct feature *feature, void *irq_set);
59 enum ifpga_fme_state {
61 IFPGA_FME_IMPLEMENTED,
65 enum ifpga_fme_state state;
67 struct ifpga_feature_list feature_list;
68 spinlock_t lock; /* protect hardware access */
70 void *parent; /* pointer to ifpga_hw */
72 /* provied by HEADER feature */
74 struct uuid bitstream_id;
78 u32 fabric_version_id;
83 void *max10_dev; /* MAX10 device */
84 void *i2c_master; /* I2C Master device */
87 enum ifpga_port_state {
88 IFPGA_PORT_UNUSED = 0,
93 struct ifpga_port_hw {
94 enum ifpga_port_state state;
96 struct ifpga_feature_list feature_list;
97 spinlock_t lock; /* protect access to hw */
99 void *parent; /* pointer to ifpga_hw */
101 int port_id; /* provied by HEADER feature */
102 struct uuid afu_id; /* provied by User AFU feature */
104 unsigned int disable_count;
107 u32 num_umsgs; /* The number of allocated umsgs */
108 u32 num_uafu_irqs; /* The number of uafu interrupts */
113 #define AFU_MAX_REGION 1
115 struct ifpga_afu_info {
116 struct opae_reg_region region[AFU_MAX_REGION];
117 unsigned int num_regions;
118 unsigned int num_irqs;
122 struct opae_adapter *adapter;
123 struct opae_adapter_data_pci *pci_data;
125 struct ifpga_fme_hw fme;
126 struct ifpga_port_hw port[MAX_FPGA_PORT_NUM];
129 static inline bool is_ifpga_hw_pf(struct ifpga_hw *hw)
131 return hw->fme.state != IFPGA_FME_UNUSED;
134 static inline bool is_valid_port_id(struct ifpga_hw *hw, u32 port_id)
136 if (port_id >= MAX_FPGA_PORT_NUM ||
137 hw->port[port_id].state != IFPGA_PORT_ATTACHED)
142 #endif /* _IFPGA_HW_H_ */