1 From 0153f87972bfa3ef33bf369b8e91142f7c2b284a Mon Sep 17 00:00:00 2001
2 From: Ioana Radulescu <ruxandra.radulescu@nxp.com>
3 Date: Wed, 17 Oct 2018 20:14:24 +0300
4 Subject: [PATCH] dpaa2-eth: Add support for new link state APIs
6 Add v2 of dpni_get_link_state() and dpni_set_link_cfg() commands.
7 The new version allows setting & getting advertised and supported
10 Signed-off-by: Valentin Catalin Neacsu <valentin-catalin.neacsu@nxp.com>
11 Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com>
13 drivers/net/ethernet/freescale/dpaa2/dpni-cmd.h | 33 ++++++++++++
14 drivers/net/ethernet/freescale/dpaa2/dpni.c | 70 +++++++++++++++++++++++++
15 drivers/net/ethernet/freescale/dpaa2/dpni.h | 27 ++++++++++
16 3 files changed, 130 insertions(+)
18 --- a/drivers/net/ethernet/freescale/dpaa2/dpni-cmd.h
19 +++ b/drivers/net/ethernet/freescale/dpaa2/dpni-cmd.h
21 #define DPNI_CMDID_GET_QDID DPNI_CMD(0x210)
22 #define DPNI_CMDID_GET_TX_DATA_OFFSET DPNI_CMD(0x212)
23 #define DPNI_CMDID_GET_LINK_STATE DPNI_CMD(0x215)
24 +#define DPNI_CMDID_GET_LINK_STATE_V2 DPNI_CMD_V2(0x215)
25 #define DPNI_CMDID_SET_MAX_FRAME_LENGTH DPNI_CMD(0x216)
26 #define DPNI_CMDID_GET_MAX_FRAME_LENGTH DPNI_CMD(0x217)
27 #define DPNI_CMDID_SET_LINK_CFG DPNI_CMD(0x21A)
28 +#define DPNI_CMDID_SET_LINK_CFG_V2 DPNI_CMD_V2(0x21A)
29 #define DPNI_CMDID_SET_TX_SHAPING DPNI_CMD_V2(0x21B)
31 #define DPNI_CMDID_SET_MCAST_PROMISC DPNI_CMD(0x220)
32 @@ -304,8 +306,22 @@ struct dpni_cmd_link_cfg {
36 +struct dpni_cmd_set_link_cfg_v2 {
48 #define DPNI_LINK_STATE_SHIFT 0
49 #define DPNI_LINK_STATE_SIZE 1
50 +#define DPNI_STATE_VALID_SHIFT 1
51 +#define DPNI_STATE_VALID_SIZE 1
53 struct dpni_rsp_get_link_state {
55 @@ -320,6 +336,23 @@ struct dpni_rsp_get_link_state {
59 +struct dpni_rsp_get_link_state_v2 {
60 + /* response word 0 */
62 + /* from LSB: up:1, valid:1 */
65 + /* response word 1 */
68 + /* response word 2 */
76 #define DPNI_COUPLED_SHIFT 0
77 #define DPNI_COUPLED_SIZE 1
79 --- a/drivers/net/ethernet/freescale/dpaa2/dpni.c
80 +++ b/drivers/net/ethernet/freescale/dpaa2/dpni.c
81 @@ -853,6 +853,36 @@ int dpni_set_link_cfg(struct fsl_mc_io *
85 + * dpni_set_link_cfg_v2() - set the link configuration.
86 + * @mc_io: Pointer to MC portal's I/O object
87 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
88 + * @token: Token of DPNI object
89 + * @cfg: Link configuration
91 + * Return: '0' on Success; Error code otherwise.
93 +int dpni_set_link_cfg_v2(struct fsl_mc_io *mc_io,
96 + const struct dpni_link_cfg *cfg)
98 + struct fsl_mc_command cmd = { 0 };
99 + struct dpni_cmd_set_link_cfg_v2 *cmd_params;
101 + /* prepare command */
102 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_LINK_CFG_V2,
105 + cmd_params = (struct dpni_cmd_set_link_cfg_v2 *)cmd.params;
106 + cmd_params->rate = cpu_to_le32(cfg->rate);
107 + cmd_params->options = cpu_to_le64(cfg->options);
108 + cmd_params->advertising = cpu_to_le64(cfg->advertising);
110 + /* send command to mc*/
111 + return mc_send_command(mc_io, &cmd);
115 * dpni_get_link_cfg() - return the link configuration
116 * @mc_io: Pointer to MC portal's I/O object
117 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
118 @@ -924,6 +954,46 @@ int dpni_get_link_state(struct fsl_mc_io
124 + * dpni_get_link_state_v2() - Return the link state (either up or down)
125 + * @mc_io: Pointer to MC portal's I/O object
126 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
127 + * @token: Token of DPNI object
128 + * @state: Returned link state;
130 + * Return: '0' on Success; Error code otherwise.
132 +int dpni_get_link_state_v2(struct fsl_mc_io *mc_io,
135 + struct dpni_link_state *state)
137 + struct fsl_mc_command cmd = { 0 };
138 + struct dpni_rsp_get_link_state_v2 *rsp_params;
141 + /* prepare command */
142 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_LINK_STATE_V2,
146 + /* send command to mc*/
147 + err = mc_send_command(mc_io, &cmd);
151 + /* retrieve response parameters */
152 + rsp_params = (struct dpni_rsp_get_link_state_v2 *)cmd.params;
153 + state->up = dpni_get_field(rsp_params->flags, LINK_STATE);
154 + state->state_valid = dpni_get_field(rsp_params->flags, STATE_VALID);
155 + state->rate = le32_to_cpu(rsp_params->rate);
156 + state->options = le64_to_cpu(rsp_params->options);
157 + state->supported = le64_to_cpu(rsp_params->supported);
158 + state->advertising = le64_to_cpu(rsp_params->advertising);
164 * dpni_set_tx_shaping() - Set the transmit shaping
165 --- a/drivers/net/ethernet/freescale/dpaa2/dpni.h
166 +++ b/drivers/net/ethernet/freescale/dpaa2/dpni.h
167 @@ -522,6 +522,19 @@ int dpni_reset_statistics(struct fsl_mc_
168 * Enable priority flow control pause frames
170 #define DPNI_LINK_OPT_PFC_PAUSE 0x0000000000000010ULL
172 + * Advertised link speeds
174 +#define DPNI_ADVERTISED_10BASET_FULL 0x0000000000000001ULL
175 +#define DPNI_ADVERTISED_100BASET_FULL 0x0000000000000002ULL
176 +#define DPNI_ADVERTISED_1000BASET_FULL 0x0000000000000004ULL
177 +#define DPNI_ADVERTISED_10000BASET_FULL 0x0000000000000010ULL
178 +#define DPNI_ADVERTISED_2500BASEX_FULL 0x0000000000000020ULL
181 + * Advertise auto-negotiation enabled
183 +#define DPNI_ADVERTISED_AUTONEG 0x0000000000000008ULL
186 * struct - Structure representing DPNI link configuration
187 @@ -531,6 +544,7 @@ int dpni_reset_statistics(struct fsl_mc_
188 struct dpni_link_cfg {
194 int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
195 @@ -538,6 +552,11 @@ int dpni_set_link_cfg(struct fsl_mc_io
197 const struct dpni_link_cfg *cfg);
199 +int dpni_set_link_cfg_v2(struct fsl_mc_io *mc_io,
202 + const struct dpni_link_cfg *cfg);
204 int dpni_get_link_cfg(struct fsl_mc_io *mc_io,
207 @@ -552,7 +571,10 @@ int dpni_get_link_cfg(struct fsl_mc_io
208 struct dpni_link_state {
217 int dpni_get_link_state(struct fsl_mc_io *mc_io,
218 @@ -560,6 +582,11 @@ int dpni_get_link_state(struct fsl_mc_io
220 struct dpni_link_state *state);
222 +int dpni_get_link_state_v2(struct fsl_mc_io *mc_io,
225 + struct dpni_link_state *state);
228 * struct dpni_tx_shaping - Structure representing DPNI tx shaping configuration
229 * @rate_limit: rate in Mbps