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 enum ifpga_feature_state {
12 IFPGA_FEATURE_UNUSED = 0,
13 IFPGA_FEATURE_ATTACHED,
16 struct feature_irq_ctx {
22 enum ifpga_feature_state state;
31 struct feature_irq_ctx *ctx;
34 void *parent; /* to parent hw data structure */
36 struct feature_ops *ops;/* callback to this private feature */
40 int (*init)(struct feature *feature);
41 void (*uinit)(struct feature *feature);
42 int (*get_prop)(struct feature *feature, struct feature_prop *prop);
43 int (*set_prop)(struct feature *feature, struct feature_prop *prop);
44 int (*set_irq)(struct feature *feature, void *irq_set);
47 enum ifpga_fme_state {
49 IFPGA_FME_IMPLEMENTED,
53 enum ifpga_fme_state state;
55 struct feature sub_feature[FME_FEATURE_ID_MAX];
56 spinlock_t lock; /* protect hardware access */
58 void *parent; /* pointer to ifpga_hw */
60 /* provied by HEADER feature */
62 struct uuid bitstream_id;
66 u32 fabric_version_id;
72 enum ifpga_port_state {
73 IFPGA_PORT_UNUSED = 0,
78 struct ifpga_port_hw {
79 enum ifpga_port_state state;
81 struct feature sub_feature[PORT_FEATURE_ID_MAX];
82 spinlock_t lock; /* protect access to hw */
84 void *parent; /* pointer to ifpga_hw */
86 int port_id; /* provied by HEADER feature */
87 struct uuid afu_id; /* provied by User AFU feature */
89 unsigned int disable_count;
92 u32 num_umsgs; /* The number of allocated umsgs */
93 u32 num_uafu_irqs; /* The number of uafu interrupts */
98 #define AFU_MAX_REGION 1
100 struct ifpga_afu_info {
101 struct opae_reg_region region[AFU_MAX_REGION];
102 unsigned int num_regions;
103 unsigned int num_irqs;
107 struct opae_adapter *adapter;
108 struct opae_adapter_data_pci *pci_data;
110 struct ifpga_fme_hw fme;
111 struct ifpga_port_hw port[MAX_FPGA_PORT_NUM];
114 static inline bool is_ifpga_hw_pf(struct ifpga_hw *hw)
116 return hw->fme.state != IFPGA_FME_UNUSED;
119 static inline bool is_valid_port_id(struct ifpga_hw *hw, u32 port_id)
121 if (port_id >= MAX_FPGA_PORT_NUM ||
122 hw->port[port_id].state != IFPGA_PORT_ATTACHED)
127 #endif /* _IFPGA_HW_H_ */