linux/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_resource.c

// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
/* Copyright (C) 2015-2018 Netronome Systems, Inc. */

/*
 * nfp_resource.c
 * Author: Jakub Kicinski <[email protected]>
 *         Jason McMullan <[email protected]>
 */
#include <linux/delay.h>
#include <linux/kernel.h>
#include <linux/slab.h>

#include "crc32.h"
#include "nfp.h"
#include "nfp_cpp.h"
#include "nfp6000/nfp6000.h"

#define NFP_RESOURCE_TBL_TARGET
#define NFP_RESOURCE_TBL_BASE

/* NFP Resource Table self-identifier */
#define NFP_RESOURCE_TBL_NAME
#define NFP_RESOURCE_TBL_KEY

#define NFP_RESOURCE_ENTRY_NAME_SZ

/**
 * struct nfp_resource_entry - Resource table entry
 * @mutex:	NFP CPP Lock
 * @mutex.owner:	NFP CPP Lock, interface owner
 * @mutex.key:		NFP CPP Lock, posix_crc32(name, 8)
 * @region:	Memory region descriptor
 * @region.name:	ASCII, zero padded name
 * @region.reserved:	padding
 * @region.cpp_action:	CPP Action
 * @region.cpp_token:	CPP Token
 * @region.cpp_target:	CPP Target ID
 * @region.page_offset:	256-byte page offset into target's CPP address
 * @region.page_size:	size, in 256-byte pages
 */
struct nfp_resource_entry {};

#define NFP_RESOURCE_TBL_SIZE
#define NFP_RESOURCE_TBL_ENTRIES

struct nfp_resource {};

static int nfp_cpp_resource_find(struct nfp_cpp *cpp, struct nfp_resource *res)
{}

static int
nfp_resource_try_acquire(struct nfp_cpp *cpp, struct nfp_resource *res,
			 struct nfp_cpp_mutex *dev_mutex)
{}

/**
 * nfp_resource_acquire() - Acquire a resource handle
 * @cpp:	NFP CPP handle
 * @name:	Name of the resource
 *
 * NOTE: This function locks the acquired resource
 *
 * Return: NFP Resource handle, or ERR_PTR()
 */
struct nfp_resource *
nfp_resource_acquire(struct nfp_cpp *cpp, const char *name)
{}

/**
 * nfp_resource_release() - Release a NFP Resource handle
 * @res:	NFP Resource handle
 *
 * NOTE: This function implictly unlocks the resource handle
 */
void nfp_resource_release(struct nfp_resource *res)
{}

/**
 * nfp_resource_wait() - Wait for resource to appear
 * @cpp:	NFP CPP handle
 * @name:	Name of the resource
 * @secs:	Number of seconds to wait
 *
 * Wait for resource to appear in the resource table, grab and release
 * its lock.  The wait is jiffies-based, don't expect fine granularity.
 *
 * Return: 0 on success, errno otherwise.
 */
int nfp_resource_wait(struct nfp_cpp *cpp, const char *name, unsigned int secs)
{}

/**
 * nfp_resource_cpp_id() - Return the cpp_id of a resource handle
 * @res:	NFP Resource handle
 *
 * Return: NFP CPP ID
 */
u32 nfp_resource_cpp_id(struct nfp_resource *res)
{}

/**
 * nfp_resource_name() - Return the name of a resource handle
 * @res:	NFP Resource handle
 *
 * Return: const char pointer to the name of the resource
 */
const char *nfp_resource_name(struct nfp_resource *res)
{}

/**
 * nfp_resource_address() - Return the address of a resource handle
 * @res:	NFP Resource handle
 *
 * Return: Address of the resource
 */
u64 nfp_resource_address(struct nfp_resource *res)
{}

/**
 * nfp_resource_size() - Return the size in bytes of a resource handle
 * @res:	NFP Resource handle
 *
 * Return: Size of the resource in bytes
 */
u64 nfp_resource_size(struct nfp_resource *res)
{}

/**
 * nfp_resource_table_init() - Run initial checks on the resource table
 * @cpp:	NFP CPP handle
 *
 * Start-of-day init procedure for resource table.  Must be called before
 * any local resource table users may exist.
 *
 * Return: 0 on success, -errno on failure
 */
int nfp_resource_table_init(struct nfp_cpp *cpp)
{}