Commit 2557c5a942213acc2a0e3353a9c00140ea11b5d4

Authored by Yogesh Gaur
Committed by York Sun
1 parent ba34890420

driver: net: fsl-mc: flib changes for MC 10.3.0

Existing MC driver framework is based on MC-9.x.x flib. This patch
migrates MC obj (DPBP, DPNI, DPRC, DPMAC etc) to use latest MC flib
which is MC-10.3.0.

Changes introduced due to migration:
1. To get OBJ token, pair of create and open API replaces create APIs
2. Pair of close and destroy APIs replaces destroy APIs
3. For version read, get_version APIs replaces get_attributes APIs
4. dpni_get/reset_statistics APIs replaces dpni_get/set_counter APIs
5. Simplifies struct dpni_cfg and removes dpni_extended_cfg struct
6. Single API dpni_get_buffer_layout/set_buffer_layout replaces
   dpni_get_rx/set_rx, tx related, tx_conf_buffer_layout related APIs.
   New API takes a queue type as an argument.
7. Similarly dpni_get_queue/set_queue replaces
   dpni_get_rx_flow/set_rx_flow , tx_flow related, tx_conf related
   APIs

Signed-off-by: Yogesh Gaur <yogeshnarayan.gaur@nxp.com>
Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
Reviewed-by: York Sun <york.sun@nxp.com>

Showing 16 changed files with 1085 additions and 1327 deletions Side-by-side Diff

drivers/net/fsl-mc/dpbp.c
1 1 /*
2 2 * Freescale Layerscape MC I/O wrapper
3 3 *
4   - * Copyright (C) 2013-2015 Freescale Semiconductor, Inc.
5   - * Author: German Rivera <German.Rivera@freescale.com>
  4 + * Copyright (C) 2013-2016 Freescale Semiconductor, Inc.
  5 + * Copyright 2017 NXP
6 6 *
7 7 * SPDX-License-Identifier: GPL-2.0+
8 8 */
9 9  
... ... @@ -50,9 +50,10 @@
50 50 }
51 51  
52 52 int dpbp_create(struct fsl_mc_io *mc_io,
  53 + uint16_t dprc_token,
53 54 uint32_t cmd_flags,
54 55 const struct dpbp_cfg *cfg,
55   - uint16_t *token)
  56 + uint32_t *obj_id)
56 57 {
57 58 struct mc_command cmd = { 0 };
58 59 int err;
... ... @@ -62,7 +63,7 @@
62 63 /* prepare command */
63 64 cmd.header = mc_encode_cmd_header(DPBP_CMDID_CREATE,
64 65 cmd_flags,
65   - 0);
  66 + dprc_token);
66 67  
67 68 /* send command to mc*/
68 69 err = mc_send_command(mc_io, &cmd);
69 70  
70 71  
71 72  
72 73  
... ... @@ -70,22 +71,26 @@
70 71 return err;
71 72  
72 73 /* retrieve response parameters */
73   - *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
  74 + MC_CMD_READ_OBJ_ID(cmd, *obj_id);
74 75  
75 76 return 0;
76 77 }
77 78  
78 79 int dpbp_destroy(struct fsl_mc_io *mc_io,
  80 + uint16_t dprc_token,
79 81 uint32_t cmd_flags,
80   - uint16_t token)
  82 + uint32_t obj_id)
81 83 {
82 84 struct mc_command cmd = { 0 };
83 85  
84 86 /* prepare command */
85 87 cmd.header = mc_encode_cmd_header(DPBP_CMDID_DESTROY,
86 88 cmd_flags,
87   - token);
  89 + dprc_token);
88 90  
  91 + /* set object id to destroy */
  92 + CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, obj_id);
  93 +
89 94 /* send command to mc*/
90 95 return mc_send_command(mc_io, &cmd);
91 96 }
... ... @@ -154,6 +159,29 @@
154 159  
155 160 /* retrieve response parameters */
156 161 DPBP_RSP_GET_ATTRIBUTES(cmd, attr);
  162 +
  163 + return 0;
  164 +}
  165 +
  166 +int dpbp_get_api_version(struct fsl_mc_io *mc_io,
  167 + u32 cmd_flags,
  168 + u16 *major_ver,
  169 + u16 *minor_ver)
  170 +{
  171 + struct mc_command cmd = { 0 };
  172 + int err;
  173 +
  174 + /* prepare command */
  175 + cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_API_VERSION,
  176 + cmd_flags, 0);
  177 +
  178 + /* send command to mc */
  179 + err = mc_send_command(mc_io, &cmd);
  180 + if (err)
  181 + return err;
  182 +
  183 + /* retrieve response parameters */
  184 + mc_cmd_read_api_version(&cmd, major_ver, minor_ver);
157 185  
158 186 return 0;
159 187 }
drivers/net/fsl-mc/dpio/dpio.c
1 1 /*
2   - * Copyright (C) 2013-2015 Freescale Semiconductor
  2 + * Copyright (C) 2013-2016 Freescale Semiconductor
  3 + * Copyright 2017 NXP
3 4 *
4 5 * SPDX-License-Identifier: GPL-2.0+
5 6 */
... ... @@ -10,7 +11,7 @@
10 11  
11 12 int dpio_open(struct fsl_mc_io *mc_io,
12 13 uint32_t cmd_flags,
13   - int dpio_id,
  14 + uint32_t dpio_id,
14 15 uint16_t *token)
15 16 {
16 17 struct mc_command cmd = { 0 };
17 18  
... ... @@ -49,9 +50,10 @@
49 50 }
50 51  
51 52 int dpio_create(struct fsl_mc_io *mc_io,
  53 + uint16_t dprc_token,
52 54 uint32_t cmd_flags,
53 55 const struct dpio_cfg *cfg,
54   - uint16_t *token)
  56 + uint32_t *obj_id)
55 57 {
56 58 struct mc_command cmd = { 0 };
57 59 int err;
... ... @@ -59,7 +61,7 @@
59 61 /* prepare command */
60 62 cmd.header = mc_encode_cmd_header(DPIO_CMDID_CREATE,
61 63 cmd_flags,
62   - 0);
  64 + dprc_token);
63 65 DPIO_CMD_CREATE(cmd, cfg);
64 66  
65 67 /* send command to mc*/
66 68  
67 69  
68 70  
69 71  
... ... @@ -68,22 +70,26 @@
68 70 return err;
69 71  
70 72 /* retrieve response parameters */
71   - *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
  73 + MC_CMD_READ_OBJ_ID(cmd, *obj_id);
72 74  
73 75 return 0;
74 76 }
75 77  
76 78 int dpio_destroy(struct fsl_mc_io *mc_io,
  79 + uint16_t dprc_token,
77 80 uint32_t cmd_flags,
78   - uint16_t token)
  81 + uint32_t obj_id)
79 82 {
80 83 struct mc_command cmd = { 0 };
81 84  
82 85 /* prepare command */
83 86 cmd.header = mc_encode_cmd_header(DPIO_CMDID_DESTROY,
84 87 cmd_flags,
85   - token);
  88 + dprc_token);
86 89  
  90 + /* set object id to destroy */
  91 + CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, obj_id);
  92 +
87 93 /* send command to mc*/
88 94 return mc_send_command(mc_io, &cmd);
89 95 }
... ... @@ -153,6 +159,29 @@
153 159  
154 160 /* retrieve response parameters */
155 161 DPIO_RSP_GET_ATTR(cmd, attr);
  162 +
  163 + return 0;
  164 +}
  165 +
  166 +int dpio_get_api_version(struct fsl_mc_io *mc_io,
  167 + u32 cmd_flags,
  168 + u16 *major_ver,
  169 + u16 *minor_ver)
  170 +{
  171 + struct mc_command cmd = { 0 };
  172 + int err;
  173 +
  174 + /* prepare command */
  175 + cmd.header = mc_encode_cmd_header(DPIO_CMDID_GET_API_VERSION,
  176 + cmd_flags, 0);
  177 +
  178 + /* send command to mc */
  179 + err = mc_send_command(mc_io, &cmd);
  180 + if (err)
  181 + return err;
  182 +
  183 + /* retrieve response parameters */
  184 + mc_cmd_read_api_version(&cmd, major_ver, minor_ver);
156 185  
157 186 return 0;
158 187 }
drivers/net/fsl-mc/dpmac.c
1 1 /*
2 2 * Freescale Layerscape MC I/O wrapper
3 3 *
4   - * Copyright (C) 2015 Freescale Semiconductor, Inc.
  4 + * Copyright (C) 2015-2016 Freescale Semiconductor, Inc.
  5 + * Copyright 2017 NXP
5 6 * Author: Prabhakar Kushwaha <prabhakar@freescale.com>
6 7 *
7 8 * SPDX-License-Identifier: GPL-2.0+
8 9  
... ... @@ -51,9 +52,10 @@
51 52 }
52 53  
53 54 int dpmac_create(struct fsl_mc_io *mc_io,
  55 + uint16_t dprc_token,
54 56 uint32_t cmd_flags,
55 57 const struct dpmac_cfg *cfg,
56   - uint16_t *token)
  58 + uint32_t *obj_id)
57 59 {
58 60 struct mc_command cmd = { 0 };
59 61 int err;
... ... @@ -61,7 +63,7 @@
61 63 /* prepare command */
62 64 cmd.header = mc_encode_cmd_header(DPMAC_CMDID_CREATE,
63 65 cmd_flags,
64   - 0);
  66 + dprc_token);
65 67 DPMAC_CMD_CREATE(cmd, cfg);
66 68  
67 69 /* send command to mc*/
68 70  
69 71  
70 72  
71 73  
... ... @@ -70,22 +72,26 @@
70 72 return err;
71 73  
72 74 /* retrieve response parameters */
73   - *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
  75 + MC_CMD_READ_OBJ_ID(cmd, *obj_id);
74 76  
75 77 return 0;
76 78 }
77 79  
78 80 int dpmac_destroy(struct fsl_mc_io *mc_io,
  81 + uint16_t dprc_token,
79 82 uint32_t cmd_flags,
80   - uint16_t token)
  83 + uint32_t obj_id)
81 84 {
82 85 struct mc_command cmd = { 0 };
83 86  
84 87 /* prepare command */
85 88 cmd.header = mc_encode_cmd_header(DPMAC_CMDID_DESTROY,
86 89 cmd_flags,
87   - token);
  90 + dprc_token);
88 91  
  92 + /* set object id to destroy */
  93 + CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, obj_id);
  94 +
89 95 /* send command to mc*/
90 96 return mc_send_command(mc_io, &cmd);
91 97 }
... ... @@ -217,6 +223,29 @@
217 223 return err;
218 224  
219 225 DPMAC_RSP_GET_COUNTER(cmd, *counter);
  226 +
  227 + return 0;
  228 +}
  229 +
  230 +int dpmac_get_api_version(struct fsl_mc_io *mc_io,
  231 + u32 cmd_flags,
  232 + u16 *major_ver,
  233 + u16 *minor_ver)
  234 +{
  235 + struct mc_command cmd = { 0 };
  236 + int err;
  237 +
  238 + /* prepare command */
  239 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_GET_API_VERSION,
  240 + cmd_flags, 0);
  241 +
  242 + /* send command to mc */
  243 + err = mc_send_command(mc_io, &cmd);
  244 + if (err)
  245 + return err;
  246 +
  247 + /* retrieve response parameters */
  248 + mc_cmd_read_api_version(&cmd, major_ver, minor_ver);
220 249  
221 250 return 0;
222 251 }
drivers/net/fsl-mc/dpni.c
1 1 /*
2   - * Copyright (C) 2013-2015 Freescale Semiconductor
  2 + * Copyright (C) 2013-2016 Freescale Semiconductor
  3 + * Copyright 2017 NXP
3 4 *
4 5 * SPDX-License-Identifier: GPL-2.0+
5 6 */
6 7  
7 8  
8 9  
9 10  
10 11  
... ... @@ -8,22 +9,22 @@
8 9 #include <fsl-mc/fsl_mc_cmd.h>
9 10 #include <fsl-mc/fsl_dpni.h>
10 11  
11   -int dpni_prepare_extended_cfg(const struct dpni_extended_cfg *cfg,
12   - uint8_t *ext_cfg_buf)
  12 +int dpni_prepare_cfg(const struct dpni_cfg *cfg,
  13 + uint8_t *cfg_buf)
13 14 {
14   - uint64_t *ext_params = (uint64_t *)ext_cfg_buf;
  15 + uint64_t *params = (uint64_t *)cfg_buf;
15 16  
16   - DPNI_PREP_EXTENDED_CFG(ext_params, cfg);
  17 + DPNI_PREP_CFG(params, cfg);
17 18  
18 19 return 0;
19 20 }
20 21  
21   -int dpni_extract_extended_cfg(struct dpni_extended_cfg *cfg,
22   - const uint8_t *ext_cfg_buf)
  22 +int dpni_extract_cfg(struct dpni_cfg *cfg,
  23 + const uint8_t *cfg_buf)
23 24 {
24   - uint64_t *ext_params = (uint64_t *)ext_cfg_buf;
  25 + uint64_t *params = (uint64_t *)cfg_buf;
25 26  
26   - DPNI_EXT_EXTENDED_CFG(ext_params, cfg);
  27 + DPNI_EXT_CFG(params, cfg);
27 28  
28 29 return 0;
29 30 }
30 31  
... ... @@ -69,9 +70,10 @@
69 70 }
70 71  
71 72 int dpni_create(struct fsl_mc_io *mc_io,
  73 + uint16_t dprc_token,
72 74 uint32_t cmd_flags,
73 75 const struct dpni_cfg *cfg,
74   - uint16_t *token)
  76 + uint32_t *obj_id)
75 77 {
76 78 struct mc_command cmd = { 0 };
77 79 int err;
... ... @@ -79,7 +81,7 @@
79 81 /* prepare command */
80 82 cmd.header = mc_encode_cmd_header(DPNI_CMDID_CREATE,
81 83 cmd_flags,
82   - 0);
  84 + dprc_token);
83 85 DPNI_CMD_CREATE(cmd, cfg);
84 86  
85 87 /* send command to mc*/
86 88  
87 89  
88 90  
89 91  
... ... @@ -88,22 +90,26 @@
88 90 return err;
89 91  
90 92 /* retrieve response parameters */
91   - *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
  93 + MC_CMD_READ_OBJ_ID(cmd, *obj_id);
92 94  
93 95 return 0;
94 96 }
95 97  
96 98 int dpni_destroy(struct fsl_mc_io *mc_io,
  99 + uint16_t dprc_token,
97 100 uint32_t cmd_flags,
98   - uint16_t token)
  101 + uint32_t obj_id)
99 102 {
100 103 struct mc_command cmd = { 0 };
101 104  
102 105 /* prepare command */
103 106 cmd.header = mc_encode_cmd_header(DPNI_CMDID_DESTROY,
104 107 cmd_flags,
105   - token);
  108 + dprc_token);
106 109  
  110 + /* set object id to destroy */
  111 + CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, obj_id);
  112 +
107 113 /* send command to mc*/
108 114 return mc_send_command(mc_io, &cmd);
109 115 }
... ... @@ -182,8 +188,6 @@
182 188 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_ATTR,
183 189 cmd_flags,
184 190 token);
185   - DPNI_CMD_GET_ATTR(cmd, attr);
186   -
187 191 /* send command to mc*/
188 192 err = mc_send_command(mc_io, &cmd);
189 193 if (err)
190 194  
191 195  
192 196  
193 197  
194 198  
... ... @@ -212,129 +216,24 @@
212 216 return mc_send_command(mc_io, &cmd);
213 217 }
214 218  
215   -int dpni_get_rx_buffer_layout(struct fsl_mc_io *mc_io,
216   - uint32_t cmd_flags,
217   - uint16_t token,
218   - struct dpni_buffer_layout *layout)
  219 +int dpni_set_buffer_layout(struct fsl_mc_io *mc_io,
  220 + uint32_t cmd_flags,
  221 + uint16_t token,
  222 + const struct dpni_buffer_layout *layout,
  223 + enum dpni_queue_type type)
219 224 {
220 225 struct mc_command cmd = { 0 };
221   - int err;
222 226  
223 227 /* prepare command */
224   - cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_RX_BUFFER_LAYOUT,
  228 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_BUFFER_LAYOUT,
225 229 cmd_flags,
226 230 token);
  231 + DPNI_CMD_SET_BUFFER_LAYOUT(cmd, layout, type);
227 232  
228 233 /* send command to mc*/
229   - err = mc_send_command(mc_io, &cmd);
230   - if (err)
231   - return err;
232   -
233   - /* retrieve response parameters */
234   - DPNI_RSP_GET_RX_BUFFER_LAYOUT(cmd, layout);
235   -
236   - return 0;
237   -}
238   -
239   -int dpni_set_rx_buffer_layout(struct fsl_mc_io *mc_io,
240   - uint32_t cmd_flags,
241   - uint16_t token,
242   - const struct dpni_buffer_layout *layout)
243   -{
244   - struct mc_command cmd = { 0 };
245   -
246   - /* prepare command */
247   - cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_RX_BUFFER_LAYOUT,
248   - cmd_flags,
249   - token);
250   - DPNI_CMD_SET_RX_BUFFER_LAYOUT(cmd, layout);
251   -
252   - /* send command to mc*/
253 234 return mc_send_command(mc_io, &cmd);
254 235 }
255 236  
256   -int dpni_get_tx_buffer_layout(struct fsl_mc_io *mc_io,
257   - uint32_t cmd_flags,
258   - uint16_t token,
259   - struct dpni_buffer_layout *layout)
260   -{
261   - struct mc_command cmd = { 0 };
262   - int err;
263   -
264   - /* prepare command */
265   - cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TX_BUFFER_LAYOUT,
266   - cmd_flags,
267   - token);
268   -
269   - /* send command to mc*/
270   - err = mc_send_command(mc_io, &cmd);
271   - if (err)
272   - return err;
273   -
274   - /* retrieve response parameters */
275   - DPNI_RSP_GET_TX_BUFFER_LAYOUT(cmd, layout);
276   -
277   - return 0;
278   -}
279   -
280   -int dpni_set_tx_buffer_layout(struct fsl_mc_io *mc_io,
281   - uint32_t cmd_flags,
282   - uint16_t token,
283   - const struct dpni_buffer_layout *layout)
284   -{
285   - struct mc_command cmd = { 0 };
286   -
287   - /* prepare command */
288   - cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_BUFFER_LAYOUT,
289   - cmd_flags,
290   - token);
291   - DPNI_CMD_SET_TX_BUFFER_LAYOUT(cmd, layout);
292   -
293   - /* send command to mc*/
294   - return mc_send_command(mc_io, &cmd);
295   -}
296   -
297   -int dpni_get_tx_conf_buffer_layout(struct fsl_mc_io *mc_io,
298   - uint32_t cmd_flags,
299   - uint16_t token,
300   - struct dpni_buffer_layout *layout)
301   -{
302   - struct mc_command cmd = { 0 };
303   - int err;
304   -
305   - /* prepare command */
306   - cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TX_CONF_BUFFER_LAYOUT,
307   - cmd_flags,
308   - token);
309   -
310   - /* send command to mc*/
311   - err = mc_send_command(mc_io, &cmd);
312   - if (err)
313   - return err;
314   -
315   - /* retrieve response parameters */
316   - DPNI_RSP_GET_TX_CONF_BUFFER_LAYOUT(cmd, layout);
317   -
318   - return 0;
319   -}
320   -
321   -int dpni_set_tx_conf_buffer_layout(struct fsl_mc_io *mc_io,
322   - uint32_t cmd_flags,
323   - uint16_t token,
324   - const struct dpni_buffer_layout *layout)
325   -{
326   - struct mc_command cmd = { 0 };
327   -
328   - /* prepare command */
329   - cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_CONF_BUFFER_LAYOUT,
330   - cmd_flags,
331   - token);
332   - DPNI_CMD_SET_TX_CONF_BUFFER_LAYOUT(cmd, layout);
333   -
334   - /* send command to mc*/
335   - return mc_send_command(mc_io, &cmd);
336   -}
337   -
338 237 int dpni_get_qdid(struct fsl_mc_io *mc_io,
339 238 uint32_t cmd_flags,
340 239 uint16_t token,
... ... @@ -383,50 +282,6 @@
383 282 return 0;
384 283 }
385 284  
386   -int dpni_get_counter(struct fsl_mc_io *mc_io,
387   - uint32_t cmd_flags,
388   - uint16_t token,
389   - enum dpni_counter counter,
390   - uint64_t *value)
391   -{
392   - struct mc_command cmd = { 0 };
393   - int err;
394   -
395   - /* prepare command */
396   - cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_COUNTER,
397   - cmd_flags,
398   - token);
399   - DPNI_CMD_GET_COUNTER(cmd, counter);
400   -
401   - /* send command to mc*/
402   - err = mc_send_command(mc_io, &cmd);
403   - if (err)
404   - return err;
405   -
406   - /* retrieve response parameters */
407   - DPNI_RSP_GET_COUNTER(cmd, *value);
408   -
409   - return 0;
410   -}
411   -
412   -int dpni_set_counter(struct fsl_mc_io *mc_io,
413   - uint32_t cmd_flags,
414   - uint16_t token,
415   - enum dpni_counter counter,
416   - uint64_t value)
417   -{
418   - struct mc_command cmd = { 0 };
419   -
420   - /* prepare command */
421   - cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_COUNTER,
422   - cmd_flags,
423   - token);
424   - DPNI_CMD_SET_COUNTER(cmd, counter, value);
425   -
426   - /* send command to mc*/
427   - return mc_send_command(mc_io, &cmd);
428   -}
429   -
430 285 int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
431 286 uint32_t cmd_flags,
432 287 uint16_t token,
433 288  
434 289  
435 290  
436 291  
437 292  
438 293  
439 294  
440 295  
441 296  
442 297  
443 298  
444 299  
... ... @@ -544,91 +399,64 @@
544 399 return mc_send_command(mc_io, &cmd);
545 400 }
546 401  
547   -int dpni_set_tx_flow(struct fsl_mc_io *mc_io,
548   - uint32_t cmd_flags,
549   - uint16_t token,
550   - uint16_t *flow_id,
551   - const struct dpni_tx_flow_cfg *cfg)
  402 +int dpni_get_api_version(struct fsl_mc_io *mc_io,
  403 + u32 cmd_flags,
  404 + u16 *major_ver,
  405 + u16 *minor_ver)
