|
Packit |
534379 |
// Copyright(c) 2018-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 |
#ifdef HAVE_CONFIG_H
|
|
Packit |
534379 |
#include <config.h>
|
|
Packit |
534379 |
#endif /* HAVE_CONFIG_H */
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#ifndef _GNU_SOURCE
|
|
Packit |
534379 |
#define _GNU_SOURCE
|
|
Packit |
534379 |
#endif // _GNU_SOURCE
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#include <stdlib.h>
|
|
Packit |
534379 |
#include <string.h>
|
|
Packit |
534379 |
#include <errno.h>
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#include <opae/enum.h>
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#include "props.h"
|
|
Packit |
534379 |
|
|
Packit |
534379 |
struct _fpga_properties *opae_properties_create(void)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
struct _fpga_properties *props;
|
|
Packit |
534379 |
pthread_mutexattr_t mattr;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
props = (struct _fpga_properties *)calloc(
|
|
Packit |
534379 |
1, sizeof(struct _fpga_properties));
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (!props)
|
|
Packit |
534379 |
return NULL;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
props->magic = FPGA_PROPERTY_MAGIC;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (pthread_mutexattr_init(&mattr)) {
|
|
Packit |
534379 |
OPAE_ERR("pthread_mutexattr_init() failed");
|
|
Packit |
534379 |
goto out_free;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE)) {
|
|
Packit |
534379 |
OPAE_ERR("pthread_mutexattr_settype() failed");
|
|
Packit |
534379 |
goto out_destroy_attr;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (pthread_mutex_init(&props->lock, &mattr)) {
|
|
Packit |
534379 |
OPAE_ERR("pthread_mutex_init() failed");
|
|
Packit |
534379 |
goto out_destroy_attr;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
pthread_mutexattr_destroy(&mattr);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return props;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
out_destroy_attr:
|
|
Packit |
534379 |
err = pthread_mutexattr_destroy(&mattr);
|
|
Packit |
534379 |
if (err)
|
|
Packit |
534379 |
OPAE_ERR("pthread_mutexattr_destroy() failed: %s",
|
|
Packit |
534379 |
strerror(err));
|
|
Packit |
534379 |
out_free:
|
|
Packit |
534379 |
free(props);
|
|
Packit |
534379 |
return NULL;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaDestroyProperties(fpga_properties *prop)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
struct _fpga_properties *p;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
p = opae_validate_and_lock_properties(*prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_PARENT) &&
|
|
Packit |
534379 |
(p->flags & OPAE_PROPERTIES_FLAG_PARENT_ALLOC)) {
|
|
Packit |
534379 |
// The parent token has a wrapper that we allocated.
|
|
Packit |
534379 |
// Free it.
|
|
Packit |
534379 |
opae_wrapped_token *wrapped_token =
|
|
Packit |
534379 |
opae_validate_wrapped_token(p->parent);
|
|
Packit |
534379 |
if (wrapped_token)
|
|
Packit |
534379 |
opae_destroy_wrapped_token(wrapped_token);
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
p->magic = 0;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
err = pthread_mutex_destroy(&p->lock);
|
|
Packit |
534379 |
if (err)
|
|
Packit |
534379 |
OPAE_ERR("pthread_mutex_destroy() failed: %s", strerror(err));
|
|
Packit |
534379 |
|
|
Packit |
534379 |
free(p);
|
|
Packit |
534379 |
*prop = NULL;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return FPGA_OK;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaCloneProperties(fpga_properties src,
|
|
Packit |
534379 |
fpga_properties *dst)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *clone;
|
|
Packit |
534379 |
pthread_mutex_t save_lock;
|
|
Packit |
534379 |
struct _fpga_properties *p;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(dst);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
p = opae_validate_and_lock_properties(src);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
clone = opae_properties_create();
|
|
Packit |
534379 |
if (!clone) {
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
return FPGA_EXCEPTION;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
save_lock = clone->lock;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
*clone = *p;
|
|
Packit |
534379 |
clone->lock = save_lock;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
*dst = clone;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return FPGA_OK;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaClearProperties(fpga_properties props)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p = opae_validate_and_lock_properties(props);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
p->valid_fields = 0;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return FPGA_OK;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesGetParent(const fpga_properties prop,
|
|
Packit |
534379 |
fpga_token *parent)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(parent);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_PARENT)) {
|
|
Packit |
534379 |
res = fpgaCloneToken(p->parent, parent);
|
|
Packit |
534379 |
if (res != FPGA_OK)
|
|
Packit |
534379 |
OPAE_ERR("cloning token from property");
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_MSG("No parent");
|
|
Packit |
534379 |
res = FPGA_NOT_FOUND;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesSetParent(fpga_properties prop,
|
|
Packit |
534379 |
fpga_token parent)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(parent);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_PARENT) &&
|
|
Packit |
534379 |
(p->flags & OPAE_PROPERTIES_FLAG_PARENT_ALLOC)) {
|
|
Packit |
534379 |
// We have a wrapped parent token that we allocated.
|
|
Packit |
534379 |
// Free it.
|
|
Packit |
534379 |
opae_wrapped_token *wrapped_token =
|
|
Packit |
534379 |
opae_validate_wrapped_token(p->parent);
|
|
Packit |
534379 |
if (wrapped_token)
|
|
Packit |
534379 |
opae_destroy_wrapped_token(wrapped_token);
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
// When explicitly setting a parent token,
|
|
Packit |
534379 |
// the caller assumes responsibility for freeing
|
|
Packit |
534379 |
// that token.
|
|
Packit |
534379 |
p->flags &= ~OPAE_PROPERTIES_FLAG_PARENT_ALLOC;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
p->parent = parent;
|
|
Packit |
534379 |
SET_FIELD_VALID(p, FPGA_PROPERTY_PARENT);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return FPGA_OK;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesGetObjectType(
|
|
Packit |
534379 |
const fpga_properties prop, fpga_objtype *objtype)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(objtype);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_OBJTYPE)) {
|
|
Packit |
534379 |
*objtype = p->objtype;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_MSG("No object type");
|
|
Packit |
534379 |
res = FPGA_NOT_FOUND;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesSetObjectType(fpga_properties prop,
|
|
Packit |
534379 |
fpga_objtype objtype)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
p->objtype = objtype;
|
|
Packit |
534379 |
SET_FIELD_VALID(p, FPGA_PROPERTY_OBJTYPE);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return FPGA_OK;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesGetSegment(const fpga_properties prop,
|
|
Packit |
534379 |
uint16_t *segment)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(segment);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_SEGMENT)) {
|
|
Packit |
534379 |
*segment = p->segment;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_MSG("No segment");
|
|
Packit |
534379 |
res = FPGA_NOT_FOUND;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesSetSegment(fpga_properties prop,
|
|
Packit |
534379 |
uint16_t segment)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
SET_FIELD_VALID(p, FPGA_PROPERTY_SEGMENT);
|
|
Packit |
534379 |
p->segment = segment;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return FPGA_OK;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesGetBus(const fpga_properties prop,
|
|
Packit |
534379 |
uint8_t *bus)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(bus);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_BUS)) {
|
|
Packit |
534379 |
*bus = p->bus;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_MSG("No bus");
|
|
Packit |
534379 |
res = FPGA_NOT_FOUND;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesSetBus(fpga_properties prop,
|
|
Packit |
534379 |
uint8_t bus)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
SET_FIELD_VALID(p, FPGA_PROPERTY_BUS);
|
|
Packit |
534379 |
p->bus = bus;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesGetDevice(const fpga_properties prop,
|
|
Packit |
534379 |
uint8_t *device)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(device);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_DEVICE)) {
|
|
Packit |
534379 |
*device = p->device;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_MSG("No device");
|
|
Packit |
534379 |
res = FPGA_NOT_FOUND;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesSetDevice(fpga_properties prop,
|
|
Packit |
534379 |
uint8_t device)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
SET_FIELD_VALID(p, FPGA_PROPERTY_DEVICE);
|
|
Packit |
534379 |
p->device = device;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesGetFunction(const fpga_properties prop,
|
|
Packit |
534379 |
uint8_t *function)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(function);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_FUNCTION)) {
|
|
Packit |
534379 |
*function = p->function;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_MSG("No function");
|
|
Packit |
534379 |
res = FPGA_NOT_FOUND;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesSetFunction(fpga_properties prop,
|
|
Packit |
534379 |
uint8_t function)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
// PCIe supports 8 functions per device.
|
|
Packit |
534379 |
if (function > 7) {
|
|
Packit |
534379 |
OPAE_MSG("Invalid function number");
|
|
Packit |
534379 |
return FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
SET_FIELD_VALID(p, FPGA_PROPERTY_FUNCTION);
|
|
Packit |
534379 |
p->function = function;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesGetSocketID(const fpga_properties prop,
|
|
Packit |
534379 |
uint8_t *socket_id)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(socket_id);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_SOCKETID)) {
|
|
Packit |
534379 |
*socket_id = p->socket_id;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_MSG("No socket ID");
|
|
Packit |
534379 |
res = FPGA_NOT_FOUND;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesSetSocketID(fpga_properties prop,
|
|
Packit |
534379 |
uint8_t socket_id)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
SET_FIELD_VALID(p, FPGA_PROPERTY_SOCKETID);
|
|
Packit |
534379 |
p->socket_id = socket_id;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesGetDeviceID(const fpga_properties prop,
|
|
Packit |
534379 |
uint16_t *device_id)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(device_id);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_DEVICEID)) {
|
|
Packit |
534379 |
*device_id = p->device_id;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_MSG("No device ID");
|
|
Packit |
534379 |
res = FPGA_NOT_FOUND;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesSetDeviceID(fpga_properties prop,
|
|
Packit |
534379 |
uint16_t device_id)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
SET_FIELD_VALID(p, FPGA_PROPERTY_DEVICEID);
|
|
Packit |
534379 |
p->device_id = device_id;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesGetNumSlots(const fpga_properties prop,
|
|
Packit |
534379 |
uint32_t *num_slots)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(num_slots);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_OBJTYPE)
|
|
Packit |
534379 |
&& FPGA_DEVICE == p->objtype) {
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_NUM_SLOTS)) {
|
|
Packit |
534379 |
*num_slots = p->u.fpga.num_slots;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_MSG("No number of slots");
|
|
Packit |
534379 |
res = FPGA_NOT_FOUND;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_ERR(
|
|
Packit |
534379 |
"Attempting to get num_slots from invalid object type: %d",
|
|
Packit |
534379 |
p->objtype);
|
|
Packit |
534379 |
res = FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesSetNumSlots(fpga_properties prop,
|
|
Packit |
534379 |
uint32_t num_slots)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_OBJTYPE)
|
|
Packit |
534379 |
&& FPGA_DEVICE == p->objtype) {
|
|
Packit |
534379 |
SET_FIELD_VALID(p, FPGA_PROPERTY_NUM_SLOTS);
|
|
Packit |
534379 |
p->u.fpga.num_slots = num_slots;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_ERR(
|
|
Packit |
534379 |
"Attempting to set num slots on invalid object type: %d",
|
|
Packit |
534379 |
p->objtype);
|
|
Packit |
534379 |
res = FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesGetBBSID(const fpga_properties prop,
|
|
Packit |
534379 |
uint64_t *bbs_id)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(bbs_id);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_OBJTYPE)
|
|
Packit |
534379 |
&& FPGA_DEVICE == p->objtype) {
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_BBSID)) {
|
|
Packit |
534379 |
*bbs_id = p->u.fpga.bbs_id;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_MSG("No BBS ID");
|
|
Packit |
534379 |
res = FPGA_NOT_FOUND;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_ERR(
|
|
Packit |
534379 |
"Attempting to get BBS ID from invalid object type: %d",
|
|
Packit |
534379 |
p->objtype);
|
|
Packit |
534379 |
res = FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesSetBBSID(fpga_properties prop,
|
|
Packit |
534379 |
uint64_t bbs_id)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_OBJTYPE)
|
|
Packit |
534379 |
&& FPGA_DEVICE == p->objtype) {
|
|
Packit |
534379 |
SET_FIELD_VALID(p, FPGA_PROPERTY_BBSID);
|
|
Packit |
534379 |
p->u.fpga.bbs_id = bbs_id;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_ERR("Attempting to set BBS ID on invalid object type: %d",
|
|
Packit |
534379 |
p->objtype);
|
|
Packit |
534379 |
res = FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesGetBBSVersion(const fpga_properties prop,
|
|
Packit |
534379 |
fpga_version *bbs_version)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(bbs_version);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_OBJTYPE)
|
|
Packit |
534379 |
&& FPGA_DEVICE == p->objtype) {
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_BBSVERSION)) {
|
|
Packit |
534379 |
*bbs_version = p->u.fpga.bbs_version;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_MSG("No BBS version");
|
|
Packit |
534379 |
res = FPGA_NOT_FOUND;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_ERR(
|
|
Packit |
534379 |
"Attempting to get BBS version from invalid object type: %d",
|
|
Packit |
534379 |
p->objtype);
|
|
Packit |
534379 |
res = FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesSetBBSVersion(fpga_properties prop,
|
|
Packit |
534379 |
fpga_version bbs_version)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_OBJTYPE)
|
|
Packit |
534379 |
&& FPGA_DEVICE == p->objtype) {
|
|
Packit |
534379 |
SET_FIELD_VALID(p, FPGA_PROPERTY_BBSVERSION);
|
|
Packit |
534379 |
p->u.fpga.bbs_version = bbs_version;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_ERR(
|
|
Packit |
534379 |
"Attempting to set BBS version on invalid object type: %d",
|
|
Packit |
534379 |
p->objtype);
|
|
Packit |
534379 |
res = FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesGetVendorID(const fpga_properties prop,
|
|
Packit |
534379 |
uint16_t *vendor_id)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(vendor_id);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_VENDORID)) {
|
|
Packit |
534379 |
*vendor_id = p->vendor_id;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_MSG("No vendor ID");
|
|
Packit |
534379 |
res = FPGA_NOT_FOUND;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesSetVendorID(fpga_properties prop,
|
|
Packit |
534379 |
uint16_t vendor_id)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
SET_FIELD_VALID(p, FPGA_PROPERTY_VENDORID);
|
|
Packit |
534379 |
p->vendor_id = vendor_id;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesGetModel(const fpga_properties prop,
|
|
Packit |
534379 |
char *model)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
UNUSED_PARAM(prop);
|
|
Packit |
534379 |
UNUSED_PARAM(model);
|
|
Packit |
534379 |
OPAE_MSG("Model not supported");
|
|
Packit |
534379 |
return FPGA_NOT_SUPPORTED;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesSetModel(fpga_properties prop,
|
|
Packit |
534379 |
char *model)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
UNUSED_PARAM(prop);
|
|
Packit |
534379 |
UNUSED_PARAM(model);
|
|
Packit |
534379 |
OPAE_MSG("Model not supported");
|
|
Packit |
534379 |
return FPGA_NOT_SUPPORTED;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesGetLocalMemorySize(
|
|
Packit |
534379 |
const fpga_properties prop, uint64_t *local_memory_size)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
UNUSED_PARAM(prop);
|
|
Packit |
534379 |
UNUSED_PARAM(local_memory_size);
|
|
Packit |
534379 |
OPAE_MSG("Local memory not supported");
|
|
Packit |
534379 |
return FPGA_NOT_SUPPORTED;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesSetLocalMemorySize(fpga_properties prop,
|
|
Packit |
534379 |
uint64_t local_memory_size)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
UNUSED_PARAM(prop);
|
|
Packit |
534379 |
UNUSED_PARAM(local_memory_size);
|
|
Packit |
534379 |
OPAE_MSG("Local memory not supported");
|
|
Packit |
534379 |
return FPGA_NOT_SUPPORTED;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesGetCapabilities(
|
|
Packit |
534379 |
const fpga_properties prop, uint64_t *capabilities)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
UNUSED_PARAM(prop);
|
|
Packit |
534379 |
UNUSED_PARAM(capabilities);
|
|
Packit |
534379 |
OPAE_MSG("Capabilities not supported");
|
|
Packit |
534379 |
return FPGA_NOT_SUPPORTED;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesSetCapabilities(fpga_properties prop,
|
|
Packit |
534379 |
uint64_t capabilities)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
UNUSED_PARAM(prop);
|
|
Packit |
534379 |
UNUSED_PARAM(capabilities);
|
|
Packit |
534379 |
OPAE_MSG("Capabilities not supported");
|
|
Packit |
534379 |
return FPGA_NOT_SUPPORTED;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesGetGUID(const fpga_properties prop,
|
|
Packit |
534379 |
fpga_guid *guid)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(guid);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_GUID)) {
|
|
Packit |
534379 |
memcpy(*guid, p->guid, sizeof(fpga_guid));
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_MSG("No GUID");
|
|
Packit |
534379 |
res = FPGA_NOT_FOUND;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesSetGUID(fpga_properties prop,
|
|
Packit |
534379 |
fpga_guid guid)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
SET_FIELD_VALID(p, FPGA_PROPERTY_GUID);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
memcpy(p->guid, guid, sizeof(fpga_guid));
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesGetNumMMIO(const fpga_properties prop,
|
|
Packit |
534379 |
uint32_t *mmio_spaces)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(mmio_spaces);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_OBJTYPE)
|
|
Packit |
534379 |
&& FPGA_ACCELERATOR == p->objtype) {
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_NUM_MMIO)) {
|
|
Packit |
534379 |
*mmio_spaces = p->u.accelerator.num_mmio;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_MSG("No MMIO spaces");
|
|
Packit |
534379 |
res = FPGA_NOT_FOUND;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_ERR(
|
|
Packit |
534379 |
"Attempting to get number of MMIO spaces from invalid object type: %d",
|
|
Packit |
534379 |
p->objtype);
|
|
Packit |
534379 |
res = FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesSetNumMMIO(fpga_properties prop,
|
|
Packit |
534379 |
uint32_t mmio_spaces)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_OBJTYPE)
|
|
Packit |
534379 |
&& FPGA_ACCELERATOR == p->objtype) {
|
|
Packit |
534379 |
SET_FIELD_VALID(p, FPGA_PROPERTY_NUM_MMIO);
|
|
Packit |
534379 |
p->u.accelerator.num_mmio = mmio_spaces;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_ERR(
|
|
Packit |
534379 |
"Attempting to set number of MMIO spaces on invalid object type: %d",
|
|
Packit |
534379 |
p->objtype);
|
|
Packit |
534379 |
res = FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesGetNumInterrupts(
|
|
Packit |
534379 |
const fpga_properties prop, uint32_t *num_interrupts)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(num_interrupts);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_OBJTYPE)
|
|
Packit |
534379 |
&& FPGA_ACCELERATOR == p->objtype) {
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_NUM_INTERRUPTS)) {
|
|
Packit |
534379 |
*num_interrupts = p->u.accelerator.num_interrupts;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_MSG("No interrupts");
|
|
Packit |
534379 |
res = FPGA_NOT_FOUND;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_ERR(
|
|
Packit |
534379 |
"Attempting to get number of interrupts from invalid object type: %d",
|
|
Packit |
534379 |
p->objtype);
|
|
Packit |
534379 |
res = FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesSetNumInterrupts(fpga_properties prop,
|
|
Packit |
534379 |
uint32_t num_interrupts)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_OBJTYPE)
|
|
Packit |
534379 |
&& FPGA_ACCELERATOR == p->objtype) {
|
|
Packit |
534379 |
SET_FIELD_VALID(p, FPGA_PROPERTY_NUM_INTERRUPTS);
|
|
Packit |
534379 |
p->u.accelerator.num_interrupts = num_interrupts;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_ERR(
|
|
Packit |
534379 |
"Attempting to set number of interrupts on invalid object type: %d",
|
|
Packit |
534379 |
p->objtype);
|
|
Packit |
534379 |
res = FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesGetAcceleratorState(
|
|
Packit |
534379 |
const fpga_properties prop, fpga_accelerator_state *state)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(state);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_OBJTYPE)
|
|
Packit |
534379 |
&& FPGA_ACCELERATOR == p->objtype) {
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_ACCELERATOR_STATE)) {
|
|
Packit |
534379 |
*state = p->u.accelerator.state;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_MSG("No accelerator state");
|
|
Packit |
534379 |
res = FPGA_NOT_FOUND;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_ERR("Attempting to get state from invalid object type: %d",
|
|
Packit |
534379 |
p->objtype);
|
|
Packit |
534379 |
res = FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesSetAcceleratorState(
|
|
Packit |
534379 |
fpga_properties prop, fpga_accelerator_state state)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_OBJTYPE)
|
|
Packit |
534379 |
&& FPGA_ACCELERATOR == p->objtype) {
|
|
Packit |
534379 |
SET_FIELD_VALID(p, FPGA_PROPERTY_ACCELERATOR_STATE);
|
|
Packit |
534379 |
p->u.accelerator.state = state;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_ERR("Attempting to set state from invalid object type: %d",
|
|
Packit |
534379 |
p->objtype);
|
|
Packit |
534379 |
res = FPGA_INVALID_PARAM;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesGetObjectID(const fpga_properties prop,
|
|
Packit |
534379 |
uint64_t *object_id)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(object_id);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_OBJECTID)) {
|
|
Packit |
534379 |
*object_id = p->object_id;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_MSG("No object ID");
|
|
Packit |
534379 |
res = FPGA_NOT_FOUND;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesSetObjectID(fpga_properties prop,
|
|
Packit |
534379 |
uint64_t object_id)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
SET_FIELD_VALID(p, FPGA_PROPERTY_OBJECTID);
|
|
Packit |
534379 |
p->object_id = object_id;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesGetNumErrors(const fpga_properties prop,
|
|
Packit |
534379 |
uint32_t *num_errors)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(num_errors);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
if (FIELD_VALID(p, FPGA_PROPERTY_NUM_ERRORS)) {
|
|
Packit |
534379 |
*num_errors = p->num_errors;
|
|
Packit |
534379 |
} else {
|
|
Packit |
534379 |
OPAE_MSG("No num errors");
|
|
Packit |
534379 |
res = FPGA_NOT_FOUND;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
fpga_result __OPAE_API__ fpgaPropertiesSetNumErrors(const fpga_properties prop,
|
|
Packit |
534379 |
uint32_t num_errors)
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
fpga_result res = FPGA_OK;
|
|
Packit |
534379 |
int err;
|
|
Packit |
534379 |
struct _fpga_properties *p = opae_validate_and_lock_properties(prop);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
ASSERT_NOT_NULL(p);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
SET_FIELD_VALID(p, FPGA_PROPERTY_NUM_ERRORS);
|
|
Packit |
534379 |
p->num_errors = num_errors;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
opae_mutex_unlock(err, &p->lock);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
return res;
|
|
Packit |
534379 |
}
|