xref: /linux/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h (revision 8be4d31cb8aaeea27bde4b7ddb26e28a89062ebf)
14ad79e13SYuval Mintz /* bnx2x_sp.h: Qlogic Everest network driver.
2619c5cb6SVlad Zolotarov  *
34ad79e13SYuval Mintz  * Copyright 2011-2013 Broadcom Corporation
44ad79e13SYuval Mintz  * Copyright (c) 2014 QLogic Corporation
54ad79e13SYuval Mintz  * All rights reserved
6619c5cb6SVlad Zolotarov  *
74ad79e13SYuval Mintz  * Unless you and Qlogic execute a separate written software license
8619c5cb6SVlad Zolotarov  * agreement governing use of this software, this software is licensed to you
9619c5cb6SVlad Zolotarov  * under the terms of the GNU General Public License version 2, available
104ad79e13SYuval Mintz  * at http://www.gnu.org/licenses/gpl-2.0.html (the "GPL").
11619c5cb6SVlad Zolotarov  *
12619c5cb6SVlad Zolotarov  * Notwithstanding the above, under no circumstances may you combine this
134ad79e13SYuval Mintz  * software in any way with any other Qlogic software provided under a
144ad79e13SYuval Mintz  * license other than the GPL, without Qlogic's express prior written
15619c5cb6SVlad Zolotarov  * consent.
16619c5cb6SVlad Zolotarov  *
1708f6dd89SAriel Elior  * Maintained by: Ariel Elior <ariel.elior@qlogic.com>
18619c5cb6SVlad Zolotarov  * Written by: Vladislav Zolotarov
19619c5cb6SVlad Zolotarov  *
20619c5cb6SVlad Zolotarov  */
21619c5cb6SVlad Zolotarov #ifndef BNX2X_SP_VERBS
22619c5cb6SVlad Zolotarov #define BNX2X_SP_VERBS
23042181f5SVladislav Zolotarov 
24619c5cb6SVlad Zolotarov struct bnx2x;
25619c5cb6SVlad Zolotarov struct eth_context;
26042181f5SVladislav Zolotarov 
27619c5cb6SVlad Zolotarov /* Bits representing general command's configuration */
28619c5cb6SVlad Zolotarov enum {
29619c5cb6SVlad Zolotarov 	RAMROD_TX,
30619c5cb6SVlad Zolotarov 	RAMROD_RX,
31619c5cb6SVlad Zolotarov 	/* Wait until all pending commands complete */
32619c5cb6SVlad Zolotarov 	RAMROD_COMP_WAIT,
33619c5cb6SVlad Zolotarov 	/* Don't send a ramrod, only update a registry */
34619c5cb6SVlad Zolotarov 	RAMROD_DRV_CLR_ONLY,
35619c5cb6SVlad Zolotarov 	/* Configure HW according to the current object state */
36619c5cb6SVlad Zolotarov 	RAMROD_RESTORE,
37619c5cb6SVlad Zolotarov 	 /* Execute the next command now */
38619c5cb6SVlad Zolotarov 	RAMROD_EXEC,
3916a5fd92SYuval Mintz 	/* Don't add a new command and continue execution of postponed
40619c5cb6SVlad Zolotarov 	 * commands. If not set a new command will be added to the
41619c5cb6SVlad Zolotarov 	 * pending commands list.
42619c5cb6SVlad Zolotarov 	 */
43619c5cb6SVlad Zolotarov 	RAMROD_CONT,
4455c11941SMerav Sicron 	/* If there is another pending ramrod, wait until it finishes and
4555c11941SMerav Sicron 	 * re-try to submit this one. This flag can be set only in sleepable
4655c11941SMerav Sicron 	 * context, and should not be set from the context that completes the
4755c11941SMerav Sicron 	 * ramrods as deadlock will occur.
4855c11941SMerav Sicron 	 */
4955c11941SMerav Sicron 	RAMROD_RETRY,
50619c5cb6SVlad Zolotarov };
51042181f5SVladislav Zolotarov 
52619c5cb6SVlad Zolotarov typedef enum {
53619c5cb6SVlad Zolotarov 	BNX2X_OBJ_TYPE_RX,
54619c5cb6SVlad Zolotarov 	BNX2X_OBJ_TYPE_TX,
55619c5cb6SVlad Zolotarov 	BNX2X_OBJ_TYPE_RX_TX,
56619c5cb6SVlad Zolotarov } bnx2x_obj_type;
57042181f5SVladislav Zolotarov 
582de67439SYuval Mintz /* Public slow path states */
59619c5cb6SVlad Zolotarov enum {
60619c5cb6SVlad Zolotarov 	BNX2X_FILTER_MAC_PENDING,
61619c5cb6SVlad Zolotarov 	BNX2X_FILTER_VLAN_PENDING,
62619c5cb6SVlad Zolotarov 	BNX2X_FILTER_VLAN_MAC_PENDING,
63619c5cb6SVlad Zolotarov 	BNX2X_FILTER_RX_MODE_PENDING,
64619c5cb6SVlad Zolotarov 	BNX2X_FILTER_RX_MODE_SCHED,
65619c5cb6SVlad Zolotarov 	BNX2X_FILTER_ISCSI_ETH_START_SCHED,
66619c5cb6SVlad Zolotarov 	BNX2X_FILTER_ISCSI_ETH_STOP_SCHED,
67619c5cb6SVlad Zolotarov 	BNX2X_FILTER_FCOE_ETH_START_SCHED,
68619c5cb6SVlad Zolotarov 	BNX2X_FILTER_FCOE_ETH_STOP_SCHED,
69619c5cb6SVlad Zolotarov 	BNX2X_FILTER_MCAST_PENDING,
70619c5cb6SVlad Zolotarov 	BNX2X_FILTER_MCAST_SCHED,
71619c5cb6SVlad Zolotarov 	BNX2X_FILTER_RSS_CONF_PENDING,
72a3348722SBarak Witkowski 	BNX2X_AFEX_FCOE_Q_UPDATE_PENDING,
73a3348722SBarak Witkowski 	BNX2X_AFEX_PENDING_VIFSET_MCP_ACK
74619c5cb6SVlad Zolotarov };
75042181f5SVladislav Zolotarov 
76619c5cb6SVlad Zolotarov struct bnx2x_raw_obj {
77619c5cb6SVlad Zolotarov 	u8		func_id;
78042181f5SVladislav Zolotarov 
79619c5cb6SVlad Zolotarov 	/* Queue params */
80619c5cb6SVlad Zolotarov 	u8		cl_id;
81619c5cb6SVlad Zolotarov 	u32		cid;
82042181f5SVladislav Zolotarov 
83619c5cb6SVlad Zolotarov 	/* Ramrod data buffer params */
84619c5cb6SVlad Zolotarov 	void		*rdata;
85619c5cb6SVlad Zolotarov 	dma_addr_t	rdata_mapping;
86619c5cb6SVlad Zolotarov 
87619c5cb6SVlad Zolotarov 	/* Ramrod state params */
88619c5cb6SVlad Zolotarov 	int		state;   /* "ramrod is pending" state bit */
89619c5cb6SVlad Zolotarov 	unsigned long	*pstate; /* pointer to state buffer */
90619c5cb6SVlad Zolotarov 
91619c5cb6SVlad Zolotarov 	bnx2x_obj_type	obj_type;
92619c5cb6SVlad Zolotarov 
93619c5cb6SVlad Zolotarov 	int (*wait_comp)(struct bnx2x *bp,
94619c5cb6SVlad Zolotarov 			 struct bnx2x_raw_obj *o);
95619c5cb6SVlad Zolotarov 
96619c5cb6SVlad Zolotarov 	bool (*check_pending)(struct bnx2x_raw_obj *o);
97619c5cb6SVlad Zolotarov 	void (*clear_pending)(struct bnx2x_raw_obj *o);
98619c5cb6SVlad Zolotarov 	void (*set_pending)(struct bnx2x_raw_obj *o);
99619c5cb6SVlad Zolotarov };
100619c5cb6SVlad Zolotarov 
101619c5cb6SVlad Zolotarov /************************* VLAN-MAC commands related parameters ***************/
102619c5cb6SVlad Zolotarov struct bnx2x_mac_ramrod_data {
103619c5cb6SVlad Zolotarov 	u8 mac[ETH_ALEN];
10491226790SDmitry Kravkov 	u8 is_inner_mac;
105619c5cb6SVlad Zolotarov };
106619c5cb6SVlad Zolotarov 
107619c5cb6SVlad Zolotarov struct bnx2x_vlan_ramrod_data {
108619c5cb6SVlad Zolotarov 	u16 vlan;
109619c5cb6SVlad Zolotarov };
110619c5cb6SVlad Zolotarov 
111619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_ramrod_data {
112619c5cb6SVlad Zolotarov 	u8 mac[ETH_ALEN];
11391226790SDmitry Kravkov 	u8 is_inner_mac;
114619c5cb6SVlad Zolotarov 	u16 vlan;
115619c5cb6SVlad Zolotarov };
116619c5cb6SVlad Zolotarov 
117619c5cb6SVlad Zolotarov union bnx2x_classification_ramrod_data {
118619c5cb6SVlad Zolotarov 	struct bnx2x_mac_ramrod_data mac;
119619c5cb6SVlad Zolotarov 	struct bnx2x_vlan_ramrod_data vlan;
120619c5cb6SVlad Zolotarov 	struct bnx2x_vlan_mac_ramrod_data vlan_mac;
121619c5cb6SVlad Zolotarov };
122619c5cb6SVlad Zolotarov 
123619c5cb6SVlad Zolotarov /* VLAN_MAC commands */
124619c5cb6SVlad Zolotarov enum bnx2x_vlan_mac_cmd {
125619c5cb6SVlad Zolotarov 	BNX2X_VLAN_MAC_ADD,
126619c5cb6SVlad Zolotarov 	BNX2X_VLAN_MAC_DEL,
127619c5cb6SVlad Zolotarov 	BNX2X_VLAN_MAC_MOVE,
128619c5cb6SVlad Zolotarov };
129619c5cb6SVlad Zolotarov 
130619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_data {
131619c5cb6SVlad Zolotarov 	/* Requested command: BNX2X_VLAN_MAC_XX */
132619c5cb6SVlad Zolotarov 	enum bnx2x_vlan_mac_cmd cmd;
13316a5fd92SYuval Mintz 	/* used to contain the data related vlan_mac_flags bits from
134619c5cb6SVlad Zolotarov 	 * ramrod parameters.
135619c5cb6SVlad Zolotarov 	 */
136619c5cb6SVlad Zolotarov 	unsigned long vlan_mac_flags;
137619c5cb6SVlad Zolotarov 
138619c5cb6SVlad Zolotarov 	/* Needed for MOVE command */
139619c5cb6SVlad Zolotarov 	struct bnx2x_vlan_mac_obj *target_obj;
140619c5cb6SVlad Zolotarov 
141619c5cb6SVlad Zolotarov 	union bnx2x_classification_ramrod_data u;
142619c5cb6SVlad Zolotarov };
143619c5cb6SVlad Zolotarov 
144619c5cb6SVlad Zolotarov /*************************** Exe Queue obj ************************************/
145619c5cb6SVlad Zolotarov union bnx2x_exe_queue_cmd_data {
146619c5cb6SVlad Zolotarov 	struct bnx2x_vlan_mac_data vlan_mac;
147619c5cb6SVlad Zolotarov 
148619c5cb6SVlad Zolotarov 	struct {
149619c5cb6SVlad Zolotarov 		/* TODO */
150619c5cb6SVlad Zolotarov 	} mcast;
151619c5cb6SVlad Zolotarov };
152619c5cb6SVlad Zolotarov 
153619c5cb6SVlad Zolotarov struct bnx2x_exeq_elem {
154619c5cb6SVlad Zolotarov 	struct list_head		link;
155619c5cb6SVlad Zolotarov 
156619c5cb6SVlad Zolotarov 	/* Length of this element in the exe_chunk. */
157619c5cb6SVlad Zolotarov 	int				cmd_len;
158619c5cb6SVlad Zolotarov 
159619c5cb6SVlad Zolotarov 	union bnx2x_exe_queue_cmd_data	cmd_data;
160619c5cb6SVlad Zolotarov };
161619c5cb6SVlad Zolotarov 
162619c5cb6SVlad Zolotarov union bnx2x_qable_obj;
163619c5cb6SVlad Zolotarov 
164619c5cb6SVlad Zolotarov union bnx2x_exeq_comp_elem {
165619c5cb6SVlad Zolotarov 	union event_ring_elem *elem;
166619c5cb6SVlad Zolotarov };
167619c5cb6SVlad Zolotarov 
168619c5cb6SVlad Zolotarov struct bnx2x_exe_queue_obj;
169619c5cb6SVlad Zolotarov 
170619c5cb6SVlad Zolotarov typedef int (*exe_q_validate)(struct bnx2x *bp,
171619c5cb6SVlad Zolotarov 			      union bnx2x_qable_obj *o,
172619c5cb6SVlad Zolotarov 			      struct bnx2x_exeq_elem *elem);
173619c5cb6SVlad Zolotarov 
174460a25cdSYuval Mintz typedef int (*exe_q_remove)(struct bnx2x *bp,
175460a25cdSYuval Mintz 			    union bnx2x_qable_obj *o,
176460a25cdSYuval Mintz 			    struct bnx2x_exeq_elem *elem);
177460a25cdSYuval Mintz 
1781aa8b471SBen Hutchings /* Return positive if entry was optimized, 0 - if not, negative
179619c5cb6SVlad Zolotarov  * in case of an error.
180619c5cb6SVlad Zolotarov  */
181619c5cb6SVlad Zolotarov typedef int (*exe_q_optimize)(struct bnx2x *bp,
182619c5cb6SVlad Zolotarov 			      union bnx2x_qable_obj *o,
183619c5cb6SVlad Zolotarov 			      struct bnx2x_exeq_elem *elem);
184619c5cb6SVlad Zolotarov typedef int (*exe_q_execute)(struct bnx2x *bp,
185619c5cb6SVlad Zolotarov 			     union bnx2x_qable_obj *o,
186619c5cb6SVlad Zolotarov 			     struct list_head *exe_chunk,
187619c5cb6SVlad Zolotarov 			     unsigned long *ramrod_flags);
188619c5cb6SVlad Zolotarov typedef struct bnx2x_exeq_elem *
189619c5cb6SVlad Zolotarov 			(*exe_q_get)(struct bnx2x_exe_queue_obj *o,
190619c5cb6SVlad Zolotarov 				     struct bnx2x_exeq_elem *elem);
191619c5cb6SVlad Zolotarov 
192619c5cb6SVlad Zolotarov struct bnx2x_exe_queue_obj {
19316a5fd92SYuval Mintz 	/* Commands pending for an execution. */
194619c5cb6SVlad Zolotarov 	struct list_head	exe_queue;
195619c5cb6SVlad Zolotarov 
19616a5fd92SYuval Mintz 	/* Commands pending for an completion. */
197619c5cb6SVlad Zolotarov 	struct list_head	pending_comp;
198619c5cb6SVlad Zolotarov 
199619c5cb6SVlad Zolotarov 	spinlock_t		lock;
200619c5cb6SVlad Zolotarov 
201619c5cb6SVlad Zolotarov 	/* Maximum length of commands' list for one execution */
202619c5cb6SVlad Zolotarov 	int			exe_chunk_len;
203619c5cb6SVlad Zolotarov 
204619c5cb6SVlad Zolotarov 	union bnx2x_qable_obj	*owner;
205619c5cb6SVlad Zolotarov 
206619c5cb6SVlad Zolotarov 	/****** Virtual functions ******/
207619c5cb6SVlad Zolotarov 	/**
208619c5cb6SVlad Zolotarov 	 * Called before commands execution for commands that are really
209619c5cb6SVlad Zolotarov 	 * going to be executed (after 'optimize').
210619c5cb6SVlad Zolotarov 	 *
211619c5cb6SVlad Zolotarov 	 * Must run under exe_queue->lock
212619c5cb6SVlad Zolotarov 	 */
213619c5cb6SVlad Zolotarov 	exe_q_validate		validate;
214619c5cb6SVlad Zolotarov 
215460a25cdSYuval Mintz 	/**
216460a25cdSYuval Mintz 	 * Called before removing pending commands, cleaning allocated
217460a25cdSYuval Mintz 	 * resources (e.g., credits from validate)
218460a25cdSYuval Mintz 	 */
219460a25cdSYuval Mintz 	 exe_q_remove		remove;
220619c5cb6SVlad Zolotarov 
221619c5cb6SVlad Zolotarov 	/**
222619c5cb6SVlad Zolotarov 	 * This will try to cancel the current pending commands list
223619c5cb6SVlad Zolotarov 	 * considering the new command.
224619c5cb6SVlad Zolotarov 	 *
225460a25cdSYuval Mintz 	 * Returns the number of optimized commands or a negative error code
226460a25cdSYuval Mintz 	 *
227619c5cb6SVlad Zolotarov 	 * Must run under exe_queue->lock
228619c5cb6SVlad Zolotarov 	 */
229619c5cb6SVlad Zolotarov 	exe_q_optimize		optimize;
230619c5cb6SVlad Zolotarov 
231619c5cb6SVlad Zolotarov 	/**
232619c5cb6SVlad Zolotarov 	 * Run the next commands chunk (owner specific).
233619c5cb6SVlad Zolotarov 	 */
234619c5cb6SVlad Zolotarov 	exe_q_execute		execute;
235619c5cb6SVlad Zolotarov 
236619c5cb6SVlad Zolotarov 	/**
237619c5cb6SVlad Zolotarov 	 * Return the exe_queue element containing the specific command
238619c5cb6SVlad Zolotarov 	 * if any. Otherwise return NULL.
239619c5cb6SVlad Zolotarov 	 */
240619c5cb6SVlad Zolotarov 	exe_q_get		get;
241619c5cb6SVlad Zolotarov };
242619c5cb6SVlad Zolotarov /***************** Classification verbs: Set/Del MAC/VLAN/VLAN-MAC ************/
243619c5cb6SVlad Zolotarov /*
24416a5fd92SYuval Mintz  * Element in the VLAN_MAC registry list having all currently configured
245619c5cb6SVlad Zolotarov  * rules.
246619c5cb6SVlad Zolotarov  */
247619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_registry_elem {
248619c5cb6SVlad Zolotarov 	struct list_head	link;
249619c5cb6SVlad Zolotarov 
25016a5fd92SYuval Mintz 	/* Used to store the cam offset used for the mac/vlan/vlan-mac.
251619c5cb6SVlad Zolotarov 	 * Relevant for 57710 and 57711 only. VLANs and MACs share the
252619c5cb6SVlad Zolotarov 	 * same CAM for these chips.
253619c5cb6SVlad Zolotarov 	 */
254619c5cb6SVlad Zolotarov 	int			cam_offset;
255619c5cb6SVlad Zolotarov 
256619c5cb6SVlad Zolotarov 	/* Needed for DEL and RESTORE flows */
257619c5cb6SVlad Zolotarov 	unsigned long		vlan_mac_flags;
258619c5cb6SVlad Zolotarov 
259619c5cb6SVlad Zolotarov 	union bnx2x_classification_ramrod_data u;
260619c5cb6SVlad Zolotarov };
261619c5cb6SVlad Zolotarov 
262619c5cb6SVlad Zolotarov /* Bits representing VLAN_MAC commands specific flags */
263619c5cb6SVlad Zolotarov enum {
264619c5cb6SVlad Zolotarov 	BNX2X_UC_LIST_MAC,
265619c5cb6SVlad Zolotarov 	BNX2X_ETH_MAC,
266619c5cb6SVlad Zolotarov 	BNX2X_ISCSI_ETH_MAC,
267619c5cb6SVlad Zolotarov 	BNX2X_NETQ_ETH_MAC,
26804f05230SSudarsana Reddy Kalluru 	BNX2X_VLAN,
269619c5cb6SVlad Zolotarov 	BNX2X_DONT_CONSUME_CAM_CREDIT,
270619c5cb6SVlad Zolotarov 	BNX2X_DONT_CONSUME_CAM_CREDIT_DEST,
271619c5cb6SVlad Zolotarov };
272e8379c79SYuval Mintz /* When looking for matching filters, some flags are not interesting */
273e8379c79SYuval Mintz #define BNX2X_VLAN_MAC_CMP_MASK	(1 << BNX2X_UC_LIST_MAC | \
274e8379c79SYuval Mintz 				 1 << BNX2X_ETH_MAC | \
275e8379c79SYuval Mintz 				 1 << BNX2X_ISCSI_ETH_MAC | \
27604f05230SSudarsana Reddy Kalluru 				 1 << BNX2X_NETQ_ETH_MAC | \
27704f05230SSudarsana Reddy Kalluru 				 1 << BNX2X_VLAN)
278e8379c79SYuval Mintz #define BNX2X_VLAN_MAC_CMP_FLAGS(flags) \
279e8379c79SYuval Mintz 	((flags) & BNX2X_VLAN_MAC_CMP_MASK)
280619c5cb6SVlad Zolotarov 
281619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_ramrod_params {
282619c5cb6SVlad Zolotarov 	/* Object to run the command from */
283619c5cb6SVlad Zolotarov 	struct bnx2x_vlan_mac_obj *vlan_mac_obj;
284619c5cb6SVlad Zolotarov 
285619c5cb6SVlad Zolotarov 	/* General command flags: COMP_WAIT, etc. */
286619c5cb6SVlad Zolotarov 	unsigned long ramrod_flags;
287619c5cb6SVlad Zolotarov 
288619c5cb6SVlad Zolotarov 	/* Command specific configuration request */
289619c5cb6SVlad Zolotarov 	struct bnx2x_vlan_mac_data user_req;
290619c5cb6SVlad Zolotarov };
291619c5cb6SVlad Zolotarov 
292619c5cb6SVlad Zolotarov struct bnx2x_vlan_mac_obj {
293619c5cb6SVlad Zolotarov 	struct bnx2x_raw_obj raw;
294619c5cb6SVlad Zolotarov 
295619c5cb6SVlad Zolotarov 	/* Bookkeeping list: will prevent the addition of already existing
296619c5cb6SVlad Zolotarov 	 * entries.
297619c5cb6SVlad Zolotarov 	 */
298619c5cb6SVlad Zolotarov 	struct list_head		head;
2998b09be5fSYuval Mintz 	/* Implement a simple reader/writer lock on the head list.
3008b09be5fSYuval Mintz 	 * all these fields should only be accessed under the exe_queue lock
3018b09be5fSYuval Mintz 	 */
3028b09be5fSYuval Mintz 	u8		head_reader; /* Num. of readers accessing head list */
3038b09be5fSYuval Mintz 	bool		head_exe_request; /* Pending execution request. */
3048b09be5fSYuval Mintz 	unsigned long	saved_ramrod_flags; /* Ramrods of pending execution */
305619c5cb6SVlad Zolotarov 
306619c5cb6SVlad Zolotarov 	/* TODO: Add it's initialization in the init functions */
307619c5cb6SVlad Zolotarov 	struct bnx2x_exe_queue_obj	exe_queue;
308619c5cb6SVlad Zolotarov 
309619c5cb6SVlad Zolotarov 	/* MACs credit pool */
310619c5cb6SVlad Zolotarov 	struct bnx2x_credit_pool_obj	*macs_pool;
311619c5cb6SVlad Zolotarov 
312619c5cb6SVlad Zolotarov 	/* VLANs credit pool */
313619c5cb6SVlad Zolotarov 	struct bnx2x_credit_pool_obj	*vlans_pool;
314619c5cb6SVlad Zolotarov 
315619c5cb6SVlad Zolotarov 	/* RAMROD command to be used */
316619c5cb6SVlad Zolotarov 	int				ramrod_cmd;
317619c5cb6SVlad Zolotarov 
318ed5162a0SAriel Elior 	/* copy first n elements onto preallocated buffer
319ed5162a0SAriel Elior 	 *
320ed5162a0SAriel Elior 	 * @param n number of elements to get
321ed5162a0SAriel Elior 	 * @param buf buffer preallocated by caller into which elements
322ed5162a0SAriel Elior 	 *            will be copied. Note elements are 4-byte aligned
32316a5fd92SYuval Mintz 	 *            so buffer size must be able to accommodate the
324ed5162a0SAriel Elior 	 *            aligned elements.
325ed5162a0SAriel Elior 	 *
326ed5162a0SAriel Elior 	 * @return number of copied bytes
327ed5162a0SAriel Elior 	 */
3283ec9f9caSAriel Elior 	int (*get_n_elements)(struct bnx2x *bp,
3293ec9f9caSAriel Elior 			      struct bnx2x_vlan_mac_obj *o, int n, u8 *base,
3303ec9f9caSAriel Elior 			      u8 stride, u8 size);
331ed5162a0SAriel Elior 
332619c5cb6SVlad Zolotarov 	/**
333619c5cb6SVlad Zolotarov 	 * Checks if ADD-ramrod with the given params may be performed.
334619c5cb6SVlad Zolotarov 	 *
335619c5cb6SVlad Zolotarov 	 * @return zero if the element may be added
336619c5cb6SVlad Zolotarov 	 */
337619c5cb6SVlad Zolotarov 
33851c1a580SMerav Sicron 	int (*check_add)(struct bnx2x *bp,
33951c1a580SMerav Sicron 			 struct bnx2x_vlan_mac_obj *o,
340619c5cb6SVlad Zolotarov 			 union bnx2x_classification_ramrod_data *data);
341619c5cb6SVlad Zolotarov 
342619c5cb6SVlad Zolotarov 	/**
343619c5cb6SVlad Zolotarov 	 * Checks if DEL-ramrod with the given params may be performed.
344619c5cb6SVlad Zolotarov 	 *
345619c5cb6SVlad Zolotarov 	 * @return true if the element may be deleted
346619c5cb6SVlad Zolotarov 	 */
347619c5cb6SVlad Zolotarov 	struct bnx2x_vlan_mac_registry_elem *
34851c1a580SMerav Sicron 		(*check_del)(struct bnx2x *bp,
34951c1a580SMerav Sicron 			     struct bnx2x_vlan_mac_obj *o,
350619c5cb6SVlad Zolotarov 			     union bnx2x_classification_ramrod_data *data);
351619c5cb6SVlad Zolotarov 
352619c5cb6SVlad Zolotarov 	/**
353619c5cb6SVlad Zolotarov 	 * Checks if DEL-ramrod with the given params may be performed.
354619c5cb6SVlad Zolotarov 	 *
355619c5cb6SVlad Zolotarov 	 * @return true if the element may be deleted
356619c5cb6SVlad Zolotarov 	 */
35751c1a580SMerav Sicron 	bool (*check_move)(struct bnx2x *bp,
35851c1a580SMerav Sicron 			   struct bnx2x_vlan_mac_obj *src_o,
359619c5cb6SVlad Zolotarov 			   struct bnx2x_vlan_mac_obj *dst_o,
360619c5cb6SVlad Zolotarov 			   union bnx2x_classification_ramrod_data *data);
361619c5cb6SVlad Zolotarov 
362619c5cb6SVlad Zolotarov 	/**
363619c5cb6SVlad Zolotarov 	 *  Update the relevant credit object(s) (consume/return
364619c5cb6SVlad Zolotarov 	 *  correspondingly).
365619c5cb6SVlad Zolotarov 	 */
366619c5cb6SVlad Zolotarov 	bool (*get_credit)(struct bnx2x_vlan_mac_obj *o);
367619c5cb6SVlad Zolotarov 	bool (*put_credit)(struct bnx2x_vlan_mac_obj *o);
368619c5cb6SVlad Zolotarov 	bool (*get_cam_offset)(struct bnx2x_vlan_mac_obj *o, int *offset);
369619c5cb6SVlad Zolotarov 	bool (*put_cam_offset)(struct bnx2x_vlan_mac_obj *o, int offset);
370619c5cb6SVlad Zolotarov 
371619c5cb6SVlad Zolotarov 	/**
372619c5cb6SVlad Zolotarov 	 * Configures one rule in the ramrod data buffer.
373619c5cb6SVlad Zolotarov 	 */
374619c5cb6SVlad Zolotarov 	void (*set_one_rule)(struct bnx2x *bp,
375619c5cb6SVlad Zolotarov 			     struct bnx2x_vlan_mac_obj *o,
376619c5cb6SVlad Zolotarov 			     struct bnx2x_exeq_elem *elem, int rule_idx,
377619c5cb6SVlad Zolotarov 			     int cam_offset);
378619c5cb6SVlad Zolotarov 
379619c5cb6SVlad Zolotarov 	/**
380619c5cb6SVlad Zolotarov 	*  Delete all configured elements having the given
381619c5cb6SVlad Zolotarov 	*  vlan_mac_flags specification. Assumes no pending for
382*fe09560fSBjorn Helgaas 	*  execution commands. Will schedule all currently
383619c5cb6SVlad Zolotarov 	*  configured MACs/VLANs/VLAN-MACs matching the vlan_mac_flags
384619c5cb6SVlad Zolotarov 	*  specification for deletion and will use the given
385619c5cb6SVlad Zolotarov 	*  ramrod_flags for the last DEL operation.
386619c5cb6SVlad Zolotarov 	 *
387619c5cb6SVlad Zolotarov 	 * @param bp
388619c5cb6SVlad Zolotarov 	 * @param o
389619c5cb6SVlad Zolotarov 	 * @param ramrod_flags RAMROD_XX flags
390619c5cb6SVlad Zolotarov 	 *
391619c5cb6SVlad Zolotarov 	 * @return 0 if the last operation has completed successfully
392619c5cb6SVlad Zolotarov 	 *         and there are no more elements left, positive value
393619c5cb6SVlad Zolotarov 	 *         if there are pending for completion commands,
394619c5cb6SVlad Zolotarov 	 *         negative value in case of failure.
395619c5cb6SVlad Zolotarov 	 */
396619c5cb6SVlad Zolotarov 	int (*delete_all)(struct bnx2x *bp,
397619c5cb6SVlad Zolotarov 			  struct bnx2x_vlan_mac_obj *o,
398619c5cb6SVlad Zolotarov 			  unsigned long *vlan_mac_flags,
399619c5cb6SVlad Zolotarov 			  unsigned long *ramrod_flags);
400619c5cb6SVlad Zolotarov 
401619c5cb6SVlad Zolotarov 	/**
402619c5cb6SVlad Zolotarov 	 * Reconfigures the next MAC/VLAN/VLAN-MAC element from the previously
403619c5cb6SVlad Zolotarov 	 * configured elements list.
404619c5cb6SVlad Zolotarov 	 *
405619c5cb6SVlad Zolotarov 	 * @param bp
406619c5cb6SVlad Zolotarov 	 * @param p Command parameters (RAMROD_COMP_WAIT bit in
407619c5cb6SVlad Zolotarov 	 *          ramrod_flags is only taken into an account)
40816a5fd92SYuval Mintz 	 * @param ppos a pointer to the cookie that should be given back in the
409619c5cb6SVlad Zolotarov 	 *        next call to make function handle the next element. If
410619c5cb6SVlad Zolotarov 	 *        *ppos is set to NULL it will restart the iterator.
411619c5cb6SVlad Zolotarov 	 *        If returned *ppos == NULL this means that the last
412619c5cb6SVlad Zolotarov 	 *        element has been handled.
413619c5cb6SVlad Zolotarov 	 *
414619c5cb6SVlad Zolotarov 	 * @return int
415619c5cb6SVlad Zolotarov 	 */
416619c5cb6SVlad Zolotarov 	int (*restore)(struct bnx2x *bp,
417619c5cb6SVlad Zolotarov 		       struct bnx2x_vlan_mac_ramrod_params *p,
418619c5cb6SVlad Zolotarov 		       struct bnx2x_vlan_mac_registry_elem **ppos);
419619c5cb6SVlad Zolotarov 
420619c5cb6SVlad Zolotarov 	/**
42116a5fd92SYuval Mintz 	 * Should be called on a completion arrival.
422619c5cb6SVlad Zolotarov 	 *
423619c5cb6SVlad Zolotarov 	 * @param bp
424619c5cb6SVlad Zolotarov 	 * @param o
425619c5cb6SVlad Zolotarov 	 * @param cqe Completion element we are handling
426619c5cb6SVlad Zolotarov 	 * @param ramrod_flags if RAMROD_CONT is set the next bulk of
427619c5cb6SVlad Zolotarov 	 *		       pending commands will be executed.
428619c5cb6SVlad Zolotarov 	 *		       RAMROD_DRV_CLR_ONLY and RAMROD_RESTORE
429619c5cb6SVlad Zolotarov 	 *		       may also be set if needed.
430619c5cb6SVlad Zolotarov 	 *
431619c5cb6SVlad Zolotarov 	 * @return 0 if there are neither pending nor waiting for
432619c5cb6SVlad Zolotarov 	 *         completion commands. Positive value if there are
433619c5cb6SVlad Zolotarov 	 *         pending for execution or for completion commands.
434619c5cb6SVlad Zolotarov 	 *         Negative value in case of an error (including an
435619c5cb6SVlad Zolotarov 	 *         error in the cqe).
436619c5cb6SVlad Zolotarov 	 */
437619c5cb6SVlad Zolotarov 	int (*complete)(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o,
438619c5cb6SVlad Zolotarov 			union event_ring_elem *cqe,
439619c5cb6SVlad Zolotarov 			unsigned long *ramrod_flags);
440619c5cb6SVlad Zolotarov 
441619c5cb6SVlad Zolotarov 	/**
442619c5cb6SVlad Zolotarov 	 * Wait for completion of all commands. Don't schedule new ones,
443619c5cb6SVlad Zolotarov 	 * just wait. It assumes that the completion code will schedule
444619c5cb6SVlad Zolotarov 	 * for new commands.
445619c5cb6SVlad Zolotarov 	 */
446619c5cb6SVlad Zolotarov 	int (*wait)(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o);
447619c5cb6SVlad Zolotarov };
448619c5cb6SVlad Zolotarov 
4490a52fd01SYuval Mintz enum {
4500a52fd01SYuval Mintz 	BNX2X_LLH_CAM_ISCSI_ETH_LINE = 0,
4510a52fd01SYuval Mintz 	BNX2X_LLH_CAM_ETH_LINE,
4520a52fd01SYuval Mintz 	BNX2X_LLH_CAM_MAX_PF_LINE = NIG_REG_LLH1_FUNC_MEM_SIZE / 2
4530a52fd01SYuval Mintz };
4540a52fd01SYuval Mintz 
455619c5cb6SVlad Zolotarov /** RX_MODE verbs:DROP_ALL/ACCEPT_ALL/ACCEPT_ALL_MULTI/ACCEPT_ALL_VLAN/NORMAL */
456619c5cb6SVlad Zolotarov 
45716a5fd92SYuval Mintz /* RX_MODE ramrod special flags: set in rx_mode_flags field in
458619c5cb6SVlad Zolotarov  * a bnx2x_rx_mode_ramrod_params.
459619c5cb6SVlad Zolotarov  */
460619c5cb6SVlad Zolotarov enum {
461619c5cb6SVlad Zolotarov 	BNX2X_RX_MODE_FCOE_ETH,
462619c5cb6SVlad Zolotarov 	BNX2X_RX_MODE_ISCSI_ETH,
463619c5cb6SVlad Zolotarov };
464619c5cb6SVlad Zolotarov 
465619c5cb6SVlad Zolotarov enum {
466619c5cb6SVlad Zolotarov 	BNX2X_ACCEPT_UNICAST,
467619c5cb6SVlad Zolotarov 	BNX2X_ACCEPT_MULTICAST,
468619c5cb6SVlad Zolotarov 	BNX2X_ACCEPT_ALL_UNICAST,
469619c5cb6SVlad Zolotarov 	BNX2X_ACCEPT_ALL_MULTICAST,
470619c5cb6SVlad Zolotarov 	BNX2X_ACCEPT_BROADCAST,
471619c5cb6SVlad Zolotarov 	BNX2X_ACCEPT_UNMATCHED,
472619c5cb6SVlad Zolotarov 	BNX2X_ACCEPT_ANY_VLAN
473619c5cb6SVlad Zolotarov };
474619c5cb6SVlad Zolotarov 
475619c5cb6SVlad Zolotarov struct bnx2x_rx_mode_ramrod_params {
476619c5cb6SVlad Zolotarov 	struct bnx2x_rx_mode_obj *rx_mode_obj;
477619c5cb6SVlad Zolotarov 	unsigned long *pstate;
478619c5cb6SVlad Zolotarov 	int state;
479619c5cb6SVlad Zolotarov 	u8 cl_id;
480619c5cb6SVlad Zolotarov 	u32 cid;
481619c5cb6SVlad Zolotarov 	u8 func_id;
482619c5cb6SVlad Zolotarov 	unsigned long ramrod_flags;
483619c5cb6SVlad Zolotarov 	unsigned long rx_mode_flags;
484619c5cb6SVlad Zolotarov 
48516a5fd92SYuval Mintz 	/* rdata is either a pointer to eth_filter_rules_ramrod_data(e2) or to
486619c5cb6SVlad Zolotarov 	 * a tstorm_eth_mac_filter_config (e1x).
487619c5cb6SVlad Zolotarov 	 */
488619c5cb6SVlad Zolotarov 	void *rdata;
489619c5cb6SVlad Zolotarov 	dma_addr_t rdata_mapping;
490619c5cb6SVlad Zolotarov 
491619c5cb6SVlad Zolotarov 	/* Rx mode settings */
492619c5cb6SVlad Zolotarov 	unsigned long rx_accept_flags;
493619c5cb6SVlad Zolotarov 
494619c5cb6SVlad Zolotarov 	/* internal switching settings */
495619c5cb6SVlad Zolotarov 	unsigned long tx_accept_flags;
496619c5cb6SVlad Zolotarov };
497619c5cb6SVlad Zolotarov 
498619c5cb6SVlad Zolotarov struct bnx2x_rx_mode_obj {
499619c5cb6SVlad Zolotarov 	int (*config_rx_mode)(struct bnx2x *bp,
500619c5cb6SVlad Zolotarov 			      struct bnx2x_rx_mode_ramrod_params *p);
501619c5cb6SVlad Zolotarov 
502619c5cb6SVlad Zolotarov 	int (*wait_comp)(struct bnx2x *bp,
503619c5cb6SVlad Zolotarov 			 struct bnx2x_rx_mode_ramrod_params *p);
504619c5cb6SVlad Zolotarov };
505619c5cb6SVlad Zolotarov 
506619c5cb6SVlad Zolotarov /********************** Set multicast group ***********************************/
507619c5cb6SVlad Zolotarov 
508619c5cb6SVlad Zolotarov struct bnx2x_mcast_list_elem {
509619c5cb6SVlad Zolotarov 	struct list_head link;
510619c5cb6SVlad Zolotarov 	u8 *mac;
511619c5cb6SVlad Zolotarov };
512619c5cb6SVlad Zolotarov 
513619c5cb6SVlad Zolotarov union bnx2x_mcast_config_data {
514619c5cb6SVlad Zolotarov 	u8 *mac;
515619c5cb6SVlad Zolotarov 	u8 bin; /* used in a RESTORE flow */
516619c5cb6SVlad Zolotarov };
517619c5cb6SVlad Zolotarov 
518619c5cb6SVlad Zolotarov struct bnx2x_mcast_ramrod_params {
519619c5cb6SVlad Zolotarov 	struct bnx2x_mcast_obj *mcast_obj;
520619c5cb6SVlad Zolotarov 
521619c5cb6SVlad Zolotarov 	/* Relevant options are RAMROD_COMP_WAIT and RAMROD_DRV_CLR_ONLY */
522619c5cb6SVlad Zolotarov 	unsigned long ramrod_flags;
523619c5cb6SVlad Zolotarov 
524619c5cb6SVlad Zolotarov 	struct list_head mcast_list; /* list of struct bnx2x_mcast_list_elem */
525619c5cb6SVlad Zolotarov 	/** TODO:
526619c5cb6SVlad Zolotarov 	 *      - rename it to macs_num.
527619c5cb6SVlad Zolotarov 	 *      - Add a new command type for handling pending commands
528619c5cb6SVlad Zolotarov 	 *        (remove "zero semantics").
529619c5cb6SVlad Zolotarov 	 *
530619c5cb6SVlad Zolotarov 	 *  Length of mcast_list. If zero and ADD_CONT command - post
531619c5cb6SVlad Zolotarov 	 *  pending commands.
532619c5cb6SVlad Zolotarov 	 */
533619c5cb6SVlad Zolotarov 	int mcast_list_len;
534619c5cb6SVlad Zolotarov };
535619c5cb6SVlad Zolotarov 
53686564c3fSYuval Mintz enum bnx2x_mcast_cmd {
537619c5cb6SVlad Zolotarov 	BNX2X_MCAST_CMD_ADD,
538619c5cb6SVlad Zolotarov 	BNX2X_MCAST_CMD_CONT,
539619c5cb6SVlad Zolotarov 	BNX2X_MCAST_CMD_DEL,
540619c5cb6SVlad Zolotarov 	BNX2X_MCAST_CMD_RESTORE,
541c7b7b483SYuval Mintz 
542c7b7b483SYuval Mintz 	/* Following this, multicast configuration should equal to approx
543c7b7b483SYuval Mintz 	 * the set of MACs provided [i.e., remove all else].
544c7b7b483SYuval Mintz 	 * The two sub-commands are used internally to decide whether a given
545c7b7b483SYuval Mintz 	 * bin is to be added or removed
546c7b7b483SYuval Mintz 	 */
547c7b7b483SYuval Mintz 	BNX2X_MCAST_CMD_SET,
548c7b7b483SYuval Mintz 	BNX2X_MCAST_CMD_SET_ADD,
549c7b7b483SYuval Mintz 	BNX2X_MCAST_CMD_SET_DEL,
550619c5cb6SVlad Zolotarov };
551619c5cb6SVlad Zolotarov 
552619c5cb6SVlad Zolotarov struct bnx2x_mcast_obj {
553619c5cb6SVlad Zolotarov 	struct bnx2x_raw_obj raw;
554619c5cb6SVlad Zolotarov 
555619c5cb6SVlad Zolotarov 	union {
556619c5cb6SVlad Zolotarov 		struct {
557619c5cb6SVlad Zolotarov 		#define BNX2X_MCAST_BINS_NUM	256
558619c5cb6SVlad Zolotarov 		#define BNX2X_MCAST_VEC_SZ	(BNX2X_MCAST_BINS_NUM / 64)
559619c5cb6SVlad Zolotarov 			u64 vec[BNX2X_MCAST_VEC_SZ];
560619c5cb6SVlad Zolotarov 
561619c5cb6SVlad Zolotarov 			/** Number of BINs to clear. Should be updated
562619c5cb6SVlad Zolotarov 			 *  immediately when a command arrives in order to
563619c5cb6SVlad Zolotarov 			 *  properly create DEL commands.
564619c5cb6SVlad Zolotarov 			 */
565619c5cb6SVlad Zolotarov 			int num_bins_set;
566619c5cb6SVlad Zolotarov 		} aprox_match;
567619c5cb6SVlad Zolotarov 
568619c5cb6SVlad Zolotarov 		struct {
569619c5cb6SVlad Zolotarov 			struct list_head macs;
570619c5cb6SVlad Zolotarov 			int num_macs_set;
571619c5cb6SVlad Zolotarov 		} exact_match;
572619c5cb6SVlad Zolotarov 	} registry;
573619c5cb6SVlad Zolotarov 
574619c5cb6SVlad Zolotarov 	/* Pending commands */
575619c5cb6SVlad Zolotarov 	struct list_head pending_cmds_head;
576619c5cb6SVlad Zolotarov 
577619c5cb6SVlad Zolotarov 	/* A state that is set in raw.pstate, when there are pending commands */
578619c5cb6SVlad Zolotarov 	int sched_state;
579619c5cb6SVlad Zolotarov 
580619c5cb6SVlad Zolotarov 	/* Maximal number of mcast MACs configured in one command */
581619c5cb6SVlad Zolotarov 	int max_cmd_len;
582619c5cb6SVlad Zolotarov 
583619c5cb6SVlad Zolotarov 	/* Total number of currently pending MACs to configure: both
584619c5cb6SVlad Zolotarov 	 * in the pending commands list and in the current command.
585619c5cb6SVlad Zolotarov 	 */
586619c5cb6SVlad Zolotarov 	int total_pending_num;
587619c5cb6SVlad Zolotarov 
588619c5cb6SVlad Zolotarov 	u8 engine_id;
589619c5cb6SVlad Zolotarov 
590619c5cb6SVlad Zolotarov 	/**
591619c5cb6SVlad Zolotarov 	 * @param cmd command to execute (BNX2X_MCAST_CMD_X, see above)
592619c5cb6SVlad Zolotarov 	 */
593619c5cb6SVlad Zolotarov 	int (*config_mcast)(struct bnx2x *bp,
59486564c3fSYuval Mintz 			    struct bnx2x_mcast_ramrod_params *p,
59586564c3fSYuval Mintz 			    enum bnx2x_mcast_cmd cmd);
596619c5cb6SVlad Zolotarov 
597619c5cb6SVlad Zolotarov 	/**
598619c5cb6SVlad Zolotarov 	 * Fills the ramrod data during the RESTORE flow.
599619c5cb6SVlad Zolotarov 	 *
600619c5cb6SVlad Zolotarov 	 * @param bp
601619c5cb6SVlad Zolotarov 	 * @param o
602619c5cb6SVlad Zolotarov 	 * @param start_idx Registry index to start from
603619c5cb6SVlad Zolotarov 	 * @param rdata_idx Index in the ramrod data to start from
604619c5cb6SVlad Zolotarov 	 *
605619c5cb6SVlad Zolotarov 	 * @return -1 if we handled the whole registry or index of the last
606619c5cb6SVlad Zolotarov 	 *         handled registry element.
607619c5cb6SVlad Zolotarov 	 */
608619c5cb6SVlad Zolotarov 	int (*hdl_restore)(struct bnx2x *bp, struct bnx2x_mcast_obj *o,
609619c5cb6SVlad Zolotarov 			   int start_bin, int *rdata_idx);
610619c5cb6SVlad Zolotarov 
611619c5cb6SVlad Zolotarov 	int (*enqueue_cmd)(struct bnx2x *bp, struct bnx2x_mcast_obj *o,
61286564c3fSYuval Mintz 			   struct bnx2x_mcast_ramrod_params *p,
61386564c3fSYuval Mintz 			   enum bnx2x_mcast_cmd cmd);
614619c5cb6SVlad Zolotarov 
615619c5cb6SVlad Zolotarov 	void (*set_one_rule)(struct bnx2x *bp,
616619c5cb6SVlad Zolotarov 			     struct bnx2x_mcast_obj *o, int idx,
61786564c3fSYuval Mintz 			     union bnx2x_mcast_config_data *cfg_data,
61886564c3fSYuval Mintz 			     enum bnx2x_mcast_cmd cmd);
619619c5cb6SVlad Zolotarov 
620619c5cb6SVlad Zolotarov 	/** Checks if there are more mcast MACs to be set or a previous
621619c5cb6SVlad Zolotarov 	 *  command is still pending.
622619c5cb6SVlad Zolotarov 	 */
623619c5cb6SVlad Zolotarov 	bool (*check_pending)(struct bnx2x_mcast_obj *o);
624619c5cb6SVlad Zolotarov 
625619c5cb6SVlad Zolotarov 	/**
626619c5cb6SVlad Zolotarov 	 * Set/Clear/Check SCHEDULED state of the object
627619c5cb6SVlad Zolotarov 	 */
628619c5cb6SVlad Zolotarov 	void (*set_sched)(struct bnx2x_mcast_obj *o);
629619c5cb6SVlad Zolotarov 	void (*clear_sched)(struct bnx2x_mcast_obj *o);
630619c5cb6SVlad Zolotarov 	bool (*check_sched)(struct bnx2x_mcast_obj *o);
631619c5cb6SVlad Zolotarov 
632619c5cb6SVlad Zolotarov 	/* Wait until all pending commands complete */
633619c5cb6SVlad Zolotarov 	int (*wait_comp)(struct bnx2x *bp, struct bnx2x_mcast_obj *o);
634619c5cb6SVlad Zolotarov 
635619c5cb6SVlad Zolotarov 	/**
636619c5cb6SVlad Zolotarov 	 * Handle the internal object counters needed for proper
637619c5cb6SVlad Zolotarov 	 * commands handling. Checks that the provided parameters are
638619c5cb6SVlad Zolotarov 	 * feasible.
639619c5cb6SVlad Zolotarov 	 */
640619c5cb6SVlad Zolotarov 	int (*validate)(struct bnx2x *bp,
64186564c3fSYuval Mintz 			struct bnx2x_mcast_ramrod_params *p,
64286564c3fSYuval Mintz 			enum bnx2x_mcast_cmd cmd);
643619c5cb6SVlad Zolotarov 
644619c5cb6SVlad Zolotarov 	/**
645619c5cb6SVlad Zolotarov 	 * Restore the values of internal counters in case of a failure.
646619c5cb6SVlad Zolotarov 	 */
647619c5cb6SVlad Zolotarov 	void (*revert)(struct bnx2x *bp,
648619c5cb6SVlad Zolotarov 		       struct bnx2x_mcast_ramrod_params *p,
649c7b7b483SYuval Mintz 		       int old_num_bins,
650c7b7b483SYuval Mintz 		       enum bnx2x_mcast_cmd cmd);
651619c5cb6SVlad Zolotarov 
652619c5cb6SVlad Zolotarov 	int (*get_registry_size)(struct bnx2x_mcast_obj *o);
653619c5cb6SVlad Zolotarov 	void (*set_registry_size)(struct bnx2x_mcast_obj *o, int n);
654619c5cb6SVlad Zolotarov };
655619c5cb6SVlad Zolotarov 
656619c5cb6SVlad Zolotarov /*************************** Credit handling **********************************/
657619c5cb6SVlad Zolotarov struct bnx2x_credit_pool_obj {
658619c5cb6SVlad Zolotarov 
659619c5cb6SVlad Zolotarov 	/* Current amount of credit in the pool */
660619c5cb6SVlad Zolotarov 	atomic_t	credit;
661619c5cb6SVlad Zolotarov 
662619c5cb6SVlad Zolotarov 	/* Maximum allowed credit. put() will check against it. */
663619c5cb6SVlad Zolotarov 	int		pool_sz;
664619c5cb6SVlad Zolotarov 
66516a5fd92SYuval Mintz 	/* Allocate a pool table statically.
666619c5cb6SVlad Zolotarov 	 *
66716a5fd92SYuval Mintz 	 * Currently the maximum allowed size is MAX_MAC_CREDIT_E2(272)
668619c5cb6SVlad Zolotarov 	 *
669619c5cb6SVlad Zolotarov 	 * The set bit in the table will mean that the entry is available.
670619c5cb6SVlad Zolotarov 	 */
671619c5cb6SVlad Zolotarov #define BNX2X_POOL_VEC_SIZE	(MAX_MAC_CREDIT_E2 / 64)
672619c5cb6SVlad Zolotarov 	u64		pool_mirror[BNX2X_POOL_VEC_SIZE];
673619c5cb6SVlad Zolotarov 
674619c5cb6SVlad Zolotarov 	/* Base pool offset (initialized differently */
675619c5cb6SVlad Zolotarov 	int		base_pool_offset;
676619c5cb6SVlad Zolotarov 
677619c5cb6SVlad Zolotarov 	/**
678619c5cb6SVlad Zolotarov 	 * Get the next free pool entry.
679619c5cb6SVlad Zolotarov 	 *
680619c5cb6SVlad Zolotarov 	 * @return true if there was a free entry in the pool
681619c5cb6SVlad Zolotarov 	 */
682619c5cb6SVlad Zolotarov 	bool (*get_entry)(struct bnx2x_credit_pool_obj *o, int *entry);
683619c5cb6SVlad Zolotarov 
684619c5cb6SVlad Zolotarov 	/**
685619c5cb6SVlad Zolotarov 	 * Return the entry back to the pool.
686619c5cb6SVlad Zolotarov 	 *
687619c5cb6SVlad Zolotarov 	 * @return true if entry is legal and has been successfully
688619c5cb6SVlad Zolotarov 	 *         returned to the pool.
689619c5cb6SVlad Zolotarov 	 */
690619c5cb6SVlad Zolotarov 	bool (*put_entry)(struct bnx2x_credit_pool_obj *o, int entry);
691619c5cb6SVlad Zolotarov 
692619c5cb6SVlad Zolotarov 	/**
693619c5cb6SVlad Zolotarov 	 * Get the requested amount of credit from the pool.
694619c5cb6SVlad Zolotarov 	 *
695619c5cb6SVlad Zolotarov 	 * @param cnt Amount of requested credit
696619c5cb6SVlad Zolotarov 	 * @return true if the operation is successful
697619c5cb6SVlad Zolotarov 	 */
698619c5cb6SVlad Zolotarov 	bool (*get)(struct bnx2x_credit_pool_obj *o, int cnt);
699619c5cb6SVlad Zolotarov 
700619c5cb6SVlad Zolotarov 	/**
701619c5cb6SVlad Zolotarov 	 * Returns the credit to the pool.
702619c5cb6SVlad Zolotarov 	 *
703619c5cb6SVlad Zolotarov 	 * @param cnt Amount of credit to return
704619c5cb6SVlad Zolotarov 	 * @return true if the operation is successful
705619c5cb6SVlad Zolotarov 	 */
706619c5cb6SVlad Zolotarov 	bool (*put)(struct bnx2x_credit_pool_obj *o, int cnt);
707619c5cb6SVlad Zolotarov 
708619c5cb6SVlad Zolotarov 	/**
709619c5cb6SVlad Zolotarov 	 * Reads the current amount of credit.
710619c5cb6SVlad Zolotarov 	 */
711619c5cb6SVlad Zolotarov 	int (*check)(struct bnx2x_credit_pool_obj *o);
712619c5cb6SVlad Zolotarov };
713619c5cb6SVlad Zolotarov 
714619c5cb6SVlad Zolotarov /*************************** RSS configuration ********************************/
715619c5cb6SVlad Zolotarov enum {
716619c5cb6SVlad Zolotarov 	/* RSS_MODE bits are mutually exclusive */
717619c5cb6SVlad Zolotarov 	BNX2X_RSS_MODE_DISABLED,
718619c5cb6SVlad Zolotarov 	BNX2X_RSS_MODE_REGULAR,
719619c5cb6SVlad Zolotarov 
720619c5cb6SVlad Zolotarov 	BNX2X_RSS_SET_SRCH, /* Setup searcher, E1x specific flag */
721619c5cb6SVlad Zolotarov 
722619c5cb6SVlad Zolotarov 	BNX2X_RSS_IPV4,
723619c5cb6SVlad Zolotarov 	BNX2X_RSS_IPV4_TCP,
7245d317c6aSMerav Sicron 	BNX2X_RSS_IPV4_UDP,
725619c5cb6SVlad Zolotarov 	BNX2X_RSS_IPV6,
726619c5cb6SVlad Zolotarov 	BNX2X_RSS_IPV6_TCP,
7275d317c6aSMerav Sicron 	BNX2X_RSS_IPV6_UDP,
72828311f8eSYuval Mintz 
72928311f8eSYuval Mintz 	BNX2X_RSS_IPV4_VXLAN,
73028311f8eSYuval Mintz 	BNX2X_RSS_IPV6_VXLAN,
73128311f8eSYuval Mintz 	BNX2X_RSS_TUNN_INNER_HDRS,
732619c5cb6SVlad Zolotarov };
733619c5cb6SVlad Zolotarov 
734619c5cb6SVlad Zolotarov struct bnx2x_config_rss_params {
735619c5cb6SVlad Zolotarov 	struct bnx2x_rss_config_obj *rss_obj;
736619c5cb6SVlad Zolotarov 
737619c5cb6SVlad Zolotarov 	/* may have RAMROD_COMP_WAIT set only */
738619c5cb6SVlad Zolotarov 	unsigned long	ramrod_flags;
739619c5cb6SVlad Zolotarov 
740619c5cb6SVlad Zolotarov 	/* BNX2X_RSS_X bits */
741619c5cb6SVlad Zolotarov 	unsigned long	rss_flags;
742619c5cb6SVlad Zolotarov 
743619c5cb6SVlad Zolotarov 	/* Number hash bits to take into an account */
744619c5cb6SVlad Zolotarov 	u8		rss_result_mask;
745619c5cb6SVlad Zolotarov 
746619c5cb6SVlad Zolotarov 	/* Indirection table */
747619c5cb6SVlad Zolotarov 	u8		ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
748619c5cb6SVlad Zolotarov 
749619c5cb6SVlad Zolotarov 	/* RSS hash values */
750619c5cb6SVlad Zolotarov 	u32		rss_key[10];
751619c5cb6SVlad Zolotarov 
752619c5cb6SVlad Zolotarov 	/* valid only iff BNX2X_RSS_UPDATE_TOE is set */
753619c5cb6SVlad Zolotarov 	u16		toe_rss_bitmap;
754619c5cb6SVlad Zolotarov };
755619c5cb6SVlad Zolotarov 
756619c5cb6SVlad Zolotarov struct bnx2x_rss_config_obj {
757619c5cb6SVlad Zolotarov 	struct bnx2x_raw_obj	raw;
758619c5cb6SVlad Zolotarov 
759619c5cb6SVlad Zolotarov 	/* RSS engine to use */
760619c5cb6SVlad Zolotarov 	u8			engine_id;
761619c5cb6SVlad Zolotarov 
762619c5cb6SVlad Zolotarov 	/* Last configured indirection table */
763619c5cb6SVlad Zolotarov 	u8			ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
764619c5cb6SVlad Zolotarov 
7655d317c6aSMerav Sicron 	/* flags for enabling 4-tupple hash on UDP */
7665d317c6aSMerav Sicron 	u8			udp_rss_v4;
7675d317c6aSMerav Sicron 	u8			udp_rss_v6;
7685d317c6aSMerav Sicron 
769619c5cb6SVlad Zolotarov 	int (*config_rss)(struct bnx2x *bp,
770619c5cb6SVlad Zolotarov 			  struct bnx2x_config_rss_params *p);
771619c5cb6SVlad Zolotarov };
772619c5cb6SVlad Zolotarov 
773619c5cb6SVlad Zolotarov /*********************** Queue state update ***********************************/
774619c5cb6SVlad Zolotarov 
775619c5cb6SVlad Zolotarov /* UPDATE command options */
776619c5cb6SVlad Zolotarov enum {
777619c5cb6SVlad Zolotarov 	BNX2X_Q_UPDATE_IN_VLAN_REM,
778619c5cb6SVlad Zolotarov 	BNX2X_Q_UPDATE_IN_VLAN_REM_CHNG,
779619c5cb6SVlad Zolotarov 	BNX2X_Q_UPDATE_OUT_VLAN_REM,
780619c5cb6SVlad Zolotarov 	BNX2X_Q_UPDATE_OUT_VLAN_REM_CHNG,
781619c5cb6SVlad Zolotarov 	BNX2X_Q_UPDATE_ANTI_SPOOF,
782619c5cb6SVlad Zolotarov 	BNX2X_Q_UPDATE_ANTI_SPOOF_CHNG,
783619c5cb6SVlad Zolotarov 	BNX2X_Q_UPDATE_ACTIVATE,
784619c5cb6SVlad Zolotarov 	BNX2X_Q_UPDATE_ACTIVATE_CHNG,
785619c5cb6SVlad Zolotarov 	BNX2X_Q_UPDATE_DEF_VLAN_EN,
786619c5cb6SVlad Zolotarov 	BNX2X_Q_UPDATE_DEF_VLAN_EN_CHNG,
787619c5cb6SVlad Zolotarov 	BNX2X_Q_UPDATE_SILENT_VLAN_REM_CHNG,
788c14db202SYuval Mintz 	BNX2X_Q_UPDATE_SILENT_VLAN_REM,
789c14db202SYuval Mintz 	BNX2X_Q_UPDATE_TX_SWITCHING_CHNG,
790eeed018cSMichal Kalderon 	BNX2X_Q_UPDATE_TX_SWITCHING,
791eeed018cSMichal Kalderon 	BNX2X_Q_UPDATE_PTP_PKTS_CHNG,
792eeed018cSMichal Kalderon 	BNX2X_Q_UPDATE_PTP_PKTS,
793619c5cb6SVlad Zolotarov };
794619c5cb6SVlad Zolotarov 
795619c5cb6SVlad Zolotarov /* Allowed Queue states */
796619c5cb6SVlad Zolotarov enum bnx2x_q_state {
797619c5cb6SVlad Zolotarov 	BNX2X_Q_STATE_RESET,
798619c5cb6SVlad Zolotarov 	BNX2X_Q_STATE_INITIALIZED,
799619c5cb6SVlad Zolotarov 	BNX2X_Q_STATE_ACTIVE,
8006383c0b3SAriel Elior 	BNX2X_Q_STATE_MULTI_COS,
8016383c0b3SAriel Elior 	BNX2X_Q_STATE_MCOS_TERMINATED,
802619c5cb6SVlad Zolotarov 	BNX2X_Q_STATE_INACTIVE,
803619c5cb6SVlad Zolotarov 	BNX2X_Q_STATE_STOPPED,
804619c5cb6SVlad Zolotarov 	BNX2X_Q_STATE_TERMINATED,
805619c5cb6SVlad Zolotarov 	BNX2X_Q_STATE_FLRED,
806619c5cb6SVlad Zolotarov 	BNX2X_Q_STATE_MAX,
807619c5cb6SVlad Zolotarov };
808619c5cb6SVlad Zolotarov 
80967c431a5SAriel Elior /* Allowed Queue states */
81067c431a5SAriel Elior enum bnx2x_q_logical_state {
81167c431a5SAriel Elior 	BNX2X_Q_LOGICAL_STATE_ACTIVE,
81267c431a5SAriel Elior 	BNX2X_Q_LOGICAL_STATE_STOPPED,
81367c431a5SAriel Elior };
81467c431a5SAriel Elior 
815619c5cb6SVlad Zolotarov /* Allowed commands */
816619c5cb6SVlad Zolotarov enum bnx2x_queue_cmd {
817619c5cb6SVlad Zolotarov 	BNX2X_Q_CMD_INIT,
818619c5cb6SVlad Zolotarov 	BNX2X_Q_CMD_SETUP,
8196383c0b3SAriel Elior 	BNX2X_Q_CMD_SETUP_TX_ONLY,
820619c5cb6SVlad Zolotarov 	BNX2X_Q_CMD_DEACTIVATE,
821619c5cb6SVlad Zolotarov 	BNX2X_Q_CMD_ACTIVATE,
822619c5cb6SVlad Zolotarov 	BNX2X_Q_CMD_UPDATE,
823619c5cb6SVlad Zolotarov 	BNX2X_Q_CMD_UPDATE_TPA,
824619c5cb6SVlad Zolotarov 	BNX2X_Q_CMD_HALT,
825619c5cb6SVlad Zolotarov 	BNX2X_Q_CMD_CFC_DEL,
826619c5cb6SVlad Zolotarov 	BNX2X_Q_CMD_TERMINATE,
827619c5cb6SVlad Zolotarov 	BNX2X_Q_CMD_EMPTY,
828619c5cb6SVlad Zolotarov 	BNX2X_Q_CMD_MAX,
829619c5cb6SVlad Zolotarov };
830619c5cb6SVlad Zolotarov 
831619c5cb6SVlad Zolotarov /* queue SETUP + INIT flags */
832619c5cb6SVlad Zolotarov enum {
833619c5cb6SVlad Zolotarov 	BNX2X_Q_FLG_TPA,
834f5219d8eSVladislav Zolotarov 	BNX2X_Q_FLG_TPA_IPV6,
835621b4d66SDmitry Kravkov 	BNX2X_Q_FLG_TPA_GRO,
836619c5cb6SVlad Zolotarov 	BNX2X_Q_FLG_STATS,
837619c5cb6SVlad Zolotarov 	BNX2X_Q_FLG_ZERO_STATS,
838619c5cb6SVlad Zolotarov 	BNX2X_Q_FLG_ACTIVE,
839619c5cb6SVlad Zolotarov 	BNX2X_Q_FLG_OV,
840619c5cb6SVlad Zolotarov 	BNX2X_Q_FLG_VLAN,
841619c5cb6SVlad Zolotarov 	BNX2X_Q_FLG_COS,
842619c5cb6SVlad Zolotarov 	BNX2X_Q_FLG_HC,
843619c5cb6SVlad Zolotarov 	BNX2X_Q_FLG_HC_EN,
844619c5cb6SVlad Zolotarov 	BNX2X_Q_FLG_DHC,
845619c5cb6SVlad Zolotarov 	BNX2X_Q_FLG_FCOE,
846619c5cb6SVlad Zolotarov 	BNX2X_Q_FLG_LEADING_RSS,
847619c5cb6SVlad Zolotarov 	BNX2X_Q_FLG_MCAST,
848619c5cb6SVlad Zolotarov 	BNX2X_Q_FLG_DEF_VLAN,
849619c5cb6SVlad Zolotarov 	BNX2X_Q_FLG_TX_SWITCH,
850619c5cb6SVlad Zolotarov 	BNX2X_Q_FLG_TX_SEC,
851619c5cb6SVlad Zolotarov 	BNX2X_Q_FLG_ANTI_SPOOF,
852a3348722SBarak Witkowski 	BNX2X_Q_FLG_SILENT_VLAN_REM,
85391226790SDmitry Kravkov 	BNX2X_Q_FLG_FORCE_DEFAULT_PRI,
854e42780b6SDmitry Kravkov 	BNX2X_Q_FLG_REFUSE_OUTBAND_VLAN,
855e287a75cSDmitry Kravkov 	BNX2X_Q_FLG_PCSUM_ON_PKT,
856e287a75cSDmitry Kravkov 	BNX2X_Q_FLG_TUN_INC_INNER_IP_ID
857619c5cb6SVlad Zolotarov };
858619c5cb6SVlad Zolotarov 
85916a5fd92SYuval Mintz /* Queue type options: queue type may be a combination of below. */
860619c5cb6SVlad Zolotarov enum bnx2x_q_type {
861619c5cb6SVlad Zolotarov 	/** TODO: Consider moving both these flags into the init()
862619c5cb6SVlad Zolotarov 	 *        ramrod params.
863619c5cb6SVlad Zolotarov 	 */
864619c5cb6SVlad Zolotarov 	BNX2X_Q_TYPE_HAS_RX,
865619c5cb6SVlad Zolotarov 	BNX2X_Q_TYPE_HAS_TX,
866619c5cb6SVlad Zolotarov };
867619c5cb6SVlad Zolotarov 
8686383c0b3SAriel Elior #define BNX2X_PRIMARY_CID_INDEX			0
8698d7b0278SAriel Elior #define BNX2X_MULTI_TX_COS_E1X			3 /* QM only */
8706383c0b3SAriel Elior #define BNX2X_MULTI_TX_COS_E2_E3A0		2
8716383c0b3SAriel Elior #define BNX2X_MULTI_TX_COS_E3B0			3
8728d7b0278SAriel Elior #define BNX2X_MULTI_TX_COS			3 /* Maximum possible */
8736383c0b3SAriel Elior 
8743ec9f9caSAriel Elior #define MAC_PAD (ALIGN(ETH_ALEN, sizeof(u32)) - ETH_ALEN)
875eeed018cSMichal Kalderon /* DMAE channel to be used by FW for timesync workaroun. A driver that sends
876eeed018cSMichal Kalderon  * timesync-related ramrods must not use this DMAE command ID.
877eeed018cSMichal Kalderon  */
878eeed018cSMichal Kalderon #define FW_DMAE_CMD_ID 6
8796383c0b3SAriel Elior 
880619c5cb6SVlad Zolotarov struct bnx2x_queue_init_params {
881619c5cb6SVlad Zolotarov 	struct {
882619c5cb6SVlad Zolotarov 		unsigned long	flags;
883619c5cb6SVlad Zolotarov 		u16		hc_rate;
884619c5cb6SVlad Zolotarov 		u8		fw_sb_id;
885619c5cb6SVlad Zolotarov 		u8		sb_cq_index;
886619c5cb6SVlad Zolotarov 	} tx;
887619c5cb6SVlad Zolotarov 
888619c5cb6SVlad Zolotarov 	struct {
889619c5cb6SVlad Zolotarov 		unsigned long	flags;
890619c5cb6SVlad Zolotarov 		u16		hc_rate;
891619c5cb6SVlad Zolotarov 		u8		fw_sb_id;
892619c5cb6SVlad Zolotarov 		u8		sb_cq_index;
893619c5cb6SVlad Zolotarov 	} rx;
894619c5cb6SVlad Zolotarov 
895619c5cb6SVlad Zolotarov 	/* CID context in the host memory */
8966383c0b3SAriel Elior 	struct eth_context *cxts[BNX2X_MULTI_TX_COS];
8976383c0b3SAriel Elior 
8986383c0b3SAriel Elior 	/* maximum number of cos supported by hardware */
8996383c0b3SAriel Elior 	u8 max_cos;
9006383c0b3SAriel Elior };
9016383c0b3SAriel Elior 
9026383c0b3SAriel Elior struct bnx2x_queue_terminate_params {
9036383c0b3SAriel Elior 	/* index within the tx_only cids of this queue object */
9046383c0b3SAriel Elior 	u8 cid_index;
9056383c0b3SAriel Elior };
9066383c0b3SAriel Elior 
9076383c0b3SAriel Elior struct bnx2x_queue_cfc_del_params {
9086383c0b3SAriel Elior 	/* index within the tx_only cids of this queue object */
9096383c0b3SAriel Elior 	u8 cid_index;
910619c5cb6SVlad Zolotarov };
911619c5cb6SVlad Zolotarov 
912619c5cb6SVlad Zolotarov struct bnx2x_queue_update_params {
913619c5cb6SVlad Zolotarov 	unsigned long	update_flags; /* BNX2X_Q_UPDATE_XX bits */
914619c5cb6SVlad Zolotarov 	u16		def_vlan;
915619c5cb6SVlad Zolotarov 	u16		silent_removal_value;
916619c5cb6SVlad Zolotarov 	u16		silent_removal_mask;
9176383c0b3SAriel Elior /* index within the tx_only cids of this queue object */
9186383c0b3SAriel Elior 	u8		cid_index;
919619c5cb6SVlad Zolotarov };
920619c5cb6SVlad Zolotarov 
92114a94ebdSMichal Kalderon struct bnx2x_queue_update_tpa_params {
92214a94ebdSMichal Kalderon 	dma_addr_t sge_map;
92314a94ebdSMichal Kalderon 	u8 update_ipv4;
92414a94ebdSMichal Kalderon 	u8 update_ipv6;
92514a94ebdSMichal Kalderon 	u8 max_tpa_queues;
92614a94ebdSMichal Kalderon 	u8 max_sges_pkt;
92714a94ebdSMichal Kalderon 	u8 complete_on_both_clients;
92814a94ebdSMichal Kalderon 	u8 dont_verify_thr;
92914a94ebdSMichal Kalderon 	u8 tpa_mode;
93014a94ebdSMichal Kalderon 	u8 _pad;
93114a94ebdSMichal Kalderon 
93214a94ebdSMichal Kalderon 	u16 sge_buff_sz;
93314a94ebdSMichal Kalderon 	u16 max_agg_sz;
93414a94ebdSMichal Kalderon 
93514a94ebdSMichal Kalderon 	u16 sge_pause_thr_low;
93614a94ebdSMichal Kalderon 	u16 sge_pause_thr_high;
93714a94ebdSMichal Kalderon };
93814a94ebdSMichal Kalderon 
939619c5cb6SVlad Zolotarov struct rxq_pause_params {
940619c5cb6SVlad Zolotarov 	u16		bd_th_lo;
941619c5cb6SVlad Zolotarov 	u16		bd_th_hi;
942619c5cb6SVlad Zolotarov 	u16		rcq_th_lo;
943619c5cb6SVlad Zolotarov 	u16		rcq_th_hi;
944619c5cb6SVlad Zolotarov 	u16		sge_th_lo; /* valid iff BNX2X_Q_FLG_TPA */
945619c5cb6SVlad Zolotarov 	u16		sge_th_hi; /* valid iff BNX2X_Q_FLG_TPA */
946619c5cb6SVlad Zolotarov 	u16		pri_map;
947619c5cb6SVlad Zolotarov };
948619c5cb6SVlad Zolotarov 
949619c5cb6SVlad Zolotarov /* general */
950619c5cb6SVlad Zolotarov struct bnx2x_general_setup_params {
951619c5cb6SVlad Zolotarov 	/* valid iff BNX2X_Q_FLG_STATS */
952619c5cb6SVlad Zolotarov 	u8		stat_id;
953619c5cb6SVlad Zolotarov 
954619c5cb6SVlad Zolotarov 	u8		spcl_id;
955619c5cb6SVlad Zolotarov 	u16		mtu;
9566383c0b3SAriel Elior 	u8		cos;
95702dc4025SYuval Mintz 
95802dc4025SYuval Mintz 	u8		fp_hsi;
959619c5cb6SVlad Zolotarov };
960619c5cb6SVlad Zolotarov 
961619c5cb6SVlad Zolotarov struct bnx2x_rxq_setup_params {
962619c5cb6SVlad Zolotarov 	/* dma */
963619c5cb6SVlad Zolotarov 	dma_addr_t	dscr_map;
964619c5cb6SVlad Zolotarov 	dma_addr_t	sge_map;
965619c5cb6SVlad Zolotarov 	dma_addr_t	rcq_map;
966619c5cb6SVlad Zolotarov 	dma_addr_t	rcq_np_map;
967619c5cb6SVlad Zolotarov 
968619c5cb6SVlad Zolotarov 	u16		drop_flags;
969619c5cb6SVlad Zolotarov 	u16		buf_sz;
970619c5cb6SVlad Zolotarov 	u8		fw_sb_id;
971619c5cb6SVlad Zolotarov 	u8		cl_qzone_id;
972619c5cb6SVlad Zolotarov 
973619c5cb6SVlad Zolotarov 	/* valid iff BNX2X_Q_FLG_TPA */
974619c5cb6SVlad Zolotarov 	u16		tpa_agg_sz;
975619c5cb6SVlad Zolotarov 	u16		sge_buf_sz;
976619c5cb6SVlad Zolotarov 	u8		max_sges_pkt;
977619c5cb6SVlad Zolotarov 	u8		max_tpa_queues;
978619c5cb6SVlad Zolotarov 	u8		rss_engine_id;
979619c5cb6SVlad Zolotarov 
980259afa1fSYuval Mintz 	/* valid iff BNX2X_Q_FLG_MCAST */
981259afa1fSYuval Mintz 	u8		mcast_engine_id;
982259afa1fSYuval Mintz 
983619c5cb6SVlad Zolotarov 	u8		cache_line_log;
984619c5cb6SVlad Zolotarov 
985619c5cb6SVlad Zolotarov 	u8		sb_cq_index;
986619c5cb6SVlad Zolotarov 
987619c5cb6SVlad Zolotarov 	/* valid iff BXN2X_Q_FLG_SILENT_VLAN_REM */
988619c5cb6SVlad Zolotarov 	u16 silent_removal_value;
989619c5cb6SVlad Zolotarov 	u16 silent_removal_mask;
990619c5cb6SVlad Zolotarov };
991619c5cb6SVlad Zolotarov 
992619c5cb6SVlad Zolotarov struct bnx2x_txq_setup_params {
993619c5cb6SVlad Zolotarov 	/* dma */
994619c5cb6SVlad Zolotarov 	dma_addr_t	dscr_map;
995619c5cb6SVlad Zolotarov 
996619c5cb6SVlad Zolotarov 	u8		fw_sb_id;
997619c5cb6SVlad Zolotarov 	u8		sb_cq_index;
998619c5cb6SVlad Zolotarov 	u8		cos;		/* valid iff BNX2X_Q_FLG_COS */
999619c5cb6SVlad Zolotarov 	u16		traffic_type;
1000619c5cb6SVlad Zolotarov 	/* equals to the leading rss client id, used for TX classification*/
1001619c5cb6SVlad Zolotarov 	u8		tss_leading_cl_id;
1002619c5cb6SVlad Zolotarov 
1003619c5cb6SVlad Zolotarov 	/* valid iff BNX2X_Q_FLG_DEF_VLAN */
1004619c5cb6SVlad Zolotarov 	u16		default_vlan;
1005619c5cb6SVlad Zolotarov };
1006619c5cb6SVlad Zolotarov 
1007619c5cb6SVlad Zolotarov struct bnx2x_queue_setup_params {
1008619c5cb6SVlad Zolotarov 	struct bnx2x_general_setup_params gen_params;
1009619c5cb6SVlad Zolotarov 	struct bnx2x_txq_setup_params txq_params;
10106383c0b3SAriel Elior 	struct bnx2x_rxq_setup_params rxq_params;
10116383c0b3SAriel Elior 	struct rxq_pause_params pause_params;
1012619c5cb6SVlad Zolotarov 	unsigned long flags;
1013619c5cb6SVlad Zolotarov };
1014619c5cb6SVlad Zolotarov 
10156383c0b3SAriel Elior struct bnx2x_queue_setup_tx_only_params {
10166383c0b3SAriel Elior 	struct bnx2x_general_setup_params	gen_params;
10176383c0b3SAriel Elior 	struct bnx2x_txq_setup_params		txq_params;
10186383c0b3SAriel Elior 	unsigned long				flags;
10196383c0b3SAriel Elior 	/* index within the tx_only cids of this queue object */
10206383c0b3SAriel Elior 	u8					cid_index;
10216383c0b3SAriel Elior };
1022619c5cb6SVlad Zolotarov 
1023619c5cb6SVlad Zolotarov struct bnx2x_queue_state_params {
1024619c5cb6SVlad Zolotarov 	struct bnx2x_queue_sp_obj *q_obj;
1025619c5cb6SVlad Zolotarov 
1026619c5cb6SVlad Zolotarov 	/* Current command */
1027619c5cb6SVlad Zolotarov 	enum bnx2x_queue_cmd cmd;
1028619c5cb6SVlad Zolotarov 
1029619c5cb6SVlad Zolotarov 	/* may have RAMROD_COMP_WAIT set only */
1030619c5cb6SVlad Zolotarov 	unsigned long ramrod_flags;
1031619c5cb6SVlad Zolotarov 
1032619c5cb6SVlad Zolotarov 	/* Params according to the current command */
1033619c5cb6SVlad Zolotarov 	union {
1034619c5cb6SVlad Zolotarov 		struct bnx2x_queue_update_params	update;
103514a94ebdSMichal Kalderon 		struct bnx2x_queue_update_tpa_params    update_tpa;
1036619c5cb6SVlad Zolotarov 		struct bnx2x_queue_setup_params		setup;
1037619c5cb6SVlad Zolotarov 		struct bnx2x_queue_init_params		init;
10386383c0b3SAriel Elior 		struct bnx2x_queue_setup_tx_only_params	tx_only;
10396383c0b3SAriel Elior 		struct bnx2x_queue_terminate_params	terminate;
10406383c0b3SAriel Elior 		struct bnx2x_queue_cfc_del_params	cfc_del;
1041619c5cb6SVlad Zolotarov 	} params;
1042619c5cb6SVlad Zolotarov };
1043619c5cb6SVlad Zolotarov 
1044a3348722SBarak Witkowski struct bnx2x_viflist_params {
1045a3348722SBarak Witkowski 	u8 echo_res;
1046a3348722SBarak Witkowski 	u8 func_bit_map_res;
1047a3348722SBarak Witkowski };
1048a3348722SBarak Witkowski 
1049619c5cb6SVlad Zolotarov struct bnx2x_queue_sp_obj {
10506383c0b3SAriel Elior 	u32		cids[BNX2X_MULTI_TX_COS];
1051619c5cb6SVlad Zolotarov 	u8		cl_id;
1052619c5cb6SVlad Zolotarov 	u8		func_id;
1053619c5cb6SVlad Zolotarov 
105416a5fd92SYuval Mintz 	/* number of traffic classes supported by queue.
105516a5fd92SYuval Mintz 	 * The primary connection of the queue supports the first traffic
105616a5fd92SYuval Mintz 	 * class. Any further traffic class is supported by a tx-only
10576383c0b3SAriel Elior 	 * connection.
10586383c0b3SAriel Elior 	 *
10596383c0b3SAriel Elior 	 * Therefore max_cos is also a number of valid entries in the cids
10606383c0b3SAriel Elior 	 * array.
10616383c0b3SAriel Elior 	 */
10626383c0b3SAriel Elior 	u8 max_cos;
10636383c0b3SAriel Elior 	u8 num_tx_only, next_tx_only;
10646383c0b3SAriel Elior 
1065619c5cb6SVlad Zolotarov 	enum bnx2x_q_state state, next_state;
1066619c5cb6SVlad Zolotarov 
1067619c5cb6SVlad Zolotarov 	/* bits from enum bnx2x_q_type */
1068619c5cb6SVlad Zolotarov 	unsigned long	type;
1069619c5cb6SVlad Zolotarov 
1070619c5cb6SVlad Zolotarov 	/* BNX2X_Q_CMD_XX bits. This object implements "one
1071619c5cb6SVlad Zolotarov 	 * pending" paradigm but for debug and tracing purposes it's
107216a5fd92SYuval Mintz 	 * more convenient to have different bits for different
1073619c5cb6SVlad Zolotarov 	 * commands.
1074619c5cb6SVlad Zolotarov 	 */
1075619c5cb6SVlad Zolotarov 	unsigned long	pending;
1076619c5cb6SVlad Zolotarov 
1077619c5cb6SVlad Zolotarov 	/* Buffer to use as a ramrod data and its mapping */
1078619c5cb6SVlad Zolotarov 	void		*rdata;
1079619c5cb6SVlad Zolotarov 	dma_addr_t	rdata_mapping;
1080619c5cb6SVlad Zolotarov 
1081619c5cb6SVlad Zolotarov 	/**
1082619c5cb6SVlad Zolotarov 	 * Performs one state change according to the given parameters.
1083619c5cb6SVlad Zolotarov 	 *
1084619c5cb6SVlad Zolotarov 	 * @return 0 in case of success and negative value otherwise.
1085619c5cb6SVlad Zolotarov 	 */
1086619c5cb6SVlad Zolotarov 	int (*send_cmd)(struct bnx2x *bp,
1087619c5cb6SVlad Zolotarov 			struct bnx2x_queue_state_params *params);
1088619c5cb6SVlad Zolotarov 
1089619c5cb6SVlad Zolotarov 	/**
1090619c5cb6SVlad Zolotarov 	 * Sets the pending bit according to the requested transition.
1091619c5cb6SVlad Zolotarov 	 */
1092619c5cb6SVlad Zolotarov 	int (*set_pending)(struct bnx2x_queue_sp_obj *o,
1093619c5cb6SVlad Zolotarov 			   struct bnx2x_queue_state_params *params);
1094619c5cb6SVlad Zolotarov 
1095619c5cb6SVlad Zolotarov 	/**
1096619c5cb6SVlad Zolotarov 	 * Checks that the requested state transition is legal.
1097619c5cb6SVlad Zolotarov 	 */
1098619c5cb6SVlad Zolotarov 	int (*check_transition)(struct bnx2x *bp,
1099619c5cb6SVlad Zolotarov 				struct bnx2x_queue_sp_obj *o,
1100619c5cb6SVlad Zolotarov 				struct bnx2x_queue_state_params *params);
1101619c5cb6SVlad Zolotarov 
1102619c5cb6SVlad Zolotarov 	/**
1103619c5cb6SVlad Zolotarov 	 * Completes the pending command.
1104619c5cb6SVlad Zolotarov 	 */
1105619c5cb6SVlad Zolotarov 	int (*complete_cmd)(struct bnx2x *bp,
1106619c5cb6SVlad Zolotarov 			    struct bnx2x_queue_sp_obj *o,
1107619c5cb6SVlad Zolotarov 			    enum bnx2x_queue_cmd);
1108619c5cb6SVlad Zolotarov 
1109619c5cb6SVlad Zolotarov 	int (*wait_comp)(struct bnx2x *bp,
1110619c5cb6SVlad Zolotarov 			 struct bnx2x_queue_sp_obj *o,
1111619c5cb6SVlad Zolotarov 			 enum bnx2x_queue_cmd cmd);
1112619c5cb6SVlad Zolotarov };
1113619c5cb6SVlad Zolotarov 
1114619c5cb6SVlad Zolotarov /********************** Function state update *********************************/
1115e42780b6SDmitry Kravkov 
1116e42780b6SDmitry Kravkov /* UPDATE command options */
1117e42780b6SDmitry Kravkov enum {
1118e42780b6SDmitry Kravkov 	BNX2X_F_UPDATE_TX_SWITCH_SUSPEND_CHNG,
1119e42780b6SDmitry Kravkov 	BNX2X_F_UPDATE_TX_SWITCH_SUSPEND,
11207609647eSYuval Mintz 	BNX2X_F_UPDATE_SD_VLAN_TAG_CHNG,
11217609647eSYuval Mintz 	BNX2X_F_UPDATE_SD_VLAN_ETH_TYPE_CHNG,
11227609647eSYuval Mintz 	BNX2X_F_UPDATE_VLAN_FORCE_PRIO_CHNG,
11237609647eSYuval Mintz 	BNX2X_F_UPDATE_VLAN_FORCE_PRIO_FLAG,
1124e42780b6SDmitry Kravkov 	BNX2X_F_UPDATE_TUNNEL_CFG_CHNG,
112528311f8eSYuval Mintz 	BNX2X_F_UPDATE_TUNNEL_INNER_CLSS_L2GRE,
112628311f8eSYuval Mintz 	BNX2X_F_UPDATE_TUNNEL_INNER_CLSS_VXLAN,
112728311f8eSYuval Mintz 	BNX2X_F_UPDATE_TUNNEL_INNER_CLSS_L2GENEVE,
112828311f8eSYuval Mintz 	BNX2X_F_UPDATE_TUNNEL_INNER_RSS,
1129e42780b6SDmitry Kravkov };
1130e42780b6SDmitry Kravkov 
1131619c5cb6SVlad Zolotarov /* Allowed Function states */
1132619c5cb6SVlad Zolotarov enum bnx2x_func_state {
1133619c5cb6SVlad Zolotarov 	BNX2X_F_STATE_RESET,
1134619c5cb6SVlad Zolotarov 	BNX2X_F_STATE_INITIALIZED,
1135619c5cb6SVlad Zolotarov 	BNX2X_F_STATE_STARTED,
11366debea87SDmitry Kravkov 	BNX2X_F_STATE_TX_STOPPED,
1137619c5cb6SVlad Zolotarov 	BNX2X_F_STATE_MAX,
1138619c5cb6SVlad Zolotarov };
1139619c5cb6SVlad Zolotarov 
1140619c5cb6SVlad Zolotarov /* Allowed Function commands */
1141619c5cb6SVlad Zolotarov enum bnx2x_func_cmd {
1142619c5cb6SVlad Zolotarov 	BNX2X_F_CMD_HW_INIT,
1143619c5cb6SVlad Zolotarov 	BNX2X_F_CMD_START,
1144619c5cb6SVlad Zolotarov 	BNX2X_F_CMD_STOP,
1145619c5cb6SVlad Zolotarov 	BNX2X_F_CMD_HW_RESET,
1146a3348722SBarak Witkowski 	BNX2X_F_CMD_AFEX_UPDATE,
1147a3348722SBarak Witkowski 	BNX2X_F_CMD_AFEX_VIFLISTS,
11486debea87SDmitry Kravkov 	BNX2X_F_CMD_TX_STOP,
11496debea87SDmitry Kravkov 	BNX2X_F_CMD_TX_START,
115055c11941SMerav Sicron 	BNX2X_F_CMD_SWITCH_UPDATE,
1151eeed018cSMichal Kalderon 	BNX2X_F_CMD_SET_TIMESYNC,
1152619c5cb6SVlad Zolotarov 	BNX2X_F_CMD_MAX,
1153619c5cb6SVlad Zolotarov };
1154619c5cb6SVlad Zolotarov 
1155619c5cb6SVlad Zolotarov struct bnx2x_func_hw_init_params {
1156619c5cb6SVlad Zolotarov 	/* A load phase returned by MCP.
1157619c5cb6SVlad Zolotarov 	 *
1158619c5cb6SVlad Zolotarov 	 * May be:
1159619c5cb6SVlad Zolotarov 	 *		FW_MSG_CODE_DRV_LOAD_COMMON_CHIP
1160619c5cb6SVlad Zolotarov 	 *		FW_MSG_CODE_DRV_LOAD_COMMON
1161619c5cb6SVlad Zolotarov 	 *		FW_MSG_CODE_DRV_LOAD_PORT
1162619c5cb6SVlad Zolotarov 	 *		FW_MSG_CODE_DRV_LOAD_FUNCTION
1163619c5cb6SVlad Zolotarov 	 */
1164619c5cb6SVlad Zolotarov 	u32 load_phase;
1165619c5cb6SVlad Zolotarov };
1166619c5cb6SVlad Zolotarov 
1167619c5cb6SVlad Zolotarov struct bnx2x_func_hw_reset_params {
1168619c5cb6SVlad Zolotarov 	/* A load phase returned by MCP.
1169619c5cb6SVlad Zolotarov 	 *
1170619c5cb6SVlad Zolotarov 	 * May be:
1171619c5cb6SVlad Zolotarov 	 *		FW_MSG_CODE_DRV_LOAD_COMMON_CHIP
1172619c5cb6SVlad Zolotarov 	 *		FW_MSG_CODE_DRV_LOAD_COMMON
1173619c5cb6SVlad Zolotarov 	 *		FW_MSG_CODE_DRV_LOAD_PORT
1174619c5cb6SVlad Zolotarov 	 *		FW_MSG_CODE_DRV_LOAD_FUNCTION
1175619c5cb6SVlad Zolotarov 	 */
1176619c5cb6SVlad Zolotarov 	u32 reset_phase;
1177619c5cb6SVlad Zolotarov };
1178619c5cb6SVlad Zolotarov 
1179619c5cb6SVlad Zolotarov struct bnx2x_func_start_params {
1180619c5cb6SVlad Zolotarov 	/* Multi Function mode:
1181619c5cb6SVlad Zolotarov 	 *	- Single Function
1182619c5cb6SVlad Zolotarov 	 *	- Switch Dependent
1183619c5cb6SVlad Zolotarov 	 *	- Switch Independent
1184619c5cb6SVlad Zolotarov 	 */
1185619c5cb6SVlad Zolotarov 	u16 mf_mode;
1186619c5cb6SVlad Zolotarov 
1187619c5cb6SVlad Zolotarov 	/* Switch Dependent mode outer VLAN tag */
1188619c5cb6SVlad Zolotarov 	u16 sd_vlan_tag;
1189619c5cb6SVlad Zolotarov 
1190619c5cb6SVlad Zolotarov 	/* Function cos mode */
1191619c5cb6SVlad Zolotarov 	u8 network_cos_mode;
11921bc277f7SDmitry Kravkov 
119328311f8eSYuval Mintz 	/* UDP dest port for VXLAN */
119428311f8eSYuval Mintz 	u16 vxlan_dst_port;
11951bc277f7SDmitry Kravkov 
119628311f8eSYuval Mintz 	/* UDP dest port for Geneve */
119728311f8eSYuval Mintz 	u16 geneve_dst_port;
11981bc277f7SDmitry Kravkov 
119928311f8eSYuval Mintz 	/* Enable inner Rx classifications for L2GRE packets */
120028311f8eSYuval Mintz 	u8 inner_clss_l2gre;
1201e42780b6SDmitry Kravkov 
120228311f8eSYuval Mintz 	/* Enable inner Rx classifications for L2-Geneve packets */
120328311f8eSYuval Mintz 	u8 inner_clss_l2geneve;
120428311f8eSYuval Mintz 
120528311f8eSYuval Mintz 	/* Enable inner Rx classification for vxlan packets */
120628311f8eSYuval Mintz 	u8 inner_clss_vxlan;
120728311f8eSYuval Mintz 
120828311f8eSYuval Mintz 	/* Enable RSS according to inner header */
120928311f8eSYuval Mintz 	u8 inner_rss;
12107609647eSYuval Mintz 
12117609647eSYuval Mintz 	/* Allows accepting of packets failing MF classification, possibly
12127609647eSYuval Mintz 	 * only matching a given ethertype
12137609647eSYuval Mintz 	 */
12147609647eSYuval Mintz 	u8 class_fail;
12157609647eSYuval Mintz 	u16 class_fail_ethtype;
12167609647eSYuval Mintz 
12177609647eSYuval Mintz 	/* Override priority of output packets */
12187609647eSYuval Mintz 	u8 sd_vlan_force_pri;
12197609647eSYuval Mintz 	u8 sd_vlan_force_pri_val;
12207609647eSYuval Mintz 
12217609647eSYuval Mintz 	/* Replace vlan's ethertype */
12227609647eSYuval Mintz 	u16 sd_vlan_eth_type;
12237609647eSYuval Mintz 
12247609647eSYuval Mintz 	/* Prevent inner vlans from being added by FW */
12257609647eSYuval Mintz 	u8 no_added_tags;
122628311f8eSYuval Mintz 
122728311f8eSYuval Mintz 	/* Inner-to-Outer vlan priority mapping */
122828311f8eSYuval Mintz 	u8 c2s_pri[MAX_VLAN_PRIORITIES];
122928311f8eSYuval Mintz 	u8 c2s_pri_default;
123028311f8eSYuval Mintz 	u8 c2s_pri_valid;
1231619c5cb6SVlad Zolotarov };
1232619c5cb6SVlad Zolotarov 
123355c11941SMerav Sicron struct bnx2x_func_switch_update_params {
1234e42780b6SDmitry Kravkov 	unsigned long changes; /* BNX2X_F_UPDATE_XX bits */
12357609647eSYuval Mintz 	u16 vlan;
12367609647eSYuval Mintz 	u16 vlan_eth_type;
12377609647eSYuval Mintz 	u8 vlan_force_prio;
123828311f8eSYuval Mintz 	u16 vxlan_dst_port;
123928311f8eSYuval Mintz 	u16 geneve_dst_port;
124055c11941SMerav Sicron };
124155c11941SMerav Sicron 
1242a3348722SBarak Witkowski struct bnx2x_func_afex_update_params {
1243a3348722SBarak Witkowski 	u16 vif_id;
1244a3348722SBarak Witkowski 	u16 afex_default_vlan;
1245a3348722SBarak Witkowski 	u8 allowed_priorities;
1246a3348722SBarak Witkowski };
1247a3348722SBarak Witkowski 
1248a3348722SBarak Witkowski struct bnx2x_func_afex_viflists_params {
1249a3348722SBarak Witkowski 	u16 vif_list_index;
1250a3348722SBarak Witkowski 	u8 func_bit_map;
1251a3348722SBarak Witkowski 	u8 afex_vif_list_command;
1252a3348722SBarak Witkowski 	u8 func_to_clear;
1253a3348722SBarak Witkowski };
1254eeed018cSMichal Kalderon 
12556debea87SDmitry Kravkov struct bnx2x_func_tx_start_params {
12566debea87SDmitry Kravkov 	struct priority_cos traffic_type_to_priority_cos[MAX_TRAFFIC_TYPES];
12576debea87SDmitry Kravkov 	u8 dcb_enabled;
12586debea87SDmitry Kravkov 	u8 dcb_version;
12596debea87SDmitry Kravkov 	u8 dont_add_pri_0_en;
126028311f8eSYuval Mintz 	u8 dcb_outer_pri[MAX_TRAFFIC_TYPES];
12616debea87SDmitry Kravkov };
12626debea87SDmitry Kravkov 
1263eeed018cSMichal Kalderon struct bnx2x_func_set_timesync_params {
1264eeed018cSMichal Kalderon 	/* Reset, set or keep the current drift value */
1265eeed018cSMichal Kalderon 	u8 drift_adjust_cmd;
1266eeed018cSMichal Kalderon 
1267eeed018cSMichal Kalderon 	/* Dec, inc or keep the current offset */
1268eeed018cSMichal Kalderon 	u8 offset_cmd;
1269eeed018cSMichal Kalderon 
1270eeed018cSMichal Kalderon 	/* Drift value direction */
1271eeed018cSMichal Kalderon 	u8 add_sub_drift_adjust_value;
1272eeed018cSMichal Kalderon 
1273eeed018cSMichal Kalderon 	/* Drift, period and offset values to be used according to the commands
1274eeed018cSMichal Kalderon 	 * above.
1275eeed018cSMichal Kalderon 	 */
1276eeed018cSMichal Kalderon 	u8 drift_adjust_value;
1277eeed018cSMichal Kalderon 	u32 drift_adjust_period;
1278eeed018cSMichal Kalderon 	u64 offset_delta;
1279eeed018cSMichal Kalderon };
1280eeed018cSMichal Kalderon 
1281619c5cb6SVlad Zolotarov struct bnx2x_func_state_params {
1282619c5cb6SVlad Zolotarov 	struct bnx2x_func_sp_obj *f_obj;
1283619c5cb6SVlad Zolotarov 
1284619c5cb6SVlad Zolotarov 	/* Current command */
1285619c5cb6SVlad Zolotarov 	enum bnx2x_func_cmd cmd;
1286619c5cb6SVlad Zolotarov 
1287619c5cb6SVlad Zolotarov 	/* may have RAMROD_COMP_WAIT set only */
1288619c5cb6SVlad Zolotarov 	unsigned long	ramrod_flags;
1289619c5cb6SVlad Zolotarov 
1290619c5cb6SVlad Zolotarov 	/* Params according to the current command */
1291619c5cb6SVlad Zolotarov 	union {
1292619c5cb6SVlad Zolotarov 		struct bnx2x_func_hw_init_params hw_init;
1293619c5cb6SVlad Zolotarov 		struct bnx2x_func_hw_reset_params hw_reset;
1294619c5cb6SVlad Zolotarov 		struct bnx2x_func_start_params start;
129555c11941SMerav Sicron 		struct bnx2x_func_switch_update_params switch_update;
1296a3348722SBarak Witkowski 		struct bnx2x_func_afex_update_params afex_update;
1297a3348722SBarak Witkowski 		struct bnx2x_func_afex_viflists_params afex_viflists;
12986debea87SDmitry Kravkov 		struct bnx2x_func_tx_start_params tx_start;
1299eeed018cSMichal Kalderon 		struct bnx2x_func_set_timesync_params set_timesync;
1300619c5cb6SVlad Zolotarov 	} params;
1301619c5cb6SVlad Zolotarov };
1302619c5cb6SVlad Zolotarov 
1303619c5cb6SVlad Zolotarov struct bnx2x_func_sp_drv_ops {
1304619c5cb6SVlad Zolotarov 	/* Init tool + runtime initialization:
1305619c5cb6SVlad Zolotarov 	 *      - Common Chip
1306619c5cb6SVlad Zolotarov 	 *      - Common (per Path)
1307619c5cb6SVlad Zolotarov 	 *      - Port
1308619c5cb6SVlad Zolotarov 	 *      - Function phases
1309619c5cb6SVlad Zolotarov 	 */
1310619c5cb6SVlad Zolotarov 	int (*init_hw_cmn_chip)(struct bnx2x *bp);
1311619c5cb6SVlad Zolotarov 	int (*init_hw_cmn)(struct bnx2x *bp);
1312619c5cb6SVlad Zolotarov 	int (*init_hw_port)(struct bnx2x *bp);
1313619c5cb6SVlad Zolotarov 	int (*init_hw_func)(struct bnx2x *bp);
1314619c5cb6SVlad Zolotarov 
1315619c5cb6SVlad Zolotarov 	/* Reset Function HW: Common, Port, Function phases. */
1316619c5cb6SVlad Zolotarov 	void (*reset_hw_cmn)(struct bnx2x *bp);
1317619c5cb6SVlad Zolotarov 	void (*reset_hw_port)(struct bnx2x *bp);
1318619c5cb6SVlad Zolotarov 	void (*reset_hw_func)(struct bnx2x *bp);
1319619c5cb6SVlad Zolotarov 
1320619c5cb6SVlad Zolotarov 	/* Init/Free GUNZIP resources */
1321619c5cb6SVlad Zolotarov 	int (*gunzip_init)(struct bnx2x *bp);
1322619c5cb6SVlad Zolotarov 	void (*gunzip_end)(struct bnx2x *bp);
1323619c5cb6SVlad Zolotarov 
1324619c5cb6SVlad Zolotarov 	/* Prepare/Release FW resources */
1325619c5cb6SVlad Zolotarov 	int (*init_fw)(struct bnx2x *bp);
1326619c5cb6SVlad Zolotarov 	void (*release_fw)(struct bnx2x *bp);
1327619c5cb6SVlad Zolotarov };
1328619c5cb6SVlad Zolotarov 
1329619c5cb6SVlad Zolotarov struct bnx2x_func_sp_obj {
1330619c5cb6SVlad Zolotarov 	enum bnx2x_func_state	state, next_state;
1331619c5cb6SVlad Zolotarov 
1332619c5cb6SVlad Zolotarov 	/* BNX2X_FUNC_CMD_XX bits. This object implements "one
1333619c5cb6SVlad Zolotarov 	 * pending" paradigm but for debug and tracing purposes it's
133416a5fd92SYuval Mintz 	 * more convenient to have different bits for different
1335619c5cb6SVlad Zolotarov 	 * commands.
1336619c5cb6SVlad Zolotarov 	 */
1337619c5cb6SVlad Zolotarov 	unsigned long		pending;
1338619c5cb6SVlad Zolotarov 
1339619c5cb6SVlad Zolotarov 	/* Buffer to use as a ramrod data and its mapping */
1340619c5cb6SVlad Zolotarov 	void			*rdata;
1341619c5cb6SVlad Zolotarov 	dma_addr_t		rdata_mapping;
1342619c5cb6SVlad Zolotarov 
1343a3348722SBarak Witkowski 	/* Buffer to use as a afex ramrod data and its mapping.
1344a3348722SBarak Witkowski 	 * This can't be same rdata as above because afex ramrod requests
1345a3348722SBarak Witkowski 	 * can arrive to the object in parallel to other ramrod requests.
1346a3348722SBarak Witkowski 	 */
1347a3348722SBarak Witkowski 	void			*afex_rdata;
1348a3348722SBarak Witkowski 	dma_addr_t		afex_rdata_mapping;
1349a3348722SBarak Witkowski 
1350619c5cb6SVlad Zolotarov 	/* this mutex validates that when pending flag is taken, the next
1351619c5cb6SVlad Zolotarov 	 * ramrod to be sent will be the one set the pending bit
1352619c5cb6SVlad Zolotarov 	 */
1353619c5cb6SVlad Zolotarov 	struct mutex		one_pending_mutex;
1354619c5cb6SVlad Zolotarov 
1355619c5cb6SVlad Zolotarov 	/* Driver interface */
1356619c5cb6SVlad Zolotarov 	struct bnx2x_func_sp_drv_ops	*drv;
1357619c5cb6SVlad Zolotarov 
1358619c5cb6SVlad Zolotarov 	/**
1359619c5cb6SVlad Zolotarov 	 * Performs one state change according to the given parameters.
1360619c5cb6SVlad Zolotarov 	 *
1361619c5cb6SVlad Zolotarov 	 * @return 0 in case of success and negative value otherwise.
1362619c5cb6SVlad Zolotarov 	 */
1363619c5cb6SVlad Zolotarov 	int (*send_cmd)(struct bnx2x *bp,
1364619c5cb6SVlad Zolotarov 			struct bnx2x_func_state_params *params);
1365619c5cb6SVlad Zolotarov 
1366619c5cb6SVlad Zolotarov 	/**
1367619c5cb6SVlad Zolotarov 	 * Checks that the requested state transition is legal.
1368619c5cb6SVlad Zolotarov 	 */
1369619c5cb6SVlad Zolotarov 	int (*check_transition)(struct bnx2x *bp,
1370619c5cb6SVlad Zolotarov 				struct bnx2x_func_sp_obj *o,
1371619c5cb6SVlad Zolotarov 				struct bnx2x_func_state_params *params);
1372619c5cb6SVlad Zolotarov 
1373619c5cb6SVlad Zolotarov 	/**
1374619c5cb6SVlad Zolotarov 	 * Completes the pending command.
1375619c5cb6SVlad Zolotarov 	 */
1376619c5cb6SVlad Zolotarov 	int (*complete_cmd)(struct bnx2x *bp,
1377619c5cb6SVlad Zolotarov 			    struct bnx2x_func_sp_obj *o,
1378619c5cb6SVlad Zolotarov 			    enum bnx2x_func_cmd cmd);
1379619c5cb6SVlad Zolotarov 
1380619c5cb6SVlad Zolotarov 	int (*wait_comp)(struct bnx2x *bp, struct bnx2x_func_sp_obj *o,
1381619c5cb6SVlad Zolotarov 			 enum bnx2x_func_cmd cmd);
1382619c5cb6SVlad Zolotarov };
1383619c5cb6SVlad Zolotarov 
1384619c5cb6SVlad Zolotarov /********************** Interfaces ********************************************/
1385619c5cb6SVlad Zolotarov /* Queueable objects set */
1386619c5cb6SVlad Zolotarov union bnx2x_qable_obj {
1387619c5cb6SVlad Zolotarov 	struct bnx2x_vlan_mac_obj vlan_mac;
1388619c5cb6SVlad Zolotarov };
1389619c5cb6SVlad Zolotarov /************** Function state update *********/
1390619c5cb6SVlad Zolotarov void bnx2x_init_func_obj(struct bnx2x *bp,
1391619c5cb6SVlad Zolotarov 			 struct bnx2x_func_sp_obj *obj,
1392619c5cb6SVlad Zolotarov 			 void *rdata, dma_addr_t rdata_mapping,
1393a3348722SBarak Witkowski 			 void *afex_rdata, dma_addr_t afex_rdata_mapping,
1394619c5cb6SVlad Zolotarov 			 struct bnx2x_func_sp_drv_ops *drv_iface);
1395619c5cb6SVlad Zolotarov 
1396619c5cb6SVlad Zolotarov int bnx2x_func_state_change(struct bnx2x *bp,
1397619c5cb6SVlad Zolotarov 			    struct bnx2x_func_state_params *params);
1398619c5cb6SVlad Zolotarov 
13996debea87SDmitry Kravkov enum bnx2x_func_state bnx2x_func_get_state(struct bnx2x *bp,
14006debea87SDmitry Kravkov 					   struct bnx2x_func_sp_obj *o);
1401619c5cb6SVlad Zolotarov /******************* Queue State **************/
1402619c5cb6SVlad Zolotarov void bnx2x_init_queue_obj(struct bnx2x *bp,
14036383c0b3SAriel Elior 			  struct bnx2x_queue_sp_obj *obj, u8 cl_id, u32 *cids,
14046383c0b3SAriel Elior 			  u8 cid_cnt, u8 func_id, void *rdata,
14056383c0b3SAriel Elior 			  dma_addr_t rdata_mapping, unsigned long type);
1406619c5cb6SVlad Zolotarov 
1407619c5cb6SVlad Zolotarov int bnx2x_queue_state_change(struct bnx2x *bp,
1408619c5cb6SVlad Zolotarov 			     struct bnx2x_queue_state_params *params);
1409619c5cb6SVlad Zolotarov 
141067c431a5SAriel Elior int bnx2x_get_q_logical_state(struct bnx2x *bp,
141167c431a5SAriel Elior 			       struct bnx2x_queue_sp_obj *obj);
141267c431a5SAriel Elior 
1413619c5cb6SVlad Zolotarov /********************* VLAN-MAC ****************/
1414619c5cb6SVlad Zolotarov void bnx2x_init_mac_obj(struct bnx2x *bp,
1415619c5cb6SVlad Zolotarov 			struct bnx2x_vlan_mac_obj *mac_obj,
1416619c5cb6SVlad Zolotarov 			u8 cl_id, u32 cid, u8 func_id, void *rdata,
1417619c5cb6SVlad Zolotarov 			dma_addr_t rdata_mapping, int state,
1418619c5cb6SVlad Zolotarov 			unsigned long *pstate, bnx2x_obj_type type,
1419619c5cb6SVlad Zolotarov 			struct bnx2x_credit_pool_obj *macs_pool);
1420619c5cb6SVlad Zolotarov 
1421619c5cb6SVlad Zolotarov void bnx2x_init_vlan_obj(struct bnx2x *bp,
1422619c5cb6SVlad Zolotarov 			 struct bnx2x_vlan_mac_obj *vlan_obj,
1423619c5cb6SVlad Zolotarov 			 u8 cl_id, u32 cid, u8 func_id, void *rdata,
1424619c5cb6SVlad Zolotarov 			 dma_addr_t rdata_mapping, int state,
1425619c5cb6SVlad Zolotarov 			 unsigned long *pstate, bnx2x_obj_type type,
1426619c5cb6SVlad Zolotarov 			 struct bnx2x_credit_pool_obj *vlans_pool);
1427619c5cb6SVlad Zolotarov 
142805cc5a39SYuval Mintz void bnx2x_init_vlan_mac_obj(struct bnx2x *bp,
142905cc5a39SYuval Mintz 			     struct bnx2x_vlan_mac_obj *vlan_mac_obj,
143005cc5a39SYuval Mintz 			     u8 cl_id, u32 cid, u8 func_id, void *rdata,
143105cc5a39SYuval Mintz 			     dma_addr_t rdata_mapping, int state,
143205cc5a39SYuval Mintz 			     unsigned long *pstate, bnx2x_obj_type type,
143305cc5a39SYuval Mintz 			     struct bnx2x_credit_pool_obj *macs_pool,
143405cc5a39SYuval Mintz 			     struct bnx2x_credit_pool_obj *vlans_pool);
143505cc5a39SYuval Mintz 
14368b09be5fSYuval Mintz int bnx2x_vlan_mac_h_read_lock(struct bnx2x *bp,
14378b09be5fSYuval Mintz 					struct bnx2x_vlan_mac_obj *o);
14388b09be5fSYuval Mintz void bnx2x_vlan_mac_h_read_unlock(struct bnx2x *bp,
14398b09be5fSYuval Mintz 				  struct bnx2x_vlan_mac_obj *o);
14408b09be5fSYuval Mintz int bnx2x_vlan_mac_h_write_lock(struct bnx2x *bp,
14418b09be5fSYuval Mintz 				struct bnx2x_vlan_mac_obj *o);
1442619c5cb6SVlad Zolotarov int bnx2x_config_vlan_mac(struct bnx2x *bp,
1443619c5cb6SVlad Zolotarov 			   struct bnx2x_vlan_mac_ramrod_params *p);
1444619c5cb6SVlad Zolotarov 
1445619c5cb6SVlad Zolotarov int bnx2x_vlan_mac_move(struct bnx2x *bp,
1446619c5cb6SVlad Zolotarov 			struct bnx2x_vlan_mac_ramrod_params *p,
1447619c5cb6SVlad Zolotarov 			struct bnx2x_vlan_mac_obj *dest_o);
1448619c5cb6SVlad Zolotarov 
1449619c5cb6SVlad Zolotarov /********************* RX MODE ****************/
1450619c5cb6SVlad Zolotarov 
1451619c5cb6SVlad Zolotarov void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
1452619c5cb6SVlad Zolotarov 			    struct bnx2x_rx_mode_obj *o);
1453619c5cb6SVlad Zolotarov 
1454619c5cb6SVlad Zolotarov /**
14551aa8b471SBen Hutchings  * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
1456619c5cb6SVlad Zolotarov  *
14571aa8b471SBen Hutchings  * @p: Command parameters
1458619c5cb6SVlad Zolotarov  *
145916a5fd92SYuval Mintz  * Return: 0 - if operation was successful and there is no pending completions,
1460619c5cb6SVlad Zolotarov  *         positive number - if there are pending completions,
1461619c5cb6SVlad Zolotarov  *         negative - if there were errors
1462619c5cb6SVlad Zolotarov  */
1463619c5cb6SVlad Zolotarov int bnx2x_config_rx_mode(struct bnx2x *bp,
1464619c5cb6SVlad Zolotarov 			 struct bnx2x_rx_mode_ramrod_params *p);
1465619c5cb6SVlad Zolotarov 
1466619c5cb6SVlad Zolotarov /****************** MULTICASTS ****************/
1467619c5cb6SVlad Zolotarov 
1468619c5cb6SVlad Zolotarov void bnx2x_init_mcast_obj(struct bnx2x *bp,
1469619c5cb6SVlad Zolotarov 			  struct bnx2x_mcast_obj *mcast_obj,
1470619c5cb6SVlad Zolotarov 			  u8 mcast_cl_id, u32 mcast_cid, u8 func_id,
1471619c5cb6SVlad Zolotarov 			  u8 engine_id, void *rdata, dma_addr_t rdata_mapping,
1472619c5cb6SVlad Zolotarov 			  int state, unsigned long *pstate,
1473619c5cb6SVlad Zolotarov 			  bnx2x_obj_type type);
1474619c5cb6SVlad Zolotarov 
1475619c5cb6SVlad Zolotarov /**
14761aa8b471SBen Hutchings  * bnx2x_config_mcast - Configure multicast MACs list.
14771aa8b471SBen Hutchings  *
14781aa8b471SBen Hutchings  * @cmd: command to execute: BNX2X_MCAST_CMD_X
14791aa8b471SBen Hutchings  *
14801aa8b471SBen Hutchings  * May configure a new list
1481619c5cb6SVlad Zolotarov  * provided in p->mcast_list (BNX2X_MCAST_CMD_ADD), clean up
1482619c5cb6SVlad Zolotarov  * (BNX2X_MCAST_CMD_DEL) or restore (BNX2X_MCAST_CMD_RESTORE) a current
1483619c5cb6SVlad Zolotarov  * configuration, continue to execute the pending commands
1484619c5cb6SVlad Zolotarov  * (BNX2X_MCAST_CMD_CONT).
1485619c5cb6SVlad Zolotarov  *
1486619c5cb6SVlad Zolotarov  * If previous command is still pending or if number of MACs to
1487619c5cb6SVlad Zolotarov  * configure is more that maximum number of MACs in one command,
1488619c5cb6SVlad Zolotarov  * the current command will be enqueued to the tail of the
1489619c5cb6SVlad Zolotarov  * pending commands list.
1490619c5cb6SVlad Zolotarov  *
149116a5fd92SYuval Mintz  * Return: 0 is operation was successful and there are no pending completions,
1492619c5cb6SVlad Zolotarov  *         negative if there were errors, positive if there are pending
1493619c5cb6SVlad Zolotarov  *         completions.
1494619c5cb6SVlad Zolotarov  */
1495619c5cb6SVlad Zolotarov int bnx2x_config_mcast(struct bnx2x *bp,
149686564c3fSYuval Mintz 		       struct bnx2x_mcast_ramrod_params *p,
149786564c3fSYuval Mintz 		       enum bnx2x_mcast_cmd cmd);
1498619c5cb6SVlad Zolotarov 
1499619c5cb6SVlad Zolotarov /****************** CREDIT POOL ****************/
1500619c5cb6SVlad Zolotarov void bnx2x_init_mac_credit_pool(struct bnx2x *bp,
1501619c5cb6SVlad Zolotarov 				struct bnx2x_credit_pool_obj *p, u8 func_id,
1502619c5cb6SVlad Zolotarov 				u8 func_num);
1503619c5cb6SVlad Zolotarov void bnx2x_init_vlan_credit_pool(struct bnx2x *bp,
1504619c5cb6SVlad Zolotarov 				 struct bnx2x_credit_pool_obj *p, u8 func_id,
1505619c5cb6SVlad Zolotarov 				 u8 func_num);
150605cc5a39SYuval Mintz void bnx2x_init_credit_pool(struct bnx2x_credit_pool_obj *p,
150705cc5a39SYuval Mintz 			    int base, int credit);
1508619c5cb6SVlad Zolotarov 
1509619c5cb6SVlad Zolotarov /****************** RSS CONFIGURATION ****************/
1510619c5cb6SVlad Zolotarov void bnx2x_init_rss_config_obj(struct bnx2x *bp,
1511619c5cb6SVlad Zolotarov 			       struct bnx2x_rss_config_obj *rss_obj,
1512619c5cb6SVlad Zolotarov 			       u8 cl_id, u32 cid, u8 func_id, u8 engine_id,
1513619c5cb6SVlad Zolotarov 			       void *rdata, dma_addr_t rdata_mapping,
1514619c5cb6SVlad Zolotarov 			       int state, unsigned long *pstate,
1515619c5cb6SVlad Zolotarov 			       bnx2x_obj_type type);
1516619c5cb6SVlad Zolotarov 
1517619c5cb6SVlad Zolotarov /**
15181aa8b471SBen Hutchings  * bnx2x_config_rss - Updates RSS configuration according to provided parameters
1519619c5cb6SVlad Zolotarov  *
15201aa8b471SBen Hutchings  * Return: 0 in case of success
1521619c5cb6SVlad Zolotarov  */
1522619c5cb6SVlad Zolotarov int bnx2x_config_rss(struct bnx2x *bp,
1523619c5cb6SVlad Zolotarov 		     struct bnx2x_config_rss_params *p);
1524619c5cb6SVlad Zolotarov 
1525619c5cb6SVlad Zolotarov /**
15261aa8b471SBen Hutchings  * bnx2x_get_rss_ind_table - Return the current ind_table configuration.
1527619c5cb6SVlad Zolotarov  *
15281aa8b471SBen Hutchings  * @ind_table: buffer to fill with the current indirection
1529619c5cb6SVlad Zolotarov  *                  table content. Should be at least
1530619c5cb6SVlad Zolotarov  *                  T_ETH_INDIRECTION_TABLE_SIZE bytes long.
1531619c5cb6SVlad Zolotarov  */
1532619c5cb6SVlad Zolotarov void bnx2x_get_rss_ind_table(struct bnx2x_rss_config_obj *rss_obj,
1533619c5cb6SVlad Zolotarov 			     u8 *ind_table);
1534619c5cb6SVlad Zolotarov 
153505cc5a39SYuval Mintz #define PF_MAC_CREDIT_E2(bp, func_num)					\
153605cc5a39SYuval Mintz 	((MAX_MAC_CREDIT_E2 - GET_NUM_VFS_PER_PATH(bp) * VF_MAC_CREDIT_CNT) / \
153705cc5a39SYuval Mintz 	 func_num + GET_NUM_VFS_PER_PF(bp) * VF_MAC_CREDIT_CNT)
153805cc5a39SYuval Mintz 
15395cdc40c7SManish Chopra #define BNX2X_VFS_VLAN_CREDIT(bp)	\
15405cdc40c7SManish Chopra 	(GET_NUM_VFS_PER_PATH(bp) * VF_VLAN_CREDIT_CNT)
15415cdc40c7SManish Chopra 
154205cc5a39SYuval Mintz #define PF_VLAN_CREDIT_E2(bp, func_num)					 \
15435cdc40c7SManish Chopra 	((MAX_VLAN_CREDIT_E2 - 1 - BNX2X_VFS_VLAN_CREDIT(bp)) /	\
154405cc5a39SYuval Mintz 	 func_num + GET_NUM_VFS_PER_PF(bp) * VF_VLAN_CREDIT_CNT)
154505cc5a39SYuval Mintz 
1546619c5cb6SVlad Zolotarov #endif /* BNX2X_SP_VERBS */
1547