552 406 {
553 407 struct mc_command cmd = { 0 };
554 408 int err;
555 409  
556 410 /* prepare command */
557   - cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_FLOW,
558   - cmd_flags,
559   - token);
560   - DPNI_CMD_SET_TX_FLOW(cmd, *flow_id, cfg);
  411 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_API_VERSION,
  412 + cmd_flags, 0);
561 413  
562   - /* send command to mc*/
  414 + /* send command to mc */
563 415 err = mc_send_command(mc_io, &cmd);
564 416 if (err)
565 417 return err;
566 418  
567 419 /* retrieve response parameters */
568   - DPNI_RSP_SET_TX_FLOW(cmd, *flow_id);
  420 + mc_cmd_read_api_version(&cmd, major_ver, minor_ver);
569 421  
570 422 return 0;
571 423 }
572 424  
573   -int dpni_get_tx_flow(struct fsl_mc_io *mc_io,
574   - uint32_t cmd_flags,
575   - uint16_t token,
576   - uint16_t flow_id,
577   - struct dpni_tx_flow_attr *attr)
  425 +int dpni_set_queue(struct fsl_mc_io *mc_io,
  426 + uint32_t cmd_flags,
  427 + uint16_t token,
  428 + enum dpni_queue_type type,
  429 + uint8_t tc,
  430 + uint8_t index,
  431 + const struct dpni_queue *queue)
578 432 {
579 433 struct mc_command cmd = { 0 };
580   - int err;
581   -
582 434 /* prepare command */
583   - cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TX_FLOW,
  435 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_QUEUE,
584 436 cmd_flags,
585 437 token);
586   - DPNI_CMD_GET_TX_FLOW(cmd, flow_id);
  438 + DPNI_CMD_SET_QUEUE(cmd, type, tc, index, queue);
587 439  
588 440 /* send command to mc*/
589   - err = mc_send_command(mc_io, &cmd);
590   - if (err)
591   - return err;
592   -
593   - /* retrieve response parameters */
594   - DPNI_RSP_GET_TX_FLOW(cmd, attr);
595   -
596   - return 0;
597   -}
598   -
599   -int dpni_set_rx_flow(struct fsl_mc_io *mc_io,
600   - uint32_t cmd_flags,
601   - uint16_t token,
602   - uint8_t tc_id,
603   - uint16_t flow_id,
604   - const struct dpni_queue_cfg *cfg)
605   -{
606   - struct mc_command cmd = { 0 };
607   -
608   - /* prepare command */
609   - cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_RX_FLOW,
610   - cmd_flags,
611   - token);
612   - DPNI_CMD_SET_RX_FLOW(cmd, tc_id, flow_id, cfg);
613   -
614   - /* send command to mc*/
615 441 return mc_send_command(mc_io, &cmd);
616 442 }
617 443  
618   -int dpni_get_rx_flow(struct fsl_mc_io *mc_io,
619   - uint32_t cmd_flags,
620   - uint16_t token,
621   - uint8_t tc_id,
622   - uint16_t flow_id,
623   - struct dpni_queue_attr *attr)
  444 +int dpni_get_queue(struct fsl_mc_io *mc_io,
  445 + uint32_t cmd_flags,
  446 + uint16_t token,
  447 + enum dpni_queue_type type,
  448 + uint8_t tc,
  449 + uint8_t index,
  450 + struct dpni_queue *queue)
624 451 {
625 452 struct mc_command cmd = { 0 };
626 453 int err;
  454 +
627 455 /* prepare command */
628   - cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_RX_FLOW,
  456 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_QUEUE,
629 457 cmd_flags,
630 458 token);
631   - DPNI_CMD_GET_RX_FLOW(cmd, tc_id, flow_id);
  459 + DPNI_CMD_GET_QUEUE(cmd, type, tc, index);
632 460  
633 461 /* send command to mc*/
634 462 err = mc_send_command(mc_io, &cmd);
635 463  
636 464  
637 465  
638 466  
639 467  
640 468  
641 469  
642 470  
643 471  
... ... @@ -636,51 +464,66 @@
636 464 return err;
637 465  
638 466 /* retrieve response parameters */
639   - DPNI_RSP_GET_RX_FLOW(cmd, attr);
640   -
  467 + DPNI_RSP_GET_QUEUE(cmd, queue);
641 468 return 0;
642 469 }
643 470  
644   -int dpni_set_tx_conf(struct fsl_mc_io *mc_io,
645   - uint32_t cmd_flags,
646   - uint16_t token,
647   - uint16_t flow_id,
648   - const struct dpni_tx_conf_cfg *cfg)
  471 +int dpni_set_tx_confirmation_mode(struct fsl_mc_io *mc_io,
  472 + uint32_t cmd_flags,
  473 + uint16_t token,
  474 + enum dpni_confirmation_mode mode)
649 475 {
  476 + struct dpni_tx_confirmation_mode *cmd_params;
650 477 struct mc_command cmd = { 0 };
651 478  
652 479 /* prepare command */
653   - cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_CONF,
  480 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_CONFIRMATION_MODE,
654 481 cmd_flags,
655 482 token);
656   - DPNI_CMD_SET_TX_CONF(cmd, flow_id, cfg);
657 483  
  484 + cmd_params = (struct dpni_tx_confirmation_mode *)cmd.params;
  485 + cmd_params->confirmation_mode = mode;
  486 +
658 487 /* send command to mc*/
659 488 return mc_send_command(mc_io, &cmd);
660 489 }
661 490  
662   -int dpni_get_tx_conf(struct fsl_mc_io *mc_io,
663   - uint32_t cmd_flags,
664   - uint16_t token,
665   - uint16_t flow_id,
666   - struct dpni_tx_conf_attr *attr)
  491 +int dpni_get_statistics(struct fsl_mc_io *mc_io,
  492 + uint32_t cmd_flags,
  493 + uint16_t token,
  494 + uint8_t page,
  495 + struct dpni_statistics *stat)
667 496 {
668 497 struct mc_command cmd = { 0 };
669 498 int err;
670 499  
671 500 /* prepare command */
672   - cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TX_CONF,
673   - cmd_flags,
674   - token);
675   - DPNI_CMD_GET_TX_CONF(cmd, flow_id);
  501 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_STATISTICS,
  502 + cmd_flags, token);
  503 + DPNI_CMD_GET_STATISTICS(cmd, page);
676 504  
677 505 /* send command to mc*/
678 506 err = mc_send_command(mc_io, &cmd);
679 507 if (err)
680 508 return err;
681 509  
682   - DPNI_RSP_GET_TX_CONF(cmd, attr);
  510 + /* retrieve response parameters */
  511 + DPNI_RSP_GET_STATISTICS(cmd, stat);
683 512  
684 513 return 0;
  514 +}
  515 +
  516 +int dpni_reset_statistics(struct fsl_mc_io *mc_io,
  517 + uint32_t cmd_flags,
  518 + uint16_t token)
  519 +{
  520 + struct mc_command cmd = { 0 };
  521 +
  522 + /* prepare command */
  523 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_RESET_STATISTICS,
  524 + cmd_flags, token);
  525 +
  526 + /* send command to mc*/
  527 + return mc_send_command(mc_io, &cmd);
685 528 }
drivers/net/fsl-mc/dprc.c
1 1 /*
2 2 * Freescale Layerscape MC I/O wrapper
3 3 *
4   - * Copyright (C) 2013-2015 Freescale Semiconductor, Inc.
5   - * Author: German Rivera <German.Rivera@freescale.com>
  4 + * Copyright (C) 2013-2016 Freescale Semiconductor, Inc.
  5 + * Copyright 2017 NXP
6 6 *
7 7 * SPDX-License-Identifier: GPL-2.0+
8 8 */
... ... @@ -350,6 +350,29 @@
350 350  
351 351 /* retrieve response parameters */
352 352 DPRC_RSP_GET_CONNECTION(cmd, endpoint2, *state);
  353 +
  354 + return 0;
  355 +}
  356 +
  357 +int dprc_get_api_version(struct fsl_mc_io *mc_io,
  358 + u32 cmd_flags,
  359 + u16 *major_ver,
  360 + u16 *minor_ver)
  361 +{
  362 + struct mc_command cmd = { 0 };
  363 + int err;
  364 +
  365 + /* prepare command */
  366 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_API_VERSION,
  367 + cmd_flags, 0);
  368 +
  369 + /* send command to mc */
  370 + err = mc_send_command(mc_io, &cmd);
  371 + if (err)
  372 + return err;
  373 +
  374 + /* retrieve response parameters */
  375 + mc_cmd_read_api_version(&cmd, major_ver, minor_ver);
353 376  
354 377 return 0;
355 378 }
drivers/net/fsl-mc/fsl_dpmng_cmd.h
1   -/* Copyright 2013-2015 Freescale Semiconductor Inc.
  1 +/* Copyright 2013-2016 Freescale Semiconductor Inc.
  2 + * Copyright 2017 NXP
2 3 *
3 4 * SPDX-License-Identifier: GPL-2.0+
4 5 */
... ... @@ -6,7 +7,7 @@
6 7 #define __FSL_DPMNG_CMD_H
7 8  
8 9 /* Command IDs */
9   -#define DPMNG_CMDID_GET_VERSION 0x831
  10 +#define DPMNG_CMDID_GET_VERSION 0x8311
10 11  
11 12 /* cmd, param, offset, width, type, arg_name */
12 13 #define DPMNG_RSP_GET_VERSION(cmd, mc_ver_info) \
drivers/net/fsl-mc/mc.c
... ... @@ -854,21 +854,25 @@
854 854  
855 855 static int dprc_version_check(struct fsl_mc_io *mc_io, uint16_t handle)
856 856 {
857   - struct dprc_attributes attr;
858 857 int error;
  858 + uint16_t major_ver, minor_ver;
859 859  
860   - memset(&attr, 0, sizeof(struct dprc_attributes));
861   - error = dprc_get_attributes(mc_io, MC_CMD_NO_FLAGS, handle, &attr);
862   - if (error == 0) {
863   - if ((attr.version.major != DPRC_VER_MAJOR) ||
864   - (attr.version.minor != DPRC_VER_MINOR)) {
865   - printf("DPRC version mismatch found %u.%u,",
866   - attr.version.major,
867   - attr.version.minor);
868   - printf("supported version is %u.%u\n",
869   - DPRC_VER_MAJOR, DPRC_VER_MINOR);
870   - }
  860 + error = dprc_get_api_version(mc_io, 0,
  861 + &major_ver,
  862 + &minor_ver);
  863 + if (error < 0) {
  864 + printf("dprc_get_api_version() failed: %d\n", error);
  865 + return error;
871 866 }
  867 +
  868 + if (major_ver < DPRC_VER_MAJOR || (major_ver == DPRC_VER_MAJOR &&
  869 + minor_ver < DPRC_VER_MINOR)) {
  870 + printf("DPRC version mismatch found %u.%u,",
  871 + major_ver, minor_ver);
  872 + printf("supported version is %u.%u\n",
  873 + DPRC_VER_MAJOR, DPRC_VER_MINOR);
  874 + }
  875 +
872 876 return error;
873 877 }
874 878  
... ... @@ -878,6 +882,7 @@
878 882 struct dpio_attr attr;
879 883 struct dpio_cfg dpio_cfg;
880 884 int err = 0;
  885 + uint16_t major_ver, minor_ver;
881 886  
882 887 dflt_dpio = (struct fsl_dpio_obj *)calloc(
883 888 sizeof(struct fsl_dpio_obj), 1);
884 889  
885 890  
... ... @@ -886,18 +891,44 @@
886 891 err = -ENOMEM;
887 892 goto err_calloc;
888 893 }
889   -
890 894 dpio_cfg.channel_mode = DPIO_LOCAL_CHANNEL;
891 895 dpio_cfg.num_priorities = 8;
892 896  
893   - err = dpio_create(dflt_mc_io, MC_CMD_NO_FLAGS, &dpio_cfg,
894   - &dflt_dpio->dpio_handle);
  897 + err = dpio_create(dflt_mc_io,
  898 + dflt_dprc_handle,
  899 + MC_CMD_NO_FLAGS,
  900 + &dpio_cfg,
  901 + &dflt_dpio->dpio_id);
895 902 if (err < 0) {
896 903 printf("dpio_create() failed: %d\n", err);
897 904 err = -ENODEV;
898 905 goto err_create;
899 906 }
900 907  
  908 + err = dpio_get_api_version(dflt_mc_io, 0,
  909 + &major_ver,
  910 + &minor_ver);
  911 + if (err < 0) {
  912 + printf("dpio_get_api_version() failed: %d\n", err);
  913 + goto err_get_api_ver;
  914 + }
  915 +
  916 + if (major_ver < DPIO_VER_MAJOR || (major_ver == DPIO_VER_MAJOR &&
  917 + minor_ver < DPIO_VER_MINOR)) {
  918 + printf("DPRC version mismatch found %u.%u,",
  919 + major_ver,
  920 + minor_ver);
  921 + }
  922 +
  923 + err = dpio_open(dflt_mc_io,
  924 + MC_CMD_NO_FLAGS,
  925 + dflt_dpio->dpio_id,
  926 + &dflt_dpio->dpio_handle);
  927 + if (err) {
  928 + printf("dpio_open() failed\n");
  929 + goto err_open;
  930 + }
  931 +
901 932 memset(&attr, 0, sizeof(struct dpio_attr));
902 933 err = dpio_get_attributes(dflt_mc_io, MC_CMD_NO_FLAGS,
903 934 dflt_dpio->dpio_handle, &attr);
904 935  
... ... @@ -906,15 +937,11 @@
906 937 goto err_get_attr;
907 938 }
908 939  
909   - if ((attr.version.major != DPIO_VER_MAJOR) ||
910   - (attr.version.minor != DPIO_VER_MINOR)) {
911   - printf("DPIO version mismatch found %u.%u,",
912   - attr.version.major, attr.version.minor);
913   - printf("supported version is %u.%u\n",
914   - DPIO_VER_MAJOR, DPIO_VER_MINOR);
  940 + if (dflt_dpio->dpio_id != attr.id) {
  941 + printf("dnpi object id and attribute id are not same\n");
  942 + goto err_attr_not_same;
915 943 }
916 944  
917   - dflt_dpio->dpio_id = attr.id;
918 945 #ifdef DEBUG
919 946 printf("Init: DPIO id=0x%d\n", dflt_dpio->dpio_id);
920 947 #endif
921 948  
... ... @@ -945,8 +972,14 @@
945 972 dpio_disable(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle);
946 973 err_get_enable:
947 974 err_get_attr:
  975 +err_attr_not_same:
948 976 dpio_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle);
949   - dpio_destroy(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle);
  977 +err_open:
  978 +err_get_api_ver:
  979 + dpio_destroy(dflt_mc_io,
  980 + dflt_dprc_handle,
  981 + MC_CMD_NO_FLAGS,
  982 + dflt_dpio->dpio_id);
950 983 err_create:
951 984 free(dflt_dpio);
952 985 err_calloc:
953 986  
... ... @@ -963,8 +996,17 @@
963 996 goto err;
964 997 }
965 998  
966   - err = dpio_destroy(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle);
  999 + dpio_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle);
967 1000 if (err < 0) {
  1001 + printf("dpio_close() failed: %d\n", err);
  1002 + goto err;
  1003 + }
  1004 +
  1005 + err = dpio_destroy(dflt_mc_io,
  1006 + dflt_dprc_handle,
  1007 + MC_CMD_NO_FLAGS,
  1008 + dflt_dpio->dpio_id);
  1009 + if (err < 0) {
968 1010 printf("dpio_destroy() failed: %d\n", err);
969 1011 goto err;
970 1012 }
... ... @@ -1040,6 +1082,7 @@
1040 1082  
1041 1083 child_portal_id = MC_PORTAL_OFFSET_TO_PORTAL_ID(mc_portal_offset);
1042 1084 dflt_mc_io->mmio_regs = SOC_MC_PORTAL_ADDR(child_portal_id);
  1085 +
1043 1086 #ifdef DEBUG
1044 1087 printf("MC portal of child DPRC container: %d, physical addr %p)\n",
1045 1088 child_dprc_id, dflt_mc_io->mmio_regs);
... ... @@ -1110,6 +1153,7 @@
1110 1153 int err;
1111 1154 struct dpbp_attr dpbp_attr;
1112 1155 struct dpbp_cfg dpbp_cfg;
  1156 + uint16_t major_ver, minor_ver;
1113 1157  
1114 1158 dflt_dpbp = (struct fsl_dpbp_obj *)calloc(
1115 1159 sizeof(struct fsl_dpbp_obj), 1);
... ... @@ -1121,8 +1165,11 @@
1121 1165  
1122 1166 dpbp_cfg.options = 512;
1123 1167  
1124   - err = dpbp_create(dflt_mc_io, MC_CMD_NO_FLAGS, &dpbp_cfg,
1125   - &dflt_dpbp->dpbp_handle);
  1168 + err = dpbp_create(dflt_mc_io,
  1169 + dflt_dprc_handle,
  1170 + MC_CMD_NO_FLAGS,
  1171 + &dpbp_cfg,
  1172 + &dflt_dpbp->dpbp_id);
1126 1173  
1127 1174 if (err < 0) {
1128 1175 err = -ENODEV;
... ... @@ -1130,6 +1177,31 @@
1130 1177 goto err_create;
1131 1178 }
1132 1179  
  1180 + err = dpbp_get_api_version(dflt_mc_io, 0,
  1181 + &major_ver,
  1182 + &minor_ver);
  1183 + if (err < 0) {
  1184 + printf("dpbp_get_api_version() failed: %d\n", err);
  1185 + goto err_get_api_ver;
  1186 + }
  1187 +
  1188 + if (major_ver < DPBP_VER_MAJOR || (major_ver == DPBP_VER_MAJOR &&
  1189 + minor_ver < DPBP_VER_MINOR)) {
  1190 + printf("DPBP version mismatch found %u.%u,",
  1191 + major_ver, minor_ver);
  1192 + printf("supported version is %u.%u\n",
  1193 + DPBP_VER_MAJOR, DPBP_VER_MINOR);
  1194 + }
  1195 +
  1196 + err = dpbp_open(dflt_mc_io,
  1197 + MC_CMD_NO_FLAGS,
  1198 + dflt_dpbp->dpbp_id,
  1199 + &dflt_dpbp->dpbp_handle);
  1200 + if (err) {
  1201 + printf("dpbp_open() failed\n");
  1202 + goto err_open;
  1203 + }
  1204 +
1133 1205 memset(&dpbp_attr, 0, sizeof(struct dpbp_attr));
1134 1206 err = dpbp_get_attributes(dflt_mc_io, MC_CMD_NO_FLAGS,
1135 1207 dflt_dpbp->dpbp_handle,
1136 1208  
1137 1209  
... ... @@ -1139,17 +1211,13 @@
1139 1211 goto err_get_attr;
1140 1212 }
1141 1213  
1142   - if ((dpbp_attr.version.major != DPBP_VER_MAJOR) ||
1143   - (dpbp_attr.version.minor != DPBP_VER_MINOR)) {
1144   - printf("DPBP version mismatch found %u.%u,",
1145   - dpbp_attr.version.major, dpbp_attr.version.minor);
1146   - printf("supported version is %u.%u\n",
1147   - DPBP_VER_MAJOR, DPBP_VER_MINOR);
  1214 + if (dflt_dpbp->dpbp_id != dpbp_attr.id) {
  1215 + printf("dpbp object id and attribute id are not same\n");
  1216 + goto err_attr_not_same;
1148 1217 }
1149 1218  
1150   - dflt_dpbp->dpbp_attr.id = dpbp_attr.id;
1151 1219 #ifdef DEBUG
1152   - printf("Init: DPBP id=0x%d\n", dflt_dpbp->dpbp_attr.id);
  1220 + printf("Init: DPBP id=0x%x\n", dflt_dpbp->dpbp_attr.id);
1153 1221 #endif
1154 1222  
1155 1223 err = dpbp_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle);
1156 1224  
1157 1225  
1158 1226  
... ... @@ -1160,12 +1228,18 @@
1160 1228  
1161 1229 return 0;
1162 1230  
1163   -err_close:
1164   - free(dflt_dpbp);
1165 1231 err_get_attr:
  1232 +err_attr_not_same:
1166 1233 dpbp_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle);
1167   - dpbp_destroy(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle);
  1234 + dpbp_destroy(dflt_mc_io,
  1235 + dflt_dprc_handle,
  1236 + MC_CMD_NO_FLAGS,
  1237 + dflt_dpbp->dpbp_id);
  1238 +err_get_api_ver:
  1239 +err_close:
  1240 +err_open:
1168 1241 err_create:
  1242 + free(dflt_dpbp);
