1 /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
3 * Copyright 2014-2016 Freescale Semiconductor Inc.
7 #ifndef __FSL_DPAA2_IO_H
8 #define __FSL_DPAA2_IO_H
10 #include <linux/types.h>
11 #include <linux/cpumask.h>
12 #include <linux/irqreturn.h>
15 #include "dpaa2-global.h"
18 struct dpaa2_io_store
;
24 * The DPIO service provides APIs for users to interact with the datapath
25 * by enqueueing and dequeing frame descriptors.
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
32 #define DPAA2_IO_ANY_CPU -1
35 * struct dpaa2_io_desc - The DPIO descriptor
36 * @receives_notifications: Use notificaton mode. Non-zero if the DPIO
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
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
48 * Describes the attributes and features of the DPIO object.
50 struct dpaa2_io_desc
{
51 int receives_notifications
;
55 void __iomem
*regs_cinh
;
60 struct dpaa2_io
*dpaa2_io_create(const struct dpaa2_io_desc
*desc
);
62 void dpaa2_io_down(struct dpaa2_io
*d
);
64 irqreturn_t
dpaa2_io_irq(struct dpaa2_io
*obj
);
66 struct dpaa2_io
*dpaa2_io_service_select(int cpu
);
69 * struct dpaa2_io_notification_ctx - The DPIO notification context structure
70 * @cb: The callback to be invoked when the notification arrives
71 * @is_cdan: Zero for FQDAN, non-zero for CDAN
72 * @id: FQID or channel ID, needed for rearm
73 * @desired_cpu: The cpu on which the notifications will show up. Use
74 * DPAA2_IO_ANY_CPU if don't care
75 * @dpio_id: The dpio index
76 * @qman64: The 64-bit context value shows up in the FQDAN/CDAN.
77 * @node: The list node
78 * @dpio_private: The dpio object internal to dpio_service
80 * Used when a FQDAN/CDAN registration is made by drivers.
82 struct dpaa2_io_notification_ctx
{
83 void (*cb
)(struct dpaa2_io_notification_ctx
*ctx
);
89 struct list_head node
;
93 int dpaa2_io_service_register(struct dpaa2_io
*service
,
94 struct dpaa2_io_notification_ctx
*ctx
);
95 void dpaa2_io_service_deregister(struct dpaa2_io
*service
,
96 struct dpaa2_io_notification_ctx
*ctx
);
97 int dpaa2_io_service_rearm(struct dpaa2_io
*service
,
98 struct dpaa2_io_notification_ctx
*ctx
);
100 int dpaa2_io_service_pull_channel(struct dpaa2_io
*d
, u32 channelid
,
101 struct dpaa2_io_store
*s
);
103 int dpaa2_io_service_enqueue_qd(struct dpaa2_io
*d
, u32 qdid
, u8 prio
,
104 u16 qdbin
, const struct dpaa2_fd
*fd
);
105 int dpaa2_io_service_release(struct dpaa2_io
*d
, u32 bpid
,
106 const u64
*buffers
, unsigned int num_buffers
);
107 int dpaa2_io_service_acquire(struct dpaa2_io
*d
, u32 bpid
,
108 u64
*buffers
, unsigned int num_buffers
);
110 struct dpaa2_io_store
*dpaa2_io_store_create(unsigned int max_frames
,
112 void dpaa2_io_store_destroy(struct dpaa2_io_store
*s
);
113 struct dpaa2_dq
*dpaa2_io_store_next(struct dpaa2_io_store
*s
, int *is_last
);
115 #endif /* __FSL_DPAA2_IO_H */