xref: /OK3568_Linux_fs/kernel/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * This file is part of the Chelsio T4 Ethernet driver for Linux.
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Copyright (c) 2003-2016 Chelsio Communications, Inc. All rights reserved.
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  * This software is available to you under a choice of one of two
7*4882a593Smuzhiyun  * licenses.  You may choose to be licensed under the terms of the GNU
8*4882a593Smuzhiyun  * General Public License (GPL) Version 2, available from the file
9*4882a593Smuzhiyun  * COPYING in the main directory of this source tree, or the
10*4882a593Smuzhiyun  * OpenIB.org BSD license below:
11*4882a593Smuzhiyun  *
12*4882a593Smuzhiyun  *     Redistribution and use in source and binary forms, with or
13*4882a593Smuzhiyun  *     without modification, are permitted provided that the following
14*4882a593Smuzhiyun  *     conditions are met:
15*4882a593Smuzhiyun  *
16*4882a593Smuzhiyun  *      - Redistributions of source code must retain the above
17*4882a593Smuzhiyun  *        copyright notice, this list of conditions and the following
18*4882a593Smuzhiyun  *        disclaimer.
19*4882a593Smuzhiyun  *
20*4882a593Smuzhiyun  *      - Redistributions in binary form must reproduce the above
21*4882a593Smuzhiyun  *        copyright notice, this list of conditions and the following
22*4882a593Smuzhiyun  *        disclaimer in the documentation and/or other materials
23*4882a593Smuzhiyun  *        provided with the distribution.
24*4882a593Smuzhiyun  *
25*4882a593Smuzhiyun  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26*4882a593Smuzhiyun  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27*4882a593Smuzhiyun  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28*4882a593Smuzhiyun  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29*4882a593Smuzhiyun  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30*4882a593Smuzhiyun  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31*4882a593Smuzhiyun  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32*4882a593Smuzhiyun  * SOFTWARE.
33*4882a593Smuzhiyun  */
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun #ifndef __CXGB4_H__
36*4882a593Smuzhiyun #define __CXGB4_H__
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun #include "t4_hw.h"
39*4882a593Smuzhiyun 
40*4882a593Smuzhiyun #include <linux/bitops.h>
41*4882a593Smuzhiyun #include <linux/cache.h>
42*4882a593Smuzhiyun #include <linux/interrupt.h>
43*4882a593Smuzhiyun #include <linux/list.h>
44*4882a593Smuzhiyun #include <linux/netdevice.h>
45*4882a593Smuzhiyun #include <linux/pci.h>
46*4882a593Smuzhiyun #include <linux/spinlock.h>
47*4882a593Smuzhiyun #include <linux/timer.h>
48*4882a593Smuzhiyun #include <linux/vmalloc.h>
49*4882a593Smuzhiyun #include <linux/rhashtable.h>
50*4882a593Smuzhiyun #include <linux/etherdevice.h>
51*4882a593Smuzhiyun #include <linux/net_tstamp.h>
52*4882a593Smuzhiyun #include <linux/ptp_clock_kernel.h>
53*4882a593Smuzhiyun #include <linux/ptp_classify.h>
54*4882a593Smuzhiyun #include <linux/crash_dump.h>
55*4882a593Smuzhiyun #include <linux/thermal.h>
56*4882a593Smuzhiyun #include <asm/io.h>
57*4882a593Smuzhiyun #include "t4_chip_type.h"
58*4882a593Smuzhiyun #include "cxgb4_uld.h"
59*4882a593Smuzhiyun #include "t4fw_api.h"
60*4882a593Smuzhiyun 
61*4882a593Smuzhiyun #define CH_WARN(adap, fmt, ...) dev_warn(adap->pdev_dev, fmt, ## __VA_ARGS__)
62*4882a593Smuzhiyun extern struct list_head adapter_list;
63*4882a593Smuzhiyun extern struct list_head uld_list;
64*4882a593Smuzhiyun extern struct mutex uld_mutex;
65*4882a593Smuzhiyun 
66*4882a593Smuzhiyun /* Suspend an Ethernet Tx queue with fewer available descriptors than this.
67*4882a593Smuzhiyun  * This is the same as calc_tx_descs() for a TSO packet with
68*4882a593Smuzhiyun  * nr_frags == MAX_SKB_FRAGS.
69*4882a593Smuzhiyun  */
70*4882a593Smuzhiyun #define ETHTXQ_STOP_THRES \
71*4882a593Smuzhiyun 	(1 + DIV_ROUND_UP((3 * MAX_SKB_FRAGS) / 2 + (MAX_SKB_FRAGS & 1), 8))
72*4882a593Smuzhiyun 
73*4882a593Smuzhiyun #define FW_PARAM_DEV(param) \
74*4882a593Smuzhiyun 	(FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DEV) | \
75*4882a593Smuzhiyun 	 FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_DEV_##param))
76*4882a593Smuzhiyun 
77*4882a593Smuzhiyun #define FW_PARAM_PFVF(param) \
78*4882a593Smuzhiyun 	(FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_PFVF) | \
79*4882a593Smuzhiyun 	 FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_PFVF_##param) |  \
80*4882a593Smuzhiyun 	 FW_PARAMS_PARAM_Y_V(0) | \
81*4882a593Smuzhiyun 	 FW_PARAMS_PARAM_Z_V(0))
82*4882a593Smuzhiyun 
83*4882a593Smuzhiyun enum {
84*4882a593Smuzhiyun 	MAX_NPORTS	= 4,     /* max # of ports */
85*4882a593Smuzhiyun 	SERNUM_LEN	= 24,    /* Serial # length */
86*4882a593Smuzhiyun 	EC_LEN		= 16,    /* E/C length */
87*4882a593Smuzhiyun 	ID_LEN		= 16,    /* ID length */
88*4882a593Smuzhiyun 	PN_LEN		= 16,    /* Part Number length */
89*4882a593Smuzhiyun 	MACADDR_LEN	= 12,    /* MAC Address length */
90*4882a593Smuzhiyun };
91*4882a593Smuzhiyun 
92*4882a593Smuzhiyun enum {
93*4882a593Smuzhiyun 	T4_REGMAP_SIZE = (160 * 1024),
94*4882a593Smuzhiyun 	T5_REGMAP_SIZE = (332 * 1024),
95*4882a593Smuzhiyun };
96*4882a593Smuzhiyun 
97*4882a593Smuzhiyun enum {
98*4882a593Smuzhiyun 	MEM_EDC0,
99*4882a593Smuzhiyun 	MEM_EDC1,
100*4882a593Smuzhiyun 	MEM_MC,
101*4882a593Smuzhiyun 	MEM_MC0 = MEM_MC,
102*4882a593Smuzhiyun 	MEM_MC1,
103*4882a593Smuzhiyun 	MEM_HMA,
104*4882a593Smuzhiyun };
105*4882a593Smuzhiyun 
106*4882a593Smuzhiyun enum {
107*4882a593Smuzhiyun 	MEMWIN0_APERTURE = 2048,
108*4882a593Smuzhiyun 	MEMWIN0_BASE     = 0x1b800,
109*4882a593Smuzhiyun 	MEMWIN1_APERTURE = 32768,
110*4882a593Smuzhiyun 	MEMWIN1_BASE     = 0x28000,
111*4882a593Smuzhiyun 	MEMWIN1_BASE_T5  = 0x52000,
112*4882a593Smuzhiyun 	MEMWIN2_APERTURE = 65536,
113*4882a593Smuzhiyun 	MEMWIN2_BASE     = 0x30000,
114*4882a593Smuzhiyun 	MEMWIN2_APERTURE_T5 = 131072,
115*4882a593Smuzhiyun 	MEMWIN2_BASE_T5  = 0x60000,
116*4882a593Smuzhiyun };
117*4882a593Smuzhiyun 
118*4882a593Smuzhiyun enum dev_master {
119*4882a593Smuzhiyun 	MASTER_CANT,
120*4882a593Smuzhiyun 	MASTER_MAY,
121*4882a593Smuzhiyun 	MASTER_MUST
122*4882a593Smuzhiyun };
123*4882a593Smuzhiyun 
124*4882a593Smuzhiyun enum dev_state {
125*4882a593Smuzhiyun 	DEV_STATE_UNINIT,
126*4882a593Smuzhiyun 	DEV_STATE_INIT,
127*4882a593Smuzhiyun 	DEV_STATE_ERR
128*4882a593Smuzhiyun };
129*4882a593Smuzhiyun 
130*4882a593Smuzhiyun enum cc_pause {
131*4882a593Smuzhiyun 	PAUSE_RX      = 1 << 0,
132*4882a593Smuzhiyun 	PAUSE_TX      = 1 << 1,
133*4882a593Smuzhiyun 	PAUSE_AUTONEG = 1 << 2
134*4882a593Smuzhiyun };
135*4882a593Smuzhiyun 
136*4882a593Smuzhiyun enum cc_fec {
137*4882a593Smuzhiyun 	FEC_AUTO      = 1 << 0,	 /* IEEE 802.3 "automatic" */
138*4882a593Smuzhiyun 	FEC_RS        = 1 << 1,  /* Reed-Solomon */
139*4882a593Smuzhiyun 	FEC_BASER_RS  = 1 << 2   /* BaseR/Reed-Solomon */
140*4882a593Smuzhiyun };
141*4882a593Smuzhiyun 
142*4882a593Smuzhiyun enum {
143*4882a593Smuzhiyun 	CXGB4_ETHTOOL_FLASH_FW = 1,
144*4882a593Smuzhiyun 	CXGB4_ETHTOOL_FLASH_PHY = 2,
145*4882a593Smuzhiyun 	CXGB4_ETHTOOL_FLASH_BOOT = 3,
146*4882a593Smuzhiyun 	CXGB4_ETHTOOL_FLASH_BOOTCFG = 4
147*4882a593Smuzhiyun };
148*4882a593Smuzhiyun 
149*4882a593Smuzhiyun enum cxgb4_netdev_tls_ops {
150*4882a593Smuzhiyun 	CXGB4_TLSDEV_OPS  = 1,
151*4882a593Smuzhiyun 	CXGB4_XFRMDEV_OPS
152*4882a593Smuzhiyun };
153*4882a593Smuzhiyun 
154*4882a593Smuzhiyun struct cxgb4_bootcfg_data {
155*4882a593Smuzhiyun 	__le16 signature;
156*4882a593Smuzhiyun 	__u8 reserved[2];
157*4882a593Smuzhiyun };
158*4882a593Smuzhiyun 
159*4882a593Smuzhiyun struct cxgb4_pcir_data {
160*4882a593Smuzhiyun 	__le32 signature;	/* Signature. The string "PCIR" */
161*4882a593Smuzhiyun 	__le16 vendor_id;	/* Vendor Identification */
162*4882a593Smuzhiyun 	__le16 device_id;	/* Device Identification */
163*4882a593Smuzhiyun 	__u8 vital_product[2];	/* Pointer to Vital Product Data */
164*4882a593Smuzhiyun 	__u8 length[2];		/* PCIR Data Structure Length */
165*4882a593Smuzhiyun 	__u8 revision;		/* PCIR Data Structure Revision */
166*4882a593Smuzhiyun 	__u8 class_code[3];	/* Class Code */
167*4882a593Smuzhiyun 	__u8 image_length[2];	/* Image Length. Multiple of 512B */
168*4882a593Smuzhiyun 	__u8 code_revision[2];	/* Revision Level of Code/Data */
169*4882a593Smuzhiyun 	__u8 code_type;
170*4882a593Smuzhiyun 	__u8 indicator;
171*4882a593Smuzhiyun 	__u8 reserved[2];
172*4882a593Smuzhiyun };
173*4882a593Smuzhiyun 
174*4882a593Smuzhiyun /* BIOS boot headers */
175*4882a593Smuzhiyun struct cxgb4_pci_exp_rom_header {
176*4882a593Smuzhiyun 	__le16 signature;	/* ROM Signature. Should be 0xaa55 */
177*4882a593Smuzhiyun 	__u8 reserved[22];	/* Reserved per processor Architecture data */
178*4882a593Smuzhiyun 	__le16 pcir_offset;	/* Offset to PCI Data Structure */
179*4882a593Smuzhiyun };
180*4882a593Smuzhiyun 
181*4882a593Smuzhiyun /* Legacy PCI Expansion ROM Header */
182*4882a593Smuzhiyun struct legacy_pci_rom_hdr {
183*4882a593Smuzhiyun 	__u8 signature[2];	/* ROM Signature. Should be 0xaa55 */
184*4882a593Smuzhiyun 	__u8 size512;		/* Current Image Size in units of 512 bytes */
185*4882a593Smuzhiyun 	__u8 initentry_point[4];
186*4882a593Smuzhiyun 	__u8 cksum;		/* Checksum computed on the entire Image */
187*4882a593Smuzhiyun 	__u8 reserved[16];	/* Reserved */
188*4882a593Smuzhiyun 	__le16 pcir_offset;	/* Offset to PCI Data Struture */
189*4882a593Smuzhiyun };
190*4882a593Smuzhiyun 
191*4882a593Smuzhiyun #define CXGB4_HDR_CODE1 0x00
192*4882a593Smuzhiyun #define CXGB4_HDR_CODE2 0x03
193*4882a593Smuzhiyun #define CXGB4_HDR_INDI 0x80
194*4882a593Smuzhiyun 
195*4882a593Smuzhiyun /* BOOT constants */
196*4882a593Smuzhiyun enum {
197*4882a593Smuzhiyun 	BOOT_CFG_SIG = 0x4243,
198*4882a593Smuzhiyun 	BOOT_SIZE_INC = 512,
199*4882a593Smuzhiyun 	BOOT_SIGNATURE = 0xaa55,
200*4882a593Smuzhiyun 	BOOT_MIN_SIZE = sizeof(struct cxgb4_pci_exp_rom_header),
201*4882a593Smuzhiyun 	BOOT_MAX_SIZE = 1024 * BOOT_SIZE_INC,
202*4882a593Smuzhiyun 	PCIR_SIGNATURE = 0x52494350
203*4882a593Smuzhiyun };
204*4882a593Smuzhiyun 
205*4882a593Smuzhiyun struct port_stats {
206*4882a593Smuzhiyun 	u64 tx_octets;            /* total # of octets in good frames */
207*4882a593Smuzhiyun 	u64 tx_frames;            /* all good frames */
208*4882a593Smuzhiyun 	u64 tx_bcast_frames;      /* all broadcast frames */
209*4882a593Smuzhiyun 	u64 tx_mcast_frames;      /* all multicast frames */
210*4882a593Smuzhiyun 	u64 tx_ucast_frames;      /* all unicast frames */
211*4882a593Smuzhiyun 	u64 tx_error_frames;      /* all error frames */
212*4882a593Smuzhiyun 
213*4882a593Smuzhiyun 	u64 tx_frames_64;         /* # of Tx frames in a particular range */
214*4882a593Smuzhiyun 	u64 tx_frames_65_127;
215*4882a593Smuzhiyun 	u64 tx_frames_128_255;
216*4882a593Smuzhiyun 	u64 tx_frames_256_511;
217*4882a593Smuzhiyun 	u64 tx_frames_512_1023;
218*4882a593Smuzhiyun 	u64 tx_frames_1024_1518;
219*4882a593Smuzhiyun 	u64 tx_frames_1519_max;
220*4882a593Smuzhiyun 
221*4882a593Smuzhiyun 	u64 tx_drop;              /* # of dropped Tx frames */
222*4882a593Smuzhiyun 	u64 tx_pause;             /* # of transmitted pause frames */
223*4882a593Smuzhiyun 	u64 tx_ppp0;              /* # of transmitted PPP prio 0 frames */
224*4882a593Smuzhiyun 	u64 tx_ppp1;              /* # of transmitted PPP prio 1 frames */
225*4882a593Smuzhiyun 	u64 tx_ppp2;              /* # of transmitted PPP prio 2 frames */
226*4882a593Smuzhiyun 	u64 tx_ppp3;              /* # of transmitted PPP prio 3 frames */
227*4882a593Smuzhiyun 	u64 tx_ppp4;              /* # of transmitted PPP prio 4 frames */
228*4882a593Smuzhiyun 	u64 tx_ppp5;              /* # of transmitted PPP prio 5 frames */
229*4882a593Smuzhiyun 	u64 tx_ppp6;              /* # of transmitted PPP prio 6 frames */
230*4882a593Smuzhiyun 	u64 tx_ppp7;              /* # of transmitted PPP prio 7 frames */
231*4882a593Smuzhiyun 
232*4882a593Smuzhiyun 	u64 rx_octets;            /* total # of octets in good frames */
233*4882a593Smuzhiyun 	u64 rx_frames;            /* all good frames */
234*4882a593Smuzhiyun 	u64 rx_bcast_frames;      /* all broadcast frames */
235*4882a593Smuzhiyun 	u64 rx_mcast_frames;      /* all multicast frames */
236*4882a593Smuzhiyun 	u64 rx_ucast_frames;      /* all unicast frames */
237*4882a593Smuzhiyun 	u64 rx_too_long;          /* # of frames exceeding MTU */
238*4882a593Smuzhiyun 	u64 rx_jabber;            /* # of jabber frames */
239*4882a593Smuzhiyun 	u64 rx_fcs_err;           /* # of received frames with bad FCS */
240*4882a593Smuzhiyun 	u64 rx_len_err;           /* # of received frames with length error */
241*4882a593Smuzhiyun 	u64 rx_symbol_err;        /* symbol errors */
242*4882a593Smuzhiyun 	u64 rx_runt;              /* # of short frames */
243*4882a593Smuzhiyun 
244*4882a593Smuzhiyun 	u64 rx_frames_64;         /* # of Rx frames in a particular range */
245*4882a593Smuzhiyun 	u64 rx_frames_65_127;
246*4882a593Smuzhiyun 	u64 rx_frames_128_255;
247*4882a593Smuzhiyun 	u64 rx_frames_256_511;
248*4882a593Smuzhiyun 	u64 rx_frames_512_1023;
249*4882a593Smuzhiyun 	u64 rx_frames_1024_1518;
250*4882a593Smuzhiyun 	u64 rx_frames_1519_max;
251*4882a593Smuzhiyun 
252*4882a593Smuzhiyun 	u64 rx_pause;             /* # of received pause frames */
253*4882a593Smuzhiyun 	u64 rx_ppp0;              /* # of received PPP prio 0 frames */
254*4882a593Smuzhiyun 	u64 rx_ppp1;              /* # of received PPP prio 1 frames */
255*4882a593Smuzhiyun 	u64 rx_ppp2;              /* # of received PPP prio 2 frames */
256*4882a593Smuzhiyun 	u64 rx_ppp3;              /* # of received PPP prio 3 frames */
257*4882a593Smuzhiyun 	u64 rx_ppp4;              /* # of received PPP prio 4 frames */
258*4882a593Smuzhiyun 	u64 rx_ppp5;              /* # of received PPP prio 5 frames */
259*4882a593Smuzhiyun 	u64 rx_ppp6;              /* # of received PPP prio 6 frames */
260*4882a593Smuzhiyun 	u64 rx_ppp7;              /* # of received PPP prio 7 frames */
261*4882a593Smuzhiyun 
262*4882a593Smuzhiyun 	u64 rx_ovflow0;           /* drops due to buffer-group 0 overflows */
263*4882a593Smuzhiyun 	u64 rx_ovflow1;           /* drops due to buffer-group 1 overflows */
264*4882a593Smuzhiyun 	u64 rx_ovflow2;           /* drops due to buffer-group 2 overflows */
265*4882a593Smuzhiyun 	u64 rx_ovflow3;           /* drops due to buffer-group 3 overflows */
266*4882a593Smuzhiyun 	u64 rx_trunc0;            /* buffer-group 0 truncated packets */
267*4882a593Smuzhiyun 	u64 rx_trunc1;            /* buffer-group 1 truncated packets */
268*4882a593Smuzhiyun 	u64 rx_trunc2;            /* buffer-group 2 truncated packets */
269*4882a593Smuzhiyun 	u64 rx_trunc3;            /* buffer-group 3 truncated packets */
270*4882a593Smuzhiyun };
271*4882a593Smuzhiyun 
272*4882a593Smuzhiyun struct lb_port_stats {
273*4882a593Smuzhiyun 	u64 octets;
274*4882a593Smuzhiyun 	u64 frames;
275*4882a593Smuzhiyun 	u64 bcast_frames;
276*4882a593Smuzhiyun 	u64 mcast_frames;
277*4882a593Smuzhiyun 	u64 ucast_frames;
278*4882a593Smuzhiyun 	u64 error_frames;
279*4882a593Smuzhiyun 
280*4882a593Smuzhiyun 	u64 frames_64;
281*4882a593Smuzhiyun 	u64 frames_65_127;
282*4882a593Smuzhiyun 	u64 frames_128_255;
283*4882a593Smuzhiyun 	u64 frames_256_511;
284*4882a593Smuzhiyun 	u64 frames_512_1023;
285*4882a593Smuzhiyun 	u64 frames_1024_1518;
286*4882a593Smuzhiyun 	u64 frames_1519_max;
287*4882a593Smuzhiyun 
288*4882a593Smuzhiyun 	u64 drop;
289*4882a593Smuzhiyun 
290*4882a593Smuzhiyun 	u64 ovflow0;
291*4882a593Smuzhiyun 	u64 ovflow1;
292*4882a593Smuzhiyun 	u64 ovflow2;
293*4882a593Smuzhiyun 	u64 ovflow3;
294*4882a593Smuzhiyun 	u64 trunc0;
295*4882a593Smuzhiyun 	u64 trunc1;
296*4882a593Smuzhiyun 	u64 trunc2;
297*4882a593Smuzhiyun 	u64 trunc3;
298*4882a593Smuzhiyun };
299*4882a593Smuzhiyun 
300*4882a593Smuzhiyun struct tp_tcp_stats {
301*4882a593Smuzhiyun 	u32 tcp_out_rsts;
302*4882a593Smuzhiyun 	u64 tcp_in_segs;
303*4882a593Smuzhiyun 	u64 tcp_out_segs;
304*4882a593Smuzhiyun 	u64 tcp_retrans_segs;
305*4882a593Smuzhiyun };
306*4882a593Smuzhiyun 
307*4882a593Smuzhiyun struct tp_usm_stats {
308*4882a593Smuzhiyun 	u32 frames;
309*4882a593Smuzhiyun 	u32 drops;
310*4882a593Smuzhiyun 	u64 octets;
311*4882a593Smuzhiyun };
312*4882a593Smuzhiyun 
313*4882a593Smuzhiyun struct tp_fcoe_stats {
314*4882a593Smuzhiyun 	u32 frames_ddp;
315*4882a593Smuzhiyun 	u32 frames_drop;
316*4882a593Smuzhiyun 	u64 octets_ddp;
317*4882a593Smuzhiyun };
318*4882a593Smuzhiyun 
319*4882a593Smuzhiyun struct tp_err_stats {
320*4882a593Smuzhiyun 	u32 mac_in_errs[4];
321*4882a593Smuzhiyun 	u32 hdr_in_errs[4];
322*4882a593Smuzhiyun 	u32 tcp_in_errs[4];
323*4882a593Smuzhiyun 	u32 tnl_cong_drops[4];
324*4882a593Smuzhiyun 	u32 ofld_chan_drops[4];
325*4882a593Smuzhiyun 	u32 tnl_tx_drops[4];
326*4882a593Smuzhiyun 	u32 ofld_vlan_drops[4];
327*4882a593Smuzhiyun 	u32 tcp6_in_errs[4];
328*4882a593Smuzhiyun 	u32 ofld_no_neigh;
329*4882a593Smuzhiyun 	u32 ofld_cong_defer;
330*4882a593Smuzhiyun };
331*4882a593Smuzhiyun 
332*4882a593Smuzhiyun struct tp_cpl_stats {
333*4882a593Smuzhiyun 	u32 req[4];
334*4882a593Smuzhiyun 	u32 rsp[4];
335*4882a593Smuzhiyun };
336*4882a593Smuzhiyun 
337*4882a593Smuzhiyun struct tp_rdma_stats {
338*4882a593Smuzhiyun 	u32 rqe_dfr_pkt;
339*4882a593Smuzhiyun 	u32 rqe_dfr_mod;
340*4882a593Smuzhiyun };
341*4882a593Smuzhiyun 
342*4882a593Smuzhiyun struct sge_params {
343*4882a593Smuzhiyun 	u32 hps;			/* host page size for our PF/VF */
344*4882a593Smuzhiyun 	u32 eq_qpp;			/* egress queues/page for our PF/VF */
345*4882a593Smuzhiyun 	u32 iq_qpp;			/* egress queues/page for our PF/VF */
346*4882a593Smuzhiyun };
347*4882a593Smuzhiyun 
348*4882a593Smuzhiyun struct tp_params {
349*4882a593Smuzhiyun 	unsigned int tre;            /* log2 of core clocks per TP tick */
350*4882a593Smuzhiyun 	unsigned int la_mask;        /* what events are recorded by TP LA */
351*4882a593Smuzhiyun 	unsigned short tx_modq_map;  /* TX modulation scheduler queue to */
352*4882a593Smuzhiyun 				     /* channel map */
353*4882a593Smuzhiyun 
354*4882a593Smuzhiyun 	uint32_t dack_re;            /* DACK timer resolution */
355*4882a593Smuzhiyun 	unsigned short tx_modq[NCHAN];	/* channel to modulation queue map */
356*4882a593Smuzhiyun 
357*4882a593Smuzhiyun 	u32 vlan_pri_map;               /* cached TP_VLAN_PRI_MAP */
358*4882a593Smuzhiyun 	u32 filter_mask;
359*4882a593Smuzhiyun 	u32 ingress_config;             /* cached TP_INGRESS_CONFIG */
360*4882a593Smuzhiyun 
361*4882a593Smuzhiyun 	/* cached TP_OUT_CONFIG compressed error vector
362*4882a593Smuzhiyun 	 * and passing outer header info for encapsulated packets.
363*4882a593Smuzhiyun 	 */
364*4882a593Smuzhiyun 	int rx_pkt_encap;
365*4882a593Smuzhiyun 
366*4882a593Smuzhiyun 	/* TP_VLAN_PRI_MAP Compressed Filter Tuple field offsets.  This is a
367*4882a593Smuzhiyun 	 * subset of the set of fields which may be present in the Compressed
368*4882a593Smuzhiyun 	 * Filter Tuple portion of filters and TCP TCB connections.  The
369*4882a593Smuzhiyun 	 * fields which are present are controlled by the TP_VLAN_PRI_MAP.
370*4882a593Smuzhiyun 	 * Since a variable number of fields may or may not be present, their
371*4882a593Smuzhiyun 	 * shifted field positions within the Compressed Filter Tuple may
372*4882a593Smuzhiyun 	 * vary, or not even be present if the field isn't selected in
373*4882a593Smuzhiyun 	 * TP_VLAN_PRI_MAP.  Since some of these fields are needed in various
374*4882a593Smuzhiyun 	 * places we store their offsets here, or a -1 if the field isn't
375*4882a593Smuzhiyun 	 * present.
376*4882a593Smuzhiyun 	 */
377*4882a593Smuzhiyun 	int fcoe_shift;
378*4882a593Smuzhiyun 	int port_shift;
379*4882a593Smuzhiyun 	int vnic_shift;
380*4882a593Smuzhiyun 	int vlan_shift;
381*4882a593Smuzhiyun 	int tos_shift;
382*4882a593Smuzhiyun 	int protocol_shift;
383*4882a593Smuzhiyun 	int ethertype_shift;
384*4882a593Smuzhiyun 	int macmatch_shift;
385*4882a593Smuzhiyun 	int matchtype_shift;
386*4882a593Smuzhiyun 	int frag_shift;
387*4882a593Smuzhiyun 
388*4882a593Smuzhiyun 	u64 hash_filter_mask;
389*4882a593Smuzhiyun };
390*4882a593Smuzhiyun 
391*4882a593Smuzhiyun struct vpd_params {
392*4882a593Smuzhiyun 	unsigned int cclk;
393*4882a593Smuzhiyun 	u8 ec[EC_LEN + 1];
394*4882a593Smuzhiyun 	u8 sn[SERNUM_LEN + 1];
395*4882a593Smuzhiyun 	u8 id[ID_LEN + 1];
396*4882a593Smuzhiyun 	u8 pn[PN_LEN + 1];
397*4882a593Smuzhiyun 	u8 na[MACADDR_LEN + 1];
398*4882a593Smuzhiyun };
399*4882a593Smuzhiyun 
400*4882a593Smuzhiyun /* Maximum resources provisioned for a PCI PF.
401*4882a593Smuzhiyun  */
402*4882a593Smuzhiyun struct pf_resources {
403*4882a593Smuzhiyun 	unsigned int nvi;		/* N virtual interfaces */
404*4882a593Smuzhiyun 	unsigned int neq;		/* N egress Qs */
405*4882a593Smuzhiyun 	unsigned int nethctrl;		/* N egress ETH or CTRL Qs */
406*4882a593Smuzhiyun 	unsigned int niqflint;		/* N ingress Qs/w free list(s) & intr */
407*4882a593Smuzhiyun 	unsigned int niq;		/* N ingress Qs */
408*4882a593Smuzhiyun 	unsigned int tc;		/* PCI-E traffic class */
409*4882a593Smuzhiyun 	unsigned int pmask;		/* port access rights mask */
410*4882a593Smuzhiyun 	unsigned int nexactf;		/* N exact MPS filters */
411*4882a593Smuzhiyun 	unsigned int r_caps;		/* read capabilities */
412*4882a593Smuzhiyun 	unsigned int wx_caps;		/* write/execute capabilities */
413*4882a593Smuzhiyun };
414*4882a593Smuzhiyun 
415*4882a593Smuzhiyun struct pci_params {
416*4882a593Smuzhiyun 	unsigned int vpd_cap_addr;
417*4882a593Smuzhiyun 	unsigned char speed;
418*4882a593Smuzhiyun 	unsigned char width;
419*4882a593Smuzhiyun };
420*4882a593Smuzhiyun 
421*4882a593Smuzhiyun struct devlog_params {
422*4882a593Smuzhiyun 	u32 memtype;                    /* which memory (EDC0, EDC1, MC) */
423*4882a593Smuzhiyun 	u32 start;                      /* start of log in firmware memory */
424*4882a593Smuzhiyun 	u32 size;                       /* size of log */
425*4882a593Smuzhiyun };
426*4882a593Smuzhiyun 
427*4882a593Smuzhiyun /* Stores chip specific parameters */
428*4882a593Smuzhiyun struct arch_specific_params {
429*4882a593Smuzhiyun 	u8 nchan;
430*4882a593Smuzhiyun 	u8 pm_stats_cnt;
431*4882a593Smuzhiyun 	u8 cng_ch_bits_log;		/* congestion channel map bits width */
432*4882a593Smuzhiyun 	u16 mps_rplc_size;
433*4882a593Smuzhiyun 	u16 vfcount;
434*4882a593Smuzhiyun 	u32 sge_fl_db;
435*4882a593Smuzhiyun 	u16 mps_tcam_size;
436*4882a593Smuzhiyun };
437*4882a593Smuzhiyun 
438*4882a593Smuzhiyun struct adapter_params {
439*4882a593Smuzhiyun 	struct sge_params sge;
440*4882a593Smuzhiyun 	struct tp_params  tp;
441*4882a593Smuzhiyun 	struct vpd_params vpd;
442*4882a593Smuzhiyun 	struct pf_resources pfres;
443*4882a593Smuzhiyun 	struct pci_params pci;
444*4882a593Smuzhiyun 	struct devlog_params devlog;
445*4882a593Smuzhiyun 	enum pcie_memwin drv_memwin;
446*4882a593Smuzhiyun 
447*4882a593Smuzhiyun 	unsigned int cim_la_size;
448*4882a593Smuzhiyun 
449*4882a593Smuzhiyun 	unsigned int sf_size;             /* serial flash size in bytes */
450*4882a593Smuzhiyun 	unsigned int sf_nsec;             /* # of flash sectors */
451*4882a593Smuzhiyun 
452*4882a593Smuzhiyun 	unsigned int fw_vers;		  /* firmware version */
453*4882a593Smuzhiyun 	unsigned int bs_vers;		  /* bootstrap version */
454*4882a593Smuzhiyun 	unsigned int tp_vers;		  /* TP microcode version */
455*4882a593Smuzhiyun 	unsigned int er_vers;		  /* expansion ROM version */
456*4882a593Smuzhiyun 	unsigned int scfg_vers;		  /* Serial Configuration version */
457*4882a593Smuzhiyun 	unsigned int vpd_vers;		  /* VPD Version */
458*4882a593Smuzhiyun 	u8 api_vers[7];
459*4882a593Smuzhiyun 
460*4882a593Smuzhiyun 	unsigned short mtus[NMTUS];
461*4882a593Smuzhiyun 	unsigned short a_wnd[NCCTRL_WIN];
462*4882a593Smuzhiyun 	unsigned short b_wnd[NCCTRL_WIN];
463*4882a593Smuzhiyun 
464*4882a593Smuzhiyun 	unsigned char nports;             /* # of ethernet ports */
465*4882a593Smuzhiyun 	unsigned char portvec;
466*4882a593Smuzhiyun 	enum chip_type chip;               /* chip code */
467*4882a593Smuzhiyun 	struct arch_specific_params arch;  /* chip specific params */
468*4882a593Smuzhiyun 	unsigned char offload;
469*4882a593Smuzhiyun 	unsigned char crypto;		/* HW capability for crypto */
470*4882a593Smuzhiyun 	unsigned char ethofld;		/* QoS support */
471*4882a593Smuzhiyun 
472*4882a593Smuzhiyun 	unsigned char bypass;
473*4882a593Smuzhiyun 	unsigned char hash_filter;
474*4882a593Smuzhiyun 
475*4882a593Smuzhiyun 	unsigned int ofldq_wr_cred;
476*4882a593Smuzhiyun 	bool ulptx_memwrite_dsgl;          /* use of T5 DSGL allowed */
477*4882a593Smuzhiyun 
478*4882a593Smuzhiyun 	unsigned int nsched_cls;          /* number of traffic classes */
479*4882a593Smuzhiyun 	unsigned int max_ordird_qp;       /* Max read depth per RDMA QP */
480*4882a593Smuzhiyun 	unsigned int max_ird_adapter;     /* Max read depth per adapter */
481*4882a593Smuzhiyun 	bool fr_nsmr_tpte_wr_support;	  /* FW support for FR_NSMR_TPTE_WR */
482*4882a593Smuzhiyun 	u8 fw_caps_support;		/* 32-bit Port Capabilities */
483*4882a593Smuzhiyun 	bool filter2_wr_support;	/* FW support for FILTER2_WR */
484*4882a593Smuzhiyun 	unsigned int viid_smt_extn_support:1; /* FW returns vin and smt index */
485*4882a593Smuzhiyun 
486*4882a593Smuzhiyun 	/* MPS Buffer Group Map[per Port].  Bit i is set if buffer group i is
487*4882a593Smuzhiyun 	 * used by the Port
488*4882a593Smuzhiyun 	 */
489*4882a593Smuzhiyun 	u8 mps_bg_map[MAX_NPORTS];	/* MPS Buffer Group Map */
490*4882a593Smuzhiyun 	bool write_w_imm_support;       /* FW supports WRITE_WITH_IMMEDIATE */
491*4882a593Smuzhiyun 	bool write_cmpl_support;        /* FW supports WRITE_CMPL */
492*4882a593Smuzhiyun };
493*4882a593Smuzhiyun 
494*4882a593Smuzhiyun /* State needed to monitor the forward progress of SGE Ingress DMA activities
495*4882a593Smuzhiyun  * and possible hangs.
496*4882a593Smuzhiyun  */
497*4882a593Smuzhiyun struct sge_idma_monitor_state {
498*4882a593Smuzhiyun 	unsigned int idma_1s_thresh;	/* 1s threshold in Core Clock ticks */
499*4882a593Smuzhiyun 	unsigned int idma_stalled[2];	/* synthesized stalled timers in HZ */
500*4882a593Smuzhiyun 	unsigned int idma_state[2];	/* IDMA Hang detect state */
501*4882a593Smuzhiyun 	unsigned int idma_qid[2];	/* IDMA Hung Ingress Queue ID */
502*4882a593Smuzhiyun 	unsigned int idma_warn[2];	/* time to warning in HZ */
503*4882a593Smuzhiyun };
504*4882a593Smuzhiyun 
505*4882a593Smuzhiyun /* Firmware Mailbox Command/Reply log.  All values are in Host-Endian format.
506*4882a593Smuzhiyun  * The access and execute times are signed in order to accommodate negative
507*4882a593Smuzhiyun  * error returns.
508*4882a593Smuzhiyun  */
509*4882a593Smuzhiyun struct mbox_cmd {
510*4882a593Smuzhiyun 	u64 cmd[MBOX_LEN / 8];		/* a Firmware Mailbox Command/Reply */
511*4882a593Smuzhiyun 	u64 timestamp;			/* OS-dependent timestamp */
512*4882a593Smuzhiyun 	u32 seqno;			/* sequence number */
513*4882a593Smuzhiyun 	s16 access;			/* time (ms) to access mailbox */
514*4882a593Smuzhiyun 	s16 execute;			/* time (ms) to execute */
515*4882a593Smuzhiyun };
516*4882a593Smuzhiyun 
517*4882a593Smuzhiyun struct mbox_cmd_log {
518*4882a593Smuzhiyun 	unsigned int size;		/* number of entries in the log */
519*4882a593Smuzhiyun 	unsigned int cursor;		/* next position in the log to write */
520*4882a593Smuzhiyun 	u32 seqno;			/* next sequence number */
521*4882a593Smuzhiyun 	/* variable length mailbox command log starts here */
522*4882a593Smuzhiyun };
523*4882a593Smuzhiyun 
524*4882a593Smuzhiyun /* Given a pointer to a Firmware Mailbox Command Log and a log entry index,
525*4882a593Smuzhiyun  * return a pointer to the specified entry.
526*4882a593Smuzhiyun  */
mbox_cmd_log_entry(struct mbox_cmd_log * log,unsigned int entry_idx)527*4882a593Smuzhiyun static inline struct mbox_cmd *mbox_cmd_log_entry(struct mbox_cmd_log *log,
528*4882a593Smuzhiyun 						  unsigned int entry_idx)
529*4882a593Smuzhiyun {
530*4882a593Smuzhiyun 	return &((struct mbox_cmd *)&(log)[1])[entry_idx];
531*4882a593Smuzhiyun }
532*4882a593Smuzhiyun 
533*4882a593Smuzhiyun #define FW_VERSION(chip) ( \
534*4882a593Smuzhiyun 		FW_HDR_FW_VER_MAJOR_G(chip##FW_VERSION_MAJOR) | \
535*4882a593Smuzhiyun 		FW_HDR_FW_VER_MINOR_G(chip##FW_VERSION_MINOR) | \
536*4882a593Smuzhiyun 		FW_HDR_FW_VER_MICRO_G(chip##FW_VERSION_MICRO) | \
537*4882a593Smuzhiyun 		FW_HDR_FW_VER_BUILD_G(chip##FW_VERSION_BUILD))
538*4882a593Smuzhiyun #define FW_INTFVER(chip, intf) (FW_HDR_INTFVER_##intf)
539*4882a593Smuzhiyun 
540*4882a593Smuzhiyun struct cxgb4_ethtool_lb_test {
541*4882a593Smuzhiyun 	struct completion completion;
542*4882a593Smuzhiyun 	int result;
543*4882a593Smuzhiyun 	int loopback;
544*4882a593Smuzhiyun };
545*4882a593Smuzhiyun 
546*4882a593Smuzhiyun struct fw_info {
547*4882a593Smuzhiyun 	u8 chip;
548*4882a593Smuzhiyun 	char *fs_name;
549*4882a593Smuzhiyun 	char *fw_mod_name;
550*4882a593Smuzhiyun 	struct fw_hdr fw_hdr;
551*4882a593Smuzhiyun };
552*4882a593Smuzhiyun 
553*4882a593Smuzhiyun struct trace_params {
554*4882a593Smuzhiyun 	u32 data[TRACE_LEN / 4];
555*4882a593Smuzhiyun 	u32 mask[TRACE_LEN / 4];
556*4882a593Smuzhiyun 	unsigned short snap_len;
557*4882a593Smuzhiyun 	unsigned short min_len;
558*4882a593Smuzhiyun 	unsigned char skip_ofst;
559*4882a593Smuzhiyun 	unsigned char skip_len;
560*4882a593Smuzhiyun 	unsigned char invert;
561*4882a593Smuzhiyun 	unsigned char port;
562*4882a593Smuzhiyun };
563*4882a593Smuzhiyun 
564*4882a593Smuzhiyun struct cxgb4_fw_data {
565*4882a593Smuzhiyun 	__be32 signature;
566*4882a593Smuzhiyun 	__u8 reserved[4];
567*4882a593Smuzhiyun };
568*4882a593Smuzhiyun 
569*4882a593Smuzhiyun /* Firmware Port Capabilities types. */
570*4882a593Smuzhiyun 
571*4882a593Smuzhiyun typedef u16 fw_port_cap16_t;	/* 16-bit Port Capabilities integral value */
572*4882a593Smuzhiyun typedef u32 fw_port_cap32_t;	/* 32-bit Port Capabilities integral value */
573*4882a593Smuzhiyun 
574*4882a593Smuzhiyun enum fw_caps {
575*4882a593Smuzhiyun 	FW_CAPS_UNKNOWN	= 0,	/* 0'ed out initial state */
576*4882a593Smuzhiyun 	FW_CAPS16	= 1,	/* old Firmware: 16-bit Port Capabilities */
577*4882a593Smuzhiyun 	FW_CAPS32	= 2,	/* new Firmware: 32-bit Port Capabilities */
578*4882a593Smuzhiyun };
579*4882a593Smuzhiyun 
580*4882a593Smuzhiyun struct link_config {
581*4882a593Smuzhiyun 	fw_port_cap32_t pcaps;           /* link capabilities */
582*4882a593Smuzhiyun 	fw_port_cap32_t def_acaps;       /* default advertised capabilities */
583*4882a593Smuzhiyun 	fw_port_cap32_t acaps;           /* advertised capabilities */
584*4882a593Smuzhiyun 	fw_port_cap32_t lpacaps;         /* peer advertised capabilities */
585*4882a593Smuzhiyun 
586*4882a593Smuzhiyun 	fw_port_cap32_t speed_caps;      /* speed(s) user has requested */
587*4882a593Smuzhiyun 	unsigned int   speed;            /* actual link speed (Mb/s) */
588*4882a593Smuzhiyun 
589*4882a593Smuzhiyun 	enum cc_pause  requested_fc;     /* flow control user has requested */
590*4882a593Smuzhiyun 	enum cc_pause  fc;               /* actual link flow control */
591*4882a593Smuzhiyun 	enum cc_pause  advertised_fc;    /* actual advertised flow control */
592*4882a593Smuzhiyun 
593*4882a593Smuzhiyun 	enum cc_fec    requested_fec;	 /* Forward Error Correction: */
594*4882a593Smuzhiyun 	enum cc_fec    fec;		 /* requested and actual in use */
595*4882a593Smuzhiyun 
596*4882a593Smuzhiyun 	unsigned char  autoneg;          /* autonegotiating? */
597*4882a593Smuzhiyun 
598*4882a593Smuzhiyun 	unsigned char  link_ok;          /* link up? */
599*4882a593Smuzhiyun 	unsigned char  link_down_rc;     /* link down reason */
600*4882a593Smuzhiyun 
601*4882a593Smuzhiyun 	bool new_module;		 /* ->OS Transceiver Module inserted */
602*4882a593Smuzhiyun 	bool redo_l1cfg;		 /* ->CC redo current "sticky" L1 CFG */
603*4882a593Smuzhiyun };
604*4882a593Smuzhiyun 
605*4882a593Smuzhiyun #define FW_LEN16(fw_struct) FW_CMD_LEN16_V(sizeof(fw_struct) / 16)
606*4882a593Smuzhiyun 
607*4882a593Smuzhiyun enum {
608*4882a593Smuzhiyun 	MAX_ETH_QSETS = 32,           /* # of Ethernet Tx/Rx queue sets */
609*4882a593Smuzhiyun 	MAX_OFLD_QSETS = 16,          /* # of offload Tx, iscsi Rx queue sets */
610*4882a593Smuzhiyun 	MAX_CTRL_QUEUES = NCHAN,      /* # of control Tx queues */
611*4882a593Smuzhiyun };
612*4882a593Smuzhiyun 
613*4882a593Smuzhiyun enum {
614*4882a593Smuzhiyun 	MAX_TXQ_ENTRIES      = 16384,
615*4882a593Smuzhiyun 	MAX_CTRL_TXQ_ENTRIES = 1024,
616*4882a593Smuzhiyun 	MAX_RSPQ_ENTRIES     = 16384,
617*4882a593Smuzhiyun 	MAX_RX_BUFFERS       = 16384,
618*4882a593Smuzhiyun 	MIN_TXQ_ENTRIES      = 32,
619*4882a593Smuzhiyun 	MIN_CTRL_TXQ_ENTRIES = 32,
620*4882a593Smuzhiyun 	MIN_RSPQ_ENTRIES     = 128,
621*4882a593Smuzhiyun 	MIN_FL_ENTRIES       = 16
622*4882a593Smuzhiyun };
623*4882a593Smuzhiyun 
624*4882a593Smuzhiyun enum {
625*4882a593Smuzhiyun 	MAX_TXQ_DESC_SIZE      = 64,
626*4882a593Smuzhiyun 	MAX_RXQ_DESC_SIZE      = 128,
627*4882a593Smuzhiyun 	MAX_FL_DESC_SIZE       = 8,
628*4882a593Smuzhiyun 	MAX_CTRL_TXQ_DESC_SIZE = 64,
629*4882a593Smuzhiyun };
630*4882a593Smuzhiyun 
631*4882a593Smuzhiyun enum {
632*4882a593Smuzhiyun 	INGQ_EXTRAS = 2,        /* firmware event queue and */
633*4882a593Smuzhiyun 				/*   forwarded interrupts */
634*4882a593Smuzhiyun 	MAX_INGQ = MAX_ETH_QSETS + INGQ_EXTRAS,
635*4882a593Smuzhiyun };
636*4882a593Smuzhiyun 
637*4882a593Smuzhiyun enum {
638*4882a593Smuzhiyun 	PRIV_FLAG_PORT_TX_VM_BIT,
639*4882a593Smuzhiyun };
640*4882a593Smuzhiyun 
641*4882a593Smuzhiyun #define PRIV_FLAG_PORT_TX_VM		BIT(PRIV_FLAG_PORT_TX_VM_BIT)
642*4882a593Smuzhiyun 
643*4882a593Smuzhiyun #define PRIV_FLAGS_ADAP			0
644*4882a593Smuzhiyun #define PRIV_FLAGS_PORT			PRIV_FLAG_PORT_TX_VM
645*4882a593Smuzhiyun 
646*4882a593Smuzhiyun struct adapter;
647*4882a593Smuzhiyun struct sge_rspq;
648*4882a593Smuzhiyun 
649*4882a593Smuzhiyun #include "cxgb4_dcb.h"
650*4882a593Smuzhiyun 
651*4882a593Smuzhiyun #ifdef CONFIG_CHELSIO_T4_FCOE
652*4882a593Smuzhiyun #include "cxgb4_fcoe.h"
653*4882a593Smuzhiyun #endif /* CONFIG_CHELSIO_T4_FCOE */
654*4882a593Smuzhiyun 
655*4882a593Smuzhiyun struct port_info {
656*4882a593Smuzhiyun 	struct adapter *adapter;
657*4882a593Smuzhiyun 	u16    viid;
658*4882a593Smuzhiyun 	int    xact_addr_filt;        /* index of exact MAC address filter */
659*4882a593Smuzhiyun 	u16    rss_size;              /* size of VI's RSS table slice */
660*4882a593Smuzhiyun 	s8     mdio_addr;
661*4882a593Smuzhiyun 	enum fw_port_type port_type;
662*4882a593Smuzhiyun 	u8     mod_type;
663*4882a593Smuzhiyun 	u8     port_id;
664*4882a593Smuzhiyun 	u8     tx_chan;
665*4882a593Smuzhiyun 	u8     lport;                 /* associated offload logical port */
666*4882a593Smuzhiyun 	u8     nqsets;                /* # of qsets */
667*4882a593Smuzhiyun 	u8     first_qset;            /* index of first qset */
668*4882a593Smuzhiyun 	u8     rss_mode;
669*4882a593Smuzhiyun 	struct link_config link_cfg;
670*4882a593Smuzhiyun 	u16   *rss;
671*4882a593Smuzhiyun 	struct port_stats stats_base;
672*4882a593Smuzhiyun #ifdef CONFIG_CHELSIO_T4_DCB
673*4882a593Smuzhiyun 	struct port_dcb_info dcb;     /* Data Center Bridging support */
674*4882a593Smuzhiyun #endif
675*4882a593Smuzhiyun #ifdef CONFIG_CHELSIO_T4_FCOE
676*4882a593Smuzhiyun 	struct cxgb_fcoe fcoe;
677*4882a593Smuzhiyun #endif /* CONFIG_CHELSIO_T4_FCOE */
678*4882a593Smuzhiyun 	bool rxtstamp;  /* Enable TS */
679*4882a593Smuzhiyun 	struct hwtstamp_config tstamp_config;
680*4882a593Smuzhiyun 	bool ptp_enable;
681*4882a593Smuzhiyun 	struct sched_table *sched_tbl;
682*4882a593Smuzhiyun 	u32 eth_flags;
683*4882a593Smuzhiyun 
684*4882a593Smuzhiyun 	/* viid and smt fields either returned by fw
685*4882a593Smuzhiyun 	 * or decoded by parsing viid by driver.
686*4882a593Smuzhiyun 	 */
687*4882a593Smuzhiyun 	u8 vin;
688*4882a593Smuzhiyun 	u8 vivld;
689*4882a593Smuzhiyun 	u8 smt_idx;
690*4882a593Smuzhiyun 	u8 rx_cchan;
691*4882a593Smuzhiyun 
692*4882a593Smuzhiyun 	bool tc_block_shared;
693*4882a593Smuzhiyun 
694*4882a593Smuzhiyun 	/* Mirror VI information */
695*4882a593Smuzhiyun 	u16 viid_mirror;
696*4882a593Smuzhiyun 	u16 nmirrorqsets;
697*4882a593Smuzhiyun 	u32 vi_mirror_count;
698*4882a593Smuzhiyun 	struct mutex vi_mirror_mutex; /* Sync access to Mirror VI info */
699*4882a593Smuzhiyun 	struct cxgb4_ethtool_lb_test ethtool_lb;
700*4882a593Smuzhiyun };
701*4882a593Smuzhiyun 
702*4882a593Smuzhiyun struct dentry;
703*4882a593Smuzhiyun struct work_struct;
704*4882a593Smuzhiyun 
705*4882a593Smuzhiyun enum {                                 /* adapter flags */
706*4882a593Smuzhiyun 	CXGB4_FULL_INIT_DONE		= (1 << 0),
707*4882a593Smuzhiyun 	CXGB4_DEV_ENABLED		= (1 << 1),
708*4882a593Smuzhiyun 	CXGB4_USING_MSI			= (1 << 2),
709*4882a593Smuzhiyun 	CXGB4_USING_MSIX		= (1 << 3),
710*4882a593Smuzhiyun 	CXGB4_FW_OK			= (1 << 4),
711*4882a593Smuzhiyun 	CXGB4_RSS_TNLALLLOOKUP		= (1 << 5),
712*4882a593Smuzhiyun 	CXGB4_USING_SOFT_PARAMS		= (1 << 6),
713*4882a593Smuzhiyun 	CXGB4_MASTER_PF			= (1 << 7),
714*4882a593Smuzhiyun 	CXGB4_FW_OFLD_CONN		= (1 << 9),
715*4882a593Smuzhiyun 	CXGB4_ROOT_NO_RELAXED_ORDERING	= (1 << 10),
716*4882a593Smuzhiyun 	CXGB4_SHUTTING_DOWN		= (1 << 11),
717*4882a593Smuzhiyun 	CXGB4_SGE_DBQ_TIMER		= (1 << 12),
718*4882a593Smuzhiyun };
719*4882a593Smuzhiyun 
720*4882a593Smuzhiyun enum {
721*4882a593Smuzhiyun 	ULP_CRYPTO_LOOKASIDE = 1 << 0,
722*4882a593Smuzhiyun 	ULP_CRYPTO_IPSEC_INLINE = 1 << 1,
723*4882a593Smuzhiyun 	ULP_CRYPTO_KTLS_INLINE  = 1 << 3,
724*4882a593Smuzhiyun };
725*4882a593Smuzhiyun 
726*4882a593Smuzhiyun #define CXGB4_MIRROR_RXQ_DEFAULT_DESC_NUM 1024
727*4882a593Smuzhiyun #define CXGB4_MIRROR_RXQ_DEFAULT_DESC_SIZE 64
728*4882a593Smuzhiyun #define CXGB4_MIRROR_RXQ_DEFAULT_INTR_USEC 5
729*4882a593Smuzhiyun #define CXGB4_MIRROR_RXQ_DEFAULT_PKT_CNT 8
730*4882a593Smuzhiyun 
731*4882a593Smuzhiyun #define CXGB4_MIRROR_FLQ_DEFAULT_DESC_NUM 72
732*4882a593Smuzhiyun 
733*4882a593Smuzhiyun struct rx_sw_desc;
734*4882a593Smuzhiyun 
735*4882a593Smuzhiyun struct sge_fl {                     /* SGE free-buffer queue state */
736*4882a593Smuzhiyun 	unsigned int avail;         /* # of available Rx buffers */
737*4882a593Smuzhiyun 	unsigned int pend_cred;     /* new buffers since last FL DB ring */
738*4882a593Smuzhiyun 	unsigned int cidx;          /* consumer index */
739*4882a593Smuzhiyun 	unsigned int pidx;          /* producer index */
740*4882a593Smuzhiyun 	unsigned long alloc_failed; /* # of times buffer allocation failed */
741*4882a593Smuzhiyun 	unsigned long large_alloc_failed;
742*4882a593Smuzhiyun 	unsigned long mapping_err;  /* # of RX Buffer DMA Mapping failures */
743*4882a593Smuzhiyun 	unsigned long low;          /* # of times momentarily starving */
744*4882a593Smuzhiyun 	unsigned long starving;
745*4882a593Smuzhiyun 	/* RO fields */
746*4882a593Smuzhiyun 	unsigned int cntxt_id;      /* SGE context id for the free list */
747*4882a593Smuzhiyun 	unsigned int size;          /* capacity of free list */
748*4882a593Smuzhiyun 	struct rx_sw_desc *sdesc;   /* address of SW Rx descriptor ring */
749*4882a593Smuzhiyun 	__be64 *desc;               /* address of HW Rx descriptor ring */
750*4882a593Smuzhiyun 	dma_addr_t addr;            /* bus address of HW ring start */
751*4882a593Smuzhiyun 	void __iomem *bar2_addr;    /* address of BAR2 Queue registers */
752*4882a593Smuzhiyun 	unsigned int bar2_qid;      /* Queue ID for BAR2 Queue registers */
753*4882a593Smuzhiyun };
754*4882a593Smuzhiyun 
755*4882a593Smuzhiyun /* A packet gather list */
756*4882a593Smuzhiyun struct pkt_gl {
757*4882a593Smuzhiyun 	u64 sgetstamp;		    /* SGE Time Stamp for Ingress Packet */
758*4882a593Smuzhiyun 	struct page_frag frags[MAX_SKB_FRAGS];
759*4882a593Smuzhiyun 	void *va;                         /* virtual address of first byte */
760*4882a593Smuzhiyun 	unsigned int nfrags;              /* # of fragments */
761*4882a593Smuzhiyun 	unsigned int tot_len;             /* total length of fragments */
762*4882a593Smuzhiyun };
763*4882a593Smuzhiyun 
764*4882a593Smuzhiyun typedef int (*rspq_handler_t)(struct sge_rspq *q, const __be64 *rsp,
765*4882a593Smuzhiyun 			      const struct pkt_gl *gl);
766*4882a593Smuzhiyun typedef void (*rspq_flush_handler_t)(struct sge_rspq *q);
767*4882a593Smuzhiyun /* LRO related declarations for ULD */
768*4882a593Smuzhiyun struct t4_lro_mgr {
769*4882a593Smuzhiyun #define MAX_LRO_SESSIONS		64
770*4882a593Smuzhiyun 	u8 lro_session_cnt;         /* # of sessions to aggregate */
771*4882a593Smuzhiyun 	unsigned long lro_pkts;     /* # of LRO super packets */
772*4882a593Smuzhiyun 	unsigned long lro_merged;   /* # of wire packets merged by LRO */
773*4882a593Smuzhiyun 	struct sk_buff_head lroq;   /* list of aggregated sessions */
774*4882a593Smuzhiyun };
775*4882a593Smuzhiyun 
776*4882a593Smuzhiyun struct sge_rspq {                   /* state for an SGE response queue */
777*4882a593Smuzhiyun 	struct napi_struct napi;
778*4882a593Smuzhiyun 	const __be64 *cur_desc;     /* current descriptor in queue */
779*4882a593Smuzhiyun 	unsigned int cidx;          /* consumer index */
780*4882a593Smuzhiyun 	u8 gen;                     /* current generation bit */
781*4882a593Smuzhiyun 	u8 intr_params;             /* interrupt holdoff parameters */
782*4882a593Smuzhiyun 	u8 next_intr_params;        /* holdoff params for next interrupt */
783*4882a593Smuzhiyun 	u8 adaptive_rx;
784*4882a593Smuzhiyun 	u8 pktcnt_idx;              /* interrupt packet threshold */
785*4882a593Smuzhiyun 	u8 uld;                     /* ULD handling this queue */
786*4882a593Smuzhiyun 	u8 idx;                     /* queue index within its group */
787*4882a593Smuzhiyun 	int offset;                 /* offset into current Rx buffer */
788*4882a593Smuzhiyun 	u16 cntxt_id;               /* SGE context id for the response q */
789*4882a593Smuzhiyun 	u16 abs_id;                 /* absolute SGE id for the response q */
790*4882a593Smuzhiyun 	__be64 *desc;               /* address of HW response ring */
791*4882a593Smuzhiyun 	dma_addr_t phys_addr;       /* physical address of the ring */
792*4882a593Smuzhiyun 	void __iomem *bar2_addr;    /* address of BAR2 Queue registers */
793*4882a593Smuzhiyun 	unsigned int bar2_qid;      /* Queue ID for BAR2 Queue registers */
794*4882a593Smuzhiyun 	unsigned int iqe_len;       /* entry size */
795*4882a593Smuzhiyun 	unsigned int size;          /* capacity of response queue */
796*4882a593Smuzhiyun 	struct adapter *adap;
797*4882a593Smuzhiyun 	struct net_device *netdev;  /* associated net device */
798*4882a593Smuzhiyun 	rspq_handler_t handler;
799*4882a593Smuzhiyun 	rspq_flush_handler_t flush_handler;
800*4882a593Smuzhiyun 	struct t4_lro_mgr lro_mgr;
801*4882a593Smuzhiyun };
802*4882a593Smuzhiyun 
803*4882a593Smuzhiyun struct sge_eth_stats {              /* Ethernet queue statistics */
804*4882a593Smuzhiyun 	unsigned long pkts;         /* # of ethernet packets */
805*4882a593Smuzhiyun 	unsigned long lro_pkts;     /* # of LRO super packets */
806*4882a593Smuzhiyun 	unsigned long lro_merged;   /* # of wire packets merged by LRO */
807*4882a593Smuzhiyun 	unsigned long rx_cso;       /* # of Rx checksum offloads */
808*4882a593Smuzhiyun 	unsigned long vlan_ex;      /* # of Rx VLAN extractions */
809*4882a593Smuzhiyun 	unsigned long rx_drops;     /* # of packets dropped due to no mem */
810*4882a593Smuzhiyun 	unsigned long bad_rx_pkts;  /* # of packets with err_vec!=0 */
811*4882a593Smuzhiyun };
812*4882a593Smuzhiyun 
813*4882a593Smuzhiyun struct sge_eth_rxq {                /* SW Ethernet Rx queue */
814*4882a593Smuzhiyun 	struct sge_rspq rspq;
815*4882a593Smuzhiyun 	struct sge_fl fl;
816*4882a593Smuzhiyun 	struct sge_eth_stats stats;
817*4882a593Smuzhiyun 	struct msix_info *msix;
818*4882a593Smuzhiyun } ____cacheline_aligned_in_smp;
819*4882a593Smuzhiyun 
820*4882a593Smuzhiyun struct sge_ofld_stats {             /* offload queue statistics */
821*4882a593Smuzhiyun 	unsigned long pkts;         /* # of packets */
822*4882a593Smuzhiyun 	unsigned long imm;          /* # of immediate-data packets */
823*4882a593Smuzhiyun 	unsigned long an;           /* # of asynchronous notifications */
824*4882a593Smuzhiyun 	unsigned long nomem;        /* # of responses deferred due to no mem */
825*4882a593Smuzhiyun };
826*4882a593Smuzhiyun 
827*4882a593Smuzhiyun struct sge_ofld_rxq {               /* SW offload Rx queue */
828*4882a593Smuzhiyun 	struct sge_rspq rspq;
829*4882a593Smuzhiyun 	struct sge_fl fl;
830*4882a593Smuzhiyun 	struct sge_ofld_stats stats;
831*4882a593Smuzhiyun 	struct msix_info *msix;
832*4882a593Smuzhiyun } ____cacheline_aligned_in_smp;
833*4882a593Smuzhiyun 
834*4882a593Smuzhiyun struct tx_desc {
835*4882a593Smuzhiyun 	__be64 flit[8];
836*4882a593Smuzhiyun };
837*4882a593Smuzhiyun 
838*4882a593Smuzhiyun struct ulptx_sgl;
839*4882a593Smuzhiyun 
840*4882a593Smuzhiyun struct tx_sw_desc {
841*4882a593Smuzhiyun 	struct sk_buff *skb; /* SKB to free after getting completion */
842*4882a593Smuzhiyun 	dma_addr_t addr[MAX_SKB_FRAGS + 1]; /* DMA mapped addresses */
843*4882a593Smuzhiyun };
844*4882a593Smuzhiyun 
845*4882a593Smuzhiyun struct sge_txq {
846*4882a593Smuzhiyun 	unsigned int  in_use;       /* # of in-use Tx descriptors */
847*4882a593Smuzhiyun 	unsigned int  q_type;	    /* Q type Eth/Ctrl/Ofld */
848*4882a593Smuzhiyun 	unsigned int  size;         /* # of descriptors */
849*4882a593Smuzhiyun 	unsigned int  cidx;         /* SW consumer index */
850*4882a593Smuzhiyun 	unsigned int  pidx;         /* producer index */
851*4882a593Smuzhiyun 	unsigned long stops;        /* # of times q has been stopped */
852*4882a593Smuzhiyun 	unsigned long restarts;     /* # of queue restarts */
853*4882a593Smuzhiyun 	unsigned int  cntxt_id;     /* SGE context id for the Tx q */
854*4882a593Smuzhiyun 	struct tx_desc *desc;       /* address of HW Tx descriptor ring */
855*4882a593Smuzhiyun 	struct tx_sw_desc *sdesc;   /* address of SW Tx descriptor ring */
856*4882a593Smuzhiyun 	struct sge_qstat *stat;     /* queue status entry */
857*4882a593Smuzhiyun 	dma_addr_t    phys_addr;    /* physical address of the ring */
858*4882a593Smuzhiyun 	spinlock_t db_lock;
859*4882a593Smuzhiyun 	int db_disabled;
860*4882a593Smuzhiyun 	unsigned short db_pidx;
861*4882a593Smuzhiyun 	unsigned short db_pidx_inc;
862*4882a593Smuzhiyun 	void __iomem *bar2_addr;    /* address of BAR2 Queue registers */
863*4882a593Smuzhiyun 	unsigned int bar2_qid;      /* Queue ID for BAR2 Queue registers */
864*4882a593Smuzhiyun };
865*4882a593Smuzhiyun 
866*4882a593Smuzhiyun struct sge_eth_txq {                /* state for an SGE Ethernet Tx queue */
867*4882a593Smuzhiyun 	struct sge_txq q;
868*4882a593Smuzhiyun 	struct netdev_queue *txq;   /* associated netdev TX queue */
869*4882a593Smuzhiyun #ifdef CONFIG_CHELSIO_T4_DCB
870*4882a593Smuzhiyun 	u8 dcb_prio;		    /* DCB Priority bound to queue */
871*4882a593Smuzhiyun #endif
872*4882a593Smuzhiyun 	u8 dbqt;                    /* SGE Doorbell Queue Timer in use */
873*4882a593Smuzhiyun 	unsigned int dbqtimerix;    /* SGE Doorbell Queue Timer Index */
874*4882a593Smuzhiyun 	unsigned long tso;          /* # of TSO requests */
875*4882a593Smuzhiyun 	unsigned long uso;          /* # of USO requests */
876*4882a593Smuzhiyun 	unsigned long tx_cso;       /* # of Tx checksum offloads */
877*4882a593Smuzhiyun 	unsigned long vlan_ins;     /* # of Tx VLAN insertions */
878*4882a593Smuzhiyun 	unsigned long mapping_err;  /* # of I/O MMU packet mapping errors */
879*4882a593Smuzhiyun } ____cacheline_aligned_in_smp;
880*4882a593Smuzhiyun 
881*4882a593Smuzhiyun struct sge_uld_txq {               /* state for an SGE offload Tx queue */
882*4882a593Smuzhiyun 	struct sge_txq q;
883*4882a593Smuzhiyun 	struct adapter *adap;
884*4882a593Smuzhiyun 	struct sk_buff_head sendq;  /* list of backpressured packets */
885*4882a593Smuzhiyun 	struct tasklet_struct qresume_tsk; /* restarts the queue */
886*4882a593Smuzhiyun 	bool service_ofldq_running; /* service_ofldq() is processing sendq */
887*4882a593Smuzhiyun 	u8 full;                    /* the Tx ring is full */
888*4882a593Smuzhiyun 	unsigned long mapping_err;  /* # of I/O MMU packet mapping errors */
889*4882a593Smuzhiyun } ____cacheline_aligned_in_smp;
890*4882a593Smuzhiyun 
891*4882a593Smuzhiyun struct sge_ctrl_txq {               /* state for an SGE control Tx queue */
892*4882a593Smuzhiyun 	struct sge_txq q;
893*4882a593Smuzhiyun 	struct adapter *adap;
894*4882a593Smuzhiyun 	struct sk_buff_head sendq;  /* list of backpressured packets */
895*4882a593Smuzhiyun 	struct tasklet_struct qresume_tsk; /* restarts the queue */
896*4882a593Smuzhiyun 	u8 full;                    /* the Tx ring is full */
897*4882a593Smuzhiyun } ____cacheline_aligned_in_smp;
898*4882a593Smuzhiyun 
899*4882a593Smuzhiyun struct sge_uld_rxq_info {
900*4882a593Smuzhiyun 	char name[IFNAMSIZ];	/* name of ULD driver */
901*4882a593Smuzhiyun 	struct sge_ofld_rxq *uldrxq; /* Rxq's for ULD */
902*4882a593Smuzhiyun 	u16 *rspq_id;		/* response queue id's of rxq */
903*4882a593Smuzhiyun 	u16 nrxq;		/* # of ingress uld queues */
904*4882a593Smuzhiyun 	u16 nciq;		/* # of completion queues */
905*4882a593Smuzhiyun 	u8 uld;			/* uld type */
906*4882a593Smuzhiyun };
907*4882a593Smuzhiyun 
908*4882a593Smuzhiyun struct sge_uld_txq_info {
909*4882a593Smuzhiyun 	struct sge_uld_txq *uldtxq; /* Txq's for ULD */
910*4882a593Smuzhiyun 	atomic_t users;		/* num users */
911*4882a593Smuzhiyun 	u16 ntxq;		/* # of egress uld queues */
912*4882a593Smuzhiyun };
913*4882a593Smuzhiyun 
914*4882a593Smuzhiyun /* struct to maintain ULD list to reallocate ULD resources on hotplug */
915*4882a593Smuzhiyun struct cxgb4_uld_list {
916*4882a593Smuzhiyun 	struct cxgb4_uld_info uld_info;
917*4882a593Smuzhiyun 	struct list_head list_node;
918*4882a593Smuzhiyun 	enum cxgb4_uld uld_type;
919*4882a593Smuzhiyun };
920*4882a593Smuzhiyun 
921*4882a593Smuzhiyun enum sge_eosw_state {
922*4882a593Smuzhiyun 	CXGB4_EO_STATE_CLOSED = 0, /* Not ready to accept traffic */
923*4882a593Smuzhiyun 	CXGB4_EO_STATE_FLOWC_OPEN_SEND, /* Send FLOWC open request */
924*4882a593Smuzhiyun 	CXGB4_EO_STATE_FLOWC_OPEN_REPLY, /* Waiting for FLOWC open reply */
925*4882a593Smuzhiyun 	CXGB4_EO_STATE_ACTIVE, /* Ready to accept traffic */
926*4882a593Smuzhiyun 	CXGB4_EO_STATE_FLOWC_CLOSE_SEND, /* Send FLOWC close request */
927*4882a593Smuzhiyun 	CXGB4_EO_STATE_FLOWC_CLOSE_REPLY, /* Waiting for FLOWC close reply */
928*4882a593Smuzhiyun };
929*4882a593Smuzhiyun 
930*4882a593Smuzhiyun struct sge_eosw_txq {
931*4882a593Smuzhiyun 	spinlock_t lock; /* Per queue lock to synchronize completions */
932*4882a593Smuzhiyun 	enum sge_eosw_state state; /* Current ETHOFLD State */
933*4882a593Smuzhiyun 	struct tx_sw_desc *desc; /* Descriptor ring to hold packets */
934*4882a593Smuzhiyun 	u32 ndesc; /* Number of descriptors */
935*4882a593Smuzhiyun 	u32 pidx; /* Current Producer Index */
936*4882a593Smuzhiyun 	u32 last_pidx; /* Last successfully transmitted Producer Index */
937*4882a593Smuzhiyun 	u32 cidx; /* Current Consumer Index */
938*4882a593Smuzhiyun 	u32 last_cidx; /* Last successfully reclaimed Consumer Index */
939*4882a593Smuzhiyun 	u32 flowc_idx; /* Descriptor containing a FLOWC request */
940*4882a593Smuzhiyun 	u32 inuse; /* Number of packets held in ring */
941*4882a593Smuzhiyun 
942*4882a593Smuzhiyun 	u32 cred; /* Current available credits */
943*4882a593Smuzhiyun 	u32 ncompl; /* # of completions posted */
944*4882a593Smuzhiyun 	u32 last_compl; /* # of credits consumed since last completion req */
945*4882a593Smuzhiyun 
946*4882a593Smuzhiyun 	u32 eotid; /* Index into EOTID table in software */
947*4882a593Smuzhiyun 	u32 hwtid; /* Hardware EOTID index */
948*4882a593Smuzhiyun 
949*4882a593Smuzhiyun 	u32 hwqid; /* Underlying hardware queue index */
950*4882a593Smuzhiyun 	struct net_device *netdev; /* Pointer to netdevice */
951*4882a593Smuzhiyun 	struct tasklet_struct qresume_tsk; /* Restarts the queue */
952*4882a593Smuzhiyun 	struct completion completion; /* completion for FLOWC rendezvous */
953*4882a593Smuzhiyun };
954*4882a593Smuzhiyun 
955*4882a593Smuzhiyun struct sge_eohw_txq {
956*4882a593Smuzhiyun 	spinlock_t lock; /* Per queue lock */
957*4882a593Smuzhiyun 	struct sge_txq q; /* HW Txq */
958*4882a593Smuzhiyun 	struct adapter *adap; /* Backpointer to adapter */
959*4882a593Smuzhiyun 	unsigned long tso; /* # of TSO requests */
960*4882a593Smuzhiyun 	unsigned long uso; /* # of USO requests */
961*4882a593Smuzhiyun 	unsigned long tx_cso; /* # of Tx checksum offloads */
962*4882a593Smuzhiyun 	unsigned long vlan_ins; /* # of Tx VLAN insertions */
963*4882a593Smuzhiyun 	unsigned long mapping_err; /* # of I/O MMU packet mapping errors */
964*4882a593Smuzhiyun };
965*4882a593Smuzhiyun 
966*4882a593Smuzhiyun struct sge {
967*4882a593Smuzhiyun 	struct sge_eth_txq ethtxq[MAX_ETH_QSETS];
968*4882a593Smuzhiyun 	struct sge_eth_txq ptptxq;
969*4882a593Smuzhiyun 	struct sge_ctrl_txq ctrlq[MAX_CTRL_QUEUES];
970*4882a593Smuzhiyun 
971*4882a593Smuzhiyun 	struct sge_eth_rxq ethrxq[MAX_ETH_QSETS];
972*4882a593Smuzhiyun 	struct sge_rspq fw_evtq ____cacheline_aligned_in_smp;
973*4882a593Smuzhiyun 	struct sge_uld_rxq_info **uld_rxq_info;
974*4882a593Smuzhiyun 	struct sge_uld_txq_info **uld_txq_info;
975*4882a593Smuzhiyun 
976*4882a593Smuzhiyun 	struct sge_rspq intrq ____cacheline_aligned_in_smp;
977*4882a593Smuzhiyun 	spinlock_t intrq_lock;
978*4882a593Smuzhiyun 
979*4882a593Smuzhiyun 	struct sge_eohw_txq *eohw_txq;
980*4882a593Smuzhiyun 	struct sge_ofld_rxq *eohw_rxq;
981*4882a593Smuzhiyun 
982*4882a593Smuzhiyun 	struct sge_eth_rxq *mirror_rxq[NCHAN];
983*4882a593Smuzhiyun 
984*4882a593Smuzhiyun 	u16 max_ethqsets;           /* # of available Ethernet queue sets */
985*4882a593Smuzhiyun 	u16 ethqsets;               /* # of active Ethernet queue sets */
986*4882a593Smuzhiyun 	u16 ethtxq_rover;           /* Tx queue to clean up next */
987*4882a593Smuzhiyun 	u16 ofldqsets;              /* # of active ofld queue sets */
988*4882a593Smuzhiyun 	u16 nqs_per_uld;	    /* # of Rx queues per ULD */
989*4882a593Smuzhiyun 	u16 eoqsets;                /* # of ETHOFLD queues */
990*4882a593Smuzhiyun 	u16 mirrorqsets;            /* # of Mirror queues */
991*4882a593Smuzhiyun 
992*4882a593Smuzhiyun 	u16 timer_val[SGE_NTIMERS];
993*4882a593Smuzhiyun 	u8 counter_val[SGE_NCOUNTERS];
994*4882a593Smuzhiyun 	u16 dbqtimer_tick;
995*4882a593Smuzhiyun 	u16 dbqtimer_val[SGE_NDBQTIMERS];
996*4882a593Smuzhiyun 	u32 fl_pg_order;            /* large page allocation size */
997*4882a593Smuzhiyun 	u32 stat_len;               /* length of status page at ring end */
998*4882a593Smuzhiyun 	u32 pktshift;               /* padding between CPL & packet data */
999*4882a593Smuzhiyun 	u32 fl_align;               /* response queue message alignment */
1000*4882a593Smuzhiyun 	u32 fl_starve_thres;        /* Free List starvation threshold */
1001*4882a593Smuzhiyun 
1002*4882a593Smuzhiyun 	struct sge_idma_monitor_state idma_monitor;
1003*4882a593Smuzhiyun 	unsigned int egr_start;
1004*4882a593Smuzhiyun 	unsigned int egr_sz;
1005*4882a593Smuzhiyun 	unsigned int ingr_start;
1006*4882a593Smuzhiyun 	unsigned int ingr_sz;
1007*4882a593Smuzhiyun 	void **egr_map;    /* qid->queue egress queue map */
1008*4882a593Smuzhiyun 	struct sge_rspq **ingr_map; /* qid->queue ingress queue map */
1009*4882a593Smuzhiyun 	unsigned long *starving_fl;
1010*4882a593Smuzhiyun 	unsigned long *txq_maperr;
1011*4882a593Smuzhiyun 	unsigned long *blocked_fl;
1012*4882a593Smuzhiyun 	struct timer_list rx_timer; /* refills starving FLs */
1013*4882a593Smuzhiyun 	struct timer_list tx_timer; /* checks Tx queues */
1014*4882a593Smuzhiyun 
1015*4882a593Smuzhiyun 	int fwevtq_msix_idx; /* Index to firmware event queue MSI-X info */
1016*4882a593Smuzhiyun 	int nd_msix_idx; /* Index to non-data interrupts MSI-X info */
1017*4882a593Smuzhiyun };
1018*4882a593Smuzhiyun 
1019*4882a593Smuzhiyun #define for_each_ethrxq(sge, i) for (i = 0; i < (sge)->ethqsets; i++)
1020*4882a593Smuzhiyun #define for_each_ofldtxq(sge, i) for (i = 0; i < (sge)->ofldqsets; i++)
1021*4882a593Smuzhiyun 
1022*4882a593Smuzhiyun struct l2t_data;
1023*4882a593Smuzhiyun 
1024*4882a593Smuzhiyun #ifdef CONFIG_PCI_IOV
1025*4882a593Smuzhiyun 
1026*4882a593Smuzhiyun /* T4 supports SRIOV on PF0-3 and T5 on PF0-7.  However, the Serial
1027*4882a593Smuzhiyun  * Configuration initialization for T5 only has SR-IOV functionality enabled
1028*4882a593Smuzhiyun  * on PF0-3 in order to simplify everything.
1029*4882a593Smuzhiyun  */
1030*4882a593Smuzhiyun #define NUM_OF_PF_WITH_SRIOV 4
1031*4882a593Smuzhiyun 
1032*4882a593Smuzhiyun #endif
1033*4882a593Smuzhiyun 
1034*4882a593Smuzhiyun struct doorbell_stats {
1035*4882a593Smuzhiyun 	u32 db_drop;
1036*4882a593Smuzhiyun 	u32 db_empty;
1037*4882a593Smuzhiyun 	u32 db_full;
1038*4882a593Smuzhiyun };
1039*4882a593Smuzhiyun 
1040*4882a593Smuzhiyun struct hash_mac_addr {
1041*4882a593Smuzhiyun 	struct list_head list;
1042*4882a593Smuzhiyun 	u8 addr[ETH_ALEN];
1043*4882a593Smuzhiyun 	unsigned int iface_mac;
1044*4882a593Smuzhiyun };
1045*4882a593Smuzhiyun 
1046*4882a593Smuzhiyun struct msix_bmap {
1047*4882a593Smuzhiyun 	unsigned long *msix_bmap;
1048*4882a593Smuzhiyun 	unsigned int mapsize;
1049*4882a593Smuzhiyun 	spinlock_t lock; /* lock for acquiring bitmap */
1050*4882a593Smuzhiyun };
1051*4882a593Smuzhiyun 
1052*4882a593Smuzhiyun struct msix_info {
1053*4882a593Smuzhiyun 	unsigned short vec;
1054*4882a593Smuzhiyun 	char desc[IFNAMSIZ + 10];
1055*4882a593Smuzhiyun 	unsigned int idx;
1056*4882a593Smuzhiyun 	cpumask_var_t aff_mask;
1057*4882a593Smuzhiyun };
1058*4882a593Smuzhiyun 
1059*4882a593Smuzhiyun struct vf_info {
1060*4882a593Smuzhiyun 	unsigned char vf_mac_addr[ETH_ALEN];
1061*4882a593Smuzhiyun 	unsigned int tx_rate;
1062*4882a593Smuzhiyun 	bool pf_set_mac;
1063*4882a593Smuzhiyun 	u16 vlan;
1064*4882a593Smuzhiyun 	int link_state;
1065*4882a593Smuzhiyun };
1066*4882a593Smuzhiyun 
1067*4882a593Smuzhiyun enum {
1068*4882a593Smuzhiyun 	HMA_DMA_MAPPED_FLAG = 1
1069*4882a593Smuzhiyun };
1070*4882a593Smuzhiyun 
1071*4882a593Smuzhiyun struct hma_data {
1072*4882a593Smuzhiyun 	unsigned char flags;
1073*4882a593Smuzhiyun 	struct sg_table *sgt;
1074*4882a593Smuzhiyun 	dma_addr_t *phy_addr;	/* physical address of the page */
1075*4882a593Smuzhiyun };
1076*4882a593Smuzhiyun 
1077*4882a593Smuzhiyun struct mbox_list {
1078*4882a593Smuzhiyun 	struct list_head list;
1079*4882a593Smuzhiyun };
1080*4882a593Smuzhiyun 
1081*4882a593Smuzhiyun #if IS_ENABLED(CONFIG_THERMAL)
1082*4882a593Smuzhiyun struct ch_thermal {
1083*4882a593Smuzhiyun 	struct thermal_zone_device *tzdev;
1084*4882a593Smuzhiyun 	int trip_temp;
1085*4882a593Smuzhiyun 	int trip_type;
1086*4882a593Smuzhiyun };
1087*4882a593Smuzhiyun #endif
1088*4882a593Smuzhiyun 
1089*4882a593Smuzhiyun struct mps_entries_ref {
1090*4882a593Smuzhiyun 	struct list_head list;
1091*4882a593Smuzhiyun 	u8 addr[ETH_ALEN];
1092*4882a593Smuzhiyun 	u8 mask[ETH_ALEN];
1093*4882a593Smuzhiyun 	u16 idx;
1094*4882a593Smuzhiyun 	refcount_t refcnt;
1095*4882a593Smuzhiyun };
1096*4882a593Smuzhiyun 
1097*4882a593Smuzhiyun struct cxgb4_ethtool_filter_info {
1098*4882a593Smuzhiyun 	u32 *loc_array; /* Array holding the actual TIDs set to filters */
1099*4882a593Smuzhiyun 	unsigned long *bmap; /* Bitmap for managing filters in use */
1100*4882a593Smuzhiyun 	u32 in_use; /* # of filters in use */
1101*4882a593Smuzhiyun };
1102*4882a593Smuzhiyun 
1103*4882a593Smuzhiyun struct cxgb4_ethtool_filter {
1104*4882a593Smuzhiyun 	u32 nentries; /* Adapter wide number of supported filters */
1105*4882a593Smuzhiyun 	struct cxgb4_ethtool_filter_info *port; /* Per port entry */
1106*4882a593Smuzhiyun };
1107*4882a593Smuzhiyun 
1108*4882a593Smuzhiyun struct adapter {
1109*4882a593Smuzhiyun 	void __iomem *regs;
1110*4882a593Smuzhiyun 	void __iomem *bar2;
1111*4882a593Smuzhiyun 	u32 t4_bar0;
1112*4882a593Smuzhiyun 	struct pci_dev *pdev;
1113*4882a593Smuzhiyun 	struct device *pdev_dev;
1114*4882a593Smuzhiyun 	const char *name;
1115*4882a593Smuzhiyun 	unsigned int mbox;
1116*4882a593Smuzhiyun 	unsigned int pf;
1117*4882a593Smuzhiyun 	unsigned int flags;
1118*4882a593Smuzhiyun 	unsigned int adap_idx;
1119*4882a593Smuzhiyun 	enum chip_type chip;
1120*4882a593Smuzhiyun 	u32 eth_flags;
1121*4882a593Smuzhiyun 
1122*4882a593Smuzhiyun 	int msg_enable;
1123*4882a593Smuzhiyun 	__be16 vxlan_port;
1124*4882a593Smuzhiyun 	__be16 geneve_port;
1125*4882a593Smuzhiyun 
1126*4882a593Smuzhiyun 	struct adapter_params params;
1127*4882a593Smuzhiyun 	struct cxgb4_virt_res vres;
1128*4882a593Smuzhiyun 	unsigned int swintr;
1129*4882a593Smuzhiyun 
1130*4882a593Smuzhiyun 	/* MSI-X Info for NIC and OFLD queues */
1131*4882a593Smuzhiyun 	struct msix_info *msix_info;
1132*4882a593Smuzhiyun 	struct msix_bmap msix_bmap;
1133*4882a593Smuzhiyun 
1134*4882a593Smuzhiyun 	struct doorbell_stats db_stats;
1135*4882a593Smuzhiyun 	struct sge sge;
1136*4882a593Smuzhiyun 
1137*4882a593Smuzhiyun 	struct net_device *port[MAX_NPORTS];
1138*4882a593Smuzhiyun 	u8 chan_map[NCHAN];                   /* channel -> port map */
1139*4882a593Smuzhiyun 
1140*4882a593Smuzhiyun 	struct vf_info *vfinfo;
1141*4882a593Smuzhiyun 	u8 num_vfs;
1142*4882a593Smuzhiyun 
1143*4882a593Smuzhiyun 	u32 filter_mode;
1144*4882a593Smuzhiyun 	unsigned int l2t_start;
1145*4882a593Smuzhiyun 	unsigned int l2t_end;
1146*4882a593Smuzhiyun 	struct l2t_data *l2t;
1147*4882a593Smuzhiyun 	unsigned int clipt_start;
1148*4882a593Smuzhiyun 	unsigned int clipt_end;
1149*4882a593Smuzhiyun 	struct clip_tbl *clipt;
1150*4882a593Smuzhiyun 	unsigned int rawf_start;
1151*4882a593Smuzhiyun 	unsigned int rawf_cnt;
1152*4882a593Smuzhiyun 	struct smt_data *smt;
1153*4882a593Smuzhiyun 	struct cxgb4_uld_info *uld;
1154*4882a593Smuzhiyun 	void *uld_handle[CXGB4_ULD_MAX];
1155*4882a593Smuzhiyun 	unsigned int num_uld;
1156*4882a593Smuzhiyun 	unsigned int num_ofld_uld;
1157*4882a593Smuzhiyun 	struct list_head list_node;
1158*4882a593Smuzhiyun 	struct list_head rcu_node;
1159*4882a593Smuzhiyun 	struct list_head mac_hlist; /* list of MAC addresses in MPS Hash */
1160*4882a593Smuzhiyun 	struct list_head mps_ref;
1161*4882a593Smuzhiyun 	spinlock_t mps_ref_lock; /* lock for syncing mps ref/def activities */
1162*4882a593Smuzhiyun 
1163*4882a593Smuzhiyun 	void *iscsi_ppm;
1164*4882a593Smuzhiyun 
1165*4882a593Smuzhiyun 	struct tid_info tids;
1166*4882a593Smuzhiyun 	void **tid_release_head;
1167*4882a593Smuzhiyun 	spinlock_t tid_release_lock;
1168*4882a593Smuzhiyun 	struct workqueue_struct *workq;
1169*4882a593Smuzhiyun 	struct work_struct tid_release_task;
1170*4882a593Smuzhiyun 	struct work_struct db_full_task;
1171*4882a593Smuzhiyun 	struct work_struct db_drop_task;
1172*4882a593Smuzhiyun 	struct work_struct fatal_err_notify_task;
1173*4882a593Smuzhiyun 	bool tid_release_task_busy;
1174*4882a593Smuzhiyun 
1175*4882a593Smuzhiyun 	/* lock for mailbox cmd list */
1176*4882a593Smuzhiyun 	spinlock_t mbox_lock;
1177*4882a593Smuzhiyun 	struct mbox_list mlist;
1178*4882a593Smuzhiyun 
1179*4882a593Smuzhiyun 	/* support for mailbox command/reply logging */
1180*4882a593Smuzhiyun #define T4_OS_LOG_MBOX_CMDS 256
1181*4882a593Smuzhiyun 	struct mbox_cmd_log *mbox_log;
1182*4882a593Smuzhiyun 
1183*4882a593Smuzhiyun 	struct mutex uld_mutex;
1184*4882a593Smuzhiyun 
1185*4882a593Smuzhiyun 	struct dentry *debugfs_root;
1186*4882a593Smuzhiyun 	bool use_bd;     /* Use SGE Back Door intfc for reading SGE Contexts */
1187*4882a593Smuzhiyun 	bool trace_rss;	/* 1 implies that different RSS flit per filter is
1188*4882a593Smuzhiyun 			 * used per filter else if 0 default RSS flit is
1189*4882a593Smuzhiyun 			 * used for all 4 filters.
1190*4882a593Smuzhiyun 			 */
1191*4882a593Smuzhiyun 
1192*4882a593Smuzhiyun 	struct ptp_clock *ptp_clock;
1193*4882a593Smuzhiyun 	struct ptp_clock_info ptp_clock_info;
1194*4882a593Smuzhiyun 	struct sk_buff *ptp_tx_skb;
1195*4882a593Smuzhiyun 	/* ptp lock */
1196*4882a593Smuzhiyun 	spinlock_t ptp_lock;
1197*4882a593Smuzhiyun 	spinlock_t stats_lock;
1198*4882a593Smuzhiyun 	spinlock_t win0_lock ____cacheline_aligned_in_smp;
1199*4882a593Smuzhiyun 
1200*4882a593Smuzhiyun 	/* TC u32 offload */
1201*4882a593Smuzhiyun 	struct cxgb4_tc_u32_table *tc_u32;
1202*4882a593Smuzhiyun 	struct chcr_ktls chcr_ktls;
1203*4882a593Smuzhiyun 	struct chcr_stats_debug chcr_stats;
1204*4882a593Smuzhiyun #if IS_ENABLED(CONFIG_CHELSIO_TLS_DEVICE)
1205*4882a593Smuzhiyun 	struct ch_ktls_stats_debug ch_ktls_stats;
1206*4882a593Smuzhiyun #endif
1207*4882a593Smuzhiyun #if IS_ENABLED(CONFIG_CHELSIO_IPSEC_INLINE)
1208*4882a593Smuzhiyun 	struct ch_ipsec_stats_debug ch_ipsec_stats;
1209*4882a593Smuzhiyun #endif
1210*4882a593Smuzhiyun 
1211*4882a593Smuzhiyun 	/* TC flower offload */
1212*4882a593Smuzhiyun 	bool tc_flower_initialized;
1213*4882a593Smuzhiyun 	struct rhashtable flower_tbl;
1214*4882a593Smuzhiyun 	struct rhashtable_params flower_ht_params;
1215*4882a593Smuzhiyun 	struct timer_list flower_stats_timer;
1216*4882a593Smuzhiyun 	struct work_struct flower_stats_work;
1217*4882a593Smuzhiyun 
1218*4882a593Smuzhiyun 	/* Ethtool Dump */
1219*4882a593Smuzhiyun 	struct ethtool_dump eth_dump;
1220*4882a593Smuzhiyun 
1221*4882a593Smuzhiyun 	/* HMA */
1222*4882a593Smuzhiyun 	struct hma_data hma;
1223*4882a593Smuzhiyun 
1224*4882a593Smuzhiyun 	struct srq_data *srq;
1225*4882a593Smuzhiyun 
1226*4882a593Smuzhiyun 	/* Dump buffer for collecting logs in kdump kernel */
1227*4882a593Smuzhiyun 	struct vmcoredd_data vmcoredd;
1228*4882a593Smuzhiyun #if IS_ENABLED(CONFIG_THERMAL)
1229*4882a593Smuzhiyun 	struct ch_thermal ch_thermal;
1230*4882a593Smuzhiyun #endif
1231*4882a593Smuzhiyun 
1232*4882a593Smuzhiyun 	/* TC MQPRIO offload */
1233*4882a593Smuzhiyun 	struct cxgb4_tc_mqprio *tc_mqprio;
1234*4882a593Smuzhiyun 
1235*4882a593Smuzhiyun 	/* TC MATCHALL classifier offload */
1236*4882a593Smuzhiyun 	struct cxgb4_tc_matchall *tc_matchall;
1237*4882a593Smuzhiyun 
1238*4882a593Smuzhiyun 	/* Ethtool n-tuple */
1239*4882a593Smuzhiyun 	struct cxgb4_ethtool_filter *ethtool_filters;
1240*4882a593Smuzhiyun };
1241*4882a593Smuzhiyun 
1242*4882a593Smuzhiyun /* Support for "sched-class" command to allow a TX Scheduling Class to be
1243*4882a593Smuzhiyun  * programmed with various parameters.
1244*4882a593Smuzhiyun  */
1245*4882a593Smuzhiyun struct ch_sched_params {
1246*4882a593Smuzhiyun 	u8   type;                     /* packet or flow */
1247*4882a593Smuzhiyun 	union {
1248*4882a593Smuzhiyun 		struct {
1249*4882a593Smuzhiyun 			u8   level;    /* scheduler hierarchy level */
1250*4882a593Smuzhiyun 			u8   mode;     /* per-class or per-flow */
1251*4882a593Smuzhiyun 			u8   rateunit; /* bit or packet rate */
1252*4882a593Smuzhiyun 			u8   ratemode; /* %port relative or kbps absolute */
1253*4882a593Smuzhiyun 			u8   channel;  /* scheduler channel [0..N] */
1254*4882a593Smuzhiyun 			u8   class;    /* scheduler class [0..N] */
1255*4882a593Smuzhiyun 			u32  minrate;  /* minimum rate */
1256*4882a593Smuzhiyun 			u32  maxrate;  /* maximum rate */
1257*4882a593Smuzhiyun 			u16  weight;   /* percent weight */
1258*4882a593Smuzhiyun 			u16  pktsize;  /* average packet size */
1259*4882a593Smuzhiyun 			u16  burstsize;  /* burst buffer size */
1260*4882a593Smuzhiyun 		} params;
1261*4882a593Smuzhiyun 	} u;
1262*4882a593Smuzhiyun };
1263*4882a593Smuzhiyun 
1264*4882a593Smuzhiyun enum {
1265*4882a593Smuzhiyun 	SCHED_CLASS_TYPE_PACKET = 0,    /* class type */
1266*4882a593Smuzhiyun };
1267*4882a593Smuzhiyun 
1268*4882a593Smuzhiyun enum {
1269*4882a593Smuzhiyun 	SCHED_CLASS_LEVEL_CL_RL = 0,    /* class rate limiter */
1270*4882a593Smuzhiyun 	SCHED_CLASS_LEVEL_CH_RL = 2,    /* channel rate limiter */
1271*4882a593Smuzhiyun };
1272*4882a593Smuzhiyun 
1273*4882a593Smuzhiyun enum {
1274*4882a593Smuzhiyun 	SCHED_CLASS_MODE_CLASS = 0,     /* per-class scheduling */
1275*4882a593Smuzhiyun 	SCHED_CLASS_MODE_FLOW,          /* per-flow scheduling */
1276*4882a593Smuzhiyun };
1277*4882a593Smuzhiyun 
1278*4882a593Smuzhiyun enum {
1279*4882a593Smuzhiyun 	SCHED_CLASS_RATEUNIT_BITS = 0,  /* bit rate scheduling */
1280*4882a593Smuzhiyun };
1281*4882a593Smuzhiyun 
1282*4882a593Smuzhiyun enum {
1283*4882a593Smuzhiyun 	SCHED_CLASS_RATEMODE_ABS = 1,   /* Kb/s */
1284*4882a593Smuzhiyun };
1285*4882a593Smuzhiyun 
1286*4882a593Smuzhiyun /* Support for "sched_queue" command to allow one or more NIC TX Queues
1287*4882a593Smuzhiyun  * to be bound to a TX Scheduling Class.
1288*4882a593Smuzhiyun  */
1289*4882a593Smuzhiyun struct ch_sched_queue {
1290*4882a593Smuzhiyun 	s8   queue;    /* queue index */
1291*4882a593Smuzhiyun 	s8   class;    /* class index */
1292*4882a593Smuzhiyun };
1293*4882a593Smuzhiyun 
1294*4882a593Smuzhiyun /* Support for "sched_flowc" command to allow one or more FLOWC
1295*4882a593Smuzhiyun  * to be bound to a TX Scheduling Class.
1296*4882a593Smuzhiyun  */
1297*4882a593Smuzhiyun struct ch_sched_flowc {
1298*4882a593Smuzhiyun 	s32 tid;   /* TID to bind */
1299*4882a593Smuzhiyun 	s8  class; /* class index */
1300*4882a593Smuzhiyun };
1301*4882a593Smuzhiyun 
1302*4882a593Smuzhiyun /* Defined bit width of user definable filter tuples
1303*4882a593Smuzhiyun  */
1304*4882a593Smuzhiyun #define ETHTYPE_BITWIDTH 16
1305*4882a593Smuzhiyun #define FRAG_BITWIDTH 1
1306*4882a593Smuzhiyun #define MACIDX_BITWIDTH 9
1307*4882a593Smuzhiyun #define FCOE_BITWIDTH 1
1308*4882a593Smuzhiyun #define IPORT_BITWIDTH 3
1309*4882a593Smuzhiyun #define MATCHTYPE_BITWIDTH 3
1310*4882a593Smuzhiyun #define PROTO_BITWIDTH 8
1311*4882a593Smuzhiyun #define TOS_BITWIDTH 8
1312*4882a593Smuzhiyun #define PF_BITWIDTH 8
1313*4882a593Smuzhiyun #define VF_BITWIDTH 8
1314*4882a593Smuzhiyun #define IVLAN_BITWIDTH 16
1315*4882a593Smuzhiyun #define OVLAN_BITWIDTH 16
1316*4882a593Smuzhiyun #define ENCAP_VNI_BITWIDTH 24
1317*4882a593Smuzhiyun 
1318*4882a593Smuzhiyun /* Filter matching rules.  These consist of a set of ingress packet field
1319*4882a593Smuzhiyun  * (value, mask) tuples.  The associated ingress packet field matches the
1320*4882a593Smuzhiyun  * tuple when ((field & mask) == value).  (Thus a wildcard "don't care" field
1321*4882a593Smuzhiyun  * rule can be constructed by specifying a tuple of (0, 0).)  A filter rule
1322*4882a593Smuzhiyun  * matches an ingress packet when all of the individual individual field
1323*4882a593Smuzhiyun  * matching rules are true.
1324*4882a593Smuzhiyun  *
1325*4882a593Smuzhiyun  * Partial field masks are always valid, however, while it may be easy to
1326*4882a593Smuzhiyun  * understand their meanings for some fields (e.g. IP address to match a
1327*4882a593Smuzhiyun  * subnet), for others making sensible partial masks is less intuitive (e.g.
1328*4882a593Smuzhiyun  * MPS match type) ...
1329*4882a593Smuzhiyun  *
1330*4882a593Smuzhiyun  * Most of the following data structures are modeled on T4 capabilities.
1331*4882a593Smuzhiyun  * Drivers for earlier chips use the subsets which make sense for those chips.
1332*4882a593Smuzhiyun  * We really need to come up with a hardware-independent mechanism to
1333*4882a593Smuzhiyun  * represent hardware filter capabilities ...
1334*4882a593Smuzhiyun  */
1335*4882a593Smuzhiyun struct ch_filter_tuple {
1336*4882a593Smuzhiyun 	/* Compressed header matching field rules.  The TP_VLAN_PRI_MAP
1337*4882a593Smuzhiyun 	 * register selects which of these fields will participate in the
1338*4882a593Smuzhiyun 	 * filter match rules -- up to a maximum of 36 bits.  Because
1339*4882a593Smuzhiyun 	 * TP_VLAN_PRI_MAP is a global register, all filters must use the same
1340*4882a593Smuzhiyun 	 * set of fields.
1341*4882a593Smuzhiyun 	 */
1342*4882a593Smuzhiyun 	uint32_t ethtype:ETHTYPE_BITWIDTH;      /* Ethernet type */
1343*4882a593Smuzhiyun 	uint32_t frag:FRAG_BITWIDTH;            /* IP fragmentation header */
1344*4882a593Smuzhiyun 	uint32_t ivlan_vld:1;                   /* inner VLAN valid */
1345*4882a593Smuzhiyun 	uint32_t ovlan_vld:1;                   /* outer VLAN valid */
1346*4882a593Smuzhiyun 	uint32_t pfvf_vld:1;                    /* PF/VF valid */
1347*4882a593Smuzhiyun 	uint32_t encap_vld:1;			/* Encapsulation valid */
1348*4882a593Smuzhiyun 	uint32_t macidx:MACIDX_BITWIDTH;        /* exact match MAC index */
1349*4882a593Smuzhiyun 	uint32_t fcoe:FCOE_BITWIDTH;            /* FCoE packet */
1350*4882a593Smuzhiyun 	uint32_t iport:IPORT_BITWIDTH;          /* ingress port */
1351*4882a593Smuzhiyun 	uint32_t matchtype:MATCHTYPE_BITWIDTH;  /* MPS match type */
1352*4882a593Smuzhiyun 	uint32_t proto:PROTO_BITWIDTH;          /* protocol type */
1353*4882a593Smuzhiyun 	uint32_t tos:TOS_BITWIDTH;              /* TOS/Traffic Type */
1354*4882a593Smuzhiyun 	uint32_t pf:PF_BITWIDTH;                /* PCI-E PF ID */
1355*4882a593Smuzhiyun 	uint32_t vf:VF_BITWIDTH;                /* PCI-E VF ID */
1356*4882a593Smuzhiyun 	uint32_t ivlan:IVLAN_BITWIDTH;          /* inner VLAN */
1357*4882a593Smuzhiyun 	uint32_t ovlan:OVLAN_BITWIDTH;          /* outer VLAN */
1358*4882a593Smuzhiyun 	uint32_t vni:ENCAP_VNI_BITWIDTH;	/* VNI of tunnel */
1359*4882a593Smuzhiyun 
1360*4882a593Smuzhiyun 	/* Uncompressed header matching field rules.  These are always
1361*4882a593Smuzhiyun 	 * available for field rules.
1362*4882a593Smuzhiyun 	 */
1363*4882a593Smuzhiyun 	uint8_t lip[16];        /* local IP address (IPv4 in [3:0]) */
1364*4882a593Smuzhiyun 	uint8_t fip[16];        /* foreign IP address (IPv4 in [3:0]) */
1365*4882a593Smuzhiyun 	uint16_t lport;         /* local port */
1366*4882a593Smuzhiyun 	uint16_t fport;         /* foreign port */
1367*4882a593Smuzhiyun };
1368*4882a593Smuzhiyun 
1369*4882a593Smuzhiyun /* A filter ioctl command.
1370*4882a593Smuzhiyun  */
1371*4882a593Smuzhiyun struct ch_filter_specification {
1372*4882a593Smuzhiyun 	/* Administrative fields for filter.
1373*4882a593Smuzhiyun 	 */
1374*4882a593Smuzhiyun 	uint32_t hitcnts:1;     /* count filter hits in TCB */
1375*4882a593Smuzhiyun 	uint32_t prio:1;        /* filter has priority over active/server */
1376*4882a593Smuzhiyun 
1377*4882a593Smuzhiyun 	/* Fundamental filter typing.  This is the one element of filter
1378*4882a593Smuzhiyun 	 * matching that doesn't exist as a (value, mask) tuple.
1379*4882a593Smuzhiyun 	 */
1380*4882a593Smuzhiyun 	uint32_t type:1;        /* 0 => IPv4, 1 => IPv6 */
1381*4882a593Smuzhiyun 	u32 hash:1;		/* 0 => wild-card, 1 => exact-match */
1382*4882a593Smuzhiyun 
1383*4882a593Smuzhiyun 	/* Packet dispatch information.  Ingress packets which match the
1384*4882a593Smuzhiyun 	 * filter rules will be dropped, passed to the host or switched back
1385*4882a593Smuzhiyun 	 * out as egress packets.
1386*4882a593Smuzhiyun 	 */
1387*4882a593Smuzhiyun 	uint32_t action:2;      /* drop, pass, switch */
1388*4882a593Smuzhiyun 
1389*4882a593Smuzhiyun 	uint32_t rpttid:1;      /* report TID in RSS hash field */
1390*4882a593Smuzhiyun 
1391*4882a593Smuzhiyun 	uint32_t dirsteer:1;    /* 0 => RSS, 1 => steer to iq */
1392*4882a593Smuzhiyun 	uint32_t iq:10;         /* ingress queue */
1393*4882a593Smuzhiyun 
1394*4882a593Smuzhiyun 	uint32_t maskhash:1;    /* dirsteer=0: store RSS hash in TCB */
1395*4882a593Smuzhiyun 	uint32_t dirsteerhash:1;/* dirsteer=1: 0 => TCB contains RSS hash */
1396*4882a593Smuzhiyun 				/*             1 => TCB contains IQ ID */
1397*4882a593Smuzhiyun 
1398*4882a593Smuzhiyun 	/* Switch proxy/rewrite fields.  An ingress packet which matches a
1399*4882a593Smuzhiyun 	 * filter with "switch" set will be looped back out as an egress
1400*4882a593Smuzhiyun 	 * packet -- potentially with some Ethernet header rewriting.
1401*4882a593Smuzhiyun 	 */
1402*4882a593Smuzhiyun 	uint32_t eport:2;       /* egress port to switch packet out */
1403*4882a593Smuzhiyun 	uint32_t newdmac:1;     /* rewrite destination MAC address */
1404*4882a593Smuzhiyun 	uint32_t newsmac:1;     /* rewrite source MAC address */
1405*4882a593Smuzhiyun 	uint32_t newvlan:2;     /* rewrite VLAN Tag */
1406*4882a593Smuzhiyun 	uint32_t nat_mode:3;    /* specify NAT operation mode */
1407*4882a593Smuzhiyun 	uint8_t dmac[ETH_ALEN]; /* new destination MAC address */
1408*4882a593Smuzhiyun 	uint8_t smac[ETH_ALEN]; /* new source MAC address */
1409*4882a593Smuzhiyun 	uint16_t vlan;          /* VLAN Tag to insert */
1410*4882a593Smuzhiyun 
1411*4882a593Smuzhiyun 	u8 nat_lip[16];		/* local IP to use after NAT'ing */
1412*4882a593Smuzhiyun 	u8 nat_fip[16];		/* foreign IP to use after NAT'ing */
1413*4882a593Smuzhiyun 	u16 nat_lport;		/* local port to use after NAT'ing */
1414*4882a593Smuzhiyun 	u16 nat_fport;		/* foreign port to use after NAT'ing */
1415*4882a593Smuzhiyun 
1416*4882a593Smuzhiyun 	u32 tc_prio;		/* TC's filter priority index */
1417*4882a593Smuzhiyun 	u64 tc_cookie;		/* Unique cookie identifying TC rules */
1418*4882a593Smuzhiyun 
1419*4882a593Smuzhiyun 	/* reservation for future additions */
1420*4882a593Smuzhiyun 	u8 rsvd[12];
1421*4882a593Smuzhiyun 
1422*4882a593Smuzhiyun 	/* Filter rule value/mask pairs.
1423*4882a593Smuzhiyun 	 */
1424*4882a593Smuzhiyun 	struct ch_filter_tuple val;
1425*4882a593Smuzhiyun 	struct ch_filter_tuple mask;
1426*4882a593Smuzhiyun };
1427*4882a593Smuzhiyun 
1428*4882a593Smuzhiyun enum {
1429*4882a593Smuzhiyun 	FILTER_PASS = 0,        /* default */
1430*4882a593Smuzhiyun 	FILTER_DROP,
1431*4882a593Smuzhiyun 	FILTER_SWITCH
1432*4882a593Smuzhiyun };
1433*4882a593Smuzhiyun 
1434*4882a593Smuzhiyun enum {
1435*4882a593Smuzhiyun 	VLAN_NOCHANGE = 0,      /* default */
1436*4882a593Smuzhiyun 	VLAN_REMOVE,
1437*4882a593Smuzhiyun 	VLAN_INSERT,
1438*4882a593Smuzhiyun 	VLAN_REWRITE
1439*4882a593Smuzhiyun };
1440*4882a593Smuzhiyun 
1441*4882a593Smuzhiyun enum {
1442*4882a593Smuzhiyun 	NAT_MODE_NONE = 0,	/* No NAT performed */
1443*4882a593Smuzhiyun 	NAT_MODE_DIP,		/* NAT on Dst IP */
1444*4882a593Smuzhiyun 	NAT_MODE_DIP_DP,	/* NAT on Dst IP, Dst Port */
1445*4882a593Smuzhiyun 	NAT_MODE_DIP_DP_SIP,	/* NAT on Dst IP, Dst Port and Src IP */
1446*4882a593Smuzhiyun 	NAT_MODE_DIP_DP_SP,	/* NAT on Dst IP, Dst Port and Src Port */
1447*4882a593Smuzhiyun 	NAT_MODE_SIP_SP,	/* NAT on Src IP and Src Port */
1448*4882a593Smuzhiyun 	NAT_MODE_DIP_SIP_SP,	/* NAT on Dst IP, Src IP and Src Port */
1449*4882a593Smuzhiyun 	NAT_MODE_ALL		/* NAT on entire 4-tuple */
1450*4882a593Smuzhiyun };
1451*4882a593Smuzhiyun 
1452*4882a593Smuzhiyun #define CXGB4_FILTER_TYPE_MAX 2
1453*4882a593Smuzhiyun 
1454*4882a593Smuzhiyun /* Host shadow copy of ingress filter entry.  This is in host native format
1455*4882a593Smuzhiyun  * and doesn't match the ordering or bit order, etc. of the hardware of the
1456*4882a593Smuzhiyun  * firmware command.  The use of bit-field structure elements is purely to
1457*4882a593Smuzhiyun  * remind ourselves of the field size limitations and save memory in the case
1458*4882a593Smuzhiyun  * where the filter table is large.
1459*4882a593Smuzhiyun  */
1460*4882a593Smuzhiyun struct filter_entry {
1461*4882a593Smuzhiyun 	/* Administrative fields for filter. */
1462*4882a593Smuzhiyun 	u32 valid:1;            /* filter allocated and valid */
1463*4882a593Smuzhiyun 	u32 locked:1;           /* filter is administratively locked */
1464*4882a593Smuzhiyun 
1465*4882a593Smuzhiyun 	u32 pending:1;          /* filter action is pending firmware reply */
1466*4882a593Smuzhiyun 	struct filter_ctx *ctx; /* Caller's completion hook */
1467*4882a593Smuzhiyun 	struct l2t_entry *l2t;  /* Layer Two Table entry for dmac */
1468*4882a593Smuzhiyun 	struct smt_entry *smt;  /* Source Mac Table entry for smac */
1469*4882a593Smuzhiyun 	struct net_device *dev; /* Associated net device */
1470*4882a593Smuzhiyun 	u32 tid;                /* This will store the actual tid */
1471*4882a593Smuzhiyun 
1472*4882a593Smuzhiyun 	/* The filter itself.  Most of this is a straight copy of information
1473*4882a593Smuzhiyun 	 * provided by the extended ioctl().  Some fields are translated to
1474*4882a593Smuzhiyun 	 * internal forms -- for instance the Ingress Queue ID passed in from
1475*4882a593Smuzhiyun 	 * the ioctl() is translated into the Absolute Ingress Queue ID.
1476*4882a593Smuzhiyun 	 */
1477*4882a593Smuzhiyun 	struct ch_filter_specification fs;
1478*4882a593Smuzhiyun };
1479*4882a593Smuzhiyun 
is_offload(const struct adapter * adap)1480*4882a593Smuzhiyun static inline int is_offload(const struct adapter *adap)
1481*4882a593Smuzhiyun {
1482*4882a593Smuzhiyun 	return adap->params.offload;
1483*4882a593Smuzhiyun }
1484*4882a593Smuzhiyun 
is_hashfilter(const struct adapter * adap)1485*4882a593Smuzhiyun static inline int is_hashfilter(const struct adapter *adap)
1486*4882a593Smuzhiyun {
1487*4882a593Smuzhiyun 	return adap->params.hash_filter;
1488*4882a593Smuzhiyun }
1489*4882a593Smuzhiyun 
is_pci_uld(const struct adapter * adap)1490*4882a593Smuzhiyun static inline int is_pci_uld(const struct adapter *adap)
1491*4882a593Smuzhiyun {
1492*4882a593Smuzhiyun 	return adap->params.crypto;
1493*4882a593Smuzhiyun }
1494*4882a593Smuzhiyun 
is_uld(const struct adapter * adap)1495*4882a593Smuzhiyun static inline int is_uld(const struct adapter *adap)
1496*4882a593Smuzhiyun {
1497*4882a593Smuzhiyun 	return (adap->params.offload || adap->params.crypto);
1498*4882a593Smuzhiyun }
1499*4882a593Smuzhiyun 
is_ethofld(const struct adapter * adap)1500*4882a593Smuzhiyun static inline int is_ethofld(const struct adapter *adap)
1501*4882a593Smuzhiyun {
1502*4882a593Smuzhiyun 	return adap->params.ethofld;
1503*4882a593Smuzhiyun }
1504*4882a593Smuzhiyun 
t4_read_reg(struct adapter * adap,u32 reg_addr)1505*4882a593Smuzhiyun static inline u32 t4_read_reg(struct adapter *adap, u32 reg_addr)
1506*4882a593Smuzhiyun {
1507*4882a593Smuzhiyun 	return readl(adap->regs + reg_addr);
1508*4882a593Smuzhiyun }
1509*4882a593Smuzhiyun 
t4_write_reg(struct adapter * adap,u32 reg_addr,u32 val)1510*4882a593Smuzhiyun static inline void t4_write_reg(struct adapter *adap, u32 reg_addr, u32 val)
1511*4882a593Smuzhiyun {
1512*4882a593Smuzhiyun 	writel(val, adap->regs + reg_addr);
1513*4882a593Smuzhiyun }
1514*4882a593Smuzhiyun 
1515*4882a593Smuzhiyun #ifndef readq
readq(const volatile void __iomem * addr)1516*4882a593Smuzhiyun static inline u64 readq(const volatile void __iomem *addr)
1517*4882a593Smuzhiyun {
1518*4882a593Smuzhiyun 	return readl(addr) + ((u64)readl(addr + 4) << 32);
1519*4882a593Smuzhiyun }
1520*4882a593Smuzhiyun 
writeq(u64 val,volatile void __iomem * addr)1521*4882a593Smuzhiyun static inline void writeq(u64 val, volatile void __iomem *addr)
1522*4882a593Smuzhiyun {
1523*4882a593Smuzhiyun 	writel(val, addr);
1524*4882a593Smuzhiyun 	writel(val >> 32, addr + 4);
1525*4882a593Smuzhiyun }
1526*4882a593Smuzhiyun #endif
1527*4882a593Smuzhiyun 
t4_read_reg64(struct adapter * adap,u32 reg_addr)1528*4882a593Smuzhiyun static inline u64 t4_read_reg64(struct adapter *adap, u32 reg_addr)
1529*4882a593Smuzhiyun {
1530*4882a593Smuzhiyun 	return readq(adap->regs + reg_addr);
1531*4882a593Smuzhiyun }
1532*4882a593Smuzhiyun 
t4_write_reg64(struct adapter * adap,u32 reg_addr,u64 val)1533*4882a593Smuzhiyun static inline void t4_write_reg64(struct adapter *adap, u32 reg_addr, u64 val)
1534*4882a593Smuzhiyun {
1535*4882a593Smuzhiyun 	writeq(val, adap->regs + reg_addr);
1536*4882a593Smuzhiyun }
1537*4882a593Smuzhiyun 
1538*4882a593Smuzhiyun /**
1539*4882a593Smuzhiyun  * t4_set_hw_addr - store a port's MAC address in SW
1540*4882a593Smuzhiyun  * @adapter: the adapter
1541*4882a593Smuzhiyun  * @port_idx: the port index
1542*4882a593Smuzhiyun  * @hw_addr: the Ethernet address
1543*4882a593Smuzhiyun  *
1544*4882a593Smuzhiyun  * Store the Ethernet address of the given port in SW.  Called by the common
1545*4882a593Smuzhiyun  * code when it retrieves a port's Ethernet address from EEPROM.
1546*4882a593Smuzhiyun  */
t4_set_hw_addr(struct adapter * adapter,int port_idx,u8 hw_addr[])1547*4882a593Smuzhiyun static inline void t4_set_hw_addr(struct adapter *adapter, int port_idx,
1548*4882a593Smuzhiyun 				  u8 hw_addr[])
1549*4882a593Smuzhiyun {
1550*4882a593Smuzhiyun 	ether_addr_copy(adapter->port[port_idx]->dev_addr, hw_addr);
1551*4882a593Smuzhiyun 	ether_addr_copy(adapter->port[port_idx]->perm_addr, hw_addr);
1552*4882a593Smuzhiyun }
1553*4882a593Smuzhiyun 
1554*4882a593Smuzhiyun /**
1555*4882a593Smuzhiyun  * netdev2pinfo - return the port_info structure associated with a net_device
1556*4882a593Smuzhiyun  * @dev: the netdev
1557*4882a593Smuzhiyun  *
1558*4882a593Smuzhiyun  * Return the struct port_info associated with a net_device
1559*4882a593Smuzhiyun  */
netdev2pinfo(const struct net_device * dev)1560*4882a593Smuzhiyun static inline struct port_info *netdev2pinfo(const struct net_device *dev)
1561*4882a593Smuzhiyun {
1562*4882a593Smuzhiyun 	return netdev_priv(dev);
1563*4882a593Smuzhiyun }
1564*4882a593Smuzhiyun 
1565*4882a593Smuzhiyun /**
1566*4882a593Smuzhiyun  * adap2pinfo - return the port_info of a port
1567*4882a593Smuzhiyun  * @adap: the adapter
1568*4882a593Smuzhiyun  * @idx: the port index
1569*4882a593Smuzhiyun  *
1570*4882a593Smuzhiyun  * Return the port_info structure for the port of the given index.
1571*4882a593Smuzhiyun  */
adap2pinfo(struct adapter * adap,int idx)1572*4882a593Smuzhiyun static inline struct port_info *adap2pinfo(struct adapter *adap, int idx)
1573*4882a593Smuzhiyun {
1574*4882a593Smuzhiyun 	return netdev_priv(adap->port[idx]);
1575*4882a593Smuzhiyun }
1576*4882a593Smuzhiyun 
1577*4882a593Smuzhiyun /**
1578*4882a593Smuzhiyun  * netdev2adap - return the adapter structure associated with a net_device
1579*4882a593Smuzhiyun  * @dev: the netdev
1580*4882a593Smuzhiyun  *
1581*4882a593Smuzhiyun  * Return the struct adapter associated with a net_device
1582*4882a593Smuzhiyun  */
netdev2adap(const struct net_device * dev)1583*4882a593Smuzhiyun static inline struct adapter *netdev2adap(const struct net_device *dev)
1584*4882a593Smuzhiyun {
1585*4882a593Smuzhiyun 	return netdev2pinfo(dev)->adapter;
1586*4882a593Smuzhiyun }
1587*4882a593Smuzhiyun 
1588*4882a593Smuzhiyun /* Return a version number to identify the type of adapter.  The scheme is:
1589*4882a593Smuzhiyun  * - bits 0..9: chip version
1590*4882a593Smuzhiyun  * - bits 10..15: chip revision
1591*4882a593Smuzhiyun  * - bits 16..23: register dump version
1592*4882a593Smuzhiyun  */
mk_adap_vers(struct adapter * ap)1593*4882a593Smuzhiyun static inline unsigned int mk_adap_vers(struct adapter *ap)
1594*4882a593Smuzhiyun {
1595*4882a593Smuzhiyun 	return CHELSIO_CHIP_VERSION(ap->params.chip) |
1596*4882a593Smuzhiyun 		(CHELSIO_CHIP_RELEASE(ap->params.chip) << 10) | (1 << 16);
1597*4882a593Smuzhiyun }
1598*4882a593Smuzhiyun 
1599*4882a593Smuzhiyun /* Return a queue's interrupt hold-off time in us.  0 means no timer. */
qtimer_val(const struct adapter * adap,const struct sge_rspq * q)1600*4882a593Smuzhiyun static inline unsigned int qtimer_val(const struct adapter *adap,
1601*4882a593Smuzhiyun 				      const struct sge_rspq *q)
1602*4882a593Smuzhiyun {
1603*4882a593Smuzhiyun 	unsigned int idx = q->intr_params >> 1;
1604*4882a593Smuzhiyun 
1605*4882a593Smuzhiyun 	return idx < SGE_NTIMERS ? adap->sge.timer_val[idx] : 0;
1606*4882a593Smuzhiyun }
1607*4882a593Smuzhiyun 
1608*4882a593Smuzhiyun /* driver name used for ethtool_drvinfo */
1609*4882a593Smuzhiyun extern char cxgb4_driver_name[];
1610*4882a593Smuzhiyun 
1611*4882a593Smuzhiyun void t4_os_portmod_changed(struct adapter *adap, int port_id);
1612*4882a593Smuzhiyun void t4_os_link_changed(struct adapter *adap, int port_id, int link_stat);
1613*4882a593Smuzhiyun 
1614*4882a593Smuzhiyun void t4_free_sge_resources(struct adapter *adap);
1615*4882a593Smuzhiyun void t4_free_ofld_rxqs(struct adapter *adap, int n, struct sge_ofld_rxq *q);
1616*4882a593Smuzhiyun irq_handler_t t4_intr_handler(struct adapter *adap);
1617*4882a593Smuzhiyun netdev_tx_t t4_start_xmit(struct sk_buff *skb, struct net_device *dev);
1618*4882a593Smuzhiyun int cxgb4_selftest_lb_pkt(struct net_device *netdev);
1619*4882a593Smuzhiyun int t4_ethrx_handler(struct sge_rspq *q, const __be64 *rsp,
1620*4882a593Smuzhiyun 		     const struct pkt_gl *gl);
1621*4882a593Smuzhiyun int t4_mgmt_tx(struct adapter *adap, struct sk_buff *skb);
1622*4882a593Smuzhiyun int t4_ofld_send(struct adapter *adap, struct sk_buff *skb);
1623*4882a593Smuzhiyun int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
1624*4882a593Smuzhiyun 		     struct net_device *dev, int intr_idx,
1625*4882a593Smuzhiyun 		     struct sge_fl *fl, rspq_handler_t hnd,
1626*4882a593Smuzhiyun 		     rspq_flush_handler_t flush_handler, int cong);
1627*4882a593Smuzhiyun int t4_sge_alloc_eth_txq(struct adapter *adap, struct sge_eth_txq *txq,
1628*4882a593Smuzhiyun 			 struct net_device *dev, struct netdev_queue *netdevq,
1629*4882a593Smuzhiyun 			 unsigned int iqid, u8 dbqt);
1630*4882a593Smuzhiyun int t4_sge_alloc_ctrl_txq(struct adapter *adap, struct sge_ctrl_txq *txq,
1631*4882a593Smuzhiyun 			  struct net_device *dev, unsigned int iqid,
1632*4882a593Smuzhiyun 			  unsigned int cmplqid);
1633*4882a593Smuzhiyun int t4_sge_mod_ctrl_txq(struct adapter *adap, unsigned int eqid,
1634*4882a593Smuzhiyun 			unsigned int cmplqid);
1635*4882a593Smuzhiyun int t4_sge_alloc_uld_txq(struct adapter *adap, struct sge_uld_txq *txq,
1636*4882a593Smuzhiyun 			 struct net_device *dev, unsigned int iqid,
1637*4882a593Smuzhiyun 			 unsigned int uld_type);
1638*4882a593Smuzhiyun int t4_sge_alloc_ethofld_txq(struct adapter *adap, struct sge_eohw_txq *txq,
1639*4882a593Smuzhiyun 			     struct net_device *dev, u32 iqid);
1640*4882a593Smuzhiyun void t4_sge_free_ethofld_txq(struct adapter *adap, struct sge_eohw_txq *txq);
1641*4882a593Smuzhiyun irqreturn_t t4_sge_intr_msix(int irq, void *cookie);
1642*4882a593Smuzhiyun int t4_sge_init(struct adapter *adap);
1643*4882a593Smuzhiyun void t4_sge_start(struct adapter *adap);
1644*4882a593Smuzhiyun void t4_sge_stop(struct adapter *adap);
1645*4882a593Smuzhiyun int t4_sge_eth_txq_egress_update(struct adapter *adap, struct sge_eth_txq *q,
1646*4882a593Smuzhiyun 				 int maxreclaim);
1647*4882a593Smuzhiyun void cxgb4_set_ethtool_ops(struct net_device *netdev);
1648*4882a593Smuzhiyun int cxgb4_write_rss(const struct port_info *pi, const u16 *queues);
1649*4882a593Smuzhiyun enum cpl_tx_tnl_lso_type cxgb_encap_offload_supported(struct sk_buff *skb);
1650*4882a593Smuzhiyun extern int dbfifo_int_thresh;
1651*4882a593Smuzhiyun 
1652*4882a593Smuzhiyun #define for_each_port(adapter, iter) \
1653*4882a593Smuzhiyun 	for (iter = 0; iter < (adapter)->params.nports; ++iter)
1654*4882a593Smuzhiyun 
is_bypass(struct adapter * adap)1655*4882a593Smuzhiyun static inline int is_bypass(struct adapter *adap)
1656*4882a593Smuzhiyun {
1657*4882a593Smuzhiyun 	return adap->params.bypass;
1658*4882a593Smuzhiyun }
1659*4882a593Smuzhiyun 
is_bypass_device(int device)1660*4882a593Smuzhiyun static inline int is_bypass_device(int device)
1661*4882a593Smuzhiyun {
1662*4882a593Smuzhiyun 	/* this should be set based upon device capabilities */
1663*4882a593Smuzhiyun 	switch (device) {
1664*4882a593Smuzhiyun 	case 0x440b:
1665*4882a593Smuzhiyun 	case 0x440c:
1666*4882a593Smuzhiyun 		return 1;
1667*4882a593Smuzhiyun 	default:
1668*4882a593Smuzhiyun 		return 0;
1669*4882a593Smuzhiyun 	}
1670*4882a593Smuzhiyun }
1671*4882a593Smuzhiyun 
is_10gbt_device(int device)1672*4882a593Smuzhiyun static inline int is_10gbt_device(int device)
1673*4882a593Smuzhiyun {
1674*4882a593Smuzhiyun 	/* this should be set based upon device capabilities */
1675*4882a593Smuzhiyun 	switch (device) {
1676*4882a593Smuzhiyun 	case 0x4409:
1677*4882a593Smuzhiyun 	case 0x4486:
1678*4882a593Smuzhiyun 		return 1;
1679*4882a593Smuzhiyun 
1680*4882a593Smuzhiyun 	default:
1681*4882a593Smuzhiyun 		return 0;
1682*4882a593Smuzhiyun 	}
1683*4882a593Smuzhiyun }
1684*4882a593Smuzhiyun 
core_ticks_per_usec(const struct adapter * adap)1685*4882a593Smuzhiyun static inline unsigned int core_ticks_per_usec(const struct adapter *adap)
1686*4882a593Smuzhiyun {
1687*4882a593Smuzhiyun 	return adap->params.vpd.cclk / 1000;
1688*4882a593Smuzhiyun }
1689*4882a593Smuzhiyun 
us_to_core_ticks(const struct adapter * adap,unsigned int us)1690*4882a593Smuzhiyun static inline unsigned int us_to_core_ticks(const struct adapter *adap,
1691*4882a593Smuzhiyun 					    unsigned int us)
1692*4882a593Smuzhiyun {
1693*4882a593Smuzhiyun 	return (us * adap->params.vpd.cclk) / 1000;
1694*4882a593Smuzhiyun }
1695*4882a593Smuzhiyun 
core_ticks_to_us(const struct adapter * adapter,unsigned int ticks)1696*4882a593Smuzhiyun static inline unsigned int core_ticks_to_us(const struct adapter *adapter,
1697*4882a593Smuzhiyun 					    unsigned int ticks)
1698*4882a593Smuzhiyun {
1699*4882a593Smuzhiyun 	/* add Core Clock / 2 to round ticks to nearest uS */
1700*4882a593Smuzhiyun 	return ((ticks * 1000 + adapter->params.vpd.cclk/2) /
1701*4882a593Smuzhiyun 		adapter->params.vpd.cclk);
1702*4882a593Smuzhiyun }
1703*4882a593Smuzhiyun 
dack_ticks_to_usec(const struct adapter * adap,unsigned int ticks)1704*4882a593Smuzhiyun static inline unsigned int dack_ticks_to_usec(const struct adapter *adap,
1705*4882a593Smuzhiyun 					      unsigned int ticks)
1706*4882a593Smuzhiyun {
1707*4882a593Smuzhiyun 	return (ticks << adap->params.tp.dack_re) / core_ticks_per_usec(adap);
1708*4882a593Smuzhiyun }
1709*4882a593Smuzhiyun 
1710*4882a593Smuzhiyun void t4_set_reg_field(struct adapter *adap, unsigned int addr, u32 mask,
1711*4882a593Smuzhiyun 		      u32 val);
1712*4882a593Smuzhiyun 
1713*4882a593Smuzhiyun int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox, const void *cmd,
1714*4882a593Smuzhiyun 			    int size, void *rpl, bool sleep_ok, int timeout);
1715*4882a593Smuzhiyun int t4_wr_mbox_meat(struct adapter *adap, int mbox, const void *cmd, int size,
1716*4882a593Smuzhiyun 		    void *rpl, bool sleep_ok);
1717*4882a593Smuzhiyun 
t4_wr_mbox_timeout(struct adapter * adap,int mbox,const void * cmd,int size,void * rpl,int timeout)1718*4882a593Smuzhiyun static inline int t4_wr_mbox_timeout(struct adapter *adap, int mbox,
1719*4882a593Smuzhiyun 				     const void *cmd, int size, void *rpl,
1720*4882a593Smuzhiyun 				     int timeout)
1721*4882a593Smuzhiyun {
1722*4882a593Smuzhiyun 	return t4_wr_mbox_meat_timeout(adap, mbox, cmd, size, rpl, true,
1723*4882a593Smuzhiyun 				       timeout);
1724*4882a593Smuzhiyun }
1725*4882a593Smuzhiyun 
t4_wr_mbox(struct adapter * adap,int mbox,const void * cmd,int size,void * rpl)1726*4882a593Smuzhiyun static inline int t4_wr_mbox(struct adapter *adap, int mbox, const void *cmd,
1727*4882a593Smuzhiyun 			     int size, void *rpl)
1728*4882a593Smuzhiyun {
1729*4882a593Smuzhiyun 	return t4_wr_mbox_meat(adap, mbox, cmd, size, rpl, true);
1730*4882a593Smuzhiyun }
1731*4882a593Smuzhiyun 
t4_wr_mbox_ns(struct adapter * adap,int mbox,const void * cmd,int size,void * rpl)1732*4882a593Smuzhiyun static inline int t4_wr_mbox_ns(struct adapter *adap, int mbox, const void *cmd,
1733*4882a593Smuzhiyun 				int size, void *rpl)
1734*4882a593Smuzhiyun {
1735*4882a593Smuzhiyun 	return t4_wr_mbox_meat(adap, mbox, cmd, size, rpl, false);
1736*4882a593Smuzhiyun }
1737*4882a593Smuzhiyun 
1738*4882a593Smuzhiyun /**
1739*4882a593Smuzhiyun  *	hash_mac_addr - return the hash value of a MAC address
1740*4882a593Smuzhiyun  *	@addr: the 48-bit Ethernet MAC address
1741*4882a593Smuzhiyun  *
1742*4882a593Smuzhiyun  *	Hashes a MAC address according to the hash function used by HW inexact
1743*4882a593Smuzhiyun  *	(hash) address matching.
1744*4882a593Smuzhiyun  */
hash_mac_addr(const u8 * addr)1745*4882a593Smuzhiyun static inline int hash_mac_addr(const u8 *addr)
1746*4882a593Smuzhiyun {
1747*4882a593Smuzhiyun 	u32 a = ((u32)addr[0] << 16) | ((u32)addr[1] << 8) | addr[2];
1748*4882a593Smuzhiyun 	u32 b = ((u32)addr[3] << 16) | ((u32)addr[4] << 8) | addr[5];
1749*4882a593Smuzhiyun 
1750*4882a593Smuzhiyun 	a ^= b;
1751*4882a593Smuzhiyun 	a ^= (a >> 12);
1752*4882a593Smuzhiyun 	a ^= (a >> 6);
1753*4882a593Smuzhiyun 	return a & 0x3f;
1754*4882a593Smuzhiyun }
1755*4882a593Smuzhiyun 
1756*4882a593Smuzhiyun int cxgb4_set_rspq_intr_params(struct sge_rspq *q, unsigned int us,
1757*4882a593Smuzhiyun 			       unsigned int cnt);
init_rspq(struct adapter * adap,struct sge_rspq * q,unsigned int us,unsigned int cnt,unsigned int size,unsigned int iqe_size)1758*4882a593Smuzhiyun static inline void init_rspq(struct adapter *adap, struct sge_rspq *q,
1759*4882a593Smuzhiyun 			     unsigned int us, unsigned int cnt,
1760*4882a593Smuzhiyun 			     unsigned int size, unsigned int iqe_size)
1761*4882a593Smuzhiyun {
1762*4882a593Smuzhiyun 	q->adap = adap;
1763*4882a593Smuzhiyun 	cxgb4_set_rspq_intr_params(q, us, cnt);
1764*4882a593Smuzhiyun 	q->iqe_len = iqe_size;
1765*4882a593Smuzhiyun 	q->size = size;
1766*4882a593Smuzhiyun }
1767*4882a593Smuzhiyun 
1768*4882a593Smuzhiyun /**
1769*4882a593Smuzhiyun  *     t4_is_inserted_mod_type - is a plugged in Firmware Module Type
1770*4882a593Smuzhiyun  *     @fw_mod_type: the Firmware Mofule Type
1771*4882a593Smuzhiyun  *
1772*4882a593Smuzhiyun  *     Return whether the Firmware Module Type represents a real Transceiver
1773*4882a593Smuzhiyun  *     Module/Cable Module Type which has been inserted.
1774*4882a593Smuzhiyun  */
t4_is_inserted_mod_type(unsigned int fw_mod_type)1775*4882a593Smuzhiyun static inline bool t4_is_inserted_mod_type(unsigned int fw_mod_type)
1776*4882a593Smuzhiyun {
1777*4882a593Smuzhiyun 	return (fw_mod_type != FW_PORT_MOD_TYPE_NONE &&
1778*4882a593Smuzhiyun 		fw_mod_type != FW_PORT_MOD_TYPE_NOTSUPPORTED &&
1779*4882a593Smuzhiyun 		fw_mod_type != FW_PORT_MOD_TYPE_UNKNOWN &&
1780*4882a593Smuzhiyun 		fw_mod_type != FW_PORT_MOD_TYPE_ERROR);
1781*4882a593Smuzhiyun }
1782*4882a593Smuzhiyun 
1783*4882a593Smuzhiyun void t4_write_indirect(struct adapter *adap, unsigned int addr_reg,
1784*4882a593Smuzhiyun 		       unsigned int data_reg, const u32 *vals,
1785*4882a593Smuzhiyun 		       unsigned int nregs, unsigned int start_idx);
1786*4882a593Smuzhiyun void t4_read_indirect(struct adapter *adap, unsigned int addr_reg,
1787*4882a593Smuzhiyun 		      unsigned int data_reg, u32 *vals, unsigned int nregs,
1788*4882a593Smuzhiyun 		      unsigned int start_idx);
1789*4882a593Smuzhiyun void t4_hw_pci_read_cfg4(struct adapter *adapter, int reg, u32 *val);
1790*4882a593Smuzhiyun 
1791*4882a593Smuzhiyun struct fw_filter_wr;
1792*4882a593Smuzhiyun 
1793*4882a593Smuzhiyun void t4_intr_enable(struct adapter *adapter);
1794*4882a593Smuzhiyun void t4_intr_disable(struct adapter *adapter);
1795*4882a593Smuzhiyun int t4_slow_intr_handler(struct adapter *adapter);
1796*4882a593Smuzhiyun 
1797*4882a593Smuzhiyun int t4_wait_dev_ready(void __iomem *regs);
1798*4882a593Smuzhiyun 
1799*4882a593Smuzhiyun fw_port_cap32_t t4_link_acaps(struct adapter *adapter, unsigned int port,
1800*4882a593Smuzhiyun 			      struct link_config *lc);
1801*4882a593Smuzhiyun int t4_link_l1cfg_core(struct adapter *adap, unsigned int mbox,
1802*4882a593Smuzhiyun 		       unsigned int port, struct link_config *lc,
1803*4882a593Smuzhiyun 		       u8 sleep_ok, int timeout);
1804*4882a593Smuzhiyun 
t4_link_l1cfg(struct adapter * adapter,unsigned int mbox,unsigned int port,struct link_config * lc)1805*4882a593Smuzhiyun static inline int t4_link_l1cfg(struct adapter *adapter, unsigned int mbox,
1806*4882a593Smuzhiyun 				unsigned int port, struct link_config *lc)
1807*4882a593Smuzhiyun {
1808*4882a593Smuzhiyun 	return t4_link_l1cfg_core(adapter, mbox, port, lc,
1809*4882a593Smuzhiyun 				  true, FW_CMD_MAX_TIMEOUT);
1810*4882a593Smuzhiyun }
1811*4882a593Smuzhiyun 
t4_link_l1cfg_ns(struct adapter * adapter,unsigned int mbox,unsigned int port,struct link_config * lc)1812*4882a593Smuzhiyun static inline int t4_link_l1cfg_ns(struct adapter *adapter, unsigned int mbox,
1813*4882a593Smuzhiyun 				   unsigned int port, struct link_config *lc)
1814*4882a593Smuzhiyun {
1815*4882a593Smuzhiyun 	return t4_link_l1cfg_core(adapter, mbox, port, lc,
1816*4882a593Smuzhiyun 				  false, FW_CMD_MAX_TIMEOUT);
1817*4882a593Smuzhiyun }
1818*4882a593Smuzhiyun 
1819*4882a593Smuzhiyun int t4_restart_aneg(struct adapter *adap, unsigned int mbox, unsigned int port);
1820*4882a593Smuzhiyun 
1821*4882a593Smuzhiyun u32 t4_read_pcie_cfg4(struct adapter *adap, int reg);
1822*4882a593Smuzhiyun u32 t4_get_util_window(struct adapter *adap);
1823*4882a593Smuzhiyun void t4_setup_memwin(struct adapter *adap, u32 memwin_base, u32 window);
1824*4882a593Smuzhiyun 
1825*4882a593Smuzhiyun int t4_memory_rw_init(struct adapter *adap, int win, int mtype, u32 *mem_off,
1826*4882a593Smuzhiyun 		      u32 *mem_base, u32 *mem_aperture);
1827*4882a593Smuzhiyun void t4_memory_update_win(struct adapter *adap, int win, u32 addr);
1828*4882a593Smuzhiyun void t4_memory_rw_residual(struct adapter *adap, u32 off, u32 addr, u8 *buf,
1829*4882a593Smuzhiyun 			   int dir);
1830*4882a593Smuzhiyun #define T4_MEMORY_WRITE	0
1831*4882a593Smuzhiyun #define T4_MEMORY_READ	1
1832*4882a593Smuzhiyun int t4_memory_rw(struct adapter *adap, int win, int mtype, u32 addr, u32 len,
1833*4882a593Smuzhiyun 		 void *buf, int dir);
t4_memory_write(struct adapter * adap,int mtype,u32 addr,u32 len,__be32 * buf)1834*4882a593Smuzhiyun static inline int t4_memory_write(struct adapter *adap, int mtype, u32 addr,
1835*4882a593Smuzhiyun 				  u32 len, __be32 *buf)
1836*4882a593Smuzhiyun {
1837*4882a593Smuzhiyun 	return t4_memory_rw(adap, 0, mtype, addr, len, buf, 0);
1838*4882a593Smuzhiyun }
1839*4882a593Smuzhiyun 
1840*4882a593Smuzhiyun unsigned int t4_get_regs_len(struct adapter *adapter);
1841*4882a593Smuzhiyun void t4_get_regs(struct adapter *adap, void *buf, size_t buf_size);
1842*4882a593Smuzhiyun 
1843*4882a593Smuzhiyun int t4_eeprom_ptov(unsigned int phys_addr, unsigned int fn, unsigned int sz);
1844*4882a593Smuzhiyun int t4_seeprom_wp(struct adapter *adapter, bool enable);
1845*4882a593Smuzhiyun int t4_get_raw_vpd_params(struct adapter *adapter, struct vpd_params *p);
1846*4882a593Smuzhiyun int t4_get_vpd_params(struct adapter *adapter, struct vpd_params *p);
1847*4882a593Smuzhiyun int t4_get_pfres(struct adapter *adapter);
1848*4882a593Smuzhiyun int t4_read_flash(struct adapter *adapter, unsigned int addr,
1849*4882a593Smuzhiyun 		  unsigned int nwords, u32 *data, int byte_oriented);
1850*4882a593Smuzhiyun int t4_load_fw(struct adapter *adapter, const u8 *fw_data, unsigned int size);
1851*4882a593Smuzhiyun int t4_load_phy_fw(struct adapter *adap, int win,
1852*4882a593Smuzhiyun 		   int (*phy_fw_version)(const u8 *, size_t),
1853*4882a593Smuzhiyun 		   const u8 *phy_fw_data, size_t phy_fw_size);
1854*4882a593Smuzhiyun int t4_phy_fw_ver(struct adapter *adap, int *phy_fw_ver);
1855*4882a593Smuzhiyun int t4_fwcache(struct adapter *adap, enum fw_params_param_dev_fwcache op);
1856*4882a593Smuzhiyun int t4_fw_upgrade(struct adapter *adap, unsigned int mbox,
1857*4882a593Smuzhiyun 		  const u8 *fw_data, unsigned int size, int force);
1858*4882a593Smuzhiyun int t4_fl_pkt_align(struct adapter *adap);
1859*4882a593Smuzhiyun unsigned int t4_flash_cfg_addr(struct adapter *adapter);
1860*4882a593Smuzhiyun int t4_check_fw_version(struct adapter *adap);
1861*4882a593Smuzhiyun int t4_load_cfg(struct adapter *adapter, const u8 *cfg_data, unsigned int size);
1862*4882a593Smuzhiyun int t4_get_fw_version(struct adapter *adapter, u32 *vers);
1863*4882a593Smuzhiyun int t4_get_bs_version(struct adapter *adapter, u32 *vers);
1864*4882a593Smuzhiyun int t4_get_tp_version(struct adapter *adapter, u32 *vers);
1865*4882a593Smuzhiyun int t4_get_exprom_version(struct adapter *adapter, u32 *vers);
1866*4882a593Smuzhiyun int t4_get_scfg_version(struct adapter *adapter, u32 *vers);
1867*4882a593Smuzhiyun int t4_get_vpd_version(struct adapter *adapter, u32 *vers);
1868*4882a593Smuzhiyun int t4_get_version_info(struct adapter *adapter);
1869*4882a593Smuzhiyun void t4_dump_version_info(struct adapter *adapter);
1870*4882a593Smuzhiyun int t4_prep_fw(struct adapter *adap, struct fw_info *fw_info,
1871*4882a593Smuzhiyun 	       const u8 *fw_data, unsigned int fw_size,
1872*4882a593Smuzhiyun 	       struct fw_hdr *card_fw, enum dev_state state, int *reset);
1873*4882a593Smuzhiyun int t4_prep_adapter(struct adapter *adapter);
1874*4882a593Smuzhiyun int t4_shutdown_adapter(struct adapter *adapter);
1875*4882a593Smuzhiyun 
1876*4882a593Smuzhiyun enum t4_bar2_qtype { T4_BAR2_QTYPE_EGRESS, T4_BAR2_QTYPE_INGRESS };
1877*4882a593Smuzhiyun int t4_bar2_sge_qregs(struct adapter *adapter,
1878*4882a593Smuzhiyun 		      unsigned int qid,
1879*4882a593Smuzhiyun 		      enum t4_bar2_qtype qtype,
1880*4882a593Smuzhiyun 		      int user,
1881*4882a593Smuzhiyun 		      u64 *pbar2_qoffset,
1882*4882a593Smuzhiyun 		      unsigned int *pbar2_qid);
1883*4882a593Smuzhiyun 
1884*4882a593Smuzhiyun unsigned int qtimer_val(const struct adapter *adap,
1885*4882a593Smuzhiyun 			const struct sge_rspq *q);
1886*4882a593Smuzhiyun 
1887*4882a593Smuzhiyun int t4_init_devlog_params(struct adapter *adapter);
1888*4882a593Smuzhiyun int t4_init_sge_params(struct adapter *adapter);
1889*4882a593Smuzhiyun int t4_init_tp_params(struct adapter *adap, bool sleep_ok);
1890*4882a593Smuzhiyun int t4_filter_field_shift(const struct adapter *adap, int filter_sel);
1891*4882a593Smuzhiyun int t4_init_rss_mode(struct adapter *adap, int mbox);
1892*4882a593Smuzhiyun int t4_init_portinfo(struct port_info *pi, int mbox,
1893*4882a593Smuzhiyun 		     int port, int pf, int vf, u8 mac[]);
1894*4882a593Smuzhiyun int t4_port_init(struct adapter *adap, int mbox, int pf, int vf);
1895*4882a593Smuzhiyun int t4_init_port_mirror(struct port_info *pi, u8 mbox, u8 port, u8 pf, u8 vf,
1896*4882a593Smuzhiyun 			u16 *mirror_viid);
1897*4882a593Smuzhiyun void t4_fatal_err(struct adapter *adapter);
1898*4882a593Smuzhiyun unsigned int t4_chip_rss_size(struct adapter *adapter);
1899*4882a593Smuzhiyun int t4_config_rss_range(struct adapter *adapter, int mbox, unsigned int viid,
1900*4882a593Smuzhiyun 			int start, int n, const u16 *rspq, unsigned int nrspq);
1901*4882a593Smuzhiyun int t4_config_glbl_rss(struct adapter *adapter, int mbox, unsigned int mode,
1902*4882a593Smuzhiyun 		       unsigned int flags);
1903*4882a593Smuzhiyun int t4_config_vi_rss(struct adapter *adapter, int mbox, unsigned int viid,
1904*4882a593Smuzhiyun 		     unsigned int flags, unsigned int defq);
1905*4882a593Smuzhiyun int t4_read_rss(struct adapter *adapter, u16 *entries);
1906*4882a593Smuzhiyun void t4_read_rss_key(struct adapter *adapter, u32 *key, bool sleep_ok);
1907*4882a593Smuzhiyun void t4_write_rss_key(struct adapter *adap, const u32 *key, int idx,
1908*4882a593Smuzhiyun 		      bool sleep_ok);
1909*4882a593Smuzhiyun void t4_read_rss_pf_config(struct adapter *adapter, unsigned int index,
1910*4882a593Smuzhiyun 			   u32 *valp, bool sleep_ok);
1911*4882a593Smuzhiyun void t4_read_rss_vf_config(struct adapter *adapter, unsigned int index,
1912*4882a593Smuzhiyun 			   u32 *vfl, u32 *vfh, bool sleep_ok);
1913*4882a593Smuzhiyun u32 t4_read_rss_pf_map(struct adapter *adapter, bool sleep_ok);
1914*4882a593Smuzhiyun u32 t4_read_rss_pf_mask(struct adapter *adapter, bool sleep_ok);
1915*4882a593Smuzhiyun 
1916*4882a593Smuzhiyun unsigned int t4_get_mps_bg_map(struct adapter *adapter, int pidx);
1917*4882a593Smuzhiyun unsigned int t4_get_tp_ch_map(struct adapter *adapter, int pidx);
1918*4882a593Smuzhiyun void t4_pmtx_get_stats(struct adapter *adap, u32 cnt[], u64 cycles[]);
1919*4882a593Smuzhiyun void t4_pmrx_get_stats(struct adapter *adap, u32 cnt[], u64 cycles[]);
1920*4882a593Smuzhiyun int t4_read_cim_ibq(struct adapter *adap, unsigned int qid, u32 *data,
1921*4882a593Smuzhiyun 		    size_t n);
1922*4882a593Smuzhiyun int t4_read_cim_obq(struct adapter *adap, unsigned int qid, u32 *data,
1923*4882a593Smuzhiyun 		    size_t n);
1924*4882a593Smuzhiyun int t4_cim_read(struct adapter *adap, unsigned int addr, unsigned int n,
1925*4882a593Smuzhiyun 		unsigned int *valp);
1926*4882a593Smuzhiyun int t4_cim_write(struct adapter *adap, unsigned int addr, unsigned int n,
1927*4882a593Smuzhiyun 		 const unsigned int *valp);
1928*4882a593Smuzhiyun int t4_cim_read_la(struct adapter *adap, u32 *la_buf, unsigned int *wrptr);
1929*4882a593Smuzhiyun void t4_cim_read_pif_la(struct adapter *adap, u32 *pif_req, u32 *pif_rsp,
1930*4882a593Smuzhiyun 			unsigned int *pif_req_wrptr,
1931*4882a593Smuzhiyun 			unsigned int *pif_rsp_wrptr);
1932*4882a593Smuzhiyun void t4_cim_read_ma_la(struct adapter *adap, u32 *ma_req, u32 *ma_rsp);
1933*4882a593Smuzhiyun void t4_read_cimq_cfg(struct adapter *adap, u16 *base, u16 *size, u16 *thres);
1934*4882a593Smuzhiyun const char *t4_get_port_type_description(enum fw_port_type port_type);
1935*4882a593Smuzhiyun void t4_get_port_stats(struct adapter *adap, int idx, struct port_stats *p);
1936*4882a593Smuzhiyun void t4_get_port_stats_offset(struct adapter *adap, int idx,
1937*4882a593Smuzhiyun 			      struct port_stats *stats,
1938*4882a593Smuzhiyun 			      struct port_stats *offset);
1939*4882a593Smuzhiyun void t4_get_lb_stats(struct adapter *adap, int idx, struct lb_port_stats *p);
1940*4882a593Smuzhiyun void t4_read_mtu_tbl(struct adapter *adap, u16 *mtus, u8 *mtu_log);
1941*4882a593Smuzhiyun void t4_read_cong_tbl(struct adapter *adap, u16 incr[NMTUS][NCCTRL_WIN]);
1942*4882a593Smuzhiyun void t4_tp_wr_bits_indirect(struct adapter *adap, unsigned int addr,
1943*4882a593Smuzhiyun 			    unsigned int mask, unsigned int val);
1944*4882a593Smuzhiyun void t4_tp_read_la(struct adapter *adap, u64 *la_buf, unsigned int *wrptr);
1945*4882a593Smuzhiyun void t4_tp_get_err_stats(struct adapter *adap, struct tp_err_stats *st,
1946*4882a593Smuzhiyun 			 bool sleep_ok);
1947*4882a593Smuzhiyun void t4_tp_get_cpl_stats(struct adapter *adap, struct tp_cpl_stats *st,
1948*4882a593Smuzhiyun 			 bool sleep_ok);
1949*4882a593Smuzhiyun void t4_tp_get_rdma_stats(struct adapter *adap, struct tp_rdma_stats *st,
1950*4882a593Smuzhiyun 			  bool sleep_ok);
1951*4882a593Smuzhiyun void t4_get_usm_stats(struct adapter *adap, struct tp_usm_stats *st,
1952*4882a593Smuzhiyun 		      bool sleep_ok);
1953*4882a593Smuzhiyun void t4_tp_get_tcp_stats(struct adapter *adap, struct tp_tcp_stats *v4,
1954*4882a593Smuzhiyun 			 struct tp_tcp_stats *v6, bool sleep_ok);
1955*4882a593Smuzhiyun void t4_get_fcoe_stats(struct adapter *adap, unsigned int idx,
1956*4882a593Smuzhiyun 		       struct tp_fcoe_stats *st, bool sleep_ok);
1957*4882a593Smuzhiyun void t4_load_mtus(struct adapter *adap, const unsigned short *mtus,
1958*4882a593Smuzhiyun 		  const unsigned short *alpha, const unsigned short *beta);
1959*4882a593Smuzhiyun 
1960*4882a593Smuzhiyun void t4_ulprx_read_la(struct adapter *adap, u32 *la_buf);
1961*4882a593Smuzhiyun 
1962*4882a593Smuzhiyun void t4_get_chan_txrate(struct adapter *adap, u64 *nic_rate, u64 *ofld_rate);
1963*4882a593Smuzhiyun void t4_mk_filtdelwr(unsigned int ftid, struct fw_filter_wr *wr, int qid);
1964*4882a593Smuzhiyun 
1965*4882a593Smuzhiyun void t4_wol_magic_enable(struct adapter *adap, unsigned int port,
1966*4882a593Smuzhiyun 			 const u8 *addr);
1967*4882a593Smuzhiyun int t4_wol_pat_enable(struct adapter *adap, unsigned int port, unsigned int map,
1968*4882a593Smuzhiyun 		      u64 mask0, u64 mask1, unsigned int crc, bool enable);
1969*4882a593Smuzhiyun 
1970*4882a593Smuzhiyun int t4_fw_hello(struct adapter *adap, unsigned int mbox, unsigned int evt_mbox,
1971*4882a593Smuzhiyun 		enum dev_master master, enum dev_state *state);
1972*4882a593Smuzhiyun int t4_fw_bye(struct adapter *adap, unsigned int mbox);
1973*4882a593Smuzhiyun int t4_early_init(struct adapter *adap, unsigned int mbox);
1974*4882a593Smuzhiyun int t4_fw_reset(struct adapter *adap, unsigned int mbox, int reset);
1975*4882a593Smuzhiyun int t4_fixup_host_params(struct adapter *adap, unsigned int page_size,
1976*4882a593Smuzhiyun 			  unsigned int cache_line_size);
1977*4882a593Smuzhiyun int t4_fw_initialize(struct adapter *adap, unsigned int mbox);
1978*4882a593Smuzhiyun int t4_query_params(struct adapter *adap, unsigned int mbox, unsigned int pf,
1979*4882a593Smuzhiyun 		    unsigned int vf, unsigned int nparams, const u32 *params,
1980*4882a593Smuzhiyun 		    u32 *val);
1981*4882a593Smuzhiyun int t4_query_params_ns(struct adapter *adap, unsigned int mbox, unsigned int pf,
1982*4882a593Smuzhiyun 		       unsigned int vf, unsigned int nparams, const u32 *params,
1983*4882a593Smuzhiyun 		       u32 *val);
1984*4882a593Smuzhiyun int t4_query_params_rw(struct adapter *adap, unsigned int mbox, unsigned int pf,
1985*4882a593Smuzhiyun 		       unsigned int vf, unsigned int nparams, const u32 *params,
1986*4882a593Smuzhiyun 		       u32 *val, int rw, bool sleep_ok);
1987*4882a593Smuzhiyun int t4_set_params_timeout(struct adapter *adap, unsigned int mbox,
1988*4882a593Smuzhiyun 			  unsigned int pf, unsigned int vf,
1989*4882a593Smuzhiyun 			  unsigned int nparams, const u32 *params,
1990*4882a593Smuzhiyun 			  const u32 *val, int timeout);
1991*4882a593Smuzhiyun int t4_set_params(struct adapter *adap, unsigned int mbox, unsigned int pf,
1992*4882a593Smuzhiyun 		  unsigned int vf, unsigned int nparams, const u32 *params,
1993*4882a593Smuzhiyun 		  const u32 *val);
1994*4882a593Smuzhiyun int t4_cfg_pfvf(struct adapter *adap, unsigned int mbox, unsigned int pf,
1995*4882a593Smuzhiyun 		unsigned int vf, unsigned int txq, unsigned int txq_eth_ctrl,
1996*4882a593Smuzhiyun 		unsigned int rxqi, unsigned int rxq, unsigned int tc,
1997*4882a593Smuzhiyun 		unsigned int vi, unsigned int cmask, unsigned int pmask,
1998*4882a593Smuzhiyun 		unsigned int nexact, unsigned int rcaps, unsigned int wxcaps);
1999*4882a593Smuzhiyun int t4_alloc_vi(struct adapter *adap, unsigned int mbox, unsigned int port,
2000*4882a593Smuzhiyun 		unsigned int pf, unsigned int vf, unsigned int nmac, u8 *mac,
2001*4882a593Smuzhiyun 		unsigned int *rss_size, u8 *vivld, u8 *vin);
2002*4882a593Smuzhiyun int t4_free_vi(struct adapter *adap, unsigned int mbox,
2003*4882a593Smuzhiyun 	       unsigned int pf, unsigned int vf,
2004*4882a593Smuzhiyun 	       unsigned int viid);
2005*4882a593Smuzhiyun int t4_set_rxmode(struct adapter *adap, unsigned int mbox, unsigned int viid,
2006*4882a593Smuzhiyun 		  unsigned int viid_mirror, int mtu, int promisc, int all_multi,
2007*4882a593Smuzhiyun 		  int bcast, int vlanex, bool sleep_ok);
2008*4882a593Smuzhiyun int t4_free_raw_mac_filt(struct adapter *adap, unsigned int viid,
2009*4882a593Smuzhiyun 			 const u8 *addr, const u8 *mask, unsigned int idx,
2010*4882a593Smuzhiyun 			 u8 lookup_type, u8 port_id, bool sleep_ok);
2011*4882a593Smuzhiyun int t4_free_encap_mac_filt(struct adapter *adap, unsigned int viid, int idx,
2012*4882a593Smuzhiyun 			   bool sleep_ok);
2013*4882a593Smuzhiyun int t4_alloc_encap_mac_filt(struct adapter *adap, unsigned int viid,
2014*4882a593Smuzhiyun 			    const u8 *addr, const u8 *mask, unsigned int vni,
2015*4882a593Smuzhiyun 			    unsigned int vni_mask, u8 dip_hit, u8 lookup_type,
2016*4882a593Smuzhiyun 			    bool sleep_ok);
2017*4882a593Smuzhiyun int t4_alloc_raw_mac_filt(struct adapter *adap, unsigned int viid,
2018*4882a593Smuzhiyun 			  const u8 *addr, const u8 *mask, unsigned int idx,
2019*4882a593Smuzhiyun 			  u8 lookup_type, u8 port_id, bool sleep_ok);
2020*4882a593Smuzhiyun int t4_alloc_mac_filt(struct adapter *adap, unsigned int mbox,
2021*4882a593Smuzhiyun 		      unsigned int viid, bool free, unsigned int naddr,
2022*4882a593Smuzhiyun 		      const u8 **addr, u16 *idx, u64 *hash, bool sleep_ok);
2023*4882a593Smuzhiyun int t4_free_mac_filt(struct adapter *adap, unsigned int mbox,
2024*4882a593Smuzhiyun 		     unsigned int viid, unsigned int naddr,
2025*4882a593Smuzhiyun 		     const u8 **addr, bool sleep_ok);
2026*4882a593Smuzhiyun int t4_change_mac(struct adapter *adap, unsigned int mbox, unsigned int viid,
2027*4882a593Smuzhiyun 		  int idx, const u8 *addr, bool persist, u8 *smt_idx);
2028*4882a593Smuzhiyun int t4_set_addr_hash(struct adapter *adap, unsigned int mbox, unsigned int viid,
2029*4882a593Smuzhiyun 		     bool ucast, u64 vec, bool sleep_ok);
2030*4882a593Smuzhiyun int t4_enable_vi_params(struct adapter *adap, unsigned int mbox,
2031*4882a593Smuzhiyun 			unsigned int viid, bool rx_en, bool tx_en, bool dcb_en);
2032*4882a593Smuzhiyun int t4_enable_pi_params(struct adapter *adap, unsigned int mbox,
2033*4882a593Smuzhiyun 			struct port_info *pi,
2034*4882a593Smuzhiyun 			bool rx_en, bool tx_en, bool dcb_en);
2035*4882a593Smuzhiyun int t4_enable_vi(struct adapter *adap, unsigned int mbox, unsigned int viid,
2036*4882a593Smuzhiyun 		 bool rx_en, bool tx_en);
2037*4882a593Smuzhiyun int t4_identify_port(struct adapter *adap, unsigned int mbox, unsigned int viid,
2038*4882a593Smuzhiyun 		     unsigned int nblinks);
2039*4882a593Smuzhiyun int t4_mdio_rd(struct adapter *adap, unsigned int mbox, unsigned int phy_addr,
2040*4882a593Smuzhiyun 	       unsigned int mmd, unsigned int reg, u16 *valp);
2041*4882a593Smuzhiyun int t4_mdio_wr(struct adapter *adap, unsigned int mbox, unsigned int phy_addr,
2042*4882a593Smuzhiyun 	       unsigned int mmd, unsigned int reg, u16 val);
2043*4882a593Smuzhiyun int t4_iq_stop(struct adapter *adap, unsigned int mbox, unsigned int pf,
2044*4882a593Smuzhiyun 	       unsigned int vf, unsigned int iqtype, unsigned int iqid,
2045*4882a593Smuzhiyun 	       unsigned int fl0id, unsigned int fl1id);
2046*4882a593Smuzhiyun int t4_iq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
2047*4882a593Smuzhiyun 	       unsigned int vf, unsigned int iqtype, unsigned int iqid,
2048*4882a593Smuzhiyun 	       unsigned int fl0id, unsigned int fl1id);
2049*4882a593Smuzhiyun int t4_eth_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
2050*4882a593Smuzhiyun 		   unsigned int vf, unsigned int eqid);
2051*4882a593Smuzhiyun int t4_ctrl_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
2052*4882a593Smuzhiyun 		    unsigned int vf, unsigned int eqid);
2053*4882a593Smuzhiyun int t4_ofld_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
2054*4882a593Smuzhiyun 		    unsigned int vf, unsigned int eqid);
2055*4882a593Smuzhiyun int t4_sge_ctxt_flush(struct adapter *adap, unsigned int mbox, int ctxt_type);
2056*4882a593Smuzhiyun int t4_read_sge_dbqtimers(struct adapter *adap, unsigned int ndbqtimers,
2057*4882a593Smuzhiyun 			  u16 *dbqtimers);
2058*4882a593Smuzhiyun void t4_handle_get_port_info(struct port_info *pi, const __be64 *rpl);
2059*4882a593Smuzhiyun int t4_update_port_info(struct port_info *pi);
2060*4882a593Smuzhiyun int t4_get_link_params(struct port_info *pi, unsigned int *link_okp,
2061*4882a593Smuzhiyun 		       unsigned int *speedp, unsigned int *mtup);
2062*4882a593Smuzhiyun int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl);
2063*4882a593Smuzhiyun void t4_db_full(struct adapter *adapter);
2064*4882a593Smuzhiyun void t4_db_dropped(struct adapter *adapter);
2065*4882a593Smuzhiyun int t4_set_trace_filter(struct adapter *adapter, const struct trace_params *tp,
2066*4882a593Smuzhiyun 			int filter_index, int enable);
2067*4882a593Smuzhiyun void t4_get_trace_filter(struct adapter *adapter, struct trace_params *tp,
2068*4882a593Smuzhiyun 			 int filter_index, int *enabled);
2069*4882a593Smuzhiyun int t4_fwaddrspace_write(struct adapter *adap, unsigned int mbox,
2070*4882a593Smuzhiyun 			 u32 addr, u32 val);
2071*4882a593Smuzhiyun void t4_read_pace_tbl(struct adapter *adap, unsigned int pace_vals[NTX_SCHED]);
2072*4882a593Smuzhiyun void t4_get_tx_sched(struct adapter *adap, unsigned int sched,
2073*4882a593Smuzhiyun 		     unsigned int *kbps, unsigned int *ipg, bool sleep_ok);
2074*4882a593Smuzhiyun int t4_sge_ctxt_rd(struct adapter *adap, unsigned int mbox, unsigned int cid,
2075*4882a593Smuzhiyun 		   enum ctxt_type ctype, u32 *data);
2076*4882a593Smuzhiyun int t4_sge_ctxt_rd_bd(struct adapter *adap, unsigned int cid,
2077*4882a593Smuzhiyun 		      enum ctxt_type ctype, u32 *data);
2078*4882a593Smuzhiyun int t4_sched_params(struct adapter *adapter, u8 type, u8 level, u8 mode,
2079*4882a593Smuzhiyun 		    u8 rateunit, u8 ratemode, u8 channel, u8 class,
2080*4882a593Smuzhiyun 		    u32 minrate, u32 maxrate, u16 weight, u16 pktsize,
2081*4882a593Smuzhiyun 		    u16 burstsize);
2082*4882a593Smuzhiyun void t4_sge_decode_idma_state(struct adapter *adapter, int state);
2083*4882a593Smuzhiyun void t4_idma_monitor_init(struct adapter *adapter,
2084*4882a593Smuzhiyun 			  struct sge_idma_monitor_state *idma);
2085*4882a593Smuzhiyun void t4_idma_monitor(struct adapter *adapter,
2086*4882a593Smuzhiyun 		     struct sge_idma_monitor_state *idma,
2087*4882a593Smuzhiyun 		     int hz, int ticks);
2088*4882a593Smuzhiyun int t4_set_vf_mac_acl(struct adapter *adapter, unsigned int vf,
2089*4882a593Smuzhiyun 		      unsigned int naddr, u8 *addr);
2090*4882a593Smuzhiyun void t4_tp_pio_read(struct adapter *adap, u32 *buff, u32 nregs,
2091*4882a593Smuzhiyun 		    u32 start_index, bool sleep_ok);
2092*4882a593Smuzhiyun void t4_tp_tm_pio_read(struct adapter *adap, u32 *buff, u32 nregs,
2093*4882a593Smuzhiyun 		       u32 start_index, bool sleep_ok);
2094*4882a593Smuzhiyun void t4_tp_mib_read(struct adapter *adap, u32 *buff, u32 nregs,
2095*4882a593Smuzhiyun 		    u32 start_index, bool sleep_ok);
2096*4882a593Smuzhiyun 
2097*4882a593Smuzhiyun void t4_uld_mem_free(struct adapter *adap);
2098*4882a593Smuzhiyun int t4_uld_mem_alloc(struct adapter *adap);
2099*4882a593Smuzhiyun void t4_uld_clean_up(struct adapter *adap);
2100*4882a593Smuzhiyun void t4_register_netevent_notifier(void);
2101*4882a593Smuzhiyun int t4_i2c_rd(struct adapter *adap, unsigned int mbox, int port,
2102*4882a593Smuzhiyun 	      unsigned int devid, unsigned int offset,
2103*4882a593Smuzhiyun 	      unsigned int len, u8 *buf);
2104*4882a593Smuzhiyun int t4_load_boot(struct adapter *adap, u8 *boot_data,
2105*4882a593Smuzhiyun 		 unsigned int boot_addr, unsigned int size);
2106*4882a593Smuzhiyun int t4_load_bootcfg(struct adapter *adap,
2107*4882a593Smuzhiyun 		    const u8 *cfg_data, unsigned int size);
2108*4882a593Smuzhiyun void free_rspq_fl(struct adapter *adap, struct sge_rspq *rq, struct sge_fl *fl);
2109*4882a593Smuzhiyun void free_tx_desc(struct adapter *adap, struct sge_txq *q,
2110*4882a593Smuzhiyun 		  unsigned int n, bool unmap);
2111*4882a593Smuzhiyun void cxgb4_eosw_txq_free_desc(struct adapter *adap, struct sge_eosw_txq *txq,
2112*4882a593Smuzhiyun 			      u32 ndesc);
2113*4882a593Smuzhiyun int cxgb4_ethofld_send_flowc(struct net_device *dev, u32 eotid, u32 tc);
2114*4882a593Smuzhiyun void cxgb4_ethofld_restart(struct tasklet_struct *t);
2115*4882a593Smuzhiyun int cxgb4_ethofld_rx_handler(struct sge_rspq *q, const __be64 *rsp,
2116*4882a593Smuzhiyun 			     const struct pkt_gl *si);
2117*4882a593Smuzhiyun void free_txq(struct adapter *adap, struct sge_txq *q);
2118*4882a593Smuzhiyun void cxgb4_reclaim_completed_tx(struct adapter *adap,
2119*4882a593Smuzhiyun 				struct sge_txq *q, bool unmap);
2120*4882a593Smuzhiyun int cxgb4_map_skb(struct device *dev, const struct sk_buff *skb,
2121*4882a593Smuzhiyun 		  dma_addr_t *addr);
2122*4882a593Smuzhiyun void cxgb4_inline_tx_skb(const struct sk_buff *skb, const struct sge_txq *q,
2123*4882a593Smuzhiyun 			 void *pos);
2124*4882a593Smuzhiyun void cxgb4_write_sgl(const struct sk_buff *skb, struct sge_txq *q,
2125*4882a593Smuzhiyun 		     struct ulptx_sgl *sgl, u64 *end, unsigned int start,
2126*4882a593Smuzhiyun 		     const dma_addr_t *addr);
2127*4882a593Smuzhiyun void cxgb4_write_partial_sgl(const struct sk_buff *skb, struct sge_txq *q,
2128*4882a593Smuzhiyun 			     struct ulptx_sgl *sgl, u64 *end,
2129*4882a593Smuzhiyun 			     const dma_addr_t *addr, u32 start, u32 send_len);
2130*4882a593Smuzhiyun void cxgb4_ring_tx_db(struct adapter *adap, struct sge_txq *q, int n);
2131*4882a593Smuzhiyun int t4_set_vlan_acl(struct adapter *adap, unsigned int mbox, unsigned int vf,
2132*4882a593Smuzhiyun 		    u16 vlan);
2133*4882a593Smuzhiyun int cxgb4_dcb_enabled(const struct net_device *dev);
2134*4882a593Smuzhiyun 
2135*4882a593Smuzhiyun int cxgb4_thermal_init(struct adapter *adap);
2136*4882a593Smuzhiyun int cxgb4_thermal_remove(struct adapter *adap);
2137*4882a593Smuzhiyun int cxgb4_set_msix_aff(struct adapter *adap, unsigned short vec,
2138*4882a593Smuzhiyun 		       cpumask_var_t *aff_mask, int idx);
2139*4882a593Smuzhiyun void cxgb4_clear_msix_aff(unsigned short vec, cpumask_var_t aff_mask);
2140*4882a593Smuzhiyun 
2141*4882a593Smuzhiyun int cxgb4_change_mac(struct port_info *pi, unsigned int viid,
2142*4882a593Smuzhiyun 		     int *tcam_idx, const u8 *addr,
2143*4882a593Smuzhiyun 		     bool persistent, u8 *smt_idx);
2144*4882a593Smuzhiyun 
2145*4882a593Smuzhiyun int cxgb4_alloc_mac_filt(struct adapter *adap, unsigned int viid,
2146*4882a593Smuzhiyun 			 bool free, unsigned int naddr,
2147*4882a593Smuzhiyun 			 const u8 **addr, u16 *idx,
2148*4882a593Smuzhiyun 			 u64 *hash, bool sleep_ok);
2149*4882a593Smuzhiyun int cxgb4_free_mac_filt(struct adapter *adap, unsigned int viid,
2150*4882a593Smuzhiyun 			unsigned int naddr, const u8 **addr, bool sleep_ok);
2151*4882a593Smuzhiyun int cxgb4_init_mps_ref_entries(struct adapter *adap);
2152*4882a593Smuzhiyun void cxgb4_free_mps_ref_entries(struct adapter *adap);
2153*4882a593Smuzhiyun int cxgb4_alloc_encap_mac_filt(struct adapter *adap, unsigned int viid,
2154*4882a593Smuzhiyun 			       const u8 *addr, const u8 *mask,
2155*4882a593Smuzhiyun 			       unsigned int vni, unsigned int vni_mask,
2156*4882a593Smuzhiyun 			       u8 dip_hit, u8 lookup_type, bool sleep_ok);
2157*4882a593Smuzhiyun int cxgb4_free_encap_mac_filt(struct adapter *adap, unsigned int viid,
2158*4882a593Smuzhiyun 			      int idx, bool sleep_ok);
2159*4882a593Smuzhiyun int cxgb4_free_raw_mac_filt(struct adapter *adap,
2160*4882a593Smuzhiyun 			    unsigned int viid,
2161*4882a593Smuzhiyun 			    const u8 *addr,
2162*4882a593Smuzhiyun 			    const u8 *mask,
2163*4882a593Smuzhiyun 			    unsigned int idx,
2164*4882a593Smuzhiyun 			    u8 lookup_type,
2165*4882a593Smuzhiyun 			    u8 port_id,
2166*4882a593Smuzhiyun 			    bool sleep_ok);
2167*4882a593Smuzhiyun int cxgb4_alloc_raw_mac_filt(struct adapter *adap,
2168*4882a593Smuzhiyun 			     unsigned int viid,
2169*4882a593Smuzhiyun 			     const u8 *addr,
2170*4882a593Smuzhiyun 			     const u8 *mask,
2171*4882a593Smuzhiyun 			     unsigned int idx,
2172*4882a593Smuzhiyun 			     u8 lookup_type,
2173*4882a593Smuzhiyun 			     u8 port_id,
2174*4882a593Smuzhiyun 			     bool sleep_ok);
2175*4882a593Smuzhiyun int cxgb4_update_mac_filt(struct port_info *pi, unsigned int viid,
2176*4882a593Smuzhiyun 			  int *tcam_idx, const u8 *addr,
2177*4882a593Smuzhiyun 			  bool persistent, u8 *smt_idx);
2178*4882a593Smuzhiyun int cxgb4_get_msix_idx_from_bmap(struct adapter *adap);
2179*4882a593Smuzhiyun void cxgb4_free_msix_idx_in_bmap(struct adapter *adap, u32 msix_idx);
2180*4882a593Smuzhiyun void cxgb4_enable_rx(struct adapter *adap, struct sge_rspq *q);
2181*4882a593Smuzhiyun void cxgb4_quiesce_rx(struct sge_rspq *q);
2182*4882a593Smuzhiyun int cxgb4_port_mirror_alloc(struct net_device *dev);
2183*4882a593Smuzhiyun void cxgb4_port_mirror_free(struct net_device *dev);
2184*4882a593Smuzhiyun #if IS_ENABLED(CONFIG_CHELSIO_TLS_DEVICE)
2185*4882a593Smuzhiyun int cxgb4_set_ktls_feature(struct adapter *adap, bool enable);
2186*4882a593Smuzhiyun #endif
2187*4882a593Smuzhiyun #endif /* __CXGB4_H__ */
2188