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 33 #ifndef _QED_OOO_H 34 #define _QED_OOO_H 35 #include <linux/types.h> 36 #include <linux/list.h> 37 #include <linux/slab.h> 38 #include "qed.h" 39 40 #define QED_MAX_NUM_ISLES 256 41 #define QED_MAX_NUM_OOO_HISTORY_ENTRIES 512 42 43 #define QED_OOO_LEFT_BUF 0 44 #define QED_OOO_RIGHT_BUF 1 45 46 struct qed_ooo_buffer { 47 struct list_head list_entry; 48 void *rx_buffer_virt_addr; 49 dma_addr_t rx_buffer_phys_addr; 50 u32 rx_buffer_size; 51 u16 packet_length; 52 u16 parse_flags; 53 u16 vlan; 54 u8 placement_offset; 55 }; 56 57 struct qed_ooo_isle { 58 struct list_head list_entry; 59 struct list_head buffers_list; 60 }; 61 62 struct qed_ooo_archipelago { 63 struct list_head list_entry; 64 struct list_head isles_list; 65 u32 cid; 66 }; 67 68 struct qed_ooo_history { 69 struct ooo_opaque *p_cqes; 70 u32 head_idx; 71 u32 num_of_cqes; 72 }; 73 74 struct qed_ooo_info { 75 struct list_head free_buffers_list; 76 struct list_head ready_buffers_list; 77 struct list_head free_isles_list; 78 struct list_head free_archipelagos_list; 79 struct list_head archipelagos_list; 80 struct qed_ooo_archipelago *p_archipelagos_mem; 81 struct qed_ooo_isle *p_isles_mem; 82 struct qed_ooo_history ooo_history; 83 u32 cur_isles_number; 84 u32 max_isles_number; 85 u32 gen_isles_number; 86 }; 87 88 #if IS_ENABLED(CONFIG_QED_ISCSI) 89 void qed_ooo_save_history_entry(struct qed_hwfn *p_hwfn, 90 struct qed_ooo_info *p_ooo_info, 91 struct ooo_opaque *p_cqe); 92 93 struct qed_ooo_info *qed_ooo_alloc(struct qed_hwfn *p_hwfn); 94 95 void qed_ooo_release_connection_isles(struct qed_hwfn *p_hwfn, 96 struct qed_ooo_info *p_ooo_info, 97 u32 cid); 98 99 void qed_ooo_release_all_isles(struct qed_hwfn *p_hwfn, 100 struct qed_ooo_info *p_ooo_info); 101 102 void qed_ooo_setup(struct qed_hwfn *p_hwfn, struct qed_ooo_info *p_ooo_info); 103 104 void qed_ooo_free(struct qed_hwfn *p_hwfn, struct qed_ooo_info *p_ooo_info); 105 106 void qed_ooo_put_free_buffer(struct qed_hwfn *p_hwfn, 107 struct qed_ooo_info *p_ooo_info, 108 struct qed_ooo_buffer *p_buffer); 109 110 struct qed_ooo_buffer * 111 qed_ooo_get_free_buffer(struct qed_hwfn *p_hwfn, 112 struct qed_ooo_info *p_ooo_info); 113 114 void qed_ooo_put_ready_buffer(struct qed_hwfn *p_hwfn, 115 struct qed_ooo_info *p_ooo_info, 116 struct qed_ooo_buffer *p_buffer, u8 on_tail); 117 118 struct qed_ooo_buffer * 119 qed_ooo_get_ready_buffer(struct qed_hwfn *p_hwfn, 120 struct qed_ooo_info *p_ooo_info); 121 122 void qed_ooo_delete_isles(struct qed_hwfn *p_hwfn, 123 struct qed_ooo_info *p_ooo_info, 124 u32 cid, u8 drop_isle, u8 drop_size); 125 126 void qed_ooo_add_new_isle(struct qed_hwfn *p_hwfn, 127 struct qed_ooo_info *p_ooo_info, 128 u32 cid, 129 u8 ooo_isle, struct qed_ooo_buffer *p_buffer); 130 131 void qed_ooo_add_new_buffer(struct qed_hwfn *p_hwfn, 132 struct qed_ooo_info *p_ooo_info, 133 u32 cid, 134 u8 ooo_isle, 135 struct qed_ooo_buffer *p_buffer, u8 buffer_side); 136 137 void qed_ooo_join_isles(struct qed_hwfn *p_hwfn, 138 struct qed_ooo_info *p_ooo_info, u32 cid, 139 u8 left_isle); 140 #else /* IS_ENABLED(CONFIG_QED_ISCSI) */ 141 static inline void qed_ooo_save_history_entry(struct qed_hwfn *p_hwfn, 142 struct qed_ooo_info *p_ooo_info, 143 struct ooo_opaque *p_cqe) {} 144 145 static inline struct qed_ooo_info *qed_ooo_alloc( 146 struct qed_hwfn *p_hwfn) { return NULL; } 147 148 static inline void 149 qed_ooo_release_connection_isles(struct qed_hwfn *p_hwfn, 150 struct qed_ooo_info *p_ooo_info, 151 u32 cid) {} 152 153 static inline void qed_ooo_release_all_isles(struct qed_hwfn *p_hwfn, 154 struct qed_ooo_info *p_ooo_info) 155 {} 156 157 static inline void qed_ooo_setup(struct qed_hwfn *p_hwfn, 158 struct qed_ooo_info *p_ooo_info) {} 159 160 static inline void qed_ooo_free(struct qed_hwfn *p_hwfn, 161 struct qed_ooo_info *p_ooo_info) {} 162 163 static inline void qed_ooo_put_free_buffer(struct qed_hwfn *p_hwfn, 164 struct qed_ooo_info *p_ooo_info, 165 struct qed_ooo_buffer *p_buffer) {} 166 167 static inline struct qed_ooo_buffer * 168 qed_ooo_get_free_buffer(struct qed_hwfn *p_hwfn, 169 struct qed_ooo_info *p_ooo_info) { return NULL; } 170 171 static inline void qed_ooo_put_ready_buffer(struct qed_hwfn *p_hwfn, 172 struct qed_ooo_info *p_ooo_info, 173 struct qed_ooo_buffer *p_buffer, 174 u8 on_tail) {} 175 176 static inline struct qed_ooo_buffer * 177 qed_ooo_get_ready_buffer(struct qed_hwfn *p_hwfn, 178 struct qed_ooo_info *p_ooo_info) { return NULL; } 179 180 static inline void qed_ooo_delete_isles(struct qed_hwfn *p_hwfn, 181 struct qed_ooo_info *p_ooo_info, 182 u32 cid, u8 drop_isle, u8 drop_size) {} 183 184 static inline void qed_ooo_add_new_isle(struct qed_hwfn *p_hwfn, 185 struct qed_ooo_info *p_ooo_info, 186 u32 cid, u8 ooo_isle, 187 struct qed_ooo_buffer *p_buffer) {} 188 189 static inline void qed_ooo_add_new_buffer(struct qed_hwfn *p_hwfn, 190 struct qed_ooo_info *p_ooo_info, 191 u32 cid, u8 ooo_isle, 192 struct qed_ooo_buffer *p_buffer, 193 u8 buffer_side) {} 194 195 static inline void qed_ooo_join_isles(struct qed_hwfn *p_hwfn, 196 struct qed_ooo_info *p_ooo_info, u32 cid, 197 u8 left_isle) {} 198 #endif /* IS_ENABLED(CONFIG_QED_ISCSI) */ 199 200 #endif 201