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 "../../fsl-mc/include/mc-sys.h"
34 #include "../../fsl-mc/include/mc-cmd.h"
39 * dpni_prepare_key_cfg() - function prepare extract parameters
40 * @cfg: defining a full Key Generation profile (rule)
41 * @key_cfg_buf: Zeroed 256 bytes of memory before mapping it to DMA
43 * This function has to be called before the following functions:
44 * - dpni_set_rx_tc_dist()
45 * - dpni_set_qos_table()
47 int dpni_prepare_key_cfg(const struct dpkg_profile_cfg *cfg, u8 *key_cfg_buf)
50 struct dpni_ext_set_rx_tc_dist *dpni_ext;
51 struct dpni_dist_extract *extr;
53 if (cfg->num_extracts > DPKG_MAX_NUM_OF_EXTRACTS)
56 dpni_ext = (struct dpni_ext_set_rx_tc_dist *)key_cfg_buf;
57 dpni_ext->num_extracts = cfg->num_extracts;
59 for (i = 0; i < cfg->num_extracts; i++) {
60 extr = &dpni_ext->extracts[i];
62 switch (cfg->extracts[i].type) {
63 case DPKG_EXTRACT_FROM_HDR:
64 extr->prot = cfg->extracts[i].extract.from_hdr.prot;
65 dpni_set_field(extr->efh_type, EFH_TYPE,
66 cfg->extracts[i].extract.from_hdr.type);
67 extr->size = cfg->extracts[i].extract.from_hdr.size;
68 extr->offset = cfg->extracts[i].extract.from_hdr.offset;
69 extr->field = cpu_to_le32(
70 cfg->extracts[i].extract.from_hdr.field);
72 cfg->extracts[i].extract.from_hdr.hdr_index;
74 case DPKG_EXTRACT_FROM_DATA:
75 extr->size = cfg->extracts[i].extract.from_data.size;
77 cfg->extracts[i].extract.from_data.offset;
79 case DPKG_EXTRACT_FROM_PARSE:
80 extr->size = cfg->extracts[i].extract.from_parse.size;
82 cfg->extracts[i].extract.from_parse.offset;
88 extr->num_of_byte_masks = cfg->extracts[i].num_of_byte_masks;
89 dpni_set_field(extr->extract_type, EXTRACT_TYPE,
90 cfg->extracts[i].type);
92 for (j = 0; j < DPKG_NUM_OF_MASKS; j++) {
93 extr->masks[j].mask = cfg->extracts[i].masks[j].mask;
94 extr->masks[j].offset =
95 cfg->extracts[i].masks[j].offset;
103 * dpni_open() - Open a control session for the specified object
104 * @mc_io: Pointer to MC portal's I/O object
105 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
106 * @dpni_id: DPNI unique ID
107 * @token: Returned token; use in subsequent API calls
109 * This function can be used to open a control session for an
110 * already created object; an object may have been declared in
111 * the DPL or by calling the dpni_create() function.
112 * This function returns a unique authentication token,
113 * associated with the specific object ID and the specific MC
114 * portal; this token must be used in all subsequent commands for
115 * this specific object.
117 * Return: '0' on Success; Error code otherwise.
119 int dpni_open(struct fsl_mc_io *mc_io,
124 struct mc_command cmd = { 0 };
125 struct dpni_cmd_open *cmd_params;
129 /* prepare command */
130 cmd.header = mc_encode_cmd_header(DPNI_CMDID_OPEN,
133 cmd_params = (struct dpni_cmd_open *)cmd.params;
134 cmd_params->dpni_id = cpu_to_le32(dpni_id);
136 /* send command to mc*/
137 err = mc_send_command(mc_io, &cmd);
141 /* retrieve response parameters */
142 *token = mc_cmd_hdr_read_token(&cmd);
148 * dpni_close() - Close the control session of the object
149 * @mc_io: Pointer to MC portal's I/O object
150 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
151 * @token: Token of DPNI object
153 * After this function is called, no further operations are
154 * allowed on the object without opening a new control session.
156 * Return: '0' on Success; Error code otherwise.
158 int dpni_close(struct fsl_mc_io *mc_io,
162 struct mc_command cmd = { 0 };
164 /* prepare command */
165 cmd.header = mc_encode_cmd_header(DPNI_CMDID_CLOSE,
169 /* send command to mc*/
170 return mc_send_command(mc_io, &cmd);
174 * dpni_set_pools() - Set buffer pools configuration
175 * @mc_io: Pointer to MC portal's I/O object
176 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
177 * @token: Token of DPNI object
178 * @cfg: Buffer pools configuration
180 * mandatory for DPNI operation
181 * warning:Allowed only when DPNI is disabled
183 * Return: '0' on Success; Error code otherwise.
185 int dpni_set_pools(struct fsl_mc_io *mc_io,
188 const struct dpni_pools_cfg *cfg)
190 struct mc_command cmd = { 0 };
191 struct dpni_cmd_set_pools *cmd_params;
194 /* prepare command */
195 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_POOLS,
198 cmd_params = (struct dpni_cmd_set_pools *)cmd.params;
199 cmd_params->num_dpbp = cfg->num_dpbp;
200 for (i = 0; i < DPNI_MAX_DPBP; i++) {
201 cmd_params->dpbp_id[i] = cpu_to_le32(cfg->pools[i].dpbp_id);
202 cmd_params->buffer_size[i] =
203 cpu_to_le16(cfg->pools[i].buffer_size);
204 cmd_params->backup_pool_mask |=
205 DPNI_BACKUP_POOL(cfg->pools[i].backup_pool, i);
208 /* send command to mc*/
209 return mc_send_command(mc_io, &cmd);
213 * dpni_enable() - Enable the DPNI, allow sending and receiving frames.
214 * @mc_io: Pointer to MC portal's I/O object
215 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
216 * @token: Token of DPNI object
218 * Return: '0' on Success; Error code otherwise.
220 int dpni_enable(struct fsl_mc_io *mc_io,
224 struct mc_command cmd = { 0 };
226 /* prepare command */
227 cmd.header = mc_encode_cmd_header(DPNI_CMDID_ENABLE,
231 /* send command to mc*/
232 return mc_send_command(mc_io, &cmd);
236 * dpni_disable() - Disable the DPNI, stop sending and receiving frames.
237 * @mc_io: Pointer to MC portal's I/O object
238 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
239 * @token: Token of DPNI object
241 * Return: '0' on Success; Error code otherwise.
243 int dpni_disable(struct fsl_mc_io *mc_io,
247 struct mc_command cmd = { 0 };
249 /* prepare command */
250 cmd.header = mc_encode_cmd_header(DPNI_CMDID_DISABLE,
254 /* send command to mc*/
255 return mc_send_command(mc_io, &cmd);
259 * dpni_is_enabled() - Check if the DPNI is enabled.
260 * @mc_io: Pointer to MC portal's I/O object
261 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
262 * @token: Token of DPNI object
263 * @en: Returns '1' if object is enabled; '0' otherwise
265 * Return: '0' on Success; Error code otherwise.
267 int dpni_is_enabled(struct fsl_mc_io *mc_io,
272 struct mc_command cmd = { 0 };
273 struct dpni_rsp_is_enabled *rsp_params;
276 /* prepare command */
277 cmd.header = mc_encode_cmd_header(DPNI_CMDID_IS_ENABLED,
281 /* send command to mc*/
282 err = mc_send_command(mc_io, &cmd);
286 /* retrieve response parameters */
287 rsp_params = (struct dpni_rsp_is_enabled *)cmd.params;
288 *en = dpni_get_field(rsp_params->enabled, ENABLE);
294 * dpni_reset() - Reset the DPNI, returns the object to initial state.
295 * @mc_io: Pointer to MC portal's I/O object
296 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
297 * @token: Token of DPNI object
299 * Return: '0' on Success; Error code otherwise.
301 int dpni_reset(struct fsl_mc_io *mc_io,
305 struct mc_command cmd = { 0 };
307 /* prepare command */
308 cmd.header = mc_encode_cmd_header(DPNI_CMDID_RESET,
312 /* send command to mc*/
313 return mc_send_command(mc_io, &cmd);
317 * dpni_set_irq_enable() - Set overall interrupt state.
318 * @mc_io: Pointer to MC portal's I/O object
319 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
320 * @token: Token of DPNI object
321 * @irq_index: The interrupt index to configure
322 * @en: Interrupt state: - enable = 1, disable = 0
324 * Allows GPP software to control when interrupts are generated.
325 * Each interrupt can have up to 32 causes. The enable/disable control's the
326 * overall interrupt state. if the interrupt is disabled no causes will cause
329 * Return: '0' on Success; Error code otherwise.
331 int dpni_set_irq_enable(struct fsl_mc_io *mc_io,
337 struct mc_command cmd = { 0 };
338 struct dpni_cmd_set_irq_enable *cmd_params;
340 /* prepare command */
341 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_IRQ_ENABLE,
344 cmd_params = (struct dpni_cmd_set_irq_enable *)cmd.params;
345 dpni_set_field(cmd_params->enable, ENABLE, en);
346 cmd_params->irq_index = irq_index;
348 /* send command to mc*/
349 return mc_send_command(mc_io, &cmd);
353 * dpni_get_irq_enable() - Get overall interrupt state
354 * @mc_io: Pointer to MC portal's I/O object
355 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
356 * @token: Token of DPNI object
357 * @irq_index: The interrupt index to configure
358 * @en: Returned interrupt state - enable = 1, disable = 0
360 * Return: '0' on Success; Error code otherwise.
362 int dpni_get_irq_enable(struct fsl_mc_io *mc_io,
368 struct mc_command cmd = { 0 };
369 struct dpni_cmd_get_irq_enable *cmd_params;
370 struct dpni_rsp_get_irq_enable *rsp_params;
374 /* prepare command */
375 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_IRQ_ENABLE,
378 cmd_params = (struct dpni_cmd_get_irq_enable *)cmd.params;
379 cmd_params->irq_index = irq_index;
381 /* send command to mc*/
382 err = mc_send_command(mc_io, &cmd);
386 /* retrieve response parameters */
387 rsp_params = (struct dpni_rsp_get_irq_enable *)cmd.params;
388 *en = dpni_get_field(rsp_params->enabled, ENABLE);
394 * dpni_set_irq_mask() - Set interrupt mask.
395 * @mc_io: Pointer to MC portal's I/O object
396 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
397 * @token: Token of DPNI object
398 * @irq_index: The interrupt index to configure
399 * @mask: event mask to trigger interrupt;
402 * 1 = consider event for asserting IRQ
404 * Every interrupt can have up to 32 causes and the interrupt model supports
405 * masking/unmasking each cause independently
407 * Return: '0' on Success; Error code otherwise.
409 int dpni_set_irq_mask(struct fsl_mc_io *mc_io,
415 struct mc_command cmd = { 0 };
416 struct dpni_cmd_set_irq_mask *cmd_params;
418 /* prepare command */
419 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_IRQ_MASK,
422 cmd_params = (struct dpni_cmd_set_irq_mask *)cmd.params;
423 cmd_params->mask = cpu_to_le32(mask);
424 cmd_params->irq_index = irq_index;
426 /* send command to mc*/
427 return mc_send_command(mc_io, &cmd);
431 * dpni_get_irq_mask() - Get interrupt mask.
432 * @mc_io: Pointer to MC portal's I/O object
433 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
434 * @token: Token of DPNI object
435 * @irq_index: The interrupt index to configure
436 * @mask: Returned event mask to trigger interrupt
438 * Every interrupt can have up to 32 causes and the interrupt model supports
439 * masking/unmasking each cause independently
441 * Return: '0' on Success; Error code otherwise.
443 int dpni_get_irq_mask(struct fsl_mc_io *mc_io,
449 struct mc_command cmd = { 0 };
450 struct dpni_cmd_get_irq_mask *cmd_params;
451 struct dpni_rsp_get_irq_mask *rsp_params;
454 /* prepare command */
455 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_IRQ_MASK,
458 cmd_params = (struct dpni_cmd_get_irq_mask *)cmd.params;
459 cmd_params->irq_index = irq_index;
461 /* send command to mc*/
462 err = mc_send_command(mc_io, &cmd);
466 /* retrieve response parameters */
467 rsp_params = (struct dpni_rsp_get_irq_mask *)cmd.params;
468 *mask = le32_to_cpu(rsp_params->mask);
474 * dpni_get_irq_status() - Get the current status of any pending interrupts.
475 * @mc_io: Pointer to MC portal's I/O object
476 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
477 * @token: Token of DPNI object
478 * @irq_index: The interrupt index to configure
479 * @status: Returned interrupts status - one bit per cause:
480 * 0 = no interrupt pending
481 * 1 = interrupt pending
483 * Return: '0' on Success; Error code otherwise.
485 int dpni_get_irq_status(struct fsl_mc_io *mc_io,
491 struct mc_command cmd = { 0 };
492 struct dpni_cmd_get_irq_status *cmd_params;
493 struct dpni_rsp_get_irq_status *rsp_params;
496 /* prepare command */
497 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_IRQ_STATUS,
500 cmd_params = (struct dpni_cmd_get_irq_status *)cmd.params;
501 cmd_params->status = cpu_to_le32(*status);
502 cmd_params->irq_index = irq_index;
504 /* send command to mc*/
505 err = mc_send_command(mc_io, &cmd);
509 /* retrieve response parameters */
510 rsp_params = (struct dpni_rsp_get_irq_status *)cmd.params;
511 *status = le32_to_cpu(rsp_params->status);
517 * dpni_clear_irq_status() - Clear a pending interrupt's status
518 * @mc_io: Pointer to MC portal's I/O object
519 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
520 * @token: Token of DPNI object
521 * @irq_index: The interrupt index to configure
522 * @status: bits to clear (W1C) - one bit per cause:
524 * 1 = clear status bit
526 * Return: '0' on Success; Error code otherwise.
528 int dpni_clear_irq_status(struct fsl_mc_io *mc_io,
534 struct mc_command cmd = { 0 };
535 struct dpni_cmd_clear_irq_status *cmd_params;
537 /* prepare command */
538 cmd.header = mc_encode_cmd_header(DPNI_CMDID_CLEAR_IRQ_STATUS,
541 cmd_params = (struct dpni_cmd_clear_irq_status *)cmd.params;
542 cmd_params->irq_index = irq_index;
543 cmd_params->status = cpu_to_le32(status);
545 /* send command to mc*/
546 return mc_send_command(mc_io, &cmd);
550 * dpni_get_attributes() - Retrieve DPNI attributes.
551 * @mc_io: Pointer to MC portal's I/O object
552 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
553 * @token: Token of DPNI object
554 * @attr: Object's attributes
556 * Return: '0' on Success; Error code otherwise.
558 int dpni_get_attributes(struct fsl_mc_io *mc_io,
561 struct dpni_attr *attr)
563 struct mc_command cmd = { 0 };
564 struct dpni_rsp_get_attr *rsp_params;
568 /* prepare command */
569 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_ATTR,
573 /* send command to mc*/
574 err = mc_send_command(mc_io, &cmd);
578 /* retrieve response parameters */
579 rsp_params = (struct dpni_rsp_get_attr *)cmd.params;
580 attr->options = le32_to_cpu(rsp_params->options);
581 attr->num_queues = rsp_params->num_queues;
582 attr->num_tcs = rsp_params->num_tcs;
583 attr->mac_filter_entries = rsp_params->mac_filter_entries;
584 attr->vlan_filter_entries = rsp_params->vlan_filter_entries;
585 attr->qos_entries = rsp_params->qos_entries;
586 attr->fs_entries = le16_to_cpu(rsp_params->fs_entries);
587 attr->qos_key_size = rsp_params->qos_key_size;
588 attr->fs_key_size = rsp_params->fs_key_size;
589 attr->wriop_version = le16_to_cpu(rsp_params->wriop_version);
595 * dpni_set_errors_behavior() - Set errors behavior
596 * @mc_io: Pointer to MC portal's I/O object
597 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
598 * @token: Token of DPNI object
599 * @cfg: Errors configuration
601 * this function may be called numerous times with different
604 * Return: '0' on Success; Error code otherwise.
606 int dpni_set_errors_behavior(struct fsl_mc_io *mc_io,
609 struct dpni_error_cfg *cfg)
611 struct mc_command cmd = { 0 };
612 struct dpni_cmd_set_errors_behavior *cmd_params;
614 /* prepare command */
615 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_ERRORS_BEHAVIOR,
618 cmd_params = (struct dpni_cmd_set_errors_behavior *)cmd.params;
619 cmd_params->errors = cpu_to_le32(cfg->errors);
620 dpni_set_field(cmd_params->flags, ERROR_ACTION, cfg->error_action);
621 dpni_set_field(cmd_params->flags, FRAME_ANN, cfg->set_frame_annotation);
623 /* send command to mc*/
624 return mc_send_command(mc_io, &cmd);
628 * dpni_get_buffer_layout() - Retrieve buffer layout attributes.
629 * @mc_io: Pointer to MC portal's I/O object
630 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
631 * @token: Token of DPNI object
632 * @qtype: Type of queue to retrieve configuration for
633 * @layout: Returns buffer layout attributes
635 * Return: '0' on Success; Error code otherwise.
637 int dpni_get_buffer_layout(struct fsl_mc_io *mc_io,
640 enum dpni_queue_type qtype,
641 struct dpni_buffer_layout *layout)
643 struct mc_command cmd = { 0 };
644 struct dpni_cmd_get_buffer_layout *cmd_params;
645 struct dpni_rsp_get_buffer_layout *rsp_params;
648 /* prepare command */
649 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_BUFFER_LAYOUT,
652 cmd_params = (struct dpni_cmd_get_buffer_layout *)cmd.params;
653 cmd_params->qtype = qtype;
655 /* send command to mc*/
656 err = mc_send_command(mc_io, &cmd);
660 /* retrieve response parameters */
661 rsp_params = (struct dpni_rsp_get_buffer_layout *)cmd.params;
662 layout->pass_timestamp = dpni_get_field(rsp_params->flags, PASS_TS);
663 layout->pass_parser_result = dpni_get_field(rsp_params->flags, PASS_PR);
664 layout->pass_frame_status = dpni_get_field(rsp_params->flags, PASS_FS);
665 layout->private_data_size = le16_to_cpu(rsp_params->private_data_size);
666 layout->data_align = le16_to_cpu(rsp_params->data_align);
667 layout->data_head_room = le16_to_cpu(rsp_params->head_room);
668 layout->data_tail_room = le16_to_cpu(rsp_params->tail_room);
674 * dpni_set_buffer_layout() - Set buffer layout configuration.
675 * @mc_io: Pointer to MC portal's I/O object
676 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
677 * @token: Token of DPNI object
678 * @qtype: Type of queue this configuration applies to
679 * @layout: Buffer layout configuration
681 * Return: '0' on Success; Error code otherwise.
683 * @warning Allowed only when DPNI is disabled
685 int dpni_set_buffer_layout(struct fsl_mc_io *mc_io,
688 enum dpni_queue_type qtype,
689 const struct dpni_buffer_layout *layout)
691 struct mc_command cmd = { 0 };
692 struct dpni_cmd_set_buffer_layout *cmd_params;
694 /* prepare command */
695 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_BUFFER_LAYOUT,
698 cmd_params = (struct dpni_cmd_set_buffer_layout *)cmd.params;
699 cmd_params->qtype = qtype;
700 cmd_params->options = cpu_to_le16(layout->options);
701 dpni_set_field(cmd_params->flags, PASS_TS, layout->pass_timestamp);
702 dpni_set_field(cmd_params->flags, PASS_PR, layout->pass_parser_result);
703 dpni_set_field(cmd_params->flags, PASS_FS, layout->pass_frame_status);
704 cmd_params->private_data_size = cpu_to_le16(layout->private_data_size);
705 cmd_params->data_align = cpu_to_le16(layout->data_align);
706 cmd_params->head_room = cpu_to_le16(layout->data_head_room);
707 cmd_params->tail_room = cpu_to_le16(layout->data_tail_room);
709 /* send command to mc*/
710 return mc_send_command(mc_io, &cmd);
714 * dpni_set_offload() - Set DPNI offload configuration.
715 * @mc_io: Pointer to MC portal's I/O object
716 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
717 * @token: Token of DPNI object
718 * @type: Type of DPNI offload
719 * @config: Offload configuration.
720 * For checksum offloads, non-zero value enables the offload
722 * Return: '0' on Success; Error code otherwise.
724 * @warning Allowed only when DPNI is disabled
727 int dpni_set_offload(struct fsl_mc_io *mc_io,
730 enum dpni_offload type,
733 struct mc_command cmd = { 0 };
734 struct dpni_cmd_set_offload *cmd_params;
736 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_OFFLOAD,
739 cmd_params = (struct dpni_cmd_set_offload *)cmd.params;
740 cmd_params->dpni_offload = type;
741 cmd_params->config = cpu_to_le32(config);
743 return mc_send_command(mc_io, &cmd);
746 int dpni_get_offload(struct fsl_mc_io *mc_io,
749 enum dpni_offload type,
752 struct mc_command cmd = { 0 };
753 struct dpni_cmd_get_offload *cmd_params;
754 struct dpni_rsp_get_offload *rsp_params;
757 /* prepare command */
758 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_OFFLOAD,
761 cmd_params = (struct dpni_cmd_get_offload *)cmd.params;
762 cmd_params->dpni_offload = type;
764 /* send command to mc*/
765 err = mc_send_command(mc_io, &cmd);
769 /* retrieve response parameters */
770 rsp_params = (struct dpni_rsp_get_offload *)cmd.params;
771 *config = le32_to_cpu(rsp_params->config);
777 * dpni_get_qdid() - Get the Queuing Destination ID (QDID) that should be used
778 * for enqueue operations
779 * @mc_io: Pointer to MC portal's I/O object
780 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
781 * @token: Token of DPNI object
782 * @qtype: Type of queue to receive QDID for
783 * @qdid: Returned virtual QDID value that should be used as an argument
784 * in all enqueue operations
786 * Return: '0' on Success; Error code otherwise.
788 int dpni_get_qdid(struct fsl_mc_io *mc_io,
791 enum dpni_queue_type qtype,
794 struct mc_command cmd = { 0 };
795 struct dpni_cmd_get_qdid *cmd_params;
796 struct dpni_rsp_get_qdid *rsp_params;
799 /* prepare command */
800 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_QDID,
803 cmd_params = (struct dpni_cmd_get_qdid *)cmd.params;
804 cmd_params->qtype = qtype;
806 /* send command to mc*/
807 err = mc_send_command(mc_io, &cmd);
811 /* retrieve response parameters */
812 rsp_params = (struct dpni_rsp_get_qdid *)cmd.params;
813 *qdid = le16_to_cpu(rsp_params->qdid);
819 * dpni_get_tx_data_offset() - Get the Tx data offset (from start of buffer)
820 * @mc_io: Pointer to MC portal's I/O object
821 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
822 * @token: Token of DPNI object
823 * @data_offset: Tx data offset (from start of buffer)
825 * Return: '0' on Success; Error code otherwise.
827 int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
832 struct mc_command cmd = { 0 };
833 struct dpni_rsp_get_tx_data_offset *rsp_params;
836 /* prepare command */
837 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TX_DATA_OFFSET,
841 /* send command to mc*/
842 err = mc_send_command(mc_io, &cmd);
846 /* retrieve response parameters */
847 rsp_params = (struct dpni_rsp_get_tx_data_offset *)cmd.params;
848 *data_offset = le16_to_cpu(rsp_params->data_offset);
854 * dpni_set_link_cfg() - set the link configuration.
855 * @mc_io: Pointer to MC portal's I/O object
856 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
857 * @token: Token of DPNI object
858 * @cfg: Link configuration
860 * Return: '0' on Success; Error code otherwise.
862 int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
865 const struct dpni_link_cfg *cfg)
867 struct mc_command cmd = { 0 };
868 struct dpni_cmd_set_link_cfg *cmd_params;
870 /* prepare command */
871 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_LINK_CFG,
874 cmd_params = (struct dpni_cmd_set_link_cfg *)cmd.params;
875 cmd_params->rate = cpu_to_le32(cfg->rate);
876 cmd_params->options = cpu_to_le64(cfg->options);
878 /* send command to mc*/
879 return mc_send_command(mc_io, &cmd);
883 * dpni_get_link_state() - Return the link state (either up or down)
884 * @mc_io: Pointer to MC portal's I/O object
885 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
886 * @token: Token of DPNI object
887 * @state: Returned link state;
889 * Return: '0' on Success; Error code otherwise.
891 int dpni_get_link_state(struct fsl_mc_io *mc_io,
894 struct dpni_link_state *state)
896 struct mc_command cmd = { 0 };
897 struct dpni_rsp_get_link_state *rsp_params;
900 /* prepare command */
901 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_LINK_STATE,
905 /* send command to mc*/
906 err = mc_send_command(mc_io, &cmd);
910 /* retrieve response parameters */
911 rsp_params = (struct dpni_rsp_get_link_state *)cmd.params;
912 state->up = dpni_get_field(rsp_params->flags, LINK_STATE);
913 state->rate = le32_to_cpu(rsp_params->rate);
914 state->options = le64_to_cpu(rsp_params->options);
920 * dpni_set_max_frame_length() - Set the maximum received frame length.
921 * @mc_io: Pointer to MC portal's I/O object
922 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
923 * @token: Token of DPNI object
924 * @max_frame_length: Maximum received frame length (in
925 * bytes); frame is discarded if its
926 * length exceeds this value
928 * Return: '0' on Success; Error code otherwise.
930 int dpni_set_max_frame_length(struct fsl_mc_io *mc_io,
933 u16 max_frame_length)
935 struct mc_command cmd = { 0 };
936 struct dpni_cmd_set_max_frame_length *cmd_params;
938 /* prepare command */
939 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_MAX_FRAME_LENGTH,
942 cmd_params = (struct dpni_cmd_set_max_frame_length *)cmd.params;
943 cmd_params->max_frame_length = cpu_to_le16(max_frame_length);
945 /* send command to mc*/
946 return mc_send_command(mc_io, &cmd);
950 * dpni_get_max_frame_length() - Get the maximum received frame length.
951 * @mc_io: Pointer to MC portal's I/O object
952 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
953 * @token: Token of DPNI object
954 * @max_frame_length: Maximum received frame length (in
955 * bytes); frame is discarded if its
956 * length exceeds this value
958 * Return: '0' on Success; Error code otherwise.
960 int dpni_get_max_frame_length(struct fsl_mc_io *mc_io,
963 u16 *max_frame_length)
965 struct mc_command cmd = { 0 };
966 struct dpni_rsp_get_max_frame_length *rsp_params;
969 /* prepare command */
970 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_MAX_FRAME_LENGTH,
974 /* send command to mc*/
975 err = mc_send_command(mc_io, &cmd);
979 /* retrieve response parameters */
980 rsp_params = (struct dpni_rsp_get_max_frame_length *)cmd.params;
981 *max_frame_length = le16_to_cpu(rsp_params->max_frame_length);
987 * dpni_set_multicast_promisc() - Enable/disable multicast promiscuous mode
988 * @mc_io: Pointer to MC portal's I/O object
989 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
990 * @token: Token of DPNI object
991 * @en: Set to '1' to enable; '0' to disable
993 * Return: '0' on Success; Error code otherwise.
995 int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io,
1000 struct mc_command cmd = { 0 };
1001 struct dpni_cmd_set_multicast_promisc *cmd_params;
1003 /* prepare command */
1004 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_MCAST_PROMISC,
1007 cmd_params = (struct dpni_cmd_set_multicast_promisc *)cmd.params;
1008 dpni_set_field(cmd_params->enable, ENABLE, en);
1010 /* send command to mc*/
1011 return mc_send_command(mc_io, &cmd);
1015 * dpni_get_multicast_promisc() - Get multicast promiscuous mode
1016 * @mc_io: Pointer to MC portal's I/O object
1017 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1018 * @token: Token of DPNI object
1019 * @en: Returns '1' if enabled; '0' otherwise
1021 * Return: '0' on Success; Error code otherwise.
1023 int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io,
1028 struct mc_command cmd = { 0 };
1029 struct dpni_rsp_get_multicast_promisc *rsp_params;
1032 /* prepare command */
1033 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_MCAST_PROMISC,
1037 /* send command to mc*/
1038 err = mc_send_command(mc_io, &cmd);
1042 /* retrieve response parameters */
1043 rsp_params = (struct dpni_rsp_get_multicast_promisc *)cmd.params;
1044 *en = dpni_get_field(rsp_params->enabled, ENABLE);
1050 * dpni_set_unicast_promisc() - Enable/disable unicast promiscuous mode
1051 * @mc_io: Pointer to MC portal's I/O object
1052 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1053 * @token: Token of DPNI object
1054 * @en: Set to '1' to enable; '0' to disable
1056 * Return: '0' on Success; Error code otherwise.
1058 int dpni_set_unicast_promisc(struct fsl_mc_io *mc_io,
1063 struct mc_command cmd = { 0 };
1064 struct dpni_cmd_set_unicast_promisc *cmd_params;
1066 /* prepare command */
1067 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_UNICAST_PROMISC,
1070 cmd_params = (struct dpni_cmd_set_unicast_promisc *)cmd.params;
1071 dpni_set_field(cmd_params->enable, ENABLE, en);
1073 /* send command to mc*/
1074 return mc_send_command(mc_io, &cmd);
1078 * dpni_get_unicast_promisc() - Get unicast promiscuous mode
1079 * @mc_io: Pointer to MC portal's I/O object
1080 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1081 * @token: Token of DPNI object
1082 * @en: Returns '1' if enabled; '0' otherwise
1084 * Return: '0' on Success; Error code otherwise.
1086 int dpni_get_unicast_promisc(struct fsl_mc_io *mc_io,
1091 struct mc_command cmd = { 0 };
1092 struct dpni_rsp_get_unicast_promisc *rsp_params;
1095 /* prepare command */
1096 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_UNICAST_PROMISC,
1100 /* send command to mc*/
1101 err = mc_send_command(mc_io, &cmd);
1105 /* retrieve response parameters */
1106 rsp_params = (struct dpni_rsp_get_unicast_promisc *)cmd.params;
1107 *en = dpni_get_field(rsp_params->enabled, ENABLE);
1113 * dpni_set_primary_mac_addr() - Set the primary MAC address
1114 * @mc_io: Pointer to MC portal's I/O object
1115 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1116 * @token: Token of DPNI object
1117 * @mac_addr: MAC address to set as primary address
1119 * Return: '0' on Success; Error code otherwise.
1121 int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
1124 const u8 mac_addr[6])
1126 struct mc_command cmd = { 0 };
1127 struct dpni_cmd_set_primary_mac_addr *cmd_params;
1130 /* prepare command */
1131 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_PRIM_MAC,
1134 cmd_params = (struct dpni_cmd_set_primary_mac_addr *)cmd.params;
1135 for (i = 0; i < 6; i++)
1136 cmd_params->mac_addr[i] = mac_addr[5 - i];
1138 /* send command to mc*/
1139 return mc_send_command(mc_io, &cmd);
1143 * dpni_get_primary_mac_addr() - Get the primary MAC address
1144 * @mc_io: Pointer to MC portal's I/O object
1145 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1146 * @token: Token of DPNI object
1147 * @mac_addr: Returned MAC address
1149 * Return: '0' on Success; Error code otherwise.
1151 int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
1156 struct mc_command cmd = { 0 };
1157 struct dpni_rsp_get_primary_mac_addr *rsp_params;
1160 /* prepare command */
1161 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_PRIM_MAC,
1165 /* send command to mc*/
1166 err = mc_send_command(mc_io, &cmd);
1170 /* retrieve response parameters */
1171 rsp_params = (struct dpni_rsp_get_primary_mac_addr *)cmd.params;
1172 for (i = 0; i < 6; i++)
1173 mac_addr[5 - i] = rsp_params->mac_addr[i];
1179 * dpni_get_port_mac_addr() - Retrieve MAC address associated to the physical
1180 * port the DPNI is attached to
1181 * @mc_io: Pointer to MC portal's I/O object
1182 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1183 * @token: Token of DPNI object
1184 * @mac_addr: MAC address of the physical port, if any, otherwise 0
1186 * The primary MAC address is not cleared by this operation.
1188 * Return: '0' on Success; Error code otherwise.
1190 int dpni_get_port_mac_addr(struct fsl_mc_io *mc_io,
1195 struct mc_command cmd = { 0 };
1196 struct dpni_rsp_get_port_mac_addr *rsp_params;
1199 /* prepare command */
1200 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_PORT_MAC_ADDR,
1204 /* send command to mc*/
1205 err = mc_send_command(mc_io, &cmd);
1209 /* retrieve response parameters */
1210 rsp_params = (struct dpni_rsp_get_port_mac_addr *)cmd.params;
1211 for (i = 0; i < 6; i++)
1212 mac_addr[5 - i] = rsp_params->mac_addr[i];
1218 * dpni_add_mac_addr() - Add MAC address filter
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 * @mac_addr: MAC address to add
1224 * Return: '0' on Success; Error code otherwise.
1226 int dpni_add_mac_addr(struct fsl_mc_io *mc_io,
1229 const u8 mac_addr[6])
1231 struct mc_command cmd = { 0 };
1232 struct dpni_cmd_add_mac_addr *cmd_params;
1235 /* prepare command */
1236 cmd.header = mc_encode_cmd_header(DPNI_CMDID_ADD_MAC_ADDR,
1239 cmd_params = (struct dpni_cmd_add_mac_addr *)cmd.params;
1240 for (i = 0; i < 6; i++)
1241 cmd_params->mac_addr[i] = mac_addr[5 - i];
1243 /* send command to mc*/
1244 return mc_send_command(mc_io, &cmd);
1248 * dpni_remove_mac_addr() - Remove MAC address filter
1249 * @mc_io: Pointer to MC portal's I/O object
1250 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1251 * @token: Token of DPNI object
1252 * @mac_addr: MAC address to remove
1254 * Return: '0' on Success; Error code otherwise.
1256 int dpni_remove_mac_addr(struct fsl_mc_io *mc_io,
1259 const u8 mac_addr[6])
1261 struct mc_command cmd = { 0 };
1262 struct dpni_cmd_remove_mac_addr *cmd_params;
1265 /* prepare command */
1266 cmd.header = mc_encode_cmd_header(DPNI_CMDID_REMOVE_MAC_ADDR,
1269 cmd_params = (struct dpni_cmd_remove_mac_addr *)cmd.params;
1270 for (i = 0; i < 6; i++)
1271 cmd_params->mac_addr[i] = mac_addr[5 - i];
1273 /* send command to mc*/
1274 return mc_send_command(mc_io, &cmd);
1278 * dpni_clear_mac_filters() - Clear all unicast and/or multicast MAC filters
1279 * @mc_io: Pointer to MC portal's I/O object
1280 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1281 * @token: Token of DPNI object
1282 * @unicast: Set to '1' to clear unicast addresses
1283 * @multicast: Set to '1' to clear multicast addresses
1285 * The primary MAC address is not cleared by this operation.
1287 * Return: '0' on Success; Error code otherwise.
1289 int dpni_clear_mac_filters(struct fsl_mc_io *mc_io,
1295 struct mc_command cmd = { 0 };
1296 struct dpni_cmd_clear_mac_filters *cmd_params;
1298 /* prepare command */
1299 cmd.header = mc_encode_cmd_header(DPNI_CMDID_CLR_MAC_FILTERS,
1302 cmd_params = (struct dpni_cmd_clear_mac_filters *)cmd.params;
1303 dpni_set_field(cmd_params->flags, UNICAST_FILTERS, unicast);
1304 dpni_set_field(cmd_params->flags, MULTICAST_FILTERS, multicast);
1306 /* send command to mc*/
1307 return mc_send_command(mc_io, &cmd);
1311 * dpni_set_rx_tc_dist() - Set Rx traffic class distribution configuration
1312 * @mc_io: Pointer to MC portal's I/O object
1313 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1314 * @token: Token of DPNI object
1315 * @tc_id: Traffic class selection (0-7)
1316 * @cfg: Traffic class distribution configuration
1318 * warning: if 'dist_mode != DPNI_DIST_MODE_NONE', call dpni_prepare_key_cfg()
1319 * first to prepare the key_cfg_iova parameter
1321 * Return: '0' on Success; error code otherwise.
1323 int dpni_set_rx_tc_dist(struct fsl_mc_io *mc_io,
1327 const struct dpni_rx_tc_dist_cfg *cfg)
1329 struct mc_command cmd = { 0 };
1330 struct dpni_cmd_set_rx_tc_dist *cmd_params;
1332 /* prepare command */
1333 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_RX_TC_DIST,
1336 cmd_params = (struct dpni_cmd_set_rx_tc_dist *)cmd.params;
1337 cmd_params->dist_size = cpu_to_le16(cfg->dist_size);
1338 cmd_params->tc_id = tc_id;
1339 dpni_set_field(cmd_params->flags, DIST_MODE, cfg->dist_mode);
1340 dpni_set_field(cmd_params->flags, MISS_ACTION, cfg->fs_cfg.miss_action);
1341 cmd_params->default_flow_id = cpu_to_le16(cfg->fs_cfg.default_flow_id);
1342 cmd_params->key_cfg_iova = cpu_to_le64(cfg->key_cfg_iova);
1344 /* send command to mc*/
1345 return mc_send_command(mc_io, &cmd);
1349 * dpni_set_queue() - Set queue parameters
1350 * @mc_io: Pointer to MC portal's I/O object
1351 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1352 * @token: Token of DPNI object
1353 * @qtype: Type of queue - all queue types are supported, although
1354 * the command is ignored for Tx
1355 * @tc: Traffic class, in range 0 to NUM_TCS - 1
1356 * @index: Selects the specific queue out of the set allocated for the
1357 * same TC. Value must be in range 0 to NUM_QUEUES - 1
1358 * @options: A combination of DPNI_QUEUE_OPT_ values that control what
1359 * configuration options are set on the queue
1360 * @queue: Queue structure
1362 * Return: '0' on Success; Error code otherwise.
1364 int dpni_set_queue(struct fsl_mc_io *mc_io,
1367 enum dpni_queue_type qtype,
1371 const struct dpni_queue *queue)
1373 struct mc_command cmd = { 0 };
1374 struct dpni_cmd_set_queue *cmd_params;
1376 /* prepare command */
1377 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_QUEUE,
1380 cmd_params = (struct dpni_cmd_set_queue *)cmd.params;
1381 cmd_params->qtype = qtype;
1382 cmd_params->tc = tc;
1383 cmd_params->index = index;
1384 cmd_params->options = options;
1385 cmd_params->dest_id = cpu_to_le32(queue->destination.id);
1386 cmd_params->dest_prio = queue->destination.priority;
1387 dpni_set_field(cmd_params->flags, DEST_TYPE, queue->destination.type);
1388 dpni_set_field(cmd_params->flags, STASH_CTRL, queue->flc.stash_control);
1389 dpni_set_field(cmd_params->flags, HOLD_ACTIVE,
1390 queue->destination.hold_active);
1391 cmd_params->flc = cpu_to_le64(queue->flc.value);
1392 cmd_params->user_context = cpu_to_le64(queue->user_context);
1394 /* send command to mc */
1395 return mc_send_command(mc_io, &cmd);
1399 * dpni_get_queue() - Get queue parameters
1400 * @mc_io: Pointer to MC portal's I/O object
1401 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1402 * @token: Token of DPNI object
1403 * @qtype: Type of queue - all queue types are supported
1404 * @tc: Traffic class, in range 0 to NUM_TCS - 1
1405 * @index: Selects the specific queue out of the set allocated for the
1406 * same TC. Value must be in range 0 to NUM_QUEUES - 1
1407 * @queue: Queue configuration structure
1408 * @qid: Queue identification
1410 * Return: '0' on Success; Error code otherwise.
1412 int dpni_get_queue(struct fsl_mc_io *mc_io,
1415 enum dpni_queue_type qtype,
1418 struct dpni_queue *queue,
1419 struct dpni_queue_id *qid)
1421 struct mc_command cmd = { 0 };
1422 struct dpni_cmd_get_queue *cmd_params;
1423 struct dpni_rsp_get_queue *rsp_params;
1426 /* prepare command */
1427 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_QUEUE,
1430 cmd_params = (struct dpni_cmd_get_queue *)cmd.params;
1431 cmd_params->qtype = qtype;
1432 cmd_params->tc = tc;
1433 cmd_params->index = index;
1435 /* send command to mc */
1436 err = mc_send_command(mc_io, &cmd);
1440 /* retrieve response parameters */
1441 rsp_params = (struct dpni_rsp_get_queue *)cmd.params;
1442 queue->destination.id = le32_to_cpu(rsp_params->dest_id);
1443 queue->destination.priority = rsp_params->dest_prio;
1444 queue->destination.type = dpni_get_field(rsp_params->flags,
1446 queue->flc.stash_control = dpni_get_field(rsp_params->flags,
1448 queue->destination.hold_active = dpni_get_field(rsp_params->flags,
1450 queue->flc.value = le64_to_cpu(rsp_params->flc);
1451 queue->user_context = le64_to_cpu(rsp_params->user_context);
1452 qid->fqid = le32_to_cpu(rsp_params->fqid);
1453 qid->qdbin = le16_to_cpu(rsp_params->qdbin);
1459 * dpni_get_statistics() - Get DPNI statistics
1460 * @mc_io: Pointer to MC portal's I/O object
1461 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1462 * @token: Token of DPNI object
1463 * @page: Selects the statistics page to retrieve, see
1464 * DPNI_GET_STATISTICS output. Pages are numbered 0 to 2.
1465 * @stat: Structure containing the statistics
1467 * Return: '0' on Success; Error code otherwise.
1469 int dpni_get_statistics(struct fsl_mc_io *mc_io,
1473 union dpni_statistics *stat)
1475 struct mc_command cmd = { 0 };
1476 struct dpni_cmd_get_statistics *cmd_params;
1477 struct dpni_rsp_get_statistics *rsp_params;
1480 /* prepare command */
1481 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_STATISTICS,
1484 cmd_params = (struct dpni_cmd_get_statistics *)cmd.params;
1485 cmd_params->page_number = page;
1487 /* send command to mc */
1488 err = mc_send_command(mc_io, &cmd);
1492 /* retrieve response parameters */
1493 rsp_params = (struct dpni_rsp_get_statistics *)cmd.params;
1494 for (i = 0; i < DPNI_STATISTICS_CNT; i++)
1495 stat->raw.counter[i] = le64_to_cpu(rsp_params->counter[i]);
1501 * dpni_set_taildrop() - Set taildrop per queue or TC
1502 * @mc_io: Pointer to MC portal's I/O object
1503 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1504 * @token: Token of DPNI object
1505 * @cg_point: Congestion point
1506 * @q_type: Queue type on which the taildrop is configured.
1507 * Only Rx queues are supported for now
1508 * @tc: Traffic class to apply this taildrop to
1509 * @q_index: Index of the queue if the DPNI supports multiple queues for
1510 * traffic distribution. Ignored if CONGESTION_POINT is not 0.
1511 * @taildrop: Taildrop structure
1513 * Return: '0' on Success; Error code otherwise.
1515 int dpni_set_taildrop(struct fsl_mc_io *mc_io,
1518 enum dpni_congestion_point cg_point,
1519 enum dpni_queue_type qtype,
1522 struct dpni_taildrop *taildrop)
1524 struct mc_command cmd = { 0 };
1525 struct dpni_cmd_set_taildrop *cmd_params;
1527 /* prepare command */
1528 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TAILDROP,
1531 cmd_params = (struct dpni_cmd_set_taildrop *)cmd.params;
1532 cmd_params->congestion_point = cg_point;
1533 cmd_params->qtype = qtype;
1534 cmd_params->tc = tc;
1535 cmd_params->index = index;
1536 dpni_set_field(cmd_params->enable, ENABLE, taildrop->enable);
1537 cmd_params->units = taildrop->units;
1538 cmd_params->threshold = cpu_to_le32(taildrop->threshold);
1540 /* send command to mc */
1541 return mc_send_command(mc_io, &cmd);
1545 * dpni_get_taildrop() - Get taildrop information
1546 * @mc_io: Pointer to MC portal's I/O object
1547 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1548 * @token: Token of DPNI object
1549 * @cg_point: Congestion point
1550 * @q_type: Queue type on which the taildrop is configured.
1551 * Only Rx queues are supported for now
1552 * @tc: Traffic class to apply this taildrop to
1553 * @q_index: Index of the queue if the DPNI supports multiple queues for
1554 * traffic distribution. Ignored if CONGESTION_POINT is not 0.
1555 * @taildrop: Taildrop structure
1557 * Return: '0' on Success; Error code otherwise.
1559 int dpni_get_taildrop(struct fsl_mc_io *mc_io,
1562 enum dpni_congestion_point cg_point,
1563 enum dpni_queue_type qtype,
1566 struct dpni_taildrop *taildrop)
1568 struct mc_command cmd = { 0 };
1569 struct dpni_cmd_get_taildrop *cmd_params;
1570 struct dpni_rsp_get_taildrop *rsp_params;
1573 /* prepare command */
1574 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TAILDROP,
1577 cmd_params = (struct dpni_cmd_get_taildrop *)cmd.params;
1578 cmd_params->congestion_point = cg_point;
1579 cmd_params->qtype = qtype;
1580 cmd_params->tc = tc;
1581 cmd_params->index = index;
1583 /* send command to mc */
1584 err = mc_send_command(mc_io, &cmd);
1588 /* retrieve response parameters */
1589 rsp_params = (struct dpni_rsp_get_taildrop *)cmd.params;
1590 taildrop->enable = dpni_get_field(rsp_params->enable, ENABLE);
1591 taildrop->units = rsp_params->units;
1592 taildrop->threshold = le32_to_cpu(rsp_params->threshold);