1
2
3
4
5
6
7#ifndef _QED_LL2_H
8#define _QED_LL2_H
9
10#include <linux/types.h>
11#include <linux/kernel.h>
12#include <linux/list.h>
13#include <linux/mutex.h>
14#include <linux/slab.h>
15#include <linux/spinlock.h>
16#include <linux/qed/qed_chain.h>
17#include <linux/qed/qed_ll2_if.h>
18#include "qed.h"
19#include "qed_hsi.h"
20#include "qed_sp.h"
21
22#define QED_MAX_NUM_OF_LL2_CONNECTIONS (4)
23
24
25
26#define QED_MAX_NUM_OF_LL2_CONNS_PF (4)
27#define QED_MAX_NUM_OF_LEGACY_LL2_CONNS_PF (3)
28
29#define QED_MAX_NUM_OF_CTX_LL2_CONNS_PF \
30 (QED_MAX_NUM_OF_LL2_CONNS_PF - QED_MAX_NUM_OF_LEGACY_LL2_CONNS_PF)
31
32#define QED_LL2_LEGACY_CONN_BASE_PF 0
33#define QED_LL2_CTX_CONN_BASE_PF QED_MAX_NUM_OF_LEGACY_LL2_CONNS_PF
34
35struct qed_ll2_rx_packet {
36 struct list_head list_entry;
37 struct core_rx_bd_with_buff_len *rxq_bd;
38 dma_addr_t rx_buf_addr;
39 u16 buf_length;
40 void *cookie;
41 u8 placement_offset;
42 u16 parse_flags;
43 u16 packet_length;
44 u16 vlan;
45 u32 opaque_data[2];
46};
47
48struct qed_ll2_tx_packet {
49 struct list_head list_entry;
50 u16 bd_used;
51 bool notify_fw;
52 void *cookie;
53
54 struct {
55 struct core_tx_bd *txq_bd;
56 dma_addr_t tx_frag;
57 u16 frag_len;
58 } bds_set[];
59};
60
61struct qed_ll2_rx_queue {
62
63 spinlock_t lock;
64 struct qed_chain rxq_chain;
65 struct qed_chain rcq_chain;
66 u8 rx_sb_index;
67 u8 ctx_based;
68 bool b_cb_registered;
69 __le16 *p_fw_cons;
70 struct list_head active_descq;
71 struct list_head free_descq;
72 struct list_head posting_descq;
73 struct qed_ll2_rx_packet *descq_array;
74 void __iomem *set_prod_addr;
75 struct core_pwm_prod_update_data db_data;
76};
77
78struct qed_ll2_tx_queue {
79
80 spinlock_t lock;
81 struct qed_chain txq_chain;
82 u8 tx_sb_index;
83 bool b_cb_registered;
84 __le16 *p_fw_cons;
85 struct list_head active_descq;
86 struct list_head free_descq;
87 struct list_head sending_descq;
88 u16 cur_completing_bd_idx;
89 void __iomem *doorbell_addr;
90 struct core_db_data db_msg;
91 u16 bds_idx;
92 u16 cur_send_frag_num;
93 u16 cur_completing_frag_num;
94 bool b_completing_packet;
95 void *descq_mem;
96 struct qed_ll2_tx_packet *cur_send_packet;
97 struct qed_ll2_tx_packet cur_completing_packet;
98};
99
100struct qed_ll2_info {
101
102 struct mutex mutex;
103
104 struct qed_ll2_acquire_data_inputs input;
105 u32 cid;
106 u8 my_id;
107 u8 queue_id;
108 u8 tx_stats_id;
109 bool b_active;
110 enum core_tx_dest tx_dest;
111 u8 tx_stats_en;
112 bool main_func_queue;
113 struct qed_ll2_rx_queue rx_queue;
114 struct qed_ll2_tx_queue tx_queue;
115 struct qed_ll2_cbs cbs;
116};
117
118extern const struct qed_ll2_ops qed_ll2_ops_pass;
119
120
121
122
123
124
125
126
127
128
129
130
131int qed_ll2_acquire_connection(void *cxt, struct qed_ll2_acquire_data *data);
132
133
134
135
136
137
138
139
140
141
142int qed_ll2_establish_connection(void *cxt, u8 connection_handle);
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157int qed_ll2_post_rx_buffer(void *cxt,
158 u8 connection_handle,
159 dma_addr_t addr,
160 u16 buf_len, void *cookie, u8 notify_fw);
161
162
163
164
165
166
167
168
169
170
171
172
173int qed_ll2_prepare_tx_packet(void *cxt,
174 u8 connection_handle,
175 struct qed_ll2_tx_pkt_info *pkt,
176 bool notify_fw);
177
178
179
180
181
182
183
184
185
186
187
188void qed_ll2_release_connection(void *cxt, u8 connection_handle);
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203int qed_ll2_set_fragment_of_tx_packet(void *cxt,
204 u8 connection_handle,
205 dma_addr_t addr, u16 nbytes);
206
207
208
209
210
211
212
213
214
215
216int qed_ll2_terminate_connection(void *cxt, u8 connection_handle);
217
218
219
220
221
222
223
224
225
226
227
228int qed_ll2_get_stats(void *cxt,
229 u8 connection_handle, struct qed_ll2_stats *p_stats);
230
231
232
233
234
235
236
237
238int qed_ll2_alloc(struct qed_hwfn *p_hwfn);
239
240
241
242
243
244
245
246
247
248void qed_ll2_setup(struct qed_hwfn *p_hwfn);
249
250
251
252
253
254
255
256
257
258void qed_ll2_free(struct qed_hwfn *p_hwfn);
259
260#endif
261