1adfc5217SJeff Kirsher /* bnx2x_sp.h: Broadcom Everest network driver.
2adfc5217SJeff Kirsher  *
3247fa82bSYuval Mintz  * Copyright (c) 2011-2013 Broadcom Corporation
4adfc5217SJeff Kirsher  *
5adfc5217SJeff Kirsher  * Unless you and Broadcom execute a separate written software license
6adfc5217SJeff Kirsher  * agreement governing use of this software, this software is licensed to you
7adfc5217SJeff Kirsher  * under the terms of the GNU General Public License version 2, available
8adfc5217SJeff Kirsher  * at http://www.gnu.org/licenses/old-licenses/gpl-2.0.html (the "GPL").
9adfc5217SJeff Kirsher  *
10adfc5217SJeff Kirsher  * Notwithstanding the above, under no circumstances may you combine this
11adfc5217SJeff Kirsher  * software in any way with any other Broadcom software provided under a
12adfc5217SJeff Kirsher  * license other than the GPL, without Broadcom's express prior written
13adfc5217SJeff Kirsher  * consent.
14adfc5217SJeff Kirsher  *
1508f6dd89SAriel Elior  * Maintained by: Ariel Elior <ariel.elior@qlogic.com>
16adfc5217SJeff Kirsher  * Written by: Vladislav Zolotarov
17adfc5217SJeff Kirsher  *
18adfc5217SJeff Kirsher  */
19adfc5217SJeff Kirsher #ifndef BNX2X_SP_VERBS
20adfc5217SJeff Kirsher #define BNX2X_SP_VERBS
21adfc5217SJeff Kirsher 
22adfc5217SJeff Kirsher struct bnx2x;
23adfc5217SJeff Kirsher struct eth_context;
24adfc5217SJeff Kirsher 
25adfc5217SJeff Kirsher /* Bits representing general command's configuration */
26adfc5217SJeff Kirsher enum {
27adfc5217SJeff Kirsher 	RAMROD_TX,
28adfc5217SJeff Kirsher 	RAMROD_RX,
29adfc5217SJeff Kirsher 	/* Wait until all pending commands complete */
30adfc5217SJeff Kirsher 	RAMROD_COMP_WAIT,
31adfc5217SJeff Kirsher 	/* Don't send a ramrod, only update a registry */
32adfc5217SJeff Kirsher 	RAMROD_DRV_CLR_ONLY,
33adfc5217SJeff Kirsher 	/* Configure HW according to the current object state */
34adfc5217SJeff Kirsher 	RAMROD_RESTORE,
35adfc5217SJeff Kirsher 	 /* Execute the next command now */
36adfc5217SJeff Kirsher 	RAMROD_EXEC,
3716a5fd92SYuval Mintz 	/* Don't add a new command and continue execution of postponed
38adfc5217SJeff Kirsher 	 * commands. If not set a new command will be added to the
39adfc5217SJeff Kirsher 	 * pending commands list.
40adfc5217SJeff Kirsher 	 */
41adfc5217SJeff Kirsher 	RAMROD_CONT,
4255c11941SMerav Sicron 	/* If there is another pending ramrod, wait until it finishes and
4355c11941SMerav Sicron 	 * re-try to submit this one. This flag can be set only in sleepable
4455c11941SMerav Sicron 	 * context, and should not be set from the context that completes the
4555c11941SMerav Sicron 	 * ramrods as deadlock will occur.
4655c11941SMerav Sicron 	 */
4755c11941SMerav Sicron 	RAMROD_RETRY,
48adfc5217SJeff Kirsher };
49adfc5217SJeff Kirsher 
50adfc5217SJeff Kirsher typedef enum {
51adfc5217SJeff Kirsher 	BNX2X_OBJ_TYPE_RX,
52adfc5217SJeff Kirsher 	BNX2X_OBJ_TYPE_TX,
53adfc5217SJeff Kirsher 	BNX2X_OBJ_TYPE_RX_TX,
54adfc5217SJeff Kirsher } bnx2x_obj_type;
55adfc5217SJeff Kirsher 
562de67439SYuval Mintz /* Public slow path states */
57adfc5217SJeff Kirsher enum {
58adfc5217SJeff Kirsher 	BNX2X_FILTER_MAC_PENDING,
59adfc5217SJeff Kirsher 	BNX2X_FILTER_VLAN_PENDING,
60adfc5217SJeff Kirsher 	BNX2X_FILTER_VLAN_MAC_PENDING,
61adfc5217SJeff Kirsher 	BNX2X_FILTER_RX_MODE_PENDING,
62adfc5217SJeff Kirsher 	BNX2X_FILTER_RX_MODE_SCHED,
63adfc5217SJeff Kirsher 	BNX2X_FILTER_ISCSI_ETH_START_SCHED,
64adfc5217SJeff Kirsher 	BNX2X_FILTER_ISCSI_ETH_STOP_SCHED,
65adfc5217SJeff Kirsher 	BNX2X_FILTER_FCOE_ETH_START_SCHED,
66adfc5217SJeff Kirsher 	BNX2X_FILTER_FCOE_ETH_STOP_SCHED,
67adfc5217SJeff Kirsher 	BNX2X_FILTER_MCAST_PENDING,
68adfc5217SJeff Kirsher 	BNX2X_FILTER_MCAST_SCHED,
69adfc5217SJeff Kirsher 	BNX2X_FILTER_RSS_CONF_PENDING,
70a3348722SBarak Witkowski 	BNX2X_AFEX_FCOE_Q_UPDATE_PENDING,
71a3348722SBarak Witkowski 	BNX2X_AFEX_PENDING_VIFSET_MCP_ACK
72adfc5217SJeff Kirsher };
73adfc5217SJeff Kirsher 
74adfc5217SJeff Kirsher struct bnx2x_raw_obj {
75adfc5217SJeff Kirsher 	u8		func_id;
76adfc5217SJeff Kirsher 
77adfc5217SJeff Kirsher 	/* Queue params */
78adfc5217SJeff Kirsher 	u8		cl_id;
79adfc5217SJeff Kirsher 	u32		cid;
80adfc5217SJeff Kirsher 
81adfc5217SJeff Kirsher 	/* Ramrod data buffer params */
82adfc5217SJeff Kirsher 	void		*rdata;
83adfc5217SJeff Kirsher 	dma_addr_t	rdata_mapping;
84adfc5217SJeff Kirsher 
85adfc5217SJeff Kirsher 	/* Ramrod state params */
86adfc5217SJeff Kirsher 	int		state;   /* "ramrod is pending" state bit */
87adfc5217SJeff Kirsher 	unsigned long	*pstate; /* pointer to state buffer */
88adfc5217SJeff Kirsher 
89adfc5217SJeff Kirsher 	bnx2x_obj_type	obj_type;
90adfc5217SJeff Kirsher 
91adfc5217SJeff Kirsher 	int (*wait_comp)(struct bnx2x *bp,
92adfc5217SJeff Kirsher 			 struct bnx2x_raw_obj *o);
93adfc5217SJeff Kirsher 
94adfc5217SJeff Kirsher 	bool (*check_pending)(struct bnx2x_raw_obj *o);
95adfc5217SJeff Kirsher 	void (*clear_pending)(struct bnx2x_raw_obj *o);
96adfc5217SJeff Kirsher 	void (*set_pending)(struct bnx2x_raw_obj *o);
97adfc5217SJeff Kirsher };
98adfc5217SJeff Kirsher 
99adfc5217SJeff Kirsher /************************* VLAN-MAC commands related parameters ***************/
100adfc5217SJeff Kirsher struct bnx2x_mac_ramrod_data {
101adfc5217SJeff Kirsher 	u8 mac[ETH_ALEN];
10291226790SDmitry Kravkov 	u8 is_inner_mac;
103adfc5217SJeff Kirsher };
104adfc5217SJeff Kirsher 
105adfc5217SJeff Kirsher struct bnx2x_vlan_ramrod_data {
106adfc5217SJeff Kirsher 	u16 vlan;
107adfc5217SJeff Kirsher };
108adfc5217SJeff Kirsher 
109adfc5217SJeff Kirsher struct bnx2x_vlan_mac_ramrod_data {
110adfc5217SJeff Kirsher 	u8 mac[ETH_ALEN];
11191226790SDmitry Kravkov 	u8 is_inner_mac;
112adfc5217SJeff Kirsher 	u16 vlan;
113adfc5217SJeff Kirsher };
114adfc5217SJeff Kirsher 
115adfc5217SJeff Kirsher union bnx2x_classification_ramrod_data {
116adfc5217SJeff Kirsher 	struct bnx2x_mac_ramrod_data mac;
117adfc5217SJeff Kirsher 	struct bnx2x_vlan_ramrod_data vlan;
118adfc5217SJeff Kirsher 	struct bnx2x_vlan_mac_ramrod_data vlan_mac;
119adfc5217SJeff Kirsher };
120adfc5217SJeff Kirsher 
121adfc5217SJeff Kirsher /* VLAN_MAC commands */
122adfc5217SJeff Kirsher enum bnx2x_vlan_mac_cmd {
123adfc5217SJeff Kirsher 	BNX2X_VLAN_MAC_ADD,
124adfc5217SJeff Kirsher 	BNX2X_VLAN_MAC_DEL,
125adfc5217SJeff Kirsher 	BNX2X_VLAN_MAC_MOVE,
126adfc5217SJeff Kirsher };
127adfc5217SJeff Kirsher 
128adfc5217SJeff Kirsher struct bnx2x_vlan_mac_data {
129adfc5217SJeff Kirsher 	/* Requested command: BNX2X_VLAN_MAC_XX */
130adfc5217SJeff Kirsher 	enum bnx2x_vlan_mac_cmd cmd;
13116a5fd92SYuval Mintz 	/* used to contain the data related vlan_mac_flags bits from
132adfc5217SJeff Kirsher 	 * ramrod parameters.
133adfc5217SJeff Kirsher 	 */
134adfc5217SJeff Kirsher 	unsigned long vlan_mac_flags;
135adfc5217SJeff Kirsher 
136adfc5217SJeff Kirsher 	/* Needed for MOVE command */
137adfc5217SJeff Kirsher 	struct bnx2x_vlan_mac_obj *target_obj;
138adfc5217SJeff Kirsher 
139adfc5217SJeff Kirsher 	union bnx2x_classification_ramrod_data u;
140adfc5217SJeff Kirsher };
141adfc5217SJeff Kirsher 
142adfc5217SJeff Kirsher /*************************** Exe Queue obj ************************************/
143adfc5217SJeff Kirsher union bnx2x_exe_queue_cmd_data {
144adfc5217SJeff Kirsher 	struct bnx2x_vlan_mac_data vlan_mac;
145adfc5217SJeff Kirsher 
146adfc5217SJeff Kirsher 	struct {
147adfc5217SJeff Kirsher 		/* TODO */
148adfc5217SJeff Kirsher 	} mcast;
149adfc5217SJeff Kirsher };
150adfc5217SJeff Kirsher 
151adfc5217SJeff Kirsher struct bnx2x_exeq_elem {
152adfc5217SJeff Kirsher 	struct list_head		link;
153adfc5217SJeff Kirsher 
154adfc5217SJeff Kirsher 	/* Length of this element in the exe_chunk. */
155adfc5217SJeff Kirsher 	int				cmd_len;
156adfc5217SJeff Kirsher 
157adfc5217SJeff Kirsher 	union bnx2x_exe_queue_cmd_data	cmd_data;
158adfc5217SJeff Kirsher };
159adfc5217SJeff Kirsher 
160adfc5217SJeff Kirsher union bnx2x_qable_obj;
161adfc5217SJeff Kirsher 
162adfc5217SJeff Kirsher union bnx2x_exeq_comp_elem {
163adfc5217SJeff Kirsher 	union event_ring_elem *elem;
164adfc5217SJeff Kirsher };
165adfc5217SJeff Kirsher 
166adfc5217SJeff Kirsher struct bnx2x_exe_queue_obj;
167adfc5217SJeff Kirsher 
168adfc5217SJeff Kirsher typedef int (*exe_q_validate)(struct bnx2x *bp,
169adfc5217SJeff Kirsher 			      union bnx2x_qable_obj *o,
170adfc5217SJeff Kirsher 			      struct bnx2x_exeq_elem *elem);
171adfc5217SJeff Kirsher 
172460a25cdSYuval Mintz typedef int (*exe_q_remove)(struct bnx2x *bp,
173460a25cdSYuval Mintz 			    union bnx2x_qable_obj *o,
174460a25cdSYuval Mintz 			    struct bnx2x_exeq_elem *elem);
175460a25cdSYuval Mintz 
1761aa8b471SBen Hutchings /* Return positive if entry was optimized, 0 - if not, negative
177adfc5217SJeff Kirsher  * in case of an error.
178adfc5217SJeff Kirsher  */
179adfc5217SJeff Kirsher typedef int (*exe_q_optimize)(struct bnx2x *bp,
180adfc5217SJeff Kirsher 			      union bnx2x_qable_obj *o,
181adfc5217SJeff Kirsher 			      struct bnx2x_exeq_elem *elem);
182adfc5217SJeff Kirsher typedef int (*exe_q_execute)(struct bnx2x *bp,
183adfc5217SJeff Kirsher 			     union bnx2x_qable_obj *o,
184adfc5217SJeff Kirsher 			     struct list_head *exe_chunk,
185adfc5217SJeff Kirsher 			     unsigned long *ramrod_flags);
186adfc5217SJeff Kirsher typedef struct bnx2x_exeq_elem *
187adfc5217SJeff Kirsher 			(*exe_q_get)(struct bnx2x_exe_queue_obj *o,
188adfc5217SJeff Kirsher 				     struct bnx2x_exeq_elem *elem);
189adfc5217SJeff Kirsher 
190adfc5217SJeff Kirsher struct bnx2x_exe_queue_obj {
19116a5fd92SYuval Mintz 	/* Commands pending for an execution. */
192adfc5217SJeff Kirsher 	struct list_head	exe_queue;
193adfc5217SJeff Kirsher 
19416a5fd92SYuval Mintz 	/* Commands pending for an completion. */
195adfc5217SJeff Kirsher 	struct list_head	pending_comp;
196adfc5217SJeff Kirsher 
197adfc5217SJeff Kirsher 	spinlock_t		lock;
198adfc5217SJeff Kirsher 
199adfc5217SJeff Kirsher 	/* Maximum length of commands' list for one execution */
200adfc5217SJeff Kirsher 	int			exe_chunk_len;
201adfc5217SJeff Kirsher 
202adfc5217SJeff Kirsher 	union bnx2x_qable_obj	*owner;
203adfc5217SJeff Kirsher 
204adfc5217SJeff Kirsher 	/****** Virtual functions ******/
205adfc5217SJeff Kirsher 	/**
206adfc5217SJeff Kirsher 	 * Called before commands execution for commands that are really
207adfc5217SJeff Kirsher 	 * going to be executed (after 'optimize').
208adfc5217SJeff Kirsher 	 *
209adfc5217SJeff Kirsher 	 * Must run under exe_queue->lock
210adfc5217SJeff Kirsher 	 */
211adfc5217SJeff Kirsher 	exe_q_validate		validate;
212adfc5217SJeff Kirsher 
213460a25cdSYuval Mintz 	/**
214460a25cdSYuval Mintz 	 * Called before removing pending commands, cleaning allocated
215460a25cdSYuval Mintz 	 * resources (e.g., credits from validate)
216460a25cdSYuval Mintz 	 */
217460a25cdSYuval Mintz 	 exe_q_remove		remove;
218adfc5217SJeff Kirsher 
219adfc5217SJeff Kirsher 	/**
220adfc5217SJeff Kirsher 	 * This will try to cancel the current pending commands list
221adfc5217SJeff Kirsher 	 * considering the new command.
222adfc5217SJeff Kirsher 	 *
223460a25cdSYuval Mintz 	 * Returns the number of optimized commands or a negative error code
224460a25cdSYuval Mintz 	 *
225adfc5217SJeff Kirsher 	 * Must run under exe_queue->lock
226adfc5217SJeff Kirsher 	 */
227adfc5217SJeff Kirsher 	exe_q_optimize		optimize;
228adfc5217SJeff Kirsher 
229adfc5217SJeff Kirsher 	/**
230adfc5217SJeff Kirsher 	 * Run the next commands chunk (owner specific).
231adfc5217SJeff Kirsher 	 */
232adfc5217SJeff Kirsher 	exe_q_execute		execute;
233adfc5217SJeff Kirsher 
234adfc5217SJeff Kirsher 	/**
235adfc5217SJeff Kirsher 	 * Return the exe_queue element containing the specific command
236adfc5217SJeff Kirsher 	 * if any. Otherwise return NULL.
237adfc5217SJeff Kirsher 	 */
238adfc5217SJeff Kirsher 	exe_q_get		get;
239adfc5217SJeff Kirsher };
240adfc5217SJeff Kirsher /***************** Classification verbs: Set/Del MAC/VLAN/VLAN-MAC ************/
241adfc5217SJeff Kirsher /*
24216a5fd92SYuval Mintz  * Element in the VLAN_MAC registry list having all currently configured
243adfc5217SJeff Kirsher  * rules.
244adfc5217SJeff Kirsher  */
245adfc5217SJeff Kirsher struct bnx2x_vlan_mac_registry_elem {
246adfc5217SJeff Kirsher 	struct list_head	link;
247adfc5217SJeff Kirsher 
24816a5fd92SYuval Mintz 	/* Used to store the cam offset used for the mac/vlan/vlan-mac.
249adfc5217SJeff Kirsher 	 * Relevant for 57710 and 57711 only. VLANs and MACs share the
250adfc5217SJeff Kirsher 	 * same CAM for these chips.
251adfc5217SJeff Kirsher 	 */
252adfc5217SJeff Kirsher 	int			cam_offset;
253adfc5217SJeff Kirsher 
254adfc5217SJeff Kirsher 	/* Needed for DEL and RESTORE flows */
255adfc5217SJeff Kirsher 	unsigned long		vlan_mac_flags;
256adfc5217SJeff Kirsher 
257adfc5217SJeff Kirsher 	union bnx2x_classification_ramrod_data u;
258adfc5217SJeff Kirsher };
259adfc5217SJeff Kirsher 
260adfc5217SJeff Kirsher /* Bits representing VLAN_MAC commands specific flags */
261adfc5217SJeff Kirsher enum {
262adfc5217SJeff Kirsher 	BNX2X_UC_LIST_MAC,
263adfc5217SJeff Kirsher 	BNX2X_ETH_MAC,
264adfc5217SJeff Kirsher 	BNX2X_ISCSI_ETH_MAC,
265adfc5217SJeff Kirsher 	BNX2X_NETQ_ETH_MAC,
266adfc5217SJeff Kirsher 	BNX2X_DONT_CONSUME_CAM_CREDIT,
267adfc5217SJeff Kirsher 	BNX2X_DONT_CONSUME_CAM_CREDIT_DEST,
268adfc5217SJeff Kirsher };
269e8379c79SYuval Mintz /* When looking for matching filters, some flags are not interesting */
270e8379c79SYuval Mintz #define BNX2X_VLAN_MAC_CMP_MASK	(1 << BNX2X_UC_LIST_MAC | \
271e8379c79SYuval Mintz 				 1 << BNX2X_ETH_MAC | \
272e8379c79SYuval Mintz 				 1 << BNX2X_ISCSI_ETH_MAC | \
273e8379c79SYuval Mintz 				 1 << BNX2X_NETQ_ETH_MAC)
274e8379c79SYuval Mintz #define BNX2X_VLAN_MAC_CMP_FLAGS(flags) \
275e8379c79SYuval Mintz 	((flags) & BNX2X_VLAN_MAC_CMP_MASK)
276adfc5217SJeff Kirsher 
277adfc5217SJeff Kirsher struct bnx2x_vlan_mac_ramrod_params {
278adfc5217SJeff Kirsher 	/* Object to run the command from */
279adfc5217SJeff Kirsher 	struct bnx2x_vlan_mac_obj *vlan_mac_obj;
280adfc5217SJeff Kirsher 
281adfc5217SJeff Kirsher 	/* General command flags: COMP_WAIT, etc. */
282adfc5217SJeff Kirsher 	unsigned long ramrod_flags;
283adfc5217SJeff Kirsher 
284adfc5217SJeff Kirsher 	/* Command specific configuration request */
285adfc5217SJeff Kirsher 	struct bnx2x_vlan_mac_data user_req;
286adfc5217SJeff Kirsher };
287adfc5217SJeff Kirsher 
288adfc5217SJeff Kirsher struct bnx2x_vlan_mac_obj {
289adfc5217SJeff Kirsher 	struct bnx2x_raw_obj raw;
290adfc5217SJeff Kirsher 
291adfc5217SJeff Kirsher 	/* Bookkeeping list: will prevent the addition of already existing
292adfc5217SJeff Kirsher 	 * entries.
293adfc5217SJeff Kirsher 	 */
294adfc5217SJeff Kirsher 	struct list_head		head;
2958b09be5fSYuval Mintz 	/* Implement a simple reader/writer lock on the head list.
2968b09be5fSYuval Mintz 	 * all these fields should only be accessed under the exe_queue lock
2978b09be5fSYuval Mintz 	 */
2988b09be5fSYuval Mintz 	u8		head_reader; /* Num. of readers accessing head list */
2998b09be5fSYuval Mintz 	bool		head_exe_request; /* Pending execution request. */
3008b09be5fSYuval Mintz 	unsigned long	saved_ramrod_flags; /* Ramrods of pending execution */
301adfc5217SJeff Kirsher 
302adfc5217SJeff Kirsher 	/* TODO: Add it's initialization in the init functions */
303adfc5217SJeff Kirsher 	struct bnx2x_exe_queue_obj	exe_queue;
304adfc5217SJeff Kirsher 
305adfc5217SJeff Kirsher 	/* MACs credit pool */
306adfc5217SJeff Kirsher 	struct bnx2x_credit_pool_obj	*macs_pool;
307adfc5217SJeff Kirsher 
308adfc5217SJeff Kirsher 	/* VLANs credit pool */
309adfc5217SJeff Kirsher 	struct bnx2x_credit_pool_obj	*vlans_pool;
310adfc5217SJeff Kirsher 
311adfc5217SJeff Kirsher 	/* RAMROD command to be used */
312adfc5217SJeff Kirsher 	int				ramrod_cmd;
313adfc5217SJeff Kirsher 
314ed5162a0SAriel Elior 	/* copy first n elements onto preallocated buffer
315ed5162a0SAriel Elior 	 *
316ed5162a0SAriel Elior 	 * @param n number of elements to get
317ed5162a0SAriel Elior 	 * @param buf buffer preallocated by caller into which elements
318ed5162a0SAriel Elior 	 *            will be copied. Note elements are 4-byte aligned
31916a5fd92SYuval Mintz 	 *            so buffer size must be able to accommodate the
320ed5162a0SAriel Elior 	 *            aligned elements.
321ed5162a0SAriel Elior 	 *
322ed5162a0SAriel Elior 	 * @return number of copied bytes
323ed5162a0SAriel Elior 	 */
3243ec9f9caSAriel Elior 	int (*get_n_elements)(struct bnx2x *bp,
3253ec9f9caSAriel Elior 			      struct bnx2x_vlan_mac_obj *o, int n, u8 *base,
3263ec9f9caSAriel Elior 			      u8 stride, u8 size);
327ed5162a0SAriel Elior 
328adfc5217SJeff Kirsher 	/**
329adfc5217SJeff Kirsher 	 * Checks if ADD-ramrod with the given params may be performed.
330adfc5217SJeff Kirsher 	 *
331adfc5217SJeff Kirsher 	 * @return zero if the element may be added
332adfc5217SJeff Kirsher 	 */
333adfc5217SJeff Kirsher 
33451c1a580SMerav Sicron 	int (*check_add)(struct bnx2x *bp,
33551c1a580SMerav Sicron 			 struct bnx2x_vlan_mac_obj *o,
336adfc5217SJeff Kirsher 			 union bnx2x_classification_ramrod_data *data);
337adfc5217SJeff Kirsher 
338adfc5217SJeff Kirsher 	/**
339adfc5217SJeff Kirsher 	 * Checks if DEL-ramrod with the given params may be performed.
340adfc5217SJeff Kirsher 	 *
341adfc5217SJeff Kirsher 	 * @return true if the element may be deleted
342adfc5217SJeff Kirsher 	 */
343adfc5217SJeff Kirsher 	struct bnx2x_vlan_mac_registry_elem *
34451c1a580SMerav Sicron 		(*check_del)(struct bnx2x *bp,
34551c1a580SMerav Sicron 			     struct bnx2x_vlan_mac_obj *o,
346adfc5217SJeff Kirsher 			     union bnx2x_classification_ramrod_data *data);
347adfc5217SJeff Kirsher 
348adfc5217SJeff Kirsher 	/**
349adfc5217SJeff Kirsher 	 * Checks if DEL-ramrod with the given params may be performed.
350adfc5217SJeff Kirsher 	 *
351adfc5217SJeff Kirsher 	 * @return true if the element may be deleted
352adfc5217SJeff Kirsher 	 */
35351c1a580SMerav Sicron 	bool (*check_move)(struct bnx2x *bp,
35451c1a580SMerav Sicron 			   struct bnx2x_vlan_mac_obj *src_o,
355adfc5217SJeff Kirsher 			   struct bnx2x_vlan_mac_obj *dst_o,
356adfc5217SJeff Kirsher 			   union bnx2x_classification_ramrod_data *data);
357adfc5217SJeff Kirsher 
358adfc5217SJeff Kirsher 	/**
359adfc5217SJeff Kirsher 	 *  Update the relevant credit object(s) (consume/return
360adfc5217SJeff Kirsher 	 *  correspondingly).
361adfc5217SJeff Kirsher 	 */
362adfc5217SJeff Kirsher 	bool (*get_credit)(struct bnx2x_vlan_mac_obj *o);
363adfc5217SJeff Kirsher 	bool (*put_credit)(struct bnx2x_vlan_mac_obj *o);
364adfc5217SJeff Kirsher 	bool (*get_cam_offset)(struct bnx2x_vlan_mac_obj *o, int *offset);
365adfc5217SJeff Kirsher 	bool (*put_cam_offset)(struct bnx2x_vlan_mac_obj *o, int offset);
366adfc5217SJeff Kirsher 
367adfc5217SJeff Kirsher 	/**
368adfc5217SJeff Kirsher 	 * Configures one rule in the ramrod data buffer.
369adfc5217SJeff Kirsher 	 */
370adfc5217SJeff Kirsher 	void (*set_one_rule)(struct bnx2x *bp,
371adfc5217SJeff Kirsher 			     struct bnx2x_vlan_mac_obj *o,
372adfc5217SJeff Kirsher 			     struct bnx2x_exeq_elem *elem, int rule_idx,
373adfc5217SJeff Kirsher 			     int cam_offset);
374adfc5217SJeff Kirsher 
375adfc5217SJeff Kirsher 	/**
376adfc5217SJeff Kirsher 	*  Delete all configured elements having the given
377adfc5217SJeff Kirsher 	*  vlan_mac_flags specification. Assumes no pending for
378adfc5217SJeff Kirsher 	*  execution commands. Will schedule all all currently
379adfc5217SJeff Kirsher 	*  configured MACs/VLANs/VLAN-MACs matching the vlan_mac_flags
380adfc5217SJeff Kirsher 	*  specification for deletion and will use the given
381adfc5217SJeff Kirsher 	*  ramrod_flags for the last DEL operation.
382adfc5217SJeff Kirsher 	 *
383adfc5217SJeff Kirsher 	 * @param bp
384adfc5217SJeff Kirsher 	 * @param o
385adfc5217SJeff Kirsher 	 * @param ramrod_flags RAMROD_XX flags
386adfc5217SJeff Kirsher 	 *
387adfc5217SJeff Kirsher 	 * @return 0 if the last operation has completed successfully
388adfc5217SJeff Kirsher 	 *         and there are no more elements left, positive value
389adfc5217SJeff Kirsher 	 *         if there are pending for completion commands,
390adfc5217SJeff Kirsher 	 *         negative value in case of failure.
391adfc5217SJeff Kirsher 	 */
392adfc5217SJeff Kirsher 	int (*delete_all)(struct bnx2x *bp,
393adfc5217SJeff Kirsher 			  struct bnx2x_vlan_mac_obj *o,
394adfc5217SJeff Kirsher 			  unsigned long *vlan_mac_flags,
395adfc5217SJeff Kirsher 			  unsigned long *ramrod_flags);
396adfc5217SJeff Kirsher 
397adfc5217SJeff Kirsher 	/**
398adfc5217SJeff Kirsher 	 * Reconfigures the next MAC/VLAN/VLAN-MAC element from the previously
399adfc5217SJeff Kirsher 	 * configured elements list.
400adfc5217SJeff Kirsher 	 *
401adfc5217SJeff Kirsher 	 * @param bp
402adfc5217SJeff Kirsher 	 * @param p Command parameters (RAMROD_COMP_WAIT bit in
403adfc5217SJeff Kirsher 	 *          ramrod_flags is only taken into an account)
40416a5fd92SYuval Mintz 	 * @param ppos a pointer to the cookie that should be given back in the
405adfc5217SJeff Kirsher 	 *        next call to make function handle the next element. If
406adfc5217SJeff Kirsher 	 *        *ppos is set to NULL it will restart the iterator.
407adfc5217SJeff Kirsher 	 *        If returned *ppos == NULL this means that the last
408adfc5217SJeff Kirsher 	 *        element has been handled.
409adfc5217SJeff Kirsher 	 *
410adfc5217SJeff Kirsher 	 * @return int
411adfc5217SJeff Kirsher 	 */
412adfc5217SJeff Kirsher 	int (*restore)(struct bnx2x *bp,
413adfc5217SJeff Kirsher 		       struct bnx2x_vlan_mac_ramrod_params *p,
414adfc5217SJeff Kirsher 		       struct bnx2x_vlan_mac_registry_elem **ppos);
415adfc5217SJeff Kirsher 
416adfc5217SJeff Kirsher 	/**
41716a5fd92SYuval Mintz 	 * Should be called on a completion arrival.
418adfc5217SJeff Kirsher 	 *
419adfc5217SJeff Kirsher 	 * @param bp
420adfc5217SJeff Kirsher 	 * @param o
421adfc5217SJeff Kirsher 	 * @param cqe Completion element we are handling
422adfc5217SJeff Kirsher 	 * @param ramrod_flags if RAMROD_CONT is set the next bulk of
423adfc5217SJeff Kirsher 	 *		       pending commands will be executed.
424adfc5217SJeff Kirsher 	 *		       RAMROD_DRV_CLR_ONLY and RAMROD_RESTORE
425adfc5217SJeff Kirsher 	 *		       may also be set if needed.
426adfc5217SJeff Kirsher 	 *
427adfc5217SJeff Kirsher 	 * @return 0 if there are neither pending nor waiting for
428adfc5217SJeff Kirsher 	 *         completion commands. Positive value if there are
429adfc5217SJeff Kirsher 	 *         pending for execution or for completion commands.
430adfc5217SJeff Kirsher 	 *         Negative value in case of an error (including an
431adfc5217SJeff Kirsher 	 *         error in the cqe).
432adfc5217SJeff Kirsher 	 */
433adfc5217SJeff Kirsher 	int (*complete)(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o,
434adfc5217SJeff Kirsher 			union event_ring_elem *cqe,
435adfc5217SJeff Kirsher 			unsigned long *ramrod_flags);
436adfc5217SJeff Kirsher 
437adfc5217SJeff Kirsher 	/**
438adfc5217SJeff Kirsher 	 * Wait for completion of all commands. Don't schedule new ones,
439adfc5217SJeff Kirsher 	 * just wait. It assumes that the completion code will schedule
440adfc5217SJeff Kirsher 	 * for new commands.
441adfc5217SJeff Kirsher 	 */
442adfc5217SJeff Kirsher 	int (*wait)(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o);
443adfc5217SJeff Kirsher };
444adfc5217SJeff Kirsher 
4450a52fd01SYuval Mintz enum {
4460a52fd01SYuval Mintz 	BNX2X_LLH_CAM_ISCSI_ETH_LINE = 0,
4470a52fd01SYuval Mintz 	BNX2X_LLH_CAM_ETH_LINE,
4480a52fd01SYuval Mintz 	BNX2X_LLH_CAM_MAX_PF_LINE = NIG_REG_LLH1_FUNC_MEM_SIZE / 2
4490a52fd01SYuval Mintz };
4500a52fd01SYuval Mintz 
451adfc5217SJeff Kirsher /** RX_MODE verbs:DROP_ALL/ACCEPT_ALL/ACCEPT_ALL_MULTI/ACCEPT_ALL_VLAN/NORMAL */
452adfc5217SJeff Kirsher 
45316a5fd92SYuval Mintz /* RX_MODE ramrod special flags: set in rx_mode_flags field in
454adfc5217SJeff Kirsher  * a bnx2x_rx_mode_ramrod_params.
455adfc5217SJeff Kirsher  */
456adfc5217SJeff Kirsher enum {
457adfc5217SJeff Kirsher 	BNX2X_RX_MODE_FCOE_ETH,
458adfc5217SJeff Kirsher 	BNX2X_RX_MODE_ISCSI_ETH,
459adfc5217SJeff Kirsher };
460adfc5217SJeff Kirsher 
461adfc5217SJeff Kirsher enum {
462adfc5217SJeff Kirsher 	BNX2X_ACCEPT_UNICAST,
463adfc5217SJeff Kirsher 	BNX2X_ACCEPT_MULTICAST,
464adfc5217SJeff Kirsher 	BNX2X_ACCEPT_ALL_UNICAST,
465adfc5217SJeff Kirsher 	BNX2X_ACCEPT_ALL_MULTICAST,
466adfc5217SJeff Kirsher 	BNX2X_ACCEPT_BROADCAST,
467adfc5217SJeff Kirsher 	BNX2X_ACCEPT_UNMATCHED,
468adfc5217SJeff Kirsher 	BNX2X_ACCEPT_ANY_VLAN
469adfc5217SJeff Kirsher };
470adfc5217SJeff Kirsher 
471adfc5217SJeff Kirsher struct bnx2x_rx_mode_ramrod_params {
472adfc5217SJeff Kirsher 	struct bnx2x_rx_mode_obj *rx_mode_obj;
473adfc5217SJeff Kirsher 	unsigned long *pstate;
474adfc5217SJeff Kirsher 	int state;
475adfc5217SJeff Kirsher 	u8 cl_id;
476adfc5217SJeff Kirsher 	u32 cid;
477adfc5217SJeff Kirsher 	u8 func_id;
478adfc5217SJeff Kirsher 	unsigned long ramrod_flags;
479adfc5217SJeff Kirsher 	unsigned long rx_mode_flags;
480adfc5217SJeff Kirsher 
48116a5fd92SYuval Mintz 	/* rdata is either a pointer to eth_filter_rules_ramrod_data(e2) or to
482adfc5217SJeff Kirsher 	 * a tstorm_eth_mac_filter_config (e1x).
483adfc5217SJeff Kirsher 	 */
484adfc5217SJeff Kirsher 	void *rdata;
485adfc5217SJeff Kirsher 	dma_addr_t rdata_mapping;
486adfc5217SJeff Kirsher 
487adfc5217SJeff Kirsher 	/* Rx mode settings */
488adfc5217SJeff Kirsher 	unsigned long rx_accept_flags;
489adfc5217SJeff Kirsher 
490adfc5217SJeff Kirsher 	/* internal switching settings */
491adfc5217SJeff Kirsher 	unsigned long tx_accept_flags;
492adfc5217SJeff Kirsher };
493adfc5217SJeff Kirsher 
494adfc5217SJeff Kirsher struct bnx2x_rx_mode_obj {
495adfc5217SJeff Kirsher 	int (*config_rx_mode)(struct bnx2x *bp,
496adfc5217SJeff Kirsher 			      struct bnx2x_rx_mode_ramrod_params *p);
497adfc5217SJeff Kirsher 
498adfc5217SJeff Kirsher 	int (*wait_comp)(struct bnx2x *bp,
499adfc5217SJeff Kirsher 			 struct bnx2x_rx_mode_ramrod_params *p);
500adfc5217SJeff Kirsher };
501adfc5217SJeff Kirsher 
502adfc5217SJeff Kirsher /********************** Set multicast group ***********************************/
503adfc5217SJeff Kirsher 
504adfc5217SJeff Kirsher struct bnx2x_mcast_list_elem {
505adfc5217SJeff Kirsher 	struct list_head link;
506adfc5217SJeff Kirsher 	u8 *mac;
507adfc5217SJeff Kirsher };
508adfc5217SJeff Kirsher 
509adfc5217SJeff Kirsher union bnx2x_mcast_config_data {
510adfc5217SJeff Kirsher 	u8 *mac;
511adfc5217SJeff Kirsher 	u8 bin; /* used in a RESTORE flow */
512adfc5217SJeff Kirsher };
513adfc5217SJeff Kirsher 
514adfc5217SJeff Kirsher struct bnx2x_mcast_ramrod_params {
515adfc5217SJeff Kirsher 	struct bnx2x_mcast_obj *mcast_obj;
516adfc5217SJeff Kirsher 
517adfc5217SJeff Kirsher 	/* Relevant options are RAMROD_COMP_WAIT and RAMROD_DRV_CLR_ONLY */
518adfc5217SJeff Kirsher 	unsigned long ramrod_flags;
519adfc5217SJeff Kirsher 
520adfc5217SJeff Kirsher 	struct list_head mcast_list; /* list of struct bnx2x_mcast_list_elem */
521adfc5217SJeff Kirsher 	/** TODO:
522adfc5217SJeff Kirsher 	 *      - rename it to macs_num.
523adfc5217SJeff Kirsher 	 *      - Add a new command type for handling pending commands
524adfc5217SJeff Kirsher 	 *        (remove "zero semantics").
525adfc5217SJeff Kirsher 	 *
526adfc5217SJeff Kirsher 	 *  Length of mcast_list. If zero and ADD_CONT command - post
527adfc5217SJeff Kirsher 	 *  pending commands.
528adfc5217SJeff Kirsher 	 */
529adfc5217SJeff Kirsher 	int mcast_list_len;
530adfc5217SJeff Kirsher };
531adfc5217SJeff Kirsher 
53286564c3fSYuval Mintz enum bnx2x_mcast_cmd {
533adfc5217SJeff Kirsher 	BNX2X_MCAST_CMD_ADD,
534adfc5217SJeff Kirsher 	BNX2X_MCAST_CMD_CONT,
535adfc5217SJeff Kirsher 	BNX2X_MCAST_CMD_DEL,
536adfc5217SJeff Kirsher 	BNX2X_MCAST_CMD_RESTORE,
537adfc5217SJeff Kirsher };
538adfc5217SJeff Kirsher 
539adfc5217SJeff Kirsher struct bnx2x_mcast_obj {
540adfc5217SJeff Kirsher 	struct bnx2x_raw_obj raw;
541adfc5217SJeff Kirsher 
542adfc5217SJeff Kirsher 	union {
543adfc5217SJeff Kirsher 		struct {
544adfc5217SJeff Kirsher 		#define BNX2X_MCAST_BINS_NUM	256
545adfc5217SJeff Kirsher 		#define BNX2X_MCAST_VEC_SZ	(BNX2X_MCAST_BINS_NUM / 64)
546adfc5217SJeff Kirsher 			u64 vec[BNX2X_MCAST_VEC_SZ];
547adfc5217SJeff Kirsher 
548adfc5217SJeff Kirsher 			/** Number of BINs to clear. Should be updated
549adfc5217SJeff Kirsher 			 *  immediately when a command arrives in order to
550adfc5217SJeff Kirsher 			 *  properly create DEL commands.
551adfc5217SJeff Kirsher 			 */
552adfc5217SJeff Kirsher 			int num_bins_set;
553adfc5217SJeff Kirsher 		} aprox_match;
554adfc5217SJeff Kirsher 
555adfc5217SJeff Kirsher 		struct {
556adfc5217SJeff Kirsher 			struct list_head macs;
557adfc5217SJeff Kirsher 			int num_macs_set;
558adfc5217SJeff Kirsher 		} exact_match;
559adfc5217SJeff Kirsher 	} registry;
560adfc5217SJeff Kirsher 
561adfc5217SJeff Kirsher 	/* Pending commands */
562adfc5217SJeff Kirsher 	struct list_head pending_cmds_head;
563adfc5217SJeff Kirsher 
564adfc5217SJeff Kirsher 	/* A state that is set in raw.pstate, when there are pending commands */
565adfc5217SJeff Kirsher 	int sched_state;
566adfc5217SJeff Kirsher 
567adfc5217SJeff Kirsher 	/* Maximal number of mcast MACs configured in one command */
568adfc5217SJeff Kirsher 	int max_cmd_len;
569adfc5217SJeff Kirsher 
570adfc5217SJeff Kirsher 	/* Total number of currently pending MACs to configure: both
571adfc5217SJeff Kirsher 	 * in the pending commands list and in the current command.
572adfc5217SJeff Kirsher 	 */
573adfc5217SJeff Kirsher 	int total_pending_num;
574adfc5217SJeff Kirsher 
575adfc5217SJeff Kirsher 	u8 engine_id;
576adfc5217SJeff Kirsher 
577adfc5217SJeff Kirsher 	/**
578adfc5217SJeff Kirsher 	 * @param cmd command to execute (BNX2X_MCAST_CMD_X, see above)
579adfc5217SJeff Kirsher 	 */
580adfc5217SJeff Kirsher 	int (*config_mcast)(struct bnx2x *bp,
58186564c3fSYuval Mintz 			    struct bnx2x_mcast_ramrod_params *p,
58286564c3fSYuval Mintz 			    enum bnx2x_mcast_cmd cmd);
583adfc5217SJeff Kirsher 
584adfc5217SJeff Kirsher 	/**
585adfc5217SJeff Kirsher 	 * Fills the ramrod data during the RESTORE flow.
586adfc5217SJeff Kirsher 	 *
587adfc5217SJeff Kirsher 	 * @param bp
588adfc5217SJeff Kirsher 	 * @param o
589adfc5217SJeff Kirsher 	 * @param start_idx Registry index to start from
590adfc5217SJeff Kirsher 	 * @param rdata_idx Index in the ramrod data to start from
591adfc5217SJeff Kirsher 	 *
592adfc5217SJeff Kirsher 	 * @return -1 if we handled the whole registry or index of the last
593adfc5217SJeff Kirsher 	 *         handled registry element.
594adfc5217SJeff Kirsher 	 */
595adfc5217SJeff Kirsher 	int (*hdl_restore)(struct bnx2x *bp, struct bnx2x_mcast_obj *o,
596adfc5217SJeff Kirsher 			   int start_bin, int *rdata_idx);
597adfc5217SJeff Kirsher 
598adfc5217SJeff Kirsher 	int (*enqueue_cmd)(struct bnx2x *bp, struct bnx2x_mcast_obj *o,
59986564c3fSYuval Mintz 			   struct bnx2x_mcast_ramrod_params *p,
60086564c3fSYuval Mintz 			   enum bnx2x_mcast_cmd cmd);
601adfc5217SJeff Kirsher 
602adfc5217SJeff Kirsher 	void (*set_one_rule)(struct bnx2x *bp,
603adfc5217SJeff Kirsher 			     struct bnx2x_mcast_obj *o, int idx,
60486564c3fSYuval Mintz 			     union bnx2x_mcast_config_data *cfg_data,
60586564c3fSYuval Mintz 			     enum bnx2x_mcast_cmd cmd);
606adfc5217SJeff Kirsher 
607adfc5217SJeff Kirsher 	/** Checks if there are more mcast MACs to be set or a previous
608adfc5217SJeff Kirsher 	 *  command is still pending.
609adfc5217SJeff Kirsher 	 */
610adfc5217SJeff Kirsher 	bool (*check_pending)(struct bnx2x_mcast_obj *o);
611adfc5217SJeff Kirsher 
612adfc5217SJeff Kirsher 	/**
613adfc5217SJeff Kirsher 	 * Set/Clear/Check SCHEDULED state of the object
614adfc5217SJeff Kirsher 	 */
615adfc5217SJeff Kirsher 	void (*set_sched)(struct bnx2x_mcast_obj *o);
616adfc5217SJeff Kirsher 	void (*clear_sched)(struct bnx2x_mcast_obj *o);
617adfc5217SJeff Kirsher 	bool (*check_sched)(struct bnx2x_mcast_obj *o);
618adfc5217SJeff Kirsher 
619adfc5217SJeff Kirsher 	/* Wait until all pending commands complete */
620adfc5217SJeff Kirsher 	int (*wait_comp)(struct bnx2x *bp, struct bnx2x_mcast_obj *o);
621adfc5217SJeff Kirsher 
622adfc5217SJeff Kirsher 	/**
623adfc5217SJeff Kirsher 	 * Handle the internal object counters needed for proper
624adfc5217SJeff Kirsher 	 * commands handling. Checks that the provided parameters are
625adfc5217SJeff Kirsher 	 * feasible.
626adfc5217SJeff Kirsher 	 */
627adfc5217SJeff Kirsher 	int (*validate)(struct bnx2x *bp,
62886564c3fSYuval Mintz 			struct bnx2x_mcast_ramrod_params *p,
62986564c3fSYuval Mintz 			enum bnx2x_mcast_cmd cmd);
630adfc5217SJeff Kirsher 
631adfc5217SJeff Kirsher 	/**
632adfc5217SJeff Kirsher 	 * Restore the values of internal counters in case of a failure.
633adfc5217SJeff Kirsher 	 */
634adfc5217SJeff Kirsher 	void (*revert)(struct bnx2x *bp,
635adfc5217SJeff Kirsher 		       struct bnx2x_mcast_ramrod_params *p,
636adfc5217SJeff Kirsher 		       int old_num_bins);
637adfc5217SJeff Kirsher 
638adfc5217SJeff Kirsher 	int (*get_registry_size)(struct bnx2x_mcast_obj *o);
639adfc5217SJeff Kirsher 	void (*set_registry_size)(struct bnx2x_mcast_obj *o, int n);
640adfc5217SJeff Kirsher };
641adfc5217SJeff Kirsher 
642adfc5217SJeff Kirsher /*************************** Credit handling **********************************/
643adfc5217SJeff Kirsher struct bnx2x_credit_pool_obj {
644adfc5217SJeff Kirsher 
645adfc5217SJeff Kirsher 	/* Current amount of credit in the pool */
646adfc5217SJeff Kirsher 	atomic_t	credit;
647adfc5217SJeff Kirsher 
648adfc5217SJeff Kirsher 	/* Maximum allowed credit. put() will check against it. */
649adfc5217SJeff Kirsher 	int		pool_sz;
650adfc5217SJeff Kirsher 
65116a5fd92SYuval Mintz 	/* Allocate a pool table statically.
652adfc5217SJeff Kirsher 	 *
65316a5fd92SYuval Mintz 	 * Currently the maximum allowed size is MAX_MAC_CREDIT_E2(272)
654adfc5217SJeff Kirsher 	 *
655adfc5217SJeff Kirsher 	 * The set bit in the table will mean that the entry is available.
656adfc5217SJeff Kirsher 	 */
657adfc5217SJeff Kirsher #define BNX2X_POOL_VEC_SIZE	(MAX_MAC_CREDIT_E2 / 64)
658adfc5217SJeff Kirsher 	u64		pool_mirror[BNX2X_POOL_VEC_SIZE];
659adfc5217SJeff Kirsher 
660adfc5217SJeff Kirsher 	/* Base pool offset (initialized differently */
661adfc5217SJeff Kirsher 	int		base_pool_offset;
662adfc5217SJeff Kirsher 
663adfc5217SJeff Kirsher 	/**
664adfc5217SJeff Kirsher 	 * Get the next free pool entry.
665adfc5217SJeff Kirsher 	 *
666adfc5217SJeff Kirsher 	 * @return true if there was a free entry in the pool
667adfc5217SJeff Kirsher 	 */
668adfc5217SJeff Kirsher 	bool (*get_entry)(struct bnx2x_credit_pool_obj *o, int *entry);
669adfc5217SJeff Kirsher 
670adfc5217SJeff Kirsher 	/**
671adfc5217SJeff Kirsher 	 * Return the entry back to the pool.
672adfc5217SJeff Kirsher 	 *
673adfc5217SJeff Kirsher 	 * @return true if entry is legal and has been successfully
674adfc5217SJeff Kirsher 	 *         returned to the pool.
675adfc5217SJeff Kirsher 	 */
676adfc5217SJeff Kirsher 	bool (*put_entry)(struct bnx2x_credit_pool_obj *o, int entry);
677adfc5217SJeff Kirsher 
678adfc5217SJeff Kirsher 	/**
679adfc5217SJeff Kirsher 	 * Get the requested amount of credit from the pool.
680adfc5217SJeff Kirsher 	 *
681adfc5217SJeff Kirsher 	 * @param cnt Amount of requested credit
682adfc5217SJeff Kirsher 	 * @return true if the operation is successful
683adfc5217SJeff Kirsher 	 */
684adfc5217SJeff Kirsher 	bool (*get)(struct bnx2x_credit_pool_obj *o, int cnt);
685adfc5217SJeff Kirsher 
686adfc5217SJeff Kirsher 	/**
687adfc5217SJeff Kirsher 	 * Returns the credit to the pool.
688adfc5217SJeff Kirsher 	 *
689adfc5217SJeff Kirsher 	 * @param cnt Amount of credit to return
690adfc5217SJeff Kirsher 	 * @return true if the operation is successful
691adfc5217SJeff Kirsher 	 */
692adfc5217SJeff Kirsher 	bool (*put)(struct bnx2x_credit_pool_obj *o, int cnt);
693adfc5217SJeff Kirsher 
694adfc5217SJeff Kirsher 	/**
695adfc5217SJeff Kirsher 	 * Reads the current amount of credit.
696adfc5217SJeff Kirsher 	 */
697adfc5217SJeff Kirsher 	int (*check)(struct bnx2x_credit_pool_obj *o);
698adfc5217SJeff Kirsher };
699adfc5217SJeff Kirsher 
700adfc5217SJeff Kirsher /*************************** RSS configuration ********************************/
701adfc5217SJeff Kirsher enum {
702adfc5217SJeff Kirsher 	/* RSS_MODE bits are mutually exclusive */
703adfc5217SJeff Kirsher 	BNX2X_RSS_MODE_DISABLED,
704adfc5217SJeff Kirsher 	BNX2X_RSS_MODE_REGULAR,
705adfc5217SJeff Kirsher 
706adfc5217SJeff Kirsher 	BNX2X_RSS_SET_SRCH, /* Setup searcher, E1x specific flag */
707adfc5217SJeff Kirsher 
708adfc5217SJeff Kirsher 	BNX2X_RSS_IPV4,
709adfc5217SJeff Kirsher 	BNX2X_RSS_IPV4_TCP,
7105d317c6aSMerav Sicron 	BNX2X_RSS_IPV4_UDP,
711adfc5217SJeff Kirsher 	BNX2X_RSS_IPV6,
712adfc5217SJeff Kirsher 	BNX2X_RSS_IPV6_TCP,
7135d317c6aSMerav Sicron 	BNX2X_RSS_IPV6_UDP,
714e42780b6SDmitry Kravkov 	BNX2X_RSS_GRE_INNER_HDRS,
715adfc5217SJeff Kirsher };
716adfc5217SJeff Kirsher 
717adfc5217SJeff Kirsher struct bnx2x_config_rss_params {
718adfc5217SJeff Kirsher 	struct bnx2x_rss_config_obj *rss_obj;
719adfc5217SJeff Kirsher 
720adfc5217SJeff Kirsher 	/* may have RAMROD_COMP_WAIT set only */
721adfc5217SJeff Kirsher 	unsigned long	ramrod_flags;
722adfc5217SJeff Kirsher 
723adfc5217SJeff Kirsher 	/* BNX2X_RSS_X bits */
724adfc5217SJeff Kirsher 	unsigned long	rss_flags;
725adfc5217SJeff Kirsher 
726adfc5217SJeff Kirsher 	/* Number hash bits to take into an account */
727adfc5217SJeff Kirsher 	u8		rss_result_mask;
728adfc5217SJeff Kirsher 
729adfc5217SJeff Kirsher 	/* Indirection table */
730adfc5217SJeff Kirsher 	u8		ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
731adfc5217SJeff Kirsher 
732adfc5217SJeff Kirsher 	/* RSS hash values */
733adfc5217SJeff Kirsher 	u32		rss_key[10];
734adfc5217SJeff Kirsher 
735adfc5217SJeff Kirsher 	/* valid only iff BNX2X_RSS_UPDATE_TOE is set */
736adfc5217SJeff Kirsher 	u16		toe_rss_bitmap;
737adfc5217SJeff Kirsher };
738adfc5217SJeff Kirsher 
739adfc5217SJeff Kirsher struct bnx2x_rss_config_obj {
740adfc5217SJeff Kirsher 	struct bnx2x_raw_obj	raw;
741adfc5217SJeff Kirsher 
742adfc5217SJeff Kirsher 	/* RSS engine to use */
743adfc5217SJeff Kirsher 	u8			engine_id;
744adfc5217SJeff Kirsher 
745adfc5217SJeff Kirsher 	/* Last configured indirection table */
746adfc5217SJeff Kirsher 	u8			ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
747adfc5217SJeff Kirsher 
7485d317c6aSMerav Sicron 	/* flags for enabling 4-tupple hash on UDP */
7495d317c6aSMerav Sicron 	u8			udp_rss_v4;
7505d317c6aSMerav Sicron 	u8			udp_rss_v6;
7515d317c6aSMerav Sicron 
752adfc5217SJeff Kirsher 	int (*config_rss)(struct bnx2x *bp,
753adfc5217SJeff Kirsher 			  struct bnx2x_config_rss_params *p);
754adfc5217SJeff Kirsher };
755adfc5217SJeff Kirsher 
756adfc5217SJeff Kirsher /*********************** Queue state update ***********************************/
757adfc5217SJeff Kirsher 
758adfc5217SJeff Kirsher /* UPDATE command options */
759adfc5217SJeff Kirsher enum {
760adfc5217SJeff Kirsher 	BNX2X_Q_UPDATE_IN_VLAN_REM,
761adfc5217SJeff Kirsher 	BNX2X_Q_UPDATE_IN_VLAN_REM_CHNG,
762adfc5217SJeff Kirsher 	BNX2X_Q_UPDATE_OUT_VLAN_REM,
763adfc5217SJeff Kirsher 	BNX2X_Q_UPDATE_OUT_VLAN_REM_CHNG,
764adfc5217SJeff Kirsher 	BNX2X_Q_UPDATE_ANTI_SPOOF,
765adfc5217SJeff Kirsher 	BNX2X_Q_UPDATE_ANTI_SPOOF_CHNG,
766adfc5217SJeff Kirsher 	BNX2X_Q_UPDATE_ACTIVATE,
767adfc5217SJeff Kirsher 	BNX2X_Q_UPDATE_ACTIVATE_CHNG,
768adfc5217SJeff Kirsher 	BNX2X_Q_UPDATE_DEF_VLAN_EN,
769adfc5217SJeff Kirsher 	BNX2X_Q_UPDATE_DEF_VLAN_EN_CHNG,
770adfc5217SJeff Kirsher 	BNX2X_Q_UPDATE_SILENT_VLAN_REM_CHNG,
771c14db202SYuval Mintz 	BNX2X_Q_UPDATE_SILENT_VLAN_REM,
772c14db202SYuval Mintz 	BNX2X_Q_UPDATE_TX_SWITCHING_CHNG,
773eeed018cSMichal Kalderon 	BNX2X_Q_UPDATE_TX_SWITCHING,
774eeed018cSMichal Kalderon 	BNX2X_Q_UPDATE_PTP_PKTS_CHNG,
775eeed018cSMichal Kalderon 	BNX2X_Q_UPDATE_PTP_PKTS,
776adfc5217SJeff Kirsher };
777adfc5217SJeff Kirsher 
778adfc5217SJeff Kirsher /* Allowed Queue states */
779adfc5217SJeff Kirsher enum bnx2x_q_state {
780adfc5217SJeff Kirsher 	BNX2X_Q_STATE_RESET,
781adfc5217SJeff Kirsher 	BNX2X_Q_STATE_INITIALIZED,
782adfc5217SJeff Kirsher 	BNX2X_Q_STATE_ACTIVE,
783adfc5217SJeff Kirsher 	BNX2X_Q_STATE_MULTI_COS,
784adfc5217SJeff Kirsher 	BNX2X_Q_STATE_MCOS_TERMINATED,
785adfc5217SJeff Kirsher 	BNX2X_Q_STATE_INACTIVE,
786adfc5217SJeff Kirsher 	BNX2X_Q_STATE_STOPPED,
787adfc5217SJeff Kirsher 	BNX2X_Q_STATE_TERMINATED,
788adfc5217SJeff Kirsher 	BNX2X_Q_STATE_FLRED,
789adfc5217SJeff Kirsher 	BNX2X_Q_STATE_MAX,
790adfc5217SJeff Kirsher };
791adfc5217SJeff Kirsher 
79267c431a5SAriel Elior /* Allowed Queue states */
79367c431a5SAriel Elior enum bnx2x_q_logical_state {
79467c431a5SAriel Elior 	BNX2X_Q_LOGICAL_STATE_ACTIVE,
79567c431a5SAriel Elior 	BNX2X_Q_LOGICAL_STATE_STOPPED,
79667c431a5SAriel Elior };
79767c431a5SAriel Elior 
798adfc5217SJeff Kirsher /* Allowed commands */
799adfc5217SJeff Kirsher enum bnx2x_queue_cmd {
800adfc5217SJeff Kirsher 	BNX2X_Q_CMD_INIT,
801adfc5217SJeff Kirsher 	BNX2X_Q_CMD_SETUP,
802adfc5217SJeff Kirsher 	BNX2X_Q_CMD_SETUP_TX_ONLY,
803adfc5217SJeff Kirsher 	BNX2X_Q_CMD_DEACTIVATE,
804adfc5217SJeff Kirsher 	BNX2X_Q_CMD_ACTIVATE,
805adfc5217SJeff Kirsher 	BNX2X_Q_CMD_UPDATE,
806adfc5217SJeff Kirsher 	BNX2X_Q_CMD_UPDATE_TPA,
807adfc5217SJeff Kirsher 	BNX2X_Q_CMD_HALT,
808adfc5217SJeff Kirsher 	BNX2X_Q_CMD_CFC_DEL,
809adfc5217SJeff Kirsher 	BNX2X_Q_CMD_TERMINATE,
810adfc5217SJeff Kirsher 	BNX2X_Q_CMD_EMPTY,
811adfc5217SJeff Kirsher 	BNX2X_Q_CMD_MAX,
812adfc5217SJeff Kirsher };
813adfc5217SJeff Kirsher 
814adfc5217SJeff Kirsher /* queue SETUP + INIT flags */
815adfc5217SJeff Kirsher enum {
816adfc5217SJeff Kirsher 	BNX2X_Q_FLG_TPA,
817adfc5217SJeff Kirsher 	BNX2X_Q_FLG_TPA_IPV6,
818621b4d66SDmitry Kravkov 	BNX2X_Q_FLG_TPA_GRO,
819adfc5217SJeff Kirsher 	BNX2X_Q_FLG_STATS,
820adfc5217SJeff Kirsher 	BNX2X_Q_FLG_ZERO_STATS,
821adfc5217SJeff Kirsher 	BNX2X_Q_FLG_ACTIVE,
822adfc5217SJeff Kirsher 	BNX2X_Q_FLG_OV,
823adfc5217SJeff Kirsher 	BNX2X_Q_FLG_VLAN,
824adfc5217SJeff Kirsher 	BNX2X_Q_FLG_COS,
825adfc5217SJeff Kirsher 	BNX2X_Q_FLG_HC,
826adfc5217SJeff Kirsher 	BNX2X_Q_FLG_HC_EN,
827adfc5217SJeff Kirsher 	BNX2X_Q_FLG_DHC,
828adfc5217SJeff Kirsher 	BNX2X_Q_FLG_FCOE,
829adfc5217SJeff Kirsher 	BNX2X_Q_FLG_LEADING_RSS,
830adfc5217SJeff Kirsher 	BNX2X_Q_FLG_MCAST,
831adfc5217SJeff Kirsher 	BNX2X_Q_FLG_DEF_VLAN,
832adfc5217SJeff Kirsher 	BNX2X_Q_FLG_TX_SWITCH,
833adfc5217SJeff Kirsher 	BNX2X_Q_FLG_TX_SEC,
834adfc5217SJeff Kirsher 	BNX2X_Q_FLG_ANTI_SPOOF,
835a3348722SBarak Witkowski 	BNX2X_Q_FLG_SILENT_VLAN_REM,
83691226790SDmitry Kravkov 	BNX2X_Q_FLG_FORCE_DEFAULT_PRI,
837e42780b6SDmitry Kravkov 	BNX2X_Q_FLG_REFUSE_OUTBAND_VLAN,
838e287a75cSDmitry Kravkov 	BNX2X_Q_FLG_PCSUM_ON_PKT,
839e287a75cSDmitry Kravkov 	BNX2X_Q_FLG_TUN_INC_INNER_IP_ID
840adfc5217SJeff Kirsher };
841adfc5217SJeff Kirsher 
84216a5fd92SYuval Mintz /* Queue type options: queue type may be a combination of below. */
843adfc5217SJeff Kirsher enum bnx2x_q_type {
844adfc5217SJeff Kirsher 	/** TODO: Consider moving both these flags into the init()
845adfc5217SJeff Kirsher 	 *        ramrod params.
846adfc5217SJeff Kirsher 	 */
847adfc5217SJeff Kirsher 	BNX2X_Q_TYPE_HAS_RX,
848adfc5217SJeff Kirsher 	BNX2X_Q_TYPE_HAS_TX,
849adfc5217SJeff Kirsher };
850adfc5217SJeff Kirsher 
851adfc5217SJeff Kirsher #define BNX2X_PRIMARY_CID_INDEX			0
8528d7b0278SAriel Elior #define BNX2X_MULTI_TX_COS_E1X			3 /* QM only */
853adfc5217SJeff Kirsher #define BNX2X_MULTI_TX_COS_E2_E3A0		2
854adfc5217SJeff Kirsher #define BNX2X_MULTI_TX_COS_E3B0			3
8558d7b0278SAriel Elior #define BNX2X_MULTI_TX_COS			3 /* Maximum possible */
856adfc5217SJeff Kirsher 
8573ec9f9caSAriel Elior #define MAC_PAD (ALIGN(ETH_ALEN, sizeof(u32)) - ETH_ALEN)
858eeed018cSMichal Kalderon /* DMAE channel to be used by FW for timesync workaroun. A driver that sends
859eeed018cSMichal Kalderon  * timesync-related ramrods must not use this DMAE command ID.
860eeed018cSMichal Kalderon  */
861eeed018cSMichal Kalderon #define FW_DMAE_CMD_ID 6
862adfc5217SJeff Kirsher 
863adfc5217SJeff Kirsher struct bnx2x_queue_init_params {
864adfc5217SJeff Kirsher 	struct {
865adfc5217SJeff Kirsher 		unsigned long	flags;
866adfc5217SJeff Kirsher 		u16		hc_rate;
867adfc5217SJeff Kirsher 		u8		fw_sb_id;
868adfc5217SJeff Kirsher 		u8		sb_cq_index;
869adfc5217SJeff Kirsher 	} tx;
870adfc5217SJeff Kirsher 
871adfc5217SJeff Kirsher 	struct {
872adfc5217SJeff Kirsher 		unsigned long	flags;
873adfc5217SJeff Kirsher 		u16		hc_rate;
874adfc5217SJeff Kirsher 		u8		fw_sb_id;
875adfc5217SJeff Kirsher 		u8		sb_cq_index;
876adfc5217SJeff Kirsher 	} rx;
877adfc5217SJeff Kirsher 
878adfc5217SJeff Kirsher 	/* CID context in the host memory */
879adfc5217SJeff Kirsher 	struct eth_context *cxts[BNX2X_MULTI_TX_COS];
880adfc5217SJeff Kirsher 
881adfc5217SJeff Kirsher 	/* maximum number of cos supported by hardware */
882adfc5217SJeff Kirsher 	u8 max_cos;
883adfc5217SJeff Kirsher };
884adfc5217SJeff Kirsher 
885adfc5217SJeff Kirsher struct bnx2x_queue_terminate_params {
886adfc5217SJeff Kirsher 	/* index within the tx_only cids of this queue object */
887adfc5217SJeff Kirsher 	u8 cid_index;
888adfc5217SJeff Kirsher };
889adfc5217SJeff Kirsher 
890adfc5217SJeff Kirsher struct bnx2x_queue_cfc_del_params {
891adfc5217SJeff Kirsher 	/* index within the tx_only cids of this queue object */
892adfc5217SJeff Kirsher 	u8 cid_index;
893adfc5217SJeff Kirsher };
894adfc5217SJeff Kirsher 
895adfc5217SJeff Kirsher struct bnx2x_queue_update_params {
896adfc5217SJeff Kirsher 	unsigned long	update_flags; /* BNX2X_Q_UPDATE_XX bits */
897adfc5217SJeff Kirsher 	u16		def_vlan;
898adfc5217SJeff Kirsher 	u16		silent_removal_value;
899adfc5217SJeff Kirsher 	u16		silent_removal_mask;
900adfc5217SJeff Kirsher /* index within the tx_only cids of this queue object */
901adfc5217SJeff Kirsher 	u8		cid_index;
902adfc5217SJeff Kirsher };
903adfc5217SJeff Kirsher 
90414a94ebdSMichal Kalderon struct bnx2x_queue_update_tpa_params {
90514a94ebdSMichal Kalderon 	dma_addr_t sge_map;
90614a94ebdSMichal Kalderon 	u8 update_ipv4;
90714a94ebdSMichal Kalderon 	u8 update_ipv6;
90814a94ebdSMichal Kalderon 	u8 max_tpa_queues;
90914a94ebdSMichal Kalderon 	u8 max_sges_pkt;
91014a94ebdSMichal Kalderon 	u8 complete_on_both_clients;
91114a94ebdSMichal Kalderon 	u8 dont_verify_thr;
91214a94ebdSMichal Kalderon 	u8 tpa_mode;
91314a94ebdSMichal Kalderon 	u8 _pad;
91414a94ebdSMichal Kalderon 
91514a94ebdSMichal Kalderon 	u16 sge_buff_sz;
91614a94ebdSMichal Kalderon 	u16 max_agg_sz;
91714a94ebdSMichal Kalderon 
91814a94ebdSMichal Kalderon 	u16 sge_pause_thr_low;
91914a94ebdSMichal Kalderon 	u16 sge_pause_thr_high;
92014a94ebdSMichal Kalderon };
92114a94ebdSMichal Kalderon 
922adfc5217SJeff Kirsher struct rxq_pause_params {
923adfc5217SJeff Kirsher 	u16		bd_th_lo;
924adfc5217SJeff Kirsher 	u16		bd_th_hi;
925adfc5217SJeff Kirsher 	u16		rcq_th_lo;
926adfc5217SJeff Kirsher 	u16		rcq_th_hi;
927adfc5217SJeff Kirsher 	u16		sge_th_lo; /* valid iff BNX2X_Q_FLG_TPA */
928adfc5217SJeff Kirsher 	u16		sge_th_hi; /* valid iff BNX2X_Q_FLG_TPA */
929adfc5217SJeff Kirsher 	u16		pri_map;
930adfc5217SJeff Kirsher };
931adfc5217SJeff Kirsher 
932adfc5217SJeff Kirsher /* general */
933adfc5217SJeff Kirsher struct bnx2x_general_setup_params {
934adfc5217SJeff Kirsher 	/* valid iff BNX2X_Q_FLG_STATS */
935adfc5217SJeff Kirsher 	u8		stat_id;
936adfc5217SJeff Kirsher 
937adfc5217SJeff Kirsher 	u8		spcl_id;
938adfc5217SJeff Kirsher 	u16		mtu;
939adfc5217SJeff Kirsher 	u8		cos;
940adfc5217SJeff Kirsher };
941adfc5217SJeff Kirsher 
942adfc5217SJeff Kirsher struct bnx2x_rxq_setup_params {
943adfc5217SJeff Kirsher 	/* dma */
944adfc5217SJeff Kirsher 	dma_addr_t	dscr_map;
945adfc5217SJeff Kirsher 	dma_addr_t	sge_map;
946adfc5217SJeff Kirsher 	dma_addr_t	rcq_map;
947adfc5217SJeff Kirsher 	dma_addr_t	rcq_np_map;
948adfc5217SJeff Kirsher 
949adfc5217SJeff Kirsher 	u16		drop_flags;
950adfc5217SJeff Kirsher 	u16		buf_sz;
951adfc5217SJeff Kirsher 	u8		fw_sb_id;
952adfc5217SJeff Kirsher 	u8		cl_qzone_id;
953adfc5217SJeff Kirsher 
954adfc5217SJeff Kirsher 	/* valid iff BNX2X_Q_FLG_TPA */
955adfc5217SJeff Kirsher 	u16		tpa_agg_sz;
956adfc5217SJeff Kirsher 	u16		sge_buf_sz;
957adfc5217SJeff Kirsher 	u8		max_sges_pkt;
958adfc5217SJeff Kirsher 	u8		max_tpa_queues;
959adfc5217SJeff Kirsher 	u8		rss_engine_id;
960adfc5217SJeff Kirsher 
961259afa1fSYuval Mintz 	/* valid iff BNX2X_Q_FLG_MCAST */
962259afa1fSYuval Mintz 	u8		mcast_engine_id;
963259afa1fSYuval Mintz 
964adfc5217SJeff Kirsher 	u8		cache_line_log;
965adfc5217SJeff Kirsher 
966adfc5217SJeff Kirsher 	u8		sb_cq_index;
967adfc5217SJeff Kirsher 
968adfc5217SJeff Kirsher 	/* valid iff BXN2X_Q_FLG_SILENT_VLAN_REM */
969adfc5217SJeff Kirsher 	u16 silent_removal_value;
970adfc5217SJeff Kirsher 	u16 silent_removal_mask;
971adfc5217SJeff Kirsher };
972adfc5217SJeff Kirsher 
973adfc5217SJeff Kirsher struct bnx2x_txq_setup_params {
974adfc5217SJeff Kirsher 	/* dma */
975adfc5217SJeff Kirsher 	dma_addr_t	dscr_map;
976adfc5217SJeff Kirsher 
977adfc5217SJeff Kirsher 	u8		fw_sb_id;
978adfc5217SJeff Kirsher 	u8		sb_cq_index;
979adfc5217SJeff Kirsher 	u8		cos;		/* valid iff BNX2X_Q_FLG_COS */
980adfc5217SJeff Kirsher 	u16		traffic_type;
981adfc5217SJeff Kirsher 	/* equals to the leading rss client id, used for TX classification*/
982adfc5217SJeff Kirsher 	u8		tss_leading_cl_id;
983adfc5217SJeff Kirsher 
984adfc5217SJeff Kirsher 	/* valid iff BNX2X_Q_FLG_DEF_VLAN */
985adfc5217SJeff Kirsher 	u16		default_vlan;
986adfc5217SJeff Kirsher };
987adfc5217SJeff Kirsher 
988adfc5217SJeff Kirsher struct bnx2x_queue_setup_params {
989adfc5217SJeff Kirsher 	struct bnx2x_general_setup_params gen_params;
990adfc5217SJeff Kirsher 	struct bnx2x_txq_setup_params txq_params;
991adfc5217SJeff Kirsher 	struct bnx2x_rxq_setup_params rxq_params;
992adfc5217SJeff Kirsher 	struct rxq_pause_params pause_params;
993adfc5217SJeff Kirsher 	unsigned long flags;
994adfc5217SJeff Kirsher };
995adfc5217SJeff Kirsher 
996adfc5217SJeff Kirsher struct bnx2x_queue_setup_tx_only_params {
997adfc5217SJeff Kirsher 	struct bnx2x_general_setup_params	gen_params;
998adfc5217SJeff Kirsher 	struct bnx2x_txq_setup_params		txq_params;
999adfc5217SJeff Kirsher 	unsigned long				flags;
1000adfc5217SJeff Kirsher 	/* index within the tx_only cids of this queue object */
1001adfc5217SJeff Kirsher 	u8					cid_index;
1002adfc5217SJeff Kirsher };
1003adfc5217SJeff Kirsher 
1004adfc5217SJeff Kirsher struct bnx2x_queue_state_params {
1005adfc5217SJeff Kirsher 	struct bnx2x_queue_sp_obj *q_obj;
1006adfc5217SJeff Kirsher 
1007adfc5217SJeff Kirsher 	/* Current command */
1008adfc5217SJeff Kirsher 	enum bnx2x_queue_cmd cmd;
1009adfc5217SJeff Kirsher 
1010adfc5217SJeff Kirsher 	/* may have RAMROD_COMP_WAIT set only */
1011adfc5217SJeff Kirsher 	unsigned long ramrod_flags;
1012adfc5217SJeff Kirsher 
1013adfc5217SJeff Kirsher 	/* Params according to the current command */
1014adfc5217SJeff Kirsher 	union {
1015adfc5217SJeff Kirsher 		struct bnx2x_queue_update_params	update;
101614a94ebdSMichal Kalderon 		struct bnx2x_queue_update_tpa_params    update_tpa;
1017adfc5217SJeff Kirsher 		struct bnx2x_queue_setup_params		setup;
1018adfc5217SJeff Kirsher 		struct bnx2x_queue_init_params		init;
1019adfc5217SJeff Kirsher 		struct bnx2x_queue_setup_tx_only_params	tx_only;
1020adfc5217SJeff Kirsher 		struct bnx2x_queue_terminate_params	terminate;
1021adfc5217SJeff Kirsher 		struct bnx2x_queue_cfc_del_params	cfc_del;
1022adfc5217SJeff Kirsher 	} params;
1023adfc5217SJeff Kirsher };
1024adfc5217SJeff Kirsher 
1025a3348722SBarak Witkowski struct bnx2x_viflist_params {
1026a3348722SBarak Witkowski 	u8 echo_res;
1027a3348722SBarak Witkowski 	u8 func_bit_map_res;
1028a3348722SBarak Witkowski };
1029a3348722SBarak Witkowski 
1030adfc5217SJeff Kirsher struct bnx2x_queue_sp_obj {
1031adfc5217SJeff Kirsher 	u32		cids[BNX2X_MULTI_TX_COS];
1032adfc5217SJeff Kirsher 	u8		cl_id;
1033adfc5217SJeff Kirsher 	u8		func_id;
1034adfc5217SJeff Kirsher 
103516a5fd92SYuval Mintz 	/* number of traffic classes supported by queue.
103616a5fd92SYuval Mintz 	 * The primary connection of the queue supports the first traffic
103716a5fd92SYuval Mintz 	 * class. Any further traffic class is supported by a tx-only
1038adfc5217SJeff Kirsher 	 * connection.
1039adfc5217SJeff Kirsher 	 *
1040adfc5217SJeff Kirsher 	 * Therefore max_cos is also a number of valid entries in the cids
1041adfc5217SJeff Kirsher 	 * array.
1042adfc5217SJeff Kirsher 	 */
1043adfc5217SJeff Kirsher 	u8 max_cos;
1044adfc5217SJeff Kirsher 	u8 num_tx_only, next_tx_only;
1045adfc5217SJeff Kirsher 
1046adfc5217SJeff Kirsher 	enum bnx2x_q_state state, next_state;
1047adfc5217SJeff Kirsher 
1048adfc5217SJeff Kirsher 	/* bits from enum bnx2x_q_type */
1049adfc5217SJeff Kirsher 	unsigned long	type;
1050adfc5217SJeff Kirsher 
1051adfc5217SJeff Kirsher 	/* BNX2X_Q_CMD_XX bits. This object implements "one
1052adfc5217SJeff Kirsher 	 * pending" paradigm but for debug and tracing purposes it's
105316a5fd92SYuval Mintz 	 * more convenient to have different bits for different
1054adfc5217SJeff Kirsher 	 * commands.
1055adfc5217SJeff Kirsher 	 */
1056adfc5217SJeff Kirsher 	unsigned long	pending;
1057adfc5217SJeff Kirsher 
1058adfc5217SJeff Kirsher 	/* Buffer to use as a ramrod data and its mapping */
1059adfc5217SJeff Kirsher 	void		*rdata;
1060adfc5217SJeff Kirsher 	dma_addr_t	rdata_mapping;
1061adfc5217SJeff Kirsher 
1062adfc5217SJeff Kirsher 	/**
1063adfc5217SJeff Kirsher 	 * Performs one state change according to the given parameters.
1064adfc5217SJeff Kirsher 	 *
1065adfc5217SJeff Kirsher 	 * @return 0 in case of success and negative value otherwise.
1066adfc5217SJeff Kirsher 	 */
1067adfc5217SJeff Kirsher 	int (*send_cmd)(struct bnx2x *bp,
1068adfc5217SJeff Kirsher 			struct bnx2x_queue_state_params *params);
1069adfc5217SJeff Kirsher 
1070adfc5217SJeff Kirsher 	/**
1071adfc5217SJeff Kirsher 	 * Sets the pending bit according to the requested transition.
1072adfc5217SJeff Kirsher 	 */
1073adfc5217SJeff Kirsher 	int (*set_pending)(struct bnx2x_queue_sp_obj *o,
1074adfc5217SJeff Kirsher 			   struct bnx2x_queue_state_params *params);
1075adfc5217SJeff Kirsher 
1076adfc5217SJeff Kirsher 	/**
1077adfc5217SJeff Kirsher 	 * Checks that the requested state transition is legal.
1078adfc5217SJeff Kirsher 	 */
1079adfc5217SJeff Kirsher 	int (*check_transition)(struct bnx2x *bp,
1080adfc5217SJeff Kirsher 				struct bnx2x_queue_sp_obj *o,
1081adfc5217SJeff Kirsher 				struct bnx2x_queue_state_params *params);
1082adfc5217SJeff Kirsher 
1083adfc5217SJeff Kirsher 	/**
1084adfc5217SJeff Kirsher 	 * Completes the pending command.
1085adfc5217SJeff Kirsher 	 */
1086adfc5217SJeff Kirsher 	int (*complete_cmd)(struct bnx2x *bp,
1087adfc5217SJeff Kirsher 			    struct bnx2x_queue_sp_obj *o,
1088adfc5217SJeff Kirsher 			    enum bnx2x_queue_cmd);
1089adfc5217SJeff Kirsher 
1090adfc5217SJeff Kirsher 	int (*wait_comp)(struct bnx2x *bp,
1091adfc5217SJeff Kirsher 			 struct bnx2x_queue_sp_obj *o,
1092adfc5217SJeff Kirsher 			 enum bnx2x_queue_cmd cmd);
1093adfc5217SJeff Kirsher };
1094adfc5217SJeff Kirsher 
1095adfc5217SJeff Kirsher /********************** Function state update *********************************/
1096e42780b6SDmitry Kravkov 
1097e42780b6SDmitry Kravkov /* UPDATE command options */
1098e42780b6SDmitry Kravkov enum {
1099e42780b6SDmitry Kravkov 	BNX2X_F_UPDATE_TX_SWITCH_SUSPEND_CHNG,
1100e42780b6SDmitry Kravkov 	BNX2X_F_UPDATE_TX_SWITCH_SUSPEND,
11017609647eSYuval Mintz 	BNX2X_F_UPDATE_SD_VLAN_TAG_CHNG,
11027609647eSYuval Mintz 	BNX2X_F_UPDATE_SD_VLAN_ETH_TYPE_CHNG,
11037609647eSYuval Mintz 	BNX2X_F_UPDATE_VLAN_FORCE_PRIO_CHNG,
11047609647eSYuval Mintz 	BNX2X_F_UPDATE_VLAN_FORCE_PRIO_FLAG,
1105e42780b6SDmitry Kravkov 	BNX2X_F_UPDATE_TUNNEL_CFG_CHNG,
1106e42780b6SDmitry Kravkov 	BNX2X_F_UPDATE_TUNNEL_CLSS_EN,
1107e42780b6SDmitry Kravkov 	BNX2X_F_UPDATE_TUNNEL_INNER_GRE_RSS_EN,
1108e42780b6SDmitry Kravkov };
1109e42780b6SDmitry Kravkov 
1110adfc5217SJeff Kirsher /* Allowed Function states */
1111adfc5217SJeff Kirsher enum bnx2x_func_state {
1112adfc5217SJeff Kirsher 	BNX2X_F_STATE_RESET,
1113adfc5217SJeff Kirsher 	BNX2X_F_STATE_INITIALIZED,
1114adfc5217SJeff Kirsher 	BNX2X_F_STATE_STARTED,
1115adfc5217SJeff Kirsher 	BNX2X_F_STATE_TX_STOPPED,
1116adfc5217SJeff Kirsher 	BNX2X_F_STATE_MAX,
1117adfc5217SJeff Kirsher };
1118adfc5217SJeff Kirsher 
1119adfc5217SJeff Kirsher /* Allowed Function commands */
1120adfc5217SJeff Kirsher enum bnx2x_func_cmd {
1121adfc5217SJeff Kirsher 	BNX2X_F_CMD_HW_INIT,
1122adfc5217SJeff Kirsher 	BNX2X_F_CMD_START,
1123adfc5217SJeff Kirsher 	BNX2X_F_CMD_STOP,
1124adfc5217SJeff Kirsher 	BNX2X_F_CMD_HW_RESET,
1125a3348722SBarak Witkowski 	BNX2X_F_CMD_AFEX_UPDATE,
1126a3348722SBarak Witkowski 	BNX2X_F_CMD_AFEX_VIFLISTS,
1127adfc5217SJeff Kirsher 	BNX2X_F_CMD_TX_STOP,
1128adfc5217SJeff Kirsher 	BNX2X_F_CMD_TX_START,
112955c11941SMerav Sicron 	BNX2X_F_CMD_SWITCH_UPDATE,
1130eeed018cSMichal Kalderon 	BNX2X_F_CMD_SET_TIMESYNC,
1131adfc5217SJeff Kirsher 	BNX2X_F_CMD_MAX,
1132adfc5217SJeff Kirsher };
1133adfc5217SJeff Kirsher 
1134adfc5217SJeff Kirsher struct bnx2x_func_hw_init_params {
1135adfc5217SJeff Kirsher 	/* A load phase returned by MCP.
1136adfc5217SJeff Kirsher 	 *
1137adfc5217SJeff Kirsher 	 * May be:
1138adfc5217SJeff Kirsher 	 *		FW_MSG_CODE_DRV_LOAD_COMMON_CHIP
1139adfc5217SJeff Kirsher 	 *		FW_MSG_CODE_DRV_LOAD_COMMON
1140adfc5217SJeff Kirsher 	 *		FW_MSG_CODE_DRV_LOAD_PORT
1141adfc5217SJeff Kirsher 	 *		FW_MSG_CODE_DRV_LOAD_FUNCTION
1142adfc5217SJeff Kirsher 	 */
1143adfc5217SJeff Kirsher 	u32 load_phase;
1144adfc5217SJeff Kirsher };
1145adfc5217SJeff Kirsher 
1146adfc5217SJeff Kirsher struct bnx2x_func_hw_reset_params {
1147adfc5217SJeff Kirsher 	/* A load phase returned by MCP.
1148adfc5217SJeff Kirsher 	 *
1149adfc5217SJeff Kirsher 	 * May be:
1150adfc5217SJeff Kirsher 	 *		FW_MSG_CODE_DRV_LOAD_COMMON_CHIP
1151adfc5217SJeff Kirsher 	 *		FW_MSG_CODE_DRV_LOAD_COMMON
1152adfc5217SJeff Kirsher 	 *		FW_MSG_CODE_DRV_LOAD_PORT
1153adfc5217SJeff Kirsher 	 *		FW_MSG_CODE_DRV_LOAD_FUNCTION
1154adfc5217SJeff Kirsher 	 */
1155adfc5217SJeff Kirsher 	u32 reset_phase;
1156adfc5217SJeff Kirsher };
1157adfc5217SJeff Kirsher 
1158adfc5217SJeff Kirsher struct bnx2x_func_start_params {
1159adfc5217SJeff Kirsher 	/* Multi Function mode:
1160adfc5217SJeff Kirsher 	 *	- Single Function
1161adfc5217SJeff Kirsher 	 *	- Switch Dependent
1162adfc5217SJeff Kirsher 	 *	- Switch Independent
1163adfc5217SJeff Kirsher 	 */
1164adfc5217SJeff Kirsher 	u16 mf_mode;
1165adfc5217SJeff Kirsher 
1166adfc5217SJeff Kirsher 	/* Switch Dependent mode outer VLAN tag */
1167adfc5217SJeff Kirsher 	u16 sd_vlan_tag;
1168adfc5217SJeff Kirsher 
1169adfc5217SJeff Kirsher 	/* Function cos mode */
1170adfc5217SJeff Kirsher 	u8 network_cos_mode;
11711bc277f7SDmitry Kravkov 
1172e42780b6SDmitry Kravkov 	/* TUNN_MODE_NONE/TUNN_MODE_VXLAN/TUNN_MODE_GRE */
1173e42780b6SDmitry Kravkov 	u8 tunnel_mode;
11741bc277f7SDmitry Kravkov 
1175e42780b6SDmitry Kravkov 	/* tunneling classification enablement */
1176e42780b6SDmitry Kravkov 	u8 tunn_clss_en;
11771bc277f7SDmitry Kravkov 
1178e42780b6SDmitry Kravkov 	/* NVGRE_TUNNEL/L2GRE_TUNNEL/IPGRE_TUNNEL */
1179e42780b6SDmitry Kravkov 	u8 gre_tunnel_type;
1180e42780b6SDmitry Kravkov 
1181e42780b6SDmitry Kravkov 	/* Enables Inner GRE RSS on the function, depends on the client RSS
1182e42780b6SDmitry Kravkov 	 * capailities
1183e42780b6SDmitry Kravkov 	 */
1184e42780b6SDmitry Kravkov 	u8 inner_gre_rss_en;
11857609647eSYuval Mintz 
11867609647eSYuval Mintz 	/* Allows accepting of packets failing MF classification, possibly
11877609647eSYuval Mintz 	 * only matching a given ethertype
11887609647eSYuval Mintz 	 */
11897609647eSYuval Mintz 	u8 class_fail;
11907609647eSYuval Mintz 	u16 class_fail_ethtype;
11917609647eSYuval Mintz 
11927609647eSYuval Mintz 	/* Override priority of output packets */
11937609647eSYuval Mintz 	u8 sd_vlan_force_pri;
11947609647eSYuval Mintz 	u8 sd_vlan_force_pri_val;
11957609647eSYuval Mintz 
11967609647eSYuval Mintz 	/* Replace vlan's ethertype */
11977609647eSYuval Mintz 	u16 sd_vlan_eth_type;
11987609647eSYuval Mintz 
11997609647eSYuval Mintz 	/* Prevent inner vlans from being added by FW */
12007609647eSYuval Mintz 	u8 no_added_tags;
1201adfc5217SJeff Kirsher };
1202adfc5217SJeff Kirsher 
120355c11941SMerav Sicron struct bnx2x_func_switch_update_params {
1204e42780b6SDmitry Kravkov 	unsigned long changes; /* BNX2X_F_UPDATE_XX bits */
12057609647eSYuval Mintz 	u16 vlan;
12067609647eSYuval Mintz 	u16 vlan_eth_type;
12077609647eSYuval Mintz 	u8 vlan_force_prio;
1208e42780b6SDmitry Kravkov 	u8 tunnel_mode;
1209e42780b6SDmitry Kravkov 	u8 gre_tunnel_type;
121055c11941SMerav Sicron };
121155c11941SMerav Sicron 
1212a3348722SBarak Witkowski struct bnx2x_func_afex_update_params {
1213a3348722SBarak Witkowski 	u16 vif_id;
1214a3348722SBarak Witkowski 	u16 afex_default_vlan;
1215a3348722SBarak Witkowski 	u8 allowed_priorities;
1216a3348722SBarak Witkowski };
1217a3348722SBarak Witkowski 
1218a3348722SBarak Witkowski struct bnx2x_func_afex_viflists_params {
1219a3348722SBarak Witkowski 	u16 vif_list_index;
1220a3348722SBarak Witkowski 	u8 func_bit_map;
1221a3348722SBarak Witkowski 	u8 afex_vif_list_command;
1222a3348722SBarak Witkowski 	u8 func_to_clear;
1223a3348722SBarak Witkowski };
1224eeed018cSMichal Kalderon 
1225adfc5217SJeff Kirsher struct bnx2x_func_tx_start_params {
1226adfc5217SJeff Kirsher 	struct priority_cos traffic_type_to_priority_cos[MAX_TRAFFIC_TYPES];
1227adfc5217SJeff Kirsher 	u8 dcb_enabled;
1228adfc5217SJeff Kirsher 	u8 dcb_version;
1229adfc5217SJeff Kirsher 	u8 dont_add_pri_0_en;
1230adfc5217SJeff Kirsher };
1231adfc5217SJeff Kirsher 
1232eeed018cSMichal Kalderon struct bnx2x_func_set_timesync_params {
1233eeed018cSMichal Kalderon 	/* Reset, set or keep the current drift value */
1234eeed018cSMichal Kalderon 	u8 drift_adjust_cmd;
1235eeed018cSMichal Kalderon 
1236eeed018cSMichal Kalderon 	/* Dec, inc or keep the current offset */
1237eeed018cSMichal Kalderon 	u8 offset_cmd;
1238eeed018cSMichal Kalderon 
1239eeed018cSMichal Kalderon 	/* Drift value direction */
1240eeed018cSMichal Kalderon 	u8 add_sub_drift_adjust_value;
1241eeed018cSMichal Kalderon 
1242eeed018cSMichal Kalderon 	/* Drift, period and offset values to be used according to the commands
1243eeed018cSMichal Kalderon 	 * above.
1244eeed018cSMichal Kalderon 	 */
1245eeed018cSMichal Kalderon 	u8 drift_adjust_value;
1246eeed018cSMichal Kalderon 	u32 drift_adjust_period;
1247eeed018cSMichal Kalderon 	u64 offset_delta;
1248eeed018cSMichal Kalderon };
1249eeed018cSMichal Kalderon 
1250adfc5217SJeff Kirsher struct bnx2x_func_state_params {
1251adfc5217SJeff Kirsher 	struct bnx2x_func_sp_obj *f_obj;
1252adfc5217SJeff Kirsher 
1253adfc5217SJeff Kirsher 	/* Current command */
1254adfc5217SJeff Kirsher 	enum bnx2x_func_cmd cmd;
1255adfc5217SJeff Kirsher 
1256adfc5217SJeff Kirsher 	/* may have RAMROD_COMP_WAIT set only */
1257adfc5217SJeff Kirsher 	unsigned long	ramrod_flags;
1258adfc5217SJeff Kirsher 
1259adfc5217SJeff Kirsher 	/* Params according to the current command */
1260adfc5217SJeff Kirsher 	union {
1261adfc5217SJeff Kirsher 		struct bnx2x_func_hw_init_params hw_init;
1262adfc5217SJeff Kirsher 		struct bnx2x_func_hw_reset_params hw_reset;
1263adfc5217SJeff Kirsher 		struct bnx2x_func_start_params start;
126455c11941SMerav Sicron 		struct bnx2x_func_switch_update_params switch_update;
1265a3348722SBarak Witkowski 		struct bnx2x_func_afex_update_params afex_update;
1266a3348722SBarak Witkowski 		struct bnx2x_func_afex_viflists_params afex_viflists;
1267adfc5217SJeff Kirsher 		struct bnx2x_func_tx_start_params tx_start;
1268eeed018cSMichal Kalderon 		struct bnx2x_func_set_timesync_params set_timesync;
1269adfc5217SJeff Kirsher 	} params;
1270adfc5217SJeff Kirsher };
1271adfc5217SJeff Kirsher 
1272adfc5217SJeff Kirsher struct bnx2x_func_sp_drv_ops {
1273adfc5217SJeff Kirsher 	/* Init tool + runtime initialization:
1274adfc5217SJeff Kirsher 	 *      - Common Chip
1275adfc5217SJeff Kirsher 	 *      - Common (per Path)
1276adfc5217SJeff Kirsher 	 *      - Port
1277adfc5217SJeff Kirsher 	 *      - Function phases
1278adfc5217SJeff Kirsher 	 */
1279adfc5217SJeff Kirsher 	int (*init_hw_cmn_chip)(struct bnx2x *bp);
1280adfc5217SJeff Kirsher 	int (*init_hw_cmn)(struct bnx2x *bp);
1281adfc5217SJeff Kirsher 	int (*init_hw_port)(struct bnx2x *bp);
1282adfc5217SJeff Kirsher 	int (*init_hw_func)(struct bnx2x *bp);
1283adfc5217SJeff Kirsher 
1284adfc5217SJeff Kirsher 	/* Reset Function HW: Common, Port, Function phases. */
1285adfc5217SJeff Kirsher 	void (*reset_hw_cmn)(struct bnx2x *bp);
1286adfc5217SJeff Kirsher 	void (*reset_hw_port)(struct bnx2x *bp);
1287adfc5217SJeff Kirsher 	void (*reset_hw_func)(struct bnx2x *bp);
1288adfc5217SJeff Kirsher 
1289adfc5217SJeff Kirsher 	/* Init/Free GUNZIP resources */
1290adfc5217SJeff Kirsher 	int (*gunzip_init)(struct bnx2x *bp);
1291adfc5217SJeff Kirsher 	void (*gunzip_end)(struct bnx2x *bp);
1292adfc5217SJeff Kirsher 
1293adfc5217SJeff Kirsher 	/* Prepare/Release FW resources */
1294adfc5217SJeff Kirsher 	int (*init_fw)(struct bnx2x *bp);
1295adfc5217SJeff Kirsher 	void (*release_fw)(struct bnx2x *bp);
1296adfc5217SJeff Kirsher };
1297adfc5217SJeff Kirsher 
1298adfc5217SJeff Kirsher struct bnx2x_func_sp_obj {
1299adfc5217SJeff Kirsher 	enum bnx2x_func_state	state, next_state;
1300adfc5217SJeff Kirsher 
1301adfc5217SJeff Kirsher 	/* BNX2X_FUNC_CMD_XX bits. This object implements "one
1302adfc5217SJeff Kirsher 	 * pending" paradigm but for debug and tracing purposes it's
130316a5fd92SYuval Mintz 	 * more convenient to have different bits for different
1304adfc5217SJeff Kirsher 	 * commands.
1305adfc5217SJeff Kirsher 	 */
1306adfc5217SJeff Kirsher 	unsigned long		pending;
1307adfc5217SJeff Kirsher 
1308adfc5217SJeff Kirsher 	/* Buffer to use as a ramrod data and its mapping */
1309adfc5217SJeff Kirsher 	void			*rdata;
1310adfc5217SJeff Kirsher 	dma_addr_t		rdata_mapping;
1311adfc5217SJeff Kirsher 
1312a3348722SBarak Witkowski 	/* Buffer to use as a afex ramrod data and its mapping.
1313a3348722SBarak Witkowski 	 * This can't be same rdata as above because afex ramrod requests
1314a3348722SBarak Witkowski 	 * can arrive to the object in parallel to other ramrod requests.
1315a3348722SBarak Witkowski 	 */
1316a3348722SBarak Witkowski 	void			*afex_rdata;
1317a3348722SBarak Witkowski 	dma_addr_t		afex_rdata_mapping;
1318a3348722SBarak Witkowski 
1319adfc5217SJeff Kirsher 	/* this mutex validates that when pending flag is taken, the next
1320adfc5217SJeff Kirsher 	 * ramrod to be sent will be the one set the pending bit
1321adfc5217SJeff Kirsher 	 */
1322adfc5217SJeff Kirsher 	struct mutex		one_pending_mutex;
1323adfc5217SJeff Kirsher 
1324adfc5217SJeff Kirsher 	/* Driver interface */
1325adfc5217SJeff Kirsher 	struct bnx2x_func_sp_drv_ops	*drv;
1326adfc5217SJeff Kirsher 
1327adfc5217SJeff Kirsher 	/**
1328adfc5217SJeff Kirsher 	 * Performs one state change according to the given parameters.
1329adfc5217SJeff Kirsher 	 *
1330adfc5217SJeff Kirsher 	 * @return 0 in case of success and negative value otherwise.
1331adfc5217SJeff Kirsher 	 */
1332adfc5217SJeff Kirsher 	int (*send_cmd)(struct bnx2x *bp,
1333adfc5217SJeff Kirsher 			struct bnx2x_func_state_params *params);
1334adfc5217SJeff Kirsher 
1335adfc5217SJeff Kirsher 	/**
1336adfc5217SJeff Kirsher 	 * Checks that the requested state transition is legal.
1337adfc5217SJeff Kirsher 	 */
1338adfc5217SJeff Kirsher 	int (*check_transition)(struct bnx2x *bp,
1339adfc5217SJeff Kirsher 				struct bnx2x_func_sp_obj *o,
1340adfc5217SJeff Kirsher 				struct bnx2x_func_state_params *params);
1341adfc5217SJeff Kirsher 
1342adfc5217SJeff Kirsher 	/**
1343adfc5217SJeff Kirsher 	 * Completes the pending command.
1344adfc5217SJeff Kirsher 	 */
1345adfc5217SJeff Kirsher 	int (*complete_cmd)(struct bnx2x *bp,
1346adfc5217SJeff Kirsher 			    struct bnx2x_func_sp_obj *o,
1347adfc5217SJeff Kirsher 			    enum bnx2x_func_cmd cmd);
1348adfc5217SJeff Kirsher 
1349adfc5217SJeff Kirsher 	int (*wait_comp)(struct bnx2x *bp, struct bnx2x_func_sp_obj *o,
1350adfc5217SJeff Kirsher 			 enum bnx2x_func_cmd cmd);
1351adfc5217SJeff Kirsher };
1352adfc5217SJeff Kirsher 
1353adfc5217SJeff Kirsher /********************** Interfaces ********************************************/
1354adfc5217SJeff Kirsher /* Queueable objects set */
1355adfc5217SJeff Kirsher union bnx2x_qable_obj {
1356adfc5217SJeff Kirsher 	struct bnx2x_vlan_mac_obj vlan_mac;
1357adfc5217SJeff Kirsher };
1358adfc5217SJeff Kirsher /************** Function state update *********/
1359adfc5217SJeff Kirsher void bnx2x_init_func_obj(struct bnx2x *bp,
1360adfc5217SJeff Kirsher 			 struct bnx2x_func_sp_obj *obj,
1361adfc5217SJeff Kirsher 			 void *rdata, dma_addr_t rdata_mapping,
1362a3348722SBarak Witkowski 			 void *afex_rdata, dma_addr_t afex_rdata_mapping,
1363adfc5217SJeff Kirsher 			 struct bnx2x_func_sp_drv_ops *drv_iface);
1364adfc5217SJeff Kirsher 
1365adfc5217SJeff Kirsher int bnx2x_func_state_change(struct bnx2x *bp,
1366adfc5217SJeff Kirsher 			    struct bnx2x_func_state_params *params);
1367adfc5217SJeff Kirsher 
1368adfc5217SJeff Kirsher enum bnx2x_func_state bnx2x_func_get_state(struct bnx2x *bp,
1369adfc5217SJeff Kirsher 					   struct bnx2x_func_sp_obj *o);
1370adfc5217SJeff Kirsher /******************* Queue State **************/
1371adfc5217SJeff Kirsher void bnx2x_init_queue_obj(struct bnx2x *bp,
1372adfc5217SJeff Kirsher 			  struct bnx2x_queue_sp_obj *obj, u8 cl_id, u32 *cids,
1373adfc5217SJeff Kirsher 			  u8 cid_cnt, u8 func_id, void *rdata,
1374adfc5217SJeff Kirsher 			  dma_addr_t rdata_mapping, unsigned long type);
1375adfc5217SJeff Kirsher 
1376adfc5217SJeff Kirsher int bnx2x_queue_state_change(struct bnx2x *bp,
1377adfc5217SJeff Kirsher 			     struct bnx2x_queue_state_params *params);
1378adfc5217SJeff Kirsher 
137967c431a5SAriel Elior int bnx2x_get_q_logical_state(struct bnx2x *bp,
138067c431a5SAriel Elior 			       struct bnx2x_queue_sp_obj *obj);
138167c431a5SAriel Elior 
1382adfc5217SJeff Kirsher /********************* VLAN-MAC ****************/
1383adfc5217SJeff Kirsher void bnx2x_init_mac_obj(struct bnx2x *bp,
1384adfc5217SJeff Kirsher 			struct bnx2x_vlan_mac_obj *mac_obj,
1385adfc5217SJeff Kirsher 			u8 cl_id, u32 cid, u8 func_id, void *rdata,
1386adfc5217SJeff Kirsher 			dma_addr_t rdata_mapping, int state,
1387adfc5217SJeff Kirsher 			unsigned long *pstate, bnx2x_obj_type type,
1388adfc5217SJeff Kirsher 			struct bnx2x_credit_pool_obj *macs_pool);
1389adfc5217SJeff Kirsher 
1390adfc5217SJeff Kirsher void bnx2x_init_vlan_obj(struct bnx2x *bp,
1391adfc5217SJeff Kirsher 			 struct bnx2x_vlan_mac_obj *vlan_obj,
1392adfc5217SJeff Kirsher 			 u8 cl_id, u32 cid, u8 func_id, void *rdata,
1393adfc5217SJeff Kirsher 			 dma_addr_t rdata_mapping, int state,
1394adfc5217SJeff Kirsher 			 unsigned long *pstate, bnx2x_obj_type type,
1395adfc5217SJeff Kirsher 			 struct bnx2x_credit_pool_obj *vlans_pool);
1396adfc5217SJeff Kirsher 
13978b09be5fSYuval Mintz int bnx2x_vlan_mac_h_read_lock(struct bnx2x *bp,
13988b09be5fSYuval Mintz 					struct bnx2x_vlan_mac_obj *o);
13998b09be5fSYuval Mintz void bnx2x_vlan_mac_h_read_unlock(struct bnx2x *bp,
14008b09be5fSYuval Mintz 				  struct bnx2x_vlan_mac_obj *o);
14018b09be5fSYuval Mintz int bnx2x_vlan_mac_h_write_lock(struct bnx2x *bp,
14028b09be5fSYuval Mintz 				struct bnx2x_vlan_mac_obj *o);
1403adfc5217SJeff Kirsher int bnx2x_config_vlan_mac(struct bnx2x *bp,
1404adfc5217SJeff Kirsher 			   struct bnx2x_vlan_mac_ramrod_params *p);
1405adfc5217SJeff Kirsher 
1406adfc5217SJeff Kirsher int bnx2x_vlan_mac_move(struct bnx2x *bp,
1407adfc5217SJeff Kirsher 			struct bnx2x_vlan_mac_ramrod_params *p,
1408adfc5217SJeff Kirsher 			struct bnx2x_vlan_mac_obj *dest_o);
1409adfc5217SJeff Kirsher 
1410adfc5217SJeff Kirsher /********************* RX MODE ****************/
1411adfc5217SJeff Kirsher 
1412adfc5217SJeff Kirsher void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
1413adfc5217SJeff Kirsher 			    struct bnx2x_rx_mode_obj *o);
1414adfc5217SJeff Kirsher 
1415adfc5217SJeff Kirsher /**
14161aa8b471SBen Hutchings  * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
1417adfc5217SJeff Kirsher  *
14181aa8b471SBen Hutchings  * @p: Command parameters
1419adfc5217SJeff Kirsher  *
142016a5fd92SYuval Mintz  * Return: 0 - if operation was successful and there is no pending completions,
1421adfc5217SJeff Kirsher  *         positive number - if there are pending completions,
1422adfc5217SJeff Kirsher  *         negative - if there were errors
1423adfc5217SJeff Kirsher  */
1424adfc5217SJeff Kirsher int bnx2x_config_rx_mode(struct bnx2x *bp,
1425adfc5217SJeff Kirsher 			 struct bnx2x_rx_mode_ramrod_params *p);
1426adfc5217SJeff Kirsher 
1427adfc5217SJeff Kirsher /****************** MULTICASTS ****************/
1428adfc5217SJeff Kirsher 
1429adfc5217SJeff Kirsher void bnx2x_init_mcast_obj(struct bnx2x *bp,
1430adfc5217SJeff Kirsher 			  struct bnx2x_mcast_obj *mcast_obj,
1431adfc5217SJeff Kirsher 			  u8 mcast_cl_id, u32 mcast_cid, u8 func_id,
1432adfc5217SJeff Kirsher 			  u8 engine_id, void *rdata, dma_addr_t rdata_mapping,
1433adfc5217SJeff Kirsher 			  int state, unsigned long *pstate,
1434adfc5217SJeff Kirsher 			  bnx2x_obj_type type);
1435adfc5217SJeff Kirsher 
1436adfc5217SJeff Kirsher /**
14371aa8b471SBen Hutchings  * bnx2x_config_mcast - Configure multicast MACs list.
14381aa8b471SBen Hutchings  *
14391aa8b471SBen Hutchings  * @cmd: command to execute: BNX2X_MCAST_CMD_X
14401aa8b471SBen Hutchings  *
14411aa8b471SBen Hutchings  * May configure a new list
1442adfc5217SJeff Kirsher  * provided in p->mcast_list (BNX2X_MCAST_CMD_ADD), clean up
1443adfc5217SJeff Kirsher  * (BNX2X_MCAST_CMD_DEL) or restore (BNX2X_MCAST_CMD_RESTORE) a current
1444adfc5217SJeff Kirsher  * configuration, continue to execute the pending commands
1445adfc5217SJeff Kirsher  * (BNX2X_MCAST_CMD_CONT).
1446adfc5217SJeff Kirsher  *
1447adfc5217SJeff Kirsher  * If previous command is still pending or if number of MACs to
1448adfc5217SJeff Kirsher  * configure is more that maximum number of MACs in one command,
1449adfc5217SJeff Kirsher  * the current command will be enqueued to the tail of the
1450adfc5217SJeff Kirsher  * pending commands list.
1451adfc5217SJeff Kirsher  *
145216a5fd92SYuval Mintz  * Return: 0 is operation was successful and there are no pending completions,
1453adfc5217SJeff Kirsher  *         negative if there were errors, positive if there are pending
1454adfc5217SJeff Kirsher  *         completions.
1455adfc5217SJeff Kirsher  */
1456adfc5217SJeff Kirsher int bnx2x_config_mcast(struct bnx2x *bp,
145786564c3fSYuval Mintz 		       struct bnx2x_mcast_ramrod_params *p,
145886564c3fSYuval Mintz 		       enum bnx2x_mcast_cmd cmd);
1459adfc5217SJeff Kirsher 
1460adfc5217SJeff Kirsher /****************** CREDIT POOL ****************/
1461adfc5217SJeff Kirsher void bnx2x_init_mac_credit_pool(struct bnx2x *bp,
1462adfc5217SJeff Kirsher 				struct bnx2x_credit_pool_obj *p, u8 func_id,
1463adfc5217SJeff Kirsher 				u8 func_num);
1464adfc5217SJeff Kirsher void bnx2x_init_vlan_credit_pool(struct bnx2x *bp,
1465adfc5217SJeff Kirsher 				 struct bnx2x_credit_pool_obj *p, u8 func_id,
1466adfc5217SJeff Kirsher 				 u8 func_num);
1467adfc5217SJeff Kirsher 
1468adfc5217SJeff Kirsher /****************** RSS CONFIGURATION ****************/
1469adfc5217SJeff Kirsher void bnx2x_init_rss_config_obj(struct bnx2x *bp,
1470adfc5217SJeff Kirsher 			       struct bnx2x_rss_config_obj *rss_obj,
1471adfc5217SJeff Kirsher 			       u8 cl_id, u32 cid, u8 func_id, u8 engine_id,
1472adfc5217SJeff Kirsher 			       void *rdata, dma_addr_t rdata_mapping,
1473adfc5217SJeff Kirsher 			       int state, unsigned long *pstate,
1474adfc5217SJeff Kirsher 			       bnx2x_obj_type type);
1475adfc5217SJeff Kirsher 
1476adfc5217SJeff Kirsher /**
14771aa8b471SBen Hutchings  * bnx2x_config_rss - Updates RSS configuration according to provided parameters
1478adfc5217SJeff Kirsher  *
14791aa8b471SBen Hutchings  * Return: 0 in case of success
1480adfc5217SJeff Kirsher  */
1481adfc5217SJeff Kirsher int bnx2x_config_rss(struct bnx2x *bp,
1482adfc5217SJeff Kirsher 		     struct bnx2x_config_rss_params *p);
1483adfc5217SJeff Kirsher 
1484adfc5217SJeff Kirsher /**
14851aa8b471SBen Hutchings  * bnx2x_get_rss_ind_table - Return the current ind_table configuration.
1486adfc5217SJeff Kirsher  *
14871aa8b471SBen Hutchings  * @ind_table: buffer to fill with the current indirection
1488adfc5217SJeff Kirsher  *                  table content. Should be at least
1489adfc5217SJeff Kirsher  *                  T_ETH_INDIRECTION_TABLE_SIZE bytes long.
1490adfc5217SJeff Kirsher  */
1491adfc5217SJeff Kirsher void bnx2x_get_rss_ind_table(struct bnx2x_rss_config_obj *rss_obj,
1492adfc5217SJeff Kirsher 			     u8 *ind_table);
1493adfc5217SJeff Kirsher 
1494adfc5217SJeff Kirsher #endif /* BNX2X_SP_VERBS */
1495