GK SDK 源码库: XMIPCLinuxV100R005C00SPC030 (kernel/tools/open_source excluded)

This commit is contained in:
lai
2026-09-06 03:52:57 +08:00
commit b1928b41c0
21813 changed files with 4413081 additions and 0 deletions
@@ -0,0 +1,120 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright (C) 2014 Freescale Semiconductor
*/
#ifndef __FSL_DPAA_FD_H
#define __FSL_DPAA_FD_H
/* Place-holder for FDs, we represent it via the simplest form that we need for
* now. Different overlays may be needed to support different options, etc. (It
* is impractical to define One True Struct, because the resulting encoding
* routines (lots of read-modify-writes) would be worst-case performance whether
* or not circumstances required them.) */
struct dpaa_fd {
union {
u32 words[8];
struct dpaa_fd_simple {
u32 addr_lo;
u32 addr_hi;
u32 len;
/* offset in the MS 16 bits, BPID in the LS 16 bits */
u32 bpid_offset;
u32 frc; /* frame context */
/* "err", "va", "cbmt", "asal", [...] */
u32 ctrl;
/* flow context */
u32 flc_lo;
u32 flc_hi;
} simple;
};
};
enum dpaa_fd_format {
dpaa_fd_single = 0,
dpaa_fd_list,
dpaa_fd_sg
};
static inline u64 ldpaa_fd_get_addr(const struct dpaa_fd *fd)
{
return (u64)((((uint64_t)fd->simple.addr_hi) << 32)
+ fd->simple.addr_lo);
}
static inline void ldpaa_fd_set_addr(struct dpaa_fd *fd, u64 addr)
{
fd->simple.addr_hi = upper_32_bits(addr);
fd->simple.addr_lo = lower_32_bits(addr);
}
static inline u32 ldpaa_fd_get_len(const struct dpaa_fd *fd)
{
return fd->simple.len;
}
static inline void ldpaa_fd_set_len(struct dpaa_fd *fd, u32 len)
{
fd->simple.len = len;
}
static inline uint16_t ldpaa_fd_get_offset(const struct dpaa_fd *fd)
{
return (uint16_t)(fd->simple.bpid_offset >> 16) & 0x0FFF;
}
static inline void ldpaa_fd_set_offset(struct dpaa_fd *fd, uint16_t offset)
{
fd->simple.bpid_offset &= 0xF000FFFF;
fd->simple.bpid_offset |= (u32)offset << 16;
}
static inline uint16_t ldpaa_fd_get_bpid(const struct dpaa_fd *fd)
{
return (uint16_t)(fd->simple.bpid_offset & 0xFFFF);
}
static inline void ldpaa_fd_set_bpid(struct dpaa_fd *fd, uint16_t bpid)
{
fd->simple.bpid_offset &= 0xFFFF0000;
fd->simple.bpid_offset |= (u32)bpid;
}
/* When frames are dequeued, the FDs show up inside "dequeue" result structures
* (if at all, not all dequeue results contain valid FDs). This structure type
* is intentionally defined without internal detail, and the only reason it
* isn't declared opaquely (without size) is to allow the user to provide
* suitably-sized (and aligned) memory for these entries. */
struct ldpaa_dq {
uint32_t dont_manipulate_directly[16];
};
/* Parsing frame dequeue results */
#define LDPAA_DQ_STAT_FQEMPTY 0x80
#define LDPAA_DQ_STAT_HELDACTIVE 0x40
#define LDPAA_DQ_STAT_FORCEELIGIBLE 0x20
#define LDPAA_DQ_STAT_VALIDFRAME 0x10
#define LDPAA_DQ_STAT_ODPVALID 0x04
#define LDPAA_DQ_STAT_VOLATILE 0x02
#define LDPAA_DQ_STAT_EXPIRED 0x01
uint32_t ldpaa_dq_flags(const struct ldpaa_dq *);
static inline int ldpaa_dq_is_pull(const struct ldpaa_dq *dq)
{
return (int)(ldpaa_dq_flags(dq) & LDPAA_DQ_STAT_VOLATILE);
}
static inline int ldpaa_dq_is_pull_complete(
const struct ldpaa_dq *dq)
{
return (int)(ldpaa_dq_flags(dq) & LDPAA_DQ_STAT_EXPIRED);
}
/* seqnum/odpid are valid only if VALIDFRAME and ODPVALID flags are TRUE */
uint16_t ldpaa_dq_seqnum(const struct ldpaa_dq *);
uint16_t ldpaa_dq_odpid(const struct ldpaa_dq *);
uint32_t ldpaa_dq_fqid(const struct ldpaa_dq *);
uint32_t ldpaa_dq_byte_count(const struct ldpaa_dq *);
uint32_t ldpaa_dq_frame_count(const struct ldpaa_dq *);
uint32_t ldpaa_dq_fqd_ctx_hi(const struct ldpaa_dq *);
uint32_t ldpaa_dq_fqd_ctx_lo(const struct ldpaa_dq *);
/* get the Frame Descriptor */
const struct dpaa_fd *ldpaa_dq_fd(const struct ldpaa_dq *);
#endif /* __FSL_DPAA_FD_H */
@@ -0,0 +1,229 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Freescale Layerscape MC I/O wrapper
*
* Copyright 2013-2016 Freescale Semiconductor, Inc.
* Copyright 2017 NXP
*/
/*!
* @file fsl_dpbp.h
* @brief Data Path Buffer Pool API
*/
#ifndef __FSL_DPBP_H
#define __FSL_DPBP_H
/* DPBP Version */
#define DPBP_VER_MAJOR 3
#define DPBP_VER_MINOR 3
/* Command IDs */
#define DPBP_CMDID_CLOSE 0x8001
#define DPBP_CMDID_OPEN 0x8041
#define DPBP_CMDID_CREATE 0x9041
#define DPBP_CMDID_DESTROY 0x9841
#define DPBP_CMDID_GET_API_VERSION 0xa041
#define DPBP_CMDID_ENABLE 0x0021
#define DPBP_CMDID_DISABLE 0x0031
#define DPBP_CMDID_GET_ATTR 0x0041
#define DPBP_CMDID_RESET 0x0051
#define DPBP_CMDID_IS_ENABLED 0x0061
/* cmd, param, offset, width, type, arg_name */
#define DPBP_CMD_OPEN(cmd, dpbp_id) \
MC_CMD_OP(cmd, 0, 0, 32, int, dpbp_id)
/* cmd, param, offset, width, type, arg_name */
#define DPBP_RSP_GET_ATTRIBUTES(cmd, attr) \
do { \
MC_RSP_OP(cmd, 0, 16, 16, uint16_t, attr->bpid); \
MC_RSP_OP(cmd, 0, 32, 32, int, attr->id);\
} while (0)
/* Data Path Buffer Pool API
* Contains initialization APIs and runtime control APIs for DPBP
*/
struct fsl_mc_io;
/**
* dpbp_open() - Open a control session for the specified object.
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @dpbp_id: DPBP unique ID
* @token: Returned token; use in subsequent API calls
*
* This function can be used to open a control session for an
* already created object; an object may have been declared in
* the DPL or by calling the dpbp_create function.
* This function returns a unique authentication token,
* associated with the specific object ID and the specific MC
* portal; this token must be used in all subsequent commands for
* this specific object
*
* Return: '0' on Success; Error code otherwise.
*/
int dpbp_open(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
int dpbp_id,
uint16_t *token);
/**
* dpbp_close() - Close the control session of the object
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPBP object
*
* After this function is called, no further operations are
* allowed on the object without opening a new control session.
*
* Return: '0' on Success; Error code otherwise.
*/
int dpbp_close(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token);
/**
* struct dpbp_cfg - Structure representing DPBP configuration
* @options: place holder
*/
struct dpbp_cfg {
uint32_t options;
};
/**
* dpbp_create() - Create the DPBP object.
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @cfg: Configuration structure
* @token: Returned token; use in subsequent API calls
*
* Create the DPBP object, allocate required resources and
* perform required initialization.
*
* The object can be created either by declaring it in the
* DPL file, or by calling this function.
* This function returns a unique authentication token,
* associated with the specific object ID and the specific MC
* portal; this token must be used in all subsequent calls to
* this specific object. For objects that are created using the
* DPL file, call dpbp_open function to get an authentication
* token first.
*
* Return: '0' on Success; Error code otherwise.
*/
int dpbp_create(struct fsl_mc_io *mc_io,
uint16_t dprc_token,
uint32_t cmd_flags,
const struct dpbp_cfg *cfg,
uint32_t *obj_id);
/**
* dpbp_destroy() - Destroy the DPBP object and release all its resources.
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPBP object
*
* Return: '0' on Success; error code otherwise.
*/
int dpbp_destroy(struct fsl_mc_io *mc_io,
uint16_t dprc_token,
uint32_t cmd_flags,
uint32_t obj_id);
/**
* dpbp_enable() - Enable the DPBP.
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPBP object
*
* Return: '0' on Success; Error code otherwise.
*/
int dpbp_enable(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token);
/**
* dpbp_disable() - Disable the DPBP.
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPBP object
*
* Return: '0' on Success; Error code otherwise.
*/
int dpbp_disable(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token);
/**
* dpbp_is_enabled() - Check if the DPBP is enabled.
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPBP object
* @en: Returns '1' if object is enabled; '0' otherwise
*
* Return: '0' on Success; Error code otherwise.
*/
int dpbp_is_enabled(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
int *en);
/**
* dpbp_reset() - Reset the DPBP, returns the object to initial state.
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPBP object
*
* Return: '0' on Success; Error code otherwise.
*/
int dpbp_reset(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token);
/**
* struct dpbp_attr - Structure representing DPBP attributes
* @id: DPBP object ID
* @version: DPBP version
* @bpid: Hardware buffer pool ID; should be used as an argument in
* acquire/release operations on buffers
*/
struct dpbp_attr {
uint32_t id;
uint16_t bpid;
};
/**
* dpbp_get_attributes - Retrieve DPBP attributes.
*
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPBP object
* @attr: Returned object's attributes
*
* Return: '0' on Success; Error code otherwise.
*/
int dpbp_get_attributes(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
struct dpbp_attr *attr);
/**
* dpbp_get_api_version - Retrieve DPBP Major and Minor version info.
*
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @major_ver: DPBP major version
* @minor_ver: DPBP minor version
*
* Return: '0' on Success; Error code otherwise.
*/
int dpbp_get_api_version(struct fsl_mc_io *mc_io,
u32 cmd_flags,
u16 *major_ver,
u16 *minor_ver);
/** @} */
#endif /* __FSL_DPBP_H */
@@ -0,0 +1,243 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright 2013-2016 Freescale Semiconductor, Inc.
* Copyright 2017 NXP
*/
#ifndef _FSL_DPIO_H
#define _FSL_DPIO_H
/* DPIO Version */
#define DPIO_VER_MAJOR 4
#define DPIO_VER_MINOR 2
/* Command IDs */
#define DPIO_CMDID_CLOSE 0x8001
#define DPIO_CMDID_OPEN 0x8031
#define DPIO_CMDID_CREATE 0x9031
#define DPIO_CMDID_DESTROY 0x9831
#define DPIO_CMDID_GET_API_VERSION 0xa031
#define DPIO_CMDID_ENABLE 0x0021
#define DPIO_CMDID_DISABLE 0x0031
#define DPIO_CMDID_GET_ATTR 0x0041
#define DPIO_CMDID_RESET 0x0051
/* cmd, param, offset, width, type, arg_name */
#define DPIO_CMD_OPEN(cmd, dpio_id) \
MC_CMD_OP(cmd, 0, 0, 32, int, dpio_id)
/* cmd, param, offset, width, type, arg_name */
#define DPIO_CMD_CREATE(cmd, cfg) \
do { \
MC_CMD_OP(cmd, 0, 16, 2, enum dpio_channel_mode, \
cfg->channel_mode);\
MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->num_priorities);\
} while (0)
/* cmd, param, offset, width, type, arg_name */
#define DPIO_RSP_GET_ATTR(cmd, attr) \
do { \
MC_RSP_OP(cmd, 0, 0, 32, int, attr->id);\
MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->qbman_portal_id);\
MC_RSP_OP(cmd, 0, 48, 8, uint8_t, attr->num_priorities);\
MC_RSP_OP(cmd, 0, 56, 4, enum dpio_channel_mode, attr->channel_mode);\
MC_RSP_OP(cmd, 1, 0, 64, uint64_t, attr->qbman_portal_ce_offset);\
MC_RSP_OP(cmd, 2, 0, 64, uint64_t, attr->qbman_portal_ci_offset);\
MC_RSP_OP(cmd, 3, 32, 32, uint32_t, attr->qbman_version);\
} while (0)
/* Data Path I/O Portal API
* Contains initialization APIs and runtime control APIs for DPIO
*/
struct fsl_mc_io;
/**
* dpio_open() - Open a control session for the specified object
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @dpio_id: DPIO unique ID
* @token: Returned token; use in subsequent API calls
*
* This function can be used to open a control session for an
* already created object; an object may have been declared in
* the DPL or by calling the dpio_create() function.
* This function returns a unique authentication token,
* associated with the specific object ID and the specific MC
* portal; this token must be used in all subsequent commands for
* this specific object.
*
* Return: '0' on Success; Error code otherwise.
*/
int dpio_open(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint32_t dpio_id,
uint16_t *token);
/**
* dpio_close() - Close the control session of the object
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPIO object
*
* Return: '0' on Success; Error code otherwise.
*/
int dpio_close(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token);
/**
* enum dpio_channel_mode - DPIO notification channel mode
* @DPIO_NO_CHANNEL: No support for notification channel
* @DPIO_LOCAL_CHANNEL: Notifications on data availability can be received by a
* dedicated channel in the DPIO; user should point the queue's
* destination in the relevant interface to this DPIO
*/
enum dpio_channel_mode {
DPIO_NO_CHANNEL = 0,
DPIO_LOCAL_CHANNEL = 1,
};
/**
* struct dpio_cfg - Structure representing DPIO configuration
* @channel_mode: Notification channel mode
* @num_priorities: Number of priorities for the notification channel (1-8);
* relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL'
*/
struct dpio_cfg {
enum dpio_channel_mode channel_mode;
uint8_t num_priorities;
};
/**
* dpio_create() - Create the DPIO object.
* @mc_io: Pointer to MC portal's I/O object
* @token: Authentication token.
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @cfg: Configuration structure
* @obj_id: Returned obj_id; use in subsequent API calls
*
* Create the DPIO object, allocate required resources and
* perform required initialization.
*
* The object can be created either by declaring it in the
* DPL file, or by calling this function.
*
* This function returns a unique authentication token,
* associated with the specific object ID and the specific MC
* portal; this token must be used in all subsequent calls to
* this specific object. For objects that are created using the
* DPL file, call dpio_open() function to get an authentication
* token first.
*
* Return: '0' on Success; Error code otherwise.
*/
int dpio_create(struct fsl_mc_io *mc_io,
uint16_t token,
uint32_t cmd_flags,
const struct dpio_cfg *cfg,
uint32_t *obj_id);
/**
* dpio_destroy() - Destroy the DPIO object and release all its resources.
* @mc_io: Pointer to MC portal's I/O object
* @token: Authentication token.
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @obj_id: Object ID of DPIO
*
* Return: '0' on Success; Error code otherwise
*/
int dpio_destroy(struct fsl_mc_io *mc_io,
uint16_t token,
uint32_t cmd_flags,
uint32_t obj_id);
/**
* dpio_enable() - Enable the DPIO, allow I/O portal operations.
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPIO object
*
* Return: '0' on Success; Error code otherwise
*/
int dpio_enable(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token);
/**
* dpio_disable() - Disable the DPIO, stop any I/O portal operation.
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPIO object
*
* Return: '0' on Success; Error code otherwise
*/
int dpio_disable(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token);
/**
* dpio_reset() - Reset the DPIO, returns the object to initial state.
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPIO object
*
* Return: '0' on Success; Error code otherwise.
*/
int dpio_reset(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token);
/**
* struct dpio_attr - Structure representing DPIO attributes
* @id: DPIO object ID
* @version: DPIO version
* @qbman_portal_ce_offset: offset of the software portal cache-enabled area
* @qbman_portal_ci_offset: offset of the software portal cache-inhibited area
* @qbman_portal_id: Software portal ID
* @channel_mode: Notification channel mode
* @num_priorities: Number of priorities for the notification channel (1-8);
* relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL'
* @qbman_version: QBMAN version
*/
struct dpio_attr {
uint32_t id;
uint64_t qbman_portal_ce_offset;
uint64_t qbman_portal_ci_offset;
uint16_t qbman_portal_id;
enum dpio_channel_mode channel_mode;
uint8_t num_priorities;
uint32_t qbman_version;
};
/**
* dpio_get_attributes() - Retrieve DPIO attributes
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPIO object
* @attr: Returned object's attributes
*
* Return: '0' on Success; Error code otherwise
*/
int dpio_get_attributes(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
struct dpio_attr *attr);
/**
* dpio_get_api_version - Retrieve DPIO Major and Minor version info.
*
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @major_ver: DPIO major version
* @minor_ver: DPIO minor version
*
* Return: '0' on Success; Error code otherwise.
*/
int dpio_get_api_version(struct fsl_mc_io *mc_io,
u32 cmd_flags,
u16 *major_ver,
u16 *minor_ver);
#endif /* _FSL_DPIO_H */
@@ -0,0 +1,476 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Freescale Layerscape MC I/O wrapper
*
* Copyright 2015-2016 Freescale Semiconductor, Inc.
* Copyright 2017 NXP
* Author: Prabhakar Kushwaha <prabhakar@freescale.com>
*/
#ifndef __FSL_DPMAC_H
#define __FSL_DPMAC_H
/* DPMAC Version */
#define DPMAC_VER_MAJOR 4
#define DPMAC_VER_MINOR 2
/* Command IDs */
#define DPMAC_CMDID_CLOSE 0x8001
#define DPMAC_CMDID_OPEN 0x80c1
#define DPMAC_CMDID_CREATE 0x90c1
#define DPMAC_CMDID_DESTROY 0x98c1
#define DPMAC_CMDID_GET_API_VERSION 0xa0c1
#define DPMAC_CMDID_GET_ATTR 0x0041
#define DPMAC_CMDID_RESET 0x0051
#define DPMAC_CMDID_MDIO_READ 0x0c01
#define DPMAC_CMDID_MDIO_WRITE 0x0c11
#define DPMAC_CMDID_GET_LINK_CFG 0x0c21
#define DPMAC_CMDID_SET_LINK_STATE 0x0c31
#define DPMAC_CMDID_GET_COUNTER 0x0c41
/* cmd, param, offset, width, type, arg_name */
#define DPMAC_CMD_CREATE(cmd, cfg) \
MC_CMD_OP(cmd, 0, 0, 16, uint16_t, cfg->mac_id)
/* cmd, param, offset, width, type, arg_name */
#define DPMAC_CMD_OPEN(cmd, dpmac_id) \
MC_CMD_OP(cmd, 0, 0, 32, int, dpmac_id)
/* cmd, param, offset, width, type, arg_name */
#define DPMAC_RSP_GET_ATTRIBUTES(cmd, attr) \
do { \
MC_RSP_OP(cmd, 0, 0, 32, int, attr->phy_id);\
MC_RSP_OP(cmd, 0, 32, 32, int, attr->id);\
MC_RSP_OP(cmd, 1, 32, 8, enum dpmac_link_type, attr->link_type);\
MC_RSP_OP(cmd, 1, 40, 8, enum dpmac_eth_if, attr->eth_if);\
MC_RSP_OP(cmd, 2, 0, 32, uint32_t, attr->max_rate);\
} while (0)
/* cmd, param, offset, width, type, arg_name */
#define DPMAC_CMD_MDIO_READ(cmd, cfg) \
do { \
MC_CMD_OP(cmd, 0, 0, 8, uint8_t, cfg->phy_addr); \
MC_CMD_OP(cmd, 0, 8, 8, uint8_t, cfg->reg); \
} while (0)
/* cmd, param, offset, width, type, arg_name */
#define DPMAC_RSP_MDIO_READ(cmd, data) \
MC_RSP_OP(cmd, 0, 16, 16, uint16_t, data)
/* cmd, param, offset, width, type, arg_name */
#define DPMAC_CMD_MDIO_WRITE(cmd, cfg) \
do { \
MC_CMD_OP(cmd, 0, 0, 8, uint8_t, cfg->phy_addr); \
MC_CMD_OP(cmd, 0, 8, 8, uint8_t, cfg->reg); \
MC_CMD_OP(cmd, 0, 16, 16, uint16_t, cfg->data); \
} while (0)
/* cmd, param, offset, width, type, arg_name */
#define DPMAC_RSP_GET_LINK_CFG(cmd, cfg) \
do { \
MC_RSP_OP(cmd, 0, 0, 64, uint64_t, cfg->options); \
MC_RSP_OP(cmd, 1, 0, 32, uint32_t, cfg->rate); \
} while (0)
/* cmd, param, offset, width, type, arg_name */
#define DPMAC_CMD_SET_LINK_STATE(cmd, cfg) \
do { \
MC_CMD_OP(cmd, 0, 0, 64, uint64_t, cfg->options); \
MC_CMD_OP(cmd, 1, 0, 32, uint32_t, cfg->rate); \
MC_CMD_OP(cmd, 2, 0, 1, int, cfg->up); \
} while (0)
/* cmd, param, offset, width, type, arg_name */
#define DPMAC_CMD_GET_COUNTER(cmd, type) \
MC_CMD_OP(cmd, 1, 0, 64, enum dpmac_counter, type)
/* cmd, param, offset, width, type, arg_name */
#define DPMAC_RSP_GET_COUNTER(cmd, counter) \
MC_RSP_OP(cmd, 1, 0, 64, uint64_t, counter)
/* Data Path MAC API
* Contains initialization APIs and runtime control APIs for DPMAC
*/
struct fsl_mc_io;
/**
* dpmac_open() - Open a control session for the specified object.
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @dpmac_id: DPMAC unique ID
* @token: Returned token; use in subsequent API calls
*
* This function can be used to open a control session for an
* already created object; an object may have been declared in
* the DPL or by calling the dpmac_create function.
* This function returns a unique authentication token,
* associated with the specific object ID and the specific MC
* portal; this token must be used in all subsequent commands for
* this specific object
*
* Return: '0' on Success; Error code otherwise.
*/
int dpmac_open(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
int dpmac_id,
uint16_t *token);
/**
* dpmac_close() - Close the control session of the object
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPMAC object
*
* After this function is called, no further operations are
* allowed on the object without opening a new control session.
*
* Return: '0' on Success; Error code otherwise.
*/
int dpmac_close(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token);
/**
* enum dpmac_link_type - DPMAC link type
* @DPMAC_LINK_TYPE_NONE: No link
* @DPMAC_LINK_TYPE_FIXED: Link is fixed type
* @DPMAC_LINK_TYPE_PHY: Link by PHY ID
* @DPMAC_LINK_TYPE_BACKPLANE: Backplane link type
*/
enum dpmac_link_type {
DPMAC_LINK_TYPE_NONE,
DPMAC_LINK_TYPE_FIXED,
DPMAC_LINK_TYPE_PHY,
DPMAC_LINK_TYPE_BACKPLANE
};
/**
* enum dpmac_eth_if - DPMAC Ethrnet interface
* @DPMAC_ETH_IF_MII: MII interface
* @DPMAC_ETH_IF_RMII: RMII interface
* @DPMAC_ETH_IF_SMII: SMII interface
* @DPMAC_ETH_IF_GMII: GMII interface
* @DPMAC_ETH_IF_RGMII: RGMII interface
* @DPMAC_ETH_IF_SGMII: SGMII interface
* @DPMAC_ETH_IF_QSGMII: QSGMII interface
* @DPMAC_ETH_IF_XAUI: XAUI interface
* @DPMAC_ETH_IF_XFI: XFI interface
*/
enum dpmac_eth_if {
DPMAC_ETH_IF_MII,
DPMAC_ETH_IF_RMII,
DPMAC_ETH_IF_SMII,
DPMAC_ETH_IF_GMII,
DPMAC_ETH_IF_RGMII,
DPMAC_ETH_IF_SGMII,
DPMAC_ETH_IF_QSGMII,
DPMAC_ETH_IF_XAUI,
DPMAC_ETH_IF_XFI
};
/**
* struct dpmac_cfg - Structure representing DPMAC configuration
* @mac_id: Represents the Hardware MAC ID; in case of multiple WRIOP,
* the MAC IDs are continuous.
* For example: 2 WRIOPs, 16 MACs in each:
* MAC IDs for the 1st WRIOP: 1-16,
* MAC IDs for the 2nd WRIOP: 17-32.
*/
struct dpmac_cfg {
int mac_id;
};
/**
* dpmac_create() - Create the DPMAC object.
* @mc_io: Pointer to MC portal's I/O object
* @token: Authentication token.
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @cfg: Configuration structure
* @obj_id: Returned obj_id; use in subsequent API calls
*
* Create the DPMAC object, allocate required resources and
* perform required initialization.
*
* The object can be created either by declaring it in the
* DPL file, or by calling this function.
* This function returns a unique authentication token,
* associated with the specific object ID and the specific MC
* portal; this token must be used in all subsequent calls to
* this specific object. For objects that are created using the
* DPL file, call dpmac_open function to get an authentication
* token first.
*
* Return: '0' on Success; Error code otherwise.
*/
int dpmac_create(struct fsl_mc_io *mc_io,
uint16_t token,
uint32_t cmd_flags,
const struct dpmac_cfg *cfg,
uint32_t *obj_id);
/**
* dpmac_destroy() - Destroy the DPMAC object and release all its resources.
* @mc_io: Pointer to MC portal's I/O object
* @token: Authentication token.
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @obj_id: DPMAC object id
*
* Return: '0' on Success; error code otherwise.
*/
int dpmac_destroy(struct fsl_mc_io *mc_io,
uint16_t token,
uint32_t cmd_flags,
uint32_t obj_id);
/* DPMAC IRQ Index and Events */
/* IRQ index */
#define DPMAC_IRQ_INDEX 0
/* IRQ event - indicates a change in link state */
#define DPMAC_IRQ_EVENT_LINK_CFG_REQ 0x00000001
/* irq event - Indicates that the link state changed */
#define DPMAC_IRQ_EVENT_LINK_CHANGED 0x00000002
/**
* struct dpmac_attr - Structure representing DPMAC attributes
* @id: DPMAC object ID
* @phy_id: PHY ID
* @link_type: link type
* @eth_if: Ethernet interface
* @max_rate: Maximum supported rate - in Mbps
* @version: DPMAC version
*/
struct dpmac_attr {
int id;
int phy_id;
enum dpmac_link_type link_type;
enum dpmac_eth_if eth_if;
uint32_t max_rate;
};
/**
* dpmac_get_attributes - Retrieve DPMAC attributes.
*
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPMAC object
* @attr: Returned object's attributes
*
* Return: '0' on Success; Error code otherwise.
*/
int dpmac_get_attributes(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
struct dpmac_attr *attr);
/**
* struct dpmac_mdio_cfg - DPMAC MDIO read/write parameters
* @phy_addr: MDIO device address
* @reg: Address of the register within the Clause 45 PHY device from which data
* is to be read
* @data: Data read/write from/to MDIO
*/
struct dpmac_mdio_cfg {
uint8_t phy_addr;
uint8_t reg;
uint16_t data;
};
/**
* dpmac_mdio_read() - Perform MDIO read transaction
* @mc_io: Pointer to opaque I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPMAC object
* @cfg: Structure with MDIO transaction parameters
*
* Return: '0' on Success; Error code otherwise.
*/
int dpmac_mdio_read(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
struct dpmac_mdio_cfg *cfg);
/**
* dpmac_mdio_write() - Perform MDIO write transaction
* @mc_io: Pointer to opaque I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPMAC object
* @cfg: Structure with MDIO transaction parameters
*
* Return: '0' on Success; Error code otherwise.
*/
int dpmac_mdio_write(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
struct dpmac_mdio_cfg *cfg);
/* DPMAC link configuration/state options */
/* Enable auto-negotiation */
#define DPMAC_LINK_OPT_AUTONEG 0x0000000000000001ULL
/* Enable half-duplex mode */
#define DPMAC_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
/* Enable pause frames */
#define DPMAC_LINK_OPT_PAUSE 0x0000000000000004ULL
/* Enable a-symmetric pause frames */
#define DPMAC_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
/**
* struct dpmac_link_cfg - Structure representing DPMAC link configuration
* @rate: Link's rate - in Mbps
* @options: Enable/Disable DPMAC link cfg features (bitmap)
*/
struct dpmac_link_cfg {
uint32_t rate;
uint64_t options;
};
/**
* dpmac_get_link_cfg() - Get Ethernet link configuration
* @mc_io: Pointer to opaque I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPMAC object
* @cfg: Returned structure with the link configuration
*
* Return: '0' on Success; Error code otherwise.
*/
int dpmac_get_link_cfg(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
struct dpmac_link_cfg *cfg);
/**
* struct dpmac_link_state - DPMAC link configuration request
* @rate: Rate in Mbps
* @options: Enable/Disable DPMAC link cfg features (bitmap)
* @up: Link state
*/
struct dpmac_link_state {
uint32_t rate;
uint64_t options;
int up;
};
/**
* dpmac_set_link_state() - Set the Ethernet link status
* @mc_io: Pointer to opaque I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPMAC object
* @link_state: Link state configuration
*
* Return: '0' on Success; Error code otherwise.
*/
int dpmac_set_link_state(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
struct dpmac_link_state *link_state);
/**
* enum dpni_counter - DPNI counter types
* @DPMAC_CNT_ING_FRAME_64: counts 64-octet frame, good or bad.
* @DPMAC_CNT_ING_FRAME_127: counts 65- to 127-octet frame, good or bad.
* @DPMAC_CNT_ING_FRAME_255: counts 128- to 255-octet frame, good or bad.
* @DPMAC_CNT_ING_FRAME_511: counts 256- to 511-octet frame, good or bad.
* @DPMAC_CNT_ING_FRAME_1023: counts 512- to 1023-octet frame, good or bad.
* @DPMAC_CNT_ING_FRAME_1518: counts 1024- to 1518-octet frame, good or bad.
* @DPMAC_CNT_ING_FRAME_1519_MAX: counts 1519-octet frame and larger
* (up to max frame length specified),
* good or bad.
* @DPMAC_CNT_ING_FRAG: counts packet which is shorter than 64 octets received
* with a wrong CRC
* @DPMAC_CNT_ING_JABBER: counts packet longer than the maximum frame length
* specified, with a bad frame check sequence.
* @DPMAC_CNT_ING_FRAME_DISCARD: counts dropped packet due to internal errors.
* Occurs when a receive FIFO overflows.
* Includes also packets truncated as a result of
* the receive FIFO overflow.
* @DPMAC_CNT_ING_ALIGN_ERR: counts frame with an alignment error
* (optional used for wrong SFD)
* @DPMAC_CNT_EGR_UNDERSIZED: counts packet transmitted that was less than 64
* octets long with a good CRC.
* @DPMAC_CNT_ING_OVERSIZED: counts packet longer than the maximum frame length
* specified, with a good frame check sequence.
* @DPMAC_CNT_ING_VALID_PAUSE_FRAME: counts valid pause frame (regular and PFC).
* @DPMAC_CNT_EGR_VALID_PAUSE_FRAME: counts valid pause frame transmitted
* (regular and PFC).
* @DPMAC_CNT_ING_BYTE: counts octet received except preamble for all valid
* frames and valid pause frames.
* @DPMAC_CNT_ING_MCAST_FRAME: counts received multicast frame
* @DPMAC_CNT_ING_BCAST_FRAME: counts received broadcast frame
* @DPMAC_CNT_ING_ALL_FRAME: counts each good or bad packet received.
* @DPMAC_CNT_ING_UCAST_FRAME: counts received unicast frame
* @DPMAC_CNT_ING_ERR_FRAME: counts frame received with an error
* (except for undersized/fragment frame)
* @DPMAC_CNT_EGR_BYTE: counts octet transmitted except preamble for all valid
* frames and valid pause frames transmitted.
* @DPMAC_CNT_EGR_MCAST_FRAME: counts transmitted multicast frame
* @DPMAC_CNT_EGR_BCAST_FRAME: counts transmitted broadcast frame
* @DPMAC_CNT_EGR_UCAST_FRAME: counts transmitted unicast frame
* @DPMAC_CNT_EGR_ERR_FRAME: counts frame transmitted with an error
* @DPMAC_CNT_ING_GOOD_FRAME: counts frame received without error, including
* pause frames.
*/
enum dpmac_counter {
DPMAC_CNT_ING_FRAME_64,
DPMAC_CNT_ING_FRAME_127,
DPMAC_CNT_ING_FRAME_255,
DPMAC_CNT_ING_FRAME_511,
DPMAC_CNT_ING_FRAME_1023,
DPMAC_CNT_ING_FRAME_1518,
DPMAC_CNT_ING_FRAME_1519_MAX,
DPMAC_CNT_ING_FRAG,
DPMAC_CNT_ING_JABBER,
DPMAC_CNT_ING_FRAME_DISCARD,
DPMAC_CNT_ING_ALIGN_ERR,
DPMAC_CNT_EGR_UNDERSIZED,
DPMAC_CNT_ING_OVERSIZED,
DPMAC_CNT_ING_VALID_PAUSE_FRAME,
DPMAC_CNT_EGR_VALID_PAUSE_FRAME,
DPMAC_CNT_ING_BYTE,
DPMAC_CNT_ING_MCAST_FRAME,
DPMAC_CNT_ING_BCAST_FRAME,
DPMAC_CNT_ING_ALL_FRAME,
DPMAC_CNT_ING_UCAST_FRAME,
DPMAC_CNT_ING_ERR_FRAME,
DPMAC_CNT_EGR_BYTE,
DPMAC_CNT_EGR_MCAST_FRAME,
DPMAC_CNT_EGR_BCAST_FRAME,
DPMAC_CNT_EGR_UCAST_FRAME,
DPMAC_CNT_EGR_ERR_FRAME,
DPMAC_CNT_ING_GOOD_FRAME
};
/**
* dpmac_get_counter() - Read a specific DPMAC counter
* @mc_io: Pointer to opaque I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPMAC object
* @type: The requested counter
* @counter: Returned counter value
*
* Return: The requested counter; '0' otherwise.
*/
int dpmac_get_counter(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
enum dpmac_counter type,
uint64_t *counter);
/**
* dpmac_get_api_version - Retrieve DPMAC Major and Minor version info.
*
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @major_ver: DPMAC major version
* @minor_ver: DPMAC minor version
*
* Return: '0' on Success; Error code otherwise.
*/
int dpmac_get_api_version(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t *major_ver,
uint16_t *minor_ver);
#endif /* __FSL_DPMAC_H */
@@ -0,0 +1,46 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/* Copyright 2013-2015 Freescale Semiconductor Inc.
*/
#ifndef __FSL_DPMNG_H
#define __FSL_DPMNG_H
/* Management Complex General API
* Contains general API for the Management Complex firmware
*/
struct fsl_mc_io;
/**
* Management Complex firmware version information
*/
#define MC_VER_MAJOR 9
#define MC_VER_MINOR 0
/**
* struct mc_versoin
* @major: Major version number: incremented on API compatibility changes
* @minor: Minor version number: incremented on API additions (that are
* backward compatible); reset when major version is incremented
* @revision: Internal revision number: incremented on implementation changes
* and/or bug fixes that have no impact on API
*/
struct mc_version {
uint32_t major;
uint32_t minor;
uint32_t revision;
};
/**
* mc_get_version() - Retrieves the Management Complex firmware
* version information
* @mc_io: Pointer to opaque I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @mc_ver_info: Returned version information structure
*
* Return: '0' on Success; Error code otherwise.
*/
int mc_get_version(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
struct mc_version *mc_ver_info);
#endif /* __FSL_DPMNG_H */
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,957 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Freescale Layerscape MC I/O wrapper
*
* Copyright 2013-2016 Freescale Semiconductor, Inc.
* Copyright 2017 NXP
*/
#ifndef _FSL_DPRC_H
#define _FSL_DPRC_H
/* DPRC Version */
#define DPRC_VER_MAJOR 6
#define DPRC_VER_MINOR 1
/* Command IDs */
#define DPRC_CMDID_CLOSE 0x8001
#define DPRC_CMDID_OPEN 0x8051
#define DPRC_CMDID_CREATE 0x9051
#define DPRC_CMDID_GET_ATTR 0x0041
#define DPRC_CMDID_RESET_CONT 0x0051
#define DPRC_CMDID_GET_API_VERSION 0xa051
#define DPRC_CMDID_CREATE_CONT 0x1511
#define DPRC_CMDID_DESTROY_CONT 0x1521
#define DPRC_CMDID_GET_CONT_ID 0x8301
#define DPRC_CMDID_GET_OBJ_COUNT 0x1591
#define DPRC_CMDID_GET_OBJ 0x15A1
#define DPRC_CMDID_GET_RES_COUNT 0x15B1
#define DPRC_CMDID_GET_RES_IDS 0x15C1
#define DPRC_CMDID_GET_OBJ_REG 0x15E1
#define DPRC_CMDID_CONNECT 0x1671
#define DPRC_CMDID_DISCONNECT 0x1681
#define DPRC_CMDID_GET_CONNECTION 0x16C1
/* cmd, param, offset, width, type, arg_name */
#define DPRC_RSP_GET_CONTAINER_ID(cmd, container_id) \
MC_RSP_OP(cmd, 0, 0, 32, int, container_id)
/* cmd, param, offset, width, type, arg_name */
#define DPRC_CMD_OPEN(cmd, container_id) \
MC_CMD_OP(cmd, 0, 0, 32, int, container_id)
/* cmd, param, offset, width, type, arg_name */
#define DPRC_CMD_CREATE_CONTAINER(cmd, cfg) \
do { \
MC_CMD_OP(cmd, 0, 32, 16, uint16_t, cfg->icid); \
MC_CMD_OP(cmd, 0, 0, 32, uint32_t, cfg->options); \
MC_CMD_OP(cmd, 1, 32, 32, int, cfg->portal_id); \
MC_CMD_OP(cmd, 2, 0, 8, char, cfg->label[0]);\
MC_CMD_OP(cmd, 2, 8, 8, char, cfg->label[1]);\
MC_CMD_OP(cmd, 2, 16, 8, char, cfg->label[2]);\
MC_CMD_OP(cmd, 2, 24, 8, char, cfg->label[3]);\
MC_CMD_OP(cmd, 2, 32, 8, char, cfg->label[4]);\
MC_CMD_OP(cmd, 2, 40, 8, char, cfg->label[5]);\
MC_CMD_OP(cmd, 2, 48, 8, char, cfg->label[6]);\
MC_CMD_OP(cmd, 2, 56, 8, char, cfg->label[7]);\
MC_CMD_OP(cmd, 3, 0, 8, char, cfg->label[8]);\
MC_CMD_OP(cmd, 3, 8, 8, char, cfg->label[9]);\
MC_CMD_OP(cmd, 3, 16, 8, char, cfg->label[10]);\
MC_CMD_OP(cmd, 3, 24, 8, char, cfg->label[11]);\
MC_CMD_OP(cmd, 3, 32, 8, char, cfg->label[12]);\
MC_CMD_OP(cmd, 3, 40, 8, char, cfg->label[13]);\
MC_CMD_OP(cmd, 3, 48, 8, char, cfg->label[14]);\
MC_CMD_OP(cmd, 3, 56, 8, char, cfg->label[15]);\
} while (0)
/* cmd, param, offset, width, type, arg_name */
#define DPRC_RSP_CREATE_CONTAINER(cmd, child_container_id, child_portal_offset)\
do { \
MC_RSP_OP(cmd, 1, 0, 32, int, child_container_id); \
MC_RSP_OP(cmd, 2, 0, 64, uint64_t, child_portal_offset);\
} while (0)
/* cmd, param, offset, width, type, arg_name */
#define DPRC_CMD_DESTROY_CONTAINER(cmd, child_container_id) \
MC_CMD_OP(cmd, 0, 0, 32, int, child_container_id)
/* cmd, param, offset, width, type, arg_name */
#define DPRC_CMD_RESET_CONTAINER(cmd, child_container_id) \
MC_CMD_OP(cmd, 0, 0, 32, int, child_container_id)
/* cmd, param, offset, width, type, arg_name */
#define DPRC_RSP_GET_ATTRIBUTES(cmd, attr) \
do { \
MC_RSP_OP(cmd, 0, 0, 32, int, attr->container_id); \
MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->icid); \
MC_RSP_OP(cmd, 1, 0, 32, uint32_t, attr->options);\
MC_RSP_OP(cmd, 1, 32, 32, int, attr->portal_id); \
} while (0)
/* cmd, param, offset, width, type, arg_name */
#define DPRC_RSP_GET_OBJ_COUNT(cmd, obj_count) \
MC_RSP_OP(cmd, 0, 32, 32, int, obj_count)
/* cmd, param, offset, width, type, arg_name */
#define DPRC_CMD_GET_OBJ(cmd, obj_index) \
MC_CMD_OP(cmd, 0, 0, 32, int, obj_index)
/* cmd, param, offset, width, type, arg_name */
#define DPRC_RSP_GET_OBJ(cmd, obj_desc) \
do { \
MC_RSP_OP(cmd, 0, 32, 32, int, obj_desc->id); \
MC_RSP_OP(cmd, 1, 0, 16, uint16_t, obj_desc->vendor); \
MC_RSP_OP(cmd, 1, 16, 8, uint8_t, obj_desc->irq_count); \
MC_RSP_OP(cmd, 1, 24, 8, uint8_t, obj_desc->region_count); \
MC_RSP_OP(cmd, 1, 32, 32, uint32_t, obj_desc->state);\
MC_RSP_OP(cmd, 2, 0, 16, uint16_t, obj_desc->ver_major);\
MC_RSP_OP(cmd, 2, 16, 16, uint16_t, obj_desc->ver_minor);\
MC_RSP_OP(cmd, 2, 32, 16, uint16_t, obj_desc->flags); \
MC_RSP_OP(cmd, 3, 0, 8, char, obj_desc->type[0]);\
MC_RSP_OP(cmd, 3, 8, 8, char, obj_desc->type[1]);\
MC_RSP_OP(cmd, 3, 16, 8, char, obj_desc->type[2]);\
MC_RSP_OP(cmd, 3, 24, 8, char, obj_desc->type[3]);\
MC_RSP_OP(cmd, 3, 32, 8, char, obj_desc->type[4]);\
MC_RSP_OP(cmd, 3, 40, 8, char, obj_desc->type[5]);\
MC_RSP_OP(cmd, 3, 48, 8, char, obj_desc->type[6]);\
MC_RSP_OP(cmd, 3, 56, 8, char, obj_desc->type[7]);\
MC_RSP_OP(cmd, 4, 0, 8, char, obj_desc->type[8]);\
MC_RSP_OP(cmd, 4, 8, 8, char, obj_desc->type[9]);\
MC_RSP_OP(cmd, 4, 16, 8, char, obj_desc->type[10]);\
MC_RSP_OP(cmd, 4, 24, 8, char, obj_desc->type[11]);\
MC_RSP_OP(cmd, 4, 32, 8, char, obj_desc->type[12]);\
MC_RSP_OP(cmd, 4, 40, 8, char, obj_desc->type[13]);\
MC_RSP_OP(cmd, 4, 48, 8, char, obj_desc->type[14]);\
MC_RSP_OP(cmd, 4, 56, 8, char, obj_desc->type[15]);\
MC_RSP_OP(cmd, 5, 0, 8, char, obj_desc->label[0]);\
MC_RSP_OP(cmd, 5, 8, 8, char, obj_desc->label[1]);\
MC_RSP_OP(cmd, 5, 16, 8, char, obj_desc->label[2]);\
MC_RSP_OP(cmd, 5, 24, 8, char, obj_desc->label[3]);\
MC_RSP_OP(cmd, 5, 32, 8, char, obj_desc->label[4]);\
MC_RSP_OP(cmd, 5, 40, 8, char, obj_desc->label[5]);\
MC_RSP_OP(cmd, 5, 48, 8, char, obj_desc->label[6]);\
MC_RSP_OP(cmd, 5, 56, 8, char, obj_desc->label[7]);\
MC_RSP_OP(cmd, 6, 0, 8, char, obj_desc->label[8]);\
MC_RSP_OP(cmd, 6, 8, 8, char, obj_desc->label[9]);\
MC_RSP_OP(cmd, 6, 16, 8, char, obj_desc->label[10]);\
MC_RSP_OP(cmd, 6, 24, 8, char, obj_desc->label[11]);\
MC_RSP_OP(cmd, 6, 32, 8, char, obj_desc->label[12]);\
MC_RSP_OP(cmd, 6, 40, 8, char, obj_desc->label[13]);\
MC_RSP_OP(cmd, 6, 48, 8, char, obj_desc->label[14]);\
MC_RSP_OP(cmd, 6, 56, 8, char, obj_desc->label[15]);\
} while (0)
/* cmd, param, offset, width, type, arg_name */
#define DPRC_CMD_GET_OBJ_DESC(cmd, obj_type, obj_id) \
do { \
MC_CMD_OP(cmd, 0, 0, 32, int, obj_id);\
MC_CMD_OP(cmd, 1, 0, 8, char, obj_type[0]);\
MC_CMD_OP(cmd, 1, 8, 8, char, obj_type[1]);\
MC_CMD_OP(cmd, 1, 16, 8, char, obj_type[2]);\
MC_CMD_OP(cmd, 1, 24, 8, char, obj_type[3]);\
MC_CMD_OP(cmd, 1, 32, 8, char, obj_type[4]);\
MC_CMD_OP(cmd, 1, 40, 8, char, obj_type[5]);\
MC_CMD_OP(cmd, 1, 48, 8, char, obj_type[6]);\
MC_CMD_OP(cmd, 1, 56, 8, char, obj_type[7]);\
MC_CMD_OP(cmd, 2, 0, 8, char, obj_type[8]);\
MC_CMD_OP(cmd, 2, 8, 8, char, obj_type[9]);\
MC_CMD_OP(cmd, 2, 16, 8, char, obj_type[10]);\
MC_CMD_OP(cmd, 2, 24, 8, char, obj_type[11]);\
MC_CMD_OP(cmd, 2, 32, 8, char, obj_type[12]);\
MC_CMD_OP(cmd, 2, 40, 8, char, obj_type[13]);\
MC_CMD_OP(cmd, 2, 48, 8, char, obj_type[14]);\
MC_CMD_OP(cmd, 2, 56, 8, char, obj_type[15]);\
} while (0)
/* cmd, param, offset, width, type, arg_name */
#define DPRC_RSP_GET_OBJ_DESC(cmd, obj_desc) \
do { \
MC_RSP_OP(cmd, 0, 32, 32, int, obj_desc->id); \
MC_RSP_OP(cmd, 1, 0, 16, uint16_t, obj_desc->vendor); \
MC_RSP_OP(cmd, 1, 16, 8, uint8_t, obj_desc->irq_count); \
MC_RSP_OP(cmd, 1, 24, 8, uint8_t, obj_desc->region_count); \
MC_RSP_OP(cmd, 1, 32, 32, uint32_t, obj_desc->state);\
MC_RSP_OP(cmd, 2, 0, 16, uint16_t, obj_desc->ver_major);\
MC_RSP_OP(cmd, 2, 16, 16, uint16_t, obj_desc->ver_minor);\
MC_RSP_OP(cmd, 2, 32, 16, uint16_t, obj_desc->flags); \
MC_RSP_OP(cmd, 3, 0, 8, char, obj_desc->type[0]);\
MC_RSP_OP(cmd, 3, 8, 8, char, obj_desc->type[1]);\
MC_RSP_OP(cmd, 3, 16, 8, char, obj_desc->type[2]);\
MC_RSP_OP(cmd, 3, 24, 8, char, obj_desc->type[3]);\
MC_RSP_OP(cmd, 3, 32, 8, char, obj_desc->type[4]);\
MC_RSP_OP(cmd, 3, 40, 8, char, obj_desc->type[5]);\
MC_RSP_OP(cmd, 3, 48, 8, char, obj_desc->type[6]);\
MC_RSP_OP(cmd, 3, 56, 8, char, obj_desc->type[7]);\
MC_RSP_OP(cmd, 4, 0, 8, char, obj_desc->type[8]);\
MC_RSP_OP(cmd, 4, 8, 8, char, obj_desc->type[9]);\
MC_RSP_OP(cmd, 4, 16, 8, char, obj_desc->type[10]);\
MC_RSP_OP(cmd, 4, 24, 8, char, obj_desc->type[11]);\
MC_RSP_OP(cmd, 4, 32, 8, char, obj_desc->type[12]);\
MC_RSP_OP(cmd, 4, 40, 8, char, obj_desc->type[13]);\
MC_RSP_OP(cmd, 4, 48, 8, char, obj_desc->type[14]);\
MC_RSP_OP(cmd, 4, 56, 8, char, obj_desc->type[15]);\
MC_RSP_OP(cmd, 5, 0, 8, char, obj_desc->label[0]);\
MC_RSP_OP(cmd, 5, 8, 8, char, obj_desc->label[1]);\
MC_RSP_OP(cmd, 5, 16, 8, char, obj_desc->label[2]);\
MC_RSP_OP(cmd, 5, 24, 8, char, obj_desc->label[3]);\
MC_RSP_OP(cmd, 5, 32, 8, char, obj_desc->label[4]);\
MC_RSP_OP(cmd, 5, 40, 8, char, obj_desc->label[5]);\
MC_RSP_OP(cmd, 5, 48, 8, char, obj_desc->label[6]);\
MC_RSP_OP(cmd, 5, 56, 8, char, obj_desc->label[7]);\
MC_RSP_OP(cmd, 6, 0, 8, char, obj_desc->label[8]);\
MC_RSP_OP(cmd, 6, 8, 8, char, obj_desc->label[9]);\
MC_RSP_OP(cmd, 6, 16, 8, char, obj_desc->label[10]);\
MC_RSP_OP(cmd, 6, 24, 8, char, obj_desc->label[11]);\
MC_RSP_OP(cmd, 6, 32, 8, char, obj_desc->label[12]);\
MC_RSP_OP(cmd, 6, 40, 8, char, obj_desc->label[13]);\
MC_RSP_OP(cmd, 6, 48, 8, char, obj_desc->label[14]);\
MC_RSP_OP(cmd, 6, 56, 8, char, obj_desc->label[15]);\
} while (0)
/* cmd, param, offset, width, type, arg_name */
#define DPRC_CMD_GET_RES_COUNT(cmd, type) \
do { \
MC_CMD_OP(cmd, 1, 0, 8, char, type[0]);\
MC_CMD_OP(cmd, 1, 8, 8, char, type[1]);\
MC_CMD_OP(cmd, 1, 16, 8, char, type[2]);\
MC_CMD_OP(cmd, 1, 24, 8, char, type[3]);\
MC_CMD_OP(cmd, 1, 32, 8, char, type[4]);\
MC_CMD_OP(cmd, 1, 40, 8, char, type[5]);\
MC_CMD_OP(cmd, 1, 48, 8, char, type[6]);\
MC_CMD_OP(cmd, 1, 56, 8, char, type[7]);\
MC_CMD_OP(cmd, 2, 0, 8, char, type[8]);\
MC_CMD_OP(cmd, 2, 8, 8, char, type[9]);\
MC_CMD_OP(cmd, 2, 16, 8, char, type[10]);\
MC_CMD_OP(cmd, 2, 24, 8, char, type[11]);\
MC_CMD_OP(cmd, 2, 32, 8, char, type[12]);\
MC_CMD_OP(cmd, 2, 40, 8, char, type[13]);\
MC_CMD_OP(cmd, 2, 48, 8, char, type[14]);\
MC_CMD_OP(cmd, 2, 56, 8, char, type[15]);\
} while (0)
/* cmd, param, offset, width, type, arg_name */
#define DPRC_RSP_GET_RES_COUNT(cmd, res_count) \
MC_RSP_OP(cmd, 0, 0, 32, int, res_count)
/* cmd, param, offset, width, type, arg_name */
#define DPRC_CMD_GET_RES_IDS(cmd, range_desc, type) \
do { \
MC_CMD_OP(cmd, 0, 42, 7, enum dprc_iter_status, \
range_desc->iter_status); \
MC_CMD_OP(cmd, 1, 0, 32, int, range_desc->base_id); \
MC_CMD_OP(cmd, 1, 32, 32, int, range_desc->last_id);\
MC_CMD_OP(cmd, 2, 0, 8, char, type[0]);\
MC_CMD_OP(cmd, 2, 8, 8, char, type[1]);\
MC_CMD_OP(cmd, 2, 16, 8, char, type[2]);\
MC_CMD_OP(cmd, 2, 24, 8, char, type[3]);\
MC_CMD_OP(cmd, 2, 32, 8, char, type[4]);\
MC_CMD_OP(cmd, 2, 40, 8, char, type[5]);\
MC_CMD_OP(cmd, 2, 48, 8, char, type[6]);\
MC_CMD_OP(cmd, 2, 56, 8, char, type[7]);\
MC_CMD_OP(cmd, 3, 0, 8, char, type[8]);\
MC_CMD_OP(cmd, 3, 8, 8, char, type[9]);\
MC_CMD_OP(cmd, 3, 16, 8, char, type[10]);\
MC_CMD_OP(cmd, 3, 24, 8, char, type[11]);\
MC_CMD_OP(cmd, 3, 32, 8, char, type[12]);\
MC_CMD_OP(cmd, 3, 40, 8, char, type[13]);\
MC_CMD_OP(cmd, 3, 48, 8, char, type[14]);\
MC_CMD_OP(cmd, 3, 56, 8, char, type[15]);\
} while (0)
/* cmd, param, offset, width, type, arg_name */
#define DPRC_RSP_GET_RES_IDS(cmd, range_desc) \
do { \
MC_RSP_OP(cmd, 0, 42, 7, enum dprc_iter_status, \
range_desc->iter_status);\
MC_RSP_OP(cmd, 1, 0, 32, int, range_desc->base_id); \
MC_RSP_OP(cmd, 1, 32, 32, int, range_desc->last_id);\
} while (0)
/* cmd, param, offset, width, type, arg_name */
#define DPRC_CMD_GET_OBJ_REGION(cmd, obj_type, obj_id, region_index) \
do { \
MC_CMD_OP(cmd, 0, 0, 32, int, obj_id); \
MC_CMD_OP(cmd, 0, 48, 8, uint8_t, region_index);\
MC_CMD_OP(cmd, 3, 0, 8, char, obj_type[0]);\
MC_CMD_OP(cmd, 3, 8, 8, char, obj_type[1]);\
MC_CMD_OP(cmd, 3, 16, 8, char, obj_type[2]);\
MC_CMD_OP(cmd, 3, 24, 8, char, obj_type[3]);\
MC_CMD_OP(cmd, 3, 32, 8, char, obj_type[4]);\
MC_CMD_OP(cmd, 3, 40, 8, char, obj_type[5]);\
MC_CMD_OP(cmd, 3, 48, 8, char, obj_type[6]);\
MC_CMD_OP(cmd, 3, 56, 8, char, obj_type[7]);\
MC_CMD_OP(cmd, 4, 0, 8, char, obj_type[8]);\
MC_CMD_OP(cmd, 4, 8, 8, char, obj_type[9]);\
MC_CMD_OP(cmd, 4, 16, 8, char, obj_type[10]);\
MC_CMD_OP(cmd, 4, 24, 8, char, obj_type[11]);\
MC_CMD_OP(cmd, 4, 32, 8, char, obj_type[12]);\
MC_CMD_OP(cmd, 4, 40, 8, char, obj_type[13]);\
MC_CMD_OP(cmd, 4, 48, 8, char, obj_type[14]);\
MC_CMD_OP(cmd, 4, 56, 8, char, obj_type[15]);\
} while (0)
/* param, offset, width, type, arg_name */
#define DPRC_RSP_GET_OBJ_REGION(cmd, region_desc) \
do { \
MC_RSP_OP(cmd, 1, 0, 32, uint32_t, region_desc->base_offset);\
MC_RSP_OP(cmd, 2, 0, 32, uint32_t, region_desc->size); \
MC_RSP_OP(cmd, 2, 32, 4, enum dprc_region_type, region_desc->type);\
MC_RSP_OP(cmd, 3, 0, 32, uint32_t, region_desc->flags);\
} while (0)
/* cmd, param, offset, width, type, arg_name */
#define DPRC_CMD_SET_OBJ_LABEL(cmd, obj_type, obj_id, label) \
do { \
MC_CMD_OP(cmd, 0, 0, 32, int, obj_id); \
MC_CMD_OP(cmd, 1, 0, 8, char, label[0]);\
MC_CMD_OP(cmd, 1, 8, 8, char, label[1]);\
MC_CMD_OP(cmd, 1, 16, 8, char, label[2]);\
MC_CMD_OP(cmd, 1, 24, 8, char, label[3]);\
MC_CMD_OP(cmd, 1, 32, 8, char, label[4]);\
MC_CMD_OP(cmd, 1, 40, 8, char, label[5]);\
MC_CMD_OP(cmd, 1, 48, 8, char, label[6]);\
MC_CMD_OP(cmd, 1, 56, 8, char, label[7]);\
MC_CMD_OP(cmd, 2, 0, 8, char, label[8]);\
MC_CMD_OP(cmd, 2, 8, 8, char, label[9]);\
MC_CMD_OP(cmd, 2, 16, 8, char, label[10]);\
MC_CMD_OP(cmd, 2, 24, 8, char, label[11]);\
MC_CMD_OP(cmd, 2, 32, 8, char, label[12]);\
MC_CMD_OP(cmd, 2, 40, 8, char, label[13]);\
MC_CMD_OP(cmd, 2, 48, 8, char, label[14]);\
MC_CMD_OP(cmd, 2, 56, 8, char, label[15]);\
MC_CMD_OP(cmd, 3, 0, 8, char, obj_type[0]);\
MC_CMD_OP(cmd, 3, 8, 8, char, obj_type[1]);\
MC_CMD_OP(cmd, 3, 16, 8, char, obj_type[2]);\
MC_CMD_OP(cmd, 3, 24, 8, char, obj_type[3]);\
MC_CMD_OP(cmd, 3, 32, 8, char, obj_type[4]);\
MC_CMD_OP(cmd, 3, 40, 8, char, obj_type[5]);\
MC_CMD_OP(cmd, 3, 48, 8, char, obj_type[6]);\
MC_CMD_OP(cmd, 3, 56, 8, char, obj_type[7]);\
MC_CMD_OP(cmd, 4, 0, 8, char, obj_type[8]);\
MC_CMD_OP(cmd, 4, 8, 8, char, obj_type[9]);\
MC_CMD_OP(cmd, 4, 16, 8, char, obj_type[10]);\
MC_CMD_OP(cmd, 4, 24, 8, char, obj_type[11]);\
MC_CMD_OP(cmd, 4, 32, 8, char, obj_type[12]);\
MC_CMD_OP(cmd, 4, 40, 8, char, obj_type[13]);\
MC_CMD_OP(cmd, 4, 48, 8, char, obj_type[14]);\
MC_CMD_OP(cmd, 4, 56, 8, char, obj_type[15]);\
} while (0)
/* cmd, param, offset, width, type, arg_name */
#define DPRC_CMD_CONNECT(cmd, endpoint1, endpoint2, cfg) \
do { \
MC_CMD_OP(cmd, 0, 0, 32, int, endpoint1->id); \
MC_CMD_OP(cmd, 0, 32, 32, int, endpoint1->if_id); \
MC_CMD_OP(cmd, 1, 0, 32, int, endpoint2->id); \
MC_CMD_OP(cmd, 1, 32, 32, int, endpoint2->if_id); \
MC_CMD_OP(cmd, 2, 0, 8, char, endpoint1->type[0]); \
MC_CMD_OP(cmd, 2, 8, 8, char, endpoint1->type[1]); \
MC_CMD_OP(cmd, 2, 16, 8, char, endpoint1->type[2]); \
MC_CMD_OP(cmd, 2, 24, 8, char, endpoint1->type[3]); \
MC_CMD_OP(cmd, 2, 32, 8, char, endpoint1->type[4]); \
MC_CMD_OP(cmd, 2, 40, 8, char, endpoint1->type[5]); \
MC_CMD_OP(cmd, 2, 48, 8, char, endpoint1->type[6]); \
MC_CMD_OP(cmd, 2, 56, 8, char, endpoint1->type[7]); \
MC_CMD_OP(cmd, 3, 0, 8, char, endpoint1->type[8]); \
MC_CMD_OP(cmd, 3, 8, 8, char, endpoint1->type[9]); \
MC_CMD_OP(cmd, 3, 16, 8, char, endpoint1->type[10]); \
MC_CMD_OP(cmd, 3, 24, 8, char, endpoint1->type[11]); \
MC_CMD_OP(cmd, 3, 32, 8, char, endpoint1->type[12]); \
MC_CMD_OP(cmd, 3, 40, 8, char, endpoint1->type[13]); \
MC_CMD_OP(cmd, 3, 48, 8, char, endpoint1->type[14]); \
MC_CMD_OP(cmd, 3, 56, 8, char, endpoint1->type[15]); \
MC_CMD_OP(cmd, 4, 0, 32, uint32_t, cfg->max_rate); \
MC_CMD_OP(cmd, 4, 32, 32, uint32_t, cfg->committed_rate); \
MC_CMD_OP(cmd, 5, 0, 8, char, endpoint2->type[0]); \
MC_CMD_OP(cmd, 5, 8, 8, char, endpoint2->type[1]); \
MC_CMD_OP(cmd, 5, 16, 8, char, endpoint2->type[2]); \
MC_CMD_OP(cmd, 5, 24, 8, char, endpoint2->type[3]); \
MC_CMD_OP(cmd, 5, 32, 8, char, endpoint2->type[4]); \
MC_CMD_OP(cmd, 5, 40, 8, char, endpoint2->type[5]); \
MC_CMD_OP(cmd, 5, 48, 8, char, endpoint2->type[6]); \
MC_CMD_OP(cmd, 5, 56, 8, char, endpoint2->type[7]); \
MC_CMD_OP(cmd, 6, 0, 8, char, endpoint2->type[8]); \
MC_CMD_OP(cmd, 6, 8, 8, char, endpoint2->type[9]); \
MC_CMD_OP(cmd, 6, 16, 8, char, endpoint2->type[10]); \
MC_CMD_OP(cmd, 6, 24, 8, char, endpoint2->type[11]); \
MC_CMD_OP(cmd, 6, 32, 8, char, endpoint2->type[12]); \
MC_CMD_OP(cmd, 6, 40, 8, char, endpoint2->type[13]); \
MC_CMD_OP(cmd, 6, 48, 8, char, endpoint2->type[14]); \
MC_CMD_OP(cmd, 6, 56, 8, char, endpoint2->type[15]); \
} while (0)
/* cmd, param, offset, width, type, arg_name */
#define DPRC_CMD_DISCONNECT(cmd, endpoint) \
do { \
MC_CMD_OP(cmd, 0, 0, 32, int, endpoint->id); \
MC_CMD_OP(cmd, 0, 32, 16, uint16_t, endpoint->if_id); \
MC_CMD_OP(cmd, 1, 0, 8, char, endpoint->type[0]); \
MC_CMD_OP(cmd, 1, 8, 8, char, endpoint->type[1]); \
MC_CMD_OP(cmd, 1, 16, 8, char, endpoint->type[2]); \
MC_CMD_OP(cmd, 1, 24, 8, char, endpoint->type[3]); \
MC_CMD_OP(cmd, 1, 32, 8, char, endpoint->type[4]); \
MC_CMD_OP(cmd, 1, 40, 8, char, endpoint->type[5]); \
MC_CMD_OP(cmd, 1, 48, 8, char, endpoint->type[6]); \
MC_CMD_OP(cmd, 1, 56, 8, char, endpoint->type[7]); \
MC_CMD_OP(cmd, 2, 0, 8, char, endpoint->type[8]); \
MC_CMD_OP(cmd, 2, 8, 8, char, endpoint->type[9]); \
MC_CMD_OP(cmd, 2, 16, 8, char, endpoint->type[10]); \
MC_CMD_OP(cmd, 2, 24, 8, char, endpoint->type[11]); \
MC_CMD_OP(cmd, 2, 32, 8, char, endpoint->type[12]); \
MC_CMD_OP(cmd, 2, 40, 8, char, endpoint->type[13]); \
MC_CMD_OP(cmd, 2, 48, 8, char, endpoint->type[14]); \
MC_CMD_OP(cmd, 2, 56, 8, char, endpoint->type[15]); \
} while (0)
/* cmd, param, offset, width, type, arg_name */
#define DPRC_CMD_GET_CONNECTION(cmd, endpoint1) \
do { \
MC_CMD_OP(cmd, 0, 0, 32, int, endpoint1->id); \
MC_CMD_OP(cmd, 0, 32, 32, int, endpoint1->if_id); \
MC_CMD_OP(cmd, 1, 0, 8, char, endpoint1->type[0]); \
MC_CMD_OP(cmd, 1, 8, 8, char, endpoint1->type[1]); \
MC_CMD_OP(cmd, 1, 16, 8, char, endpoint1->type[2]); \
MC_CMD_OP(cmd, 1, 24, 8, char, endpoint1->type[3]); \
MC_CMD_OP(cmd, 1, 32, 8, char, endpoint1->type[4]); \
MC_CMD_OP(cmd, 1, 40, 8, char, endpoint1->type[5]); \
MC_CMD_OP(cmd, 1, 48, 8, char, endpoint1->type[6]); \
MC_CMD_OP(cmd, 1, 56, 8, char, endpoint1->type[7]); \
MC_CMD_OP(cmd, 2, 0, 8, char, endpoint1->type[8]); \
MC_CMD_OP(cmd, 2, 8, 8, char, endpoint1->type[9]); \
MC_CMD_OP(cmd, 2, 16, 8, char, endpoint1->type[10]); \
MC_CMD_OP(cmd, 2, 24, 8, char, endpoint1->type[11]); \
MC_CMD_OP(cmd, 2, 32, 8, char, endpoint1->type[12]); \
MC_CMD_OP(cmd, 2, 40, 8, char, endpoint1->type[13]); \
MC_CMD_OP(cmd, 2, 48, 8, char, endpoint1->type[14]); \
MC_CMD_OP(cmd, 2, 56, 8, char, endpoint1->type[15]); \
} while (0)
/* cmd, param, offset, width, type, arg_name */
#define DPRC_RSP_GET_CONNECTION(cmd, endpoint2, state) \
do { \
MC_RSP_OP(cmd, 3, 0, 32, int, endpoint2->id); \
MC_RSP_OP(cmd, 3, 32, 16, uint16_t, endpoint2->if_id); \
MC_RSP_OP(cmd, 4, 0, 8, char, endpoint2->type[0]); \
MC_RSP_OP(cmd, 4, 8, 8, char, endpoint2->type[1]); \
MC_RSP_OP(cmd, 4, 16, 8, char, endpoint2->type[2]); \
MC_RSP_OP(cmd, 4, 24, 8, char, endpoint2->type[3]); \
MC_RSP_OP(cmd, 4, 32, 8, char, endpoint2->type[4]); \
MC_RSP_OP(cmd, 4, 40, 8, char, endpoint2->type[5]); \
MC_RSP_OP(cmd, 4, 48, 8, char, endpoint2->type[6]); \
MC_RSP_OP(cmd, 4, 56, 8, char, endpoint2->type[7]); \
MC_RSP_OP(cmd, 5, 0, 8, char, endpoint2->type[8]); \
MC_RSP_OP(cmd, 5, 8, 8, char, endpoint2->type[9]); \
MC_RSP_OP(cmd, 5, 16, 8, char, endpoint2->type[10]); \
MC_RSP_OP(cmd, 5, 24, 8, char, endpoint2->type[11]); \
MC_RSP_OP(cmd, 5, 32, 8, char, endpoint2->type[12]); \
MC_RSP_OP(cmd, 5, 40, 8, char, endpoint2->type[13]); \
MC_RSP_OP(cmd, 5, 48, 8, char, endpoint2->type[14]); \
MC_RSP_OP(cmd, 5, 56, 8, char, endpoint2->type[15]); \
MC_RSP_OP(cmd, 6, 0, 32, int, state); \
} while (0)
/* Data Path Resource Container API
* Contains DPRC API for managing and querying DPAA resources
*/
struct fsl_mc_io;
/**
* Set this value as the icid value in dprc_cfg structure when creating a
* container, in case the ICID is not selected by the user and should be
* allocated by the DPRC from the pool of ICIDs.
*/
#define DPRC_GET_ICID_FROM_POOL (uint16_t)(~(0))
/**
* Set this value as the portal_id value in dprc_cfg structure when creating a
* container, in case the portal ID is not specifically selected by the
* user and should be allocated by the DPRC from the pool of portal ids.
*/
#define DPRC_GET_PORTAL_ID_FROM_POOL (int)(~(0))
/**
* dprc_get_container_id() - Get container ID associated with a given portal.
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @container_id: Requested container ID
*
* Return: '0' on Success; Error code otherwise.
*/
int dprc_get_container_id(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
int *container_id);
/**
* dprc_open() - Open DPRC object for use
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @container_id: Container ID to open
* @token: Returned token of DPRC object
*
* Return: '0' on Success; Error code otherwise.
*
* @warning Required before any operation on the object.
*/
int dprc_open(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
int container_id,
uint16_t *token);
/**
* dprc_close() - Close the control session of the object
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPRC object
*
* After this function is called, no further operations are
* allowed on the object without opening a new control session.
*
* Return: '0' on Success; Error code otherwise.
*/
int dprc_close(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token);
/**
* Container general options
*
* These options may be selected at container creation by the container creator
* and can be retrieved using dprc_get_attributes()
*/
/* Spawn Policy Option allowed - Indicates that the new container is allowed
* to spawn and have its own child containers.
*/
#define DPRC_CFG_OPT_SPAWN_ALLOWED 0x00000001
/* General Container allocation policy - Indicates that the new container is
* allowed to allocate requested resources from its parent container; if not
* set, the container is only allowed to use resources in its own pools; Note
* that this is a container's global policy, but the parent container may
* override it and set specific quota per resource type.
*/
#define DPRC_CFG_OPT_ALLOC_ALLOWED 0x00000002
/* Object initialization allowed - software context associated with this
* container is allowed to invoke object initialization operations.
*/
#define DPRC_CFG_OPT_OBJ_CREATE_ALLOWED 0x00000004
/* Topology change allowed - software context associated with this
* container is allowed to invoke topology operations, such as attach/detach
* of network objects.
*/
#define DPRC_CFG_OPT_TOPOLOGY_CHANGES_ALLOWED 0x00000008
/* AIOP - Indicates that container belongs to AIOP. */
#define DPRC_CFG_OPT_AIOP 0x00000020
/* IRQ Config - Indicates that the container allowed to configure its IRQs.*/
#define DPRC_CFG_OPT_IRQ_CFG_ALLOWED 0x00000040
/**
* struct dprc_cfg - Container configuration options
* @icid: Container's ICID; if set to 'DPRC_GET_ICID_FROM_POOL', a free
* ICID value is allocated by the DPRC
* @portal_id: Portal ID; if set to 'DPRC_GET_PORTAL_ID_FROM_POOL', a free
* portal ID is allocated by the DPRC
* @options: Combination of 'DPRC_CFG_OPT_<X>' options
* @label: Object's label
*/
struct dprc_cfg {
uint16_t icid;
int portal_id;
uint64_t options;
char label[16];
};
/**
* dprc_create_container() - Create child container
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPRC object
* @cfg: Child container configuration
* @child_container_id: Returned child container ID
* @child_portal_offset: Returned child portal offset from MC portal base
*
*
* Return: '0' on Success; Error code otherwise.
*/
int dprc_create_container(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
struct dprc_cfg *cfg,
int *child_container_id,
uint64_t *child_portal_offset);
/**
* dprc_destroy_container() - Destroy child container.
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPRC object
* @child_container_id: ID of the container to destroy
*
* This function terminates the child container, so following this call the
* child container ID becomes invalid.
*
* Notes:
* - All resources and objects of the destroyed container are returned to the
* parent container or destroyed if were created be the destroyed container.
* - This function destroy all the child containers of the specified
* container prior to destroying the container itself.
*
* warning: Only the parent container is allowed to destroy a child policy
* Container 0 can't be destroyed
*
* Return: '0' on Success; Error code otherwise.
*
*/
int dprc_destroy_container(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
int child_container_id);
/**
* dprc_reset_container - Reset child container.
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPRC object
* @child_container_id: ID of the container to reset
*
* In case a software context crashes or becomes non-responsive, the parent
* may wish to reset its resources container before the software context is
* restarted.
*
* This routine informs all objects assigned to the child container that the
* container is being reset, so they may perform any cleanup operations that are
* needed. All objects handles that were owned by the child container shall be
* closed.
*
* Note that such request may be submitted even if the child software context
* has not crashed, but the resulting object cleanup operations will not be
* aware of that.
*
* Return: '0' on Success; Error code otherwise.
*/
int dprc_reset_container(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
int child_container_id);
/**
* struct dprc_attributes - Container attributes
* @container_id: Container's ID
* @icid: Container's ICID
* @portal_id: Container's portal ID
* @options: Container's options as set at container's creation
* @version: DPRC version
*/
struct dprc_attributes {
int container_id;
uint16_t icid;
int portal_id;
uint64_t options;
};
/**
* dprc_get_attributes() - Obtains container attributes
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPRC object
* @attributes: Returned container attributes
*
* Return: '0' on Success; Error code otherwise.
*/
int dprc_get_attributes(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
struct dprc_attributes *attributes);
/**
* dprc_get_obj_count() - Obtains the number of objects in the DPRC
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPRC object
* @obj_count: Number of objects assigned to the DPRC
*
* Return: '0' on Success; Error code otherwise.
*/
int dprc_get_obj_count(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
int *obj_count);
/* Objects Attributes Flags */
/* Opened state - Indicates that an object is open by at least one owner */
#define DPRC_OBJ_STATE_OPEN 0x00000001
/* Plugged state - Indicates that the object is plugged */
#define DPRC_OBJ_STATE_PLUGGED 0x00000002
/**
* Shareability flag - Object flag indicating no memory shareability.
* the object generates memory accesses that are non coherent with other
* masters;
* user is responsible for proper memory handling through IOMMU configuration.
*/
#define DPRC_OBJ_FLAG_NO_MEM_SHAREABILITY 0x0001
/**
* struct dprc_obj_desc - Object descriptor, returned from dprc_get_obj()
* @type: Type of object: NULL terminated string
* @id: ID of logical object resource
* @vendor: Object vendor identifier
* @ver_major: Major version number
* @ver_minor: Minor version number
* @irq_count: Number of interrupts supported by the object
* @region_count: Number of mappable regions supported by the object
* @state: Object state: combination of DPRC_OBJ_STATE_ states
* @label: Object label
* @flags: Object's flags
*/
struct dprc_obj_desc {
char type[16];
int id;
uint16_t vendor;
uint16_t ver_major;
uint16_t ver_minor;
uint8_t irq_count;
uint8_t region_count;
uint32_t state;
char label[16];
uint16_t flags;
};
/**
* dprc_get_obj() - Get general information on an object
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPRC object
* @obj_index: Index of the object to be queried (< obj_count)
* @obj_desc: Returns the requested object descriptor
*
* The object descriptors are retrieved one by one by incrementing
* obj_index up to (not including) the value of obj_count returned
* from dprc_get_obj_count(). dprc_get_obj_count() must
* be called prior to dprc_get_obj().
*
* Return: '0' on Success; Error code otherwise.
*/
int dprc_get_obj(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
int obj_index,
struct dprc_obj_desc *obj_desc);
/**
* dprc_get_res_count() - Obtains the number of free resources that are
* assigned to this container, by pool type
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPRC object
* @type: pool type
* @res_count: Returned number of free resources of the given
* resource type that are assigned to this DPRC
*
* Return: '0' on Success; Error code otherwise.
*/
int dprc_get_res_count(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
char *type,
int *res_count);
/**
* enum dprc_iter_status - Iteration status
* @DPRC_ITER_STATUS_FIRST: Perform first iteration
* @DPRC_ITER_STATUS_MORE: Indicates more/next iteration is needed
* @DPRC_ITER_STATUS_LAST: Indicates last iteration
*/
enum dprc_iter_status {
DPRC_ITER_STATUS_FIRST = 0,
DPRC_ITER_STATUS_MORE = 1,
DPRC_ITER_STATUS_LAST = 2
};
/**
* struct dprc_res_ids_range_desc - Resource ID range descriptor
* @base_id: Base resource ID of this range
* @last_id: Last resource ID of this range
* @iter_status: Iteration status - should be set to DPRC_ITER_STATUS_FIRST at
* first iteration; while the returned marker is DPRC_ITER_STATUS_MORE,
* additional iterations are needed, until the returned marker is
* DPRC_ITER_STATUS_LAST
*/
struct dprc_res_ids_range_desc {
int base_id;
int last_id;
enum dprc_iter_status iter_status;
};
/**
* dprc_get_res_ids() - Obtains IDs of free resources in the container
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPRC object
* @type: pool type
* @range_desc: range descriptor
*
* Return: '0' on Success; Error code otherwise.
*/
int dprc_get_res_ids(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
char *type,
struct dprc_res_ids_range_desc *range_desc);
/* Region flags */
/* Cacheable - Indicates that region should be mapped as cacheable */
#define DPRC_REGION_CACHEABLE 0x00000001
/**
* enum dprc_region_type - Region type
* @DPRC_REGION_TYPE_MC_PORTAL: MC portal region
* @DPRC_REGION_TYPE_QBMAN_PORTAL: Qbman portal region
*/
enum dprc_region_type {
DPRC_REGION_TYPE_MC_PORTAL,
DPRC_REGION_TYPE_QBMAN_PORTAL
};
/**
* struct dprc_region_desc - Mappable region descriptor
* @base_offset: Region offset from region's base address.
* For DPMCP and DPRC objects, region base is offset from SoC MC portals
* base address; For DPIO, region base is offset from SoC QMan portals
* base address
* @size: Region size (in bytes)
* @flags: Region attributes
* @type: Portal region type
*/
struct dprc_region_desc {
uint32_t base_offset;
uint32_t size;
uint32_t flags;
enum dprc_region_type type;
};
/**
* dprc_get_obj_region() - Get region information for a specified object.
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPRC object
* @obj_type: Object type as returned in dprc_get_obj()
* @obj_id: Unique object instance as returned in dprc_get_obj()
* @region_index: The specific region to query
* @region_desc: Returns the requested region descriptor
*
* Return: '0' on Success; Error code otherwise.
*/
int dprc_get_obj_region(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
char *obj_type,
int obj_id,
uint8_t region_index,
struct dprc_region_desc *region_desc);
/**
* struct dprc_endpoint - Endpoint description for link connect/disconnect
* operations
* @type: Endpoint object type: NULL terminated string
* @id: Endpoint object ID
* @if_id: Interface ID; should be set for endpoints with multiple
* interfaces ("dpsw", "dpdmux"); for others, always set to 0
*/
struct dprc_endpoint {
char type[16];
int id;
uint16_t if_id;
};
/**
* struct dprc_connection_cfg - Connection configuration.
* Used for virtual connections only
* @committed_rate: Committed rate (Mbits/s)
* @max_rate: Maximum rate (Mbits/s)
*/
struct dprc_connection_cfg {
uint32_t committed_rate;
uint32_t max_rate;
};
/**
* dprc_connect() - Connect two endpoints to create a network link between them
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPRC object
* @endpoint1: Endpoint 1 configuration parameters
* @endpoint2: Endpoint 2 configuration parameters
* @cfg: Connection configuration. The connection configuration is ignored for
* connections made to DPMAC objects, where rate is retrieved from the
* MAC configuration.
*
* Return: '0' on Success; Error code otherwise.
*/
int dprc_connect(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
const struct dprc_endpoint *endpoint1,
const struct dprc_endpoint *endpoint2,
const struct dprc_connection_cfg *cfg);
/**
* dprc_disconnect() - Disconnect one endpoint to remove its network connection
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPRC object
* @endpoint: Endpoint configuration parameters
*
* Return: '0' on Success; Error code otherwise.
*/
int dprc_disconnect(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
const struct dprc_endpoint *endpoint);
/**
* dprc_get_connection() - Get connected endpoint and link status if connection
* exists.
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPRC object
* @endpoint1: Endpoint 1 configuration parameters
* @endpoint2: Returned endpoint 2 configuration parameters
* @state: Returned link state:
* 1 - link is up;
* 0 - link is down;
* -1 - no connection (endpoint2 information is irrelevant)
*
* Return: '0' on Success; -ENAVAIL if connection does not exist.
*/
int dprc_get_connection(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
const struct dprc_endpoint *endpoint1,
struct dprc_endpoint *endpoint2,
int *state);
/**
* dprc_get_api_version - Retrieve DPRC Major and Minor version info.
*
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @major_ver: DPRC major version
* @minor_ver: DPRC minor version
*
* Return: '0' on Success; Error code otherwise.
*/
int dprc_get_api_version(struct fsl_mc_io *mc_io,
u32 cmd_flags,
u16 *major_ver,
u16 *minor_ver);
#endif /* _FSL_DPRC_H */
@@ -0,0 +1,67 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright (C) 2014 Freescale Semiconductor
*/
#ifndef __FSL_MC_H__
#define __FSL_MC_H__
#include <common.h>
#define MC_CCSR_BASE_ADDR \
((struct mc_ccsr_registers __iomem *)0x8340000)
#define GCR1_P1_STOP BIT(31)
#define GCR1_P2_STOP BIT(30)
#define GCR1_P1_DE_RST BIT(23)
#define GCR1_P2_DE_RST BIT(22)
#define GCR1_M1_DE_RST BIT(15)
#define GCR1_M2_DE_RST BIT(14)
#define GCR1_M_ALL_DE_RST (GCR1_M1_DE_RST | GCR1_M2_DE_RST)
#define GSR_FS_MASK 0x3fffffff
#define SOC_MC_PORTALS_BASE_ADDR ((void __iomem *)0x00080C000000)
#define SOC_QBMAN_PORTALS_BASE_ADDR ((void __iomem *)0x000818000000)
#define SOC_MC_PORTAL_STRIDE 0x10000
#define SOC_MC_PORTAL_ADDR(_portal_id) \
((void __iomem *)((uintptr_t)SOC_MC_PORTALS_BASE_ADDR + \
(_portal_id) * SOC_MC_PORTAL_STRIDE))
#define MC_PORTAL_OFFSET_TO_PORTAL_ID(_portal_offset) \
((_portal_offset) / SOC_MC_PORTAL_STRIDE)
struct mc_ccsr_registers {
u32 reg_gcr1;
u32 reserved1;
u32 reg_gsr;
u32 reserved2;
u32 reg_sicbalr;
u32 reg_sicbahr;
u32 reg_sicapr;
u32 reserved3;
u32 reg_mcfbalr;
u32 reg_mcfbahr;
u32 reg_mcfapr;
u32 reserved4[0x2f1];
u32 reg_psr;
u32 reserved5;
u32 reg_brr[2];
u32 reserved6[0x80];
u32 reg_error[];
};
void fdt_fsl_mc_fixup_iommu_map_entry(void *blob);
int get_mc_boot_status(void);
int get_dpl_apply_status(void);
int is_lazy_dpl_addr_valid(void);
void fdt_fixup_mc_ddr(u64 *base, u64 *size);
#ifdef CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET
int get_aiop_apply_status(void);
#endif
u64 mc_get_dram_addr(void);
unsigned long mc_get_dram_block_size(void);
int fsl_mc_ldpaa_init(bd_t *bis);
int fsl_mc_ldpaa_exit(bd_t *bd);
void mc_env_boot(void);
#endif
@@ -0,0 +1,182 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/* Copyright 2013-2016 Freescale Semiconductor, Inc.
* Copyright 2017 NXP
*/
#ifndef __FSL_MC_CMD_H
#define __FSL_MC_CMD_H
#define MC_CMD_NUM_OF_PARAMS 7
#define MAKE_UMASK64(_width) \
((uint64_t)((_width) < 64 ? ((uint64_t)1 << (_width)) - 1 : -1))
static inline uint64_t mc_enc(int lsoffset, int width, uint64_t val)
{
return (uint64_t)(((uint64_t)val & MAKE_UMASK64(width)) << lsoffset);
}
static inline uint64_t mc_dec(uint64_t val, int lsoffset, int width)
{
return (uint64_t)((val >> lsoffset) & MAKE_UMASK64(width));
}
struct mc_command {
uint64_t header;
uint64_t params[MC_CMD_NUM_OF_PARAMS];
};
struct mc_rsp_create {
__le32 object_id;
};
struct mc_rsp_api_ver {
__le16 major_ver;
__le16 minor_ver;
};
enum mc_cmd_status {
MC_CMD_STATUS_OK = 0x0, /*!< Completed successfully */
MC_CMD_STATUS_READY = 0x1, /*!< Ready to be processed */
MC_CMD_STATUS_AUTH_ERR = 0x3, /*!< Authentication error */
MC_CMD_STATUS_NO_PRIVILEGE = 0x4, /*!< No privilege */
MC_CMD_STATUS_DMA_ERR = 0x5, /*!< DMA or I/O error */
MC_CMD_STATUS_CONFIG_ERR = 0x6, /*!< Configuration error */
MC_CMD_STATUS_TIMEOUT = 0x7, /*!< Operation timed out */
MC_CMD_STATUS_NO_RESOURCE = 0x8, /*!< No resources */
MC_CMD_STATUS_NO_MEMORY = 0x9, /*!< No memory available */
MC_CMD_STATUS_BUSY = 0xA, /*!< Device is busy */
MC_CMD_STATUS_UNSUPPORTED_OP = 0xB, /*!< Unsupported operation */
MC_CMD_STATUS_INVALID_STATE = 0xC /*!< Invalid state */
};
/*
* MC command flags
*/
/* High priority flag */
#define MC_CMD_FLAG_PRI 0x00008000
/* No flags */
#define MC_CMD_NO_FLAGS 0x00000000
/* Command completion flag */
#define MC_CMD_FLAG_INTR_DIS 0x01000000
#define MC_CMD_HDR_CMDID_O 48 /* Command ID field offset */
#define MC_CMD_HDR_CMDID_S 16 /* Command ID field size */
#define MC_CMD_HDR_STATUS_O 16 /* Status field offset */
#define MC_CMD_HDR_TOKEN_O 32 /* Token field offset */
#define MC_CMD_HDR_TOKEN_S 16 /* Token field size */
#define MC_CMD_HDR_STATUS_S 8 /* Status field size*/
#define MC_CMD_HDR_FLAGS_O 0 /* Flags field offset */
#define MC_CMD_HDR_FLAGS_S 32 /* Flags field size*/
#define MC_CMD_HDR_FLAGS_MASK 0x0000FFFF /* Command flags mask */
#define MC_CMD_HDR_READ_STATUS(_hdr) \
((enum mc_cmd_status)mc_dec((_hdr), \
MC_CMD_HDR_STATUS_O, MC_CMD_HDR_STATUS_S))
#define MC_CMD_HDR_READ_TOKEN(_hdr) \
((uint16_t)mc_dec((_hdr), MC_CMD_HDR_TOKEN_O, MC_CMD_HDR_TOKEN_S))
#define MC_PREP_OP(_ext, _param, _offset, _width, _type, _arg) \
((_ext)[_param] |= cpu_to_le64(mc_enc((_offset), (_width), _arg)))
#define MC_EXT_OP(_ext, _param, _offset, _width, _type, _arg) \
(_arg = (_type)mc_dec(cpu_to_le64(_ext[_param]), (_offset), (_width)))
#define MC_CMD_OP(_cmd, _param, _offset, _width, _type, _arg) \
((_cmd).params[_param] |= mc_enc((_offset), (_width), _arg))
#define MC_RSP_OP(_cmd, _param, _offset, _width, _type, _arg) \
(_arg = (_type)mc_dec(_cmd.params[_param], (_offset), (_width)))
/* cmd, param, offset, width, type, arg_name */
#define MC_CMD_READ_OBJ_ID(cmd, obj_id) \
MC_RSP_OP(cmd, 0, 0, 32, uint32_t, obj_id)
/* cmd, param, offset, width, type, arg_name */
#define CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, object_id) \
MC_CMD_OP(cmd, 0, 0, 32, uint32_t, object_id)
static inline uint64_t mc_encode_cmd_header(uint16_t cmd_id,
uint32_t cmd_flags,
uint16_t token)
{
uint64_t hdr = 0;
hdr = mc_enc(MC_CMD_HDR_CMDID_O, MC_CMD_HDR_CMDID_S, cmd_id);
hdr |= mc_enc(MC_CMD_HDR_FLAGS_O, MC_CMD_HDR_FLAGS_S,
(cmd_flags & MC_CMD_HDR_FLAGS_MASK));
hdr |= mc_enc(MC_CMD_HDR_TOKEN_O, MC_CMD_HDR_TOKEN_S, token);
hdr |= mc_enc(MC_CMD_HDR_STATUS_O, MC_CMD_HDR_STATUS_S,
MC_CMD_STATUS_READY);
return hdr;
}
/**
* mc_write_command - writes a command to a Management Complex (MC) portal
*
* @portal: pointer to an MC portal
* @cmd: pointer to a filled command
*/
static inline void mc_write_command(struct mc_command __iomem *portal,
struct mc_command *cmd)
{
int i;
/* copy command parameters into the portal */
for (i = 0; i < MC_CMD_NUM_OF_PARAMS; i++)
writeq(cmd->params[i], &portal->params[i]);
/* submit the command by writing the header */
writeq(cmd->header, &portal->header);
}
/**
* mc_read_response - reads the response for the last MC command from a
* Management Complex (MC) portal
*
* @portal: pointer to an MC portal
* @resp: pointer to command response buffer
*
* Returns MC_CMD_STATUS_OK on Success; Error code otherwise.
*/
static inline enum mc_cmd_status mc_read_response(
struct mc_command __iomem *portal,
struct mc_command *resp)
{
int i;
enum mc_cmd_status status;
/* Copy command response header from MC portal: */
resp->header = readq(&portal->header);
status = MC_CMD_HDR_READ_STATUS(resp->header);
if (status != MC_CMD_STATUS_OK)
return status;
/* Copy command response data from MC portal: */
for (i = 0; i < MC_CMD_NUM_OF_PARAMS; i++)
resp->params[i] = readq(&portal->params[i]);
return status;
}
/**
* mc_read_version - read version of the given cmd
*
* @cmd: pointer to a filled command
* @major_version: major version value for the given cmd
* @minor_version: minor version value for the given cmd
*/
static inline void mc_cmd_read_api_version(struct mc_command *cmd,
u16 *major_ver,
u16 *minor_ver)
{
struct mc_rsp_api_ver *rsp_params;
rsp_params = (struct mc_rsp_api_ver *)cmd->params;
*major_ver = le16_to_cpu(rsp_params->major_ver);
*minor_ver = le16_to_cpu(rsp_params->minor_ver);
}
#endif /* __FSL_MC_CMD_H */
@@ -0,0 +1,71 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright 2014-2016 Freescale Semiconductor, Inc.
* Copyright 2017 NXP
*/
#ifndef _FSL_MC_PRIVATE_H_
#define _FSL_MC_PRIVATE_H_
#include <errno.h>
#include <malloc.h>
#include <asm/io.h>
#include <linux/compat.h>
#include <linux/types.h>
#include <linux/stringify.h>
#include <phy.h>
#include <fsl-mc/fsl_mc_sys.h>
#include <fsl-mc/fsl_mc_cmd.h>
#include <fsl-mc/fsl_dprc.h>
#include <fsl-mc/fsl_dpbp.h>
#include <fsl-mc/fsl_dpni.h>
extern struct fsl_mc_io *dflt_mc_io;
/**
* struct dpbp_node - DPBP strucuture
* @uint16_t handle: DPBP object handle
* @struct dpbp_attr: DPBP attribute
*/
struct fsl_dpbp_obj {
uint32_t dpbp_id;
uint16_t dpbp_handle;
struct dpbp_attr dpbp_attr;
};
extern struct fsl_dpbp_obj *dflt_dpbp;
/**
* struct fsl_dpio_obj - DPIO strucuture
* @int dpio_id: DPIO id
* @struct qbman_swp *sw_portal: SW portal object
*/
struct fsl_dpio_obj {
uint32_t dpio_id;
uint16_t dpio_handle;
struct qbman_swp *sw_portal; /** SW portal object */
};
extern struct fsl_dpio_obj *dflt_dpio;
/**
* struct dpni_node - DPNI strucuture
* @int dpni_id: DPNI id
* @uint16_t handle: DPNI object handle
* @struct dpni_attr: DPNI attributes
* @struct dpni_buffer_layout: DPNI buffer layout
*/
struct fsl_dpni_obj {
uint32_t dpni_id;
uint16_t dpni_handle;
struct dpni_attr dpni_attrs;
struct dpni_buffer_layout buf_layout;
};
extern struct fsl_dpni_obj *dflt_dpni;
int mc_init(u64 mc_fw_addr, u64 mc_dpc_addr);
int ldpaa_eth_init(int dpmac_id, phy_interface_t enet_if);
int mc_apply_dpl(u64 mc_dpl_addr);
#endif /* _FSL_MC_PRIVATE_H_ */
@@ -0,0 +1,25 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Freescale Layerscape Management Complex (MC) Environment-specific code
*
* Copyright (C) 2014 Freescale Semiconductor, Inc.
*/
#ifndef _FSL_MC_SYS_H
#define _FSL_MC_SYS_H
#include <asm/io.h>
struct mc_command;
/*
* struct mc_portal_wrapper - MC command portal wrapper object
*/
struct fsl_mc_io {
struct mc_command __iomem *mmio_regs;
};
int mc_send_command(struct fsl_mc_io *mc_io,
struct mc_command *cmd);
#endif /* _FSL_MC_SYS_H */
@@ -0,0 +1,86 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright (C) 2014 Freescale Semiconductor
*/
#ifndef _FSL_QBMAN_BASE_H
#define _FSL_QBMAN_BASE_H
/* Descriptor for a QBMan instance on the SoC. On partitions/targets that do not
* control this QBMan instance, these values may simply be place-holders. The
* idea is simply that we be able to distinguish between them, eg. so that SWP
* descriptors can identify which QBMan instance they belong to. */
struct qbman_block_desc {
void *ccsr_reg_bar; /* CCSR register map */
int irq_rerr; /* Recoverable error interrupt line */
int irq_nrerr; /* Non-recoverable error interrupt line */
};
/* Descriptor for a QBMan software portal, expressed in terms that make sense to
* the user context. Ie. on MC, this information is likely to be true-physical,
* and instantiated statically at compile-time. On GPP, this information is
* likely to be obtained via "discovery" over a partition's "layerscape bus"
* (ie. in response to a MC portal command), and would take into account any
* virtualisation of the GPP user's address space and/or interrupt numbering. */
struct qbman_swp_desc {
const struct qbman_block_desc *block; /* The QBMan instance */
void *cena_bar; /* Cache-enabled portal register map */
void *cinh_bar; /* Cache-inhibited portal register map */
};
/* Driver object for managing a QBMan portal */
struct qbman_swp;
/* Place-holder for FDs, we represent it via the simplest form that we need for
* now. Different overlays may be needed to support different options, etc. (It
* is impractical to define One True Struct, because the resulting encoding
* routines (lots of read-modify-writes) would be worst-case performance whether
* or not circumstances required them.)
*
* Note, as with all data-structures exchanged between software and hardware (be
* they located in the portal register map or DMA'd to and from main-memory),
* the driver ensures that the caller of the driver API sees the data-structures
* in host-endianness. "struct qbman_fd" is no exception. The 32-bit words
* contained within this structure are represented in host-endianness, even if
* hardware always treats them as little-endian. As such, if any of these fields
* are interpreted in a binary (rather than numerical) fashion by hardware
* blocks (eg. accelerators), then the user should be careful. We illustrate
* with an example;
*
* Suppose the desired behaviour of an accelerator is controlled by the "frc"
* field of the FDs that are sent to it. Suppose also that the behaviour desired
* by the user corresponds to an "frc" value which is expressed as the literal
* sequence of bytes 0xfe, 0xed, 0xab, and 0xba. So "frc" should be the 32-bit
* value in which 0xfe is the first byte and 0xba is the last byte, and as
* hardware is little-endian, this amounts to a 32-bit "value" of 0xbaabedfe. If
* the software is little-endian also, this can simply be achieved by setting
* frc=0xbaabedfe. On the other hand, if software is big-endian, it should set
* frc=0xfeedabba! The best away of avoiding trouble with this sort of thing is
* to treat the 32-bit words as numerical values, in which the offset of a field
* from the beginning of the first byte (as required or generated by hardware)
* is numerically encoded by a left-shift (ie. by raising the field to a
* corresponding power of 2). Ie. in the current example, software could set
* "frc" in the following way, and it would work correctly on both little-endian
* and big-endian operation;
* fd.frc = (0xfe << 0) | (0xed << 8) | (0xab << 16) | (0xba << 24);
*/
struct qbman_fd {
union {
uint32_t words[8];
struct qbman_fd_simple {
uint32_t addr_lo;
uint32_t addr_hi;
uint32_t len;
/* offset in the MS 16 bits, BPID in the LS 16 bits */
uint32_t bpid_offset;
uint32_t frc; /* frame context */
/* "err", "va", "cbmt", "asal", [...] */
uint32_t ctrl;
/* flow context */
uint32_t flc_lo;
uint32_t flc_hi;
} simple;
};
};
#endif /* !_FSL_QBMAN_BASE_H */
@@ -0,0 +1,174 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright (C) 2014 Freescale Semiconductor
*/
#ifndef _FSL_QBMAN_PORTAL_H
#define _FSL_QBMAN_PORTAL_H
#include <fsl-mc/fsl_qbman_base.h>
/* Create and destroy a functional object representing the given QBMan portal
* descriptor. */
struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *);
/************/
/* Dequeues */
/************/
/* See the QBMan driver API documentation for details on the enqueue
* mechanisms. NB: the use of a 'ldpaa_' prefix for this type is because it is
* primarily used by the "DPIO" layer that sits above (and hides) the QBMan
* driver. The structure is defined in the DPIO interface, but to avoid circular
* dependencies we just pre/re-declare it here opaquely. */
struct ldpaa_dq;
/* ------------------- */
/* Pull-mode dequeuing */
/* ------------------- */
struct qbman_pull_desc {
uint32_t dont_manipulate_directly[6];
};
/* Clear the contents of a descriptor to default/starting state. */
void qbman_pull_desc_clear(struct qbman_pull_desc *);
/* If not called, or if called with 'storage' as NULL, the result pull dequeues
* will produce results to DQRR. If 'storage' is non-NULL, then results are
* produced to the given memory location (using the physical/DMA address which
* the caller provides in 'storage_phys'), and 'stash' controls whether or not
* those writes to main-memory express a cache-warming attribute. */
void qbman_pull_desc_set_storage(struct qbman_pull_desc *,
struct ldpaa_dq *storage,
dma_addr_t storage_phys,
int stash);
/* numframes must be between 1 and 16, inclusive */
void qbman_pull_desc_set_numframes(struct qbman_pull_desc *, uint8_t numframes);
/* token is the value that shows up in the dequeue results that can be used to
* detect when the results have been published, and is not really used when
* dequeue results go to DQRR. The easiest technique is to zero result "storage"
* before issuing a pull dequeue, and use any non-zero 'token' value. */
void qbman_pull_desc_set_token(struct qbman_pull_desc *, uint8_t token);
/* Exactly one of the following descriptor "actions" should be set. (Calling any
* one of these will replace the effect of any prior call to one of these.)
* - pull dequeue from the given frame queue (FQ)
* - pull dequeue from any FQ in the given work queue (WQ)
* - pull dequeue from any FQ in any WQ in the given channel
*/
void qbman_pull_desc_set_fq(struct qbman_pull_desc *, uint32_t fqid);
/* Issue the pull dequeue command */
int qbman_swp_pull(struct qbman_swp *, struct qbman_pull_desc *);
/* -------------------------------- */
/* Polling DQRR for dequeue results */
/* -------------------------------- */
/* NULL return if there are no unconsumed DQRR entries. Returns a DQRR entry
* only once, so repeated calls can return a sequence of DQRR entries, without
* requiring they be consumed immediately or in any particular order. */
const struct ldpaa_dq *qbman_swp_dqrr_next(struct qbman_swp *);
/* Consume DQRR entries previously returned from qbman_swp_dqrr_next(). */
void qbman_swp_dqrr_consume(struct qbman_swp *, const struct ldpaa_dq *);
/* ------------------------------------------------- */
/* Polling user-provided storage for dequeue results */
/* ------------------------------------------------- */
/* Only used for user-provided storage of dequeue results, not DQRR. Prior to
* being used, the storage must set "oldtoken", so that the driver notices when
* hardware has filled it in with results using a "newtoken". NB, for efficiency
* purposes, the driver will perform any required endianness conversion to
* ensure that the user's dequeue result storage is in host-endian format
* (whether or not that is the same as the little-endian format that hardware
* DMA'd to the user's storage). As such, once the user has called
* qbman_dq_entry_has_newtoken() and been returned a valid dequeue result, they
* should not call it again on the same memory location (except of course if
* another dequeue command has been executed to produce a new result to that
* location).
*/
void qbman_dq_entry_set_oldtoken(struct ldpaa_dq *,
unsigned int num_entries,
uint8_t oldtoken);
int qbman_dq_entry_has_newtoken(struct qbman_swp *,
const struct ldpaa_dq *,
uint8_t newtoken);
/* -------------------------------------------------------- */
/* Parsing dequeue entries (DQRR and user-provided storage) */
/* -------------------------------------------------------- */
/* DQRR entries may contain non-dequeue results, ie. notifications */
int qbman_dq_entry_is_DQ(const struct ldpaa_dq *);
/************/
/* Enqueues */
/************/
struct qbman_eq_desc {
uint32_t dont_manipulate_directly[8];
};
/* Clear the contents of a descriptor to default/starting state. */
void qbman_eq_desc_clear(struct qbman_eq_desc *);
/* Exactly one of the following descriptor "actions" should be set. (Calling
* any one of these will replace the effect of any prior call to one of these.)
* - enqueue without order-restoration
* - enqueue with order-restoration
* - fill a hole in the order-restoration sequence, without any enqueue
* - advance NESN (Next Expected Sequence Number), without any enqueue
* 'respond_success' indicates whether an enqueue response should be DMA'd
* after success (otherwise a response is DMA'd only after failure).
* 'incomplete' indicates that other fragments of the same 'seqnum' are yet to
* be enqueued.
*/
void qbman_eq_desc_set_no_orp(struct qbman_eq_desc *, int respond_success);
void qbman_eq_desc_set_response(struct qbman_eq_desc *,
dma_addr_t storage_phys,
int stash);
/* token is the value that shows up in an enqueue response that can be used to
* detect when the results have been published. The easiest technique is to zero
* result "storage" before issuing an enqueue, and use any non-zero 'token'
* value. */
void qbman_eq_desc_set_token(struct qbman_eq_desc *, uint8_t token);
/* Exactly one of the following descriptor "targets" should be set. (Calling any
* one of these will replace the effect of any prior call to one of these.)
* - enqueue to a frame queue
* - enqueue to a queuing destination
* Note, that none of these will have any affect if the "action" type has been
* set to "orp_hole" or "orp_nesn".
*/
void qbman_eq_desc_set_fq(struct qbman_eq_desc *, uint32_t fqid);
void qbman_eq_desc_set_qd(struct qbman_eq_desc *, uint32_t qdid,
uint32_t qd_bin, uint32_t qd_prio);
/* Issue an enqueue command. ('fd' should only be NULL if the "action" of the
* descriptor is "orp_hole" or "orp_nesn".) */
int qbman_swp_enqueue(struct qbman_swp *, const struct qbman_eq_desc *,
const struct qbman_fd *fd);
/*******************/
/* Buffer releases */
/*******************/
struct qbman_release_desc {
uint32_t dont_manipulate_directly[1];
};
/* Clear the contents of a descriptor to default/starting state. */
void qbman_release_desc_clear(struct qbman_release_desc *);
/* Set the ID of the buffer pool to release to */
void qbman_release_desc_set_bpid(struct qbman_release_desc *, uint32_t bpid);
/* Issue a release command. 'num_buffers' must be less than 8. */
int qbman_swp_release(struct qbman_swp *, const struct qbman_release_desc *,
const uint64_t *buffers, unsigned int num_buffers);
/*******************/
/* Buffer acquires */
/*******************/
int qbman_swp_acquire(struct qbman_swp *, uint32_t bpid, uint64_t *buffers,
unsigned int num_buffers);
#endif /* !_FSL_QBMAN_PORTAL_H */
@@ -0,0 +1,73 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright (C) 2015 Freescale Semiconductor
*/
#ifndef __LDPAA_WRIOP_H
#define __LDPAA_WRIOP_H
#include <phy.h>
#define DEFAULT_WRIOP_MDIO1_NAME "FSL_MDIO0"
#define DEFAULT_WRIOP_MDIO2_NAME "FSL_MDIO1"
#define WRIOP_MAX_PHY_NUM 2
enum wriop_port {
WRIOP1_DPMAC1 = 1,
WRIOP1_DPMAC2,
WRIOP1_DPMAC3,
WRIOP1_DPMAC4,
WRIOP1_DPMAC5,
WRIOP1_DPMAC6,
WRIOP1_DPMAC7,
WRIOP1_DPMAC8,
WRIOP1_DPMAC9,
WRIOP1_DPMAC10,
WRIOP1_DPMAC11,
WRIOP1_DPMAC12,
WRIOP1_DPMAC13,
WRIOP1_DPMAC14,
WRIOP1_DPMAC15,
WRIOP1_DPMAC16,
WRIOP1_DPMAC17,
WRIOP1_DPMAC18,
WRIOP1_DPMAC19,
WRIOP1_DPMAC20,
WRIOP1_DPMAC21,
WRIOP1_DPMAC22,
WRIOP1_DPMAC23,
WRIOP1_DPMAC24,
NUM_WRIOP_PORTS,
};
struct wriop_dpmac_info {
u8 enabled;
u8 id;
u8 board_mux;
int phy_addr[WRIOP_MAX_PHY_NUM];
phy_interface_t enet_if;
struct phy_device *phydev[WRIOP_MAX_PHY_NUM];
struct mii_dev *bus;
};
extern struct wriop_dpmac_info dpmac_info[NUM_WRIOP_PORTS];
void wriop_init_dpmac(int sd, int dpmac_id, int lane_prtcl);
void wriop_init_dpmac_enet_if(int dpmac_id, phy_interface_t enet_if);
int wriop_disable_dpmac(int dpmac_id);
int wriop_enable_dpmac(int dpmac_id);
int wriop_is_enabled_dpmac(int dpmac_id);
int wriop_set_mdio(int dpmac_id, struct mii_dev *bus);
struct mii_dev *wriop_get_mdio(int dpmac_id);
int wriop_set_phy_address(int dpmac_id, int phy_num, int address);
int wriop_get_phy_address(int dpmac_id, int phy_num);
int wriop_set_phy_dev(int dpmac_id, int phy_num, struct phy_device *phydev);
struct phy_device *wriop_get_phy_dev(int dpmac_id, int phy_num);
phy_interface_t wriop_get_enet_if(int dpmac_id);
void wriop_dpmac_disable(int dpmac_id);
void wriop_dpmac_enable(int dpmac_id);
phy_interface_t wriop_dpmac_enet_if(int dpmac_id, int lane_prtcl);
void wriop_init_dpmac_qsgmii(int sd, int lane_prtcl);
void wriop_init_rgmii(void);
#endif /* __LDPAA_WRIOP_H */