2 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license.
7 * Copyright 2013-2016 Freescale Semiconductor Inc.
8 * Copyright (c) 2016 NXP.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * * Neither the name of the above-listed copyright holders nor the
18 * names of any contributors may be used to endorse or promote products
19 * derived from this software without specific prior written permission.
23 * ALTERNATIVELY, this software may be distributed under the terms of the
24 * GNU General Public License ("GPL") as published by the Free Software
25 * Foundation, either version 2 of that License or (at your option) any
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
32 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGE.
41 #include <fsl_mc_sys.h>
42 #include <fsl_mc_cmd.h>
43 #include <fsl_dpseci.h>
44 #include <fsl_dpseci_cmd.h>
47 dpseci_open(struct fsl_mc_io *mc_io,
52 struct mc_command cmd = { 0 };
56 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_OPEN,
59 DPSECI_CMD_OPEN(cmd, dpseci_id);
61 /* send command to mc */
62 err = mc_send_command(mc_io, &cmd);
66 /* retrieve response parameters */
67 *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
73 dpseci_close(struct fsl_mc_io *mc_io,
77 struct mc_command cmd = { 0 };
80 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_CLOSE,
84 /* send command to mc */
85 return mc_send_command(mc_io, &cmd);
89 dpseci_create(struct fsl_mc_io *mc_io,
92 const struct dpseci_cfg *cfg,
95 struct mc_command cmd = { 0 };
99 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_CREATE,
102 DPSECI_CMD_CREATE(cmd, cfg);
104 /* send command to mc */
105 err = mc_send_command(mc_io, &cmd);
109 /* retrieve response parameters */
110 CMD_CREATE_RSP_GET_OBJ_ID_PARAM0(cmd, *obj_id);
116 dpseci_destroy(struct fsl_mc_io *mc_io,
121 struct mc_command cmd = { 0 };
123 /* prepare command */
124 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_DESTROY,
127 /* set object id to destroy */
128 CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, object_id);
129 /* send command to mc */
130 return mc_send_command(mc_io, &cmd);
134 dpseci_enable(struct fsl_mc_io *mc_io,
138 struct mc_command cmd = { 0 };
140 /* prepare command */
141 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_ENABLE,
145 /* send command to mc */
146 return mc_send_command(mc_io, &cmd);
150 dpseci_disable(struct fsl_mc_io *mc_io,
154 struct mc_command cmd = { 0 };
156 /* prepare command */
157 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_DISABLE,
161 /* send command to mc */
162 return mc_send_command(mc_io, &cmd);
166 dpseci_is_enabled(struct fsl_mc_io *mc_io,
171 struct mc_command cmd = { 0 };
173 /* prepare command */
174 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_IS_ENABLED,
178 /* send command to mc */
179 err = mc_send_command(mc_io, &cmd);
183 /* retrieve response parameters */
184 DPSECI_RSP_IS_ENABLED(cmd, *en);
190 dpseci_reset(struct fsl_mc_io *mc_io,
194 struct mc_command cmd = { 0 };
196 /* prepare command */
197 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_RESET,
201 /* send command to mc */
202 return mc_send_command(mc_io, &cmd);
206 dpseci_get_irq(struct fsl_mc_io *mc_io,
211 struct dpseci_irq_cfg *irq_cfg)
213 struct mc_command cmd = { 0 };
216 /* prepare command */
217 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_IRQ,
220 DPSECI_CMD_GET_IRQ(cmd, irq_index);
222 /* send command to mc */
223 err = mc_send_command(mc_io, &cmd);
227 /* retrieve response parameters */
228 DPSECI_RSP_GET_IRQ(cmd, *type, irq_cfg);
234 dpseci_set_irq(struct fsl_mc_io *mc_io,
238 struct dpseci_irq_cfg *irq_cfg)
240 struct mc_command cmd = { 0 };
242 /* prepare command */
243 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_SET_IRQ,
246 DPSECI_CMD_SET_IRQ(cmd, irq_index, irq_cfg);
248 /* send command to mc */
249 return mc_send_command(mc_io, &cmd);
253 dpseci_get_irq_enable(struct fsl_mc_io *mc_io,
259 struct mc_command cmd = { 0 };
262 /* prepare command */
263 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_IRQ_ENABLE,
266 DPSECI_CMD_GET_IRQ_ENABLE(cmd, irq_index);
268 /* send command to mc */
269 err = mc_send_command(mc_io, &cmd);
273 /* retrieve response parameters */
274 DPSECI_RSP_GET_IRQ_ENABLE(cmd, *en);
280 dpseci_set_irq_enable(struct fsl_mc_io *mc_io,
286 struct mc_command cmd = { 0 };
288 /* prepare command */
289 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_SET_IRQ_ENABLE,
292 DPSECI_CMD_SET_IRQ_ENABLE(cmd, irq_index, en);
294 /* send command to mc */
295 return mc_send_command(mc_io, &cmd);
299 dpseci_get_irq_mask(struct fsl_mc_io *mc_io,
305 struct mc_command cmd = { 0 };
308 /* prepare command */
309 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_IRQ_MASK,
312 DPSECI_CMD_GET_IRQ_MASK(cmd, irq_index);
314 /* send command to mc */
315 err = mc_send_command(mc_io, &cmd);
319 /* retrieve response parameters */
320 DPSECI_RSP_GET_IRQ_MASK(cmd, *mask);
326 dpseci_set_irq_mask(struct fsl_mc_io *mc_io,
332 struct mc_command cmd = { 0 };
334 /* prepare command */
335 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_SET_IRQ_MASK,
338 DPSECI_CMD_SET_IRQ_MASK(cmd, irq_index, mask);
340 /* send command to mc */
341 return mc_send_command(mc_io, &cmd);
345 dpseci_get_irq_status(struct fsl_mc_io *mc_io,
351 struct mc_command cmd = { 0 };
354 /* prepare command */
355 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_IRQ_STATUS,
358 DPSECI_CMD_GET_IRQ_STATUS(cmd, irq_index, *status);
360 /* send command to mc */
361 err = mc_send_command(mc_io, &cmd);
365 /* retrieve response parameters */
366 DPSECI_RSP_GET_IRQ_STATUS(cmd, *status);
372 dpseci_clear_irq_status(struct fsl_mc_io *mc_io,
378 struct mc_command cmd = { 0 };
380 /* prepare command */
381 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_CLEAR_IRQ_STATUS,
384 DPSECI_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status);
386 /* send command to mc */
387 return mc_send_command(mc_io, &cmd);
391 dpseci_get_attributes(struct fsl_mc_io *mc_io,
394 struct dpseci_attr *attr)
396 struct mc_command cmd = { 0 };
399 /* prepare command */
400 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_ATTR,
404 /* send command to mc */
405 err = mc_send_command(mc_io, &cmd);
409 /* retrieve response parameters */
410 DPSECI_RSP_GET_ATTR(cmd, attr);
416 dpseci_set_rx_queue(struct fsl_mc_io *mc_io,
420 const struct dpseci_rx_queue_cfg *cfg)
422 struct mc_command cmd = { 0 };
424 /* prepare command */
425 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_SET_RX_QUEUE,
428 DPSECI_CMD_SET_RX_QUEUE(cmd, queue, cfg);
430 /* send command to mc */
431 return mc_send_command(mc_io, &cmd);
435 dpseci_get_rx_queue(struct fsl_mc_io *mc_io,
439 struct dpseci_rx_queue_attr *attr)
441 struct mc_command cmd = { 0 };
444 /* prepare command */
445 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_RX_QUEUE,
448 DPSECI_CMD_GET_RX_QUEUE(cmd, queue);
450 /* send command to mc */
451 err = mc_send_command(mc_io, &cmd);
455 /* retrieve response parameters */
456 DPSECI_RSP_GET_RX_QUEUE(cmd, attr);
462 dpseci_get_tx_queue(struct fsl_mc_io *mc_io,
466 struct dpseci_tx_queue_attr *attr)
468 struct mc_command cmd = { 0 };
471 /* prepare command */
472 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_TX_QUEUE,
475 DPSECI_CMD_GET_TX_QUEUE(cmd, queue);
477 /* send command to mc */
478 err = mc_send_command(mc_io, &cmd);
482 /* retrieve response parameters */
483 DPSECI_RSP_GET_TX_QUEUE(cmd, attr);
489 dpseci_get_sec_attr(struct fsl_mc_io *mc_io,
492 struct dpseci_sec_attr *attr)
494 struct mc_command cmd = { 0 };
497 /* prepare command */
498 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_SEC_ATTR,
502 /* send command to mc */
503 err = mc_send_command(mc_io, &cmd);
507 /* retrieve response parameters */
508 DPSECI_RSP_GET_SEC_ATTR(cmd, attr);
514 dpseci_get_sec_counters(struct fsl_mc_io *mc_io,
517 struct dpseci_sec_counters *counters)
519 struct mc_command cmd = { 0 };
522 /* prepare command */
523 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_SEC_COUNTERS,
527 /* send command to mc */
528 err = mc_send_command(mc_io, &cmd);
532 /* retrieve response parameters */
533 DPSECI_RSP_GET_SEC_COUNTERS(cmd, counters);
539 dpseci_get_api_version(struct fsl_mc_io *mc_io,
544 struct mc_command cmd = { 0 };
547 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_API_VERSION,
551 err = mc_send_command(mc_io, &cmd);
555 DPSECI_RSP_GET_API_VERSION(cmd, *major_ver, *minor_ver);