summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/qlogic/qed/qed_ooo.h
blob: 3a7e1b59d6fc8247edca682956fcdd50f34f7a88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
/* QLogic qed NIC Driver
 * Copyright (c) 2015-2017  QLogic Corporation
 * Copyright (c) 2019-2020 Marvell International Ltd.
 */

#ifndef _QED_OOO_H
#define _QED_OOO_H
#include <linux/types.h>
#include <linux/list.h>
#include <linux/slab.h>
#include "qed.h"

#define QED_MAX_NUM_ISLES	256
#define QED_MAX_NUM_OOO_HISTORY_ENTRIES	512

#define QED_OOO_LEFT_BUF	0
#define QED_OOO_RIGHT_BUF	1

struct qed_ooo_buffer {
	struct list_head list_entry;
	void *rx_buffer_virt_addr;
	dma_addr_t rx_buffer_phys_addr;
	u32 rx_buffer_size;
	u16 packet_length;
	u16 parse_flags;
	u16 vlan;
	u8 placement_offset;
};

struct qed_ooo_isle {
	struct list_head list_entry;
	struct list_head buffers_list;
};

struct qed_ooo_archipelago {
	struct list_head isles_list;
};

struct qed_ooo_history {
	struct ooo_opaque *p_cqes;
	u32 head_idx;
	u32 num_of_cqes;
};

struct qed_ooo_info {
	struct list_head free_buffers_list;
	struct list_head ready_buffers_list;
	struct list_head free_isles_list;
	struct qed_ooo_archipelago *p_archipelagos_mem;
	struct qed_ooo_isle *p_isles_mem;
	struct qed_ooo_history ooo_history;
	u32 cur_isles_number;
	u32 max_isles_number;
	u32 gen_isles_number;
	u16 max_num_archipelagos;
	u16 cid_base;
};

#if IS_ENABLED(CONFIG_QED_OOO)
void qed_ooo_save_history_entry(struct qed_hwfn *p_hwfn,
				struct qed_ooo_info *p_ooo_info,
				struct ooo_opaque *p_cqe);

int qed_ooo_alloc(struct qed_hwfn *p_hwfn);

void qed_ooo_setup(struct qed_hwfn *p_hwfn);

void qed_ooo_free(struct qed_hwfn *p_hwfn);

void qed_ooo_release_connection_isles(struct qed_hwfn *p_hwfn,
				      struct qed_ooo_info *p_ooo_info,
				      u32 cid);

void qed_ooo_release_all_isles(struct qed_hwfn *p_hwfn,
			       struct qed_ooo_info *p_ooo_info);

void qed_ooo_put_free_buffer(struct qed_hwfn *p_hwfn,
			     struct qed_ooo_info *p_ooo_info,
			     struct qed_ooo_buffer *p_buffer);

struct qed_ooo_buffer *
qed_ooo_get_free_buffer(struct qed_hwfn *p_hwfn,
			struct qed_ooo_info *p_ooo_info);

void qed_ooo_put_ready_buffer(struct qed_hwfn *p_hwfn,
			      struct qed_ooo_info *p_ooo_info,
			      struct qed_ooo_buffer *p_buffer, u8 on_tail);

struct qed_ooo_buffer *
qed_ooo_get_ready_buffer(struct qed_hwfn *p_hwfn,
			 struct qed_ooo_info *p_ooo_info);

void qed_ooo_delete_isles(struct qed_hwfn *p_hwfn,
			  struct qed_ooo_info *p_ooo_info,
			  u32 cid, u8 drop_isle, u8 drop_size);

void qed_ooo_add_new_isle(struct qed_hwfn *p_hwfn,
			  struct qed_ooo_info *p_ooo_info,
			  u32 cid,
			  u8 ooo_isle, struct qed_ooo_buffer *p_buffer);

void qed_ooo_add_new_buffer(struct qed_hwfn *p_hwfn,
			    struct qed_ooo_info *p_ooo_info,
			    u32 cid,
			    u8 ooo_isle,
			    struct qed_ooo_buffer *p_buffer, u8 buffer_side);

void qed_ooo_join_isles(struct qed_hwfn *p_hwfn,
			struct qed_ooo_info *p_ooo_info, u32 cid,
			u8 left_isle);
#else /* IS_ENABLED(CONFIG_QED_ISCSI) */
static inline void qed_ooo_save_history_entry(struct qed_hwfn *p_hwfn,
					      struct qed_ooo_info *p_ooo_info,
					      struct ooo_opaque *p_cqe) {}

static inline int qed_ooo_alloc(struct qed_hwfn *p_hwfn)
{
	return -EINVAL;
}

static inline void qed_ooo_setup(struct qed_hwfn *p_hwfn) {}

static inline void qed_ooo_free(struct qed_hwfn *p_hwfn) {}

static inline void
qed_ooo_release_connection_isles(struct qed_hwfn *p_hwfn,
				 struct qed_ooo_info *p_ooo_info,
				 u32 cid) {}

static inline void qed_ooo_release_all_isles(struct qed_hwfn *p_hwfn,
					     struct qed_ooo_info *p_ooo_info)
					     {}

static inline void qed_ooo_put_free_buffer(struct qed_hwfn *p_hwfn,
					   struct qed_ooo_info *p_ooo_info,
					   struct qed_ooo_buffer *p_buffer) {}

static inline struct qed_ooo_buffer *
qed_ooo_get_free_buffer(struct qed_hwfn *p_hwfn,
			struct qed_ooo_info *p_ooo_info) { return NULL; }

static inline void qed_ooo_put_ready_buffer(struct qed_hwfn *p_hwfn,
					    struct qed_ooo_info *p_ooo_info,
					    struct qed_ooo_buffer *p_buffer,
					    u8 on_tail) {}

static inline struct qed_ooo_buffer *
qed_ooo_get_ready_buffer(struct qed_hwfn *p_hwfn,
			 struct qed_ooo_info *p_ooo_info) { return NULL; }

static inline void qed_ooo_delete_isles(struct qed_hwfn *p_hwfn,
					struct qed_ooo_info *p_ooo_info,
					u32 cid, u8 drop_isle, u8 drop_size) {}

static inline void qed_ooo_add_new_isle(struct qed_hwfn *p_hwfn,
					struct qed_ooo_info *p_ooo_info,
					u32 cid, u8 ooo_isle,
					struct qed_ooo_buffer *p_buffer) {}

static inline void qed_ooo_add_new_buffer(struct qed_hwfn *p_hwfn,
					  struct qed_ooo_info *p_ooo_info,
					  u32 cid, u8 ooo_isle,
					  struct qed_ooo_buffer *p_buffer,
					  u8 buffer_side) {}

static inline void qed_ooo_join_isles(struct qed_hwfn *p_hwfn,
				      struct qed_ooo_info *p_ooo_info, u32 cid,
				      u8 left_isle) {}
#endif /* IS_ENABLED(CONFIG_QED_ISCSI) */

#endif