qed_ooo.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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 list_entry;
  58. struct list_head isles_list;
  59. u32 cid;
  60. };
  61. struct qed_ooo_history {
  62. struct ooo_opaque *p_cqes;
  63. u32 head_idx;
  64. u32 num_of_cqes;
  65. };
  66. struct qed_ooo_info {
  67. struct list_head free_buffers_list;
  68. struct list_head ready_buffers_list;
  69. struct list_head free_isles_list;
  70. struct list_head free_archipelagos_list;
  71. struct list_head archipelagos_list;
  72. struct qed_ooo_archipelago *p_archipelagos_mem;
  73. struct qed_ooo_isle *p_isles_mem;
  74. struct qed_ooo_history ooo_history;
  75. u32 cur_isles_number;
  76. u32 max_isles_number;
  77. u32 gen_isles_number;
  78. };
  79. #if IS_ENABLED(CONFIG_QED_ISCSI)
  80. void qed_ooo_save_history_entry(struct qed_hwfn *p_hwfn,
  81. struct qed_ooo_info *p_ooo_info,
  82. struct ooo_opaque *p_cqe);
  83. struct qed_ooo_info *qed_ooo_alloc(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_setup(struct qed_hwfn *p_hwfn, struct qed_ooo_info *p_ooo_info);
  90. void qed_ooo_free(struct qed_hwfn *p_hwfn, struct qed_ooo_info *p_ooo_info);
  91. void qed_ooo_put_free_buffer(struct qed_hwfn *p_hwfn,
  92. struct qed_ooo_info *p_ooo_info,
  93. struct qed_ooo_buffer *p_buffer);
  94. struct qed_ooo_buffer *
  95. qed_ooo_get_free_buffer(struct qed_hwfn *p_hwfn,
  96. struct qed_ooo_info *p_ooo_info);
  97. void qed_ooo_put_ready_buffer(struct qed_hwfn *p_hwfn,
  98. struct qed_ooo_info *p_ooo_info,
  99. struct qed_ooo_buffer *p_buffer, u8 on_tail);
  100. struct qed_ooo_buffer *
  101. qed_ooo_get_ready_buffer(struct qed_hwfn *p_hwfn,
  102. struct qed_ooo_info *p_ooo_info);
  103. void qed_ooo_delete_isles(struct qed_hwfn *p_hwfn,
  104. struct qed_ooo_info *p_ooo_info,
  105. u32 cid, u8 drop_isle, u8 drop_size);
  106. void qed_ooo_add_new_isle(struct qed_hwfn *p_hwfn,
  107. struct qed_ooo_info *p_ooo_info,
  108. u32 cid,
  109. u8 ooo_isle, struct qed_ooo_buffer *p_buffer);
  110. void qed_ooo_add_new_buffer(struct qed_hwfn *p_hwfn,
  111. struct qed_ooo_info *p_ooo_info,
  112. u32 cid,
  113. u8 ooo_isle,
  114. struct qed_ooo_buffer *p_buffer, u8 buffer_side);
  115. void qed_ooo_join_isles(struct qed_hwfn *p_hwfn,
  116. struct qed_ooo_info *p_ooo_info, u32 cid,
  117. u8 left_isle);
  118. #else /* IS_ENABLED(CONFIG_QED_ISCSI) */
  119. static inline void qed_ooo_save_history_entry(struct qed_hwfn *p_hwfn,
  120. struct qed_ooo_info *p_ooo_info,
  121. struct ooo_opaque *p_cqe) {}
  122. static inline struct qed_ooo_info *qed_ooo_alloc(
  123. struct qed_hwfn *p_hwfn) { return NULL; }
  124. static inline void
  125. qed_ooo_release_connection_isles(struct qed_hwfn *p_hwfn,
  126. struct qed_ooo_info *p_ooo_info,
  127. u32 cid) {}
  128. static inline void qed_ooo_release_all_isles(struct qed_hwfn *p_hwfn,
  129. struct qed_ooo_info *p_ooo_info)
  130. {}
  131. static inline void qed_ooo_setup(struct qed_hwfn *p_hwfn,
  132. struct qed_ooo_info *p_ooo_info) {}
  133. static inline void qed_ooo_free(struct qed_hwfn *p_hwfn,
  134. struct qed_ooo_info *p_ooo_info) {}
  135. static inline void qed_ooo_put_free_buffer(struct qed_hwfn *p_hwfn,
  136. struct qed_ooo_info *p_ooo_info,
  137. struct qed_ooo_buffer *p_buffer) {}
  138. static inline struct qed_ooo_buffer *
  139. qed_ooo_get_free_buffer(struct qed_hwfn *p_hwfn,
  140. struct qed_ooo_info *p_ooo_info) { return NULL; }
  141. static inline void qed_ooo_put_ready_buffer(struct qed_hwfn *p_hwfn,
  142. struct qed_ooo_info *p_ooo_info,
  143. struct qed_ooo_buffer *p_buffer,
  144. u8 on_tail) {}
  145. static inline struct qed_ooo_buffer *
  146. qed_ooo_get_ready_buffer(struct qed_hwfn *p_hwfn,
  147. struct qed_ooo_info *p_ooo_info) { return NULL; }
  148. static inline void qed_ooo_delete_isles(struct qed_hwfn *p_hwfn,
  149. struct qed_ooo_info *p_ooo_info,
  150. u32 cid, u8 drop_isle, u8 drop_size) {}
  151. static inline void qed_ooo_add_new_isle(struct qed_hwfn *p_hwfn,
  152. struct qed_ooo_info *p_ooo_info,
  153. u32 cid, u8 ooo_isle,
  154. struct qed_ooo_buffer *p_buffer) {}
  155. static inline void qed_ooo_add_new_buffer(struct qed_hwfn *p_hwfn,
  156. struct qed_ooo_info *p_ooo_info,
  157. u32 cid, u8 ooo_isle,
  158. struct qed_ooo_buffer *p_buffer,
  159. u8 buffer_side) {}
  160. static inline void qed_ooo_join_isles(struct qed_hwfn *p_hwfn,
  161. struct qed_ooo_info *p_ooo_info, u32 cid,
  162. u8 left_isle) {}
  163. #endif /* IS_ENABLED(CONFIG_QED_ISCSI) */
  164. #endif