ipa_endpoint.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
  3. * Copyright (C) 2019-2022 Linaro Ltd.
  4. */
  5. #ifndef _IPA_ENDPOINT_H_
  6. #define _IPA_ENDPOINT_H_
  7. #include <linux/types.h>
  8. #include <linux/workqueue.h>
  9. #include <linux/if_ether.h>
  10. #include "gsi.h"
  11. #include "ipa_reg.h"
  12. struct net_device;
  13. struct sk_buff;
  14. struct ipa;
  15. struct ipa_gsi_endpoint_data;
  16. /* Non-zero granularity of counter used to implement aggregation timeout */
  17. #define IPA_AGGR_GRANULARITY 500 /* microseconds */
  18. #define IPA_MTU ETH_DATA_LEN
  19. enum ipa_endpoint_name {
  20. IPA_ENDPOINT_AP_COMMAND_TX,
  21. IPA_ENDPOINT_AP_LAN_RX,
  22. IPA_ENDPOINT_AP_MODEM_TX,
  23. IPA_ENDPOINT_AP_MODEM_RX,
  24. IPA_ENDPOINT_MODEM_COMMAND_TX,
  25. IPA_ENDPOINT_MODEM_LAN_TX,
  26. IPA_ENDPOINT_MODEM_LAN_RX,
  27. IPA_ENDPOINT_MODEM_AP_TX,
  28. IPA_ENDPOINT_MODEM_AP_RX,
  29. IPA_ENDPOINT_MODEM_DL_NLO_TX,
  30. IPA_ENDPOINT_COUNT, /* Number of names (not an index) */
  31. };
  32. #define IPA_ENDPOINT_MAX 32 /* Max supported by driver */
  33. /**
  34. * struct ipa_endpoint_tx - Endpoint configuration for TX endpoints
  35. * @seq_type: primary packet processing sequencer type
  36. * @seq_rep_type: sequencer type for replication processing
  37. * @status_endpoint: endpoint to which status elements are sent
  38. *
  39. * The @status_endpoint is only valid if the endpoint's @status_enable
  40. * flag is set.
  41. */
  42. struct ipa_endpoint_tx {
  43. enum ipa_seq_type seq_type;
  44. enum ipa_seq_rep_type seq_rep_type;
  45. enum ipa_endpoint_name status_endpoint;
  46. };
  47. /**
  48. * struct ipa_endpoint_rx - Endpoint configuration for RX endpoints
  49. * @buffer_size: requested receive buffer size (bytes)
  50. * @pad_align: power-of-2 boundary to which packet payload is aligned
  51. * @aggr_time_limit: time before aggregation closes (microseconds)
  52. * @aggr_hard_limit: whether aggregation closes before or after boundary
  53. * @aggr_close_eof: whether aggregation closes on end-of-frame
  54. * @holb_drop: whether to drop packets to avoid head-of-line blocking
  55. *
  56. * The actual size of the receive buffer is rounded up if necessary
  57. * to be a power-of-2 number of pages.
  58. *
  59. * With each packet it transfers, the IPA hardware can perform certain
  60. * transformations of its packet data. One of these is adding pad bytes
  61. * to the end of the packet data so the result ends on a power-of-2 boundary.
  62. *
  63. * It is also able to aggregate multiple packets into a single receive buffer.
  64. * Aggregation is "open" while a buffer is being filled, and "closes" when
  65. * certain criteria are met.
  66. *
  67. * A time limit can be specified to close aggregation. Aggregation will be
  68. * closed if this period passes after data is first written into a receive
  69. * buffer. If not specified, no time limit is imposed.
  70. *
  71. * Insufficient space available in the receive buffer can close aggregation.
  72. * The aggregation byte limit defines the point (in units of 1024 bytes) in
  73. * the buffer where aggregation closes. With a "soft" aggregation limit,
  74. * aggregation closes when a packet written to the buffer *crosses* that
  75. * aggregation limit. With a "hard" aggregation limit, aggregation will
  76. * close *before* writing a packet that would cross that boundary.
  77. */
  78. struct ipa_endpoint_rx {
  79. u32 buffer_size;
  80. u32 pad_align;
  81. u32 aggr_time_limit;
  82. bool aggr_hard_limit;
  83. bool aggr_close_eof;
  84. bool holb_drop;
  85. };
  86. /**
  87. * struct ipa_endpoint_config - IPA endpoint hardware configuration
  88. * @resource_group: resource group to assign endpoint to
  89. * @checksum: whether checksum offload is enabled
  90. * @qmap: whether endpoint uses QMAP protocol
  91. * @aggregation: whether endpoint supports aggregation
  92. * @status_enable: whether endpoint uses status elements
  93. * @dma_mode: whether endpoint operates in DMA mode
  94. * @dma_endpoint: peer endpoint, if operating in DMA mode
  95. * @tx: TX-specific endpoint information (see above)
  96. * @rx: RX-specific endpoint information (see above)
  97. */
  98. struct ipa_endpoint_config {
  99. u32 resource_group;
  100. bool checksum;
  101. bool qmap;
  102. bool aggregation;
  103. bool status_enable;
  104. bool dma_mode;
  105. enum ipa_endpoint_name dma_endpoint;
  106. union {
  107. struct ipa_endpoint_tx tx;
  108. struct ipa_endpoint_rx rx;
  109. };
  110. };
  111. /**
  112. * enum ipa_replenish_flag: RX buffer replenish flags
  113. *
  114. * @IPA_REPLENISH_ENABLED: Whether receive buffer replenishing is enabled
  115. * @IPA_REPLENISH_ACTIVE: Whether replenishing is underway
  116. * @IPA_REPLENISH_COUNT: Number of defined replenish flags
  117. */
  118. enum ipa_replenish_flag {
  119. IPA_REPLENISH_ENABLED,
  120. IPA_REPLENISH_ACTIVE,
  121. IPA_REPLENISH_COUNT, /* Number of flags (must be last) */
  122. };
  123. /**
  124. * struct ipa_endpoint - IPA endpoint information
  125. * @ipa: IPA pointer
  126. * @ee_id: Execution environmnent endpoint is associated with
  127. * @channel_id: GSI channel used by the endpoint
  128. * @endpoint_id: IPA endpoint number
  129. * @toward_ipa: Endpoint direction (true = TX, false = RX)
  130. * @config: Default endpoint configuration
  131. * @skb_frag_max: Maximum allowed number of TX SKB fragments
  132. * @evt_ring_id: GSI event ring used by the endpoint
  133. * @netdev: Network device pointer, if endpoint uses one
  134. * @replenish_flags: Replenishing state flags
  135. * @replenish_count: Total number of replenish transactions committed
  136. * @replenish_work: Work item used for repeated replenish failures
  137. */
  138. struct ipa_endpoint {
  139. struct ipa *ipa;
  140. enum gsi_ee_id ee_id;
  141. u32 channel_id;
  142. u32 endpoint_id;
  143. bool toward_ipa;
  144. struct ipa_endpoint_config config;
  145. u32 skb_frag_max; /* Used for netdev TX only */
  146. u32 evt_ring_id;
  147. /* Net device this endpoint is associated with, if any */
  148. struct net_device *netdev;
  149. /* Receive buffer replenishing for RX endpoints */
  150. DECLARE_BITMAP(replenish_flags, IPA_REPLENISH_COUNT);
  151. u64 replenish_count;
  152. struct delayed_work replenish_work; /* global wq */
  153. };
  154. void ipa_endpoint_modem_hol_block_clear_all(struct ipa *ipa);
  155. void ipa_endpoint_modem_pause_all(struct ipa *ipa, bool enable);
  156. int ipa_endpoint_modem_exception_reset_all(struct ipa *ipa);
  157. int ipa_endpoint_skb_tx(struct ipa_endpoint *endpoint, struct sk_buff *skb);
  158. int ipa_endpoint_enable_one(struct ipa_endpoint *endpoint);
  159. void ipa_endpoint_disable_one(struct ipa_endpoint *endpoint);
  160. void ipa_endpoint_suspend_one(struct ipa_endpoint *endpoint);
  161. void ipa_endpoint_resume_one(struct ipa_endpoint *endpoint);
  162. void ipa_endpoint_suspend(struct ipa *ipa);
  163. void ipa_endpoint_resume(struct ipa *ipa);
  164. void ipa_endpoint_setup(struct ipa *ipa);
  165. void ipa_endpoint_teardown(struct ipa *ipa);
  166. int ipa_endpoint_config(struct ipa *ipa);
  167. void ipa_endpoint_deconfig(struct ipa *ipa);
  168. void ipa_endpoint_default_route_set(struct ipa *ipa, u32 endpoint_id);
  169. void ipa_endpoint_default_route_clear(struct ipa *ipa);
  170. u32 ipa_endpoint_init(struct ipa *ipa, u32 count,
  171. const struct ipa_gsi_endpoint_data *data);
  172. void ipa_endpoint_exit(struct ipa *ipa);
  173. void ipa_endpoint_trans_complete(struct ipa_endpoint *ipa,
  174. struct gsi_trans *trans);
  175. void ipa_endpoint_trans_release(struct ipa_endpoint *ipa,
  176. struct gsi_trans *trans);
  177. #endif /* _IPA_ENDPOINT_H_ */