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 2016-2017 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.
40 #ifndef _FSL_DPSECI_CMD_H
41 #define _FSL_DPSECI_CMD_H
44 #define DPSECI_VER_MAJOR 5
45 #define DPSECI_VER_MINOR 1
47 /* Command versioning */
48 #define DPSECI_CMD_BASE_VERSION 1
49 #define DPSECI_CMD_BASE_VERSION_V2 2
50 #define DPSECI_CMD_ID_OFFSET 4
52 #define DPSECI_CMD_V1(id) \
53 ((id << DPSECI_CMD_ID_OFFSET) | DPSECI_CMD_BASE_VERSION)
54 #define DPSECI_CMD_V2(id) \
55 ((id << DPSECI_CMD_ID_OFFSET) | DPSECI_CMD_BASE_VERSION_V2)
58 #define DPSECI_CMDID_CLOSE DPSECI_CMD_V1(0x800)
59 #define DPSECI_CMDID_OPEN DPSECI_CMD_V1(0x809)
60 #define DPSECI_CMDID_CREATE DPSECI_CMD_V2(0x909)
61 #define DPSECI_CMDID_DESTROY DPSECI_CMD_V1(0x989)
62 #define DPSECI_CMDID_GET_API_VERSION DPSECI_CMD_V1(0xa09)
64 #define DPSECI_CMDID_ENABLE DPSECI_CMD_V1(0x002)
65 #define DPSECI_CMDID_DISABLE DPSECI_CMD_V1(0x003)
66 #define DPSECI_CMDID_GET_ATTR DPSECI_CMD_V1(0x004)
67 #define DPSECI_CMDID_RESET DPSECI_CMD_V1(0x005)
68 #define DPSECI_CMDID_IS_ENABLED DPSECI_CMD_V1(0x006)
70 #define DPSECI_CMDID_SET_RX_QUEUE DPSECI_CMD_V1(0x194)
71 #define DPSECI_CMDID_GET_RX_QUEUE DPSECI_CMD_V1(0x196)
72 #define DPSECI_CMDID_GET_TX_QUEUE DPSECI_CMD_V1(0x197)
73 #define DPSECI_CMDID_GET_SEC_ATTR DPSECI_CMD_V1(0x198)
74 #define DPSECI_CMDID_GET_SEC_COUNTERS DPSECI_CMD_V1(0x199)
76 #define DPSECI_CMDID_SET_CONGESTION_NOTIFICATION DPSECI_CMD_V1(0x170)
77 #define DPSECI_CMDID_GET_CONGESTION_NOTIFICATION DPSECI_CMD_V1(0x171)
79 /* Macros for accessing command fields smaller than 1byte */
80 #define DPSECI_MASK(field) \
81 GENMASK(DPSECI_##field##_SHIFT + DPSECI_##field##_SIZE - 1, \
82 DPSECI_##field##_SHIFT)
83 #define dpseci_set_field(var, field, val) \
84 ((var) |= (((val) << DPSECI_##field##_SHIFT) & DPSECI_MASK(field)))
85 #define dpseci_get_field(var, field) \
86 (((var) & DPSECI_MASK(field)) >> DPSECI_##field##_SHIFT)
89 struct dpseci_cmd_open {
93 struct dpseci_cmd_create {
94 uint8_t priorities[8];
95 uint8_t num_tx_queues;
96 uint8_t num_rx_queues;
101 struct dpseci_cmd_destroy {
105 #define DPSECI_ENABLE_SHIFT 0
106 #define DPSECI_ENABLE_SIZE 1
108 struct dpseci_rsp_is_enabled {
109 /* only the first LSB */
113 struct dpseci_rsp_get_attr {
116 uint8_t num_tx_queues;
117 uint8_t num_rx_queues;
122 #define DPSECI_DEST_TYPE_SHIFT 0
123 #define DPSECI_DEST_TYPE_SIZE 4
125 #define DPSECI_ORDER_PRESERVATION_SHIFT 0
126 #define DPSECI_ORDER_PRESERVATION_SIZE 1
128 struct dpseci_cmd_set_rx_queue {
130 uint8_t dest_priority;
132 /* from LSB: dest_type:4 */
138 uint8_t order_preservation_en;
141 struct dpseci_cmd_get_queue {
146 struct dpseci_rsp_get_rx_queue {
148 uint8_t dest_priority;
150 /* from LSB: dest_type:4 */
156 uint8_t order_preservation_en;
160 struct dpseci_rsp_get_tx_queue {
166 struct dpseci_rsp_get_sec_attr {
173 uint8_t zuc_auth_acc_num;
174 uint8_t zuc_enc_acc_num;
176 uint8_t snow_f8_acc_num;
177 uint8_t snow_f9_acc_num;
181 uint8_t kasumi_acc_num;
185 uint8_t arc4_acc_num;
190 struct dpseci_rsp_get_sec_counters {
191 uint64_t dequeued_requests;
192 uint64_t ob_enc_requests;
193 uint64_t ib_dec_requests;
194 uint64_t ob_enc_bytes;
195 uint64_t ob_prot_bytes;
196 uint64_t ib_dec_bytes;
197 uint64_t ib_valid_bytes;
200 struct dpseci_rsp_get_api_version {
205 #define DPSECI_DEST_TYPE_SHIFT 0
206 #define DPSECI_DEST_TYPE_SIZE 4
207 #define DPSECI_CG_UNITS_SHIFT 4
208 #define DPSECI_CG_UNITS_SIZE 2
210 struct dpseci_cmd_set_congestion_notification {
212 uint16_t notification_mode;
213 uint8_t dest_priority;
214 /* from LSB: dest_type: 4 units:2 */
216 uint64_t message_iova;
217 uint64_t message_ctx;
218 uint32_t threshold_entry;
219 uint32_t threshold_exit;
223 #endif /* _FSL_DPSECI_CMD_H */