|
Packit |
534379 |
// Copyright(c) 2017-2020, 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 |
#ifndef __FPGA_SYSFS_INT_H__
|
|
Packit |
534379 |
#define __FPGA_SYSFS_INT_H__
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#include <opae/types.h>
|
|
Packit |
534379 |
#include <stdint.h>
|
|
Packit |
534379 |
#include <unistd.h>
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#include "types_int.h"
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#define SYSFS_PATH_MAX 256
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#define FPGA_SYSFS_CLASS_PATH_INTEL "/sys/class/fpga"
|
|
Packit |
534379 |
#define FPGA_SYSFS_CLASS_PATH_DFL "/sys/class/fpga_region"
|
|
Packit |
534379 |
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#ifdef __cplusplus
|
|
Packit |
534379 |
extern "C" {
|
|
Packit |
534379 |
#endif
|
|
Packit |
534379 |
|
|
Packit |
534379 |
|
|
Packit |
534379 |
struct _sysfs_fpga_device;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
typedef struct _sysfs_fpga_region {
|
|
Packit |
534379 |
struct _sysfs_fpga_device *device;
|
|
Packit |
534379 |
char sysfs_path[SYSFS_PATH_MAX];
|
|
Packit |
534379 |
char sysfs_name[SYSFS_PATH_MAX];
|
|
Packit |
534379 |
fpga_objtype type;
|
|
Packit |
534379 |
int number;
|
|
Packit |
534379 |
} sysfs_fpga_region;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#define SYSFS_MAX_RESOURCES 4
|
|
Packit |
534379 |
typedef struct _sysfs_fpga_device {
|
|
Packit |
534379 |
char sysfs_path[SYSFS_PATH_MAX];
|
|
Packit |
534379 |
char sysfs_name[SYSFS_PATH_MAX];
|
|
Packit |
534379 |
int number;
|
|
Packit |
534379 |
sysfs_fpga_region *fme;
|
|
Packit |
534379 |
sysfs_fpga_region *port;
|
|
Packit |
534379 |
uint32_t segment;
|
|
Packit |
534379 |
uint8_t bus;
|
|
Packit |
534379 |
uint8_t device;
|
|
Packit |
534379 |
uint8_t function;
|
|
Packit |
534379 |
uint32_t device_id;
|
|
Packit |
534379 |
uint32_t vendor_id;
|
|
Packit |
534379 |
} sysfs_fpga_device;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
int sysfs_initialize(void);
|
|
Packit |
534379 |
int sysfs_finalize(void);
|
|
Packit |
534379 |
int sysfs_device_count(void);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
typedef fpga_result (*device_cb)(const sysfs_fpga_device *device, void *context);
|
|
Packit |
534379 |
fpga_result sysfs_foreach_device(device_cb cb, void *context);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
const sysfs_fpga_device *sysfs_get_device(size_t num);
|
|
Packit |
534379 |
int sysfs_parse_attribute64(const char *root, const char *attr_path, uint64_t *value);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result sysfs_get_fme_pr_interface_id(const char *sysfs_res_path, fpga_guid guid);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result sysfs_get_guid(fpga_token token, const char *sysfspath, fpga_guid guid);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result sysfs_get_fme_path(const char *rpath, char *fpath);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result sysfs_path_is_valid(const char *root, const char *attr_path);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
/**
|
|
Packit |
534379 |
* @brief Get BBS interface id
|
|
Packit |
534379 |
*
|
|
Packit |
534379 |
* @param handle
|
|
Packit |
534379 |
* @parm Interface id low pointer
|
|
Packit |
534379 |
* @parm Interface id high pointer
|
|
Packit |
534379 |
*
|
|
Packit |
534379 |
* @return
|
|
Packit |
534379 |
*/
|
|
Packit |
534379 |
fpga_result sysfs_get_interface_id(fpga_token token, fpga_guid guid);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
/*
|
|
Packit |
534379 |
* sysfs utility functions.
|
|
Packit |
534379 |
*/
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result opae_glob_path(char *path, size_t len);
|
|
Packit |
534379 |
fpga_result sysfs_sbdf_from_path(const char *sysfspath, int *s, int *b, int *d, int *f);
|
|
Packit |
534379 |
fpga_result sysfs_read_int(const char *path, int *i);
|
|
Packit |
534379 |
fpga_result sysfs_read_u32(const char *path, uint32_t *u);
|
|
Packit |
534379 |
fpga_result sysfs_read_u32_pair(const char *path, uint32_t *u1, uint32_t *u2,
|
|
Packit |
534379 |
char sep);
|
|
Packit |
534379 |
fpga_result sysfs_read_u64(const char *path, uint64_t *u);
|
|
Packit |
534379 |
fpga_result sysfs_write_u64(const char *path, uint64_t u);
|
|
Packit |
534379 |
fpga_result sysfs_read_guid(const char *path, fpga_guid guid);
|
|
Packit |
534379 |
fpga_result sysfs_get_socket_id(int dev, int subdev, uint8_t *socket_id);
|
|
Packit |
534379 |
fpga_result sysfs_get_afu_id(int dev, int subdev, fpga_guid guid);
|
|
Packit |
534379 |
fpga_result sysfs_get_pr_id(int dev, int subdev, fpga_guid guid);
|
|
Packit |
534379 |
fpga_result sysfs_get_slots(int dev, int subdev, uint32_t *slots);
|
|
Packit |
534379 |
fpga_result sysfs_get_bitstream_id(int dev, int subdev, uint64_t *id);
|
|
Packit |
534379 |
fpga_result get_port_sysfs(fpga_handle handle, char *sysfs_port);
|
|
Packit |
534379 |
enum fpga_hw_type opae_id_to_hw_type(uint16_t vendor_id, uint16_t device_id);
|
|
Packit |
534379 |
fpga_result get_fpga_hw_type(fpga_handle handle, enum fpga_hw_type *hw_type);
|
|
Packit |
534379 |
fpga_result sysfs_deviceid_from_path(const char *sysfspath,
|
|
Packit |
534379 |
uint64_t *deviceid);
|
|
Packit |
534379 |
fpga_result sysfs_objectid_from_path(const char *sysfspath,
|
|
Packit |
534379 |
uint64_t *object_id);
|
|
Packit |
534379 |
ssize_t eintr_read(int fd, void *buf, size_t count);
|
|
Packit |
534379 |
ssize_t eintr_write(int fd, void *buf, size_t count);
|
|
Packit |
534379 |
fpga_result cat_token_sysfs_path(char *dest, fpga_token token,
|
|
Packit |
534379 |
const char *path);
|
|
Packit |
534379 |
fpga_result cat_sysfs_path(char *dest, const char *path);
|
|
Packit |
534379 |
fpga_result cat_handle_sysfs_path(char *dest, fpga_handle handle,
|
|
Packit |
534379 |
const char *path);
|
|
Packit |
534379 |
struct _fpga_object *alloc_fpga_object(const char *sysfspath, const char *name);
|
|
Packit |
534379 |
fpga_result destroy_fpga_object(struct _fpga_object *obj);
|
|
Packit |
534379 |
fpga_result sync_object(fpga_object object);
|
|
Packit |
534379 |
fpga_result make_sysfs_group(char *sysfspath, const char *name,
|
|
Packit |
534379 |
fpga_object *object, int flags, fpga_handle handle);
|
|
Packit |
534379 |
fpga_result make_sysfs_object(char *sysfspath, const char *name,
|
|
Packit |
534379 |
fpga_object *object, int flags, fpga_handle handle);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result sysfs_write_u64_decimal(const char *path, uint64_t u);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result sysfs_get_port_error_path(fpga_handle handle, char *sysfs_port_error);
|
|
Packit |
534379 |
fpga_result sysfs_get_port_error_clear_path(fpga_handle handle, char *sysfs_port_error_clear);
|
|
Packit |
534379 |
fpga_result sysfs_get_fme_pwr_path(fpga_token token, char *sysfs_pwr);
|
|
Packit |
534379 |
fpga_result sysfs_get_fme_temp_path(fpga_token token, char *sysfs_temp);
|
|
Packit |
534379 |
fpga_result sysfs_get_fme_perf_path(fpga_token token, char *sysfs_perf);
|
|
Packit |
534379 |
fpga_result sysfs_get_bmc_path(fpga_token token, char *sysfs_bmc);
|
|
Packit |
534379 |
fpga_result sysfs_get_max10_path(fpga_token token, char *sysfs_max10);
|
|
Packit |
534379 |
fpga_result check_sysfs_path_is_valid(const char *sysfs_path);
|
|
Packit |
534379 |
#ifdef __cplusplus
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
#endif
|
|
Packit |
534379 |
#endif // ___FPGA_SYSFS_INT_H__
|