dpaa2-io.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
  2. /*
  3. * Copyright 2014-2016 Freescale Semiconductor Inc.
  4. * Copyright 2017-2019 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. * @qman_clk: The qman clock frequency in Hz
  42. *
  43. * Describes the attributes and features of the DPIO object.
  44. */
  45. struct dpaa2_io_desc {
  46. int receives_notifications;
  47. int has_8prio;
  48. int cpu;
  49. void *regs_cena;
  50. void __iomem *regs_cinh;
  51. int dpio_id;
  52. u32 qman_version;
  53. u32 qman_clk;
  54. };
  55. struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc,
  56. struct device *dev);
  57. void dpaa2_io_down(struct dpaa2_io *d);
  58. irqreturn_t dpaa2_io_irq(struct dpaa2_io *obj);
  59. struct dpaa2_io *dpaa2_io_service_select(int cpu);
  60. /**
  61. * struct dpaa2_io_notification_ctx - The DPIO notification context structure
  62. * @cb: The callback to be invoked when the notification arrives
  63. * @is_cdan: Zero for FQDAN, non-zero for CDAN
  64. * @id: FQID or channel ID, needed for rearm
  65. * @desired_cpu: The cpu on which the notifications will show up. Use
  66. * DPAA2_IO_ANY_CPU if don't care
  67. * @dpio_id: The dpio index
  68. * @qman64: The 64-bit context value shows up in the FQDAN/CDAN.
  69. * @node: The list node
  70. * @dpio_private: The dpio object internal to dpio_service
  71. *
  72. * Used when a FQDAN/CDAN registration is made by drivers.
  73. */
  74. struct dpaa2_io_notification_ctx {
  75. void (*cb)(struct dpaa2_io_notification_ctx *ctx);
  76. int is_cdan;
  77. u32 id;
  78. int desired_cpu;
  79. int dpio_id;
  80. u64 qman64;
  81. struct list_head node;
  82. void *dpio_private;
  83. };
  84. int dpaa2_io_get_cpu(struct dpaa2_io *d);
  85. int dpaa2_io_service_register(struct dpaa2_io *service,
  86. struct dpaa2_io_notification_ctx *ctx,
  87. struct device *dev);
  88. void dpaa2_io_service_deregister(struct dpaa2_io *service,
  89. struct dpaa2_io_notification_ctx *ctx,
  90. struct device *dev);
  91. int dpaa2_io_service_rearm(struct dpaa2_io *service,
  92. struct dpaa2_io_notification_ctx *ctx);
  93. int dpaa2_io_service_pull_fq(struct dpaa2_io *d, u32 fqid,
  94. struct dpaa2_io_store *s);
  95. int dpaa2_io_service_pull_channel(struct dpaa2_io *d, u32 channelid,
  96. struct dpaa2_io_store *s);
  97. int dpaa2_io_service_enqueue_fq(struct dpaa2_io *d, u32 fqid,
  98. const struct dpaa2_fd *fd);
  99. int dpaa2_io_service_enqueue_multiple_fq(struct dpaa2_io *d, u32 fqid,
  100. const struct dpaa2_fd *fd, int number_of_frame);
  101. int dpaa2_io_service_enqueue_multiple_desc_fq(struct dpaa2_io *d, u32 *fqid,
  102. const struct dpaa2_fd *fd, int number_of_frame);
  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, u16 bpid,
  106. const u64 *buffers, unsigned int num_buffers);
  107. int dpaa2_io_service_acquire(struct dpaa2_io *d, u16 bpid,
  108. u64 *buffers, unsigned int num_buffers);
  109. struct dpaa2_io_store *dpaa2_io_store_create(unsigned int max_frames,
  110. struct device *dev);
  111. void dpaa2_io_store_destroy(struct dpaa2_io_store *s);
  112. struct dpaa2_dq *dpaa2_io_store_next(struct dpaa2_io_store *s, int *is_last);
  113. int dpaa2_io_query_fq_count(struct dpaa2_io *d, u32 fqid,
  114. u32 *fcnt, u32 *bcnt);
  115. int dpaa2_io_query_bp_count(struct dpaa2_io *d, u16 bpid,
  116. u32 *num);
  117. int dpaa2_io_set_irq_coalescing(struct dpaa2_io *d, u32 irq_holdoff);
  118. void dpaa2_io_get_irq_coalescing(struct dpaa2_io *d, u32 *irq_holdoff);
  119. void dpaa2_io_set_adaptive_coalescing(struct dpaa2_io *d,
  120. int use_adaptive_rx_coalesce);
  121. int dpaa2_io_get_adaptive_coalescing(struct dpaa2_io *d);
  122. void dpaa2_io_update_net_dim(struct dpaa2_io *d, __u64 frames, __u64 bytes);
  123. #endif /* __FSL_DPAA2_IO_H */