qed_ooo.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /* QLogic qed NIC Driver
  2. * Copyright (c) 2015-2017 QLogic Corporation
  3. *
  4. * This software is available to you under a choice of one of two
  5. * licenses. You may choose to be licensed under the terms of the GNU
  6. * General Public License (GPL) Version 2, available from the file
  7. * COPYING in the main directory of this source tree, or the
  8. * OpenIB.org BSD license below:
  9. *
  10. * Redistribution and use in source and binary forms, with or
  11. * without modification, are permitted provided that the following
  12. * conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above
  15. * copyright notice, this list of conditions and the following
  16. * disclaimer.
  17. *
  18. * - Redistributions in binary form must reproduce the above
  19. * copyright notice, this list of conditions and the following
  20. * disclaimer in the documentation and /or other materials
  21. * provided with the distribution.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  27. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  28. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  29. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  30. * SOFTWARE.
  31. */
  32. #ifndef _QED_OOO_H
  33. #define _QED_OOO_H
  34. #include <linux/types.h>
  35. #include <linux/list.h>
  36. #include <linux/slab.h>
  37. #include "qed.h"
  38. #define QED_MAX_NUM_ISLES 256
  39. #define QED_MAX_NUM_OOO_HISTORY_ENTRIES 512
  40. #define QED_OOO_LEFT_BUF 0
  41. #define QED_OOO_RIGHT_BUF 1
  42. struct qed_ooo_buffer {
  43. struct list_head list_entry;
  44. void *rx_buffer_virt_addr;
  45. dma_addr_t rx_buffer_phys_addr;
  46. u32 rx_buffer_size;
  47. u16 packet_length;
  48. u16 parse_flags;
  49. u16 vlan;
  50. u8 placement_offset;
  51. };
  52. struct qed_ooo_isle {
  53. struct list_head list_entry;
  54. struct list_head buffers_list;
  55. };
  56. struct qed_ooo_archipelago {
  57. struct list_head isles_list;
  58. };
  59. struct qed_ooo_history {
  60. struct ooo_opaque *p_cqes;
  61. u32 head_idx;
  62. u32 num_of_cqes;
  63. };
  64. struct qed_ooo_info {
  65. struct list_head free_buffers_list;
  66. struct list_head ready_buffers_list;
  67. struct list_head free_isles_list;
  68. struct qed_ooo_archipelago *p_archipelagos_mem;
  69. struct qed_ooo_isle *p_isles_mem;
  70. struct qed_ooo_history ooo_history;
  71. u32 cur_isles_number;
  72. u32 max_isles_number;
  73. u32 gen_isles_number;
  74. u16 max_num_archipelagos;
  75. u16 cid_base;
  76. };
  77. #if IS_ENABLED(CONFIG_QED_OOO)
  78. void qed_ooo_save_history_entry(struct qed_hwfn *p_hwfn,
  79. struct qed_ooo_info *p_ooo_info,
  80. struct ooo_opaque *p_cqe);
  81. int qed_ooo_alloc(struct qed_hwfn *p_hwfn);
  82. void qed_ooo_setup(struct qed_hwfn *p_hwfn);
  83. void qed_ooo_free(struct qed_hwfn *p_hwfn);
  84. void qed_ooo_release_connection_isles(struct qed_hwfn *p_hwfn,
  85. struct qed_ooo_info *p_ooo_info,
  86. u32 cid);
  87. void qed_ooo_release_all_isles(struct qed_hwfn *p_hwfn,
  88. struct qed_ooo_info *p_ooo_info);
  89. void qed_ooo_put_free_buffer(struct qed_hwfn *p_hwfn,
  90. struct qed_ooo_info *p_ooo_info,
  91. struct qed_ooo_buffer *p_buffer);
  92. struct qed_ooo_buffer *
  93. qed_ooo_get_free_buffer(struct qed_hwfn *p_hwfn,
  94. struct qed_ooo_info *p_ooo_info);
  95. void qed_ooo_put_ready_buffer(struct qed_hwfn *p_hwfn,
  96. struct qed_ooo_info *p_ooo_info,
  97. struct qed_ooo_buffer *p_buffer, u8 on_tail);
  98. struct qed_ooo_buffer *
  99. qed_ooo_get_ready_buffer(struct qed_hwfn *p_hwfn,
  100. struct qed_ooo_info *p_ooo_info);
  101. void qed_ooo_delete_isles(struct qed_hwfn *p_hwfn,
  102. struct qed_ooo_info *p_ooo_info,
  103. u32 cid, u8 drop_isle, u8 drop_size);
  104. void qed_ooo_add_new_isle(struct qed_hwfn *p_hwfn,
  105. struct qed_ooo_info *p_ooo_info,
  106. u32 cid,
  107. u8 ooo_isle, struct qed_ooo_buffer *p_buffer);
  108. void qed_ooo_add_new_buffer(struct qed_hwfn *p_hwfn,
  109. struct qed_ooo_info *p_ooo_info,
  110. u32 cid,
  111. u8 ooo_isle,
  112. struct qed_ooo_buffer *p_buffer, u8 buffer_side);
  113. void qed_ooo_join_isles(struct qed_hwfn *p_hwfn,
  114. struct qed_ooo_info *p_ooo_info, u32 cid,
  115. u8 left_isle);
  116. #else /* IS_ENABLED(CONFIG_QED_ISCSI) */
  117. static inline void qed_ooo_save_history_entry(struct qed_hwfn *p_hwfn,
  118. struct qed_ooo_info *p_ooo_info,
  119. struct ooo_opaque *p_cqe) {}
  120. static inline int qed_ooo_alloc(struct qed_hwfn *p_hwfn)
  121. {
  122. return -EINVAL;
  123. }
  124. static inline void qed_ooo_setup(struct qed_hwfn *p_hwfn) {}
  125. static inline void qed_ooo_free(struct qed_hwfn *p_hwfn) {}
  126. static inline void
  127. qed_ooo_release_connection_isles(struct qed_hwfn *p_hwfn,
  128. struct qed_ooo_info *p_ooo_info,
  129. u32 cid) {}
  130. static inline void qed_ooo_release_all_isles(struct qed_hwfn *p_hwfn,
  131. struct qed_ooo_info *p_ooo_info)
  132. {}
  133. static inline void qed_ooo_put_free_buffer(struct qed_hwfn *p_hwfn,
  134. struct qed_ooo_info *p_ooo_info,
  135. struct qed_ooo_buffer *p_buffer) {}
  136. static inline struct qed_ooo_buffer *
  137. qed_ooo_get_free_buffer(struct qed_hwfn *p_hwfn,
  138. struct qed_ooo_info *p_ooo_info) { return NULL; }
  139. static inline void qed_ooo_put_ready_buffer(struct qed_hwfn *p_hwfn,
  140. struct qed_ooo_info *p_ooo_info,
  141. struct qed_ooo_buffer *p_buffer,
  142. u8 on_tail) {}
  143. static inline struct qed_ooo_buffer *
  144. qed_ooo_get_ready_buffer(struct qed_hwfn *p_hwfn,
  145. struct qed_ooo_info *p_ooo_info) { return NULL; }
  146. static inline void qed_ooo_delete_isles(struct qed_hwfn *p_hwfn,
  147. struct qed_ooo_info *p_ooo_info,
  148. u32 cid, u8 drop_isle, u8 drop_size) {}
  149. static inline void qed_ooo_add_new_isle(struct qed_hwfn *p_hwfn,
  150. struct qed_ooo_info *p_ooo_info,
  151. u32 cid, u8 ooo_isle,
  152. struct qed_ooo_buffer *p_buffer) {}
  153. static inline void qed_ooo_add_new_buffer(struct qed_hwfn *p_hwfn,
  154. struct qed_ooo_info *p_ooo_info,
  155. u32 cid, u8 ooo_isle,
  156. struct qed_ooo_buffer *p_buffer,
  157. u8 buffer_side) {}
  158. static inline void qed_ooo_join_isles(struct qed_hwfn *p_hwfn,
  159. struct qed_ooo_info *p_ooo_info, u32 cid,
  160. u8 left_isle) {}
  161. #endif /* IS_ENABLED(CONFIG_QED_ISCSI) */
  162. #endif