1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright 2018 NXP 3 */ 4 5 #ifndef __FSL_DPDMAI_H 6 #define __FSL_DPDMAI_H 7 8 #include <rte_compat.h> 9 10 struct fsl_mc_io; 11 12 /* Data Path DMA Interface API 13 * Contains initialization APIs and runtime control APIs for DPDMAI 14 */ 15 16 /* General DPDMAI macros */ 17 18 /** 19 * Maximum number of Tx/Rx priorities per DPDMAI object 20 */ 21 #define DPDMAI_PRIO_NUM 2 22 23 /** 24 * All queues considered; see dpdmai_set_rx_queue() 25 */ 26 #define DPDMAI_ALL_QUEUES (uint8_t)(-1) 27 28 __rte_internal 29 int dpdmai_open(struct fsl_mc_io *mc_io, 30 uint32_t cmd_flags, 31 int dpdmai_id, 32 uint16_t *token); 33 34 __rte_internal 35 int dpdmai_close(struct fsl_mc_io *mc_io, 36 uint32_t cmd_flags, 37 uint16_t token); 38 39 /** 40 * struct dpdmai_cfg - Structure representing DPDMAI configuration 41 * @priorities: Priorities for the DMA hardware processing; valid priorities are 42 * configured with values 1-8; the entry following last valid entry 43 * should be configured with 0 44 */ 45 struct dpdmai_cfg { 46 uint8_t num_queues; 47 uint8_t priorities[DPDMAI_PRIO_NUM]; 48 }; 49 50 int dpdmai_create(struct fsl_mc_io *mc_io, 51 uint16_t dprc_token, 52 uint32_t cmd_flags, 53 const struct dpdmai_cfg *cfg, 54 uint32_t *obj_id); 55 56 int dpdmai_destroy(struct fsl_mc_io *mc_io, 57 uint16_t dprc_token, 58 uint32_t cmd_flags, 59 uint32_t object_id); 60 61 __rte_internal 62 int dpdmai_enable(struct fsl_mc_io *mc_io, 63 uint32_t cmd_flags, 64 uint16_t token); 65 66 __rte_internal 67 int dpdmai_disable(struct fsl_mc_io *mc_io, 68 uint32_t cmd_flags, 69 uint16_t token); 70 71 int dpdmai_is_enabled(struct fsl_mc_io *mc_io, 72 uint32_t cmd_flags, 73 uint16_t token, 74 int *en); 75 76 int dpdmai_reset(struct fsl_mc_io *mc_io, 77 uint32_t cmd_flags, 78 uint16_t token); 79 80 /** 81 * struct dpdmai_attr - Structure representing DPDMAI attributes 82 * @id: DPDMAI object ID 83 * @num_of_priorities: number of priorities 84 */ 85 struct dpdmai_attr { 86 int id; 87 uint8_t num_of_priorities; 88 uint8_t num_of_queues; 89 }; 90 91 __rte_internal 92 int dpdmai_get_attributes(struct fsl_mc_io *mc_io, 93 uint32_t cmd_flags, 94 uint16_t token, 95 struct dpdmai_attr *attr); 96 97 /** 98 * enum dpdmai_dest - DPDMAI destination types 99 * @DPDMAI_DEST_NONE: Unassigned destination; The queue is set in parked mode 100 * and does not generate FQDAN notifications; user is expected to dequeue 101 * from the queue based on polling or other user-defined method 102 * @DPDMAI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN 103 * notifications to the specified DPIO; user is expected to dequeue 104 * from the queue only after notification is received 105 * @DPDMAI_DEST_DPCON: The queue is set in schedule mode and does not generate 106 * FQDAN notifications, but is connected to the specified DPCON object; 107 * user is expected to dequeue from the DPCON channel 108 */ 109 enum dpdmai_dest { 110 DPDMAI_DEST_NONE = 0, 111 DPDMAI_DEST_DPIO = 1, 112 DPDMAI_DEST_DPCON = 2 113 }; 114 115 /** 116 * struct dpdmai_dest_cfg - Structure representing DPDMAI destination parameters 117 * @dest_type: Destination type 118 * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type 119 * @priority: Priority selection within the DPIO or DPCON channel; valid values 120 * are 0-1 or 0-7, depending on the number of priorities in that 121 * channel; not relevant for 'DPDMAI_DEST_NONE' option 122 */ 123 struct dpdmai_dest_cfg { 124 enum dpdmai_dest dest_type; 125 int dest_id; 126 uint8_t priority; 127 }; 128 129 /* DPDMAI queue modification options */ 130 131 /** 132 * Select to modify the user's context associated with the queue 133 */ 134 #define DPDMAI_QUEUE_OPT_USER_CTX 0x00000001 135 136 /** 137 * Select to modify the queue's destination 138 */ 139 #define DPDMAI_QUEUE_OPT_DEST 0x00000002 140 141 /** 142 * struct dpdmai_rx_queue_cfg - DPDMAI RX queue configuration 143 * @options: Flags representing the suggested modifications to the queue; 144 * Use any combination of 'DPDMAI_QUEUE_OPT_<X>' flags 145 * @user_ctx: User context value provided in the frame descriptor of each 146 * dequeued frame; 147 * valid only if 'DPDMAI_QUEUE_OPT_USER_CTX' is contained in 'options' 148 * @dest_cfg: Queue destination parameters; 149 * valid only if 'DPDMAI_QUEUE_OPT_DEST' is contained in 'options' 150 */ 151 struct dpdmai_rx_queue_cfg { 152 uint32_t options; 153 uint64_t user_ctx; 154 struct dpdmai_dest_cfg dest_cfg; 155 156 }; 157 158 __rte_internal 159 int dpdmai_set_rx_queue(struct fsl_mc_io *mc_io, 160 uint32_t cmd_flags, 161 uint16_t token, 162 uint8_t queue_idx, 163 uint8_t priority, 164 const struct dpdmai_rx_queue_cfg *cfg); 165 166 /** 167 * struct dpdmai_rx_queue_attr - Structure representing attributes of Rx queues 168 * @user_ctx: User context value provided in the frame descriptor of each 169 * dequeued frame 170 * @dest_cfg: Queue destination configuration 171 * @fqid: Virtual FQID value to be used for dequeue operations 172 */ 173 struct dpdmai_rx_queue_attr { 174 uint64_t user_ctx; 175 struct dpdmai_dest_cfg dest_cfg; 176 uint32_t fqid; 177 }; 178 179 __rte_internal 180 int dpdmai_get_rx_queue(struct fsl_mc_io *mc_io, 181 uint32_t cmd_flags, 182 uint16_t token, 183 uint8_t queue_idx, 184 uint8_t priority, 185 struct dpdmai_rx_queue_attr *attr); 186 187 /** 188 * struct dpdmai_tx_queue_attr - Structure representing attributes of Tx queues 189 * @fqid: Virtual FQID to be used for sending frames to DMA hardware 190 */ 191 192 struct dpdmai_tx_queue_attr { 193 uint32_t fqid; 194 }; 195 196 __rte_internal 197 int dpdmai_get_tx_queue(struct fsl_mc_io *mc_io, 198 uint32_t cmd_flags, 199 uint16_t token, 200 uint8_t queue_idx, 201 uint8_t priority, 202 struct dpdmai_tx_queue_attr *attr); 203 204 #endif /* __FSL_DPDMAI_H */ 205