Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
0002 /*
0003  * Copyright 2013-2016 Freescale Semiconductor Inc.
0004  * Copyright 2017-2018 NXP
0005  */
0006 #ifndef _DPSECI_H_
0007 #define _DPSECI_H_
0008 
0009 /*
0010  * Data Path SEC Interface API
0011  * Contains initialization APIs and runtime control APIs for DPSECI
0012  */
0013 
0014 struct fsl_mc_io;
0015 
0016 /**
0017  * General DPSECI macros
0018  */
0019 
0020 /**
0021  * Maximum number of Tx/Rx queues per DPSECI object
0022  */
0023 #define DPSECI_MAX_QUEUE_NUM        16
0024 
0025 /**
0026  * All queues considered; see dpseci_set_rx_queue()
0027  */
0028 #define DPSECI_ALL_QUEUES   (u8)(-1)
0029 
0030 int dpseci_open(struct fsl_mc_io *mc_io, u32 cmd_flags, int dpseci_id,
0031         u16 *token);
0032 
0033 int dpseci_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
0034 
0035 /**
0036  * Enable the Congestion Group support
0037  */
0038 #define DPSECI_OPT_HAS_CG       0x000020
0039 
0040 /**
0041  * struct dpseci_cfg - Structure representing DPSECI configuration
0042  * @options: Any combination of the following flags:
0043  *      DPSECI_OPT_HAS_CG
0044  * @num_tx_queues: num of queues towards the SEC
0045  * @num_rx_queues: num of queues back from the SEC
0046  * @priorities: Priorities for the SEC hardware processing;
0047  *      each place in the array is the priority of the tx queue
0048  *      towards the SEC;
0049  *      valid priorities are configured with values 1-8;
0050  */
0051 struct dpseci_cfg {
0052     u32 options;
0053     u8 num_tx_queues;
0054     u8 num_rx_queues;
0055     u8 priorities[DPSECI_MAX_QUEUE_NUM];
0056 };
0057 
0058 int dpseci_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
0059 
0060 int dpseci_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
0061 
0062 int dpseci_reset(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
0063 
0064 int dpseci_is_enabled(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0065               int *en);
0066 
0067 /**
0068  * struct dpseci_attr - Structure representing DPSECI attributes
0069  * @id: DPSECI object ID
0070  * @num_tx_queues: number of queues towards the SEC
0071  * @num_rx_queues: number of queues back from the SEC
0072  * @options: any combination of the following flags:
0073  *      DPSECI_OPT_HAS_CG
0074  */
0075 struct dpseci_attr {
0076     int id;
0077     u8 num_tx_queues;
0078     u8 num_rx_queues;
0079     u32 options;
0080 };
0081 
0082 int dpseci_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0083               struct dpseci_attr *attr);
0084 
0085 /**
0086  * enum dpseci_dest - DPSECI destination types
0087  * @DPSECI_DEST_NONE: Unassigned destination; The queue is set in parked mode
0088  *  and does not generate FQDAN notifications; user is expected to dequeue
0089  *  from the queue based on polling or other user-defined method
0090  * @DPSECI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
0091  *  notifications to the specified DPIO; user is expected to dequeue from
0092  *  the queue only after notification is received
0093  * @DPSECI_DEST_DPCON: The queue is set in schedule mode and does not generate
0094  *  FQDAN notifications, but is connected to the specified DPCON object;
0095  *  user is expected to dequeue from the DPCON channel
0096  */
0097 enum dpseci_dest {
0098     DPSECI_DEST_NONE = 0,
0099     DPSECI_DEST_DPIO,
0100     DPSECI_DEST_DPCON
0101 };
0102 
0103 /**
0104  * struct dpseci_dest_cfg - Structure representing DPSECI destination parameters
0105  * @dest_type: Destination type
0106  * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
0107  * @priority: Priority selection within the DPIO or DPCON channel; valid values
0108  *  are 0-1 or 0-7, depending on the number of priorities in that channel;
0109  *  not relevant for 'DPSECI_DEST_NONE' option
0110  */
0111 struct dpseci_dest_cfg {
0112     enum dpseci_dest dest_type;
0113     int dest_id;
0114     u8 priority;
0115 };
0116 
0117 /**
0118  * DPSECI queue modification options
0119  */
0120 
0121 /**
0122  * Select to modify the user's context associated with the queue
0123  */
0124 #define DPSECI_QUEUE_OPT_USER_CTX       0x00000001
0125 
0126 /**
0127  * Select to modify the queue's destination
0128  */
0129 #define DPSECI_QUEUE_OPT_DEST           0x00000002
0130 
0131 /**
0132  * Select to modify the queue's order preservation
0133  */
0134 #define DPSECI_QUEUE_OPT_ORDER_PRESERVATION 0x00000004
0135 
0136 /**
0137  * struct dpseci_rx_queue_cfg - DPSECI RX queue configuration
0138  * @options: Flags representing the suggested modifications to the queue;
0139  *  Use any combination of 'DPSECI_QUEUE_OPT_<X>' flags
0140  * @order_preservation_en: order preservation configuration for the rx queue
0141  * valid only if 'DPSECI_QUEUE_OPT_ORDER_PRESERVATION' is contained in 'options'
0142  * @user_ctx: User context value provided in the frame descriptor of each
0143  *  dequeued frame; valid only if 'DPSECI_QUEUE_OPT_USER_CTX' is contained
0144  *  in 'options'
0145  * @dest_cfg: Queue destination parameters; valid only if
0146  *  'DPSECI_QUEUE_OPT_DEST' is contained in 'options'
0147  */
0148 struct dpseci_rx_queue_cfg {
0149     u32 options;
0150     int order_preservation_en;
0151     u64 user_ctx;
0152     struct dpseci_dest_cfg dest_cfg;
0153 };
0154 
0155 int dpseci_set_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0156             u8 queue, const struct dpseci_rx_queue_cfg *cfg);
0157 
0158 /**
0159  * struct dpseci_rx_queue_attr - Structure representing attributes of Rx queues
0160  * @user_ctx: User context value provided in the frame descriptor of each
0161  *  dequeued frame
0162  * @order_preservation_en: Status of the order preservation configuration on the
0163  *  queue
0164  * @dest_cfg: Queue destination configuration
0165  * @fqid: Virtual FQID value to be used for dequeue operations
0166  */
0167 struct dpseci_rx_queue_attr {
0168     u64 user_ctx;
0169     int order_preservation_en;
0170     struct dpseci_dest_cfg dest_cfg;
0171     u32 fqid;
0172 };
0173 
0174 int dpseci_get_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0175             u8 queue, struct dpseci_rx_queue_attr *attr);
0176 
0177 /**
0178  * struct dpseci_tx_queue_attr - Structure representing attributes of Tx queues
0179  * @fqid: Virtual FQID to be used for sending frames to SEC hardware
0180  * @priority: SEC hardware processing priority for the queue
0181  */
0182 struct dpseci_tx_queue_attr {
0183     u32 fqid;
0184     u8 priority;
0185 };
0186 
0187 int dpseci_get_tx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0188             u8 queue, struct dpseci_tx_queue_attr *attr);
0189 
0190 /**
0191  * struct dpseci_sec_attr - Structure representing attributes of the SEC
0192  *  hardware accelerator
0193  * @ip_id: ID for SEC
0194  * @major_rev: Major revision number for SEC
0195  * @minor_rev: Minor revision number for SEC
0196  * @era: SEC Era
0197  * @deco_num: The number of copies of the DECO that are implemented in this
0198  *  version of SEC
0199  * @zuc_auth_acc_num: The number of copies of ZUCA that are implemented in this
0200  *  version of SEC
0201  * @zuc_enc_acc_num: The number of copies of ZUCE that are implemented in this
0202  *  version of SEC
0203  * @snow_f8_acc_num: The number of copies of the SNOW-f8 module that are
0204  *  implemented in this version of SEC
0205  * @snow_f9_acc_num: The number of copies of the SNOW-f9 module that are
0206  *  implemented in this version of SEC
0207  * @crc_acc_num: The number of copies of the CRC module that are implemented in
0208  *  this version of SEC
0209  * @pk_acc_num:  The number of copies of the Public Key module that are
0210  *  implemented in this version of SEC
0211  * @kasumi_acc_num: The number of copies of the Kasumi module that are
0212  *  implemented in this version of SEC
0213  * @rng_acc_num: The number of copies of the Random Number Generator that are
0214  *  implemented in this version of SEC
0215  * @md_acc_num: The number of copies of the MDHA (Hashing module) that are
0216  *  implemented in this version of SEC
0217  * @arc4_acc_num: The number of copies of the ARC4 module that are implemented
0218  *  in this version of SEC
0219  * @des_acc_num: The number of copies of the DES module that are implemented in
0220  *  this version of SEC
0221  * @aes_acc_num: The number of copies of the AES module that are implemented in
0222  *  this version of SEC
0223  * @ccha_acc_num: The number of copies of the ChaCha20 module that are
0224  *  implemented in this version of SEC.
0225  * @ptha_acc_num: The number of copies of the Poly1305 module that are
0226  *  implemented in this version of SEC.
0227  **/
0228 struct dpseci_sec_attr {
0229     u16 ip_id;
0230     u8 major_rev;
0231     u8 minor_rev;
0232     u8 era;
0233     u8 deco_num;
0234     u8 zuc_auth_acc_num;
0235     u8 zuc_enc_acc_num;
0236     u8 snow_f8_acc_num;
0237     u8 snow_f9_acc_num;
0238     u8 crc_acc_num;
0239     u8 pk_acc_num;
0240     u8 kasumi_acc_num;
0241     u8 rng_acc_num;
0242     u8 md_acc_num;
0243     u8 arc4_acc_num;
0244     u8 des_acc_num;
0245     u8 aes_acc_num;
0246     u8 ccha_acc_num;
0247     u8 ptha_acc_num;
0248 };
0249 
0250 int dpseci_get_sec_attr(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0251             struct dpseci_sec_attr *attr);
0252 
0253 int dpseci_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags,
0254                u16 *major_ver, u16 *minor_ver);
0255 
0256 /**
0257  * enum dpseci_congestion_unit - DPSECI congestion units
0258  * @DPSECI_CONGESTION_UNIT_BYTES: bytes units
0259  * @DPSECI_CONGESTION_UNIT_FRAMES: frames units
0260  */
0261 enum dpseci_congestion_unit {
0262     DPSECI_CONGESTION_UNIT_BYTES = 0,
0263     DPSECI_CONGESTION_UNIT_FRAMES
0264 };
0265 
0266 /**
0267  * CSCN message is written to message_iova once entering a
0268  * congestion state (see 'threshold_entry')
0269  */
0270 #define DPSECI_CGN_MODE_WRITE_MEM_ON_ENTER      0x00000001
0271 
0272 /**
0273  * CSCN message is written to message_iova once exiting a
0274  * congestion state (see 'threshold_exit')
0275  */
0276 #define DPSECI_CGN_MODE_WRITE_MEM_ON_EXIT       0x00000002
0277 
0278 /**
0279  * CSCN write will attempt to allocate into a cache (coherent write);
0280  * valid only if 'DPSECI_CGN_MODE_WRITE_MEM_<X>' is selected
0281  */
0282 #define DPSECI_CGN_MODE_COHERENT_WRITE          0x00000004
0283 
0284 /**
0285  * if 'dpseci_dest_cfg.dest_type != DPSECI_DEST_NONE' CSCN message is sent to
0286  * DPIO/DPCON's WQ channel once entering a congestion state
0287  * (see 'threshold_entry')
0288  */
0289 #define DPSECI_CGN_MODE_NOTIFY_DEST_ON_ENTER        0x00000008
0290 
0291 /**
0292  * if 'dpseci_dest_cfg.dest_type != DPSECI_DEST_NONE' CSCN message is sent to
0293  * DPIO/DPCON's WQ channel once exiting a congestion state
0294  * (see 'threshold_exit')
0295  */
0296 #define DPSECI_CGN_MODE_NOTIFY_DEST_ON_EXIT     0x00000010
0297 
0298 /**
0299  * if 'dpseci_dest_cfg.dest_type != DPSECI_DEST_NONE' when the CSCN is written
0300  * to the sw-portal's DQRR, the DQRI interrupt is asserted immediately
0301  * (if enabled)
0302  */
0303 #define DPSECI_CGN_MODE_INTR_COALESCING_DISABLED    0x00000020
0304 
0305 /**
0306  * struct dpseci_congestion_notification_cfg - congestion notification
0307  *  configuration
0308  * @units: units type
0309  * @threshold_entry: above this threshold we enter a congestion state.
0310  *  set it to '0' to disable it
0311  * @threshold_exit: below this threshold we exit the congestion state.
0312  * @message_ctx: The context that will be part of the CSCN message
0313  * @message_iova: I/O virtual address (must be in DMA-able memory),
0314  *  must be 16B aligned;
0315  * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel
0316  * @notification_mode: Mask of available options; use 'DPSECI_CGN_MODE_<X>'
0317  *  values
0318  */
0319 struct dpseci_congestion_notification_cfg {
0320     enum dpseci_congestion_unit units;
0321     u32 threshold_entry;
0322     u32 threshold_exit;
0323     u64 message_ctx;
0324     u64 message_iova;
0325     struct dpseci_dest_cfg dest_cfg;
0326     u16 notification_mode;
0327 };
0328 
0329 int dpseci_set_congestion_notification(struct fsl_mc_io *mc_io, u32 cmd_flags,
0330     u16 token, const struct dpseci_congestion_notification_cfg *cfg);
0331 
0332 int dpseci_get_congestion_notification(struct fsl_mc_io *mc_io, u32 cmd_flags,
0333     u16 token, struct dpseci_congestion_notification_cfg *cfg);
0334 
0335 #endif /* _DPSECI_H_ */