1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
3 * Copyright 2013-2016 Freescale Semiconductor Inc.
4 * Copyright 2016-2020 NXP
10 /* Data Path SEC Interface API
11 * Contains initialization APIs and runtime control APIs for DPSECI
14 #include <fsl_dpopr.h>
19 * General DPSECI macros
23 * Maximum number of Tx/Rx priorities per DPSECI object
25 #define DPSECI_MAX_QUEUE_NUM 16
28 * All queues considered; see dpseci_set_rx_queue()
30 #define DPSECI_ALL_QUEUES (uint8_t)(-1)
32 int dpseci_open(struct fsl_mc_io *mc_io,
37 int dpseci_close(struct fsl_mc_io *mc_io,
42 * Enable the Congestion Group support
44 #define DPSECI_OPT_HAS_CG 0x000020
47 * Enable the Order Restoration support
49 #define DPSECI_OPT_HAS_OPR 0x000040
52 * Order Point Records are shared for the entire DPSECI
54 #define DPSECI_OPT_OPR_SHARED 0x000080
57 * struct dpseci_cfg - Structure representing DPSECI configuration
58 * @options: Any combination of the following options:
61 * DPSECI_OPT_OPR_SHARED
62 * @num_tx_queues: num of queues towards the SEC
63 * @num_rx_queues: num of queues back from the SEC
64 * @priorities: Priorities for the SEC hardware processing;
65 * each place in the array is the priority of the tx queue
67 * valid priorities are configured with values 1-8;
71 uint8_t num_tx_queues;
72 uint8_t num_rx_queues;
73 uint8_t priorities[DPSECI_MAX_QUEUE_NUM];
76 int dpseci_create(struct fsl_mc_io *mc_io,
79 const struct dpseci_cfg *cfg,
82 int dpseci_destroy(struct fsl_mc_io *mc_io,
87 int dpseci_enable(struct fsl_mc_io *mc_io,
91 int dpseci_disable(struct fsl_mc_io *mc_io,
95 int dpseci_is_enabled(struct fsl_mc_io *mc_io,
100 int dpseci_reset(struct fsl_mc_io *mc_io,
105 * struct dpseci_attr - Structure representing DPSECI attributes
106 * @id: DPSECI object ID
107 * @num_tx_queues: number of queues towards the SEC
108 * @num_rx_queues: number of queues back from the SEC
109 * @options: Any combination of the following options:
112 * DPSECI_OPT_OPR_SHARED
116 uint8_t num_tx_queues;
117 uint8_t num_rx_queues;
121 int dpseci_get_attributes(struct fsl_mc_io *mc_io,
124 struct dpseci_attr *attr);
127 * enum dpseci_dest - DPSECI destination types
128 * @DPSECI_DEST_NONE: Unassigned destination; The queue is set in parked mode
129 * and does not generate FQDAN notifications; user is expected to
130 * dequeue from the queue based on polling or other user-defined
132 * @DPSECI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
133 * notifications to the specified DPIO; user is expected to dequeue
134 * from the queue only after notification is received
135 * @DPSECI_DEST_DPCON: The queue is set in schedule mode and does not generate
136 * FQDAN notifications, but is connected to the specified DPCON
137 * object; user is expected to dequeue from the DPCON channel
140 DPSECI_DEST_NONE = 0,
141 DPSECI_DEST_DPIO = 1,
142 DPSECI_DEST_DPCON = 2
146 * struct dpseci_dest_cfg - Structure representing DPSECI destination parameters
147 * @dest_type: Destination type
148 * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
149 * @priority: Priority selection within the DPIO or DPCON channel; valid values
150 * are 0-1 or 0-7, depending on the number of priorities in that
151 * channel; not relevant for 'DPSECI_DEST_NONE' option
153 struct dpseci_dest_cfg {
154 enum dpseci_dest dest_type;
160 * DPSECI queue modification options
164 * Select to modify the user's context associated with the queue
166 #define DPSECI_QUEUE_OPT_USER_CTX 0x00000001
169 * Select to modify the queue's destination
171 #define DPSECI_QUEUE_OPT_DEST 0x00000002
174 * Select to modify the queue's order preservation
176 #define DPSECI_QUEUE_OPT_ORDER_PRESERVATION 0x00000004
179 * struct dpseci_rx_queue_cfg - DPSECI RX queue configuration
180 * @options: Flags representing the suggested modifications to the queue;
181 * Use any combination of 'DPSECI_QUEUE_OPT_<X>' flags
182 * @order_preservation_en: order preservation configuration for the rx queue
183 * valid only if 'DPSECI_QUEUE_OPT_ORDER_PRESERVATION' is contained in 'options'
184 * @user_ctx: User context value provided in the frame descriptor of each
186 * valid only if 'DPSECI_QUEUE_OPT_USER_CTX' is contained in 'options'
187 * @dest_cfg: Queue destination parameters;
188 * valid only if 'DPSECI_QUEUE_OPT_DEST' is contained in 'options'
190 struct dpseci_rx_queue_cfg {
192 int order_preservation_en;
194 struct dpseci_dest_cfg dest_cfg;
197 int dpseci_set_rx_queue(struct fsl_mc_io *mc_io,
201 const struct dpseci_rx_queue_cfg *cfg);
204 * struct dpseci_rx_queue_attr - Structure representing attributes of Rx queues
205 * @user_ctx: User context value provided in the frame descriptor of each
207 * @order_preservation_en: Status of the order preservation configuration
209 * @dest_cfg: Queue destination configuration
210 * @fqid: Virtual FQID value to be used for dequeue operations
212 struct dpseci_rx_queue_attr {
214 int order_preservation_en;
215 struct dpseci_dest_cfg dest_cfg;
219 int dpseci_get_rx_queue(struct fsl_mc_io *mc_io,
223 struct dpseci_rx_queue_attr *attr);
226 * struct dpseci_tx_queue_attr - Structure representing attributes of Tx queues
227 * @fqid: Virtual FQID to be used for sending frames to SEC hardware
228 * @priority: SEC hardware processing priority for the queue
230 struct dpseci_tx_queue_attr {
235 int dpseci_get_tx_queue(struct fsl_mc_io *mc_io,
239 struct dpseci_tx_queue_attr *attr);
242 * struct dpseci_sec_attr - Structure representing attributes of the SEC
243 * hardware accelerator
244 * @ip_id: ID for SEC.
245 * @major_rev: Major revision number for SEC.
246 * @minor_rev: Minor revision number for SEC.
248 * @deco_num: The number of copies of the DECO that are implemented
249 * in this version of SEC.
250 * @zuc_auth_acc_num: The number of copies of ZUCA that are implemented
251 * in this version of SEC.
252 * @zuc_enc_acc_num: The number of copies of ZUCE that are implemented
253 * in this version of SEC.
254 * @snow_f8_acc_num: The number of copies of the SNOW-f8 module that are
255 * implemented in this version of SEC.
256 * @snow_f9_acc_num: The number of copies of the SNOW-f9 module that are
257 * implemented in this version of SEC.
258 * @crc_acc_num: The number of copies of the CRC module that are
259 * implemented in this version of SEC.
260 * @pk_acc_num: The number of copies of the Public Key module that are
261 * implemented in this version of SEC.
262 * @kasumi_acc_num: The number of copies of the Kasumi module that are
263 * implemented in this version of SEC.
264 * @rng_acc_num: The number of copies of the Random Number Generator that
265 * are implemented in this version of SEC.
266 * @md_acc_num: The number of copies of the MDHA (Hashing module) that
267 * are implemented in this version of SEC.
268 * @arc4_acc_num: The number of copies of the ARC4 module that are
269 * implemented in this version of SEC.
270 * @des_acc_num: The number of copies of the DES module that are
271 * implemented in this version of SEC.
272 * @aes_acc_num: The number of copies of the AES module that are
273 * implemented in this version of SEC.
274 * @ccha_acc_num: The number of copies of the ChaCha20 module that are
275 * implemented in this version of SEC.
276 * @ptha_acc_num: The number of copies of the Poly1305 module that are
277 * implemented in this version of SEC.
280 struct dpseci_sec_attr {
286 uint8_t zuc_auth_acc_num;
287 uint8_t zuc_enc_acc_num;
288 uint8_t snow_f8_acc_num;
289 uint8_t snow_f9_acc_num;
292 uint8_t kasumi_acc_num;
295 uint8_t arc4_acc_num;
298 uint8_t ccha_acc_num;
299 uint8_t ptha_acc_num;
302 int dpseci_get_sec_attr(struct fsl_mc_io *mc_io,
305 struct dpseci_sec_attr *attr);
308 * struct dpseci_sec_counters - Structure representing global SEC counters and
309 * not per dpseci counters
310 * @dequeued_requests: Number of Requests Dequeued
311 * @ob_enc_requests: Number of Outbound Encrypt Requests
312 * @ib_dec_requests: Number of Inbound Decrypt Requests
313 * @ob_enc_bytes: Number of Outbound Bytes Encrypted
314 * @ob_prot_bytes: Number of Outbound Bytes Protected
315 * @ib_dec_bytes: Number of Inbound Bytes Decrypted
316 * @ib_valid_bytes: Number of Inbound Bytes Validated
318 struct dpseci_sec_counters {
319 uint64_t dequeued_requests;
320 uint64_t ob_enc_requests;
321 uint64_t ib_dec_requests;
322 uint64_t ob_enc_bytes;
323 uint64_t ob_prot_bytes;
324 uint64_t ib_dec_bytes;
325 uint64_t ib_valid_bytes;
328 int dpseci_get_sec_counters(struct fsl_mc_io *mc_io,
331 struct dpseci_sec_counters *counters);
333 int dpseci_get_api_version(struct fsl_mc_io *mc_io,
336 uint16_t *minor_ver);
338 int dpseci_set_opr(struct fsl_mc_io *mc_io,
343 struct opr_cfg *cfg);
345 int dpseci_get_opr(struct fsl_mc_io *mc_io,
350 struct opr_qry *qry);
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 */