1169 1243 err_calloc:
1170 1244 return err;
1171 1245 }
1172 1246  
... ... @@ -1174,16 +1248,9 @@
1174 1248 {
1175 1249 int err;
1176 1250  
1177   - err = dpbp_open(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_attr.id,
1178   - &dflt_dpbp->dpbp_handle);
  1251 + err = dpbp_destroy(dflt_mc_io, dflt_dprc_handle, MC_CMD_NO_FLAGS,
  1252 + dflt_dpbp->dpbp_id);
1179 1253 if (err < 0) {
1180   - printf("dpbp_open() failed: %d\n", err);
1181   - goto err;
1182   - }
1183   -
1184   - err = dpbp_destroy(dflt_mc_io, MC_CMD_NO_FLAGS,
1185   - dflt_dpbp->dpbp_handle);
1186   - if (err < 0) {
1187 1254 printf("dpbp_destroy() failed: %d\n", err);
1188 1255 goto err;
1189 1256 }
1190 1257  
... ... @@ -1203,10 +1270,9 @@
1203 1270 static int dpni_init(void)
1204 1271 {
1205 1272 int err;
1206   - struct dpni_attr dpni_attr;
1207   - uint8_t ext_cfg_buf[256] = {0};
1208   - struct dpni_extended_cfg dpni_extended_cfg;
  1273 + uint8_t cfg_buf[256] = {0};
1209 1274 struct dpni_cfg dpni_cfg;
  1275 + uint16_t major_ver, minor_ver;
1210 1276  
1211 1277 dflt_dpni = (struct fsl_dpni_obj *)calloc(
1212 1278 sizeof(struct fsl_dpni_obj), 1);
1213 1279  
1214 1280  
1215 1281  
1216 1282  
1217 1283  
1218 1284  
1219 1285  
1220 1286  
1221 1287  
... ... @@ -1216,50 +1282,53 @@
1216 1282 goto err_calloc;
1217 1283 }
1218 1284  
1219   - memset(&dpni_extended_cfg, 0, sizeof(dpni_extended_cfg));
1220   - err = dpni_prepare_extended_cfg(&dpni_extended_cfg, &ext_cfg_buf[0]);
  1285 + memset(&dpni_cfg, 0, sizeof(dpni_cfg));
  1286 + err = dpni_prepare_cfg(&dpni_cfg, &cfg_buf[0]);
1221 1287 if (err < 0) {
1222 1288 err = -ENODEV;
1223   - printf("dpni_prepare_extended_cfg() failed: %d\n", err);
1224   - goto err_prepare_extended_cfg;
  1289 + printf("dpni_prepare_cfg() failed: %d\n", err);
  1290 + goto err_prepare_cfg;
1225 1291 }
1226 1292  
1227   - memset(&dpni_cfg, 0, sizeof(dpni_cfg));
1228   - dpni_cfg.adv.options = DPNI_OPT_UNICAST_FILTER |
1229   - DPNI_OPT_MULTICAST_FILTER;
1230   -
1231   - dpni_cfg.adv.ext_cfg_iova = (uint64_t)&ext_cfg_buf[0];
1232   - err = dpni_create(dflt_mc_io, MC_CMD_NO_FLAGS, &dpni_cfg,
1233   - &dflt_dpni->dpni_handle);
1234   -
  1293 + err = dpni_create(dflt_mc_io,
  1294 + dflt_dprc_handle,
  1295 + MC_CMD_NO_FLAGS,
  1296 + &dpni_cfg,
  1297 + &dflt_dpni->dpni_id);
1235 1298 if (err < 0) {
1236 1299 err = -ENODEV;
1237   - printf("dpni_create() failed: %d\n", err);
  1300 + printf("dpni create() failed: %d\n", err);
1238 1301 goto err_create;
1239 1302 }
1240 1303  
1241   - memset(&dpni_attr, 0, sizeof(struct dpni_attr));
1242   - err = dpni_get_attributes(dflt_mc_io, MC_CMD_NO_FLAGS,
1243   - dflt_dpni->dpni_handle,
1244   - &dpni_attr);
  1304 + err = dpni_get_api_version(dflt_mc_io, 0,
  1305 + &major_ver,
  1306 + &minor_ver);
1245 1307 if (err < 0) {
1246   - printf("dpni_get_attributes() failed: %d\n", err);
1247   - goto err_get_attr;
  1308 + printf("dpni_get_api_version() failed: %d\n", err);
  1309 + goto err_get_version;
1248 1310 }
1249 1311  
1250   - if ((dpni_attr.version.major != DPNI_VER_MAJOR) ||
1251   - (dpni_attr.version.minor != DPNI_VER_MINOR)) {
  1312 + if (major_ver < DPNI_VER_MAJOR || (major_ver == DPNI_VER_MAJOR &&
  1313 + minor_ver < DPNI_VER_MINOR)) {
1252 1314 printf("DPNI version mismatch found %u.%u,",
1253   - dpni_attr.version.major, dpni_attr.version.minor);
  1315 + major_ver, minor_ver);
1254 1316 printf("supported version is %u.%u\n",
1255 1317 DPNI_VER_MAJOR, DPNI_VER_MINOR);
1256 1318 }
1257 1319  
1258   - dflt_dpni->dpni_id = dpni_attr.id;
  1320 + err = dpni_open(dflt_mc_io,
  1321 + MC_CMD_NO_FLAGS,
  1322 + dflt_dpni->dpni_id,
  1323 + &dflt_dpni->dpni_handle);
  1324 + if (err) {
  1325 + printf("dpni_open() failed\n");
  1326 + goto err_open;
  1327 + }
  1328 +
1259 1329 #ifdef DEBUG
1260 1330 printf("Init: DPNI id=0x%d\n", dflt_dpni->dpni_id);
1261 1331 #endif
1262   -
1263 1332 err = dpni_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle);
1264 1333 if (err < 0) {
1265 1334 printf("dpni_close() failed: %d\n", err);
1266 1335  
1267 1336  
... ... @@ -1269,11 +1338,15 @@
1269 1338 return 0;
1270 1339  
1271 1340 err_close:
1272   -err_get_attr:
1273 1341 dpni_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle);
1274   - dpni_destroy(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle);
  1342 +err_open:
  1343 +err_get_version:
  1344 + dpni_destroy(dflt_mc_io,
  1345 + dflt_dprc_handle,
  1346 + MC_CMD_NO_FLAGS,
  1347 + dflt_dpni->dpni_id);
1275 1348 err_create:
1276   -err_prepare_extended_cfg:
  1349 +err_prepare_cfg:
1277 1350 free(dflt_dpni);
1278 1351 err_calloc:
1279 1352 return err;
1280 1353  
... ... @@ -1283,16 +1356,9 @@
1283 1356 {
1284 1357 int err;
1285 1358  
1286   - err = dpni_open(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_id,
1287   - &dflt_dpni->dpni_handle);
  1359 + err = dpni_destroy(dflt_mc_io, dflt_dprc_handle, MC_CMD_NO_FLAGS,
  1360 + dflt_dpni->dpni_id);
1288 1361 if (err < 0) {
1289   - printf("dpni_open() failed: %d\n", err);
1290   - goto err;
1291   - }
1292   -
1293   - err = dpni_destroy(dflt_mc_io, MC_CMD_NO_FLAGS,
1294   - dflt_dpni->dpni_handle);
1295   - if (err < 0) {
1296 1362 printf("dpni_destroy() failed: %d\n", err);
1297 1363 goto err;
1298 1364 }
... ... @@ -1420,6 +1486,7 @@
1420 1486 #endif
1421 1487  
1422 1488 sub_cmd = argv[2][0];
  1489 +
1423 1490 switch (sub_cmd) {
1424 1491 case 'm':
1425 1492 if (argc < 5)
drivers/net/ldpaa_eth/ldpaa_eth.c
1 1 /*
2   - * Copyright (C) 2014 Freescale Semiconductor
  2 + * Copyright (C) 2014-2016 Freescale Semiconductor
  3 + * Copyright 2017 NXP
3 4 *
4 5 * SPDX-License-Identifier: GPL-2.0+
5 6 */
6 7  
7 8  
8 9  
9 10  
10 11  
11 12  
12 13  
13 14  
... ... @@ -42,80 +43,67 @@
42 43 #endif
43 44  
44 45 #ifdef DEBUG
45   -static void ldpaa_eth_get_dpni_counter(void)
46   -{
47   - int err = 0;
48   - u64 value;
49 46  
50   - err = dpni_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
51   - dflt_dpni->dpni_handle,
52   - DPNI_CNT_ING_FRAME,
53   - &value);
54   - if (err < 0) {
55   - printf("dpni_get_counter: DPNI_CNT_ING_FRAME failed\n");
56   - return;
57   - }
58   - printf("DPNI_CNT_ING_FRAME=%lld\n", value);
  47 +#define DPNI_STATS_PER_PAGE 6
59 48  
60   - err = dpni_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
61   - dflt_dpni->dpni_handle,
62   - DPNI_CNT_ING_BYTE,
63   - &value);
64   - if (err < 0) {
65   - printf("dpni_get_counter: DPNI_CNT_ING_BYTE failed\n");
66   - return;
67   - }
68   - printf("DPNI_CNT_ING_BYTE=%lld\n", value);
  49 +static const char *dpni_statistics[][DPNI_STATS_PER_PAGE] = {
  50 + {
  51 + "DPNI_CNT_ING_ALL_FRAMES",
  52 + "DPNI_CNT_ING_ALL_BYTES",
  53 + "DPNI_CNT_ING_MCAST_FRAMES",
  54 + "DPNI_CNT_ING_MCAST_BYTES",
  55 + "DPNI_CNT_ING_BCAST_FRAMES",
  56 + "DPNI_CNT_ING_BCAST_BYTES",
  57 + }, {
  58 + "DPNI_CNT_EGR_ALL_FRAMES",
  59 + "DPNI_CNT_EGR_ALL_BYTES",
  60 + "DPNI_CNT_EGR_MCAST_FRAMES",
  61 + "DPNI_CNT_EGR_MCAST_BYTES",
  62 + "DPNI_CNT_EGR_BCAST_FRAMES",
  63 + "DPNI_CNT_EGR_BCAST_BYTES",
  64 + }, {
  65 + "DPNI_CNT_ING_FILTERED_FRAMES",
  66 + "DPNI_CNT_ING_DISCARDED_FRAMES",
  67 + "DPNI_CNT_ING_NOBUFFER_DISCARDS",
  68 + "DPNI_CNT_EGR_DISCARDED_FRAMES",
  69 + "DPNI_CNT_EGR_CNF_FRAMES",
  70 + ""
  71 + },
  72 +};
69 73  
70   - err = dpni_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
71   - dflt_dpni->dpni_handle,
72   - DPNI_CNT_ING_FRAME_DROP ,
73   - &value);
74   - if (err < 0) {
75   - printf("dpni_get_counter: DPNI_CNT_ING_FRAME_DROP failed\n");
76   - return;
77   - }
78   - printf("DPNI_CNT_ING_FRAME_DROP =%lld\n", value);
  74 +static void print_dpni_stats(const char *strings[],
  75 + struct dpni_statistics dpni_stats)
  76 +{
  77 + uint64_t *stat;
  78 + int i;
79 79  
80   - err = dpni_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
81   - dflt_dpni->dpni_handle,
82   - DPNI_CNT_ING_FRAME_DISCARD,
83   - &value);
84   - if (err < 0) {
85   - printf("dpni_get_counter: DPNI_CNT_ING_FRAME_DISCARD failed\n");
86   - return;
  80 + stat = (uint64_t *)&dpni_stats;
  81 + for (i = 0; i < DPNI_STATS_PER_PAGE; i++) {
  82 + if (strcmp(strings[i], "\0") == 0)
  83 + break;
  84 + printf("%s= %llu\n", strings[i], *stat);
  85 + stat++;
87 86 }
88   - printf("DPNI_CNT_ING_FRAME_DISCARD=%lld\n", value);
  87 +}
89 88  
90   - err = dpni_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
91   - dflt_dpni->dpni_handle,
92   - DPNI_CNT_EGR_FRAME,
93   - &value);
94   - if (err < 0) {
95   - printf("dpni_get_counter: DPNI_CNT_EGR_FRAME failed\n");
96   - return;
97   - }
98   - printf("DPNI_CNT_EGR_FRAME=%lld\n", value);
  89 +static void ldpaa_eth_get_dpni_counter(void)
  90 +{
  91 + int err = 0;
  92 + unsigned int page = 0;
  93 + struct dpni_statistics dpni_stats;
99 94  
100   - err = dpni_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
101   - dflt_dpni->dpni_handle,
102   - DPNI_CNT_EGR_BYTE ,
103   - &value);
104   - if (err < 0) {
105   - printf("dpni_get_counter: DPNI_CNT_EGR_BYTE failed\n");
106   - return;
  95 + printf("DPNI counters ..\n");
  96 + for (page = 0; page < 3; page++) {
  97 + err = dpni_get_statistics(dflt_mc_io, MC_CMD_NO_FLAGS,
  98 + dflt_dpni->dpni_handle, page,
  99 + &dpni_stats);
  100 + if (err < 0) {
  101 + printf("dpni_get_statistics: failed:");
  102 + printf("%d for page[%d]\n", err, page);
  103 + return;
  104 + }
  105 + print_dpni_stats(dpni_statistics[page], dpni_stats);
107 106 }
108   - printf("DPNI_CNT_EGR_BYTE =%lld\n", value);
109   -
110   - err = dpni_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
111   - dflt_dpni->dpni_handle,
112   - DPNI_CNT_EGR_FRAME_DISCARD ,
113   - &value);
114   - if (err < 0) {
115   - printf("dpni_get_counter: DPNI_CNT_EGR_FRAME_DISCARD failed\n");
116   - return;
117   - }
118   - printf("DPNI_CNT_EGR_FRAME_DISCARD =%lld\n", value);
119 107 }
120 108  
121 109 static void ldpaa_eth_get_dpmac_counter(struct eth_device *net_dev)
... ... @@ -132,6 +120,7 @@
132 120 printf("dpmac_get_counter: DPMAC_CNT_ING_BYTE failed\n");
133 121 return;
134 122 }
  123 + printf("\nDPMAC counters ..\n");
135 124 printf("DPMAC_CNT_ING_BYTE=%lld\n", value);
136 125  
137 126 err = dpmac_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
... ... @@ -392,7 +381,6 @@
392 381 static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)
393 382 {
394 383 struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)net_dev->priv;
395   - struct dpni_queue_attr rx_queue_attr;
396 384 struct dpmac_link_state dpmac_link_state = { 0 };
397 385 #ifdef DEBUG
398 386 struct dpni_link_state link_state;
... ... @@ -400,6 +388,7 @@
400 388 int err = 0;
401 389 struct mii_dev *bus;
402 390 phy_interface_t enet_if;
  391 + struct dpni_queue d_queue;
403 392  
404 393 if (net_dev->state == ETH_STATE_ACTIVE)
405 394 return 0;
... ... @@ -508,6 +497,10 @@
508 497 }
509 498  
510 499 #ifdef DEBUG
  500 + printf("DPMAC link status: %d - ", dpmac_link_state.up);
  501 + dpmac_link_state.up == 0 ? printf("down\n") :
  502 + dpmac_link_state.up == 1 ? printf("up\n") : printf("error state\n");
  503 +
511 504 err = dpni_get_link_state(dflt_mc_io, MC_CMD_NO_FLAGS,
512 505 dflt_dpni->dpni_handle, &link_state);
513 506 if (err < 0) {
514 507  
515 508  
516 509  
... ... @@ -515,20 +508,21 @@
515 508 return err;
516 509 }
517 510  
518   - printf("link status: %d - ", link_state.up);
  511 + printf("DPNI link status: %d - ", link_state.up);
519 512 link_state.up == 0 ? printf("down\n") :
520 513 link_state.up == 1 ? printf("up\n") : printf("error state\n");
521 514 #endif
522 515  
523   - /* TODO: support multiple Rx flows */
524   - err = dpni_get_rx_flow(dflt_mc_io, MC_CMD_NO_FLAGS,
525   - dflt_dpni->dpni_handle, 0, 0, &rx_queue_attr);
  516 + memset(&d_queue, 0, sizeof(struct dpni_queue));
  517 + err = dpni_get_queue(dflt_mc_io, MC_CMD_NO_FLAGS,
  518 + dflt_dpni->dpni_handle, DPNI_QUEUE_RX,
  519 + 0, 0, &d_queue);
526 520 if (err) {
527   - printf("dpni_get_rx_flow() failed\n");
528   - goto err_rx_flow;
  521 + printf("dpni_get_queue failed\n");
  522 + goto err_get_queue;
529 523 }
530 524  
531   - priv->rx_dflt_fqid = rx_queue_attr.fqid;
  525 + priv->rx_dflt_fqid = d_queue.fqid;
532 526  
533 527 err = dpni_get_qdid(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle,
534 528 &priv->tx_qdid);
... ... @@ -540,7 +534,7 @@
540 534 return priv->phydev->link;
541 535  
542 536 err_qdid:
543   -err_rx_flow:
  537 +err_get_queue:
544 538 dpni_disable(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle);
545 539 err_dpni_bind:
546 540 ldpaa_dpbp_free();
... ... @@ -548,7 +542,10 @@
548 542 dpni_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle);
549 543 err_dpni_setup:
550 544 err_dpamc_bind:
551   - dpmac_destroy(dflt_mc_io, MC_CMD_NO_FLAGS, priv->dpmac_handle);
  545 + dpmac_close(dflt_mc_io, MC_CMD_NO_FLAGS, priv->dpmac_handle);
  546 + dpmac_destroy(dflt_mc_io,
  547 + dflt_dprc_handle,
  548 + MC_CMD_NO_FLAGS, priv->dpmac_id);
552 549 err_dpmac_setup:
553 550 return err;
554 551 }
555 552  
... ... @@ -575,8 +572,15 @@
575 572 if (err < 0)
576 573 printf("dprc_disconnect() failed dpmac_endpoint\n");
577 574  
578   - err = dpmac_destroy(dflt_mc_io, MC_CMD_NO_FLAGS, priv->dpmac_handle);
  575 + err = dpmac_close(dflt_mc_io, MC_CMD_NO_FLAGS, priv->dpmac_handle);
579 576 if (err < 0)
  577 + printf("dpmac_close() failed\n");
  578 +
  579 + err = dpmac_destroy(dflt_mc_io,
  580 + dflt_dprc_handle,
  581 + MC_CMD_NO_FLAGS,
  582 + priv->dpmac_id);
  583 + if (err < 0)
580 584 printf("dpmac_destroy() failed\n");
581 585  
582 586 /* Stop Tx and Rx traffic */
583 587  
584 588  
585 589  
... ... @@ -593,9 +597,16 @@
593 597 }
594 598 #endif
595 599  
  600 + /* Free DPBP handle and reset. */
596 601 ldpaa_dpbp_free();
  602 +
597 603 dpni_reset(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle);
  604 + if (err < 0)
  605 + printf("dpni_reset() failed\n");
  606 +
598 607 dpni_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle);
  608 + if (err < 0)
  609 + printf("dpni_close() failed\n");
599 610 }
600 611  
601 612 static void ldpaa_dpbp_drain_cnt(int count)
... ... @@ -711,6 +722,7 @@
711 722 }
712 723  
713 724 err = ldpaa_dpbp_seed(dflt_dpbp->dpbp_attr.bpid);
  725 +
