Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

dmaengine: fsl-dpaa2-qdma: Update DPDMAI interfaces to version 3

Update the DPDMAI interfaces to support MC firmware up to 10.1x.x, which
major change is to add dpaa domain id support. User space MC controller
tool can create difference dpaa domain for difference virtual environment.
DMA queues can map to difference service priorities.

The MC command was basic compatible original one. The new command use
previous reserved field.

- Add queue number for dpdmai_get_tx(rx)_queue().
- Unified rx(tx)_queue_attr.
- Update pad/reserved field of struct dpdmai_rsp_get_attributes and
struct dpdmai_cmd_queue for new API.
- Update command DPDMAI_SET(GET)_RX_QUEUE and DPDMAI_CMDID_GET_TX_QUEUE

Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20240409163630.1996052-1-Frank.Li@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Frank Li and committed by
Vinod Koul
bd2f66bc b52e28ec

+67 -35
+7 -7
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c
··· 362 362 363 363 for (i = 0; i < priv->num_pairs; i++) { 364 364 err = dpdmai_get_rx_queue(priv->mc_io, 0, ls_dev->mc_handle, 365 - i, &priv->rx_queue_attr[i]); 365 + i, 0, &priv->rx_queue_attr[i]); 366 366 if (err) { 367 367 dev_err(dev, "dpdmai_get_rx_queue() failed\n"); 368 368 goto exit; ··· 370 370 ppriv->rsp_fqid = priv->rx_queue_attr[i].fqid; 371 371 372 372 err = dpdmai_get_tx_queue(priv->mc_io, 0, ls_dev->mc_handle, 373 - i, &priv->tx_fqid[i]); 373 + i, 0, &priv->tx_queue_attr[i]); 374 374 if (err) { 375 375 dev_err(dev, "dpdmai_get_tx_queue() failed\n"); 376 376 goto exit; 377 377 } 378 - ppriv->req_fqid = priv->tx_fqid[i]; 379 - ppriv->prio = i; 378 + ppriv->req_fqid = priv->tx_queue_attr[i].fqid; 379 + ppriv->prio = DPAA2_QDMA_DEFAULT_PRIORITY; 380 380 ppriv->priv = priv; 381 381 ppriv++; 382 382 } ··· 542 542 rx_queue_cfg.dest_cfg.dest_id = ppriv->nctx.dpio_id; 543 543 rx_queue_cfg.dest_cfg.priority = ppriv->prio; 544 544 err = dpdmai_set_rx_queue(priv->mc_io, 0, ls_dev->mc_handle, 545 - rx_queue_cfg.dest_cfg.priority, 545 + rx_queue_cfg.dest_cfg.priority, 0, 546 546 &rx_queue_cfg); 547 547 if (err) { 548 548 dev_err(dev, "dpdmai_set_rx_queue() failed\n"); ··· 642 642 for (i = 0; i < dpaa2_qdma->n_chans; i++) { 643 643 dpaa2_chan = &dpaa2_qdma->chans[i]; 644 644 dpaa2_chan->qdma = dpaa2_qdma; 645 - dpaa2_chan->fqid = priv->tx_fqid[i % num]; 645 + dpaa2_chan->fqid = priv->tx_queue_attr[i % num].fqid; 646 646 dpaa2_chan->vchan.desc_free = dpaa2_qdma_free_desc; 647 647 vchan_init(&dpaa2_chan->vchan, &dpaa2_qdma->dma_dev); 648 648 spin_lock_init(&dpaa2_chan->queue_lock); ··· 802 802 dpdmai_disable(priv->mc_io, 0, ls_dev->mc_handle); 803 803 dpaa2_dpdmai_dpio_unbind(priv); 804 804 dpdmai_close(priv->mc_io, 0, ls_dev->mc_handle); 805 - dpdmai_destroy(priv->mc_io, 0, ls_dev->mc_handle); 805 + dpdmai_destroy(priv->mc_io, 0, priv->dpqdma_id, ls_dev->mc_handle); 806 806 } 807 807 808 808 static const struct fsl_mc_device_id dpaa2_qdma_id_table[] = {
+3 -2
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.h
··· 6 6 7 7 #define DPAA2_QDMA_STORE_SIZE 16 8 8 #define NUM_CH 8 9 + #define DPAA2_QDMA_DEFAULT_PRIORITY 0 9 10 10 11 struct dpaa2_qdma_sd_d { 11 12 u32 rsv:32; ··· 123 122 struct dpaa2_qdma_engine *dpaa2_qdma; 124 123 struct dpaa2_qdma_priv_per_prio *ppriv; 125 124 126 - struct dpdmai_rx_queue_attr rx_queue_attr[DPDMAI_PRIO_NUM]; 127 - u32 tx_fqid[DPDMAI_PRIO_NUM]; 125 + struct dpdmai_rx_queue_attr rx_queue_attr[DPDMAI_MAX_QUEUE_NUM]; 126 + struct dpdmai_tx_queue_attr tx_queue_attr[DPDMAI_MAX_QUEUE_NUM]; 128 127 }; 129 128 130 129 struct dpaa2_qdma_priv_per_prio {
+34 -14
drivers/dma/fsl-dpaa2-qdma/dpdmai.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 // Copyright 2019 NXP 3 3 4 + #include <linux/bitfield.h> 4 5 #include <linux/module.h> 5 6 #include <linux/types.h> 6 7 #include <linux/io.h> 7 8 #include <linux/fsl/mc.h> 8 9 #include "dpdmai.h" 9 10 11 + #define DEST_TYPE_MASK 0xF 12 + 10 13 struct dpdmai_rsp_get_attributes { 11 14 __le32 id; 12 15 u8 num_of_priorities; 13 - u8 pad0[3]; 16 + u8 num_of_queues; 17 + u8 pad0[2]; 14 18 __le16 major; 15 19 __le16 minor; 16 20 }; 17 21 18 22 struct dpdmai_cmd_queue { 19 23 __le32 dest_id; 20 - u8 priority; 21 - u8 queue; 24 + u8 dest_priority; 25 + union { 26 + u8 queue; 27 + u8 pri; 28 + }; 22 29 u8 dest_type; 23 - u8 pad; 30 + u8 queue_idx; 24 31 __le64 user_ctx; 25 32 union { 26 33 __le32 options; 27 34 __le32 fqid; 28 35 }; 29 - }; 36 + } __packed; 30 37 31 38 struct dpdmai_rsp_get_tx_queue { 32 39 __le64 pad; ··· 41 34 }; 42 35 43 36 struct dpdmai_cmd_open { 37 + __le32 dpdmai_id; 38 + } __packed; 39 + 40 + struct dpdmai_cmd_destroy { 44 41 __le32 dpdmai_id; 45 42 } __packed; 46 43 ··· 124 113 * dpdmai_destroy() - Destroy the DPDMAI object and release all its resources. 125 114 * @mc_io: Pointer to MC portal's I/O object 126 115 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' 116 + * @dpdmai_id: The object id; it must be a valid id within the container that created this object; 127 117 * @token: Token of DPDMAI object 128 118 * 129 119 * Return: '0' on Success; error code otherwise. 130 120 */ 131 - int dpdmai_destroy(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token) 121 + int dpdmai_destroy(struct fsl_mc_io *mc_io, u32 cmd_flags, u32 dpdmai_id, u16 token) 132 122 { 123 + struct dpdmai_cmd_destroy *cmd_params; 133 124 struct fsl_mc_command cmd = { 0 }; 134 125 135 126 /* prepare command */ 136 127 cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_DESTROY, 137 128 cmd_flags, token); 129 + 130 + cmd_params = (struct dpdmai_cmd_destroy *)&cmd.params; 131 + cmd_params->dpdmai_id = cpu_to_le32(dpdmai_id); 138 132 139 133 /* send command to mc*/ 140 134 return mc_send_command(mc_io, &cmd); ··· 240 224 attr->version.major = le16_to_cpu(rsp_params->major); 241 225 attr->version.minor = le16_to_cpu(rsp_params->minor); 242 226 attr->num_of_priorities = rsp_params->num_of_priorities; 227 + attr->num_of_queues = rsp_params->num_of_queues; 243 228 244 229 return 0; 245 230 } ··· 257 240 * 258 241 * Return: '0' on Success; Error code otherwise. 259 242 */ 260 - int dpdmai_set_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, 243 + int dpdmai_set_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u8 queue_idx, 261 244 u8 priority, const struct dpdmai_rx_queue_cfg *cfg) 262 245 { 263 246 struct dpdmai_cmd_queue *cmd_params; ··· 269 252 270 253 cmd_params = (struct dpdmai_cmd_queue *)cmd.params; 271 254 cmd_params->dest_id = cpu_to_le32(cfg->dest_cfg.dest_id); 272 - cmd_params->priority = cfg->dest_cfg.priority; 273 - cmd_params->queue = priority; 255 + cmd_params->dest_priority = cfg->dest_cfg.priority; 256 + cmd_params->pri = priority; 274 257 cmd_params->dest_type = cfg->dest_cfg.dest_type; 275 258 cmd_params->user_ctx = cpu_to_le64(cfg->user_ctx); 276 259 cmd_params->options = cpu_to_le32(cfg->options); 260 + cmd_params->queue_idx = queue_idx; 277 261 278 262 /* send command to mc*/ 279 263 return mc_send_command(mc_io, &cmd); ··· 292 274 * 293 275 * Return: '0' on Success; Error code otherwise. 294 276 */ 295 - int dpdmai_get_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, 277 + int dpdmai_get_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u8 queue_idx, 296 278 u8 priority, struct dpdmai_rx_queue_attr *attr) 297 279 { 298 280 struct dpdmai_cmd_queue *cmd_params; ··· 305 287 306 288 cmd_params = (struct dpdmai_cmd_queue *)cmd.params; 307 289 cmd_params->queue = priority; 290 + cmd_params->queue_idx = queue_idx; 308 291 309 292 /* send command to mc*/ 310 293 err = mc_send_command(mc_io, &cmd); ··· 314 295 315 296 /* retrieve response parameters */ 316 297 attr->dest_cfg.dest_id = le32_to_cpu(cmd_params->dest_id); 317 - attr->dest_cfg.priority = cmd_params->priority; 318 - attr->dest_cfg.dest_type = cmd_params->dest_type; 298 + attr->dest_cfg.priority = cmd_params->dest_priority; 299 + attr->dest_cfg.dest_type = FIELD_GET(DEST_TYPE_MASK, cmd_params->dest_type); 319 300 attr->user_ctx = le64_to_cpu(cmd_params->user_ctx); 320 301 attr->fqid = le32_to_cpu(cmd_params->fqid); 321 302 ··· 335 316 * Return: '0' on Success; Error code otherwise. 336 317 */ 337 318 int dpdmai_get_tx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, 338 - u16 token, u8 priority, u32 *fqid) 319 + u16 token, u8 queue_idx, u8 priority, struct dpdmai_tx_queue_attr *attr) 339 320 { 340 321 struct dpdmai_rsp_get_tx_queue *rsp_params; 341 322 struct dpdmai_cmd_queue *cmd_params; ··· 348 329 349 330 cmd_params = (struct dpdmai_cmd_queue *)cmd.params; 350 331 cmd_params->queue = priority; 332 + cmd_params->queue_idx = queue_idx; 351 333 352 334 /* send command to mc*/ 353 335 err = mc_send_command(mc_io, &cmd); ··· 358 338 /* retrieve response parameters */ 359 339 360 340 rsp_params = (struct dpdmai_rsp_get_tx_queue *)cmd.params; 361 - *fqid = le32_to_cpu(rsp_params->fqid); 341 + attr->fqid = le32_to_cpu(rsp_params->fqid); 362 342 363 343 return 0; 364 344 }
+23 -12
drivers/dma/fsl-dpaa2-qdma/dpdmai.h
··· 5 5 #define __FSL_DPDMAI_H 6 6 7 7 /* DPDMAI Version */ 8 - #define DPDMAI_VER_MAJOR 2 9 - #define DPDMAI_VER_MINOR 2 8 + #define DPDMAI_VER_MAJOR 3 9 + #define DPDMAI_VER_MINOR 3 10 10 11 - #define DPDMAI_CMD_BASE_VERSION 0 11 + #define DPDMAI_CMD_BASE_VERSION 1 12 12 #define DPDMAI_CMD_ID_OFFSET 4 13 13 14 - #define DPDMAI_CMDID_FORMAT(x) (((x) << DPDMAI_CMD_ID_OFFSET) | \ 15 - DPDMAI_CMD_BASE_VERSION) 14 + /* 15 + * Maximum number of Tx/Rx queues per DPDMAI object 16 + */ 17 + #define DPDMAI_MAX_QUEUE_NUM 8 18 + 19 + #define DPDMAI_CMDID_FORMAT_V(x, v) (((x) << DPDMAI_CMD_ID_OFFSET) | (v)) 20 + #define DPDMAI_CMDID_FORMAT(x) DPDMAI_CMDID_FORMAT_V(x, DPDMAI_CMD_BASE_VERSION) 16 21 17 22 /* Command IDs */ 18 23 #define DPDMAI_CMDID_CLOSE DPDMAI_CMDID_FORMAT(0x800) ··· 31 26 #define DPDMAI_CMDID_RESET DPDMAI_CMDID_FORMAT(0x005) 32 27 #define DPDMAI_CMDID_IS_ENABLED DPDMAI_CMDID_FORMAT(0x006) 33 28 34 - #define DPDMAI_CMDID_SET_RX_QUEUE DPDMAI_CMDID_FORMAT(0x1A0) 35 - #define DPDMAI_CMDID_GET_RX_QUEUE DPDMAI_CMDID_FORMAT(0x1A1) 36 - #define DPDMAI_CMDID_GET_TX_QUEUE DPDMAI_CMDID_FORMAT(0x1A2) 29 + #define DPDMAI_CMDID_SET_RX_QUEUE DPDMAI_CMDID_FORMAT_V(0x1A0, 2) 30 + #define DPDMAI_CMDID_GET_RX_QUEUE DPDMAI_CMDID_FORMAT_V(0x1A1, 2) 31 + #define DPDMAI_CMDID_GET_TX_QUEUE DPDMAI_CMDID_FORMAT_V(0x1A2, 2) 37 32 38 33 #define MC_CMD_HDR_TOKEN_O 32 /* Token field offset */ 39 34 #define MC_CMD_HDR_TOKEN_S 16 /* Token field size */ ··· 69 64 * should be configured with 0 70 65 */ 71 66 struct dpdmai_cfg { 67 + u8 num_queues; 72 68 u8 priorities[DPDMAI_PRIO_NUM]; 73 69 }; 74 70 ··· 91 85 u16 minor; 92 86 } version; 93 87 u8 num_of_priorities; 88 + u8 num_of_queues; 94 89 }; 95 90 96 91 /** ··· 156 149 u32 fqid; 157 150 }; 158 151 152 + struct dpdmai_tx_queue_attr { 153 + u32 fqid; 154 + }; 155 + 159 156 int dpdmai_open(struct fsl_mc_io *mc_io, u32 cmd_flags, 160 157 int dpdmai_id, u16 *token); 161 158 int dpdmai_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token); 162 - int dpdmai_destroy(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token); 159 + int dpdmai_destroy(struct fsl_mc_io *mc_io, u32 cmd_flags, u32 dpdmai_id, u16 token); 163 160 int dpdmai_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token); 164 161 int dpdmai_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token); 165 162 int dpdmai_reset(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token); 166 163 int dpdmai_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags, 167 164 u16 token, struct dpdmai_attr *attr); 168 165 int dpdmai_set_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, 169 - u8 priority, const struct dpdmai_rx_queue_cfg *cfg); 166 + u8 queue_idx, u8 priority, const struct dpdmai_rx_queue_cfg *cfg); 170 167 int dpdmai_get_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, 171 - u8 priority, struct dpdmai_rx_queue_attr *attr); 168 + u8 queue_idx, u8 priority, struct dpdmai_rx_queue_attr *attr); 172 169 int dpdmai_get_tx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, 173 - u16 token, u8 priority, u32 *fqid); 170 + u16 token, u8 queue_idx, u8 priority, struct dpdmai_tx_queue_attr *attr); 174 171 175 172 #endif /* __FSL_DPDMAI_H */