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