714 726 if (err) {
715 727 printf("Buffer seeding failed for DPBP %d (bpid=%d)\n",
716 728 dflt_dpbp->dpbp_attr.id, dflt_dpbp->dpbp_attr.bpid);
717 729  
718 730  
... ... @@ -739,21 +751,19 @@
739 751 static int ldpaa_dpmac_version_check(struct fsl_mc_io *mc_io,
740 752 struct ldpaa_eth_priv *priv)
741 753 {
742   - struct dpmac_attr attr;
743 754 int error;
  755 + uint16_t major_ver, minor_ver;
744 756  
745   - memset(&attr, 0, sizeof(struct dpmac_attr));
746   - error = dpmac_get_attributes(mc_io, MC_CMD_NO_FLAGS,
747   - priv->dpmac_handle,
748   - &attr);
749   - if (error == 0) {
750   - if ((attr.version.major != DPMAC_VER_MAJOR) ||
751   - (attr.version.minor != DPMAC_VER_MINOR)) {
752   - printf("DPMAC version mismatch found %u.%u,",
753   - attr.version.major, attr.version.minor);
754   - printf("supported version is %u.%u\n",
755   - DPMAC_VER_MAJOR, DPMAC_VER_MINOR);
756   - }
  757 + error = dpmac_get_api_version(dflt_mc_io, 0,
  758 + &major_ver,
  759 + &minor_ver);
  760 + if ((major_ver < DPMAC_VER_MAJOR) ||
  761 + (major_ver == DPMAC_VER_MAJOR && minor_ver < DPMAC_VER_MINOR)) {
  762 + printf("DPMAC version mismatch found %u.%u,",
  763 + major_ver, minor_ver);
  764 + printf("supported version is %u.%u\n",
  765 + DPMAC_VER_MAJOR, DPMAC_VER_MINOR);
  766 + return error;
757 767 }
758 768  
759 769 return error;
760 770  
761 771  
762 772  
763 773  
... ... @@ -765,16 +775,38 @@
765 775 struct dpmac_cfg dpmac_cfg;
766 776  
767 777 dpmac_cfg.mac_id = priv->dpmac_id;
768   - err = dpmac_create(dflt_mc_io, MC_CMD_NO_FLAGS, &dpmac_cfg,
769   - &priv->dpmac_handle);
  778 +
  779 + err = dpmac_create(dflt_mc_io,
  780 + dflt_dprc_handle,
  781 + MC_CMD_NO_FLAGS, &dpmac_cfg,
  782 + &priv->dpmac_id);
770 783 if (err)
771 784 printf("dpmac_create() failed\n");
772 785  
773 786 err = ldpaa_dpmac_version_check(dflt_mc_io, priv);
774   - if (err < 0)
  787 + if (err < 0) {
775 788 printf("ldpaa_dpmac_version_check() failed: %d\n", err);
  789 + goto err_version_check;
  790 + }
776 791  
  792 + err = dpmac_open(dflt_mc_io,
  793 + MC_CMD_NO_FLAGS,
  794 + priv->dpmac_id,
  795 + &priv->dpmac_handle);
  796 + if (err < 0) {
  797 + printf("dpmac_open() failed: %d\n", err);
  798 + goto err_open;
  799 + }
  800 +
777 801 return err;
  802 +
  803 +err_open:
  804 +err_version_check:
  805 + dpmac_destroy(dflt_mc_io,
  806 + dflt_dprc_handle,
  807 + MC_CMD_NO_FLAGS, priv->dpmac_id);
  808 +
  809 + return err;
778 810 }
779 811  
780 812 static int ldpaa_dpmac_bind(struct ldpaa_eth_priv *priv)
... ... @@ -838,7 +870,6 @@
838 870 printf("dpni_open() failed\n");
839 871 goto err_open;
840 872 }
841   -
842 873 err = dpni_get_attributes(dflt_mc_io, MC_CMD_NO_FLAGS,
843 874 dflt_dpni->dpni_handle,
844 875 &dflt_dpni->dpni_attrs);
845 876  
846 877  
... ... @@ -857,12 +888,13 @@
857 888 dflt_dpni->buf_layout.private_data_size = LDPAA_ETH_SWA_SIZE;
858 889 /* HW erratum mandates data alignment in multiples of 256 */
859 890 dflt_dpni->buf_layout.data_align = LDPAA_ETH_BUF_ALIGN;
  891 +
860 892 /* ...rx, ... */
861   - err = dpni_set_rx_buffer_layout(dflt_mc_io, MC_CMD_NO_FLAGS,
862   - dflt_dpni->dpni_handle,
863   - &dflt_dpni->buf_layout);
  893 + err = dpni_set_buffer_layout(dflt_mc_io, MC_CMD_NO_FLAGS,
  894 + dflt_dpni->dpni_handle,
  895 + &dflt_dpni->buf_layout, DPNI_QUEUE_RX);
864 896 if (err) {
865   - printf("dpni_set_rx_buffer_layout() failed");
  897 + printf("dpni_set_buffer_layout() failed");
866 898 goto err_buf_layout;
867 899 }
868 900  
869 901  
870 902  
871 903  
... ... @@ -870,21 +902,22 @@
870 902 /* remove Rx-only options */
871 903 dflt_dpni->buf_layout.options &= ~(DPNI_BUF_LAYOUT_OPT_DATA_ALIGN |
872 904 DPNI_BUF_LAYOUT_OPT_PARSER_RESULT);
873   - err = dpni_set_tx_buffer_layout(dflt_mc_io, MC_CMD_NO_FLAGS,
874   - dflt_dpni->dpni_handle,
875   - &dflt_dpni->buf_layout);
  905 + err = dpni_set_buffer_layout(dflt_mc_io, MC_CMD_NO_FLAGS,
  906 + dflt_dpni->dpni_handle,
  907 + &dflt_dpni->buf_layout, DPNI_QUEUE_TX);
876 908 if (err) {
877   - printf("dpni_set_tx_buffer_layout() failed");
  909 + printf("dpni_set_buffer_layout() failed");
878 910 goto err_buf_layout;
879 911 }
880 912  
881 913 /* ... tx-confirm. */
882 914 dflt_dpni->buf_layout.options &= ~DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE;
883   - err = dpni_set_tx_conf_buffer_layout(dflt_mc_io, MC_CMD_NO_FLAGS,
884   - dflt_dpni->dpni_handle,
885   - &dflt_dpni->buf_layout);
  915 + err = dpni_set_buffer_layout(dflt_mc_io, MC_CMD_NO_FLAGS,
  916 + dflt_dpni->dpni_handle,
  917 + &dflt_dpni->buf_layout,
  918 + DPNI_QUEUE_TX_CONFIRM);
886 919 if (err) {
887   - printf("dpni_set_tx_conf_buffer_layout() failed");
  920 + printf("dpni_set_buffer_layout() failed");
888 921 goto err_buf_layout;
889 922 }
890 923  
... ... @@ -919,8 +952,7 @@
919 952 static int ldpaa_dpni_bind(struct ldpaa_eth_priv *priv)
920 953 {
921 954 struct dpni_pools_cfg pools_params;
922   - struct dpni_tx_flow_cfg dflt_tx_flow;
923   - struct dpni_tx_conf_cfg tx_conf_cfg;
  955 + struct dpni_queue tx_queue;
924 956 int err = 0;
925 957  
926 958 memset(&pools_params, 0, sizeof(pools_params));
927 959  
928 960  
929 961  
930 962  
... ... @@ -934,26 +966,22 @@
934 966 return err;
935 967 }
936 968  
937   - priv->tx_flow_id = DPNI_NEW_FLOW_ID;
938   - memset(&dflt_tx_flow, 0, sizeof(dflt_tx_flow));
  969 + memset(&tx_queue, 0, sizeof(struct dpni_queue));
939 970  
940   - dflt_tx_flow.use_common_tx_conf_queue = 0;
941   - err = dpni_set_tx_flow(dflt_mc_io, MC_CMD_NO_FLAGS,
942   - dflt_dpni->dpni_handle, &priv->tx_flow_id,
943   - &dflt_tx_flow);
  971 + err = dpni_set_queue(dflt_mc_io, MC_CMD_NO_FLAGS,
  972 + dflt_dpni->dpni_handle,
  973 + DPNI_QUEUE_TX, 0, 0, &tx_queue);
  974 +
944 975 if (err) {
945   - printf("dpni_set_tx_flow() failed\n");
  976 + printf("dpni_set_queue() failed\n");
946 977 return err;
947 978 }
948 979  
949   - memset(&tx_conf_cfg, 0, sizeof(struct dpni_tx_conf_cfg));
950   - tx_conf_cfg.errors_only = true;
951   - /*Set tx-conf and error configuration*/
952   - err = dpni_set_tx_conf(dflt_mc_io, MC_CMD_NO_FLAGS,
953   - dflt_dpni->dpni_handle,
954   - priv->tx_flow_id, &tx_conf_cfg);
  980 + err = dpni_set_tx_confirmation_mode(dflt_mc_io, MC_CMD_NO_FLAGS,
  981 + dflt_dpni->dpni_handle,
  982 + DPNI_CONF_DISABLE);
955 983 if (err) {
956   - printf("dpni_set_tx_conf() failed\n");
  984 + printf("dpni_set_tx_confirmation_mode() failed\n");
957 985 return err;
958 986 }
959 987  
... ... @@ -995,7 +1023,6 @@
995 1023 struct eth_device *net_dev = NULL;
996 1024 struct ldpaa_eth_priv *priv = NULL;
997 1025 int err = 0;
998   -
999 1026  
1000 1027 /* Net device */
1001 1028 net_dev = (struct eth_device *)malloc(sizeof(struct eth_device));
drivers/net/ldpaa_eth/ldpaa_eth.h
1 1 /*
2   - * Copyright (C) 2014 Freescale Semiconductor
  2 + * Copyright (C) 2014-2016 Freescale Semiconductor
  3 + * Copyright 2017 NXP
3 4 *
4 5 * SPDX-License-Identifier: GPL-2.0+
5 6 */
... ... @@ -117,7 +118,7 @@
117 118  
118 119 struct ldpaa_eth_priv {
119 120 struct eth_device *net_dev;
120   - int dpmac_id;
  121 + uint32_t dpmac_id;
121 122 uint16_t dpmac_handle;
122 123  
123 124 uint16_t tx_data_offset;
include/fsl-mc/fsl_dpbp.h
1 1 /*
2 2 * Freescale Layerscape MC I/O wrapper
3 3 *
4   - * Copyright (C) 2013-2015 Freescale Semiconductor, Inc.
5   - * Author: German Rivera <German.Rivera@freescale.com>
  4 + * Copyright (C) 2013-2016 Freescale Semiconductor, Inc.
  5 + * Copyright 2017 NXP
6 6 *
7 7 * SPDX-License-Identifier: GPL-2.0+
8 8 */
9 9  
10 10  
... ... @@ -14,19 +14,21 @@
14 14 #define __FSL_DPBP_H
15 15  
16 16 /* DPBP Version */
17   -#define DPBP_VER_MAJOR 2
18   -#define DPBP_VER_MINOR 2
  17 +#define DPBP_VER_MAJOR 3
  18 +#define DPBP_VER_MINOR 3
19 19  
20 20 /* Command IDs */
21   -#define DPBP_CMDID_CLOSE 0x800
22   -#define DPBP_CMDID_OPEN 0x804
23   -#define DPBP_CMDID_CREATE 0x904
24   -#define DPBP_CMDID_DESTROY 0x900
  21 +#define DPBP_CMDID_CLOSE 0x8001
  22 +#define DPBP_CMDID_OPEN 0x8041
  23 +#define DPBP_CMDID_CREATE 0x9041
  24 +#define DPBP_CMDID_DESTROY 0x9841
  25 +#define DPBP_CMDID_GET_API_VERSION 0xa041
25 26  
26   -#define DPBP_CMDID_ENABLE 0x002
27   -#define DPBP_CMDID_DISABLE 0x003
28   -#define DPBP_CMDID_GET_ATTR 0x004
29   -#define DPBP_CMDID_RESET 0x005
  27 +#define DPBP_CMDID_ENABLE 0x0021
  28 +#define DPBP_CMDID_DISABLE 0x0031
  29 +#define DPBP_CMDID_GET_ATTR 0x0041
  30 +#define DPBP_CMDID_RESET 0x0051
  31 +#define DPBP_CMDID_IS_ENABLED 0x0061
30 32  
31 33 /* cmd, param, offset, width, type, arg_name */
32 34 #define DPBP_CMD_OPEN(cmd, dpbp_id) \
... ... @@ -37,8 +39,6 @@
37 39 do { \
38 40 MC_RSP_OP(cmd, 0, 16, 16, uint16_t, attr->bpid); \
39 41 MC_RSP_OP(cmd, 0, 32, 32, int, attr->id);\
40   - MC_RSP_OP(cmd, 1, 0, 16, uint16_t, attr->version.major);\
41   - MC_RSP_OP(cmd, 1, 16, 16, uint16_t, attr->version.minor);\
42 42 } while (0)
43 43  
44 44 /* Data Path Buffer Pool API
45 45  
... ... @@ -114,9 +114,10 @@
114 114 * Return: '0' on Success; Error code otherwise.
115 115 */
116 116 int dpbp_create(struct fsl_mc_io *mc_io,
  117 + uint16_t dprc_token,
117 118 uint32_t cmd_flags,
118 119 const struct dpbp_cfg *cfg,
119   - uint16_t *token);
  120 + uint32_t *obj_id);
120 121  
121 122 /**
122 123 * dpbp_destroy() - Destroy the DPBP object and release all its resources.
123 124  
... ... @@ -127,8 +128,9 @@
127 128 * Return: '0' on Success; error code otherwise.
128 129 */
129 130 int dpbp_destroy(struct fsl_mc_io *mc_io,
  131 + uint16_t dprc_token,
130 132 uint32_t cmd_flags,
131   - uint16_t token);
  133 + uint32_t obj_id);
132 134  
133 135 /**
134 136 * dpbp_enable() - Enable the DPBP.
... ... @@ -189,16 +191,7 @@
189 191 * acquire/release operations on buffers
190 192 */
191 193 struct dpbp_attr {
192   - int id;
193   - /**
194   - * struct version - Structure representing DPBP version
195   - * @major: DPBP major version
196   - * @minor: DPBP minor version
197   - */
198   - struct {
199   - uint16_t major;
200   - uint16_t minor;
201   - } version;
  194 + uint32_t id;
202 195 uint16_t bpid;
203 196 };
204 197  
... ... @@ -216,6 +209,21 @@
216 209 uint32_t cmd_flags,
217 210 uint16_t token,
218 211 struct dpbp_attr *attr);
  212 +
  213 +/**
  214 + * dpbp_get_api_version - Retrieve DPBP Major and Minor version info.
  215 + *
  216 + * @mc_io: Pointer to MC portal's I/O object
  217 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  218 + * @major_ver: DPBP major version
  219 + * @minor_ver: DPBP minor version
  220 + *
  221 + * Return: '0' on Success; Error code otherwise.
  222 + */
  223 +int dpbp_get_api_version(struct fsl_mc_io *mc_io,
  224 + u32 cmd_flags,
  225 + u16 *major_ver,
  226 + u16 *minor_ver);
219 227  
220 228 /** @} */
221 229  
include/fsl-mc/fsl_dpio.h
1 1 /*
2   - * Copyright (C) 2013-2015 Freescale Semiconductor
  2 + * Copyright (C) 2013-2016 Freescale Semiconductor
  3 + * Copyright 2017 NXP
3 4 *
4 5 * SPDX-License-Identifier: GPL-2.0+
5 6 */
6 7  
7 8  
... ... @@ -8,19 +9,20 @@
8 9 #define _FSL_DPIO_H
9 10  
10 11 /* DPIO Version */
11   -#define DPIO_VER_MAJOR 3
  12 +#define DPIO_VER_MAJOR 4
12 13 #define DPIO_VER_MINOR 2
13 14  
14 15 /* Command IDs */
15   -#define DPIO_CMDID_CLOSE 0x800
16   -#define DPIO_CMDID_OPEN 0x803
17   -#define DPIO_CMDID_CREATE 0x903
18   -#define DPIO_CMDID_DESTROY 0x900
  16 +#define DPIO_CMDID_CLOSE 0x8001
  17 +#define DPIO_CMDID_OPEN 0x8031
  18 +#define DPIO_CMDID_CREATE 0x9031
  19 +#define DPIO_CMDID_DESTROY 0x9831
  20 +#define DPIO_CMDID_GET_API_VERSION 0xa031
19 21  
20   -#define DPIO_CMDID_ENABLE 0x002
21   -#define DPIO_CMDID_DISABLE 0x003
22   -#define DPIO_CMDID_GET_ATTR 0x004
23   -#define DPIO_CMDID_RESET 0x005
  22 +#define DPIO_CMDID_ENABLE 0x0021
  23 +#define DPIO_CMDID_DISABLE 0x0031
  24 +#define DPIO_CMDID_GET_ATTR 0x0041
  25 +#define DPIO_CMDID_RESET 0x0051
24 26  
25 27 /* cmd, param, offset, width, type, arg_name */
26 28 #define DPIO_CMD_OPEN(cmd, dpio_id) \
... ... @@ -43,8 +45,6 @@
43 45 MC_RSP_OP(cmd, 0, 56, 4, enum dpio_channel_mode, attr->channel_mode);\
44 46 MC_RSP_OP(cmd, 1, 0, 64, uint64_t, attr->qbman_portal_ce_offset);\
45 47 MC_RSP_OP(cmd, 2, 0, 64, uint64_t, attr->qbman_portal_ci_offset);\
46   - MC_RSP_OP(cmd, 3, 0, 16, uint16_t, attr->version.major);\
47   - MC_RSP_OP(cmd, 3, 16, 16, uint16_t, attr->version.minor);\
48 48 MC_RSP_OP(cmd, 3, 32, 32, uint32_t, attr->qbman_version);\
49 49 } while (0)
50 50  
... ... @@ -73,7 +73,7 @@
73 73 */
74 74 int dpio_open(struct fsl_mc_io *mc_io,
75 75 uint32_t cmd_flags,
76   - int dpio_id,
  76 + uint32_t dpio_id,
77 77 uint16_t *token);
78 78  
79 79 /**
80 80  
... ... @@ -114,9 +114,10 @@
114 114 /**
115 115 * dpio_create() - Create the DPIO object.
116 116 * @mc_io: Pointer to MC portal's I/O object
  117 + * @token: Authentication token.
117 118 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
118 119 * @cfg: Configuration structure
119   - * @token: Returned token; use in subsequent API calls
  120 + * @obj_id: Returned obj_id; use in subsequent API calls
120 121 *
121 122 * Create the DPIO object, allocate required resources and
122 123 * perform required initialization.
123 124  
124 125  
125 126  
126 127  
127 128  
... ... @@ -134,21 +135,24 @@
134 135 * Return: '0' on Success; Error code otherwise.
135 136 */
136 137 int dpio_create(struct fsl_mc_io *mc_io,
  138 + uint16_t token,
137 139 uint32_t cmd_flags,
138 140 const struct dpio_cfg *cfg,
139   - uint16_t *token);
  141 + uint32_t *obj_id);
140 142  
141 143 /**
142 144 * dpio_destroy() - Destroy the DPIO object and release all its resources.
143 145 * @mc_io: Pointer to MC portal's I/O object
  146 + * @token: Authentication token.
144 147 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
145   - * @token: Token of DPIO object
  148 + * @obj_id: Object ID of DPIO
146 149 *
147 150 * Return: '0' on Success; Error code otherwise
148 151 */
149 152 int dpio_destroy(struct fsl_mc_io *mc_io,
  153 + uint16_t token,
150 154 uint32_t cmd_flags,
151   - uint16_t token);
  155 + uint32_t obj_id);
152 156  
153 157 /**
154 158 * dpio_enable() - Enable the DPIO, allow I/O portal operations.
... ... @@ -199,16 +203,7 @@
199 203 * @qbman_version: QBMAN version
200 204 */
201 205 struct dpio_attr {
202   - int id;
203   - /**
204   - * struct version - DPIO version
205   - * @major: DPIO major version
206   - * @minor: DPIO minor version
207   - */
208   - struct {
209   - uint16_t major;
210   - uint16_t minor;
211   - } version;
  206 + uint32_t id;
212 207 uint64_t qbman_portal_ce_offset;
213 208 uint64_t qbman_portal_ci_offset;
214 209 uint16_t qbman_portal_id;
... ... @@ -230,6 +225,21 @@
230 225 uint32_t cmd_flags,
231 226 uint16_t token,
232 227 struct dpio_attr *attr);
  228 +
  229 +/**
  230 + * dpio_get_api_version - Retrieve DPIO Major and Minor version info.
  231 + *
  232 + * @mc_io: Pointer to MC portal's I/O object
  233 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  234 + * @major_ver: DPIO major version
  235 + * @minor_ver: DPIO minor version
  236 + *
  237 + * Return: '0' on Success; Error code otherwise.
  238 + */
  239 +int dpio_get_api_version(struct fsl_mc_io *mc_io,
  240 + u32 cmd_flags,
  241 + u16 *major_ver,
  242 + u16 *minor_ver);
233 243  
234 244 #endif /* _FSL_DPIO_H */
include/fsl-mc/fsl_dpmac.h
1 1 /*
2 2 * Freescale Layerscape MC I/O wrapper
3 3 *
4   - * Copyright (C) 2015 Freescale Semiconductor, Inc.
  4 + * Copyright (C) 2015-2016 Freescale Semiconductor, Inc.
  5 + * Copyright 2017 NXP
5 6 * Author: Prabhakar Kushwaha <prabhakar@freescale.com>
6 7 *
7 8 * SPDX-License-Identifier: GPL-2.0+
8 9  
9 10  
10 11  
11 12  
... ... @@ -11,27 +12,28 @@
11 12 #define __FSL_DPMAC_H
12 13  
13 14 /* DPMAC Version */
14   -#define DPMAC_VER_MAJOR 3
  15 +#define DPMAC_VER_MAJOR 4
15 16 #define DPMAC_VER_MINOR 2
16 17  
17 18 /* Command IDs */
18   -#define DPMAC_CMDID_CLOSE 0x800
19   -#define DPMAC_CMDID_OPEN 0x80c
20   -#define DPMAC_CMDID_CREATE 0x90c
21   -#define DPMAC_CMDID_DESTROY 0x900
  19 +#define DPMAC_CMDID_CLOSE 0x8001
  20 +#define DPMAC_CMDID_OPEN 0x80c1
  21 +#define DPMAC_CMDID_CREATE 0x90c1
  22 +#define DPMAC_CMDID_DESTROY 0x98c1
  23 +#define DPMAC_CMDID_GET_API_VERSION 0xa0c1
22 24  
23   -#define DPMAC_CMDID_GET_ATTR 0x004
24   -#define DPMAC_CMDID_RESET 0x005
  25 +#define DPMAC_CMDID_GET_ATTR 0x0041
  26 +#define DPMAC_CMDID_RESET 0x0051
25 27  
26   -#define DPMAC_CMDID_MDIO_READ 0x0c0
27   -#define DPMAC_CMDID_MDIO_WRITE 0x0c1
28   -#define DPMAC_CMDID_GET_LINK_CFG 0x0c2
29   -#define DPMAC_CMDID_SET_LINK_STATE 0x0c3
30   -#define DPMAC_CMDID_GET_COUNTER 0x0c4
  28 +#define DPMAC_CMDID_MDIO_READ 0x0c01
  29 +#define DPMAC_CMDID_MDIO_WRITE 0x0c11
  30 +#define DPMAC_CMDID_GET_LINK_CFG 0x0c21
  31 +#define DPMAC_CMDID_SET_LINK_STATE 0x0c31
  32 +#define DPMAC_CMDID_GET_COUNTER 0x0c41
31 33  
32 34 /* cmd, param, offset, width, type, arg_name */
33 35 #define DPMAC_CMD_CREATE(cmd, cfg) \
34   - MC_CMD_OP(cmd, 0, 0, 32, int, cfg->mac_id)
  36 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, cfg->mac_id)
35 37  
36 38 /* cmd, param, offset, width, type, arg_name */
37 39 #define DPMAC_CMD_OPEN(cmd, dpmac_id) \
... ... @@ -42,8 +44,6 @@
42 44 do { \
43 45 MC_RSP_OP(cmd, 0, 0, 32, int, attr->phy_id);\
44 46 MC_RSP_OP(cmd, 0, 32, 32, int, attr->id);\
45   - MC_RSP_OP(cmd, 1, 0, 16, uint16_t, attr->version.major);\
46   - MC_RSP_OP(cmd, 1, 16, 16, uint16_t, attr->version.minor);\
47 47 MC_RSP_OP(cmd, 1, 32, 8, enum dpmac_link_type, attr->link_type);\
48 48 MC_RSP_OP(cmd, 1, 40, 8, enum dpmac_eth_if, attr->eth_if);\
49 49 MC_RSP_OP(cmd, 2, 0, 32, uint32_t, attr->max_rate);\
... ... @@ -85,7 +85,7 @@
85 85  
86 86 /* cmd, param, offset, width, type, arg_name */
87 87 #define DPMAC_CMD_GET_COUNTER(cmd, type) \
88   - MC_CMD_OP(cmd, 0, 0, 8, enum dpmac_counter, type)
  88 + MC_CMD_OP(cmd, 1, 0, 64, enum dpmac_counter, type)
89 89  
90 90 /* cmd, param, offset, width, type, arg_name */
91 91 #define DPMAC_RSP_GET_COUNTER(cmd, counter) \
92 92  
... ... @@ -187,9 +187,10 @@
187 187 /**
188 188 * dpmac_create() - Create the DPMAC object.
189 189 * @mc_io: Pointer to MC portal's I/O object
  190 + * @token: Authentication token.
190 191 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
191 192 * @cfg: Configuration structure
192   - * @token: Returned token; use in subsequent API calls
  193 + * @obj_id: Returned obj_id; use in subsequent API calls
193 194 *
194 195 * Create the DPMAC object, allocate required resources and
195 196 * perform required initialization.
196 197  
197 198  
198 199  
199 200  
200 201  
... ... @@ -206,21 +207,24 @@
206 207 * Return: '0' on Success; Error code otherwise.
207 208 */
208 209 int dpmac_create(struct fsl_mc_io *mc_io,
  210 + uint16_t token,
209 211 uint32_t cmd_flags,
210 212 const struct dpmac_cfg *cfg,
211   - uint16_t *token);
  213 + uint32_t *obj_id);
212 214  
213 215 /**
214 216 * dpmac_destroy() - Destroy the DPMAC object and release all its resources.
215 217 * @mc_io: Pointer to MC portal's I/O object
  218 + * @token: Authentication token.
216 219 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
217   - * @token: Token of DPMAC object
  220 + * @obj_id: DPMAC object id
218 221 *
219 222 * Return: '0' on Success; error code otherwise.
220 223 */
221 224 int dpmac_destroy(struct fsl_mc_io *mc_io,
  225 + uint16_t token,
222 226 uint32_t cmd_flags,
223   - uint16_t token);
  227 + uint32_t obj_id);
