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;
84 enum ifpga_port_state {
85 IFPGA_PORT_UNUSED = 0,
90 struct ifpga_port_hw {
91 enum ifpga_port_state state;
93 struct ifpga_feature_list feature_list;
94 spinlock_t lock; /* protect access to hw */
96 void *parent; /* pointer to ifpga_hw */
98 int port_id; /* provied by HEADER feature */
99 struct uuid afu_id; /* provied by User AFU feature */
101 unsigned int disable_count;
104 u32 num_umsgs; /* The number of allocated umsgs */
105 u32 num_uafu_irqs; /* The number of uafu interrupts */
110 #define AFU_MAX_REGION 1
112 struct ifpga_afu_info {
113 struct opae_reg_region region[AFU_MAX_REGION];
114 unsigned int num_regions;
115 unsigned int num_irqs;
119 struct opae_adapter *adapter;
120 struct opae_adapter_data_pci *pci_data;
122 struct ifpga_fme_hw fme;
123 struct ifpga_port_hw port[MAX_FPGA_PORT_NUM];
126 static inline bool is_ifpga_hw_pf(struct ifpga_hw *hw)
128 return hw->fme.state != IFPGA_FME_UNUSED;
131 static inline bool is_valid_port_id(struct ifpga_hw *hw, u32 port_id)
133 if (port_id >= MAX_FPGA_PORT_NUM ||
134 hw->port[port_id].state != IFPGA_PORT_ATTACHED)
139 #endif /* _IFPGA_HW_H_ */