1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
3 * Copyright 2013-2016 Freescale Semiconductor Inc.
4 * Copyright 2016-2017 NXP
10 /* Data Path SEC Interface API
11 * Contains initialization APIs and runtime control APIs for DPSECI
17 * General DPSECI macros
21 * Maximum number of Tx/Rx priorities per DPSECI object
23 #define DPSECI_MAX_QUEUE_NUM 16
26 * All queues considered; see dpseci_set_rx_queue()
28 #define DPSECI_ALL_QUEUES (uint8_t)(-1)
30 int dpseci_open(struct fsl_mc_io *mc_io,
35 int dpseci_close(struct fsl_mc_io *mc_io,
40 * Enable the Congestion Group support
42 #define DPSECI_OPT_HAS_CG 0x000020
45 * struct dpseci_cfg - Structure representing DPSECI configuration
46 * @options: Any combination of the following options:
49 * DPSECI_OPT_OPR_SHARED
50 * @num_tx_queues: num of queues towards the SEC
51 * @num_rx_queues: num of queues back from the SEC
52 * @priorities: Priorities for the SEC hardware processing;
53 * each place in the array is the priority of the tx queue
55 * valid priorities are configured with values 1-8;
59 uint8_t num_tx_queues;
60 uint8_t num_rx_queues;
61 uint8_t priorities[DPSECI_MAX_QUEUE_NUM];
64 int dpseci_create(struct fsl_mc_io *mc_io,
67 const struct dpseci_cfg *cfg,
70 int dpseci_destroy(struct fsl_mc_io *mc_io,
75 int dpseci_enable(struct fsl_mc_io *mc_io,
79 int dpseci_disable(struct fsl_mc_io *mc_io,
83 int dpseci_is_enabled(struct fsl_mc_io *mc_io,
88 int dpseci_reset(struct fsl_mc_io *mc_io,
93 * struct dpseci_attr - Structure representing DPSECI attributes
94 * @id: DPSECI object ID
95 * @num_tx_queues: number of queues towards the SEC
96 * @num_rx_queues: number of queues back from the SEC
97 * @options: Any combination of the following options:
100 * DPSECI_OPT_OPR_SHARED
104 uint8_t num_tx_queues;
105 uint8_t num_rx_queues;
109 int dpseci_get_attributes(struct fsl_mc_io *mc_io,
112 struct dpseci_attr *attr);
115 * enum dpseci_dest - DPSECI destination types
116 * @DPSECI_DEST_NONE: Unassigned destination; The queue is set in parked mode
117 * and does not generate FQDAN notifications; user is expected to
118 * dequeue from the queue based on polling or other user-defined
120 * @DPSECI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
121 * notifications to the specified DPIO; user is expected to dequeue
122 * from the queue only after notification is received
123 * @DPSECI_DEST_DPCON: The queue is set in schedule mode and does not generate
124 * FQDAN notifications, but is connected to the specified DPCON
125 * object; user is expected to dequeue from the DPCON channel
128 DPSECI_DEST_NONE = 0,
129 DPSECI_DEST_DPIO = 1,
130 DPSECI_DEST_DPCON = 2
134 * struct dpseci_dest_cfg - Structure representing DPSECI destination parameters
135 * @dest_type: Destination type
136 * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
137 * @priority: Priority selection within the DPIO or DPCON channel; valid values
138 * are 0-1 or 0-7, depending on the number of priorities in that
139 * channel; not relevant for 'DPSECI_DEST_NONE' option
141 struct dpseci_dest_cfg {
142 enum dpseci_dest dest_type;
148 * DPSECI queue modification options
152 * Select to modify the user's context associated with the queue
154 #define DPSECI_QUEUE_OPT_USER_CTX 0x00000001
157 * Select to modify the queue's destination
159 #define DPSECI_QUEUE_OPT_DEST 0x00000002
162 * Select to modify the queue's order preservation
164 #define DPSECI_QUEUE_OPT_ORDER_PRESERVATION 0x00000004
167 * struct dpseci_rx_queue_cfg - DPSECI RX queue configuration
168 * @options: Flags representing the suggested modifications to the queue;
169 * Use any combination of 'DPSECI_QUEUE_OPT_<X>' flags
170 * @order_preservation_en: order preservation configuration for the rx queue
171 * valid only if 'DPSECI_QUEUE_OPT_ORDER_PRESERVATION' is contained in 'options'
172 * @user_ctx: User context value provided in the frame descriptor of each
174 * valid only if 'DPSECI_QUEUE_OPT_USER_CTX' is contained in 'options'
175 * @dest_cfg: Queue destination parameters;
176 * valid only if 'DPSECI_QUEUE_OPT_DEST' is contained in 'options'
178 struct dpseci_rx_queue_cfg {
180 int order_preservation_en;
182 struct dpseci_dest_cfg dest_cfg;
185 int dpseci_set_rx_queue(struct fsl_mc_io *mc_io,
189 const struct dpseci_rx_queue_cfg *cfg);
192 * struct dpseci_rx_queue_attr - Structure representing attributes of Rx queues
193 * @user_ctx: User context value provided in the frame descriptor of each
195 * @order_preservation_en: Status of the order preservation configuration
197 * @dest_cfg: Queue destination configuration
198 * @fqid: Virtual FQID value to be used for dequeue operations
200 struct dpseci_rx_queue_attr {
202 int order_preservation_en;
203 struct dpseci_dest_cfg dest_cfg;
207 int dpseci_get_rx_queue(struct fsl_mc_io *mc_io,
211 struct dpseci_rx_queue_attr *attr);
214 * struct dpseci_tx_queue_attr - Structure representing attributes of Tx queues
215 * @fqid: Virtual FQID to be used for sending frames to SEC hardware
216 * @priority: SEC hardware processing priority for the queue
218 struct dpseci_tx_queue_attr {
223 int dpseci_get_tx_queue(struct fsl_mc_io *mc_io,
227 struct dpseci_tx_queue_attr *attr);
230 * struct dpseci_sec_attr - Structure representing attributes of the SEC
231 * hardware accelerator
232 * @ip_id: ID for SEC.
233 * @major_rev: Major revision number for SEC.
234 * @minor_rev: Minor revision number for SEC.
236 * @deco_num: The number of copies of the DECO that are implemented
237 * in this version of SEC.
238 * @zuc_auth_acc_num: The number of copies of ZUCA that are implemented
239 * in this version of SEC.
240 * @zuc_enc_acc_num: The number of copies of ZUCE that are implemented
241 * in this version of SEC.
242 * @snow_f8_acc_num: The number of copies of the SNOW-f8 module that are
243 * implemented in this version of SEC.
244 * @snow_f9_acc_num: The number of copies of the SNOW-f9 module that are
245 * implemented in this version of SEC.
246 * @crc_acc_num: The number of copies of the CRC module that are
247 * implemented in this version of SEC.
248 * @pk_acc_num: The number of copies of the Public Key module that are
249 * implemented in this version of SEC.
250 * @kasumi_acc_num: The number of copies of the Kasumi module that are
251 * implemented in this version of SEC.
252 * @rng_acc_num: The number of copies of the Random Number Generator that
253 * are implemented in this version of SEC.
254 * @md_acc_num: The number of copies of the MDHA (Hashing module) that
255 * are implemented in this version of SEC.
256 * @arc4_acc_num: The number of copies of the ARC4 module that are
257 * implemented in this version of SEC.
258 * @des_acc_num: The number of copies of the DES module that are
259 * implemented in this version of SEC.
260 * @aes_acc_num: The number of copies of the AES module that are
261 * implemented in this version of SEC.
262 * @ccha_acc_num: The number of copies of the ChaCha20 module that are
263 * implemented in this version of SEC.
264 * @ptha_acc_num: The number of copies of the Poly1305 module that are
265 * implemented in this version of SEC.
268 struct dpseci_sec_attr {
274 uint8_t zuc_auth_acc_num;
275 uint8_t zuc_enc_acc_num;
276 uint8_t snow_f8_acc_num;
277 uint8_t snow_f9_acc_num;
280 uint8_t kasumi_acc_num;
283 uint8_t arc4_acc_num;
286 uint8_t ccha_acc_num;
287 uint8_t ptha_acc_num;
290 int dpseci_get_sec_attr(struct fsl_mc_io *mc_io,
293 struct dpseci_sec_attr *attr);
296 * struct dpseci_sec_counters - Structure representing global SEC counters and
297 * not per dpseci counters
298 * @dequeued_requests: Number of Requests Dequeued
299 * @ob_enc_requests: Number of Outbound Encrypt Requests
300 * @ib_dec_requests: Number of Inbound Decrypt Requests
301 * @ob_enc_bytes: Number of Outbound Bytes Encrypted
302 * @ob_prot_bytes: Number of Outbound Bytes Protected
303 * @ib_dec_bytes: Number of Inbound Bytes Decrypted
304 * @ib_valid_bytes: Number of Inbound Bytes Validated
306 struct dpseci_sec_counters {
307 uint64_t dequeued_requests;
308 uint64_t ob_enc_requests;
309 uint64_t ib_dec_requests;
310 uint64_t ob_enc_bytes;
311 uint64_t ob_prot_bytes;
312 uint64_t ib_dec_bytes;
313 uint64_t ib_valid_bytes;
316 int dpseci_get_sec_counters(struct fsl_mc_io *mc_io,
319 struct dpseci_sec_counters *counters);
321 int dpseci_get_api_version(struct fsl_mc_io *mc_io,
324 uint16_t *minor_ver);
326 int dpseci_set_opr(struct fsl_mc_io *mc_io,
331 struct opr_cfg *cfg);
333 int dpseci_get_opr(struct fsl_mc_io *mc_io,
338 struct opr_qry *qry);
341 * enum dpseci_congestion_unit - DPSECI congestion units
342 * @DPSECI_CONGESTION_UNIT_BYTES: bytes units
343 * @DPSECI_CONGESTION_UNIT_FRAMES: frames units
345 enum dpseci_congestion_unit {
346 DPSECI_CONGESTION_UNIT_BYTES = 0,
347 DPSECI_CONGESTION_UNIT_FRAMES
351 * CSCN message is written to message_iova once entering a
352 * congestion state (see 'threshold_entry')
354 #define DPSECI_CGN_MODE_WRITE_MEM_ON_ENTER 0x00000001
356 * CSCN message is written to message_iova once exiting a
357 * congestion state (see 'threshold_exit')
359 #define DPSECI_CGN_MODE_WRITE_MEM_ON_EXIT 0x00000002
361 * CSCN write will attempt to allocate into a cache (coherent write);
362 * valid only if 'DPSECI_CGN_MODE_WRITE_MEM_<X>' is selected
364 #define DPSECI_CGN_MODE_COHERENT_WRITE 0x00000004
366 * if 'dpseci_dest_cfg.dest_type != DPSECI_DEST_NONE' CSCN message is sent to
367 * DPIO/DPCON's WQ channel once entering a congestion state
368 * (see 'threshold_entry')
370 #define DPSECI_CGN_MODE_NOTIFY_DEST_ON_ENTER 0x00000008
372 * if 'dpseci_dest_cfg.dest_type != DPSECI_DEST_NONE' CSCN message is sent to
373 * DPIO/DPCON's WQ channel once exiting a congestion state
374 * (see 'threshold_exit')
376 #define DPSECI_CGN_MODE_NOTIFY_DEST_ON_EXIT 0x00000010
378 * if 'dpseci_dest_cfg.dest_type != DPSECI_DEST_NONE' when the CSCN is written
379 * to the sw-portal's DQRR, the DQRI interrupt is asserted immediately
382 #define DPSECI_CGN_MODE_INTR_COALESCING_DISABLED 0x00000020
385 * struct dpseci_congestion_notification_cfg - congestion notification
388 * @threshold_entry: above this threshold we enter a congestion state.
389 * set it to '0' to disable it
390 * @threshold_exit: below this threshold we exit the congestion state.
391 * @message_ctx: The context that will be part of the CSCN message
392 * @message_iova: I/O virtual address (must be in DMA-able memory),
393 * must be 16B aligned;
394 * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel
395 * @notification_mode: Mask of available options; use 'DPSECI_CGN_MODE_<X>'
398 struct dpseci_congestion_notification_cfg {
399 enum dpseci_congestion_unit units;
400 uint32_t threshold_entry;
401 uint32_t threshold_exit;
402 uint64_t message_ctx;
403 uint64_t message_iova;
404 struct dpseci_dest_cfg dest_cfg;
405 uint16_t notification_mode;
408 int dpseci_set_congestion_notification(
409 struct fsl_mc_io *mc_io,
412 const struct dpseci_congestion_notification_cfg *cfg);
414 int dpseci_get_congestion_notification(
415 struct fsl_mc_io *mc_io,
418 struct dpseci_congestion_notification_cfg *cfg);
420 #endif /* __FSL_DPSECI_H */