1f7917c00SJeff Kirsher /*
2f7917c00SJeff Kirsher  * Copyright (c) 2005-2008 Chelsio, Inc. All rights reserved.
3f7917c00SJeff Kirsher  *
4f7917c00SJeff Kirsher  * This software is available to you under a choice of one of two
5f7917c00SJeff Kirsher  * licenses.  You may choose to be licensed under the terms of the GNU
6f7917c00SJeff Kirsher  * General Public License (GPL) Version 2, available from the file
7f7917c00SJeff Kirsher  * COPYING in the main directory of this source tree, or the
8f7917c00SJeff Kirsher  * OpenIB.org BSD license below:
9f7917c00SJeff Kirsher  *
10f7917c00SJeff Kirsher  *     Redistribution and use in source and binary forms, with or
11f7917c00SJeff Kirsher  *     without modification, are permitted provided that the following
12f7917c00SJeff Kirsher  *     conditions are met:
13f7917c00SJeff Kirsher  *
14f7917c00SJeff Kirsher  *      - Redistributions of source code must retain the above
15f7917c00SJeff Kirsher  *        copyright notice, this list of conditions and the following
16f7917c00SJeff Kirsher  *        disclaimer.
17f7917c00SJeff Kirsher  *
18f7917c00SJeff Kirsher  *      - Redistributions in binary form must reproduce the above
19f7917c00SJeff Kirsher  *        copyright notice, this list of conditions and the following
20f7917c00SJeff Kirsher  *        disclaimer in the documentation and/or other materials
21f7917c00SJeff Kirsher  *        provided with the distribution.
22f7917c00SJeff Kirsher  *
23f7917c00SJeff Kirsher  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24f7917c00SJeff Kirsher  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25f7917c00SJeff Kirsher  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26f7917c00SJeff Kirsher  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27f7917c00SJeff Kirsher  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28f7917c00SJeff Kirsher  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29f7917c00SJeff Kirsher  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30f7917c00SJeff Kirsher  * SOFTWARE.
31f7917c00SJeff Kirsher  */
32f7917c00SJeff Kirsher #ifndef __CHELSIO_COMMON_H
33f7917c00SJeff Kirsher #define __CHELSIO_COMMON_H
34f7917c00SJeff Kirsher 
35f7917c00SJeff Kirsher #include <linux/kernel.h>
36f7917c00SJeff Kirsher #include <linux/types.h>
37f7917c00SJeff Kirsher #include <linux/ctype.h>
38f7917c00SJeff Kirsher #include <linux/delay.h>
39f7917c00SJeff Kirsher #include <linux/netdevice.h>
40f7917c00SJeff Kirsher #include <linux/ethtool.h>
41f7917c00SJeff Kirsher #include <linux/mdio.h>
42f7917c00SJeff Kirsher #include "version.h"
43f7917c00SJeff Kirsher 
44f7917c00SJeff Kirsher #define CH_ERR(adap, fmt, ...)   dev_err(&adap->pdev->dev, fmt, ##__VA_ARGS__)
45f7917c00SJeff Kirsher #define CH_WARN(adap, fmt, ...)  dev_warn(&adap->pdev->dev, fmt, ##__VA_ARGS__)
46f7b4fb22SJoe Perches #define CH_ALERT(adap, fmt, ...) dev_alert(&adap->pdev->dev, fmt, ##__VA_ARGS__)
47f7917c00SJeff Kirsher 
48f7917c00SJeff Kirsher /*
49f7917c00SJeff Kirsher  * More powerful macro that selectively prints messages based on msg_enable.
50f7917c00SJeff Kirsher  * For info and debugging messages.
51f7917c00SJeff Kirsher  */
52f7917c00SJeff Kirsher #define CH_MSG(adapter, level, category, fmt, ...) do { \
53f7917c00SJeff Kirsher 	if ((adapter)->msg_enable & NETIF_MSG_##category) \
54f7917c00SJeff Kirsher 		dev_printk(KERN_##level, &adapter->pdev->dev, fmt, \
55f7917c00SJeff Kirsher 			   ## __VA_ARGS__); \
56f7917c00SJeff Kirsher } while (0)
57f7917c00SJeff Kirsher 
58f7917c00SJeff Kirsher #ifdef DEBUG
59f7917c00SJeff Kirsher # define CH_DBG(adapter, category, fmt, ...) \
60f7917c00SJeff Kirsher 	CH_MSG(adapter, DEBUG, category, fmt, ## __VA_ARGS__)
61f7917c00SJeff Kirsher #else
62f7917c00SJeff Kirsher # define CH_DBG(adapter, category, fmt, ...)
63f7917c00SJeff Kirsher #endif
64f7917c00SJeff Kirsher 
65f7917c00SJeff Kirsher /* Additional NETIF_MSG_* categories */
66f7917c00SJeff Kirsher #define NETIF_MSG_MMIO 0x8000000
67f7917c00SJeff Kirsher 
68f7917c00SJeff Kirsher enum {
69f7917c00SJeff Kirsher 	MAX_NPORTS = 2,		/* max # of ports */
70f7917c00SJeff Kirsher 	MAX_FRAME_SIZE = 10240,	/* max MAC frame size, including header + FCS */
71f7917c00SJeff Kirsher 	EEPROMSIZE = 8192,	/* Serial EEPROM size */
72f7917c00SJeff Kirsher 	SERNUM_LEN     = 16,    /* Serial # length */
73f7917c00SJeff Kirsher 	RSS_TABLE_SIZE = 64,	/* size of RSS lookup and mapping tables */
74f7917c00SJeff Kirsher 	TCB_SIZE = 128,		/* TCB size */
75f7917c00SJeff Kirsher 	NMTUS = 16,		/* size of MTU table */
76f7917c00SJeff Kirsher 	NCCTRL_WIN = 32,	/* # of congestion control windows */
77f7917c00SJeff Kirsher 	PROTO_SRAM_LINES = 128, /* size of TP sram */
78f7917c00SJeff Kirsher };
79f7917c00SJeff Kirsher 
80f7917c00SJeff Kirsher #define MAX_RX_COALESCING_LEN 12288U
81f7917c00SJeff Kirsher 
82f7917c00SJeff Kirsher enum {
83f7917c00SJeff Kirsher 	PAUSE_RX = 1 << 0,
84f7917c00SJeff Kirsher 	PAUSE_TX = 1 << 1,
85f7917c00SJeff Kirsher 	PAUSE_AUTONEG = 1 << 2
86f7917c00SJeff Kirsher };
87f7917c00SJeff Kirsher 
88f7917c00SJeff Kirsher enum {
89f7917c00SJeff Kirsher 	SUPPORTED_IRQ      = 1 << 24
90f7917c00SJeff Kirsher };
91f7917c00SJeff Kirsher 
92f7917c00SJeff Kirsher enum {				/* adapter interrupt-maintained statistics */
93f7917c00SJeff Kirsher 	STAT_ULP_CH0_PBL_OOB,
94f7917c00SJeff Kirsher 	STAT_ULP_CH1_PBL_OOB,
95f7917c00SJeff Kirsher 	STAT_PCI_CORR_ECC,
96f7917c00SJeff Kirsher 
97f7917c00SJeff Kirsher 	IRQ_NUM_STATS		/* keep last */
98f7917c00SJeff Kirsher };
99f7917c00SJeff Kirsher 
100f7917c00SJeff Kirsher #define TP_VERSION_MAJOR	1
101f7917c00SJeff Kirsher #define TP_VERSION_MINOR	1
102f7917c00SJeff Kirsher #define TP_VERSION_MICRO	0
103f7917c00SJeff Kirsher 
104f7917c00SJeff Kirsher #define S_TP_VERSION_MAJOR		16
105f7917c00SJeff Kirsher #define M_TP_VERSION_MAJOR		0xFF
106f7917c00SJeff Kirsher #define V_TP_VERSION_MAJOR(x)		((x) << S_TP_VERSION_MAJOR)
107f7917c00SJeff Kirsher #define G_TP_VERSION_MAJOR(x)		\
108f7917c00SJeff Kirsher 	    (((x) >> S_TP_VERSION_MAJOR) & M_TP_VERSION_MAJOR)
109f7917c00SJeff Kirsher 
110f7917c00SJeff Kirsher #define S_TP_VERSION_MINOR		8
111f7917c00SJeff Kirsher #define M_TP_VERSION_MINOR		0xFF
112f7917c00SJeff Kirsher #define V_TP_VERSION_MINOR(x)		((x) << S_TP_VERSION_MINOR)
113f7917c00SJeff Kirsher #define G_TP_VERSION_MINOR(x)		\
114f7917c00SJeff Kirsher 	    (((x) >> S_TP_VERSION_MINOR) & M_TP_VERSION_MINOR)
115f7917c00SJeff Kirsher 
116f7917c00SJeff Kirsher #define S_TP_VERSION_MICRO		0
117f7917c00SJeff Kirsher #define M_TP_VERSION_MICRO		0xFF
118f7917c00SJeff Kirsher #define V_TP_VERSION_MICRO(x)		((x) << S_TP_VERSION_MICRO)
119f7917c00SJeff Kirsher #define G_TP_VERSION_MICRO(x)		\
120f7917c00SJeff Kirsher 	    (((x) >> S_TP_VERSION_MICRO) & M_TP_VERSION_MICRO)
121f7917c00SJeff Kirsher 
122f7917c00SJeff Kirsher enum {
123f7917c00SJeff Kirsher 	SGE_QSETS = 8,		/* # of SGE Tx/Rx/RspQ sets */
124f7917c00SJeff Kirsher 	SGE_RXQ_PER_SET = 2,	/* # of Rx queues per set */
125f7917c00SJeff Kirsher 	SGE_TXQ_PER_SET = 3	/* # of Tx queues per set */
126f7917c00SJeff Kirsher };
127f7917c00SJeff Kirsher 
128f7917c00SJeff Kirsher enum sge_context_type {		/* SGE egress context types */
129f7917c00SJeff Kirsher 	SGE_CNTXT_RDMA = 0,
130f7917c00SJeff Kirsher 	SGE_CNTXT_ETH = 2,
131f7917c00SJeff Kirsher 	SGE_CNTXT_OFLD = 4,
132f7917c00SJeff Kirsher 	SGE_CNTXT_CTRL = 5
133f7917c00SJeff Kirsher };
134f7917c00SJeff Kirsher 
135f7917c00SJeff Kirsher enum {
136f7917c00SJeff Kirsher 	AN_PKT_SIZE = 32,	/* async notification packet size */
137f7917c00SJeff Kirsher 	IMMED_PKT_SIZE = 48	/* packet size for immediate data */
138f7917c00SJeff Kirsher };
139f7917c00SJeff Kirsher 
140f7917c00SJeff Kirsher struct sg_ent {			/* SGE scatter/gather entry */
141f7917c00SJeff Kirsher 	__be32 len[2];
142f7917c00SJeff Kirsher 	__be64 addr[2];
143f7917c00SJeff Kirsher };
144f7917c00SJeff Kirsher 
145f7917c00SJeff Kirsher #ifndef SGE_NUM_GENBITS
146f7917c00SJeff Kirsher /* Must be 1 or 2 */
147f7917c00SJeff Kirsher # define SGE_NUM_GENBITS 2
148f7917c00SJeff Kirsher #endif
149f7917c00SJeff Kirsher 
150f7917c00SJeff Kirsher #define TX_DESC_FLITS 16U
151f7917c00SJeff Kirsher #define WR_FLITS (TX_DESC_FLITS + 1 - SGE_NUM_GENBITS)
152f7917c00SJeff Kirsher 
153f7917c00SJeff Kirsher struct cphy;
154f7917c00SJeff Kirsher struct adapter;
155f7917c00SJeff Kirsher 
156f7917c00SJeff Kirsher struct mdio_ops {
157f7917c00SJeff Kirsher 	int (*read)(struct net_device *dev, int phy_addr, int mmd_addr,
158f7917c00SJeff Kirsher 		    u16 reg_addr);
159f7917c00SJeff Kirsher 	int (*write)(struct net_device *dev, int phy_addr, int mmd_addr,
160f7917c00SJeff Kirsher 		     u16 reg_addr, u16 val);
161f7917c00SJeff Kirsher 	unsigned mode_support;
162f7917c00SJeff Kirsher };
163f7917c00SJeff Kirsher 
164f7917c00SJeff Kirsher struct adapter_info {
165f7917c00SJeff Kirsher 	unsigned char nports0;        /* # of ports on channel 0 */
166f7917c00SJeff Kirsher 	unsigned char nports1;        /* # of ports on channel 1 */
167f7917c00SJeff Kirsher 	unsigned char phy_base_addr;	/* MDIO PHY base address */
168f7917c00SJeff Kirsher 	unsigned int gpio_out;	/* GPIO output settings */
169f7917c00SJeff Kirsher 	unsigned char gpio_intr[MAX_NPORTS]; /* GPIO PHY IRQ pins */
170f7917c00SJeff Kirsher 	unsigned long caps;	/* adapter capabilities */
171f7917c00SJeff Kirsher 	const struct mdio_ops *mdio_ops;	/* MDIO operations */
172f7917c00SJeff Kirsher 	const char *desc;	/* product description */
173f7917c00SJeff Kirsher };
174f7917c00SJeff Kirsher 
175f7917c00SJeff Kirsher struct mc5_stats {
176f7917c00SJeff Kirsher 	unsigned long parity_err;
177f7917c00SJeff Kirsher 	unsigned long active_rgn_full;
178f7917c00SJeff Kirsher 	unsigned long nfa_srch_err;
179f7917c00SJeff Kirsher 	unsigned long unknown_cmd;
180f7917c00SJeff Kirsher 	unsigned long reqq_parity_err;
181f7917c00SJeff Kirsher 	unsigned long dispq_parity_err;
182f7917c00SJeff Kirsher 	unsigned long del_act_empty;
183f7917c00SJeff Kirsher };
184f7917c00SJeff Kirsher 
185f7917c00SJeff Kirsher struct mc7_stats {
186f7917c00SJeff Kirsher 	unsigned long corr_err;
187f7917c00SJeff Kirsher 	unsigned long uncorr_err;
188f7917c00SJeff Kirsher 	unsigned long parity_err;
189f7917c00SJeff Kirsher 	unsigned long addr_err;
190f7917c00SJeff Kirsher };
191f7917c00SJeff Kirsher 
192f7917c00SJeff Kirsher struct mac_stats {
193f7917c00SJeff Kirsher 	u64 tx_octets;		/* total # of octets in good frames */
194f7917c00SJeff Kirsher 	u64 tx_octets_bad;	/* total # of octets in error frames */
195f7917c00SJeff Kirsher 	u64 tx_frames;		/* all good frames */
196f7917c00SJeff Kirsher 	u64 tx_mcast_frames;	/* good multicast frames */
197f7917c00SJeff Kirsher 	u64 tx_bcast_frames;	/* good broadcast frames */
198f7917c00SJeff Kirsher 	u64 tx_pause;		/* # of transmitted pause frames */
199f7917c00SJeff Kirsher 	u64 tx_deferred;	/* frames with deferred transmissions */
200f7917c00SJeff Kirsher 	u64 tx_late_collisions;	/* # of late collisions */
201f7917c00SJeff Kirsher 	u64 tx_total_collisions;	/* # of total collisions */
202f7917c00SJeff Kirsher 	u64 tx_excess_collisions;	/* frame errors from excessive collissions */
203f7917c00SJeff Kirsher 	u64 tx_underrun;	/* # of Tx FIFO underruns */
204f7917c00SJeff Kirsher 	u64 tx_len_errs;	/* # of Tx length errors */
205f7917c00SJeff Kirsher 	u64 tx_mac_internal_errs;	/* # of internal MAC errors on Tx */
206f7917c00SJeff Kirsher 	u64 tx_excess_deferral;	/* # of frames with excessive deferral */
207f7917c00SJeff Kirsher 	u64 tx_fcs_errs;	/* # of frames with bad FCS */
208f7917c00SJeff Kirsher 
209f7917c00SJeff Kirsher 	u64 tx_frames_64;	/* # of Tx frames in a particular range */
210f7917c00SJeff Kirsher 	u64 tx_frames_65_127;
211f7917c00SJeff Kirsher 	u64 tx_frames_128_255;
212f7917c00SJeff Kirsher 	u64 tx_frames_256_511;
213f7917c00SJeff Kirsher 	u64 tx_frames_512_1023;
214f7917c00SJeff Kirsher 	u64 tx_frames_1024_1518;
215f7917c00SJeff Kirsher 	u64 tx_frames_1519_max;
216f7917c00SJeff Kirsher 
217f7917c00SJeff Kirsher 	u64 rx_octets;		/* total # of octets in good frames */
218f7917c00SJeff Kirsher 	u64 rx_octets_bad;	/* total # of octets in error frames */
219f7917c00SJeff Kirsher 	u64 rx_frames;		/* all good frames */
220f7917c00SJeff Kirsher 	u64 rx_mcast_frames;	/* good multicast frames */
221f7917c00SJeff Kirsher 	u64 rx_bcast_frames;	/* good broadcast frames */
222f7917c00SJeff Kirsher 	u64 rx_pause;		/* # of received pause frames */
223f7917c00SJeff Kirsher 	u64 rx_fcs_errs;	/* # of received frames with bad FCS */
224f7917c00SJeff Kirsher 	u64 rx_align_errs;	/* alignment errors */
225f7917c00SJeff Kirsher 	u64 rx_symbol_errs;	/* symbol errors */
226f7917c00SJeff Kirsher 	u64 rx_data_errs;	/* data errors */
227f7917c00SJeff Kirsher 	u64 rx_sequence_errs;	/* sequence errors */
228f7917c00SJeff Kirsher 	u64 rx_runt;		/* # of runt frames */
229f7917c00SJeff Kirsher 	u64 rx_jabber;		/* # of jabber frames */
230f7917c00SJeff Kirsher 	u64 rx_short;		/* # of short frames */
231f7917c00SJeff Kirsher 	u64 rx_too_long;	/* # of oversized frames */
232f7917c00SJeff Kirsher 	u64 rx_mac_internal_errs;	/* # of internal MAC errors on Rx */
233f7917c00SJeff Kirsher 
234f7917c00SJeff Kirsher 	u64 rx_frames_64;	/* # of Rx frames in a particular range */
235f7917c00SJeff Kirsher 	u64 rx_frames_65_127;
236f7917c00SJeff Kirsher 	u64 rx_frames_128_255;
237f7917c00SJeff Kirsher 	u64 rx_frames_256_511;
238f7917c00SJeff Kirsher 	u64 rx_frames_512_1023;
239f7917c00SJeff Kirsher 	u64 rx_frames_1024_1518;
240f7917c00SJeff Kirsher 	u64 rx_frames_1519_max;
241f7917c00SJeff Kirsher 
242f7917c00SJeff Kirsher 	u64 rx_cong_drops;	/* # of Rx drops due to SGE congestion */
243f7917c00SJeff Kirsher 
244f7917c00SJeff Kirsher 	unsigned long tx_fifo_parity_err;
245f7917c00SJeff Kirsher 	unsigned long rx_fifo_parity_err;
246f7917c00SJeff Kirsher 	unsigned long tx_fifo_urun;
247f7917c00SJeff Kirsher 	unsigned long rx_fifo_ovfl;
248f7917c00SJeff Kirsher 	unsigned long serdes_signal_loss;
249f7917c00SJeff Kirsher 	unsigned long xaui_pcs_ctc_err;
250f7917c00SJeff Kirsher 	unsigned long xaui_pcs_align_change;
251f7917c00SJeff Kirsher 
252f7917c00SJeff Kirsher 	unsigned long num_toggled; /* # times toggled TxEn due to stuck TX */
253f7917c00SJeff Kirsher 	unsigned long num_resets;  /* # times reset due to stuck TX */
254f7917c00SJeff Kirsher 
255f7917c00SJeff Kirsher 	unsigned long link_faults;  /* # detected link faults */
256f7917c00SJeff Kirsher };
257f7917c00SJeff Kirsher 
258f7917c00SJeff Kirsher struct tp_mib_stats {
259f7917c00SJeff Kirsher 	u32 ipInReceive_hi;
260f7917c00SJeff Kirsher 	u32 ipInReceive_lo;
261f7917c00SJeff Kirsher 	u32 ipInHdrErrors_hi;
262f7917c00SJeff Kirsher 	u32 ipInHdrErrors_lo;
263f7917c00SJeff Kirsher 	u32 ipInAddrErrors_hi;
264f7917c00SJeff Kirsher 	u32 ipInAddrErrors_lo;
265f7917c00SJeff Kirsher 	u32 ipInUnknownProtos_hi;
266f7917c00SJeff Kirsher 	u32 ipInUnknownProtos_lo;
267f7917c00SJeff Kirsher 	u32 ipInDiscards_hi;
268f7917c00SJeff Kirsher 	u32 ipInDiscards_lo;
269f7917c00SJeff Kirsher 	u32 ipInDelivers_hi;
270f7917c00SJeff Kirsher 	u32 ipInDelivers_lo;
271f7917c00SJeff Kirsher 	u32 ipOutRequests_hi;
272f7917c00SJeff Kirsher 	u32 ipOutRequests_lo;
273f7917c00SJeff Kirsher 	u32 ipOutDiscards_hi;
274f7917c00SJeff Kirsher 	u32 ipOutDiscards_lo;
275f7917c00SJeff Kirsher 	u32 ipOutNoRoutes_hi;
276f7917c00SJeff Kirsher 	u32 ipOutNoRoutes_lo;
277f7917c00SJeff Kirsher 	u32 ipReasmTimeout;
278f7917c00SJeff Kirsher 	u32 ipReasmReqds;
279f7917c00SJeff Kirsher 	u32 ipReasmOKs;
280f7917c00SJeff Kirsher 	u32 ipReasmFails;
281f7917c00SJeff Kirsher 
282f7917c00SJeff Kirsher 	u32 reserved[8];
283f7917c00SJeff Kirsher 
284f7917c00SJeff Kirsher 	u32 tcpActiveOpens;
285f7917c00SJeff Kirsher 	u32 tcpPassiveOpens;
286f7917c00SJeff Kirsher 	u32 tcpAttemptFails;
287f7917c00SJeff Kirsher 	u32 tcpEstabResets;
288f7917c00SJeff Kirsher 	u32 tcpOutRsts;
289f7917c00SJeff Kirsher 	u32 tcpCurrEstab;
290f7917c00SJeff Kirsher 	u32 tcpInSegs_hi;
291f7917c00SJeff Kirsher 	u32 tcpInSegs_lo;
292f7917c00SJeff Kirsher 	u32 tcpOutSegs_hi;
293f7917c00SJeff Kirsher 	u32 tcpOutSegs_lo;
294f7917c00SJeff Kirsher 	u32 tcpRetransSeg_hi;
295f7917c00SJeff Kirsher 	u32 tcpRetransSeg_lo;
296f7917c00SJeff Kirsher 	u32 tcpInErrs_hi;
297f7917c00SJeff Kirsher 	u32 tcpInErrs_lo;
298f7917c00SJeff Kirsher 	u32 tcpRtoMin;
299f7917c00SJeff Kirsher 	u32 tcpRtoMax;
300f7917c00SJeff Kirsher };
301f7917c00SJeff Kirsher 
302f7917c00SJeff Kirsher struct tp_params {
303f7917c00SJeff Kirsher 	unsigned int nchan;	/* # of channels */
304f7917c00SJeff Kirsher 	unsigned int pmrx_size;	/* total PMRX capacity */
305f7917c00SJeff Kirsher 	unsigned int pmtx_size;	/* total PMTX capacity */
306f7917c00SJeff Kirsher 	unsigned int cm_size;	/* total CM capacity */
307f7917c00SJeff Kirsher 	unsigned int chan_rx_size;	/* per channel Rx size */
308f7917c00SJeff Kirsher 	unsigned int chan_tx_size;	/* per channel Tx size */
309f7917c00SJeff Kirsher 	unsigned int rx_pg_size;	/* Rx page size */
310f7917c00SJeff Kirsher 	unsigned int tx_pg_size;	/* Tx page size */
311f7917c00SJeff Kirsher 	unsigned int rx_num_pgs;	/* # of Rx pages */
312f7917c00SJeff Kirsher 	unsigned int tx_num_pgs;	/* # of Tx pages */
313f7917c00SJeff Kirsher 	unsigned int ntimer_qs;	/* # of timer queues */
314f7917c00SJeff Kirsher };
315f7917c00SJeff Kirsher 
316f7917c00SJeff Kirsher struct qset_params {		/* SGE queue set parameters */
317f7917c00SJeff Kirsher 	unsigned int polling;	/* polling/interrupt service for rspq */
318f7917c00SJeff Kirsher 	unsigned int coalesce_usecs;	/* irq coalescing timer */
319f7917c00SJeff Kirsher 	unsigned int rspq_size;	/* # of entries in response queue */
320f7917c00SJeff Kirsher 	unsigned int fl_size;	/* # of entries in regular free list */
321f7917c00SJeff Kirsher 	unsigned int jumbo_size;	/* # of entries in jumbo free list */
322f7917c00SJeff Kirsher 	unsigned int txq_size[SGE_TXQ_PER_SET];	/* Tx queue sizes */
323f7917c00SJeff Kirsher 	unsigned int cong_thres;	/* FL congestion threshold */
324f7917c00SJeff Kirsher 	unsigned int vector;		/* Interrupt (line or vector) number */
325f7917c00SJeff Kirsher };
326f7917c00SJeff Kirsher 
327f7917c00SJeff Kirsher struct sge_params {
328f7917c00SJeff Kirsher 	unsigned int max_pkt_size;	/* max offload pkt size */
329f7917c00SJeff Kirsher 	struct qset_params qset[SGE_QSETS];
330f7917c00SJeff Kirsher };
331f7917c00SJeff Kirsher 
332f7917c00SJeff Kirsher struct mc5_params {
333f7917c00SJeff Kirsher 	unsigned int mode;	/* selects MC5 width */
334f7917c00SJeff Kirsher 	unsigned int nservers;	/* size of server region */
335f7917c00SJeff Kirsher 	unsigned int nfilters;	/* size of filter region */
336f7917c00SJeff Kirsher 	unsigned int nroutes;	/* size of routing region */
337f7917c00SJeff Kirsher };
338f7917c00SJeff Kirsher 
339f7917c00SJeff Kirsher /* Default MC5 region sizes */
340f7917c00SJeff Kirsher enum {
341f7917c00SJeff Kirsher 	DEFAULT_NSERVERS = 512,
342f7917c00SJeff Kirsher 	DEFAULT_NFILTERS = 128
343f7917c00SJeff Kirsher };
344f7917c00SJeff Kirsher 
345f7917c00SJeff Kirsher /* MC5 modes, these must be non-0 */
346f7917c00SJeff Kirsher enum {
347f7917c00SJeff Kirsher 	MC5_MODE_144_BIT = 1,
348f7917c00SJeff Kirsher 	MC5_MODE_72_BIT = 2
349f7917c00SJeff Kirsher };
350f7917c00SJeff Kirsher 
351f7917c00SJeff Kirsher /* MC5 min active region size */
352f7917c00SJeff Kirsher enum { MC5_MIN_TIDS = 16 };
353f7917c00SJeff Kirsher 
354f7917c00SJeff Kirsher struct vpd_params {
355f7917c00SJeff Kirsher 	unsigned int cclk;
356f7917c00SJeff Kirsher 	unsigned int mclk;
357f7917c00SJeff Kirsher 	unsigned int uclk;
358f7917c00SJeff Kirsher 	unsigned int mdc;
359f7917c00SJeff Kirsher 	unsigned int mem_timing;
360f7917c00SJeff Kirsher 	u8 sn[SERNUM_LEN + 1];
361f7917c00SJeff Kirsher 	u8 eth_base[6];
362f7917c00SJeff Kirsher 	u8 port_type[MAX_NPORTS];
363f7917c00SJeff Kirsher 	unsigned short xauicfg[2];
364f7917c00SJeff Kirsher };
365f7917c00SJeff Kirsher 
366f7917c00SJeff Kirsher struct pci_params {
367f7917c00SJeff Kirsher 	unsigned int vpd_cap_addr;
368f7917c00SJeff Kirsher 	unsigned short speed;
369f7917c00SJeff Kirsher 	unsigned char width;
370f7917c00SJeff Kirsher 	unsigned char variant;
371f7917c00SJeff Kirsher };
372f7917c00SJeff Kirsher 
373f7917c00SJeff Kirsher enum {
374f7917c00SJeff Kirsher 	PCI_VARIANT_PCI,
375f7917c00SJeff Kirsher 	PCI_VARIANT_PCIX_MODE1_PARITY,
376f7917c00SJeff Kirsher 	PCI_VARIANT_PCIX_MODE1_ECC,
377f7917c00SJeff Kirsher 	PCI_VARIANT_PCIX_266_MODE2,
378f7917c00SJeff Kirsher 	PCI_VARIANT_PCIE
379f7917c00SJeff Kirsher };
380f7917c00SJeff Kirsher 
381f7917c00SJeff Kirsher struct adapter_params {
382f7917c00SJeff Kirsher 	struct sge_params sge;
383f7917c00SJeff Kirsher 	struct mc5_params mc5;
384f7917c00SJeff Kirsher 	struct tp_params tp;
385f7917c00SJeff Kirsher 	struct vpd_params vpd;
386f7917c00SJeff Kirsher 	struct pci_params pci;
387f7917c00SJeff Kirsher 
388f7917c00SJeff Kirsher 	const struct adapter_info *info;
389f7917c00SJeff Kirsher 
390f7917c00SJeff Kirsher 	unsigned short mtus[NMTUS];
391f7917c00SJeff Kirsher 	unsigned short a_wnd[NCCTRL_WIN];
392f7917c00SJeff Kirsher 	unsigned short b_wnd[NCCTRL_WIN];
393f7917c00SJeff Kirsher 
394f7917c00SJeff Kirsher 	unsigned int nports;	/* # of ethernet ports */
395f7917c00SJeff Kirsher 	unsigned int chan_map;  /* bitmap of in-use Tx channels */
396f7917c00SJeff Kirsher 	unsigned int stats_update_period;	/* MAC stats accumulation period */
397f7917c00SJeff Kirsher 	unsigned int linkpoll_period;	/* link poll period in 0.1s */
398f7917c00SJeff Kirsher 	unsigned int rev;	/* chip revision */
399f7917c00SJeff Kirsher 	unsigned int offload;
400f7917c00SJeff Kirsher };
401f7917c00SJeff Kirsher 
402f7917c00SJeff Kirsher enum {					    /* chip revisions */
403f7917c00SJeff Kirsher 	T3_REV_A  = 0,
404f7917c00SJeff Kirsher 	T3_REV_B  = 2,
405f7917c00SJeff Kirsher 	T3_REV_B2 = 3,
406f7917c00SJeff Kirsher 	T3_REV_C  = 4,
407f7917c00SJeff Kirsher };
408f7917c00SJeff Kirsher 
409f7917c00SJeff Kirsher struct trace_params {
410f7917c00SJeff Kirsher 	u32 sip;
411f7917c00SJeff Kirsher 	u32 sip_mask;
412f7917c00SJeff Kirsher 	u32 dip;
413f7917c00SJeff Kirsher 	u32 dip_mask;
414f7917c00SJeff Kirsher 	u16 sport;
415f7917c00SJeff Kirsher 	u16 sport_mask;
416f7917c00SJeff Kirsher 	u16 dport;
417f7917c00SJeff Kirsher 	u16 dport_mask;
418f7917c00SJeff Kirsher 	u32 vlan:12;
419f7917c00SJeff Kirsher 	u32 vlan_mask:12;
420f7917c00SJeff Kirsher 	u32 intf:4;
421f7917c00SJeff Kirsher 	u32 intf_mask:4;
422f7917c00SJeff Kirsher 	u8 proto;
423f7917c00SJeff Kirsher 	u8 proto_mask;
424f7917c00SJeff Kirsher };
425f7917c00SJeff Kirsher 
426f7917c00SJeff Kirsher struct link_config {
427f7917c00SJeff Kirsher 	unsigned int supported;	/* link capabilities */
428f7917c00SJeff Kirsher 	unsigned int advertising;	/* advertised capabilities */
429f7917c00SJeff Kirsher 	unsigned short requested_speed;	/* speed user has requested */
430f7917c00SJeff Kirsher 	unsigned short speed;	/* actual link speed */
431f7917c00SJeff Kirsher 	unsigned char requested_duplex;	/* duplex user has requested */
432f7917c00SJeff Kirsher 	unsigned char duplex;	/* actual link duplex */
433f7917c00SJeff Kirsher 	unsigned char requested_fc;	/* flow control user has requested */
434f7917c00SJeff Kirsher 	unsigned char fc;	/* actual link flow control */
435f7917c00SJeff Kirsher 	unsigned char autoneg;	/* autonegotiating? */
436f7917c00SJeff Kirsher 	unsigned int link_ok;	/* link up? */
437f7917c00SJeff Kirsher };
438f7917c00SJeff Kirsher 
439f7917c00SJeff Kirsher #define SPEED_INVALID   0xffff
440f7917c00SJeff Kirsher #define DUPLEX_INVALID  0xff
441f7917c00SJeff Kirsher 
442f7917c00SJeff Kirsher struct mc5 {
443f7917c00SJeff Kirsher 	struct adapter *adapter;
444f7917c00SJeff Kirsher 	unsigned int tcam_size;
445f7917c00SJeff Kirsher 	unsigned char part_type;
446f7917c00SJeff Kirsher 	unsigned char parity_enabled;
447f7917c00SJeff Kirsher 	unsigned char mode;
448f7917c00SJeff Kirsher 	struct mc5_stats stats;
449f7917c00SJeff Kirsher };
450f7917c00SJeff Kirsher 
t3_mc5_size(const struct mc5 * p)451f7917c00SJeff Kirsher static inline unsigned int t3_mc5_size(const struct mc5 *p)
452f7917c00SJeff Kirsher {
453f7917c00SJeff Kirsher 	return p->tcam_size;
454f7917c00SJeff Kirsher }
455f7917c00SJeff Kirsher 
456f7917c00SJeff Kirsher struct mc7 {
457f7917c00SJeff Kirsher 	struct adapter *adapter;	/* backpointer to adapter */
458f7917c00SJeff Kirsher 	unsigned int size;	/* memory size in bytes */
459f7917c00SJeff Kirsher 	unsigned int width;	/* MC7 interface width */
460f7917c00SJeff Kirsher 	unsigned int offset;	/* register address offset for MC7 instance */
461f7917c00SJeff Kirsher 	const char *name;	/* name of MC7 instance */
462f7917c00SJeff Kirsher 	struct mc7_stats stats;	/* MC7 statistics */
463f7917c00SJeff Kirsher };
464f7917c00SJeff Kirsher 
t3_mc7_size(const struct mc7 * p)465f7917c00SJeff Kirsher static inline unsigned int t3_mc7_size(const struct mc7 *p)
466f7917c00SJeff Kirsher {
467f7917c00SJeff Kirsher 	return p->size;
468f7917c00SJeff Kirsher }
469f7917c00SJeff Kirsher 
470f7917c00SJeff Kirsher struct cmac {
471f7917c00SJeff Kirsher 	struct adapter *adapter;
472f7917c00SJeff Kirsher 	unsigned int offset;
473f7917c00SJeff Kirsher 	unsigned int nucast;	/* # of address filters for unicast MACs */
474f7917c00SJeff Kirsher 	unsigned int tx_tcnt;
475f7917c00SJeff Kirsher 	unsigned int tx_xcnt;
476f7917c00SJeff Kirsher 	u64 tx_mcnt;
477f7917c00SJeff Kirsher 	unsigned int rx_xcnt;
478f7917c00SJeff Kirsher 	unsigned int rx_ocnt;
479f7917c00SJeff Kirsher 	u64 rx_mcnt;
480f7917c00SJeff Kirsher 	unsigned int toggle_cnt;
481f7917c00SJeff Kirsher 	unsigned int txen;
482f7917c00SJeff Kirsher 	u64 rx_pause;
483f7917c00SJeff Kirsher 	struct mac_stats stats;
484f7917c00SJeff Kirsher };
485f7917c00SJeff Kirsher 
486f7917c00SJeff Kirsher enum {
487f7917c00SJeff Kirsher 	MAC_DIRECTION_RX = 1,
488f7917c00SJeff Kirsher 	MAC_DIRECTION_TX = 2,
489f7917c00SJeff Kirsher 	MAC_RXFIFO_SIZE = 32768
490f7917c00SJeff Kirsher };
491f7917c00SJeff Kirsher 
492f7917c00SJeff Kirsher /* PHY loopback direction */
493f7917c00SJeff Kirsher enum {
494f7917c00SJeff Kirsher 	PHY_LOOPBACK_TX = 1,
495f7917c00SJeff Kirsher 	PHY_LOOPBACK_RX = 2
496f7917c00SJeff Kirsher };
497f7917c00SJeff Kirsher 
498f7917c00SJeff Kirsher /* PHY interrupt types */
499f7917c00SJeff Kirsher enum {
500f7917c00SJeff Kirsher 	cphy_cause_link_change = 1,
501f7917c00SJeff Kirsher 	cphy_cause_fifo_error = 2,
502f7917c00SJeff Kirsher 	cphy_cause_module_change = 4,
503f7917c00SJeff Kirsher };
504f7917c00SJeff Kirsher 
505f7917c00SJeff Kirsher /* PHY module types */
506f7917c00SJeff Kirsher enum {
507f7917c00SJeff Kirsher 	phy_modtype_none,
508f7917c00SJeff Kirsher 	phy_modtype_sr,
509f7917c00SJeff Kirsher 	phy_modtype_lr,
510f7917c00SJeff Kirsher 	phy_modtype_lrm,
511f7917c00SJeff Kirsher 	phy_modtype_twinax,
512f7917c00SJeff Kirsher 	phy_modtype_twinax_long,
513f7917c00SJeff Kirsher 	phy_modtype_unknown
514f7917c00SJeff Kirsher };
515f7917c00SJeff Kirsher 
516f7917c00SJeff Kirsher /* PHY operations */
517f7917c00SJeff Kirsher struct cphy_ops {
518f7917c00SJeff Kirsher 	int (*reset)(struct cphy *phy, int wait);
519f7917c00SJeff Kirsher 
520f7917c00SJeff Kirsher 	int (*intr_enable)(struct cphy *phy);
521f7917c00SJeff Kirsher 	int (*intr_disable)(struct cphy *phy);
522f7917c00SJeff Kirsher 	int (*intr_clear)(struct cphy *phy);
523f7917c00SJeff Kirsher 	int (*intr_handler)(struct cphy *phy);
524f7917c00SJeff Kirsher 
525f7917c00SJeff Kirsher 	int (*autoneg_enable)(struct cphy *phy);
526f7917c00SJeff Kirsher 	int (*autoneg_restart)(struct cphy *phy);
527f7917c00SJeff Kirsher 
528f7917c00SJeff Kirsher 	int (*advertise)(struct cphy *phy, unsigned int advertise_map);
529f7917c00SJeff Kirsher 	int (*set_loopback)(struct cphy *phy, int mmd, int dir, int enable);
530f7917c00SJeff Kirsher 	int (*set_speed_duplex)(struct cphy *phy, int speed, int duplex);
531f7917c00SJeff Kirsher 	int (*get_link_status)(struct cphy *phy, int *link_ok, int *speed,
532f7917c00SJeff Kirsher 			       int *duplex, int *fc);
533f7917c00SJeff Kirsher 	int (*power_down)(struct cphy *phy, int enable);
534f7917c00SJeff Kirsher 
535f7917c00SJeff Kirsher 	u32 mmds;
536f7917c00SJeff Kirsher };
537f7917c00SJeff Kirsher enum {
538f7917c00SJeff Kirsher 	EDC_OPT_AEL2005 = 0,
539f7917c00SJeff Kirsher 	EDC_OPT_AEL2005_SIZE = 1084,
540f7917c00SJeff Kirsher 	EDC_TWX_AEL2005 = 1,
541f7917c00SJeff Kirsher 	EDC_TWX_AEL2005_SIZE = 1464,
542f7917c00SJeff Kirsher 	EDC_TWX_AEL2020 = 2,
543f7917c00SJeff Kirsher 	EDC_TWX_AEL2020_SIZE = 1628,
544f7917c00SJeff Kirsher 	EDC_MAX_SIZE = EDC_TWX_AEL2020_SIZE, /* Max cache size */
545f7917c00SJeff Kirsher };
546f7917c00SJeff Kirsher 
547f7917c00SJeff Kirsher /* A PHY instance */
548f7917c00SJeff Kirsher struct cphy {
549f7917c00SJeff Kirsher 	u8 modtype;			/* PHY module type */
550f7917c00SJeff Kirsher 	short priv;			/* scratch pad */
551f7917c00SJeff Kirsher 	unsigned int caps;		/* PHY capabilities */
552f7917c00SJeff Kirsher 	struct adapter *adapter;	/* associated adapter */
553f7917c00SJeff Kirsher 	const char *desc;		/* PHY description */
554f7917c00SJeff Kirsher 	unsigned long fifo_errors;	/* FIFO over/under-flows */
555f7917c00SJeff Kirsher 	const struct cphy_ops *ops;	/* PHY operations */
556f7917c00SJeff Kirsher 	struct mdio_if_info mdio;
557f7917c00SJeff Kirsher 	u16 phy_cache[EDC_MAX_SIZE];	/* EDC cache */
558f7917c00SJeff Kirsher };
559f7917c00SJeff Kirsher 
560f7917c00SJeff Kirsher /* Convenience MDIO read/write wrappers */
t3_mdio_read(struct cphy * phy,int mmd,int reg,unsigned int * valp)561f7917c00SJeff Kirsher static inline int t3_mdio_read(struct cphy *phy, int mmd, int reg,
562f7917c00SJeff Kirsher 			       unsigned int *valp)
563f7917c00SJeff Kirsher {
564f7917c00SJeff Kirsher 	int rc = phy->mdio.mdio_read(phy->mdio.dev, phy->mdio.prtad, mmd, reg);
565f7917c00SJeff Kirsher 	*valp = (rc >= 0) ? rc : -1;
566f7917c00SJeff Kirsher 	return (rc >= 0) ? 0 : rc;
567f7917c00SJeff Kirsher }
568f7917c00SJeff Kirsher 
t3_mdio_write(struct cphy * phy,int mmd,int reg,unsigned int val)569f7917c00SJeff Kirsher static inline int t3_mdio_write(struct cphy *phy, int mmd, int reg,
570f7917c00SJeff Kirsher 				unsigned int val)
571f7917c00SJeff Kirsher {
572f7917c00SJeff Kirsher 	return phy->mdio.mdio_write(phy->mdio.dev, phy->mdio.prtad, mmd,
573f7917c00SJeff Kirsher 				    reg, val);
574f7917c00SJeff Kirsher }
575f7917c00SJeff Kirsher 
576f7917c00SJeff Kirsher /* Convenience initializer */
cphy_init(struct cphy * phy,struct adapter * adapter,int phy_addr,const struct cphy_ops * phy_ops,const struct mdio_ops * mdio_ops,unsigned int caps,const char * desc)577f7917c00SJeff Kirsher static inline void cphy_init(struct cphy *phy, struct adapter *adapter,
57846f85a92SJulia Lawall 			     int phy_addr, const struct cphy_ops *phy_ops,
579f7917c00SJeff Kirsher 			     const struct mdio_ops *mdio_ops,
580f7917c00SJeff Kirsher 			      unsigned int caps, const char *desc)
581f7917c00SJeff Kirsher {
582f7917c00SJeff Kirsher 	phy->caps = caps;
583f7917c00SJeff Kirsher 	phy->adapter = adapter;
584f7917c00SJeff Kirsher 	phy->desc = desc;
585f7917c00SJeff Kirsher 	phy->ops = phy_ops;
586f7917c00SJeff Kirsher 	if (mdio_ops) {
587f7917c00SJeff Kirsher 		phy->mdio.prtad = phy_addr;
588f7917c00SJeff Kirsher 		phy->mdio.mmds = phy_ops->mmds;
589f7917c00SJeff Kirsher 		phy->mdio.mode_support = mdio_ops->mode_support;
590f7917c00SJeff Kirsher 		phy->mdio.mdio_read = mdio_ops->read;
591f7917c00SJeff Kirsher 		phy->mdio.mdio_write = mdio_ops->write;
592f7917c00SJeff Kirsher 	}
593f7917c00SJeff Kirsher }
594f7917c00SJeff Kirsher 
595f7917c00SJeff Kirsher /* Accumulate MAC statistics every 180 seconds.  For 1G we multiply by 10. */
596f7917c00SJeff Kirsher #define MAC_STATS_ACCUM_SECS 180
597f7917c00SJeff Kirsher 
598f7917c00SJeff Kirsher #define XGM_REG(reg_addr, idx) \
599f7917c00SJeff Kirsher 	((reg_addr) + (idx) * (XGMAC0_1_BASE_ADDR - XGMAC0_0_BASE_ADDR))
600f7917c00SJeff Kirsher 
601f7917c00SJeff Kirsher struct addr_val_pair {
602f7917c00SJeff Kirsher 	unsigned int reg_addr;
603f7917c00SJeff Kirsher 	unsigned int val;
604f7917c00SJeff Kirsher };
605f7917c00SJeff Kirsher 
606f7917c00SJeff Kirsher #include "adapter.h"
607f7917c00SJeff Kirsher 
608f7917c00SJeff Kirsher #ifndef PCI_VENDOR_ID_CHELSIO
609f7917c00SJeff Kirsher # define PCI_VENDOR_ID_CHELSIO 0x1425
610f7917c00SJeff Kirsher #endif
611f7917c00SJeff Kirsher 
612f7917c00SJeff Kirsher #define for_each_port(adapter, iter) \
613f7917c00SJeff Kirsher 	for (iter = 0; iter < (adapter)->params.nports; ++iter)
614f7917c00SJeff Kirsher 
615f7917c00SJeff Kirsher #define adapter_info(adap) ((adap)->params.info)
616f7917c00SJeff Kirsher 
uses_xaui(const struct adapter * adap)617f7917c00SJeff Kirsher static inline int uses_xaui(const struct adapter *adap)
618f7917c00SJeff Kirsher {
619f7917c00SJeff Kirsher 	return adapter_info(adap)->caps & SUPPORTED_AUI;
620f7917c00SJeff Kirsher }
621f7917c00SJeff Kirsher 
is_10G(const struct adapter * adap)622f7917c00SJeff Kirsher static inline int is_10G(const struct adapter *adap)
623f7917c00SJeff Kirsher {
624f7917c00SJeff Kirsher 	return adapter_info(adap)->caps & SUPPORTED_10000baseT_Full;
625f7917c00SJeff Kirsher }
626f7917c00SJeff Kirsher 
is_offload(const struct adapter * adap)627f7917c00SJeff Kirsher static inline int is_offload(const struct adapter *adap)
628f7917c00SJeff Kirsher {
629f7917c00SJeff Kirsher 	return adap->params.offload;
630f7917c00SJeff Kirsher }
631f7917c00SJeff Kirsher 
core_ticks_per_usec(const struct adapter * adap)632f7917c00SJeff Kirsher static inline unsigned int core_ticks_per_usec(const struct adapter *adap)
633f7917c00SJeff Kirsher {
634f7917c00SJeff Kirsher 	return adap->params.vpd.cclk / 1000;
635f7917c00SJeff Kirsher }
636f7917c00SJeff Kirsher 
is_pcie(const struct adapter * adap)637f7917c00SJeff Kirsher static inline unsigned int is_pcie(const struct adapter *adap)
638f7917c00SJeff Kirsher {
639f7917c00SJeff Kirsher 	return adap->params.pci.variant == PCI_VARIANT_PCIE;
640f7917c00SJeff Kirsher }
641f7917c00SJeff Kirsher 
642f7917c00SJeff Kirsher void t3_set_reg_field(struct adapter *adap, unsigned int addr, u32 mask,
643f7917c00SJeff Kirsher 		      u32 val);
644f7917c00SJeff Kirsher void t3_write_regs(struct adapter *adapter, const struct addr_val_pair *p,
645f7917c00SJeff Kirsher 		   int n, unsigned int offset);
646f7917c00SJeff Kirsher int t3_wait_op_done_val(struct adapter *adapter, int reg, u32 mask,
647f7917c00SJeff Kirsher 			int polarity, int attempts, int delay, u32 *valp);
t3_wait_op_done(struct adapter * adapter,int reg,u32 mask,int polarity,int attempts,int delay)648f7917c00SJeff Kirsher static inline int t3_wait_op_done(struct adapter *adapter, int reg, u32 mask,
649f7917c00SJeff Kirsher 				  int polarity, int attempts, int delay)
650f7917c00SJeff Kirsher {
651f7917c00SJeff Kirsher 	return t3_wait_op_done_val(adapter, reg, mask, polarity, attempts,
652f7917c00SJeff Kirsher 				   delay, NULL);
653f7917c00SJeff Kirsher }
654f7917c00SJeff Kirsher int t3_mdio_change_bits(struct cphy *phy, int mmd, int reg, unsigned int clear,
655f7917c00SJeff Kirsher 			unsigned int set);
656f7917c00SJeff Kirsher int t3_phy_reset(struct cphy *phy, int mmd, int wait);
657f7917c00SJeff Kirsher int t3_phy_advertise(struct cphy *phy, unsigned int advert);
658f7917c00SJeff Kirsher int t3_phy_advertise_fiber(struct cphy *phy, unsigned int advert);
659f7917c00SJeff Kirsher int t3_set_phy_speed_duplex(struct cphy *phy, int speed, int duplex);
660f7917c00SJeff Kirsher int t3_phy_lasi_intr_enable(struct cphy *phy);
661f7917c00SJeff Kirsher int t3_phy_lasi_intr_disable(struct cphy *phy);
662f7917c00SJeff Kirsher int t3_phy_lasi_intr_clear(struct cphy *phy);
663f7917c00SJeff Kirsher int t3_phy_lasi_intr_handler(struct cphy *phy);
664f7917c00SJeff Kirsher 
665f7917c00SJeff Kirsher void t3_intr_enable(struct adapter *adapter);
666f7917c00SJeff Kirsher void t3_intr_disable(struct adapter *adapter);
667f7917c00SJeff Kirsher void t3_intr_clear(struct adapter *adapter);
668f7917c00SJeff Kirsher void t3_xgm_intr_enable(struct adapter *adapter, int idx);
669f7917c00SJeff Kirsher void t3_xgm_intr_disable(struct adapter *adapter, int idx);
670f7917c00SJeff Kirsher void t3_port_intr_enable(struct adapter *adapter, int idx);
671f7917c00SJeff Kirsher void t3_port_intr_disable(struct adapter *adapter, int idx);
672f7917c00SJeff Kirsher int t3_slow_intr_handler(struct adapter *adapter);
673f7917c00SJeff Kirsher int t3_phy_intr_handler(struct adapter *adapter);
674f7917c00SJeff Kirsher 
675f7917c00SJeff Kirsher void t3_link_changed(struct adapter *adapter, int port_id);
676f7917c00SJeff Kirsher void t3_link_fault(struct adapter *adapter, int port_id);
677f7917c00SJeff Kirsher int t3_link_start(struct cphy *phy, struct cmac *mac, struct link_config *lc);
678f7917c00SJeff Kirsher const struct adapter_info *t3_get_adapter_info(unsigned int board_id);
679f7917c00SJeff Kirsher int t3_seeprom_wp(struct adapter *adapter, int enable);
680f7917c00SJeff Kirsher int t3_get_tp_version(struct adapter *adapter, u32 *vers);
681f7917c00SJeff Kirsher int t3_check_tpsram_version(struct adapter *adapter);
682f7917c00SJeff Kirsher int t3_check_tpsram(struct adapter *adapter, const u8 *tp_ram,
683f7917c00SJeff Kirsher 		    unsigned int size);
684f7917c00SJeff Kirsher int t3_set_proto_sram(struct adapter *adap, const u8 *data);
685f7917c00SJeff Kirsher int t3_load_fw(struct adapter *adapter, const u8 * fw_data, unsigned int size);
686f7917c00SJeff Kirsher int t3_get_fw_version(struct adapter *adapter, u32 *vers);
687f7917c00SJeff Kirsher int t3_check_fw_version(struct adapter *adapter);
688f7917c00SJeff Kirsher int t3_init_hw(struct adapter *adapter, u32 fw_params);
689f7917c00SJeff Kirsher int t3_reset_adapter(struct adapter *adapter);
690f7917c00SJeff Kirsher int t3_prep_adapter(struct adapter *adapter, const struct adapter_info *ai,
691f7917c00SJeff Kirsher 		    int reset);
692f7917c00SJeff Kirsher int t3_replay_prep_adapter(struct adapter *adapter);
693f7917c00SJeff Kirsher void t3_led_ready(struct adapter *adapter);
694f7917c00SJeff Kirsher void t3_fatal_err(struct adapter *adapter);
695f7917c00SJeff Kirsher void t3_set_vlan_accel(struct adapter *adapter, unsigned int ports, int on);
696f7917c00SJeff Kirsher void t3_config_rss(struct adapter *adapter, unsigned int rss_config,
697f7917c00SJeff Kirsher 		   const u8 * cpus, const u16 *rspq);
698f7917c00SJeff Kirsher int t3_cim_ctl_blk_read(struct adapter *adap, unsigned int addr,
699f7917c00SJeff Kirsher 			unsigned int n, unsigned int *valp);
700f7917c00SJeff Kirsher int t3_mc7_bd_read(struct mc7 *mc7, unsigned int start, unsigned int n,
701f7917c00SJeff Kirsher 		   u64 *buf);
702f7917c00SJeff Kirsher 
703f7917c00SJeff Kirsher int t3_mac_reset(struct cmac *mac);
704f7917c00SJeff Kirsher void t3b_pcs_reset(struct cmac *mac);
705f7917c00SJeff Kirsher void t3_mac_disable_exact_filters(struct cmac *mac);
706f7917c00SJeff Kirsher void t3_mac_enable_exact_filters(struct cmac *mac);
707f7917c00SJeff Kirsher int t3_mac_enable(struct cmac *mac, int which);
708f7917c00SJeff Kirsher int t3_mac_disable(struct cmac *mac, int which);
709f7917c00SJeff Kirsher int t3_mac_set_mtu(struct cmac *mac, unsigned int mtu);
710f7917c00SJeff Kirsher int t3_mac_set_rx_mode(struct cmac *mac, struct net_device *dev);
711f7917c00SJeff Kirsher int t3_mac_set_address(struct cmac *mac, unsigned int idx, const u8 addr[6]);
712f7917c00SJeff Kirsher int t3_mac_set_num_ucast(struct cmac *mac, int n);
713f7917c00SJeff Kirsher const struct mac_stats *t3_mac_update_stats(struct cmac *mac);
714f7917c00SJeff Kirsher int t3_mac_set_speed_duplex_fc(struct cmac *mac, int speed, int duplex, int fc);
715f7917c00SJeff Kirsher int t3b2_mac_watchdog_task(struct cmac *mac);
716f7917c00SJeff Kirsher 
717f7917c00SJeff Kirsher void t3_mc5_prep(struct adapter *adapter, struct mc5 *mc5, int mode);
718f7917c00SJeff Kirsher int t3_mc5_init(struct mc5 *mc5, unsigned int nservers, unsigned int nfilters,
719f7917c00SJeff Kirsher 		unsigned int nroutes);
720f7917c00SJeff Kirsher void t3_mc5_intr_handler(struct mc5 *mc5);
721f7917c00SJeff Kirsher 
722f7917c00SJeff Kirsher void t3_tp_set_offload_mode(struct adapter *adap, int enable);
723f7917c00SJeff Kirsher void t3_tp_get_mib_stats(struct adapter *adap, struct tp_mib_stats *tps);
724f7917c00SJeff Kirsher void t3_load_mtus(struct adapter *adap, unsigned short mtus[NMTUS],
725f7917c00SJeff Kirsher 		  unsigned short alpha[NCCTRL_WIN],
726f7917c00SJeff Kirsher 		  unsigned short beta[NCCTRL_WIN], unsigned short mtu_cap);
727f7917c00SJeff Kirsher void t3_config_trace_filter(struct adapter *adapter,
728f7917c00SJeff Kirsher 			    const struct trace_params *tp, int filter_index,
729f7917c00SJeff Kirsher 			    int invert, int enable);
730f7917c00SJeff Kirsher int t3_config_sched(struct adapter *adap, unsigned int kbps, int sched);
731f7917c00SJeff Kirsher 
732f7917c00SJeff Kirsher void t3_sge_prep(struct adapter *adap, struct sge_params *p);
733f7917c00SJeff Kirsher void t3_sge_init(struct adapter *adap, struct sge_params *p);
734f7917c00SJeff Kirsher int t3_sge_init_ecntxt(struct adapter *adapter, unsigned int id, int gts_enable,
735f7917c00SJeff Kirsher 		       enum sge_context_type type, int respq, u64 base_addr,
736f7917c00SJeff Kirsher 		       unsigned int size, unsigned int token, int gen,
737f7917c00SJeff Kirsher 		       unsigned int cidx);
738f7917c00SJeff Kirsher int t3_sge_init_flcntxt(struct adapter *adapter, unsigned int id,
739f7917c00SJeff Kirsher 			int gts_enable, u64 base_addr, unsigned int size,
740f7917c00SJeff Kirsher 			unsigned int esize, unsigned int cong_thres, int gen,
741f7917c00SJeff Kirsher 			unsigned int cidx);
742f7917c00SJeff Kirsher int t3_sge_init_rspcntxt(struct adapter *adapter, unsigned int id,
743f7917c00SJeff Kirsher 			 int irq_vec_idx, u64 base_addr, unsigned int size,
744f7917c00SJeff Kirsher 			 unsigned int fl_thres, int gen, unsigned int cidx);
745f7917c00SJeff Kirsher int t3_sge_init_cqcntxt(struct adapter *adapter, unsigned int id, u64 base_addr,
746f7917c00SJeff Kirsher 			unsigned int size, int rspq, int ovfl_mode,
747f7917c00SJeff Kirsher 			unsigned int credits, unsigned int credit_thres);
748f7917c00SJeff Kirsher int t3_sge_enable_ecntxt(struct adapter *adapter, unsigned int id, int enable);
749f7917c00SJeff Kirsher int t3_sge_disable_fl(struct adapter *adapter, unsigned int id);
750f7917c00SJeff Kirsher int t3_sge_disable_rspcntxt(struct adapter *adapter, unsigned int id);
751f7917c00SJeff Kirsher int t3_sge_disable_cqcntxt(struct adapter *adapter, unsigned int id);
752f7917c00SJeff Kirsher int t3_sge_cqcntxt_op(struct adapter *adapter, unsigned int id, unsigned int op,
753f7917c00SJeff Kirsher 		      unsigned int credits);
754f7917c00SJeff Kirsher 
755f7917c00SJeff Kirsher int t3_vsc8211_phy_prep(struct cphy *phy, struct adapter *adapter,
756f7917c00SJeff Kirsher 			int phy_addr, const struct mdio_ops *mdio_ops);
757f7917c00SJeff Kirsher int t3_ael1002_phy_prep(struct cphy *phy, struct adapter *adapter,
758f7917c00SJeff Kirsher 			int phy_addr, const struct mdio_ops *mdio_ops);
759f7917c00SJeff Kirsher int t3_ael1006_phy_prep(struct cphy *phy, struct adapter *adapter,
760f7917c00SJeff Kirsher 			int phy_addr, const struct mdio_ops *mdio_ops);
761f7917c00SJeff Kirsher int t3_ael2005_phy_prep(struct cphy *phy, struct adapter *adapter,
762f7917c00SJeff Kirsher 			int phy_addr, const struct mdio_ops *mdio_ops);
763f7917c00SJeff Kirsher int t3_ael2020_phy_prep(struct cphy *phy, struct adapter *adapter,
764f7917c00SJeff Kirsher 			int phy_addr, const struct mdio_ops *mdio_ops);
765f7917c00SJeff Kirsher int t3_qt2045_phy_prep(struct cphy *phy, struct adapter *adapter, int phy_addr,
766f7917c00SJeff Kirsher 		       const struct mdio_ops *mdio_ops);
767f7917c00SJeff Kirsher int t3_xaui_direct_phy_prep(struct cphy *phy, struct adapter *adapter,
768f7917c00SJeff Kirsher 			    int phy_addr, const struct mdio_ops *mdio_ops);
769f7917c00SJeff Kirsher int t3_aq100x_phy_prep(struct cphy *phy, struct adapter *adapter,
770f7917c00SJeff Kirsher 			    int phy_addr, const struct mdio_ops *mdio_ops);
771*5e0b8928SÍñigo Huguet 
772*5e0b8928SÍñigo Huguet extern struct workqueue_struct *cxgb3_wq;
773f7917c00SJeff Kirsher #endif				/* __CHELSIO_COMMON_H */
774