Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* Copyright 2019 NXP */
0003 
0004 #ifndef __FSL_DPDMAI_H
0005 #define __FSL_DPDMAI_H
0006 
0007 /* DPDMAI Version */
0008 #define DPDMAI_VER_MAJOR    2
0009 #define DPDMAI_VER_MINOR    2
0010 
0011 #define DPDMAI_CMD_BASE_VERSION 0
0012 #define DPDMAI_CMD_ID_OFFSET    4
0013 
0014 #define DPDMAI_CMDID_FORMAT(x)  (((x) << DPDMAI_CMD_ID_OFFSET) | \
0015                 DPDMAI_CMD_BASE_VERSION)
0016 
0017 /* Command IDs */
0018 #define DPDMAI_CMDID_CLOSE      DPDMAI_CMDID_FORMAT(0x800)
0019 #define DPDMAI_CMDID_OPEN               DPDMAI_CMDID_FORMAT(0x80E)
0020 #define DPDMAI_CMDID_CREATE             DPDMAI_CMDID_FORMAT(0x90E)
0021 #define DPDMAI_CMDID_DESTROY            DPDMAI_CMDID_FORMAT(0x900)
0022 
0023 #define DPDMAI_CMDID_ENABLE             DPDMAI_CMDID_FORMAT(0x002)
0024 #define DPDMAI_CMDID_DISABLE            DPDMAI_CMDID_FORMAT(0x003)
0025 #define DPDMAI_CMDID_GET_ATTR           DPDMAI_CMDID_FORMAT(0x004)
0026 #define DPDMAI_CMDID_RESET              DPDMAI_CMDID_FORMAT(0x005)
0027 #define DPDMAI_CMDID_IS_ENABLED         DPDMAI_CMDID_FORMAT(0x006)
0028 
0029 #define DPDMAI_CMDID_SET_IRQ            DPDMAI_CMDID_FORMAT(0x010)
0030 #define DPDMAI_CMDID_GET_IRQ            DPDMAI_CMDID_FORMAT(0x011)
0031 #define DPDMAI_CMDID_SET_IRQ_ENABLE     DPDMAI_CMDID_FORMAT(0x012)
0032 #define DPDMAI_CMDID_GET_IRQ_ENABLE     DPDMAI_CMDID_FORMAT(0x013)
0033 #define DPDMAI_CMDID_SET_IRQ_MASK       DPDMAI_CMDID_FORMAT(0x014)
0034 #define DPDMAI_CMDID_GET_IRQ_MASK       DPDMAI_CMDID_FORMAT(0x015)
0035 #define DPDMAI_CMDID_GET_IRQ_STATUS     DPDMAI_CMDID_FORMAT(0x016)
0036 #define DPDMAI_CMDID_CLEAR_IRQ_STATUS   DPDMAI_CMDID_FORMAT(0x017)
0037 
0038 #define DPDMAI_CMDID_SET_RX_QUEUE   DPDMAI_CMDID_FORMAT(0x1A0)
0039 #define DPDMAI_CMDID_GET_RX_QUEUE       DPDMAI_CMDID_FORMAT(0x1A1)
0040 #define DPDMAI_CMDID_GET_TX_QUEUE       DPDMAI_CMDID_FORMAT(0x1A2)
0041 
0042 #define MC_CMD_HDR_TOKEN_O 32  /* Token field offset */
0043 #define MC_CMD_HDR_TOKEN_S 16  /* Token field size */
0044 
0045 #define MAKE_UMASK64(_width) \
0046     ((u64)((_width) < 64 ? ((u64)1 << (_width)) - 1 : (u64)-1))
0047 
0048 /* Data Path DMA Interface API
0049  * Contains initialization APIs and runtime control APIs for DPDMAI
0050  */
0051 
0052 /**
0053  * Maximum number of Tx/Rx priorities per DPDMAI object
0054  */
0055 #define DPDMAI_PRIO_NUM     2
0056 
0057 /* DPDMAI queue modification options */
0058 
0059 /**
0060  * Select to modify the user's context associated with the queue
0061  */
0062 #define DPDMAI_QUEUE_OPT_USER_CTX   0x1
0063 
0064 /**
0065  * Select to modify the queue's destination
0066  */
0067 #define DPDMAI_QUEUE_OPT_DEST       0x2
0068 
0069 /**
0070  * struct dpdmai_cfg - Structure representing DPDMAI configuration
0071  * @priorities: Priorities for the DMA hardware processing; valid priorities are
0072  *  configured with values 1-8; the entry following last valid entry
0073  *  should be configured with 0
0074  */
0075 struct dpdmai_cfg {
0076     u8 priorities[DPDMAI_PRIO_NUM];
0077 };
0078 
0079 /**
0080  * struct dpdmai_attr - Structure representing DPDMAI attributes
0081  * @id: DPDMAI object ID
0082  * @version: DPDMAI version
0083  * @num_of_priorities: number of priorities
0084  */
0085 struct dpdmai_attr {
0086     int id;
0087     /**
0088      * struct version - DPDMAI version
0089      * @major: DPDMAI major version
0090      * @minor: DPDMAI minor version
0091      */
0092     struct {
0093         u16 major;
0094         u16 minor;
0095     } version;
0096     u8 num_of_priorities;
0097 };
0098 
0099 /**
0100  * enum dpdmai_dest - DPDMAI destination types
0101  * @DPDMAI_DEST_NONE: Unassigned destination; The queue is set in parked mode
0102  *  and does not generate FQDAN notifications; user is expected to dequeue
0103  *  from the queue based on polling or other user-defined method
0104  * @DPDMAI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
0105  *  notifications to the specified DPIO; user is expected to dequeue
0106  *  from the queue only after notification is received
0107  * @DPDMAI_DEST_DPCON: The queue is set in schedule mode and does not generate
0108  *  FQDAN notifications, but is connected to the specified DPCON object;
0109  *  user is expected to dequeue from the DPCON channel
0110  */
0111 enum dpdmai_dest {
0112     DPDMAI_DEST_NONE = 0,
0113     DPDMAI_DEST_DPIO = 1,
0114     DPDMAI_DEST_DPCON = 2
0115 };
0116 
0117 /**
0118  * struct dpdmai_dest_cfg - Structure representing DPDMAI destination parameters
0119  * @dest_type: Destination type
0120  * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
0121  * @priority: Priority selection within the DPIO or DPCON channel; valid values
0122  *  are 0-1 or 0-7, depending on the number of priorities in that
0123  *  channel; not relevant for 'DPDMAI_DEST_NONE' option
0124  */
0125 struct dpdmai_dest_cfg {
0126     enum dpdmai_dest dest_type;
0127     int dest_id;
0128     u8 priority;
0129 };
0130 
0131 /**
0132  * struct dpdmai_rx_queue_cfg - DPDMAI RX queue configuration
0133  * @options: Flags representing the suggested modifications to the queue;
0134  *  Use any combination of 'DPDMAI_QUEUE_OPT_<X>' flags
0135  * @user_ctx: User context value provided in the frame descriptor of each
0136  *  dequeued frame;
0137  *  valid only if 'DPDMAI_QUEUE_OPT_USER_CTX' is contained in 'options'
0138  * @dest_cfg: Queue destination parameters;
0139  *  valid only if 'DPDMAI_QUEUE_OPT_DEST' is contained in 'options'
0140  */
0141 struct dpdmai_rx_queue_cfg {
0142     struct dpdmai_dest_cfg dest_cfg;
0143     u32 options;
0144     u64 user_ctx;
0145 
0146 };
0147 
0148 /**
0149  * struct dpdmai_rx_queue_attr - Structure representing attributes of Rx queues
0150  * @user_ctx:  User context value provided in the frame descriptor of each
0151  *   dequeued frame
0152  * @dest_cfg: Queue destination configuration
0153  * @fqid: Virtual FQID value to be used for dequeue operations
0154  */
0155 struct dpdmai_rx_queue_attr {
0156     struct dpdmai_dest_cfg  dest_cfg;
0157     u64 user_ctx;
0158     u32 fqid;
0159 };
0160 
0161 int dpdmai_open(struct fsl_mc_io *mc_io, u32 cmd_flags,
0162         int dpdmai_id, u16 *token);
0163 int dpdmai_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
0164 int dpdmai_destroy(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
0165 int dpdmai_create(struct fsl_mc_io *mc_io, u32 cmd_flags,
0166           const struct dpdmai_cfg *cfg, u16 *token);
0167 int dpdmai_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
0168 int dpdmai_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
0169 int dpdmai_reset(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
0170 int dpdmai_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags,
0171               u16 token, struct dpdmai_attr *attr);
0172 int dpdmai_set_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0173             u8 priority, const struct dpdmai_rx_queue_cfg *cfg);
0174 int dpdmai_get_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0175             u8 priority, struct dpdmai_rx_queue_attr *attr);
0176 int dpdmai_get_tx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags,
0177             u16 token, u8 priority, u32 *fqid);
0178 
0179 #endif /* __FSL_DPDMAI_H */