162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * This file is part of the Chelsio T4 Ethernet driver for Linux.
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * Copyright (c) 2003-2016 Chelsio Communications, Inc. All rights reserved.
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * This software is available to you under a choice of one of two
762306a36Sopenharmony_ci * licenses.  You may choose to be licensed under the terms of the GNU
862306a36Sopenharmony_ci * General Public License (GPL) Version 2, available from the file
962306a36Sopenharmony_ci * COPYING in the main directory of this source tree, or the
1062306a36Sopenharmony_ci * OpenIB.org BSD license below:
1162306a36Sopenharmony_ci *
1262306a36Sopenharmony_ci *     Redistribution and use in source and binary forms, with or
1362306a36Sopenharmony_ci *     without modification, are permitted provided that the following
1462306a36Sopenharmony_ci *     conditions are met:
1562306a36Sopenharmony_ci *
1662306a36Sopenharmony_ci *      - Redistributions of source code must retain the above
1762306a36Sopenharmony_ci *        copyright notice, this list of conditions and the following
1862306a36Sopenharmony_ci *        disclaimer.
1962306a36Sopenharmony_ci *
2062306a36Sopenharmony_ci *      - Redistributions in binary form must reproduce the above
2162306a36Sopenharmony_ci *        copyright notice, this list of conditions and the following
2262306a36Sopenharmony_ci *        disclaimer in the documentation and/or other materials
2362306a36Sopenharmony_ci *        provided with the distribution.
2462306a36Sopenharmony_ci *
2562306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2662306a36Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2762306a36Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2862306a36Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
2962306a36Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
3062306a36Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
3162306a36Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3262306a36Sopenharmony_ci * SOFTWARE.
3362306a36Sopenharmony_ci */
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci#ifndef __CXGB4_H__
3662306a36Sopenharmony_ci#define __CXGB4_H__
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci#include "t4_hw.h"
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci#include <linux/bitops.h>
4162306a36Sopenharmony_ci#include <linux/cache.h>
4262306a36Sopenharmony_ci#include <linux/ethtool.h>
4362306a36Sopenharmony_ci#include <linux/interrupt.h>
4462306a36Sopenharmony_ci#include <linux/list.h>
4562306a36Sopenharmony_ci#include <linux/netdevice.h>
4662306a36Sopenharmony_ci#include <linux/pci.h>
4762306a36Sopenharmony_ci#include <linux/spinlock.h>
4862306a36Sopenharmony_ci#include <linux/timer.h>
4962306a36Sopenharmony_ci#include <linux/vmalloc.h>
5062306a36Sopenharmony_ci#include <linux/rhashtable.h>
5162306a36Sopenharmony_ci#include <linux/etherdevice.h>
5262306a36Sopenharmony_ci#include <linux/net_tstamp.h>
5362306a36Sopenharmony_ci#include <linux/ptp_clock_kernel.h>
5462306a36Sopenharmony_ci#include <linux/ptp_classify.h>
5562306a36Sopenharmony_ci#include <linux/crash_dump.h>
5662306a36Sopenharmony_ci#include <linux/thermal.h>
5762306a36Sopenharmony_ci#include <asm/io.h>
5862306a36Sopenharmony_ci#include "t4_chip_type.h"
5962306a36Sopenharmony_ci#include "cxgb4_uld.h"
6062306a36Sopenharmony_ci#include "t4fw_api.h"
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ci#define CH_WARN(adap, fmt, ...) dev_warn(adap->pdev_dev, fmt, ## __VA_ARGS__)
6362306a36Sopenharmony_ciextern struct list_head adapter_list;
6462306a36Sopenharmony_ciextern struct list_head uld_list;
6562306a36Sopenharmony_ciextern struct mutex uld_mutex;
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci/* Suspend an Ethernet Tx queue with fewer available descriptors than this.
6862306a36Sopenharmony_ci * This is the same as calc_tx_descs() for a TSO packet with
6962306a36Sopenharmony_ci * nr_frags == MAX_SKB_FRAGS.
7062306a36Sopenharmony_ci */
7162306a36Sopenharmony_ci#define ETHTXQ_STOP_THRES \
7262306a36Sopenharmony_ci	(1 + DIV_ROUND_UP((3 * MAX_SKB_FRAGS) / 2 + (MAX_SKB_FRAGS & 1), 8))
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci#define FW_PARAM_DEV(param) \
7562306a36Sopenharmony_ci	(FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DEV) | \
7662306a36Sopenharmony_ci	 FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_DEV_##param))
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci#define FW_PARAM_PFVF(param) \
7962306a36Sopenharmony_ci	(FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_PFVF) | \
8062306a36Sopenharmony_ci	 FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_PFVF_##param) |  \
8162306a36Sopenharmony_ci	 FW_PARAMS_PARAM_Y_V(0) | \
8262306a36Sopenharmony_ci	 FW_PARAMS_PARAM_Z_V(0))
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_cienum {
8562306a36Sopenharmony_ci	MAX_NPORTS	= 4,     /* max # of ports */
8662306a36Sopenharmony_ci	SERNUM_LEN	= 24,    /* Serial # length */
8762306a36Sopenharmony_ci	ID_LEN		= 16,    /* ID length */
8862306a36Sopenharmony_ci	PN_LEN		= 16,    /* Part Number length */
8962306a36Sopenharmony_ci	MACADDR_LEN	= 12,    /* MAC Address length */
9062306a36Sopenharmony_ci};
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_cienum {
9362306a36Sopenharmony_ci	T4_REGMAP_SIZE = (160 * 1024),
9462306a36Sopenharmony_ci	T5_REGMAP_SIZE = (332 * 1024),
9562306a36Sopenharmony_ci};
9662306a36Sopenharmony_ci
9762306a36Sopenharmony_cienum {
9862306a36Sopenharmony_ci	MEM_EDC0,
9962306a36Sopenharmony_ci	MEM_EDC1,
10062306a36Sopenharmony_ci	MEM_MC,
10162306a36Sopenharmony_ci	MEM_MC0 = MEM_MC,
10262306a36Sopenharmony_ci	MEM_MC1,
10362306a36Sopenharmony_ci	MEM_HMA,
10462306a36Sopenharmony_ci};
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_cienum {
10762306a36Sopenharmony_ci	MEMWIN0_APERTURE = 2048,
10862306a36Sopenharmony_ci	MEMWIN0_BASE     = 0x1b800,
10962306a36Sopenharmony_ci	MEMWIN1_APERTURE = 32768,
11062306a36Sopenharmony_ci	MEMWIN1_BASE     = 0x28000,
11162306a36Sopenharmony_ci	MEMWIN1_BASE_T5  = 0x52000,
11262306a36Sopenharmony_ci	MEMWIN2_APERTURE = 65536,
11362306a36Sopenharmony_ci	MEMWIN2_BASE     = 0x30000,
11462306a36Sopenharmony_ci	MEMWIN2_APERTURE_T5 = 131072,
11562306a36Sopenharmony_ci	MEMWIN2_BASE_T5  = 0x60000,
11662306a36Sopenharmony_ci};
11762306a36Sopenharmony_ci
11862306a36Sopenharmony_cienum dev_master {
11962306a36Sopenharmony_ci	MASTER_CANT,
12062306a36Sopenharmony_ci	MASTER_MAY,
12162306a36Sopenharmony_ci	MASTER_MUST
12262306a36Sopenharmony_ci};
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_cienum dev_state {
12562306a36Sopenharmony_ci	DEV_STATE_UNINIT,
12662306a36Sopenharmony_ci	DEV_STATE_INIT,
12762306a36Sopenharmony_ci	DEV_STATE_ERR
12862306a36Sopenharmony_ci};
12962306a36Sopenharmony_ci
13062306a36Sopenharmony_cienum cc_pause {
13162306a36Sopenharmony_ci	PAUSE_RX      = 1 << 0,
13262306a36Sopenharmony_ci	PAUSE_TX      = 1 << 1,
13362306a36Sopenharmony_ci	PAUSE_AUTONEG = 1 << 2
13462306a36Sopenharmony_ci};
13562306a36Sopenharmony_ci
13662306a36Sopenharmony_cienum cc_fec {
13762306a36Sopenharmony_ci	FEC_AUTO      = 1 << 0,	 /* IEEE 802.3 "automatic" */
13862306a36Sopenharmony_ci	FEC_RS        = 1 << 1,  /* Reed-Solomon */
13962306a36Sopenharmony_ci	FEC_BASER_RS  = 1 << 2   /* BaseR/Reed-Solomon */
14062306a36Sopenharmony_ci};
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_cienum {
14362306a36Sopenharmony_ci	CXGB4_ETHTOOL_FLASH_FW = 1,
14462306a36Sopenharmony_ci	CXGB4_ETHTOOL_FLASH_PHY = 2,
14562306a36Sopenharmony_ci	CXGB4_ETHTOOL_FLASH_BOOT = 3,
14662306a36Sopenharmony_ci	CXGB4_ETHTOOL_FLASH_BOOTCFG = 4
14762306a36Sopenharmony_ci};
14862306a36Sopenharmony_ci
14962306a36Sopenharmony_cienum cxgb4_netdev_tls_ops {
15062306a36Sopenharmony_ci	CXGB4_TLSDEV_OPS  = 1,
15162306a36Sopenharmony_ci	CXGB4_XFRMDEV_OPS
15262306a36Sopenharmony_ci};
15362306a36Sopenharmony_ci
15462306a36Sopenharmony_cistruct cxgb4_bootcfg_data {
15562306a36Sopenharmony_ci	__le16 signature;
15662306a36Sopenharmony_ci	__u8 reserved[2];
15762306a36Sopenharmony_ci};
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_cistruct cxgb4_pcir_data {
16062306a36Sopenharmony_ci	__le32 signature;	/* Signature. The string "PCIR" */
16162306a36Sopenharmony_ci	__le16 vendor_id;	/* Vendor Identification */
16262306a36Sopenharmony_ci	__le16 device_id;	/* Device Identification */
16362306a36Sopenharmony_ci	__u8 vital_product[2];	/* Pointer to Vital Product Data */
16462306a36Sopenharmony_ci	__u8 length[2];		/* PCIR Data Structure Length */
16562306a36Sopenharmony_ci	__u8 revision;		/* PCIR Data Structure Revision */
16662306a36Sopenharmony_ci	__u8 class_code[3];	/* Class Code */
16762306a36Sopenharmony_ci	__u8 image_length[2];	/* Image Length. Multiple of 512B */
16862306a36Sopenharmony_ci	__u8 code_revision[2];	/* Revision Level of Code/Data */
16962306a36Sopenharmony_ci	__u8 code_type;
17062306a36Sopenharmony_ci	__u8 indicator;
17162306a36Sopenharmony_ci	__u8 reserved[2];
17262306a36Sopenharmony_ci};
17362306a36Sopenharmony_ci
17462306a36Sopenharmony_ci/* BIOS boot headers */
17562306a36Sopenharmony_cistruct cxgb4_pci_exp_rom_header {
17662306a36Sopenharmony_ci	__le16 signature;	/* ROM Signature. Should be 0xaa55 */
17762306a36Sopenharmony_ci	__u8 reserved[22];	/* Reserved per processor Architecture data */
17862306a36Sopenharmony_ci	__le16 pcir_offset;	/* Offset to PCI Data Structure */
17962306a36Sopenharmony_ci};
18062306a36Sopenharmony_ci
18162306a36Sopenharmony_ci/* Legacy PCI Expansion ROM Header */
18262306a36Sopenharmony_cistruct legacy_pci_rom_hdr {
18362306a36Sopenharmony_ci	__u8 signature[2];	/* ROM Signature. Should be 0xaa55 */
18462306a36Sopenharmony_ci	__u8 size512;		/* Current Image Size in units of 512 bytes */
18562306a36Sopenharmony_ci	__u8 initentry_point[4];
18662306a36Sopenharmony_ci	__u8 cksum;		/* Checksum computed on the entire Image */
18762306a36Sopenharmony_ci	__u8 reserved[16];	/* Reserved */
18862306a36Sopenharmony_ci	__le16 pcir_offset;	/* Offset to PCI Data Struture */
18962306a36Sopenharmony_ci};
19062306a36Sopenharmony_ci
19162306a36Sopenharmony_ci#define CXGB4_HDR_CODE1 0x00
19262306a36Sopenharmony_ci#define CXGB4_HDR_CODE2 0x03
19362306a36Sopenharmony_ci#define CXGB4_HDR_INDI 0x80
19462306a36Sopenharmony_ci
19562306a36Sopenharmony_ci/* BOOT constants */
19662306a36Sopenharmony_cienum {
19762306a36Sopenharmony_ci	BOOT_CFG_SIG = 0x4243,
19862306a36Sopenharmony_ci	BOOT_SIZE_INC = 512,
19962306a36Sopenharmony_ci	BOOT_SIGNATURE = 0xaa55,
20062306a36Sopenharmony_ci	BOOT_MIN_SIZE = sizeof(struct cxgb4_pci_exp_rom_header),
20162306a36Sopenharmony_ci	BOOT_MAX_SIZE = 1024 * BOOT_SIZE_INC,
20262306a36Sopenharmony_ci	PCIR_SIGNATURE = 0x52494350
20362306a36Sopenharmony_ci};
20462306a36Sopenharmony_ci
20562306a36Sopenharmony_cistruct port_stats {
20662306a36Sopenharmony_ci	u64 tx_octets;            /* total # of octets in good frames */
20762306a36Sopenharmony_ci	u64 tx_frames;            /* all good frames */
20862306a36Sopenharmony_ci	u64 tx_bcast_frames;      /* all broadcast frames */
20962306a36Sopenharmony_ci	u64 tx_mcast_frames;      /* all multicast frames */
21062306a36Sopenharmony_ci	u64 tx_ucast_frames;      /* all unicast frames */
21162306a36Sopenharmony_ci	u64 tx_error_frames;      /* all error frames */
21262306a36Sopenharmony_ci
21362306a36Sopenharmony_ci	u64 tx_frames_64;         /* # of Tx frames in a particular range */
21462306a36Sopenharmony_ci	u64 tx_frames_65_127;
21562306a36Sopenharmony_ci	u64 tx_frames_128_255;
21662306a36Sopenharmony_ci	u64 tx_frames_256_511;
21762306a36Sopenharmony_ci	u64 tx_frames_512_1023;
21862306a36Sopenharmony_ci	u64 tx_frames_1024_1518;
21962306a36Sopenharmony_ci	u64 tx_frames_1519_max;
22062306a36Sopenharmony_ci
22162306a36Sopenharmony_ci	u64 tx_drop;              /* # of dropped Tx frames */
22262306a36Sopenharmony_ci	u64 tx_pause;             /* # of transmitted pause frames */
22362306a36Sopenharmony_ci	u64 tx_ppp0;              /* # of transmitted PPP prio 0 frames */
22462306a36Sopenharmony_ci	u64 tx_ppp1;              /* # of transmitted PPP prio 1 frames */
22562306a36Sopenharmony_ci	u64 tx_ppp2;              /* # of transmitted PPP prio 2 frames */
22662306a36Sopenharmony_ci	u64 tx_ppp3;              /* # of transmitted PPP prio 3 frames */
22762306a36Sopenharmony_ci	u64 tx_ppp4;              /* # of transmitted PPP prio 4 frames */
22862306a36Sopenharmony_ci	u64 tx_ppp5;              /* # of transmitted PPP prio 5 frames */
22962306a36Sopenharmony_ci	u64 tx_ppp6;              /* # of transmitted PPP prio 6 frames */
23062306a36Sopenharmony_ci	u64 tx_ppp7;              /* # of transmitted PPP prio 7 frames */
23162306a36Sopenharmony_ci
23262306a36Sopenharmony_ci	u64 rx_octets;            /* total # of octets in good frames */
23362306a36Sopenharmony_ci	u64 rx_frames;            /* all good frames */
23462306a36Sopenharmony_ci	u64 rx_bcast_frames;      /* all broadcast frames */
23562306a36Sopenharmony_ci	u64 rx_mcast_frames;      /* all multicast frames */
23662306a36Sopenharmony_ci	u64 rx_ucast_frames;      /* all unicast frames */
23762306a36Sopenharmony_ci	u64 rx_too_long;          /* # of frames exceeding MTU */
23862306a36Sopenharmony_ci	u64 rx_jabber;            /* # of jabber frames */
23962306a36Sopenharmony_ci	u64 rx_fcs_err;           /* # of received frames with bad FCS */
24062306a36Sopenharmony_ci	u64 rx_len_err;           /* # of received frames with length error */
24162306a36Sopenharmony_ci	u64 rx_symbol_err;        /* symbol errors */
24262306a36Sopenharmony_ci	u64 rx_runt;              /* # of short frames */
24362306a36Sopenharmony_ci
24462306a36Sopenharmony_ci	u64 rx_frames_64;         /* # of Rx frames in a particular range */
24562306a36Sopenharmony_ci	u64 rx_frames_65_127;
24662306a36Sopenharmony_ci	u64 rx_frames_128_255;
24762306a36Sopenharmony_ci	u64 rx_frames_256_511;
24862306a36Sopenharmony_ci	u64 rx_frames_512_1023;
24962306a36Sopenharmony_ci	u64 rx_frames_1024_1518;
25062306a36Sopenharmony_ci	u64 rx_frames_1519_max;
25162306a36Sopenharmony_ci
25262306a36Sopenharmony_ci	u64 rx_pause;             /* # of received pause frames */
25362306a36Sopenharmony_ci	u64 rx_ppp0;              /* # of received PPP prio 0 frames */
25462306a36Sopenharmony_ci	u64 rx_ppp1;              /* # of received PPP prio 1 frames */
25562306a36Sopenharmony_ci	u64 rx_ppp2;              /* # of received PPP prio 2 frames */
25662306a36Sopenharmony_ci	u64 rx_ppp3;              /* # of received PPP prio 3 frames */
25762306a36Sopenharmony_ci	u64 rx_ppp4;              /* # of received PPP prio 4 frames */
25862306a36Sopenharmony_ci	u64 rx_ppp5;              /* # of received PPP prio 5 frames */
25962306a36Sopenharmony_ci	u64 rx_ppp6;              /* # of received PPP prio 6 frames */
26062306a36Sopenharmony_ci	u64 rx_ppp7;              /* # of received PPP prio 7 frames */
26162306a36Sopenharmony_ci
26262306a36Sopenharmony_ci	u64 rx_ovflow0;           /* drops due to buffer-group 0 overflows */
26362306a36Sopenharmony_ci	u64 rx_ovflow1;           /* drops due to buffer-group 1 overflows */
26462306a36Sopenharmony_ci	u64 rx_ovflow2;           /* drops due to buffer-group 2 overflows */
26562306a36Sopenharmony_ci	u64 rx_ovflow3;           /* drops due to buffer-group 3 overflows */
26662306a36Sopenharmony_ci	u64 rx_trunc0;            /* buffer-group 0 truncated packets */
26762306a36Sopenharmony_ci	u64 rx_trunc1;            /* buffer-group 1 truncated packets */
26862306a36Sopenharmony_ci	u64 rx_trunc2;            /* buffer-group 2 truncated packets */
26962306a36Sopenharmony_ci	u64 rx_trunc3;            /* buffer-group 3 truncated packets */
27062306a36Sopenharmony_ci};
27162306a36Sopenharmony_ci
27262306a36Sopenharmony_cistruct lb_port_stats {
27362306a36Sopenharmony_ci	u64 octets;
27462306a36Sopenharmony_ci	u64 frames;
27562306a36Sopenharmony_ci	u64 bcast_frames;
27662306a36Sopenharmony_ci	u64 mcast_frames;
27762306a36Sopenharmony_ci	u64 ucast_frames;
27862306a36Sopenharmony_ci	u64 error_frames;
27962306a36Sopenharmony_ci
28062306a36Sopenharmony_ci	u64 frames_64;
28162306a36Sopenharmony_ci	u64 frames_65_127;
28262306a36Sopenharmony_ci	u64 frames_128_255;
28362306a36Sopenharmony_ci	u64 frames_256_511;
28462306a36Sopenharmony_ci	u64 frames_512_1023;
28562306a36Sopenharmony_ci	u64 frames_1024_1518;
28662306a36Sopenharmony_ci	u64 frames_1519_max;
28762306a36Sopenharmony_ci
28862306a36Sopenharmony_ci	u64 drop;
28962306a36Sopenharmony_ci
29062306a36Sopenharmony_ci	u64 ovflow0;
29162306a36Sopenharmony_ci	u64 ovflow1;
29262306a36Sopenharmony_ci	u64 ovflow2;
29362306a36Sopenharmony_ci	u64 ovflow3;
29462306a36Sopenharmony_ci	u64 trunc0;
29562306a36Sopenharmony_ci	u64 trunc1;
29662306a36Sopenharmony_ci	u64 trunc2;
29762306a36Sopenharmony_ci	u64 trunc3;
29862306a36Sopenharmony_ci};
29962306a36Sopenharmony_ci
30062306a36Sopenharmony_cistruct tp_tcp_stats {
30162306a36Sopenharmony_ci	u32 tcp_out_rsts;
30262306a36Sopenharmony_ci	u64 tcp_in_segs;
30362306a36Sopenharmony_ci	u64 tcp_out_segs;
30462306a36Sopenharmony_ci	u64 tcp_retrans_segs;
30562306a36Sopenharmony_ci};
30662306a36Sopenharmony_ci
30762306a36Sopenharmony_cistruct tp_usm_stats {
30862306a36Sopenharmony_ci	u32 frames;
30962306a36Sopenharmony_ci	u32 drops;
31062306a36Sopenharmony_ci	u64 octets;
31162306a36Sopenharmony_ci};
31262306a36Sopenharmony_ci
31362306a36Sopenharmony_cistruct tp_fcoe_stats {
31462306a36Sopenharmony_ci	u32 frames_ddp;
31562306a36Sopenharmony_ci	u32 frames_drop;
31662306a36Sopenharmony_ci	u64 octets_ddp;
31762306a36Sopenharmony_ci};
31862306a36Sopenharmony_ci
31962306a36Sopenharmony_cistruct tp_err_stats {
32062306a36Sopenharmony_ci	u32 mac_in_errs[4];
32162306a36Sopenharmony_ci	u32 hdr_in_errs[4];
32262306a36Sopenharmony_ci	u32 tcp_in_errs[4];
32362306a36Sopenharmony_ci	u32 tnl_cong_drops[4];
32462306a36Sopenharmony_ci	u32 ofld_chan_drops[4];
32562306a36Sopenharmony_ci	u32 tnl_tx_drops[4];
32662306a36Sopenharmony_ci	u32 ofld_vlan_drops[4];
32762306a36Sopenharmony_ci	u32 tcp6_in_errs[4];
32862306a36Sopenharmony_ci	u32 ofld_no_neigh;
32962306a36Sopenharmony_ci	u32 ofld_cong_defer;
33062306a36Sopenharmony_ci};
33162306a36Sopenharmony_ci
33262306a36Sopenharmony_cistruct tp_cpl_stats {
33362306a36Sopenharmony_ci	u32 req[4];
33462306a36Sopenharmony_ci	u32 rsp[4];
33562306a36Sopenharmony_ci};
33662306a36Sopenharmony_ci
33762306a36Sopenharmony_cistruct tp_rdma_stats {
33862306a36Sopenharmony_ci	u32 rqe_dfr_pkt;
33962306a36Sopenharmony_ci	u32 rqe_dfr_mod;
34062306a36Sopenharmony_ci};
34162306a36Sopenharmony_ci
34262306a36Sopenharmony_cistruct sge_params {
34362306a36Sopenharmony_ci	u32 hps;			/* host page size for our PF/VF */
34462306a36Sopenharmony_ci	u32 eq_qpp;			/* egress queues/page for our PF/VF */
34562306a36Sopenharmony_ci	u32 iq_qpp;			/* egress queues/page for our PF/VF */
34662306a36Sopenharmony_ci};
34762306a36Sopenharmony_ci
34862306a36Sopenharmony_cistruct tp_params {
34962306a36Sopenharmony_ci	unsigned int tre;            /* log2 of core clocks per TP tick */
35062306a36Sopenharmony_ci	unsigned int la_mask;        /* what events are recorded by TP LA */
35162306a36Sopenharmony_ci	unsigned short tx_modq_map;  /* TX modulation scheduler queue to */
35262306a36Sopenharmony_ci				     /* channel map */
35362306a36Sopenharmony_ci
35462306a36Sopenharmony_ci	uint32_t dack_re;            /* DACK timer resolution */
35562306a36Sopenharmony_ci	unsigned short tx_modq[NCHAN];	/* channel to modulation queue map */
35662306a36Sopenharmony_ci
35762306a36Sopenharmony_ci	u32 vlan_pri_map;               /* cached TP_VLAN_PRI_MAP */
35862306a36Sopenharmony_ci	u32 filter_mask;
35962306a36Sopenharmony_ci	u32 ingress_config;             /* cached TP_INGRESS_CONFIG */
36062306a36Sopenharmony_ci
36162306a36Sopenharmony_ci	/* cached TP_OUT_CONFIG compressed error vector
36262306a36Sopenharmony_ci	 * and passing outer header info for encapsulated packets.
36362306a36Sopenharmony_ci	 */
36462306a36Sopenharmony_ci	int rx_pkt_encap;
36562306a36Sopenharmony_ci
36662306a36Sopenharmony_ci	/* TP_VLAN_PRI_MAP Compressed Filter Tuple field offsets.  This is a
36762306a36Sopenharmony_ci	 * subset of the set of fields which may be present in the Compressed
36862306a36Sopenharmony_ci	 * Filter Tuple portion of filters and TCP TCB connections.  The
36962306a36Sopenharmony_ci	 * fields which are present are controlled by the TP_VLAN_PRI_MAP.
37062306a36Sopenharmony_ci	 * Since a variable number of fields may or may not be present, their
37162306a36Sopenharmony_ci	 * shifted field positions within the Compressed Filter Tuple may
37262306a36Sopenharmony_ci	 * vary, or not even be present if the field isn't selected in
37362306a36Sopenharmony_ci	 * TP_VLAN_PRI_MAP.  Since some of these fields are needed in various
37462306a36Sopenharmony_ci	 * places we store their offsets here, or a -1 if the field isn't
37562306a36Sopenharmony_ci	 * present.
37662306a36Sopenharmony_ci	 */
37762306a36Sopenharmony_ci	int fcoe_shift;
37862306a36Sopenharmony_ci	int port_shift;
37962306a36Sopenharmony_ci	int vnic_shift;
38062306a36Sopenharmony_ci	int vlan_shift;
38162306a36Sopenharmony_ci	int tos_shift;
38262306a36Sopenharmony_ci	int protocol_shift;
38362306a36Sopenharmony_ci	int ethertype_shift;
38462306a36Sopenharmony_ci	int macmatch_shift;
38562306a36Sopenharmony_ci	int matchtype_shift;
38662306a36Sopenharmony_ci	int frag_shift;
38762306a36Sopenharmony_ci
38862306a36Sopenharmony_ci	u64 hash_filter_mask;
38962306a36Sopenharmony_ci};
39062306a36Sopenharmony_ci
39162306a36Sopenharmony_cistruct vpd_params {
39262306a36Sopenharmony_ci	unsigned int cclk;
39362306a36Sopenharmony_ci	u8 sn[SERNUM_LEN + 1];
39462306a36Sopenharmony_ci	u8 id[ID_LEN + 1];
39562306a36Sopenharmony_ci	u8 pn[PN_LEN + 1];
39662306a36Sopenharmony_ci	u8 na[MACADDR_LEN + 1];
39762306a36Sopenharmony_ci};
39862306a36Sopenharmony_ci
39962306a36Sopenharmony_ci/* Maximum resources provisioned for a PCI PF.
40062306a36Sopenharmony_ci */
40162306a36Sopenharmony_cistruct pf_resources {
40262306a36Sopenharmony_ci	unsigned int nvi;		/* N virtual interfaces */
40362306a36Sopenharmony_ci	unsigned int neq;		/* N egress Qs */
40462306a36Sopenharmony_ci	unsigned int nethctrl;		/* N egress ETH or CTRL Qs */
40562306a36Sopenharmony_ci	unsigned int niqflint;		/* N ingress Qs/w free list(s) & intr */
40662306a36Sopenharmony_ci	unsigned int niq;		/* N ingress Qs */
40762306a36Sopenharmony_ci	unsigned int tc;		/* PCI-E traffic class */
40862306a36Sopenharmony_ci	unsigned int pmask;		/* port access rights mask */
40962306a36Sopenharmony_ci	unsigned int nexactf;		/* N exact MPS filters */
41062306a36Sopenharmony_ci	unsigned int r_caps;		/* read capabilities */
41162306a36Sopenharmony_ci	unsigned int wx_caps;		/* write/execute capabilities */
41262306a36Sopenharmony_ci};
41362306a36Sopenharmony_ci
41462306a36Sopenharmony_cistruct pci_params {
41562306a36Sopenharmony_ci	unsigned char speed;
41662306a36Sopenharmony_ci	unsigned char width;
41762306a36Sopenharmony_ci};
41862306a36Sopenharmony_ci
41962306a36Sopenharmony_cistruct devlog_params {
42062306a36Sopenharmony_ci	u32 memtype;                    /* which memory (EDC0, EDC1, MC) */
42162306a36Sopenharmony_ci	u32 start;                      /* start of log in firmware memory */
42262306a36Sopenharmony_ci	u32 size;                       /* size of log */
42362306a36Sopenharmony_ci};
42462306a36Sopenharmony_ci
42562306a36Sopenharmony_ci/* Stores chip specific parameters */
42662306a36Sopenharmony_cistruct arch_specific_params {
42762306a36Sopenharmony_ci	u8 nchan;
42862306a36Sopenharmony_ci	u8 pm_stats_cnt;
42962306a36Sopenharmony_ci	u8 cng_ch_bits_log;		/* congestion channel map bits width */
43062306a36Sopenharmony_ci	u16 mps_rplc_size;
43162306a36Sopenharmony_ci	u16 vfcount;
43262306a36Sopenharmony_ci	u32 sge_fl_db;
43362306a36Sopenharmony_ci	u16 mps_tcam_size;
43462306a36Sopenharmony_ci};
43562306a36Sopenharmony_ci
43662306a36Sopenharmony_cistruct adapter_params {
43762306a36Sopenharmony_ci	struct sge_params sge;
43862306a36Sopenharmony_ci	struct tp_params  tp;
43962306a36Sopenharmony_ci	struct vpd_params vpd;
44062306a36Sopenharmony_ci	struct pf_resources pfres;
44162306a36Sopenharmony_ci	struct pci_params pci;
44262306a36Sopenharmony_ci	struct devlog_params devlog;
44362306a36Sopenharmony_ci	enum pcie_memwin drv_memwin;
44462306a36Sopenharmony_ci
44562306a36Sopenharmony_ci	unsigned int cim_la_size;
44662306a36Sopenharmony_ci
44762306a36Sopenharmony_ci	unsigned int sf_size;             /* serial flash size in bytes */
44862306a36Sopenharmony_ci	unsigned int sf_nsec;             /* # of flash sectors */
44962306a36Sopenharmony_ci
45062306a36Sopenharmony_ci	unsigned int fw_vers;		  /* firmware version */
45162306a36Sopenharmony_ci	unsigned int bs_vers;		  /* bootstrap version */
45262306a36Sopenharmony_ci	unsigned int tp_vers;		  /* TP microcode version */
45362306a36Sopenharmony_ci	unsigned int er_vers;		  /* expansion ROM version */
45462306a36Sopenharmony_ci	unsigned int scfg_vers;		  /* Serial Configuration version */
45562306a36Sopenharmony_ci	unsigned int vpd_vers;		  /* VPD Version */
45662306a36Sopenharmony_ci	u8 api_vers[7];
45762306a36Sopenharmony_ci
45862306a36Sopenharmony_ci	unsigned short mtus[NMTUS];
45962306a36Sopenharmony_ci	unsigned short a_wnd[NCCTRL_WIN];
46062306a36Sopenharmony_ci	unsigned short b_wnd[NCCTRL_WIN];
46162306a36Sopenharmony_ci
46262306a36Sopenharmony_ci	unsigned char nports;             /* # of ethernet ports */
46362306a36Sopenharmony_ci	unsigned char portvec;
46462306a36Sopenharmony_ci	enum chip_type chip;               /* chip code */
46562306a36Sopenharmony_ci	struct arch_specific_params arch;  /* chip specific params */
46662306a36Sopenharmony_ci	unsigned char offload;
46762306a36Sopenharmony_ci	unsigned char crypto;		/* HW capability for crypto */
46862306a36Sopenharmony_ci	unsigned char ethofld;		/* QoS support */
46962306a36Sopenharmony_ci
47062306a36Sopenharmony_ci	unsigned char bypass;
47162306a36Sopenharmony_ci	unsigned char hash_filter;
47262306a36Sopenharmony_ci
47362306a36Sopenharmony_ci	unsigned int ofldq_wr_cred;
47462306a36Sopenharmony_ci	bool ulptx_memwrite_dsgl;          /* use of T5 DSGL allowed */
47562306a36Sopenharmony_ci
47662306a36Sopenharmony_ci	unsigned int nsched_cls;          /* number of traffic classes */
47762306a36Sopenharmony_ci	unsigned int max_ordird_qp;       /* Max read depth per RDMA QP */
47862306a36Sopenharmony_ci	unsigned int max_ird_adapter;     /* Max read depth per adapter */
47962306a36Sopenharmony_ci	bool fr_nsmr_tpte_wr_support;	  /* FW support for FR_NSMR_TPTE_WR */
48062306a36Sopenharmony_ci	u8 fw_caps_support;		/* 32-bit Port Capabilities */
48162306a36Sopenharmony_ci	bool filter2_wr_support;	/* FW support for FILTER2_WR */
48262306a36Sopenharmony_ci	unsigned int viid_smt_extn_support:1; /* FW returns vin and smt index */
48362306a36Sopenharmony_ci
48462306a36Sopenharmony_ci	/* MPS Buffer Group Map[per Port].  Bit i is set if buffer group i is
48562306a36Sopenharmony_ci	 * used by the Port
48662306a36Sopenharmony_ci	 */
48762306a36Sopenharmony_ci	u8 mps_bg_map[MAX_NPORTS];	/* MPS Buffer Group Map */
48862306a36Sopenharmony_ci	bool write_w_imm_support;       /* FW supports WRITE_WITH_IMMEDIATE */
48962306a36Sopenharmony_ci	bool write_cmpl_support;        /* FW supports WRITE_CMPL */
49062306a36Sopenharmony_ci};
49162306a36Sopenharmony_ci
49262306a36Sopenharmony_ci/* State needed to monitor the forward progress of SGE Ingress DMA activities
49362306a36Sopenharmony_ci * and possible hangs.
49462306a36Sopenharmony_ci */
49562306a36Sopenharmony_cistruct sge_idma_monitor_state {
49662306a36Sopenharmony_ci	unsigned int idma_1s_thresh;	/* 1s threshold in Core Clock ticks */
49762306a36Sopenharmony_ci	unsigned int idma_stalled[2];	/* synthesized stalled timers in HZ */
49862306a36Sopenharmony_ci	unsigned int idma_state[2];	/* IDMA Hang detect state */
49962306a36Sopenharmony_ci	unsigned int idma_qid[2];	/* IDMA Hung Ingress Queue ID */
50062306a36Sopenharmony_ci	unsigned int idma_warn[2];	/* time to warning in HZ */
50162306a36Sopenharmony_ci};
50262306a36Sopenharmony_ci
50362306a36Sopenharmony_ci/* Firmware Mailbox Command/Reply log.  All values are in Host-Endian format.
50462306a36Sopenharmony_ci * The access and execute times are signed in order to accommodate negative
50562306a36Sopenharmony_ci * error returns.
50662306a36Sopenharmony_ci */
50762306a36Sopenharmony_cistruct mbox_cmd {
50862306a36Sopenharmony_ci	u64 cmd[MBOX_LEN / 8];		/* a Firmware Mailbox Command/Reply */
50962306a36Sopenharmony_ci	u64 timestamp;			/* OS-dependent timestamp */
51062306a36Sopenharmony_ci	u32 seqno;			/* sequence number */
51162306a36Sopenharmony_ci	s16 access;			/* time (ms) to access mailbox */
51262306a36Sopenharmony_ci	s16 execute;			/* time (ms) to execute */
51362306a36Sopenharmony_ci};
51462306a36Sopenharmony_ci
51562306a36Sopenharmony_cistruct mbox_cmd_log {
51662306a36Sopenharmony_ci	unsigned int size;		/* number of entries in the log */
51762306a36Sopenharmony_ci	unsigned int cursor;		/* next position in the log to write */
51862306a36Sopenharmony_ci	u32 seqno;			/* next sequence number */
51962306a36Sopenharmony_ci	/* variable length mailbox command log starts here */
52062306a36Sopenharmony_ci};
52162306a36Sopenharmony_ci
52262306a36Sopenharmony_ci/* Given a pointer to a Firmware Mailbox Command Log and a log entry index,
52362306a36Sopenharmony_ci * return a pointer to the specified entry.
52462306a36Sopenharmony_ci */
52562306a36Sopenharmony_cistatic inline struct mbox_cmd *mbox_cmd_log_entry(struct mbox_cmd_log *log,
52662306a36Sopenharmony_ci						  unsigned int entry_idx)
52762306a36Sopenharmony_ci{
52862306a36Sopenharmony_ci	return &((struct mbox_cmd *)&(log)[1])[entry_idx];
52962306a36Sopenharmony_ci}
53062306a36Sopenharmony_ci
53162306a36Sopenharmony_ci#define FW_VERSION(chip) ( \
53262306a36Sopenharmony_ci		FW_HDR_FW_VER_MAJOR_G(chip##FW_VERSION_MAJOR) | \
53362306a36Sopenharmony_ci		FW_HDR_FW_VER_MINOR_G(chip##FW_VERSION_MINOR) | \
53462306a36Sopenharmony_ci		FW_HDR_FW_VER_MICRO_G(chip##FW_VERSION_MICRO) | \
53562306a36Sopenharmony_ci		FW_HDR_FW_VER_BUILD_G(chip##FW_VERSION_BUILD))
53662306a36Sopenharmony_ci#define FW_INTFVER(chip, intf) (FW_HDR_INTFVER_##intf)
53762306a36Sopenharmony_ci
53862306a36Sopenharmony_cistruct cxgb4_ethtool_lb_test {
53962306a36Sopenharmony_ci	struct completion completion;
54062306a36Sopenharmony_ci	int result;
54162306a36Sopenharmony_ci	int loopback;
54262306a36Sopenharmony_ci};
54362306a36Sopenharmony_ci
54462306a36Sopenharmony_cistruct fw_info {
54562306a36Sopenharmony_ci	u8 chip;
54662306a36Sopenharmony_ci	char *fs_name;
54762306a36Sopenharmony_ci	char *fw_mod_name;
54862306a36Sopenharmony_ci	struct fw_hdr fw_hdr;
54962306a36Sopenharmony_ci};
55062306a36Sopenharmony_ci
55162306a36Sopenharmony_cistruct trace_params {
55262306a36Sopenharmony_ci	u32 data[TRACE_LEN / 4];
55362306a36Sopenharmony_ci	u32 mask[TRACE_LEN / 4];
55462306a36Sopenharmony_ci	unsigned short snap_len;
55562306a36Sopenharmony_ci	unsigned short min_len;
55662306a36Sopenharmony_ci	unsigned char skip_ofst;
55762306a36Sopenharmony_ci	unsigned char skip_len;
55862306a36Sopenharmony_ci	unsigned char invert;
55962306a36Sopenharmony_ci	unsigned char port;
56062306a36Sopenharmony_ci};
56162306a36Sopenharmony_ci
56262306a36Sopenharmony_cistruct cxgb4_fw_data {
56362306a36Sopenharmony_ci	__be32 signature;
56462306a36Sopenharmony_ci	__u8 reserved[4];
56562306a36Sopenharmony_ci};
56662306a36Sopenharmony_ci
56762306a36Sopenharmony_ci/* Firmware Port Capabilities types. */
56862306a36Sopenharmony_ci
56962306a36Sopenharmony_citypedef u16 fw_port_cap16_t;	/* 16-bit Port Capabilities integral value */
57062306a36Sopenharmony_citypedef u32 fw_port_cap32_t;	/* 32-bit Port Capabilities integral value */
57162306a36Sopenharmony_ci
57262306a36Sopenharmony_cienum fw_caps {
57362306a36Sopenharmony_ci	FW_CAPS_UNKNOWN	= 0,	/* 0'ed out initial state */
57462306a36Sopenharmony_ci	FW_CAPS16	= 1,	/* old Firmware: 16-bit Port Capabilities */
57562306a36Sopenharmony_ci	FW_CAPS32	= 2,	/* new Firmware: 32-bit Port Capabilities */
57662306a36Sopenharmony_ci};
57762306a36Sopenharmony_ci
57862306a36Sopenharmony_cistruct link_config {
57962306a36Sopenharmony_ci	fw_port_cap32_t pcaps;           /* link capabilities */
58062306a36Sopenharmony_ci	fw_port_cap32_t def_acaps;       /* default advertised capabilities */
58162306a36Sopenharmony_ci	fw_port_cap32_t acaps;           /* advertised capabilities */
58262306a36Sopenharmony_ci	fw_port_cap32_t lpacaps;         /* peer advertised capabilities */
58362306a36Sopenharmony_ci
58462306a36Sopenharmony_ci	fw_port_cap32_t speed_caps;      /* speed(s) user has requested */
58562306a36Sopenharmony_ci	unsigned int   speed;            /* actual link speed (Mb/s) */
58662306a36Sopenharmony_ci
58762306a36Sopenharmony_ci	enum cc_pause  requested_fc;     /* flow control user has requested */
58862306a36Sopenharmony_ci	enum cc_pause  fc;               /* actual link flow control */
58962306a36Sopenharmony_ci	enum cc_pause  advertised_fc;    /* actual advertised flow control */
59062306a36Sopenharmony_ci
59162306a36Sopenharmony_ci	enum cc_fec    requested_fec;	 /* Forward Error Correction: */
59262306a36Sopenharmony_ci	enum cc_fec    fec;		 /* requested and actual in use */
59362306a36Sopenharmony_ci
59462306a36Sopenharmony_ci	unsigned char  autoneg;          /* autonegotiating? */
59562306a36Sopenharmony_ci
59662306a36Sopenharmony_ci	unsigned char  link_ok;          /* link up? */
59762306a36Sopenharmony_ci	unsigned char  link_down_rc;     /* link down reason */
59862306a36Sopenharmony_ci
59962306a36Sopenharmony_ci	bool new_module;		 /* ->OS Transceiver Module inserted */
60062306a36Sopenharmony_ci	bool redo_l1cfg;		 /* ->CC redo current "sticky" L1 CFG */
60162306a36Sopenharmony_ci};
60262306a36Sopenharmony_ci
60362306a36Sopenharmony_ci#define FW_LEN16(fw_struct) FW_CMD_LEN16_V(sizeof(fw_struct) / 16)
60462306a36Sopenharmony_ci
60562306a36Sopenharmony_cienum {
60662306a36Sopenharmony_ci	MAX_ETH_QSETS = 32,           /* # of Ethernet Tx/Rx queue sets */
60762306a36Sopenharmony_ci	MAX_OFLD_QSETS = 16,          /* # of offload Tx, iscsi Rx queue sets */
60862306a36Sopenharmony_ci	MAX_CTRL_QUEUES = NCHAN,      /* # of control Tx queues */
60962306a36Sopenharmony_ci};
61062306a36Sopenharmony_ci
61162306a36Sopenharmony_cienum {
61262306a36Sopenharmony_ci	MAX_TXQ_ENTRIES      = 16384,
61362306a36Sopenharmony_ci	MAX_CTRL_TXQ_ENTRIES = 1024,
61462306a36Sopenharmony_ci	MAX_RSPQ_ENTRIES     = 16384,
61562306a36Sopenharmony_ci	MAX_RX_BUFFERS       = 16384,
61662306a36Sopenharmony_ci	MIN_TXQ_ENTRIES      = 32,
61762306a36Sopenharmony_ci	MIN_CTRL_TXQ_ENTRIES = 32,
61862306a36Sopenharmony_ci	MIN_RSPQ_ENTRIES     = 128,
61962306a36Sopenharmony_ci	MIN_FL_ENTRIES       = 16
62062306a36Sopenharmony_ci};
62162306a36Sopenharmony_ci
62262306a36Sopenharmony_cienum {
62362306a36Sopenharmony_ci	MAX_TXQ_DESC_SIZE      = 64,
62462306a36Sopenharmony_ci	MAX_RXQ_DESC_SIZE      = 128,
62562306a36Sopenharmony_ci	MAX_FL_DESC_SIZE       = 8,
62662306a36Sopenharmony_ci	MAX_CTRL_TXQ_DESC_SIZE = 64,
62762306a36Sopenharmony_ci};
62862306a36Sopenharmony_ci
62962306a36Sopenharmony_cienum {
63062306a36Sopenharmony_ci	INGQ_EXTRAS = 2,        /* firmware event queue and */
63162306a36Sopenharmony_ci				/*   forwarded interrupts */
63262306a36Sopenharmony_ci	MAX_INGQ = MAX_ETH_QSETS + INGQ_EXTRAS,
63362306a36Sopenharmony_ci};
63462306a36Sopenharmony_ci
63562306a36Sopenharmony_cienum {
63662306a36Sopenharmony_ci	PRIV_FLAG_PORT_TX_VM_BIT,
63762306a36Sopenharmony_ci};
63862306a36Sopenharmony_ci
63962306a36Sopenharmony_ci#define PRIV_FLAG_PORT_TX_VM		BIT(PRIV_FLAG_PORT_TX_VM_BIT)
64062306a36Sopenharmony_ci
64162306a36Sopenharmony_ci#define PRIV_FLAGS_ADAP			0
64262306a36Sopenharmony_ci#define PRIV_FLAGS_PORT			PRIV_FLAG_PORT_TX_VM
64362306a36Sopenharmony_ci
64462306a36Sopenharmony_cistruct adapter;
64562306a36Sopenharmony_cistruct sge_rspq;
64662306a36Sopenharmony_ci
64762306a36Sopenharmony_ci#include "cxgb4_dcb.h"
64862306a36Sopenharmony_ci
64962306a36Sopenharmony_ci#ifdef CONFIG_CHELSIO_T4_FCOE
65062306a36Sopenharmony_ci#include "cxgb4_fcoe.h"
65162306a36Sopenharmony_ci#endif /* CONFIG_CHELSIO_T4_FCOE */
65262306a36Sopenharmony_ci
65362306a36Sopenharmony_cistruct port_info {
65462306a36Sopenharmony_ci	struct adapter *adapter;
65562306a36Sopenharmony_ci	u16    viid;
65662306a36Sopenharmony_ci	int    xact_addr_filt;        /* index of exact MAC address filter */
65762306a36Sopenharmony_ci	u16    rss_size;              /* size of VI's RSS table slice */
65862306a36Sopenharmony_ci	s8     mdio_addr;
65962306a36Sopenharmony_ci	enum fw_port_type port_type;
66062306a36Sopenharmony_ci	u8     mod_type;
66162306a36Sopenharmony_ci	u8     port_id;
66262306a36Sopenharmony_ci	u8     tx_chan;
66362306a36Sopenharmony_ci	u8     lport;                 /* associated offload logical port */
66462306a36Sopenharmony_ci	u8     nqsets;                /* # of qsets */
66562306a36Sopenharmony_ci	u8     first_qset;            /* index of first qset */
66662306a36Sopenharmony_ci	u8     rss_mode;
66762306a36Sopenharmony_ci	struct link_config link_cfg;
66862306a36Sopenharmony_ci	u16   *rss;
66962306a36Sopenharmony_ci	struct port_stats stats_base;
67062306a36Sopenharmony_ci#ifdef CONFIG_CHELSIO_T4_DCB
67162306a36Sopenharmony_ci	struct port_dcb_info dcb;     /* Data Center Bridging support */
67262306a36Sopenharmony_ci#endif
67362306a36Sopenharmony_ci#ifdef CONFIG_CHELSIO_T4_FCOE
67462306a36Sopenharmony_ci	struct cxgb_fcoe fcoe;
67562306a36Sopenharmony_ci#endif /* CONFIG_CHELSIO_T4_FCOE */
67662306a36Sopenharmony_ci	bool rxtstamp;  /* Enable TS */
67762306a36Sopenharmony_ci	struct hwtstamp_config tstamp_config;
67862306a36Sopenharmony_ci	bool ptp_enable;
67962306a36Sopenharmony_ci	struct sched_table *sched_tbl;
68062306a36Sopenharmony_ci	u32 eth_flags;
68162306a36Sopenharmony_ci
68262306a36Sopenharmony_ci	/* viid and smt fields either returned by fw
68362306a36Sopenharmony_ci	 * or decoded by parsing viid by driver.
68462306a36Sopenharmony_ci	 */
68562306a36Sopenharmony_ci	u8 vin;
68662306a36Sopenharmony_ci	u8 vivld;
68762306a36Sopenharmony_ci	u8 smt_idx;
68862306a36Sopenharmony_ci	u8 rx_cchan;
68962306a36Sopenharmony_ci
69062306a36Sopenharmony_ci	bool tc_block_shared;
69162306a36Sopenharmony_ci
69262306a36Sopenharmony_ci	/* Mirror VI information */
69362306a36Sopenharmony_ci	u16 viid_mirror;
69462306a36Sopenharmony_ci	u16 nmirrorqsets;
69562306a36Sopenharmony_ci	u32 vi_mirror_count;
69662306a36Sopenharmony_ci	struct mutex vi_mirror_mutex; /* Sync access to Mirror VI info */
69762306a36Sopenharmony_ci	struct cxgb4_ethtool_lb_test ethtool_lb;
69862306a36Sopenharmony_ci};
69962306a36Sopenharmony_ci
70062306a36Sopenharmony_cistruct dentry;
70162306a36Sopenharmony_cistruct work_struct;
70262306a36Sopenharmony_ci
70362306a36Sopenharmony_cienum {                                 /* adapter flags */
70462306a36Sopenharmony_ci	CXGB4_FULL_INIT_DONE		= (1 << 0),
70562306a36Sopenharmony_ci	CXGB4_DEV_ENABLED		= (1 << 1),
70662306a36Sopenharmony_ci	CXGB4_USING_MSI			= (1 << 2),
70762306a36Sopenharmony_ci	CXGB4_USING_MSIX		= (1 << 3),
70862306a36Sopenharmony_ci	CXGB4_FW_OK			= (1 << 4),
70962306a36Sopenharmony_ci	CXGB4_RSS_TNLALLLOOKUP		= (1 << 5),
71062306a36Sopenharmony_ci	CXGB4_USING_SOFT_PARAMS		= (1 << 6),
71162306a36Sopenharmony_ci	CXGB4_MASTER_PF			= (1 << 7),
71262306a36Sopenharmony_ci	CXGB4_FW_OFLD_CONN		= (1 << 9),
71362306a36Sopenharmony_ci	CXGB4_ROOT_NO_RELAXED_ORDERING	= (1 << 10),
71462306a36Sopenharmony_ci	CXGB4_SHUTTING_DOWN		= (1 << 11),
71562306a36Sopenharmony_ci	CXGB4_SGE_DBQ_TIMER		= (1 << 12),
71662306a36Sopenharmony_ci};
71762306a36Sopenharmony_ci
71862306a36Sopenharmony_cienum {
71962306a36Sopenharmony_ci	ULP_CRYPTO_LOOKASIDE = 1 << 0,
72062306a36Sopenharmony_ci	ULP_CRYPTO_IPSEC_INLINE = 1 << 1,
72162306a36Sopenharmony_ci	ULP_CRYPTO_KTLS_INLINE  = 1 << 3,
72262306a36Sopenharmony_ci};
72362306a36Sopenharmony_ci
72462306a36Sopenharmony_ci#define CXGB4_MIRROR_RXQ_DEFAULT_DESC_NUM 1024
72562306a36Sopenharmony_ci#define CXGB4_MIRROR_RXQ_DEFAULT_DESC_SIZE 64
72662306a36Sopenharmony_ci#define CXGB4_MIRROR_RXQ_DEFAULT_INTR_USEC 5
72762306a36Sopenharmony_ci#define CXGB4_MIRROR_RXQ_DEFAULT_PKT_CNT 8
72862306a36Sopenharmony_ci
72962306a36Sopenharmony_ci#define CXGB4_MIRROR_FLQ_DEFAULT_DESC_NUM 72
73062306a36Sopenharmony_ci
73162306a36Sopenharmony_cistruct rx_sw_desc;
73262306a36Sopenharmony_ci
73362306a36Sopenharmony_cistruct sge_fl {                     /* SGE free-buffer queue state */
73462306a36Sopenharmony_ci	unsigned int avail;         /* # of available Rx buffers */
73562306a36Sopenharmony_ci	unsigned int pend_cred;     /* new buffers since last FL DB ring */
73662306a36Sopenharmony_ci	unsigned int cidx;          /* consumer index */
73762306a36Sopenharmony_ci	unsigned int pidx;          /* producer index */
73862306a36Sopenharmony_ci	unsigned long alloc_failed; /* # of times buffer allocation failed */
73962306a36Sopenharmony_ci	unsigned long large_alloc_failed;
74062306a36Sopenharmony_ci	unsigned long mapping_err;  /* # of RX Buffer DMA Mapping failures */
74162306a36Sopenharmony_ci	unsigned long low;          /* # of times momentarily starving */
74262306a36Sopenharmony_ci	unsigned long starving;
74362306a36Sopenharmony_ci	/* RO fields */
74462306a36Sopenharmony_ci	unsigned int cntxt_id;      /* SGE context id for the free list */
74562306a36Sopenharmony_ci	unsigned int size;          /* capacity of free list */
74662306a36Sopenharmony_ci	struct rx_sw_desc *sdesc;   /* address of SW Rx descriptor ring */
74762306a36Sopenharmony_ci	__be64 *desc;               /* address of HW Rx descriptor ring */
74862306a36Sopenharmony_ci	dma_addr_t addr;            /* bus address of HW ring start */
74962306a36Sopenharmony_ci	void __iomem *bar2_addr;    /* address of BAR2 Queue registers */
75062306a36Sopenharmony_ci	unsigned int bar2_qid;      /* Queue ID for BAR2 Queue registers */
75162306a36Sopenharmony_ci};
75262306a36Sopenharmony_ci
75362306a36Sopenharmony_ci/* A packet gather list */
75462306a36Sopenharmony_cistruct pkt_gl {
75562306a36Sopenharmony_ci	u64 sgetstamp;		    /* SGE Time Stamp for Ingress Packet */
75662306a36Sopenharmony_ci	struct page_frag frags[MAX_SKB_FRAGS];
75762306a36Sopenharmony_ci	void *va;                         /* virtual address of first byte */
75862306a36Sopenharmony_ci	unsigned int nfrags;              /* # of fragments */
75962306a36Sopenharmony_ci	unsigned int tot_len;             /* total length of fragments */
76062306a36Sopenharmony_ci};
76162306a36Sopenharmony_ci
76262306a36Sopenharmony_citypedef int (*rspq_handler_t)(struct sge_rspq *q, const __be64 *rsp,
76362306a36Sopenharmony_ci			      const struct pkt_gl *gl);
76462306a36Sopenharmony_citypedef void (*rspq_flush_handler_t)(struct sge_rspq *q);
76562306a36Sopenharmony_ci/* LRO related declarations for ULD */
76662306a36Sopenharmony_cistruct t4_lro_mgr {
76762306a36Sopenharmony_ci#define MAX_LRO_SESSIONS		64
76862306a36Sopenharmony_ci	u8 lro_session_cnt;         /* # of sessions to aggregate */
76962306a36Sopenharmony_ci	unsigned long lro_pkts;     /* # of LRO super packets */
77062306a36Sopenharmony_ci	unsigned long lro_merged;   /* # of wire packets merged by LRO */
77162306a36Sopenharmony_ci	struct sk_buff_head lroq;   /* list of aggregated sessions */
77262306a36Sopenharmony_ci};
77362306a36Sopenharmony_ci
77462306a36Sopenharmony_cistruct sge_rspq {                   /* state for an SGE response queue */
77562306a36Sopenharmony_ci	struct napi_struct napi;
77662306a36Sopenharmony_ci	const __be64 *cur_desc;     /* current descriptor in queue */
77762306a36Sopenharmony_ci	unsigned int cidx;          /* consumer index */
77862306a36Sopenharmony_ci	u8 gen;                     /* current generation bit */
77962306a36Sopenharmony_ci	u8 intr_params;             /* interrupt holdoff parameters */
78062306a36Sopenharmony_ci	u8 next_intr_params;        /* holdoff params for next interrupt */
78162306a36Sopenharmony_ci	u8 adaptive_rx;
78262306a36Sopenharmony_ci	u8 pktcnt_idx;              /* interrupt packet threshold */
78362306a36Sopenharmony_ci	u8 uld;                     /* ULD handling this queue */
78462306a36Sopenharmony_ci	u8 idx;                     /* queue index within its group */
78562306a36Sopenharmony_ci	int offset;                 /* offset into current Rx buffer */
78662306a36Sopenharmony_ci	u16 cntxt_id;               /* SGE context id for the response q */
78762306a36Sopenharmony_ci	u16 abs_id;                 /* absolute SGE id for the response q */
78862306a36Sopenharmony_ci	__be64 *desc;               /* address of HW response ring */
78962306a36Sopenharmony_ci	dma_addr_t phys_addr;       /* physical address of the ring */
79062306a36Sopenharmony_ci	void __iomem *bar2_addr;    /* address of BAR2 Queue registers */
79162306a36Sopenharmony_ci	unsigned int bar2_qid;      /* Queue ID for BAR2 Queue registers */
79262306a36Sopenharmony_ci	unsigned int iqe_len;       /* entry size */
79362306a36Sopenharmony_ci	unsigned int size;          /* capacity of response queue */
79462306a36Sopenharmony_ci	struct adapter *adap;
79562306a36Sopenharmony_ci	struct net_device *netdev;  /* associated net device */
79662306a36Sopenharmony_ci	rspq_handler_t handler;
79762306a36Sopenharmony_ci	rspq_flush_handler_t flush_handler;
79862306a36Sopenharmony_ci	struct t4_lro_mgr lro_mgr;
79962306a36Sopenharmony_ci};
80062306a36Sopenharmony_ci
80162306a36Sopenharmony_cistruct sge_eth_stats {              /* Ethernet queue statistics */
80262306a36Sopenharmony_ci	unsigned long pkts;         /* # of ethernet packets */
80362306a36Sopenharmony_ci	unsigned long lro_pkts;     /* # of LRO super packets */
80462306a36Sopenharmony_ci	unsigned long lro_merged;   /* # of wire packets merged by LRO */
80562306a36Sopenharmony_ci	unsigned long rx_cso;       /* # of Rx checksum offloads */
80662306a36Sopenharmony_ci	unsigned long vlan_ex;      /* # of Rx VLAN extractions */
80762306a36Sopenharmony_ci	unsigned long rx_drops;     /* # of packets dropped due to no mem */
80862306a36Sopenharmony_ci	unsigned long bad_rx_pkts;  /* # of packets with err_vec!=0 */
80962306a36Sopenharmony_ci};
81062306a36Sopenharmony_ci
81162306a36Sopenharmony_cistruct sge_eth_rxq {                /* SW Ethernet Rx queue */
81262306a36Sopenharmony_ci	struct sge_rspq rspq;
81362306a36Sopenharmony_ci	struct sge_fl fl;
81462306a36Sopenharmony_ci	struct sge_eth_stats stats;
81562306a36Sopenharmony_ci	struct msix_info *msix;
81662306a36Sopenharmony_ci} ____cacheline_aligned_in_smp;
81762306a36Sopenharmony_ci
81862306a36Sopenharmony_cistruct sge_ofld_stats {             /* offload queue statistics */
81962306a36Sopenharmony_ci	unsigned long pkts;         /* # of packets */
82062306a36Sopenharmony_ci	unsigned long imm;          /* # of immediate-data packets */
82162306a36Sopenharmony_ci	unsigned long an;           /* # of asynchronous notifications */
82262306a36Sopenharmony_ci	unsigned long nomem;        /* # of responses deferred due to no mem */
82362306a36Sopenharmony_ci};
82462306a36Sopenharmony_ci
82562306a36Sopenharmony_cistruct sge_ofld_rxq {               /* SW offload Rx queue */
82662306a36Sopenharmony_ci	struct sge_rspq rspq;
82762306a36Sopenharmony_ci	struct sge_fl fl;
82862306a36Sopenharmony_ci	struct sge_ofld_stats stats;
82962306a36Sopenharmony_ci	struct msix_info *msix;
83062306a36Sopenharmony_ci} ____cacheline_aligned_in_smp;
83162306a36Sopenharmony_ci
83262306a36Sopenharmony_cistruct tx_desc {
83362306a36Sopenharmony_ci	__be64 flit[8];
83462306a36Sopenharmony_ci};
83562306a36Sopenharmony_ci
83662306a36Sopenharmony_cistruct ulptx_sgl;
83762306a36Sopenharmony_ci
83862306a36Sopenharmony_cistruct tx_sw_desc {
83962306a36Sopenharmony_ci	struct sk_buff *skb; /* SKB to free after getting completion */
84062306a36Sopenharmony_ci	dma_addr_t addr[MAX_SKB_FRAGS + 1]; /* DMA mapped addresses */
84162306a36Sopenharmony_ci};
84262306a36Sopenharmony_ci
84362306a36Sopenharmony_cistruct sge_txq {
84462306a36Sopenharmony_ci	unsigned int  in_use;       /* # of in-use Tx descriptors */
84562306a36Sopenharmony_ci	unsigned int  q_type;	    /* Q type Eth/Ctrl/Ofld */
84662306a36Sopenharmony_ci	unsigned int  size;         /* # of descriptors */
84762306a36Sopenharmony_ci	unsigned int  cidx;         /* SW consumer index */
84862306a36Sopenharmony_ci	unsigned int  pidx;         /* producer index */
84962306a36Sopenharmony_ci	unsigned long stops;        /* # of times q has been stopped */
85062306a36Sopenharmony_ci	unsigned long restarts;     /* # of queue restarts */
85162306a36Sopenharmony_ci	unsigned int  cntxt_id;     /* SGE context id for the Tx q */
85262306a36Sopenharmony_ci	struct tx_desc *desc;       /* address of HW Tx descriptor ring */
85362306a36Sopenharmony_ci	struct tx_sw_desc *sdesc;   /* address of SW Tx descriptor ring */
85462306a36Sopenharmony_ci	struct sge_qstat *stat;     /* queue status entry */
85562306a36Sopenharmony_ci	dma_addr_t    phys_addr;    /* physical address of the ring */
85662306a36Sopenharmony_ci	spinlock_t db_lock;
85762306a36Sopenharmony_ci	int db_disabled;
85862306a36Sopenharmony_ci	unsigned short db_pidx;
85962306a36Sopenharmony_ci	unsigned short db_pidx_inc;
86062306a36Sopenharmony_ci	void __iomem *bar2_addr;    /* address of BAR2 Queue registers */
86162306a36Sopenharmony_ci	unsigned int bar2_qid;      /* Queue ID for BAR2 Queue registers */
86262306a36Sopenharmony_ci};
86362306a36Sopenharmony_ci
86462306a36Sopenharmony_cistruct sge_eth_txq {                /* state for an SGE Ethernet Tx queue */
86562306a36Sopenharmony_ci	struct sge_txq q;
86662306a36Sopenharmony_ci	struct netdev_queue *txq;   /* associated netdev TX queue */
86762306a36Sopenharmony_ci#ifdef CONFIG_CHELSIO_T4_DCB
86862306a36Sopenharmony_ci	u8 dcb_prio;		    /* DCB Priority bound to queue */
86962306a36Sopenharmony_ci#endif
87062306a36Sopenharmony_ci	u8 dbqt;                    /* SGE Doorbell Queue Timer in use */
87162306a36Sopenharmony_ci	unsigned int dbqtimerix;    /* SGE Doorbell Queue Timer Index */
87262306a36Sopenharmony_ci	unsigned long tso;          /* # of TSO requests */
87362306a36Sopenharmony_ci	unsigned long uso;          /* # of USO requests */
87462306a36Sopenharmony_ci	unsigned long tx_cso;       /* # of Tx checksum offloads */
87562306a36Sopenharmony_ci	unsigned long vlan_ins;     /* # of Tx VLAN insertions */
87662306a36Sopenharmony_ci	unsigned long mapping_err;  /* # of I/O MMU packet mapping errors */
87762306a36Sopenharmony_ci} ____cacheline_aligned_in_smp;
87862306a36Sopenharmony_ci
87962306a36Sopenharmony_cistruct sge_uld_txq {               /* state for an SGE offload Tx queue */
88062306a36Sopenharmony_ci	struct sge_txq q;
88162306a36Sopenharmony_ci	struct adapter *adap;
88262306a36Sopenharmony_ci	struct sk_buff_head sendq;  /* list of backpressured packets */
88362306a36Sopenharmony_ci	struct tasklet_struct qresume_tsk; /* restarts the queue */
88462306a36Sopenharmony_ci	bool service_ofldq_running; /* service_ofldq() is processing sendq */
88562306a36Sopenharmony_ci	u8 full;                    /* the Tx ring is full */
88662306a36Sopenharmony_ci	unsigned long mapping_err;  /* # of I/O MMU packet mapping errors */
88762306a36Sopenharmony_ci} ____cacheline_aligned_in_smp;
88862306a36Sopenharmony_ci
88962306a36Sopenharmony_cistruct sge_ctrl_txq {               /* state for an SGE control Tx queue */
89062306a36Sopenharmony_ci	struct sge_txq q;
89162306a36Sopenharmony_ci	struct adapter *adap;
89262306a36Sopenharmony_ci	struct sk_buff_head sendq;  /* list of backpressured packets */
89362306a36Sopenharmony_ci	struct tasklet_struct qresume_tsk; /* restarts the queue */
89462306a36Sopenharmony_ci	u8 full;                    /* the Tx ring is full */
89562306a36Sopenharmony_ci} ____cacheline_aligned_in_smp;
89662306a36Sopenharmony_ci
89762306a36Sopenharmony_cistruct sge_uld_rxq_info {
89862306a36Sopenharmony_ci	char name[IFNAMSIZ];	/* name of ULD driver */
89962306a36Sopenharmony_ci	struct sge_ofld_rxq *uldrxq; /* Rxq's for ULD */
90062306a36Sopenharmony_ci	u16 *rspq_id;		/* response queue id's of rxq */
90162306a36Sopenharmony_ci	u16 nrxq;		/* # of ingress uld queues */
90262306a36Sopenharmony_ci	u16 nciq;		/* # of completion queues */
90362306a36Sopenharmony_ci	u8 uld;			/* uld type */
90462306a36Sopenharmony_ci};
90562306a36Sopenharmony_ci
90662306a36Sopenharmony_cistruct sge_uld_txq_info {
90762306a36Sopenharmony_ci	struct sge_uld_txq *uldtxq; /* Txq's for ULD */
90862306a36Sopenharmony_ci	atomic_t users;		/* num users */
90962306a36Sopenharmony_ci	u16 ntxq;		/* # of egress uld queues */
91062306a36Sopenharmony_ci};
91162306a36Sopenharmony_ci
91262306a36Sopenharmony_ci/* struct to maintain ULD list to reallocate ULD resources on hotplug */
91362306a36Sopenharmony_cistruct cxgb4_uld_list {
91462306a36Sopenharmony_ci	struct cxgb4_uld_info uld_info;
91562306a36Sopenharmony_ci	struct list_head list_node;
91662306a36Sopenharmony_ci	enum cxgb4_uld uld_type;
91762306a36Sopenharmony_ci};
91862306a36Sopenharmony_ci
91962306a36Sopenharmony_cienum sge_eosw_state {
92062306a36Sopenharmony_ci	CXGB4_EO_STATE_CLOSED = 0, /* Not ready to accept traffic */
92162306a36Sopenharmony_ci	CXGB4_EO_STATE_FLOWC_OPEN_SEND, /* Send FLOWC open request */
92262306a36Sopenharmony_ci	CXGB4_EO_STATE_FLOWC_OPEN_REPLY, /* Waiting for FLOWC open reply */
92362306a36Sopenharmony_ci	CXGB4_EO_STATE_ACTIVE, /* Ready to accept traffic */
92462306a36Sopenharmony_ci	CXGB4_EO_STATE_FLOWC_CLOSE_SEND, /* Send FLOWC close request */
92562306a36Sopenharmony_ci	CXGB4_EO_STATE_FLOWC_CLOSE_REPLY, /* Waiting for FLOWC close reply */
92662306a36Sopenharmony_ci};
92762306a36Sopenharmony_ci
92862306a36Sopenharmony_cistruct sge_eosw_txq {
92962306a36Sopenharmony_ci	spinlock_t lock; /* Per queue lock to synchronize completions */
93062306a36Sopenharmony_ci	enum sge_eosw_state state; /* Current ETHOFLD State */
93162306a36Sopenharmony_ci	struct tx_sw_desc *desc; /* Descriptor ring to hold packets */
93262306a36Sopenharmony_ci	u32 ndesc; /* Number of descriptors */
93362306a36Sopenharmony_ci	u32 pidx; /* Current Producer Index */
93462306a36Sopenharmony_ci	u32 last_pidx; /* Last successfully transmitted Producer Index */
93562306a36Sopenharmony_ci	u32 cidx; /* Current Consumer Index */
93662306a36Sopenharmony_ci	u32 last_cidx; /* Last successfully reclaimed Consumer Index */
93762306a36Sopenharmony_ci	u32 flowc_idx; /* Descriptor containing a FLOWC request */
93862306a36Sopenharmony_ci	u32 inuse; /* Number of packets held in ring */
93962306a36Sopenharmony_ci
94062306a36Sopenharmony_ci	u32 cred; /* Current available credits */
94162306a36Sopenharmony_ci	u32 ncompl; /* # of completions posted */
94262306a36Sopenharmony_ci	u32 last_compl; /* # of credits consumed since last completion req */
94362306a36Sopenharmony_ci
94462306a36Sopenharmony_ci	u32 eotid; /* Index into EOTID table in software */
94562306a36Sopenharmony_ci	u32 hwtid; /* Hardware EOTID index */
94662306a36Sopenharmony_ci
94762306a36Sopenharmony_ci	u32 hwqid; /* Underlying hardware queue index */
94862306a36Sopenharmony_ci	struct net_device *netdev; /* Pointer to netdevice */
94962306a36Sopenharmony_ci	struct tasklet_struct qresume_tsk; /* Restarts the queue */
95062306a36Sopenharmony_ci	struct completion completion; /* completion for FLOWC rendezvous */
95162306a36Sopenharmony_ci};
95262306a36Sopenharmony_ci
95362306a36Sopenharmony_cistruct sge_eohw_txq {
95462306a36Sopenharmony_ci	spinlock_t lock; /* Per queue lock */
95562306a36Sopenharmony_ci	struct sge_txq q; /* HW Txq */
95662306a36Sopenharmony_ci	struct adapter *adap; /* Backpointer to adapter */
95762306a36Sopenharmony_ci	unsigned long tso; /* # of TSO requests */
95862306a36Sopenharmony_ci	unsigned long uso; /* # of USO requests */
95962306a36Sopenharmony_ci	unsigned long tx_cso; /* # of Tx checksum offloads */
96062306a36Sopenharmony_ci	unsigned long vlan_ins; /* # of Tx VLAN insertions */
96162306a36Sopenharmony_ci	unsigned long mapping_err; /* # of I/O MMU packet mapping errors */
96262306a36Sopenharmony_ci};
96362306a36Sopenharmony_ci
96462306a36Sopenharmony_cistruct sge {
96562306a36Sopenharmony_ci	struct sge_eth_txq ethtxq[MAX_ETH_QSETS];
96662306a36Sopenharmony_ci	struct sge_eth_txq ptptxq;
96762306a36Sopenharmony_ci	struct sge_ctrl_txq ctrlq[MAX_CTRL_QUEUES];
96862306a36Sopenharmony_ci
96962306a36Sopenharmony_ci	struct sge_eth_rxq ethrxq[MAX_ETH_QSETS];
97062306a36Sopenharmony_ci	struct sge_rspq fw_evtq ____cacheline_aligned_in_smp;
97162306a36Sopenharmony_ci	struct sge_uld_rxq_info **uld_rxq_info;
97262306a36Sopenharmony_ci	struct sge_uld_txq_info **uld_txq_info;
97362306a36Sopenharmony_ci
97462306a36Sopenharmony_ci	struct sge_rspq intrq ____cacheline_aligned_in_smp;
97562306a36Sopenharmony_ci	spinlock_t intrq_lock;
97662306a36Sopenharmony_ci
97762306a36Sopenharmony_ci	struct sge_eohw_txq *eohw_txq;
97862306a36Sopenharmony_ci	struct sge_ofld_rxq *eohw_rxq;
97962306a36Sopenharmony_ci
98062306a36Sopenharmony_ci	struct sge_eth_rxq *mirror_rxq[NCHAN];
98162306a36Sopenharmony_ci
98262306a36Sopenharmony_ci	u16 max_ethqsets;           /* # of available Ethernet queue sets */
98362306a36Sopenharmony_ci	u16 ethqsets;               /* # of active Ethernet queue sets */
98462306a36Sopenharmony_ci	u16 ethtxq_rover;           /* Tx queue to clean up next */
98562306a36Sopenharmony_ci	u16 ofldqsets;              /* # of active ofld queue sets */
98662306a36Sopenharmony_ci	u16 nqs_per_uld;	    /* # of Rx queues per ULD */
98762306a36Sopenharmony_ci	u16 eoqsets;                /* # of ETHOFLD queues */
98862306a36Sopenharmony_ci	u16 mirrorqsets;            /* # of Mirror queues */
98962306a36Sopenharmony_ci
99062306a36Sopenharmony_ci	u16 timer_val[SGE_NTIMERS];
99162306a36Sopenharmony_ci	u8 counter_val[SGE_NCOUNTERS];
99262306a36Sopenharmony_ci	u16 dbqtimer_tick;
99362306a36Sopenharmony_ci	u16 dbqtimer_val[SGE_NDBQTIMERS];
99462306a36Sopenharmony_ci	u32 fl_pg_order;            /* large page allocation size */
99562306a36Sopenharmony_ci	u32 stat_len;               /* length of status page at ring end */
99662306a36Sopenharmony_ci	u32 pktshift;               /* padding between CPL & packet data */
99762306a36Sopenharmony_ci	u32 fl_align;               /* response queue message alignment */
99862306a36Sopenharmony_ci	u32 fl_starve_thres;        /* Free List starvation threshold */
99962306a36Sopenharmony_ci
100062306a36Sopenharmony_ci	struct sge_idma_monitor_state idma_monitor;
100162306a36Sopenharmony_ci	unsigned int egr_start;
100262306a36Sopenharmony_ci	unsigned int egr_sz;
100362306a36Sopenharmony_ci	unsigned int ingr_start;
100462306a36Sopenharmony_ci	unsigned int ingr_sz;
100562306a36Sopenharmony_ci	void **egr_map;    /* qid->queue egress queue map */
100662306a36Sopenharmony_ci	struct sge_rspq **ingr_map; /* qid->queue ingress queue map */
100762306a36Sopenharmony_ci	unsigned long *starving_fl;
100862306a36Sopenharmony_ci	unsigned long *txq_maperr;
100962306a36Sopenharmony_ci	unsigned long *blocked_fl;
101062306a36Sopenharmony_ci	struct timer_list rx_timer; /* refills starving FLs */
101162306a36Sopenharmony_ci	struct timer_list tx_timer; /* checks Tx queues */
101262306a36Sopenharmony_ci
101362306a36Sopenharmony_ci	int fwevtq_msix_idx; /* Index to firmware event queue MSI-X info */
101462306a36Sopenharmony_ci	int nd_msix_idx; /* Index to non-data interrupts MSI-X info */
101562306a36Sopenharmony_ci};
101662306a36Sopenharmony_ci
101762306a36Sopenharmony_ci#define for_each_ethrxq(sge, i) for (i = 0; i < (sge)->ethqsets; i++)
101862306a36Sopenharmony_ci#define for_each_ofldtxq(sge, i) for (i = 0; i < (sge)->ofldqsets; i++)
101962306a36Sopenharmony_ci
102062306a36Sopenharmony_cistruct l2t_data;
102162306a36Sopenharmony_ci
102262306a36Sopenharmony_ci#ifdef CONFIG_PCI_IOV
102362306a36Sopenharmony_ci
102462306a36Sopenharmony_ci/* T4 supports SRIOV on PF0-3 and T5 on PF0-7.  However, the Serial
102562306a36Sopenharmony_ci * Configuration initialization for T5 only has SR-IOV functionality enabled
102662306a36Sopenharmony_ci * on PF0-3 in order to simplify everything.
102762306a36Sopenharmony_ci */
102862306a36Sopenharmony_ci#define NUM_OF_PF_WITH_SRIOV 4
102962306a36Sopenharmony_ci
103062306a36Sopenharmony_ci#endif
103162306a36Sopenharmony_ci
103262306a36Sopenharmony_cistruct doorbell_stats {
103362306a36Sopenharmony_ci	u32 db_drop;
103462306a36Sopenharmony_ci	u32 db_empty;
103562306a36Sopenharmony_ci	u32 db_full;
103662306a36Sopenharmony_ci};
103762306a36Sopenharmony_ci
103862306a36Sopenharmony_cistruct hash_mac_addr {
103962306a36Sopenharmony_ci	struct list_head list;
104062306a36Sopenharmony_ci	u8 addr[ETH_ALEN];
104162306a36Sopenharmony_ci	unsigned int iface_mac;
104262306a36Sopenharmony_ci};
104362306a36Sopenharmony_ci
104462306a36Sopenharmony_cistruct msix_bmap {
104562306a36Sopenharmony_ci	unsigned long *msix_bmap;
104662306a36Sopenharmony_ci	unsigned int mapsize;
104762306a36Sopenharmony_ci	spinlock_t lock; /* lock for acquiring bitmap */
104862306a36Sopenharmony_ci};
104962306a36Sopenharmony_ci
105062306a36Sopenharmony_cistruct msix_info {
105162306a36Sopenharmony_ci	unsigned short vec;
105262306a36Sopenharmony_ci	char desc[IFNAMSIZ + 10];
105362306a36Sopenharmony_ci	unsigned int idx;
105462306a36Sopenharmony_ci	cpumask_var_t aff_mask;
105562306a36Sopenharmony_ci};
105662306a36Sopenharmony_ci
105762306a36Sopenharmony_cistruct vf_info {
105862306a36Sopenharmony_ci	unsigned char vf_mac_addr[ETH_ALEN];
105962306a36Sopenharmony_ci	unsigned int tx_rate;
106062306a36Sopenharmony_ci	bool pf_set_mac;
106162306a36Sopenharmony_ci	u16 vlan;
106262306a36Sopenharmony_ci	int link_state;
106362306a36Sopenharmony_ci};
106462306a36Sopenharmony_ci
106562306a36Sopenharmony_cienum {
106662306a36Sopenharmony_ci	HMA_DMA_MAPPED_FLAG = 1
106762306a36Sopenharmony_ci};
106862306a36Sopenharmony_ci
106962306a36Sopenharmony_cistruct hma_data {
107062306a36Sopenharmony_ci	unsigned char flags;
107162306a36Sopenharmony_ci	struct sg_table *sgt;
107262306a36Sopenharmony_ci	dma_addr_t *phy_addr;	/* physical address of the page */
107362306a36Sopenharmony_ci};
107462306a36Sopenharmony_ci
107562306a36Sopenharmony_cistruct mbox_list {
107662306a36Sopenharmony_ci	struct list_head list;
107762306a36Sopenharmony_ci};
107862306a36Sopenharmony_ci
107962306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_THERMAL)
108062306a36Sopenharmony_cistruct ch_thermal {
108162306a36Sopenharmony_ci	struct thermal_zone_device *tzdev;
108262306a36Sopenharmony_ci};
108362306a36Sopenharmony_ci#endif
108462306a36Sopenharmony_ci
108562306a36Sopenharmony_cistruct mps_entries_ref {
108662306a36Sopenharmony_ci	struct list_head list;
108762306a36Sopenharmony_ci	u8 addr[ETH_ALEN];
108862306a36Sopenharmony_ci	u8 mask[ETH_ALEN];
108962306a36Sopenharmony_ci	u16 idx;
109062306a36Sopenharmony_ci	refcount_t refcnt;
109162306a36Sopenharmony_ci};
109262306a36Sopenharmony_ci
109362306a36Sopenharmony_cistruct cxgb4_ethtool_filter_info {
109462306a36Sopenharmony_ci	u32 *loc_array; /* Array holding the actual TIDs set to filters */
109562306a36Sopenharmony_ci	unsigned long *bmap; /* Bitmap for managing filters in use */
109662306a36Sopenharmony_ci	u32 in_use; /* # of filters in use */
109762306a36Sopenharmony_ci};
109862306a36Sopenharmony_ci
109962306a36Sopenharmony_cistruct cxgb4_ethtool_filter {
110062306a36Sopenharmony_ci	u32 nentries; /* Adapter wide number of supported filters */
110162306a36Sopenharmony_ci	struct cxgb4_ethtool_filter_info *port; /* Per port entry */
110262306a36Sopenharmony_ci};
110362306a36Sopenharmony_ci
110462306a36Sopenharmony_cistruct adapter {
110562306a36Sopenharmony_ci	void __iomem *regs;
110662306a36Sopenharmony_ci	void __iomem *bar2;
110762306a36Sopenharmony_ci	u32 t4_bar0;
110862306a36Sopenharmony_ci	struct pci_dev *pdev;
110962306a36Sopenharmony_ci	struct device *pdev_dev;
111062306a36Sopenharmony_ci	const char *name;
111162306a36Sopenharmony_ci	unsigned int mbox;
111262306a36Sopenharmony_ci	unsigned int pf;
111362306a36Sopenharmony_ci	unsigned int flags;
111462306a36Sopenharmony_ci	unsigned int adap_idx;
111562306a36Sopenharmony_ci	enum chip_type chip;
111662306a36Sopenharmony_ci	u32 eth_flags;
111762306a36Sopenharmony_ci
111862306a36Sopenharmony_ci	int msg_enable;
111962306a36Sopenharmony_ci	__be16 vxlan_port;
112062306a36Sopenharmony_ci	__be16 geneve_port;
112162306a36Sopenharmony_ci
112262306a36Sopenharmony_ci	struct adapter_params params;
112362306a36Sopenharmony_ci	struct cxgb4_virt_res vres;
112462306a36Sopenharmony_ci	unsigned int swintr;
112562306a36Sopenharmony_ci
112662306a36Sopenharmony_ci	/* MSI-X Info for NIC and OFLD queues */
112762306a36Sopenharmony_ci	struct msix_info *msix_info;
112862306a36Sopenharmony_ci	struct msix_bmap msix_bmap;
112962306a36Sopenharmony_ci
113062306a36Sopenharmony_ci	struct doorbell_stats db_stats;
113162306a36Sopenharmony_ci	struct sge sge;
113262306a36Sopenharmony_ci
113362306a36Sopenharmony_ci	struct net_device *port[MAX_NPORTS];
113462306a36Sopenharmony_ci	u8 chan_map[NCHAN];                   /* channel -> port map */
113562306a36Sopenharmony_ci
113662306a36Sopenharmony_ci	struct vf_info *vfinfo;
113762306a36Sopenharmony_ci	u8 num_vfs;
113862306a36Sopenharmony_ci
113962306a36Sopenharmony_ci	u32 filter_mode;
114062306a36Sopenharmony_ci	unsigned int l2t_start;
114162306a36Sopenharmony_ci	unsigned int l2t_end;
114262306a36Sopenharmony_ci	struct l2t_data *l2t;
114362306a36Sopenharmony_ci	unsigned int clipt_start;
114462306a36Sopenharmony_ci	unsigned int clipt_end;
114562306a36Sopenharmony_ci	struct clip_tbl *clipt;
114662306a36Sopenharmony_ci	unsigned int rawf_start;
114762306a36Sopenharmony_ci	unsigned int rawf_cnt;
114862306a36Sopenharmony_ci	struct smt_data *smt;
114962306a36Sopenharmony_ci	struct cxgb4_uld_info *uld;
115062306a36Sopenharmony_ci	void *uld_handle[CXGB4_ULD_MAX];
115162306a36Sopenharmony_ci	unsigned int num_uld;
115262306a36Sopenharmony_ci	unsigned int num_ofld_uld;
115362306a36Sopenharmony_ci	struct list_head list_node;
115462306a36Sopenharmony_ci	struct list_head rcu_node;
115562306a36Sopenharmony_ci	struct list_head mac_hlist; /* list of MAC addresses in MPS Hash */
115662306a36Sopenharmony_ci	struct list_head mps_ref;
115762306a36Sopenharmony_ci	spinlock_t mps_ref_lock; /* lock for syncing mps ref/def activities */
115862306a36Sopenharmony_ci
115962306a36Sopenharmony_ci	void *iscsi_ppm;
116062306a36Sopenharmony_ci
116162306a36Sopenharmony_ci	struct tid_info tids;
116262306a36Sopenharmony_ci	void **tid_release_head;
116362306a36Sopenharmony_ci	spinlock_t tid_release_lock;
116462306a36Sopenharmony_ci	struct workqueue_struct *workq;
116562306a36Sopenharmony_ci	struct work_struct tid_release_task;
116662306a36Sopenharmony_ci	struct work_struct db_full_task;
116762306a36Sopenharmony_ci	struct work_struct db_drop_task;
116862306a36Sopenharmony_ci	struct work_struct fatal_err_notify_task;
116962306a36Sopenharmony_ci	bool tid_release_task_busy;
117062306a36Sopenharmony_ci
117162306a36Sopenharmony_ci	/* lock for mailbox cmd list */
117262306a36Sopenharmony_ci	spinlock_t mbox_lock;
117362306a36Sopenharmony_ci	struct mbox_list mlist;
117462306a36Sopenharmony_ci
117562306a36Sopenharmony_ci	/* support for mailbox command/reply logging */
117662306a36Sopenharmony_ci#define T4_OS_LOG_MBOX_CMDS 256
117762306a36Sopenharmony_ci	struct mbox_cmd_log *mbox_log;
117862306a36Sopenharmony_ci
117962306a36Sopenharmony_ci	struct mutex uld_mutex;
118062306a36Sopenharmony_ci
118162306a36Sopenharmony_ci	struct dentry *debugfs_root;
118262306a36Sopenharmony_ci	bool use_bd;     /* Use SGE Back Door intfc for reading SGE Contexts */
118362306a36Sopenharmony_ci	bool trace_rss;	/* 1 implies that different RSS flit per filter is
118462306a36Sopenharmony_ci			 * used per filter else if 0 default RSS flit is
118562306a36Sopenharmony_ci			 * used for all 4 filters.
118662306a36Sopenharmony_ci			 */
118762306a36Sopenharmony_ci
118862306a36Sopenharmony_ci	struct ptp_clock *ptp_clock;
118962306a36Sopenharmony_ci	struct ptp_clock_info ptp_clock_info;
119062306a36Sopenharmony_ci	struct sk_buff *ptp_tx_skb;
119162306a36Sopenharmony_ci	/* ptp lock */
119262306a36Sopenharmony_ci	spinlock_t ptp_lock;
119362306a36Sopenharmony_ci	spinlock_t stats_lock;
119462306a36Sopenharmony_ci	spinlock_t win0_lock ____cacheline_aligned_in_smp;
119562306a36Sopenharmony_ci
119662306a36Sopenharmony_ci	/* TC u32 offload */
119762306a36Sopenharmony_ci	struct cxgb4_tc_u32_table *tc_u32;
119862306a36Sopenharmony_ci	struct chcr_ktls chcr_ktls;
119962306a36Sopenharmony_ci	struct chcr_stats_debug chcr_stats;
120062306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_CHELSIO_TLS_DEVICE)
120162306a36Sopenharmony_ci	struct ch_ktls_stats_debug ch_ktls_stats;
120262306a36Sopenharmony_ci#endif
120362306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_CHELSIO_IPSEC_INLINE)
120462306a36Sopenharmony_ci	struct ch_ipsec_stats_debug ch_ipsec_stats;
120562306a36Sopenharmony_ci#endif
120662306a36Sopenharmony_ci
120762306a36Sopenharmony_ci	/* TC flower offload */
120862306a36Sopenharmony_ci	bool tc_flower_initialized;
120962306a36Sopenharmony_ci	struct rhashtable flower_tbl;
121062306a36Sopenharmony_ci	struct rhashtable_params flower_ht_params;
121162306a36Sopenharmony_ci	struct timer_list flower_stats_timer;
121262306a36Sopenharmony_ci	struct work_struct flower_stats_work;
121362306a36Sopenharmony_ci
121462306a36Sopenharmony_ci	/* Ethtool Dump */
121562306a36Sopenharmony_ci	struct ethtool_dump eth_dump;
121662306a36Sopenharmony_ci
121762306a36Sopenharmony_ci	/* HMA */
121862306a36Sopenharmony_ci	struct hma_data hma;
121962306a36Sopenharmony_ci
122062306a36Sopenharmony_ci	struct srq_data *srq;
122162306a36Sopenharmony_ci
122262306a36Sopenharmony_ci	/* Dump buffer for collecting logs in kdump kernel */
122362306a36Sopenharmony_ci	struct vmcoredd_data vmcoredd;
122462306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_THERMAL)
122562306a36Sopenharmony_ci	struct ch_thermal ch_thermal;
122662306a36Sopenharmony_ci#endif
122762306a36Sopenharmony_ci
122862306a36Sopenharmony_ci	/* TC MQPRIO offload */
122962306a36Sopenharmony_ci	struct cxgb4_tc_mqprio *tc_mqprio;
123062306a36Sopenharmony_ci
123162306a36Sopenharmony_ci	/* TC MATCHALL classifier offload */
123262306a36Sopenharmony_ci	struct cxgb4_tc_matchall *tc_matchall;
123362306a36Sopenharmony_ci
123462306a36Sopenharmony_ci	/* Ethtool n-tuple */
123562306a36Sopenharmony_ci	struct cxgb4_ethtool_filter *ethtool_filters;
123662306a36Sopenharmony_ci};
123762306a36Sopenharmony_ci
123862306a36Sopenharmony_ci/* Support for "sched-class" command to allow a TX Scheduling Class to be
123962306a36Sopenharmony_ci * programmed with various parameters.
124062306a36Sopenharmony_ci */
124162306a36Sopenharmony_cistruct ch_sched_params {
124262306a36Sopenharmony_ci	u8   type;                     /* packet or flow */
124362306a36Sopenharmony_ci	union {
124462306a36Sopenharmony_ci		struct {
124562306a36Sopenharmony_ci			u8   level;    /* scheduler hierarchy level */
124662306a36Sopenharmony_ci			u8   mode;     /* per-class or per-flow */
124762306a36Sopenharmony_ci			u8   rateunit; /* bit or packet rate */
124862306a36Sopenharmony_ci			u8   ratemode; /* %port relative or kbps absolute */
124962306a36Sopenharmony_ci			u8   channel;  /* scheduler channel [0..N] */
125062306a36Sopenharmony_ci			u8   class;    /* scheduler class [0..N] */
125162306a36Sopenharmony_ci			u32  minrate;  /* minimum rate */
125262306a36Sopenharmony_ci			u32  maxrate;  /* maximum rate */
125362306a36Sopenharmony_ci			u16  weight;   /* percent weight */
125462306a36Sopenharmony_ci			u16  pktsize;  /* average packet size */
125562306a36Sopenharmony_ci			u16  burstsize;  /* burst buffer size */
125662306a36Sopenharmony_ci		} params;
125762306a36Sopenharmony_ci	} u;
125862306a36Sopenharmony_ci};
125962306a36Sopenharmony_ci
126062306a36Sopenharmony_cienum {
126162306a36Sopenharmony_ci	SCHED_CLASS_TYPE_PACKET = 0,    /* class type */
126262306a36Sopenharmony_ci};
126362306a36Sopenharmony_ci
126462306a36Sopenharmony_cienum {
126562306a36Sopenharmony_ci	SCHED_CLASS_LEVEL_CL_RL = 0,    /* class rate limiter */
126662306a36Sopenharmony_ci	SCHED_CLASS_LEVEL_CH_RL = 2,    /* channel rate limiter */
126762306a36Sopenharmony_ci};
126862306a36Sopenharmony_ci
126962306a36Sopenharmony_cienum {
127062306a36Sopenharmony_ci	SCHED_CLASS_MODE_CLASS = 0,     /* per-class scheduling */
127162306a36Sopenharmony_ci	SCHED_CLASS_MODE_FLOW,          /* per-flow scheduling */
127262306a36Sopenharmony_ci};
127362306a36Sopenharmony_ci
127462306a36Sopenharmony_cienum {
127562306a36Sopenharmony_ci	SCHED_CLASS_RATEUNIT_BITS = 0,  /* bit rate scheduling */
127662306a36Sopenharmony_ci};
127762306a36Sopenharmony_ci
127862306a36Sopenharmony_cienum {
127962306a36Sopenharmony_ci	SCHED_CLASS_RATEMODE_ABS = 1,   /* Kb/s */
128062306a36Sopenharmony_ci};
128162306a36Sopenharmony_ci
128262306a36Sopenharmony_ci/* Support for "sched_queue" command to allow one or more NIC TX Queues
128362306a36Sopenharmony_ci * to be bound to a TX Scheduling Class.
128462306a36Sopenharmony_ci */
128562306a36Sopenharmony_cistruct ch_sched_queue {
128662306a36Sopenharmony_ci	s8   queue;    /* queue index */
128762306a36Sopenharmony_ci	s8   class;    /* class index */
128862306a36Sopenharmony_ci};
128962306a36Sopenharmony_ci
129062306a36Sopenharmony_ci/* Support for "sched_flowc" command to allow one or more FLOWC
129162306a36Sopenharmony_ci * to be bound to a TX Scheduling Class.
129262306a36Sopenharmony_ci */
129362306a36Sopenharmony_cistruct ch_sched_flowc {
129462306a36Sopenharmony_ci	s32 tid;   /* TID to bind */
129562306a36Sopenharmony_ci	s8  class; /* class index */
129662306a36Sopenharmony_ci};
129762306a36Sopenharmony_ci
129862306a36Sopenharmony_ci/* Defined bit width of user definable filter tuples
129962306a36Sopenharmony_ci */
130062306a36Sopenharmony_ci#define ETHTYPE_BITWIDTH 16
130162306a36Sopenharmony_ci#define FRAG_BITWIDTH 1
130262306a36Sopenharmony_ci#define MACIDX_BITWIDTH 9
130362306a36Sopenharmony_ci#define FCOE_BITWIDTH 1
130462306a36Sopenharmony_ci#define IPORT_BITWIDTH 3
130562306a36Sopenharmony_ci#define MATCHTYPE_BITWIDTH 3
130662306a36Sopenharmony_ci#define PROTO_BITWIDTH 8
130762306a36Sopenharmony_ci#define TOS_BITWIDTH 8
130862306a36Sopenharmony_ci#define PF_BITWIDTH 8
130962306a36Sopenharmony_ci#define VF_BITWIDTH 8
131062306a36Sopenharmony_ci#define IVLAN_BITWIDTH 16
131162306a36Sopenharmony_ci#define OVLAN_BITWIDTH 16
131262306a36Sopenharmony_ci#define ENCAP_VNI_BITWIDTH 24
131362306a36Sopenharmony_ci
131462306a36Sopenharmony_ci/* Filter matching rules.  These consist of a set of ingress packet field
131562306a36Sopenharmony_ci * (value, mask) tuples.  The associated ingress packet field matches the
131662306a36Sopenharmony_ci * tuple when ((field & mask) == value).  (Thus a wildcard "don't care" field
131762306a36Sopenharmony_ci * rule can be constructed by specifying a tuple of (0, 0).)  A filter rule
131862306a36Sopenharmony_ci * matches an ingress packet when all of the individual individual field
131962306a36Sopenharmony_ci * matching rules are true.
132062306a36Sopenharmony_ci *
132162306a36Sopenharmony_ci * Partial field masks are always valid, however, while it may be easy to
132262306a36Sopenharmony_ci * understand their meanings for some fields (e.g. IP address to match a
132362306a36Sopenharmony_ci * subnet), for others making sensible partial masks is less intuitive (e.g.
132462306a36Sopenharmony_ci * MPS match type) ...
132562306a36Sopenharmony_ci *
132662306a36Sopenharmony_ci * Most of the following data structures are modeled on T4 capabilities.
132762306a36Sopenharmony_ci * Drivers for earlier chips use the subsets which make sense for those chips.
132862306a36Sopenharmony_ci * We really need to come up with a hardware-independent mechanism to
132962306a36Sopenharmony_ci * represent hardware filter capabilities ...
133062306a36Sopenharmony_ci */
133162306a36Sopenharmony_cistruct ch_filter_tuple {
133262306a36Sopenharmony_ci	/* Compressed header matching field rules.  The TP_VLAN_PRI_MAP
133362306a36Sopenharmony_ci	 * register selects which of these fields will participate in the
133462306a36Sopenharmony_ci	 * filter match rules -- up to a maximum of 36 bits.  Because
133562306a36Sopenharmony_ci	 * TP_VLAN_PRI_MAP is a global register, all filters must use the same
133662306a36Sopenharmony_ci	 * set of fields.
133762306a36Sopenharmony_ci	 */
133862306a36Sopenharmony_ci	uint32_t ethtype:ETHTYPE_BITWIDTH;      /* Ethernet type */
133962306a36Sopenharmony_ci	uint32_t frag:FRAG_BITWIDTH;            /* IP fragmentation header */
134062306a36Sopenharmony_ci	uint32_t ivlan_vld:1;                   /* inner VLAN valid */
134162306a36Sopenharmony_ci	uint32_t ovlan_vld:1;                   /* outer VLAN valid */
134262306a36Sopenharmony_ci	uint32_t pfvf_vld:1;                    /* PF/VF valid */
134362306a36Sopenharmony_ci	uint32_t encap_vld:1;			/* Encapsulation valid */
134462306a36Sopenharmony_ci	uint32_t macidx:MACIDX_BITWIDTH;        /* exact match MAC index */
134562306a36Sopenharmony_ci	uint32_t fcoe:FCOE_BITWIDTH;            /* FCoE packet */
134662306a36Sopenharmony_ci	uint32_t iport:IPORT_BITWIDTH;          /* ingress port */
134762306a36Sopenharmony_ci	uint32_t matchtype:MATCHTYPE_BITWIDTH;  /* MPS match type */
134862306a36Sopenharmony_ci	uint32_t proto:PROTO_BITWIDTH;          /* protocol type */
134962306a36Sopenharmony_ci	uint32_t tos:TOS_BITWIDTH;              /* TOS/Traffic Type */
135062306a36Sopenharmony_ci	uint32_t pf:PF_BITWIDTH;                /* PCI-E PF ID */
135162306a36Sopenharmony_ci	uint32_t vf:VF_BITWIDTH;                /* PCI-E VF ID */
135262306a36Sopenharmony_ci	uint32_t ivlan:IVLAN_BITWIDTH;          /* inner VLAN */
135362306a36Sopenharmony_ci	uint32_t ovlan:OVLAN_BITWIDTH;          /* outer VLAN */
135462306a36Sopenharmony_ci	uint32_t vni:ENCAP_VNI_BITWIDTH;	/* VNI of tunnel */
135562306a36Sopenharmony_ci
135662306a36Sopenharmony_ci	/* Uncompressed header matching field rules.  These are always
135762306a36Sopenharmony_ci	 * available for field rules.
135862306a36Sopenharmony_ci	 */
135962306a36Sopenharmony_ci	uint8_t lip[16];        /* local IP address (IPv4 in [3:0]) */
136062306a36Sopenharmony_ci	uint8_t fip[16];        /* foreign IP address (IPv4 in [3:0]) */
136162306a36Sopenharmony_ci	uint16_t lport;         /* local port */
136262306a36Sopenharmony_ci	uint16_t fport;         /* foreign port */
136362306a36Sopenharmony_ci};
136462306a36Sopenharmony_ci
136562306a36Sopenharmony_ci/* A filter ioctl command.
136662306a36Sopenharmony_ci */
136762306a36Sopenharmony_cistruct ch_filter_specification {
136862306a36Sopenharmony_ci	/* Administrative fields for filter.
136962306a36Sopenharmony_ci	 */
137062306a36Sopenharmony_ci	uint32_t hitcnts:1;     /* count filter hits in TCB */
137162306a36Sopenharmony_ci	uint32_t prio:1;        /* filter has priority over active/server */
137262306a36Sopenharmony_ci
137362306a36Sopenharmony_ci	/* Fundamental filter typing.  This is the one element of filter
137462306a36Sopenharmony_ci	 * matching that doesn't exist as a (value, mask) tuple.
137562306a36Sopenharmony_ci	 */
137662306a36Sopenharmony_ci	uint32_t type:1;        /* 0 => IPv4, 1 => IPv6 */
137762306a36Sopenharmony_ci	u32 hash:1;		/* 0 => wild-card, 1 => exact-match */
137862306a36Sopenharmony_ci
137962306a36Sopenharmony_ci	/* Packet dispatch information.  Ingress packets which match the
138062306a36Sopenharmony_ci	 * filter rules will be dropped, passed to the host or switched back
138162306a36Sopenharmony_ci	 * out as egress packets.
138262306a36Sopenharmony_ci	 */
138362306a36Sopenharmony_ci	uint32_t action:2;      /* drop, pass, switch */
138462306a36Sopenharmony_ci
138562306a36Sopenharmony_ci	uint32_t rpttid:1;      /* report TID in RSS hash field */
138662306a36Sopenharmony_ci
138762306a36Sopenharmony_ci	uint32_t dirsteer:1;    /* 0 => RSS, 1 => steer to iq */
138862306a36Sopenharmony_ci	uint32_t iq:10;         /* ingress queue */
138962306a36Sopenharmony_ci
139062306a36Sopenharmony_ci	uint32_t maskhash:1;    /* dirsteer=0: store RSS hash in TCB */
139162306a36Sopenharmony_ci	uint32_t dirsteerhash:1;/* dirsteer=1: 0 => TCB contains RSS hash */
139262306a36Sopenharmony_ci				/*             1 => TCB contains IQ ID */
139362306a36Sopenharmony_ci
139462306a36Sopenharmony_ci	/* Switch proxy/rewrite fields.  An ingress packet which matches a
139562306a36Sopenharmony_ci	 * filter with "switch" set will be looped back out as an egress
139662306a36Sopenharmony_ci	 * packet -- potentially with some Ethernet header rewriting.
139762306a36Sopenharmony_ci	 */
139862306a36Sopenharmony_ci	uint32_t eport:2;       /* egress port to switch packet out */
139962306a36Sopenharmony_ci	uint32_t newdmac:1;     /* rewrite destination MAC address */
140062306a36Sopenharmony_ci	uint32_t newsmac:1;     /* rewrite source MAC address */
140162306a36Sopenharmony_ci	uint32_t newvlan:2;     /* rewrite VLAN Tag */
140262306a36Sopenharmony_ci	uint32_t nat_mode:3;    /* specify NAT operation mode */
140362306a36Sopenharmony_ci	uint8_t dmac[ETH_ALEN]; /* new destination MAC address */
140462306a36Sopenharmony_ci	uint8_t smac[ETH_ALEN]; /* new source MAC address */
140562306a36Sopenharmony_ci	uint16_t vlan;          /* VLAN Tag to insert */
140662306a36Sopenharmony_ci
140762306a36Sopenharmony_ci	u8 nat_lip[16];		/* local IP to use after NAT'ing */
140862306a36Sopenharmony_ci	u8 nat_fip[16];		/* foreign IP to use after NAT'ing */
140962306a36Sopenharmony_ci	u16 nat_lport;		/* local port to use after NAT'ing */
141062306a36Sopenharmony_ci	u16 nat_fport;		/* foreign port to use after NAT'ing */
141162306a36Sopenharmony_ci
141262306a36Sopenharmony_ci	u32 tc_prio;		/* TC's filter priority index */
141362306a36Sopenharmony_ci	u64 tc_cookie;		/* Unique cookie identifying TC rules */
141462306a36Sopenharmony_ci
141562306a36Sopenharmony_ci	/* reservation for future additions */
141662306a36Sopenharmony_ci	u8 rsvd[12];
141762306a36Sopenharmony_ci
141862306a36Sopenharmony_ci	/* Filter rule value/mask pairs.
141962306a36Sopenharmony_ci	 */
142062306a36Sopenharmony_ci	struct ch_filter_tuple val;
142162306a36Sopenharmony_ci	struct ch_filter_tuple mask;
142262306a36Sopenharmony_ci};
142362306a36Sopenharmony_ci
142462306a36Sopenharmony_cienum {
142562306a36Sopenharmony_ci	FILTER_PASS = 0,        /* default */
142662306a36Sopenharmony_ci	FILTER_DROP,
142762306a36Sopenharmony_ci	FILTER_SWITCH
142862306a36Sopenharmony_ci};
142962306a36Sopenharmony_ci
143062306a36Sopenharmony_cienum {
143162306a36Sopenharmony_ci	VLAN_NOCHANGE = 0,      /* default */
143262306a36Sopenharmony_ci	VLAN_REMOVE,
143362306a36Sopenharmony_ci	VLAN_INSERT,
143462306a36Sopenharmony_ci	VLAN_REWRITE
143562306a36Sopenharmony_ci};
143662306a36Sopenharmony_ci
143762306a36Sopenharmony_cienum {
143862306a36Sopenharmony_ci	NAT_MODE_NONE = 0,	/* No NAT performed */
143962306a36Sopenharmony_ci	NAT_MODE_DIP,		/* NAT on Dst IP */
144062306a36Sopenharmony_ci	NAT_MODE_DIP_DP,	/* NAT on Dst IP, Dst Port */
144162306a36Sopenharmony_ci	NAT_MODE_DIP_DP_SIP,	/* NAT on Dst IP, Dst Port and Src IP */
144262306a36Sopenharmony_ci	NAT_MODE_DIP_DP_SP,	/* NAT on Dst IP, Dst Port and Src Port */
144362306a36Sopenharmony_ci	NAT_MODE_SIP_SP,	/* NAT on Src IP and Src Port */
144462306a36Sopenharmony_ci	NAT_MODE_DIP_SIP_SP,	/* NAT on Dst IP, Src IP and Src Port */
144562306a36Sopenharmony_ci	NAT_MODE_ALL		/* NAT on entire 4-tuple */
144662306a36Sopenharmony_ci};
144762306a36Sopenharmony_ci
144862306a36Sopenharmony_ci#define CXGB4_FILTER_TYPE_MAX 2
144962306a36Sopenharmony_ci
145062306a36Sopenharmony_ci/* Host shadow copy of ingress filter entry.  This is in host native format
145162306a36Sopenharmony_ci * and doesn't match the ordering or bit order, etc. of the hardware of the
145262306a36Sopenharmony_ci * firmware command.  The use of bit-field structure elements is purely to
145362306a36Sopenharmony_ci * remind ourselves of the field size limitations and save memory in the case
145462306a36Sopenharmony_ci * where the filter table is large.
145562306a36Sopenharmony_ci */
145662306a36Sopenharmony_cistruct filter_entry {
145762306a36Sopenharmony_ci	/* Administrative fields for filter. */
145862306a36Sopenharmony_ci	u32 valid:1;            /* filter allocated and valid */
145962306a36Sopenharmony_ci	u32 locked:1;           /* filter is administratively locked */
146062306a36Sopenharmony_ci
146162306a36Sopenharmony_ci	u32 pending:1;          /* filter action is pending firmware reply */
146262306a36Sopenharmony_ci	struct filter_ctx *ctx; /* Caller's completion hook */
146362306a36Sopenharmony_ci	struct l2t_entry *l2t;  /* Layer Two Table entry for dmac */
146462306a36Sopenharmony_ci	struct smt_entry *smt;  /* Source Mac Table entry for smac */
146562306a36Sopenharmony_ci	struct net_device *dev; /* Associated net device */
146662306a36Sopenharmony_ci	u32 tid;                /* This will store the actual tid */
146762306a36Sopenharmony_ci
146862306a36Sopenharmony_ci	/* The filter itself.  Most of this is a straight copy of information
146962306a36Sopenharmony_ci	 * provided by the extended ioctl().  Some fields are translated to
147062306a36Sopenharmony_ci	 * internal forms -- for instance the Ingress Queue ID passed in from
147162306a36Sopenharmony_ci	 * the ioctl() is translated into the Absolute Ingress Queue ID.
147262306a36Sopenharmony_ci	 */
147362306a36Sopenharmony_ci	struct ch_filter_specification fs;
147462306a36Sopenharmony_ci};
147562306a36Sopenharmony_ci
147662306a36Sopenharmony_cistatic inline int is_offload(const struct adapter *adap)
147762306a36Sopenharmony_ci{
147862306a36Sopenharmony_ci	return adap->params.offload;
147962306a36Sopenharmony_ci}
148062306a36Sopenharmony_ci
148162306a36Sopenharmony_cistatic inline int is_hashfilter(const struct adapter *adap)
148262306a36Sopenharmony_ci{
148362306a36Sopenharmony_ci	return adap->params.hash_filter;
148462306a36Sopenharmony_ci}
148562306a36Sopenharmony_ci
148662306a36Sopenharmony_cistatic inline int is_pci_uld(const struct adapter *adap)
148762306a36Sopenharmony_ci{
148862306a36Sopenharmony_ci	return adap->params.crypto;
148962306a36Sopenharmony_ci}
149062306a36Sopenharmony_ci
149162306a36Sopenharmony_cistatic inline int is_uld(const struct adapter *adap)
149262306a36Sopenharmony_ci{
149362306a36Sopenharmony_ci	return (adap->params.offload || adap->params.crypto);
149462306a36Sopenharmony_ci}
149562306a36Sopenharmony_ci
149662306a36Sopenharmony_cistatic inline int is_ethofld(const struct adapter *adap)
149762306a36Sopenharmony_ci{
149862306a36Sopenharmony_ci	return adap->params.ethofld;
149962306a36Sopenharmony_ci}
150062306a36Sopenharmony_ci
150162306a36Sopenharmony_cistatic inline u32 t4_read_reg(struct adapter *adap, u32 reg_addr)
150262306a36Sopenharmony_ci{
150362306a36Sopenharmony_ci	return readl(adap->regs + reg_addr);
150462306a36Sopenharmony_ci}
150562306a36Sopenharmony_ci
150662306a36Sopenharmony_cistatic inline void t4_write_reg(struct adapter *adap, u32 reg_addr, u32 val)
150762306a36Sopenharmony_ci{
150862306a36Sopenharmony_ci	writel(val, adap->regs + reg_addr);
150962306a36Sopenharmony_ci}
151062306a36Sopenharmony_ci
151162306a36Sopenharmony_ci#ifndef readq
151262306a36Sopenharmony_cistatic inline u64 readq(const volatile void __iomem *addr)
151362306a36Sopenharmony_ci{
151462306a36Sopenharmony_ci	return readl(addr) + ((u64)readl(addr + 4) << 32);
151562306a36Sopenharmony_ci}
151662306a36Sopenharmony_ci
151762306a36Sopenharmony_cistatic inline void writeq(u64 val, volatile void __iomem *addr)
151862306a36Sopenharmony_ci{
151962306a36Sopenharmony_ci	writel(val, addr);
152062306a36Sopenharmony_ci	writel(val >> 32, addr + 4);
152162306a36Sopenharmony_ci}
152262306a36Sopenharmony_ci#endif
152362306a36Sopenharmony_ci
152462306a36Sopenharmony_cistatic inline u64 t4_read_reg64(struct adapter *adap, u32 reg_addr)
152562306a36Sopenharmony_ci{
152662306a36Sopenharmony_ci	return readq(adap->regs + reg_addr);
152762306a36Sopenharmony_ci}
152862306a36Sopenharmony_ci
152962306a36Sopenharmony_cistatic inline void t4_write_reg64(struct adapter *adap, u32 reg_addr, u64 val)
153062306a36Sopenharmony_ci{
153162306a36Sopenharmony_ci	writeq(val, adap->regs + reg_addr);
153262306a36Sopenharmony_ci}
153362306a36Sopenharmony_ci
153462306a36Sopenharmony_ci/**
153562306a36Sopenharmony_ci * t4_set_hw_addr - store a port's MAC address in SW
153662306a36Sopenharmony_ci * @adapter: the adapter
153762306a36Sopenharmony_ci * @port_idx: the port index
153862306a36Sopenharmony_ci * @hw_addr: the Ethernet address
153962306a36Sopenharmony_ci *
154062306a36Sopenharmony_ci * Store the Ethernet address of the given port in SW.  Called by the common
154162306a36Sopenharmony_ci * code when it retrieves a port's Ethernet address from EEPROM.
154262306a36Sopenharmony_ci */
154362306a36Sopenharmony_cistatic inline void t4_set_hw_addr(struct adapter *adapter, int port_idx,
154462306a36Sopenharmony_ci				  u8 hw_addr[])
154562306a36Sopenharmony_ci{
154662306a36Sopenharmony_ci	eth_hw_addr_set(adapter->port[port_idx], hw_addr);
154762306a36Sopenharmony_ci	ether_addr_copy(adapter->port[port_idx]->perm_addr, hw_addr);
154862306a36Sopenharmony_ci}
154962306a36Sopenharmony_ci
155062306a36Sopenharmony_ci/**
155162306a36Sopenharmony_ci * netdev2pinfo - return the port_info structure associated with a net_device
155262306a36Sopenharmony_ci * @dev: the netdev
155362306a36Sopenharmony_ci *
155462306a36Sopenharmony_ci * Return the struct port_info associated with a net_device
155562306a36Sopenharmony_ci */
155662306a36Sopenharmony_cistatic inline struct port_info *netdev2pinfo(const struct net_device *dev)
155762306a36Sopenharmony_ci{
155862306a36Sopenharmony_ci	return netdev_priv(dev);
155962306a36Sopenharmony_ci}
156062306a36Sopenharmony_ci
156162306a36Sopenharmony_ci/**
156262306a36Sopenharmony_ci * adap2pinfo - return the port_info of a port
156362306a36Sopenharmony_ci * @adap: the adapter
156462306a36Sopenharmony_ci * @idx: the port index
156562306a36Sopenharmony_ci *
156662306a36Sopenharmony_ci * Return the port_info structure for the port of the given index.
156762306a36Sopenharmony_ci */
156862306a36Sopenharmony_cistatic inline struct port_info *adap2pinfo(struct adapter *adap, int idx)
156962306a36Sopenharmony_ci{
157062306a36Sopenharmony_ci	return netdev_priv(adap->port[idx]);
157162306a36Sopenharmony_ci}
157262306a36Sopenharmony_ci
157362306a36Sopenharmony_ci/**
157462306a36Sopenharmony_ci * netdev2adap - return the adapter structure associated with a net_device
157562306a36Sopenharmony_ci * @dev: the netdev
157662306a36Sopenharmony_ci *
157762306a36Sopenharmony_ci * Return the struct adapter associated with a net_device
157862306a36Sopenharmony_ci */
157962306a36Sopenharmony_cistatic inline struct adapter *netdev2adap(const struct net_device *dev)
158062306a36Sopenharmony_ci{
158162306a36Sopenharmony_ci	return netdev2pinfo(dev)->adapter;
158262306a36Sopenharmony_ci}
158362306a36Sopenharmony_ci
158462306a36Sopenharmony_ci/* Return a version number to identify the type of adapter.  The scheme is:
158562306a36Sopenharmony_ci * - bits 0..9: chip version
158662306a36Sopenharmony_ci * - bits 10..15: chip revision
158762306a36Sopenharmony_ci * - bits 16..23: register dump version
158862306a36Sopenharmony_ci */
158962306a36Sopenharmony_cistatic inline unsigned int mk_adap_vers(struct adapter *ap)
159062306a36Sopenharmony_ci{
159162306a36Sopenharmony_ci	return CHELSIO_CHIP_VERSION(ap->params.chip) |
159262306a36Sopenharmony_ci		(CHELSIO_CHIP_RELEASE(ap->params.chip) << 10) | (1 << 16);
159362306a36Sopenharmony_ci}
159462306a36Sopenharmony_ci
159562306a36Sopenharmony_ci/* Return a queue's interrupt hold-off time in us.  0 means no timer. */
159662306a36Sopenharmony_cistatic inline unsigned int qtimer_val(const struct adapter *adap,
159762306a36Sopenharmony_ci				      const struct sge_rspq *q)
159862306a36Sopenharmony_ci{
159962306a36Sopenharmony_ci	unsigned int idx = q->intr_params >> 1;
160062306a36Sopenharmony_ci
160162306a36Sopenharmony_ci	return idx < SGE_NTIMERS ? adap->sge.timer_val[idx] : 0;
160262306a36Sopenharmony_ci}
160362306a36Sopenharmony_ci
160462306a36Sopenharmony_ci/* driver name used for ethtool_drvinfo */
160562306a36Sopenharmony_ciextern char cxgb4_driver_name[];
160662306a36Sopenharmony_ci
160762306a36Sopenharmony_civoid t4_os_portmod_changed(struct adapter *adap, int port_id);
160862306a36Sopenharmony_civoid t4_os_link_changed(struct adapter *adap, int port_id, int link_stat);
160962306a36Sopenharmony_ci
161062306a36Sopenharmony_civoid t4_free_sge_resources(struct adapter *adap);
161162306a36Sopenharmony_civoid t4_free_ofld_rxqs(struct adapter *adap, int n, struct sge_ofld_rxq *q);
161262306a36Sopenharmony_ciirq_handler_t t4_intr_handler(struct adapter *adap);
161362306a36Sopenharmony_cinetdev_tx_t t4_start_xmit(struct sk_buff *skb, struct net_device *dev);
161462306a36Sopenharmony_ciint cxgb4_selftest_lb_pkt(struct net_device *netdev);
161562306a36Sopenharmony_ciint t4_ethrx_handler(struct sge_rspq *q, const __be64 *rsp,
161662306a36Sopenharmony_ci		     const struct pkt_gl *gl);
161762306a36Sopenharmony_ciint t4_mgmt_tx(struct adapter *adap, struct sk_buff *skb);
161862306a36Sopenharmony_ciint t4_ofld_send(struct adapter *adap, struct sk_buff *skb);
161962306a36Sopenharmony_ciint t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
162062306a36Sopenharmony_ci		     struct net_device *dev, int intr_idx,
162162306a36Sopenharmony_ci		     struct sge_fl *fl, rspq_handler_t hnd,
162262306a36Sopenharmony_ci		     rspq_flush_handler_t flush_handler, int cong);
162362306a36Sopenharmony_ciint t4_sge_alloc_eth_txq(struct adapter *adap, struct sge_eth_txq *txq,
162462306a36Sopenharmony_ci			 struct net_device *dev, struct netdev_queue *netdevq,
162562306a36Sopenharmony_ci			 unsigned int iqid, u8 dbqt);
162662306a36Sopenharmony_ciint t4_sge_alloc_ctrl_txq(struct adapter *adap, struct sge_ctrl_txq *txq,
162762306a36Sopenharmony_ci			  struct net_device *dev, unsigned int iqid,
162862306a36Sopenharmony_ci			  unsigned int cmplqid);
162962306a36Sopenharmony_ciint t4_sge_mod_ctrl_txq(struct adapter *adap, unsigned int eqid,
163062306a36Sopenharmony_ci			unsigned int cmplqid);
163162306a36Sopenharmony_ciint t4_sge_alloc_uld_txq(struct adapter *adap, struct sge_uld_txq *txq,
163262306a36Sopenharmony_ci			 struct net_device *dev, unsigned int iqid,
163362306a36Sopenharmony_ci			 unsigned int uld_type);
163462306a36Sopenharmony_ciint t4_sge_alloc_ethofld_txq(struct adapter *adap, struct sge_eohw_txq *txq,
163562306a36Sopenharmony_ci			     struct net_device *dev, u32 iqid);
163662306a36Sopenharmony_civoid t4_sge_free_ethofld_txq(struct adapter *adap, struct sge_eohw_txq *txq);
163762306a36Sopenharmony_ciirqreturn_t t4_sge_intr_msix(int irq, void *cookie);
163862306a36Sopenharmony_ciint t4_sge_init(struct adapter *adap);
163962306a36Sopenharmony_civoid t4_sge_start(struct adapter *adap);
164062306a36Sopenharmony_civoid t4_sge_stop(struct adapter *adap);
164162306a36Sopenharmony_ciint t4_sge_eth_txq_egress_update(struct adapter *adap, struct sge_eth_txq *q,
164262306a36Sopenharmony_ci				 int maxreclaim);
164362306a36Sopenharmony_civoid cxgb4_set_ethtool_ops(struct net_device *netdev);
164462306a36Sopenharmony_ciint cxgb4_write_rss(const struct port_info *pi, const u16 *queues);
164562306a36Sopenharmony_cienum cpl_tx_tnl_lso_type cxgb_encap_offload_supported(struct sk_buff *skb);
164662306a36Sopenharmony_ciextern int dbfifo_int_thresh;
164762306a36Sopenharmony_ci
164862306a36Sopenharmony_ci#define for_each_port(adapter, iter) \
164962306a36Sopenharmony_ci	for (iter = 0; iter < (adapter)->params.nports; ++iter)
165062306a36Sopenharmony_ci
165162306a36Sopenharmony_cistatic inline int is_bypass(struct adapter *adap)
165262306a36Sopenharmony_ci{
165362306a36Sopenharmony_ci	return adap->params.bypass;
165462306a36Sopenharmony_ci}
165562306a36Sopenharmony_ci
165662306a36Sopenharmony_cistatic inline int is_bypass_device(int device)
165762306a36Sopenharmony_ci{
165862306a36Sopenharmony_ci	/* this should be set based upon device capabilities */
165962306a36Sopenharmony_ci	switch (device) {
166062306a36Sopenharmony_ci	case 0x440b:
166162306a36Sopenharmony_ci	case 0x440c:
166262306a36Sopenharmony_ci		return 1;
166362306a36Sopenharmony_ci	default:
166462306a36Sopenharmony_ci		return 0;
166562306a36Sopenharmony_ci	}
166662306a36Sopenharmony_ci}
166762306a36Sopenharmony_ci
166862306a36Sopenharmony_cistatic inline int is_10gbt_device(int device)
166962306a36Sopenharmony_ci{
167062306a36Sopenharmony_ci	/* this should be set based upon device capabilities */
167162306a36Sopenharmony_ci	switch (device) {
167262306a36Sopenharmony_ci	case 0x4409:
167362306a36Sopenharmony_ci	case 0x4486:
167462306a36Sopenharmony_ci		return 1;
167562306a36Sopenharmony_ci
167662306a36Sopenharmony_ci	default:
167762306a36Sopenharmony_ci		return 0;
167862306a36Sopenharmony_ci	}
167962306a36Sopenharmony_ci}
168062306a36Sopenharmony_ci
168162306a36Sopenharmony_cistatic inline unsigned int core_ticks_per_usec(const struct adapter *adap)
168262306a36Sopenharmony_ci{
168362306a36Sopenharmony_ci	return adap->params.vpd.cclk / 1000;
168462306a36Sopenharmony_ci}
168562306a36Sopenharmony_ci
168662306a36Sopenharmony_cistatic inline unsigned int us_to_core_ticks(const struct adapter *adap,
168762306a36Sopenharmony_ci					    unsigned int us)
168862306a36Sopenharmony_ci{
168962306a36Sopenharmony_ci	return (us * adap->params.vpd.cclk) / 1000;
169062306a36Sopenharmony_ci}
169162306a36Sopenharmony_ci
169262306a36Sopenharmony_cistatic inline unsigned int core_ticks_to_us(const struct adapter *adapter,
169362306a36Sopenharmony_ci					    unsigned int ticks)
169462306a36Sopenharmony_ci{
169562306a36Sopenharmony_ci	/* add Core Clock / 2 to round ticks to nearest uS */
169662306a36Sopenharmony_ci	return ((ticks * 1000 + adapter->params.vpd.cclk/2) /
169762306a36Sopenharmony_ci		adapter->params.vpd.cclk);
169862306a36Sopenharmony_ci}
169962306a36Sopenharmony_ci
170062306a36Sopenharmony_cistatic inline unsigned int dack_ticks_to_usec(const struct adapter *adap,
170162306a36Sopenharmony_ci					      unsigned int ticks)
170262306a36Sopenharmony_ci{
170362306a36Sopenharmony_ci	return (ticks << adap->params.tp.dack_re) / core_ticks_per_usec(adap);
170462306a36Sopenharmony_ci}
170562306a36Sopenharmony_ci
170662306a36Sopenharmony_civoid t4_set_reg_field(struct adapter *adap, unsigned int addr, u32 mask,
170762306a36Sopenharmony_ci		      u32 val);
170862306a36Sopenharmony_ci
170962306a36Sopenharmony_ciint t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox, const void *cmd,
171062306a36Sopenharmony_ci			    int size, void *rpl, bool sleep_ok, int timeout);
171162306a36Sopenharmony_ciint t4_wr_mbox_meat(struct adapter *adap, int mbox, const void *cmd, int size,
171262306a36Sopenharmony_ci		    void *rpl, bool sleep_ok);
171362306a36Sopenharmony_ci
171462306a36Sopenharmony_cistatic inline int t4_wr_mbox_timeout(struct adapter *adap, int mbox,
171562306a36Sopenharmony_ci				     const void *cmd, int size, void *rpl,
171662306a36Sopenharmony_ci				     int timeout)
171762306a36Sopenharmony_ci{
171862306a36Sopenharmony_ci	return t4_wr_mbox_meat_timeout(adap, mbox, cmd, size, rpl, true,
171962306a36Sopenharmony_ci				       timeout);
172062306a36Sopenharmony_ci}
172162306a36Sopenharmony_ci
172262306a36Sopenharmony_cistatic inline int t4_wr_mbox(struct adapter *adap, int mbox, const void *cmd,
172362306a36Sopenharmony_ci			     int size, void *rpl)
172462306a36Sopenharmony_ci{
172562306a36Sopenharmony_ci	return t4_wr_mbox_meat(adap, mbox, cmd, size, rpl, true);
172662306a36Sopenharmony_ci}
172762306a36Sopenharmony_ci
172862306a36Sopenharmony_cistatic inline int t4_wr_mbox_ns(struct adapter *adap, int mbox, const void *cmd,
172962306a36Sopenharmony_ci				int size, void *rpl)
173062306a36Sopenharmony_ci{
173162306a36Sopenharmony_ci	return t4_wr_mbox_meat(adap, mbox, cmd, size, rpl, false);
173262306a36Sopenharmony_ci}
173362306a36Sopenharmony_ci
173462306a36Sopenharmony_ci/**
173562306a36Sopenharmony_ci *	hash_mac_addr - return the hash value of a MAC address
173662306a36Sopenharmony_ci *	@addr: the 48-bit Ethernet MAC address
173762306a36Sopenharmony_ci *
173862306a36Sopenharmony_ci *	Hashes a MAC address according to the hash function used by HW inexact
173962306a36Sopenharmony_ci *	(hash) address matching.
174062306a36Sopenharmony_ci */
174162306a36Sopenharmony_cistatic inline int hash_mac_addr(const u8 *addr)
174262306a36Sopenharmony_ci{
174362306a36Sopenharmony_ci	u32 a = ((u32)addr[0] << 16) | ((u32)addr[1] << 8) | addr[2];
174462306a36Sopenharmony_ci	u32 b = ((u32)addr[3] << 16) | ((u32)addr[4] << 8) | addr[5];
174562306a36Sopenharmony_ci
174662306a36Sopenharmony_ci	a ^= b;
174762306a36Sopenharmony_ci	a ^= (a >> 12);
174862306a36Sopenharmony_ci	a ^= (a >> 6);
174962306a36Sopenharmony_ci	return a & 0x3f;
175062306a36Sopenharmony_ci}
175162306a36Sopenharmony_ci
175262306a36Sopenharmony_ciint cxgb4_set_rspq_intr_params(struct sge_rspq *q, unsigned int us,
175362306a36Sopenharmony_ci			       unsigned int cnt);
175462306a36Sopenharmony_cistatic inline void init_rspq(struct adapter *adap, struct sge_rspq *q,
175562306a36Sopenharmony_ci			     unsigned int us, unsigned int cnt,
175662306a36Sopenharmony_ci			     unsigned int size, unsigned int iqe_size)
175762306a36Sopenharmony_ci{
175862306a36Sopenharmony_ci	q->adap = adap;
175962306a36Sopenharmony_ci	cxgb4_set_rspq_intr_params(q, us, cnt);
176062306a36Sopenharmony_ci	q->iqe_len = iqe_size;
176162306a36Sopenharmony_ci	q->size = size;
176262306a36Sopenharmony_ci}
176362306a36Sopenharmony_ci
176462306a36Sopenharmony_ci/**
176562306a36Sopenharmony_ci *     t4_is_inserted_mod_type - is a plugged in Firmware Module Type
176662306a36Sopenharmony_ci *     @fw_mod_type: the Firmware Mofule Type
176762306a36Sopenharmony_ci *
176862306a36Sopenharmony_ci *     Return whether the Firmware Module Type represents a real Transceiver
176962306a36Sopenharmony_ci *     Module/Cable Module Type which has been inserted.
177062306a36Sopenharmony_ci */
177162306a36Sopenharmony_cistatic inline bool t4_is_inserted_mod_type(unsigned int fw_mod_type)
177262306a36Sopenharmony_ci{
177362306a36Sopenharmony_ci	return (fw_mod_type != FW_PORT_MOD_TYPE_NONE &&
177462306a36Sopenharmony_ci		fw_mod_type != FW_PORT_MOD_TYPE_NOTSUPPORTED &&
177562306a36Sopenharmony_ci		fw_mod_type != FW_PORT_MOD_TYPE_UNKNOWN &&
177662306a36Sopenharmony_ci		fw_mod_type != FW_PORT_MOD_TYPE_ERROR);
177762306a36Sopenharmony_ci}
177862306a36Sopenharmony_ci
177962306a36Sopenharmony_civoid t4_write_indirect(struct adapter *adap, unsigned int addr_reg,
178062306a36Sopenharmony_ci		       unsigned int data_reg, const u32 *vals,
178162306a36Sopenharmony_ci		       unsigned int nregs, unsigned int start_idx);
178262306a36Sopenharmony_civoid t4_read_indirect(struct adapter *adap, unsigned int addr_reg,
178362306a36Sopenharmony_ci		      unsigned int data_reg, u32 *vals, unsigned int nregs,
178462306a36Sopenharmony_ci		      unsigned int start_idx);
178562306a36Sopenharmony_civoid t4_hw_pci_read_cfg4(struct adapter *adapter, int reg, u32 *val);
178662306a36Sopenharmony_ci
178762306a36Sopenharmony_cistruct fw_filter_wr;
178862306a36Sopenharmony_ci
178962306a36Sopenharmony_civoid t4_intr_enable(struct adapter *adapter);
179062306a36Sopenharmony_civoid t4_intr_disable(struct adapter *adapter);
179162306a36Sopenharmony_ciint t4_slow_intr_handler(struct adapter *adapter);
179262306a36Sopenharmony_ci
179362306a36Sopenharmony_ciint t4_wait_dev_ready(void __iomem *regs);
179462306a36Sopenharmony_ci
179562306a36Sopenharmony_cifw_port_cap32_t t4_link_acaps(struct adapter *adapter, unsigned int port,
179662306a36Sopenharmony_ci			      struct link_config *lc);
179762306a36Sopenharmony_ciint t4_link_l1cfg_core(struct adapter *adap, unsigned int mbox,
179862306a36Sopenharmony_ci		       unsigned int port, struct link_config *lc,
179962306a36Sopenharmony_ci		       u8 sleep_ok, int timeout);
180062306a36Sopenharmony_ci
180162306a36Sopenharmony_cistatic inline int t4_link_l1cfg(struct adapter *adapter, unsigned int mbox,
180262306a36Sopenharmony_ci				unsigned int port, struct link_config *lc)
180362306a36Sopenharmony_ci{
180462306a36Sopenharmony_ci	return t4_link_l1cfg_core(adapter, mbox, port, lc,
180562306a36Sopenharmony_ci				  true, FW_CMD_MAX_TIMEOUT);
180662306a36Sopenharmony_ci}
180762306a36Sopenharmony_ci
180862306a36Sopenharmony_cistatic inline int t4_link_l1cfg_ns(struct adapter *adapter, unsigned int mbox,
180962306a36Sopenharmony_ci				   unsigned int port, struct link_config *lc)
181062306a36Sopenharmony_ci{
181162306a36Sopenharmony_ci	return t4_link_l1cfg_core(adapter, mbox, port, lc,
181262306a36Sopenharmony_ci				  false, FW_CMD_MAX_TIMEOUT);
181362306a36Sopenharmony_ci}
181462306a36Sopenharmony_ci
181562306a36Sopenharmony_ciint t4_restart_aneg(struct adapter *adap, unsigned int mbox, unsigned int port);
181662306a36Sopenharmony_ci
181762306a36Sopenharmony_ciu32 t4_read_pcie_cfg4(struct adapter *adap, int reg);
181862306a36Sopenharmony_ciu32 t4_get_util_window(struct adapter *adap);
181962306a36Sopenharmony_civoid t4_setup_memwin(struct adapter *adap, u32 memwin_base, u32 window);
182062306a36Sopenharmony_ci
182162306a36Sopenharmony_ciint t4_memory_rw_init(struct adapter *adap, int win, int mtype, u32 *mem_off,
182262306a36Sopenharmony_ci		      u32 *mem_base, u32 *mem_aperture);
182362306a36Sopenharmony_civoid t4_memory_update_win(struct adapter *adap, int win, u32 addr);
182462306a36Sopenharmony_civoid t4_memory_rw_residual(struct adapter *adap, u32 off, u32 addr, u8 *buf,
182562306a36Sopenharmony_ci			   int dir);
182662306a36Sopenharmony_ci#define T4_MEMORY_WRITE	0
182762306a36Sopenharmony_ci#define T4_MEMORY_READ	1
182862306a36Sopenharmony_ciint t4_memory_rw(struct adapter *adap, int win, int mtype, u32 addr, u32 len,
182962306a36Sopenharmony_ci		 void *buf, int dir);
183062306a36Sopenharmony_cistatic inline int t4_memory_write(struct adapter *adap, int mtype, u32 addr,
183162306a36Sopenharmony_ci				  u32 len, __be32 *buf)
183262306a36Sopenharmony_ci{
183362306a36Sopenharmony_ci	return t4_memory_rw(adap, 0, mtype, addr, len, buf, 0);
183462306a36Sopenharmony_ci}
183562306a36Sopenharmony_ci
183662306a36Sopenharmony_ciunsigned int t4_get_regs_len(struct adapter *adapter);
183762306a36Sopenharmony_civoid t4_get_regs(struct adapter *adap, void *buf, size_t buf_size);
183862306a36Sopenharmony_ci
183962306a36Sopenharmony_ciint t4_eeprom_ptov(unsigned int phys_addr, unsigned int fn, unsigned int sz);
184062306a36Sopenharmony_ciint t4_seeprom_wp(struct adapter *adapter, bool enable);
184162306a36Sopenharmony_ciint t4_get_raw_vpd_params(struct adapter *adapter, struct vpd_params *p);
184262306a36Sopenharmony_ciint t4_get_vpd_params(struct adapter *adapter, struct vpd_params *p);
184362306a36Sopenharmony_ciint t4_get_pfres(struct adapter *adapter);
184462306a36Sopenharmony_ciint t4_read_flash(struct adapter *adapter, unsigned int addr,
184562306a36Sopenharmony_ci		  unsigned int nwords, u32 *data, int byte_oriented);
184662306a36Sopenharmony_ciint t4_load_fw(struct adapter *adapter, const u8 *fw_data, unsigned int size);
184762306a36Sopenharmony_ciint t4_load_phy_fw(struct adapter *adap, int win,
184862306a36Sopenharmony_ci		   int (*phy_fw_version)(const u8 *, size_t),
184962306a36Sopenharmony_ci		   const u8 *phy_fw_data, size_t phy_fw_size);
185062306a36Sopenharmony_ciint t4_phy_fw_ver(struct adapter *adap, int *phy_fw_ver);
185162306a36Sopenharmony_ciint t4_fwcache(struct adapter *adap, enum fw_params_param_dev_fwcache op);
185262306a36Sopenharmony_ciint t4_fw_upgrade(struct adapter *adap, unsigned int mbox,
185362306a36Sopenharmony_ci		  const u8 *fw_data, unsigned int size, int force);
185462306a36Sopenharmony_ciint t4_fl_pkt_align(struct adapter *adap);
185562306a36Sopenharmony_ciunsigned int t4_flash_cfg_addr(struct adapter *adapter);
185662306a36Sopenharmony_ciint t4_check_fw_version(struct adapter *adap);
185762306a36Sopenharmony_ciint t4_load_cfg(struct adapter *adapter, const u8 *cfg_data, unsigned int size);
185862306a36Sopenharmony_ciint t4_get_fw_version(struct adapter *adapter, u32 *vers);
185962306a36Sopenharmony_ciint t4_get_bs_version(struct adapter *adapter, u32 *vers);
186062306a36Sopenharmony_ciint t4_get_tp_version(struct adapter *adapter, u32 *vers);
186162306a36Sopenharmony_ciint t4_get_exprom_version(struct adapter *adapter, u32 *vers);
186262306a36Sopenharmony_ciint t4_get_scfg_version(struct adapter *adapter, u32 *vers);
186362306a36Sopenharmony_ciint t4_get_vpd_version(struct adapter *adapter, u32 *vers);
186462306a36Sopenharmony_ciint t4_get_version_info(struct adapter *adapter);
186562306a36Sopenharmony_civoid t4_dump_version_info(struct adapter *adapter);
186662306a36Sopenharmony_ciint t4_prep_fw(struct adapter *adap, struct fw_info *fw_info,
186762306a36Sopenharmony_ci	       const u8 *fw_data, unsigned int fw_size,
186862306a36Sopenharmony_ci	       struct fw_hdr *card_fw, enum dev_state state, int *reset);
186962306a36Sopenharmony_ciint t4_prep_adapter(struct adapter *adapter);
187062306a36Sopenharmony_ciint t4_shutdown_adapter(struct adapter *adapter);
187162306a36Sopenharmony_ci
187262306a36Sopenharmony_cienum t4_bar2_qtype { T4_BAR2_QTYPE_EGRESS, T4_BAR2_QTYPE_INGRESS };
187362306a36Sopenharmony_ciint t4_bar2_sge_qregs(struct adapter *adapter,
187462306a36Sopenharmony_ci		      unsigned int qid,
187562306a36Sopenharmony_ci		      enum t4_bar2_qtype qtype,
187662306a36Sopenharmony_ci		      int user,
187762306a36Sopenharmony_ci		      u64 *pbar2_qoffset,
187862306a36Sopenharmony_ci		      unsigned int *pbar2_qid);
187962306a36Sopenharmony_ci
188062306a36Sopenharmony_ciunsigned int qtimer_val(const struct adapter *adap,
188162306a36Sopenharmony_ci			const struct sge_rspq *q);
188262306a36Sopenharmony_ci
188362306a36Sopenharmony_ciint t4_init_devlog_params(struct adapter *adapter);
188462306a36Sopenharmony_ciint t4_init_sge_params(struct adapter *adapter);
188562306a36Sopenharmony_ciint t4_init_tp_params(struct adapter *adap, bool sleep_ok);
188662306a36Sopenharmony_ciint t4_filter_field_shift(const struct adapter *adap, int filter_sel);
188762306a36Sopenharmony_ciint t4_init_rss_mode(struct adapter *adap, int mbox);
188862306a36Sopenharmony_ciint t4_init_portinfo(struct port_info *pi, int mbox,
188962306a36Sopenharmony_ci		     int port, int pf, int vf, u8 mac[]);
189062306a36Sopenharmony_ciint t4_port_init(struct adapter *adap, int mbox, int pf, int vf);
189162306a36Sopenharmony_ciint t4_init_port_mirror(struct port_info *pi, u8 mbox, u8 port, u8 pf, u8 vf,
189262306a36Sopenharmony_ci			u16 *mirror_viid);
189362306a36Sopenharmony_civoid t4_fatal_err(struct adapter *adapter);
189462306a36Sopenharmony_ciunsigned int t4_chip_rss_size(struct adapter *adapter);
189562306a36Sopenharmony_ciint t4_config_rss_range(struct adapter *adapter, int mbox, unsigned int viid,
189662306a36Sopenharmony_ci			int start, int n, const u16 *rspq, unsigned int nrspq);
189762306a36Sopenharmony_ciint t4_config_glbl_rss(struct adapter *adapter, int mbox, unsigned int mode,
189862306a36Sopenharmony_ci		       unsigned int flags);
189962306a36Sopenharmony_ciint t4_config_vi_rss(struct adapter *adapter, int mbox, unsigned int viid,
190062306a36Sopenharmony_ci		     unsigned int flags, unsigned int defq);
190162306a36Sopenharmony_ciint t4_read_rss(struct adapter *adapter, u16 *entries);
190262306a36Sopenharmony_civoid t4_read_rss_key(struct adapter *adapter, u32 *key, bool sleep_ok);
190362306a36Sopenharmony_civoid t4_write_rss_key(struct adapter *adap, const u32 *key, int idx,
190462306a36Sopenharmony_ci		      bool sleep_ok);
190562306a36Sopenharmony_civoid t4_read_rss_pf_config(struct adapter *adapter, unsigned int index,
190662306a36Sopenharmony_ci			   u32 *valp, bool sleep_ok);
190762306a36Sopenharmony_civoid t4_read_rss_vf_config(struct adapter *adapter, unsigned int index,
190862306a36Sopenharmony_ci			   u32 *vfl, u32 *vfh, bool sleep_ok);
190962306a36Sopenharmony_ciu32 t4_read_rss_pf_map(struct adapter *adapter, bool sleep_ok);
191062306a36Sopenharmony_ciu32 t4_read_rss_pf_mask(struct adapter *adapter, bool sleep_ok);
191162306a36Sopenharmony_ci
191262306a36Sopenharmony_ciunsigned int t4_get_mps_bg_map(struct adapter *adapter, int pidx);
191362306a36Sopenharmony_ciunsigned int t4_get_tp_ch_map(struct adapter *adapter, int pidx);
191462306a36Sopenharmony_civoid t4_pmtx_get_stats(struct adapter *adap, u32 cnt[], u64 cycles[]);
191562306a36Sopenharmony_civoid t4_pmrx_get_stats(struct adapter *adap, u32 cnt[], u64 cycles[]);
191662306a36Sopenharmony_ciint t4_read_cim_ibq(struct adapter *adap, unsigned int qid, u32 *data,
191762306a36Sopenharmony_ci		    size_t n);
191862306a36Sopenharmony_ciint t4_read_cim_obq(struct adapter *adap, unsigned int qid, u32 *data,
191962306a36Sopenharmony_ci		    size_t n);
192062306a36Sopenharmony_ciint t4_cim_read(struct adapter *adap, unsigned int addr, unsigned int n,
192162306a36Sopenharmony_ci		unsigned int *valp);
192262306a36Sopenharmony_ciint t4_cim_write(struct adapter *adap, unsigned int addr, unsigned int n,
192362306a36Sopenharmony_ci		 const unsigned int *valp);
192462306a36Sopenharmony_ciint t4_cim_read_la(struct adapter *adap, u32 *la_buf, unsigned int *wrptr);
192562306a36Sopenharmony_civoid t4_cim_read_pif_la(struct adapter *adap, u32 *pif_req, u32 *pif_rsp,
192662306a36Sopenharmony_ci			unsigned int *pif_req_wrptr,
192762306a36Sopenharmony_ci			unsigned int *pif_rsp_wrptr);
192862306a36Sopenharmony_civoid t4_cim_read_ma_la(struct adapter *adap, u32 *ma_req, u32 *ma_rsp);
192962306a36Sopenharmony_civoid t4_read_cimq_cfg(struct adapter *adap, u16 *base, u16 *size, u16 *thres);
193062306a36Sopenharmony_ciconst char *t4_get_port_type_description(enum fw_port_type port_type);
193162306a36Sopenharmony_civoid t4_get_port_stats(struct adapter *adap, int idx, struct port_stats *p);
193262306a36Sopenharmony_civoid t4_get_port_stats_offset(struct adapter *adap, int idx,
193362306a36Sopenharmony_ci			      struct port_stats *stats,
193462306a36Sopenharmony_ci			      struct port_stats *offset);
193562306a36Sopenharmony_civoid t4_get_lb_stats(struct adapter *adap, int idx, struct lb_port_stats *p);
193662306a36Sopenharmony_civoid t4_read_mtu_tbl(struct adapter *adap, u16 *mtus, u8 *mtu_log);
193762306a36Sopenharmony_civoid t4_read_cong_tbl(struct adapter *adap, u16 incr[NMTUS][NCCTRL_WIN]);
193862306a36Sopenharmony_civoid t4_tp_wr_bits_indirect(struct adapter *adap, unsigned int addr,
193962306a36Sopenharmony_ci			    unsigned int mask, unsigned int val);
194062306a36Sopenharmony_civoid t4_tp_read_la(struct adapter *adap, u64 *la_buf, unsigned int *wrptr);
194162306a36Sopenharmony_civoid t4_tp_get_err_stats(struct adapter *adap, struct tp_err_stats *st,
194262306a36Sopenharmony_ci			 bool sleep_ok);
194362306a36Sopenharmony_civoid t4_tp_get_cpl_stats(struct adapter *adap, struct tp_cpl_stats *st,
194462306a36Sopenharmony_ci			 bool sleep_ok);
194562306a36Sopenharmony_civoid t4_tp_get_rdma_stats(struct adapter *adap, struct tp_rdma_stats *st,
194662306a36Sopenharmony_ci			  bool sleep_ok);
194762306a36Sopenharmony_civoid t4_get_usm_stats(struct adapter *adap, struct tp_usm_stats *st,
194862306a36Sopenharmony_ci		      bool sleep_ok);
194962306a36Sopenharmony_civoid t4_tp_get_tcp_stats(struct adapter *adap, struct tp_tcp_stats *v4,
195062306a36Sopenharmony_ci			 struct tp_tcp_stats *v6, bool sleep_ok);
195162306a36Sopenharmony_civoid t4_get_fcoe_stats(struct adapter *adap, unsigned int idx,
195262306a36Sopenharmony_ci		       struct tp_fcoe_stats *st, bool sleep_ok);
195362306a36Sopenharmony_civoid t4_load_mtus(struct adapter *adap, const unsigned short *mtus,
195462306a36Sopenharmony_ci		  const unsigned short *alpha, const unsigned short *beta);
195562306a36Sopenharmony_ci
195662306a36Sopenharmony_civoid t4_ulprx_read_la(struct adapter *adap, u32 *la_buf);
195762306a36Sopenharmony_ci
195862306a36Sopenharmony_civoid t4_get_chan_txrate(struct adapter *adap, u64 *nic_rate, u64 *ofld_rate);
195962306a36Sopenharmony_civoid t4_mk_filtdelwr(unsigned int ftid, struct fw_filter_wr *wr, int qid);
196062306a36Sopenharmony_ci
196162306a36Sopenharmony_civoid t4_wol_magic_enable(struct adapter *adap, unsigned int port,
196262306a36Sopenharmony_ci			 const u8 *addr);
196362306a36Sopenharmony_ciint t4_wol_pat_enable(struct adapter *adap, unsigned int port, unsigned int map,
196462306a36Sopenharmony_ci		      u64 mask0, u64 mask1, unsigned int crc, bool enable);
196562306a36Sopenharmony_ci
196662306a36Sopenharmony_ciint t4_fw_hello(struct adapter *adap, unsigned int mbox, unsigned int evt_mbox,
196762306a36Sopenharmony_ci		enum dev_master master, enum dev_state *state);
196862306a36Sopenharmony_ciint t4_fw_bye(struct adapter *adap, unsigned int mbox);
196962306a36Sopenharmony_ciint t4_early_init(struct adapter *adap, unsigned int mbox);
197062306a36Sopenharmony_ciint t4_fw_reset(struct adapter *adap, unsigned int mbox, int reset);
197162306a36Sopenharmony_ciint t4_fixup_host_params(struct adapter *adap, unsigned int page_size,
197262306a36Sopenharmony_ci			  unsigned int cache_line_size);
197362306a36Sopenharmony_ciint t4_fw_initialize(struct adapter *adap, unsigned int mbox);
197462306a36Sopenharmony_ciint t4_query_params(struct adapter *adap, unsigned int mbox, unsigned int pf,
197562306a36Sopenharmony_ci		    unsigned int vf, unsigned int nparams, const u32 *params,
197662306a36Sopenharmony_ci		    u32 *val);
197762306a36Sopenharmony_ciint t4_query_params_ns(struct adapter *adap, unsigned int mbox, unsigned int pf,
197862306a36Sopenharmony_ci		       unsigned int vf, unsigned int nparams, const u32 *params,
197962306a36Sopenharmony_ci		       u32 *val);
198062306a36Sopenharmony_ciint t4_query_params_rw(struct adapter *adap, unsigned int mbox, unsigned int pf,
198162306a36Sopenharmony_ci		       unsigned int vf, unsigned int nparams, const u32 *params,
198262306a36Sopenharmony_ci		       u32 *val, int rw, bool sleep_ok);
198362306a36Sopenharmony_ciint t4_set_params_timeout(struct adapter *adap, unsigned int mbox,
198462306a36Sopenharmony_ci			  unsigned int pf, unsigned int vf,
198562306a36Sopenharmony_ci			  unsigned int nparams, const u32 *params,
198662306a36Sopenharmony_ci			  const u32 *val, int timeout);
198762306a36Sopenharmony_ciint t4_set_params(struct adapter *adap, unsigned int mbox, unsigned int pf,
198862306a36Sopenharmony_ci		  unsigned int vf, unsigned int nparams, const u32 *params,
198962306a36Sopenharmony_ci		  const u32 *val);
199062306a36Sopenharmony_ciint t4_cfg_pfvf(struct adapter *adap, unsigned int mbox, unsigned int pf,
199162306a36Sopenharmony_ci		unsigned int vf, unsigned int txq, unsigned int txq_eth_ctrl,
199262306a36Sopenharmony_ci		unsigned int rxqi, unsigned int rxq, unsigned int tc,
199362306a36Sopenharmony_ci		unsigned int vi, unsigned int cmask, unsigned int pmask,
199462306a36Sopenharmony_ci		unsigned int nexact, unsigned int rcaps, unsigned int wxcaps);
199562306a36Sopenharmony_ciint t4_alloc_vi(struct adapter *adap, unsigned int mbox, unsigned int port,
199662306a36Sopenharmony_ci		unsigned int pf, unsigned int vf, unsigned int nmac, u8 *mac,
199762306a36Sopenharmony_ci		unsigned int *rss_size, u8 *vivld, u8 *vin);
199862306a36Sopenharmony_ciint t4_free_vi(struct adapter *adap, unsigned int mbox,
199962306a36Sopenharmony_ci	       unsigned int pf, unsigned int vf,
200062306a36Sopenharmony_ci	       unsigned int viid);
200162306a36Sopenharmony_ciint t4_set_rxmode(struct adapter *adap, unsigned int mbox, unsigned int viid,
200262306a36Sopenharmony_ci		  unsigned int viid_mirror, int mtu, int promisc, int all_multi,
200362306a36Sopenharmony_ci		  int bcast, int vlanex, bool sleep_ok);
200462306a36Sopenharmony_ciint t4_free_raw_mac_filt(struct adapter *adap, unsigned int viid,
200562306a36Sopenharmony_ci			 const u8 *addr, const u8 *mask, unsigned int idx,
200662306a36Sopenharmony_ci			 u8 lookup_type, u8 port_id, bool sleep_ok);
200762306a36Sopenharmony_ciint t4_free_encap_mac_filt(struct adapter *adap, unsigned int viid, int idx,
200862306a36Sopenharmony_ci			   bool sleep_ok);
200962306a36Sopenharmony_ciint t4_alloc_encap_mac_filt(struct adapter *adap, unsigned int viid,
201062306a36Sopenharmony_ci			    const u8 *addr, const u8 *mask, unsigned int vni,
201162306a36Sopenharmony_ci			    unsigned int vni_mask, u8 dip_hit, u8 lookup_type,
201262306a36Sopenharmony_ci			    bool sleep_ok);
201362306a36Sopenharmony_ciint t4_alloc_raw_mac_filt(struct adapter *adap, unsigned int viid,
201462306a36Sopenharmony_ci			  const u8 *addr, const u8 *mask, unsigned int idx,
201562306a36Sopenharmony_ci			  u8 lookup_type, u8 port_id, bool sleep_ok);
201662306a36Sopenharmony_ciint t4_alloc_mac_filt(struct adapter *adap, unsigned int mbox,
201762306a36Sopenharmony_ci		      unsigned int viid, bool free, unsigned int naddr,
201862306a36Sopenharmony_ci		      const u8 **addr, u16 *idx, u64 *hash, bool sleep_ok);
201962306a36Sopenharmony_ciint t4_free_mac_filt(struct adapter *adap, unsigned int mbox,
202062306a36Sopenharmony_ci		     unsigned int viid, unsigned int naddr,
202162306a36Sopenharmony_ci		     const u8 **addr, bool sleep_ok);
202262306a36Sopenharmony_ciint t4_change_mac(struct adapter *adap, unsigned int mbox, unsigned int viid,
202362306a36Sopenharmony_ci		  int idx, const u8 *addr, bool persist, u8 *smt_idx);
202462306a36Sopenharmony_ciint t4_set_addr_hash(struct adapter *adap, unsigned int mbox, unsigned int viid,
202562306a36Sopenharmony_ci		     bool ucast, u64 vec, bool sleep_ok);
202662306a36Sopenharmony_ciint t4_enable_vi_params(struct adapter *adap, unsigned int mbox,
202762306a36Sopenharmony_ci			unsigned int viid, bool rx_en, bool tx_en, bool dcb_en);
202862306a36Sopenharmony_ciint t4_enable_pi_params(struct adapter *adap, unsigned int mbox,
202962306a36Sopenharmony_ci			struct port_info *pi,
203062306a36Sopenharmony_ci			bool rx_en, bool tx_en, bool dcb_en);
203162306a36Sopenharmony_ciint t4_enable_vi(struct adapter *adap, unsigned int mbox, unsigned int viid,
203262306a36Sopenharmony_ci		 bool rx_en, bool tx_en);
203362306a36Sopenharmony_ciint t4_identify_port(struct adapter *adap, unsigned int mbox, unsigned int viid,
203462306a36Sopenharmony_ci		     unsigned int nblinks);
203562306a36Sopenharmony_ciint t4_mdio_rd(struct adapter *adap, unsigned int mbox, unsigned int phy_addr,
203662306a36Sopenharmony_ci	       unsigned int mmd, unsigned int reg, u16 *valp);
203762306a36Sopenharmony_ciint t4_mdio_wr(struct adapter *adap, unsigned int mbox, unsigned int phy_addr,
203862306a36Sopenharmony_ci	       unsigned int mmd, unsigned int reg, u16 val);
203962306a36Sopenharmony_ciint t4_iq_stop(struct adapter *adap, unsigned int mbox, unsigned int pf,
204062306a36Sopenharmony_ci	       unsigned int vf, unsigned int iqtype, unsigned int iqid,
204162306a36Sopenharmony_ci	       unsigned int fl0id, unsigned int fl1id);
204262306a36Sopenharmony_ciint t4_iq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
204362306a36Sopenharmony_ci	       unsigned int vf, unsigned int iqtype, unsigned int iqid,
204462306a36Sopenharmony_ci	       unsigned int fl0id, unsigned int fl1id);
204562306a36Sopenharmony_ciint t4_eth_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
204662306a36Sopenharmony_ci		   unsigned int vf, unsigned int eqid);
204762306a36Sopenharmony_ciint t4_ctrl_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
204862306a36Sopenharmony_ci		    unsigned int vf, unsigned int eqid);
204962306a36Sopenharmony_ciint t4_ofld_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
205062306a36Sopenharmony_ci		    unsigned int vf, unsigned int eqid);
205162306a36Sopenharmony_ciint t4_sge_ctxt_flush(struct adapter *adap, unsigned int mbox, int ctxt_type);
205262306a36Sopenharmony_ciint t4_read_sge_dbqtimers(struct adapter *adap, unsigned int ndbqtimers,
205362306a36Sopenharmony_ci			  u16 *dbqtimers);
205462306a36Sopenharmony_civoid t4_handle_get_port_info(struct port_info *pi, const __be64 *rpl);
205562306a36Sopenharmony_ciint t4_update_port_info(struct port_info *pi);
205662306a36Sopenharmony_ciint t4_get_link_params(struct port_info *pi, unsigned int *link_okp,
205762306a36Sopenharmony_ci		       unsigned int *speedp, unsigned int *mtup);
205862306a36Sopenharmony_ciint t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl);
205962306a36Sopenharmony_civoid t4_db_full(struct adapter *adapter);
206062306a36Sopenharmony_civoid t4_db_dropped(struct adapter *adapter);
206162306a36Sopenharmony_ciint t4_set_trace_filter(struct adapter *adapter, const struct trace_params *tp,
206262306a36Sopenharmony_ci			int filter_index, int enable);
206362306a36Sopenharmony_civoid t4_get_trace_filter(struct adapter *adapter, struct trace_params *tp,
206462306a36Sopenharmony_ci			 int filter_index, int *enabled);
206562306a36Sopenharmony_ciint t4_fwaddrspace_write(struct adapter *adap, unsigned int mbox,
206662306a36Sopenharmony_ci			 u32 addr, u32 val);
206762306a36Sopenharmony_civoid t4_read_pace_tbl(struct adapter *adap, unsigned int pace_vals[NTX_SCHED]);
206862306a36Sopenharmony_civoid t4_get_tx_sched(struct adapter *adap, unsigned int sched,
206962306a36Sopenharmony_ci		     unsigned int *kbps, unsigned int *ipg, bool sleep_ok);
207062306a36Sopenharmony_ciint t4_sge_ctxt_rd(struct adapter *adap, unsigned int mbox, unsigned int cid,
207162306a36Sopenharmony_ci		   enum ctxt_type ctype, u32 *data);
207262306a36Sopenharmony_ciint t4_sge_ctxt_rd_bd(struct adapter *adap, unsigned int cid,
207362306a36Sopenharmony_ci		      enum ctxt_type ctype, u32 *data);
207462306a36Sopenharmony_ciint t4_sched_params(struct adapter *adapter, u8 type, u8 level, u8 mode,
207562306a36Sopenharmony_ci		    u8 rateunit, u8 ratemode, u8 channel, u8 class,
207662306a36Sopenharmony_ci		    u32 minrate, u32 maxrate, u16 weight, u16 pktsize,
207762306a36Sopenharmony_ci		    u16 burstsize);
207862306a36Sopenharmony_civoid t4_sge_decode_idma_state(struct adapter *adapter, int state);
207962306a36Sopenharmony_civoid t4_idma_monitor_init(struct adapter *adapter,
208062306a36Sopenharmony_ci			  struct sge_idma_monitor_state *idma);
208162306a36Sopenharmony_civoid t4_idma_monitor(struct adapter *adapter,
208262306a36Sopenharmony_ci		     struct sge_idma_monitor_state *idma,
208362306a36Sopenharmony_ci		     int hz, int ticks);
208462306a36Sopenharmony_ciint t4_set_vf_mac_acl(struct adapter *adapter, unsigned int vf,
208562306a36Sopenharmony_ci		      unsigned int naddr, u8 *addr);
208662306a36Sopenharmony_civoid t4_tp_pio_read(struct adapter *adap, u32 *buff, u32 nregs,
208762306a36Sopenharmony_ci		    u32 start_index, bool sleep_ok);
208862306a36Sopenharmony_civoid t4_tp_tm_pio_read(struct adapter *adap, u32 *buff, u32 nregs,
208962306a36Sopenharmony_ci		       u32 start_index, bool sleep_ok);
209062306a36Sopenharmony_civoid t4_tp_mib_read(struct adapter *adap, u32 *buff, u32 nregs,
209162306a36Sopenharmony_ci		    u32 start_index, bool sleep_ok);
209262306a36Sopenharmony_ci
209362306a36Sopenharmony_civoid t4_uld_mem_free(struct adapter *adap);
209462306a36Sopenharmony_ciint t4_uld_mem_alloc(struct adapter *adap);
209562306a36Sopenharmony_civoid t4_uld_clean_up(struct adapter *adap);
209662306a36Sopenharmony_civoid t4_register_netevent_notifier(void);
209762306a36Sopenharmony_ciint t4_i2c_rd(struct adapter *adap, unsigned int mbox, int port,
209862306a36Sopenharmony_ci	      unsigned int devid, unsigned int offset,
209962306a36Sopenharmony_ci	      unsigned int len, u8 *buf);
210062306a36Sopenharmony_ciint t4_load_boot(struct adapter *adap, u8 *boot_data,
210162306a36Sopenharmony_ci		 unsigned int boot_addr, unsigned int size);
210262306a36Sopenharmony_ciint t4_load_bootcfg(struct adapter *adap,
210362306a36Sopenharmony_ci		    const u8 *cfg_data, unsigned int size);
210462306a36Sopenharmony_civoid free_rspq_fl(struct adapter *adap, struct sge_rspq *rq, struct sge_fl *fl);
210562306a36Sopenharmony_civoid free_tx_desc(struct adapter *adap, struct sge_txq *q,
210662306a36Sopenharmony_ci		  unsigned int n, bool unmap);
210762306a36Sopenharmony_civoid cxgb4_eosw_txq_free_desc(struct adapter *adap, struct sge_eosw_txq *txq,
210862306a36Sopenharmony_ci			      u32 ndesc);
210962306a36Sopenharmony_ciint cxgb4_ethofld_send_flowc(struct net_device *dev, u32 eotid, u32 tc);
211062306a36Sopenharmony_civoid cxgb4_ethofld_restart(struct tasklet_struct *t);
211162306a36Sopenharmony_ciint cxgb4_ethofld_rx_handler(struct sge_rspq *q, const __be64 *rsp,
211262306a36Sopenharmony_ci			     const struct pkt_gl *si);
211362306a36Sopenharmony_civoid free_txq(struct adapter *adap, struct sge_txq *q);
211462306a36Sopenharmony_civoid cxgb4_reclaim_completed_tx(struct adapter *adap,
211562306a36Sopenharmony_ci				struct sge_txq *q, bool unmap);
211662306a36Sopenharmony_ciint cxgb4_map_skb(struct device *dev, const struct sk_buff *skb,
211762306a36Sopenharmony_ci		  dma_addr_t *addr);
211862306a36Sopenharmony_civoid cxgb4_inline_tx_skb(const struct sk_buff *skb, const struct sge_txq *q,
211962306a36Sopenharmony_ci			 void *pos);
212062306a36Sopenharmony_civoid cxgb4_write_sgl(const struct sk_buff *skb, struct sge_txq *q,
212162306a36Sopenharmony_ci		     struct ulptx_sgl *sgl, u64 *end, unsigned int start,
212262306a36Sopenharmony_ci		     const dma_addr_t *addr);
212362306a36Sopenharmony_civoid cxgb4_write_partial_sgl(const struct sk_buff *skb, struct sge_txq *q,
212462306a36Sopenharmony_ci			     struct ulptx_sgl *sgl, u64 *end,
212562306a36Sopenharmony_ci			     const dma_addr_t *addr, u32 start, u32 send_len);
212662306a36Sopenharmony_civoid cxgb4_ring_tx_db(struct adapter *adap, struct sge_txq *q, int n);
212762306a36Sopenharmony_ciint t4_set_vlan_acl(struct adapter *adap, unsigned int mbox, unsigned int vf,
212862306a36Sopenharmony_ci		    u16 vlan);
212962306a36Sopenharmony_ciint cxgb4_dcb_enabled(const struct net_device *dev);
213062306a36Sopenharmony_ci
213162306a36Sopenharmony_ciint cxgb4_thermal_init(struct adapter *adap);
213262306a36Sopenharmony_ciint cxgb4_thermal_remove(struct adapter *adap);
213362306a36Sopenharmony_ciint cxgb4_set_msix_aff(struct adapter *adap, unsigned short vec,
213462306a36Sopenharmony_ci		       cpumask_var_t *aff_mask, int idx);
213562306a36Sopenharmony_civoid cxgb4_clear_msix_aff(unsigned short vec, cpumask_var_t aff_mask);
213662306a36Sopenharmony_ci
213762306a36Sopenharmony_ciint cxgb4_change_mac(struct port_info *pi, unsigned int viid,
213862306a36Sopenharmony_ci		     int *tcam_idx, const u8 *addr,
213962306a36Sopenharmony_ci		     bool persistent, u8 *smt_idx);
214062306a36Sopenharmony_ci
214162306a36Sopenharmony_ciint cxgb4_alloc_mac_filt(struct adapter *adap, unsigned int viid,
214262306a36Sopenharmony_ci			 bool free, unsigned int naddr,
214362306a36Sopenharmony_ci			 const u8 **addr, u16 *idx,
214462306a36Sopenharmony_ci			 u64 *hash, bool sleep_ok);
214562306a36Sopenharmony_ciint cxgb4_free_mac_filt(struct adapter *adap, unsigned int viid,
214662306a36Sopenharmony_ci			unsigned int naddr, const u8 **addr, bool sleep_ok);
214762306a36Sopenharmony_ciint cxgb4_init_mps_ref_entries(struct adapter *adap);
214862306a36Sopenharmony_civoid cxgb4_free_mps_ref_entries(struct adapter *adap);
214962306a36Sopenharmony_ciint cxgb4_alloc_encap_mac_filt(struct adapter *adap, unsigned int viid,
215062306a36Sopenharmony_ci			       const u8 *addr, const u8 *mask,
215162306a36Sopenharmony_ci			       unsigned int vni, unsigned int vni_mask,
215262306a36Sopenharmony_ci			       u8 dip_hit, u8 lookup_type, bool sleep_ok);
215362306a36Sopenharmony_ciint cxgb4_free_encap_mac_filt(struct adapter *adap, unsigned int viid,
215462306a36Sopenharmony_ci			      int idx, bool sleep_ok);
215562306a36Sopenharmony_ciint cxgb4_free_raw_mac_filt(struct adapter *adap,
215662306a36Sopenharmony_ci			    unsigned int viid,
215762306a36Sopenharmony_ci			    const u8 *addr,
215862306a36Sopenharmony_ci			    const u8 *mask,
215962306a36Sopenharmony_ci			    unsigned int idx,
216062306a36Sopenharmony_ci			    u8 lookup_type,
216162306a36Sopenharmony_ci			    u8 port_id,
216262306a36Sopenharmony_ci			    bool sleep_ok);
216362306a36Sopenharmony_ciint cxgb4_alloc_raw_mac_filt(struct adapter *adap,
216462306a36Sopenharmony_ci			     unsigned int viid,
216562306a36Sopenharmony_ci			     const u8 *addr,
216662306a36Sopenharmony_ci			     const u8 *mask,
216762306a36Sopenharmony_ci			     unsigned int idx,
216862306a36Sopenharmony_ci			     u8 lookup_type,
216962306a36Sopenharmony_ci			     u8 port_id,
217062306a36Sopenharmony_ci			     bool sleep_ok);
217162306a36Sopenharmony_ciint cxgb4_update_mac_filt(struct port_info *pi, unsigned int viid,
217262306a36Sopenharmony_ci			  int *tcam_idx, const u8 *addr,
217362306a36Sopenharmony_ci			  bool persistent, u8 *smt_idx);
217462306a36Sopenharmony_ciint cxgb4_get_msix_idx_from_bmap(struct adapter *adap);
217562306a36Sopenharmony_civoid cxgb4_free_msix_idx_in_bmap(struct adapter *adap, u32 msix_idx);
217662306a36Sopenharmony_civoid cxgb4_enable_rx(struct adapter *adap, struct sge_rspq *q);
217762306a36Sopenharmony_civoid cxgb4_quiesce_rx(struct sge_rspq *q);
217862306a36Sopenharmony_ciint cxgb4_port_mirror_alloc(struct net_device *dev);
217962306a36Sopenharmony_civoid cxgb4_port_mirror_free(struct net_device *dev);
218062306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_CHELSIO_TLS_DEVICE)
218162306a36Sopenharmony_ciint cxgb4_set_ktls_feature(struct adapter *adap, bool enable);
218262306a36Sopenharmony_ci#endif
218362306a36Sopenharmony_ci#endif /* __CXGB4_H__ */
2184