linux/drivers/net/ethernet/microchip/fdma/fdma_api.h

/* SPDX-License-Identifier: GPL-2.0+ */

#ifndef _FDMA_API_H_
#define _FDMA_API_H_

#include <linux/bits.h>
#include <linux/etherdevice.h>
#include <linux/types.h>

/* This provides a common set of functions and data structures for interacting
 * with the Frame DMA engine on multiple Microchip switchcores.
 *
 * Frame DMA DCB format:
 *
 * +---------------------------+
 * |         Next Ptr          |
 * +---------------------------+
 * |   Reserved  |    Info     |
 * +---------------------------+
 * |         Data0 Ptr         |
 * +---------------------------+
 * |   Reserved  |    Status0  |
 * +---------------------------+
 * |         Data1 Ptr         |
 * +---------------------------+
 * |   Reserved  |    Status1  |
 * +---------------------------+
 * |         Data2 Ptr         |
 * +---------------------------+
 * |   Reserved  |    Status2  |
 * |-------------|-------------|
 * |                           |
 * |                           |
 * |                           |
 * |                           |
 * |                           |
 * |---------------------------|
 * |         Data14 Ptr        |
 * +-------------|-------------+
 * |   Reserved  |    Status14 |
 * +-------------|-------------+
 *
 * The data pointers points to the actual frame data to be received or sent. The
 * addresses of the data pointers can, as of writing, be either a: DMA address,
 * physical address or mapped address.
 *
 */

#define FDMA_DCB_INFO_DATAL(x)
#define FDMA_DCB_INFO_TOKEN
#define FDMA_DCB_INFO_INTR
#define FDMA_DCB_INFO_SW(x)

#define FDMA_DCB_STATUS_BLOCKL(x)
#define FDMA_DCB_STATUS_SOF
#define FDMA_DCB_STATUS_EOF
#define FDMA_DCB_STATUS_INTR
#define FDMA_DCB_STATUS_DONE
#define FDMA_DCB_STATUS_BLOCKO(x)
#define FDMA_DCB_INVALID_DATA

#define FDMA_DB_MAX

struct fdma;

struct fdma_db {};

struct fdma_dcb {};

struct fdma_ops {};

struct fdma {};

/* Advance the DCB index and wrap if required. */
static inline void fdma_dcb_advance(struct fdma *fdma)
{}

/* Advance the DB index. */
static inline void fdma_db_advance(struct fdma *fdma)
{}

/* Reset the db index to zero. */
static inline void fdma_db_reset(struct fdma *fdma)
{}

/* Check if a DCB can be reused in case of multiple DB's per DCB. */
static inline bool fdma_dcb_is_reusable(struct fdma *fdma)
{}

/* Check if the FDMA has marked this DB as done. */
static inline bool fdma_db_is_done(struct fdma_db *db)
{}

/* Get the length of a DB. */
static inline int fdma_db_len_get(struct fdma_db *db)
{}

/* Set the length of a DB. */
static inline void fdma_dcb_len_set(struct fdma_dcb *dcb, u32 len)
{}

/* Get a DB by index. */
static inline struct fdma_db *fdma_db_get(struct fdma *fdma, int dcb_idx,
					  int db_idx)
{}

/* Get the next DB. */
static inline struct fdma_db *fdma_db_next_get(struct fdma *fdma)
{}

/* Get a DCB by index. */
static inline struct fdma_dcb *fdma_dcb_get(struct fdma *fdma, int dcb_idx)
{}

/* Get the next DCB. */
static inline struct fdma_dcb *fdma_dcb_next_get(struct fdma *fdma)
{}

/* Check if the FDMA has frames ready for extraction. */
static inline bool fdma_has_frames(struct fdma *fdma)
{}

/* Get a nextptr by index */
static inline int fdma_nextptr_cb(struct fdma *fdma, int dcb_idx, u64 *nextptr)
{}

/* Get the DMA address of a dataptr, by index. This function is only applicable
 * if the dataptr addresses and DCB's are in contiguous memory and the driver
 * supports XDP.
 */
static inline u64 fdma_dataptr_get_contiguous(struct fdma *fdma, int dcb_idx,
					      int db_idx)
{}

/* Get the virtual address of a dataptr, by index. This function is only
 * applicable if the dataptr addresses and DCB's are in contiguous memory and
 * the driver supports XDP.
 */
static inline void *fdma_dataptr_virt_get_contiguous(struct fdma *fdma,
						     int dcb_idx, int db_idx)
{}

/* Check if this DCB is the last used DCB. */
static inline bool fdma_is_last(struct fdma *fdma, struct fdma_dcb *dcb)
{}

int fdma_dcbs_init(struct fdma *fdma, u64 info, u64 status);
int fdma_db_add(struct fdma *fdma, int dcb_idx, int db_idx, u64 status);
int fdma_dcb_add(struct fdma *fdma, int dcb_idx, u64 info, u64 status);
int __fdma_dcb_add(struct fdma *fdma, int dcb_idx, u64 info, u64 status,
		   int (*dcb_cb)(struct fdma *fdma, int dcb_idx, u64 *nextptr),
		   int (*db_cb)(struct fdma *fdma, int dcb_idx, int db_idx,
				u64 *dataptr));

int fdma_alloc_coherent(struct device *dev, struct fdma *fdma);
int fdma_alloc_phys(struct fdma *fdma);

void fdma_free_coherent(struct device *dev, struct fdma *fdma);
void fdma_free_phys(struct fdma *fdma);

u32 fdma_get_size(struct fdma *fdma);
u32 fdma_get_size_contiguous(struct fdma *fdma);

#endif