|
Packit |
534379 |
// Copyright(c) 2017, Intel Corporation
|
|
Packit |
534379 |
//
|
|
Packit |
534379 |
// Redistribution and use in source and binary forms, with or without
|
|
Packit |
534379 |
// modification, are permitted provided that the following conditions are met:
|
|
Packit |
534379 |
//
|
|
Packit |
534379 |
// * Redistributions of source code must retain the above copyright notice,
|
|
Packit |
534379 |
// this list of conditions and the following disclaimer.
|
|
Packit |
534379 |
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
Packit |
534379 |
// this list of conditions and the following disclaimer in the documentation
|
|
Packit |
534379 |
// and/or other materials provided with the distribution.
|
|
Packit |
534379 |
// * Neither the name of Intel Corporation nor the names of its contributors
|
|
Packit |
534379 |
// may be used to endorse or promote products derived from this software
|
|
Packit |
534379 |
// without specific prior written permission.
|
|
Packit |
534379 |
//
|
|
Packit |
534379 |
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
Packit |
534379 |
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
Packit |
534379 |
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
Packit |
534379 |
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
Packit |
534379 |
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
Packit |
534379 |
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
Packit |
534379 |
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
Packit |
534379 |
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
Packit |
534379 |
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
Packit |
534379 |
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
Packit |
534379 |
// POSSIBILITY OF SUCH DAMAGE.
|
|
Packit |
534379 |
|
|
Packit |
534379 |
/**
|
|
Packit |
534379 |
* @file types_enum.h
|
|
Packit |
534379 |
* @brief Definitions of enumerated types for the OPAE C API
|
|
Packit |
534379 |
*
|
|
Packit |
534379 |
* This file defines return and error codes, event and object types, states,
|
|
Packit |
534379 |
* and flags as used or reported by OPAE C API functions.
|
|
Packit |
534379 |
*/
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#ifndef __FPGA_TYPES_ENUM_H__
|
|
Packit |
534379 |
#define __FPGA_TYPES_ENUM_H__
|
|
Packit |
534379 |
|
|
Packit |
534379 |
/**
|
|
Packit |
534379 |
* OPAE C API function return codes
|
|
Packit |
534379 |
*
|
|
Packit |
534379 |
* Every public API function exported by the OPAE C library will return one of
|
|
Packit |
534379 |
* these codes. Usually, FPGA_OK denotes successful completion of the requested
|
|
Packit |
534379 |
* operation, while any return code *other* than FPGA_OK indicates an error or
|
|
Packit |
534379 |
* other deviation from the expected behavior. Users of the OPAE C API should
|
|
Packit |
534379 |
* always check the return codes of the APIs they call, and not use output
|
|
Packit |
534379 |
* parameters of functions that did not execute successfully.
|
|
Packit |
534379 |
|
|
Packit |
534379 |
* The fpgaErrStr() function converts error codes into printable messages.
|
|
Packit |
534379 |
*
|
|
Packit |
534379 |
* OPAE also has a logging mechanism that allows a developer to get more
|
|
Packit |
534379 |
* information about why a particular call failed with a specific message. If
|
|
Packit |
534379 |
* enabled, any function that returns an error code different from FPGA_OK will
|
|
Packit |
534379 |
* also print out a message with further details. This mechanism can be enabled
|
|
Packit |
534379 |
* by setting the environment variable `LIBOPAE_LOG` to 1 before running the
|
|
Packit |
534379 |
* respective application.
|
|
Packit |
534379 |
*/
|
|
Packit |
534379 |
typedef enum {
|
|
Packit |
534379 |
FPGA_OK = 0, /**< Operation completed successfully */
|
|
Packit |
534379 |
FPGA_INVALID_PARAM, /**< Invalid parameter supplied */
|
|
Packit |
534379 |
FPGA_BUSY, /**< Resource is busy */
|
|
Packit |
534379 |
FPGA_EXCEPTION, /**< An exception occurred */
|
|
Packit |
534379 |
FPGA_NOT_FOUND, /**< A required resource was not found */
|
|
Packit |
534379 |
FPGA_NO_MEMORY, /**< Not enough memory to complete operation */
|
|
Packit |
534379 |
FPGA_NOT_SUPPORTED, /**< Requested operation is not supported */
|
|
Packit |
534379 |
FPGA_NO_DRIVER, /**< Driver is not loaded */
|
|
Packit |
534379 |
FPGA_NO_DAEMON, /**< FPGA Daemon (fpgad) is not running */
|
|
Packit |
534379 |
FPGA_NO_ACCESS, /**< Insufficient privileges or permissions */
|
|
Packit |
534379 |
FPGA_RECONF_ERROR /**< Error while reconfiguring FPGA */
|
|
Packit |
534379 |
} fpga_result;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
/**
|
|
Packit |
534379 |
* FPGA events
|
|
Packit |
534379 |
*
|
|
Packit |
534379 |
* OPAE currently defines the following event types that applications can
|
|
Packit |
534379 |
* register for. Note that not all FPGA resources and target platforms may
|
|
Packit |
534379 |
* support all event types.
|
|
Packit |
534379 |
*/
|
|
Packit |
534379 |
typedef enum {
|
|
Packit |
534379 |
FPGA_EVENT_INTERRUPT = 0, /**< Interrupt generated by an accelerator */
|
|
Packit |
534379 |
FPGA_EVENT_ERROR, /**< Infrastructure error event */
|
|
Packit |
534379 |
FPGA_EVENT_POWER_THERMAL /**< Infrastructure thermal event */
|
|
Packit |
534379 |
} fpga_event_type;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
/* TODO: consider adding lifecycle events in the future
|
|
Packit |
534379 |
* to help with orchestration. Need a complete specification
|
|
Packit |
534379 |
* before including them in the API. Proposed events:
|
|
Packit |
534379 |
* FPGA_EVENT_APPEAR
|
|
Packit |
534379 |
* FPGA_EVENT_DISAPPEAR
|
|
Packit |
534379 |
* FPGA_EVENT_CHANGE
|
|
Packit |
534379 |
*/
|
|
Packit |
534379 |
|
|
Packit |
534379 |
/** accelerator state */
|
|
Packit |
534379 |
typedef enum {
|
|
Packit |
534379 |
/** accelerator is opened exclusively by another process */
|
|
Packit |
534379 |
FPGA_ACCELERATOR_ASSIGNED = 0,
|
|
Packit |
534379 |
/** accelerator is free to be opened */
|
|
Packit |
534379 |
FPGA_ACCELERATOR_UNASSIGNED
|
|
Packit |
534379 |
} fpga_accelerator_state;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
/**
|
|
Packit |
534379 |
* OPAE FPGA resources (objects)
|
|
Packit |
534379 |
*
|
|
Packit |
534379 |
* These are the FPGA resources currently supported by the OPAE object model.
|
|
Packit |
534379 |
*/
|
|
Packit |
534379 |
typedef enum {
|
|
Packit |
534379 |
/** FPGA_DEVICE objects represent FPGA devices and their management functionality.
|
|
Packit |
534379 |
* These objects can be opened (typically requires a certain privilege level or
|
|
Packit |
534379 |
* access permissions) and used for management functions like fpgaReconfigreSlot(). */
|
|
Packit |
534379 |
FPGA_DEVICE = 0,
|
|
Packit |
534379 |
/** FPGA_ACCELERATOR objects represent allocatable units for accessing
|
|
Packit |
534379 |
* accelerated functions on the FPGA. They are frequently opened for
|
|
Packit |
534379 |
* interacting via control registers (MMIO), shared memory, or other,
|
|
Packit |
534379 |
* possibly platform-specific functions. */
|
|
Packit |
534379 |
FPGA_ACCELERATOR
|
|
Packit |
534379 |
} fpga_objtype;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
/**
|
|
Packit |
534379 |
* Buffer flags
|
|
Packit |
534379 |
*
|
|
Packit |
534379 |
* These flags can be passed to the fpgaPrepareBuffer() function.
|
|
Packit |
534379 |
*/
|
|
Packit |
534379 |
enum fpga_buffer_flags {
|
|
Packit |
534379 |
FPGA_BUF_PREALLOCATED = (1u << 0), /**< Use existing buffer */
|
|
Packit |
534379 |
FPGA_BUF_QUIET = (1u << 1), /**< Suppress error messages */
|
|
Packit |
534379 |
FPGA_BUF_READ_ONLY = (1u << 2) /**< Buffer is read-only */
|
|
Packit |
534379 |
};
|
|
Packit |
534379 |
|
|
Packit |
534379 |
/**
|
|
Packit |
534379 |
* Open flags
|
|
Packit |
534379 |
*
|
|
Packit |
534379 |
* These flags can be passed to the fpgaOpen() function.
|
|
Packit |
534379 |
*/
|
|
Packit |
534379 |
enum fpga_open_flags {
|
|
Packit |
534379 |
/** Open FPGA resource for shared access */
|
|
Packit |
534379 |
FPGA_OPEN_SHARED = (1u << 0)
|
|
Packit |
534379 |
};
|
|
Packit |
534379 |
|
|
Packit |
534379 |
/**
|
|
Packit |
534379 |
* Reconfiguration flags
|
|
Packit |
534379 |
*
|
|
Packit |
534379 |
* These flags can be passed to the fpgaReconfigureSlot() function.
|
|
Packit |
534379 |
*/
|
|
Packit |
534379 |
enum fpga_reconf_flags {
|
|
Packit |
534379 |
/** Reconfigure the slot without checking if it is in use */
|
|
Packit |
534379 |
FPGA_RECONF_FORCE = (1u << 0)
|
|
Packit |
534379 |
};
|
|
Packit |
534379 |
|
|
Packit |
534379 |
enum fpga_sysobject_flags {
|
|
Packit |
534379 |
FPGA_OBJECT_SYNC = (1u << 0), /**< Synchronize data from driver */
|
|
Packit |
534379 |
FPGA_OBJECT_GLOB = (1u << 1), /**< Treat names as glob expressions */
|
|
Packit |
534379 |
FPGA_OBJECT_RAW =
|
|
Packit |
534379 |
(1u << 2), /**< Read or write object data as raw bytes */
|
|
Packit |
534379 |
FPGA_OBJECT_RECURSE_ONE =
|
|
Packit |
534379 |
(1u
|
|
Packit |
534379 |
<< 3), /**< Create subobjects one level down from containers */
|
|
Packit |
534379 |
FPGA_OBJECT_RECURSE_ALL =
|
|
Packit |
534379 |
(1u
|
|
Packit |
534379 |
<< 4) /**< Create subobjects all levels from from containers */
|
|
Packit |
534379 |
};
|
|
Packit |
534379 |
|
|
Packit |
534379 |
enum fpga_sysobject_type {
|
|
Packit |
534379 |
FPGA_OBJECT_CONTAINER =
|
|
Packit |
534379 |
(1u << 0), /**< Represents a group of objects */
|
|
Packit |
534379 |
FPGA_OBJECT_ATTRIBUTE =
|
|
Packit |
534379 |
(1u << 1) /**< An object with an attribute value that can be
|
|
Packit |
534379 |
read/written */
|
|
Packit |
534379 |
};
|
|
Packit |
534379 |
|
|
Packit |
534379 |
/** fpga metrics types
|
|
Packit |
534379 |
* opae defines power,thermal, performance counter
|
|
Packit |
534379 |
* and afu metric types
|
|
Packit |
534379 |
*/
|
|
Packit |
534379 |
enum fpga_metric_type {
|
|
Packit |
534379 |
FPGA_METRIC_TYPE_POWER, // Metric power
|
|
Packit |
534379 |
FPGA_METRIC_TYPE_THERMAL, // Metric Thermal
|
|
Packit |
534379 |
FPGA_METRIC_TYPE_PERFORMANCE_CTR, // Metric Performance counter
|
|
Packit |
534379 |
FPGA_METRIC_TYPE_AFU, // Metric AFU
|
|
Packit |
534379 |
FPGA_METRIC_TYPE_UNKNOWN // Unknown
|
|
Packit |
534379 |
};
|
|
Packit |
534379 |
|
|
Packit |
534379 |
/** Metrics data type
|
|
Packit |
534379 |
*
|
|
Packit |
534379 |
*
|
|
Packit |
534379 |
*/
|
|
Packit |
534379 |
enum fpga_metric_datatype {
|
|
Packit |
534379 |
FPGA_METRIC_DATATYPE_INT, // Metric datatype integer
|
|
Packit |
534379 |
FPGA_METRIC_DATATYPE_FLOAT, // Metric datatype float
|
|
Packit |
534379 |
FPGA_METRIC_DATATYPE_DOUBLE, // Metric datatype double
|
|
Packit |
534379 |
FPGA_METRIC_DATATYPE_BOOL, // Metric datatype bool
|
|
Packit |
534379 |
FPGA_METRIC_DATATYPE_UNKNOWN // Metric datatype unknown
|
|
Packit |
534379 |
};
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#endif // __FPGA_TYPES_ENUM_H__
|