12e0bf125SRasesh Mody /* cnic_if.h: QLogic cnic core network driver.
2adfc5217SJeff Kirsher  *
3c3661283SMichael Chan  * Copyright (c) 2006-2014 Broadcom Corporation
42e0bf125SRasesh Mody  * Copyright (c) 2014-2015 QLogic Corporation
5adfc5217SJeff Kirsher  *
6adfc5217SJeff Kirsher  * This program is free software; you can redistribute it and/or modify
7adfc5217SJeff Kirsher  * it under the terms of the GNU General Public License as published by
8adfc5217SJeff Kirsher  * the Free Software Foundation.
9adfc5217SJeff Kirsher  *
10adfc5217SJeff Kirsher  */
11adfc5217SJeff Kirsher 
12adfc5217SJeff Kirsher 
13adfc5217SJeff Kirsher #ifndef CNIC_IF_H
14adfc5217SJeff Kirsher #define CNIC_IF_H
15adfc5217SJeff Kirsher 
162e499d3cSBarak Witkowski #include "bnx2x/bnx2x_mfw_req.h"
172e499d3cSBarak Witkowski 
189b8d5044SAdheer Chandravanshi #define CNIC_MODULE_VERSION	"2.5.22"
199b8d5044SAdheer Chandravanshi #define CNIC_MODULE_RELDATE	"July 20, 2015"
20adfc5217SJeff Kirsher 
21adfc5217SJeff Kirsher #define CNIC_ULP_RDMA		0
22adfc5217SJeff Kirsher #define CNIC_ULP_ISCSI		1
23adfc5217SJeff Kirsher #define CNIC_ULP_FCOE		2
24adfc5217SJeff Kirsher #define CNIC_ULP_L4		3
25adfc5217SJeff Kirsher #define MAX_CNIC_ULP_TYPE_EXT	3
26adfc5217SJeff Kirsher #define MAX_CNIC_ULP_TYPE	4
27adfc5217SJeff Kirsher 
28be1fefc2SMichael Chan /* Use CPU native page size up to 16K for cnic ring sizes.  */
29be1fefc2SMichael Chan #if (PAGE_SHIFT > 14)
30be1fefc2SMichael Chan #define CNIC_PAGE_BITS	14
31be1fefc2SMichael Chan #else
32be1fefc2SMichael Chan #define CNIC_PAGE_BITS	PAGE_SHIFT
33be1fefc2SMichael Chan #endif
34be1fefc2SMichael Chan #define CNIC_PAGE_SIZE	(1 << (CNIC_PAGE_BITS))
35be1fefc2SMichael Chan #define CNIC_PAGE_ALIGN(addr) ALIGN(addr, CNIC_PAGE_SIZE)
36be1fefc2SMichael Chan #define CNIC_PAGE_MASK	(~((CNIC_PAGE_SIZE) - 1))
37be1fefc2SMichael Chan 
38adfc5217SJeff Kirsher struct kwqe {
39adfc5217SJeff Kirsher 	u32 kwqe_op_flag;
40adfc5217SJeff Kirsher 
41adfc5217SJeff Kirsher #define KWQE_QID_SHIFT		8
42adfc5217SJeff Kirsher #define KWQE_OPCODE_MASK	0x00ff0000
43adfc5217SJeff Kirsher #define KWQE_OPCODE_SHIFT	16
44adfc5217SJeff Kirsher #define KWQE_OPCODE(x)		((x & KWQE_OPCODE_MASK) >> KWQE_OPCODE_SHIFT)
45adfc5217SJeff Kirsher #define KWQE_LAYER_MASK			0x70000000
46adfc5217SJeff Kirsher #define KWQE_LAYER_SHIFT		28
47adfc5217SJeff Kirsher #define KWQE_FLAGS_LAYER_MASK_L2	(2<<28)
48adfc5217SJeff Kirsher #define KWQE_FLAGS_LAYER_MASK_L3	(3<<28)
49adfc5217SJeff Kirsher #define KWQE_FLAGS_LAYER_MASK_L4	(4<<28)
50adfc5217SJeff Kirsher #define KWQE_FLAGS_LAYER_MASK_L5_RDMA	(5<<28)
51adfc5217SJeff Kirsher #define KWQE_FLAGS_LAYER_MASK_L5_ISCSI	(6<<28)
52adfc5217SJeff Kirsher #define KWQE_FLAGS_LAYER_MASK_L5_FCOE	(7<<28)
53adfc5217SJeff Kirsher 
54adfc5217SJeff Kirsher 	u32 kwqe_info0;
55adfc5217SJeff Kirsher 	u32 kwqe_info1;
56adfc5217SJeff Kirsher 	u32 kwqe_info2;
57adfc5217SJeff Kirsher 	u32 kwqe_info3;
58adfc5217SJeff Kirsher 	u32 kwqe_info4;
59adfc5217SJeff Kirsher 	u32 kwqe_info5;
60adfc5217SJeff Kirsher 	u32 kwqe_info6;
61adfc5217SJeff Kirsher };
62adfc5217SJeff Kirsher 
63adfc5217SJeff Kirsher struct kwqe_16 {
64adfc5217SJeff Kirsher 	u32 kwqe_info0;
65adfc5217SJeff Kirsher 	u32 kwqe_info1;
66adfc5217SJeff Kirsher 	u32 kwqe_info2;
67adfc5217SJeff Kirsher 	u32 kwqe_info3;
68adfc5217SJeff Kirsher };
69adfc5217SJeff Kirsher 
70adfc5217SJeff Kirsher struct kcqe {
71adfc5217SJeff Kirsher 	u32 kcqe_info0;
72adfc5217SJeff Kirsher 	u32 kcqe_info1;
73adfc5217SJeff Kirsher 	u32 kcqe_info2;
74adfc5217SJeff Kirsher 	u32 kcqe_info3;
75adfc5217SJeff Kirsher 	u32 kcqe_info4;
76adfc5217SJeff Kirsher 	u32 kcqe_info5;
77adfc5217SJeff Kirsher 	u32 kcqe_info6;
78adfc5217SJeff Kirsher 	u32 kcqe_op_flag;
79adfc5217SJeff Kirsher 		#define KCQE_RAMROD_COMPLETION		(0x1<<27) /* Everest */
80adfc5217SJeff Kirsher 		#define KCQE_FLAGS_LAYER_MASK		(0x7<<28)
81adfc5217SJeff Kirsher 		#define KCQE_FLAGS_LAYER_MASK_MISC	(0<<28)
82adfc5217SJeff Kirsher 		#define KCQE_FLAGS_LAYER_MASK_L2	(2<<28)
83adfc5217SJeff Kirsher 		#define KCQE_FLAGS_LAYER_MASK_L3	(3<<28)
84adfc5217SJeff Kirsher 		#define KCQE_FLAGS_LAYER_MASK_L4	(4<<28)
85adfc5217SJeff Kirsher 		#define KCQE_FLAGS_LAYER_MASK_L5_RDMA	(5<<28)
86adfc5217SJeff Kirsher 		#define KCQE_FLAGS_LAYER_MASK_L5_ISCSI	(6<<28)
87adfc5217SJeff Kirsher 		#define KCQE_FLAGS_LAYER_MASK_L5_FCOE	(7<<28)
88adfc5217SJeff Kirsher 		#define KCQE_FLAGS_NEXT 		(1<<31)
89adfc5217SJeff Kirsher 		#define KCQE_FLAGS_OPCODE_MASK		(0xff<<16)
90adfc5217SJeff Kirsher 		#define KCQE_FLAGS_OPCODE_SHIFT		(16)
91adfc5217SJeff Kirsher 		#define KCQE_OPCODE(op)			\
92adfc5217SJeff Kirsher 		(((op) & KCQE_FLAGS_OPCODE_MASK) >> KCQE_FLAGS_OPCODE_SHIFT)
93adfc5217SJeff Kirsher };
94adfc5217SJeff Kirsher 
95adfc5217SJeff Kirsher #define MAX_CNIC_CTL_DATA	64
96adfc5217SJeff Kirsher #define MAX_DRV_CTL_DATA	64
97adfc5217SJeff Kirsher 
98adfc5217SJeff Kirsher #define CNIC_CTL_STOP_CMD		1
99adfc5217SJeff Kirsher #define CNIC_CTL_START_CMD		2
100adfc5217SJeff Kirsher #define CNIC_CTL_COMPLETION_CMD		3
101adfc5217SJeff Kirsher #define CNIC_CTL_STOP_ISCSI_CMD		4
1021d187b34SBarak Witkowski #define CNIC_CTL_FCOE_STATS_GET_CMD	5
1031d187b34SBarak Witkowski #define CNIC_CTL_ISCSI_STATS_GET_CMD	6
104adfc5217SJeff Kirsher 
105adfc5217SJeff Kirsher #define DRV_CTL_IO_WR_CMD		0x101
106adfc5217SJeff Kirsher #define DRV_CTL_IO_RD_CMD		0x102
107adfc5217SJeff Kirsher #define DRV_CTL_CTX_WR_CMD		0x103
108adfc5217SJeff Kirsher #define DRV_CTL_CTXTBL_WR_CMD		0x104
109adfc5217SJeff Kirsher #define DRV_CTL_RET_L5_SPQ_CREDIT_CMD	0x105
110adfc5217SJeff Kirsher #define DRV_CTL_START_L2_CMD		0x106
111adfc5217SJeff Kirsher #define DRV_CTL_STOP_L2_CMD		0x107
112adfc5217SJeff Kirsher #define DRV_CTL_RET_L2_SPQ_CREDIT_CMD	0x10c
113adfc5217SJeff Kirsher #define DRV_CTL_ISCSI_STOPPED_CMD	0x10d
1141d187b34SBarak Witkowski #define DRV_CTL_ULP_REGISTER_CMD	0x10e
1151d187b34SBarak Witkowski #define DRV_CTL_ULP_UNREGISTER_CMD	0x10f
116adfc5217SJeff Kirsher 
117adfc5217SJeff Kirsher struct cnic_ctl_completion {
118adfc5217SJeff Kirsher 	u32	cid;
119adfc5217SJeff Kirsher 	u8	opcode;
120adfc5217SJeff Kirsher 	u8	error;
121adfc5217SJeff Kirsher };
122adfc5217SJeff Kirsher 
123adfc5217SJeff Kirsher struct cnic_ctl_info {
124adfc5217SJeff Kirsher 	int	cmd;
125adfc5217SJeff Kirsher 	union {
126adfc5217SJeff Kirsher 		struct cnic_ctl_completion comp;
127adfc5217SJeff Kirsher 		char bytes[MAX_CNIC_CTL_DATA];
128adfc5217SJeff Kirsher 	} data;
129adfc5217SJeff Kirsher };
130adfc5217SJeff Kirsher 
131adfc5217SJeff Kirsher struct drv_ctl_spq_credit {
132adfc5217SJeff Kirsher 	u32	credit_count;
133adfc5217SJeff Kirsher };
134adfc5217SJeff Kirsher 
135adfc5217SJeff Kirsher struct drv_ctl_io {
136adfc5217SJeff Kirsher 	u32		cid_addr;
137adfc5217SJeff Kirsher 	u32		offset;
138adfc5217SJeff Kirsher 	u32		data;
139adfc5217SJeff Kirsher 	dma_addr_t	dma_addr;
140adfc5217SJeff Kirsher };
141adfc5217SJeff Kirsher 
142adfc5217SJeff Kirsher struct drv_ctl_l2_ring {
143adfc5217SJeff Kirsher 	u32		client_id;
144adfc5217SJeff Kirsher 	u32		cid;
145adfc5217SJeff Kirsher };
146adfc5217SJeff Kirsher 
1472e499d3cSBarak Witkowski struct drv_ctl_register_data {
1482e499d3cSBarak Witkowski 	int ulp_type;
1492e499d3cSBarak Witkowski 	struct fcoe_capabilities fcoe_features;
1502e499d3cSBarak Witkowski };
1512e499d3cSBarak Witkowski 
152adfc5217SJeff Kirsher struct drv_ctl_info {
153adfc5217SJeff Kirsher 	int	cmd;
154eddb7554STej Parkash 	int     drv_state;
155eddb7554STej Parkash #define DRV_NOP		0
156eddb7554STej Parkash #define DRV_ACTIVE	1
157eddb7554STej Parkash #define DRV_INACTIVE	2
158eddb7554STej Parkash #define DRV_UNLOADED	3
159adfc5217SJeff Kirsher 	union {
160adfc5217SJeff Kirsher 		struct drv_ctl_spq_credit credit;
161adfc5217SJeff Kirsher 		struct drv_ctl_io io;
162adfc5217SJeff Kirsher 		struct drv_ctl_l2_ring ring;
1631d187b34SBarak Witkowski 		int ulp_type;
1642e499d3cSBarak Witkowski 		struct drv_ctl_register_data register_data;
165adfc5217SJeff Kirsher 		char bytes[MAX_DRV_CTL_DATA];
166adfc5217SJeff Kirsher 	} data;
167adfc5217SJeff Kirsher };
168adfc5217SJeff Kirsher 
1699b8d5044SAdheer Chandravanshi #define MAX_NPIV_ENTRIES 64
1709b8d5044SAdheer Chandravanshi #define FC_NPIV_WWN_SIZE 8
1719b8d5044SAdheer Chandravanshi 
1729b8d5044SAdheer Chandravanshi struct cnic_fc_npiv_tbl {
1739b8d5044SAdheer Chandravanshi 	u8 wwpn[MAX_NPIV_ENTRIES][FC_NPIV_WWN_SIZE];
1749b8d5044SAdheer Chandravanshi 	u8 wwnn[MAX_NPIV_ENTRIES][FC_NPIV_WWN_SIZE];
1759b8d5044SAdheer Chandravanshi 	u32 count;
1769b8d5044SAdheer Chandravanshi };
1779b8d5044SAdheer Chandravanshi 
178adfc5217SJeff Kirsher struct cnic_ops {
179adfc5217SJeff Kirsher 	struct module	*cnic_owner;
180adfc5217SJeff Kirsher 	/* Calls to these functions are protected by RCU.  When
181adfc5217SJeff Kirsher 	 * unregistering, we wait for any calls to complete before
182adfc5217SJeff Kirsher 	 * continuing.
183adfc5217SJeff Kirsher 	 */
184adfc5217SJeff Kirsher 	int		(*cnic_handler)(void *, void *);
185adfc5217SJeff Kirsher 	int		(*cnic_ctl)(void *, struct cnic_ctl_info *);
186adfc5217SJeff Kirsher };
187adfc5217SJeff Kirsher 
188adfc5217SJeff Kirsher #define MAX_CNIC_VEC	8
189adfc5217SJeff Kirsher 
190adfc5217SJeff Kirsher struct cnic_irq {
191adfc5217SJeff Kirsher 	unsigned int	vector;
192adfc5217SJeff Kirsher 	void		*status_blk;
193adfc5217SJeff Kirsher 	u32		status_blk_num;
194adfc5217SJeff Kirsher 	u32		status_blk_num2;
195adfc5217SJeff Kirsher 	u32		irq_flags;
196adfc5217SJeff Kirsher #define CNIC_IRQ_FL_MSIX		0x00000001
197adfc5217SJeff Kirsher };
198adfc5217SJeff Kirsher 
199adfc5217SJeff Kirsher struct cnic_eth_dev {
200adfc5217SJeff Kirsher 	struct module	*drv_owner;
201adfc5217SJeff Kirsher 	u32		drv_state;
202adfc5217SJeff Kirsher #define CNIC_DRV_STATE_REGD		0x00000001
203adfc5217SJeff Kirsher #define CNIC_DRV_STATE_USING_MSIX	0x00000002
204adfc5217SJeff Kirsher #define CNIC_DRV_STATE_NO_ISCSI_OOO	0x00000004
205adfc5217SJeff Kirsher #define CNIC_DRV_STATE_NO_ISCSI		0x00000008
206adfc5217SJeff Kirsher #define CNIC_DRV_STATE_NO_FCOE		0x00000010
207ad9b4359SMichael Chan #define CNIC_DRV_STATE_HANDLES_IRQ	0x00000020
208adfc5217SJeff Kirsher 	u32		chip_id;
209adfc5217SJeff Kirsher 	u32		max_kwqe_pending;
210adfc5217SJeff Kirsher 	struct pci_dev	*pdev;
211adfc5217SJeff Kirsher 	void __iomem	*io_base;
212adfc5217SJeff Kirsher 	void __iomem	*io_base2;
213adfc5217SJeff Kirsher 	const void	*iro_arr;
214adfc5217SJeff Kirsher 
215adfc5217SJeff Kirsher 	u32		ctx_tbl_offset;
216adfc5217SJeff Kirsher 	u32		ctx_tbl_len;
217adfc5217SJeff Kirsher 	int		ctx_blk_size;
218adfc5217SJeff Kirsher 	u32		starting_cid;
219adfc5217SJeff Kirsher 	u32		max_iscsi_conn;
220adfc5217SJeff Kirsher 	u32		max_fcoe_conn;
221adfc5217SJeff Kirsher 	u32		max_rdma_conn;
222adfc5217SJeff Kirsher 	u32		fcoe_init_cid;
2230eb43b4bSBhanu Prakash Gollapudi 	u32		max_fcoe_exchanges;
224adfc5217SJeff Kirsher 	u32		fcoe_wwn_port_name_hi;
225adfc5217SJeff Kirsher 	u32		fcoe_wwn_port_name_lo;
226adfc5217SJeff Kirsher 	u32		fcoe_wwn_node_name_hi;
227adfc5217SJeff Kirsher 	u32		fcoe_wwn_node_name_lo;
228adfc5217SJeff Kirsher 
229adfc5217SJeff Kirsher 	u16		iscsi_l2_client_id;
230adfc5217SJeff Kirsher 	u16		iscsi_l2_cid;
231adfc5217SJeff Kirsher 	u8		iscsi_mac[ETH_ALEN];
232adfc5217SJeff Kirsher 
233adfc5217SJeff Kirsher 	int		num_irq;
234adfc5217SJeff Kirsher 	struct cnic_irq	irq_arr[MAX_CNIC_VEC];
235adfc5217SJeff Kirsher 	int		(*drv_register_cnic)(struct net_device *,
236adfc5217SJeff Kirsher 					     struct cnic_ops *, void *);
237adfc5217SJeff Kirsher 	int		(*drv_unregister_cnic)(struct net_device *);
238adfc5217SJeff Kirsher 	int		(*drv_submit_kwqes_32)(struct net_device *,
239adfc5217SJeff Kirsher 					       struct kwqe *[], u32);
240adfc5217SJeff Kirsher 	int		(*drv_submit_kwqes_16)(struct net_device *,
241adfc5217SJeff Kirsher 					       struct kwqe_16 *[], u32);
242adfc5217SJeff Kirsher 	int		(*drv_ctl)(struct net_device *, struct drv_ctl_info *);
2439b8d5044SAdheer Chandravanshi 	int		(*drv_get_fc_npiv_tbl)(struct net_device *,
2449b8d5044SAdheer Chandravanshi 					       struct cnic_fc_npiv_tbl *);
245adfc5217SJeff Kirsher 	unsigned long	reserved1[2];
2461d187b34SBarak Witkowski 	union drv_info_to_mcp	*addr_drv_info_to_mcp;
247adfc5217SJeff Kirsher };
248adfc5217SJeff Kirsher 
249adfc5217SJeff Kirsher struct cnic_sockaddr {
250adfc5217SJeff Kirsher 	union {
251adfc5217SJeff Kirsher 		struct sockaddr_in	v4;
252adfc5217SJeff Kirsher 		struct sockaddr_in6	v6;
253adfc5217SJeff Kirsher 	} local;
254adfc5217SJeff Kirsher 	union {
255adfc5217SJeff Kirsher 		struct sockaddr_in	v4;
256adfc5217SJeff Kirsher 		struct sockaddr_in6	v6;
257adfc5217SJeff Kirsher 	} remote;
258adfc5217SJeff Kirsher };
259adfc5217SJeff Kirsher 
260adfc5217SJeff Kirsher struct cnic_sock {
261adfc5217SJeff Kirsher 	struct cnic_dev *dev;
262adfc5217SJeff Kirsher 	void	*context;
263adfc5217SJeff Kirsher 	u32	src_ip[4];
264adfc5217SJeff Kirsher 	u32	dst_ip[4];
265adfc5217SJeff Kirsher 	u16	src_port;
266adfc5217SJeff Kirsher 	u16	dst_port;
267adfc5217SJeff Kirsher 	u16	vlan_id;
2681409a932SJoe Perches 	unsigned char old_ha[ETH_ALEN];
2691409a932SJoe Perches 	unsigned char ha[ETH_ALEN];
270adfc5217SJeff Kirsher 	u32	mtu;
271adfc5217SJeff Kirsher 	u32	cid;
272adfc5217SJeff Kirsher 	u32	l5_cid;
273adfc5217SJeff Kirsher 	u32	pg_cid;
274adfc5217SJeff Kirsher 	int	ulp_type;
275adfc5217SJeff Kirsher 
276adfc5217SJeff Kirsher 	u32	ka_timeout;
277adfc5217SJeff Kirsher 	u32	ka_interval;
278adfc5217SJeff Kirsher 	u8	ka_max_probe_count;
279adfc5217SJeff Kirsher 	u8	tos;
280adfc5217SJeff Kirsher 	u8	ttl;
281adfc5217SJeff Kirsher 	u8	snd_seq_scale;
282adfc5217SJeff Kirsher 	u32	rcv_buf;
283adfc5217SJeff Kirsher 	u32	snd_buf;
284adfc5217SJeff Kirsher 	u32	seed;
285adfc5217SJeff Kirsher 
286adfc5217SJeff Kirsher 	unsigned long	tcp_flags;
287adfc5217SJeff Kirsher #define SK_TCP_NO_DELAY_ACK	0x1
288adfc5217SJeff Kirsher #define SK_TCP_KEEP_ALIVE	0x2
289adfc5217SJeff Kirsher #define SK_TCP_NAGLE		0x4
290adfc5217SJeff Kirsher #define SK_TCP_TIMESTAMP	0x8
291adfc5217SJeff Kirsher #define SK_TCP_SACK		0x10
292adfc5217SJeff Kirsher #define SK_TCP_SEG_SCALING	0x20
293adfc5217SJeff Kirsher 	unsigned long	flags;
294adfc5217SJeff Kirsher #define SK_F_INUSE		0
295adfc5217SJeff Kirsher #define SK_F_OFFLD_COMPLETE	1
296adfc5217SJeff Kirsher #define SK_F_OFFLD_SCHED	2
297adfc5217SJeff Kirsher #define SK_F_PG_OFFLD_COMPLETE	3
298adfc5217SJeff Kirsher #define SK_F_CONNECT_START	4
299adfc5217SJeff Kirsher #define SK_F_IPV6		5
300adfc5217SJeff Kirsher #define SK_F_CLOSING		7
30123021c21SMichael Chan #define SK_F_HW_ERR		8
302adfc5217SJeff Kirsher 
303adfc5217SJeff Kirsher 	atomic_t ref_count;
304adfc5217SJeff Kirsher 	u32 state;
305adfc5217SJeff Kirsher 	struct kwqe kwqe1;
306adfc5217SJeff Kirsher 	struct kwqe kwqe2;
307adfc5217SJeff Kirsher 	struct kwqe kwqe3;
308adfc5217SJeff Kirsher };
309adfc5217SJeff Kirsher 
310adfc5217SJeff Kirsher struct cnic_dev {
311adfc5217SJeff Kirsher 	struct net_device	*netdev;
312adfc5217SJeff Kirsher 	struct pci_dev		*pcidev;
313adfc5217SJeff Kirsher 	void __iomem		*regview;
314adfc5217SJeff Kirsher 	struct list_head	list;
315adfc5217SJeff Kirsher 
316adfc5217SJeff Kirsher 	int (*register_device)(struct cnic_dev *dev, int ulp_type,
317adfc5217SJeff Kirsher 			       void *ulp_ctx);
318adfc5217SJeff Kirsher 	int (*unregister_device)(struct cnic_dev *dev, int ulp_type);
319adfc5217SJeff Kirsher 	int (*submit_kwqes)(struct cnic_dev *dev, struct kwqe *wqes[],
320adfc5217SJeff Kirsher 				u32 num_wqes);
321adfc5217SJeff Kirsher 	int (*submit_kwqes_16)(struct cnic_dev *dev, struct kwqe_16 *wqes[],
322adfc5217SJeff Kirsher 				u32 num_wqes);
323adfc5217SJeff Kirsher 
324adfc5217SJeff Kirsher 	int (*cm_create)(struct cnic_dev *, int, u32, u32, struct cnic_sock **,
325adfc5217SJeff Kirsher 			 void *);
326adfc5217SJeff Kirsher 	int (*cm_destroy)(struct cnic_sock *);
327adfc5217SJeff Kirsher 	int (*cm_connect)(struct cnic_sock *, struct cnic_sockaddr *);
328adfc5217SJeff Kirsher 	int (*cm_abort)(struct cnic_sock *);
329adfc5217SJeff Kirsher 	int (*cm_close)(struct cnic_sock *);
330adfc5217SJeff Kirsher 	struct cnic_dev *(*cm_select_dev)(struct sockaddr_in *, int ulp_type);
331adfc5217SJeff Kirsher 	int (*iscsi_nl_msg_recv)(struct cnic_dev *dev, u32 msg_type,
332adfc5217SJeff Kirsher 				 char *data, u16 data_size);
3339b8d5044SAdheer Chandravanshi 	int (*get_fc_npiv_tbl)(struct cnic_dev *, struct cnic_fc_npiv_tbl *);
334adfc5217SJeff Kirsher 	unsigned long	flags;
335adfc5217SJeff Kirsher #define CNIC_F_CNIC_UP		1
336adfc5217SJeff Kirsher #define CNIC_F_BNX2_CLASS	3
337adfc5217SJeff Kirsher #define CNIC_F_BNX2X_CLASS	4
338adfc5217SJeff Kirsher 	atomic_t	ref_count;
3391409a932SJoe Perches 	u8		mac_addr[ETH_ALEN];
340adfc5217SJeff Kirsher 
341adfc5217SJeff Kirsher 	int		max_iscsi_conn;
342adfc5217SJeff Kirsher 	int		max_fcoe_conn;
343adfc5217SJeff Kirsher 	int		max_rdma_conn;
344adfc5217SJeff Kirsher 
3450eb43b4bSBhanu Prakash Gollapudi 	int		max_fcoe_exchanges;
3460eb43b4bSBhanu Prakash Gollapudi 
3471d187b34SBarak Witkowski 	union drv_info_to_mcp	*stats_addr;
3482e499d3cSBarak Witkowski 	struct fcoe_capabilities	*fcoe_cap;
3491d187b34SBarak Witkowski 
350adfc5217SJeff Kirsher 	void		*cnic_priv;
351adfc5217SJeff Kirsher };
352adfc5217SJeff Kirsher 
353adfc5217SJeff Kirsher #define CNIC_WR(dev, off, val)		writel(val, dev->regview + off)
354adfc5217SJeff Kirsher #define CNIC_WR16(dev, off, val)	writew(val, dev->regview + off)
355adfc5217SJeff Kirsher #define CNIC_WR8(dev, off, val)		writeb(val, dev->regview + off)
356adfc5217SJeff Kirsher #define CNIC_RD(dev, off)		readl(dev->regview + off)
357adfc5217SJeff Kirsher #define CNIC_RD16(dev, off)		readw(dev->regview + off)
358adfc5217SJeff Kirsher 
359adfc5217SJeff Kirsher struct cnic_ulp_ops {
360adfc5217SJeff Kirsher 	/* Calls to these functions are protected by RCU.  When
361adfc5217SJeff Kirsher 	 * unregistering, we wait for any calls to complete before
362adfc5217SJeff Kirsher 	 * continuing.
363adfc5217SJeff Kirsher 	 */
364adfc5217SJeff Kirsher 
365adfc5217SJeff Kirsher 	void (*cnic_init)(struct cnic_dev *dev);
366adfc5217SJeff Kirsher 	void (*cnic_exit)(struct cnic_dev *dev);
367adfc5217SJeff Kirsher 	void (*cnic_start)(void *ulp_ctx);
368adfc5217SJeff Kirsher 	void (*cnic_stop)(void *ulp_ctx);
369adfc5217SJeff Kirsher 	void (*indicate_kcqes)(void *ulp_ctx, struct kcqe *cqes[],
370adfc5217SJeff Kirsher 				u32 num_cqes);
371adfc5217SJeff Kirsher 	void (*indicate_netevent)(void *ulp_ctx, unsigned long event, u16 vid);
372adfc5217SJeff Kirsher 	void (*cm_connect_complete)(struct cnic_sock *);
373adfc5217SJeff Kirsher 	void (*cm_close_complete)(struct cnic_sock *);
374adfc5217SJeff Kirsher 	void (*cm_abort_complete)(struct cnic_sock *);
375adfc5217SJeff Kirsher 	void (*cm_remote_close)(struct cnic_sock *);
376adfc5217SJeff Kirsher 	void (*cm_remote_abort)(struct cnic_sock *);
377adfc5217SJeff Kirsher 	int (*iscsi_nl_send_msg)(void *ulp_ctx, u32 msg_type,
378adfc5217SJeff Kirsher 				  char *data, u16 data_size);
3791d187b34SBarak Witkowski 	int (*cnic_get_stats)(void *ulp_ctx);
380adfc5217SJeff Kirsher 	struct module *owner;
381adfc5217SJeff Kirsher 	atomic_t ref_count;
382adfc5217SJeff Kirsher };
383adfc5217SJeff Kirsher 
3841ee1725bSJoe Perches int cnic_register_driver(int ulp_type, struct cnic_ulp_ops *ulp_ops);
385adfc5217SJeff Kirsher 
3861ee1725bSJoe Perches int cnic_unregister_driver(int ulp_type);
387adfc5217SJeff Kirsher 
388adfc5217SJeff Kirsher #endif
389