forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/net/ethernet/qlogic/qed/qed_cxt.h
....@@ -1,33 +1,7 @@
1
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
12 /* QLogic qed NIC Driver
23 * 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.
4
+ * Copyright (c) 2019-2020 Marvell International Ltd.
315 */
326
337 #ifndef _QED_CXT_H
....@@ -82,7 +56,8 @@
8256 enum qed_cxt_elem_type {
8357 QED_ELEM_CXT,
8458 QED_ELEM_SRQ,
85
- QED_ELEM_TASK
59
+ QED_ELEM_TASK,
60
+ QED_ELEM_XRC_SRQ,
8661 };
8762
8863 u32 qed_cxt_get_proto_cid_count(struct qed_hwfn *p_hwfn,
....@@ -235,11 +210,143 @@
235210 enum protocol_type type);
236211 u32 qed_cxt_get_proto_cid_start(struct qed_hwfn *p_hwfn,
237212 enum protocol_type type);
238
-u32 qed_cxt_get_srq_count(struct qed_hwfn *p_hwfn);
239213 int qed_cxt_free_proto_ilt(struct qed_hwfn *p_hwfn, enum protocol_type proto);
240214
241215 #define QED_CTX_WORKING_MEM 0
242216 #define QED_CTX_FL_MEM 1
243217 int qed_cxt_get_task_ctx(struct qed_hwfn *p_hwfn,
244218 u32 tid, u8 ctx_type, void **task_ctx);
219
+
220
+/* Max number of connection types in HW (DQ/CDU etc.) */
221
+#define MAX_CONN_TYPES PROTOCOLID_COMMON
222
+#define NUM_TASK_TYPES 2
223
+#define NUM_TASK_PF_SEGMENTS 4
224
+#define NUM_TASK_VF_SEGMENTS 1
225
+
226
+/* PF per protocl configuration object */
227
+#define TASK_SEGMENTS (NUM_TASK_PF_SEGMENTS + NUM_TASK_VF_SEGMENTS)
228
+#define TASK_SEGMENT_VF (NUM_TASK_PF_SEGMENTS)
229
+
230
+struct qed_tid_seg {
231
+ u32 count;
232
+ u8 type;
233
+ bool has_fl_mem;
234
+};
235
+
236
+struct qed_conn_type_cfg {
237
+ u32 cid_count;
238
+ u32 cids_per_vf;
239
+ struct qed_tid_seg tid_seg[TASK_SEGMENTS];
240
+};
241
+
242
+/* ILT Client configuration,
243
+ * Per connection type (protocol) resources (cids, tis, vf cids etc.)
244
+ * 1 - for connection context (CDUC) and for each task context we need two
245
+ * values, for regular task context and for force load memory
246
+ */
247
+#define ILT_CLI_PF_BLOCKS (1 + NUM_TASK_PF_SEGMENTS * 2)
248
+#define ILT_CLI_VF_BLOCKS (1 + NUM_TASK_VF_SEGMENTS * 2)
249
+#define CDUC_BLK (0)
250
+#define SRQ_BLK (0)
251
+#define CDUT_SEG_BLK(n) (1 + (u8)(n))
252
+#define CDUT_FL_SEG_BLK(n, X) (1 + (n) + NUM_TASK_ ## X ## _SEGMENTS)
253
+
254
+struct ilt_cfg_pair {
255
+ u32 reg;
256
+ u32 val;
257
+};
258
+
259
+struct qed_ilt_cli_blk {
260
+ u32 total_size; /* 0 means not active */
261
+ u32 real_size_in_page;
262
+ u32 start_line;
263
+ u32 dynamic_line_offset;
264
+ u32 dynamic_line_cnt;
265
+};
266
+
267
+struct qed_ilt_client_cfg {
268
+ bool active;
269
+
270
+ /* ILT boundaries */
271
+ struct ilt_cfg_pair first;
272
+ struct ilt_cfg_pair last;
273
+ struct ilt_cfg_pair p_size;
274
+
275
+ /* ILT client blocks for PF */
276
+ struct qed_ilt_cli_blk pf_blks[ILT_CLI_PF_BLOCKS];
277
+ u32 pf_total_lines;
278
+
279
+ /* ILT client blocks for VFs */
280
+ struct qed_ilt_cli_blk vf_blks[ILT_CLI_VF_BLOCKS];
281
+ u32 vf_total_lines;
282
+};
283
+
284
+struct qed_cid_acquired_map {
285
+ u32 start_cid;
286
+ u32 max_count;
287
+ unsigned long *cid_map;
288
+};
289
+
290
+struct qed_src_t2 {
291
+ struct phys_mem_desc *dma_mem;
292
+ u32 num_pages;
293
+ u64 first_free;
294
+ u64 last_free;
295
+};
296
+
297
+struct qed_cxt_mngr {
298
+ /* Per protocl configuration */
299
+ struct qed_conn_type_cfg conn_cfg[MAX_CONN_TYPES];
300
+
301
+ /* computed ILT structure */
302
+ struct qed_ilt_client_cfg clients[MAX_ILT_CLIENTS];
303
+
304
+ /* Task type sizes */
305
+ u32 task_type_size[NUM_TASK_TYPES];
306
+
307
+ /* total number of VFs for this hwfn -
308
+ * ALL VFs are symmetric in terms of HW resources
309
+ */
310
+ u32 vf_count;
311
+ u32 first_vf_in_pf;
312
+
313
+ /* Acquired CIDs */
314
+ struct qed_cid_acquired_map acquired[MAX_CONN_TYPES];
315
+
316
+ struct qed_cid_acquired_map
317
+ acquired_vf[MAX_CONN_TYPES][MAX_NUM_VFS];
318
+
319
+ /* ILT shadow table */
320
+ struct phys_mem_desc *ilt_shadow;
321
+ u32 ilt_shadow_size;
322
+ u32 pf_start_line;
323
+
324
+ /* Mutex for a dynamic ILT allocation */
325
+ struct mutex mutex;
326
+
327
+ /* SRC T2 */
328
+ struct qed_src_t2 src_t2;
329
+
330
+ /* total number of SRQ's for this hwfn */
331
+ u32 srq_count;
332
+ u32 xrc_srq_count;
333
+
334
+ /* Maximal number of L2 steering filters */
335
+ u32 arfs_count;
336
+
337
+ u8 task_type_id;
338
+ u16 task_ctx_size;
339
+ u16 conn_ctx_size;
340
+};
341
+
342
+u16 qed_get_cdut_num_pf_init_pages(struct qed_hwfn *p_hwfn);
343
+u16 qed_get_cdut_num_vf_init_pages(struct qed_hwfn *p_hwfn);
344
+u16 qed_get_cdut_num_pf_work_pages(struct qed_hwfn *p_hwfn);
345
+u16 qed_get_cdut_num_vf_work_pages(struct qed_hwfn *p_hwfn);
346
+
347
+u32 qed_cxt_get_ilt_page_size(struct qed_hwfn *p_hwfn,
348
+ enum ilt_clients ilt_client);
349
+
350
+u32 qed_cxt_get_total_srq_count(struct qed_hwfn *p_hwfn);
351
+
245352 #endif