Commit decd3d0c authored by Ioana Ciornei's avatar Ioana Ciornei Committed by Greg Kroah-Hartman

staging: fsl-mc: uprev binary interface to match MC v10.x

DPAA2 will not support MC firmware versions prior to MC v10.x.
Update the MC interface code and drivers to reflect this.
   -update the object .h files and code that builds commands to include
    the new command version in the command header
   -object versions are no longer available in the object attributes,
    so remove references to them and instead get the version from the
    new get_api_version() command
   -create/destroy commands for all objects have new arguments
   -dpmng_get_container_id() is replaced by dprc_get_container_id()

This supports a hardware ABI change and thus to match the new ABI
all the above changes need to happen in a single patch.

All MC firmware versions >= 10 will be supported going forward.
Signed-off-by: default avatarIoana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: default avatarStuart Yoder <stuart.yoder@nxp.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6466dac7
......@@ -33,37 +33,48 @@
#define _FSL_DPBP_CMD_H
/* DPBP Version */
#define DPBP_VER_MAJOR 2
#define DPBP_VER_MAJOR 3
#define DPBP_VER_MINOR 2
/* Command versioning */
#define DPBP_CMD_BASE_VERSION 1
#define DPBP_CMD_ID_OFFSET 4
#define DPBP_CMD(id) ((id << DPBP_CMD_ID_OFFSET) | DPBP_CMD_BASE_VERSION)
/* Command IDs */
#define DPBP_CMDID_CLOSE 0x800
#define DPBP_CMDID_OPEN 0x804
#define DPBP_CMDID_CREATE 0x904
#define DPBP_CMDID_DESTROY 0x900
#define DPBP_CMDID_ENABLE 0x002
#define DPBP_CMDID_DISABLE 0x003
#define DPBP_CMDID_GET_ATTR 0x004
#define DPBP_CMDID_RESET 0x005
#define DPBP_CMDID_IS_ENABLED 0x006
#define DPBP_CMDID_SET_IRQ 0x010
#define DPBP_CMDID_GET_IRQ 0x011
#define DPBP_CMDID_SET_IRQ_ENABLE 0x012
#define DPBP_CMDID_GET_IRQ_ENABLE 0x013
#define DPBP_CMDID_SET_IRQ_MASK 0x014
#define DPBP_CMDID_GET_IRQ_MASK 0x015
#define DPBP_CMDID_GET_IRQ_STATUS 0x016
#define DPBP_CMDID_CLEAR_IRQ_STATUS 0x017
#define DPBP_CMDID_SET_NOTIFICATIONS 0x01b0
#define DPBP_CMDID_GET_NOTIFICATIONS 0x01b1
#define DPBP_CMDID_CLOSE DPBP_CMD(0x800)
#define DPBP_CMDID_OPEN DPBP_CMD(0x804)
#define DPBP_CMDID_CREATE DPBP_CMD(0x904)
#define DPBP_CMDID_DESTROY DPBP_CMD(0x984)
#define DPBP_CMDID_GET_API_VERSION DPBP_CMD(0xa04)
#define DPBP_CMDID_ENABLE DPBP_CMD(0x002)
#define DPBP_CMDID_DISABLE DPBP_CMD(0x003)
#define DPBP_CMDID_GET_ATTR DPBP_CMD(0x004)
#define DPBP_CMDID_RESET DPBP_CMD(0x005)
#define DPBP_CMDID_IS_ENABLED DPBP_CMD(0x006)
#define DPBP_CMDID_SET_IRQ DPBP_CMD(0x010)
#define DPBP_CMDID_GET_IRQ DPBP_CMD(0x011)
#define DPBP_CMDID_SET_IRQ_ENABLE DPBP_CMD(0x012)
#define DPBP_CMDID_GET_IRQ_ENABLE DPBP_CMD(0x013)
#define DPBP_CMDID_SET_IRQ_MASK DPBP_CMD(0x014)
#define DPBP_CMDID_GET_IRQ_MASK DPBP_CMD(0x015)
#define DPBP_CMDID_GET_IRQ_STATUS DPBP_CMD(0x016)
#define DPBP_CMDID_CLEAR_IRQ_STATUS DPBP_CMD(0x017)
#define DPBP_CMDID_SET_NOTIFICATIONS DPBP_CMD(0x01b0)
#define DPBP_CMDID_GET_NOTIFICATIONS DPBP_CMD(0x01b1)
struct dpbp_cmd_open {
__le32 dpbp_id;
};
struct dpbp_cmd_destroy {
__le32 object_id;
};
#define DPBP_ENABLE 0x1
struct dpbp_rsp_is_enabled {
......
......@@ -108,28 +108,26 @@ EXPORT_SYMBOL(dpbp_close);
/**
* dpbp_create() - Create the DPBP object.
* @mc_io: Pointer to MC portal's I/O object
* @dprc_token: Parent container token; '0' for default container
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @cfg: Configuration structure
* @token: Returned token; use in subsequent API calls
* @obj_id: Returned object id; 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.
* This function accepts an authentication token of a parent
* container that this object should be assigned to and returns
* an object id. This object_id will be used in all subsequent calls to
* this specific object.
*
* Return: '0' on Success; Error code otherwise.
*/
int dpbp_create(struct fsl_mc_io *mc_io,
u16 dprc_token,
u32 cmd_flags,
const struct dpbp_cfg *cfg,
u16 *token)
u32 *obj_id)
{
struct mc_command cmd = { 0 };
int err;
......@@ -138,7 +136,7 @@ int dpbp_create(struct fsl_mc_io *mc_io,
/* prepare command */
cmd.header = mc_encode_cmd_header(DPBP_CMDID_CREATE,
cmd_flags, 0);
cmd_flags, dprc_token);
/* send command to mc*/
err = mc_send_command(mc_io, &cmd);
......@@ -146,7 +144,7 @@ int dpbp_create(struct fsl_mc_io *mc_io,
return err;
/* retrieve response parameters */
*token = mc_cmd_hdr_read_token(&cmd);
*obj_id = mc_cmd_read_object_id(&cmd);
return 0;
}
......@@ -154,20 +152,25 @@ int dpbp_create(struct fsl_mc_io *mc_io,
/**
* dpbp_destroy() - Destroy the DPBP object and release all its resources.
* @mc_io: Pointer to MC portal's I/O object
* @dprc_token: Parent container token; '0' for default container
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPBP object
* @obj_id: ID of DPBP object
*
* Return: '0' on Success; error code otherwise.
*/
int dpbp_destroy(struct fsl_mc_io *mc_io,
u16 dprc_token,
u32 cmd_flags,
u16 token)
u32 obj_id)
{
struct dpbp_cmd_destroy *cmd_params;
struct mc_command cmd = { 0 };
/* prepare command */
cmd.header = mc_encode_cmd_header(DPBP_CMDID_DESTROY,
cmd_flags, token);
cmd_flags, dprc_token);
cmd_params = (struct dpbp_cmd_destroy *)cmd.params;
cmd_params->object_id = cpu_to_le32(obj_id);
/* send command to mc*/
return mc_send_command(mc_io, &cmd);
......@@ -610,8 +613,6 @@ int dpbp_get_attributes(struct fsl_mc_io *mc_io,
rsp_params = (struct dpbp_rsp_get_attributes *)cmd.params;
attr->bpid = le16_to_cpu(rsp_params->bpid);
attr->id = le32_to_cpu(rsp_params->id);
attr->version.major = le16_to_cpu(rsp_params->version_major);
attr->version.minor = le16_to_cpu(rsp_params->version_minor);
return 0;
}
......@@ -690,3 +691,35 @@ int dpbp_get_notifications(struct fsl_mc_io *mc_io,
return 0;
}
/**
* dpbp_get_api_version - Get Data Path Buffer Pool API version
* @mc_io: Pointer to Mc portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @major_ver: Major version of Buffer Pool API
* @minor_ver: Minor version of Buffer Pool API
*
* 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)
{
struct mc_command cmd = { 0 };
int err;
/* prepare command */
cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_API_VERSION,
cmd_flags, 0);
/* send command to mc */
err = mc_send_command(mc_io, &cmd);
if (err)
return err;
/* retrieve response parameters */
mc_cmd_read_api_version(&cmd, major_ver, minor_ver);
return 0;
}
......@@ -33,25 +33,32 @@
#define _FSL_DPMCP_CMD_H
/* Minimal supported DPMCP Version */
#define DPMCP_MIN_VER_MAJOR 3
#define DPMCP_MIN_VER_MINOR 0
#define DPMCP_MIN_VER_MAJOR 3
#define DPMCP_MIN_VER_MINOR 0
/* Command versioning */
#define DPMCP_CMD_BASE_VERSION 1
#define DPMCP_CMD_ID_OFFSET 4
#define DPMCP_CMD(id) ((id << DPMCP_CMD_ID_OFFSET) | DPMCP_CMD_BASE_VERSION)
/* Command IDs */
#define DPMCP_CMDID_CLOSE 0x800
#define DPMCP_CMDID_OPEN 0x80b
#define DPMCP_CMDID_CREATE 0x90b
#define DPMCP_CMDID_DESTROY 0x900
#define DPMCP_CMDID_GET_ATTR 0x004
#define DPMCP_CMDID_RESET 0x005
#define DPMCP_CMDID_SET_IRQ 0x010
#define DPMCP_CMDID_GET_IRQ 0x011
#define DPMCP_CMDID_SET_IRQ_ENABLE 0x012
#define DPMCP_CMDID_GET_IRQ_ENABLE 0x013
#define DPMCP_CMDID_SET_IRQ_MASK 0x014
#define DPMCP_CMDID_GET_IRQ_MASK 0x015
#define DPMCP_CMDID_GET_IRQ_STATUS 0x016
#define DPMCP_CMDID_CLOSE DPMCP_CMD(0x800)
#define DPMCP_CMDID_OPEN DPMCP_CMD(0x80b)
#define DPMCP_CMDID_CREATE DPMCP_CMD(0x90b)
#define DPMCP_CMDID_DESTROY DPMCP_CMD(0x98b)
#define DPMCP_CMDID_GET_API_VERSION DPMCP_CMD(0xa0b)
#define DPMCP_CMDID_GET_ATTR DPMCP_CMD(0x004)
#define DPMCP_CMDID_RESET DPMCP_CMD(0x005)
#define DPMCP_CMDID_SET_IRQ DPMCP_CMD(0x010)
#define DPMCP_CMDID_GET_IRQ DPMCP_CMD(0x011)
#define DPMCP_CMDID_SET_IRQ_ENABLE DPMCP_CMD(0x012)
#define DPMCP_CMDID_GET_IRQ_ENABLE DPMCP_CMD(0x013)
#define DPMCP_CMDID_SET_IRQ_MASK DPMCP_CMD(0x014)
#define DPMCP_CMDID_GET_IRQ_MASK DPMCP_CMD(0x015)
#define DPMCP_CMDID_GET_IRQ_STATUS DPMCP_CMD(0x016)
struct dpmcp_cmd_open {
__le32 dpmcp_id;
......@@ -61,6 +68,10 @@ struct dpmcp_cmd_create {
__le32 portal_id;
};
struct dpmcp_cmd_destroy {
__le32 object_id;
};
struct dpmcp_cmd_set_irq {
/* cmd word 0 */
u8 irq_index;
......
......@@ -106,28 +106,29 @@ int dpmcp_close(struct fsl_mc_io *mc_io,
/**
* dpmcp_create() - Create the DPMCP object.
* @mc_io: Pointer to MC portal's I/O object
* @dprc_token: Parent container token; '0' for default container
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @cfg: Configuration structure
* @token: Returned token; use in subsequent API calls
* @obj_id: Returned object id; use in subsequent API calls
*
* Create the DPMCP 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 dpmcp_open function to get an authentication
* token first.
* This function accepts an authentication token of a parent
* container that this object should be assigned to and returns
* an object id. This object_id will be used in all subsequent calls to
* this specific object.
*
* Return: '0' on Success; Error code otherwise.
*/
int dpmcp_create(struct fsl_mc_io *mc_io,
u16 dprc_token,
u32 cmd_flags,
const struct dpmcp_cfg *cfg,
u16 *token)
u32 *obj_id)
{
struct mc_command cmd = { 0 };
struct dpmcp_cmd_create *cmd_params;
......@@ -136,7 +137,7 @@ int dpmcp_create(struct fsl_mc_io *mc_io,
/* prepare command */
cmd.header = mc_encode_cmd_header(DPMCP_CMDID_CREATE,
cmd_flags, 0);
cmd_flags, dprc_token);
cmd_params = (struct dpmcp_cmd_create *)cmd.params;
cmd_params->portal_id = cpu_to_le32(cfg->portal_id);
......@@ -146,7 +147,7 @@ int dpmcp_create(struct fsl_mc_io *mc_io,
return err;
/* retrieve response parameters */
*token = mc_cmd_hdr_read_token(&cmd);
*obj_id = mc_cmd_read_object_id(&cmd);
return 0;
}
......@@ -154,20 +155,25 @@ int dpmcp_create(struct fsl_mc_io *mc_io,
/**
* dpmcp_destroy() - Destroy the DPMCP object and release all its resources.
* @mc_io: Pointer to MC portal's I/O object
* @dprc_token: Parent container token; '0' for default container
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPMCP object
* @obj_id: ID of DPMCP object
*
* Return: '0' on Success; error code otherwise.
*/
int dpmcp_destroy(struct fsl_mc_io *mc_io,
u16 dprc_token,
u32 cmd_flags,
u16 token)
u32 obj_id)
{
struct mc_command cmd = { 0 };
struct dpmcp_cmd_destroy *cmd_params;
/* prepare command */
cmd.header = mc_encode_cmd_header(DPMCP_CMDID_DESTROY,
cmd_flags, token);
cmd_flags, dprc_token);
cmd_params = (struct dpmcp_cmd_destroy *)cmd.params;
cmd_params->object_id = cpu_to_le32(obj_id);
/* send command to mc*/
return mc_send_command(mc_io, &cmd);
......@@ -497,8 +503,38 @@ int dpmcp_get_attributes(struct fsl_mc_io *mc_io,
/* retrieve response parameters */
rsp_params = (struct dpmcp_rsp_get_attributes *)cmd.params;
attr->id = le32_to_cpu(rsp_params->id);
attr->version.major = le16_to_cpu(rsp_params->version_major);
attr->version.minor = le16_to_cpu(rsp_params->version_minor);
return 0;
}
/**
* dpmcp_get_api_version - Get Data Path Management Command Portal API version
* @mc_io: Pointer to Mc portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @major_ver: Major version of Data Path Management Command Portal API
* @minor_ver: Minor version of Data Path Management Command Portal API
*
* Return: '0' on Success; Error code otherwise.
*/
int dpmcp_get_api_version(struct fsl_mc_io *mc_io,
u32 cmd_flags,
u16 *major_ver,
u16 *minor_ver)
{
struct mc_command cmd = { 0 };
int err;
/* prepare command */
cmd.header = mc_encode_cmd_header(DPMCP_CMDID_GET_API_VERSION,
cmd_flags, 0);
/* send command to mc */
err = mc_send_command(mc_io, &cmd);
if (err)
return err;
/* retrieve response parameters */
mc_cmd_read_api_version(&cmd, major_ver, minor_ver);
return 0;
}
......@@ -61,13 +61,15 @@ struct dpmcp_cfg {
};
int dpmcp_create(struct fsl_mc_io *mc_io,
u16 dprc_token,
u32 cmd_flags,
const struct dpmcp_cfg *cfg,
u16 *token);
const struct dpmcp_cfg *cfg,
u32 *obj_id);
int dpmcp_destroy(struct fsl_mc_io *mc_io,
u16 dprc_token,
u32 cmd_flags,
u16 token);
u32 obj_id);
int dpmcp_reset(struct fsl_mc_io *mc_io,
u32 cmd_flags,
......@@ -137,19 +139,9 @@ int dpmcp_get_irq_status(struct fsl_mc_io *mc_io,
/**
* struct dpmcp_attr - Structure representing DPMCP attributes
* @id: DPMCP object ID
* @version: DPMCP version
*/
struct dpmcp_attr {
int id;
/**
* struct version - Structure representing DPMCP version
* @major: DPMCP major version
* @minor: DPMCP minor version
*/
struct {
u16 major;
u16 minor;
} version;
};
int dpmcp_get_attributes(struct fsl_mc_io *mc_io,
......
......@@ -40,13 +40,14 @@
#ifndef __FSL_DPMNG_CMD_H
#define __FSL_DPMNG_CMD_H
/* Command IDs */
#define DPMNG_CMDID_GET_CONT_ID 0x830
#define DPMNG_CMDID_GET_VERSION 0x831
/* Command versioning */
#define DPMNG_CMD_BASE_VERSION 1
#define DPMNG_CMD_ID_OFFSET 4
struct dpmng_rsp_get_container_id {
__le32 container_id;
};
#define DPMNG_CMD(id) ((id << DPMNG_CMD_ID_OFFSET) | DPMNG_CMD_BASE_VERSION)
/* Command IDs */
#define DPMNG_CMDID_GET_VERSION DPMNG_CMD(0x831)
struct dpmng_rsp_get_version {
__le32 revision;
......
......@@ -72,36 +72,3 @@ int mc_get_version(struct fsl_mc_io *mc_io,
}
EXPORT_SYMBOL(mc_get_version);
/**
* dpmng_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 dpmng_get_container_id(struct fsl_mc_io *mc_io,
u32 cmd_flags,
int *container_id)
{
struct mc_command cmd = { 0 };
struct dpmng_rsp_get_container_id *rsp_params;
int err;
/* prepare command */
cmd.header = mc_encode_cmd_header(DPMNG_CMDID_GET_CONT_ID,
cmd_flags,
0);
/* send command to mc*/
err = mc_send_command(mc_io, &cmd);
if (err)
return err;
/* retrieve response parameters */
rsp_params = (struct dpmng_rsp_get_container_id *)cmd.params;
*container_id = le32_to_cpu(rsp_params->container_id);
return 0;
}
......@@ -41,48 +41,56 @@
#define _FSL_DPRC_CMD_H
/* Minimal supported DPRC Version */
#define DPRC_MIN_VER_MAJOR 5
#define DPRC_MIN_VER_MAJOR 6
#define DPRC_MIN_VER_MINOR 0
/* Command versioning */
#define DPRC_CMD_BASE_VERSION 1
#define DPRC_CMD_ID_OFFSET 4
#define DPRC_CMD(id) ((id << DPRC_CMD_ID_OFFSET) | DPRC_CMD_BASE_VERSION)
/* Command IDs */
#define DPRC_CMDID_CLOSE 0x800
#define DPRC_CMDID_OPEN 0x805
#define DPRC_CMDID_CREATE 0x905
#define DPRC_CMDID_GET_ATTR 0x004
#define DPRC_CMDID_RESET_CONT 0x005
#define DPRC_CMDID_SET_IRQ 0x010
#define DPRC_CMDID_GET_IRQ 0x011
#define DPRC_CMDID_SET_IRQ_ENABLE 0x012
#define DPRC_CMDID_GET_IRQ_ENABLE 0x013
#define DPRC_CMDID_SET_IRQ_MASK 0x014
#define DPRC_CMDID_GET_IRQ_MASK 0x015
#define DPRC_CMDID_GET_IRQ_STATUS 0x016
#define DPRC_CMDID_CLEAR_IRQ_STATUS 0x017
#define DPRC_CMDID_CREATE_CONT 0x151
#define DPRC_CMDID_DESTROY_CONT 0x152
#define DPRC_CMDID_SET_RES_QUOTA 0x155
#define DPRC_CMDID_GET_RES_QUOTA 0x156
#define DPRC_CMDID_ASSIGN 0x157
#define DPRC_CMDID_UNASSIGN 0x158
#define DPRC_CMDID_GET_OBJ_COUNT 0x159
#define DPRC_CMDID_GET_OBJ 0x15A
#define DPRC_CMDID_GET_RES_COUNT 0x15B
#define DPRC_CMDID_GET_RES_IDS 0x15C
#define DPRC_CMDID_GET_OBJ_REG 0x15E
#define DPRC_CMDID_SET_OBJ_IRQ 0x15F
#define DPRC_CMDID_GET_OBJ_IRQ 0x160
#define DPRC_CMDID_SET_OBJ_LABEL 0x161
#define DPRC_CMDID_GET_OBJ_DESC 0x162
#define DPRC_CMDID_CONNECT 0x167
#define DPRC_CMDID_DISCONNECT 0x168
#define DPRC_CMDID_GET_POOL 0x169
#define DPRC_CMDID_GET_POOL_COUNT 0x16A
#define DPRC_CMDID_GET_CONNECTION 0x16C
#define DPRC_CMDID_CLOSE DPRC_CMD(0x800)
#define DPRC_CMDID_OPEN DPRC_CMD(0x805)
#define DPRC_CMDID_CREATE DPRC_CMD(0x905)
#define DPRC_CMDID_GET_API_VERSION DPRC_CMD(0xa05)
#define DPRC_CMDID_GET_ATTR DPRC_CMD(0x004)
#define DPRC_CMDID_RESET_CONT DPRC_CMD(0x005)
#define DPRC_CMDID_SET_IRQ DPRC_CMD(0x010)
#define DPRC_CMDID_GET_IRQ DPRC_CMD(0x011)
#define DPRC_CMDID_SET_IRQ_ENABLE DPRC_CMD(0x012)
#define DPRC_CMDID_GET_IRQ_ENABLE DPRC_CMD(0x013)
#define DPRC_CMDID_SET_IRQ_MASK DPRC_CMD(0x014)
#define DPRC_CMDID_GET_IRQ_MASK DPRC_CMD(0x015)
#define DPRC_CMDID_GET_IRQ_STATUS DPRC_CMD(0x016)
#define DPRC_CMDID_CLEAR_IRQ_STATUS DPRC_CMD(0x017)
#define DPRC_CMDID_CREATE_CONT DPRC_CMD(0x151)
#define DPRC_CMDID_DESTROY_CONT DPRC_CMD(0x152)
#define DPRC_CMDID_GET_CONT_ID DPRC_CMD(0x830)
#define DPRC_CMDID_SET_RES_QUOTA DPRC_CMD(0x155)
#define DPRC_CMDID_GET_RES_QUOTA DPRC_CMD(0x156)
#define DPRC_CMDID_ASSIGN DPRC_CMD(0x157)
#define DPRC_CMDID_UNASSIGN DPRC_CMD(0x158)
#define DPRC_CMDID_GET_OBJ_COUNT DPRC_CMD(0x159)
#define DPRC_CMDID_GET_OBJ DPRC_CMD(0x15A)
#define DPRC_CMDID_GET_RES_COUNT DPRC_CMD(0x15B)
#define DPRC_CMDID_GET_RES_IDS DPRC_CMD(0x15C)
#define DPRC_CMDID_GET_OBJ_REG DPRC_CMD(0x15E)
#define DPRC_CMDID_SET_OBJ_IRQ DPRC_CMD(0x15F)
#define DPRC_CMDID_GET_OBJ_IRQ DPRC_CMD(0x160)
#define DPRC_CMDID_SET_OBJ_LABEL DPRC_CMD(0x161)
#define DPRC_CMDID_GET_OBJ_DESC DPRC_CMD(0x162)
#define DPRC_CMDID_CONNECT DPRC_CMD(0x167)
#define DPRC_CMDID_DISCONNECT DPRC_CMD(0x168)
#define DPRC_CMDID_GET_POOL DPRC_CMD(0x169)
#define DPRC_CMDID_GET_POOL_COUNT DPRC_CMD(0x16A)
#define DPRC_CMDID_GET_CONNECTION DPRC_CMD(0x16C)
struct dprc_cmd_open {
__le32 container_id;
......@@ -198,9 +206,6 @@ struct dprc_rsp_get_attributes {
/* response word 1 */
__le32 options;
__le32 portal_id;
/* response word 2 */
__le16 version_major;
__le16 version_minor;
};
struct dprc_cmd_set_res_quota {
......
......@@ -597,6 +597,7 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
bool mc_io_created = false;
bool msi_domain_set = false;
u16 major_ver, minor_ver;
if (WARN_ON(strcmp(mc_dev->obj_desc.type, "dprc") != 0))
return -EINVAL;
......@@ -669,13 +670,21 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
goto error_cleanup_open;
}
if (mc_bus->dprc_attr.version.major < DPRC_MIN_VER_MAJOR ||
(mc_bus->dprc_attr.version.major == DPRC_MIN_VER_MAJOR &&
mc_bus->dprc_attr.version.minor < DPRC_MIN_VER_MINOR)) {
error = dprc_get_api_version(mc_dev->mc_io, 0,
&major_ver,
&minor_ver);
if (error < 0) {
dev_err(&mc_dev->dev, "dprc_get_api_version() failed: %d\n",
error);
goto error_cleanup_open;
}
if (major_ver < DPRC_MIN_VER_MAJOR ||
(major_ver == DPRC_MIN_VER_MAJOR &&
minor_ver < DPRC_MIN_VER_MINOR)) {
dev_err(&mc_dev->dev,
"ERROR: DPRC version %d.%d not supported\n",
mc_bus->dprc_attr.version.major,
mc_bus->dprc_attr.version.minor);
major_ver, minor_ver);
error = -ENOTSUPP;
goto error_cleanup_open;
}
......
......@@ -565,8 +565,6 @@ int dprc_get_attributes(struct fsl_mc_io *mc_io,
attr->icid = le16_to_cpu(rsp_params->icid);
attr->options = le32_to_cpu(rsp_params->options);
attr->portal_id = le32_to_cpu(rsp_params->portal_id);
attr->version.major = le16_to_cpu(rsp_params->version_major);
attr->version.minor = le16_to_cpu(rsp_params->version_minor);
return 0;
}
......@@ -1386,3 +1384,66 @@ int dprc_get_connection(struct fsl_mc_io *mc_io,
return 0;
}
/**
* dprc_get_api_version - Get Data Path Resource Container API version
* @mc_io: Pointer to Mc portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @major_ver: Major version of Data Path Resource Container API
* @minor_ver: Minor version of Data Path Resource Container API
*
* 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)
{
struct mc_command cmd = { 0 };
int err;
/* prepare command */
cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_API_VERSION,
cmd_flags, 0);
/* send command to mc */
err = mc_send_command(mc_io, &cmd);
if (err)
return err;
/* retrieve response parameters */
mc_cmd_read_api_version(&cmd, major_ver, minor_ver);
return 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,
u32 cmd_flags,
int *container_id)
{
struct mc_command cmd = { 0 };
int err;
/* prepare command */
cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_CONT_ID,
cmd_flags,
0);
/* send command to mc*/
err = mc_send_command(mc_io, &cmd);
if (err)
return err;
/* retrieve response parameters */
*container_id = (int)mc_cmd_read_object_id(&cmd);
return 0;
}
......@@ -313,21 +313,6 @@ static int get_dprc_icid(struct fsl_mc_io *mc_io,
return error;
}
static int get_dprc_version(struct fsl_mc_io *mc_io,
int container_id, u16 *major, u16 *minor)
{
struct dprc_attributes attr;
int error;
error = get_dprc_attr(mc_io, container_id, &attr);
if (error == 0) {
*major = attr.version.major;
*minor = attr.version.minor;
}
return error;
}
static int translate_mc_addr(struct fsl_mc_device *mc_dev,
enum dprc_region_type mc_region_type,
u64 mc_offset, phys_addr_t *phys_addr)
......@@ -789,7 +774,7 @@ static int fsl_mc_bus_probe(struct platform_device *pdev)
if (error < 0)
goto error_cleanup_mc_io;
error = dpmng_get_container_id(mc_io, 0, &container_id);
error = dprc_get_container_id(mc_io, 0, &container_id);
if (error < 0) {
dev_err(&pdev->dev,
"dpmng_get_container_id() failed: %d\n", error);
......@@ -797,8 +782,9 @@ static int fsl_mc_bus_probe(struct platform_device *pdev)
}
memset(&obj_desc, 0, sizeof(struct dprc_obj_desc));
error = get_dprc_version(mc_io, container_id,
&obj_desc.ver_major, &obj_desc.ver_minor);
error = dprc_get_api_version(mc_io, 0,
&obj_desc.ver_major,
&obj_desc.ver_minor);
if (error < 0)
goto error_cleanup_mc_io;
......
......@@ -67,7 +67,7 @@ static u16 mc_cmd_hdr_read_cmdid(struct mc_command *cmd)
struct mc_cmd_header *hdr = (struct mc_cmd_header *)&cmd->header;
u16 cmd_id = le16_to_cpu(hdr->cmd_id);
return (cmd_id & MC_CMD_HDR_CMDID_MASK) >> MC_CMD_HDR_CMDID_SHIFT;
return cmd_id;
}
static int mc_status_to_error(enum mc_cmd_status status)
......@@ -200,7 +200,7 @@ static int mc_polling_wait_preemptible(struct fsl_mc_io *mc_io,
if (time_after_eq(jiffies, jiffies_until_timeout)) {
dev_dbg(mc_io->dev,
"MC command timed out (portal: %#llx, obj handle: %#x, command: %#x)\n",
"MC command timed out (portal: %#llx, dprc handle: %#x, command: %#x)\n",
mc_io->portal_phys_addr,
(unsigned int)mc_cmd_hdr_read_token(cmd),
(unsigned int)mc_cmd_hdr_read_cmdid(cmd));
......@@ -240,7 +240,7 @@ static int mc_polling_wait_atomic(struct fsl_mc_io *mc_io,
timeout_usecs -= MC_CMD_COMPLETION_POLLING_MAX_SLEEP_USECS;
if (timeout_usecs == 0) {
dev_dbg(mc_io->dev,
"MC command timed out (portal: %#llx, obj handle: %#x, command: %#x)\n",
"MC command timed out (portal: %#llx, dprc handle: %#x, command: %#x)\n",
mc_io->portal_phys_addr,
(unsigned int)mc_cmd_hdr_read_token(cmd),
(unsigned int)mc_cmd_hdr_read_cmdid(cmd));
......@@ -294,7 +294,7 @@ int mc_send_command(struct fsl_mc_io *mc_io, struct mc_command *cmd)
if (status != MC_CMD_STATUS_OK) {
dev_dbg(mc_io->dev,
"MC command failed: portal: %#llx, obj handle: %#x, command: %#x, status: %s (%#x)\n",
"MC command failed: portal: %#llx, dprc handle: %#x, command: %#x, status: %s (%#x)\n",
mc_io->portal_phys_addr,
(unsigned int)mc_cmd_hdr_read_token(cmd),
(unsigned int)mc_cmd_hdr_read_cmdid(cmd),
......
......@@ -58,13 +58,15 @@ struct dpbp_cfg {
};
int dpbp_create(struct fsl_mc_io *mc_io,
u16 dprc_token,
u32 cmd_flags,
const struct dpbp_cfg *cfg,
u16 *token);
u32 *obj_id);
int dpbp_destroy(struct fsl_mc_io *mc_io,
u16 dprc_token,
u32 cmd_flags,
u16 token);
u32 obj_id);
int dpbp_enable(struct fsl_mc_io *mc_io,
u32 cmd_flags,
......@@ -147,21 +149,11 @@ int dpbp_clear_irq_status(struct fsl_mc_io *mc_io,
/**
* 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 {
int id;
/**
* struct version - Structure representing DPBP version
* @major: DPBP major version
* @minor: DPBP minor version
*/
struct {
u16 major;
u16 minor;
} version;
u16 bpid;
};
......@@ -217,6 +209,11 @@ int dpbp_get_notifications(struct fsl_mc_io *mc_io,
u16 token,
struct dpbp_notification_cfg *cfg);
int dpbp_get_api_version(struct fsl_mc_io *mc_io,
u32 cmd_flags,
u16 *major_ver,
u16 *minor_ver);
/** @} */
#endif /* __FSL_DPBP_H */
......@@ -239,22 +239,12 @@ int dprc_clear_irq_status(struct fsl_mc_io *mc_io,
* @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;
u16 icid;
int portal_id;
u64 options;
/**
* struct version - DPRC version
* @major: DPRC major version
* @minor: DPRC minor version
*/
struct {
u16 major;
u16 minor;
} version;
};
int dprc_get_attributes(struct fsl_mc_io *mc_io,
......@@ -551,5 +541,14 @@ int dprc_get_connection(struct fsl_mc_io *mc_io,
struct dprc_endpoint *endpoint2,
int *state);
int dprc_get_api_version(struct fsl_mc_io *mc_io,
u32 cmd_flags,
u16 *major_ver,
u16 *minor_ver);
int dprc_get_container_id(struct fsl_mc_io *mc_io,
u32 cmd_flags,
int *container_id);
#endif /* _FSL_DPRC_H */
......@@ -49,6 +49,15 @@ struct mc_command {
u64 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 */
......@@ -73,11 +82,6 @@ enum mc_cmd_status {
/* Command completion flag */
#define MC_CMD_FLAG_INTR_DIS 0x01
#define MC_CMD_HDR_CMDID_MASK 0xFFF0
#define MC_CMD_HDR_CMDID_SHIFT 4
#define MC_CMD_HDR_TOKEN_MASK 0xFFC0
#define MC_CMD_HDR_TOKEN_SHIFT 6
static inline u64 mc_encode_cmd_header(u16 cmd_id,
u32 cmd_flags,
u16 token)
......@@ -85,10 +89,8 @@ static inline u64 mc_encode_cmd_header(u16 cmd_id,
u64 header = 0;
struct mc_cmd_header *hdr = (struct mc_cmd_header *)&header;
hdr->cmd_id = cpu_to_le16((cmd_id << MC_CMD_HDR_CMDID_SHIFT) &
MC_CMD_HDR_CMDID_MASK);
hdr->token = cpu_to_le16((token << MC_CMD_HDR_TOKEN_SHIFT) &
MC_CMD_HDR_TOKEN_MASK);
hdr->cmd_id = cpu_to_le16(cmd_id);
hdr->token = cpu_to_le16(token);
hdr->status = MC_CMD_STATUS_READY;
if (cmd_flags & MC_CMD_FLAG_PRI)
hdr->flags_hw = MC_CMD_FLAG_PRI;
......@@ -103,7 +105,26 @@ static inline u16 mc_cmd_hdr_read_token(struct mc_command *cmd)
struct mc_cmd_header *hdr = (struct mc_cmd_header *)&cmd->header;
u16 token = le16_to_cpu(hdr->token);
return (token & MC_CMD_HDR_TOKEN_MASK) >> MC_CMD_HDR_TOKEN_SHIFT;
return token;
}
static inline u32 mc_cmd_read_object_id(struct mc_command *cmd)
{
struct mc_rsp_create *rsp_params;
rsp_params = (struct mc_rsp_create *)cmd->params;
return le32_to_cpu(rsp_params->object_id);
}
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 */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment