1 /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
3 * Copyright 2013-2016 Freescale Semiconductor Inc.
4 * Copyright 2017-2018 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 queues per DPSECI object
23 #define DPSECI_MAX_QUEUE_NUM 16
26 * All queues considered; see dpseci_set_rx_queue()
28 #define DPSECI_ALL_QUEUES (u8)(-1)
30 int dpseci_open(struct fsl_mc_io
*mc_io
, u32 cmd_flags
, int dpseci_id
,
33 int dpseci_close(struct fsl_mc_io
*mc_io
, u32 cmd_flags
, u16 token
);
36 * Enable the Congestion Group support
38 #define DPSECI_OPT_HAS_CG 0x000020
41 * struct dpseci_cfg - Structure representing DPSECI configuration
42 * @options: Any combination of the following flags:
44 * @num_tx_queues: num of queues towards the SEC
45 * @num_rx_queues: num of queues back from the SEC
46 * @priorities: Priorities for the SEC hardware processing;
47 * each place in the array is the priority of the tx queue
49 * valid priorities are configured with values 1-8;
55 u8 priorities
[DPSECI_MAX_QUEUE_NUM
];
58 int dpseci_enable(struct fsl_mc_io
*mc_io
, u32 cmd_flags
, u16 token
);
60 int dpseci_disable(struct fsl_mc_io
*mc_io
, u32 cmd_flags
, u16 token
);
62 int dpseci_is_enabled(struct fsl_mc_io
*mc_io
, u32 cmd_flags
, u16 token
,
66 * struct dpseci_attr - Structure representing DPSECI attributes
67 * @id: DPSECI object ID
68 * @num_tx_queues: number of queues towards the SEC
69 * @num_rx_queues: number of queues back from the SEC
70 * @options: any combination of the following flags:
80 int dpseci_get_attributes(struct fsl_mc_io
*mc_io
, u32 cmd_flags
, u16 token
,
81 struct dpseci_attr
*attr
);
84 * enum dpseci_dest - DPSECI destination types
85 * @DPSECI_DEST_NONE: Unassigned destination; The queue is set in parked mode
86 * and does not generate FQDAN notifications; user is expected to dequeue
87 * from the queue based on polling or other user-defined method
88 * @DPSECI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
89 * notifications to the specified DPIO; user is expected to dequeue from
90 * the queue only after notification is received
91 * @DPSECI_DEST_DPCON: The queue is set in schedule mode and does not generate
92 * FQDAN notifications, but is connected to the specified DPCON object;
93 * user is expected to dequeue from the DPCON channel
102 * struct dpseci_dest_cfg - Structure representing DPSECI destination parameters
103 * @dest_type: Destination type
104 * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
105 * @priority: Priority selection within the DPIO or DPCON channel; valid values
106 * are 0-1 or 0-7, depending on the number of priorities in that channel;
107 * not relevant for 'DPSECI_DEST_NONE' option
109 struct dpseci_dest_cfg
{
110 enum dpseci_dest dest_type
;
116 * DPSECI queue modification options
120 * Select to modify the user's context associated with the queue
122 #define DPSECI_QUEUE_OPT_USER_CTX 0x00000001
125 * Select to modify the queue's destination
127 #define DPSECI_QUEUE_OPT_DEST 0x00000002
130 * Select to modify the queue's order preservation
132 #define DPSECI_QUEUE_OPT_ORDER_PRESERVATION 0x00000004
135 * struct dpseci_rx_queue_cfg - DPSECI RX queue configuration
136 * @options: Flags representing the suggested modifications to the queue;
137 * Use any combination of 'DPSECI_QUEUE_OPT_<X>' flags
138 * @order_preservation_en: order preservation configuration for the rx queue
139 * valid only if 'DPSECI_QUEUE_OPT_ORDER_PRESERVATION' is contained in 'options'
140 * @user_ctx: User context value provided in the frame descriptor of each
141 * dequeued frame; valid only if 'DPSECI_QUEUE_OPT_USER_CTX' is contained
143 * @dest_cfg: Queue destination parameters; valid only if
144 * 'DPSECI_QUEUE_OPT_DEST' is contained in 'options'
146 struct dpseci_rx_queue_cfg
{
148 int order_preservation_en
;
150 struct dpseci_dest_cfg dest_cfg
;
153 int dpseci_set_rx_queue(struct fsl_mc_io
*mc_io
, u32 cmd_flags
, u16 token
,
154 u8 queue
, const struct dpseci_rx_queue_cfg
*cfg
);
157 * struct dpseci_rx_queue_attr - Structure representing attributes of Rx queues
158 * @user_ctx: User context value provided in the frame descriptor of each
160 * @order_preservation_en: Status of the order preservation configuration on the
162 * @dest_cfg: Queue destination configuration
163 * @fqid: Virtual FQID value to be used for dequeue operations
165 struct dpseci_rx_queue_attr
{
167 int order_preservation_en
;
168 struct dpseci_dest_cfg dest_cfg
;
172 int dpseci_get_rx_queue(struct fsl_mc_io
*mc_io
, u32 cmd_flags
, u16 token
,
173 u8 queue
, struct dpseci_rx_queue_attr
*attr
);
176 * struct dpseci_tx_queue_attr - Structure representing attributes of Tx queues
177 * @fqid: Virtual FQID to be used for sending frames to SEC hardware
178 * @priority: SEC hardware processing priority for the queue
180 struct dpseci_tx_queue_attr
{
185 int dpseci_get_tx_queue(struct fsl_mc_io
*mc_io
, u32 cmd_flags
, u16 token
,
186 u8 queue
, struct dpseci_tx_queue_attr
*attr
);
189 * struct dpseci_sec_attr - Structure representing attributes of the SEC
190 * hardware accelerator
192 * @major_rev: Major revision number for SEC
193 * @minor_rev: Minor revision number for SEC
195 * @deco_num: The number of copies of the DECO that are implemented in this
197 * @zuc_auth_acc_num: The number of copies of ZUCA that are implemented in this
199 * @zuc_enc_acc_num: The number of copies of ZUCE that are implemented in this
201 * @snow_f8_acc_num: The number of copies of the SNOW-f8 module that are
202 * implemented in this version of SEC
203 * @snow_f9_acc_num: The number of copies of the SNOW-f9 module that are
204 * implemented in this version of SEC
205 * @crc_acc_num: The number of copies of the CRC module that are implemented in
206 * this version of SEC
207 * @pk_acc_num: The number of copies of the Public Key module that are
208 * implemented in this version of SEC
209 * @kasumi_acc_num: The number of copies of the Kasumi module that are
210 * implemented in this version of SEC
211 * @rng_acc_num: The number of copies of the Random Number Generator that are
212 * implemented in this version of SEC
213 * @md_acc_num: The number of copies of the MDHA (Hashing module) that are
214 * implemented in this version of SEC
215 * @arc4_acc_num: The number of copies of the ARC4 module that are implemented
216 * in this version of SEC
217 * @des_acc_num: The number of copies of the DES module that are implemented in
218 * this version of SEC
219 * @aes_acc_num: The number of copies of the AES module that are implemented in
220 * this version of SEC
221 * @ccha_acc_num: The number of copies of the ChaCha20 module that are
222 * implemented in this version of SEC.
223 * @ptha_acc_num: The number of copies of the Poly1305 module that are
224 * implemented in this version of SEC.
226 struct dpseci_sec_attr
{
248 int dpseci_get_sec_attr(struct fsl_mc_io
*mc_io
, u32 cmd_flags
, u16 token
,
249 struct dpseci_sec_attr
*attr
);
251 int dpseci_get_api_version(struct fsl_mc_io
*mc_io
, u32 cmd_flags
,
252 u16
*major_ver
, u16
*minor_ver
);
255 * enum dpseci_congestion_unit - DPSECI congestion units
256 * @DPSECI_CONGESTION_UNIT_BYTES: bytes units
257 * @DPSECI_CONGESTION_UNIT_FRAMES: frames units
259 enum dpseci_congestion_unit
{
260 DPSECI_CONGESTION_UNIT_BYTES
= 0,
261 DPSECI_CONGESTION_UNIT_FRAMES
265 * CSCN message is written to message_iova once entering a
266 * congestion state (see 'threshold_entry')
268 #define DPSECI_CGN_MODE_WRITE_MEM_ON_ENTER 0x00000001
271 * CSCN message is written to message_iova once exiting a
272 * congestion state (see 'threshold_exit')
274 #define DPSECI_CGN_MODE_WRITE_MEM_ON_EXIT 0x00000002
277 * CSCN write will attempt to allocate into a cache (coherent write);
278 * valid only if 'DPSECI_CGN_MODE_WRITE_MEM_<X>' is selected
280 #define DPSECI_CGN_MODE_COHERENT_WRITE 0x00000004
283 * if 'dpseci_dest_cfg.dest_type != DPSECI_DEST_NONE' CSCN message is sent to
284 * DPIO/DPCON's WQ channel once entering a congestion state
285 * (see 'threshold_entry')
287 #define DPSECI_CGN_MODE_NOTIFY_DEST_ON_ENTER 0x00000008
290 * if 'dpseci_dest_cfg.dest_type != DPSECI_DEST_NONE' CSCN message is sent to
291 * DPIO/DPCON's WQ channel once exiting a congestion state
292 * (see 'threshold_exit')
294 #define DPSECI_CGN_MODE_NOTIFY_DEST_ON_EXIT 0x00000010
297 * if 'dpseci_dest_cfg.dest_type != DPSECI_DEST_NONE' when the CSCN is written
298 * to the sw-portal's DQRR, the DQRI interrupt is asserted immediately
301 #define DPSECI_CGN_MODE_INTR_COALESCING_DISABLED 0x00000020
304 * struct dpseci_congestion_notification_cfg - congestion notification
307 * @threshold_entry: above this threshold we enter a congestion state.
308 * set it to '0' to disable it
309 * @threshold_exit: below this threshold we exit the congestion state.
310 * @message_ctx: The context that will be part of the CSCN message
311 * @message_iova: I/O virtual address (must be in DMA-able memory),
312 * must be 16B aligned;
313 * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel
314 * @notification_mode: Mask of available options; use 'DPSECI_CGN_MODE_<X>'
317 struct dpseci_congestion_notification_cfg
{
318 enum dpseci_congestion_unit units
;
323 struct dpseci_dest_cfg dest_cfg
;
324 u16 notification_mode
;
327 int dpseci_set_congestion_notification(struct fsl_mc_io
*mc_io
, u32 cmd_flags
,
328 u16 token
, const struct dpseci_congestion_notification_cfg
*cfg
);
330 int dpseci_get_congestion_notification(struct fsl_mc_io
*mc_io
, u32 cmd_flags
,
331 u16 token
, struct dpseci_congestion_notification_cfg
*cfg
);
333 #endif /* _DPSECI_H_ */