/* SPDX-License-Identifier: GPL-2.0 */1/* Copyright 2019 NXP */23#ifndef __FSL_DPDMAI_H4#define __FSL_DPDMAI_H56/* DPDMAI Version */7#define DPDMAI_VER_MAJOR 38#define DPDMAI_VER_MINOR 3910#define DPDMAI_CMD_BASE_VERSION 111#define DPDMAI_CMD_ID_OFFSET 41213/*14* Maximum number of Tx/Rx queues per DPDMAI object15*/16#define DPDMAI_MAX_QUEUE_NUM 81718#define DPDMAI_CMDID_FORMAT_V(x, v) (((x) << DPDMAI_CMD_ID_OFFSET) | (v))19#define DPDMAI_CMDID_FORMAT(x) DPDMAI_CMDID_FORMAT_V(x, DPDMAI_CMD_BASE_VERSION)2021/* Command IDs */22#define DPDMAI_CMDID_CLOSE DPDMAI_CMDID_FORMAT(0x800)23#define DPDMAI_CMDID_OPEN DPDMAI_CMDID_FORMAT(0x80E)24#define DPDMAI_CMDID_CREATE DPDMAI_CMDID_FORMAT(0x90E)25#define DPDMAI_CMDID_DESTROY DPDMAI_CMDID_FORMAT(0x900)2627#define DPDMAI_CMDID_ENABLE DPDMAI_CMDID_FORMAT(0x002)28#define DPDMAI_CMDID_DISABLE DPDMAI_CMDID_FORMAT(0x003)29#define DPDMAI_CMDID_GET_ATTR DPDMAI_CMDID_FORMAT(0x004)30#define DPDMAI_CMDID_RESET DPDMAI_CMDID_FORMAT(0x005)31#define DPDMAI_CMDID_IS_ENABLED DPDMAI_CMDID_FORMAT(0x006)3233#define DPDMAI_CMDID_SET_RX_QUEUE DPDMAI_CMDID_FORMAT_V(0x1A0, 2)34#define DPDMAI_CMDID_GET_RX_QUEUE DPDMAI_CMDID_FORMAT_V(0x1A1, 2)35#define DPDMAI_CMDID_GET_TX_QUEUE DPDMAI_CMDID_FORMAT_V(0x1A2, 2)3637#define MC_CMD_HDR_TOKEN_O 32 /* Token field offset */38#define MC_CMD_HDR_TOKEN_S 16 /* Token field size */3940#define MAKE_UMASK64(_width) \41((u64)((_width) < 64 ? ((u64)1 << (_width)) - 1 : (u64)-1))4243/* Data Path DMA Interface API44* Contains initialization APIs and runtime control APIs for DPDMAI45*/4647/*48* Maximum number of Tx/Rx priorities per DPDMAI object49*/50#define DPDMAI_PRIO_NUM 25152/* DPDMAI queue modification options */5354/*55* Select to modify the user's context associated with the queue56*/57#define DPDMAI_QUEUE_OPT_USER_CTX 0x15859/*60* Select to modify the queue's destination61*/62#define DPDMAI_QUEUE_OPT_DEST 0x26364/**65* struct dpdmai_cfg - Structure representing DPDMAI configuration66* @num_queues: Number of the DMA queues67* @priorities: Priorities for the DMA hardware processing; valid priorities are68* configured with values 1-8; the entry following last valid entry69* should be configured with 070*/71struct dpdmai_cfg {72u8 num_queues;73u8 priorities[DPDMAI_PRIO_NUM];74};7576/**77* struct dpdmai_attr - Structure representing DPDMAI attributes78* @id: DPDMAI object ID79* @version: DPDMAI version80* @version.major: DPDMAI major version81* @version.minor: DPDMAI minor version82* @num_of_priorities: number of priorities83* @num_of_queues: number of the DMA queues84*/85struct dpdmai_attr {86int id;87struct {88u16 major;89u16 minor;90} version;91u8 num_of_priorities;92u8 num_of_queues;93};9495/**96* enum dpdmai_dest - DPDMAI destination types97* @DPDMAI_DEST_NONE: Unassigned destination; The queue is set in parked mode98* and does not generate FQDAN notifications; user is expected to dequeue99* from the queue based on polling or other user-defined method100* @DPDMAI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN101* notifications to the specified DPIO; user is expected to dequeue102* from the queue only after notification is received103* @DPDMAI_DEST_DPCON: The queue is set in schedule mode and does not generate104* FQDAN notifications, but is connected to the specified DPCON object;105* user is expected to dequeue from the DPCON channel106*/107enum dpdmai_dest {108DPDMAI_DEST_NONE = 0,109DPDMAI_DEST_DPIO = 1,110DPDMAI_DEST_DPCON = 2111};112113/**114* struct dpdmai_dest_cfg - Structure representing DPDMAI destination parameters115* @dest_type: Destination type116* @dest_id: Either DPIO ID or DPCON ID, depending on the destination type117* @priority: Priority selection within the DPIO or DPCON channel; valid values118* are 0-1 or 0-7, depending on the number of priorities in that119* channel; not relevant for 'DPDMAI_DEST_NONE' option120*/121struct dpdmai_dest_cfg {122enum dpdmai_dest dest_type;123int dest_id;124u8 priority;125};126127/**128* struct dpdmai_rx_queue_cfg - DPDMAI RX queue configuration129* @options: Flags representing the suggested modifications to the queue;130* Use any combination of 'DPDMAI_QUEUE_OPT_<X>' flags131* @user_ctx: User context value provided in the frame descriptor of each132* dequeued frame;133* valid only if 'DPDMAI_QUEUE_OPT_USER_CTX' is contained in 'options'134* @dest_cfg: Queue destination parameters;135* valid only if 'DPDMAI_QUEUE_OPT_DEST' is contained in 'options'136*/137struct dpdmai_rx_queue_cfg {138struct dpdmai_dest_cfg dest_cfg;139u32 options;140u64 user_ctx;141142};143144/**145* struct dpdmai_rx_queue_attr - Structure representing attributes of Rx queues146* @user_ctx: User context value provided in the frame descriptor of each147* dequeued frame148* @dest_cfg: Queue destination configuration149* @fqid: Virtual FQID value to be used for dequeue operations150*/151struct dpdmai_rx_queue_attr {152struct dpdmai_dest_cfg dest_cfg;153u64 user_ctx;154u32 fqid;155};156157struct dpdmai_tx_queue_attr {158u32 fqid;159};160161int dpdmai_open(struct fsl_mc_io *mc_io, u32 cmd_flags,162int dpdmai_id, u16 *token);163int dpdmai_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);164int dpdmai_destroy(struct fsl_mc_io *mc_io, u32 cmd_flags, u32 dpdmai_id, u16 token);165int dpdmai_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);166int dpdmai_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);167int dpdmai_reset(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);168int dpdmai_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags,169u16 token, struct dpdmai_attr *attr);170int dpdmai_set_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,171u8 queue_idx, u8 priority, const struct dpdmai_rx_queue_cfg *cfg);172int dpdmai_get_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,173u8 queue_idx, u8 priority, struct dpdmai_rx_queue_attr *attr);174int dpdmai_get_tx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags,175u16 token, u8 queue_idx, u8 priority, struct dpdmai_tx_queue_attr *attr);176177#endif /* __FSL_DPDMAI_H */178179180