1c89105c9SRoy Pledge /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ 2c89105c9SRoy Pledge /* 3c89105c9SRoy Pledge * Copyright 2014-2016 Freescale Semiconductor Inc. 49d988097SYouri Querry * Copyright 2017-2019 NXP 5c89105c9SRoy Pledge * 6c89105c9SRoy Pledge */ 7c89105c9SRoy Pledge #ifndef __FSL_DPAA2_IO_H 8c89105c9SRoy Pledge #define __FSL_DPAA2_IO_H 9c89105c9SRoy Pledge 10c89105c9SRoy Pledge #include <linux/types.h> 11c89105c9SRoy Pledge #include <linux/cpumask.h> 12c89105c9SRoy Pledge #include <linux/irqreturn.h> 13c89105c9SRoy Pledge 14c89105c9SRoy Pledge #include "dpaa2-fd.h" 15c89105c9SRoy Pledge #include "dpaa2-global.h" 16c89105c9SRoy Pledge 17c89105c9SRoy Pledge struct dpaa2_io; 18c89105c9SRoy Pledge struct dpaa2_io_store; 19c89105c9SRoy Pledge struct device; 20c89105c9SRoy Pledge 21c89105c9SRoy Pledge /** 22c89105c9SRoy Pledge * DOC: DPIO Service 23c89105c9SRoy Pledge * 24c89105c9SRoy Pledge * The DPIO service provides APIs for users to interact with the datapath 25c89105c9SRoy Pledge * by enqueueing and dequeing frame descriptors. 26c89105c9SRoy Pledge * 27c89105c9SRoy Pledge * The following set of APIs can be used to enqueue and dequeue frames 28c89105c9SRoy Pledge * as well as producing notification callbacks when data is available 29c89105c9SRoy Pledge * for dequeue. 30c89105c9SRoy Pledge */ 31c89105c9SRoy Pledge 32c89105c9SRoy Pledge #define DPAA2_IO_ANY_CPU -1 33c89105c9SRoy Pledge 34c89105c9SRoy Pledge /** 35c89105c9SRoy Pledge * struct dpaa2_io_desc - The DPIO descriptor 36c89105c9SRoy Pledge * @receives_notifications: Use notificaton mode. Non-zero if the DPIO 37c89105c9SRoy Pledge * has a channel. 38c89105c9SRoy Pledge * @has_8prio: Set to non-zero for channel with 8 priority WQs. Ignored 39c89105c9SRoy Pledge * unless receives_notification is TRUE. 40c89105c9SRoy Pledge * @cpu: The cpu index that at least interrupt handlers will 41c89105c9SRoy Pledge * execute on. 42c89105c9SRoy Pledge * @stash_affinity: The stash affinity for this portal favour 'cpu' 43c89105c9SRoy Pledge * @regs_cena: The cache enabled regs. 44c89105c9SRoy Pledge * @regs_cinh: The cache inhibited regs 45c89105c9SRoy Pledge * @dpio_id: The dpio index 46c89105c9SRoy Pledge * @qman_version: The qman version 472cf0b6feSIoana Ciornei * @qman_clk: The qman clock frequency in Hz 48c89105c9SRoy Pledge * 49c89105c9SRoy Pledge * Describes the attributes and features of the DPIO object. 50c89105c9SRoy Pledge */ 51c89105c9SRoy Pledge struct dpaa2_io_desc { 52c89105c9SRoy Pledge int receives_notifications; 53c89105c9SRoy Pledge int has_8prio; 54c89105c9SRoy Pledge int cpu; 55c89105c9SRoy Pledge void *regs_cena; 56c89105c9SRoy Pledge void __iomem *regs_cinh; 57c89105c9SRoy Pledge int dpio_id; 58c89105c9SRoy Pledge u32 qman_version; 592cf0b6feSIoana Ciornei u32 qman_clk; 60c89105c9SRoy Pledge }; 61c89105c9SRoy Pledge 62cf9ff75dSIoana Ciornei struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc, 63cf9ff75dSIoana Ciornei struct device *dev); 64c89105c9SRoy Pledge 65c89105c9SRoy Pledge void dpaa2_io_down(struct dpaa2_io *d); 66c89105c9SRoy Pledge 67c89105c9SRoy Pledge irqreturn_t dpaa2_io_irq(struct dpaa2_io *obj); 68c89105c9SRoy Pledge 69c89105c9SRoy Pledge struct dpaa2_io *dpaa2_io_service_select(int cpu); 70c89105c9SRoy Pledge 71c89105c9SRoy Pledge /** 72c89105c9SRoy Pledge * struct dpaa2_io_notification_ctx - The DPIO notification context structure 73c89105c9SRoy Pledge * @cb: The callback to be invoked when the notification arrives 74c89105c9SRoy Pledge * @is_cdan: Zero for FQDAN, non-zero for CDAN 75c89105c9SRoy Pledge * @id: FQID or channel ID, needed for rearm 76c89105c9SRoy Pledge * @desired_cpu: The cpu on which the notifications will show up. Use 77c89105c9SRoy Pledge * DPAA2_IO_ANY_CPU if don't care 78c89105c9SRoy Pledge * @dpio_id: The dpio index 79c89105c9SRoy Pledge * @qman64: The 64-bit context value shows up in the FQDAN/CDAN. 80c89105c9SRoy Pledge * @node: The list node 81c89105c9SRoy Pledge * @dpio_private: The dpio object internal to dpio_service 82c89105c9SRoy Pledge * 83c89105c9SRoy Pledge * Used when a FQDAN/CDAN registration is made by drivers. 84c89105c9SRoy Pledge */ 85c89105c9SRoy Pledge struct dpaa2_io_notification_ctx { 86c89105c9SRoy Pledge void (*cb)(struct dpaa2_io_notification_ctx *ctx); 87c89105c9SRoy Pledge int is_cdan; 88c89105c9SRoy Pledge u32 id; 89c89105c9SRoy Pledge int desired_cpu; 90c89105c9SRoy Pledge int dpio_id; 91c89105c9SRoy Pledge u64 qman64; 92c89105c9SRoy Pledge struct list_head node; 93c89105c9SRoy Pledge void *dpio_private; 94c89105c9SRoy Pledge }; 95c89105c9SRoy Pledge 96991e8732SIoana Ciornei int dpaa2_io_get_cpu(struct dpaa2_io *d); 97991e8732SIoana Ciornei 98c89105c9SRoy Pledge int dpaa2_io_service_register(struct dpaa2_io *service, 9947441f7fSIoana Ciornei struct dpaa2_io_notification_ctx *ctx, 10047441f7fSIoana Ciornei struct device *dev); 101c89105c9SRoy Pledge void dpaa2_io_service_deregister(struct dpaa2_io *service, 10247441f7fSIoana Ciornei struct dpaa2_io_notification_ctx *ctx, 10347441f7fSIoana Ciornei struct device *dev); 104c89105c9SRoy Pledge int dpaa2_io_service_rearm(struct dpaa2_io *service, 105c89105c9SRoy Pledge struct dpaa2_io_notification_ctx *ctx); 106c89105c9SRoy Pledge 10748c43de0SHoria Geantă int dpaa2_io_service_pull_fq(struct dpaa2_io *d, u32 fqid, 10848c43de0SHoria Geantă struct dpaa2_io_store *s); 109c89105c9SRoy Pledge int dpaa2_io_service_pull_channel(struct dpaa2_io *d, u32 channelid, 110c89105c9SRoy Pledge struct dpaa2_io_store *s); 111c89105c9SRoy Pledge 11248c43de0SHoria Geantă int dpaa2_io_service_enqueue_fq(struct dpaa2_io *d, u32 fqid, 11348c43de0SHoria Geantă const struct dpaa2_fd *fd); 1149d988097SYouri Querry int dpaa2_io_service_enqueue_multiple_fq(struct dpaa2_io *d, u32 fqid, 1159d988097SYouri Querry const struct dpaa2_fd *fd, int number_of_frame); 1169d988097SYouri Querry int dpaa2_io_service_enqueue_multiple_desc_fq(struct dpaa2_io *d, u32 *fqid, 1179d988097SYouri Querry const struct dpaa2_fd *fd, int number_of_frame); 118c89105c9SRoy Pledge int dpaa2_io_service_enqueue_qd(struct dpaa2_io *d, u32 qdid, u8 prio, 119c89105c9SRoy Pledge u16 qdbin, const struct dpaa2_fd *fd); 1208a533a7dSIoana Ciocoi Radulescu int dpaa2_io_service_release(struct dpaa2_io *d, u16 bpid, 121c89105c9SRoy Pledge const u64 *buffers, unsigned int num_buffers); 1228a533a7dSIoana Ciocoi Radulescu int dpaa2_io_service_acquire(struct dpaa2_io *d, u16 bpid, 123c89105c9SRoy Pledge u64 *buffers, unsigned int num_buffers); 124c89105c9SRoy Pledge 125c89105c9SRoy Pledge struct dpaa2_io_store *dpaa2_io_store_create(unsigned int max_frames, 126c89105c9SRoy Pledge struct device *dev); 127c89105c9SRoy Pledge void dpaa2_io_store_destroy(struct dpaa2_io_store *s); 128c89105c9SRoy Pledge struct dpaa2_dq *dpaa2_io_store_next(struct dpaa2_io_store *s, int *is_last); 129c89105c9SRoy Pledge 130e80081c3SRoy Pledge int dpaa2_io_query_fq_count(struct dpaa2_io *d, u32 fqid, 131e80081c3SRoy Pledge u32 *fcnt, u32 *bcnt); 132e80081c3SRoy Pledge int dpaa2_io_query_bp_count(struct dpaa2_io *d, u16 bpid, 133e80081c3SRoy Pledge u32 *num); 134ed1d2143SIoana Ciornei 135ed1d2143SIoana Ciornei int dpaa2_io_set_irq_coalescing(struct dpaa2_io *d, u32 irq_holdoff); 136ed1d2143SIoana Ciornei void dpaa2_io_get_irq_coalescing(struct dpaa2_io *d, u32 *irq_holdoff); 137*69651bd8SIoana Ciornei void dpaa2_io_set_adaptive_coalescing(struct dpaa2_io *d, 138*69651bd8SIoana Ciornei int use_adaptive_rx_coalesce); 139*69651bd8SIoana Ciornei int dpaa2_io_get_adaptive_coalescing(struct dpaa2_io *d); 140*69651bd8SIoana Ciornei void dpaa2_io_update_net_dim(struct dpaa2_io *d, __u64 frames, __u64 bytes); 141c89105c9SRoy Pledge #endif /* __FSL_DPAA2_IO_H */ 142