WIP FPC-III support
[linux/fpc-iii.git] / drivers / net / ethernet / qlogic / qed / qed_ooo.h
blob3a7e1b59d6fc8247edca682956fcdd50f34f7a88
1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
2 /* QLogic qed NIC Driver
3 * Copyright (c) 2015-2017 QLogic Corporation
4 * Copyright (c) 2019-2020 Marvell International Ltd.
5 */
7 #ifndef _QED_OOO_H
8 #define _QED_OOO_H
9 #include <linux/types.h>
10 #include <linux/list.h>
11 #include <linux/slab.h>
12 #include "qed.h"
14 #define QED_MAX_NUM_ISLES 256
15 #define QED_MAX_NUM_OOO_HISTORY_ENTRIES 512
17 #define QED_OOO_LEFT_BUF 0
18 #define QED_OOO_RIGHT_BUF 1
20 struct qed_ooo_buffer {
21 struct list_head list_entry;
22 void *rx_buffer_virt_addr;
23 dma_addr_t rx_buffer_phys_addr;
24 u32 rx_buffer_size;
25 u16 packet_length;
26 u16 parse_flags;
27 u16 vlan;
28 u8 placement_offset;
31 struct qed_ooo_isle {
32 struct list_head list_entry;
33 struct list_head buffers_list;
36 struct qed_ooo_archipelago {
37 struct list_head isles_list;
40 struct qed_ooo_history {
41 struct ooo_opaque *p_cqes;
42 u32 head_idx;
43 u32 num_of_cqes;
46 struct qed_ooo_info {
47 struct list_head free_buffers_list;
48 struct list_head ready_buffers_list;
49 struct list_head free_isles_list;
50 struct qed_ooo_archipelago *p_archipelagos_mem;
51 struct qed_ooo_isle *p_isles_mem;
52 struct qed_ooo_history ooo_history;
53 u32 cur_isles_number;
54 u32 max_isles_number;
55 u32 gen_isles_number;
56 u16 max_num_archipelagos;
57 u16 cid_base;
60 #if IS_ENABLED(CONFIG_QED_OOO)
61 void qed_ooo_save_history_entry(struct qed_hwfn *p_hwfn,
62 struct qed_ooo_info *p_ooo_info,
63 struct ooo_opaque *p_cqe);
65 int qed_ooo_alloc(struct qed_hwfn *p_hwfn);
67 void qed_ooo_setup(struct qed_hwfn *p_hwfn);
69 void qed_ooo_free(struct qed_hwfn *p_hwfn);
71 void qed_ooo_release_connection_isles(struct qed_hwfn *p_hwfn,
72 struct qed_ooo_info *p_ooo_info,
73 u32 cid);
75 void qed_ooo_release_all_isles(struct qed_hwfn *p_hwfn,
76 struct qed_ooo_info *p_ooo_info);
78 void qed_ooo_put_free_buffer(struct qed_hwfn *p_hwfn,
79 struct qed_ooo_info *p_ooo_info,
80 struct qed_ooo_buffer *p_buffer);
82 struct qed_ooo_buffer *
83 qed_ooo_get_free_buffer(struct qed_hwfn *p_hwfn,
84 struct qed_ooo_info *p_ooo_info);
86 void qed_ooo_put_ready_buffer(struct qed_hwfn *p_hwfn,
87 struct qed_ooo_info *p_ooo_info,
88 struct qed_ooo_buffer *p_buffer, u8 on_tail);
90 struct qed_ooo_buffer *
91 qed_ooo_get_ready_buffer(struct qed_hwfn *p_hwfn,
92 struct qed_ooo_info *p_ooo_info);
94 void qed_ooo_delete_isles(struct qed_hwfn *p_hwfn,
95 struct qed_ooo_info *p_ooo_info,
96 u32 cid, u8 drop_isle, u8 drop_size);
98 void qed_ooo_add_new_isle(struct qed_hwfn *p_hwfn,
99 struct qed_ooo_info *p_ooo_info,
100 u32 cid,
101 u8 ooo_isle, struct qed_ooo_buffer *p_buffer);
103 void qed_ooo_add_new_buffer(struct qed_hwfn *p_hwfn,
104 struct qed_ooo_info *p_ooo_info,
105 u32 cid,
106 u8 ooo_isle,
107 struct qed_ooo_buffer *p_buffer, u8 buffer_side);
109 void qed_ooo_join_isles(struct qed_hwfn *p_hwfn,
110 struct qed_ooo_info *p_ooo_info, u32 cid,
111 u8 left_isle);
112 #else /* IS_ENABLED(CONFIG_QED_ISCSI) */
113 static inline void qed_ooo_save_history_entry(struct qed_hwfn *p_hwfn,
114 struct qed_ooo_info *p_ooo_info,
115 struct ooo_opaque *p_cqe) {}
117 static inline int qed_ooo_alloc(struct qed_hwfn *p_hwfn)
119 return -EINVAL;
122 static inline void qed_ooo_setup(struct qed_hwfn *p_hwfn) {}
124 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) {}
131 static inline void qed_ooo_release_all_isles(struct qed_hwfn *p_hwfn,
132 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) {}
139 static inline struct qed_ooo_buffer *
140 qed_ooo_get_free_buffer(struct qed_hwfn *p_hwfn,
141 struct qed_ooo_info *p_ooo_info) { return NULL; }
143 static inline void qed_ooo_put_ready_buffer(struct qed_hwfn *p_hwfn,
144 struct qed_ooo_info *p_ooo_info,
145 struct qed_ooo_buffer *p_buffer,
146 u8 on_tail) {}
148 static inline struct qed_ooo_buffer *
149 qed_ooo_get_ready_buffer(struct qed_hwfn *p_hwfn,
150 struct qed_ooo_info *p_ooo_info) { return NULL; }
152 static inline void qed_ooo_delete_isles(struct qed_hwfn *p_hwfn,
153 struct qed_ooo_info *p_ooo_info,
154 u32 cid, u8 drop_isle, u8 drop_size) {}
156 static inline void qed_ooo_add_new_isle(struct qed_hwfn *p_hwfn,
157 struct qed_ooo_info *p_ooo_info,
158 u32 cid, u8 ooo_isle,
159 struct qed_ooo_buffer *p_buffer) {}
161 static inline void qed_ooo_add_new_buffer(struct qed_hwfn *p_hwfn,
162 struct qed_ooo_info *p_ooo_info,
163 u32 cid, u8 ooo_isle,
164 struct qed_ooo_buffer *p_buffer,
165 u8 buffer_side) {}
167 static inline void qed_ooo_join_isles(struct qed_hwfn *p_hwfn,
168 struct qed_ooo_info *p_ooo_info, u32 cid,
169 u8 left_isle) {}
170 #endif /* IS_ENABLED(CONFIG_QED_ISCSI) */
172 #endif