1f7917c00SJeff Kirsher /*
2f7917c00SJeff Kirsher  * This file is part of the Chelsio T4 Ethernet driver for Linux.
3f7917c00SJeff Kirsher  *
4ce100b8bSAnish Bhatt  * Copyright (c) 2003-2014 Chelsio Communications, Inc. All rights reserved.
5f7917c00SJeff Kirsher  *
6f7917c00SJeff Kirsher  * This software is available to you under a choice of one of two
7f7917c00SJeff Kirsher  * licenses.  You may choose to be licensed under the terms of the GNU
8f7917c00SJeff Kirsher  * General Public License (GPL) Version 2, available from the file
9f7917c00SJeff Kirsher  * COPYING in the main directory of this source tree, or the
10f7917c00SJeff Kirsher  * OpenIB.org BSD license below:
11f7917c00SJeff Kirsher  *
12f7917c00SJeff Kirsher  *     Redistribution and use in source and binary forms, with or
13f7917c00SJeff Kirsher  *     without modification, are permitted provided that the following
14f7917c00SJeff Kirsher  *     conditions are met:
15f7917c00SJeff Kirsher  *
16f7917c00SJeff Kirsher  *      - Redistributions of source code must retain the above
17f7917c00SJeff Kirsher  *        copyright notice, this list of conditions and the following
18f7917c00SJeff Kirsher  *        disclaimer.
19f7917c00SJeff Kirsher  *
20f7917c00SJeff Kirsher  *      - Redistributions in binary form must reproduce the above
21f7917c00SJeff Kirsher  *        copyright notice, this list of conditions and the following
22f7917c00SJeff Kirsher  *        disclaimer in the documentation and/or other materials
23f7917c00SJeff Kirsher  *        provided with the distribution.
24f7917c00SJeff Kirsher  *
25f7917c00SJeff Kirsher  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26f7917c00SJeff Kirsher  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27f7917c00SJeff Kirsher  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28f7917c00SJeff Kirsher  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29f7917c00SJeff Kirsher  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30f7917c00SJeff Kirsher  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31f7917c00SJeff Kirsher  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32f7917c00SJeff Kirsher  * SOFTWARE.
33f7917c00SJeff Kirsher  */
34f7917c00SJeff Kirsher 
35f7917c00SJeff Kirsher #ifndef __CXGB4_H__
36f7917c00SJeff Kirsher #define __CXGB4_H__
37f7917c00SJeff Kirsher 
38dca4faebSVipul Pandya #include "t4_hw.h"
39dca4faebSVipul Pandya 
40f7917c00SJeff Kirsher #include <linux/bitops.h>
41f7917c00SJeff Kirsher #include <linux/cache.h>
42f7917c00SJeff Kirsher #include <linux/interrupt.h>
43f7917c00SJeff Kirsher #include <linux/list.h>
44f7917c00SJeff Kirsher #include <linux/netdevice.h>
45f7917c00SJeff Kirsher #include <linux/pci.h>
46f7917c00SJeff Kirsher #include <linux/spinlock.h>
47f7917c00SJeff Kirsher #include <linux/timer.h>
48c0b8b992SDavid S. Miller #include <linux/vmalloc.h>
49f7917c00SJeff Kirsher #include <asm/io.h>
50f7917c00SJeff Kirsher #include "cxgb4_uld.h"
51f7917c00SJeff Kirsher 
523069ee9bSVipul Pandya #define CH_WARN(adap, fmt, ...) dev_warn(adap->pdev_dev, fmt, ## __VA_ARGS__)
533069ee9bSVipul Pandya 
54f7917c00SJeff Kirsher enum {
55f7917c00SJeff Kirsher 	MAX_NPORTS = 4,     /* max # of ports */
56f7917c00SJeff Kirsher 	SERNUM_LEN = 24,    /* Serial # length */
57f7917c00SJeff Kirsher 	EC_LEN     = 16,    /* E/C length */
58f7917c00SJeff Kirsher 	ID_LEN     = 16,    /* ID length */
59a94cd705SKumar Sanghvi 	PN_LEN     = 16,    /* Part Number length */
60f7917c00SJeff Kirsher };
61f7917c00SJeff Kirsher 
62f7917c00SJeff Kirsher enum {
63f7917c00SJeff Kirsher 	MEM_EDC0,
64f7917c00SJeff Kirsher 	MEM_EDC1,
652422d9a3SSantosh Rastapur 	MEM_MC,
662422d9a3SSantosh Rastapur 	MEM_MC0 = MEM_MC,
672422d9a3SSantosh Rastapur 	MEM_MC1
68f7917c00SJeff Kirsher };
69f7917c00SJeff Kirsher 
703069ee9bSVipul Pandya enum {
713eb4afbfSVipul Pandya 	MEMWIN0_APERTURE = 2048,
723eb4afbfSVipul Pandya 	MEMWIN0_BASE     = 0x1b800,
733069ee9bSVipul Pandya 	MEMWIN1_APERTURE = 32768,
743069ee9bSVipul Pandya 	MEMWIN1_BASE     = 0x28000,
752422d9a3SSantosh Rastapur 	MEMWIN1_BASE_T5  = 0x52000,
763eb4afbfSVipul Pandya 	MEMWIN2_APERTURE = 65536,
773eb4afbfSVipul Pandya 	MEMWIN2_BASE     = 0x30000,
780abfd152SHariprasad Shenai 	MEMWIN2_APERTURE_T5 = 131072,
790abfd152SHariprasad Shenai 	MEMWIN2_BASE_T5  = 0x60000,
803069ee9bSVipul Pandya };
813069ee9bSVipul Pandya 
82f7917c00SJeff Kirsher enum dev_master {
83f7917c00SJeff Kirsher 	MASTER_CANT,
84f7917c00SJeff Kirsher 	MASTER_MAY,
85f7917c00SJeff Kirsher 	MASTER_MUST
86f7917c00SJeff Kirsher };
87f7917c00SJeff Kirsher 
88f7917c00SJeff Kirsher enum dev_state {
89f7917c00SJeff Kirsher 	DEV_STATE_UNINIT,
90f7917c00SJeff Kirsher 	DEV_STATE_INIT,
91f7917c00SJeff Kirsher 	DEV_STATE_ERR
92f7917c00SJeff Kirsher };
93f7917c00SJeff Kirsher 
94f7917c00SJeff Kirsher enum {
95f7917c00SJeff Kirsher 	PAUSE_RX      = 1 << 0,
96f7917c00SJeff Kirsher 	PAUSE_TX      = 1 << 1,
97f7917c00SJeff Kirsher 	PAUSE_AUTONEG = 1 << 2
98f7917c00SJeff Kirsher };
99f7917c00SJeff Kirsher 
100f7917c00SJeff Kirsher struct port_stats {
101f7917c00SJeff Kirsher 	u64 tx_octets;            /* total # of octets in good frames */
102f7917c00SJeff Kirsher 	u64 tx_frames;            /* all good frames */
103f7917c00SJeff Kirsher 	u64 tx_bcast_frames;      /* all broadcast frames */
104f7917c00SJeff Kirsher 	u64 tx_mcast_frames;      /* all multicast frames */
105f7917c00SJeff Kirsher 	u64 tx_ucast_frames;      /* all unicast frames */
106f7917c00SJeff Kirsher 	u64 tx_error_frames;      /* all error frames */
107f7917c00SJeff Kirsher 
108f7917c00SJeff Kirsher 	u64 tx_frames_64;         /* # of Tx frames in a particular range */
109f7917c00SJeff Kirsher 	u64 tx_frames_65_127;
110f7917c00SJeff Kirsher 	u64 tx_frames_128_255;
111f7917c00SJeff Kirsher 	u64 tx_frames_256_511;
112f7917c00SJeff Kirsher 	u64 tx_frames_512_1023;
113f7917c00SJeff Kirsher 	u64 tx_frames_1024_1518;
114f7917c00SJeff Kirsher 	u64 tx_frames_1519_max;
115f7917c00SJeff Kirsher 
116f7917c00SJeff Kirsher 	u64 tx_drop;              /* # of dropped Tx frames */
117f7917c00SJeff Kirsher 	u64 tx_pause;             /* # of transmitted pause frames */
118f7917c00SJeff Kirsher 	u64 tx_ppp0;              /* # of transmitted PPP prio 0 frames */
119f7917c00SJeff Kirsher 	u64 tx_ppp1;              /* # of transmitted PPP prio 1 frames */
120f7917c00SJeff Kirsher 	u64 tx_ppp2;              /* # of transmitted PPP prio 2 frames */
121f7917c00SJeff Kirsher 	u64 tx_ppp3;              /* # of transmitted PPP prio 3 frames */
122f7917c00SJeff Kirsher 	u64 tx_ppp4;              /* # of transmitted PPP prio 4 frames */
123f7917c00SJeff Kirsher 	u64 tx_ppp5;              /* # of transmitted PPP prio 5 frames */
124f7917c00SJeff Kirsher 	u64 tx_ppp6;              /* # of transmitted PPP prio 6 frames */
125f7917c00SJeff Kirsher 	u64 tx_ppp7;              /* # of transmitted PPP prio 7 frames */
126f7917c00SJeff Kirsher 
127f7917c00SJeff Kirsher 	u64 rx_octets;            /* total # of octets in good frames */
128f7917c00SJeff Kirsher 	u64 rx_frames;            /* all good frames */
129f7917c00SJeff Kirsher 	u64 rx_bcast_frames;      /* all broadcast frames */
130f7917c00SJeff Kirsher 	u64 rx_mcast_frames;      /* all multicast frames */
131f7917c00SJeff Kirsher 	u64 rx_ucast_frames;      /* all unicast frames */
132f7917c00SJeff Kirsher 	u64 rx_too_long;          /* # of frames exceeding MTU */
133f7917c00SJeff Kirsher 	u64 rx_jabber;            /* # of jabber frames */
134f7917c00SJeff Kirsher 	u64 rx_fcs_err;           /* # of received frames with bad FCS */
135f7917c00SJeff Kirsher 	u64 rx_len_err;           /* # of received frames with length error */
136f7917c00SJeff Kirsher 	u64 rx_symbol_err;        /* symbol errors */
137f7917c00SJeff Kirsher 	u64 rx_runt;              /* # of short frames */
138f7917c00SJeff Kirsher 
139f7917c00SJeff Kirsher 	u64 rx_frames_64;         /* # of Rx frames in a particular range */
140f7917c00SJeff Kirsher 	u64 rx_frames_65_127;
141f7917c00SJeff Kirsher 	u64 rx_frames_128_255;
142f7917c00SJeff Kirsher 	u64 rx_frames_256_511;
143f7917c00SJeff Kirsher 	u64 rx_frames_512_1023;
144f7917c00SJeff Kirsher 	u64 rx_frames_1024_1518;
145f7917c00SJeff Kirsher 	u64 rx_frames_1519_max;
146f7917c00SJeff Kirsher 
147f7917c00SJeff Kirsher 	u64 rx_pause;             /* # of received pause frames */
148f7917c00SJeff Kirsher 	u64 rx_ppp0;              /* # of received PPP prio 0 frames */
149f7917c00SJeff Kirsher 	u64 rx_ppp1;              /* # of received PPP prio 1 frames */
150f7917c00SJeff Kirsher 	u64 rx_ppp2;              /* # of received PPP prio 2 frames */
151f7917c00SJeff Kirsher 	u64 rx_ppp3;              /* # of received PPP prio 3 frames */
152f7917c00SJeff Kirsher 	u64 rx_ppp4;              /* # of received PPP prio 4 frames */
153f7917c00SJeff Kirsher 	u64 rx_ppp5;              /* # of received PPP prio 5 frames */
154f7917c00SJeff Kirsher 	u64 rx_ppp6;              /* # of received PPP prio 6 frames */
155f7917c00SJeff Kirsher 	u64 rx_ppp7;              /* # of received PPP prio 7 frames */
156f7917c00SJeff Kirsher 
157f7917c00SJeff Kirsher 	u64 rx_ovflow0;           /* drops due to buffer-group 0 overflows */
158f7917c00SJeff Kirsher 	u64 rx_ovflow1;           /* drops due to buffer-group 1 overflows */
159f7917c00SJeff Kirsher 	u64 rx_ovflow2;           /* drops due to buffer-group 2 overflows */
160f7917c00SJeff Kirsher 	u64 rx_ovflow3;           /* drops due to buffer-group 3 overflows */
161f7917c00SJeff Kirsher 	u64 rx_trunc0;            /* buffer-group 0 truncated packets */
162f7917c00SJeff Kirsher 	u64 rx_trunc1;            /* buffer-group 1 truncated packets */
163f7917c00SJeff Kirsher 	u64 rx_trunc2;            /* buffer-group 2 truncated packets */
164f7917c00SJeff Kirsher 	u64 rx_trunc3;            /* buffer-group 3 truncated packets */
165f7917c00SJeff Kirsher };
166f7917c00SJeff Kirsher 
167f7917c00SJeff Kirsher struct lb_port_stats {
168f7917c00SJeff Kirsher 	u64 octets;
169f7917c00SJeff Kirsher 	u64 frames;
170f7917c00SJeff Kirsher 	u64 bcast_frames;
171f7917c00SJeff Kirsher 	u64 mcast_frames;
172f7917c00SJeff Kirsher 	u64 ucast_frames;
173f7917c00SJeff Kirsher 	u64 error_frames;
174f7917c00SJeff Kirsher 
175f7917c00SJeff Kirsher 	u64 frames_64;
176f7917c00SJeff Kirsher 	u64 frames_65_127;
177f7917c00SJeff Kirsher 	u64 frames_128_255;
178f7917c00SJeff Kirsher 	u64 frames_256_511;
179f7917c00SJeff Kirsher 	u64 frames_512_1023;
180f7917c00SJeff Kirsher 	u64 frames_1024_1518;
181f7917c00SJeff Kirsher 	u64 frames_1519_max;
182f7917c00SJeff Kirsher 
183f7917c00SJeff Kirsher 	u64 drop;
184f7917c00SJeff Kirsher 
185f7917c00SJeff Kirsher 	u64 ovflow0;
186f7917c00SJeff Kirsher 	u64 ovflow1;
187f7917c00SJeff Kirsher 	u64 ovflow2;
188f7917c00SJeff Kirsher 	u64 ovflow3;
189f7917c00SJeff Kirsher 	u64 trunc0;
190f7917c00SJeff Kirsher 	u64 trunc1;
191f7917c00SJeff Kirsher 	u64 trunc2;
192f7917c00SJeff Kirsher 	u64 trunc3;
193f7917c00SJeff Kirsher };
194f7917c00SJeff Kirsher 
195f7917c00SJeff Kirsher struct tp_tcp_stats {
196f7917c00SJeff Kirsher 	u32 tcpOutRsts;
197f7917c00SJeff Kirsher 	u64 tcpInSegs;
198f7917c00SJeff Kirsher 	u64 tcpOutSegs;
199f7917c00SJeff Kirsher 	u64 tcpRetransSegs;
200f7917c00SJeff Kirsher };
201f7917c00SJeff Kirsher 
202f7917c00SJeff Kirsher struct tp_err_stats {
203f7917c00SJeff Kirsher 	u32 macInErrs[4];
204f7917c00SJeff Kirsher 	u32 hdrInErrs[4];
205f7917c00SJeff Kirsher 	u32 tcpInErrs[4];
206f7917c00SJeff Kirsher 	u32 tnlCongDrops[4];
207f7917c00SJeff Kirsher 	u32 ofldChanDrops[4];
208f7917c00SJeff Kirsher 	u32 tnlTxDrops[4];
209f7917c00SJeff Kirsher 	u32 ofldVlanDrops[4];
210f7917c00SJeff Kirsher 	u32 tcp6InErrs[4];
211f7917c00SJeff Kirsher 	u32 ofldNoNeigh;
212f7917c00SJeff Kirsher 	u32 ofldCongDefer;
213f7917c00SJeff Kirsher };
214f7917c00SJeff Kirsher 
215e85c9a7aSHariprasad Shenai struct sge_params {
216e85c9a7aSHariprasad Shenai 	u32 hps;			/* host page size for our PF/VF */
217e85c9a7aSHariprasad Shenai 	u32 eq_qpp;			/* egress queues/page for our PF/VF */
218e85c9a7aSHariprasad Shenai 	u32 iq_qpp;			/* egress queues/page for our PF/VF */
219e85c9a7aSHariprasad Shenai };
220e85c9a7aSHariprasad Shenai 
221f7917c00SJeff Kirsher struct tp_params {
222f7917c00SJeff Kirsher 	unsigned int ntxchan;        /* # of Tx channels */
223f7917c00SJeff Kirsher 	unsigned int tre;            /* log2 of core clocks per TP tick */
2242d277b3bSHariprasad Shenai 	unsigned int la_mask;        /* what events are recorded by TP LA */
225dca4faebSVipul Pandya 	unsigned short tx_modq_map;  /* TX modulation scheduler queue to */
226dca4faebSVipul Pandya 				     /* channel map */
227636f9d37SVipul Pandya 
228636f9d37SVipul Pandya 	uint32_t dack_re;            /* DACK timer resolution */
229636f9d37SVipul Pandya 	unsigned short tx_modq[NCHAN];	/* channel to modulation queue map */
230dcf7b6f5SKumar Sanghvi 
231dcf7b6f5SKumar Sanghvi 	u32 vlan_pri_map;               /* cached TP_VLAN_PRI_MAP */
232dcf7b6f5SKumar Sanghvi 	u32 ingress_config;             /* cached TP_INGRESS_CONFIG */
233dcf7b6f5SKumar Sanghvi 
234dcf7b6f5SKumar Sanghvi 	/* TP_VLAN_PRI_MAP Compressed Filter Tuple field offsets.  This is a
235dcf7b6f5SKumar Sanghvi 	 * subset of the set of fields which may be present in the Compressed
236dcf7b6f5SKumar Sanghvi 	 * Filter Tuple portion of filters and TCP TCB connections.  The
237dcf7b6f5SKumar Sanghvi 	 * fields which are present are controlled by the TP_VLAN_PRI_MAP.
238dcf7b6f5SKumar Sanghvi 	 * Since a variable number of fields may or may not be present, their
239dcf7b6f5SKumar Sanghvi 	 * shifted field positions within the Compressed Filter Tuple may
240dcf7b6f5SKumar Sanghvi 	 * vary, or not even be present if the field isn't selected in
241dcf7b6f5SKumar Sanghvi 	 * TP_VLAN_PRI_MAP.  Since some of these fields are needed in various
242dcf7b6f5SKumar Sanghvi 	 * places we store their offsets here, or a -1 if the field isn't
243dcf7b6f5SKumar Sanghvi 	 * present.
244dcf7b6f5SKumar Sanghvi 	 */
245dcf7b6f5SKumar Sanghvi 	int vlan_shift;
246dcf7b6f5SKumar Sanghvi 	int vnic_shift;
247dcf7b6f5SKumar Sanghvi 	int port_shift;
248dcf7b6f5SKumar Sanghvi 	int protocol_shift;
249f7917c00SJeff Kirsher };
250f7917c00SJeff Kirsher 
251f7917c00SJeff Kirsher struct vpd_params {
252f7917c00SJeff Kirsher 	unsigned int cclk;
253f7917c00SJeff Kirsher 	u8 ec[EC_LEN + 1];
254f7917c00SJeff Kirsher 	u8 sn[SERNUM_LEN + 1];
255f7917c00SJeff Kirsher 	u8 id[ID_LEN + 1];
256a94cd705SKumar Sanghvi 	u8 pn[PN_LEN + 1];
257f7917c00SJeff Kirsher };
258f7917c00SJeff Kirsher 
259f7917c00SJeff Kirsher struct pci_params {
260f7917c00SJeff Kirsher 	unsigned char speed;
261f7917c00SJeff Kirsher 	unsigned char width;
262f7917c00SJeff Kirsher };
263f7917c00SJeff Kirsher 
264d14807ddSHariprasad Shenai #define CHELSIO_CHIP_CODE(version, revision) (((version) << 4) | (revision))
265d14807ddSHariprasad Shenai #define CHELSIO_CHIP_FPGA          0x100
266d14807ddSHariprasad Shenai #define CHELSIO_CHIP_VERSION(code) (((code) >> 4) & 0xf)
267d14807ddSHariprasad Shenai #define CHELSIO_CHIP_RELEASE(code) ((code) & 0xf)
268d14807ddSHariprasad Shenai 
269d14807ddSHariprasad Shenai #define CHELSIO_T4		0x4
270d14807ddSHariprasad Shenai #define CHELSIO_T5		0x5
271d14807ddSHariprasad Shenai 
272d14807ddSHariprasad Shenai enum chip_type {
273d14807ddSHariprasad Shenai 	T4_A1 = CHELSIO_CHIP_CODE(CHELSIO_T4, 1),
274d14807ddSHariprasad Shenai 	T4_A2 = CHELSIO_CHIP_CODE(CHELSIO_T4, 2),
275d14807ddSHariprasad Shenai 	T4_FIRST_REV	= T4_A1,
276d14807ddSHariprasad Shenai 	T4_LAST_REV	= T4_A2,
277d14807ddSHariprasad Shenai 
278d14807ddSHariprasad Shenai 	T5_A0 = CHELSIO_CHIP_CODE(CHELSIO_T5, 0),
279d14807ddSHariprasad Shenai 	T5_A1 = CHELSIO_CHIP_CODE(CHELSIO_T5, 1),
280d14807ddSHariprasad Shenai 	T5_FIRST_REV	= T5_A0,
281d14807ddSHariprasad Shenai 	T5_LAST_REV	= T5_A1,
282d14807ddSHariprasad Shenai };
283d14807ddSHariprasad Shenai 
28449aa284fSHariprasad Shenai struct devlog_params {
28549aa284fSHariprasad Shenai 	u32 memtype;                    /* which memory (EDC0, EDC1, MC) */
28649aa284fSHariprasad Shenai 	u32 start;                      /* start of log in firmware memory */
28749aa284fSHariprasad Shenai 	u32 size;                       /* size of log */
28849aa284fSHariprasad Shenai };
28949aa284fSHariprasad Shenai 
290f7917c00SJeff Kirsher struct adapter_params {
291e85c9a7aSHariprasad Shenai 	struct sge_params sge;
292f7917c00SJeff Kirsher 	struct tp_params  tp;
293f7917c00SJeff Kirsher 	struct vpd_params vpd;
294f7917c00SJeff Kirsher 	struct pci_params pci;
29549aa284fSHariprasad Shenai 	struct devlog_params devlog;
29649aa284fSHariprasad Shenai 	enum pcie_memwin drv_memwin;
297f7917c00SJeff Kirsher 
298f1ff24aaSHariprasad Shenai 	unsigned int cim_la_size;
299f1ff24aaSHariprasad Shenai 
300f7917c00SJeff Kirsher 	unsigned int sf_size;             /* serial flash size in bytes */
301f7917c00SJeff Kirsher 	unsigned int sf_nsec;             /* # of flash sectors */
302f7917c00SJeff Kirsher 	unsigned int sf_fw_start;         /* start of FW image in flash */
303f7917c00SJeff Kirsher 
304f7917c00SJeff Kirsher 	unsigned int fw_vers;
305f7917c00SJeff Kirsher 	unsigned int tp_vers;
306f7917c00SJeff Kirsher 	u8 api_vers[7];
307f7917c00SJeff Kirsher 
308f7917c00SJeff Kirsher 	unsigned short mtus[NMTUS];
309f7917c00SJeff Kirsher 	unsigned short a_wnd[NCCTRL_WIN];
310f7917c00SJeff Kirsher 	unsigned short b_wnd[NCCTRL_WIN];
311f7917c00SJeff Kirsher 
312f7917c00SJeff Kirsher 	unsigned char nports;             /* # of ethernet ports */
313f7917c00SJeff Kirsher 	unsigned char portvec;
314d14807ddSHariprasad Shenai 	enum chip_type chip;               /* chip code */
315f7917c00SJeff Kirsher 	unsigned char offload;
316f7917c00SJeff Kirsher 
3179a4da2cdSVipul Pandya 	unsigned char bypass;
3189a4da2cdSVipul Pandya 
319f7917c00SJeff Kirsher 	unsigned int ofldq_wr_cred;
3201ac0f095SKumar Sanghvi 	bool ulptx_memwrite_dsgl;          /* use of T5 DSGL allowed */
3214c2c5763SHariprasad Shenai 
3224c2c5763SHariprasad Shenai 	unsigned int max_ordird_qp;       /* Max read depth per RDMA QP */
3234c2c5763SHariprasad Shenai 	unsigned int max_ird_adapter;     /* Max read depth per adapter */
324f7917c00SJeff Kirsher };
325f7917c00SJeff Kirsher 
32616e47624SHariprasad Shenai #include "t4fw_api.h"
32716e47624SHariprasad Shenai 
32816e47624SHariprasad Shenai #define FW_VERSION(chip) ( \
329b2e1a3f0SHariprasad Shenai 		FW_HDR_FW_VER_MAJOR_G(chip##FW_VERSION_MAJOR) | \
330b2e1a3f0SHariprasad Shenai 		FW_HDR_FW_VER_MINOR_G(chip##FW_VERSION_MINOR) | \
331b2e1a3f0SHariprasad Shenai 		FW_HDR_FW_VER_MICRO_G(chip##FW_VERSION_MICRO) | \
332b2e1a3f0SHariprasad Shenai 		FW_HDR_FW_VER_BUILD_G(chip##FW_VERSION_BUILD))
33316e47624SHariprasad Shenai #define FW_INTFVER(chip, intf) (FW_HDR_INTFVER_##intf)
33416e47624SHariprasad Shenai 
33516e47624SHariprasad Shenai struct fw_info {
33616e47624SHariprasad Shenai 	u8 chip;
33716e47624SHariprasad Shenai 	char *fs_name;
33816e47624SHariprasad Shenai 	char *fw_mod_name;
33916e47624SHariprasad Shenai 	struct fw_hdr fw_hdr;
34016e47624SHariprasad Shenai };
34116e47624SHariprasad Shenai 
34216e47624SHariprasad Shenai 
343f7917c00SJeff Kirsher struct trace_params {
344f7917c00SJeff Kirsher 	u32 data[TRACE_LEN / 4];
345f7917c00SJeff Kirsher 	u32 mask[TRACE_LEN / 4];
346f7917c00SJeff Kirsher 	unsigned short snap_len;
347f7917c00SJeff Kirsher 	unsigned short min_len;
348f7917c00SJeff Kirsher 	unsigned char skip_ofst;
349f7917c00SJeff Kirsher 	unsigned char skip_len;
350f7917c00SJeff Kirsher 	unsigned char invert;
351f7917c00SJeff Kirsher 	unsigned char port;
352f7917c00SJeff Kirsher };
353f7917c00SJeff Kirsher 
354f7917c00SJeff Kirsher struct link_config {
355f7917c00SJeff Kirsher 	unsigned short supported;        /* link capabilities */
356f7917c00SJeff Kirsher 	unsigned short advertising;      /* advertised capabilities */
357f7917c00SJeff Kirsher 	unsigned short requested_speed;  /* speed user has requested */
358f7917c00SJeff Kirsher 	unsigned short speed;            /* actual link speed */
359f7917c00SJeff Kirsher 	unsigned char  requested_fc;     /* flow control user has requested */
360f7917c00SJeff Kirsher 	unsigned char  fc;               /* actual link flow control */
361f7917c00SJeff Kirsher 	unsigned char  autoneg;          /* autonegotiating? */
362f7917c00SJeff Kirsher 	unsigned char  link_ok;          /* link up? */
363f7917c00SJeff Kirsher };
364f7917c00SJeff Kirsher 
365e2ac9628SHariprasad Shenai #define FW_LEN16(fw_struct) FW_CMD_LEN16_V(sizeof(fw_struct) / 16)
366f7917c00SJeff Kirsher 
367f7917c00SJeff Kirsher enum {
368f7917c00SJeff Kirsher 	MAX_ETH_QSETS = 32,           /* # of Ethernet Tx/Rx queue sets */
369f7917c00SJeff Kirsher 	MAX_OFLD_QSETS = 16,          /* # of offload Tx/Rx queue sets */
370f7917c00SJeff Kirsher 	MAX_CTRL_QUEUES = NCHAN,      /* # of control Tx queues */
371f7917c00SJeff Kirsher 	MAX_RDMA_QUEUES = NCHAN,      /* # of streaming RDMA Rx queues */
372cf38be6dSHariprasad Shenai 	MAX_RDMA_CIQS = NCHAN,        /* # of  RDMA concentrator IQs */
373cf38be6dSHariprasad Shenai 	MAX_ISCSI_QUEUES = NCHAN,     /* # of streaming iSCSI Rx queues */
374f7917c00SJeff Kirsher };
375f7917c00SJeff Kirsher 
376f7917c00SJeff Kirsher enum {
377cf38be6dSHariprasad Shenai 	INGQ_EXTRAS = 2,        /* firmware event queue and */
378cf38be6dSHariprasad Shenai 				/*   forwarded interrupts */
379cf38be6dSHariprasad Shenai 	MAX_INGQ = MAX_ETH_QSETS + MAX_OFLD_QSETS + MAX_RDMA_QUEUES
380cf38be6dSHariprasad Shenai 		   + MAX_RDMA_CIQS + MAX_ISCSI_QUEUES + INGQ_EXTRAS,
381f7917c00SJeff Kirsher };
382f7917c00SJeff Kirsher 
383f7917c00SJeff Kirsher struct adapter;
384f7917c00SJeff Kirsher struct sge_rspq;
385f7917c00SJeff Kirsher 
386688848b1SAnish Bhatt #include "cxgb4_dcb.h"
387688848b1SAnish Bhatt 
388f7917c00SJeff Kirsher struct port_info {
389f7917c00SJeff Kirsher 	struct adapter *adapter;
390f7917c00SJeff Kirsher 	u16    viid;
391f7917c00SJeff Kirsher 	s16    xact_addr_filt;        /* index of exact MAC address filter */
392f7917c00SJeff Kirsher 	u16    rss_size;              /* size of VI's RSS table slice */
393f7917c00SJeff Kirsher 	s8     mdio_addr;
39440e9de4bSHariprasad Shenai 	enum fw_port_type port_type;
395f7917c00SJeff Kirsher 	u8     mod_type;
396f7917c00SJeff Kirsher 	u8     port_id;
397f7917c00SJeff Kirsher 	u8     tx_chan;
398f7917c00SJeff Kirsher 	u8     lport;                 /* associated offload logical port */
399f7917c00SJeff Kirsher 	u8     nqsets;                /* # of qsets */
400f7917c00SJeff Kirsher 	u8     first_qset;            /* index of first qset */
401f7917c00SJeff Kirsher 	u8     rss_mode;
402f7917c00SJeff Kirsher 	struct link_config link_cfg;
403f7917c00SJeff Kirsher 	u16   *rss;
404688848b1SAnish Bhatt #ifdef CONFIG_CHELSIO_T4_DCB
405688848b1SAnish Bhatt 	struct port_dcb_info dcb;     /* Data Center Bridging support */
406688848b1SAnish Bhatt #endif
407f7917c00SJeff Kirsher };
408f7917c00SJeff Kirsher 
409f7917c00SJeff Kirsher struct dentry;
410f7917c00SJeff Kirsher struct work_struct;
411f7917c00SJeff Kirsher 
412f7917c00SJeff Kirsher enum {                                 /* adapter flags */
413f7917c00SJeff Kirsher 	FULL_INIT_DONE     = (1 << 0),
414144be3d9SGavin Shan 	DEV_ENABLED        = (1 << 1),
415144be3d9SGavin Shan 	USING_MSI          = (1 << 2),
416144be3d9SGavin Shan 	USING_MSIX         = (1 << 3),
417f7917c00SJeff Kirsher 	FW_OK              = (1 << 4),
41813ee15d3SVipul Pandya 	RSS_TNLALLLOOKUP   = (1 << 5),
41952367a76SVipul Pandya 	USING_SOFT_PARAMS  = (1 << 6),
42052367a76SVipul Pandya 	MASTER_PF          = (1 << 7),
42152367a76SVipul Pandya 	FW_OFLD_CONN       = (1 << 9),
422f7917c00SJeff Kirsher };
423f7917c00SJeff Kirsher 
424f7917c00SJeff Kirsher struct rx_sw_desc;
425f7917c00SJeff Kirsher 
426f7917c00SJeff Kirsher struct sge_fl {                     /* SGE free-buffer queue state */
427f7917c00SJeff Kirsher 	unsigned int avail;         /* # of available Rx buffers */
428f7917c00SJeff Kirsher 	unsigned int pend_cred;     /* new buffers since last FL DB ring */
429f7917c00SJeff Kirsher 	unsigned int cidx;          /* consumer index */
430f7917c00SJeff Kirsher 	unsigned int pidx;          /* producer index */
431f7917c00SJeff Kirsher 	unsigned long alloc_failed; /* # of times buffer allocation failed */
432f7917c00SJeff Kirsher 	unsigned long large_alloc_failed;
433f7917c00SJeff Kirsher 	unsigned long starving;
434f7917c00SJeff Kirsher 	/* RO fields */
435f7917c00SJeff Kirsher 	unsigned int cntxt_id;      /* SGE context id for the free list */
436f7917c00SJeff Kirsher 	unsigned int size;          /* capacity of free list */
437f7917c00SJeff Kirsher 	struct rx_sw_desc *sdesc;   /* address of SW Rx descriptor ring */
438f7917c00SJeff Kirsher 	__be64 *desc;               /* address of HW Rx descriptor ring */
439f7917c00SJeff Kirsher 	dma_addr_t addr;            /* bus address of HW ring start */
440df64e4d3SHariprasad Shenai 	void __iomem *bar2_addr;    /* address of BAR2 Queue registers */
441df64e4d3SHariprasad Shenai 	unsigned int bar2_qid;      /* Queue ID for BAR2 Queue registers */
442f7917c00SJeff Kirsher };
443f7917c00SJeff Kirsher 
444f7917c00SJeff Kirsher /* A packet gather list */
445f7917c00SJeff Kirsher struct pkt_gl {
446e91b0f24SIan Campbell 	struct page_frag frags[MAX_SKB_FRAGS];
447f7917c00SJeff Kirsher 	void *va;                         /* virtual address of first byte */
448f7917c00SJeff Kirsher 	unsigned int nfrags;              /* # of fragments */
449f7917c00SJeff Kirsher 	unsigned int tot_len;             /* total length of fragments */
450f7917c00SJeff Kirsher };
451f7917c00SJeff Kirsher 
452f7917c00SJeff Kirsher typedef int (*rspq_handler_t)(struct sge_rspq *q, const __be64 *rsp,
453f7917c00SJeff Kirsher 			      const struct pkt_gl *gl);
454f7917c00SJeff Kirsher 
455f7917c00SJeff Kirsher struct sge_rspq {                   /* state for an SGE response queue */
456f7917c00SJeff Kirsher 	struct napi_struct napi;
457f7917c00SJeff Kirsher 	const __be64 *cur_desc;     /* current descriptor in queue */
458f7917c00SJeff Kirsher 	unsigned int cidx;          /* consumer index */
459f7917c00SJeff Kirsher 	u8 gen;                     /* current generation bit */
460f7917c00SJeff Kirsher 	u8 intr_params;             /* interrupt holdoff parameters */
461f7917c00SJeff Kirsher 	u8 next_intr_params;        /* holdoff params for next interrupt */
462e553ec3fSHariprasad Shenai 	u8 adaptive_rx;
463f7917c00SJeff Kirsher 	u8 pktcnt_idx;              /* interrupt packet threshold */
464f7917c00SJeff Kirsher 	u8 uld;                     /* ULD handling this queue */
465f7917c00SJeff Kirsher 	u8 idx;                     /* queue index within its group */
466f7917c00SJeff Kirsher 	int offset;                 /* offset into current Rx buffer */
467f7917c00SJeff Kirsher 	u16 cntxt_id;               /* SGE context id for the response q */
468f7917c00SJeff Kirsher 	u16 abs_id;                 /* absolute SGE id for the response q */
469f7917c00SJeff Kirsher 	__be64 *desc;               /* address of HW response ring */
470f7917c00SJeff Kirsher 	dma_addr_t phys_addr;       /* physical address of the ring */
471df64e4d3SHariprasad Shenai 	void __iomem *bar2_addr;    /* address of BAR2 Queue registers */
472df64e4d3SHariprasad Shenai 	unsigned int bar2_qid;      /* Queue ID for BAR2 Queue registers */
473f7917c00SJeff Kirsher 	unsigned int iqe_len;       /* entry size */
474f7917c00SJeff Kirsher 	unsigned int size;          /* capacity of response queue */
475f7917c00SJeff Kirsher 	struct adapter *adap;
476f7917c00SJeff Kirsher 	struct net_device *netdev;  /* associated net device */
477f7917c00SJeff Kirsher 	rspq_handler_t handler;
4783a336cb1SHariprasad Shenai #ifdef CONFIG_NET_RX_BUSY_POLL
4793a336cb1SHariprasad Shenai #define CXGB_POLL_STATE_IDLE		0
4803a336cb1SHariprasad Shenai #define CXGB_POLL_STATE_NAPI		BIT(0) /* NAPI owns this poll */
4813a336cb1SHariprasad Shenai #define CXGB_POLL_STATE_POLL		BIT(1) /* poll owns this poll */
4823a336cb1SHariprasad Shenai #define CXGB_POLL_STATE_NAPI_YIELD	BIT(2) /* NAPI yielded this poll */
4833a336cb1SHariprasad Shenai #define CXGB_POLL_STATE_POLL_YIELD	BIT(3) /* poll yielded this poll */
4843a336cb1SHariprasad Shenai #define CXGB_POLL_YIELD			(CXGB_POLL_STATE_NAPI_YIELD |   \
4853a336cb1SHariprasad Shenai 					 CXGB_POLL_STATE_POLL_YIELD)
4863a336cb1SHariprasad Shenai #define CXGB_POLL_LOCKED		(CXGB_POLL_STATE_NAPI |         \
4873a336cb1SHariprasad Shenai 					 CXGB_POLL_STATE_POLL)
4883a336cb1SHariprasad Shenai #define CXGB_POLL_USER_PEND		(CXGB_POLL_STATE_POLL |         \
4893a336cb1SHariprasad Shenai 					 CXGB_POLL_STATE_POLL_YIELD)
4903a336cb1SHariprasad Shenai 	unsigned int bpoll_state;
4913a336cb1SHariprasad Shenai 	spinlock_t bpoll_lock;		/* lock for busy poll */
4923a336cb1SHariprasad Shenai #endif /* CONFIG_NET_RX_BUSY_POLL */
4933a336cb1SHariprasad Shenai 
494f7917c00SJeff Kirsher };
495f7917c00SJeff Kirsher 
496f7917c00SJeff Kirsher struct sge_eth_stats {              /* Ethernet queue statistics */
497f7917c00SJeff Kirsher 	unsigned long pkts;         /* # of ethernet packets */
498f7917c00SJeff Kirsher 	unsigned long lro_pkts;     /* # of LRO super packets */
499f7917c00SJeff Kirsher 	unsigned long lro_merged;   /* # of wire packets merged by LRO */
500f7917c00SJeff Kirsher 	unsigned long rx_cso;       /* # of Rx checksum offloads */
501f7917c00SJeff Kirsher 	unsigned long vlan_ex;      /* # of Rx VLAN extractions */
502f7917c00SJeff Kirsher 	unsigned long rx_drops;     /* # of packets dropped due to no mem */
503f7917c00SJeff Kirsher };
504f7917c00SJeff Kirsher 
505f7917c00SJeff Kirsher struct sge_eth_rxq {                /* SW Ethernet Rx queue */
506f7917c00SJeff Kirsher 	struct sge_rspq rspq;
507f7917c00SJeff Kirsher 	struct sge_fl fl;
508f7917c00SJeff Kirsher 	struct sge_eth_stats stats;
509f7917c00SJeff Kirsher } ____cacheline_aligned_in_smp;
510f7917c00SJeff Kirsher 
511f7917c00SJeff Kirsher struct sge_ofld_stats {             /* offload queue statistics */
512f7917c00SJeff Kirsher 	unsigned long pkts;         /* # of packets */
513f7917c00SJeff Kirsher 	unsigned long imm;          /* # of immediate-data packets */
514f7917c00SJeff Kirsher 	unsigned long an;           /* # of asynchronous notifications */
515f7917c00SJeff Kirsher 	unsigned long nomem;        /* # of responses deferred due to no mem */
516f7917c00SJeff Kirsher };
517f7917c00SJeff Kirsher 
518f7917c00SJeff Kirsher struct sge_ofld_rxq {               /* SW offload Rx queue */
519f7917c00SJeff Kirsher 	struct sge_rspq rspq;
520f7917c00SJeff Kirsher 	struct sge_fl fl;
521f7917c00SJeff Kirsher 	struct sge_ofld_stats stats;
522f7917c00SJeff Kirsher } ____cacheline_aligned_in_smp;
523f7917c00SJeff Kirsher 
524f7917c00SJeff Kirsher struct tx_desc {
525f7917c00SJeff Kirsher 	__be64 flit[8];
526f7917c00SJeff Kirsher };
527f7917c00SJeff Kirsher 
528f7917c00SJeff Kirsher struct tx_sw_desc;
529f7917c00SJeff Kirsher 
530f7917c00SJeff Kirsher struct sge_txq {
531f7917c00SJeff Kirsher 	unsigned int  in_use;       /* # of in-use Tx descriptors */
532f7917c00SJeff Kirsher 	unsigned int  size;         /* # of descriptors */
533f7917c00SJeff Kirsher 	unsigned int  cidx;         /* SW consumer index */
534f7917c00SJeff Kirsher 	unsigned int  pidx;         /* producer index */
535f7917c00SJeff Kirsher 	unsigned long stops;        /* # of times q has been stopped */
536f7917c00SJeff Kirsher 	unsigned long restarts;     /* # of queue restarts */
537f7917c00SJeff Kirsher 	unsigned int  cntxt_id;     /* SGE context id for the Tx q */
538f7917c00SJeff Kirsher 	struct tx_desc *desc;       /* address of HW Tx descriptor ring */
539f7917c00SJeff Kirsher 	struct tx_sw_desc *sdesc;   /* address of SW Tx descriptor ring */
540f7917c00SJeff Kirsher 	struct sge_qstat *stat;     /* queue status entry */
541f7917c00SJeff Kirsher 	dma_addr_t    phys_addr;    /* physical address of the ring */
5423069ee9bSVipul Pandya 	spinlock_t db_lock;
5433069ee9bSVipul Pandya 	int db_disabled;
5443069ee9bSVipul Pandya 	unsigned short db_pidx;
54505eb2389SSteve Wise 	unsigned short db_pidx_inc;
546df64e4d3SHariprasad Shenai 	void __iomem *bar2_addr;    /* address of BAR2 Queue registers */
547df64e4d3SHariprasad Shenai 	unsigned int bar2_qid;      /* Queue ID for BAR2 Queue registers */
548f7917c00SJeff Kirsher };
549f7917c00SJeff Kirsher 
550f7917c00SJeff Kirsher struct sge_eth_txq {                /* state for an SGE Ethernet Tx queue */
551f7917c00SJeff Kirsher 	struct sge_txq q;
552f7917c00SJeff Kirsher 	struct netdev_queue *txq;   /* associated netdev TX queue */
55310b00466SAnish Bhatt #ifdef CONFIG_CHELSIO_T4_DCB
55410b00466SAnish Bhatt 	u8 dcb_prio;		    /* DCB Priority bound to queue */
55510b00466SAnish Bhatt #endif
556f7917c00SJeff Kirsher 	unsigned long tso;          /* # of TSO requests */
557f7917c00SJeff Kirsher 	unsigned long tx_cso;       /* # of Tx checksum offloads */
558f7917c00SJeff Kirsher 	unsigned long vlan_ins;     /* # of Tx VLAN insertions */
559f7917c00SJeff Kirsher 	unsigned long mapping_err;  /* # of I/O MMU packet mapping errors */
560f7917c00SJeff Kirsher } ____cacheline_aligned_in_smp;
561f7917c00SJeff Kirsher 
562f7917c00SJeff Kirsher struct sge_ofld_txq {               /* state for an SGE offload Tx queue */
563f7917c00SJeff Kirsher 	struct sge_txq q;
564f7917c00SJeff Kirsher 	struct adapter *adap;
565f7917c00SJeff Kirsher 	struct sk_buff_head sendq;  /* list of backpressured packets */
566f7917c00SJeff Kirsher 	struct tasklet_struct qresume_tsk; /* restarts the queue */
567f7917c00SJeff Kirsher 	u8 full;                    /* the Tx ring is full */
568f7917c00SJeff Kirsher 	unsigned long mapping_err;  /* # of I/O MMU packet mapping errors */
569f7917c00SJeff Kirsher } ____cacheline_aligned_in_smp;
570f7917c00SJeff Kirsher 
571f7917c00SJeff Kirsher struct sge_ctrl_txq {               /* state for an SGE control Tx queue */
572f7917c00SJeff Kirsher 	struct sge_txq q;
573f7917c00SJeff Kirsher 	struct adapter *adap;
574f7917c00SJeff Kirsher 	struct sk_buff_head sendq;  /* list of backpressured packets */
575f7917c00SJeff Kirsher 	struct tasklet_struct qresume_tsk; /* restarts the queue */
576f7917c00SJeff Kirsher 	u8 full;                    /* the Tx ring is full */
577f7917c00SJeff Kirsher } ____cacheline_aligned_in_smp;
578f7917c00SJeff Kirsher 
579f7917c00SJeff Kirsher struct sge {
580f7917c00SJeff Kirsher 	struct sge_eth_txq ethtxq[MAX_ETH_QSETS];
581f7917c00SJeff Kirsher 	struct sge_ofld_txq ofldtxq[MAX_OFLD_QSETS];
582f7917c00SJeff Kirsher 	struct sge_ctrl_txq ctrlq[MAX_CTRL_QUEUES];
583f7917c00SJeff Kirsher 
584f7917c00SJeff Kirsher 	struct sge_eth_rxq ethrxq[MAX_ETH_QSETS];
585f7917c00SJeff Kirsher 	struct sge_ofld_rxq ofldrxq[MAX_OFLD_QSETS];
586f7917c00SJeff Kirsher 	struct sge_ofld_rxq rdmarxq[MAX_RDMA_QUEUES];
587cf38be6dSHariprasad Shenai 	struct sge_ofld_rxq rdmaciq[MAX_RDMA_CIQS];
588f7917c00SJeff Kirsher 	struct sge_rspq fw_evtq ____cacheline_aligned_in_smp;
589f7917c00SJeff Kirsher 
590f7917c00SJeff Kirsher 	struct sge_rspq intrq ____cacheline_aligned_in_smp;
591f7917c00SJeff Kirsher 	spinlock_t intrq_lock;
592f7917c00SJeff Kirsher 
593f7917c00SJeff Kirsher 	u16 max_ethqsets;           /* # of available Ethernet queue sets */
594f7917c00SJeff Kirsher 	u16 ethqsets;               /* # of active Ethernet queue sets */
595f7917c00SJeff Kirsher 	u16 ethtxq_rover;           /* Tx queue to clean up next */
596f7917c00SJeff Kirsher 	u16 ofldqsets;              /* # of active offload queue sets */
597f7917c00SJeff Kirsher 	u16 rdmaqs;                 /* # of available RDMA Rx queues */
598cf38be6dSHariprasad Shenai 	u16 rdmaciqs;               /* # of available RDMA concentrator IQs */
599f7917c00SJeff Kirsher 	u16 ofld_rxq[MAX_OFLD_QSETS];
600f7917c00SJeff Kirsher 	u16 rdma_rxq[NCHAN];
601cf38be6dSHariprasad Shenai 	u16 rdma_ciq[NCHAN];
602f7917c00SJeff Kirsher 	u16 timer_val[SGE_NTIMERS];
603f7917c00SJeff Kirsher 	u8 counter_val[SGE_NCOUNTERS];
60452367a76SVipul Pandya 	u32 fl_pg_order;            /* large page allocation size */
60552367a76SVipul Pandya 	u32 stat_len;               /* length of status page at ring end */
60652367a76SVipul Pandya 	u32 pktshift;               /* padding between CPL & packet data */
60752367a76SVipul Pandya 	u32 fl_align;               /* response queue message alignment */
60852367a76SVipul Pandya 	u32 fl_starve_thres;        /* Free List starvation threshold */
6090f4d201fSKumar Sanghvi 
6100f4d201fSKumar Sanghvi 	/* State variables for detecting an SGE Ingress DMA hang */
6110f4d201fSKumar Sanghvi 	unsigned int idma_1s_thresh;/* SGE same State Counter 1s threshold */
6120f4d201fSKumar Sanghvi 	unsigned int idma_stalled[2];/* SGE synthesized stalled timers in HZ */
6130f4d201fSKumar Sanghvi 	unsigned int idma_state[2]; /* SGE IDMA Hang detect state */
6140f4d201fSKumar Sanghvi 	unsigned int idma_qid[2];   /* SGE IDMA Hung Ingress Queue ID */
6150f4d201fSKumar Sanghvi 
616f7917c00SJeff Kirsher 	unsigned int egr_start;
6174b8e27a8SHariprasad Shenai 	unsigned int egr_sz;
618f7917c00SJeff Kirsher 	unsigned int ingr_start;
6194b8e27a8SHariprasad Shenai 	unsigned int ingr_sz;
6204b8e27a8SHariprasad Shenai 	void **egr_map;    /* qid->queue egress queue map */
6214b8e27a8SHariprasad Shenai 	struct sge_rspq **ingr_map; /* qid->queue ingress queue map */
6224b8e27a8SHariprasad Shenai 	unsigned long *starving_fl;
6234b8e27a8SHariprasad Shenai 	unsigned long *txq_maperr;
624f7917c00SJeff Kirsher 	struct timer_list rx_timer; /* refills starving FLs */
625f7917c00SJeff Kirsher 	struct timer_list tx_timer; /* checks Tx queues */
626f7917c00SJeff Kirsher };
627f7917c00SJeff Kirsher 
628f7917c00SJeff Kirsher #define for_each_ethrxq(sge, i) for (i = 0; i < (sge)->ethqsets; i++)
629f7917c00SJeff Kirsher #define for_each_ofldrxq(sge, i) for (i = 0; i < (sge)->ofldqsets; i++)
630f7917c00SJeff Kirsher #define for_each_rdmarxq(sge, i) for (i = 0; i < (sge)->rdmaqs; i++)
631cf38be6dSHariprasad Shenai #define for_each_rdmaciq(sge, i) for (i = 0; i < (sge)->rdmaciqs; i++)
632f7917c00SJeff Kirsher 
633f7917c00SJeff Kirsher struct l2t_data;
634f7917c00SJeff Kirsher 
6352422d9a3SSantosh Rastapur #ifdef CONFIG_PCI_IOV
6362422d9a3SSantosh Rastapur 
6377d6727cfSSantosh Rastapur /* T4 supports SRIOV on PF0-3 and T5 on PF0-7.  However, the Serial
6387d6727cfSSantosh Rastapur  * Configuration initialization for T5 only has SR-IOV functionality enabled
6397d6727cfSSantosh Rastapur  * on PF0-3 in order to simplify everything.
6402422d9a3SSantosh Rastapur  */
6417d6727cfSSantosh Rastapur #define NUM_OF_PF_WITH_SRIOV 4
6422422d9a3SSantosh Rastapur 
6432422d9a3SSantosh Rastapur #endif
6442422d9a3SSantosh Rastapur 
645f7917c00SJeff Kirsher struct adapter {
646f7917c00SJeff Kirsher 	void __iomem *regs;
64722adfe0aSSantosh Rastapur 	void __iomem *bar2;
6480abfd152SHariprasad Shenai 	u32 t4_bar0;
649f7917c00SJeff Kirsher 	struct pci_dev *pdev;
650f7917c00SJeff Kirsher 	struct device *pdev_dev;
6513069ee9bSVipul Pandya 	unsigned int mbox;
652f7917c00SJeff Kirsher 	unsigned int fn;
653f7917c00SJeff Kirsher 	unsigned int flags;
6542422d9a3SSantosh Rastapur 	enum chip_type chip;
655f7917c00SJeff Kirsher 
656f7917c00SJeff Kirsher 	int msg_enable;
657f7917c00SJeff Kirsher 
658f7917c00SJeff Kirsher 	struct adapter_params params;
659f7917c00SJeff Kirsher 	struct cxgb4_virt_res vres;
660f7917c00SJeff Kirsher 	unsigned int swintr;
661f7917c00SJeff Kirsher 
662f7917c00SJeff Kirsher 	unsigned int wol;
663f7917c00SJeff Kirsher 
664f7917c00SJeff Kirsher 	struct {
665f7917c00SJeff Kirsher 		unsigned short vec;
666f7917c00SJeff Kirsher 		char desc[IFNAMSIZ + 10];
667f7917c00SJeff Kirsher 	} msix_info[MAX_INGQ + 1];
668f7917c00SJeff Kirsher 
669f7917c00SJeff Kirsher 	struct sge sge;
670f7917c00SJeff Kirsher 
671f7917c00SJeff Kirsher 	struct net_device *port[MAX_NPORTS];
672f7917c00SJeff Kirsher 	u8 chan_map[NCHAN];                   /* channel -> port map */
673f7917c00SJeff Kirsher 
674793dad94SVipul Pandya 	u32 filter_mode;
675636f9d37SVipul Pandya 	unsigned int l2t_start;
676636f9d37SVipul Pandya 	unsigned int l2t_end;
677f7917c00SJeff Kirsher 	struct l2t_data *l2t;
678b5a02f50SAnish Bhatt 	unsigned int clipt_start;
679b5a02f50SAnish Bhatt 	unsigned int clipt_end;
680b5a02f50SAnish Bhatt 	struct clip_tbl *clipt;
681f7917c00SJeff Kirsher 	void *uld_handle[CXGB4_ULD_MAX];
682f7917c00SJeff Kirsher 	struct list_head list_node;
68301bcca68SVipul Pandya 	struct list_head rcu_node;
684f7917c00SJeff Kirsher 
685f7917c00SJeff Kirsher 	struct tid_info tids;
686f7917c00SJeff Kirsher 	void **tid_release_head;
687f7917c00SJeff Kirsher 	spinlock_t tid_release_lock;
68829aaee65SAnish Bhatt 	struct workqueue_struct *workq;
689f7917c00SJeff Kirsher 	struct work_struct tid_release_task;
690881806bcSVipul Pandya 	struct work_struct db_full_task;
691881806bcSVipul Pandya 	struct work_struct db_drop_task;
692f7917c00SJeff Kirsher 	bool tid_release_task_busy;
693f7917c00SJeff Kirsher 
694f7917c00SJeff Kirsher 	struct dentry *debugfs_root;
695f7917c00SJeff Kirsher 
696f7917c00SJeff Kirsher 	spinlock_t stats_lock;
697fc5ab020SHariprasad Shenai 	spinlock_t win0_lock ____cacheline_aligned_in_smp;
698f7917c00SJeff Kirsher };
699f7917c00SJeff Kirsher 
700f2b7e78dSVipul Pandya /* Defined bit width of user definable filter tuples
701f2b7e78dSVipul Pandya  */
702f2b7e78dSVipul Pandya #define ETHTYPE_BITWIDTH 16
703f2b7e78dSVipul Pandya #define FRAG_BITWIDTH 1
704f2b7e78dSVipul Pandya #define MACIDX_BITWIDTH 9
705f2b7e78dSVipul Pandya #define FCOE_BITWIDTH 1
706f2b7e78dSVipul Pandya #define IPORT_BITWIDTH 3
707f2b7e78dSVipul Pandya #define MATCHTYPE_BITWIDTH 3
708f2b7e78dSVipul Pandya #define PROTO_BITWIDTH 8
709f2b7e78dSVipul Pandya #define TOS_BITWIDTH 8
710f2b7e78dSVipul Pandya #define PF_BITWIDTH 8
711f2b7e78dSVipul Pandya #define VF_BITWIDTH 8
712f2b7e78dSVipul Pandya #define IVLAN_BITWIDTH 16
713f2b7e78dSVipul Pandya #define OVLAN_BITWIDTH 16
714f2b7e78dSVipul Pandya 
715f2b7e78dSVipul Pandya /* Filter matching rules.  These consist of a set of ingress packet field
716f2b7e78dSVipul Pandya  * (value, mask) tuples.  The associated ingress packet field matches the
717f2b7e78dSVipul Pandya  * tuple when ((field & mask) == value).  (Thus a wildcard "don't care" field
718f2b7e78dSVipul Pandya  * rule can be constructed by specifying a tuple of (0, 0).)  A filter rule
719f2b7e78dSVipul Pandya  * matches an ingress packet when all of the individual individual field
720f2b7e78dSVipul Pandya  * matching rules are true.
721f2b7e78dSVipul Pandya  *
722f2b7e78dSVipul Pandya  * Partial field masks are always valid, however, while it may be easy to
723f2b7e78dSVipul Pandya  * understand their meanings for some fields (e.g. IP address to match a
724f2b7e78dSVipul Pandya  * subnet), for others making sensible partial masks is less intuitive (e.g.
725f2b7e78dSVipul Pandya  * MPS match type) ...
726f2b7e78dSVipul Pandya  *
727f2b7e78dSVipul Pandya  * Most of the following data structures are modeled on T4 capabilities.
728f2b7e78dSVipul Pandya  * Drivers for earlier chips use the subsets which make sense for those chips.
729f2b7e78dSVipul Pandya  * We really need to come up with a hardware-independent mechanism to
730f2b7e78dSVipul Pandya  * represent hardware filter capabilities ...
731f2b7e78dSVipul Pandya  */
732f2b7e78dSVipul Pandya struct ch_filter_tuple {
733f2b7e78dSVipul Pandya 	/* Compressed header matching field rules.  The TP_VLAN_PRI_MAP
734f2b7e78dSVipul Pandya 	 * register selects which of these fields will participate in the
735f2b7e78dSVipul Pandya 	 * filter match rules -- up to a maximum of 36 bits.  Because
736f2b7e78dSVipul Pandya 	 * TP_VLAN_PRI_MAP is a global register, all filters must use the same
737f2b7e78dSVipul Pandya 	 * set of fields.
738f2b7e78dSVipul Pandya 	 */
739f2b7e78dSVipul Pandya 	uint32_t ethtype:ETHTYPE_BITWIDTH;      /* Ethernet type */
740f2b7e78dSVipul Pandya 	uint32_t frag:FRAG_BITWIDTH;            /* IP fragmentation header */
741f2b7e78dSVipul Pandya 	uint32_t ivlan_vld:1;                   /* inner VLAN valid */
742f2b7e78dSVipul Pandya 	uint32_t ovlan_vld:1;                   /* outer VLAN valid */
743f2b7e78dSVipul Pandya 	uint32_t pfvf_vld:1;                    /* PF/VF valid */
744f2b7e78dSVipul Pandya 	uint32_t macidx:MACIDX_BITWIDTH;        /* exact match MAC index */
745f2b7e78dSVipul Pandya 	uint32_t fcoe:FCOE_BITWIDTH;            /* FCoE packet */
746f2b7e78dSVipul Pandya 	uint32_t iport:IPORT_BITWIDTH;          /* ingress port */
747f2b7e78dSVipul Pandya 	uint32_t matchtype:MATCHTYPE_BITWIDTH;  /* MPS match type */
748f2b7e78dSVipul Pandya 	uint32_t proto:PROTO_BITWIDTH;          /* protocol type */
749f2b7e78dSVipul Pandya 	uint32_t tos:TOS_BITWIDTH;              /* TOS/Traffic Type */
750f2b7e78dSVipul Pandya 	uint32_t pf:PF_BITWIDTH;                /* PCI-E PF ID */
751f2b7e78dSVipul Pandya 	uint32_t vf:VF_BITWIDTH;                /* PCI-E VF ID */
752f2b7e78dSVipul Pandya 	uint32_t ivlan:IVLAN_BITWIDTH;          /* inner VLAN */
753f2b7e78dSVipul Pandya 	uint32_t ovlan:OVLAN_BITWIDTH;          /* outer VLAN */
754f2b7e78dSVipul Pandya 
755f2b7e78dSVipul Pandya 	/* Uncompressed header matching field rules.  These are always
756f2b7e78dSVipul Pandya 	 * available for field rules.
757f2b7e78dSVipul Pandya 	 */
758f2b7e78dSVipul Pandya 	uint8_t lip[16];        /* local IP address (IPv4 in [3:0]) */
759f2b7e78dSVipul Pandya 	uint8_t fip[16];        /* foreign IP address (IPv4 in [3:0]) */
760f2b7e78dSVipul Pandya 	uint16_t lport;         /* local port */
761f2b7e78dSVipul Pandya 	uint16_t fport;         /* foreign port */
762f2b7e78dSVipul Pandya };
763f2b7e78dSVipul Pandya 
764f2b7e78dSVipul Pandya /* A filter ioctl command.
765f2b7e78dSVipul Pandya  */
766f2b7e78dSVipul Pandya struct ch_filter_specification {
767f2b7e78dSVipul Pandya 	/* Administrative fields for filter.
768f2b7e78dSVipul Pandya 	 */
769f2b7e78dSVipul Pandya 	uint32_t hitcnts:1;     /* count filter hits in TCB */
770f2b7e78dSVipul Pandya 	uint32_t prio:1;        /* filter has priority over active/server */
771f2b7e78dSVipul Pandya 
772f2b7e78dSVipul Pandya 	/* Fundamental filter typing.  This is the one element of filter
773f2b7e78dSVipul Pandya 	 * matching that doesn't exist as a (value, mask) tuple.
774f2b7e78dSVipul Pandya 	 */
775f2b7e78dSVipul Pandya 	uint32_t type:1;        /* 0 => IPv4, 1 => IPv6 */
776f2b7e78dSVipul Pandya 
777f2b7e78dSVipul Pandya 	/* Packet dispatch information.  Ingress packets which match the
778f2b7e78dSVipul Pandya 	 * filter rules will be dropped, passed to the host or switched back
779f2b7e78dSVipul Pandya 	 * out as egress packets.
780f2b7e78dSVipul Pandya 	 */
781f2b7e78dSVipul Pandya 	uint32_t action:2;      /* drop, pass, switch */
782f2b7e78dSVipul Pandya 
783f2b7e78dSVipul Pandya 	uint32_t rpttid:1;      /* report TID in RSS hash field */
784f2b7e78dSVipul Pandya 
785f2b7e78dSVipul Pandya 	uint32_t dirsteer:1;    /* 0 => RSS, 1 => steer to iq */
786f2b7e78dSVipul Pandya 	uint32_t iq:10;         /* ingress queue */
787f2b7e78dSVipul Pandya 
788f2b7e78dSVipul Pandya 	uint32_t maskhash:1;    /* dirsteer=0: store RSS hash in TCB */
789f2b7e78dSVipul Pandya 	uint32_t dirsteerhash:1;/* dirsteer=1: 0 => TCB contains RSS hash */
790f2b7e78dSVipul Pandya 				/*             1 => TCB contains IQ ID */
791f2b7e78dSVipul Pandya 
792f2b7e78dSVipul Pandya 	/* Switch proxy/rewrite fields.  An ingress packet which matches a
793f2b7e78dSVipul Pandya 	 * filter with "switch" set will be looped back out as an egress
794f2b7e78dSVipul Pandya 	 * packet -- potentially with some Ethernet header rewriting.
795f2b7e78dSVipul Pandya 	 */
796f2b7e78dSVipul Pandya 	uint32_t eport:2;       /* egress port to switch packet out */
797f2b7e78dSVipul Pandya 	uint32_t newdmac:1;     /* rewrite destination MAC address */
798f2b7e78dSVipul Pandya 	uint32_t newsmac:1;     /* rewrite source MAC address */
799f2b7e78dSVipul Pandya 	uint32_t newvlan:2;     /* rewrite VLAN Tag */
800f2b7e78dSVipul Pandya 	uint8_t dmac[ETH_ALEN]; /* new destination MAC address */
801f2b7e78dSVipul Pandya 	uint8_t smac[ETH_ALEN]; /* new source MAC address */
802f2b7e78dSVipul Pandya 	uint16_t vlan;          /* VLAN Tag to insert */
803f2b7e78dSVipul Pandya 
804f2b7e78dSVipul Pandya 	/* Filter rule value/mask pairs.
805f2b7e78dSVipul Pandya 	 */
806f2b7e78dSVipul Pandya 	struct ch_filter_tuple val;
807f2b7e78dSVipul Pandya 	struct ch_filter_tuple mask;
808f2b7e78dSVipul Pandya };
809f2b7e78dSVipul Pandya 
810f2b7e78dSVipul Pandya enum {
811f2b7e78dSVipul Pandya 	FILTER_PASS = 0,        /* default */
812f2b7e78dSVipul Pandya 	FILTER_DROP,
813f2b7e78dSVipul Pandya 	FILTER_SWITCH
814f2b7e78dSVipul Pandya };
815f2b7e78dSVipul Pandya 
816f2b7e78dSVipul Pandya enum {
817f2b7e78dSVipul Pandya 	VLAN_NOCHANGE = 0,      /* default */
818f2b7e78dSVipul Pandya 	VLAN_REMOVE,
819f2b7e78dSVipul Pandya 	VLAN_INSERT,
820f2b7e78dSVipul Pandya 	VLAN_REWRITE
821f2b7e78dSVipul Pandya };
822f2b7e78dSVipul Pandya 
8232422d9a3SSantosh Rastapur static inline int is_t5(enum chip_type chip)
8242422d9a3SSantosh Rastapur {
825d14807ddSHariprasad Shenai 	return CHELSIO_CHIP_VERSION(chip) == CHELSIO_T5;
8262422d9a3SSantosh Rastapur }
8272422d9a3SSantosh Rastapur 
8282422d9a3SSantosh Rastapur static inline int is_t4(enum chip_type chip)
8292422d9a3SSantosh Rastapur {
830d14807ddSHariprasad Shenai 	return CHELSIO_CHIP_VERSION(chip) == CHELSIO_T4;
8312422d9a3SSantosh Rastapur }
8322422d9a3SSantosh Rastapur 
833f7917c00SJeff Kirsher static inline u32 t4_read_reg(struct adapter *adap, u32 reg_addr)
834f7917c00SJeff Kirsher {
835f7917c00SJeff Kirsher 	return readl(adap->regs + reg_addr);
836f7917c00SJeff Kirsher }
837f7917c00SJeff Kirsher 
838f7917c00SJeff Kirsher static inline void t4_write_reg(struct adapter *adap, u32 reg_addr, u32 val)
839f7917c00SJeff Kirsher {
840f7917c00SJeff Kirsher 	writel(val, adap->regs + reg_addr);
841f7917c00SJeff Kirsher }
842f7917c00SJeff Kirsher 
843f7917c00SJeff Kirsher #ifndef readq
844f7917c00SJeff Kirsher static inline u64 readq(const volatile void __iomem *addr)
845f7917c00SJeff Kirsher {
846f7917c00SJeff Kirsher 	return readl(addr) + ((u64)readl(addr + 4) << 32);
847f7917c00SJeff Kirsher }
848f7917c00SJeff Kirsher 
849f7917c00SJeff Kirsher static inline void writeq(u64 val, volatile void __iomem *addr)
850f7917c00SJeff Kirsher {
851f7917c00SJeff Kirsher 	writel(val, addr);
852f7917c00SJeff Kirsher 	writel(val >> 32, addr + 4);
853f7917c00SJeff Kirsher }
854f7917c00SJeff Kirsher #endif
855f7917c00SJeff Kirsher 
856f7917c00SJeff Kirsher static inline u64 t4_read_reg64(struct adapter *adap, u32 reg_addr)
857f7917c00SJeff Kirsher {
858f7917c00SJeff Kirsher 	return readq(adap->regs + reg_addr);
859f7917c00SJeff Kirsher }
860f7917c00SJeff Kirsher 
861f7917c00SJeff Kirsher static inline void t4_write_reg64(struct adapter *adap, u32 reg_addr, u64 val)
862f7917c00SJeff Kirsher {
863f7917c00SJeff Kirsher 	writeq(val, adap->regs + reg_addr);
864f7917c00SJeff Kirsher }
865f7917c00SJeff Kirsher 
866f7917c00SJeff Kirsher /**
867f7917c00SJeff Kirsher  * netdev2pinfo - return the port_info structure associated with a net_device
868f7917c00SJeff Kirsher  * @dev: the netdev
869f7917c00SJeff Kirsher  *
870f7917c00SJeff Kirsher  * Return the struct port_info associated with a net_device
871f7917c00SJeff Kirsher  */
872f7917c00SJeff Kirsher static inline struct port_info *netdev2pinfo(const struct net_device *dev)
873f7917c00SJeff Kirsher {
874f7917c00SJeff Kirsher 	return netdev_priv(dev);
875f7917c00SJeff Kirsher }
876f7917c00SJeff Kirsher 
877f7917c00SJeff Kirsher /**
878f7917c00SJeff Kirsher  * adap2pinfo - return the port_info of a port
879f7917c00SJeff Kirsher  * @adap: the adapter
880f7917c00SJeff Kirsher  * @idx: the port index
881f7917c00SJeff Kirsher  *
882f7917c00SJeff Kirsher  * Return the port_info structure for the port of the given index.
883f7917c00SJeff Kirsher  */
884f7917c00SJeff Kirsher static inline struct port_info *adap2pinfo(struct adapter *adap, int idx)
885f7917c00SJeff Kirsher {
886f7917c00SJeff Kirsher 	return netdev_priv(adap->port[idx]);
887f7917c00SJeff Kirsher }
888f7917c00SJeff Kirsher 
889f7917c00SJeff Kirsher /**
890f7917c00SJeff Kirsher  * netdev2adap - return the adapter structure associated with a net_device
891f7917c00SJeff Kirsher  * @dev: the netdev
892f7917c00SJeff Kirsher  *
893f7917c00SJeff Kirsher  * Return the struct adapter associated with a net_device
894f7917c00SJeff Kirsher  */
895f7917c00SJeff Kirsher static inline struct adapter *netdev2adap(const struct net_device *dev)
896f7917c00SJeff Kirsher {
897f7917c00SJeff Kirsher 	return netdev2pinfo(dev)->adapter;
898f7917c00SJeff Kirsher }
899f7917c00SJeff Kirsher 
9003a336cb1SHariprasad Shenai #ifdef CONFIG_NET_RX_BUSY_POLL
9013a336cb1SHariprasad Shenai static inline void cxgb_busy_poll_init_lock(struct sge_rspq *q)
9023a336cb1SHariprasad Shenai {
9033a336cb1SHariprasad Shenai 	spin_lock_init(&q->bpoll_lock);
9043a336cb1SHariprasad Shenai 	q->bpoll_state = CXGB_POLL_STATE_IDLE;
9053a336cb1SHariprasad Shenai }
9063a336cb1SHariprasad Shenai 
9073a336cb1SHariprasad Shenai static inline bool cxgb_poll_lock_napi(struct sge_rspq *q)
9083a336cb1SHariprasad Shenai {
9093a336cb1SHariprasad Shenai 	bool rc = true;
9103a336cb1SHariprasad Shenai 
9113a336cb1SHariprasad Shenai 	spin_lock(&q->bpoll_lock);
9123a336cb1SHariprasad Shenai 	if (q->bpoll_state & CXGB_POLL_LOCKED) {
9133a336cb1SHariprasad Shenai 		q->bpoll_state |= CXGB_POLL_STATE_NAPI_YIELD;
9143a336cb1SHariprasad Shenai 		rc = false;
9153a336cb1SHariprasad Shenai 	} else {
9163a336cb1SHariprasad Shenai 		q->bpoll_state = CXGB_POLL_STATE_NAPI;
9173a336cb1SHariprasad Shenai 	}
9183a336cb1SHariprasad Shenai 	spin_unlock(&q->bpoll_lock);
9193a336cb1SHariprasad Shenai 	return rc;
9203a336cb1SHariprasad Shenai }
9213a336cb1SHariprasad Shenai 
9223a336cb1SHariprasad Shenai static inline bool cxgb_poll_unlock_napi(struct sge_rspq *q)
9233a336cb1SHariprasad Shenai {
9243a336cb1SHariprasad Shenai 	bool rc = false;
9253a336cb1SHariprasad Shenai 
9263a336cb1SHariprasad Shenai 	spin_lock(&q->bpoll_lock);
9273a336cb1SHariprasad Shenai 	if (q->bpoll_state & CXGB_POLL_STATE_POLL_YIELD)
9283a336cb1SHariprasad Shenai 		rc = true;
9293a336cb1SHariprasad Shenai 	q->bpoll_state = CXGB_POLL_STATE_IDLE;
9303a336cb1SHariprasad Shenai 	spin_unlock(&q->bpoll_lock);
9313a336cb1SHariprasad Shenai 	return rc;
9323a336cb1SHariprasad Shenai }
9333a336cb1SHariprasad Shenai 
9343a336cb1SHariprasad Shenai static inline bool cxgb_poll_lock_poll(struct sge_rspq *q)
9353a336cb1SHariprasad Shenai {
9363a336cb1SHariprasad Shenai 	bool rc = true;
9373a336cb1SHariprasad Shenai 
9383a336cb1SHariprasad Shenai 	spin_lock_bh(&q->bpoll_lock);
9393a336cb1SHariprasad Shenai 	if (q->bpoll_state & CXGB_POLL_LOCKED) {
9403a336cb1SHariprasad Shenai 		q->bpoll_state |= CXGB_POLL_STATE_POLL_YIELD;
9413a336cb1SHariprasad Shenai 		rc = false;
9423a336cb1SHariprasad Shenai 	} else {
9433a336cb1SHariprasad Shenai 		q->bpoll_state |= CXGB_POLL_STATE_POLL;
9443a336cb1SHariprasad Shenai 	}
9453a336cb1SHariprasad Shenai 	spin_unlock_bh(&q->bpoll_lock);
9463a336cb1SHariprasad Shenai 	return rc;
9473a336cb1SHariprasad Shenai }
9483a336cb1SHariprasad Shenai 
9493a336cb1SHariprasad Shenai static inline bool cxgb_poll_unlock_poll(struct sge_rspq *q)
9503a336cb1SHariprasad Shenai {
9513a336cb1SHariprasad Shenai 	bool rc = false;
9523a336cb1SHariprasad Shenai 
9533a336cb1SHariprasad Shenai 	spin_lock_bh(&q->bpoll_lock);
9543a336cb1SHariprasad Shenai 	if (q->bpoll_state & CXGB_POLL_STATE_POLL_YIELD)
9553a336cb1SHariprasad Shenai 		rc = true;
9563a336cb1SHariprasad Shenai 	q->bpoll_state = CXGB_POLL_STATE_IDLE;
9573a336cb1SHariprasad Shenai 	spin_unlock_bh(&q->bpoll_lock);
9583a336cb1SHariprasad Shenai 	return rc;
9593a336cb1SHariprasad Shenai }
9603a336cb1SHariprasad Shenai 
9613a336cb1SHariprasad Shenai static inline bool cxgb_poll_busy_polling(struct sge_rspq *q)
9623a336cb1SHariprasad Shenai {
9633a336cb1SHariprasad Shenai 	return q->bpoll_state & CXGB_POLL_USER_PEND;
9643a336cb1SHariprasad Shenai }
9653a336cb1SHariprasad Shenai #else
9663a336cb1SHariprasad Shenai static inline void cxgb_busy_poll_init_lock(struct sge_rspq *q)
9673a336cb1SHariprasad Shenai {
9683a336cb1SHariprasad Shenai }
9693a336cb1SHariprasad Shenai 
9703a336cb1SHariprasad Shenai static inline bool cxgb_poll_lock_napi(struct sge_rspq *q)
9713a336cb1SHariprasad Shenai {
9723a336cb1SHariprasad Shenai 	return true;
9733a336cb1SHariprasad Shenai }
9743a336cb1SHariprasad Shenai 
9753a336cb1SHariprasad Shenai static inline bool cxgb_poll_unlock_napi(struct sge_rspq *q)
9763a336cb1SHariprasad Shenai {
9773a336cb1SHariprasad Shenai 	return false;
9783a336cb1SHariprasad Shenai }
9793a336cb1SHariprasad Shenai 
9803a336cb1SHariprasad Shenai static inline bool cxgb_poll_lock_poll(struct sge_rspq *q)
9813a336cb1SHariprasad Shenai {
9823a336cb1SHariprasad Shenai 	return false;
9833a336cb1SHariprasad Shenai }
9843a336cb1SHariprasad Shenai 
9853a336cb1SHariprasad Shenai static inline bool cxgb_poll_unlock_poll(struct sge_rspq *q)
9863a336cb1SHariprasad Shenai {
9873a336cb1SHariprasad Shenai 	return false;
9883a336cb1SHariprasad Shenai }
9893a336cb1SHariprasad Shenai 
9903a336cb1SHariprasad Shenai static inline bool cxgb_poll_busy_polling(struct sge_rspq *q)
9913a336cb1SHariprasad Shenai {
9923a336cb1SHariprasad Shenai 	return false;
9933a336cb1SHariprasad Shenai }
9943a336cb1SHariprasad Shenai #endif /* CONFIG_NET_RX_BUSY_POLL */
9953a336cb1SHariprasad Shenai 
996f7917c00SJeff Kirsher void t4_os_portmod_changed(const struct adapter *adap, int port_id);
997f7917c00SJeff Kirsher void t4_os_link_changed(struct adapter *adap, int port_id, int link_stat);
998f7917c00SJeff Kirsher 
999f7917c00SJeff Kirsher void *t4_alloc_mem(size_t size);
1000f7917c00SJeff Kirsher 
1001f7917c00SJeff Kirsher void t4_free_sge_resources(struct adapter *adap);
10025fa76694SHariprasad Shenai void t4_free_ofld_rxqs(struct adapter *adap, int n, struct sge_ofld_rxq *q);
1003f7917c00SJeff Kirsher irq_handler_t t4_intr_handler(struct adapter *adap);
1004f7917c00SJeff Kirsher netdev_tx_t t4_eth_xmit(struct sk_buff *skb, struct net_device *dev);
1005f7917c00SJeff Kirsher int t4_ethrx_handler(struct sge_rspq *q, const __be64 *rsp,
1006f7917c00SJeff Kirsher 		     const struct pkt_gl *gl);
1007f7917c00SJeff Kirsher int t4_mgmt_tx(struct adapter *adap, struct sk_buff *skb);
1008f7917c00SJeff Kirsher int t4_ofld_send(struct adapter *adap, struct sk_buff *skb);
1009f7917c00SJeff Kirsher int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
1010f7917c00SJeff Kirsher 		     struct net_device *dev, int intr_idx,
1011f7917c00SJeff Kirsher 		     struct sge_fl *fl, rspq_handler_t hnd);
1012f7917c00SJeff Kirsher int t4_sge_alloc_eth_txq(struct adapter *adap, struct sge_eth_txq *txq,
1013f7917c00SJeff Kirsher 			 struct net_device *dev, struct netdev_queue *netdevq,
1014f7917c00SJeff Kirsher 			 unsigned int iqid);
1015f7917c00SJeff Kirsher int t4_sge_alloc_ctrl_txq(struct adapter *adap, struct sge_ctrl_txq *txq,
1016f7917c00SJeff Kirsher 			  struct net_device *dev, unsigned int iqid,
1017f7917c00SJeff Kirsher 			  unsigned int cmplqid);
1018f7917c00SJeff Kirsher int t4_sge_alloc_ofld_txq(struct adapter *adap, struct sge_ofld_txq *txq,
1019f7917c00SJeff Kirsher 			  struct net_device *dev, unsigned int iqid);
1020f7917c00SJeff Kirsher irqreturn_t t4_sge_intr_msix(int irq, void *cookie);
102152367a76SVipul Pandya int t4_sge_init(struct adapter *adap);
1022f7917c00SJeff Kirsher void t4_sge_start(struct adapter *adap);
1023f7917c00SJeff Kirsher void t4_sge_stop(struct adapter *adap);
10243a336cb1SHariprasad Shenai int cxgb_busy_poll(struct napi_struct *napi);
10253069ee9bSVipul Pandya extern int dbfifo_int_thresh;
1026f7917c00SJeff Kirsher 
1027f7917c00SJeff Kirsher #define for_each_port(adapter, iter) \
1028f7917c00SJeff Kirsher 	for (iter = 0; iter < (adapter)->params.nports; ++iter)
1029f7917c00SJeff Kirsher 
10309a4da2cdSVipul Pandya static inline int is_bypass(struct adapter *adap)
10319a4da2cdSVipul Pandya {
10329a4da2cdSVipul Pandya 	return adap->params.bypass;
10339a4da2cdSVipul Pandya }
10349a4da2cdSVipul Pandya 
10359a4da2cdSVipul Pandya static inline int is_bypass_device(int device)
10369a4da2cdSVipul Pandya {
10379a4da2cdSVipul Pandya 	/* this should be set based upon device capabilities */
10389a4da2cdSVipul Pandya 	switch (device) {
10399a4da2cdSVipul Pandya 	case 0x440b:
10409a4da2cdSVipul Pandya 	case 0x440c:
10419a4da2cdSVipul Pandya 		return 1;
10429a4da2cdSVipul Pandya 	default:
10439a4da2cdSVipul Pandya 		return 0;
10449a4da2cdSVipul Pandya 	}
10459a4da2cdSVipul Pandya }
10469a4da2cdSVipul Pandya 
1047f7917c00SJeff Kirsher static inline unsigned int core_ticks_per_usec(const struct adapter *adap)
1048f7917c00SJeff Kirsher {
1049f7917c00SJeff Kirsher 	return adap->params.vpd.cclk / 1000;
1050f7917c00SJeff Kirsher }
1051f7917c00SJeff Kirsher 
1052f7917c00SJeff Kirsher static inline unsigned int us_to_core_ticks(const struct adapter *adap,
1053f7917c00SJeff Kirsher 					    unsigned int us)
1054f7917c00SJeff Kirsher {
1055f7917c00SJeff Kirsher 	return (us * adap->params.vpd.cclk) / 1000;
1056f7917c00SJeff Kirsher }
1057f7917c00SJeff Kirsher 
105852367a76SVipul Pandya static inline unsigned int core_ticks_to_us(const struct adapter *adapter,
105952367a76SVipul Pandya 					    unsigned int ticks)
106052367a76SVipul Pandya {
106152367a76SVipul Pandya 	/* add Core Clock / 2 to round ticks to nearest uS */
106252367a76SVipul Pandya 	return ((ticks * 1000 + adapter->params.vpd.cclk/2) /
106352367a76SVipul Pandya 		adapter->params.vpd.cclk);
106452367a76SVipul Pandya }
106552367a76SVipul Pandya 
1066f7917c00SJeff Kirsher void t4_set_reg_field(struct adapter *adap, unsigned int addr, u32 mask,
1067f7917c00SJeff Kirsher 		      u32 val);
1068f7917c00SJeff Kirsher 
1069f7917c00SJeff Kirsher int t4_wr_mbox_meat(struct adapter *adap, int mbox, const void *cmd, int size,
1070f7917c00SJeff Kirsher 		    void *rpl, bool sleep_ok);
1071f7917c00SJeff Kirsher 
1072f7917c00SJeff Kirsher static inline int t4_wr_mbox(struct adapter *adap, int mbox, const void *cmd,
1073f7917c00SJeff Kirsher 			     int size, void *rpl)
1074f7917c00SJeff Kirsher {
1075f7917c00SJeff Kirsher 	return t4_wr_mbox_meat(adap, mbox, cmd, size, rpl, true);
1076f7917c00SJeff Kirsher }
1077f7917c00SJeff Kirsher 
1078f7917c00SJeff Kirsher static inline int t4_wr_mbox_ns(struct adapter *adap, int mbox, const void *cmd,
1079f7917c00SJeff Kirsher 				int size, void *rpl)
1080f7917c00SJeff Kirsher {
1081f7917c00SJeff Kirsher 	return t4_wr_mbox_meat(adap, mbox, cmd, size, rpl, false);
1082f7917c00SJeff Kirsher }
1083f7917c00SJeff Kirsher 
108413ee15d3SVipul Pandya void t4_write_indirect(struct adapter *adap, unsigned int addr_reg,
108513ee15d3SVipul Pandya 		       unsigned int data_reg, const u32 *vals,
108613ee15d3SVipul Pandya 		       unsigned int nregs, unsigned int start_idx);
1087f2b7e78dSVipul Pandya void t4_read_indirect(struct adapter *adap, unsigned int addr_reg,
1088f2b7e78dSVipul Pandya 		      unsigned int data_reg, u32 *vals, unsigned int nregs,
1089f2b7e78dSVipul Pandya 		      unsigned int start_idx);
10900abfd152SHariprasad Shenai void t4_hw_pci_read_cfg4(struct adapter *adapter, int reg, u32 *val);
1091f2b7e78dSVipul Pandya 
1092f2b7e78dSVipul Pandya struct fw_filter_wr;
1093f2b7e78dSVipul Pandya 
1094f7917c00SJeff Kirsher void t4_intr_enable(struct adapter *adapter);
1095f7917c00SJeff Kirsher void t4_intr_disable(struct adapter *adapter);
1096f7917c00SJeff Kirsher int t4_slow_intr_handler(struct adapter *adapter);
1097f7917c00SJeff Kirsher 
10988203b509SHariprasad Shenai int t4_wait_dev_ready(void __iomem *regs);
1099f7917c00SJeff Kirsher int t4_link_start(struct adapter *adap, unsigned int mbox, unsigned int port,
1100f7917c00SJeff Kirsher 		  struct link_config *lc);
1101f7917c00SJeff Kirsher int t4_restart_aneg(struct adapter *adap, unsigned int mbox, unsigned int port);
1102fc5ab020SHariprasad Shenai 
1103fc5ab020SHariprasad Shenai #define T4_MEMORY_WRITE	0
1104fc5ab020SHariprasad Shenai #define T4_MEMORY_READ	1
1105fc5ab020SHariprasad Shenai int t4_memory_rw(struct adapter *adap, int win, int mtype, u32 addr, u32 len,
1106f01aa633SHariprasad Shenai 		 void *buf, int dir);
1107fc5ab020SHariprasad Shenai static inline int t4_memory_write(struct adapter *adap, int mtype, u32 addr,
1108fc5ab020SHariprasad Shenai 				  u32 len, __be32 *buf)
1109fc5ab020SHariprasad Shenai {
1110fc5ab020SHariprasad Shenai 	return t4_memory_rw(adap, 0, mtype, addr, len, buf, 0);
1111fc5ab020SHariprasad Shenai }
1112fc5ab020SHariprasad Shenai 
1113f7917c00SJeff Kirsher int t4_seeprom_wp(struct adapter *adapter, bool enable);
1114636f9d37SVipul Pandya int get_vpd_params(struct adapter *adapter, struct vpd_params *p);
111549216c1cSHariprasad Shenai int t4_read_flash(struct adapter *adapter, unsigned int addr,
111649216c1cSHariprasad Shenai 		  unsigned int nwords, u32 *data, int byte_oriented);
1117f7917c00SJeff Kirsher int t4_load_fw(struct adapter *adapter, const u8 *fw_data, unsigned int size);
111849216c1cSHariprasad Shenai int t4_fwcache(struct adapter *adap, enum fw_params_param_dev_fwcache op);
111922c0b963SHariprasad Shenai int t4_fw_upgrade(struct adapter *adap, unsigned int mbox,
112022c0b963SHariprasad Shenai 		  const u8 *fw_data, unsigned int size, int force);
1121636f9d37SVipul Pandya unsigned int t4_flash_cfg_addr(struct adapter *adapter);
112216e47624SHariprasad Shenai int t4_get_fw_version(struct adapter *adapter, u32 *vers);
112316e47624SHariprasad Shenai int t4_get_tp_version(struct adapter *adapter, u32 *vers);
1124ba3f8cd5SHariprasad Shenai int t4_get_exprom_version(struct adapter *adapter, u32 *vers);
112516e47624SHariprasad Shenai int t4_prep_fw(struct adapter *adap, struct fw_info *fw_info,
112616e47624SHariprasad Shenai 	       const u8 *fw_data, unsigned int fw_size,
112716e47624SHariprasad Shenai 	       struct fw_hdr *card_fw, enum dev_state state, int *reset);
1128f7917c00SJeff Kirsher int t4_prep_adapter(struct adapter *adapter);
1129e85c9a7aSHariprasad Shenai 
1130e85c9a7aSHariprasad Shenai enum t4_bar2_qtype { T4_BAR2_QTYPE_EGRESS, T4_BAR2_QTYPE_INGRESS };
1131dd0bcc0bSStephen Rothwell int cxgb4_t4_bar2_sge_qregs(struct adapter *adapter,
1132e85c9a7aSHariprasad Shenai 		      unsigned int qid,
1133e85c9a7aSHariprasad Shenai 		      enum t4_bar2_qtype qtype,
1134e85c9a7aSHariprasad Shenai 		      u64 *pbar2_qoffset,
1135e85c9a7aSHariprasad Shenai 		      unsigned int *pbar2_qid);
1136e85c9a7aSHariprasad Shenai 
1137dc9daab2SHariprasad Shenai unsigned int qtimer_val(const struct adapter *adap,
1138dc9daab2SHariprasad Shenai 			const struct sge_rspq *q);
1139ae469b68SHariprasad Shenai 
1140ae469b68SHariprasad Shenai int t4_init_devlog_params(struct adapter *adapter);
1141e85c9a7aSHariprasad Shenai int t4_init_sge_params(struct adapter *adapter);
1142dcf7b6f5SKumar Sanghvi int t4_init_tp_params(struct adapter *adap);
1143dcf7b6f5SKumar Sanghvi int t4_filter_field_shift(const struct adapter *adap, int filter_sel);
1144f7917c00SJeff Kirsher int t4_port_init(struct adapter *adap, int mbox, int pf, int vf);
1145f7917c00SJeff Kirsher void t4_fatal_err(struct adapter *adapter);
1146f7917c00SJeff Kirsher int t4_config_rss_range(struct adapter *adapter, int mbox, unsigned int viid,
1147f7917c00SJeff Kirsher 			int start, int n, const u16 *rspq, unsigned int nrspq);
1148f7917c00SJeff Kirsher int t4_config_glbl_rss(struct adapter *adapter, int mbox, unsigned int mode,
1149f7917c00SJeff Kirsher 		       unsigned int flags);
1150688ea5feSHariprasad Shenai int t4_read_rss(struct adapter *adapter, u16 *entries);
1151688ea5feSHariprasad Shenai void t4_read_rss_key(struct adapter *adapter, u32 *key);
1152688ea5feSHariprasad Shenai void t4_write_rss_key(struct adapter *adap, const u32 *key, int idx);
1153688ea5feSHariprasad Shenai void t4_read_rss_pf_config(struct adapter *adapter, unsigned int index,
1154688ea5feSHariprasad Shenai 			   u32 *valp);
1155688ea5feSHariprasad Shenai void t4_read_rss_vf_config(struct adapter *adapter, unsigned int index,
1156688ea5feSHariprasad Shenai 			   u32 *vfl, u32 *vfh);
1157688ea5feSHariprasad Shenai u32 t4_read_rss_pf_map(struct adapter *adapter);
1158688ea5feSHariprasad Shenai u32 t4_read_rss_pf_mask(struct adapter *adapter);
1159688ea5feSHariprasad Shenai 
116019dd37baSSantosh Rastapur int t4_mc_read(struct adapter *adap, int idx, u32 addr, __be32 *data,
116119dd37baSSantosh Rastapur 	       u64 *parity);
1162f7917c00SJeff Kirsher int t4_edc_read(struct adapter *adap, int idx, u32 addr, __be32 *data,
1163f7917c00SJeff Kirsher 		u64 *parity);
1164b3bbe36aSHariprasad Shenai void t4_pmtx_get_stats(struct adapter *adap, u32 cnt[], u64 cycles[]);
1165b3bbe36aSHariprasad Shenai void t4_pmrx_get_stats(struct adapter *adap, u32 cnt[], u64 cycles[]);
1166e5f0e43bSHariprasad Shenai int t4_read_cim_ibq(struct adapter *adap, unsigned int qid, u32 *data,
1167e5f0e43bSHariprasad Shenai 		    size_t n);
1168c778af7dSHariprasad Shenai int t4_read_cim_obq(struct adapter *adap, unsigned int qid, u32 *data,
1169c778af7dSHariprasad Shenai 		    size_t n);
1170f1ff24aaSHariprasad Shenai int t4_cim_read(struct adapter *adap, unsigned int addr, unsigned int n,
1171f1ff24aaSHariprasad Shenai 		unsigned int *valp);
1172f1ff24aaSHariprasad Shenai int t4_cim_write(struct adapter *adap, unsigned int addr, unsigned int n,
1173f1ff24aaSHariprasad Shenai 		 const unsigned int *valp);
1174f1ff24aaSHariprasad Shenai int t4_cim_read_la(struct adapter *adap, u32 *la_buf, unsigned int *wrptr);
117574b3092cSHariprasad Shenai void t4_read_cimq_cfg(struct adapter *adap, u16 *base, u16 *size, u16 *thres);
117672aca4bfSKumar Sanghvi const char *t4_get_port_type_description(enum fw_port_type port_type);
1177f7917c00SJeff Kirsher void t4_get_port_stats(struct adapter *adap, int idx, struct port_stats *p);
1178f7917c00SJeff Kirsher void t4_read_mtu_tbl(struct adapter *adap, u16 *mtus, u8 *mtu_log);
1179bad43792SHariprasad Shenai void t4_read_cong_tbl(struct adapter *adap, u16 incr[NMTUS][NCCTRL_WIN]);
1180636f9d37SVipul Pandya void t4_tp_wr_bits_indirect(struct adapter *adap, unsigned int addr,
1181636f9d37SVipul Pandya 			    unsigned int mask, unsigned int val);
11822d277b3bSHariprasad Shenai void t4_tp_read_la(struct adapter *adap, u64 *la_buf, unsigned int *wrptr);
1183f7917c00SJeff Kirsher void t4_tp_get_tcp_stats(struct adapter *adap, struct tp_tcp_stats *v4,
1184f7917c00SJeff Kirsher 			 struct tp_tcp_stats *v6);
1185f7917c00SJeff Kirsher void t4_load_mtus(struct adapter *adap, const unsigned short *mtus,
1186f7917c00SJeff Kirsher 		  const unsigned short *alpha, const unsigned short *beta);
1187f7917c00SJeff Kirsher 
1188797ff0f5SHariprasad Shenai void t4_ulprx_read_la(struct adapter *adap, u32 *la_buf);
1189797ff0f5SHariprasad Shenai 
1190f2b7e78dSVipul Pandya void t4_mk_filtdelwr(unsigned int ftid, struct fw_filter_wr *wr, int qid);
1191f2b7e78dSVipul Pandya 
1192f7917c00SJeff Kirsher void t4_wol_magic_enable(struct adapter *adap, unsigned int port,
1193f7917c00SJeff Kirsher 			 const u8 *addr);
1194f7917c00SJeff Kirsher int t4_wol_pat_enable(struct adapter *adap, unsigned int port, unsigned int map,
1195f7917c00SJeff Kirsher 		      u64 mask0, u64 mask1, unsigned int crc, bool enable);
1196f7917c00SJeff Kirsher 
1197f7917c00SJeff Kirsher int t4_fw_hello(struct adapter *adap, unsigned int mbox, unsigned int evt_mbox,
1198f7917c00SJeff Kirsher 		enum dev_master master, enum dev_state *state);
1199f7917c00SJeff Kirsher int t4_fw_bye(struct adapter *adap, unsigned int mbox);
1200f7917c00SJeff Kirsher int t4_early_init(struct adapter *adap, unsigned int mbox);
1201f7917c00SJeff Kirsher int t4_fw_reset(struct adapter *adap, unsigned int mbox, int reset);
1202636f9d37SVipul Pandya int t4_fixup_host_params(struct adapter *adap, unsigned int page_size,
1203636f9d37SVipul Pandya 			  unsigned int cache_line_size);
1204636f9d37SVipul Pandya int t4_fw_initialize(struct adapter *adap, unsigned int mbox);
1205f7917c00SJeff Kirsher int t4_query_params(struct adapter *adap, unsigned int mbox, unsigned int pf,
1206f7917c00SJeff Kirsher 		    unsigned int vf, unsigned int nparams, const u32 *params,
1207f7917c00SJeff Kirsher 		    u32 *val);
1208f7917c00SJeff Kirsher int t4_set_params(struct adapter *adap, unsigned int mbox, unsigned int pf,
1209f7917c00SJeff Kirsher 		  unsigned int vf, unsigned int nparams, const u32 *params,
1210f7917c00SJeff Kirsher 		  const u32 *val);
1211688848b1SAnish Bhatt int t4_set_params_nosleep(struct adapter *adap, unsigned int mbox,
1212688848b1SAnish Bhatt 			  unsigned int pf, unsigned int vf,
1213688848b1SAnish Bhatt 			  unsigned int nparams, const u32 *params,
1214688848b1SAnish Bhatt 			  const u32 *val);
1215f7917c00SJeff Kirsher int t4_cfg_pfvf(struct adapter *adap, unsigned int mbox, unsigned int pf,
1216f7917c00SJeff Kirsher 		unsigned int vf, unsigned int txq, unsigned int txq_eth_ctrl,
1217f7917c00SJeff Kirsher 		unsigned int rxqi, unsigned int rxq, unsigned int tc,
1218f7917c00SJeff Kirsher 		unsigned int vi, unsigned int cmask, unsigned int pmask,
1219f7917c00SJeff Kirsher 		unsigned int nexact, unsigned int rcaps, unsigned int wxcaps);
1220f7917c00SJeff Kirsher int t4_alloc_vi(struct adapter *adap, unsigned int mbox, unsigned int port,
1221f7917c00SJeff Kirsher 		unsigned int pf, unsigned int vf, unsigned int nmac, u8 *mac,
1222f7917c00SJeff Kirsher 		unsigned int *rss_size);
1223f7917c00SJeff Kirsher int t4_set_rxmode(struct adapter *adap, unsigned int mbox, unsigned int viid,
1224f7917c00SJeff Kirsher 		int mtu, int promisc, int all_multi, int bcast, int vlanex,
1225f7917c00SJeff Kirsher 		bool sleep_ok);
1226f7917c00SJeff Kirsher int t4_alloc_mac_filt(struct adapter *adap, unsigned int mbox,
1227f7917c00SJeff Kirsher 		      unsigned int viid, bool free, unsigned int naddr,
1228f7917c00SJeff Kirsher 		      const u8 **addr, u16 *idx, u64 *hash, bool sleep_ok);
1229f7917c00SJeff Kirsher int t4_change_mac(struct adapter *adap, unsigned int mbox, unsigned int viid,
1230f7917c00SJeff Kirsher 		  int idx, const u8 *addr, bool persist, bool add_smt);
1231f7917c00SJeff Kirsher int t4_set_addr_hash(struct adapter *adap, unsigned int mbox, unsigned int viid,
1232f7917c00SJeff Kirsher 		     bool ucast, u64 vec, bool sleep_ok);
1233688848b1SAnish Bhatt int t4_enable_vi_params(struct adapter *adap, unsigned int mbox,
1234688848b1SAnish Bhatt 			unsigned int viid, bool rx_en, bool tx_en, bool dcb_en);
1235f7917c00SJeff Kirsher int t4_enable_vi(struct adapter *adap, unsigned int mbox, unsigned int viid,
1236f7917c00SJeff Kirsher 		 bool rx_en, bool tx_en);
1237f7917c00SJeff Kirsher int t4_identify_port(struct adapter *adap, unsigned int mbox, unsigned int viid,
1238f7917c00SJeff Kirsher 		     unsigned int nblinks);
1239f7917c00SJeff Kirsher int t4_mdio_rd(struct adapter *adap, unsigned int mbox, unsigned int phy_addr,
1240f7917c00SJeff Kirsher 	       unsigned int mmd, unsigned int reg, u16 *valp);
1241f7917c00SJeff Kirsher int t4_mdio_wr(struct adapter *adap, unsigned int mbox, unsigned int phy_addr,
1242f7917c00SJeff Kirsher 	       unsigned int mmd, unsigned int reg, u16 val);
1243f7917c00SJeff Kirsher int t4_iq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
1244f7917c00SJeff Kirsher 	       unsigned int vf, unsigned int iqtype, unsigned int iqid,
1245f7917c00SJeff Kirsher 	       unsigned int fl0id, unsigned int fl1id);
1246f7917c00SJeff Kirsher int t4_eth_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
1247f7917c00SJeff Kirsher 		   unsigned int vf, unsigned int eqid);
1248f7917c00SJeff Kirsher int t4_ctrl_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
1249f7917c00SJeff Kirsher 		    unsigned int vf, unsigned int eqid);
1250f7917c00SJeff Kirsher int t4_ofld_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
1251f7917c00SJeff Kirsher 		    unsigned int vf, unsigned int eqid);
1252f7917c00SJeff Kirsher int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl);
1253881806bcSVipul Pandya void t4_db_full(struct adapter *adapter);
1254881806bcSVipul Pandya void t4_db_dropped(struct adapter *adapter);
12558caa1e84SVipul Pandya int t4_fwaddrspace_write(struct adapter *adap, unsigned int mbox,
12568caa1e84SVipul Pandya 			 u32 addr, u32 val);
125768bce192SKumar Sanghvi void t4_sge_decode_idma_state(struct adapter *adapter, int state);
1258fd88b31aSHariprasad Shenai void t4_free_mem(void *addr);
1259f7917c00SJeff Kirsher #endif /* __CXGB4_H__ */
1260