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_H
41 #define __FSL_DPSECI_H
43 /* Data Path SEC Interface API
44 * Contains initialization APIs and runtime control APIs for DPSECI
50 * General DPSECI macros
54 * Maximum number of Tx/Rx priorities per DPSECI object
56 #define DPSECI_PRIO_NUM 8
59 * All queues considered; see dpseci_set_rx_queue()
61 #define DPSECI_ALL_QUEUES (uint8_t)(-1)
63 int dpseci_open(struct fsl_mc_io *mc_io,
68 int dpseci_close(struct fsl_mc_io *mc_io,
73 * Enable the Congestion Group support
75 #define DPSECI_OPT_HAS_CG 0x000020
78 * struct dpseci_cfg - Structure representing DPSECI configuration
79 * @options: Any combination of the following options:
82 * DPSECI_OPT_OPR_SHARED
83 * @num_tx_queues: num of queues towards the SEC
84 * @num_rx_queues: num of queues back from the SEC
85 * @priorities: Priorities for the SEC hardware processing;
86 * each place in the array is the priority of the tx queue
88 * valid priorities are configured with values 1-8;
92 uint8_t num_tx_queues;
93 uint8_t num_rx_queues;
94 uint8_t priorities[DPSECI_PRIO_NUM];
97 int dpseci_create(struct fsl_mc_io *mc_io,
100 const struct dpseci_cfg *cfg,
103 int dpseci_destroy(struct fsl_mc_io *mc_io,
108 int dpseci_enable(struct fsl_mc_io *mc_io,
112 int dpseci_disable(struct fsl_mc_io *mc_io,
116 int dpseci_is_enabled(struct fsl_mc_io *mc_io,
121 int dpseci_reset(struct fsl_mc_io *mc_io,
126 * struct dpseci_attr - Structure representing DPSECI attributes
127 * @id: DPSECI object ID
128 * @num_tx_queues: number of queues towards the SEC
129 * @num_rx_queues: number of queues back from the SEC
130 * @options: Any combination of the following options:
133 * DPSECI_OPT_OPR_SHARED
137 uint8_t num_tx_queues;
138 uint8_t num_rx_queues;
142 int dpseci_get_attributes(struct fsl_mc_io *mc_io,
145 struct dpseci_attr *attr);
148 * enum dpseci_dest - DPSECI destination types
149 * @DPSECI_DEST_NONE: Unassigned destination; The queue is set in parked mode
150 * and does not generate FQDAN notifications; user is expected to
151 * dequeue from the queue based on polling or other user-defined
153 * @DPSECI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
154 * notifications to the specified DPIO; user is expected to dequeue
155 * from the queue only after notification is received
156 * @DPSECI_DEST_DPCON: The queue is set in schedule mode and does not generate
157 * FQDAN notifications, but is connected to the specified DPCON
158 * object; user is expected to dequeue from the DPCON channel
161 DPSECI_DEST_NONE = 0,
162 DPSECI_DEST_DPIO = 1,
163 DPSECI_DEST_DPCON = 2
167 * struct dpseci_dest_cfg - Structure representing DPSECI destination parameters
168 * @dest_type: Destination type
169 * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
170 * @priority: Priority selection within the DPIO or DPCON channel; valid values
171 * are 0-1 or 0-7, depending on the number of priorities in that
172 * channel; not relevant for 'DPSECI_DEST_NONE' option
174 struct dpseci_dest_cfg {
175 enum dpseci_dest dest_type;
181 * DPSECI queue modification options
185 * Select to modify the user's context associated with the queue
187 #define DPSECI_QUEUE_OPT_USER_CTX 0x00000001
190 * Select to modify the queue's destination
192 #define DPSECI_QUEUE_OPT_DEST 0x00000002
195 * Select to modify the queue's order preservation
197 #define DPSECI_QUEUE_OPT_ORDER_PRESERVATION 0x00000004
200 * struct dpseci_rx_queue_cfg - DPSECI RX queue configuration
201 * @options: Flags representing the suggested modifications to the queue;
202 * Use any combination of 'DPSECI_QUEUE_OPT_<X>' flags
203 * @order_preservation_en: order preservation configuration for the rx queue
204 * valid only if 'DPSECI_QUEUE_OPT_ORDER_PRESERVATION' is contained in 'options'
205 * @user_ctx: User context value provided in the frame descriptor of each
207 * valid only if 'DPSECI_QUEUE_OPT_USER_CTX' is contained in 'options'
208 * @dest_cfg: Queue destination parameters;
209 * valid only if 'DPSECI_QUEUE_OPT_DEST' is contained in 'options'
211 struct dpseci_rx_queue_cfg {
213 int order_preservation_en;
215 struct dpseci_dest_cfg dest_cfg;
218 int dpseci_set_rx_queue(struct fsl_mc_io *mc_io,
222 const struct dpseci_rx_queue_cfg *cfg);
225 * struct dpseci_rx_queue_attr - Structure representing attributes of Rx queues
226 * @user_ctx: User context value provided in the frame descriptor of each
228 * @order_preservation_en: Status of the order preservation configuration
230 * @dest_cfg: Queue destination configuration
231 * @fqid: Virtual FQID value to be used for dequeue operations
233 struct dpseci_rx_queue_attr {
235 int order_preservation_en;
236 struct dpseci_dest_cfg dest_cfg;
240 int dpseci_get_rx_queue(struct fsl_mc_io *mc_io,
244 struct dpseci_rx_queue_attr *attr);
247 * struct dpseci_tx_queue_attr - Structure representing attributes of Tx queues
248 * @fqid: Virtual FQID to be used for sending frames to SEC hardware
249 * @priority: SEC hardware processing priority for the queue
251 struct dpseci_tx_queue_attr {
256 int dpseci_get_tx_queue(struct fsl_mc_io *mc_io,
260 struct dpseci_tx_queue_attr *attr);
263 * struct dpseci_sec_attr - Structure representing attributes of the SEC
264 * hardware accelerator
265 * @ip_id: ID for SEC.
266 * @major_rev: Major revision number for SEC.
267 * @minor_rev: Minor revision number for SEC.
269 * @deco_num: The number of copies of the DECO that are implemented
270 * in this version of SEC.
271 * @zuc_auth_acc_num: The number of copies of ZUCA that are implemented
272 * in this version of SEC.
273 * @zuc_enc_acc_num: The number of copies of ZUCE that are implemented
274 * in this version of SEC.
275 * @snow_f8_acc_num: The number of copies of the SNOW-f8 module that are
276 * implemented in this version of SEC.
277 * @snow_f9_acc_num: The number of copies of the SNOW-f9 module that are
278 * implemented in this version of SEC.
279 * @crc_acc_num: The number of copies of the CRC module that are
280 * implemented in this version of SEC.
281 * @pk_acc_num: The number of copies of the Public Key module that are
282 * implemented in this version of SEC.
283 * @kasumi_acc_num: The number of copies of the Kasumi module that are
284 * implemented in this version of SEC.
285 * @rng_acc_num: The number of copies of the Random Number Generator that
286 * are implemented in this version of SEC.
287 * @md_acc_num: The number of copies of the MDHA (Hashing module) that
288 * are implemented in this version of SEC.
289 * @arc4_acc_num: The number of copies of the ARC4 module that are
290 * implemented in this version of SEC.
291 * @des_acc_num: The number of copies of the DES module that are
292 * implemented in this version of SEC.
293 * @aes_acc_num: The number of copies of the AES module that are
294 * implemented in this version of SEC.
297 struct dpseci_sec_attr {
303 uint8_t zuc_auth_acc_num;
304 uint8_t zuc_enc_acc_num;
305 uint8_t snow_f8_acc_num;
306 uint8_t snow_f9_acc_num;
309 uint8_t kasumi_acc_num;
312 uint8_t arc4_acc_num;
317 int dpseci_get_sec_attr(struct fsl_mc_io *mc_io,
320 struct dpseci_sec_attr *attr);
323 * struct dpseci_sec_counters - Structure representing global SEC counters and
324 * not per dpseci counters
325 * @dequeued_requests: Number of Requests Dequeued
326 * @ob_enc_requests: Number of Outbound Encrypt Requests
327 * @ib_dec_requests: Number of Inbound Decrypt Requests
328 * @ob_enc_bytes: Number of Outbound Bytes Encrypted
329 * @ob_prot_bytes: Number of Outbound Bytes Protected
330 * @ib_dec_bytes: Number of Inbound Bytes Decrypted
331 * @ib_valid_bytes: Number of Inbound Bytes Validated
333 struct dpseci_sec_counters {
334 uint64_t dequeued_requests;
335 uint64_t ob_enc_requests;
336 uint64_t ib_dec_requests;
337 uint64_t ob_enc_bytes;
338 uint64_t ob_prot_bytes;
339 uint64_t ib_dec_bytes;
340 uint64_t ib_valid_bytes;
343 int dpseci_get_sec_counters(struct fsl_mc_io *mc_io,
346 struct dpseci_sec_counters *counters);
348 int dpseci_get_api_version(struct fsl_mc_io *mc_io,
351 uint16_t *minor_ver);
353 * enum dpseci_congestion_unit - DPSECI congestion units
354 * @DPSECI_CONGESTION_UNIT_BYTES: bytes units
355 * @DPSECI_CONGESTION_UNIT_FRAMES: frames units
357 enum dpseci_congestion_unit {
358 DPSECI_CONGESTION_UNIT_BYTES = 0,
359 DPSECI_CONGESTION_UNIT_FRAMES
363 * CSCN message is written to message_iova once entering a
364 * congestion state (see 'threshold_entry')
366 #define DPSECI_CGN_MODE_WRITE_MEM_ON_ENTER 0x00000001
368 * CSCN message is written to message_iova once exiting a
369 * congestion state (see 'threshold_exit')
371 #define DPSECI_CGN_MODE_WRITE_MEM_ON_EXIT 0x00000002
373 * CSCN write will attempt to allocate into a cache (coherent write);
374 * valid only if 'DPSECI_CGN_MODE_WRITE_MEM_<X>' is selected
376 #define DPSECI_CGN_MODE_COHERENT_WRITE 0x00000004
378 * if 'dpseci_dest_cfg.dest_type != DPSECI_DEST_NONE' CSCN message is sent to
379 * DPIO/DPCON's WQ channel once entering a congestion state
380 * (see 'threshold_entry')
382 #define DPSECI_CGN_MODE_NOTIFY_DEST_ON_ENTER 0x00000008
384 * if 'dpseci_dest_cfg.dest_type != DPSECI_DEST_NONE' CSCN message is sent to
385 * DPIO/DPCON's WQ channel once exiting a congestion state
386 * (see 'threshold_exit')
388 #define DPSECI_CGN_MODE_NOTIFY_DEST_ON_EXIT 0x00000010
390 * if 'dpseci_dest_cfg.dest_type != DPSECI_DEST_NONE' when the CSCN is written
391 * to the sw-portal's DQRR, the DQRI interrupt is asserted immediately
394 #define DPSECI_CGN_MODE_INTR_COALESCING_DISABLED 0x00000020
397 * struct dpseci_congestion_notification_cfg - congestion notification
400 * @threshold_entry: above this threshold we enter a congestion state.
401 * set it to '0' to disable it
402 * @threshold_exit: below this threshold we exit the congestion state.
403 * @message_ctx: The context that will be part of the CSCN message
404 * @message_iova: I/O virtual address (must be in DMA-able memory),
405 * must be 16B aligned;
406 * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel
407 * @notification_mode: Mask of available options; use 'DPSECI_CGN_MODE_<X>'
410 struct dpseci_congestion_notification_cfg {
411 enum dpseci_congestion_unit units;
412 uint32_t threshold_entry;
413 uint32_t threshold_exit;
414 uint64_t message_ctx;
415 uint64_t message_iova;
416 struct dpseci_dest_cfg dest_cfg;
417 uint16_t notification_mode;
420 int dpseci_set_congestion_notification(
421 struct fsl_mc_io *mc_io,
424 const struct dpseci_congestion_notification_cfg *cfg);
426 int dpseci_get_congestion_notification(
427 struct fsl_mc_io *mc_io,
430 struct dpseci_congestion_notification_cfg *cfg);
432 #endif /* __FSL_DPSECI_H */