aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/layerscape/patches-5.4/701-net-0173-staging-fsl-dpaa2-mac-Add-support-for-new-link-state.patch
blob: 601a4bf6aafa71dde3db5db74a3d61a0930f8dd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
From d84bd24a4d6e5b05f7eb1a544dfd0bd98c7f5bb1 Mon Sep 17 00:00:00 2001
From: Ioana Radulescu <ruxandra.radulescu@nxp.com>
Date: Wed, 17 Oct 2018 20:14:24 +0300
Subject: [PATCH] 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>
---
 drivers/staging/fsl-dpaa2/mac/dpmac-cmd.h | 24 +++++++++++
 drivers/staging/fsl-dpaa2/mac/dpmac.c     | 70 +++++++++++++++++++++++++++++++
 drivers/staging/fsl-dpaa2/mac/dpmac.h     | 32 ++++++++++++++
 3 files changed, 126 insertions(+)

--- a/drivers/staging/fsl-dpaa2/mac/dpmac-cmd.h
+++ b/drivers/staging/fsl-dpaa2/mac/dpmac-cmd.h
@@ -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;
 };
--- a/drivers/staging/fsl-dpaa2/mac/dpmac.c
+++ b/drivers/staging/fsl-dpaa2/mac/dpmac.c
@@ -492,6 +492,42 @@ int dpmac_get_link_cfg(struct fsl_mc_io
 }
 
 /**
+ * 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
  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
@@ -519,6 +555,40 @@ int dpmac_set_link_state(struct fsl_mc_i
 
 	/* send command to mc*/
 	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);
 }
 
 /**
--- a/drivers/staging/fsl-dpaa2/mac/dpmac.h
+++ b/drivers/staging/fsl-dpaa2/mac/dpmac.h
@@ -202,13 +202,29 @@ int dpmac_get_attributes(struct fsl_mc_i
 #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
 		       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_i
 			 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.