18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright 2014-2016 Freescale Semiconductor Inc. 48c2ecf20Sopenharmony_ci * Copyright 2017-2019 NXP 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci#ifndef __FSL_DPAA2_IO_H 88c2ecf20Sopenharmony_ci#define __FSL_DPAA2_IO_H 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/types.h> 118c2ecf20Sopenharmony_ci#include <linux/cpumask.h> 128c2ecf20Sopenharmony_ci#include <linux/irqreturn.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include "dpaa2-fd.h" 158c2ecf20Sopenharmony_ci#include "dpaa2-global.h" 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_cistruct dpaa2_io; 188c2ecf20Sopenharmony_cistruct dpaa2_io_store; 198c2ecf20Sopenharmony_cistruct device; 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci/** 228c2ecf20Sopenharmony_ci * DOC: DPIO Service 238c2ecf20Sopenharmony_ci * 248c2ecf20Sopenharmony_ci * The DPIO service provides APIs for users to interact with the datapath 258c2ecf20Sopenharmony_ci * by enqueueing and dequeing frame descriptors. 268c2ecf20Sopenharmony_ci * 278c2ecf20Sopenharmony_ci * The following set of APIs can be used to enqueue and dequeue frames 288c2ecf20Sopenharmony_ci * as well as producing notification callbacks when data is available 298c2ecf20Sopenharmony_ci * for dequeue. 308c2ecf20Sopenharmony_ci */ 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#define DPAA2_IO_ANY_CPU -1 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci/** 358c2ecf20Sopenharmony_ci * struct dpaa2_io_desc - The DPIO descriptor 368c2ecf20Sopenharmony_ci * @receives_notifications: Use notificaton mode. Non-zero if the DPIO 378c2ecf20Sopenharmony_ci * has a channel. 388c2ecf20Sopenharmony_ci * @has_8prio: Set to non-zero for channel with 8 priority WQs. Ignored 398c2ecf20Sopenharmony_ci * unless receives_notification is TRUE. 408c2ecf20Sopenharmony_ci * @cpu: The cpu index that at least interrupt handlers will 418c2ecf20Sopenharmony_ci * execute on. 428c2ecf20Sopenharmony_ci * @stash_affinity: The stash affinity for this portal favour 'cpu' 438c2ecf20Sopenharmony_ci * @regs_cena: The cache enabled regs. 448c2ecf20Sopenharmony_ci * @regs_cinh: The cache inhibited regs 458c2ecf20Sopenharmony_ci * @dpio_id: The dpio index 468c2ecf20Sopenharmony_ci * @qman_version: The qman version 478c2ecf20Sopenharmony_ci * 488c2ecf20Sopenharmony_ci * Describes the attributes and features of the DPIO object. 498c2ecf20Sopenharmony_ci */ 508c2ecf20Sopenharmony_cistruct dpaa2_io_desc { 518c2ecf20Sopenharmony_ci int receives_notifications; 528c2ecf20Sopenharmony_ci int has_8prio; 538c2ecf20Sopenharmony_ci int cpu; 548c2ecf20Sopenharmony_ci void *regs_cena; 558c2ecf20Sopenharmony_ci void __iomem *regs_cinh; 568c2ecf20Sopenharmony_ci int dpio_id; 578c2ecf20Sopenharmony_ci u32 qman_version; 588c2ecf20Sopenharmony_ci}; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cistruct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc, 618c2ecf20Sopenharmony_ci struct device *dev); 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_civoid dpaa2_io_down(struct dpaa2_io *d); 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ciirqreturn_t dpaa2_io_irq(struct dpaa2_io *obj); 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_cistruct dpaa2_io *dpaa2_io_service_select(int cpu); 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci/** 708c2ecf20Sopenharmony_ci * struct dpaa2_io_notification_ctx - The DPIO notification context structure 718c2ecf20Sopenharmony_ci * @cb: The callback to be invoked when the notification arrives 728c2ecf20Sopenharmony_ci * @is_cdan: Zero for FQDAN, non-zero for CDAN 738c2ecf20Sopenharmony_ci * @id: FQID or channel ID, needed for rearm 748c2ecf20Sopenharmony_ci * @desired_cpu: The cpu on which the notifications will show up. Use 758c2ecf20Sopenharmony_ci * DPAA2_IO_ANY_CPU if don't care 768c2ecf20Sopenharmony_ci * @dpio_id: The dpio index 778c2ecf20Sopenharmony_ci * @qman64: The 64-bit context value shows up in the FQDAN/CDAN. 788c2ecf20Sopenharmony_ci * @node: The list node 798c2ecf20Sopenharmony_ci * @dpio_private: The dpio object internal to dpio_service 808c2ecf20Sopenharmony_ci * 818c2ecf20Sopenharmony_ci * Used when a FQDAN/CDAN registration is made by drivers. 828c2ecf20Sopenharmony_ci */ 838c2ecf20Sopenharmony_cistruct dpaa2_io_notification_ctx { 848c2ecf20Sopenharmony_ci void (*cb)(struct dpaa2_io_notification_ctx *ctx); 858c2ecf20Sopenharmony_ci int is_cdan; 868c2ecf20Sopenharmony_ci u32 id; 878c2ecf20Sopenharmony_ci int desired_cpu; 888c2ecf20Sopenharmony_ci int dpio_id; 898c2ecf20Sopenharmony_ci u64 qman64; 908c2ecf20Sopenharmony_ci struct list_head node; 918c2ecf20Sopenharmony_ci void *dpio_private; 928c2ecf20Sopenharmony_ci}; 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ciint dpaa2_io_get_cpu(struct dpaa2_io *d); 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ciint dpaa2_io_service_register(struct dpaa2_io *service, 978c2ecf20Sopenharmony_ci struct dpaa2_io_notification_ctx *ctx, 988c2ecf20Sopenharmony_ci struct device *dev); 998c2ecf20Sopenharmony_civoid dpaa2_io_service_deregister(struct dpaa2_io *service, 1008c2ecf20Sopenharmony_ci struct dpaa2_io_notification_ctx *ctx, 1018c2ecf20Sopenharmony_ci struct device *dev); 1028c2ecf20Sopenharmony_ciint dpaa2_io_service_rearm(struct dpaa2_io *service, 1038c2ecf20Sopenharmony_ci struct dpaa2_io_notification_ctx *ctx); 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ciint dpaa2_io_service_pull_fq(struct dpaa2_io *d, u32 fqid, 1068c2ecf20Sopenharmony_ci struct dpaa2_io_store *s); 1078c2ecf20Sopenharmony_ciint dpaa2_io_service_pull_channel(struct dpaa2_io *d, u32 channelid, 1088c2ecf20Sopenharmony_ci struct dpaa2_io_store *s); 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ciint dpaa2_io_service_enqueue_fq(struct dpaa2_io *d, u32 fqid, 1118c2ecf20Sopenharmony_ci const struct dpaa2_fd *fd); 1128c2ecf20Sopenharmony_ciint dpaa2_io_service_enqueue_multiple_fq(struct dpaa2_io *d, u32 fqid, 1138c2ecf20Sopenharmony_ci const struct dpaa2_fd *fd, int number_of_frame); 1148c2ecf20Sopenharmony_ciint dpaa2_io_service_enqueue_multiple_desc_fq(struct dpaa2_io *d, u32 *fqid, 1158c2ecf20Sopenharmony_ci const struct dpaa2_fd *fd, int number_of_frame); 1168c2ecf20Sopenharmony_ciint dpaa2_io_service_enqueue_qd(struct dpaa2_io *d, u32 qdid, u8 prio, 1178c2ecf20Sopenharmony_ci u16 qdbin, const struct dpaa2_fd *fd); 1188c2ecf20Sopenharmony_ciint dpaa2_io_service_release(struct dpaa2_io *d, u16 bpid, 1198c2ecf20Sopenharmony_ci const u64 *buffers, unsigned int num_buffers); 1208c2ecf20Sopenharmony_ciint dpaa2_io_service_acquire(struct dpaa2_io *d, u16 bpid, 1218c2ecf20Sopenharmony_ci u64 *buffers, unsigned int num_buffers); 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_cistruct dpaa2_io_store *dpaa2_io_store_create(unsigned int max_frames, 1248c2ecf20Sopenharmony_ci struct device *dev); 1258c2ecf20Sopenharmony_civoid dpaa2_io_store_destroy(struct dpaa2_io_store *s); 1268c2ecf20Sopenharmony_cistruct dpaa2_dq *dpaa2_io_store_next(struct dpaa2_io_store *s, int *is_last); 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ciint dpaa2_io_query_fq_count(struct dpaa2_io *d, u32 fqid, 1298c2ecf20Sopenharmony_ci u32 *fcnt, u32 *bcnt); 1308c2ecf20Sopenharmony_ciint dpaa2_io_query_bp_count(struct dpaa2_io *d, u16 bpid, 1318c2ecf20Sopenharmony_ci u32 *num); 1328c2ecf20Sopenharmony_ci#endif /* __FSL_DPAA2_IO_H */ 133