224 228  
225 229 /* DPMAC IRQ Index and Events */
226 230  
... ... @@ -246,15 +250,6 @@
246 250 enum dpmac_link_type link_type;
247 251 enum dpmac_eth_if eth_if;
248 252 uint32_t max_rate;
249   - /**
250   - * struct version - Structure representing DPMAC version
251   - * @major: DPMAC major version
252   - * @minor: DPMAC minor version
253   - */
254   - struct {
255   - uint16_t major;
256   - uint16_t minor;
257   - } version;
258 253 };
259 254  
260 255 /**
... ... @@ -464,6 +459,20 @@
464 459 uint16_t token,
465 460 enum dpmac_counter type,
466 461 uint64_t *counter);
  462 +/**
  463 + * dpmac_get_api_version - Retrieve DPMAC Major and Minor version info.
  464 + *
  465 + * @mc_io: Pointer to MC portal's I/O object
  466 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  467 + * @major_ver: DPMAC major version
  468 + * @minor_ver: DPMAC minor version
  469 + *
  470 + * Return: '0' on Success; Error code otherwise.
  471 + */
  472 +int dpmac_get_api_version(struct fsl_mc_io *mc_io,
  473 + uint32_t cmd_flags,
  474 + uint16_t *major_ver,
  475 + uint16_t *minor_ver);
467 476  
468 477 #endif /* __FSL_DPMAC_H */
include/fsl-mc/fsl_dpni.h
Changes suppressed. Click to show
1 1 /*
2   - * Copyright (C) 2013-2015 Freescale Semiconductor
  2 + * Copyright (C) 2013-2016 Freescale Semiconductor
  3 + * Copyright 2017 NXP
3 4 *
4 5 * SPDX-License-Identifier: GPL-2.0+
5 6 */
6 7  
7 8  
8 9  
9 10  
10 11  
11 12  
12 13  
13 14  
14 15  
15 16  
16 17  
... ... @@ -7,134 +8,80 @@
7 8 #define _FSL_DPNI_H
8 9  
9 10 /* DPNI Version */
10   -#define DPNI_VER_MAJOR 6
11   -#define DPNI_VER_MINOR 0
  11 +#define DPNI_VER_MAJOR 7
  12 +#define DPNI_VER_MINOR 3
12 13  
13 14 /* Command IDs */
14   -#define DPNI_CMDID_OPEN 0x801
15   -#define DPNI_CMDID_CLOSE 0x800
16   -#define DPNI_CMDID_CREATE 0x901
17   -#define DPNI_CMDID_DESTROY 0x900
  15 +#define DPNI_CMDID_OPEN 0x8011
  16 +#define DPNI_CMDID_CLOSE 0x8001
  17 +#define DPNI_CMDID_CREATE 0x9011
  18 +#define DPNI_CMDID_DESTROY 0x9811
  19 +#define DPNI_CMDID_GET_API_VERSION 0xa011
18 20  
19   -#define DPNI_CMDID_ENABLE 0x002
20   -#define DPNI_CMDID_DISABLE 0x003
21   -#define DPNI_CMDID_GET_ATTR 0x004
22   -#define DPNI_CMDID_RESET 0x005
  21 +#define DPNI_CMDID_ENABLE 0x0021
  22 +#define DPNI_CMDID_DISABLE 0x0031
  23 +#define DPNI_CMDID_GET_ATTR 0x0041
  24 +#define DPNI_CMDID_RESET 0x0051
23 25  
24   -#define DPNI_CMDID_SET_POOLS 0x200
25   -#define DPNI_CMDID_GET_RX_BUFFER_LAYOUT 0x201
26   -#define DPNI_CMDID_SET_RX_BUFFER_LAYOUT 0x202
27   -#define DPNI_CMDID_GET_TX_BUFFER_LAYOUT 0x203
28   -#define DPNI_CMDID_SET_TX_BUFFER_LAYOUT 0x204
29   -#define DPNI_CMDID_SET_TX_CONF_BUFFER_LAYOUT 0x205
30   -#define DPNI_CMDID_GET_TX_CONF_BUFFER_LAYOUT 0x206
31   -#define DPNI_CMDID_SET_ERRORS_BEHAVIOR 0x20B
  26 +#define DPNI_CMDID_SET_POOLS 0x2002
  27 +#define DPNI_CMDID_SET_BUFFER_LAYOUT 0x2651
  28 +#define DPNI_CMDID_GET_BUFFER_LAYOUT 0x2641
  29 +#define DPNI_CMDID_SET_ERRORS_BEHAVIOR 0x20B1
32 30  
33   -#define DPNI_CMDID_GET_QDID 0x210
34   -#define DPNI_CMDID_GET_TX_DATA_OFFSET 0x212
35   -#define DPNI_CMDID_GET_COUNTER 0x213
36   -#define DPNI_CMDID_SET_COUNTER 0x214
37   -#define DPNI_CMDID_GET_LINK_STATE 0x215
38   -#define DPNI_CMDID_SET_LINK_CFG 0x21A
  31 +#define DPNI_CMDID_GET_QDID 0x2101
  32 +#define DPNI_CMDID_GET_TX_DATA_OFFSET 0x2121
  33 +#define DPNI_CMDID_GET_LINK_STATE 0x2151
  34 +#define DPNI_CMDID_SET_LINK_CFG 0x21A1
39 35  
40   -#define DPNI_CMDID_SET_PRIM_MAC 0x224
41   -#define DPNI_CMDID_GET_PRIM_MAC 0x225
42   -#define DPNI_CMDID_ADD_MAC_ADDR 0x226
43   -#define DPNI_CMDID_REMOVE_MAC_ADDR 0x227
  36 +#define DPNI_CMDID_SET_PRIM_MAC 0x2241
  37 +#define DPNI_CMDID_GET_PRIM_MAC 0x2251
  38 +#define DPNI_CMDID_ADD_MAC_ADDR 0x2261
  39 +#define DPNI_CMDID_REMOVE_MAC_ADDR 0x2271
44 40  
45   -#define DPNI_CMDID_SET_TX_FLOW 0x236
46   -#define DPNI_CMDID_GET_TX_FLOW 0x237
47   -#define DPNI_CMDID_SET_RX_FLOW 0x238
48   -#define DPNI_CMDID_GET_RX_FLOW 0x239
49   -#define DPNI_CMDID_SET_TX_CONF 0x257
50   -#define DPNI_CMDID_GET_TX_CONF 0x258
  41 +#define DPNI_CMDID_GET_STATISTICS 0x25D1
  42 +#define DPNI_CMDID_RESET_STATISTICS 0x25E1
  43 +#define DPNI_CMDID_GET_QUEUE 0x25F1
  44 +#define DPNI_CMDID_SET_QUEUE 0x2601
  45 +#define DPNI_CMDID_SET_TX_CONFIRMATION_MODE 0x2661
51 46  
52 47 /* cmd, param, offset, width, type, arg_name */
53 48 #define DPNI_CMD_OPEN(cmd, dpni_id) \
54 49 MC_CMD_OP(cmd, 0, 0, 32, int, dpni_id)
55 50  
56   -#define DPNI_PREP_EXTENDED_CFG(ext, cfg) \
  51 +/* cmd, param, offset, width, type, arg_name */
  52 +#define DPNI_PREP_CFG(param, cfg) \
57 53 do { \
58   - MC_PREP_OP(ext, 0, 0, 16, uint16_t, cfg->tc_cfg[0].max_dist); \
59   - MC_PREP_OP(ext, 0, 16, 16, uint16_t, cfg->tc_cfg[0].max_fs_entries); \
60   - MC_PREP_OP(ext, 0, 32, 16, uint16_t, cfg->tc_cfg[1].max_dist); \
61   - MC_PREP_OP(ext, 0, 48, 16, uint16_t, cfg->tc_cfg[1].max_fs_entries); \
62   - MC_PREP_OP(ext, 1, 0, 16, uint16_t, cfg->tc_cfg[2].max_dist); \
63   - MC_PREP_OP(ext, 1, 16, 16, uint16_t, cfg->tc_cfg[2].max_fs_entries); \
64   - MC_PREP_OP(ext, 1, 32, 16, uint16_t, cfg->tc_cfg[3].max_dist); \
65   - MC_PREP_OP(ext, 1, 48, 16, uint16_t, cfg->tc_cfg[3].max_fs_entries); \
66   - MC_PREP_OP(ext, 2, 0, 16, uint16_t, cfg->tc_cfg[4].max_dist); \
67   - MC_PREP_OP(ext, 2, 16, 16, uint16_t, cfg->tc_cfg[4].max_fs_entries); \
68   - MC_PREP_OP(ext, 2, 32, 16, uint16_t, cfg->tc_cfg[5].max_dist); \
69   - MC_PREP_OP(ext, 2, 48, 16, uint16_t, cfg->tc_cfg[5].max_fs_entries); \
70   - MC_PREP_OP(ext, 3, 0, 16, uint16_t, cfg->tc_cfg[6].max_dist); \
71   - MC_PREP_OP(ext, 3, 16, 16, uint16_t, cfg->tc_cfg[6].max_fs_entries); \
72   - MC_PREP_OP(ext, 3, 32, 16, uint16_t, cfg->tc_cfg[7].max_dist); \
73   - MC_PREP_OP(ext, 3, 48, 16, uint16_t, cfg->tc_cfg[7].max_fs_entries); \
74   - MC_PREP_OP(ext, 4, 0, 16, uint16_t, \
75   - cfg->ipr_cfg.max_open_frames_ipv4); \
76   - MC_PREP_OP(ext, 4, 16, 16, uint16_t, \
77   - cfg->ipr_cfg.max_open_frames_ipv6); \
78   - MC_PREP_OP(ext, 4, 32, 16, uint16_t, \
79   - cfg->ipr_cfg.max_reass_frm_size); \
80   - MC_PREP_OP(ext, 5, 0, 16, uint16_t, \
81   - cfg->ipr_cfg.min_frag_size_ipv4); \
82   - MC_PREP_OP(ext, 5, 16, 16, uint16_t, \
83   - cfg->ipr_cfg.min_frag_size_ipv6); \
  54 + MC_PREP_OP(param, 0, 0, 32, uint16_t, cfg->adv.options); \
  55 + MC_PREP_OP(param, 0, 32, 8, uint16_t, cfg->adv.num_queues); \
  56 + MC_PREP_OP(param, 0, 40, 8, uint16_t, cfg->adv.num_tcs); \
  57 + MC_PREP_OP(param, 0, 48, 8, uint16_t, cfg->adv.mac_entries); \
  58 + MC_PREP_OP(param, 1, 0, 8, uint16_t, cfg->adv.vlan_entries); \
  59 + MC_PREP_OP(param, 1, 16, 8, uint16_t, cfg->adv.qos_entries); \
  60 + MC_PREP_OP(param, 1, 32, 16, uint16_t, cfg->adv.fs_entries); \
84 61 } while (0)
85 62  
86   -#define DPNI_EXT_EXTENDED_CFG(ext, cfg) \
  63 +/* cmd, param, offset, width, type, arg_name */
  64 +#define DPNI_EXT_CFG(param, cfg) \
87 65 do { \
88   - MC_EXT_OP(ext, 0, 0, 16, uint16_t, cfg->tc_cfg[0].max_dist); \
89   - MC_EXT_OP(ext, 0, 16, 16, uint16_t, cfg->tc_cfg[0].max_fs_entries); \
90   - MC_EXT_OP(ext, 0, 32, 16, uint16_t, cfg->tc_cfg[1].max_dist); \
91   - MC_EXT_OP(ext, 0, 48, 16, uint16_t, cfg->tc_cfg[1].max_fs_entries); \
92   - MC_EXT_OP(ext, 1, 0, 16, uint16_t, cfg->tc_cfg[2].max_dist); \
93   - MC_EXT_OP(ext, 1, 16, 16, uint16_t, cfg->tc_cfg[2].max_fs_entries); \
94   - MC_EXT_OP(ext, 1, 32, 16, uint16_t, cfg->tc_cfg[3].max_dist); \
95   - MC_EXT_OP(ext, 1, 48, 16, uint16_t, cfg->tc_cfg[3].max_fs_entries); \
96   - MC_EXT_OP(ext, 2, 0, 16, uint16_t, cfg->tc_cfg[4].max_dist); \
97   - MC_EXT_OP(ext, 2, 16, 16, uint16_t, cfg->tc_cfg[4].max_fs_entries); \
98   - MC_EXT_OP(ext, 2, 32, 16, uint16_t, cfg->tc_cfg[5].max_dist); \
99   - MC_EXT_OP(ext, 2, 48, 16, uint16_t, cfg->tc_cfg[5].max_fs_entries); \
100   - MC_EXT_OP(ext, 3, 0, 16, uint16_t, cfg->tc_cfg[6].max_dist); \
101   - MC_EXT_OP(ext, 3, 16, 16, uint16_t, cfg->tc_cfg[6].max_fs_entries); \
102   - MC_EXT_OP(ext, 3, 32, 16, uint16_t, cfg->tc_cfg[7].max_dist); \
103   - MC_EXT_OP(ext, 3, 48, 16, uint16_t, cfg->tc_cfg[7].max_fs_entries); \
104   - MC_EXT_OP(ext, 4, 0, 16, uint16_t, \
105   - cfg->ipr_cfg.max_open_frames_ipv4); \
106   - MC_EXT_OP(ext, 4, 16, 16, uint16_t, \
107   - cfg->ipr_cfg.max_open_frames_ipv6); \
108   - MC_EXT_OP(ext, 4, 32, 16, uint16_t, \
109   - cfg->ipr_cfg.max_reass_frm_size); \
110   - MC_EXT_OP(ext, 5, 0, 16, uint16_t, \
111   - cfg->ipr_cfg.min_frag_size_ipv4); \
112   - MC_EXT_OP(ext, 5, 16, 16, uint16_t, \
113   - cfg->ipr_cfg.min_frag_size_ipv6); \
  66 + MC_EXT_OP(param, 0, 0, 32, uint16_t, cfg->adv.options); \
  67 + MC_EXT_OP(param, 0, 32, 8, uint16_t, cfg->adv.num_queues); \
  68 + MC_EXT_OP(param, 0, 40, 8, uint16_t, cfg->adv.num_tcs); \
  69 + MC_EXT_OP(param, 0, 48, 8, uint16_t, cfg->adv.mac_entries); \
  70 + MC_EXT_OP(param, 1, 0, 8, uint16_t, cfg->adv.vlan_entries); \
  71 + MC_EXT_OP(param, 1, 16, 8, uint16_t, cfg->adv.qos_entries); \
  72 + MC_EXT_OP(param, 1, 32, 16, uint16_t, cfg->adv.fs_entries); \
114 73 } while (0)
115 74  
116 75 /* cmd, param, offset, width, type, arg_name */
117 76 #define DPNI_CMD_CREATE(cmd, cfg) \
118 77 do { \
119   - MC_CMD_OP(cmd, 0, 0, 8, uint8_t, cfg->adv.max_tcs); \
120   - MC_CMD_OP(cmd, 0, 8, 8, uint8_t, cfg->adv.max_senders); \
121   - MC_CMD_OP(cmd, 0, 16, 8, uint8_t, cfg->mac_addr[5]); \
122   - MC_CMD_OP(cmd, 0, 24, 8, uint8_t, cfg->mac_addr[4]); \
123   - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->mac_addr[3]); \
124   - MC_CMD_OP(cmd, 0, 40, 8, uint8_t, cfg->mac_addr[2]); \
125   - MC_CMD_OP(cmd, 0, 48, 8, uint8_t, cfg->mac_addr[1]); \
126   - MC_CMD_OP(cmd, 0, 56, 8, uint8_t, cfg->mac_addr[0]); \
127   - MC_CMD_OP(cmd, 1, 0, 32, uint32_t, cfg->adv.options); \
128   - MC_CMD_OP(cmd, 2, 0, 8, uint8_t, cfg->adv.max_unicast_filters); \
129   - MC_CMD_OP(cmd, 2, 8, 8, uint8_t, cfg->adv.max_multicast_filters); \
130   - MC_CMD_OP(cmd, 2, 16, 8, uint8_t, cfg->adv.max_vlan_filters); \
131   - MC_CMD_OP(cmd, 2, 24, 8, uint8_t, cfg->adv.max_qos_entries); \
132   - MC_CMD_OP(cmd, 2, 32, 8, uint8_t, cfg->adv.max_qos_key_size); \
133   - MC_CMD_OP(cmd, 2, 48, 8, uint8_t, cfg->adv.max_dist_key_size); \
134   - MC_CMD_OP(cmd, 2, 56, 8, enum net_prot, cfg->adv.start_hdr); \
135   - MC_CMD_OP(cmd, 4, 48, 8, uint8_t, cfg->adv.max_policers); \
136   - MC_CMD_OP(cmd, 4, 56, 8, uint8_t, cfg->adv.max_congestion_ctrl); \
137   - MC_CMD_OP(cmd, 5, 0, 64, uint64_t, cfg->adv.ext_cfg_iova); \
  78 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, cfg->adv.options); \
  79 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->adv.num_queues); \
  80 + MC_CMD_OP(cmd, 0, 40, 8, uint8_t, cfg->adv.num_tcs); \
  81 + MC_CMD_OP(cmd, 0, 48, 8, uint8_t, cfg->adv.mac_entries); \
  82 + MC_CMD_OP(cmd, 1, 0, 8, uint8_t, cfg->adv.vlan_entries); \
  83 + MC_CMD_OP(cmd, 1, 16, 8, uint8_t, cfg->adv.qos_entries); \
  84 + MC_CMD_OP(cmd, 1, 32, 16, uint8_t, cfg->adv.fs_entries); \
138 85 } while (0)
139 86  
140 87 /* cmd, param, offset, width, type, arg_name */
141 88  
... ... @@ -168,27 +115,18 @@
168 115 } while (0)
169 116  
170 117 /* cmd, param, offset, width, type, arg_name */
171   -#define DPNI_CMD_GET_ATTR(cmd, attr) \
172   - MC_CMD_OP(cmd, 6, 0, 64, uint64_t, attr->ext_cfg_iova)
173   -
174   -/* cmd, param, offset, width, type, arg_name */
175 118 #define DPNI_RSP_GET_ATTR(cmd, attr) \
176 119 do { \
177   - MC_RSP_OP(cmd, 0, 0, 32, int, attr->id);\
178   - MC_RSP_OP(cmd, 0, 32, 8, uint8_t, attr->max_tcs); \
179   - MC_RSP_OP(cmd, 0, 40, 8, uint8_t, attr->max_senders); \
180   - MC_RSP_OP(cmd, 0, 48, 8, enum net_prot, attr->start_hdr); \
181   - MC_RSP_OP(cmd, 1, 0, 32, uint32_t, attr->options); \
182   - MC_RSP_OP(cmd, 2, 0, 8, uint8_t, attr->max_unicast_filters); \
183   - MC_RSP_OP(cmd, 2, 8, 8, uint8_t, attr->max_multicast_filters);\
184   - MC_RSP_OP(cmd, 2, 16, 8, uint8_t, attr->max_vlan_filters); \
185   - MC_RSP_OP(cmd, 2, 24, 8, uint8_t, attr->max_qos_entries); \
186   - MC_RSP_OP(cmd, 2, 32, 8, uint8_t, attr->max_qos_key_size); \
187   - MC_RSP_OP(cmd, 2, 40, 8, uint8_t, attr->max_dist_key_size); \
188   - MC_RSP_OP(cmd, 4, 48, 8, uint8_t, attr->max_policers); \
189   - MC_RSP_OP(cmd, 4, 56, 8, uint8_t, attr->max_congestion_ctrl); \
190   - MC_RSP_OP(cmd, 5, 32, 16, uint16_t, attr->version.major);\
191   - MC_RSP_OP(cmd, 5, 48, 16, uint16_t, attr->version.minor);\
  120 + MC_RSP_OP(cmd, 0, 0, 32, int, attr->options);\
  121 + MC_RSP_OP(cmd, 0, 32, 8, uint8_t, attr->max_num_queues); \
  122 + MC_RSP_OP(cmd, 0, 40, 8, uint8_t, attr->max_num_tcs); \
  123 + MC_RSP_OP(cmd, 0, 48, 8, uint8_t, attr->max_mac_entries); \
  124 + MC_RSP_OP(cmd, 1, 0, 8, uint8_t, attr->max_vlan_entries); \
  125 + MC_RSP_OP(cmd, 1, 16, 8, uint8_t, attr->max_qos_entries); \
  126 + MC_RSP_OP(cmd, 1, 32, 16, uint16_t, attr->max_fs_entries); \
  127 + MC_RSP_OP(cmd, 2, 0, 8, uint8_t, attr->max_qos_key_size); \
  128 + MC_RSP_OP(cmd, 2, 8, 8, uint8_t, attr->max_fs_key_size); \
  129 + MC_RSP_OP(cmd, 2, 16, 16, uint16_t, attr->wriop_version); \
192 130 } while (0)
193 131  
194 132 /* cmd, param, offset, width, type, arg_name */
195 133  
196 134  
... ... @@ -200,81 +138,20 @@
200 138 } while (0)
201 139  
202 140 /* cmd, param, offset, width, type, arg_name */
203   -#define DPNI_RSP_GET_RX_BUFFER_LAYOUT(cmd, layout) \
  141 +#define DPNI_CMD_SET_BUFFER_LAYOUT(cmd, layout, queue) \
