1
0
Fork 0

staging: fsl-dpaa2/mac: Add support for new link state APIs

Add v2 of dpmac_set_link_state() and dpmac_get_link_cfg() commands.
The new version allows setting & getting advertised and supported
link options.

Signed-off-by: Valentin Catalin Neacsu <valentin-catalin.neacsu@nxp.com>
Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com>
5.4-rM2-2.2.x-imx-squashed
Ioana Radulescu 2018-10-17 20:14:24 +03:00 committed by Dong Aisheng
parent d14909d06d
commit e6254bc596
3 changed files with 126 additions and 0 deletions

View File

@ -36,9 +36,11 @@
#define DPMAC_VER_MAJOR 4
#define DPMAC_VER_MINOR 2
#define DPMAC_CMD_BASE_VERSION 1
#define DPMAC_CMD_2ND_VERSION 2
#define DPMAC_CMD_ID_OFFSET 4
#define DPMAC_CMD(id) (((id) << DPMAC_CMD_ID_OFFSET) | DPMAC_CMD_BASE_VERSION)
#define DPMAC_CMD_V2(id) (((id) << DPMAC_CMD_ID_OFFSET) | DPMAC_CMD_2ND_VERSION)
/* Command IDs */
#define DPMAC_CMDID_CLOSE DPMAC_CMD(0x800)
@ -58,7 +60,9 @@
#define DPMAC_CMDID_CLEAR_IRQ_STATUS DPMAC_CMD(0x017)
#define DPMAC_CMDID_GET_LINK_CFG DPMAC_CMD(0x0c2)
#define DPMAC_CMDID_GET_LINK_CFG_V2 DPMAC_CMD_V2(0x0c2)
#define DPMAC_CMDID_SET_LINK_STATE DPMAC_CMD(0x0c3)
#define DPMAC_CMDID_SET_LINK_STATE_V2 DPMAC_CMD_V2(0x0c3)
#define DPMAC_CMDID_GET_COUNTER DPMAC_CMD(0x0c4)
#define DPMAC_CMDID_SET_PORT_MAC_ADDR DPMAC_CMD(0x0c5)
@ -139,8 +143,17 @@ struct dpmac_rsp_get_link_cfg {
u32 rate;
};
struct dpmac_rsp_get_link_cfg_v2 {
u64 options;
u32 rate;
u32 pad;
u64 advertising;
};
#define DPMAC_STATE_SIZE 1
#define DPMAC_STATE_SHIFT 0
#define DPMAC_STATE_VALID_SIZE 1
#define DPMAC_STATE_VALID_SHIFT 1
struct dpmac_cmd_set_link_state {
u64 options;
@ -150,6 +163,17 @@ struct dpmac_cmd_set_link_state {
u8 up;
};
struct dpmac_cmd_set_link_state_v2 {
u64 options;
u32 rate;
u32 pad0;
/* from lsb: up:1, state_valid:1 */
u8 state;
u8 pad1[7];
u64 supported;
u64 advertising;
};
struct dpmac_cmd_get_counter {
u8 type;
};

View File

@ -491,6 +491,42 @@ int dpmac_get_link_cfg(struct fsl_mc_io *mc_io,
return 0;
}
/**
* dpmac_get_link_cfg_v2() - 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_v2(struct fsl_mc_io *mc_io,
u32 cmd_flags,
u16 token,
struct dpmac_link_cfg *cfg)
{
struct dpmac_rsp_get_link_cfg_v2 *rsp_params;
struct fsl_mc_command cmd = { 0 };
int err = 0;
/* prepare command */
cmd.header = mc_encode_cmd_header(DPMAC_CMDID_GET_LINK_CFG_V2,
cmd_flags,
token);
/* send command to mc*/
err = mc_send_command(mc_io, &cmd);
if (err)
return err;
rsp_params = (struct dpmac_rsp_get_link_cfg_v2 *)cmd.params;
cfg->options = le64_to_cpu(rsp_params->options);
cfg->rate = le32_to_cpu(rsp_params->rate);
cfg->advertising = le64_to_cpu(rsp_params->advertising);
return 0;
}
/**
* dpmac_set_link_state() - Set the Ethernet link status
* @mc_io: Pointer to opaque I/O object
@ -521,6 +557,40 @@ int dpmac_set_link_state(struct fsl_mc_io *mc_io,
return mc_send_command(mc_io, &cmd);
}
/**
* dpmac_set_link_state_v2() - 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_v2(struct fsl_mc_io *mc_io,
u32 cmd_flags,
u16 token,
struct dpmac_link_state *link_state)
{
struct dpmac_cmd_set_link_state_v2 *cmd_params;
struct fsl_mc_command cmd = { 0 };
/* prepare command */
cmd.header = mc_encode_cmd_header(DPMAC_CMDID_SET_LINK_STATE_V2,
cmd_flags,
token);
cmd_params = (struct dpmac_cmd_set_link_state_v2 *)cmd.params;
cmd_params->options = cpu_to_le64(link_state->options);
cmd_params->rate = cpu_to_le32(link_state->rate);
dpmac_set_field(cmd_params->state, STATE, link_state->up);
dpmac_set_field(cmd_params->state, STATE_VALID,
link_state->state_valid);
cmd_params->supported = cpu_to_le64(link_state->supported);
cmd_params->advertising = cpu_to_le64(link_state->advertising);
/* send command to mc*/
return mc_send_command(mc_io, &cmd);
}
/**
* dpmac_get_counter() - Read a specific DPMAC counter
* @mc_io: Pointer to opaque I/O object

View File

@ -201,14 +201,30 @@ int dpmac_get_attributes(struct fsl_mc_io *mc_io,
*/
#define DPMAC_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
/**
* Advertised link speeds
*/
#define DPMAC_ADVERTISED_10BASET_FULL 0x0000000000000001ULL
#define DPMAC_ADVERTISED_100BASET_FULL 0x0000000000000002ULL
#define DPMAC_ADVERTISED_1000BASET_FULL 0x0000000000000004ULL
#define DPMAC_ADVERTISED_10000BASET_FULL 0x0000000000000010ULL
#define DPMAC_ADVERTISED_2500BASEX_FULL 0x0000000000000020ULL
/**
* Advertise auto-negotiation enable
*/
#define DPMAC_ADVERTISED_AUTONEG 0x0000000000000008ULL
/**
* struct dpmac_link_cfg - Structure representing DPMAC link configuration
* @rate: Link's rate - in Mbps
* @options: Enable/Disable DPMAC link cfg features (bitmap)
* @advertising: Speeds that are advertised for autoneg (bitmap)
*/
struct dpmac_link_cfg {
u32 rate;
u64 options;
u64 advertising;
};
int dpmac_get_link_cfg(struct fsl_mc_io *mc_io,
@ -216,16 +232,27 @@ int dpmac_get_link_cfg(struct fsl_mc_io *mc_io,
u16 token,
struct dpmac_link_cfg *cfg);
int dpmac_get_link_cfg_v2(struct fsl_mc_io *mc_io,
u32 cmd_flags,
u16 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
* @state_valid: Ignore/Update the state of the link
* @supported: Speeds capability of the phy (bitmap)
* @advertising: Speeds that are advertised for autoneg (bitmap)
*/
struct dpmac_link_state {
u32 rate;
u64 options;
int up;
int state_valid;
u64 supported;
u64 advertising;
};
int dpmac_set_link_state(struct fsl_mc_io *mc_io,
@ -233,6 +260,11 @@ int dpmac_set_link_state(struct fsl_mc_io *mc_io,
u16 token,
struct dpmac_link_state *link_state);
int dpmac_set_link_state_v2(struct fsl_mc_io *mc_io,
u32 cmd_flags,
u16 token,
struct dpmac_link_state *link_state);
/**
* enum dpmac_counter - DPMAC counter types
* @DPMAC_CNT_ING_FRAME_64: counts 64-bytes frames, good or bad.