dp_tx.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #ifndef __DP_TX_H
  19. #define __DP_TX_H
  20. #include <qdf_types.h>
  21. #include <qdf_nbuf.h>
  22. #include "dp_types.h"
  23. #define DP_STATS_ADD(x, y, z)
  24. #define DP_STATS_SUB(x, y, z)
  25. #define DP_STATS_MSDU_INCR(x, y, z)
  26. #define DP_TX_MAX_NUM_FRAGS 6
  27. #define DP_TX_DESC_FLAG_ALLOCATED 0x1
  28. #define DP_TX_DESC_FLAG_TO_FW 0x2
  29. #define DP_TX_DESC_FLAG_FRAG 0x4
  30. #define DP_TX_DESC_FLAG_RAW 0x8
  31. #define DP_TX_DESC_FLAG_MESH 0x10
  32. #define DP_TX_DESC_FLAG_QUEUED_TX 0x20
  33. #define DP_TX_DESC_FLAG_COMPLETED_TX 0x40
  34. #define DP_TX_FREE_SINGLE_BUF(soc, buf) \
  35. do { \
  36. qdf_nbuf_unmap(soc->osdev, buf, QDF_DMA_FROM_DEVICE); \
  37. qdf_nbuf_free(buf); \
  38. } while (0)
  39. #define DP_TX_FREE_DMA_TO_DEVICE(soc, vdev, buf) \
  40. do { \
  41. qdf_nbuf_unmap(soc->osdev, buf, QDF_DMA_TO_DEVICE); \
  42. if (!vdev->mesh_vdev) { \
  43. qdf_nbuf_free(buf); \
  44. } else { \
  45. vdev->osif_tx_free_ext((buf)); \
  46. } \
  47. } while (0)
  48. #define OCB_HEADER_VERSION 1
  49. /**
  50. * struct dp_tx_frag_info_s
  51. * @vaddr: hlos vritual address for buffer
  52. * @paddr_lo: physical address lower 32bits
  53. * @paddr_hi: physical address higher bits
  54. * @len: length of the buffer
  55. */
  56. struct dp_tx_frag_info_s {
  57. uint8_t *vaddr;
  58. uint32_t paddr_lo;
  59. uint16_t paddr_hi;
  60. uint16_t len;
  61. };
  62. /**
  63. * struct dp_tx_seg_info_s - Segmentation Descriptor
  64. * @nbuf: NBUF pointer if segment corresponds to separate nbuf
  65. * @frag_cnt: Fragment count in this segment
  66. * @total_len: Total length of segment
  67. * @frags: per-Fragment information
  68. * @next: pointer to next MSDU segment
  69. */
  70. struct dp_tx_seg_info_s {
  71. qdf_nbuf_t nbuf;
  72. uint16_t frag_cnt;
  73. uint16_t total_len;
  74. struct dp_tx_frag_info_s frags[DP_TX_MAX_NUM_FRAGS];
  75. struct dp_tx_seg_info_s *next;
  76. };
  77. /**
  78. * struct dp_tx_sg_info_s - Scatter Gather Descriptor
  79. * @num_segs: Number of segments (TSO/ME) in the frame
  80. * @total_len: Total length of the frame
  81. * @curr_seg: Points to current segment descriptor to be processed. Chain of
  82. * descriptors for SG frames/multicast-unicast converted packets.
  83. *
  84. * Used for SG (802.3 or Raw) frames and Multicast-Unicast converted frames to
  85. * carry fragmentation information
  86. * Raw Frames will be handed over to driver as an SKB chain with MPDU boundaries
  87. * indicated through flags in SKB CB (first_msdu and last_msdu). This will be
  88. * converted into set of skb sg (nr_frags) structures.
  89. */
  90. struct dp_tx_sg_info_s {
  91. uint32_t num_segs;
  92. uint32_t total_len;
  93. struct dp_tx_seg_info_s *curr_seg;
  94. };
  95. /**
  96. * struct dp_tx_queue - Tx queue
  97. * @desc_pool_id: Descriptor Pool to be used for the tx queue
  98. * @ring_id: TCL descriptor ring ID corresponding to the tx queue
  99. *
  100. * Tx queue contains information of the software (Descriptor pool)
  101. * and hardware resources (TCL ring id) to be used for a particular
  102. * transmit queue (obtained from skb_queue_mapping in case of linux)
  103. */
  104. struct dp_tx_queue {
  105. uint8_t desc_pool_id;
  106. uint8_t ring_id;
  107. };
  108. /**
  109. * struct dp_tx_msdu_info_s - MSDU Descriptor
  110. * @frm_type: Frame type - Regular/TSO/SG/Multicast enhancement
  111. * @tx_queue: Tx queue on which this MSDU should be transmitted
  112. * @num_seg: Number of segments (TSO)
  113. * @tid: TID (override) that is sent from HLOS
  114. * @u.tso_info: TSO information for TSO frame types
  115. * (chain of the TSO segments, number of segments)
  116. * @u.sg_info: Scatter Gather information for non-TSO SG frames
  117. *
  118. * This structure holds the complete MSDU information needed to program the
  119. * Hardware TCL and MSDU extension descriptors for different frame types
  120. *
  121. */
  122. struct dp_tx_msdu_info_s {
  123. enum dp_tx_frm_type frm_type;
  124. struct dp_tx_queue tx_queue;
  125. uint32_t num_seg;
  126. uint8_t tid;
  127. union {
  128. struct qdf_tso_info_t tso_info;
  129. struct dp_tx_sg_info_s sg_info;
  130. } u;
  131. uint32_t meta_data[5];
  132. };
  133. QDF_STATUS dp_tx_vdev_attach(struct dp_vdev *vdev);
  134. QDF_STATUS dp_tx_vdev_detach(struct dp_vdev *vdev);
  135. QDF_STATUS dp_tx_soc_attach(struct dp_soc *soc);
  136. QDF_STATUS dp_tx_soc_detach(struct dp_soc *soc);
  137. QDF_STATUS dp_tx_pdev_detach(struct dp_pdev *pdev);
  138. QDF_STATUS dp_tx_pdev_attach(struct dp_pdev *pdev);
  139. qdf_nbuf_t dp_tx_send(void *data_vdev, qdf_nbuf_t nbuf);
  140. uint32_t dp_tx_comp_handler(struct dp_soc *soc, uint32_t ring_id,
  141. uint32_t budget);
  142. /* TODO TX_FEATURE_NOT_YET */
  143. static inline void dp_tx_comp_process_exception(struct dp_tx_desc_s *tx_desc)
  144. {
  145. return;
  146. }
  147. static inline QDF_STATUS dp_tx_flow_control(struct dp_vdev *vdev)
  148. {
  149. return QDF_STATUS_SUCCESS;
  150. }
  151. static inline QDF_STATUS dp_tx_prepare_tso(struct dp_vdev *vdev,
  152. qdf_nbuf_t nbuf, struct dp_tx_msdu_info_s *msdu_info)
  153. {
  154. return QDF_STATUS_SUCCESS;
  155. }
  156. static inline qdf_nbuf_t dp_tx_prepare_me(struct dp_vdev *vdev,
  157. qdf_nbuf_t nbuf, struct dp_tx_msdu_info_s *msdu_info)
  158. {
  159. return nbuf;
  160. }
  161. /* TODO TX_FEATURE_NOT_YET */
  162. #endif