/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */1/*2* Copyright 2013-2016 Freescale Semiconductor Inc.3* Copyright 2017-2018 NXP4*/5#ifndef _DPSECI_H_6#define _DPSECI_H_78/*9* Data Path SEC Interface API10* Contains initialization APIs and runtime control APIs for DPSECI11*/1213struct fsl_mc_io;1415/**16* General DPSECI macros17*/1819/**20* Maximum number of Tx/Rx queues per DPSECI object21*/22#define DPSECI_MAX_QUEUE_NUM 162324/**25* All queues considered; see dpseci_set_rx_queue()26*/27#define DPSECI_ALL_QUEUES (u8)(-1)2829int dpseci_open(struct fsl_mc_io *mc_io, u32 cmd_flags, int dpseci_id,30u16 *token);3132int dpseci_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);3334/**35* Enable the Congestion Group support36*/37#define DPSECI_OPT_HAS_CG 0x0000203839/**40* struct dpseci_cfg - Structure representing DPSECI configuration41* @options: Any combination of the following flags:42* DPSECI_OPT_HAS_CG43* @num_tx_queues: num of queues towards the SEC44* @num_rx_queues: num of queues back from the SEC45* @priorities: Priorities for the SEC hardware processing;46* each place in the array is the priority of the tx queue47* towards the SEC;48* valid priorities are configured with values 1-8;49*/50struct dpseci_cfg {51u32 options;52u8 num_tx_queues;53u8 num_rx_queues;54u8 priorities[DPSECI_MAX_QUEUE_NUM];55};5657int dpseci_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);5859int dpseci_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);6061int dpseci_reset(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);6263int dpseci_is_enabled(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,64int *en);6566/**67* struct dpseci_attr - Structure representing DPSECI attributes68* @id: DPSECI object ID69* @num_tx_queues: number of queues towards the SEC70* @num_rx_queues: number of queues back from the SEC71* @options: any combination of the following flags:72* DPSECI_OPT_HAS_CG73*/74struct dpseci_attr {75int id;76u8 num_tx_queues;77u8 num_rx_queues;78u32 options;79};8081int dpseci_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,82struct dpseci_attr *attr);8384/**85* enum dpseci_dest - DPSECI destination types86* @DPSECI_DEST_NONE: Unassigned destination; The queue is set in parked mode87* and does not generate FQDAN notifications; user is expected to dequeue88* from the queue based on polling or other user-defined method89* @DPSECI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN90* notifications to the specified DPIO; user is expected to dequeue from91* the queue only after notification is received92* @DPSECI_DEST_DPCON: The queue is set in schedule mode and does not generate93* FQDAN notifications, but is connected to the specified DPCON object;94* user is expected to dequeue from the DPCON channel95*/96enum dpseci_dest {97DPSECI_DEST_NONE = 0,98DPSECI_DEST_DPIO,99DPSECI_DEST_DPCON100};101102/**103* struct dpseci_dest_cfg - Structure representing DPSECI destination parameters104* @dest_type: Destination type105* @dest_id: Either DPIO ID or DPCON ID, depending on the destination type106* @priority: Priority selection within the DPIO or DPCON channel; valid values107* are 0-1 or 0-7, depending on the number of priorities in that channel;108* not relevant for 'DPSECI_DEST_NONE' option109*/110struct dpseci_dest_cfg {111enum dpseci_dest dest_type;112int dest_id;113u8 priority;114};115116/**117* DPSECI queue modification options118*/119120/**121* Select to modify the user's context associated with the queue122*/123#define DPSECI_QUEUE_OPT_USER_CTX 0x00000001124125/**126* Select to modify the queue's destination127*/128#define DPSECI_QUEUE_OPT_DEST 0x00000002129130/**131* Select to modify the queue's order preservation132*/133#define DPSECI_QUEUE_OPT_ORDER_PRESERVATION 0x00000004134135/**136* struct dpseci_rx_queue_cfg - DPSECI RX queue configuration137* @options: Flags representing the suggested modifications to the queue;138* Use any combination of 'DPSECI_QUEUE_OPT_<X>' flags139* @order_preservation_en: order preservation configuration for the rx queue140* valid only if 'DPSECI_QUEUE_OPT_ORDER_PRESERVATION' is contained in 'options'141* @user_ctx: User context value provided in the frame descriptor of each142* dequeued frame; valid only if 'DPSECI_QUEUE_OPT_USER_CTX' is contained143* in 'options'144* @dest_cfg: Queue destination parameters; valid only if145* 'DPSECI_QUEUE_OPT_DEST' is contained in 'options'146*/147struct dpseci_rx_queue_cfg {148u32 options;149int order_preservation_en;150u64 user_ctx;151struct dpseci_dest_cfg dest_cfg;152};153154int dpseci_set_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,155u8 queue, const struct dpseci_rx_queue_cfg *cfg);156157/**158* struct dpseci_rx_queue_attr - Structure representing attributes of Rx queues159* @user_ctx: User context value provided in the frame descriptor of each160* dequeued frame161* @order_preservation_en: Status of the order preservation configuration on the162* queue163* @dest_cfg: Queue destination configuration164* @fqid: Virtual FQID value to be used for dequeue operations165*/166struct dpseci_rx_queue_attr {167u64 user_ctx;168int order_preservation_en;169struct dpseci_dest_cfg dest_cfg;170u32 fqid;171};172173int dpseci_get_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,174u8 queue, struct dpseci_rx_queue_attr *attr);175176/**177* struct dpseci_tx_queue_attr - Structure representing attributes of Tx queues178* @fqid: Virtual FQID to be used for sending frames to SEC hardware179* @priority: SEC hardware processing priority for the queue180*/181struct dpseci_tx_queue_attr {182u32 fqid;183u8 priority;184};185186int dpseci_get_tx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,187u8 queue, struct dpseci_tx_queue_attr *attr);188189/**190* struct dpseci_sec_attr - Structure representing attributes of the SEC191* hardware accelerator192* @ip_id: ID for SEC193* @major_rev: Major revision number for SEC194* @minor_rev: Minor revision number for SEC195* @era: SEC Era196* @deco_num: The number of copies of the DECO that are implemented in this197* version of SEC198* @zuc_auth_acc_num: The number of copies of ZUCA that are implemented in this199* version of SEC200* @zuc_enc_acc_num: The number of copies of ZUCE that are implemented in this201* version of SEC202* @snow_f8_acc_num: The number of copies of the SNOW-f8 module that are203* implemented in this version of SEC204* @snow_f9_acc_num: The number of copies of the SNOW-f9 module that are205* implemented in this version of SEC206* @crc_acc_num: The number of copies of the CRC module that are implemented in207* this version of SEC208* @pk_acc_num: The number of copies of the Public Key module that are209* implemented in this version of SEC210* @kasumi_acc_num: The number of copies of the Kasumi module that are211* implemented in this version of SEC212* @rng_acc_num: The number of copies of the Random Number Generator that are213* implemented in this version of SEC214* @md_acc_num: The number of copies of the MDHA (Hashing module) that are215* implemented in this version of SEC216* @arc4_acc_num: The number of copies of the ARC4 module that are implemented217* in this version of SEC218* @des_acc_num: The number of copies of the DES module that are implemented in219* this version of SEC220* @aes_acc_num: The number of copies of the AES module that are implemented in221* this version of SEC222* @ccha_acc_num: The number of copies of the ChaCha20 module that are223* implemented in this version of SEC.224* @ptha_acc_num: The number of copies of the Poly1305 module that are225* implemented in this version of SEC.226**/227struct dpseci_sec_attr {228u16 ip_id;229u8 major_rev;230u8 minor_rev;231u8 era;232u8 deco_num;233u8 zuc_auth_acc_num;234u8 zuc_enc_acc_num;235u8 snow_f8_acc_num;236u8 snow_f9_acc_num;237u8 crc_acc_num;238u8 pk_acc_num;239u8 kasumi_acc_num;240u8 rng_acc_num;241u8 md_acc_num;242u8 arc4_acc_num;243u8 des_acc_num;244u8 aes_acc_num;245u8 ccha_acc_num;246u8 ptha_acc_num;247};248249int dpseci_get_sec_attr(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,250struct dpseci_sec_attr *attr);251252int dpseci_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags,253u16 *major_ver, u16 *minor_ver);254255/**256* enum dpseci_congestion_unit - DPSECI congestion units257* @DPSECI_CONGESTION_UNIT_BYTES: bytes units258* @DPSECI_CONGESTION_UNIT_FRAMES: frames units259*/260enum dpseci_congestion_unit {261DPSECI_CONGESTION_UNIT_BYTES = 0,262DPSECI_CONGESTION_UNIT_FRAMES263};264265/**266* CSCN message is written to message_iova once entering a267* congestion state (see 'threshold_entry')268*/269#define DPSECI_CGN_MODE_WRITE_MEM_ON_ENTER 0x00000001270271/**272* CSCN message is written to message_iova once exiting a273* congestion state (see 'threshold_exit')274*/275#define DPSECI_CGN_MODE_WRITE_MEM_ON_EXIT 0x00000002276277/**278* CSCN write will attempt to allocate into a cache (coherent write);279* valid only if 'DPSECI_CGN_MODE_WRITE_MEM_<X>' is selected280*/281#define DPSECI_CGN_MODE_COHERENT_WRITE 0x00000004282283/**284* if 'dpseci_dest_cfg.dest_type != DPSECI_DEST_NONE' CSCN message is sent to285* DPIO/DPCON's WQ channel once entering a congestion state286* (see 'threshold_entry')287*/288#define DPSECI_CGN_MODE_NOTIFY_DEST_ON_ENTER 0x00000008289290/**291* if 'dpseci_dest_cfg.dest_type != DPSECI_DEST_NONE' CSCN message is sent to292* DPIO/DPCON's WQ channel once exiting a congestion state293* (see 'threshold_exit')294*/295#define DPSECI_CGN_MODE_NOTIFY_DEST_ON_EXIT 0x00000010296297/**298* if 'dpseci_dest_cfg.dest_type != DPSECI_DEST_NONE' when the CSCN is written299* to the sw-portal's DQRR, the DQRI interrupt is asserted immediately300* (if enabled)301*/302#define DPSECI_CGN_MODE_INTR_COALESCING_DISABLED 0x00000020303304/**305* struct dpseci_congestion_notification_cfg - congestion notification306* configuration307* @units: units type308* @threshold_entry: above this threshold we enter a congestion state.309* set it to '0' to disable it310* @threshold_exit: below this threshold we exit the congestion state.311* @message_ctx: The context that will be part of the CSCN message312* @message_iova: I/O virtual address (must be in DMA-able memory),313* must be 16B aligned;314* @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel315* @notification_mode: Mask of available options; use 'DPSECI_CGN_MODE_<X>'316* values317*/318struct dpseci_congestion_notification_cfg {319enum dpseci_congestion_unit units;320u32 threshold_entry;321u32 threshold_exit;322u64 message_ctx;323u64 message_iova;324struct dpseci_dest_cfg dest_cfg;325u16 notification_mode;326};327328int dpseci_set_congestion_notification(struct fsl_mc_io *mc_io, u32 cmd_flags,329u16 token, const struct dpseci_congestion_notification_cfg *cfg);330331int dpseci_get_congestion_notification(struct fsl_mc_io *mc_io, u32 cmd_flags,332u16 token, struct dpseci_congestion_notification_cfg *cfg);333334#endif /* _DPSECI_H_ */335336337