1f7917c00SJeff Kirsher /*
2f7917c00SJeff Kirsher  * This file is part of the Chelsio T4 Ethernet driver for Linux.
3f7917c00SJeff Kirsher  *
4f7917c00SJeff Kirsher  * Copyright (c) 2003-2010 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 
38f7917c00SJeff Kirsher #include <linux/bitops.h>
39f7917c00SJeff Kirsher #include <linux/cache.h>
40f7917c00SJeff Kirsher #include <linux/interrupt.h>
41f7917c00SJeff Kirsher #include <linux/list.h>
42f7917c00SJeff Kirsher #include <linux/netdevice.h>
43f7917c00SJeff Kirsher #include <linux/pci.h>
44f7917c00SJeff Kirsher #include <linux/spinlock.h>
45f7917c00SJeff Kirsher #include <linux/timer.h>
46f7917c00SJeff Kirsher #include <asm/io.h>
47f7917c00SJeff Kirsher #include "cxgb4_uld.h"
48f7917c00SJeff Kirsher #include "t4_hw.h"
49f7917c00SJeff Kirsher 
50f7917c00SJeff Kirsher #define FW_VERSION_MAJOR 1
51f7917c00SJeff Kirsher #define FW_VERSION_MINOR 1
52f7917c00SJeff Kirsher #define FW_VERSION_MICRO 0
53f7917c00SJeff Kirsher 
543069ee9bSVipul Pandya #define CH_WARN(adap, fmt, ...) dev_warn(adap->pdev_dev, fmt, ## __VA_ARGS__)
553069ee9bSVipul Pandya 
56f7917c00SJeff Kirsher enum {
57f7917c00SJeff Kirsher 	MAX_NPORTS = 4,     /* max # of ports */
58f7917c00SJeff Kirsher 	SERNUM_LEN = 24,    /* Serial # length */
59f7917c00SJeff Kirsher 	EC_LEN     = 16,    /* E/C length */
60f7917c00SJeff Kirsher 	ID_LEN     = 16,    /* ID length */
61f7917c00SJeff Kirsher };
62f7917c00SJeff Kirsher 
63f7917c00SJeff Kirsher enum {
64f7917c00SJeff Kirsher 	MEM_EDC0,
65f7917c00SJeff Kirsher 	MEM_EDC1,
66f7917c00SJeff Kirsher 	MEM_MC
67f7917c00SJeff Kirsher };
68f7917c00SJeff Kirsher 
693069ee9bSVipul Pandya enum {
703eb4afbfSVipul Pandya 	MEMWIN0_APERTURE = 2048,
713eb4afbfSVipul Pandya 	MEMWIN0_BASE     = 0x1b800,
723069ee9bSVipul Pandya 	MEMWIN1_APERTURE = 32768,
733069ee9bSVipul Pandya 	MEMWIN1_BASE     = 0x28000,
743eb4afbfSVipul Pandya 	MEMWIN2_APERTURE = 65536,
753eb4afbfSVipul Pandya 	MEMWIN2_BASE     = 0x30000,
763069ee9bSVipul Pandya };
773069ee9bSVipul Pandya 
78f7917c00SJeff Kirsher enum dev_master {
79f7917c00SJeff Kirsher 	MASTER_CANT,
80f7917c00SJeff Kirsher 	MASTER_MAY,
81f7917c00SJeff Kirsher 	MASTER_MUST
82f7917c00SJeff Kirsher };
83f7917c00SJeff Kirsher 
84f7917c00SJeff Kirsher enum dev_state {
85f7917c00SJeff Kirsher 	DEV_STATE_UNINIT,
86f7917c00SJeff Kirsher 	DEV_STATE_INIT,
87f7917c00SJeff Kirsher 	DEV_STATE_ERR
88f7917c00SJeff Kirsher };
89f7917c00SJeff Kirsher 
90f7917c00SJeff Kirsher enum {
91f7917c00SJeff Kirsher 	PAUSE_RX      = 1 << 0,
92f7917c00SJeff Kirsher 	PAUSE_TX      = 1 << 1,
93f7917c00SJeff Kirsher 	PAUSE_AUTONEG = 1 << 2
94f7917c00SJeff Kirsher };
95f7917c00SJeff Kirsher 
96f7917c00SJeff Kirsher struct port_stats {
97f7917c00SJeff Kirsher 	u64 tx_octets;            /* total # of octets in good frames */
98f7917c00SJeff Kirsher 	u64 tx_frames;            /* all good frames */
99f7917c00SJeff Kirsher 	u64 tx_bcast_frames;      /* all broadcast frames */
100f7917c00SJeff Kirsher 	u64 tx_mcast_frames;      /* all multicast frames */
101f7917c00SJeff Kirsher 	u64 tx_ucast_frames;      /* all unicast frames */
102f7917c00SJeff Kirsher 	u64 tx_error_frames;      /* all error frames */
103f7917c00SJeff Kirsher 
104f7917c00SJeff Kirsher 	u64 tx_frames_64;         /* # of Tx frames in a particular range */
105f7917c00SJeff Kirsher 	u64 tx_frames_65_127;
106f7917c00SJeff Kirsher 	u64 tx_frames_128_255;
107f7917c00SJeff Kirsher 	u64 tx_frames_256_511;
108f7917c00SJeff Kirsher 	u64 tx_frames_512_1023;
109f7917c00SJeff Kirsher 	u64 tx_frames_1024_1518;
110f7917c00SJeff Kirsher 	u64 tx_frames_1519_max;
111f7917c00SJeff Kirsher 
112f7917c00SJeff Kirsher 	u64 tx_drop;              /* # of dropped Tx frames */
113f7917c00SJeff Kirsher 	u64 tx_pause;             /* # of transmitted pause frames */
114f7917c00SJeff Kirsher 	u64 tx_ppp0;              /* # of transmitted PPP prio 0 frames */
115f7917c00SJeff Kirsher 	u64 tx_ppp1;              /* # of transmitted PPP prio 1 frames */
116f7917c00SJeff Kirsher 	u64 tx_ppp2;              /* # of transmitted PPP prio 2 frames */
117f7917c00SJeff Kirsher 	u64 tx_ppp3;              /* # of transmitted PPP prio 3 frames */
118f7917c00SJeff Kirsher 	u64 tx_ppp4;              /* # of transmitted PPP prio 4 frames */
119f7917c00SJeff Kirsher 	u64 tx_ppp5;              /* # of transmitted PPP prio 5 frames */
120f7917c00SJeff Kirsher 	u64 tx_ppp6;              /* # of transmitted PPP prio 6 frames */
121f7917c00SJeff Kirsher 	u64 tx_ppp7;              /* # of transmitted PPP prio 7 frames */
122f7917c00SJeff Kirsher 
123f7917c00SJeff Kirsher 	u64 rx_octets;            /* total # of octets in good frames */
124f7917c00SJeff Kirsher 	u64 rx_frames;            /* all good frames */
125f7917c00SJeff Kirsher 	u64 rx_bcast_frames;      /* all broadcast frames */
126f7917c00SJeff Kirsher 	u64 rx_mcast_frames;      /* all multicast frames */
127f7917c00SJeff Kirsher 	u64 rx_ucast_frames;      /* all unicast frames */
128f7917c00SJeff Kirsher 	u64 rx_too_long;          /* # of frames exceeding MTU */
129f7917c00SJeff Kirsher 	u64 rx_jabber;            /* # of jabber frames */
130f7917c00SJeff Kirsher 	u64 rx_fcs_err;           /* # of received frames with bad FCS */
131f7917c00SJeff Kirsher 	u64 rx_len_err;           /* # of received frames with length error */
132f7917c00SJeff Kirsher 	u64 rx_symbol_err;        /* symbol errors */
133f7917c00SJeff Kirsher 	u64 rx_runt;              /* # of short frames */
134f7917c00SJeff Kirsher 
135f7917c00SJeff Kirsher 	u64 rx_frames_64;         /* # of Rx frames in a particular range */
136f7917c00SJeff Kirsher 	u64 rx_frames_65_127;
137f7917c00SJeff Kirsher 	u64 rx_frames_128_255;
138f7917c00SJeff Kirsher 	u64 rx_frames_256_511;
139f7917c00SJeff Kirsher 	u64 rx_frames_512_1023;
140f7917c00SJeff Kirsher 	u64 rx_frames_1024_1518;
141f7917c00SJeff Kirsher 	u64 rx_frames_1519_max;
142f7917c00SJeff Kirsher 
143f7917c00SJeff Kirsher 	u64 rx_pause;             /* # of received pause frames */
144f7917c00SJeff Kirsher 	u64 rx_ppp0;              /* # of received PPP prio 0 frames */
145f7917c00SJeff Kirsher 	u64 rx_ppp1;              /* # of received PPP prio 1 frames */
146f7917c00SJeff Kirsher 	u64 rx_ppp2;              /* # of received PPP prio 2 frames */
147f7917c00SJeff Kirsher 	u64 rx_ppp3;              /* # of received PPP prio 3 frames */
148f7917c00SJeff Kirsher 	u64 rx_ppp4;              /* # of received PPP prio 4 frames */
149f7917c00SJeff Kirsher 	u64 rx_ppp5;              /* # of received PPP prio 5 frames */
150f7917c00SJeff Kirsher 	u64 rx_ppp6;              /* # of received PPP prio 6 frames */
151f7917c00SJeff Kirsher 	u64 rx_ppp7;              /* # of received PPP prio 7 frames */
152f7917c00SJeff Kirsher 
153f7917c00SJeff Kirsher 	u64 rx_ovflow0;           /* drops due to buffer-group 0 overflows */
154f7917c00SJeff Kirsher 	u64 rx_ovflow1;           /* drops due to buffer-group 1 overflows */
155f7917c00SJeff Kirsher 	u64 rx_ovflow2;           /* drops due to buffer-group 2 overflows */
156f7917c00SJeff Kirsher 	u64 rx_ovflow3;           /* drops due to buffer-group 3 overflows */
157f7917c00SJeff Kirsher 	u64 rx_trunc0;            /* buffer-group 0 truncated packets */
158f7917c00SJeff Kirsher 	u64 rx_trunc1;            /* buffer-group 1 truncated packets */
159f7917c00SJeff Kirsher 	u64 rx_trunc2;            /* buffer-group 2 truncated packets */
160f7917c00SJeff Kirsher 	u64 rx_trunc3;            /* buffer-group 3 truncated packets */
161f7917c00SJeff Kirsher };
162f7917c00SJeff Kirsher 
163f7917c00SJeff Kirsher struct lb_port_stats {
164f7917c00SJeff Kirsher 	u64 octets;
165f7917c00SJeff Kirsher 	u64 frames;
166f7917c00SJeff Kirsher 	u64 bcast_frames;
167f7917c00SJeff Kirsher 	u64 mcast_frames;
168f7917c00SJeff Kirsher 	u64 ucast_frames;
169f7917c00SJeff Kirsher 	u64 error_frames;
170f7917c00SJeff Kirsher 
171f7917c00SJeff Kirsher 	u64 frames_64;
172f7917c00SJeff Kirsher 	u64 frames_65_127;
173f7917c00SJeff Kirsher 	u64 frames_128_255;
174f7917c00SJeff Kirsher 	u64 frames_256_511;
175f7917c00SJeff Kirsher 	u64 frames_512_1023;
176f7917c00SJeff Kirsher 	u64 frames_1024_1518;
177f7917c00SJeff Kirsher 	u64 frames_1519_max;
178f7917c00SJeff Kirsher 
179f7917c00SJeff Kirsher 	u64 drop;
180f7917c00SJeff Kirsher 
181f7917c00SJeff Kirsher 	u64 ovflow0;
182f7917c00SJeff Kirsher 	u64 ovflow1;
183f7917c00SJeff Kirsher 	u64 ovflow2;
184f7917c00SJeff Kirsher 	u64 ovflow3;
185f7917c00SJeff Kirsher 	u64 trunc0;
186f7917c00SJeff Kirsher 	u64 trunc1;
187f7917c00SJeff Kirsher 	u64 trunc2;
188f7917c00SJeff Kirsher 	u64 trunc3;
189f7917c00SJeff Kirsher };
190f7917c00SJeff Kirsher 
191f7917c00SJeff Kirsher struct tp_tcp_stats {
192f7917c00SJeff Kirsher 	u32 tcpOutRsts;
193f7917c00SJeff Kirsher 	u64 tcpInSegs;
194f7917c00SJeff Kirsher 	u64 tcpOutSegs;
195f7917c00SJeff Kirsher 	u64 tcpRetransSegs;
196f7917c00SJeff Kirsher };
197f7917c00SJeff Kirsher 
198f7917c00SJeff Kirsher struct tp_err_stats {
199f7917c00SJeff Kirsher 	u32 macInErrs[4];
200f7917c00SJeff Kirsher 	u32 hdrInErrs[4];
201f7917c00SJeff Kirsher 	u32 tcpInErrs[4];
202f7917c00SJeff Kirsher 	u32 tnlCongDrops[4];
203f7917c00SJeff Kirsher 	u32 ofldChanDrops[4];
204f7917c00SJeff Kirsher 	u32 tnlTxDrops[4];
205f7917c00SJeff Kirsher 	u32 ofldVlanDrops[4];
206f7917c00SJeff Kirsher 	u32 tcp6InErrs[4];
207f7917c00SJeff Kirsher 	u32 ofldNoNeigh;
208f7917c00SJeff Kirsher 	u32 ofldCongDefer;
209f7917c00SJeff Kirsher };
210f7917c00SJeff Kirsher 
211f7917c00SJeff Kirsher struct tp_params {
212f7917c00SJeff Kirsher 	unsigned int ntxchan;        /* # of Tx channels */
213f7917c00SJeff Kirsher 	unsigned int tre;            /* log2 of core clocks per TP tick */
214f7917c00SJeff Kirsher };
215f7917c00SJeff Kirsher 
216f7917c00SJeff Kirsher struct vpd_params {
217f7917c00SJeff Kirsher 	unsigned int cclk;
218f7917c00SJeff Kirsher 	u8 ec[EC_LEN + 1];
219f7917c00SJeff Kirsher 	u8 sn[SERNUM_LEN + 1];
220f7917c00SJeff Kirsher 	u8 id[ID_LEN + 1];
221f7917c00SJeff Kirsher };
222f7917c00SJeff Kirsher 
223f7917c00SJeff Kirsher struct pci_params {
224f7917c00SJeff Kirsher 	unsigned char speed;
225f7917c00SJeff Kirsher 	unsigned char width;
226f7917c00SJeff Kirsher };
227f7917c00SJeff Kirsher 
228f7917c00SJeff Kirsher struct adapter_params {
229f7917c00SJeff Kirsher 	struct tp_params  tp;
230f7917c00SJeff Kirsher 	struct vpd_params vpd;
231f7917c00SJeff Kirsher 	struct pci_params pci;
232f7917c00SJeff Kirsher 
233f7917c00SJeff Kirsher 	unsigned int sf_size;             /* serial flash size in bytes */
234f7917c00SJeff Kirsher 	unsigned int sf_nsec;             /* # of flash sectors */
235f7917c00SJeff Kirsher 	unsigned int sf_fw_start;         /* start of FW image in flash */
236f7917c00SJeff Kirsher 
237f7917c00SJeff Kirsher 	unsigned int fw_vers;
238f7917c00SJeff Kirsher 	unsigned int tp_vers;
239f7917c00SJeff Kirsher 	u8 api_vers[7];
240f7917c00SJeff Kirsher 
241f7917c00SJeff Kirsher 	unsigned short mtus[NMTUS];
242f7917c00SJeff Kirsher 	unsigned short a_wnd[NCCTRL_WIN];
243f7917c00SJeff Kirsher 	unsigned short b_wnd[NCCTRL_WIN];
244f7917c00SJeff Kirsher 
245f7917c00SJeff Kirsher 	unsigned char nports;             /* # of ethernet ports */
246f7917c00SJeff Kirsher 	unsigned char portvec;
247f7917c00SJeff Kirsher 	unsigned char rev;                /* chip revision */
248f7917c00SJeff Kirsher 	unsigned char offload;
249f7917c00SJeff Kirsher 
250f7917c00SJeff Kirsher 	unsigned int ofldq_wr_cred;
251f7917c00SJeff Kirsher };
252f7917c00SJeff Kirsher 
253f7917c00SJeff Kirsher struct trace_params {
254f7917c00SJeff Kirsher 	u32 data[TRACE_LEN / 4];
255f7917c00SJeff Kirsher 	u32 mask[TRACE_LEN / 4];
256f7917c00SJeff Kirsher 	unsigned short snap_len;
257f7917c00SJeff Kirsher 	unsigned short min_len;
258f7917c00SJeff Kirsher 	unsigned char skip_ofst;
259f7917c00SJeff Kirsher 	unsigned char skip_len;
260f7917c00SJeff Kirsher 	unsigned char invert;
261f7917c00SJeff Kirsher 	unsigned char port;
262f7917c00SJeff Kirsher };
263f7917c00SJeff Kirsher 
264f7917c00SJeff Kirsher struct link_config {
265f7917c00SJeff Kirsher 	unsigned short supported;        /* link capabilities */
266f7917c00SJeff Kirsher 	unsigned short advertising;      /* advertised capabilities */
267f7917c00SJeff Kirsher 	unsigned short requested_speed;  /* speed user has requested */
268f7917c00SJeff Kirsher 	unsigned short speed;            /* actual link speed */
269f7917c00SJeff Kirsher 	unsigned char  requested_fc;     /* flow control user has requested */
270f7917c00SJeff Kirsher 	unsigned char  fc;               /* actual link flow control */
271f7917c00SJeff Kirsher 	unsigned char  autoneg;          /* autonegotiating? */
272f7917c00SJeff Kirsher 	unsigned char  link_ok;          /* link up? */
273f7917c00SJeff Kirsher };
274f7917c00SJeff Kirsher 
275f7917c00SJeff Kirsher #define FW_LEN16(fw_struct) FW_CMD_LEN16(sizeof(fw_struct) / 16)
276f7917c00SJeff Kirsher 
277f7917c00SJeff Kirsher enum {
278f7917c00SJeff Kirsher 	MAX_ETH_QSETS = 32,           /* # of Ethernet Tx/Rx queue sets */
279f7917c00SJeff Kirsher 	MAX_OFLD_QSETS = 16,          /* # of offload Tx/Rx queue sets */
280f7917c00SJeff Kirsher 	MAX_CTRL_QUEUES = NCHAN,      /* # of control Tx queues */
281f7917c00SJeff Kirsher 	MAX_RDMA_QUEUES = NCHAN,      /* # of streaming RDMA Rx queues */
282f7917c00SJeff Kirsher };
283f7917c00SJeff Kirsher 
284f7917c00SJeff Kirsher enum {
285f7917c00SJeff Kirsher 	MAX_EGRQ = 128,         /* max # of egress queues, including FLs */
286f7917c00SJeff Kirsher 	MAX_INGQ = 64           /* max # of interrupt-capable ingress queues */
287f7917c00SJeff Kirsher };
288f7917c00SJeff Kirsher 
289f7917c00SJeff Kirsher struct adapter;
290f7917c00SJeff Kirsher struct sge_rspq;
291f7917c00SJeff Kirsher 
292f7917c00SJeff Kirsher struct port_info {
293f7917c00SJeff Kirsher 	struct adapter *adapter;
294f7917c00SJeff Kirsher 	u16    viid;
295f7917c00SJeff Kirsher 	s16    xact_addr_filt;        /* index of exact MAC address filter */
296f7917c00SJeff Kirsher 	u16    rss_size;              /* size of VI's RSS table slice */
297f7917c00SJeff Kirsher 	s8     mdio_addr;
298f7917c00SJeff Kirsher 	u8     port_type;
299f7917c00SJeff Kirsher 	u8     mod_type;
300f7917c00SJeff Kirsher 	u8     port_id;
301f7917c00SJeff Kirsher 	u8     tx_chan;
302f7917c00SJeff Kirsher 	u8     lport;                 /* associated offload logical port */
303f7917c00SJeff Kirsher 	u8     nqsets;                /* # of qsets */
304f7917c00SJeff Kirsher 	u8     first_qset;            /* index of first qset */
305f7917c00SJeff Kirsher 	u8     rss_mode;
306f7917c00SJeff Kirsher 	struct link_config link_cfg;
307f7917c00SJeff Kirsher 	u16   *rss;
308f7917c00SJeff Kirsher };
309f7917c00SJeff Kirsher 
310f7917c00SJeff Kirsher struct dentry;
311f7917c00SJeff Kirsher struct work_struct;
312f7917c00SJeff Kirsher 
313f7917c00SJeff Kirsher enum {                                 /* adapter flags */
314f7917c00SJeff Kirsher 	FULL_INIT_DONE     = (1 << 0),
315f7917c00SJeff Kirsher 	USING_MSI          = (1 << 1),
316f7917c00SJeff Kirsher 	USING_MSIX         = (1 << 2),
317f7917c00SJeff Kirsher 	FW_OK              = (1 << 4),
318f7917c00SJeff Kirsher };
319f7917c00SJeff Kirsher 
320f7917c00SJeff Kirsher struct rx_sw_desc;
321f7917c00SJeff Kirsher 
322f7917c00SJeff Kirsher struct sge_fl {                     /* SGE free-buffer queue state */
323f7917c00SJeff Kirsher 	unsigned int avail;         /* # of available Rx buffers */
324f7917c00SJeff Kirsher 	unsigned int pend_cred;     /* new buffers since last FL DB ring */
325f7917c00SJeff Kirsher 	unsigned int cidx;          /* consumer index */
326f7917c00SJeff Kirsher 	unsigned int pidx;          /* producer index */
327f7917c00SJeff Kirsher 	unsigned long alloc_failed; /* # of times buffer allocation failed */
328f7917c00SJeff Kirsher 	unsigned long large_alloc_failed;
329f7917c00SJeff Kirsher 	unsigned long starving;
330f7917c00SJeff Kirsher 	/* RO fields */
331f7917c00SJeff Kirsher 	unsigned int cntxt_id;      /* SGE context id for the free list */
332f7917c00SJeff Kirsher 	unsigned int size;          /* capacity of free list */
333f7917c00SJeff Kirsher 	struct rx_sw_desc *sdesc;   /* address of SW Rx descriptor ring */
334f7917c00SJeff Kirsher 	__be64 *desc;               /* address of HW Rx descriptor ring */
335f7917c00SJeff Kirsher 	dma_addr_t addr;            /* bus address of HW ring start */
336f7917c00SJeff Kirsher };
337f7917c00SJeff Kirsher 
338f7917c00SJeff Kirsher /* A packet gather list */
339f7917c00SJeff Kirsher struct pkt_gl {
340e91b0f24SIan Campbell 	struct page_frag frags[MAX_SKB_FRAGS];
341f7917c00SJeff Kirsher 	void *va;                         /* virtual address of first byte */
342f7917c00SJeff Kirsher 	unsigned int nfrags;              /* # of fragments */
343f7917c00SJeff Kirsher 	unsigned int tot_len;             /* total length of fragments */
344f7917c00SJeff Kirsher };
345f7917c00SJeff Kirsher 
346f7917c00SJeff Kirsher typedef int (*rspq_handler_t)(struct sge_rspq *q, const __be64 *rsp,
347f7917c00SJeff Kirsher 			      const struct pkt_gl *gl);
348f7917c00SJeff Kirsher 
349f7917c00SJeff Kirsher struct sge_rspq {                   /* state for an SGE response queue */
350f7917c00SJeff Kirsher 	struct napi_struct napi;
351f7917c00SJeff Kirsher 	const __be64 *cur_desc;     /* current descriptor in queue */
352f7917c00SJeff Kirsher 	unsigned int cidx;          /* consumer index */
353f7917c00SJeff Kirsher 	u8 gen;                     /* current generation bit */
354f7917c00SJeff Kirsher 	u8 intr_params;             /* interrupt holdoff parameters */
355f7917c00SJeff Kirsher 	u8 next_intr_params;        /* holdoff params for next interrupt */
356f7917c00SJeff Kirsher 	u8 pktcnt_idx;              /* interrupt packet threshold */
357f7917c00SJeff Kirsher 	u8 uld;                     /* ULD handling this queue */
358f7917c00SJeff Kirsher 	u8 idx;                     /* queue index within its group */
359f7917c00SJeff Kirsher 	int offset;                 /* offset into current Rx buffer */
360f7917c00SJeff Kirsher 	u16 cntxt_id;               /* SGE context id for the response q */
361f7917c00SJeff Kirsher 	u16 abs_id;                 /* absolute SGE id for the response q */
362f7917c00SJeff Kirsher 	__be64 *desc;               /* address of HW response ring */
363f7917c00SJeff Kirsher 	dma_addr_t phys_addr;       /* physical address of the ring */
364f7917c00SJeff Kirsher 	unsigned int iqe_len;       /* entry size */
365f7917c00SJeff Kirsher 	unsigned int size;          /* capacity of response queue */
366f7917c00SJeff Kirsher 	struct adapter *adap;
367f7917c00SJeff Kirsher 	struct net_device *netdev;  /* associated net device */
368f7917c00SJeff Kirsher 	rspq_handler_t handler;
369f7917c00SJeff Kirsher };
370f7917c00SJeff Kirsher 
371f7917c00SJeff Kirsher struct sge_eth_stats {              /* Ethernet queue statistics */
372f7917c00SJeff Kirsher 	unsigned long pkts;         /* # of ethernet packets */
373f7917c00SJeff Kirsher 	unsigned long lro_pkts;     /* # of LRO super packets */
374f7917c00SJeff Kirsher 	unsigned long lro_merged;   /* # of wire packets merged by LRO */
375f7917c00SJeff Kirsher 	unsigned long rx_cso;       /* # of Rx checksum offloads */
376f7917c00SJeff Kirsher 	unsigned long vlan_ex;      /* # of Rx VLAN extractions */
377f7917c00SJeff Kirsher 	unsigned long rx_drops;     /* # of packets dropped due to no mem */
378f7917c00SJeff Kirsher };
379f7917c00SJeff Kirsher 
380f7917c00SJeff Kirsher struct sge_eth_rxq {                /* SW Ethernet Rx queue */
381f7917c00SJeff Kirsher 	struct sge_rspq rspq;
382f7917c00SJeff Kirsher 	struct sge_fl fl;
383f7917c00SJeff Kirsher 	struct sge_eth_stats stats;
384f7917c00SJeff Kirsher } ____cacheline_aligned_in_smp;
385f7917c00SJeff Kirsher 
386f7917c00SJeff Kirsher struct sge_ofld_stats {             /* offload queue statistics */
387f7917c00SJeff Kirsher 	unsigned long pkts;         /* # of packets */
388f7917c00SJeff Kirsher 	unsigned long imm;          /* # of immediate-data packets */
389f7917c00SJeff Kirsher 	unsigned long an;           /* # of asynchronous notifications */
390f7917c00SJeff Kirsher 	unsigned long nomem;        /* # of responses deferred due to no mem */
391f7917c00SJeff Kirsher };
392f7917c00SJeff Kirsher 
393f7917c00SJeff Kirsher struct sge_ofld_rxq {               /* SW offload Rx queue */
394f7917c00SJeff Kirsher 	struct sge_rspq rspq;
395f7917c00SJeff Kirsher 	struct sge_fl fl;
396f7917c00SJeff Kirsher 	struct sge_ofld_stats stats;
397f7917c00SJeff Kirsher } ____cacheline_aligned_in_smp;
398f7917c00SJeff Kirsher 
399f7917c00SJeff Kirsher struct tx_desc {
400f7917c00SJeff Kirsher 	__be64 flit[8];
401f7917c00SJeff Kirsher };
402f7917c00SJeff Kirsher 
403f7917c00SJeff Kirsher struct tx_sw_desc;
404f7917c00SJeff Kirsher 
405f7917c00SJeff Kirsher struct sge_txq {
406f7917c00SJeff Kirsher 	unsigned int  in_use;       /* # of in-use Tx descriptors */
407f7917c00SJeff Kirsher 	unsigned int  size;         /* # of descriptors */
408f7917c00SJeff Kirsher 	unsigned int  cidx;         /* SW consumer index */
409f7917c00SJeff Kirsher 	unsigned int  pidx;         /* producer index */
410f7917c00SJeff Kirsher 	unsigned long stops;        /* # of times q has been stopped */
411f7917c00SJeff Kirsher 	unsigned long restarts;     /* # of queue restarts */
412f7917c00SJeff Kirsher 	unsigned int  cntxt_id;     /* SGE context id for the Tx q */
413f7917c00SJeff Kirsher 	struct tx_desc *desc;       /* address of HW Tx descriptor ring */
414f7917c00SJeff Kirsher 	struct tx_sw_desc *sdesc;   /* address of SW Tx descriptor ring */
415f7917c00SJeff Kirsher 	struct sge_qstat *stat;     /* queue status entry */
416f7917c00SJeff Kirsher 	dma_addr_t    phys_addr;    /* physical address of the ring */
4173069ee9bSVipul Pandya 	spinlock_t db_lock;
4183069ee9bSVipul Pandya 	int db_disabled;
4193069ee9bSVipul Pandya 	unsigned short db_pidx;
420f7917c00SJeff Kirsher };
421f7917c00SJeff Kirsher 
422f7917c00SJeff Kirsher struct sge_eth_txq {                /* state for an SGE Ethernet Tx queue */
423f7917c00SJeff Kirsher 	struct sge_txq q;
424f7917c00SJeff Kirsher 	struct netdev_queue *txq;   /* associated netdev TX queue */
425f7917c00SJeff Kirsher 	unsigned long tso;          /* # of TSO requests */
426f7917c00SJeff Kirsher 	unsigned long tx_cso;       /* # of Tx checksum offloads */
427f7917c00SJeff Kirsher 	unsigned long vlan_ins;     /* # of Tx VLAN insertions */
428f7917c00SJeff Kirsher 	unsigned long mapping_err;  /* # of I/O MMU packet mapping errors */
429f7917c00SJeff Kirsher } ____cacheline_aligned_in_smp;
430f7917c00SJeff Kirsher 
431f7917c00SJeff Kirsher struct sge_ofld_txq {               /* state for an SGE offload Tx queue */
432f7917c00SJeff Kirsher 	struct sge_txq q;
433f7917c00SJeff Kirsher 	struct adapter *adap;
434f7917c00SJeff Kirsher 	struct sk_buff_head sendq;  /* list of backpressured packets */
435f7917c00SJeff Kirsher 	struct tasklet_struct qresume_tsk; /* restarts the queue */
436f7917c00SJeff Kirsher 	u8 full;                    /* the Tx ring is full */
437f7917c00SJeff Kirsher 	unsigned long mapping_err;  /* # of I/O MMU packet mapping errors */
438f7917c00SJeff Kirsher } ____cacheline_aligned_in_smp;
439f7917c00SJeff Kirsher 
440f7917c00SJeff Kirsher struct sge_ctrl_txq {               /* state for an SGE control Tx queue */
441f7917c00SJeff Kirsher 	struct sge_txq q;
442f7917c00SJeff Kirsher 	struct adapter *adap;
443f7917c00SJeff Kirsher 	struct sk_buff_head sendq;  /* list of backpressured packets */
444f7917c00SJeff Kirsher 	struct tasklet_struct qresume_tsk; /* restarts the queue */
445f7917c00SJeff Kirsher 	u8 full;                    /* the Tx ring is full */
446f7917c00SJeff Kirsher } ____cacheline_aligned_in_smp;
447f7917c00SJeff Kirsher 
448f7917c00SJeff Kirsher struct sge {
449f7917c00SJeff Kirsher 	struct sge_eth_txq ethtxq[MAX_ETH_QSETS];
450f7917c00SJeff Kirsher 	struct sge_ofld_txq ofldtxq[MAX_OFLD_QSETS];
451f7917c00SJeff Kirsher 	struct sge_ctrl_txq ctrlq[MAX_CTRL_QUEUES];
452f7917c00SJeff Kirsher 
453f7917c00SJeff Kirsher 	struct sge_eth_rxq ethrxq[MAX_ETH_QSETS];
454f7917c00SJeff Kirsher 	struct sge_ofld_rxq ofldrxq[MAX_OFLD_QSETS];
455f7917c00SJeff Kirsher 	struct sge_ofld_rxq rdmarxq[MAX_RDMA_QUEUES];
456f7917c00SJeff Kirsher 	struct sge_rspq fw_evtq ____cacheline_aligned_in_smp;
457f7917c00SJeff Kirsher 
458f7917c00SJeff Kirsher 	struct sge_rspq intrq ____cacheline_aligned_in_smp;
459f7917c00SJeff Kirsher 	spinlock_t intrq_lock;
460f7917c00SJeff Kirsher 
461f7917c00SJeff Kirsher 	u16 max_ethqsets;           /* # of available Ethernet queue sets */
462f7917c00SJeff Kirsher 	u16 ethqsets;               /* # of active Ethernet queue sets */
463f7917c00SJeff Kirsher 	u16 ethtxq_rover;           /* Tx queue to clean up next */
464f7917c00SJeff Kirsher 	u16 ofldqsets;              /* # of active offload queue sets */
465f7917c00SJeff Kirsher 	u16 rdmaqs;                 /* # of available RDMA Rx queues */
466f7917c00SJeff Kirsher 	u16 ofld_rxq[MAX_OFLD_QSETS];
467f7917c00SJeff Kirsher 	u16 rdma_rxq[NCHAN];
468f7917c00SJeff Kirsher 	u16 timer_val[SGE_NTIMERS];
469f7917c00SJeff Kirsher 	u8 counter_val[SGE_NCOUNTERS];
470f7917c00SJeff Kirsher 	unsigned int starve_thres;
471f7917c00SJeff Kirsher 	u8 idma_state[2];
472f7917c00SJeff Kirsher 	unsigned int egr_start;
473f7917c00SJeff Kirsher 	unsigned int ingr_start;
474f7917c00SJeff Kirsher 	void *egr_map[MAX_EGRQ];    /* qid->queue egress queue map */
475f7917c00SJeff Kirsher 	struct sge_rspq *ingr_map[MAX_INGQ]; /* qid->queue ingress queue map */
476f7917c00SJeff Kirsher 	DECLARE_BITMAP(starving_fl, MAX_EGRQ);
477f7917c00SJeff Kirsher 	DECLARE_BITMAP(txq_maperr, MAX_EGRQ);
478f7917c00SJeff Kirsher 	struct timer_list rx_timer; /* refills starving FLs */
479f7917c00SJeff Kirsher 	struct timer_list tx_timer; /* checks Tx queues */
480f7917c00SJeff Kirsher };
481f7917c00SJeff Kirsher 
482f7917c00SJeff Kirsher #define for_each_ethrxq(sge, i) for (i = 0; i < (sge)->ethqsets; i++)
483f7917c00SJeff Kirsher #define for_each_ofldrxq(sge, i) for (i = 0; i < (sge)->ofldqsets; i++)
484f7917c00SJeff Kirsher #define for_each_rdmarxq(sge, i) for (i = 0; i < (sge)->rdmaqs; i++)
485f7917c00SJeff Kirsher 
486f7917c00SJeff Kirsher struct l2t_data;
487f7917c00SJeff Kirsher 
488f7917c00SJeff Kirsher struct adapter {
489f7917c00SJeff Kirsher 	void __iomem *regs;
490f7917c00SJeff Kirsher 	struct pci_dev *pdev;
491f7917c00SJeff Kirsher 	struct device *pdev_dev;
4923069ee9bSVipul Pandya 	unsigned int mbox;
493f7917c00SJeff Kirsher 	unsigned int fn;
494f7917c00SJeff Kirsher 	unsigned int flags;
495f7917c00SJeff Kirsher 
496f7917c00SJeff Kirsher 	int msg_enable;
497f7917c00SJeff Kirsher 
498f7917c00SJeff Kirsher 	struct adapter_params params;
499f7917c00SJeff Kirsher 	struct cxgb4_virt_res vres;
500f7917c00SJeff Kirsher 	unsigned int swintr;
501f7917c00SJeff Kirsher 
502f7917c00SJeff Kirsher 	unsigned int wol;
503f7917c00SJeff Kirsher 
504f7917c00SJeff Kirsher 	struct {
505f7917c00SJeff Kirsher 		unsigned short vec;
506f7917c00SJeff Kirsher 		char desc[IFNAMSIZ + 10];
507f7917c00SJeff Kirsher 	} msix_info[MAX_INGQ + 1];
508f7917c00SJeff Kirsher 
509f7917c00SJeff Kirsher 	struct sge sge;
510f7917c00SJeff Kirsher 
511f7917c00SJeff Kirsher 	struct net_device *port[MAX_NPORTS];
512f7917c00SJeff Kirsher 	u8 chan_map[NCHAN];                   /* channel -> port map */
513f7917c00SJeff Kirsher 
514f7917c00SJeff Kirsher 	struct l2t_data *l2t;
515f7917c00SJeff Kirsher 	void *uld_handle[CXGB4_ULD_MAX];
516f7917c00SJeff Kirsher 	struct list_head list_node;
517f7917c00SJeff Kirsher 
518f7917c00SJeff Kirsher 	struct tid_info tids;
519f7917c00SJeff Kirsher 	void **tid_release_head;
520f7917c00SJeff Kirsher 	spinlock_t tid_release_lock;
521f7917c00SJeff Kirsher 	struct work_struct tid_release_task;
522881806bcSVipul Pandya 	struct work_struct db_full_task;
523881806bcSVipul Pandya 	struct work_struct db_drop_task;
524f7917c00SJeff Kirsher 	bool tid_release_task_busy;
525f7917c00SJeff Kirsher 
526f7917c00SJeff Kirsher 	struct dentry *debugfs_root;
527f7917c00SJeff Kirsher 
528f7917c00SJeff Kirsher 	spinlock_t stats_lock;
529f7917c00SJeff Kirsher };
530f7917c00SJeff Kirsher 
531f7917c00SJeff Kirsher static inline u32 t4_read_reg(struct adapter *adap, u32 reg_addr)
532f7917c00SJeff Kirsher {
533f7917c00SJeff Kirsher 	return readl(adap->regs + reg_addr);
534f7917c00SJeff Kirsher }
535f7917c00SJeff Kirsher 
536f7917c00SJeff Kirsher static inline void t4_write_reg(struct adapter *adap, u32 reg_addr, u32 val)
537f7917c00SJeff Kirsher {
538f7917c00SJeff Kirsher 	writel(val, adap->regs + reg_addr);
539f7917c00SJeff Kirsher }
540f7917c00SJeff Kirsher 
541f7917c00SJeff Kirsher #ifndef readq
542f7917c00SJeff Kirsher static inline u64 readq(const volatile void __iomem *addr)
543f7917c00SJeff Kirsher {
544f7917c00SJeff Kirsher 	return readl(addr) + ((u64)readl(addr + 4) << 32);
545f7917c00SJeff Kirsher }
546f7917c00SJeff Kirsher 
547f7917c00SJeff Kirsher static inline void writeq(u64 val, volatile void __iomem *addr)
548f7917c00SJeff Kirsher {
549f7917c00SJeff Kirsher 	writel(val, addr);
550f7917c00SJeff Kirsher 	writel(val >> 32, addr + 4);
551f7917c00SJeff Kirsher }
552f7917c00SJeff Kirsher #endif
553f7917c00SJeff Kirsher 
554f7917c00SJeff Kirsher static inline u64 t4_read_reg64(struct adapter *adap, u32 reg_addr)
555f7917c00SJeff Kirsher {
556f7917c00SJeff Kirsher 	return readq(adap->regs + reg_addr);
557f7917c00SJeff Kirsher }
558f7917c00SJeff Kirsher 
559f7917c00SJeff Kirsher static inline void t4_write_reg64(struct adapter *adap, u32 reg_addr, u64 val)
560f7917c00SJeff Kirsher {
561f7917c00SJeff Kirsher 	writeq(val, adap->regs + reg_addr);
562f7917c00SJeff Kirsher }
563f7917c00SJeff Kirsher 
564f7917c00SJeff Kirsher /**
565f7917c00SJeff Kirsher  * netdev2pinfo - return the port_info structure associated with a net_device
566f7917c00SJeff Kirsher  * @dev: the netdev
567f7917c00SJeff Kirsher  *
568f7917c00SJeff Kirsher  * Return the struct port_info associated with a net_device
569f7917c00SJeff Kirsher  */
570f7917c00SJeff Kirsher static inline struct port_info *netdev2pinfo(const struct net_device *dev)
571f7917c00SJeff Kirsher {
572f7917c00SJeff Kirsher 	return netdev_priv(dev);
573f7917c00SJeff Kirsher }
574f7917c00SJeff Kirsher 
575f7917c00SJeff Kirsher /**
576f7917c00SJeff Kirsher  * adap2pinfo - return the port_info of a port
577f7917c00SJeff Kirsher  * @adap: the adapter
578f7917c00SJeff Kirsher  * @idx: the port index
579f7917c00SJeff Kirsher  *
580f7917c00SJeff Kirsher  * Return the port_info structure for the port of the given index.
581f7917c00SJeff Kirsher  */
582f7917c00SJeff Kirsher static inline struct port_info *adap2pinfo(struct adapter *adap, int idx)
583f7917c00SJeff Kirsher {
584f7917c00SJeff Kirsher 	return netdev_priv(adap->port[idx]);
585f7917c00SJeff Kirsher }
586f7917c00SJeff Kirsher 
587f7917c00SJeff Kirsher /**
588f7917c00SJeff Kirsher  * netdev2adap - return the adapter structure associated with a net_device
589f7917c00SJeff Kirsher  * @dev: the netdev
590f7917c00SJeff Kirsher  *
591f7917c00SJeff Kirsher  * Return the struct adapter associated with a net_device
592f7917c00SJeff Kirsher  */
593f7917c00SJeff Kirsher static inline struct adapter *netdev2adap(const struct net_device *dev)
594f7917c00SJeff Kirsher {
595f7917c00SJeff Kirsher 	return netdev2pinfo(dev)->adapter;
596f7917c00SJeff Kirsher }
597f7917c00SJeff Kirsher 
598f7917c00SJeff Kirsher void t4_os_portmod_changed(const struct adapter *adap, int port_id);
599f7917c00SJeff Kirsher void t4_os_link_changed(struct adapter *adap, int port_id, int link_stat);
600f7917c00SJeff Kirsher 
601f7917c00SJeff Kirsher void *t4_alloc_mem(size_t size);
602f7917c00SJeff Kirsher 
603f7917c00SJeff Kirsher void t4_free_sge_resources(struct adapter *adap);
604f7917c00SJeff Kirsher irq_handler_t t4_intr_handler(struct adapter *adap);
605f7917c00SJeff Kirsher netdev_tx_t t4_eth_xmit(struct sk_buff *skb, struct net_device *dev);
606f7917c00SJeff Kirsher int t4_ethrx_handler(struct sge_rspq *q, const __be64 *rsp,
607f7917c00SJeff Kirsher 		     const struct pkt_gl *gl);
608f7917c00SJeff Kirsher int t4_mgmt_tx(struct adapter *adap, struct sk_buff *skb);
609f7917c00SJeff Kirsher int t4_ofld_send(struct adapter *adap, struct sk_buff *skb);
610f7917c00SJeff Kirsher int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
611f7917c00SJeff Kirsher 		     struct net_device *dev, int intr_idx,
612f7917c00SJeff Kirsher 		     struct sge_fl *fl, rspq_handler_t hnd);
613f7917c00SJeff Kirsher int t4_sge_alloc_eth_txq(struct adapter *adap, struct sge_eth_txq *txq,
614f7917c00SJeff Kirsher 			 struct net_device *dev, struct netdev_queue *netdevq,
615f7917c00SJeff Kirsher 			 unsigned int iqid);
616f7917c00SJeff Kirsher int t4_sge_alloc_ctrl_txq(struct adapter *adap, struct sge_ctrl_txq *txq,
617f7917c00SJeff Kirsher 			  struct net_device *dev, unsigned int iqid,
618f7917c00SJeff Kirsher 			  unsigned int cmplqid);
619f7917c00SJeff Kirsher int t4_sge_alloc_ofld_txq(struct adapter *adap, struct sge_ofld_txq *txq,
620f7917c00SJeff Kirsher 			  struct net_device *dev, unsigned int iqid);
621f7917c00SJeff Kirsher irqreturn_t t4_sge_intr_msix(int irq, void *cookie);
622f7917c00SJeff Kirsher void t4_sge_init(struct adapter *adap);
623f7917c00SJeff Kirsher void t4_sge_start(struct adapter *adap);
624f7917c00SJeff Kirsher void t4_sge_stop(struct adapter *adap);
6253069ee9bSVipul Pandya extern int dbfifo_int_thresh;
626f7917c00SJeff Kirsher 
627f7917c00SJeff Kirsher #define for_each_port(adapter, iter) \
628f7917c00SJeff Kirsher 	for (iter = 0; iter < (adapter)->params.nports; ++iter)
629f7917c00SJeff Kirsher 
630f7917c00SJeff Kirsher static inline unsigned int core_ticks_per_usec(const struct adapter *adap)
631f7917c00SJeff Kirsher {
632f7917c00SJeff Kirsher 	return adap->params.vpd.cclk / 1000;
633f7917c00SJeff Kirsher }
634f7917c00SJeff Kirsher 
635f7917c00SJeff Kirsher static inline unsigned int us_to_core_ticks(const struct adapter *adap,
636f7917c00SJeff Kirsher 					    unsigned int us)
637f7917c00SJeff Kirsher {
638f7917c00SJeff Kirsher 	return (us * adap->params.vpd.cclk) / 1000;
639f7917c00SJeff Kirsher }
640f7917c00SJeff Kirsher 
641f7917c00SJeff Kirsher void t4_set_reg_field(struct adapter *adap, unsigned int addr, u32 mask,
642f7917c00SJeff Kirsher 		      u32 val);
643f7917c00SJeff Kirsher 
644f7917c00SJeff Kirsher int t4_wr_mbox_meat(struct adapter *adap, int mbox, const void *cmd, int size,
645f7917c00SJeff Kirsher 		    void *rpl, bool sleep_ok);
646f7917c00SJeff Kirsher 
647f7917c00SJeff Kirsher static inline int t4_wr_mbox(struct adapter *adap, int mbox, const void *cmd,
648f7917c00SJeff Kirsher 			     int size, void *rpl)
649f7917c00SJeff Kirsher {
650f7917c00SJeff Kirsher 	return t4_wr_mbox_meat(adap, mbox, cmd, size, rpl, true);
651f7917c00SJeff Kirsher }
652f7917c00SJeff Kirsher 
653f7917c00SJeff Kirsher static inline int t4_wr_mbox_ns(struct adapter *adap, int mbox, const void *cmd,
654f7917c00SJeff Kirsher 				int size, void *rpl)
655f7917c00SJeff Kirsher {
656f7917c00SJeff Kirsher 	return t4_wr_mbox_meat(adap, mbox, cmd, size, rpl, false);
657f7917c00SJeff Kirsher }
658f7917c00SJeff Kirsher 
659f7917c00SJeff Kirsher void t4_intr_enable(struct adapter *adapter);
660f7917c00SJeff Kirsher void t4_intr_disable(struct adapter *adapter);
661f7917c00SJeff Kirsher int t4_slow_intr_handler(struct adapter *adapter);
662f7917c00SJeff Kirsher 
663f7917c00SJeff Kirsher int t4_wait_dev_ready(struct adapter *adap);
664f7917c00SJeff Kirsher int t4_link_start(struct adapter *adap, unsigned int mbox, unsigned int port,
665f7917c00SJeff Kirsher 		  struct link_config *lc);
666f7917c00SJeff Kirsher int t4_restart_aneg(struct adapter *adap, unsigned int mbox, unsigned int port);
6675afc8b84SVipul Pandya int t4_memory_write(struct adapter *adap, int mtype, u32 addr, u32 len,
6685afc8b84SVipul Pandya 		    __be32 *buf);
669f7917c00SJeff Kirsher int t4_seeprom_wp(struct adapter *adapter, bool enable);
670f7917c00SJeff Kirsher int t4_load_fw(struct adapter *adapter, const u8 *fw_data, unsigned int size);
671f7917c00SJeff Kirsher int t4_check_fw_version(struct adapter *adapter);
672f7917c00SJeff Kirsher int t4_prep_adapter(struct adapter *adapter);
673f7917c00SJeff Kirsher int t4_port_init(struct adapter *adap, int mbox, int pf, int vf);
674f7917c00SJeff Kirsher void t4_fatal_err(struct adapter *adapter);
675f7917c00SJeff Kirsher int t4_config_rss_range(struct adapter *adapter, int mbox, unsigned int viid,
676f7917c00SJeff Kirsher 			int start, int n, const u16 *rspq, unsigned int nrspq);
677f7917c00SJeff Kirsher int t4_config_glbl_rss(struct adapter *adapter, int mbox, unsigned int mode,
678f7917c00SJeff Kirsher 		       unsigned int flags);
679f7917c00SJeff Kirsher int t4_mc_read(struct adapter *adap, u32 addr, __be32 *data, u64 *parity);
680f7917c00SJeff Kirsher int t4_edc_read(struct adapter *adap, int idx, u32 addr, __be32 *data,
681f7917c00SJeff Kirsher 		u64 *parity);
682f7917c00SJeff Kirsher 
683f7917c00SJeff Kirsher void t4_get_port_stats(struct adapter *adap, int idx, struct port_stats *p);
684f7917c00SJeff Kirsher void t4_read_mtu_tbl(struct adapter *adap, u16 *mtus, u8 *mtu_log);
685f7917c00SJeff Kirsher void t4_tp_get_tcp_stats(struct adapter *adap, struct tp_tcp_stats *v4,
686f7917c00SJeff Kirsher 			 struct tp_tcp_stats *v6);
687f7917c00SJeff Kirsher void t4_load_mtus(struct adapter *adap, const unsigned short *mtus,
688f7917c00SJeff Kirsher 		  const unsigned short *alpha, const unsigned short *beta);
689f7917c00SJeff Kirsher 
690f7917c00SJeff Kirsher void t4_wol_magic_enable(struct adapter *adap, unsigned int port,
691f7917c00SJeff Kirsher 			 const u8 *addr);
692f7917c00SJeff Kirsher int t4_wol_pat_enable(struct adapter *adap, unsigned int port, unsigned int map,
693f7917c00SJeff Kirsher 		      u64 mask0, u64 mask1, unsigned int crc, bool enable);
694f7917c00SJeff Kirsher 
695f7917c00SJeff Kirsher int t4_fw_hello(struct adapter *adap, unsigned int mbox, unsigned int evt_mbox,
696f7917c00SJeff Kirsher 		enum dev_master master, enum dev_state *state);
697f7917c00SJeff Kirsher int t4_fw_bye(struct adapter *adap, unsigned int mbox);
698f7917c00SJeff Kirsher int t4_early_init(struct adapter *adap, unsigned int mbox);
699f7917c00SJeff Kirsher int t4_fw_reset(struct adapter *adap, unsigned int mbox, int reset);
700f7917c00SJeff Kirsher int t4_query_params(struct adapter *adap, unsigned int mbox, unsigned int pf,
701f7917c00SJeff Kirsher 		    unsigned int vf, unsigned int nparams, const u32 *params,
702f7917c00SJeff Kirsher 		    u32 *val);
703f7917c00SJeff Kirsher int t4_set_params(struct adapter *adap, unsigned int mbox, unsigned int pf,
704f7917c00SJeff Kirsher 		  unsigned int vf, unsigned int nparams, const u32 *params,
705f7917c00SJeff Kirsher 		  const u32 *val);
706f7917c00SJeff Kirsher int t4_cfg_pfvf(struct adapter *adap, unsigned int mbox, unsigned int pf,
707f7917c00SJeff Kirsher 		unsigned int vf, unsigned int txq, unsigned int txq_eth_ctrl,
708f7917c00SJeff Kirsher 		unsigned int rxqi, unsigned int rxq, unsigned int tc,
709f7917c00SJeff Kirsher 		unsigned int vi, unsigned int cmask, unsigned int pmask,
710f7917c00SJeff Kirsher 		unsigned int nexact, unsigned int rcaps, unsigned int wxcaps);
711f7917c00SJeff Kirsher int t4_alloc_vi(struct adapter *adap, unsigned int mbox, unsigned int port,
712f7917c00SJeff Kirsher 		unsigned int pf, unsigned int vf, unsigned int nmac, u8 *mac,
713f7917c00SJeff Kirsher 		unsigned int *rss_size);
714f7917c00SJeff Kirsher int t4_set_rxmode(struct adapter *adap, unsigned int mbox, unsigned int viid,
715f7917c00SJeff Kirsher 		int mtu, int promisc, int all_multi, int bcast, int vlanex,
716f7917c00SJeff Kirsher 		bool sleep_ok);
717f7917c00SJeff Kirsher int t4_alloc_mac_filt(struct adapter *adap, unsigned int mbox,
718f7917c00SJeff Kirsher 		      unsigned int viid, bool free, unsigned int naddr,
719f7917c00SJeff Kirsher 		      const u8 **addr, u16 *idx, u64 *hash, bool sleep_ok);
720f7917c00SJeff Kirsher int t4_change_mac(struct adapter *adap, unsigned int mbox, unsigned int viid,
721f7917c00SJeff Kirsher 		  int idx, const u8 *addr, bool persist, bool add_smt);
722f7917c00SJeff Kirsher int t4_set_addr_hash(struct adapter *adap, unsigned int mbox, unsigned int viid,
723f7917c00SJeff Kirsher 		     bool ucast, u64 vec, bool sleep_ok);
724f7917c00SJeff Kirsher int t4_enable_vi(struct adapter *adap, unsigned int mbox, unsigned int viid,
725f7917c00SJeff Kirsher 		 bool rx_en, bool tx_en);
726f7917c00SJeff Kirsher int t4_identify_port(struct adapter *adap, unsigned int mbox, unsigned int viid,
727f7917c00SJeff Kirsher 		     unsigned int nblinks);
728f7917c00SJeff Kirsher int t4_mdio_rd(struct adapter *adap, unsigned int mbox, unsigned int phy_addr,
729f7917c00SJeff Kirsher 	       unsigned int mmd, unsigned int reg, u16 *valp);
730f7917c00SJeff Kirsher int t4_mdio_wr(struct adapter *adap, unsigned int mbox, unsigned int phy_addr,
731f7917c00SJeff Kirsher 	       unsigned int mmd, unsigned int reg, u16 val);
732f7917c00SJeff Kirsher int t4_iq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
733f7917c00SJeff Kirsher 	       unsigned int vf, unsigned int iqtype, unsigned int iqid,
734f7917c00SJeff Kirsher 	       unsigned int fl0id, unsigned int fl1id);
735f7917c00SJeff Kirsher int t4_eth_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
736f7917c00SJeff Kirsher 		   unsigned int vf, unsigned int eqid);
737f7917c00SJeff Kirsher int t4_ctrl_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
738f7917c00SJeff Kirsher 		    unsigned int vf, unsigned int eqid);
739f7917c00SJeff Kirsher int t4_ofld_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
740f7917c00SJeff Kirsher 		    unsigned int vf, unsigned int eqid);
741f7917c00SJeff Kirsher int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl);
742881806bcSVipul Pandya void t4_db_full(struct adapter *adapter);
743881806bcSVipul Pandya void t4_db_dropped(struct adapter *adapter);
7448caa1e84SVipul Pandya int t4_mem_win_read_len(struct adapter *adap, u32 addr, __be32 *data, int len);
7458caa1e84SVipul Pandya int t4_fwaddrspace_write(struct adapter *adap, unsigned int mbox,
7468caa1e84SVipul Pandya 			 u32 addr, u32 val);
747f7917c00SJeff Kirsher #endif /* __CXGB4_H__ */
748