204 142 do { \
205   - MC_RSP_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
206   - MC_RSP_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
207   - MC_RSP_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
208   - MC_RSP_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
209   - MC_RSP_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
210   - MC_RSP_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
211   - MC_RSP_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
  143 + MC_CMD_OP(cmd, 0, 0, 8, enum dpni_queue_type, queue); \
  144 + MC_CMD_OP(cmd, 1, 0, 16, uint16_t, layout->private_data_size); \
  145 + MC_CMD_OP(cmd, 1, 16, 16, uint16_t, layout->data_align); \
  146 + MC_CMD_OP(cmd, 0, 32, 16, uint16_t, layout->options); \
  147 + MC_CMD_OP(cmd, 0, 48, 1, int, layout->pass_timestamp); \
  148 + MC_CMD_OP(cmd, 0, 49, 1, int, layout->pass_parser_result); \
  149 + MC_CMD_OP(cmd, 0, 50, 1, int, layout->pass_frame_status); \
  150 + MC_CMD_OP(cmd, 1, 32, 16, uint16_t, layout->data_head_room); \
  151 + MC_CMD_OP(cmd, 1, 48, 16, uint16_t, layout->data_tail_room); \
212 152 } while (0)
213 153  
214 154 /* cmd, param, offset, width, type, arg_name */
215   -#define DPNI_CMD_SET_RX_BUFFER_LAYOUT(cmd, layout) \
216   -do { \
217   - MC_CMD_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
218   - MC_CMD_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
219   - MC_CMD_OP(cmd, 0, 32, 32, uint32_t, layout->options); \
220   - MC_CMD_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
221   - MC_CMD_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
222   - MC_CMD_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
223   - MC_CMD_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
224   - MC_CMD_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
225   -} while (0)
226   -
227   -/* cmd, param, offset, width, type, arg_name */
228   -#define DPNI_RSP_GET_TX_BUFFER_LAYOUT(cmd, layout) \
229   -do { \
230   - MC_RSP_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
231   - MC_RSP_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
232   - MC_RSP_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
233   - MC_RSP_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
234   - MC_RSP_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
235   - MC_RSP_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
236   - MC_RSP_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
237   -} while (0)
238   -
239   -/* cmd, param, offset, width, type, arg_name */
240   -#define DPNI_CMD_SET_TX_BUFFER_LAYOUT(cmd, layout) \
241   -do { \
242   - MC_CMD_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
243   - MC_CMD_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
244   - MC_CMD_OP(cmd, 0, 32, 32, uint32_t, layout->options); \
245   - MC_CMD_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
246   - MC_CMD_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
247   - MC_CMD_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
248   - MC_CMD_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
249   - MC_CMD_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
250   -} while (0)
251   -
252   -/* cmd, param, offset, width, type, arg_name */
253   -#define DPNI_RSP_GET_TX_CONF_BUFFER_LAYOUT(cmd, layout) \
254   -do { \
255   - MC_RSP_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
256   - MC_RSP_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
257   - MC_RSP_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
258   - MC_RSP_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
259   - MC_RSP_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
260   - MC_RSP_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
261   - MC_RSP_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
262   -} while (0)
263   -
264   -/* cmd, param, offset, width, type, arg_name */
265   -#define DPNI_CMD_SET_TX_CONF_BUFFER_LAYOUT(cmd, layout) \
266   -do { \
267   - MC_CMD_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
268   - MC_CMD_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
269   - MC_CMD_OP(cmd, 0, 32, 32, uint32_t, layout->options); \
270   - MC_CMD_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
271   - MC_CMD_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
272   - MC_CMD_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
273   - MC_CMD_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
274   - MC_CMD_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
275   -} while (0)
276   -
277   -/* cmd, param, offset, width, type, arg_name */
278 155 #define DPNI_RSP_GET_QDID(cmd, qdid) \
279 156 MC_RSP_OP(cmd, 0, 0, 16, uint16_t, qdid)
280 157  
... ... @@ -283,21 +160,6 @@
283 160 MC_RSP_OP(cmd, 0, 0, 16, uint16_t, data_offset)
284 161  
285 162 /* cmd, param, offset, width, type, arg_name */
286   -#define DPNI_CMD_GET_COUNTER(cmd, counter) \
287   - MC_CMD_OP(cmd, 0, 0, 16, enum dpni_counter, counter)
288   -
289   -/* cmd, param, offset, width, type, arg_name */
290   -#define DPNI_RSP_GET_COUNTER(cmd, value) \
291   - MC_RSP_OP(cmd, 1, 0, 64, uint64_t, value)
292   -
293   -/* cmd, param, offset, width, type, arg_name */
294   -#define DPNI_CMD_SET_COUNTER(cmd, counter, value) \
295   -do { \
296   - MC_CMD_OP(cmd, 0, 0, 16, enum dpni_counter, counter); \
297   - MC_CMD_OP(cmd, 1, 0, 64, uint64_t, value); \
298   -} while (0)
299   -
300   -/* cmd, param, offset, width, type, arg_name */
301 163 #define DPNI_CMD_SET_LINK_CFG(cmd, cfg) \
302 164 do { \
303 165 MC_CMD_OP(cmd, 1, 0, 32, uint32_t, cfg->rate);\
304 166  
305 167  
306 168  
307 169  
308 170  
309 171  
310 172  
311 173  
312 174  
... ... @@ -358,131 +220,56 @@
358 220 MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \
359 221 } while (0)
360 222  
361   -/* cmd, param, offset, width, type, arg_name */
362   -#define DPNI_CMD_SET_TX_FLOW(cmd, flow_id, cfg) \
  223 +#define DPNI_CMD_GET_QUEUE(cmd, type, tc, index) \
363 224 do { \
364   - MC_CMD_OP(cmd, 0, 43, 1, int, cfg->l3_chksum_gen);\
365   - MC_CMD_OP(cmd, 0, 44, 1, int, cfg->l4_chksum_gen);\
366   - MC_CMD_OP(cmd, 0, 45, 1, int, cfg->use_common_tx_conf_queue);\
367   - MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id);\
368   - MC_CMD_OP(cmd, 2, 0, 32, uint32_t, cfg->options);\
  225 + MC_CMD_OP(cmd, 0, 0, 8, enum dpni_queue_type, type); \
  226 + MC_CMD_OP(cmd, 0, 8, 8, uint8_t, tc); \
  227 + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, index); \
369 228 } while (0)
370 229  
371   -/* cmd, param, offset, width, type, arg_name */
372   -#define DPNI_RSP_SET_TX_FLOW(cmd, flow_id) \
373   - MC_RSP_OP(cmd, 0, 48, 16, uint16_t, flow_id)
374   -
375   -/* cmd, param, offset, width, type, arg_name */
376   -#define DPNI_CMD_GET_TX_FLOW(cmd, flow_id) \
377   - MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id)
378   -
379   -/* cmd, param, offset, width, type, arg_name */
380   -#define DPNI_RSP_GET_TX_FLOW(cmd, attr) \
  230 +#define DPNI_RSP_GET_QUEUE(cmd, queue) \
381 231 do { \
382   - MC_RSP_OP(cmd, 0, 43, 1, int, attr->l3_chksum_gen);\
383   - MC_RSP_OP(cmd, 0, 44, 1, int, attr->l4_chksum_gen);\
384   - MC_RSP_OP(cmd, 0, 45, 1, int, attr->use_common_tx_conf_queue);\
  232 + MC_RSP_OP(cmd, 1, 0, 32, uint32_t, (queue)->destination.id); \
  233 + MC_RSP_OP(cmd, 1, 56, 4, enum dpni_dest, (queue)->destination.type); \
  234 + MC_RSP_OP(cmd, 1, 62, 1, char, (queue)->destination.stash_ctrl); \
  235 + MC_RSP_OP(cmd, 1, 63, 1, char, (queue)->destination.hold_active); \
  236 + MC_RSP_OP(cmd, 2, 0, 64, uint64_t, (queue)->flc); \
  237 + MC_RSP_OP(cmd, 3, 0, 64, uint64_t, (queue)->user_context); \
  238 + MC_RSP_OP(cmd, 4, 0, 32, uint32_t, (queue)->fqid); \
  239 + MC_RSP_OP(cmd, 4, 32, 16, uint16_t, (queue)->qdbin); \
385 240 } while (0)
386 241  
387   -/* cmd, param, offset, width, type, arg_name */
388   -#define DPNI_CMD_SET_RX_FLOW(cmd, tc_id, flow_id, cfg) \
  242 +#define DPNI_CMD_SET_QUEUE(cmd, type, tc, index, queue) \
389 243 do { \
390   - MC_CMD_OP(cmd, 0, 0, 32, int, cfg->dest_cfg.dest_id); \
391   - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->dest_cfg.priority);\
392   - MC_CMD_OP(cmd, 0, 40, 2, enum dpni_dest, cfg->dest_cfg.dest_type);\
393   - MC_CMD_OP(cmd, 0, 42, 1, int, cfg->order_preservation_en);\
394   - MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id); \
395   - MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->user_ctx); \
396   - MC_CMD_OP(cmd, 2, 16, 8, uint8_t, tc_id); \
397   - MC_CMD_OP(cmd, 2, 32, 32, uint32_t, cfg->options); \
398   - MC_CMD_OP(cmd, 3, 0, 4, enum dpni_flc_type, cfg->flc_cfg.flc_type); \
399   - MC_CMD_OP(cmd, 3, 4, 4, enum dpni_stash_size, \
400   - cfg->flc_cfg.frame_data_size);\
401   - MC_CMD_OP(cmd, 3, 8, 4, enum dpni_stash_size, \
402   - cfg->flc_cfg.flow_context_size);\
403   - MC_CMD_OP(cmd, 3, 32, 32, uint32_t, cfg->flc_cfg.options);\
404   - MC_CMD_OP(cmd, 4, 0, 64, uint64_t, cfg->flc_cfg.flow_context);\
405   - MC_CMD_OP(cmd, 5, 0, 32, uint32_t, cfg->tail_drop_threshold); \
  244 + MC_CMD_OP(cmd, 0, 0, 8, enum dpni_queue_type, type); \
  245 + MC_CMD_OP(cmd, 0, 8, 8, uint8_t, tc); \
  246 + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, index); \
  247 + MC_CMD_OP(cmd, 0, 24, 8, uint8_t, (queue)->options); \
  248 + MC_CMD_OP(cmd, 1, 0, 32, uint32_t, (queue)->destination.id); \
  249 + MC_CMD_OP(cmd, 1, 56, 4, enum dpni_dest, (queue)->destination.type); \
  250 + MC_CMD_OP(cmd, 1, 62, 1, char, (queue)->destination.stash_ctrl); \
  251 + MC_CMD_OP(cmd, 1, 63, 1, char, (queue)->destination.hold_active); \
  252 + MC_CMD_OP(cmd, 1, 0, 32, uint32_t, (queue)->destination.id); \
  253 + MC_CMD_OP(cmd, 2, 0, 64, uint64_t, (queue)->flc); \
  254 + MC_CMD_OP(cmd, 3, 0, 64, uint64_t, (queue)->user_context); \
406 255 } while (0)
407 256  
408   -/* cmd, param, offset, width, type, arg_name */
409   -#define DPNI_CMD_GET_RX_FLOW(cmd, tc_id, flow_id) \
410   -do { \
411   - MC_CMD_OP(cmd, 0, 16, 8, uint8_t, tc_id); \
412   - MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id); \
413   -} while (0)
  257 +/* cmd, param, offset, width, type, arg_name */
  258 +#define DPNI_CMD_GET_STATISTICS(cmd, page) \
  259 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, page)
414 260  
415 261 /* cmd, param, offset, width, type, arg_name */
416   -#define DPNI_RSP_GET_RX_FLOW(cmd, attr) \
  262 +#define DPNI_RSP_GET_STATISTICS(cmd, stat) \
417 263 do { \
418   - MC_RSP_OP(cmd, 0, 0, 32, int, attr->dest_cfg.dest_id); \
419   - MC_RSP_OP(cmd, 0, 32, 8, uint8_t, attr->dest_cfg.priority);\
420   - MC_RSP_OP(cmd, 0, 40, 2, enum dpni_dest, attr->dest_cfg.dest_type); \
421   - MC_RSP_OP(cmd, 0, 42, 1, int, attr->order_preservation_en);\
422   - MC_RSP_OP(cmd, 1, 0, 64, uint64_t, attr->user_ctx); \
423   - MC_RSP_OP(cmd, 2, 0, 32, uint32_t, attr->tail_drop_threshold); \
424   - MC_RSP_OP(cmd, 2, 32, 32, uint32_t, attr->fqid); \
425   - MC_RSP_OP(cmd, 3, 0, 4, enum dpni_flc_type, attr->flc_cfg.flc_type); \
426   - MC_RSP_OP(cmd, 3, 4, 4, enum dpni_stash_size, \
427   - attr->flc_cfg.frame_data_size);\
428   - MC_RSP_OP(cmd, 3, 8, 4, enum dpni_stash_size, \
429   - attr->flc_cfg.flow_context_size);\
430   - MC_RSP_OP(cmd, 3, 32, 32, uint32_t, attr->flc_cfg.options);\
431   - MC_RSP_OP(cmd, 4, 0, 64, uint64_t, attr->flc_cfg.flow_context);\
  264 + MC_RSP_OP(cmd, 0, 0, 64, uint64_t, (stat)->counter0); \
  265 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, (stat)->counter1); \
  266 + MC_RSP_OP(cmd, 2, 0, 64, uint64_t, (stat)->counter2); \
  267 + MC_RSP_OP(cmd, 3, 0, 64, uint64_t, (stat)->counter3); \
  268 + MC_RSP_OP(cmd, 4, 0, 64, uint64_t, (stat)->counter4); \
  269 + MC_RSP_OP(cmd, 5, 0, 64, uint64_t, (stat)->counter5); \
  270 + MC_RSP_OP(cmd, 6, 0, 64, uint64_t, (stat)->counter6); \
432 271 } while (0)
433 272  
434   -#define DPNI_CMD_SET_TX_CONF(cmd, flow_id, cfg) \
435   -do { \
436   - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->queue_cfg.dest_cfg.priority); \
437   - MC_CMD_OP(cmd, 0, 40, 2, enum dpni_dest, \
438   - cfg->queue_cfg.dest_cfg.dest_type); \
439   - MC_CMD_OP(cmd, 0, 42, 1, int, cfg->errors_only); \
440   - MC_CMD_OP(cmd, 0, 46, 1, int, cfg->queue_cfg.order_preservation_en); \
441   - MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id); \
442   - MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->queue_cfg.user_ctx); \
443   - MC_CMD_OP(cmd, 2, 0, 32, uint32_t, cfg->queue_cfg.options); \
444   - MC_CMD_OP(cmd, 2, 32, 32, int, cfg->queue_cfg.dest_cfg.dest_id); \
445   - MC_CMD_OP(cmd, 3, 0, 32, uint32_t, \
446   - cfg->queue_cfg.tail_drop_threshold); \
447   - MC_CMD_OP(cmd, 4, 0, 4, enum dpni_flc_type, \
448   - cfg->queue_cfg.flc_cfg.flc_type); \
449   - MC_CMD_OP(cmd, 4, 4, 4, enum dpni_stash_size, \
450   - cfg->queue_cfg.flc_cfg.frame_data_size); \
451   - MC_CMD_OP(cmd, 4, 8, 4, enum dpni_stash_size, \
452   - cfg->queue_cfg.flc_cfg.flow_context_size); \
453   - MC_CMD_OP(cmd, 4, 32, 32, uint32_t, cfg->queue_cfg.flc_cfg.options); \
454   - MC_CMD_OP(cmd, 5, 0, 64, uint64_t, \
455   - cfg->queue_cfg.flc_cfg.flow_context); \
456   -} while (0)
457   -
458   -#define DPNI_CMD_GET_TX_CONF(cmd, flow_id) \
459   - MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id)
460   -
461   -#define DPNI_RSP_GET_TX_CONF(cmd, attr) \
462   -do { \
463   - MC_RSP_OP(cmd, 0, 32, 8, uint8_t, \
464   - attr->queue_attr.dest_cfg.priority); \
465   - MC_RSP_OP(cmd, 0, 40, 2, enum dpni_dest, \
466   - attr->queue_attr.dest_cfg.dest_type); \
467   - MC_RSP_OP(cmd, 0, 42, 1, int, attr->errors_only); \
468   - MC_RSP_OP(cmd, 0, 46, 1, int, \
469   - attr->queue_attr.order_preservation_en); \
470   - MC_RSP_OP(cmd, 1, 0, 64, uint64_t, attr->queue_attr.user_ctx); \
471   - MC_RSP_OP(cmd, 2, 32, 32, int, attr->queue_attr.dest_cfg.dest_id); \
472   - MC_RSP_OP(cmd, 3, 0, 32, uint32_t, \
473   - attr->queue_attr.tail_drop_threshold); \
474   - MC_RSP_OP(cmd, 3, 32, 32, uint32_t, attr->queue_attr.fqid); \
475   - MC_RSP_OP(cmd, 4, 0, 4, enum dpni_flc_type, \
476   - attr->queue_attr.flc_cfg.flc_type); \
477   - MC_RSP_OP(cmd, 4, 4, 4, enum dpni_stash_size, \
478   - attr->queue_attr.flc_cfg.frame_data_size); \
479   - MC_RSP_OP(cmd, 4, 8, 4, enum dpni_stash_size, \
480   - attr->queue_attr.flc_cfg.flow_context_size); \
481   - MC_RSP_OP(cmd, 4, 32, 32, uint32_t, attr->queue_attr.flc_cfg.options); \
482   - MC_RSP_OP(cmd, 5, 0, 64, uint64_t, \
483   - attr->queue_attr.flc_cfg.flow_context); \
484   -} while (0)
485   -
486 273 enum net_prot {
487 274 NET_PROT_NONE = 0,
488 275 NET_PROT_PAYLOAD,
... ... @@ -645,6 +432,33 @@
645 432 #define DPNI_OPT_FS_MASK_SUPPORT 0x00040000
646 433  
647 434 /**
  435 + * enum dpni_queue_type - Identifies a type of queue targeted by the command
  436 + * @DPNI_QUEUE_RX: Rx queue
  437 + * @DPNI_QUEUE_TX: Tx queue
  438 + * @DPNI_QUEUE_TX_CONFIRM: Tx confirmation queue
  439 + * @DPNI_QUEUE_RX_ERR: Rx error queue
  440 + */
  441 +enum dpni_queue_type {
  442 + DPNI_QUEUE_RX,
  443 + DPNI_QUEUE_TX,
  444 + DPNI_QUEUE_TX_CONFIRM,
  445 + DPNI_QUEUE_RX_ERR,
  446 +};
  447 +
  448 +struct dpni_cfg {
  449 + uint8_t mac_addr[6];
  450 + struct {
  451 + uint32_t options;
  452 + uint16_t fs_entries;
  453 + uint8_t num_queues;
  454 + uint8_t num_tcs;
  455 + uint8_t mac_entries;
  456 + uint8_t vlan_entries;
  457 + uint8_t qos_entries;
  458 + } adv;
  459 +};
  460 +
  461 +/**
648 462 * struct dpni_extended_cfg - Structure representing extended DPNI configuration
649 463 * @tc_cfg: TCs configuration
650 464 * @ipr_cfg: IP reassembly configuration
651 465  
652 466  
653 467  
654 468  
... ... @@ -685,78 +499,21 @@
685 499 };
686 500  
687 501 /**
688   - * dpni_prepare_extended_cfg() - function prepare extended parameters
689   - * @cfg: extended structure
690   - * @ext_cfg_buf: Zeroed 256 bytes of memory before mapping it to DMA
  502 + * dpni_prepare_cfg() - function prepare parameters
  503 + * @cfg: cfg structure
  504 + * @cfg_buf: Zeroed 256 bytes of memory before mapping it to DMA
691 505 *
692 506 * This function has to be called before dpni_create()
693 507 */
694   -int dpni_prepare_extended_cfg(const struct dpni_extended_cfg *cfg,
695   - uint8_t *ext_cfg_buf);
696   -
  508 +int dpni_prepare_cfg(const struct dpni_cfg *cfg,
  509 + uint8_t *cfg_buf);
697 510 /**
698   - * struct dpni_cfg - Structure representing DPNI configuration
699   - * @mac_addr: Primary MAC address
700   - * @adv: Advanced parameters; default is all zeros;
701   - * use this structure to change default settings
702   - */
703   -struct dpni_cfg {
704   - uint8_t mac_addr[6];
705   - /**
706   - * struct adv - Advanced parameters
707   - * @options: Mask of available options; use 'DPNI_OPT_<X>' values
708   - * @start_hdr: Selects the packet starting header for parsing;
709   - * 'NET_PROT_NONE' is treated as default: 'NET_PROT_ETH'
710   - * @max_senders: Maximum number of different senders; used as the number
711   - * of dedicated Tx flows; Non-power-of-2 values are rounded
712   - * up to the next power-of-2 value as hardware demands it;
713   - * '0' will be treated as '1'
714   - * @max_tcs: Maximum number of traffic classes (for both Tx and Rx);
715   - * '0' will e treated as '1'
716   - * @max_unicast_filters: Maximum number of unicast filters;
717   - * '0' is treated as '16'
718   - * @max_multicast_filters: Maximum number of multicast filters;
719   - * '0' is treated as '64'
720   - * @max_qos_entries: if 'max_tcs > 1', declares the maximum entries in
721   - * the QoS table; '0' is treated as '64'
722   - * @max_qos_key_size: Maximum key size for the QoS look-up;
723   - * '0' is treated as '24' which is enough for IPv4
724   - * 5-tuple
725   - * @max_dist_key_size: Maximum key size for the distribution;
726   - * '0' is treated as '24' which is enough for IPv4 5-tuple
727   - * @max_policers: Maximum number of policers;
728   - * should be between '0' and max_tcs
729   - * @max_congestion_ctrl: Maximum number of congestion control groups
730   - * (CGs); covers early drop and congestion notification
731   - * requirements;
732   - * should be between '0' and ('max_tcs' + 'max_senders')
733   - * @ext_cfg_iova: I/O virtual address of 256 bytes DMA-able memory
734   - * filled with the extended configuration by calling
735   - * dpni_prepare_extended_cfg()
736   - */
737   - struct {
738   - uint32_t options;
739   - enum net_prot start_hdr;
740   - uint8_t max_senders;
741   - uint8_t max_tcs;
742   - uint8_t max_unicast_filters;
743   - uint8_t max_multicast_filters;
744   - uint8_t max_vlan_filters;
745   - uint8_t max_qos_entries;
746   - uint8_t max_qos_key_size;
747   - uint8_t max_dist_key_size;
748   - uint8_t max_policers;
749   - uint8_t max_congestion_ctrl;
750   - uint64_t ext_cfg_iova;
751   - } adv;
752   -};
753   -
754   -/**
755 511 * dpni_create() - Create the DPNI object
756 512 * @mc_io: Pointer to MC portal's I/O object
  513 + * @token: Authentication token.
757 514 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
758 515 * @cfg: Configuration structure
759   - * @token: Returned token; use in subsequent API calls
  516 + * @obj_id: Returned obj_id; use in subsequent API calls
760 517 *
761 518 * Create the DPNI object, allocate required resources and
762 519 * perform required initialization.
763 520  
764 521  
765 522  
766 523  
767 524  
... ... @@ -774,21 +531,24 @@
774 531 * Return: '0' on Success; Error code otherwise.
775 532 */
776 533 int dpni_create(struct fsl_mc_io *mc_io,
  534 + uint16_t token,
777 535 uint32_t cmd_flags,
778 536 const struct dpni_cfg *cfg,
779   - uint16_t *token);
  537 + uint32_t *obj_id);
