1 /* Copyright 2013-2016 Freescale Semiconductor Inc.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the name of the above-listed copyright holders nor the
12 * names of any contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
16 * ALTERNATIVELY, this software may be distributed under the terms of the
17 * GNU General Public License ("GPL") as published by the Free Software
18 * Foundation, either version 2 of that License or (at your option) any
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
33 #include <linux/kernel.h>
34 #include <linux/errno.h>
35 #include "../../fsl-mc/include/mc.h"
40 * dpni_prepare_key_cfg() - function prepare extract parameters
41 * @cfg: defining a full Key Generation profile (rule)
42 * @key_cfg_buf: Zeroed 256 bytes of memory before mapping it to DMA
44 * This function has to be called before the following functions:
45 * - dpni_set_rx_tc_dist()
46 * - dpni_set_qos_table()
48 int dpni_prepare_key_cfg(const struct dpkg_profile_cfg *cfg, u8 *key_cfg_buf)
51 struct dpni_ext_set_rx_tc_dist *dpni_ext;
52 struct dpni_dist_extract *extr;
54 if (cfg->num_extracts > DPKG_MAX_NUM_OF_EXTRACTS)
57 dpni_ext = (struct dpni_ext_set_rx_tc_dist *)key_cfg_buf;
58 dpni_ext->num_extracts = cfg->num_extracts;
60 for (i = 0; i < cfg->num_extracts; i++) {
61 extr = &dpni_ext->extracts[i];
63 switch (cfg->extracts[i].type) {
64 case DPKG_EXTRACT_FROM_HDR:
65 extr->prot = cfg->extracts[i].extract.from_hdr.prot;
66 dpni_set_field(extr->efh_type, EFH_TYPE,
67 cfg->extracts[i].extract.from_hdr.type);
68 extr->size = cfg->extracts[i].extract.from_hdr.size;
69 extr->offset = cfg->extracts[i].extract.from_hdr.offset;
70 extr->field = cpu_to_le32(
71 cfg->extracts[i].extract.from_hdr.field);
73 cfg->extracts[i].extract.from_hdr.hdr_index;
75 case DPKG_EXTRACT_FROM_DATA:
76 extr->size = cfg->extracts[i].extract.from_data.size;
78 cfg->extracts[i].extract.from_data.offset;
80 case DPKG_EXTRACT_FROM_PARSE:
81 extr->size = cfg->extracts[i].extract.from_parse.size;
83 cfg->extracts[i].extract.from_parse.offset;
89 extr->num_of_byte_masks = cfg->extracts[i].num_of_byte_masks;
90 dpni_set_field(extr->extract_type, EXTRACT_TYPE,
91 cfg->extracts[i].type);
93 for (j = 0; j < DPKG_NUM_OF_MASKS; j++) {
94 extr->masks[j].mask = cfg->extracts[i].masks[j].mask;
95 extr->masks[j].offset =
96 cfg->extracts[i].masks[j].offset;
104 * dpni_open() - Open a control session for the specified object
105 * @mc_io: Pointer to MC portal's I/O object
106 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
107 * @dpni_id: DPNI unique ID
108 * @token: Returned token; use in subsequent API calls
110 * This function can be used to open a control session for an
111 * already created object; an object may have been declared in
112 * the DPL or by calling the dpni_create() function.
113 * This function returns a unique authentication token,
114 * associated with the specific object ID and the specific MC
115 * portal; this token must be used in all subsequent commands for
116 * this specific object.
118 * Return: '0' on Success; Error code otherwise.
120 int dpni_open(struct fsl_mc_io *mc_io,
125 struct mc_command cmd = { 0 };
126 struct dpni_cmd_open *cmd_params;
130 /* prepare command */
131 cmd.header = mc_encode_cmd_header(DPNI_CMDID_OPEN,
134 cmd_params = (struct dpni_cmd_open *)cmd.params;
135 cmd_params->dpni_id = cpu_to_le32(dpni_id);
137 /* send command to mc*/
138 err = mc_send_command(mc_io, &cmd);
142 /* retrieve response parameters */
143 *token = mc_cmd_hdr_read_token(&cmd);
149 * dpni_close() - Close the control session of the object
150 * @mc_io: Pointer to MC portal's I/O object
151 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
152 * @token: Token of DPNI object
154 * After this function is called, no further operations are
155 * allowed on the object without opening a new control session.
157 * Return: '0' on Success; Error code otherwise.
159 int dpni_close(struct fsl_mc_io *mc_io,
163 struct mc_command cmd = { 0 };
165 /* prepare command */
166 cmd.header = mc_encode_cmd_header(DPNI_CMDID_CLOSE,
170 /* send command to mc*/
171 return mc_send_command(mc_io, &cmd);
175 * dpni_set_pools() - Set buffer pools configuration
176 * @mc_io: Pointer to MC portal's I/O object
177 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
178 * @token: Token of DPNI object
179 * @cfg: Buffer pools configuration
181 * mandatory for DPNI operation
182 * warning:Allowed only when DPNI is disabled
184 * Return: '0' on Success; Error code otherwise.
186 int dpni_set_pools(struct fsl_mc_io *mc_io,
189 const struct dpni_pools_cfg *cfg)
191 struct mc_command cmd = { 0 };
192 struct dpni_cmd_set_pools *cmd_params;
195 /* prepare command */
196 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_POOLS,
199 cmd_params = (struct dpni_cmd_set_pools *)cmd.params;
200 cmd_params->num_dpbp = cfg->num_dpbp;
201 for (i = 0; i < DPNI_MAX_DPBP; i++) {
202 cmd_params->dpbp_id[i] = cpu_to_le32(cfg->pools[i].dpbp_id);
203 cmd_params->buffer_size[i] =
204 cpu_to_le16(cfg->pools[i].buffer_size);
205 cmd_params->backup_pool_mask |=
206 DPNI_BACKUP_POOL(cfg->pools[i].backup_pool, i);
209 /* send command to mc*/
210 return mc_send_command(mc_io, &cmd);
214 * dpni_enable() - Enable the DPNI, allow sending and receiving frames.
215 * @mc_io: Pointer to MC portal's I/O object
216 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
217 * @token: Token of DPNI object
219 * Return: '0' on Success; Error code otherwise.
221 int dpni_enable(struct fsl_mc_io *mc_io,
225 struct mc_command cmd = { 0 };
227 /* prepare command */
228 cmd.header = mc_encode_cmd_header(DPNI_CMDID_ENABLE,
232 /* send command to mc*/
233 return mc_send_command(mc_io, &cmd);
237 * dpni_disable() - Disable the DPNI, stop sending and receiving frames.
238 * @mc_io: Pointer to MC portal's I/O object
239 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
240 * @token: Token of DPNI object
242 * Return: '0' on Success; Error code otherwise.
244 int dpni_disable(struct fsl_mc_io *mc_io,
248 struct mc_command cmd = { 0 };
250 /* prepare command */
251 cmd.header = mc_encode_cmd_header(DPNI_CMDID_DISABLE,
255 /* send command to mc*/
256 return mc_send_command(mc_io, &cmd);
260 * dpni_is_enabled() - Check if the DPNI is enabled.
261 * @mc_io: Pointer to MC portal's I/O object
262 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
263 * @token: Token of DPNI object
264 * @en: Returns '1' if object is enabled; '0' otherwise
266 * Return: '0' on Success; Error code otherwise.
268 int dpni_is_enabled(struct fsl_mc_io *mc_io,
273 struct mc_command cmd = { 0 };
274 struct dpni_rsp_is_enabled *rsp_params;
277 /* prepare command */
278 cmd.header = mc_encode_cmd_header(DPNI_CMDID_IS_ENABLED,
282 /* send command to mc*/
283 err = mc_send_command(mc_io, &cmd);
287 /* retrieve response parameters */
288 rsp_params = (struct dpni_rsp_is_enabled *)cmd.params;
289 *en = dpni_get_field(rsp_params->enabled, ENABLE);
295 * dpni_reset() - Reset the DPNI, returns the object to initial state.
296 * @mc_io: Pointer to MC portal's I/O object
297 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
298 * @token: Token of DPNI object
300 * Return: '0' on Success; Error code otherwise.
302 int dpni_reset(struct fsl_mc_io *mc_io,
306 struct mc_command cmd = { 0 };
308 /* prepare command */
309 cmd.header = mc_encode_cmd_header(DPNI_CMDID_RESET,
313 /* send command to mc*/
314 return mc_send_command(mc_io, &cmd);
318 * dpni_set_irq_enable() - Set overall interrupt state.
319 * @mc_io: Pointer to MC portal's I/O object
320 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
321 * @token: Token of DPNI object
322 * @irq_index: The interrupt index to configure
323 * @en: Interrupt state: - enable = 1, disable = 0
325 * Allows GPP software to control when interrupts are generated.
326 * Each interrupt can have up to 32 causes. The enable/disable control's the
327 * overall interrupt state. if the interrupt is disabled no causes will cause
330 * Return: '0' on Success; Error code otherwise.
332 int dpni_set_irq_enable(struct fsl_mc_io *mc_io,
338 struct mc_command cmd = { 0 };
339 struct dpni_cmd_set_irq_enable *cmd_params;
341 /* prepare command */
342 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_IRQ_ENABLE,
345 cmd_params = (struct dpni_cmd_set_irq_enable *)cmd.params;
346 dpni_set_field(cmd_params->enable, ENABLE, en);
347 cmd_params->irq_index = irq_index;
349 /* send command to mc*/
350 return mc_send_command(mc_io, &cmd);
354 * dpni_get_irq_enable() - Get overall interrupt state
355 * @mc_io: Pointer to MC portal's I/O object
356 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
357 * @token: Token of DPNI object
358 * @irq_index: The interrupt index to configure
359 * @en: Returned interrupt state - enable = 1, disable = 0
361 * Return: '0' on Success; Error code otherwise.
363 int dpni_get_irq_enable(struct fsl_mc_io *mc_io,
369 struct mc_command cmd = { 0 };
370 struct dpni_cmd_get_irq_enable *cmd_params;
371 struct dpni_rsp_get_irq_enable *rsp_params;
375 /* prepare command */
376 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_IRQ_ENABLE,
379 cmd_params = (struct dpni_cmd_get_irq_enable *)cmd.params;
380 cmd_params->irq_index = irq_index;
382 /* send command to mc*/
383 err = mc_send_command(mc_io, &cmd);
387 /* retrieve response parameters */
388 rsp_params = (struct dpni_rsp_get_irq_enable *)cmd.params;
389 *en = dpni_get_field(rsp_params->enabled, ENABLE);
395 * dpni_set_irq_mask() - Set interrupt mask.
396 * @mc_io: Pointer to MC portal's I/O object
397 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
398 * @token: Token of DPNI object
399 * @irq_index: The interrupt index to configure
400 * @mask: event mask to trigger interrupt;
403 * 1 = consider event for asserting IRQ
405 * Every interrupt can have up to 32 causes and the interrupt model supports
406 * masking/unmasking each cause independently
408 * Return: '0' on Success; Error code otherwise.
410 int dpni_set_irq_mask(struct fsl_mc_io *mc_io,
416 struct mc_command cmd = { 0 };
417 struct dpni_cmd_set_irq_mask *cmd_params;
419 /* prepare command */
420 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_IRQ_MASK,
423 cmd_params = (struct dpni_cmd_set_irq_mask *)cmd.params;
424 cmd_params->mask = cpu_to_le32(mask);
425 cmd_params->irq_index = irq_index;
427 /* send command to mc*/
428 return mc_send_command(mc_io, &cmd);
432 * dpni_get_irq_mask() - Get interrupt mask.
433 * @mc_io: Pointer to MC portal's I/O object
434 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
435 * @token: Token of DPNI object
436 * @irq_index: The interrupt index to configure
437 * @mask: Returned event mask to trigger interrupt
439 * Every interrupt can have up to 32 causes and the interrupt model supports
440 * masking/unmasking each cause independently
442 * Return: '0' on Success; Error code otherwise.
444 int dpni_get_irq_mask(struct fsl_mc_io *mc_io,
450 struct mc_command cmd = { 0 };
451 struct dpni_cmd_get_irq_mask *cmd_params;
452 struct dpni_rsp_get_irq_mask *rsp_params;
455 /* prepare command */
456 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_IRQ_MASK,
459 cmd_params = (struct dpni_cmd_get_irq_mask *)cmd.params;
460 cmd_params->irq_index = irq_index;
462 /* send command to mc*/
463 err = mc_send_command(mc_io, &cmd);
467 /* retrieve response parameters */
468 rsp_params = (struct dpni_rsp_get_irq_mask *)cmd.params;
469 *mask = le32_to_cpu(rsp_params->mask);
475 * dpni_get_irq_status() - Get the current status of any pending interrupts.
476 * @mc_io: Pointer to MC portal's I/O object
477 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
478 * @token: Token of DPNI object
479 * @irq_index: The interrupt index to configure
480 * @status: Returned interrupts status - one bit per cause:
481 * 0 = no interrupt pending
482 * 1 = interrupt pending
484 * Return: '0' on Success; Error code otherwise.
486 int dpni_get_irq_status(struct fsl_mc_io *mc_io,
492 struct mc_command cmd = { 0 };
493 struct dpni_cmd_get_irq_status *cmd_params;
494 struct dpni_rsp_get_irq_status *rsp_params;
497 /* prepare command */
498 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_IRQ_STATUS,
501 cmd_params = (struct dpni_cmd_get_irq_status *)cmd.params;
502 cmd_params->status = cpu_to_le32(*status);
503 cmd_params->irq_index = irq_index;
505 /* send command to mc*/
506 err = mc_send_command(mc_io, &cmd);
510 /* retrieve response parameters */
511 rsp_params = (struct dpni_rsp_get_irq_status *)cmd.params;
512 *status = le32_to_cpu(rsp_params->status);
518 * dpni_clear_irq_status() - Clear a pending interrupt's status
519 * @mc_io: Pointer to MC portal's I/O object
520 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
521 * @token: Token of DPNI object
522 * @irq_index: The interrupt index to configure
523 * @status: bits to clear (W1C) - one bit per cause:
525 * 1 = clear status bit
527 * Return: '0' on Success; Error code otherwise.
529 int dpni_clear_irq_status(struct fsl_mc_io *mc_io,
535 struct mc_command cmd = { 0 };
536 struct dpni_cmd_clear_irq_status *cmd_params;
538 /* prepare command */
539 cmd.header = mc_encode_cmd_header(DPNI_CMDID_CLEAR_IRQ_STATUS,
542 cmd_params = (struct dpni_cmd_clear_irq_status *)cmd.params;
543 cmd_params->irq_index = irq_index;
544 cmd_params->status = cpu_to_le32(status);
546 /* send command to mc*/
547 return mc_send_command(mc_io, &cmd);
551 * dpni_get_attributes() - Retrieve DPNI attributes.
552 * @mc_io: Pointer to MC portal's I/O object
553 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
554 * @token: Token of DPNI object
555 * @attr: Object's attributes
557 * Return: '0' on Success; Error code otherwise.
559 int dpni_get_attributes(struct fsl_mc_io *mc_io,
562 struct dpni_attr *attr)
564 struct mc_command cmd = { 0 };
565 struct dpni_rsp_get_attr *rsp_params;
569 /* prepare command */
570 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_ATTR,
574 /* send command to mc*/
575 err = mc_send_command(mc_io, &cmd);
579 /* retrieve response parameters */
580 rsp_params = (struct dpni_rsp_get_attr *)cmd.params;
581 attr->options = le32_to_cpu(rsp_params->options);
582 attr->num_queues = rsp_params->num_queues;
583 attr->num_tcs = rsp_params->num_tcs;
584 attr->mac_filter_entries = rsp_params->mac_filter_entries;
585 attr->vlan_filter_entries = rsp_params->vlan_filter_entries;
586 attr->qos_entries = rsp_params->qos_entries;
587 attr->fs_entries = le16_to_cpu(rsp_params->fs_entries);
588 attr->qos_key_size = rsp_params->qos_key_size;
589 attr->fs_key_size = rsp_params->fs_key_size;
590 attr->wriop_version = le16_to_cpu(rsp_params->wriop_version);
596 * dpni_set_errors_behavior() - Set errors behavior
597 * @mc_io: Pointer to MC portal's I/O object
598 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
599 * @token: Token of DPNI object
600 * @cfg: Errors configuration
602 * this function may be called numerous times with different
605 * Return: '0' on Success; Error code otherwise.
607 int dpni_set_errors_behavior(struct fsl_mc_io *mc_io,
610 struct dpni_error_cfg *cfg)
612 struct mc_command cmd = { 0 };
613 struct dpni_cmd_set_errors_behavior *cmd_params;
615 /* prepare command */
616 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_ERRORS_BEHAVIOR,
619 cmd_params = (struct dpni_cmd_set_errors_behavior *)cmd.params;
620 cmd_params->errors = cpu_to_le32(cfg->errors);
621 dpni_set_field(cmd_params->flags, ERROR_ACTION, cfg->error_action);
622 dpni_set_field(cmd_params->flags, FRAME_ANN, cfg->set_frame_annotation);
624 /* send command to mc*/
625 return mc_send_command(mc_io, &cmd);
629 * dpni_get_buffer_layout() - Retrieve buffer layout attributes.
630 * @mc_io: Pointer to MC portal's I/O object
631 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
632 * @token: Token of DPNI object
633 * @qtype: Type of queue to retrieve configuration for
634 * @layout: Returns buffer layout attributes
636 * Return: '0' on Success; Error code otherwise.
638 int dpni_get_buffer_layout(struct fsl_mc_io *mc_io,
641 enum dpni_queue_type qtype,
642 struct dpni_buffer_layout *layout)
644 struct mc_command cmd = { 0 };
645 struct dpni_cmd_get_buffer_layout *cmd_params;
646 struct dpni_rsp_get_buffer_layout *rsp_params;
649 /* prepare command */
650 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_BUFFER_LAYOUT,
653 cmd_params = (struct dpni_cmd_get_buffer_layout *)cmd.params;
654 cmd_params->qtype = qtype;
656 /* send command to mc*/
657 err = mc_send_command(mc_io, &cmd);
661 /* retrieve response parameters */
662 rsp_params = (struct dpni_rsp_get_buffer_layout *)cmd.params;
663 layout->pass_timestamp = dpni_get_field(rsp_params->flags, PASS_TS);
664 layout->pass_parser_result = dpni_get_field(rsp_params->flags, PASS_PR);
665 layout->pass_frame_status = dpni_get_field(rsp_params->flags, PASS_FS);
666 layout->private_data_size = le16_to_cpu(rsp_params->private_data_size);
667 layout->data_align = le16_to_cpu(rsp_params->data_align);
668 layout->data_head_room = le16_to_cpu(rsp_params->head_room);
669 layout->data_tail_room = le16_to_cpu(rsp_params->tail_room);
675 * dpni_set_buffer_layout() - Set buffer layout configuration.
676 * @mc_io: Pointer to MC portal's I/O object
677 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
678 * @token: Token of DPNI object
679 * @qtype: Type of queue this configuration applies to
680 * @layout: Buffer layout configuration
682 * Return: '0' on Success; Error code otherwise.
684 * @warning Allowed only when DPNI is disabled
686 int dpni_set_buffer_layout(struct fsl_mc_io *mc_io,
689 enum dpni_queue_type qtype,
690 const struct dpni_buffer_layout *layout)
692 struct mc_command cmd = { 0 };
693 struct dpni_cmd_set_buffer_layout *cmd_params;
695 /* prepare command */
696 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_BUFFER_LAYOUT,
699 cmd_params = (struct dpni_cmd_set_buffer_layout *)cmd.params;
700 cmd_params->qtype = qtype;
701 cmd_params->options = cpu_to_le16(layout->options);
702 dpni_set_field(cmd_params->flags, PASS_TS, layout->pass_timestamp);
703 dpni_set_field(cmd_params->flags, PASS_PR, layout->pass_parser_result);
704 dpni_set_field(cmd_params->flags, PASS_FS, layout->pass_frame_status);
705 cmd_params->private_data_size = cpu_to_le16(layout->private_data_size);
706 cmd_params->data_align = cpu_to_le16(layout->data_align);
707 cmd_params->head_room = cpu_to_le16(layout->data_head_room);
708 cmd_params->tail_room = cpu_to_le16(layout->data_tail_room);
710 /* send command to mc*/
711 return mc_send_command(mc_io, &cmd);
715 * dpni_set_offload() - Set DPNI offload configuration.
716 * @mc_io: Pointer to MC portal's I/O object
717 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
718 * @token: Token of DPNI object
719 * @type: Type of DPNI offload
720 * @config: Offload configuration.
721 * For checksum offloads, non-zero value enables the offload
723 * Return: '0' on Success; Error code otherwise.
725 * @warning Allowed only when DPNI is disabled
728 int dpni_set_offload(struct fsl_mc_io *mc_io,
731 enum dpni_offload type,
734 struct mc_command cmd = { 0 };
735 struct dpni_cmd_set_offload *cmd_params;
737 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_OFFLOAD,
740 cmd_params = (struct dpni_cmd_set_offload *)cmd.params;
741 cmd_params->dpni_offload = type;
742 cmd_params->config = cpu_to_le32(config);
744 return mc_send_command(mc_io, &cmd);
747 int dpni_get_offload(struct fsl_mc_io *mc_io,
750 enum dpni_offload type,
753 struct mc_command cmd = { 0 };
754 struct dpni_cmd_get_offload *cmd_params;
755 struct dpni_rsp_get_offload *rsp_params;
758 /* prepare command */
759 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_OFFLOAD,
762 cmd_params = (struct dpni_cmd_get_offload *)cmd.params;
763 cmd_params->dpni_offload = type;
765 /* send command to mc*/
766 err = mc_send_command(mc_io, &cmd);
770 /* retrieve response parameters */
771 rsp_params = (struct dpni_rsp_get_offload *)cmd.params;
772 *config = le32_to_cpu(rsp_params->config);
778 * dpni_get_qdid() - Get the Queuing Destination ID (QDID) that should be used
779 * for enqueue operations
780 * @mc_io: Pointer to MC portal's I/O object
781 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
782 * @token: Token of DPNI object
783 * @qtype: Type of queue to receive QDID for
784 * @qdid: Returned virtual QDID value that should be used as an argument
785 * in all enqueue operations
787 * Return: '0' on Success; Error code otherwise.
789 int dpni_get_qdid(struct fsl_mc_io *mc_io,
792 enum dpni_queue_type qtype,
795 struct mc_command cmd = { 0 };
796 struct dpni_cmd_get_qdid *cmd_params;
797 struct dpni_rsp_get_qdid *rsp_params;
800 /* prepare command */
801 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_QDID,
804 cmd_params = (struct dpni_cmd_get_qdid *)cmd.params;
805 cmd_params->qtype = qtype;
807 /* send command to mc*/
808 err = mc_send_command(mc_io, &cmd);
812 /* retrieve response parameters */
813 rsp_params = (struct dpni_rsp_get_qdid *)cmd.params;
814 *qdid = le16_to_cpu(rsp_params->qdid);
820 * dpni_get_tx_data_offset() - Get the Tx data offset (from start of buffer)
821 * @mc_io: Pointer to MC portal's I/O object
822 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
823 * @token: Token of DPNI object
824 * @data_offset: Tx data offset (from start of buffer)
826 * Return: '0' on Success; Error code otherwise.
828 int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
833 struct mc_command cmd = { 0 };
834 struct dpni_rsp_get_tx_data_offset *rsp_params;
837 /* prepare command */
838 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TX_DATA_OFFSET,
842 /* send command to mc*/
843 err = mc_send_command(mc_io, &cmd);
847 /* retrieve response parameters */
848 rsp_params = (struct dpni_rsp_get_tx_data_offset *)cmd.params;
849 *data_offset = le16_to_cpu(rsp_params->data_offset);
855 * dpni_set_link_cfg() - set the link configuration.
856 * @mc_io: Pointer to MC portal's I/O object
857 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
858 * @token: Token of DPNI object
859 * @cfg: Link configuration
861 * Return: '0' on Success; Error code otherwise.
863 int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
866 const struct dpni_link_cfg *cfg)
868 struct mc_command cmd = { 0 };
869 struct dpni_cmd_set_link_cfg *cmd_params;
871 /* prepare command */
872 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_LINK_CFG,
875 cmd_params = (struct dpni_cmd_set_link_cfg *)cmd.params;
876 cmd_params->rate = cpu_to_le32(cfg->rate);
877 cmd_params->options = cpu_to_le64(cfg->options);
879 /* send command to mc*/
880 return mc_send_command(mc_io, &cmd);
884 * dpni_get_link_state() - Return the link state (either up or down)
885 * @mc_io: Pointer to MC portal's I/O object
886 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
887 * @token: Token of DPNI object
888 * @state: Returned link state;
890 * Return: '0' on Success; Error code otherwise.
892 int dpni_get_link_state(struct fsl_mc_io *mc_io,
895 struct dpni_link_state *state)
897 struct mc_command cmd = { 0 };
898 struct dpni_rsp_get_link_state *rsp_params;
901 /* prepare command */
902 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_LINK_STATE,
906 /* send command to mc*/
907 err = mc_send_command(mc_io, &cmd);
911 /* retrieve response parameters */
912 rsp_params = (struct dpni_rsp_get_link_state *)cmd.params;
913 state->up = dpni_get_field(rsp_params->flags, LINK_STATE);
914 state->rate = le32_to_cpu(rsp_params->rate);
915 state->options = le64_to_cpu(rsp_params->options);
921 * dpni_set_max_frame_length() - Set the maximum received frame length.
922 * @mc_io: Pointer to MC portal's I/O object
923 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
924 * @token: Token of DPNI object
925 * @max_frame_length: Maximum received frame length (in
926 * bytes); frame is discarded if its
927 * length exceeds this value
929 * Return: '0' on Success; Error code otherwise.
931 int dpni_set_max_frame_length(struct fsl_mc_io *mc_io,
934 u16 max_frame_length)
936 struct mc_command cmd = { 0 };
937 struct dpni_cmd_set_max_frame_length *cmd_params;
939 /* prepare command */
940 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_MAX_FRAME_LENGTH,
943 cmd_params = (struct dpni_cmd_set_max_frame_length *)cmd.params;
944 cmd_params->max_frame_length = cpu_to_le16(max_frame_length);
946 /* send command to mc*/
947 return mc_send_command(mc_io, &cmd);
951 * dpni_get_max_frame_length() - Get the maximum received frame length.
952 * @mc_io: Pointer to MC portal's I/O object
953 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
954 * @token: Token of DPNI object
955 * @max_frame_length: Maximum received frame length (in
956 * bytes); frame is discarded if its
957 * length exceeds this value
959 * Return: '0' on Success; Error code otherwise.
961 int dpni_get_max_frame_length(struct fsl_mc_io *mc_io,
964 u16 *max_frame_length)
966 struct mc_command cmd = { 0 };
967 struct dpni_rsp_get_max_frame_length *rsp_params;
970 /* prepare command */
971 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_MAX_FRAME_LENGTH,
975 /* send command to mc*/
976 err = mc_send_command(mc_io, &cmd);
980 /* retrieve response parameters */
981 rsp_params = (struct dpni_rsp_get_max_frame_length *)cmd.params;
982 *max_frame_length = le16_to_cpu(rsp_params->max_frame_length);
988 * dpni_set_multicast_promisc() - Enable/disable multicast promiscuous mode
989 * @mc_io: Pointer to MC portal's I/O object
990 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
991 * @token: Token of DPNI object
992 * @en: Set to '1' to enable; '0' to disable
994 * Return: '0' on Success; Error code otherwise.
996 int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io,
1001 struct mc_command cmd = { 0 };
1002 struct dpni_cmd_set_multicast_promisc *cmd_params;
1004 /* prepare command */
1005 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_MCAST_PROMISC,
1008 cmd_params = (struct dpni_cmd_set_multicast_promisc *)cmd.params;
1009 dpni_set_field(cmd_params->enable, ENABLE, en);
1011 /* send command to mc*/
1012 return mc_send_command(mc_io, &cmd);
1016 * dpni_get_multicast_promisc() - Get multicast promiscuous mode
1017 * @mc_io: Pointer to MC portal's I/O object
1018 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1019 * @token: Token of DPNI object
1020 * @en: Returns '1' if enabled; '0' otherwise
1022 * Return: '0' on Success; Error code otherwise.
1024 int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io,
1029 struct mc_command cmd = { 0 };
1030 struct dpni_rsp_get_multicast_promisc *rsp_params;
1033 /* prepare command */
1034 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_MCAST_PROMISC,
1038 /* send command to mc*/
1039 err = mc_send_command(mc_io, &cmd);
1043 /* retrieve response parameters */
1044 rsp_params = (struct dpni_rsp_get_multicast_promisc *)cmd.params;
1045 *en = dpni_get_field(rsp_params->enabled, ENABLE);
1051 * dpni_set_unicast_promisc() - Enable/disable unicast promiscuous mode
1052 * @mc_io: Pointer to MC portal's I/O object
1053 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1054 * @token: Token of DPNI object
1055 * @en: Set to '1' to enable; '0' to disable
1057 * Return: '0' on Success; Error code otherwise.
1059 int dpni_set_unicast_promisc(struct fsl_mc_io *mc_io,
1064 struct mc_command cmd = { 0 };
1065 struct dpni_cmd_set_unicast_promisc *cmd_params;
1067 /* prepare command */
1068 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_UNICAST_PROMISC,
1071 cmd_params = (struct dpni_cmd_set_unicast_promisc *)cmd.params;
1072 dpni_set_field(cmd_params->enable, ENABLE, en);
1074 /* send command to mc*/
1075 return mc_send_command(mc_io, &cmd);
1079 * dpni_get_unicast_promisc() - Get unicast promiscuous mode
1080 * @mc_io: Pointer to MC portal's I/O object
1081 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1082 * @token: Token of DPNI object
1083 * @en: Returns '1' if enabled; '0' otherwise
1085 * Return: '0' on Success; Error code otherwise.
1087 int dpni_get_unicast_promisc(struct fsl_mc_io *mc_io,
1092 struct mc_command cmd = { 0 };
1093 struct dpni_rsp_get_unicast_promisc *rsp_params;
1096 /* prepare command */
1097 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_UNICAST_PROMISC,
1101 /* send command to mc*/
1102 err = mc_send_command(mc_io, &cmd);
1106 /* retrieve response parameters */
1107 rsp_params = (struct dpni_rsp_get_unicast_promisc *)cmd.params;
1108 *en = dpni_get_field(rsp_params->enabled, ENABLE);
1114 * dpni_set_primary_mac_addr() - Set the primary MAC address
1115 * @mc_io: Pointer to MC portal's I/O object
1116 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1117 * @token: Token of DPNI object
1118 * @mac_addr: MAC address to set as primary address
1120 * Return: '0' on Success; Error code otherwise.
1122 int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
1125 const u8 mac_addr[6])
1127 struct mc_command cmd = { 0 };
1128 struct dpni_cmd_set_primary_mac_addr *cmd_params;
1131 /* prepare command */
1132 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_PRIM_MAC,
1135 cmd_params = (struct dpni_cmd_set_primary_mac_addr *)cmd.params;
1136 for (i = 0; i < 6; i++)
1137 cmd_params->mac_addr[i] = mac_addr[5 - i];
1139 /* send command to mc*/
1140 return mc_send_command(mc_io, &cmd);
1144 * dpni_get_primary_mac_addr() - Get the primary MAC address
1145 * @mc_io: Pointer to MC portal's I/O object
1146 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1147 * @token: Token of DPNI object
1148 * @mac_addr: Returned MAC address
1150 * Return: '0' on Success; Error code otherwise.
1152 int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
1157 struct mc_command cmd = { 0 };
1158 struct dpni_rsp_get_primary_mac_addr *rsp_params;
1161 /* prepare command */
1162 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_PRIM_MAC,
1166 /* send command to mc*/
1167 err = mc_send_command(mc_io, &cmd);
1171 /* retrieve response parameters */
1172 rsp_params = (struct dpni_rsp_get_primary_mac_addr *)cmd.params;
1173 for (i = 0; i < 6; i++)
1174 mac_addr[5 - i] = rsp_params->mac_addr[i];
1180 * dpni_get_port_mac_addr() - Retrieve MAC address associated to the physical
1181 * port the DPNI is attached to
1182 * @mc_io: Pointer to MC portal's I/O object
1183 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1184 * @token: Token of DPNI object
1185 * @mac_addr: MAC address of the physical port, if any, otherwise 0
1187 * The primary MAC address is not cleared by this operation.
1189 * Return: '0' on Success; Error code otherwise.
1191 int dpni_get_port_mac_addr(struct fsl_mc_io *mc_io,
1196 struct mc_command cmd = { 0 };
1197 struct dpni_rsp_get_port_mac_addr *rsp_params;
1200 /* prepare command */
1201 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_PORT_MAC_ADDR,
1205 /* send command to mc*/
1206 err = mc_send_command(mc_io, &cmd);
1210 /* retrieve response parameters */
1211 rsp_params = (struct dpni_rsp_get_port_mac_addr *)cmd.params;
1212 for (i = 0; i < 6; i++)
1213 mac_addr[5 - i] = rsp_params->mac_addr[i];
1219 * dpni_add_mac_addr() - Add MAC address filter
1220 * @mc_io: Pointer to MC portal's I/O object
1221 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1222 * @token: Token of DPNI object
1223 * @mac_addr: MAC address to add
1225 * Return: '0' on Success; Error code otherwise.
1227 int dpni_add_mac_addr(struct fsl_mc_io *mc_io,
1230 const u8 mac_addr[6])
1232 struct mc_command cmd = { 0 };
1233 struct dpni_cmd_add_mac_addr *cmd_params;
1236 /* prepare command */
1237 cmd.header = mc_encode_cmd_header(DPNI_CMDID_ADD_MAC_ADDR,
1240 cmd_params = (struct dpni_cmd_add_mac_addr *)cmd.params;
1241 for (i = 0; i < 6; i++)
1242 cmd_params->mac_addr[i] = mac_addr[5 - i];
1244 /* send command to mc*/
1245 return mc_send_command(mc_io, &cmd);
1249 * dpni_remove_mac_addr() - Remove MAC address filter
1250 * @mc_io: Pointer to MC portal's I/O object
1251 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1252 * @token: Token of DPNI object
1253 * @mac_addr: MAC address to remove
1255 * Return: '0' on Success; Error code otherwise.
1257 int dpni_remove_mac_addr(struct fsl_mc_io *mc_io,
1260 const u8 mac_addr[6])
1262 struct mc_command cmd = { 0 };
1263 struct dpni_cmd_remove_mac_addr *cmd_params;
1266 /* prepare command */
1267 cmd.header = mc_encode_cmd_header(DPNI_CMDID_REMOVE_MAC_ADDR,
1270 cmd_params = (struct dpni_cmd_remove_mac_addr *)cmd.params;
1271 for (i = 0; i < 6; i++)
1272 cmd_params->mac_addr[i] = mac_addr[5 - i];
1274 /* send command to mc*/
1275 return mc_send_command(mc_io, &cmd);
1279 * dpni_clear_mac_filters() - Clear all unicast and/or multicast MAC filters
1280 * @mc_io: Pointer to MC portal's I/O object
1281 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1282 * @token: Token of DPNI object
1283 * @unicast: Set to '1' to clear unicast addresses
1284 * @multicast: Set to '1' to clear multicast addresses
1286 * The primary MAC address is not cleared by this operation.
1288 * Return: '0' on Success; Error code otherwise.
1290 int dpni_clear_mac_filters(struct fsl_mc_io *mc_io,
1296 struct mc_command cmd = { 0 };
1297 struct dpni_cmd_clear_mac_filters *cmd_params;
1299 /* prepare command */
1300 cmd.header = mc_encode_cmd_header(DPNI_CMDID_CLR_MAC_FILTERS,
1303 cmd_params = (struct dpni_cmd_clear_mac_filters *)cmd.params;
1304 dpni_set_field(cmd_params->flags, UNICAST_FILTERS, unicast);
1305 dpni_set_field(cmd_params->flags, MULTICAST_FILTERS, multicast);
1307 /* send command to mc*/
1308 return mc_send_command(mc_io, &cmd);
1312 * dpni_set_rx_tc_dist() - Set Rx traffic class distribution configuration
1313 * @mc_io: Pointer to MC portal's I/O object
1314 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1315 * @token: Token of DPNI object
1316 * @tc_id: Traffic class selection (0-7)
1317 * @cfg: Traffic class distribution configuration
1319 * warning: if 'dist_mode != DPNI_DIST_MODE_NONE', call dpni_prepare_key_cfg()
1320 * first to prepare the key_cfg_iova parameter
1322 * Return: '0' on Success; error code otherwise.
1324 int dpni_set_rx_tc_dist(struct fsl_mc_io *mc_io,
1328 const struct dpni_rx_tc_dist_cfg *cfg)
1330 struct mc_command cmd = { 0 };
1331 struct dpni_cmd_set_rx_tc_dist *cmd_params;
1333 /* prepare command */
1334 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_RX_TC_DIST,
1337 cmd_params = (struct dpni_cmd_set_rx_tc_dist *)cmd.params;
1338 cmd_params->dist_size = cpu_to_le16(cfg->dist_size);
1339 cmd_params->tc_id = tc_id;
1340 dpni_set_field(cmd_params->flags, DIST_MODE, cfg->dist_mode);
1341 dpni_set_field(cmd_params->flags, MISS_ACTION, cfg->fs_cfg.miss_action);
1342 cmd_params->default_flow_id = cpu_to_le16(cfg->fs_cfg.default_flow_id);
1343 cmd_params->key_cfg_iova = cpu_to_le64(cfg->key_cfg_iova);
1345 /* send command to mc*/
1346 return mc_send_command(mc_io, &cmd);
1350 * dpni_set_queue() - Set queue parameters
1351 * @mc_io: Pointer to MC portal's I/O object
1352 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1353 * @token: Token of DPNI object
1354 * @qtype: Type of queue - all queue types are supported, although
1355 * the command is ignored for Tx
1356 * @tc: Traffic class, in range 0 to NUM_TCS - 1
1357 * @index: Selects the specific queue out of the set allocated for the
1358 * same TC. Value must be in range 0 to NUM_QUEUES - 1
1359 * @options: A combination of DPNI_QUEUE_OPT_ values that control what
1360 * configuration options are set on the queue
1361 * @queue: Queue structure
1363 * Return: '0' on Success; Error code otherwise.
1365 int dpni_set_queue(struct fsl_mc_io *mc_io,
1368 enum dpni_queue_type qtype,
1372 const struct dpni_queue *queue)
1374 struct mc_command cmd = { 0 };
1375 struct dpni_cmd_set_queue *cmd_params;
1377 /* prepare command */
1378 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_QUEUE,
1381 cmd_params = (struct dpni_cmd_set_queue *)cmd.params;
1382 cmd_params->qtype = qtype;
1383 cmd_params->tc = tc;
1384 cmd_params->index = index;
1385 cmd_params->options = options;
1386 cmd_params->dest_id = cpu_to_le32(queue->destination.id);
1387 cmd_params->dest_prio = queue->destination.priority;
1388 dpni_set_field(cmd_params->flags, DEST_TYPE, queue->destination.type);
1389 dpni_set_field(cmd_params->flags, STASH_CTRL, queue->flc.stash_control);
1390 dpni_set_field(cmd_params->flags, HOLD_ACTIVE,
1391 queue->destination.hold_active);
1392 cmd_params->flc = cpu_to_le64(queue->flc.value);
1393 cmd_params->user_context = cpu_to_le64(queue->user_context);
1395 /* send command to mc */
1396 return mc_send_command(mc_io, &cmd);
1400 * dpni_get_queue() - Get queue parameters
1401 * @mc_io: Pointer to MC portal's I/O object
1402 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1403 * @token: Token of DPNI object
1404 * @qtype: Type of queue - all queue types are supported
1405 * @tc: Traffic class, in range 0 to NUM_TCS - 1
1406 * @index: Selects the specific queue out of the set allocated for the
1407 * same TC. Value must be in range 0 to NUM_QUEUES - 1
1408 * @queue: Queue configuration structure
1409 * @qid: Queue identification
1411 * Return: '0' on Success; Error code otherwise.
1413 int dpni_get_queue(struct fsl_mc_io *mc_io,
1416 enum dpni_queue_type qtype,
1419 struct dpni_queue *queue,
1420 struct dpni_queue_id *qid)
1422 struct mc_command cmd = { 0 };
1423 struct dpni_cmd_get_queue *cmd_params;
1424 struct dpni_rsp_get_queue *rsp_params;
1427 /* prepare command */
1428 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_QUEUE,
1431 cmd_params = (struct dpni_cmd_get_queue *)cmd.params;
1432 cmd_params->qtype = qtype;
1433 cmd_params->tc = tc;
1434 cmd_params->index = index;
1436 /* send command to mc */
1437 err = mc_send_command(mc_io, &cmd);
1441 /* retrieve response parameters */
1442 rsp_params = (struct dpni_rsp_get_queue *)cmd.params;
1443 queue->destination.id = le32_to_cpu(rsp_params->dest_id);
1444 queue->destination.priority = rsp_params->dest_prio;
1445 queue->destination.type = dpni_get_field(rsp_params->flags,
1447 queue->flc.stash_control = dpni_get_field(rsp_params->flags,
1449 queue->destination.hold_active = dpni_get_field(rsp_params->flags,
1451 queue->flc.value = le64_to_cpu(rsp_params->flc);
1452 queue->user_context = le64_to_cpu(rsp_params->user_context);
1453 qid->fqid = le32_to_cpu(rsp_params->fqid);
1454 qid->qdbin = le16_to_cpu(rsp_params->qdbin);
1460 * dpni_get_statistics() - Get DPNI statistics
1461 * @mc_io: Pointer to MC portal's I/O object
1462 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1463 * @token: Token of DPNI object
1464 * @page: Selects the statistics page to retrieve, see
1465 * DPNI_GET_STATISTICS output. Pages are numbered 0 to 2.
1466 * @stat: Structure containing the statistics
1468 * Return: '0' on Success; Error code otherwise.
1470 int dpni_get_statistics(struct fsl_mc_io *mc_io,
1474 union dpni_statistics *stat)
1476 struct mc_command cmd = { 0 };
1477 struct dpni_cmd_get_statistics *cmd_params;
1478 struct dpni_rsp_get_statistics *rsp_params;
1481 /* prepare command */
1482 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_STATISTICS,
1485 cmd_params = (struct dpni_cmd_get_statistics *)cmd.params;
1486 cmd_params->page_number = page;
1488 /* send command to mc */
1489 err = mc_send_command(mc_io, &cmd);
1493 /* retrieve response parameters */
1494 rsp_params = (struct dpni_rsp_get_statistics *)cmd.params;
1495 for (i = 0; i < DPNI_STATISTICS_CNT; i++)
1496 stat->raw.counter[i] = le64_to_cpu(rsp_params->counter[i]);
1502 * dpni_set_taildrop() - Set taildrop per queue or TC
1503 * @mc_io: Pointer to MC portal's I/O object
1504 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1505 * @token: Token of DPNI object
1506 * @cg_point: Congestion point
1507 * @q_type: Queue type on which the taildrop is configured.
1508 * Only Rx queues are supported for now
1509 * @tc: Traffic class to apply this taildrop to
1510 * @q_index: Index of the queue if the DPNI supports multiple queues for
1511 * traffic distribution. Ignored if CONGESTION_POINT is not 0.
1512 * @taildrop: Taildrop structure
1514 * Return: '0' on Success; Error code otherwise.
1516 int dpni_set_taildrop(struct fsl_mc_io *mc_io,
1519 enum dpni_congestion_point cg_point,
1520 enum dpni_queue_type qtype,
1523 struct dpni_taildrop *taildrop)
1525 struct mc_command cmd = { 0 };
1526 struct dpni_cmd_set_taildrop *cmd_params;
1528 /* prepare command */
1529 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TAILDROP,
1532 cmd_params = (struct dpni_cmd_set_taildrop *)cmd.params;
1533 cmd_params->congestion_point = cg_point;
1534 cmd_params->qtype = qtype;
1535 cmd_params->tc = tc;
1536 cmd_params->index = index;
1537 dpni_set_field(cmd_params->enable, ENABLE, taildrop->enable);
1538 cmd_params->units = taildrop->units;
1539 cmd_params->threshold = cpu_to_le32(taildrop->threshold);
1541 /* send command to mc */
1542 return mc_send_command(mc_io, &cmd);
1546 * dpni_get_taildrop() - Get taildrop information
1547 * @mc_io: Pointer to MC portal's I/O object
1548 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1549 * @token: Token of DPNI object
1550 * @cg_point: Congestion point
1551 * @q_type: Queue type on which the taildrop is configured.
1552 * Only Rx queues are supported for now
1553 * @tc: Traffic class to apply this taildrop to
1554 * @q_index: Index of the queue if the DPNI supports multiple queues for
1555 * traffic distribution. Ignored if CONGESTION_POINT is not 0.
1556 * @taildrop: Taildrop structure
1558 * Return: '0' on Success; Error code otherwise.
1560 int dpni_get_taildrop(struct fsl_mc_io *mc_io,
1563 enum dpni_congestion_point cg_point,
1564 enum dpni_queue_type qtype,
1567 struct dpni_taildrop *taildrop)
1569 struct mc_command cmd = { 0 };
1570 struct dpni_cmd_get_taildrop *cmd_params;
1571 struct dpni_rsp_get_taildrop *rsp_params;
1574 /* prepare command */
1575 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TAILDROP,
1578 cmd_params = (struct dpni_cmd_get_taildrop *)cmd.params;
1579 cmd_params->congestion_point = cg_point;
1580 cmd_params->qtype = qtype;
1581 cmd_params->tc = tc;
1582 cmd_params->index = index;
1584 /* send command to mc */
1585 err = mc_send_command(mc_io, &cmd);
1589 /* retrieve response parameters */
1590 rsp_params = (struct dpni_rsp_get_taildrop *)cmd.params;
1591 taildrop->enable = dpni_get_field(rsp_params->enable, ENABLE);
1592 taildrop->units = rsp_params->units;
1593 taildrop->threshold = le32_to_cpu(rsp_params->threshold);