]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/dpdk/drivers/bus/ifpga/rte_bus_ifpga.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / dpdk / drivers / bus / ifpga / rte_bus_ifpga.h
CommitLineData
11fdf7f2
TL
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation
3 */
4
5#ifndef _RTE_BUS_IFPGA_H_
6#define _RTE_BUS_IFPGA_H_
7
8/**
9 * @file
10 *
11 * RTE Intel FPGA Bus Interface
12 */
13
14#ifdef __cplusplus
15extern "C" {
9f95a23c 16#endif /* __cplusplus */
11fdf7f2
TL
17
18#include <rte_bus.h>
19#include <rte_pci.h>
f67539c2 20#include <rte_interrupts.h>
9f95a23c 21#include <rte_spinlock.h>
11fdf7f2
TL
22
23/** Name of Intel FPGA Bus */
24#define IFPGA_BUS_NAME ifpga
25
26/* Forward declarations */
27struct rte_afu_device;
28struct rte_afu_driver;
29
30/** Double linked list of Intel FPGA AFU device. */
31TAILQ_HEAD(ifpga_afu_dev_list, rte_afu_device);
32/** Double linked list of Intel FPGA AFU device drivers. */
33TAILQ_HEAD(ifpga_afu_drv_list, rte_afu_driver);
34
35#define IFPGA_BUS_BITSTREAM_PATH_MAX_LEN 256
36
37struct rte_afu_uuid {
38 uint64_t uuid_low;
39 uint64_t uuid_high;
f67539c2 40} __rte_packed;
11fdf7f2
TL
41
42#define IFPGA_BUS_DEV_PORT_MAX 4
43
44/**
45 * A structure describing an ID for a AFU driver. Each driver provides a
46 * table of these IDs for each device that it supports.
47 */
48struct rte_afu_id {
49 struct rte_afu_uuid uuid;
50 int port; /**< port number */
f67539c2 51} __rte_packed;
11fdf7f2
TL
52
53/**
54 * A structure PR (Partial Reconfiguration) configuration AFU driver.
55 */
56
57struct rte_afu_pr_conf {
58 struct rte_afu_id afu_id;
59 int pr_enable;
60 char bs_path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN];
61};
62
63#define AFU_PRI_STR_SIZE (PCI_PRI_STR_SIZE + 8)
64
9f95a23c
TL
65struct rte_afu_shared {
66 rte_spinlock_t lock;
67 void *data;
68};
69
11fdf7f2
TL
70/**
71 * A structure describing a AFU device.
72 */
73struct rte_afu_device {
74 TAILQ_ENTRY(rte_afu_device) next; /**< Next in device list. */
75 struct rte_device device; /**< Inherit core device */
76 struct rte_rawdev *rawdev; /**< Point Rawdev */
77 struct rte_afu_id id; /**< AFU id within FPGA. */
78 uint32_t num_region; /**< number of regions found */
79 struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE];
80 /**< AFU Memory Resource */
9f95a23c 81 struct rte_afu_shared shared;
11fdf7f2
TL
82 struct rte_intr_handle intr_handle; /**< Interrupt handle */
83 struct rte_afu_driver *driver; /**< Associated driver */
84 char path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN];
f67539c2 85} __rte_packed;
11fdf7f2
TL
86
87/**
88 * @internal
89 * Helper macro for drivers that need to convert to struct rte_afu_device.
90 */
91#define RTE_DEV_TO_AFU(ptr) \
92 container_of(ptr, struct rte_afu_device, device)
93
11fdf7f2
TL
94/**
95 * Initialization function for the driver called during FPGA BUS probing.
96 */
97typedef int (afu_probe_t)(struct rte_afu_device *);
98
99/**
100 * Uninitialization function for the driver called during hotplugging.
101 */
102typedef int (afu_remove_t)(struct rte_afu_device *);
103
104/**
105 * A structure describing a AFU device.
106 */
107struct rte_afu_driver {
108 TAILQ_ENTRY(rte_afu_driver) next; /**< Next afu driver. */
109 struct rte_driver driver; /**< Inherit core driver. */
110 afu_probe_t *probe; /**< Device Probe function. */
111 afu_remove_t *remove; /**< Device Remove function. */
112 const struct rte_afu_uuid *id_table; /**< AFU uuid within FPGA. */
113};
114
115static inline const char *
116rte_ifpga_device_name(const struct rte_afu_device *afu)
117{
118 if (afu && afu->device.name)
119 return afu->device.name;
120 return NULL;
121}
122
9f95a23c
TL
123/**
124 * Find AFU by AFU name.
125 *
126 * @param name
127 * A pointer to AFU name string.
128 */
129struct rte_afu_device *
130rte_ifpga_find_afu_by_name(const char *name);
131
11fdf7f2
TL
132/**
133 * Register a ifpga afu device driver.
134 *
135 * @param driver
136 * A pointer to a rte_afu_driver structure describing the driver
137 * to be registered.
138 */
139void rte_ifpga_driver_register(struct rte_afu_driver *driver);
140
141/**
142 * Unregister a ifpga afu device driver.
143 *
144 * @param driver
145 * A pointer to a rte_afu_driver structure describing the driver
146 * to be unregistered.
147 */
148void rte_ifpga_driver_unregister(struct rte_afu_driver *driver);
149
150#define RTE_PMD_REGISTER_AFU(nm, afudrv)\
151static const char *afudrvinit_ ## nm ## _alias;\
152RTE_INIT(afudrvinitfn_ ##afudrv)\
153{\
154 (afudrv).driver.name = RTE_STR(nm);\
155 (afudrv).driver.alias = afudrvinit_ ## nm ## _alias;\
156 rte_ifpga_driver_register(&afudrv);\
157} \
158RTE_PMD_EXPORT_NAME(nm, __COUNTER__)
159
160#define RTE_PMD_REGISTER_AFU_ALIAS(nm, alias)\
161static const char *afudrvinit_ ## nm ## _alias = RTE_STR(alias)
162
9f95a23c
TL
163#ifdef __cplusplus
164}
165#endif /* __cplusplus */
166
11fdf7f2 167#endif /* _RTE_BUS_IFPGA_H_ */