780 538  
781 539 /**
782 540 * dpni_destroy() - Destroy the DPNI object and release all its resources.
783 541 * @mc_io: Pointer to MC portal's I/O object
  542 + * @token: Authentication token.
784 543 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
785   - * @token: Token of DPNI object
  544 + * @obj_id: Returned obj_id; use in subsequent API calls
786 545 *
787 546 * Return: '0' on Success; error code otherwise.
788 547 */
789 548 int dpni_destroy(struct fsl_mc_io *mc_io,
  549 + uint16_t token,
790 550 uint32_t cmd_flags,
791   - uint16_t token);
  551 + uint32_t obj_id);
792 552  
793 553 /**
794 554 * struct dpni_pools_cfg - Structure representing buffer pools configuration
795 555  
796 556  
797 557  
798 558  
799 559  
800 560  
801 561  
802 562  
... ... @@ -867,49 +627,32 @@
867 627  
868 628 /**
869 629 * struct dpni_attr - Structure representing DPNI attributes
870   - * @id: DPNI object ID
871   - * @version: DPNI version
872   - * @start_hdr: Indicates the packet starting header for parsing
873 630 * @options: Mask of available options; reflects the value as was given in
874 631 * object's creation
875   - * @max_senders: Maximum number of different senders; used as the number
876   - * of dedicated Tx flows;
877   - * @max_tcs: Maximum number of traffic classes (for both Tx and Rx)
  632 + * @max_num_queues: Number of queues available (for both Tx and Rx)
  633 + * @max_num_tcs: Maximum number of traffic classes (for both Tx and Rx)
  634 + * @max_mac_entries: Maximum number of traffic classes (for both Tx and Rx)
878 635 * @max_unicast_filters: Maximum number of unicast filters
879 636 * @max_multicast_filters: Maximum number of multicast filters
880   - * @max_vlan_filters: Maximum number of VLAN filters
  637 + * @max_vlan_entries: Maximum number of VLAN filters
881 638 * @max_qos_entries: if 'max_tcs > 1', declares the maximum entries in QoS table
  639 + * @max_fs_entries: declares the maximum entries in flow steering table
882 640 * @max_qos_key_size: Maximum key size for the QoS look-up
883   - * @max_dist_key_size: Maximum key size for the distribution look-up
884   - * @max_policers: Maximum number of policers;
885   - * @max_congestion_ctrl: Maximum number of congestion control groups (CGs);
886   - * @ext_cfg_iova: I/O virtual address of 256 bytes DMA-able memory;
887   - * call dpni_extract_extended_cfg() to extract the extended configuration
  641 + * @max_fs_key_size: Maximum key size for the flow steering
  642 + * @wriop_version: Indicates revision of WRIOP hardware block
888 643 */
889 644 struct dpni_attr {
890   - int id;
891   - /**
892   - * struct version - DPNI version
893   - * @major: DPNI major version
894   - * @minor: DPNI minor version
895   - */
896   - struct {
897   - uint16_t major;
898   - uint16_t minor;
899   - } version;
900   - enum net_prot start_hdr;
  645 + uint32_t id;
901 646 uint32_t options;
902   - uint8_t max_senders;
903   - uint8_t max_tcs;
904   - uint8_t max_unicast_filters;
905   - uint8_t max_multicast_filters;
906   - uint8_t max_vlan_filters;
  647 + uint8_t max_num_queues;
  648 + uint8_t max_num_tcs;
  649 + uint8_t max_mac_entries;
  650 + uint8_t max_vlan_entries;
907 651 uint8_t max_qos_entries;
  652 + uint16_t max_fs_entries;
908 653 uint8_t max_qos_key_size;
909   - uint8_t max_dist_key_size;
910   - uint8_t max_policers;
911   - uint8_t max_congestion_ctrl;
912   - uint64_t ext_cfg_iova;
  654 + uint8_t max_fs_key_size;
  655 + uint16_t wriop_version;
913 656 };
914 657  
915 658 /**
916 659  
... ... @@ -927,14 +670,14 @@
927 670 struct dpni_attr *attr);
928 671  
929 672 /**
930   - * dpni_extract_extended_cfg() - extract the extended parameters
931   - * @cfg: extended structure
932   - * @ext_cfg_buf: 256 bytes of DMA-able memory
  673 + * dpni_extract_cfg() - extract the parameters
  674 + * @cfg: cfg structure
  675 + * @cfg_buf: 256 bytes of DMA-able memory
933 676 *
934 677 * This function has to be called after dpni_get_attributes()
935 678 */
936   -int dpni_extract_extended_cfg(struct dpni_extended_cfg *cfg,
937   - const uint8_t *ext_cfg_buf);
  679 +int dpni_extract_cfg(struct dpni_cfg *cfg,
  680 + const uint8_t *cfg_buf);
938 681  
939 682 /**
940 683 * DPNI errors
... ... @@ -1037,7 +780,7 @@
1037 780 * @data_tail_room: Data tail room
1038 781 */
1039 782 struct dpni_buffer_layout {
1040   - uint32_t options;
  783 + uint16_t options;
1041 784 int pass_timestamp;
1042 785 int pass_parser_result;
1043 786 int pass_frame_status;
1044 787  
1045 788  
1046 789  
1047 790  
1048 791  
1049 792  
... ... @@ -1048,98 +791,40 @@
1048 791 };
1049 792  
1050 793 /**
1051   - * dpni_get_rx_buffer_layout() - Retrieve Rx buffer layout attributes.
  794 + * dpni_get_buffer_layout() - Retrieve buffer layout attributes.
1052 795 * @mc_io: Pointer to MC portal's I/O object
1053 796 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1054 797 * @token: Token of DPNI object
1055 798 * @layout: Returns buffer layout attributes
  799 + * @type: DPNI queue type
1056 800 *
1057 801 * Return: '0' on Success; Error code otherwise.
1058 802 */
1059   -int dpni_get_rx_buffer_layout(struct fsl_mc_io *mc_io,
1060   - uint32_t cmd_flags,
1061   - uint16_t token,
1062   - struct dpni_buffer_layout *layout);
  803 +int dpni_get_buffer_layout(struct fsl_mc_io *mc_io,
  804 + uint32_t cmd_flags,
  805 + uint16_t token,
  806 + const struct dpni_buffer_layout *layout,
  807 + enum dpni_queue_type type);
1063 808  
1064 809 /**
1065   - * dpni_set_rx_buffer_layout() - Set Rx buffer layout configuration.
  810 + * dpni_set_buffer_layout() - Set buffer layout configuration.
1066 811 * @mc_io: Pointer to MC portal's I/O object
1067 812 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1068 813 * @token: Token of DPNI object
1069 814 * @layout: Buffer layout configuration
  815 + * @type: DPNI queue type
1070 816 *
1071 817 * Return: '0' on Success; Error code otherwise.
1072 818 *
1073 819 * @warning Allowed only when DPNI is disabled
1074 820 */
1075   -int dpni_set_rx_buffer_layout(struct fsl_mc_io *mc_io,
1076   - uint32_t cmd_flags,
1077   - uint16_t token,
1078   - const struct dpni_buffer_layout *layout);
  821 +int dpni_set_buffer_layout(struct fsl_mc_io *mc_io,
  822 + uint32_t cmd_flags,
  823 + uint16_t token,
  824 + const struct dpni_buffer_layout *layout,
  825 + enum dpni_queue_type type);
1079 826  
1080 827 /**
1081   - * dpni_get_tx_buffer_layout() - Retrieve Tx buffer layout attributes.
1082   - * @mc_io: Pointer to MC portal's I/O object
1083   - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1084   - * @token: Token of DPNI object
1085   - * @layout: Returns buffer layout attributes
1086   - *
1087   - * Return: '0' on Success; Error code otherwise.
1088   - */
1089   -int dpni_get_tx_buffer_layout(struct fsl_mc_io *mc_io,
1090   - uint32_t cmd_flags,
1091   - uint16_t token,
1092   - struct dpni_buffer_layout *layout);
1093   -
1094   -/**
1095   - * dpni_set_tx_buffer_layout() - Set Tx buffer layout configuration.
1096   - * @mc_io: Pointer to MC portal's I/O object
1097   - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1098   - * @token: Token of DPNI object
1099   - * @layout: Buffer layout configuration
1100   - *
1101   - * Return: '0' on Success; Error code otherwise.
1102   - *
1103   - * @warning Allowed only when DPNI is disabled
1104   - */
1105   -int dpni_set_tx_buffer_layout(struct fsl_mc_io *mc_io,
1106   - uint32_t cmd_flags,
1107   - uint16_t token,
1108   - const struct dpni_buffer_layout *layout);
1109   -
1110   -/**
1111   - * dpni_get_tx_conf_buffer_layout() - Retrieve Tx confirmation buffer layout
1112   - * attributes.
1113   - * @mc_io: Pointer to MC portal's I/O object
1114   - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1115   - * @token: Token of DPNI object
1116   - * @layout: Returns buffer layout attributes
1117   - *
1118   - * Return: '0' on Success; Error code otherwise.
1119   - */
1120   -int dpni_get_tx_conf_buffer_layout(struct fsl_mc_io *mc_io,
1121   - uint32_t cmd_flags,
1122   - uint16_t token,
1123   - struct dpni_buffer_layout *layout);
1124   -
1125   -/**
1126   - * dpni_set_tx_conf_buffer_layout() - Set Tx confirmation buffer layout
1127   - * configuration.
1128   - * @mc_io: Pointer to MC portal's I/O object
1129   - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1130   - * @token: Token of DPNI object
1131   - * @layout: Buffer layout configuration
1132   - *
1133   - * Return: '0' on Success; Error code otherwise.
1134   - *
1135   - * @warning Allowed only when DPNI is disabled
1136   - */
1137   -int dpni_set_tx_conf_buffer_layout(struct fsl_mc_io *mc_io,
1138   - uint32_t cmd_flags,
1139   - uint16_t token,
1140   - const struct dpni_buffer_layout *layout);
1141   -
1142   -/**
1143 828 * dpni_get_qdid() - Get the Queuing Destination ID (QDID) that should be used
1144 829 * for enqueue operations
1145 830 * @mc_io: Pointer to MC portal's I/O object
... ... @@ -1169,68 +854,6 @@
1169 854 uint16_t token,
1170 855 uint16_t *data_offset);
1171 856  
1172   -/**
1173   - * enum dpni_counter - DPNI counter types
1174   - * @DPNI_CNT_ING_FRAME: Counts ingress frames
1175   - * @DPNI_CNT_ING_BYTE: Counts ingress bytes
1176   - * @DPNI_CNT_ING_FRAME_DROP: Counts ingress frames dropped due to explicit
1177   - * 'drop' setting
1178   - * @DPNI_CNT_ING_FRAME_DISCARD: Counts ingress frames discarded due to errors
1179   - * @DPNI_CNT_ING_MCAST_FRAME: Counts ingress multicast frames
1180   - * @DPNI_CNT_ING_MCAST_BYTE: Counts ingress multicast bytes
1181   - * @DPNI_CNT_ING_BCAST_FRAME: Counts ingress broadcast frames
1182   - * @DPNI_CNT_ING_BCAST_BYTES: Counts ingress broadcast bytes
1183   - * @DPNI_CNT_EGR_FRAME: Counts egress frames
1184   - * @DPNI_CNT_EGR_BYTE: Counts egress bytes
1185   - * @DPNI_CNT_EGR_FRAME_DISCARD: Counts egress frames discarded due to errors
1186   - */
1187   -enum dpni_counter {
1188   - DPNI_CNT_ING_FRAME = 0x0,
1189   - DPNI_CNT_ING_BYTE = 0x1,
1190   - DPNI_CNT_ING_FRAME_DROP = 0x2,
1191   - DPNI_CNT_ING_FRAME_DISCARD = 0x3,
1192   - DPNI_CNT_ING_MCAST_FRAME = 0x4,
1193   - DPNI_CNT_ING_MCAST_BYTE = 0x5,
1194   - DPNI_CNT_ING_BCAST_FRAME = 0x6,
1195   - DPNI_CNT_ING_BCAST_BYTES = 0x7,
1196   - DPNI_CNT_EGR_FRAME = 0x8,
1197   - DPNI_CNT_EGR_BYTE = 0x9,
1198   - DPNI_CNT_EGR_FRAME_DISCARD = 0xa
1199   -};
1200   -
1201   -/**
1202   - * dpni_get_counter() - Read a specific DPNI counter
1203   - * @mc_io: Pointer to MC portal's I/O object
1204   - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1205   - * @token: Token of DPNI object
1206   - * @counter: The requested counter
1207   - * @value: Returned counter's current value
1208   - *
1209   - * Return: '0' on Success; Error code otherwise.
1210   - */
1211   -int dpni_get_counter(struct fsl_mc_io *mc_io,
1212   - uint32_t cmd_flags,
1213   - uint16_t token,
1214   - enum dpni_counter counter,
1215   - uint64_t *value);
1216   -
1217   -/**
1218   - * dpni_set_counter() - Set (or clear) a specific DPNI counter
1219   - * @mc_io: Pointer to MC portal's I/O object
1220   - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1221   - * @token: Token of DPNI object
1222   - * @counter: The requested counter
1223   - * @value: New counter value; typically pass '0' for resetting
1224   - * the counter.
1225   - *
1226   - * Return: '0' on Success; Error code otherwise.
1227   - */
1228   -int dpni_set_counter(struct fsl_mc_io *mc_io,
1229   - uint32_t cmd_flags,
1230   - uint16_t token,
1231   - enum dpni_counter counter,
1232   - uint64_t value);
1233   -
1234 857 /* Enable auto-negotiation */
1235 858 #define DPNI_LINK_OPT_AUTONEG 0x0000000000000001ULL
1236 859 /* Enable half-duplex mode */
1237 860  
1238 861  
1239 862  
1240 863  
1241 864  
1242 865  
1243 866  
1244 867  
1245 868  
1246 869  
1247 870  
1248 871  
1249 872  
1250 873  
1251 874  
1252 875  
1253 876  
1254 877  
1255 878  
1256 879  
1257 880  
1258 881  
... ... @@ -1506,184 +1129,200 @@
1506 1129 #define DPNI_TX_FLOW_OPT_L4_CHKSUM_GEN 0x00000020
1507 1130  
1508 1131 /**
1509   - * struct dpni_tx_flow_cfg - Structure representing Tx flow configuration
1510   - * @options: Flags representing the suggested modifications to the Tx flow;
1511   - * Use any combination 'DPNI_TX_FLOW_OPT_<X>' flags
1512   - * @use_common_tx_conf_queue: Set to '1' to use the common (default) Tx
1513   - * confirmation and error queue; Set to '0' to use the private
1514   - * Tx confirmation and error queue; valid only if
1515   - * 'DPNI_OPT_PRIVATE_TX_CONF_ERROR_DISABLED' wasn't set at DPNI creation
1516   - * and 'DPNI_TX_FLOW_OPT_TX_CONF_ERROR' is contained in 'options'
1517   - * @l3_chksum_gen: Set to '1' to enable L3 checksum generation; '0' to disable;
1518   - * valid only if 'DPNI_TX_FLOW_OPT_L3_CHKSUM_GEN' is contained in 'options'
1519   - * @l4_chksum_gen: Set to '1' to enable L4 checksum generation; '0' to disable;
1520   - * valid only if 'DPNI_TX_FLOW_OPT_L4_CHKSUM_GEN' is contained in 'options'
1521   - */
1522   -struct dpni_tx_flow_cfg {
1523   - uint32_t options;
1524   - int use_common_tx_conf_queue;
1525   - int l3_chksum_gen;
1526   - int l4_chksum_gen;
1527   -};
1528   -
1529   -/**
1530   - * dpni_set_tx_flow() - Set Tx flow configuration
  1132 + * dpni_get_api_version - Retrieve DPNI Major and Minor version info.
  1133 + *
1531 1134 * @mc_io: Pointer to MC portal's I/O object
1532 1135 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1533   - * @token: Token of DPNI object
1534   - * @flow_id: Provides (or returns) the sender's flow ID;
1535   - * for each new sender set (*flow_id) to 'DPNI_NEW_FLOW_ID' to generate
1536   - * a new flow_id; this ID should be used as the QDBIN argument
1537   - * in enqueue operations
1538   - * @cfg: Tx flow configuration
  1136 + * @major_ver: DPNI major version
  1137 + * @minor_ver: DPNI minor version
1539 1138 *
1540   - * Return: '0' on Success; Error code otherwise.
  1139 + * Return: '0' on Success; Error code otherwise.
1541 1140 */
1542   -int dpni_set_tx_flow(struct fsl_mc_io *mc_io,
1543   - uint32_t cmd_flags,
1544   - uint16_t token,
1545   - uint16_t *flow_id,
1546   - const struct dpni_tx_flow_cfg *cfg);
  1141 +int dpni_get_api_version(struct fsl_mc_io *mc_io,
  1142 + u32 cmd_flags,
  1143 + u16 *major_ver,
  1144 + u16 *minor_ver);
