Bogdan Purcareata | 203e2de | 2018-01-17 18:36:44 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ |
Roy Pledge | 780b626 | 2017-03-13 15:02:02 -0400 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2014-2016 Freescale Semiconductor Inc. |
Youri Querry | 9d98809 | 2019-12-12 17:01:13 +0000 | [diff] [blame] | 4 | * Copyright 2017-2019 NXP |
Roy Pledge | 780b626 | 2017-03-13 15:02:02 -0400 | [diff] [blame] | 5 | * |
Roy Pledge | 780b626 | 2017-03-13 15:02:02 -0400 | [diff] [blame] | 6 | */ |
| 7 | #ifndef __FSL_DPAA2_IO_H |
| 8 | #define __FSL_DPAA2_IO_H |
| 9 | |
| 10 | #include <linux/types.h> |
| 11 | #include <linux/cpumask.h> |
Arnd Bergmann | 06ead06 | 2017-07-26 09:53:03 +0200 | [diff] [blame] | 12 | #include <linux/irqreturn.h> |
Roy Pledge | 780b626 | 2017-03-13 15:02:02 -0400 | [diff] [blame] | 13 | |
| 14 | #include "dpaa2-fd.h" |
| 15 | #include "dpaa2-global.h" |
| 16 | |
| 17 | struct dpaa2_io; |
| 18 | struct dpaa2_io_store; |
| 19 | struct device; |
| 20 | |
| 21 | /** |
| 22 | * DOC: DPIO Service |
| 23 | * |
| 24 | * The DPIO service provides APIs for users to interact with the datapath |
| 25 | * by enqueueing and dequeing frame descriptors. |
| 26 | * |
| 27 | * The following set of APIs can be used to enqueue and dequeue frames |
| 28 | * as well as producing notification callbacks when data is available |
| 29 | * for dequeue. |
| 30 | */ |
| 31 | |
Ioana Radulescu | 8dabf52 | 2017-09-28 09:10:33 -0500 | [diff] [blame] | 32 | #define DPAA2_IO_ANY_CPU -1 |
| 33 | |
Roy Pledge | 780b626 | 2017-03-13 15:02:02 -0400 | [diff] [blame] | 34 | /** |
| 35 | * struct dpaa2_io_desc - The DPIO descriptor |
| 36 | * @receives_notifications: Use notificaton mode. Non-zero if the DPIO |
| 37 | * has a channel. |
| 38 | * @has_8prio: Set to non-zero for channel with 8 priority WQs. Ignored |
| 39 | * unless receives_notification is TRUE. |
| 40 | * @cpu: The cpu index that at least interrupt handlers will |
| 41 | * execute on. |
| 42 | * @stash_affinity: The stash affinity for this portal favour 'cpu' |
| 43 | * @regs_cena: The cache enabled regs. |
| 44 | * @regs_cinh: The cache inhibited regs |
| 45 | * @dpio_id: The dpio index |
| 46 | * @qman_version: The qman version |
| 47 | * |
| 48 | * Describes the attributes and features of the DPIO object. |
| 49 | */ |
| 50 | struct dpaa2_io_desc { |
| 51 | int receives_notifications; |
| 52 | int has_8prio; |
| 53 | int cpu; |
| 54 | void *regs_cena; |
Roy Pledge | 03fcedc | 2018-03-27 14:13:31 -0400 | [diff] [blame] | 55 | void __iomem *regs_cinh; |
Roy Pledge | 780b626 | 2017-03-13 15:02:02 -0400 | [diff] [blame] | 56 | int dpio_id; |
| 57 | u32 qman_version; |
| 58 | }; |
| 59 | |
Ioana Ciornei | cf9ff75 | 2018-12-10 16:50:18 +0000 | [diff] [blame] | 60 | struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc, |
| 61 | struct device *dev); |
Roy Pledge | 780b626 | 2017-03-13 15:02:02 -0400 | [diff] [blame] | 62 | |
| 63 | void dpaa2_io_down(struct dpaa2_io *d); |
| 64 | |
| 65 | irqreturn_t dpaa2_io_irq(struct dpaa2_io *obj); |
| 66 | |
Ioana Radulescu | 1f49538 | 2018-01-05 05:04:31 -0600 | [diff] [blame] | 67 | struct dpaa2_io *dpaa2_io_service_select(int cpu); |
| 68 | |
Roy Pledge | 780b626 | 2017-03-13 15:02:02 -0400 | [diff] [blame] | 69 | /** |
| 70 | * struct dpaa2_io_notification_ctx - The DPIO notification context structure |
| 71 | * @cb: The callback to be invoked when the notification arrives |
| 72 | * @is_cdan: Zero for FQDAN, non-zero for CDAN |
| 73 | * @id: FQID or channel ID, needed for rearm |
Ioana Radulescu | 8dabf52 | 2017-09-28 09:10:33 -0500 | [diff] [blame] | 74 | * @desired_cpu: The cpu on which the notifications will show up. Use |
| 75 | * DPAA2_IO_ANY_CPU if don't care |
Roy Pledge | 780b626 | 2017-03-13 15:02:02 -0400 | [diff] [blame] | 76 | * @dpio_id: The dpio index |
| 77 | * @qman64: The 64-bit context value shows up in the FQDAN/CDAN. |
| 78 | * @node: The list node |
| 79 | * @dpio_private: The dpio object internal to dpio_service |
| 80 | * |
| 81 | * Used when a FQDAN/CDAN registration is made by drivers. |
| 82 | */ |
| 83 | struct dpaa2_io_notification_ctx { |
Roy Pledge | 0922a46 | 2018-03-07 16:50:27 -0500 | [diff] [blame] | 84 | void (*cb)(struct dpaa2_io_notification_ctx *ctx); |
Roy Pledge | 780b626 | 2017-03-13 15:02:02 -0400 | [diff] [blame] | 85 | int is_cdan; |
| 86 | u32 id; |
| 87 | int desired_cpu; |
| 88 | int dpio_id; |
| 89 | u64 qman64; |
| 90 | struct list_head node; |
| 91 | void *dpio_private; |
| 92 | }; |
| 93 | |
Ioana Ciornei | 991e873 | 2018-12-04 11:20:29 +0000 | [diff] [blame] | 94 | int dpaa2_io_get_cpu(struct dpaa2_io *d); |
| 95 | |
Roy Pledge | 780b626 | 2017-03-13 15:02:02 -0400 | [diff] [blame] | 96 | int dpaa2_io_service_register(struct dpaa2_io *service, |
Ioana Ciornei | 47441f7 | 2018-12-10 16:50:19 +0000 | [diff] [blame] | 97 | struct dpaa2_io_notification_ctx *ctx, |
| 98 | struct device *dev); |
Roy Pledge | 780b626 | 2017-03-13 15:02:02 -0400 | [diff] [blame] | 99 | void dpaa2_io_service_deregister(struct dpaa2_io *service, |
Ioana Ciornei | 47441f7 | 2018-12-10 16:50:19 +0000 | [diff] [blame] | 100 | struct dpaa2_io_notification_ctx *ctx, |
| 101 | struct device *dev); |
Roy Pledge | 780b626 | 2017-03-13 15:02:02 -0400 | [diff] [blame] | 102 | int dpaa2_io_service_rearm(struct dpaa2_io *service, |
| 103 | struct dpaa2_io_notification_ctx *ctx); |
| 104 | |
Horia Geantă | 48c43de | 2018-09-12 11:59:27 +0300 | [diff] [blame] | 105 | int dpaa2_io_service_pull_fq(struct dpaa2_io *d, u32 fqid, |
| 106 | struct dpaa2_io_store *s); |
Roy Pledge | 780b626 | 2017-03-13 15:02:02 -0400 | [diff] [blame] | 107 | int dpaa2_io_service_pull_channel(struct dpaa2_io *d, u32 channelid, |
| 108 | struct dpaa2_io_store *s); |
| 109 | |
Horia Geantă | 48c43de | 2018-09-12 11:59:27 +0300 | [diff] [blame] | 110 | int dpaa2_io_service_enqueue_fq(struct dpaa2_io *d, u32 fqid, |
| 111 | const struct dpaa2_fd *fd); |
Youri Querry | 9d98809 | 2019-12-12 17:01:13 +0000 | [diff] [blame] | 112 | int dpaa2_io_service_enqueue_multiple_fq(struct dpaa2_io *d, u32 fqid, |
| 113 | const struct dpaa2_fd *fd, int number_of_frame); |
| 114 | int dpaa2_io_service_enqueue_multiple_desc_fq(struct dpaa2_io *d, u32 *fqid, |
| 115 | const struct dpaa2_fd *fd, int number_of_frame); |
Roy Pledge | 780b626 | 2017-03-13 15:02:02 -0400 | [diff] [blame] | 116 | int dpaa2_io_service_enqueue_qd(struct dpaa2_io *d, u32 qdid, u8 prio, |
| 117 | u16 qdbin, const struct dpaa2_fd *fd); |
Ioana Ciocoi Radulescu | 8a533a7 | 2018-12-14 16:04:06 +0000 | [diff] [blame] | 118 | int dpaa2_io_service_release(struct dpaa2_io *d, u16 bpid, |
Roy Pledge | 780b626 | 2017-03-13 15:02:02 -0400 | [diff] [blame] | 119 | const u64 *buffers, unsigned int num_buffers); |
Ioana Ciocoi Radulescu | 8a533a7 | 2018-12-14 16:04:06 +0000 | [diff] [blame] | 120 | int dpaa2_io_service_acquire(struct dpaa2_io *d, u16 bpid, |
Roy Pledge | 780b626 | 2017-03-13 15:02:02 -0400 | [diff] [blame] | 121 | u64 *buffers, unsigned int num_buffers); |
| 122 | |
| 123 | struct dpaa2_io_store *dpaa2_io_store_create(unsigned int max_frames, |
| 124 | struct device *dev); |
| 125 | void dpaa2_io_store_destroy(struct dpaa2_io_store *s); |
| 126 | struct dpaa2_dq *dpaa2_io_store_next(struct dpaa2_io_store *s, int *is_last); |
| 127 | |
Roy Pledge | e80081c | 2018-12-18 15:23:01 +0000 | [diff] [blame] | 128 | int dpaa2_io_query_fq_count(struct dpaa2_io *d, u32 fqid, |
| 129 | u32 *fcnt, u32 *bcnt); |
| 130 | int dpaa2_io_query_bp_count(struct dpaa2_io *d, u16 bpid, |
| 131 | u32 *num); |
Roy Pledge | 780b626 | 2017-03-13 15:02:02 -0400 | [diff] [blame] | 132 | #endif /* __FSL_DPAA2_IO_H */ |