dpaa2-io.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
  2. /*
  3. * Copyright 2014-2016 Freescale Semiconductor Inc.
  4. * Copyright NXP
  5. *
  6. */
  7. #ifndef __FSL_DPAA2_IO_H
  8. #define __FSL_DPAA2_IO_H
  9. #include <linux/types.h>
  10. #include <linux/cpumask.h>
  11. #include <linux/irqreturn.h>
  12. #include "dpaa2-fd.h"
  13. #include "dpaa2-global.h"
  14. struct dpaa2_io;
  15. struct dpaa2_io_store;
  16. struct device;
  17. /**
  18. * DOC: DPIO Service
  19. *
  20. * The DPIO service provides APIs for users to interact with the datapath
  21. * by enqueueing and dequeing frame descriptors.
  22. *
  23. * The following set of APIs can be used to enqueue and dequeue frames
  24. * as well as producing notification callbacks when data is available
  25. * for dequeue.
  26. */
  27. #define DPAA2_IO_ANY_CPU -1
  28. /**
  29. * struct dpaa2_io_desc - The DPIO descriptor
  30. * @receives_notifications: Use notificaton mode. Non-zero if the DPIO
  31. * has a channel.
  32. * @has_8prio: Set to non-zero for channel with 8 priority WQs. Ignored
  33. * unless receives_notification is TRUE.
  34. * @cpu: The cpu index that at least interrupt handlers will
  35. * execute on.
  36. * @stash_affinity: The stash affinity for this portal favour 'cpu'
  37. * @regs_cena: The cache enabled regs.
  38. * @regs_cinh: The cache inhibited regs
  39. * @dpio_id: The dpio index
  40. * @qman_version: The qman version
  41. *
  42. * Describes the attributes and features of the DPIO object.
  43. */
  44. struct dpaa2_io_desc {
  45. int receives_notifications;
  46. int has_8prio;
  47. int cpu;
  48. void *regs_cena;
  49. void __iomem *regs_cinh;
  50. int dpio_id;
  51. u32 qman_version;
  52. };
  53. struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc);
  54. void dpaa2_io_down(struct dpaa2_io *d);
  55. irqreturn_t dpaa2_io_irq(struct dpaa2_io *obj);
  56. struct dpaa2_io *dpaa2_io_service_select(int cpu);
  57. /**
  58. * struct dpaa2_io_notification_ctx - The DPIO notification context structure
  59. * @cb: The callback to be invoked when the notification arrives
  60. * @is_cdan: Zero for FQDAN, non-zero for CDAN
  61. * @id: FQID or channel ID, needed for rearm
  62. * @desired_cpu: The cpu on which the notifications will show up. Use
  63. * DPAA2_IO_ANY_CPU if don't care
  64. * @dpio_id: The dpio index
  65. * @qman64: The 64-bit context value shows up in the FQDAN/CDAN.
  66. * @node: The list node
  67. * @dpio_private: The dpio object internal to dpio_service
  68. *
  69. * Used when a FQDAN/CDAN registration is made by drivers.
  70. */
  71. struct dpaa2_io_notification_ctx {
  72. void (*cb)(struct dpaa2_io_notification_ctx *ctx);
  73. int is_cdan;
  74. u32 id;
  75. int desired_cpu;
  76. int dpio_id;
  77. u64 qman64;
  78. struct list_head node;
  79. void *dpio_private;
  80. };
  81. int dpaa2_io_service_register(struct dpaa2_io *service,
  82. struct dpaa2_io_notification_ctx *ctx);
  83. void dpaa2_io_service_deregister(struct dpaa2_io *service,
  84. struct dpaa2_io_notification_ctx *ctx);
  85. int dpaa2_io_service_rearm(struct dpaa2_io *service,
  86. struct dpaa2_io_notification_ctx *ctx);
  87. int dpaa2_io_service_pull_channel(struct dpaa2_io *d, u32 channelid,
  88. struct dpaa2_io_store *s);
  89. int dpaa2_io_service_enqueue_qd(struct dpaa2_io *d, u32 qdid, u8 prio,
  90. u16 qdbin, const struct dpaa2_fd *fd);
  91. int dpaa2_io_service_release(struct dpaa2_io *d, u32 bpid,
  92. const u64 *buffers, unsigned int num_buffers);
  93. int dpaa2_io_service_acquire(struct dpaa2_io *d, u32 bpid,
  94. u64 *buffers, unsigned int num_buffers);
  95. struct dpaa2_io_store *dpaa2_io_store_create(unsigned int max_frames,
  96. struct device *dev);
  97. void dpaa2_io_store_destroy(struct dpaa2_io_store *s);
  98. struct dpaa2_dq *dpaa2_io_store_next(struct dpaa2_io_store *s, int *is_last);
  99. #endif /* __FSL_DPAA2_IO_H */