1547 1145  
1548 1146 /**
1549   - * struct dpni_tx_flow_attr - Structure representing Tx flow attributes
1550   - * @use_common_tx_conf_queue: '1' if using common (default) Tx confirmation and
1551   - * error queue; '0' if using private Tx confirmation and error queue
1552   - * @l3_chksum_gen: '1' if L3 checksum generation is enabled; '0' if disabled
1553   - * @l4_chksum_gen: '1' if L4 checksum generation is enabled; '0' if disabled
  1147 + * enum dpni_confirmation_mode - Defines DPNI options supported for Tx
  1148 + * confirmation
  1149 + * @DPNI_CONF_AFFINE: For each Tx queue set associated with a sender there is
  1150 + * an affine Tx Confirmation queue
  1151 + * @DPNI_CONF_SINGLE: All Tx queues are associated with a single Tx
  1152 + * confirmation queue
  1153 + * @DPNI_CONF_DISABLE: Tx frames are not confirmed. This must be associated
  1154 + * with proper FD set-up to have buffers release to a Buffer Pool, otherwise
  1155 + * buffers will be leaked.
1554 1156 */
1555   -struct dpni_tx_flow_attr {
1556   - int use_common_tx_conf_queue;
1557   - int l3_chksum_gen;
1558   - int l4_chksum_gen;
  1157 +enum dpni_confirmation_mode {
  1158 + DPNI_CONF_AFFINE,
  1159 + DPNI_CONF_SINGLE,
  1160 + DPNI_CONF_DISABLE,
1559 1161 };
1560 1162  
1561   -/**
1562   - * dpni_get_tx_flow() - Get Tx flow attributes
1563   - * @mc_io: Pointer to MC portal's I/O object
1564   - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1565   - * @token: Token of DPNI object
1566   - * @flow_id: The sender's flow ID, as returned by the
1567   - * dpni_set_tx_flow() function
1568   - * @attr: Returned Tx flow attributes
1569   - *
1570   - * Return: '0' on Success; Error code otherwise.
1571   - */
1572   -int dpni_get_tx_flow(struct fsl_mc_io *mc_io,
1573   - uint32_t cmd_flags,
1574   - uint16_t token,
1575   - uint16_t flow_id,
1576   - struct dpni_tx_flow_attr *attr);
  1163 +struct dpni_tx_confirmation_mode {
  1164 + uint32_t pad;
  1165 + uint8_t confirmation_mode;
  1166 +};
1577 1167  
1578 1168 /**
1579   - * struct dpni_tx_conf_cfg - Structure representing Tx conf configuration
1580   - * @errors_only: Set to '1' to report back only error frames;
1581   - * Set to '0' to confirm transmission/error for all transmitted frames;
1582   - * @queue_cfg: Queue configuration
  1169 + * struct dpni_queue - Queue structure
  1170 + * @fqid: FQID used for enqueueing to and/or configuration of this specific FQ
  1171 + * @qdbin: Queueing bin, used to enqueue using QDID, DQBIN, QPRI. Only relevant
  1172 + * for Tx queues.
  1173 + * @flc: FLC value for traffic dequeued from this queue.
  1174 + * @user_context: User data, presented to the user along with any frames
  1175 + * from this queue. Not relevant for Tx queues.
1583 1176 */
1584   -struct dpni_tx_conf_cfg {
1585   - int errors_only;
1586   - struct dpni_queue_cfg queue_cfg;
  1177 +struct dpni_queue {
  1178 + /**
  1179 + * struct destination - Destination structure
  1180 + * @id: ID of the destination, only relevant if DEST_TYPE is > 0.
  1181 + * Identifies either a DPIO or a DPCON object. Not relevant for Tx
  1182 + * queues.
  1183 + * @type: May be one of the following:
  1184 + * 0 - No destination, queue can be manually queried, but won't
  1185 + * push traffic or notifications to a DPIO;
  1186 + * 1 - The destination is DPIO. When traffic becomes available in
  1187 + * the queue a FQDAN (FQ data available notification) will be
  1188 + * generated to selected DPIO;
  1189 + * 2 - The destination is a DPCON. The queue is associated with a
  1190 + * DPCON object for purpose of scheduling between multiple
  1191 + * queues. The DPCON may be independently configured to
  1192 + * generate notifications. Not relevant for Tx queues.
  1193 + * @hold_active: Hold active
  1194 + */
  1195 + struct {
  1196 + uint32_t id;
  1197 + enum dpni_dest type;
  1198 + char hold_active;
  1199 + char stash_ctrl;
  1200 + } destination;
  1201 + uint8_t options;
  1202 + uint32_t fqid;
  1203 + uint16_t qdbin;
  1204 + uint64_t flc;
  1205 + uint64_t user_context;
1587 1206 };
1588 1207  
1589 1208 /**
1590   - * dpni_set_tx_conf() - Set Tx confirmation and error queue configuration
1591   - * @mc_io: Pointer to MC portal's I/O object
1592   - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1593   - * @token: Token of DPNI object
1594   - * @flow_id: The sender's flow ID, as returned by the
1595   - * dpni_set_tx_flow() function;
1596   - * use 'DPNI_COMMON_TX_CONF' for common tx-conf
1597   - * @cfg: Queue configuration
  1209 + * dpni_set_queue() - Set queue parameters
  1210 + * @mc_io: Pointer to MC portal's I/O object
  1211 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  1212 + * @token: Token of DPNI object
  1213 + * @type: Type of queue
  1214 + * @tc: Traffic class, in range 0 to NUM_TCS - 1
  1215 + * @index: Selects the specific queue out of the set allocated for the same
  1216 + * TC. Value must be in range 0 to NUM_QUEUES - 1
  1217 + * @queue: Queue structure
1598 1218 *
1599   - * If either 'DPNI_OPT_TX_CONF_DISABLED' or
1600   - * 'DPNI_OPT_PRIVATE_TX_CONF_ERROR_DISABLED' were selected at DPNI creation,
1601   - * this function can ONLY be used with 'flow_id == DPNI_COMMON_TX_CONF';
1602   - * i.e. only serve the common tx-conf-err queue;
1603   - * if 'DPNI_OPT_TX_CONF_DISABLED' was selected, only error frames are reported
1604   - * back - successfully transmitted frames are not confirmed. Otherwise, all
1605   - * transmitted frames are sent for confirmation.
1606   - *
1607   - * Return: '0' on Success; Error code otherwise.
  1219 + * Return: '0' on Success; Error code otherwise.
1608 1220 */
1609   -int dpni_set_tx_conf(struct fsl_mc_io *mc_io,
1610   - uint32_t cmd_flags,
1611   - uint16_t token,
1612   - uint16_t flow_id,
1613   - const struct dpni_tx_conf_cfg *cfg);
  1221 +int dpni_set_queue(struct fsl_mc_io *mc_io,
  1222 + uint32_t cmd_flags,
  1223 + uint16_t token,
  1224 + enum dpni_queue_type type,
  1225 + uint8_t tc,
  1226 + uint8_t index,
  1227 + const struct dpni_queue *queue);
1614 1228  
1615 1229 /**
1616   - * struct dpni_tx_conf_attr - Structure representing Tx conf attributes
1617   - * @errors_only: '1' if only error frames are reported back; '0' if all
1618   - * transmitted frames are confirmed
1619   - * @queue_attr: Queue attributes
  1230 + * dpni_get_queue() - Get queue parameters
  1231 + * @mc_io: Pointer to MC portal's I/O object
  1232 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  1233 + * @token: Token of DPNI object
  1234 + * @type: Type of queue
  1235 + * @tc: Traffic class, in range 0 to NUM_TCS - 1
  1236 + * @index: Selects the specific queue out of the set allocated for the same
  1237 + * TC. Value must be in range 0 to NUM_QUEUES - 1
  1238 + * @queue: Queue structure
  1239 + *
  1240 + * Return: '0' on Success; Error code otherwise.
1620 1241 */
1621   -struct dpni_tx_conf_attr {
1622   - int errors_only;
1623   - struct dpni_queue_attr queue_attr;
1624   -};
  1242 +int dpni_get_queue(struct fsl_mc_io *mc_io,
  1243 + uint32_t cmd_flags,
  1244 + uint16_t token,
  1245 + enum dpni_queue_type type,
  1246 + uint8_t tc,
  1247 + uint8_t index,
  1248 + struct dpni_queue *queue);
1625 1249  
1626 1250 /**
1627   - * dpni_get_tx_conf() - Get Tx confirmation and error queue attributes
1628   - * @mc_io: Pointer to MC portal's I/O object
1629   - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1630   - * @token: Token of DPNI object
1631   - * @flow_id: The sender's flow ID, as returned by the
1632   - * dpni_set_tx_flow() function;
1633   - * use 'DPNI_COMMON_TX_CONF' for common tx-conf
1634   - * @attr: Returned tx-conf attributes
  1251 + * dpni_set_tx_confirmation_mode() - Set TX conf mode
  1252 + * @mc_io: Pointer to MC portal's I/O object
  1253 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  1254 + * @token: Token of DPNI object
  1255 + * @mode: DPNI confirmation mode type
1635 1256 *
1636   - * If either 'DPNI_OPT_TX_CONF_DISABLED' or
1637   - * 'DPNI_OPT_PRIVATE_TX_CONF_ERROR_DISABLED' were selected at DPNI creation,
1638   - * this function can ONLY be used with 'flow_id == DPNI_COMMON_TX_CONF';
1639   - * i.e. only serve the common tx-conf-err queue;
1640   - *
1641   - * Return: '0' on Success; Error code otherwise.
  1257 + * Return: '0' on Success; Error code otherwise.
1642 1258 */
1643   -int dpni_get_tx_conf(struct fsl_mc_io *mc_io,
1644   - uint32_t cmd_flags,
1645   - uint16_t token,
1646   - uint16_t flow_id,
1647   - struct dpni_tx_conf_attr *attr);
  1259 +int dpni_set_tx_confirmation_mode(struct fsl_mc_io *mc_io,
  1260 + uint32_t cmd_flags,
  1261 + uint16_t token,
  1262 + enum dpni_confirmation_mode mode);
  1263 +struct dpni_statistics {
  1264 + /**
  1265 + * Page_0 statistics structure
  1266 + * @ingress_all_frames: Ingress frame count
  1267 + * @ingress_all_bytes: Ingress byte count
  1268 + * @ingress_multicast_frames: Ingress multicast frame count
  1269 + * @ingress_multicast_bytes: Ingress multicast byte count
  1270 + * @ingress_broadcast_frames: Ingress broadcast frame count
  1271 + * @ingress_broadcast_bytes: Ingress broadcast byte count
  1272 + *
  1273 + * Page_1 statistics structure
  1274 + * @egress_all_frames: Egress frame count
  1275 + * @egress_all_bytes: Egress byte count
  1276 + * @egress_multicast_frames: Egress multicast frame count
  1277 + * @egress_multicast_bytes: Egress multicast byte count
  1278 + * @egress_broadcast_frames: Egress broadcast frame count
  1279 + * @egress_broadcast_bytes: Egress broadcast byte count
  1280 + *
  1281 + * Page_2 statistics structure
  1282 + * @ingress_filtered_frames: Ingress filtered frame count
  1283 + * @ingress_discarded_frames: Ingress discarded frame count
  1284 + * @ingress_nobuffer_discards: Ingress discarded frame count due to
  1285 + * lack of buffers.
  1286 + * @egress_discarded_frames: Egress discarded frame count
  1287 + * @egress_confirmed_frames: Egress confirmed frame count
  1288 + */
  1289 +
  1290 + uint64_t counter0;
  1291 + uint64_t counter1;
  1292 + uint64_t counter2;
  1293 + uint64_t counter3;
  1294 + uint64_t counter4;
  1295 + uint64_t counter5;
  1296 + uint64_t counter6;
  1297 +};
  1298 +
1648 1299 /**
1649   - * dpni_set_rx_flow() - Set Rx flow configuration
  1300 + * dpni_get_statistics() - Get DPNI statistics
1650 1301 * @mc_io: Pointer to MC portal's I/O object
1651 1302 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1652 1303 * @token: Token of DPNI object
1653   - * @tc_id: Traffic class selection (0-7);
1654   - * use 'DPNI_ALL_TCS' to set all TCs and all flows
1655   - * @flow_id: Rx flow id within the traffic class; use
1656   - * 'DPNI_ALL_TC_FLOWS' to set all flows within
1657   - * this tc_id; ignored if tc_id is set to
1658   - * 'DPNI_ALL_TCS';
1659   - * @cfg: Rx flow configuration
  1304 + * @page: Selects the statistics page to retrieve, see DPNI_GET_STATISTICS
  1305 + * output. Pages are numbered 0 to 2.
  1306 + * @stat: Structure containing the statistics
1660 1307 *
1661 1308 * Return: '0' on Success; Error code otherwise.
1662 1309 */
1663   -int dpni_set_rx_flow(struct fsl_mc_io *mc_io,
1664   - uint32_t cmd_flags,
1665   - uint16_t token,
1666   - uint8_t tc_id,
1667   - uint16_t flow_id,
1668   - const struct dpni_queue_cfg *cfg);
  1310 +int dpni_get_statistics(struct fsl_mc_io *mc_io,
  1311 + uint32_t cmd_flags,
  1312 + uint16_t token,
  1313 + uint8_t page,
  1314 + struct dpni_statistics *stat);
1669 1315  
1670 1316 /**
1671   - * dpni_get_rx_flow() - Get Rx flow attributes
  1317 + * dpni_reset_statistics() - Clears DPNI statistics
1672 1318 * @mc_io: Pointer to MC portal's I/O object
1673 1319 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1674 1320 * @token: Token of DPNI object
1675   - * @tc_id: Traffic class selection (0-7)
1676   - * @flow_id: Rx flow id within the traffic class
1677   - * @attr: Returned Rx flow attributes
1678 1321 *
1679 1322 * Return: '0' on Success; Error code otherwise.
1680 1323 */
1681   -int dpni_get_rx_flow(struct fsl_mc_io *mc_io,
1682   - uint32_t cmd_flags,
1683   - uint16_t token,
1684   - uint8_t tc_id,
1685   - uint16_t flow_id,
1686   - struct dpni_queue_attr *attr);
1687   -
  1324 +int dpni_reset_statistics(struct fsl_mc_io *mc_io,
  1325 + uint32_t cmd_flags,
  1326 + uint16_t token);
1688 1327 #endif /* _FSL_DPNI_H */
include/fsl-mc/fsl_dprc.h
1 1 /*
2 2 * Freescale Layerscape MC I/O wrapper
3 3 *
4   - * Copyright (C) 2013-2015 Freescale Semiconductor, Inc.
5   - * Author: German Rivera <German.Rivera@freescale.com>
  4 + * Copyright (C) 2013-2016 Freescale Semiconductor, Inc.
  5 + * Copyright 2017 NXP
6 6 *
7 7 * SPDX-License-Identifier: GPL-2.0+
8 8 */
9 9  
10 10  
11 11  
12 12  
... ... @@ -10,29 +10,30 @@
10 10 #define _FSL_DPRC_H
11 11  
12 12 /* DPRC Version */
13   -#define DPRC_VER_MAJOR 5
  13 +#define DPRC_VER_MAJOR 6
14 14 #define DPRC_VER_MINOR 1
15 15  
16 16 /* Command IDs */
17   -#define DPRC_CMDID_CLOSE 0x800
18   -#define DPRC_CMDID_OPEN 0x805
19   -#define DPRC_CMDID_CREATE 0x905
  17 +#define DPRC_CMDID_CLOSE 0x8001
  18 +#define DPRC_CMDID_OPEN 0x8051
  19 +#define DPRC_CMDID_CREATE 0x9051
20 20  
21   -#define DPRC_CMDID_GET_ATTR 0x004
22   -#define DPRC_CMDID_RESET_CONT 0x005
  21 +#define DPRC_CMDID_GET_ATTR 0x0041
  22 +#define DPRC_CMDID_RESET_CONT 0x0051
  23 +#define DPRC_CMDID_GET_API_VERSION 0xa051
23 24  
24   -#define DPRC_CMDID_CREATE_CONT 0x151
25   -#define DPRC_CMDID_DESTROY_CONT 0x152
26   -#define DPRC_CMDID_GET_CONT_ID 0x830
27   -#define DPRC_CMDID_GET_OBJ_COUNT 0x159
28   -#define DPRC_CMDID_GET_OBJ 0x15A
29   -#define DPRC_CMDID_GET_RES_COUNT 0x15B
30   -#define DPRC_CMDID_GET_RES_IDS 0x15C
31   -#define DPRC_CMDID_GET_OBJ_REG 0x15E
  25 +#define DPRC_CMDID_CREATE_CONT 0x1511
  26 +#define DPRC_CMDID_DESTROY_CONT 0x1521
  27 +#define DPRC_CMDID_GET_CONT_ID 0x8301
  28 +#define DPRC_CMDID_GET_OBJ_COUNT 0x1591
  29 +#define DPRC_CMDID_GET_OBJ 0x15A1
  30 +#define DPRC_CMDID_GET_RES_COUNT 0x15B1
  31 +#define DPRC_CMDID_GET_RES_IDS 0x15C1
  32 +#define DPRC_CMDID_GET_OBJ_REG 0x15E1
32 33  
33   -#define DPRC_CMDID_CONNECT 0x167
34   -#define DPRC_CMDID_DISCONNECT 0x168
35   -#define DPRC_CMDID_GET_CONNECTION 0x16C
  34 +#define DPRC_CMDID_CONNECT 0x1671
  35 +#define DPRC_CMDID_DISCONNECT 0x1681
  36 +#define DPRC_CMDID_GET_CONNECTION 0x16C1
36 37  
37 38 /* cmd, param, offset, width, type, arg_name */
38 39 #define DPRC_RSP_GET_CONTAINER_ID(cmd, container_id) \
... ... @@ -88,8 +89,6 @@
88 89 MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->icid); \
89 90 MC_RSP_OP(cmd, 1, 0, 32, uint32_t, attr->options);\
90 91 MC_RSP_OP(cmd, 1, 32, 32, int, attr->portal_id); \
91   - MC_RSP_OP(cmd, 2, 0, 16, uint16_t, attr->version.major);\
92   - MC_RSP_OP(cmd, 2, 16, 16, uint16_t, attr->version.minor);\
93 92 } while (0)
94 93  
95 94 /* cmd, param, offset, width, type, arg_name */
96 95  
... ... @@ -345,9 +344,9 @@
345 344 #define DPRC_CMD_CONNECT(cmd, endpoint1, endpoint2, cfg) \
346 345 do { \
347 346 MC_CMD_OP(cmd, 0, 0, 32, int, endpoint1->id); \
348   - MC_CMD_OP(cmd, 0, 32, 16, uint16_t, endpoint1->if_id); \
  347 + MC_CMD_OP(cmd, 0, 32, 32, int, endpoint1->if_id); \
349 348 MC_CMD_OP(cmd, 1, 0, 32, int, endpoint2->id); \
350   - MC_CMD_OP(cmd, 1, 32, 16, uint16_t, endpoint2->if_id); \
  349 + MC_CMD_OP(cmd, 1, 32, 32, int, endpoint2->if_id); \
351 350 MC_CMD_OP(cmd, 2, 0, 8, char, endpoint1->type[0]); \
352 351 MC_CMD_OP(cmd, 2, 8, 8, char, endpoint1->type[1]); \
353 352 MC_CMD_OP(cmd, 2, 16, 8, char, endpoint1->type[2]); \
... ... @@ -410,8 +409,8 @@
410 409 /* cmd, param, offset, width, type, arg_name */
411 410 #define DPRC_CMD_GET_CONNECTION(cmd, endpoint1) \
412 411 do { \
413   - MC_CMD_OP(cmd, 0, 0, 32, int, endpoint1->id); \
414   - MC_CMD_OP(cmd, 0, 32, 16, uint16_t, endpoint1->if_id); \
  412 + MC_CMD_OP(cmd, 0, 0, 32, int, endpoint1->id); \
  413 + MC_CMD_OP(cmd, 0, 32, 32, int, endpoint1->if_id); \
415 414 MC_CMD_OP(cmd, 1, 0, 8, char, endpoint1->type[0]); \
416 415 MC_CMD_OP(cmd, 1, 8, 8, char, endpoint1->type[1]); \
417 416 MC_CMD_OP(cmd, 1, 16, 8, char, endpoint1->type[2]); \
... ... @@ -657,15 +656,6 @@
657 656 uint16_t icid;
658 657 int portal_id;
659 658 uint64_t options;
660   - /**
661   - * struct version - DPRC version
662   - * @major: DPRC major version
663   - * @minor: DPRC minor version
664   - */
665   - struct {
666   - uint16_t major;
667   - uint16_t minor;
668   - } version;
669 659 };
670 660  
671 661 /**
... ... @@ -949,6 +939,21 @@
949 939 const struct dprc_endpoint *endpoint1,
950 940 struct dprc_endpoint *endpoint2,
951 941 int *state);
  942 +
  943 +/**
  944 + * dprc_get_api_version - Retrieve DPRC Major and Minor version info.
  945 + *
  946 + * @mc_io: Pointer to MC portal's I/O object
  947 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
  948 + * @major_ver: DPRC major version
  949 + * @minor_ver: DPRC minor version
  950 + *
  951 + * Return: '0' on Success; Error code otherwise.
  952 + */
  953 +int dprc_get_api_version(struct fsl_mc_io *mc_io,
  954 + u32 cmd_flags,
  955 + u16 *major_ver,
  956 + u16 *minor_ver);
952 957  
953 958 #endif /* _FSL_DPRC_H */
include/fsl-mc/fsl_mc_cmd.h
1   -/* Copyright 2013-2015 Freescale Semiconductor Inc.
  1 +/* Copyright 2013-2016 Freescale Semiconductor Inc.
  2 + * Copyright 2017 NXP
2 3 *
3 4 * SPDX-License-Identifier: GPL-2.0+
4 5 */
... ... @@ -24,6 +25,15 @@
24 25 uint64_t params[MC_CMD_NUM_OF_PARAMS];
25 26 };
26 27  
  28 +struct mc_rsp_create {
  29 + __le32 object_id;
  30 +};
  31 +
  32 +struct mc_rsp_api_ver {
  33 + __le16 major_ver;
  34 + __le16 minor_ver;
  35 +};
  36 +
27 37 enum mc_cmd_status {
28 38 MC_CMD_STATUS_OK = 0x0, /*!< Completed successfully */
29 39 MC_CMD_STATUS_READY = 0x1, /*!< Ready to be processed */
30 40  
31 41  
... ... @@ -51,15 +61,15 @@
51 61 #define MC_CMD_FLAG_INTR_DIS 0x01000000
52 62  
53 63  
54   -#define MC_CMD_HDR_CMDID_O 52 /* Command ID field offset */
55   -#define MC_CMD_HDR_CMDID_S 12 /* Command ID field size */
  64 +#define MC_CMD_HDR_CMDID_O 48 /* Command ID field offset */
  65 +#define MC_CMD_HDR_CMDID_S 16 /* Command ID field size */
56 66 #define MC_CMD_HDR_STATUS_O 16 /* Status field offset */
57   -#define MC_CMD_HDR_TOKEN_O 38 /* Token field offset */
58   -#define MC_CMD_HDR_TOKEN_S 10 /* Token field size */
  67 +#define MC_CMD_HDR_TOKEN_O 32 /* Token field offset */
  68 +#define MC_CMD_HDR_TOKEN_S 16 /* Token field size */
59 69 #define MC_CMD_HDR_STATUS_S 8 /* Status field size*/
60 70 #define MC_CMD_HDR_FLAGS_O 0 /* Flags field offset */
61 71 #define MC_CMD_HDR_FLAGS_S 32 /* Flags field size*/
62   -#define MC_CMD_HDR_FLAGS_MASK 0xFF00FF00 /* Command flags mask */
  72 +#define MC_CMD_HDR_FLAGS_MASK 0x0000FFFF /* Command flags mask */
63 73  
64 74 #define MC_CMD_HDR_READ_STATUS(_hdr) \
65 75 ((enum mc_cmd_status)mc_dec((_hdr), \
66 76  
... ... @@ -80,11 +90,19 @@
80 90 #define MC_RSP_OP(_cmd, _param, _offset, _width, _type, _arg) \
81 91 (_arg = (_type)mc_dec(_cmd.params[_param], (_offset), (_width)))
82 92  
  93 +/* cmd, param, offset, width, type, arg_name */
  94 +#define MC_CMD_READ_OBJ_ID(cmd, obj_id) \
  95 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, obj_id)
  96 +
  97 +/* cmd, param, offset, width, type, arg_name */
  98 +#define CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, object_id) \
  99 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, object_id)
  100 +
83 101 static inline uint64_t mc_encode_cmd_header(uint16_t cmd_id,
84 102 uint32_t cmd_flags,
85 103 uint16_t token)
86 104 {
87   - uint64_t hdr;
  105 + uint64_t hdr = 0;
88 106  
89 107 hdr = mc_enc(MC_CMD_HDR_CMDID_O, MC_CMD_HDR_CMDID_S, cmd_id);
90 108 hdr |= mc_enc(MC_CMD_HDR_FLAGS_O, MC_CMD_HDR_FLAGS_S,
... ... @@ -142,6 +160,24 @@
142 160 resp->params[i] = readq(&portal->params[i]);
143 161  
144 162 return status;
  163 +}
  164 +
  165 +/**
  166 + * mc_read_version - read version of the given cmd
  167 + *
  168 + * @cmd: pointer to a filled command
  169 + * @major_version: major version value for the given cmd
  170 + * @minor_version: minor version value for the given cmd
  171 + */
  172 +static inline void mc_cmd_read_api_version(struct mc_command *cmd,
  173 + u16 *major_ver,
  174 + u16 *minor_ver)
  175 +{
  176 + struct mc_rsp_api_ver *rsp_params;
  177 +
  178 + rsp_params = (struct mc_rsp_api_ver *)cmd->params;
  179 + *major_ver = le16_to_cpu(rsp_params->major_ver);
  180 + *minor_ver = le16_to_cpu(rsp_params->minor_ver);
145 181 }
146 182  
147 183 #endif /* __FSL_MC_CMD_H */
include/fsl-mc/fsl_mc_private.h
1 1 /*
2   - * Copyright (C) 2014 Freescale Semiconductor
  2 + * Copyright (C) 2014-2016 Freescale Semiconductor
  3 + * Copyright 2017 NXP
3 4 *
4 5 * SPDX-License-Identifier: GPL-2.0+
5 6 */
... ... @@ -29,6 +30,7 @@
29 30 * @struct dpbp_attr: DPBP attribute
30 31 */
31 32 struct fsl_dpbp_obj {
  33 + uint32_t dpbp_id;
32 34 uint16_t dpbp_handle;
33 35 struct dpbp_attr dpbp_attr;
34 36 };
... ... @@ -41,7 +43,7 @@
41 43 * @struct qbman_swp *sw_portal: SW portal object
42 44 */
43 45 struct fsl_dpio_obj {
44   - int dpio_id;
  46 + uint32_t dpio_id;
45 47 uint16_t dpio_handle;
46 48 struct qbman_swp *sw_portal; /** SW portal object */
47 49 };
... ... @@ -56,7 +58,7 @@
56 58 * @struct dpni_buffer_layout: DPNI buffer layout
57 59 */
58 60 struct fsl_dpni_obj {
59   - int dpni_id;
  61 + uint32_t dpni_id;
60 62 uint16_t dpni_handle;
61 63 struct dpni_attr dpni_attrs;
62 64 struct dpni_buffer_layout buf_layout;