162306a36Sopenharmony_ci/* bnx2x.h: QLogic Everest network driver.
262306a36Sopenharmony_ci *
362306a36Sopenharmony_ci * Copyright (c) 2007-2013 Broadcom Corporation
462306a36Sopenharmony_ci * Copyright (c) 2014 QLogic Corporation
562306a36Sopenharmony_ci * All rights reserved
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * This program is free software; you can redistribute it and/or modify
862306a36Sopenharmony_ci * it under the terms of the GNU General Public License as published by
962306a36Sopenharmony_ci * the Free Software Foundation.
1062306a36Sopenharmony_ci *
1162306a36Sopenharmony_ci * Maintained by: Ariel Elior <ariel.elior@qlogic.com>
1262306a36Sopenharmony_ci * Written by: Eliezer Tamir
1362306a36Sopenharmony_ci * Based on code from Michael Chan's bnx2 driver
1462306a36Sopenharmony_ci */
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci#ifndef BNX2X_H
1762306a36Sopenharmony_ci#define BNX2X_H
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci#include <linux/pci.h>
2062306a36Sopenharmony_ci#include <linux/netdevice.h>
2162306a36Sopenharmony_ci#include <linux/dma-mapping.h>
2262306a36Sopenharmony_ci#include <linux/types.h>
2362306a36Sopenharmony_ci#include <linux/pci_regs.h>
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci#include <linux/ptp_clock_kernel.h>
2662306a36Sopenharmony_ci#include <linux/net_tstamp.h>
2762306a36Sopenharmony_ci#include <linux/timecounter.h>
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci/* compilation time flags */
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci/* define this to make the driver freeze on error to allow getting debug info
3262306a36Sopenharmony_ci * (you will need to reboot afterwards) */
3362306a36Sopenharmony_ci/* #define BNX2X_STOP_ON_ERROR */
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci/* FIXME: Delete the DRV_MODULE_VERSION below, but please be warned
3662306a36Sopenharmony_ci * that it is not an easy task because such change has all chances
3762306a36Sopenharmony_ci * to break this driver due to amount of abuse of in-kernel interfaces
3862306a36Sopenharmony_ci * between modules and FW.
3962306a36Sopenharmony_ci *
4062306a36Sopenharmony_ci * DO NOT UPDATE DRV_MODULE_VERSION below.
4162306a36Sopenharmony_ci */
4262306a36Sopenharmony_ci#define DRV_MODULE_VERSION      "1.713.36-0"
4362306a36Sopenharmony_ci#define BNX2X_BC_VER            0x040200
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci#if defined(CONFIG_DCB)
4662306a36Sopenharmony_ci#define BCM_DCBNL
4762306a36Sopenharmony_ci#endif
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci#include "bnx2x_hsi.h"
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ci#include "../cnic_if.h"
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ci#define BNX2X_MIN_MSIX_VEC_CNT(bp)		((bp)->min_msix_vec_cnt)
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci#include <linux/mdio.h>
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci#include "bnx2x_reg.h"
5862306a36Sopenharmony_ci#include "bnx2x_fw_defs.h"
5962306a36Sopenharmony_ci#include "bnx2x_mfw_req.h"
6062306a36Sopenharmony_ci#include "bnx2x_link.h"
6162306a36Sopenharmony_ci#include "bnx2x_sp.h"
6262306a36Sopenharmony_ci#include "bnx2x_dcb.h"
6362306a36Sopenharmony_ci#include "bnx2x_stats.h"
6462306a36Sopenharmony_ci#include "bnx2x_vfpf.h"
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_cienum bnx2x_int_mode {
6762306a36Sopenharmony_ci	BNX2X_INT_MODE_MSIX,
6862306a36Sopenharmony_ci	BNX2X_INT_MODE_INTX,
6962306a36Sopenharmony_ci	BNX2X_INT_MODE_MSI
7062306a36Sopenharmony_ci};
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci/* error/debug prints */
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci#define DRV_MODULE_NAME		"bnx2x"
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci/* for messages that are currently off */
7762306a36Sopenharmony_ci#define BNX2X_MSG_OFF			0x0
7862306a36Sopenharmony_ci#define BNX2X_MSG_MCP			0x0010000 /* was: NETIF_MSG_HW */
7962306a36Sopenharmony_ci#define BNX2X_MSG_STATS			0x0020000 /* was: NETIF_MSG_TIMER */
8062306a36Sopenharmony_ci#define BNX2X_MSG_NVM			0x0040000 /* was: NETIF_MSG_HW */
8162306a36Sopenharmony_ci#define BNX2X_MSG_DMAE			0x0080000 /* was: NETIF_MSG_HW */
8262306a36Sopenharmony_ci#define BNX2X_MSG_SP			0x0100000 /* was: NETIF_MSG_INTR */
8362306a36Sopenharmony_ci#define BNX2X_MSG_FP			0x0200000 /* was: NETIF_MSG_INTR */
8462306a36Sopenharmony_ci#define BNX2X_MSG_IOV			0x0800000
8562306a36Sopenharmony_ci#define BNX2X_MSG_PTP			0x1000000
8662306a36Sopenharmony_ci#define BNX2X_MSG_IDLE			0x2000000 /* used for idle check*/
8762306a36Sopenharmony_ci#define BNX2X_MSG_ETHTOOL		0x4000000
8862306a36Sopenharmony_ci#define BNX2X_MSG_DCB			0x8000000
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_ci/* regular debug print */
9162306a36Sopenharmony_ci#define DP_INNER(fmt, ...)					\
9262306a36Sopenharmony_ci	pr_notice("[%s:%d(%s)]" fmt,				\
9362306a36Sopenharmony_ci		  __func__, __LINE__,				\
9462306a36Sopenharmony_ci		  bp->dev ? (bp->dev->name) : "?",		\
9562306a36Sopenharmony_ci		  ##__VA_ARGS__);
9662306a36Sopenharmony_ci
9762306a36Sopenharmony_ci#define DP(__mask, fmt, ...)					\
9862306a36Sopenharmony_cido {								\
9962306a36Sopenharmony_ci	if (unlikely(bp->msg_enable & (__mask)))		\
10062306a36Sopenharmony_ci		DP_INNER(fmt, ##__VA_ARGS__);			\
10162306a36Sopenharmony_ci} while (0)
10262306a36Sopenharmony_ci
10362306a36Sopenharmony_ci#define DP_AND(__mask, fmt, ...)				\
10462306a36Sopenharmony_cido {								\
10562306a36Sopenharmony_ci	if (unlikely((bp->msg_enable & (__mask)) == __mask))	\
10662306a36Sopenharmony_ci		DP_INNER(fmt, ##__VA_ARGS__);			\
10762306a36Sopenharmony_ci} while (0)
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ci#define DP_CONT(__mask, fmt, ...)				\
11062306a36Sopenharmony_cido {								\
11162306a36Sopenharmony_ci	if (unlikely(bp->msg_enable & (__mask)))		\
11262306a36Sopenharmony_ci		pr_cont(fmt, ##__VA_ARGS__);			\
11362306a36Sopenharmony_ci} while (0)
11462306a36Sopenharmony_ci
11562306a36Sopenharmony_ci/* errors debug print */
11662306a36Sopenharmony_ci#define BNX2X_DBG_ERR(fmt, ...)					\
11762306a36Sopenharmony_cido {								\
11862306a36Sopenharmony_ci	if (unlikely(netif_msg_probe(bp)))			\
11962306a36Sopenharmony_ci		pr_err("[%s:%d(%s)]" fmt,			\
12062306a36Sopenharmony_ci		       __func__, __LINE__,			\
12162306a36Sopenharmony_ci		       bp->dev ? (bp->dev->name) : "?",		\
12262306a36Sopenharmony_ci		       ##__VA_ARGS__);				\
12362306a36Sopenharmony_ci} while (0)
12462306a36Sopenharmony_ci
12562306a36Sopenharmony_ci/* for errors (never masked) */
12662306a36Sopenharmony_ci#define BNX2X_ERR(fmt, ...)					\
12762306a36Sopenharmony_cido {								\
12862306a36Sopenharmony_ci	pr_err("[%s:%d(%s)]" fmt,				\
12962306a36Sopenharmony_ci	       __func__, __LINE__,				\
13062306a36Sopenharmony_ci	       bp->dev ? (bp->dev->name) : "?",			\
13162306a36Sopenharmony_ci	       ##__VA_ARGS__);					\
13262306a36Sopenharmony_ci} while (0)
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ci#define BNX2X_ERROR(fmt, ...)					\
13562306a36Sopenharmony_ci	pr_err("[%s:%d]" fmt, __func__, __LINE__, ##__VA_ARGS__)
13662306a36Sopenharmony_ci
13762306a36Sopenharmony_ci/* before we have a dev->name use dev_info() */
13862306a36Sopenharmony_ci#define BNX2X_DEV_INFO(fmt, ...)				 \
13962306a36Sopenharmony_cido {								 \
14062306a36Sopenharmony_ci	if (unlikely(netif_msg_probe(bp)))			 \
14162306a36Sopenharmony_ci		dev_info(&bp->pdev->dev, fmt, ##__VA_ARGS__);	 \
14262306a36Sopenharmony_ci} while (0)
14362306a36Sopenharmony_ci
14462306a36Sopenharmony_ci/* Error handling */
14562306a36Sopenharmony_civoid bnx2x_panic_dump(struct bnx2x *bp, bool disable_int);
14662306a36Sopenharmony_ci#ifdef BNX2X_STOP_ON_ERROR
14762306a36Sopenharmony_ci#define bnx2x_panic()				\
14862306a36Sopenharmony_cido {						\
14962306a36Sopenharmony_ci	bp->panic = 1;				\
15062306a36Sopenharmony_ci	BNX2X_ERR("driver assert\n");		\
15162306a36Sopenharmony_ci	bnx2x_panic_dump(bp, true);		\
15262306a36Sopenharmony_ci} while (0)
15362306a36Sopenharmony_ci#else
15462306a36Sopenharmony_ci#define bnx2x_panic()				\
15562306a36Sopenharmony_cido {						\
15662306a36Sopenharmony_ci	bp->panic = 1;				\
15762306a36Sopenharmony_ci	BNX2X_ERR("driver assert\n");		\
15862306a36Sopenharmony_ci	bnx2x_panic_dump(bp, false);		\
15962306a36Sopenharmony_ci} while (0)
16062306a36Sopenharmony_ci#endif
16162306a36Sopenharmony_ci
16262306a36Sopenharmony_ci#define bnx2x_mc_addr(ha)      ((ha)->addr)
16362306a36Sopenharmony_ci#define bnx2x_uc_addr(ha)      ((ha)->addr)
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_ci#define U64_LO(x)			((u32)(((u64)(x)) & 0xffffffff))
16662306a36Sopenharmony_ci#define U64_HI(x)			((u32)(((u64)(x)) >> 32))
16762306a36Sopenharmony_ci#define HILO_U64(hi, lo)		((((u64)(hi)) << 32) + (lo))
16862306a36Sopenharmony_ci
16962306a36Sopenharmony_ci#define REG_ADDR(bp, offset)		((bp->regview) + (offset))
17062306a36Sopenharmony_ci
17162306a36Sopenharmony_ci#define REG_RD(bp, offset)		readl(REG_ADDR(bp, offset))
17262306a36Sopenharmony_ci#define REG_RD8(bp, offset)		readb(REG_ADDR(bp, offset))
17362306a36Sopenharmony_ci#define REG_RD16(bp, offset)		readw(REG_ADDR(bp, offset))
17462306a36Sopenharmony_ci
17562306a36Sopenharmony_ci#define REG_WR_RELAXED(bp, offset, val)	\
17662306a36Sopenharmony_ci	writel_relaxed((u32)val, REG_ADDR(bp, offset))
17762306a36Sopenharmony_ci
17862306a36Sopenharmony_ci#define REG_WR16_RELAXED(bp, offset, val) \
17962306a36Sopenharmony_ci	writew_relaxed((u16)val, REG_ADDR(bp, offset))
18062306a36Sopenharmony_ci
18162306a36Sopenharmony_ci#define REG_WR(bp, offset, val)		writel((u32)val, REG_ADDR(bp, offset))
18262306a36Sopenharmony_ci#define REG_WR8(bp, offset, val)	writeb((u8)val, REG_ADDR(bp, offset))
18362306a36Sopenharmony_ci#define REG_WR16(bp, offset, val)	writew((u16)val, REG_ADDR(bp, offset))
18462306a36Sopenharmony_ci
18562306a36Sopenharmony_ci#define REG_RD_IND(bp, offset)		bnx2x_reg_rd_ind(bp, offset)
18662306a36Sopenharmony_ci#define REG_WR_IND(bp, offset, val)	bnx2x_reg_wr_ind(bp, offset, val)
18762306a36Sopenharmony_ci
18862306a36Sopenharmony_ci#define REG_RD_DMAE(bp, offset, valp, len32) \
18962306a36Sopenharmony_ci	do { \
19062306a36Sopenharmony_ci		bnx2x_read_dmae(bp, offset, len32);\
19162306a36Sopenharmony_ci		memcpy(valp, bnx2x_sp(bp, wb_data[0]), (len32) * 4); \
19262306a36Sopenharmony_ci	} while (0)
19362306a36Sopenharmony_ci
19462306a36Sopenharmony_ci#define REG_WR_DMAE(bp, offset, valp, len32) \
19562306a36Sopenharmony_ci	do { \
19662306a36Sopenharmony_ci		memcpy(bnx2x_sp(bp, wb_data[0]), valp, (len32) * 4); \
19762306a36Sopenharmony_ci		bnx2x_write_dmae(bp, bnx2x_sp_mapping(bp, wb_data), \
19862306a36Sopenharmony_ci				 offset, len32); \
19962306a36Sopenharmony_ci	} while (0)
20062306a36Sopenharmony_ci
20162306a36Sopenharmony_ci#define REG_WR_DMAE_LEN(bp, offset, valp, len32) \
20262306a36Sopenharmony_ci	REG_WR_DMAE(bp, offset, valp, len32)
20362306a36Sopenharmony_ci
20462306a36Sopenharmony_ci#define VIRT_WR_DMAE_LEN(bp, data, addr, len32, le32_swap) \
20562306a36Sopenharmony_ci	do { \
20662306a36Sopenharmony_ci		memcpy(GUNZIP_BUF(bp), data, (len32) * 4); \
20762306a36Sopenharmony_ci		bnx2x_write_big_buf_wb(bp, addr, len32); \
20862306a36Sopenharmony_ci	} while (0)
20962306a36Sopenharmony_ci
21062306a36Sopenharmony_ci#define SHMEM_ADDR(bp, field)		(bp->common.shmem_base + \
21162306a36Sopenharmony_ci					 offsetof(struct shmem_region, field))
21262306a36Sopenharmony_ci#define SHMEM_RD(bp, field)		REG_RD(bp, SHMEM_ADDR(bp, field))
21362306a36Sopenharmony_ci#define SHMEM_WR(bp, field, val)	REG_WR(bp, SHMEM_ADDR(bp, field), val)
21462306a36Sopenharmony_ci
21562306a36Sopenharmony_ci#define SHMEM2_ADDR(bp, field)		(bp->common.shmem2_base + \
21662306a36Sopenharmony_ci					 offsetof(struct shmem2_region, field))
21762306a36Sopenharmony_ci#define SHMEM2_RD(bp, field)		REG_RD(bp, SHMEM2_ADDR(bp, field))
21862306a36Sopenharmony_ci#define SHMEM2_WR(bp, field, val)	REG_WR(bp, SHMEM2_ADDR(bp, field), val)
21962306a36Sopenharmony_ci#define MF_CFG_ADDR(bp, field)		(bp->common.mf_cfg_base + \
22062306a36Sopenharmony_ci					 offsetof(struct mf_cfg, field))
22162306a36Sopenharmony_ci#define MF2_CFG_ADDR(bp, field)		(bp->common.mf2_cfg_base + \
22262306a36Sopenharmony_ci					 offsetof(struct mf2_cfg, field))
22362306a36Sopenharmony_ci
22462306a36Sopenharmony_ci#define MF_CFG_RD(bp, field)		REG_RD(bp, MF_CFG_ADDR(bp, field))
22562306a36Sopenharmony_ci#define MF_CFG_WR(bp, field, val)	REG_WR(bp,\
22662306a36Sopenharmony_ci					       MF_CFG_ADDR(bp, field), (val))
22762306a36Sopenharmony_ci#define MF2_CFG_RD(bp, field)		REG_RD(bp, MF2_CFG_ADDR(bp, field))
22862306a36Sopenharmony_ci
22962306a36Sopenharmony_ci#define SHMEM2_HAS(bp, field)		((bp)->common.shmem2_base &&	\
23062306a36Sopenharmony_ci					 (SHMEM2_RD((bp), size) >	\
23162306a36Sopenharmony_ci					 offsetof(struct shmem2_region, field)))
23262306a36Sopenharmony_ci
23362306a36Sopenharmony_ci#define EMAC_RD(bp, reg)		REG_RD(bp, emac_base + reg)
23462306a36Sopenharmony_ci#define EMAC_WR(bp, reg, val)		REG_WR(bp, emac_base + reg, val)
23562306a36Sopenharmony_ci
23662306a36Sopenharmony_ci/* SP SB indices */
23762306a36Sopenharmony_ci
23862306a36Sopenharmony_ci/* General SP events - stats query, cfc delete, etc  */
23962306a36Sopenharmony_ci#define HC_SP_INDEX_ETH_DEF_CONS		3
24062306a36Sopenharmony_ci
24162306a36Sopenharmony_ci/* EQ completions */
24262306a36Sopenharmony_ci#define HC_SP_INDEX_EQ_CONS			7
24362306a36Sopenharmony_ci
24462306a36Sopenharmony_ci/* FCoE L2 connection completions */
24562306a36Sopenharmony_ci#define HC_SP_INDEX_ETH_FCOE_TX_CQ_CONS		6
24662306a36Sopenharmony_ci#define HC_SP_INDEX_ETH_FCOE_RX_CQ_CONS		4
24762306a36Sopenharmony_ci/* iSCSI L2 */
24862306a36Sopenharmony_ci#define HC_SP_INDEX_ETH_ISCSI_CQ_CONS		5
24962306a36Sopenharmony_ci#define HC_SP_INDEX_ETH_ISCSI_RX_CQ_CONS	1
25062306a36Sopenharmony_ci
25162306a36Sopenharmony_ci/* Special clients parameters */
25262306a36Sopenharmony_ci
25362306a36Sopenharmony_ci/* SB indices */
25462306a36Sopenharmony_ci/* FCoE L2 */
25562306a36Sopenharmony_ci#define BNX2X_FCOE_L2_RX_INDEX \
25662306a36Sopenharmony_ci	(&bp->def_status_blk->sp_sb.\
25762306a36Sopenharmony_ci	index_values[HC_SP_INDEX_ETH_FCOE_RX_CQ_CONS])
25862306a36Sopenharmony_ci
25962306a36Sopenharmony_ci#define BNX2X_FCOE_L2_TX_INDEX \
26062306a36Sopenharmony_ci	(&bp->def_status_blk->sp_sb.\
26162306a36Sopenharmony_ci	index_values[HC_SP_INDEX_ETH_FCOE_TX_CQ_CONS])
26262306a36Sopenharmony_ci
26362306a36Sopenharmony_ci/**
26462306a36Sopenharmony_ci *  CIDs and CLIDs:
26562306a36Sopenharmony_ci *  CLIDs below is a CLID for func 0, then the CLID for other
26662306a36Sopenharmony_ci *  functions will be calculated by the formula:
26762306a36Sopenharmony_ci *
26862306a36Sopenharmony_ci *  FUNC_N_CLID_X = N * NUM_SPECIAL_CLIENTS + FUNC_0_CLID_X
26962306a36Sopenharmony_ci *
27062306a36Sopenharmony_ci */
27162306a36Sopenharmony_cienum {
27262306a36Sopenharmony_ci	BNX2X_ISCSI_ETH_CL_ID_IDX,
27362306a36Sopenharmony_ci	BNX2X_FCOE_ETH_CL_ID_IDX,
27462306a36Sopenharmony_ci	BNX2X_MAX_CNIC_ETH_CL_ID_IDX,
27562306a36Sopenharmony_ci};
27662306a36Sopenharmony_ci
27762306a36Sopenharmony_ci/* use a value high enough to be above all the PFs, which has least significant
27862306a36Sopenharmony_ci * nibble as 8, so when cnic needs to come up with a CID for UIO to use to
27962306a36Sopenharmony_ci * calculate doorbell address according to old doorbell configuration scheme
28062306a36Sopenharmony_ci * (db_msg_sz 1 << 7 * cid + 0x40 DPM offset) it can come up with a valid number
28162306a36Sopenharmony_ci * We must avoid coming up with cid 8 for iscsi since according to this method
28262306a36Sopenharmony_ci * the designated UIO cid will come out 0 and it has a special handling for that
28362306a36Sopenharmony_ci * case which doesn't suit us. Therefore will will cieling to closes cid which
28462306a36Sopenharmony_ci * has least signigifcant nibble 8 and if it is 8 we will move forward to 0x18.
28562306a36Sopenharmony_ci */
28662306a36Sopenharmony_ci
28762306a36Sopenharmony_ci#define BNX2X_1st_NON_L2_ETH_CID(bp)	(BNX2X_NUM_NON_CNIC_QUEUES(bp) * \
28862306a36Sopenharmony_ci					 (bp)->max_cos)
28962306a36Sopenharmony_ci/* amount of cids traversed by UIO's DPM addition to doorbell */
29062306a36Sopenharmony_ci#define UIO_DPM				8
29162306a36Sopenharmony_ci/* roundup to DPM offset */
29262306a36Sopenharmony_ci#define UIO_ROUNDUP(bp)			(roundup(BNX2X_1st_NON_L2_ETH_CID(bp), \
29362306a36Sopenharmony_ci					 UIO_DPM))
29462306a36Sopenharmony_ci/* offset to nearest value which has lsb nibble matching DPM */
29562306a36Sopenharmony_ci#define UIO_CID_OFFSET(bp)		((UIO_ROUNDUP(bp) + UIO_DPM) % \
29662306a36Sopenharmony_ci					 (UIO_DPM * 2))
29762306a36Sopenharmony_ci/* add offset to rounded-up cid to get a value which could be used with UIO */
29862306a36Sopenharmony_ci#define UIO_DPM_ALIGN(bp)		(UIO_ROUNDUP(bp) + UIO_CID_OFFSET(bp))
29962306a36Sopenharmony_ci/* but wait - avoid UIO special case for cid 0 */
30062306a36Sopenharmony_ci#define UIO_DPM_CID0_OFFSET(bp)		((UIO_DPM * 2) * \
30162306a36Sopenharmony_ci					 (UIO_DPM_ALIGN(bp) == UIO_DPM))
30262306a36Sopenharmony_ci/* Properly DPM aligned CID dajusted to cid 0 secal case */
30362306a36Sopenharmony_ci#define BNX2X_CNIC_START_ETH_CID(bp)	(UIO_DPM_ALIGN(bp) + \
30462306a36Sopenharmony_ci					 (UIO_DPM_CID0_OFFSET(bp)))
30562306a36Sopenharmony_ci/* how many cids were wasted  - need this value for cid allocation */
30662306a36Sopenharmony_ci#define UIO_CID_PAD(bp)			(BNX2X_CNIC_START_ETH_CID(bp) - \
30762306a36Sopenharmony_ci					 BNX2X_1st_NON_L2_ETH_CID(bp))
30862306a36Sopenharmony_ci	/* iSCSI L2 */
30962306a36Sopenharmony_ci#define	BNX2X_ISCSI_ETH_CID(bp)		(BNX2X_CNIC_START_ETH_CID(bp))
31062306a36Sopenharmony_ci	/* FCoE L2 */
31162306a36Sopenharmony_ci#define	BNX2X_FCOE_ETH_CID(bp)		(BNX2X_CNIC_START_ETH_CID(bp) + 1)
31262306a36Sopenharmony_ci
31362306a36Sopenharmony_ci#define CNIC_SUPPORT(bp)		((bp)->cnic_support)
31462306a36Sopenharmony_ci#define CNIC_ENABLED(bp)		((bp)->cnic_enabled)
31562306a36Sopenharmony_ci#define CNIC_LOADED(bp)			((bp)->cnic_loaded)
31662306a36Sopenharmony_ci#define FCOE_INIT(bp)			((bp)->fcoe_init)
31762306a36Sopenharmony_ci
31862306a36Sopenharmony_ci#define AEU_IN_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR \
31962306a36Sopenharmony_ci	AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR
32062306a36Sopenharmony_ci
32162306a36Sopenharmony_ci#define SM_RX_ID			0
32262306a36Sopenharmony_ci#define SM_TX_ID			1
32362306a36Sopenharmony_ci
32462306a36Sopenharmony_ci/* defines for multiple tx priority indices */
32562306a36Sopenharmony_ci#define FIRST_TX_ONLY_COS_INDEX		1
32662306a36Sopenharmony_ci#define FIRST_TX_COS_INDEX		0
32762306a36Sopenharmony_ci
32862306a36Sopenharmony_ci/* rules for calculating the cids of tx-only connections */
32962306a36Sopenharmony_ci#define CID_TO_FP(cid, bp)		((cid) % BNX2X_NUM_NON_CNIC_QUEUES(bp))
33062306a36Sopenharmony_ci#define CID_COS_TO_TX_ONLY_CID(cid, cos, bp) \
33162306a36Sopenharmony_ci				(cid + cos * BNX2X_NUM_NON_CNIC_QUEUES(bp))
33262306a36Sopenharmony_ci
33362306a36Sopenharmony_ci/* fp index inside class of service range */
33462306a36Sopenharmony_ci#define FP_COS_TO_TXQ(fp, cos, bp) \
33562306a36Sopenharmony_ci			((fp)->index + cos * BNX2X_NUM_NON_CNIC_QUEUES(bp))
33662306a36Sopenharmony_ci
33762306a36Sopenharmony_ci/* Indexes for transmission queues array:
33862306a36Sopenharmony_ci * txdata for RSS i CoS j is at location i + (j * num of RSS)
33962306a36Sopenharmony_ci * txdata for FCoE (if exist) is at location max cos * num of RSS
34062306a36Sopenharmony_ci * txdata for FWD (if exist) is one location after FCoE
34162306a36Sopenharmony_ci * txdata for OOO (if exist) is one location after FWD
34262306a36Sopenharmony_ci */
34362306a36Sopenharmony_cienum {
34462306a36Sopenharmony_ci	FCOE_TXQ_IDX_OFFSET,
34562306a36Sopenharmony_ci	FWD_TXQ_IDX_OFFSET,
34662306a36Sopenharmony_ci	OOO_TXQ_IDX_OFFSET,
34762306a36Sopenharmony_ci};
34862306a36Sopenharmony_ci#define MAX_ETH_TXQ_IDX(bp)	(BNX2X_NUM_NON_CNIC_QUEUES(bp) * (bp)->max_cos)
34962306a36Sopenharmony_ci#define FCOE_TXQ_IDX(bp)	(MAX_ETH_TXQ_IDX(bp) + FCOE_TXQ_IDX_OFFSET)
35062306a36Sopenharmony_ci
35162306a36Sopenharmony_ci/* fast path */
35262306a36Sopenharmony_ci/*
35362306a36Sopenharmony_ci * This driver uses new build_skb() API :
35462306a36Sopenharmony_ci * RX ring buffer contains pointer to kmalloc() data only,
35562306a36Sopenharmony_ci * skb are built only after Hardware filled the frame.
35662306a36Sopenharmony_ci */
35762306a36Sopenharmony_cistruct sw_rx_bd {
35862306a36Sopenharmony_ci	u8		*data;
35962306a36Sopenharmony_ci	DEFINE_DMA_UNMAP_ADDR(mapping);
36062306a36Sopenharmony_ci};
36162306a36Sopenharmony_ci
36262306a36Sopenharmony_cistruct sw_tx_bd {
36362306a36Sopenharmony_ci	struct sk_buff	*skb;
36462306a36Sopenharmony_ci	u16		first_bd;
36562306a36Sopenharmony_ci	u8		flags;
36662306a36Sopenharmony_ci/* Set on the first BD descriptor when there is a split BD */
36762306a36Sopenharmony_ci#define BNX2X_TSO_SPLIT_BD		(1<<0)
36862306a36Sopenharmony_ci#define BNX2X_HAS_SECOND_PBD		(1<<1)
36962306a36Sopenharmony_ci};
37062306a36Sopenharmony_ci
37162306a36Sopenharmony_cistruct sw_rx_page {
37262306a36Sopenharmony_ci	struct page	*page;
37362306a36Sopenharmony_ci	DEFINE_DMA_UNMAP_ADDR(mapping);
37462306a36Sopenharmony_ci	unsigned int	offset;
37562306a36Sopenharmony_ci};
37662306a36Sopenharmony_ci
37762306a36Sopenharmony_ciunion db_prod {
37862306a36Sopenharmony_ci	struct doorbell_set_prod data;
37962306a36Sopenharmony_ci	u32		raw;
38062306a36Sopenharmony_ci};
38162306a36Sopenharmony_ci
38262306a36Sopenharmony_ci/* dropless fc FW/HW related params */
38362306a36Sopenharmony_ci#define BRB_SIZE(bp)		(CHIP_IS_E3(bp) ? 1024 : 512)
38462306a36Sopenharmony_ci#define MAX_AGG_QS(bp)		(CHIP_IS_E1(bp) ? \
38562306a36Sopenharmony_ci					ETH_MAX_AGGREGATION_QUEUES_E1 :\
38662306a36Sopenharmony_ci					ETH_MAX_AGGREGATION_QUEUES_E1H_E2)
38762306a36Sopenharmony_ci#define FW_DROP_LEVEL(bp)	(3 + MAX_SPQ_PENDING + MAX_AGG_QS(bp))
38862306a36Sopenharmony_ci#define FW_PREFETCH_CNT		16
38962306a36Sopenharmony_ci#define DROPLESS_FC_HEADROOM	100
39062306a36Sopenharmony_ci
39162306a36Sopenharmony_ci/* MC hsi */
39262306a36Sopenharmony_ci#define BCM_PAGE_SHIFT		12
39362306a36Sopenharmony_ci#define BCM_PAGE_SIZE		(1 << BCM_PAGE_SHIFT)
39462306a36Sopenharmony_ci#define BCM_PAGE_MASK		(~(BCM_PAGE_SIZE - 1))
39562306a36Sopenharmony_ci#define BCM_PAGE_ALIGN(addr)	(((addr) + BCM_PAGE_SIZE - 1) & BCM_PAGE_MASK)
39662306a36Sopenharmony_ci
39762306a36Sopenharmony_ci#define PAGES_PER_SGE_SHIFT	0
39862306a36Sopenharmony_ci#define PAGES_PER_SGE		(1 << PAGES_PER_SGE_SHIFT)
39962306a36Sopenharmony_ci#define SGE_PAGE_SHIFT		12
40062306a36Sopenharmony_ci#define SGE_PAGE_SIZE		(1 << SGE_PAGE_SHIFT)
40162306a36Sopenharmony_ci#define SGE_PAGE_MASK		(~(SGE_PAGE_SIZE - 1))
40262306a36Sopenharmony_ci#define SGE_PAGE_ALIGN(addr)	(((addr) + SGE_PAGE_SIZE - 1) & SGE_PAGE_MASK)
40362306a36Sopenharmony_ci#define SGE_PAGES		(SGE_PAGE_SIZE * PAGES_PER_SGE)
40462306a36Sopenharmony_ci#define TPA_AGG_SIZE		min_t(u32, (min_t(u32, 8, MAX_SKB_FRAGS) * \
40562306a36Sopenharmony_ci					    SGE_PAGES), 0xffff)
40662306a36Sopenharmony_ci
40762306a36Sopenharmony_ci/* SGE ring related macros */
40862306a36Sopenharmony_ci#define NUM_RX_SGE_PAGES	2
40962306a36Sopenharmony_ci#define RX_SGE_CNT		(BCM_PAGE_SIZE / sizeof(struct eth_rx_sge))
41062306a36Sopenharmony_ci#define NEXT_PAGE_SGE_DESC_CNT	2
41162306a36Sopenharmony_ci#define MAX_RX_SGE_CNT		(RX_SGE_CNT - NEXT_PAGE_SGE_DESC_CNT)
41262306a36Sopenharmony_ci/* RX_SGE_CNT is promised to be a power of 2 */
41362306a36Sopenharmony_ci#define RX_SGE_MASK		(RX_SGE_CNT - 1)
41462306a36Sopenharmony_ci#define NUM_RX_SGE		(RX_SGE_CNT * NUM_RX_SGE_PAGES)
41562306a36Sopenharmony_ci#define MAX_RX_SGE		(NUM_RX_SGE - 1)
41662306a36Sopenharmony_ci#define NEXT_SGE_IDX(x)		((((x) & RX_SGE_MASK) == \
41762306a36Sopenharmony_ci				  (MAX_RX_SGE_CNT - 1)) ? \
41862306a36Sopenharmony_ci					(x) + 1 + NEXT_PAGE_SGE_DESC_CNT : \
41962306a36Sopenharmony_ci					(x) + 1)
42062306a36Sopenharmony_ci#define RX_SGE(x)		((x) & MAX_RX_SGE)
42162306a36Sopenharmony_ci
42262306a36Sopenharmony_ci/*
42362306a36Sopenharmony_ci * Number of required  SGEs is the sum of two:
42462306a36Sopenharmony_ci * 1. Number of possible opened aggregations (next packet for
42562306a36Sopenharmony_ci *    these aggregations will probably consume SGE immediately)
42662306a36Sopenharmony_ci * 2. Rest of BRB blocks divided by 2 (block will consume new SGE only
42762306a36Sopenharmony_ci *    after placement on BD for new TPA aggregation)
42862306a36Sopenharmony_ci *
42962306a36Sopenharmony_ci * Takes into account NEXT_PAGE_SGE_DESC_CNT "next" elements on each page
43062306a36Sopenharmony_ci */
43162306a36Sopenharmony_ci#define NUM_SGE_REQ		(MAX_AGG_QS(bp) + \
43262306a36Sopenharmony_ci					(BRB_SIZE(bp) - MAX_AGG_QS(bp)) / 2)
43362306a36Sopenharmony_ci#define NUM_SGE_PG_REQ		((NUM_SGE_REQ + MAX_RX_SGE_CNT - 1) / \
43462306a36Sopenharmony_ci						MAX_RX_SGE_CNT)
43562306a36Sopenharmony_ci#define SGE_TH_LO(bp)		(NUM_SGE_REQ + \
43662306a36Sopenharmony_ci				 NUM_SGE_PG_REQ * NEXT_PAGE_SGE_DESC_CNT)
43762306a36Sopenharmony_ci#define SGE_TH_HI(bp)		(SGE_TH_LO(bp) + DROPLESS_FC_HEADROOM)
43862306a36Sopenharmony_ci
43962306a36Sopenharmony_ci/* Manipulate a bit vector defined as an array of u64 */
44062306a36Sopenharmony_ci
44162306a36Sopenharmony_ci/* Number of bits in one sge_mask array element */
44262306a36Sopenharmony_ci#define BIT_VEC64_ELEM_SZ		64
44362306a36Sopenharmony_ci#define BIT_VEC64_ELEM_SHIFT		6
44462306a36Sopenharmony_ci#define BIT_VEC64_ELEM_MASK		((u64)BIT_VEC64_ELEM_SZ - 1)
44562306a36Sopenharmony_ci
44662306a36Sopenharmony_ci#define __BIT_VEC64_SET_BIT(el, bit) \
44762306a36Sopenharmony_ci	do { \
44862306a36Sopenharmony_ci		el = ((el) | ((u64)0x1 << (bit))); \
44962306a36Sopenharmony_ci	} while (0)
45062306a36Sopenharmony_ci
45162306a36Sopenharmony_ci#define __BIT_VEC64_CLEAR_BIT(el, bit) \
45262306a36Sopenharmony_ci	do { \
45362306a36Sopenharmony_ci		el = ((el) & (~((u64)0x1 << (bit)))); \
45462306a36Sopenharmony_ci	} while (0)
45562306a36Sopenharmony_ci
45662306a36Sopenharmony_ci#define BIT_VEC64_SET_BIT(vec64, idx) \
45762306a36Sopenharmony_ci	__BIT_VEC64_SET_BIT((vec64)[(idx) >> BIT_VEC64_ELEM_SHIFT], \
45862306a36Sopenharmony_ci			   (idx) & BIT_VEC64_ELEM_MASK)
45962306a36Sopenharmony_ci
46062306a36Sopenharmony_ci#define BIT_VEC64_CLEAR_BIT(vec64, idx) \
46162306a36Sopenharmony_ci	__BIT_VEC64_CLEAR_BIT((vec64)[(idx) >> BIT_VEC64_ELEM_SHIFT], \
46262306a36Sopenharmony_ci			     (idx) & BIT_VEC64_ELEM_MASK)
46362306a36Sopenharmony_ci
46462306a36Sopenharmony_ci#define BIT_VEC64_TEST_BIT(vec64, idx) \
46562306a36Sopenharmony_ci	(((vec64)[(idx) >> BIT_VEC64_ELEM_SHIFT] >> \
46662306a36Sopenharmony_ci	((idx) & BIT_VEC64_ELEM_MASK)) & 0x1)
46762306a36Sopenharmony_ci
46862306a36Sopenharmony_ci/* Creates a bitmask of all ones in less significant bits.
46962306a36Sopenharmony_ci   idx - index of the most significant bit in the created mask */
47062306a36Sopenharmony_ci#define BIT_VEC64_ONES_MASK(idx) \
47162306a36Sopenharmony_ci		(((u64)0x1 << (((idx) & BIT_VEC64_ELEM_MASK) + 1)) - 1)
47262306a36Sopenharmony_ci#define BIT_VEC64_ELEM_ONE_MASK	((u64)(~0))
47362306a36Sopenharmony_ci
47462306a36Sopenharmony_ci/*******************************************************/
47562306a36Sopenharmony_ci
47662306a36Sopenharmony_ci/* Number of u64 elements in SGE mask array */
47762306a36Sopenharmony_ci#define RX_SGE_MASK_LEN			(NUM_RX_SGE / BIT_VEC64_ELEM_SZ)
47862306a36Sopenharmony_ci#define RX_SGE_MASK_LEN_MASK		(RX_SGE_MASK_LEN - 1)
47962306a36Sopenharmony_ci#define NEXT_SGE_MASK_ELEM(el)		(((el) + 1) & RX_SGE_MASK_LEN_MASK)
48062306a36Sopenharmony_ci
48162306a36Sopenharmony_ciunion host_hc_status_block {
48262306a36Sopenharmony_ci	/* pointer to fp status block e1x */
48362306a36Sopenharmony_ci	struct host_hc_status_block_e1x *e1x_sb;
48462306a36Sopenharmony_ci	/* pointer to fp status block e2 */
48562306a36Sopenharmony_ci	struct host_hc_status_block_e2  *e2_sb;
48662306a36Sopenharmony_ci};
48762306a36Sopenharmony_ci
48862306a36Sopenharmony_cistruct bnx2x_agg_info {
48962306a36Sopenharmony_ci	/*
49062306a36Sopenharmony_ci	 * First aggregation buffer is a data buffer, the following - are pages.
49162306a36Sopenharmony_ci	 * We will preallocate the data buffer for each aggregation when
49262306a36Sopenharmony_ci	 * we open the interface and will replace the BD at the consumer
49362306a36Sopenharmony_ci	 * with this one when we receive the TPA_START CQE in order to
49462306a36Sopenharmony_ci	 * keep the Rx BD ring consistent.
49562306a36Sopenharmony_ci	 */
49662306a36Sopenharmony_ci	struct sw_rx_bd		first_buf;
49762306a36Sopenharmony_ci	u8			tpa_state;
49862306a36Sopenharmony_ci#define BNX2X_TPA_START			1
49962306a36Sopenharmony_ci#define BNX2X_TPA_STOP			2
50062306a36Sopenharmony_ci#define BNX2X_TPA_ERROR			3
50162306a36Sopenharmony_ci	u8			placement_offset;
50262306a36Sopenharmony_ci	u16			parsing_flags;
50362306a36Sopenharmony_ci	u16			vlan_tag;
50462306a36Sopenharmony_ci	u16			len_on_bd;
50562306a36Sopenharmony_ci	u32			rxhash;
50662306a36Sopenharmony_ci	enum pkt_hash_types	rxhash_type;
50762306a36Sopenharmony_ci	u16			gro_size;
50862306a36Sopenharmony_ci	u16			full_page;
50962306a36Sopenharmony_ci};
51062306a36Sopenharmony_ci
51162306a36Sopenharmony_ci#define Q_STATS_OFFSET32(stat_name) \
51262306a36Sopenharmony_ci			(offsetof(struct bnx2x_eth_q_stats, stat_name) / 4)
51362306a36Sopenharmony_ci
51462306a36Sopenharmony_cistruct bnx2x_fp_txdata {
51562306a36Sopenharmony_ci
51662306a36Sopenharmony_ci	struct sw_tx_bd		*tx_buf_ring;
51762306a36Sopenharmony_ci
51862306a36Sopenharmony_ci	union eth_tx_bd_types	*tx_desc_ring;
51962306a36Sopenharmony_ci	dma_addr_t		tx_desc_mapping;
52062306a36Sopenharmony_ci
52162306a36Sopenharmony_ci	u32			cid;
52262306a36Sopenharmony_ci
52362306a36Sopenharmony_ci	union db_prod		tx_db;
52462306a36Sopenharmony_ci
52562306a36Sopenharmony_ci	u16			tx_pkt_prod;
52662306a36Sopenharmony_ci	u16			tx_pkt_cons;
52762306a36Sopenharmony_ci	u16			tx_bd_prod;
52862306a36Sopenharmony_ci	u16			tx_bd_cons;
52962306a36Sopenharmony_ci
53062306a36Sopenharmony_ci	unsigned long		tx_pkt;
53162306a36Sopenharmony_ci
53262306a36Sopenharmony_ci	__le16			*tx_cons_sb;
53362306a36Sopenharmony_ci
53462306a36Sopenharmony_ci	int			txq_index;
53562306a36Sopenharmony_ci	struct bnx2x_fastpath	*parent_fp;
53662306a36Sopenharmony_ci	int			tx_ring_size;
53762306a36Sopenharmony_ci};
53862306a36Sopenharmony_ci
53962306a36Sopenharmony_cienum bnx2x_tpa_mode_t {
54062306a36Sopenharmony_ci	TPA_MODE_DISABLED,
54162306a36Sopenharmony_ci	TPA_MODE_LRO,
54262306a36Sopenharmony_ci	TPA_MODE_GRO
54362306a36Sopenharmony_ci};
54462306a36Sopenharmony_ci
54562306a36Sopenharmony_cistruct bnx2x_alloc_pool {
54662306a36Sopenharmony_ci	struct page	*page;
54762306a36Sopenharmony_ci	unsigned int	offset;
54862306a36Sopenharmony_ci};
54962306a36Sopenharmony_ci
55062306a36Sopenharmony_cistruct bnx2x_fastpath {
55162306a36Sopenharmony_ci	struct bnx2x		*bp; /* parent */
55262306a36Sopenharmony_ci
55362306a36Sopenharmony_ci	struct napi_struct	napi;
55462306a36Sopenharmony_ci
55562306a36Sopenharmony_ci	union host_hc_status_block	status_blk;
55662306a36Sopenharmony_ci	/* chip independent shortcuts into sb structure */
55762306a36Sopenharmony_ci	__le16			*sb_index_values;
55862306a36Sopenharmony_ci	__le16			*sb_running_index;
55962306a36Sopenharmony_ci	/* chip independent shortcut into rx_prods_offset memory */
56062306a36Sopenharmony_ci	u32			ustorm_rx_prods_offset;
56162306a36Sopenharmony_ci
56262306a36Sopenharmony_ci	u32			rx_buf_size;
56362306a36Sopenharmony_ci	u32			rx_frag_size; /* 0 if kmalloced(), or rx_buf_size + NET_SKB_PAD */
56462306a36Sopenharmony_ci	dma_addr_t		status_blk_mapping;
56562306a36Sopenharmony_ci
56662306a36Sopenharmony_ci	enum bnx2x_tpa_mode_t	mode;
56762306a36Sopenharmony_ci
56862306a36Sopenharmony_ci	u8			max_cos; /* actual number of active tx coses */
56962306a36Sopenharmony_ci	struct bnx2x_fp_txdata	*txdata_ptr[BNX2X_MULTI_TX_COS];
57062306a36Sopenharmony_ci
57162306a36Sopenharmony_ci	struct sw_rx_bd		*rx_buf_ring;	/* BDs mappings ring */
57262306a36Sopenharmony_ci	struct sw_rx_page	*rx_page_ring;	/* SGE pages mappings ring */
57362306a36Sopenharmony_ci
57462306a36Sopenharmony_ci	struct eth_rx_bd	*rx_desc_ring;
57562306a36Sopenharmony_ci	dma_addr_t		rx_desc_mapping;
57662306a36Sopenharmony_ci
57762306a36Sopenharmony_ci	union eth_rx_cqe	*rx_comp_ring;
57862306a36Sopenharmony_ci	dma_addr_t		rx_comp_mapping;
57962306a36Sopenharmony_ci
58062306a36Sopenharmony_ci	/* SGE ring */
58162306a36Sopenharmony_ci	struct eth_rx_sge	*rx_sge_ring;
58262306a36Sopenharmony_ci	dma_addr_t		rx_sge_mapping;
58362306a36Sopenharmony_ci
58462306a36Sopenharmony_ci	u64			sge_mask[RX_SGE_MASK_LEN];
58562306a36Sopenharmony_ci
58662306a36Sopenharmony_ci	u32			cid;
58762306a36Sopenharmony_ci
58862306a36Sopenharmony_ci	__le16			fp_hc_idx;
58962306a36Sopenharmony_ci
59062306a36Sopenharmony_ci	u8			index;		/* number in fp array */
59162306a36Sopenharmony_ci	u8			rx_queue;	/* index for skb_record */
59262306a36Sopenharmony_ci	u8			cl_id;		/* eth client id */
59362306a36Sopenharmony_ci	u8			cl_qzone_id;
59462306a36Sopenharmony_ci	u8			fw_sb_id;	/* status block number in FW */
59562306a36Sopenharmony_ci	u8			igu_sb_id;	/* status block number in HW */
59662306a36Sopenharmony_ci
59762306a36Sopenharmony_ci	u16			rx_bd_prod;
59862306a36Sopenharmony_ci	u16			rx_bd_cons;
59962306a36Sopenharmony_ci	u16			rx_comp_prod;
60062306a36Sopenharmony_ci	u16			rx_comp_cons;
60162306a36Sopenharmony_ci	u16			rx_sge_prod;
60262306a36Sopenharmony_ci	/* The last maximal completed SGE */
60362306a36Sopenharmony_ci	u16			last_max_sge;
60462306a36Sopenharmony_ci	__le16			*rx_cons_sb;
60562306a36Sopenharmony_ci
60662306a36Sopenharmony_ci	/* TPA related */
60762306a36Sopenharmony_ci	struct bnx2x_agg_info	*tpa_info;
60862306a36Sopenharmony_ci#ifdef BNX2X_STOP_ON_ERROR
60962306a36Sopenharmony_ci	u64			tpa_queue_used;
61062306a36Sopenharmony_ci#endif
61162306a36Sopenharmony_ci	/* The size is calculated using the following:
61262306a36Sopenharmony_ci	     sizeof name field from netdev structure +
61362306a36Sopenharmony_ci	     4 ('-Xx-' string) +
61462306a36Sopenharmony_ci	     4 (for the digits and to make it DWORD aligned) */
61562306a36Sopenharmony_ci#define FP_NAME_SIZE		(sizeof(((struct net_device *)0)->name) + 8)
61662306a36Sopenharmony_ci	char			name[FP_NAME_SIZE];
61762306a36Sopenharmony_ci
61862306a36Sopenharmony_ci	struct bnx2x_alloc_pool	page_pool;
61962306a36Sopenharmony_ci};
62062306a36Sopenharmony_ci
62162306a36Sopenharmony_ci#define bnx2x_fp(bp, nr, var)	((bp)->fp[(nr)].var)
62262306a36Sopenharmony_ci#define bnx2x_sp_obj(bp, fp)	((bp)->sp_objs[(fp)->index])
62362306a36Sopenharmony_ci#define bnx2x_fp_stats(bp, fp)	(&((bp)->fp_stats[(fp)->index]))
62462306a36Sopenharmony_ci#define bnx2x_fp_qstats(bp, fp)	(&((bp)->fp_stats[(fp)->index].eth_q_stats))
62562306a36Sopenharmony_ci
62662306a36Sopenharmony_ci/* Use 2500 as a mini-jumbo MTU for FCoE */
62762306a36Sopenharmony_ci#define BNX2X_FCOE_MINI_JUMBO_MTU	2500
62862306a36Sopenharmony_ci
62962306a36Sopenharmony_ci#define	FCOE_IDX_OFFSET		0
63062306a36Sopenharmony_ci
63162306a36Sopenharmony_ci#define FCOE_IDX(bp)		(BNX2X_NUM_NON_CNIC_QUEUES(bp) + \
63262306a36Sopenharmony_ci				 FCOE_IDX_OFFSET)
63362306a36Sopenharmony_ci#define bnx2x_fcoe_fp(bp)	(&bp->fp[FCOE_IDX(bp)])
63462306a36Sopenharmony_ci#define bnx2x_fcoe(bp, var)	(bnx2x_fcoe_fp(bp)->var)
63562306a36Sopenharmony_ci#define bnx2x_fcoe_inner_sp_obj(bp)	(&bp->sp_objs[FCOE_IDX(bp)])
63662306a36Sopenharmony_ci#define bnx2x_fcoe_sp_obj(bp, var)	(bnx2x_fcoe_inner_sp_obj(bp)->var)
63762306a36Sopenharmony_ci#define bnx2x_fcoe_tx(bp, var)	(bnx2x_fcoe_fp(bp)-> \
63862306a36Sopenharmony_ci						txdata_ptr[FIRST_TX_COS_INDEX] \
63962306a36Sopenharmony_ci						->var)
64062306a36Sopenharmony_ci
64162306a36Sopenharmony_ci#define IS_ETH_FP(fp)		((fp)->index < BNX2X_NUM_ETH_QUEUES((fp)->bp))
64262306a36Sopenharmony_ci#define IS_FCOE_FP(fp)		((fp)->index == FCOE_IDX((fp)->bp))
64362306a36Sopenharmony_ci#define IS_FCOE_IDX(idx)	((idx) == FCOE_IDX(bp))
64462306a36Sopenharmony_ci
64562306a36Sopenharmony_ci/* MC hsi */
64662306a36Sopenharmony_ci#define MAX_FETCH_BD		13	/* HW max BDs per packet */
64762306a36Sopenharmony_ci#define RX_COPY_THRESH		92
64862306a36Sopenharmony_ci
64962306a36Sopenharmony_ci#define NUM_TX_RINGS		16
65062306a36Sopenharmony_ci#define TX_DESC_CNT		(BCM_PAGE_SIZE / sizeof(union eth_tx_bd_types))
65162306a36Sopenharmony_ci#define NEXT_PAGE_TX_DESC_CNT	1
65262306a36Sopenharmony_ci#define MAX_TX_DESC_CNT		(TX_DESC_CNT - NEXT_PAGE_TX_DESC_CNT)
65362306a36Sopenharmony_ci#define NUM_TX_BD		(TX_DESC_CNT * NUM_TX_RINGS)
65462306a36Sopenharmony_ci#define MAX_TX_BD		(NUM_TX_BD - 1)
65562306a36Sopenharmony_ci#define MAX_TX_AVAIL		(MAX_TX_DESC_CNT * NUM_TX_RINGS - 2)
65662306a36Sopenharmony_ci#define NEXT_TX_IDX(x)		((((x) & MAX_TX_DESC_CNT) == \
65762306a36Sopenharmony_ci				  (MAX_TX_DESC_CNT - 1)) ? \
65862306a36Sopenharmony_ci					(x) + 1 + NEXT_PAGE_TX_DESC_CNT : \
65962306a36Sopenharmony_ci					(x) + 1)
66062306a36Sopenharmony_ci#define TX_BD(x)		((x) & MAX_TX_BD)
66162306a36Sopenharmony_ci#define TX_BD_POFF(x)		((x) & MAX_TX_DESC_CNT)
66262306a36Sopenharmony_ci
66362306a36Sopenharmony_ci/* number of NEXT_PAGE descriptors may be required during placement */
66462306a36Sopenharmony_ci#define NEXT_CNT_PER_TX_PKT(bds)	\
66562306a36Sopenharmony_ci				(((bds) + MAX_TX_DESC_CNT - 1) / \
66662306a36Sopenharmony_ci				 MAX_TX_DESC_CNT * NEXT_PAGE_TX_DESC_CNT)
66762306a36Sopenharmony_ci/* max BDs per tx packet w/o next_pages:
66862306a36Sopenharmony_ci * START_BD		- describes packed
66962306a36Sopenharmony_ci * START_BD(splitted)	- includes unpaged data segment for GSO
67062306a36Sopenharmony_ci * PARSING_BD		- for TSO and CSUM data
67162306a36Sopenharmony_ci * PARSING_BD2		- for encapsulation data
67262306a36Sopenharmony_ci * Frag BDs		- describes pages for frags
67362306a36Sopenharmony_ci */
67462306a36Sopenharmony_ci#define BDS_PER_TX_PKT		4
67562306a36Sopenharmony_ci#define MAX_BDS_PER_TX_PKT	(MAX_SKB_FRAGS + BDS_PER_TX_PKT)
67662306a36Sopenharmony_ci/* max BDs per tx packet including next pages */
67762306a36Sopenharmony_ci#define MAX_DESC_PER_TX_PKT	(MAX_BDS_PER_TX_PKT + \
67862306a36Sopenharmony_ci				 NEXT_CNT_PER_TX_PKT(MAX_BDS_PER_TX_PKT))
67962306a36Sopenharmony_ci
68062306a36Sopenharmony_ci/* The RX BD ring is special, each bd is 8 bytes but the last one is 16 */
68162306a36Sopenharmony_ci#define NUM_RX_RINGS		8
68262306a36Sopenharmony_ci#define RX_DESC_CNT		(BCM_PAGE_SIZE / sizeof(struct eth_rx_bd))
68362306a36Sopenharmony_ci#define NEXT_PAGE_RX_DESC_CNT	2
68462306a36Sopenharmony_ci#define MAX_RX_DESC_CNT		(RX_DESC_CNT - NEXT_PAGE_RX_DESC_CNT)
68562306a36Sopenharmony_ci#define RX_DESC_MASK		(RX_DESC_CNT - 1)
68662306a36Sopenharmony_ci#define NUM_RX_BD		(RX_DESC_CNT * NUM_RX_RINGS)
68762306a36Sopenharmony_ci#define MAX_RX_BD		(NUM_RX_BD - 1)
68862306a36Sopenharmony_ci#define MAX_RX_AVAIL		(MAX_RX_DESC_CNT * NUM_RX_RINGS - 2)
68962306a36Sopenharmony_ci
69062306a36Sopenharmony_ci/* dropless fc calculations for BDs
69162306a36Sopenharmony_ci *
69262306a36Sopenharmony_ci * Number of BDs should as number of buffers in BRB:
69362306a36Sopenharmony_ci * Low threshold takes into account NEXT_PAGE_RX_DESC_CNT
69462306a36Sopenharmony_ci * "next" elements on each page
69562306a36Sopenharmony_ci */
69662306a36Sopenharmony_ci#define NUM_BD_REQ		BRB_SIZE(bp)
69762306a36Sopenharmony_ci#define NUM_BD_PG_REQ		((NUM_BD_REQ + MAX_RX_DESC_CNT - 1) / \
69862306a36Sopenharmony_ci					      MAX_RX_DESC_CNT)
69962306a36Sopenharmony_ci#define BD_TH_LO(bp)		(NUM_BD_REQ + \
70062306a36Sopenharmony_ci				 NUM_BD_PG_REQ * NEXT_PAGE_RX_DESC_CNT + \
70162306a36Sopenharmony_ci				 FW_DROP_LEVEL(bp))
70262306a36Sopenharmony_ci#define BD_TH_HI(bp)		(BD_TH_LO(bp) + DROPLESS_FC_HEADROOM)
70362306a36Sopenharmony_ci
70462306a36Sopenharmony_ci#define MIN_RX_AVAIL		((bp)->dropless_fc ? BD_TH_HI(bp) + 128 : 128)
70562306a36Sopenharmony_ci
70662306a36Sopenharmony_ci#define MIN_RX_SIZE_TPA_HW	(CHIP_IS_E1(bp) ? \
70762306a36Sopenharmony_ci					ETH_MIN_RX_CQES_WITH_TPA_E1 : \
70862306a36Sopenharmony_ci					ETH_MIN_RX_CQES_WITH_TPA_E1H_E2)
70962306a36Sopenharmony_ci#define MIN_RX_SIZE_NONTPA_HW   ETH_MIN_RX_CQES_WITHOUT_TPA
71062306a36Sopenharmony_ci#define MIN_RX_SIZE_TPA		(max_t(u32, MIN_RX_SIZE_TPA_HW, MIN_RX_AVAIL))
71162306a36Sopenharmony_ci#define MIN_RX_SIZE_NONTPA	(max_t(u32, MIN_RX_SIZE_NONTPA_HW,\
71262306a36Sopenharmony_ci								MIN_RX_AVAIL))
71362306a36Sopenharmony_ci
71462306a36Sopenharmony_ci#define NEXT_RX_IDX(x)		((((x) & RX_DESC_MASK) == \
71562306a36Sopenharmony_ci				  (MAX_RX_DESC_CNT - 1)) ? \
71662306a36Sopenharmony_ci					(x) + 1 + NEXT_PAGE_RX_DESC_CNT : \
71762306a36Sopenharmony_ci					(x) + 1)
71862306a36Sopenharmony_ci#define RX_BD(x)		((x) & MAX_RX_BD)
71962306a36Sopenharmony_ci
72062306a36Sopenharmony_ci/*
72162306a36Sopenharmony_ci * As long as CQE is X times bigger than BD entry we have to allocate X times
72262306a36Sopenharmony_ci * more pages for CQ ring in order to keep it balanced with BD ring
72362306a36Sopenharmony_ci */
72462306a36Sopenharmony_ci#define CQE_BD_REL	(sizeof(union eth_rx_cqe) / sizeof(struct eth_rx_bd))
72562306a36Sopenharmony_ci#define NUM_RCQ_RINGS		(NUM_RX_RINGS * CQE_BD_REL)
72662306a36Sopenharmony_ci#define RCQ_DESC_CNT		(BCM_PAGE_SIZE / sizeof(union eth_rx_cqe))
72762306a36Sopenharmony_ci#define NEXT_PAGE_RCQ_DESC_CNT	1
72862306a36Sopenharmony_ci#define MAX_RCQ_DESC_CNT	(RCQ_DESC_CNT - NEXT_PAGE_RCQ_DESC_CNT)
72962306a36Sopenharmony_ci#define NUM_RCQ_BD		(RCQ_DESC_CNT * NUM_RCQ_RINGS)
73062306a36Sopenharmony_ci#define MAX_RCQ_BD		(NUM_RCQ_BD - 1)
73162306a36Sopenharmony_ci#define MAX_RCQ_AVAIL		(MAX_RCQ_DESC_CNT * NUM_RCQ_RINGS - 2)
73262306a36Sopenharmony_ci#define NEXT_RCQ_IDX(x)		((((x) & MAX_RCQ_DESC_CNT) == \
73362306a36Sopenharmony_ci				  (MAX_RCQ_DESC_CNT - 1)) ? \
73462306a36Sopenharmony_ci					(x) + 1 + NEXT_PAGE_RCQ_DESC_CNT : \
73562306a36Sopenharmony_ci					(x) + 1)
73662306a36Sopenharmony_ci#define RCQ_BD(x)		((x) & MAX_RCQ_BD)
73762306a36Sopenharmony_ci
73862306a36Sopenharmony_ci/* dropless fc calculations for RCQs
73962306a36Sopenharmony_ci *
74062306a36Sopenharmony_ci * Number of RCQs should be as number of buffers in BRB:
74162306a36Sopenharmony_ci * Low threshold takes into account NEXT_PAGE_RCQ_DESC_CNT
74262306a36Sopenharmony_ci * "next" elements on each page
74362306a36Sopenharmony_ci */
74462306a36Sopenharmony_ci#define NUM_RCQ_REQ		BRB_SIZE(bp)
74562306a36Sopenharmony_ci#define NUM_RCQ_PG_REQ		((NUM_BD_REQ + MAX_RCQ_DESC_CNT - 1) / \
74662306a36Sopenharmony_ci					      MAX_RCQ_DESC_CNT)
74762306a36Sopenharmony_ci#define RCQ_TH_LO(bp)		(NUM_RCQ_REQ + \
74862306a36Sopenharmony_ci				 NUM_RCQ_PG_REQ * NEXT_PAGE_RCQ_DESC_CNT + \
74962306a36Sopenharmony_ci				 FW_DROP_LEVEL(bp))
75062306a36Sopenharmony_ci#define RCQ_TH_HI(bp)		(RCQ_TH_LO(bp) + DROPLESS_FC_HEADROOM)
75162306a36Sopenharmony_ci
75262306a36Sopenharmony_ci/* This is needed for determining of last_max */
75362306a36Sopenharmony_ci#define SUB_S16(a, b)		(s16)((s16)(a) - (s16)(b))
75462306a36Sopenharmony_ci#define SUB_S32(a, b)		(s32)((s32)(a) - (s32)(b))
75562306a36Sopenharmony_ci
75662306a36Sopenharmony_ci#define BNX2X_SWCID_SHIFT	17
75762306a36Sopenharmony_ci#define BNX2X_SWCID_MASK	((0x1 << BNX2X_SWCID_SHIFT) - 1)
75862306a36Sopenharmony_ci
75962306a36Sopenharmony_ci/* used on a CID received from the HW */
76062306a36Sopenharmony_ci#define SW_CID(x)			(le32_to_cpu(x) & BNX2X_SWCID_MASK)
76162306a36Sopenharmony_ci#define CQE_CMD(x)			(le32_to_cpu(x) >> \
76262306a36Sopenharmony_ci					COMMON_RAMROD_ETH_RX_CQE_CMD_ID_SHIFT)
76362306a36Sopenharmony_ci
76462306a36Sopenharmony_ci#define BD_UNMAP_ADDR(bd)		HILO_U64(le32_to_cpu((bd)->addr_hi), \
76562306a36Sopenharmony_ci						 le32_to_cpu((bd)->addr_lo))
76662306a36Sopenharmony_ci#define BD_UNMAP_LEN(bd)		(le16_to_cpu((bd)->nbytes))
76762306a36Sopenharmony_ci
76862306a36Sopenharmony_ci#define BNX2X_DB_MIN_SHIFT		3	/* 8 bytes */
76962306a36Sopenharmony_ci#define BNX2X_DB_SHIFT			3	/* 8 bytes*/
77062306a36Sopenharmony_ci#if (BNX2X_DB_SHIFT < BNX2X_DB_MIN_SHIFT)
77162306a36Sopenharmony_ci#error "Min DB doorbell stride is 8"
77262306a36Sopenharmony_ci#endif
77362306a36Sopenharmony_ci#define DOORBELL_RELAXED(bp, cid, val) \
77462306a36Sopenharmony_ci	writel_relaxed((u32)(val), (bp)->doorbells + ((bp)->db_size * (cid)))
77562306a36Sopenharmony_ci
77662306a36Sopenharmony_ci/* TX CSUM helpers */
77762306a36Sopenharmony_ci#define SKB_CS_OFF(skb)		(offsetof(struct tcphdr, check) - \
77862306a36Sopenharmony_ci				 skb->csum_offset)
77962306a36Sopenharmony_ci#define SKB_CS(skb)		(*(u16 *)(skb_transport_header(skb) + \
78062306a36Sopenharmony_ci					  skb->csum_offset))
78162306a36Sopenharmony_ci
78262306a36Sopenharmony_ci#define pbd_tcp_flags(tcp_hdr)	(ntohl(tcp_flag_word(tcp_hdr))>>16 & 0xff)
78362306a36Sopenharmony_ci
78462306a36Sopenharmony_ci#define XMIT_PLAIN		0
78562306a36Sopenharmony_ci#define XMIT_CSUM_V4		(1 << 0)
78662306a36Sopenharmony_ci#define XMIT_CSUM_V6		(1 << 1)
78762306a36Sopenharmony_ci#define XMIT_CSUM_TCP		(1 << 2)
78862306a36Sopenharmony_ci#define XMIT_GSO_V4		(1 << 3)
78962306a36Sopenharmony_ci#define XMIT_GSO_V6		(1 << 4)
79062306a36Sopenharmony_ci#define XMIT_CSUM_ENC_V4	(1 << 5)
79162306a36Sopenharmony_ci#define XMIT_CSUM_ENC_V6	(1 << 6)
79262306a36Sopenharmony_ci#define XMIT_GSO_ENC_V4		(1 << 7)
79362306a36Sopenharmony_ci#define XMIT_GSO_ENC_V6		(1 << 8)
79462306a36Sopenharmony_ci
79562306a36Sopenharmony_ci#define XMIT_CSUM_ENC		(XMIT_CSUM_ENC_V4 | XMIT_CSUM_ENC_V6)
79662306a36Sopenharmony_ci#define XMIT_GSO_ENC		(XMIT_GSO_ENC_V4 | XMIT_GSO_ENC_V6)
79762306a36Sopenharmony_ci
79862306a36Sopenharmony_ci#define XMIT_CSUM		(XMIT_CSUM_V4 | XMIT_CSUM_V6 | XMIT_CSUM_ENC)
79962306a36Sopenharmony_ci#define XMIT_GSO		(XMIT_GSO_V4 | XMIT_GSO_V6 | XMIT_GSO_ENC)
80062306a36Sopenharmony_ci
80162306a36Sopenharmony_ci/* stuff added to make the code fit 80Col */
80262306a36Sopenharmony_ci#define CQE_TYPE(cqe_fp_flags)	 ((cqe_fp_flags) & ETH_FAST_PATH_RX_CQE_TYPE)
80362306a36Sopenharmony_ci#define CQE_TYPE_START(cqe_type) ((cqe_type) == RX_ETH_CQE_TYPE_ETH_START_AGG)
80462306a36Sopenharmony_ci#define CQE_TYPE_STOP(cqe_type)  ((cqe_type) == RX_ETH_CQE_TYPE_ETH_STOP_AGG)
80562306a36Sopenharmony_ci#define CQE_TYPE_SLOW(cqe_type)  ((cqe_type) == RX_ETH_CQE_TYPE_ETH_RAMROD)
80662306a36Sopenharmony_ci#define CQE_TYPE_FAST(cqe_type)  ((cqe_type) == RX_ETH_CQE_TYPE_ETH_FASTPATH)
80762306a36Sopenharmony_ci
80862306a36Sopenharmony_ci#define ETH_RX_ERROR_FALGS		ETH_FAST_PATH_RX_CQE_PHY_DECODE_ERR_FLG
80962306a36Sopenharmony_ci
81062306a36Sopenharmony_ci#define BNX2X_PRS_FLAG_OVERETH_IPV4(flags) \
81162306a36Sopenharmony_ci				(((le16_to_cpu(flags) & \
81262306a36Sopenharmony_ci				   PARSING_FLAGS_OVER_ETHERNET_PROTOCOL) >> \
81362306a36Sopenharmony_ci				  PARSING_FLAGS_OVER_ETHERNET_PROTOCOL_SHIFT) \
81462306a36Sopenharmony_ci				 == PRS_FLAG_OVERETH_IPV4)
81562306a36Sopenharmony_ci#define BNX2X_RX_SUM_FIX(cqe) \
81662306a36Sopenharmony_ci	BNX2X_PRS_FLAG_OVERETH_IPV4(cqe->fast_path_cqe.pars_flags.flags)
81762306a36Sopenharmony_ci
81862306a36Sopenharmony_ci#define FP_USB_FUNC_OFF	\
81962306a36Sopenharmony_ci			offsetof(struct cstorm_status_block_u, func)
82062306a36Sopenharmony_ci#define FP_CSB_FUNC_OFF	\
82162306a36Sopenharmony_ci			offsetof(struct cstorm_status_block_c, func)
82262306a36Sopenharmony_ci
82362306a36Sopenharmony_ci#define HC_INDEX_ETH_RX_CQ_CONS		1
82462306a36Sopenharmony_ci
82562306a36Sopenharmony_ci#define HC_INDEX_OOO_TX_CQ_CONS		4
82662306a36Sopenharmony_ci
82762306a36Sopenharmony_ci#define HC_INDEX_ETH_TX_CQ_CONS_COS0	5
82862306a36Sopenharmony_ci
82962306a36Sopenharmony_ci#define HC_INDEX_ETH_TX_CQ_CONS_COS1	6
83062306a36Sopenharmony_ci
83162306a36Sopenharmony_ci#define HC_INDEX_ETH_TX_CQ_CONS_COS2	7
83262306a36Sopenharmony_ci
83362306a36Sopenharmony_ci#define HC_INDEX_ETH_FIRST_TX_CQ_CONS	HC_INDEX_ETH_TX_CQ_CONS_COS0
83462306a36Sopenharmony_ci
83562306a36Sopenharmony_ci#define BNX2X_RX_SB_INDEX \
83662306a36Sopenharmony_ci	(&fp->sb_index_values[HC_INDEX_ETH_RX_CQ_CONS])
83762306a36Sopenharmony_ci
83862306a36Sopenharmony_ci#define BNX2X_TX_SB_INDEX_BASE BNX2X_TX_SB_INDEX_COS0
83962306a36Sopenharmony_ci
84062306a36Sopenharmony_ci#define BNX2X_TX_SB_INDEX_COS0 \
84162306a36Sopenharmony_ci	(&fp->sb_index_values[HC_INDEX_ETH_TX_CQ_CONS_COS0])
84262306a36Sopenharmony_ci
84362306a36Sopenharmony_ci/* end of fast path */
84462306a36Sopenharmony_ci
84562306a36Sopenharmony_ci/* common */
84662306a36Sopenharmony_ci
84762306a36Sopenharmony_cistruct bnx2x_common {
84862306a36Sopenharmony_ci
84962306a36Sopenharmony_ci	u32			chip_id;
85062306a36Sopenharmony_ci/* chip num:16-31, rev:12-15, metal:4-11, bond_id:0-3 */
85162306a36Sopenharmony_ci#define CHIP_ID(bp)			(bp->common.chip_id & 0xfffffff0)
85262306a36Sopenharmony_ci
85362306a36Sopenharmony_ci#define CHIP_NUM(bp)			(bp->common.chip_id >> 16)
85462306a36Sopenharmony_ci#define CHIP_NUM_57710			0x164e
85562306a36Sopenharmony_ci#define CHIP_NUM_57711			0x164f
85662306a36Sopenharmony_ci#define CHIP_NUM_57711E			0x1650
85762306a36Sopenharmony_ci#define CHIP_NUM_57712			0x1662
85862306a36Sopenharmony_ci#define CHIP_NUM_57712_MF		0x1663
85962306a36Sopenharmony_ci#define CHIP_NUM_57712_VF		0x166f
86062306a36Sopenharmony_ci#define CHIP_NUM_57713			0x1651
86162306a36Sopenharmony_ci#define CHIP_NUM_57713E			0x1652
86262306a36Sopenharmony_ci#define CHIP_NUM_57800			0x168a
86362306a36Sopenharmony_ci#define CHIP_NUM_57800_MF		0x16a5
86462306a36Sopenharmony_ci#define CHIP_NUM_57800_VF		0x16a9
86562306a36Sopenharmony_ci#define CHIP_NUM_57810			0x168e
86662306a36Sopenharmony_ci#define CHIP_NUM_57810_MF		0x16ae
86762306a36Sopenharmony_ci#define CHIP_NUM_57810_VF		0x16af
86862306a36Sopenharmony_ci#define CHIP_NUM_57811			0x163d
86962306a36Sopenharmony_ci#define CHIP_NUM_57811_MF		0x163e
87062306a36Sopenharmony_ci#define CHIP_NUM_57811_VF		0x163f
87162306a36Sopenharmony_ci#define CHIP_NUM_57840_OBSOLETE		0x168d
87262306a36Sopenharmony_ci#define CHIP_NUM_57840_MF_OBSOLETE	0x16ab
87362306a36Sopenharmony_ci#define CHIP_NUM_57840_4_10		0x16a1
87462306a36Sopenharmony_ci#define CHIP_NUM_57840_2_20		0x16a2
87562306a36Sopenharmony_ci#define CHIP_NUM_57840_MF		0x16a4
87662306a36Sopenharmony_ci#define CHIP_NUM_57840_VF		0x16ad
87762306a36Sopenharmony_ci#define CHIP_IS_E1(bp)			(CHIP_NUM(bp) == CHIP_NUM_57710)
87862306a36Sopenharmony_ci#define CHIP_IS_57711(bp)		(CHIP_NUM(bp) == CHIP_NUM_57711)
87962306a36Sopenharmony_ci#define CHIP_IS_57711E(bp)		(CHIP_NUM(bp) == CHIP_NUM_57711E)
88062306a36Sopenharmony_ci#define CHIP_IS_57712(bp)		(CHIP_NUM(bp) == CHIP_NUM_57712)
88162306a36Sopenharmony_ci#define CHIP_IS_57712_VF(bp)		(CHIP_NUM(bp) == CHIP_NUM_57712_VF)
88262306a36Sopenharmony_ci#define CHIP_IS_57712_MF(bp)		(CHIP_NUM(bp) == CHIP_NUM_57712_MF)
88362306a36Sopenharmony_ci#define CHIP_IS_57800(bp)		(CHIP_NUM(bp) == CHIP_NUM_57800)
88462306a36Sopenharmony_ci#define CHIP_IS_57800_MF(bp)		(CHIP_NUM(bp) == CHIP_NUM_57800_MF)
88562306a36Sopenharmony_ci#define CHIP_IS_57800_VF(bp)		(CHIP_NUM(bp) == CHIP_NUM_57800_VF)
88662306a36Sopenharmony_ci#define CHIP_IS_57810(bp)		(CHIP_NUM(bp) == CHIP_NUM_57810)
88762306a36Sopenharmony_ci#define CHIP_IS_57810_MF(bp)		(CHIP_NUM(bp) == CHIP_NUM_57810_MF)
88862306a36Sopenharmony_ci#define CHIP_IS_57810_VF(bp)		(CHIP_NUM(bp) == CHIP_NUM_57810_VF)
88962306a36Sopenharmony_ci#define CHIP_IS_57811(bp)		(CHIP_NUM(bp) == CHIP_NUM_57811)
89062306a36Sopenharmony_ci#define CHIP_IS_57811_MF(bp)		(CHIP_NUM(bp) == CHIP_NUM_57811_MF)
89162306a36Sopenharmony_ci#define CHIP_IS_57811_VF(bp)		(CHIP_NUM(bp) == CHIP_NUM_57811_VF)
89262306a36Sopenharmony_ci#define CHIP_IS_57840(bp)		\
89362306a36Sopenharmony_ci		((CHIP_NUM(bp) == CHIP_NUM_57840_4_10) || \
89462306a36Sopenharmony_ci		 (CHIP_NUM(bp) == CHIP_NUM_57840_2_20) || \
89562306a36Sopenharmony_ci		 (CHIP_NUM(bp) == CHIP_NUM_57840_OBSOLETE))
89662306a36Sopenharmony_ci#define CHIP_IS_57840_MF(bp)	((CHIP_NUM(bp) == CHIP_NUM_57840_MF) || \
89762306a36Sopenharmony_ci				 (CHIP_NUM(bp) == CHIP_NUM_57840_MF_OBSOLETE))
89862306a36Sopenharmony_ci#define CHIP_IS_57840_VF(bp)		(CHIP_NUM(bp) == CHIP_NUM_57840_VF)
89962306a36Sopenharmony_ci#define CHIP_IS_E1H(bp)			(CHIP_IS_57711(bp) || \
90062306a36Sopenharmony_ci					 CHIP_IS_57711E(bp))
90162306a36Sopenharmony_ci#define CHIP_IS_57811xx(bp)		(CHIP_IS_57811(bp) || \
90262306a36Sopenharmony_ci					 CHIP_IS_57811_MF(bp) || \
90362306a36Sopenharmony_ci					 CHIP_IS_57811_VF(bp))
90462306a36Sopenharmony_ci#define CHIP_IS_E2(bp)			(CHIP_IS_57712(bp) || \
90562306a36Sopenharmony_ci					 CHIP_IS_57712_MF(bp) || \
90662306a36Sopenharmony_ci					 CHIP_IS_57712_VF(bp))
90762306a36Sopenharmony_ci#define CHIP_IS_E3(bp)			(CHIP_IS_57800(bp) || \
90862306a36Sopenharmony_ci					 CHIP_IS_57800_MF(bp) || \
90962306a36Sopenharmony_ci					 CHIP_IS_57800_VF(bp) || \
91062306a36Sopenharmony_ci					 CHIP_IS_57810(bp) || \
91162306a36Sopenharmony_ci					 CHIP_IS_57810_MF(bp) || \
91262306a36Sopenharmony_ci					 CHIP_IS_57810_VF(bp) || \
91362306a36Sopenharmony_ci					 CHIP_IS_57811xx(bp) || \
91462306a36Sopenharmony_ci					 CHIP_IS_57840(bp) || \
91562306a36Sopenharmony_ci					 CHIP_IS_57840_MF(bp) || \
91662306a36Sopenharmony_ci					 CHIP_IS_57840_VF(bp))
91762306a36Sopenharmony_ci#define CHIP_IS_E1x(bp)			(CHIP_IS_E1((bp)) || CHIP_IS_E1H((bp)))
91862306a36Sopenharmony_ci#define USES_WARPCORE(bp)		(CHIP_IS_E3(bp))
91962306a36Sopenharmony_ci#define IS_E1H_OFFSET			(!CHIP_IS_E1(bp))
92062306a36Sopenharmony_ci
92162306a36Sopenharmony_ci#define CHIP_REV_SHIFT			12
92262306a36Sopenharmony_ci#define CHIP_REV_MASK			(0xF << CHIP_REV_SHIFT)
92362306a36Sopenharmony_ci#define CHIP_REV_VAL(bp)		(bp->common.chip_id & CHIP_REV_MASK)
92462306a36Sopenharmony_ci#define CHIP_REV_Ax			(0x0 << CHIP_REV_SHIFT)
92562306a36Sopenharmony_ci#define CHIP_REV_Bx			(0x1 << CHIP_REV_SHIFT)
92662306a36Sopenharmony_ci/* assume maximum 5 revisions */
92762306a36Sopenharmony_ci#define CHIP_REV_IS_SLOW(bp)		(CHIP_REV_VAL(bp) > 0x00005000)
92862306a36Sopenharmony_ci/* Emul versions are A=>0xe, B=>0xc, C=>0xa, D=>8, E=>6 */
92962306a36Sopenharmony_ci#define CHIP_REV_IS_EMUL(bp)		((CHIP_REV_IS_SLOW(bp)) && \
93062306a36Sopenharmony_ci					 !(CHIP_REV_VAL(bp) & 0x00001000))
93162306a36Sopenharmony_ci/* FPGA versions are A=>0xf, B=>0xd, C=>0xb, D=>9, E=>7 */
93262306a36Sopenharmony_ci#define CHIP_REV_IS_FPGA(bp)		((CHIP_REV_IS_SLOW(bp)) && \
93362306a36Sopenharmony_ci					 (CHIP_REV_VAL(bp) & 0x00001000))
93462306a36Sopenharmony_ci
93562306a36Sopenharmony_ci#define CHIP_TIME(bp)			((CHIP_REV_IS_EMUL(bp)) ? 2000 : \
93662306a36Sopenharmony_ci					((CHIP_REV_IS_FPGA(bp)) ? 200 : 1))
93762306a36Sopenharmony_ci
93862306a36Sopenharmony_ci#define CHIP_METAL(bp)			(bp->common.chip_id & 0x00000ff0)
93962306a36Sopenharmony_ci#define CHIP_BOND_ID(bp)		(bp->common.chip_id & 0x0000000f)
94062306a36Sopenharmony_ci#define CHIP_REV_SIM(bp)		(((CHIP_REV_MASK - CHIP_REV_VAL(bp)) >>\
94162306a36Sopenharmony_ci					   (CHIP_REV_SHIFT + 1)) \
94262306a36Sopenharmony_ci						<< CHIP_REV_SHIFT)
94362306a36Sopenharmony_ci#define CHIP_REV(bp)			(CHIP_REV_IS_SLOW(bp) ? \
94462306a36Sopenharmony_ci						CHIP_REV_SIM(bp) :\
94562306a36Sopenharmony_ci						CHIP_REV_VAL(bp))
94662306a36Sopenharmony_ci#define CHIP_IS_E3B0(bp)		(CHIP_IS_E3(bp) && \
94762306a36Sopenharmony_ci					 (CHIP_REV(bp) == CHIP_REV_Bx))
94862306a36Sopenharmony_ci#define CHIP_IS_E3A0(bp)		(CHIP_IS_E3(bp) && \
94962306a36Sopenharmony_ci					 (CHIP_REV(bp) == CHIP_REV_Ax))
95062306a36Sopenharmony_ci/* This define is used in two main places:
95162306a36Sopenharmony_ci * 1. In the early stages of nic_load, to know if to configure Parser / Searcher
95262306a36Sopenharmony_ci * to nic-only mode or to offload mode. Offload mode is configured if either the
95362306a36Sopenharmony_ci * chip is E1x (where MIC_MODE register is not applicable), or if cnic already
95462306a36Sopenharmony_ci * registered for this port (which means that the user wants storage services).
95562306a36Sopenharmony_ci * 2. During cnic-related load, to know if offload mode is already configured in
95662306a36Sopenharmony_ci * the HW or needs to be configured.
95762306a36Sopenharmony_ci * Since the transition from nic-mode to offload-mode in HW causes traffic
95862306a36Sopenharmony_ci * corruption, nic-mode is configured only in ports on which storage services
95962306a36Sopenharmony_ci * where never requested.
96062306a36Sopenharmony_ci */
96162306a36Sopenharmony_ci#define CONFIGURE_NIC_MODE(bp)		(!CHIP_IS_E1x(bp) && !CNIC_ENABLED(bp))
96262306a36Sopenharmony_ci
96362306a36Sopenharmony_ci	int			flash_size;
96462306a36Sopenharmony_ci#define BNX2X_NVRAM_1MB_SIZE			0x20000	/* 1M bit in bytes */
96562306a36Sopenharmony_ci#define BNX2X_NVRAM_TIMEOUT_COUNT		30000
96662306a36Sopenharmony_ci#define BNX2X_NVRAM_PAGE_SIZE			256
96762306a36Sopenharmony_ci
96862306a36Sopenharmony_ci	u32			shmem_base;
96962306a36Sopenharmony_ci	u32			shmem2_base;
97062306a36Sopenharmony_ci	u32			mf_cfg_base;
97162306a36Sopenharmony_ci	u32			mf2_cfg_base;
97262306a36Sopenharmony_ci
97362306a36Sopenharmony_ci	u32			hw_config;
97462306a36Sopenharmony_ci
97562306a36Sopenharmony_ci	u32			bc_ver;
97662306a36Sopenharmony_ci
97762306a36Sopenharmony_ci	u8			int_block;
97862306a36Sopenharmony_ci#define INT_BLOCK_HC			0
97962306a36Sopenharmony_ci#define INT_BLOCK_IGU			1
98062306a36Sopenharmony_ci#define INT_BLOCK_MODE_NORMAL		0
98162306a36Sopenharmony_ci#define INT_BLOCK_MODE_BW_COMP		2
98262306a36Sopenharmony_ci#define CHIP_INT_MODE_IS_NBC(bp)		\
98362306a36Sopenharmony_ci			(!CHIP_IS_E1x(bp) &&	\
98462306a36Sopenharmony_ci			!((bp)->common.int_block & INT_BLOCK_MODE_BW_COMP))
98562306a36Sopenharmony_ci#define CHIP_INT_MODE_IS_BC(bp) (!CHIP_INT_MODE_IS_NBC(bp))
98662306a36Sopenharmony_ci
98762306a36Sopenharmony_ci	u8			chip_port_mode;
98862306a36Sopenharmony_ci#define CHIP_4_PORT_MODE			0x0
98962306a36Sopenharmony_ci#define CHIP_2_PORT_MODE			0x1
99062306a36Sopenharmony_ci#define CHIP_PORT_MODE_NONE			0x2
99162306a36Sopenharmony_ci#define CHIP_MODE(bp)			(bp->common.chip_port_mode)
99262306a36Sopenharmony_ci#define CHIP_MODE_IS_4_PORT(bp) (CHIP_MODE(bp) == CHIP_4_PORT_MODE)
99362306a36Sopenharmony_ci
99462306a36Sopenharmony_ci	u32			boot_mode;
99562306a36Sopenharmony_ci};
99662306a36Sopenharmony_ci
99762306a36Sopenharmony_ci/* IGU MSIX STATISTICS on 57712: 64 for VFs; 4 for PFs; 4 for Attentions */
99862306a36Sopenharmony_ci#define BNX2X_IGU_STAS_MSG_VF_CNT 64
99962306a36Sopenharmony_ci#define BNX2X_IGU_STAS_MSG_PF_CNT 4
100062306a36Sopenharmony_ci
100162306a36Sopenharmony_ci#define MAX_IGU_ATTN_ACK_TO       100
100262306a36Sopenharmony_ci/* end of common */
100362306a36Sopenharmony_ci
100462306a36Sopenharmony_ci/* port */
100562306a36Sopenharmony_ci
100662306a36Sopenharmony_cistruct bnx2x_port {
100762306a36Sopenharmony_ci	u32			pmf;
100862306a36Sopenharmony_ci
100962306a36Sopenharmony_ci	u32			link_config[LINK_CONFIG_SIZE];
101062306a36Sopenharmony_ci
101162306a36Sopenharmony_ci	u32			supported[LINK_CONFIG_SIZE];
101262306a36Sopenharmony_ci
101362306a36Sopenharmony_ci	u32			advertising[LINK_CONFIG_SIZE];
101462306a36Sopenharmony_ci
101562306a36Sopenharmony_ci	u32			phy_addr;
101662306a36Sopenharmony_ci
101762306a36Sopenharmony_ci	/* used to synchronize phy accesses */
101862306a36Sopenharmony_ci	struct mutex		phy_mutex;
101962306a36Sopenharmony_ci
102062306a36Sopenharmony_ci	u32			port_stx;
102162306a36Sopenharmony_ci
102262306a36Sopenharmony_ci	struct nig_stats	old_nig_stats;
102362306a36Sopenharmony_ci};
102462306a36Sopenharmony_ci
102562306a36Sopenharmony_ci/* end of port */
102662306a36Sopenharmony_ci
102762306a36Sopenharmony_ci#define STATS_OFFSET32(stat_name) \
102862306a36Sopenharmony_ci			(offsetof(struct bnx2x_eth_stats, stat_name) / 4)
102962306a36Sopenharmony_ci
103062306a36Sopenharmony_ci/* slow path */
103162306a36Sopenharmony_ci#define BNX2X_MAX_NUM_OF_VFS	64
103262306a36Sopenharmony_ci#define BNX2X_VF_CID_WND	4 /* log num of queues per VF. HW config. */
103362306a36Sopenharmony_ci#define BNX2X_CIDS_PER_VF	(1 << BNX2X_VF_CID_WND)
103462306a36Sopenharmony_ci
103562306a36Sopenharmony_ci/* We need to reserve doorbell addresses for all VF and queue combinations */
103662306a36Sopenharmony_ci#define BNX2X_VF_CIDS		(BNX2X_MAX_NUM_OF_VFS * BNX2X_CIDS_PER_VF)
103762306a36Sopenharmony_ci
103862306a36Sopenharmony_ci/* The doorbell is configured to have the same number of CIDs for PFs and for
103962306a36Sopenharmony_ci * VFs. For this reason the PF CID zone is as large as the VF zone.
104062306a36Sopenharmony_ci */
104162306a36Sopenharmony_ci#define BNX2X_FIRST_VF_CID	BNX2X_VF_CIDS
104262306a36Sopenharmony_ci#define BNX2X_MAX_NUM_VF_QUEUES	64
104362306a36Sopenharmony_ci#define BNX2X_VF_ID_INVALID	0xFF
104462306a36Sopenharmony_ci
104562306a36Sopenharmony_ci/* the number of VF CIDS multiplied by the amount of bytes reserved for each
104662306a36Sopenharmony_ci * cid must not exceed the size of the VF doorbell
104762306a36Sopenharmony_ci */
104862306a36Sopenharmony_ci#define BNX2X_VF_BAR_SIZE	512
104962306a36Sopenharmony_ci#if (BNX2X_VF_BAR_SIZE < BNX2X_CIDS_PER_VF * (1 << BNX2X_DB_SHIFT))
105062306a36Sopenharmony_ci#error "VF doorbell bar size is 512"
105162306a36Sopenharmony_ci#endif
105262306a36Sopenharmony_ci
105362306a36Sopenharmony_ci/*
105462306a36Sopenharmony_ci * The total number of L2 queues, MSIX vectors and HW contexts (CIDs) is
105562306a36Sopenharmony_ci * control by the number of fast-path status blocks supported by the
105662306a36Sopenharmony_ci * device (HW/FW). Each fast-path status block (FP-SB) aka non-default
105762306a36Sopenharmony_ci * status block represents an independent interrupts context that can
105862306a36Sopenharmony_ci * serve a regular L2 networking queue. However special L2 queues such
105962306a36Sopenharmony_ci * as the FCoE queue do not require a FP-SB and other components like
106062306a36Sopenharmony_ci * the CNIC may consume FP-SB reducing the number of possible L2 queues
106162306a36Sopenharmony_ci *
106262306a36Sopenharmony_ci * If the maximum number of FP-SB available is X then:
106362306a36Sopenharmony_ci * a. If CNIC is supported it consumes 1 FP-SB thus the max number of
106462306a36Sopenharmony_ci *    regular L2 queues is Y=X-1
106562306a36Sopenharmony_ci * b. In MF mode the actual number of L2 queues is Y= (X-1/MF_factor)
106662306a36Sopenharmony_ci * c. If the FCoE L2 queue is supported the actual number of L2 queues
106762306a36Sopenharmony_ci *    is Y+1
106862306a36Sopenharmony_ci * d. The number of irqs (MSIX vectors) is either Y+1 (one extra for
106962306a36Sopenharmony_ci *    slow-path interrupts) or Y+2 if CNIC is supported (one additional
107062306a36Sopenharmony_ci *    FP interrupt context for the CNIC).
107162306a36Sopenharmony_ci * e. The number of HW context (CID count) is always X or X+1 if FCoE
107262306a36Sopenharmony_ci *    L2 queue is supported. The cid for the FCoE L2 queue is always X.
107362306a36Sopenharmony_ci */
107462306a36Sopenharmony_ci
107562306a36Sopenharmony_ci/* fast-path interrupt contexts E1x */
107662306a36Sopenharmony_ci#define FP_SB_MAX_E1x		16
107762306a36Sopenharmony_ci/* fast-path interrupt contexts E2 */
107862306a36Sopenharmony_ci#define FP_SB_MAX_E2		HC_SB_MAX_SB_E2
107962306a36Sopenharmony_ci
108062306a36Sopenharmony_ciunion cdu_context {
108162306a36Sopenharmony_ci	struct eth_context eth;
108262306a36Sopenharmony_ci	char pad[1024];
108362306a36Sopenharmony_ci};
108462306a36Sopenharmony_ci
108562306a36Sopenharmony_ci/* CDU host DB constants */
108662306a36Sopenharmony_ci#define CDU_ILT_PAGE_SZ_HW	2
108762306a36Sopenharmony_ci#define CDU_ILT_PAGE_SZ		(8192 << CDU_ILT_PAGE_SZ_HW) /* 32K */
108862306a36Sopenharmony_ci#define ILT_PAGE_CIDS		(CDU_ILT_PAGE_SZ / sizeof(union cdu_context))
108962306a36Sopenharmony_ci
109062306a36Sopenharmony_ci#define CNIC_ISCSI_CID_MAX	256
109162306a36Sopenharmony_ci#define CNIC_FCOE_CID_MAX	2048
109262306a36Sopenharmony_ci#define CNIC_CID_MAX		(CNIC_ISCSI_CID_MAX + CNIC_FCOE_CID_MAX)
109362306a36Sopenharmony_ci#define CNIC_ILT_LINES		DIV_ROUND_UP(CNIC_CID_MAX, ILT_PAGE_CIDS)
109462306a36Sopenharmony_ci
109562306a36Sopenharmony_ci#define QM_ILT_PAGE_SZ_HW	0
109662306a36Sopenharmony_ci#define QM_ILT_PAGE_SZ		(4096 << QM_ILT_PAGE_SZ_HW) /* 4K */
109762306a36Sopenharmony_ci#define QM_CID_ROUND		1024
109862306a36Sopenharmony_ci
109962306a36Sopenharmony_ci/* TM (timers) host DB constants */
110062306a36Sopenharmony_ci#define TM_ILT_PAGE_SZ_HW	0
110162306a36Sopenharmony_ci#define TM_ILT_PAGE_SZ		(4096 << TM_ILT_PAGE_SZ_HW) /* 4K */
110262306a36Sopenharmony_ci#define TM_CONN_NUM		(BNX2X_FIRST_VF_CID + \
110362306a36Sopenharmony_ci				 BNX2X_VF_CIDS + \
110462306a36Sopenharmony_ci				 CNIC_ISCSI_CID_MAX)
110562306a36Sopenharmony_ci#define TM_ILT_SZ		(8 * TM_CONN_NUM)
110662306a36Sopenharmony_ci#define TM_ILT_LINES		DIV_ROUND_UP(TM_ILT_SZ, TM_ILT_PAGE_SZ)
110762306a36Sopenharmony_ci
110862306a36Sopenharmony_ci/* SRC (Searcher) host DB constants */
110962306a36Sopenharmony_ci#define SRC_ILT_PAGE_SZ_HW	0
111062306a36Sopenharmony_ci#define SRC_ILT_PAGE_SZ		(4096 << SRC_ILT_PAGE_SZ_HW) /* 4K */
111162306a36Sopenharmony_ci#define SRC_HASH_BITS		10
111262306a36Sopenharmony_ci#define SRC_CONN_NUM		(1 << SRC_HASH_BITS) /* 1024 */
111362306a36Sopenharmony_ci#define SRC_ILT_SZ		(sizeof(struct src_ent) * SRC_CONN_NUM)
111462306a36Sopenharmony_ci#define SRC_T2_SZ		SRC_ILT_SZ
111562306a36Sopenharmony_ci#define SRC_ILT_LINES		DIV_ROUND_UP(SRC_ILT_SZ, SRC_ILT_PAGE_SZ)
111662306a36Sopenharmony_ci
111762306a36Sopenharmony_ci#define MAX_DMAE_C		8
111862306a36Sopenharmony_ci
111962306a36Sopenharmony_ci/* DMA memory not used in fastpath */
112062306a36Sopenharmony_cistruct bnx2x_slowpath {
112162306a36Sopenharmony_ci	union {
112262306a36Sopenharmony_ci		struct mac_configuration_cmd		e1x;
112362306a36Sopenharmony_ci		struct eth_classify_rules_ramrod_data	e2;
112462306a36Sopenharmony_ci	} mac_rdata;
112562306a36Sopenharmony_ci
112662306a36Sopenharmony_ci	union {
112762306a36Sopenharmony_ci		struct eth_classify_rules_ramrod_data	e2;
112862306a36Sopenharmony_ci	} vlan_rdata;
112962306a36Sopenharmony_ci
113062306a36Sopenharmony_ci	union {
113162306a36Sopenharmony_ci		struct tstorm_eth_mac_filter_config	e1x;
113262306a36Sopenharmony_ci		struct eth_filter_rules_ramrod_data	e2;
113362306a36Sopenharmony_ci	} rx_mode_rdata;
113462306a36Sopenharmony_ci
113562306a36Sopenharmony_ci	union {
113662306a36Sopenharmony_ci		struct mac_configuration_cmd		e1;
113762306a36Sopenharmony_ci		struct eth_multicast_rules_ramrod_data  e2;
113862306a36Sopenharmony_ci	} mcast_rdata;
113962306a36Sopenharmony_ci
114062306a36Sopenharmony_ci	struct eth_rss_update_ramrod_data	rss_rdata;
114162306a36Sopenharmony_ci
114262306a36Sopenharmony_ci	/* Queue State related ramrods are always sent under rtnl_lock */
114362306a36Sopenharmony_ci	union {
114462306a36Sopenharmony_ci		struct client_init_ramrod_data  init_data;
114562306a36Sopenharmony_ci		struct client_update_ramrod_data update_data;
114662306a36Sopenharmony_ci		struct tpa_update_ramrod_data tpa_data;
114762306a36Sopenharmony_ci	} q_rdata;
114862306a36Sopenharmony_ci
114962306a36Sopenharmony_ci	union {
115062306a36Sopenharmony_ci		struct function_start_data	func_start;
115162306a36Sopenharmony_ci		/* pfc configuration for DCBX ramrod */
115262306a36Sopenharmony_ci		struct flow_control_configuration pfc_config;
115362306a36Sopenharmony_ci	} func_rdata;
115462306a36Sopenharmony_ci
115562306a36Sopenharmony_ci	/* afex ramrod can not be a part of func_rdata union because these
115662306a36Sopenharmony_ci	 * events might arrive in parallel to other events from func_rdata.
115762306a36Sopenharmony_ci	 * Therefore, if they would have been defined in the same union,
115862306a36Sopenharmony_ci	 * data can get corrupted.
115962306a36Sopenharmony_ci	 */
116062306a36Sopenharmony_ci	union {
116162306a36Sopenharmony_ci		struct afex_vif_list_ramrod_data	viflist_data;
116262306a36Sopenharmony_ci		struct function_update_data		func_update;
116362306a36Sopenharmony_ci	} func_afex_rdata;
116462306a36Sopenharmony_ci
116562306a36Sopenharmony_ci	/* used by dmae command executer */
116662306a36Sopenharmony_ci	struct dmae_command		dmae[MAX_DMAE_C];
116762306a36Sopenharmony_ci
116862306a36Sopenharmony_ci	u32				stats_comp;
116962306a36Sopenharmony_ci	union mac_stats			mac_stats;
117062306a36Sopenharmony_ci	struct nig_stats		nig_stats;
117162306a36Sopenharmony_ci	struct host_port_stats		port_stats;
117262306a36Sopenharmony_ci	struct host_func_stats		func_stats;
117362306a36Sopenharmony_ci
117462306a36Sopenharmony_ci	u32				wb_comp;
117562306a36Sopenharmony_ci	u32				wb_data[4];
117662306a36Sopenharmony_ci
117762306a36Sopenharmony_ci	union drv_info_to_mcp		drv_info_to_mcp;
117862306a36Sopenharmony_ci};
117962306a36Sopenharmony_ci
118062306a36Sopenharmony_ci#define bnx2x_sp(bp, var)		(&bp->slowpath->var)
118162306a36Sopenharmony_ci#define bnx2x_sp_mapping(bp, var) \
118262306a36Sopenharmony_ci		(bp->slowpath_mapping + offsetof(struct bnx2x_slowpath, var))
118362306a36Sopenharmony_ci
118462306a36Sopenharmony_ci/* attn group wiring */
118562306a36Sopenharmony_ci#define MAX_DYNAMIC_ATTN_GRPS		8
118662306a36Sopenharmony_ci
118762306a36Sopenharmony_cistruct attn_route {
118862306a36Sopenharmony_ci	u32 sig[5];
118962306a36Sopenharmony_ci};
119062306a36Sopenharmony_ci
119162306a36Sopenharmony_cistruct iro {
119262306a36Sopenharmony_ci	u32 base;
119362306a36Sopenharmony_ci	u16 m1;
119462306a36Sopenharmony_ci	u16 m2;
119562306a36Sopenharmony_ci	u16 m3;
119662306a36Sopenharmony_ci	u16 size;
119762306a36Sopenharmony_ci};
119862306a36Sopenharmony_ci
119962306a36Sopenharmony_cistruct hw_context {
120062306a36Sopenharmony_ci	union cdu_context *vcxt;
120162306a36Sopenharmony_ci	dma_addr_t cxt_mapping;
120262306a36Sopenharmony_ci	size_t size;
120362306a36Sopenharmony_ci};
120462306a36Sopenharmony_ci
120562306a36Sopenharmony_ci/* forward */
120662306a36Sopenharmony_cistruct bnx2x_ilt;
120762306a36Sopenharmony_ci
120862306a36Sopenharmony_cistruct bnx2x_vfdb;
120962306a36Sopenharmony_ci
121062306a36Sopenharmony_cienum bnx2x_recovery_state {
121162306a36Sopenharmony_ci	BNX2X_RECOVERY_DONE,
121262306a36Sopenharmony_ci	BNX2X_RECOVERY_INIT,
121362306a36Sopenharmony_ci	BNX2X_RECOVERY_WAIT,
121462306a36Sopenharmony_ci	BNX2X_RECOVERY_FAILED,
121562306a36Sopenharmony_ci	BNX2X_RECOVERY_NIC_LOADING
121662306a36Sopenharmony_ci};
121762306a36Sopenharmony_ci
121862306a36Sopenharmony_ci/*
121962306a36Sopenharmony_ci * Event queue (EQ or event ring) MC hsi
122062306a36Sopenharmony_ci * NUM_EQ_PAGES and EQ_DESC_CNT_PAGE must be power of 2
122162306a36Sopenharmony_ci */
122262306a36Sopenharmony_ci#define NUM_EQ_PAGES		1
122362306a36Sopenharmony_ci#define EQ_DESC_CNT_PAGE	(BCM_PAGE_SIZE / sizeof(union event_ring_elem))
122462306a36Sopenharmony_ci#define EQ_DESC_MAX_PAGE	(EQ_DESC_CNT_PAGE - 1)
122562306a36Sopenharmony_ci#define NUM_EQ_DESC		(EQ_DESC_CNT_PAGE * NUM_EQ_PAGES)
122662306a36Sopenharmony_ci#define EQ_DESC_MASK		(NUM_EQ_DESC - 1)
122762306a36Sopenharmony_ci#define MAX_EQ_AVAIL		(EQ_DESC_MAX_PAGE * NUM_EQ_PAGES - 2)
122862306a36Sopenharmony_ci
122962306a36Sopenharmony_ci/* depends on EQ_DESC_CNT_PAGE being a power of 2 */
123062306a36Sopenharmony_ci#define NEXT_EQ_IDX(x)		((((x) & EQ_DESC_MAX_PAGE) == \
123162306a36Sopenharmony_ci				  (EQ_DESC_MAX_PAGE - 1)) ? (x) + 2 : (x) + 1)
123262306a36Sopenharmony_ci
123362306a36Sopenharmony_ci/* depends on the above and on NUM_EQ_PAGES being a power of 2 */
123462306a36Sopenharmony_ci#define EQ_DESC(x)		((x) & EQ_DESC_MASK)
123562306a36Sopenharmony_ci
123662306a36Sopenharmony_ci#define BNX2X_EQ_INDEX \
123762306a36Sopenharmony_ci	(&bp->def_status_blk->sp_sb.\
123862306a36Sopenharmony_ci	index_values[HC_SP_INDEX_EQ_CONS])
123962306a36Sopenharmony_ci
124062306a36Sopenharmony_ci/* This is a data that will be used to create a link report message.
124162306a36Sopenharmony_ci * We will keep the data used for the last link report in order
124262306a36Sopenharmony_ci * to prevent reporting the same link parameters twice.
124362306a36Sopenharmony_ci */
124462306a36Sopenharmony_cistruct bnx2x_link_report_data {
124562306a36Sopenharmony_ci	u16 line_speed;			/* Effective line speed */
124662306a36Sopenharmony_ci	unsigned long link_report_flags;/* BNX2X_LINK_REPORT_XXX flags */
124762306a36Sopenharmony_ci};
124862306a36Sopenharmony_ci
124962306a36Sopenharmony_cienum {
125062306a36Sopenharmony_ci	BNX2X_LINK_REPORT_FD,		/* Full DUPLEX */
125162306a36Sopenharmony_ci	BNX2X_LINK_REPORT_LINK_DOWN,
125262306a36Sopenharmony_ci	BNX2X_LINK_REPORT_RX_FC_ON,
125362306a36Sopenharmony_ci	BNX2X_LINK_REPORT_TX_FC_ON,
125462306a36Sopenharmony_ci};
125562306a36Sopenharmony_ci
125662306a36Sopenharmony_cienum {
125762306a36Sopenharmony_ci	BNX2X_PORT_QUERY_IDX,
125862306a36Sopenharmony_ci	BNX2X_PF_QUERY_IDX,
125962306a36Sopenharmony_ci	BNX2X_FCOE_QUERY_IDX,
126062306a36Sopenharmony_ci	BNX2X_FIRST_QUEUE_QUERY_IDX,
126162306a36Sopenharmony_ci};
126262306a36Sopenharmony_ci
126362306a36Sopenharmony_cistruct bnx2x_fw_stats_req {
126462306a36Sopenharmony_ci	struct stats_query_header hdr;
126562306a36Sopenharmony_ci	struct stats_query_entry query[FP_SB_MAX_E1x+
126662306a36Sopenharmony_ci		BNX2X_FIRST_QUEUE_QUERY_IDX];
126762306a36Sopenharmony_ci};
126862306a36Sopenharmony_ci
126962306a36Sopenharmony_cistruct bnx2x_fw_stats_data {
127062306a36Sopenharmony_ci	struct stats_counter		storm_counters;
127162306a36Sopenharmony_ci	struct per_port_stats		port;
127262306a36Sopenharmony_ci	struct per_pf_stats		pf;
127362306a36Sopenharmony_ci	struct fcoe_statistics_params	fcoe;
127462306a36Sopenharmony_ci	struct per_queue_stats		queue_stats[];
127562306a36Sopenharmony_ci};
127662306a36Sopenharmony_ci
127762306a36Sopenharmony_ci/* Public slow path states */
127862306a36Sopenharmony_cienum sp_rtnl_flag {
127962306a36Sopenharmony_ci	BNX2X_SP_RTNL_SETUP_TC,
128062306a36Sopenharmony_ci	BNX2X_SP_RTNL_TX_TIMEOUT,
128162306a36Sopenharmony_ci	BNX2X_SP_RTNL_FAN_FAILURE,
128262306a36Sopenharmony_ci	BNX2X_SP_RTNL_AFEX_F_UPDATE,
128362306a36Sopenharmony_ci	BNX2X_SP_RTNL_ENABLE_SRIOV,
128462306a36Sopenharmony_ci	BNX2X_SP_RTNL_VFPF_MCAST,
128562306a36Sopenharmony_ci	BNX2X_SP_RTNL_VFPF_CHANNEL_DOWN,
128662306a36Sopenharmony_ci	BNX2X_SP_RTNL_RX_MODE,
128762306a36Sopenharmony_ci	BNX2X_SP_RTNL_HYPERVISOR_VLAN,
128862306a36Sopenharmony_ci	BNX2X_SP_RTNL_TX_STOP,
128962306a36Sopenharmony_ci	BNX2X_SP_RTNL_GET_DRV_VERSION,
129062306a36Sopenharmony_ci	BNX2X_SP_RTNL_UPDATE_SVID,
129162306a36Sopenharmony_ci};
129262306a36Sopenharmony_ci
129362306a36Sopenharmony_cienum bnx2x_iov_flag {
129462306a36Sopenharmony_ci	BNX2X_IOV_HANDLE_VF_MSG,
129562306a36Sopenharmony_ci	BNX2X_IOV_HANDLE_FLR,
129662306a36Sopenharmony_ci};
129762306a36Sopenharmony_ci
129862306a36Sopenharmony_cistruct bnx2x_prev_path_list {
129962306a36Sopenharmony_ci	struct list_head list;
130062306a36Sopenharmony_ci	u8 bus;
130162306a36Sopenharmony_ci	u8 slot;
130262306a36Sopenharmony_ci	u8 path;
130362306a36Sopenharmony_ci	u8 aer;
130462306a36Sopenharmony_ci	u8 undi;
130562306a36Sopenharmony_ci};
130662306a36Sopenharmony_ci
130762306a36Sopenharmony_cistruct bnx2x_sp_objs {
130862306a36Sopenharmony_ci	/* MACs object */
130962306a36Sopenharmony_ci	struct bnx2x_vlan_mac_obj mac_obj;
131062306a36Sopenharmony_ci
131162306a36Sopenharmony_ci	/* Queue State object */
131262306a36Sopenharmony_ci	struct bnx2x_queue_sp_obj q_obj;
131362306a36Sopenharmony_ci
131462306a36Sopenharmony_ci	/* VLANs object */
131562306a36Sopenharmony_ci	struct bnx2x_vlan_mac_obj vlan_obj;
131662306a36Sopenharmony_ci};
131762306a36Sopenharmony_ci
131862306a36Sopenharmony_cistruct bnx2x_fp_stats {
131962306a36Sopenharmony_ci	struct tstorm_per_queue_stats old_tclient;
132062306a36Sopenharmony_ci	struct ustorm_per_queue_stats old_uclient;
132162306a36Sopenharmony_ci	struct xstorm_per_queue_stats old_xclient;
132262306a36Sopenharmony_ci	struct bnx2x_eth_q_stats eth_q_stats;
132362306a36Sopenharmony_ci	struct bnx2x_eth_q_stats_old eth_q_stats_old;
132462306a36Sopenharmony_ci};
132562306a36Sopenharmony_ci
132662306a36Sopenharmony_cienum {
132762306a36Sopenharmony_ci	SUB_MF_MODE_UNKNOWN = 0,
132862306a36Sopenharmony_ci	SUB_MF_MODE_UFP,
132962306a36Sopenharmony_ci	SUB_MF_MODE_NPAR1_DOT_5,
133062306a36Sopenharmony_ci	SUB_MF_MODE_BD,
133162306a36Sopenharmony_ci};
133262306a36Sopenharmony_ci
133362306a36Sopenharmony_cistruct bnx2x_vlan_entry {
133462306a36Sopenharmony_ci	struct list_head link;
133562306a36Sopenharmony_ci	u16 vid;
133662306a36Sopenharmony_ci	bool hw;
133762306a36Sopenharmony_ci};
133862306a36Sopenharmony_ci
133962306a36Sopenharmony_cienum bnx2x_udp_port_type {
134062306a36Sopenharmony_ci	BNX2X_UDP_PORT_VXLAN,
134162306a36Sopenharmony_ci	BNX2X_UDP_PORT_GENEVE,
134262306a36Sopenharmony_ci	BNX2X_UDP_PORT_MAX,
134362306a36Sopenharmony_ci};
134462306a36Sopenharmony_ci
134562306a36Sopenharmony_cistruct bnx2x {
134662306a36Sopenharmony_ci	/* Fields used in the tx and intr/napi performance paths
134762306a36Sopenharmony_ci	 * are grouped together in the beginning of the structure
134862306a36Sopenharmony_ci	 */
134962306a36Sopenharmony_ci	struct bnx2x_fastpath	*fp;
135062306a36Sopenharmony_ci	struct bnx2x_sp_objs	*sp_objs;
135162306a36Sopenharmony_ci	struct bnx2x_fp_stats	*fp_stats;
135262306a36Sopenharmony_ci	struct bnx2x_fp_txdata	*bnx2x_txq;
135362306a36Sopenharmony_ci	void __iomem		*regview;
135462306a36Sopenharmony_ci	void __iomem		*doorbells;
135562306a36Sopenharmony_ci	u16			db_size;
135662306a36Sopenharmony_ci
135762306a36Sopenharmony_ci	u8			pf_num;	/* absolute PF number */
135862306a36Sopenharmony_ci	u8			pfid;	/* per-path PF number */
135962306a36Sopenharmony_ci	int			base_fw_ndsb; /**/
136062306a36Sopenharmony_ci#define BP_PATH(bp)			(CHIP_IS_E1x(bp) ? 0 : (bp->pf_num & 1))
136162306a36Sopenharmony_ci#define BP_PORT(bp)			(bp->pfid & 1)
136262306a36Sopenharmony_ci#define BP_FUNC(bp)			(bp->pfid)
136362306a36Sopenharmony_ci#define BP_ABS_FUNC(bp)			(bp->pf_num)
136462306a36Sopenharmony_ci#define BP_VN(bp)			((bp)->pfid >> 1)
136562306a36Sopenharmony_ci#define BP_MAX_VN_NUM(bp)		(CHIP_MODE_IS_4_PORT(bp) ? 2 : 4)
136662306a36Sopenharmony_ci#define BP_L_ID(bp)			(BP_VN(bp) << 2)
136762306a36Sopenharmony_ci#define BP_FW_MB_IDX_VN(bp, vn)		(BP_PORT(bp) +\
136862306a36Sopenharmony_ci	  (vn) * ((CHIP_IS_E1x(bp) || (CHIP_MODE_IS_4_PORT(bp))) ? 2  : 1))
136962306a36Sopenharmony_ci#define BP_FW_MB_IDX(bp)		BP_FW_MB_IDX_VN(bp, BP_VN(bp))
137062306a36Sopenharmony_ci
137162306a36Sopenharmony_ci#ifdef CONFIG_BNX2X_SRIOV
137262306a36Sopenharmony_ci	/* protects vf2pf mailbox from simultaneous access */
137362306a36Sopenharmony_ci	struct mutex		vf2pf_mutex;
137462306a36Sopenharmony_ci	/* vf pf channel mailbox contains request and response buffers */
137562306a36Sopenharmony_ci	struct bnx2x_vf_mbx_msg	*vf2pf_mbox;
137662306a36Sopenharmony_ci	dma_addr_t		vf2pf_mbox_mapping;
137762306a36Sopenharmony_ci
137862306a36Sopenharmony_ci	/* we set aside a copy of the acquire response */
137962306a36Sopenharmony_ci	struct pfvf_acquire_resp_tlv acquire_resp;
138062306a36Sopenharmony_ci
138162306a36Sopenharmony_ci	/* bulletin board for messages from pf to vf */
138262306a36Sopenharmony_ci	union pf_vf_bulletin   *pf2vf_bulletin;
138362306a36Sopenharmony_ci	dma_addr_t		pf2vf_bulletin_mapping;
138462306a36Sopenharmony_ci
138562306a36Sopenharmony_ci	union pf_vf_bulletin		shadow_bulletin;
138662306a36Sopenharmony_ci	struct pf_vf_bulletin_content	old_bulletin;
138762306a36Sopenharmony_ci
138862306a36Sopenharmony_ci	u16 requested_nr_virtfn;
138962306a36Sopenharmony_ci#endif /* CONFIG_BNX2X_SRIOV */
139062306a36Sopenharmony_ci
139162306a36Sopenharmony_ci	struct net_device	*dev;
139262306a36Sopenharmony_ci	struct pci_dev		*pdev;
139362306a36Sopenharmony_ci
139462306a36Sopenharmony_ci	const struct iro	*iro_arr;
139562306a36Sopenharmony_ci#define IRO (bp->iro_arr)
139662306a36Sopenharmony_ci
139762306a36Sopenharmony_ci	enum bnx2x_recovery_state recovery_state;
139862306a36Sopenharmony_ci	int			is_leader;
139962306a36Sopenharmony_ci	struct msix_entry	*msix_table;
140062306a36Sopenharmony_ci
140162306a36Sopenharmony_ci	int			tx_ring_size;
140262306a36Sopenharmony_ci
140362306a36Sopenharmony_ci/* L2 header size + 2*VLANs (8 bytes) + LLC SNAP (8 bytes) */
140462306a36Sopenharmony_ci#define ETH_OVERHEAD		(ETH_HLEN + 8 + 8)
140562306a36Sopenharmony_ci#define ETH_MIN_PACKET_SIZE		(ETH_ZLEN - ETH_HLEN)
140662306a36Sopenharmony_ci#define ETH_MAX_PACKET_SIZE		ETH_DATA_LEN
140762306a36Sopenharmony_ci#define ETH_MAX_JUMBO_PACKET_SIZE	9600
140862306a36Sopenharmony_ci/* TCP with Timestamp Option (32) + IPv6 (40) */
140962306a36Sopenharmony_ci#define ETH_MAX_TPA_HEADER_SIZE		72
141062306a36Sopenharmony_ci
141162306a36Sopenharmony_ci	/* Max supported alignment is 256 (8 shift)
141262306a36Sopenharmony_ci	 * minimal alignment shift 6 is optimal for 57xxx HW performance
141362306a36Sopenharmony_ci	 */
141462306a36Sopenharmony_ci#define BNX2X_RX_ALIGN_SHIFT		max(6, min(8, L1_CACHE_SHIFT))
141562306a36Sopenharmony_ci
141662306a36Sopenharmony_ci	/* FW uses 2 Cache lines Alignment for start packet and size
141762306a36Sopenharmony_ci	 *
141862306a36Sopenharmony_ci	 * We assume skb_build() uses sizeof(struct skb_shared_info) bytes
141962306a36Sopenharmony_ci	 * at the end of skb->data, to avoid wasting a full cache line.
142062306a36Sopenharmony_ci	 * This reduces memory use (skb->truesize).
142162306a36Sopenharmony_ci	 */
142262306a36Sopenharmony_ci#define BNX2X_FW_RX_ALIGN_START	(1UL << BNX2X_RX_ALIGN_SHIFT)
142362306a36Sopenharmony_ci
142462306a36Sopenharmony_ci#define BNX2X_FW_RX_ALIGN_END					\
142562306a36Sopenharmony_ci	max_t(u64, 1UL << BNX2X_RX_ALIGN_SHIFT,			\
142662306a36Sopenharmony_ci	    SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
142762306a36Sopenharmony_ci
142862306a36Sopenharmony_ci#define BNX2X_PXP_DRAM_ALIGN		(BNX2X_RX_ALIGN_SHIFT - 5)
142962306a36Sopenharmony_ci
143062306a36Sopenharmony_ci	struct host_sp_status_block *def_status_blk;
143162306a36Sopenharmony_ci#define DEF_SB_IGU_ID			16
143262306a36Sopenharmony_ci#define DEF_SB_ID			HC_SP_SB_ID
143362306a36Sopenharmony_ci	__le16			def_idx;
143462306a36Sopenharmony_ci	__le16			def_att_idx;
143562306a36Sopenharmony_ci	u32			attn_state;
143662306a36Sopenharmony_ci	struct attn_route	attn_group[MAX_DYNAMIC_ATTN_GRPS];
143762306a36Sopenharmony_ci
143862306a36Sopenharmony_ci	/* slow path ring */
143962306a36Sopenharmony_ci	struct eth_spe		*spq;
144062306a36Sopenharmony_ci	dma_addr_t		spq_mapping;
144162306a36Sopenharmony_ci	u16			spq_prod_idx;
144262306a36Sopenharmony_ci	struct eth_spe		*spq_prod_bd;
144362306a36Sopenharmony_ci	struct eth_spe		*spq_last_bd;
144462306a36Sopenharmony_ci	__le16			*dsb_sp_prod;
144562306a36Sopenharmony_ci	atomic_t		cq_spq_left; /* ETH_XXX ramrods credit */
144662306a36Sopenharmony_ci	/* used to synchronize spq accesses */
144762306a36Sopenharmony_ci	spinlock_t		spq_lock;
144862306a36Sopenharmony_ci
144962306a36Sopenharmony_ci	/* event queue */
145062306a36Sopenharmony_ci	union event_ring_elem	*eq_ring;
145162306a36Sopenharmony_ci	dma_addr_t		eq_mapping;
145262306a36Sopenharmony_ci	u16			eq_prod;
145362306a36Sopenharmony_ci	u16			eq_cons;
145462306a36Sopenharmony_ci	__le16			*eq_cons_sb;
145562306a36Sopenharmony_ci	atomic_t		eq_spq_left; /* COMMON_XXX ramrods credit */
145662306a36Sopenharmony_ci
145762306a36Sopenharmony_ci	/* Counter for marking that there is a STAT_QUERY ramrod pending */
145862306a36Sopenharmony_ci	u16			stats_pending;
145962306a36Sopenharmony_ci	/*  Counter for completed statistics ramrods */
146062306a36Sopenharmony_ci	u16			stats_comp;
146162306a36Sopenharmony_ci
146262306a36Sopenharmony_ci	/* End of fields used in the performance code paths */
146362306a36Sopenharmony_ci
146462306a36Sopenharmony_ci	int			panic;
146562306a36Sopenharmony_ci	int			msg_enable;
146662306a36Sopenharmony_ci
146762306a36Sopenharmony_ci	u32			flags;
146862306a36Sopenharmony_ci#define PCIX_FLAG			(1 << 0)
146962306a36Sopenharmony_ci#define PCI_32BIT_FLAG			(1 << 1)
147062306a36Sopenharmony_ci#define ONE_PORT_FLAG			(1 << 2)
147162306a36Sopenharmony_ci#define NO_WOL_FLAG			(1 << 3)
147262306a36Sopenharmony_ci#define USING_MSIX_FLAG			(1 << 5)
147362306a36Sopenharmony_ci#define USING_MSI_FLAG			(1 << 6)
147462306a36Sopenharmony_ci#define DISABLE_MSI_FLAG		(1 << 7)
147562306a36Sopenharmony_ci#define NO_MCP_FLAG			(1 << 9)
147662306a36Sopenharmony_ci#define MF_FUNC_DIS			(1 << 11)
147762306a36Sopenharmony_ci#define OWN_CNIC_IRQ			(1 << 12)
147862306a36Sopenharmony_ci#define NO_ISCSI_OOO_FLAG		(1 << 13)
147962306a36Sopenharmony_ci#define NO_ISCSI_FLAG			(1 << 14)
148062306a36Sopenharmony_ci#define NO_FCOE_FLAG			(1 << 15)
148162306a36Sopenharmony_ci#define BC_SUPPORTS_PFC_STATS		(1 << 17)
148262306a36Sopenharmony_ci#define TX_SWITCHING			(1 << 18)
148362306a36Sopenharmony_ci#define BC_SUPPORTS_FCOE_FEATURES	(1 << 19)
148462306a36Sopenharmony_ci#define USING_SINGLE_MSIX_FLAG		(1 << 20)
148562306a36Sopenharmony_ci#define BC_SUPPORTS_DCBX_MSG_NON_PMF	(1 << 21)
148662306a36Sopenharmony_ci#define IS_VF_FLAG			(1 << 22)
148762306a36Sopenharmony_ci#define BC_SUPPORTS_RMMOD_CMD		(1 << 23)
148862306a36Sopenharmony_ci#define HAS_PHYS_PORT_ID		(1 << 24)
148962306a36Sopenharmony_ci#define PTP_SUPPORTED			(1 << 26)
149062306a36Sopenharmony_ci#define TX_TIMESTAMPING_EN		(1 << 27)
149162306a36Sopenharmony_ci
149262306a36Sopenharmony_ci#define BP_NOMCP(bp)			((bp)->flags & NO_MCP_FLAG)
149362306a36Sopenharmony_ci
149462306a36Sopenharmony_ci#ifdef CONFIG_BNX2X_SRIOV
149562306a36Sopenharmony_ci#define IS_VF(bp)			((bp)->flags & IS_VF_FLAG)
149662306a36Sopenharmony_ci#define IS_PF(bp)			(!((bp)->flags & IS_VF_FLAG))
149762306a36Sopenharmony_ci#else
149862306a36Sopenharmony_ci#define IS_VF(bp)			false
149962306a36Sopenharmony_ci#define IS_PF(bp)			true
150062306a36Sopenharmony_ci#endif
150162306a36Sopenharmony_ci
150262306a36Sopenharmony_ci#define NO_ISCSI(bp)		((bp)->flags & NO_ISCSI_FLAG)
150362306a36Sopenharmony_ci#define NO_ISCSI_OOO(bp)	((bp)->flags & NO_ISCSI_OOO_FLAG)
150462306a36Sopenharmony_ci#define NO_FCOE(bp)		((bp)->flags & NO_FCOE_FLAG)
150562306a36Sopenharmony_ci
150662306a36Sopenharmony_ci	u8			cnic_support;
150762306a36Sopenharmony_ci	bool			cnic_enabled;
150862306a36Sopenharmony_ci	bool			cnic_loaded;
150962306a36Sopenharmony_ci	struct cnic_eth_dev	*(*cnic_probe)(struct net_device *);
151062306a36Sopenharmony_ci
151162306a36Sopenharmony_ci	bool                    nic_stopped;
151262306a36Sopenharmony_ci
151362306a36Sopenharmony_ci	/* Flag that indicates that we can start looking for FCoE L2 queue
151462306a36Sopenharmony_ci	 * completions in the default status block.
151562306a36Sopenharmony_ci	 */
151662306a36Sopenharmony_ci	bool			fcoe_init;
151762306a36Sopenharmony_ci
151862306a36Sopenharmony_ci	int			mrrs;
151962306a36Sopenharmony_ci
152062306a36Sopenharmony_ci	struct delayed_work	sp_task;
152162306a36Sopenharmony_ci	struct delayed_work	iov_task;
152262306a36Sopenharmony_ci
152362306a36Sopenharmony_ci	atomic_t		interrupt_occurred;
152462306a36Sopenharmony_ci	struct delayed_work	sp_rtnl_task;
152562306a36Sopenharmony_ci
152662306a36Sopenharmony_ci	struct delayed_work	period_task;
152762306a36Sopenharmony_ci	struct timer_list	timer;
152862306a36Sopenharmony_ci	int			current_interval;
152962306a36Sopenharmony_ci
153062306a36Sopenharmony_ci	u16			fw_seq;
153162306a36Sopenharmony_ci	u16			fw_drv_pulse_wr_seq;
153262306a36Sopenharmony_ci	u32			func_stx;
153362306a36Sopenharmony_ci
153462306a36Sopenharmony_ci	struct link_params	link_params;
153562306a36Sopenharmony_ci	struct link_vars	link_vars;
153662306a36Sopenharmony_ci	u32			link_cnt;
153762306a36Sopenharmony_ci	struct bnx2x_link_report_data last_reported_link;
153862306a36Sopenharmony_ci	bool			force_link_down;
153962306a36Sopenharmony_ci
154062306a36Sopenharmony_ci	struct mdio_if_info	mdio;
154162306a36Sopenharmony_ci
154262306a36Sopenharmony_ci	struct bnx2x_common	common;
154362306a36Sopenharmony_ci	struct bnx2x_port	port;
154462306a36Sopenharmony_ci
154562306a36Sopenharmony_ci	struct cmng_init	cmng;
154662306a36Sopenharmony_ci
154762306a36Sopenharmony_ci	u32			mf_config[E1HVN_MAX];
154862306a36Sopenharmony_ci	u32			mf_ext_config;
154962306a36Sopenharmony_ci	u32			path_has_ovlan; /* E3 */
155062306a36Sopenharmony_ci	u16			mf_ov;
155162306a36Sopenharmony_ci	u8			mf_mode;
155262306a36Sopenharmony_ci#define IS_MF(bp)		(bp->mf_mode != 0)
155362306a36Sopenharmony_ci#define IS_MF_SI(bp)		(bp->mf_mode == MULTI_FUNCTION_SI)
155462306a36Sopenharmony_ci#define IS_MF_SD(bp)		(bp->mf_mode == MULTI_FUNCTION_SD)
155562306a36Sopenharmony_ci#define IS_MF_AFEX(bp)		(bp->mf_mode == MULTI_FUNCTION_AFEX)
155662306a36Sopenharmony_ci	u8			mf_sub_mode;
155762306a36Sopenharmony_ci#define IS_MF_UFP(bp)		(IS_MF_SD(bp) && \
155862306a36Sopenharmony_ci				 bp->mf_sub_mode == SUB_MF_MODE_UFP)
155962306a36Sopenharmony_ci#define IS_MF_BD(bp)		(IS_MF_SD(bp) && \
156062306a36Sopenharmony_ci				 bp->mf_sub_mode == SUB_MF_MODE_BD)
156162306a36Sopenharmony_ci
156262306a36Sopenharmony_ci	u8			wol;
156362306a36Sopenharmony_ci
156462306a36Sopenharmony_ci	int			rx_ring_size;
156562306a36Sopenharmony_ci
156662306a36Sopenharmony_ci	u16			tx_quick_cons_trip_int;
156762306a36Sopenharmony_ci	u16			tx_quick_cons_trip;
156862306a36Sopenharmony_ci	u16			tx_ticks_int;
156962306a36Sopenharmony_ci	u16			tx_ticks;
157062306a36Sopenharmony_ci
157162306a36Sopenharmony_ci	u16			rx_quick_cons_trip_int;
157262306a36Sopenharmony_ci	u16			rx_quick_cons_trip;
157362306a36Sopenharmony_ci	u16			rx_ticks_int;
157462306a36Sopenharmony_ci	u16			rx_ticks;
157562306a36Sopenharmony_ci/* Maximal coalescing timeout in us */
157662306a36Sopenharmony_ci#define BNX2X_MAX_COALESCE_TOUT		(0xff*BNX2X_BTR)
157762306a36Sopenharmony_ci
157862306a36Sopenharmony_ci	u32			lin_cnt;
157962306a36Sopenharmony_ci
158062306a36Sopenharmony_ci	u16			state;
158162306a36Sopenharmony_ci#define BNX2X_STATE_CLOSED		0
158262306a36Sopenharmony_ci#define BNX2X_STATE_OPENING_WAIT4_LOAD	0x1000
158362306a36Sopenharmony_ci#define BNX2X_STATE_OPENING_WAIT4_PORT	0x2000
158462306a36Sopenharmony_ci#define BNX2X_STATE_OPEN		0x3000
158562306a36Sopenharmony_ci#define BNX2X_STATE_CLOSING_WAIT4_HALT	0x4000
158662306a36Sopenharmony_ci#define BNX2X_STATE_CLOSING_WAIT4_DELETE 0x5000
158762306a36Sopenharmony_ci
158862306a36Sopenharmony_ci#define BNX2X_STATE_DIAG		0xe000
158962306a36Sopenharmony_ci#define BNX2X_STATE_ERROR		0xf000
159062306a36Sopenharmony_ci
159162306a36Sopenharmony_ci#define BNX2X_MAX_PRIORITY		8
159262306a36Sopenharmony_ci	int			num_queues;
159362306a36Sopenharmony_ci	uint			num_ethernet_queues;
159462306a36Sopenharmony_ci	uint			num_cnic_queues;
159562306a36Sopenharmony_ci	int			disable_tpa;
159662306a36Sopenharmony_ci
159762306a36Sopenharmony_ci	u32			rx_mode;
159862306a36Sopenharmony_ci#define BNX2X_RX_MODE_NONE		0
159962306a36Sopenharmony_ci#define BNX2X_RX_MODE_NORMAL		1
160062306a36Sopenharmony_ci#define BNX2X_RX_MODE_ALLMULTI		2
160162306a36Sopenharmony_ci#define BNX2X_RX_MODE_PROMISC		3
160262306a36Sopenharmony_ci#define BNX2X_MAX_MULTICAST		64
160362306a36Sopenharmony_ci
160462306a36Sopenharmony_ci	u8			igu_dsb_id;
160562306a36Sopenharmony_ci	u8			igu_base_sb;
160662306a36Sopenharmony_ci	u8			igu_sb_cnt;
160762306a36Sopenharmony_ci	u8			min_msix_vec_cnt;
160862306a36Sopenharmony_ci
160962306a36Sopenharmony_ci	u32			igu_base_addr;
161062306a36Sopenharmony_ci	dma_addr_t		def_status_blk_mapping;
161162306a36Sopenharmony_ci
161262306a36Sopenharmony_ci	struct bnx2x_slowpath	*slowpath;
161362306a36Sopenharmony_ci	dma_addr_t		slowpath_mapping;
161462306a36Sopenharmony_ci
161562306a36Sopenharmony_ci	/* Mechanism protecting the drv_info_to_mcp */
161662306a36Sopenharmony_ci	struct mutex		drv_info_mutex;
161762306a36Sopenharmony_ci	bool			drv_info_mng_owner;
161862306a36Sopenharmony_ci
161962306a36Sopenharmony_ci	/* Total number of FW statistics requests */
162062306a36Sopenharmony_ci	u8			fw_stats_num;
162162306a36Sopenharmony_ci
162262306a36Sopenharmony_ci	/*
162362306a36Sopenharmony_ci	 * This is a memory buffer that will contain both statistics
162462306a36Sopenharmony_ci	 * ramrod request and data.
162562306a36Sopenharmony_ci	 */
162662306a36Sopenharmony_ci	void			*fw_stats;
162762306a36Sopenharmony_ci	dma_addr_t		fw_stats_mapping;
162862306a36Sopenharmony_ci
162962306a36Sopenharmony_ci	/*
163062306a36Sopenharmony_ci	 * FW statistics request shortcut (points at the
163162306a36Sopenharmony_ci	 * beginning of fw_stats buffer).
163262306a36Sopenharmony_ci	 */
163362306a36Sopenharmony_ci	struct bnx2x_fw_stats_req	*fw_stats_req;
163462306a36Sopenharmony_ci	dma_addr_t			fw_stats_req_mapping;
163562306a36Sopenharmony_ci	int				fw_stats_req_sz;
163662306a36Sopenharmony_ci
163762306a36Sopenharmony_ci	/*
163862306a36Sopenharmony_ci	 * FW statistics data shortcut (points at the beginning of
163962306a36Sopenharmony_ci	 * fw_stats buffer + fw_stats_req_sz).
164062306a36Sopenharmony_ci	 */
164162306a36Sopenharmony_ci	struct bnx2x_fw_stats_data	*fw_stats_data;
164262306a36Sopenharmony_ci	dma_addr_t			fw_stats_data_mapping;
164362306a36Sopenharmony_ci	int				fw_stats_data_sz;
164462306a36Sopenharmony_ci
164562306a36Sopenharmony_ci	/* For max 1024 cids (VF RSS), 32KB ILT page size and 1KB
164662306a36Sopenharmony_ci	 * context size we need 8 ILT entries.
164762306a36Sopenharmony_ci	 */
164862306a36Sopenharmony_ci#define ILT_MAX_L2_LINES	32
164962306a36Sopenharmony_ci	struct hw_context	context[ILT_MAX_L2_LINES];
165062306a36Sopenharmony_ci
165162306a36Sopenharmony_ci	struct bnx2x_ilt	*ilt;
165262306a36Sopenharmony_ci#define BP_ILT(bp)		((bp)->ilt)
165362306a36Sopenharmony_ci#define ILT_MAX_LINES		256
165462306a36Sopenharmony_ci/*
165562306a36Sopenharmony_ci * Maximum supported number of RSS queues: number of IGU SBs minus one that goes
165662306a36Sopenharmony_ci * to CNIC.
165762306a36Sopenharmony_ci */
165862306a36Sopenharmony_ci#define BNX2X_MAX_RSS_COUNT(bp)	((bp)->igu_sb_cnt - CNIC_SUPPORT(bp))
165962306a36Sopenharmony_ci
166062306a36Sopenharmony_ci/*
166162306a36Sopenharmony_ci * Maximum CID count that might be required by the bnx2x:
166262306a36Sopenharmony_ci * Max RSS * Max_Tx_Multi_Cos + FCoE + iSCSI
166362306a36Sopenharmony_ci */
166462306a36Sopenharmony_ci
166562306a36Sopenharmony_ci#define BNX2X_L2_CID_COUNT(bp)	(BNX2X_NUM_ETH_QUEUES(bp) * BNX2X_MULTI_TX_COS \
166662306a36Sopenharmony_ci				+ CNIC_SUPPORT(bp) * (2 + UIO_CID_PAD(bp)))
166762306a36Sopenharmony_ci#define BNX2X_L2_MAX_CID(bp)	(BNX2X_MAX_RSS_COUNT(bp) * BNX2X_MULTI_TX_COS \
166862306a36Sopenharmony_ci				+ CNIC_SUPPORT(bp) * (2 + UIO_CID_PAD(bp)))
166962306a36Sopenharmony_ci#define L2_ILT_LINES(bp)	(DIV_ROUND_UP(BNX2X_L2_CID_COUNT(bp),\
167062306a36Sopenharmony_ci					ILT_PAGE_CIDS))
167162306a36Sopenharmony_ci
167262306a36Sopenharmony_ci	int			qm_cid_count;
167362306a36Sopenharmony_ci
167462306a36Sopenharmony_ci	bool			dropless_fc;
167562306a36Sopenharmony_ci
167662306a36Sopenharmony_ci	void			*t2;
167762306a36Sopenharmony_ci	dma_addr_t		t2_mapping;
167862306a36Sopenharmony_ci	struct cnic_ops	__rcu	*cnic_ops;
167962306a36Sopenharmony_ci	void			*cnic_data;
168062306a36Sopenharmony_ci	u32			cnic_tag;
168162306a36Sopenharmony_ci	struct cnic_eth_dev	cnic_eth_dev;
168262306a36Sopenharmony_ci	union host_hc_status_block cnic_sb;
168362306a36Sopenharmony_ci	dma_addr_t		cnic_sb_mapping;
168462306a36Sopenharmony_ci	struct eth_spe		*cnic_kwq;
168562306a36Sopenharmony_ci	struct eth_spe		*cnic_kwq_prod;
168662306a36Sopenharmony_ci	struct eth_spe		*cnic_kwq_cons;
168762306a36Sopenharmony_ci	struct eth_spe		*cnic_kwq_last;
168862306a36Sopenharmony_ci	u16			cnic_kwq_pending;
168962306a36Sopenharmony_ci	u16			cnic_spq_pending;
169062306a36Sopenharmony_ci	u8			fip_mac[ETH_ALEN];
169162306a36Sopenharmony_ci	struct mutex		cnic_mutex;
169262306a36Sopenharmony_ci	struct bnx2x_vlan_mac_obj iscsi_l2_mac_obj;
169362306a36Sopenharmony_ci
169462306a36Sopenharmony_ci	/* Start index of the "special" (CNIC related) L2 clients */
169562306a36Sopenharmony_ci	u8				cnic_base_cl_id;
169662306a36Sopenharmony_ci
169762306a36Sopenharmony_ci	int			dmae_ready;
169862306a36Sopenharmony_ci	/* used to synchronize dmae accesses */
169962306a36Sopenharmony_ci	spinlock_t		dmae_lock;
170062306a36Sopenharmony_ci
170162306a36Sopenharmony_ci	/* used to protect the FW mail box */
170262306a36Sopenharmony_ci	struct mutex		fw_mb_mutex;
170362306a36Sopenharmony_ci
170462306a36Sopenharmony_ci	/* used to synchronize stats collecting */
170562306a36Sopenharmony_ci	int			stats_state;
170662306a36Sopenharmony_ci
170762306a36Sopenharmony_ci	/* used for synchronization of concurrent threads statistics handling */
170862306a36Sopenharmony_ci	struct semaphore	stats_lock;
170962306a36Sopenharmony_ci
171062306a36Sopenharmony_ci	/* used by dmae command loader */
171162306a36Sopenharmony_ci	struct dmae_command	stats_dmae;
171262306a36Sopenharmony_ci	int			executer_idx;
171362306a36Sopenharmony_ci
171462306a36Sopenharmony_ci	u16			stats_counter;
171562306a36Sopenharmony_ci	struct bnx2x_eth_stats	eth_stats;
171662306a36Sopenharmony_ci	struct host_func_stats		func_stats;
171762306a36Sopenharmony_ci	struct bnx2x_eth_stats_old	eth_stats_old;
171862306a36Sopenharmony_ci	struct bnx2x_net_stats_old	net_stats_old;
171962306a36Sopenharmony_ci	struct bnx2x_fw_port_stats_old	fw_stats_old;
172062306a36Sopenharmony_ci	bool			stats_init;
172162306a36Sopenharmony_ci
172262306a36Sopenharmony_ci	struct z_stream_s	*strm;
172362306a36Sopenharmony_ci	void			*gunzip_buf;
172462306a36Sopenharmony_ci	dma_addr_t		gunzip_mapping;
172562306a36Sopenharmony_ci	int			gunzip_outlen;
172662306a36Sopenharmony_ci#define FW_BUF_SIZE			0x8000
172762306a36Sopenharmony_ci#define GUNZIP_BUF(bp)			(bp->gunzip_buf)
172862306a36Sopenharmony_ci#define GUNZIP_PHYS(bp)			(bp->gunzip_mapping)
172962306a36Sopenharmony_ci#define GUNZIP_OUTLEN(bp)		(bp->gunzip_outlen)
173062306a36Sopenharmony_ci
173162306a36Sopenharmony_ci	struct raw_op		*init_ops;
173262306a36Sopenharmony_ci	/* Init blocks offsets inside init_ops */
173362306a36Sopenharmony_ci	u16			*init_ops_offsets;
173462306a36Sopenharmony_ci	/* Data blob - has 32 bit granularity */
173562306a36Sopenharmony_ci	u32			*init_data;
173662306a36Sopenharmony_ci	u32			init_mode_flags;
173762306a36Sopenharmony_ci#define INIT_MODE_FLAGS(bp)	(bp->init_mode_flags)
173862306a36Sopenharmony_ci	/* Zipped PRAM blobs - raw data */
173962306a36Sopenharmony_ci	const u8		*tsem_int_table_data;
174062306a36Sopenharmony_ci	const u8		*tsem_pram_data;
174162306a36Sopenharmony_ci	const u8		*usem_int_table_data;
174262306a36Sopenharmony_ci	const u8		*usem_pram_data;
174362306a36Sopenharmony_ci	const u8		*xsem_int_table_data;
174462306a36Sopenharmony_ci	const u8		*xsem_pram_data;
174562306a36Sopenharmony_ci	const u8		*csem_int_table_data;
174662306a36Sopenharmony_ci	const u8		*csem_pram_data;
174762306a36Sopenharmony_ci#define INIT_OPS(bp)			(bp->init_ops)
174862306a36Sopenharmony_ci#define INIT_OPS_OFFSETS(bp)		(bp->init_ops_offsets)
174962306a36Sopenharmony_ci#define INIT_DATA(bp)			(bp->init_data)
175062306a36Sopenharmony_ci#define INIT_TSEM_INT_TABLE_DATA(bp)	(bp->tsem_int_table_data)
175162306a36Sopenharmony_ci#define INIT_TSEM_PRAM_DATA(bp)		(bp->tsem_pram_data)
175262306a36Sopenharmony_ci#define INIT_USEM_INT_TABLE_DATA(bp)	(bp->usem_int_table_data)
175362306a36Sopenharmony_ci#define INIT_USEM_PRAM_DATA(bp)		(bp->usem_pram_data)
175462306a36Sopenharmony_ci#define INIT_XSEM_INT_TABLE_DATA(bp)	(bp->xsem_int_table_data)
175562306a36Sopenharmony_ci#define INIT_XSEM_PRAM_DATA(bp)		(bp->xsem_pram_data)
175662306a36Sopenharmony_ci#define INIT_CSEM_INT_TABLE_DATA(bp)	(bp->csem_int_table_data)
175762306a36Sopenharmony_ci#define INIT_CSEM_PRAM_DATA(bp)		(bp->csem_pram_data)
175862306a36Sopenharmony_ci
175962306a36Sopenharmony_ci#define PHY_FW_VER_LEN			20
176062306a36Sopenharmony_ci	char			fw_ver[32];
176162306a36Sopenharmony_ci	const struct firmware	*firmware;
176262306a36Sopenharmony_ci
176362306a36Sopenharmony_ci	struct bnx2x_vfdb	*vfdb;
176462306a36Sopenharmony_ci#define IS_SRIOV(bp)		((bp)->vfdb)
176562306a36Sopenharmony_ci
176662306a36Sopenharmony_ci	/* DCB support on/off */
176762306a36Sopenharmony_ci	u16 dcb_state;
176862306a36Sopenharmony_ci#define BNX2X_DCB_STATE_OFF			0
176962306a36Sopenharmony_ci#define BNX2X_DCB_STATE_ON			1
177062306a36Sopenharmony_ci
177162306a36Sopenharmony_ci	/* DCBX engine mode */
177262306a36Sopenharmony_ci	int dcbx_enabled;
177362306a36Sopenharmony_ci#define BNX2X_DCBX_ENABLED_OFF			0
177462306a36Sopenharmony_ci#define BNX2X_DCBX_ENABLED_ON_NEG_OFF		1
177562306a36Sopenharmony_ci#define BNX2X_DCBX_ENABLED_ON_NEG_ON		2
177662306a36Sopenharmony_ci#define BNX2X_DCBX_ENABLED_INVALID		(-1)
177762306a36Sopenharmony_ci
177862306a36Sopenharmony_ci	bool dcbx_mode_uset;
177962306a36Sopenharmony_ci
178062306a36Sopenharmony_ci	struct bnx2x_config_dcbx_params		dcbx_config_params;
178162306a36Sopenharmony_ci	struct bnx2x_dcbx_port_params		dcbx_port_params;
178262306a36Sopenharmony_ci	int					dcb_version;
178362306a36Sopenharmony_ci
178462306a36Sopenharmony_ci	/* CAM credit pools */
178562306a36Sopenharmony_ci	struct bnx2x_credit_pool_obj		vlans_pool;
178662306a36Sopenharmony_ci
178762306a36Sopenharmony_ci	struct bnx2x_credit_pool_obj		macs_pool;
178862306a36Sopenharmony_ci
178962306a36Sopenharmony_ci	/* RX_MODE object */
179062306a36Sopenharmony_ci	struct bnx2x_rx_mode_obj		rx_mode_obj;
179162306a36Sopenharmony_ci
179262306a36Sopenharmony_ci	/* MCAST object */
179362306a36Sopenharmony_ci	struct bnx2x_mcast_obj			mcast_obj;
179462306a36Sopenharmony_ci
179562306a36Sopenharmony_ci	/* RSS configuration object */
179662306a36Sopenharmony_ci	struct bnx2x_rss_config_obj		rss_conf_obj;
179762306a36Sopenharmony_ci
179862306a36Sopenharmony_ci	/* Function State controlling object */
179962306a36Sopenharmony_ci	struct bnx2x_func_sp_obj		func_obj;
180062306a36Sopenharmony_ci
180162306a36Sopenharmony_ci	unsigned long				sp_state;
180262306a36Sopenharmony_ci
180362306a36Sopenharmony_ci	/* operation indication for the sp_rtnl task */
180462306a36Sopenharmony_ci	unsigned long				sp_rtnl_state;
180562306a36Sopenharmony_ci
180662306a36Sopenharmony_ci	/* Indication of the IOV tasks */
180762306a36Sopenharmony_ci	unsigned long				iov_task_state;
180862306a36Sopenharmony_ci
180962306a36Sopenharmony_ci	/* DCBX Negotiation results */
181062306a36Sopenharmony_ci	struct dcbx_features			dcbx_local_feat;
181162306a36Sopenharmony_ci	u32					dcbx_error;
181262306a36Sopenharmony_ci
181362306a36Sopenharmony_ci#ifdef BCM_DCBNL
181462306a36Sopenharmony_ci	struct dcbx_features			dcbx_remote_feat;
181562306a36Sopenharmony_ci	u32					dcbx_remote_flags;
181662306a36Sopenharmony_ci#endif
181762306a36Sopenharmony_ci	/* AFEX: store default vlan used */
181862306a36Sopenharmony_ci	int					afex_def_vlan_tag;
181962306a36Sopenharmony_ci	enum mf_cfg_afex_vlan_mode		afex_vlan_mode;
182062306a36Sopenharmony_ci	u32					pending_max;
182162306a36Sopenharmony_ci
182262306a36Sopenharmony_ci	/* multiple tx classes of service */
182362306a36Sopenharmony_ci	u8					max_cos;
182462306a36Sopenharmony_ci
182562306a36Sopenharmony_ci	/* priority to cos mapping */
182662306a36Sopenharmony_ci	u8					prio_to_cos[8];
182762306a36Sopenharmony_ci
182862306a36Sopenharmony_ci	int fp_array_size;
182962306a36Sopenharmony_ci	u32 dump_preset_idx;
183062306a36Sopenharmony_ci
183162306a36Sopenharmony_ci	u8					phys_port_id[ETH_ALEN];
183262306a36Sopenharmony_ci
183362306a36Sopenharmony_ci	/* PTP related context */
183462306a36Sopenharmony_ci	struct ptp_clock *ptp_clock;
183562306a36Sopenharmony_ci	struct ptp_clock_info ptp_clock_info;
183662306a36Sopenharmony_ci	struct work_struct ptp_task;
183762306a36Sopenharmony_ci	struct cyclecounter cyclecounter;
183862306a36Sopenharmony_ci	struct timecounter timecounter;
183962306a36Sopenharmony_ci	bool timecounter_init_done;
184062306a36Sopenharmony_ci	struct sk_buff *ptp_tx_skb;
184162306a36Sopenharmony_ci	unsigned long ptp_tx_start;
184262306a36Sopenharmony_ci	bool hwtstamp_ioctl_called;
184362306a36Sopenharmony_ci	u16 tx_type;
184462306a36Sopenharmony_ci	u16 rx_filter;
184562306a36Sopenharmony_ci
184662306a36Sopenharmony_ci	struct bnx2x_link_report_data		vf_link_vars;
184762306a36Sopenharmony_ci	struct list_head vlan_reg;
184862306a36Sopenharmony_ci	u16 vlan_cnt;
184962306a36Sopenharmony_ci	u16 vlan_credit;
185062306a36Sopenharmony_ci	bool accept_any_vlan;
185162306a36Sopenharmony_ci
185262306a36Sopenharmony_ci	/* Vxlan/Geneve related information */
185362306a36Sopenharmony_ci	u16 udp_tunnel_ports[BNX2X_UDP_PORT_MAX];
185462306a36Sopenharmony_ci
185562306a36Sopenharmony_ci#define FW_CAP_INVALIDATE_VF_FP_HSI	BIT(0)
185662306a36Sopenharmony_ci	u32 fw_cap;
185762306a36Sopenharmony_ci
185862306a36Sopenharmony_ci	u32 fw_major;
185962306a36Sopenharmony_ci	u32 fw_minor;
186062306a36Sopenharmony_ci	u32 fw_rev;
186162306a36Sopenharmony_ci	u32 fw_eng;
186262306a36Sopenharmony_ci};
186362306a36Sopenharmony_ci
186462306a36Sopenharmony_ci/* Tx queues may be less or equal to Rx queues */
186562306a36Sopenharmony_ciextern int num_queues;
186662306a36Sopenharmony_ci#define BNX2X_NUM_QUEUES(bp)	(bp->num_queues)
186762306a36Sopenharmony_ci#define BNX2X_NUM_ETH_QUEUES(bp) ((bp)->num_ethernet_queues)
186862306a36Sopenharmony_ci#define BNX2X_NUM_NON_CNIC_QUEUES(bp)	(BNX2X_NUM_QUEUES(bp) - \
186962306a36Sopenharmony_ci					 (bp)->num_cnic_queues)
187062306a36Sopenharmony_ci#define BNX2X_NUM_RX_QUEUES(bp)	BNX2X_NUM_QUEUES(bp)
187162306a36Sopenharmony_ci
187262306a36Sopenharmony_ci#define is_multi(bp)		(BNX2X_NUM_QUEUES(bp) > 1)
187362306a36Sopenharmony_ci
187462306a36Sopenharmony_ci#define BNX2X_MAX_QUEUES(bp)	BNX2X_MAX_RSS_COUNT(bp)
187562306a36Sopenharmony_ci/* #define is_eth_multi(bp)	(BNX2X_NUM_ETH_QUEUES(bp) > 1) */
187662306a36Sopenharmony_ci
187762306a36Sopenharmony_ci#define RSS_IPV4_CAP_MASK						\
187862306a36Sopenharmony_ci	TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV4_CAPABILITY
187962306a36Sopenharmony_ci
188062306a36Sopenharmony_ci#define RSS_IPV4_TCP_CAP_MASK						\
188162306a36Sopenharmony_ci	TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV4_TCP_CAPABILITY
188262306a36Sopenharmony_ci
188362306a36Sopenharmony_ci#define RSS_IPV6_CAP_MASK						\
188462306a36Sopenharmony_ci	TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_CAPABILITY
188562306a36Sopenharmony_ci
188662306a36Sopenharmony_ci#define RSS_IPV6_TCP_CAP_MASK						\
188762306a36Sopenharmony_ci	TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_TCP_CAPABILITY
188862306a36Sopenharmony_ci
188962306a36Sopenharmony_cistruct bnx2x_func_init_params {
189062306a36Sopenharmony_ci	/* dma */
189162306a36Sopenharmony_ci	bool		spq_active;
189262306a36Sopenharmony_ci	dma_addr_t	spq_map;
189362306a36Sopenharmony_ci	u16		spq_prod;
189462306a36Sopenharmony_ci
189562306a36Sopenharmony_ci	u16		func_id;	/* abs fid */
189662306a36Sopenharmony_ci	u16		pf_id;
189762306a36Sopenharmony_ci};
189862306a36Sopenharmony_ci
189962306a36Sopenharmony_ci#define for_each_cnic_queue(bp, var) \
190062306a36Sopenharmony_ci	for ((var) = BNX2X_NUM_ETH_QUEUES(bp); (var) < BNX2X_NUM_QUEUES(bp); \
190162306a36Sopenharmony_ci	     (var)++) \
190262306a36Sopenharmony_ci		if (skip_queue(bp, var))	\
190362306a36Sopenharmony_ci			continue;		\
190462306a36Sopenharmony_ci		else
190562306a36Sopenharmony_ci
190662306a36Sopenharmony_ci#define for_each_eth_queue(bp, var) \
190762306a36Sopenharmony_ci	for ((var) = 0; (var) < BNX2X_NUM_ETH_QUEUES(bp); (var)++)
190862306a36Sopenharmony_ci
190962306a36Sopenharmony_ci#define for_each_nondefault_eth_queue(bp, var) \
191062306a36Sopenharmony_ci	for ((var) = 1; (var) < BNX2X_NUM_ETH_QUEUES(bp); (var)++)
191162306a36Sopenharmony_ci
191262306a36Sopenharmony_ci#define for_each_queue(bp, var) \
191362306a36Sopenharmony_ci	for ((var) = 0; (var) < BNX2X_NUM_QUEUES(bp); (var)++) \
191462306a36Sopenharmony_ci		if (skip_queue(bp, var))	\
191562306a36Sopenharmony_ci			continue;		\
191662306a36Sopenharmony_ci		else
191762306a36Sopenharmony_ci
191862306a36Sopenharmony_ci/* Skip forwarding FP */
191962306a36Sopenharmony_ci#define for_each_valid_rx_queue(bp, var)			\
192062306a36Sopenharmony_ci	for ((var) = 0;						\
192162306a36Sopenharmony_ci	     (var) < (CNIC_LOADED(bp) ? BNX2X_NUM_QUEUES(bp) :	\
192262306a36Sopenharmony_ci		      BNX2X_NUM_ETH_QUEUES(bp));		\
192362306a36Sopenharmony_ci	     (var)++)						\
192462306a36Sopenharmony_ci		if (skip_rx_queue(bp, var))			\
192562306a36Sopenharmony_ci			continue;				\
192662306a36Sopenharmony_ci		else
192762306a36Sopenharmony_ci
192862306a36Sopenharmony_ci#define for_each_rx_queue_cnic(bp, var) \
192962306a36Sopenharmony_ci	for ((var) = BNX2X_NUM_ETH_QUEUES(bp); (var) < BNX2X_NUM_QUEUES(bp); \
193062306a36Sopenharmony_ci	     (var)++) \
193162306a36Sopenharmony_ci		if (skip_rx_queue(bp, var))	\
193262306a36Sopenharmony_ci			continue;		\
193362306a36Sopenharmony_ci		else
193462306a36Sopenharmony_ci
193562306a36Sopenharmony_ci#define for_each_rx_queue(bp, var) \
193662306a36Sopenharmony_ci	for ((var) = 0; (var) < BNX2X_NUM_QUEUES(bp); (var)++) \
193762306a36Sopenharmony_ci		if (skip_rx_queue(bp, var))	\
193862306a36Sopenharmony_ci			continue;		\
193962306a36Sopenharmony_ci		else
194062306a36Sopenharmony_ci
194162306a36Sopenharmony_ci/* Skip OOO FP */
194262306a36Sopenharmony_ci#define for_each_valid_tx_queue(bp, var)			\
194362306a36Sopenharmony_ci	for ((var) = 0;						\
194462306a36Sopenharmony_ci	     (var) < (CNIC_LOADED(bp) ? BNX2X_NUM_QUEUES(bp) :	\
194562306a36Sopenharmony_ci		      BNX2X_NUM_ETH_QUEUES(bp));		\
194662306a36Sopenharmony_ci	     (var)++)						\
194762306a36Sopenharmony_ci		if (skip_tx_queue(bp, var))			\
194862306a36Sopenharmony_ci			continue;				\
194962306a36Sopenharmony_ci		else
195062306a36Sopenharmony_ci
195162306a36Sopenharmony_ci#define for_each_tx_queue_cnic(bp, var) \
195262306a36Sopenharmony_ci	for ((var) = BNX2X_NUM_ETH_QUEUES(bp); (var) < BNX2X_NUM_QUEUES(bp); \
195362306a36Sopenharmony_ci	     (var)++) \
195462306a36Sopenharmony_ci		if (skip_tx_queue(bp, var))	\
195562306a36Sopenharmony_ci			continue;		\
195662306a36Sopenharmony_ci		else
195762306a36Sopenharmony_ci
195862306a36Sopenharmony_ci#define for_each_tx_queue(bp, var) \
195962306a36Sopenharmony_ci	for ((var) = 0; (var) < BNX2X_NUM_QUEUES(bp); (var)++) \
196062306a36Sopenharmony_ci		if (skip_tx_queue(bp, var))	\
196162306a36Sopenharmony_ci			continue;		\
196262306a36Sopenharmony_ci		else
196362306a36Sopenharmony_ci
196462306a36Sopenharmony_ci#define for_each_nondefault_queue(bp, var) \
196562306a36Sopenharmony_ci	for ((var) = 1; (var) < BNX2X_NUM_QUEUES(bp); (var)++) \
196662306a36Sopenharmony_ci		if (skip_queue(bp, var))	\
196762306a36Sopenharmony_ci			continue;		\
196862306a36Sopenharmony_ci		else
196962306a36Sopenharmony_ci
197062306a36Sopenharmony_ci#define for_each_cos_in_tx_queue(fp, var) \
197162306a36Sopenharmony_ci	for ((var) = 0; (var) < (fp)->max_cos; (var)++)
197262306a36Sopenharmony_ci
197362306a36Sopenharmony_ci/* skip rx queue
197462306a36Sopenharmony_ci * if FCOE l2 support is disabled and this is the fcoe L2 queue
197562306a36Sopenharmony_ci */
197662306a36Sopenharmony_ci#define skip_rx_queue(bp, idx)	(NO_FCOE(bp) && IS_FCOE_IDX(idx))
197762306a36Sopenharmony_ci
197862306a36Sopenharmony_ci/* skip tx queue
197962306a36Sopenharmony_ci * if FCOE l2 support is disabled and this is the fcoe L2 queue
198062306a36Sopenharmony_ci */
198162306a36Sopenharmony_ci#define skip_tx_queue(bp, idx)	(NO_FCOE(bp) && IS_FCOE_IDX(idx))
198262306a36Sopenharmony_ci
198362306a36Sopenharmony_ci#define skip_queue(bp, idx)	(NO_FCOE(bp) && IS_FCOE_IDX(idx))
198462306a36Sopenharmony_ci
198562306a36Sopenharmony_ci/*self test*/
198662306a36Sopenharmony_ciint bnx2x_idle_chk(struct bnx2x *bp);
198762306a36Sopenharmony_ci
198862306a36Sopenharmony_ci/**
198962306a36Sopenharmony_ci * bnx2x_set_mac_one - configure a single MAC address
199062306a36Sopenharmony_ci *
199162306a36Sopenharmony_ci * @bp:			driver handle
199262306a36Sopenharmony_ci * @mac:		MAC to configure
199362306a36Sopenharmony_ci * @obj:		MAC object handle
199462306a36Sopenharmony_ci * @set:		if 'true' add a new MAC, otherwise - delete
199562306a36Sopenharmony_ci * @mac_type:		the type of the MAC to configure (e.g. ETH, UC list)
199662306a36Sopenharmony_ci * @ramrod_flags:	RAMROD_XXX flags (e.g. RAMROD_CONT, RAMROD_COMP_WAIT)
199762306a36Sopenharmony_ci *
199862306a36Sopenharmony_ci * Configures one MAC according to provided parameters or continues the
199962306a36Sopenharmony_ci * execution of previously scheduled commands if RAMROD_CONT is set in
200062306a36Sopenharmony_ci * ramrod_flags.
200162306a36Sopenharmony_ci *
200262306a36Sopenharmony_ci * Returns zero if operation has successfully completed, a positive value if the
200362306a36Sopenharmony_ci * operation has been successfully scheduled and a negative - if a requested
200462306a36Sopenharmony_ci * operations has failed.
200562306a36Sopenharmony_ci */
200662306a36Sopenharmony_ciint bnx2x_set_mac_one(struct bnx2x *bp, const u8 *mac,
200762306a36Sopenharmony_ci		      struct bnx2x_vlan_mac_obj *obj, bool set,
200862306a36Sopenharmony_ci		      int mac_type, unsigned long *ramrod_flags);
200962306a36Sopenharmony_ci
201062306a36Sopenharmony_ciint bnx2x_set_vlan_one(struct bnx2x *bp, u16 vlan,
201162306a36Sopenharmony_ci		       struct bnx2x_vlan_mac_obj *obj, bool set,
201262306a36Sopenharmony_ci		       unsigned long *ramrod_flags);
201362306a36Sopenharmony_ci
201462306a36Sopenharmony_ci/**
201562306a36Sopenharmony_ci * bnx2x_del_all_macs - delete all MACs configured for the specific MAC object
201662306a36Sopenharmony_ci *
201762306a36Sopenharmony_ci * @bp:			driver handle
201862306a36Sopenharmony_ci * @mac_obj:		MAC object handle
201962306a36Sopenharmony_ci * @mac_type:		type of the MACs to clear (BNX2X_XXX_MAC)
202062306a36Sopenharmony_ci * @wait_for_comp:	if 'true' block until completion
202162306a36Sopenharmony_ci *
202262306a36Sopenharmony_ci * Deletes all MACs of the specific type (e.g. ETH, UC list).
202362306a36Sopenharmony_ci *
202462306a36Sopenharmony_ci * Returns zero if operation has successfully completed, a positive value if the
202562306a36Sopenharmony_ci * operation has been successfully scheduled and a negative - if a requested
202662306a36Sopenharmony_ci * operations has failed.
202762306a36Sopenharmony_ci */
202862306a36Sopenharmony_ciint bnx2x_del_all_macs(struct bnx2x *bp,
202962306a36Sopenharmony_ci		       struct bnx2x_vlan_mac_obj *mac_obj,
203062306a36Sopenharmony_ci		       int mac_type, bool wait_for_comp);
203162306a36Sopenharmony_ci
203262306a36Sopenharmony_ci/* Init Function API  */
203362306a36Sopenharmony_civoid bnx2x_func_init(struct bnx2x *bp, struct bnx2x_func_init_params *p);
203462306a36Sopenharmony_civoid bnx2x_init_sb(struct bnx2x *bp, dma_addr_t mapping, int vfid,
203562306a36Sopenharmony_ci		    u8 vf_valid, int fw_sb_id, int igu_sb_id);
203662306a36Sopenharmony_ciint bnx2x_get_gpio(struct bnx2x *bp, int gpio_num, u8 port);
203762306a36Sopenharmony_ciint bnx2x_set_gpio(struct bnx2x *bp, int gpio_num, u32 mode, u8 port);
203862306a36Sopenharmony_ciint bnx2x_set_mult_gpio(struct bnx2x *bp, u8 pins, u32 mode);
203962306a36Sopenharmony_ciint bnx2x_set_gpio_int(struct bnx2x *bp, int gpio_num, u32 mode, u8 port);
204062306a36Sopenharmony_civoid bnx2x_read_mf_cfg(struct bnx2x *bp);
204162306a36Sopenharmony_ci
204262306a36Sopenharmony_ciint bnx2x_pretend_func(struct bnx2x *bp, u16 pretend_func_val);
204362306a36Sopenharmony_ci
204462306a36Sopenharmony_ci/* dmae */
204562306a36Sopenharmony_civoid bnx2x_read_dmae(struct bnx2x *bp, u32 src_addr, u32 len32);
204662306a36Sopenharmony_civoid bnx2x_write_dmae(struct bnx2x *bp, dma_addr_t dma_addr, u32 dst_addr,
204762306a36Sopenharmony_ci		      u32 len32);
204862306a36Sopenharmony_civoid bnx2x_post_dmae(struct bnx2x *bp, struct dmae_command *dmae, int idx);
204962306a36Sopenharmony_ciu32 bnx2x_dmae_opcode_add_comp(u32 opcode, u8 comp_type);
205062306a36Sopenharmony_ciu32 bnx2x_dmae_opcode_clr_src_reset(u32 opcode);
205162306a36Sopenharmony_ciu32 bnx2x_dmae_opcode(struct bnx2x *bp, u8 src_type, u8 dst_type,
205262306a36Sopenharmony_ci		      bool with_comp, u8 comp_type);
205362306a36Sopenharmony_ci
205462306a36Sopenharmony_civoid bnx2x_prep_dmae_with_comp(struct bnx2x *bp, struct dmae_command *dmae,
205562306a36Sopenharmony_ci			       u8 src_type, u8 dst_type);
205662306a36Sopenharmony_ciint bnx2x_issue_dmae_with_comp(struct bnx2x *bp, struct dmae_command *dmae,
205762306a36Sopenharmony_ci			       u32 *comp);
205862306a36Sopenharmony_ci
205962306a36Sopenharmony_ci/* FLR related routines */
206062306a36Sopenharmony_ciu32 bnx2x_flr_clnup_poll_count(struct bnx2x *bp);
206162306a36Sopenharmony_civoid bnx2x_tx_hw_flushed(struct bnx2x *bp, u32 poll_count);
206262306a36Sopenharmony_ciint bnx2x_send_final_clnup(struct bnx2x *bp, u8 clnup_func, u32 poll_cnt);
206362306a36Sopenharmony_ciu8 bnx2x_is_pcie_pending(struct pci_dev *dev);
206462306a36Sopenharmony_ciint bnx2x_flr_clnup_poll_hw_counter(struct bnx2x *bp, u32 reg,
206562306a36Sopenharmony_ci				    char *msg, u32 poll_cnt);
206662306a36Sopenharmony_ci
206762306a36Sopenharmony_civoid bnx2x_calc_fc_adv(struct bnx2x *bp);
206862306a36Sopenharmony_ciint bnx2x_sp_post(struct bnx2x *bp, int command, int cid,
206962306a36Sopenharmony_ci		  u32 data_hi, u32 data_lo, int cmd_type);
207062306a36Sopenharmony_civoid bnx2x_update_coalesce(struct bnx2x *bp);
207162306a36Sopenharmony_ciint bnx2x_get_cur_phy_idx(struct bnx2x *bp);
207262306a36Sopenharmony_ci
207362306a36Sopenharmony_cibool bnx2x_port_after_undi(struct bnx2x *bp);
207462306a36Sopenharmony_ci
207562306a36Sopenharmony_cistatic inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms,
207662306a36Sopenharmony_ci			   int wait)
207762306a36Sopenharmony_ci{
207862306a36Sopenharmony_ci	u32 val;
207962306a36Sopenharmony_ci
208062306a36Sopenharmony_ci	do {
208162306a36Sopenharmony_ci		val = REG_RD(bp, reg);
208262306a36Sopenharmony_ci		if (val == expected)
208362306a36Sopenharmony_ci			break;
208462306a36Sopenharmony_ci		ms -= wait;
208562306a36Sopenharmony_ci		msleep(wait);
208662306a36Sopenharmony_ci
208762306a36Sopenharmony_ci	} while (ms > 0);
208862306a36Sopenharmony_ci
208962306a36Sopenharmony_ci	return val;
209062306a36Sopenharmony_ci}
209162306a36Sopenharmony_ci
209262306a36Sopenharmony_civoid bnx2x_igu_clear_sb_gen(struct bnx2x *bp, u8 func, u8 idu_sb_id,
209362306a36Sopenharmony_ci			    bool is_pf);
209462306a36Sopenharmony_ci
209562306a36Sopenharmony_ci#define BNX2X_ILT_ZALLOC(x, y, size)					\
209662306a36Sopenharmony_ci	x = dma_alloc_coherent(&bp->pdev->dev, size, y, GFP_KERNEL)
209762306a36Sopenharmony_ci
209862306a36Sopenharmony_ci#define BNX2X_ILT_FREE(x, y, size) \
209962306a36Sopenharmony_ci	do { \
210062306a36Sopenharmony_ci		if (x) { \
210162306a36Sopenharmony_ci			dma_free_coherent(&bp->pdev->dev, size, x, y); \
210262306a36Sopenharmony_ci			x = NULL; \
210362306a36Sopenharmony_ci			y = 0; \
210462306a36Sopenharmony_ci		} \
210562306a36Sopenharmony_ci	} while (0)
210662306a36Sopenharmony_ci
210762306a36Sopenharmony_ci#define ILOG2(x)	(ilog2((x)))
210862306a36Sopenharmony_ci
210962306a36Sopenharmony_ci#define ILT_NUM_PAGE_ENTRIES	(3072)
211062306a36Sopenharmony_ci/* In 57710/11 we use whole table since we have 8 func
211162306a36Sopenharmony_ci * In 57712 we have only 4 func, but use same size per func, then only half of
211262306a36Sopenharmony_ci * the table in use
211362306a36Sopenharmony_ci */
211462306a36Sopenharmony_ci#define ILT_PER_FUNC		(ILT_NUM_PAGE_ENTRIES/8)
211562306a36Sopenharmony_ci
211662306a36Sopenharmony_ci#define FUNC_ILT_BASE(func)	(func * ILT_PER_FUNC)
211762306a36Sopenharmony_ci/*
211862306a36Sopenharmony_ci * the phys address is shifted right 12 bits and has an added
211962306a36Sopenharmony_ci * 1=valid bit added to the 53rd bit
212062306a36Sopenharmony_ci * then since this is a wide register(TM)
212162306a36Sopenharmony_ci * we split it into two 32 bit writes
212262306a36Sopenharmony_ci */
212362306a36Sopenharmony_ci#define ONCHIP_ADDR1(x)		((u32)(((u64)x >> 12) & 0xFFFFFFFF))
212462306a36Sopenharmony_ci#define ONCHIP_ADDR2(x)		((u32)((1 << 20) | ((u64)x >> 44)))
212562306a36Sopenharmony_ci
212662306a36Sopenharmony_ci/* load/unload mode */
212762306a36Sopenharmony_ci#define LOAD_NORMAL			0
212862306a36Sopenharmony_ci#define LOAD_OPEN			1
212962306a36Sopenharmony_ci#define LOAD_DIAG			2
213062306a36Sopenharmony_ci#define LOAD_LOOPBACK_EXT		3
213162306a36Sopenharmony_ci#define UNLOAD_NORMAL			0
213262306a36Sopenharmony_ci#define UNLOAD_CLOSE			1
213362306a36Sopenharmony_ci#define UNLOAD_RECOVERY			2
213462306a36Sopenharmony_ci
213562306a36Sopenharmony_ci/* DMAE command defines */
213662306a36Sopenharmony_ci#define DMAE_TIMEOUT			-1
213762306a36Sopenharmony_ci#define DMAE_PCI_ERROR			-2	/* E2 and onward */
213862306a36Sopenharmony_ci#define DMAE_NOT_RDY			-3
213962306a36Sopenharmony_ci#define DMAE_PCI_ERR_FLAG		0x80000000
214062306a36Sopenharmony_ci
214162306a36Sopenharmony_ci#define DMAE_SRC_PCI			0
214262306a36Sopenharmony_ci#define DMAE_SRC_GRC			1
214362306a36Sopenharmony_ci
214462306a36Sopenharmony_ci#define DMAE_DST_NONE			0
214562306a36Sopenharmony_ci#define DMAE_DST_PCI			1
214662306a36Sopenharmony_ci#define DMAE_DST_GRC			2
214762306a36Sopenharmony_ci
214862306a36Sopenharmony_ci#define DMAE_COMP_PCI			0
214962306a36Sopenharmony_ci#define DMAE_COMP_GRC			1
215062306a36Sopenharmony_ci
215162306a36Sopenharmony_ci/* E2 and onward - PCI error handling in the completion */
215262306a36Sopenharmony_ci
215362306a36Sopenharmony_ci#define DMAE_COMP_REGULAR		0
215462306a36Sopenharmony_ci#define DMAE_COM_SET_ERR		1
215562306a36Sopenharmony_ci
215662306a36Sopenharmony_ci#define DMAE_CMD_SRC_PCI		(DMAE_SRC_PCI << \
215762306a36Sopenharmony_ci						DMAE_COMMAND_SRC_SHIFT)
215862306a36Sopenharmony_ci#define DMAE_CMD_SRC_GRC		(DMAE_SRC_GRC << \
215962306a36Sopenharmony_ci						DMAE_COMMAND_SRC_SHIFT)
216062306a36Sopenharmony_ci
216162306a36Sopenharmony_ci#define DMAE_CMD_DST_PCI		(DMAE_DST_PCI << \
216262306a36Sopenharmony_ci						DMAE_COMMAND_DST_SHIFT)
216362306a36Sopenharmony_ci#define DMAE_CMD_DST_GRC		(DMAE_DST_GRC << \
216462306a36Sopenharmony_ci						DMAE_COMMAND_DST_SHIFT)
216562306a36Sopenharmony_ci
216662306a36Sopenharmony_ci#define DMAE_CMD_C_DST_PCI		(DMAE_COMP_PCI << \
216762306a36Sopenharmony_ci						DMAE_COMMAND_C_DST_SHIFT)
216862306a36Sopenharmony_ci#define DMAE_CMD_C_DST_GRC		(DMAE_COMP_GRC << \
216962306a36Sopenharmony_ci						DMAE_COMMAND_C_DST_SHIFT)
217062306a36Sopenharmony_ci
217162306a36Sopenharmony_ci#define DMAE_CMD_C_ENABLE		DMAE_COMMAND_C_TYPE_ENABLE
217262306a36Sopenharmony_ci
217362306a36Sopenharmony_ci#define DMAE_CMD_ENDIANITY_NO_SWAP	(0 << DMAE_COMMAND_ENDIANITY_SHIFT)
217462306a36Sopenharmony_ci#define DMAE_CMD_ENDIANITY_B_SWAP	(1 << DMAE_COMMAND_ENDIANITY_SHIFT)
217562306a36Sopenharmony_ci#define DMAE_CMD_ENDIANITY_DW_SWAP	(2 << DMAE_COMMAND_ENDIANITY_SHIFT)
217662306a36Sopenharmony_ci#define DMAE_CMD_ENDIANITY_B_DW_SWAP	(3 << DMAE_COMMAND_ENDIANITY_SHIFT)
217762306a36Sopenharmony_ci
217862306a36Sopenharmony_ci#define DMAE_CMD_PORT_0			0
217962306a36Sopenharmony_ci#define DMAE_CMD_PORT_1			DMAE_COMMAND_PORT
218062306a36Sopenharmony_ci
218162306a36Sopenharmony_ci#define DMAE_CMD_SRC_RESET		DMAE_COMMAND_SRC_RESET
218262306a36Sopenharmony_ci#define DMAE_CMD_DST_RESET		DMAE_COMMAND_DST_RESET
218362306a36Sopenharmony_ci#define DMAE_CMD_E1HVN_SHIFT		DMAE_COMMAND_E1HVN_SHIFT
218462306a36Sopenharmony_ci
218562306a36Sopenharmony_ci#define DMAE_SRC_PF			0
218662306a36Sopenharmony_ci#define DMAE_SRC_VF			1
218762306a36Sopenharmony_ci
218862306a36Sopenharmony_ci#define DMAE_DST_PF			0
218962306a36Sopenharmony_ci#define DMAE_DST_VF			1
219062306a36Sopenharmony_ci
219162306a36Sopenharmony_ci#define DMAE_C_SRC			0
219262306a36Sopenharmony_ci#define DMAE_C_DST			1
219362306a36Sopenharmony_ci
219462306a36Sopenharmony_ci#define DMAE_LEN32_RD_MAX		0x80
219562306a36Sopenharmony_ci#define DMAE_LEN32_WR_MAX(bp)		(CHIP_IS_E1(bp) ? 0x400 : 0x2000)
219662306a36Sopenharmony_ci
219762306a36Sopenharmony_ci#define DMAE_COMP_VAL			0x60d0d0ae /* E2 and on - upper bit
219862306a36Sopenharmony_ci						    * indicates error
219962306a36Sopenharmony_ci						    */
220062306a36Sopenharmony_ci
220162306a36Sopenharmony_ci#define MAX_DMAE_C_PER_PORT		8
220262306a36Sopenharmony_ci#define INIT_DMAE_C(bp)			(BP_PORT(bp) * MAX_DMAE_C_PER_PORT + \
220362306a36Sopenharmony_ci					 BP_VN(bp))
220462306a36Sopenharmony_ci#define PMF_DMAE_C(bp)			(BP_PORT(bp) * MAX_DMAE_C_PER_PORT + \
220562306a36Sopenharmony_ci					 E1HVN_MAX)
220662306a36Sopenharmony_ci
220762306a36Sopenharmony_ci/* Following is the DMAE channel number allocation for the clients.
220862306a36Sopenharmony_ci *   MFW: OCBB/OCSD implementations use DMAE channels 14/15 respectively.
220962306a36Sopenharmony_ci *   Driver: 0-3 and 8-11 (for PF dmae operations)
221062306a36Sopenharmony_ci *           4 and 12 (for stats requests)
221162306a36Sopenharmony_ci */
221262306a36Sopenharmony_ci#define BNX2X_FW_DMAE_C                 13 /* Channel for FW DMAE operations */
221362306a36Sopenharmony_ci
221462306a36Sopenharmony_ci/* PCIE link and speed */
221562306a36Sopenharmony_ci#define PCICFG_LINK_WIDTH		0x1f00000
221662306a36Sopenharmony_ci#define PCICFG_LINK_WIDTH_SHIFT		20
221762306a36Sopenharmony_ci#define PCICFG_LINK_SPEED		0xf0000
221862306a36Sopenharmony_ci#define PCICFG_LINK_SPEED_SHIFT		16
221962306a36Sopenharmony_ci
222062306a36Sopenharmony_ci#define BNX2X_NUM_TESTS_SF		7
222162306a36Sopenharmony_ci#define BNX2X_NUM_TESTS_MF		3
222262306a36Sopenharmony_ci#define BNX2X_NUM_TESTS(bp)		(IS_MF(bp) ? BNX2X_NUM_TESTS_MF : \
222362306a36Sopenharmony_ci					     IS_VF(bp) ? 0 : BNX2X_NUM_TESTS_SF)
222462306a36Sopenharmony_ci
222562306a36Sopenharmony_ci#define BNX2X_PHY_LOOPBACK		0
222662306a36Sopenharmony_ci#define BNX2X_MAC_LOOPBACK		1
222762306a36Sopenharmony_ci#define BNX2X_EXT_LOOPBACK		2
222862306a36Sopenharmony_ci#define BNX2X_PHY_LOOPBACK_FAILED	1
222962306a36Sopenharmony_ci#define BNX2X_MAC_LOOPBACK_FAILED	2
223062306a36Sopenharmony_ci#define BNX2X_EXT_LOOPBACK_FAILED	3
223162306a36Sopenharmony_ci#define BNX2X_LOOPBACK_FAILED		(BNX2X_MAC_LOOPBACK_FAILED | \
223262306a36Sopenharmony_ci					 BNX2X_PHY_LOOPBACK_FAILED)
223362306a36Sopenharmony_ci
223462306a36Sopenharmony_ci#define STROM_ASSERT_ARRAY_SIZE		50
223562306a36Sopenharmony_ci
223662306a36Sopenharmony_ci/* must be used on a CID before placing it on a HW ring */
223762306a36Sopenharmony_ci#define HW_CID(bp, x)			((BP_PORT(bp) << 23) | \
223862306a36Sopenharmony_ci					 (BP_VN(bp) << BNX2X_SWCID_SHIFT) | \
223962306a36Sopenharmony_ci					 (x))
224062306a36Sopenharmony_ci
224162306a36Sopenharmony_ci#define SP_DESC_CNT		(BCM_PAGE_SIZE / sizeof(struct eth_spe))
224262306a36Sopenharmony_ci#define MAX_SP_DESC_CNT			(SP_DESC_CNT - 1)
224362306a36Sopenharmony_ci
224462306a36Sopenharmony_ci#define BNX2X_BTR			4
224562306a36Sopenharmony_ci#define MAX_SPQ_PENDING			8
224662306a36Sopenharmony_ci
224762306a36Sopenharmony_ci/* CMNG constants, as derived from system spec calculations */
224862306a36Sopenharmony_ci/* default MIN rate in case VNIC min rate is configured to zero - 100Mbps */
224962306a36Sopenharmony_ci#define DEF_MIN_RATE					100
225062306a36Sopenharmony_ci/* resolution of the rate shaping timer - 400 usec */
225162306a36Sopenharmony_ci#define RS_PERIODIC_TIMEOUT_USEC			400
225262306a36Sopenharmony_ci/* number of bytes in single QM arbitration cycle -
225362306a36Sopenharmony_ci * coefficient for calculating the fairness timer */
225462306a36Sopenharmony_ci#define QM_ARB_BYTES					160000
225562306a36Sopenharmony_ci/* resolution of Min algorithm 1:100 */
225662306a36Sopenharmony_ci#define MIN_RES						100
225762306a36Sopenharmony_ci/* how many bytes above threshold for the minimal credit of Min algorithm*/
225862306a36Sopenharmony_ci#define MIN_ABOVE_THRESH				32768
225962306a36Sopenharmony_ci/* Fairness algorithm integration time coefficient -
226062306a36Sopenharmony_ci * for calculating the actual Tfair */
226162306a36Sopenharmony_ci#define T_FAIR_COEF	((MIN_ABOVE_THRESH +  QM_ARB_BYTES) * 8 * MIN_RES)
226262306a36Sopenharmony_ci/* Memory of fairness algorithm . 2 cycles */
226362306a36Sopenharmony_ci#define FAIR_MEM					2
226462306a36Sopenharmony_ci
226562306a36Sopenharmony_ci#define ATTN_NIG_FOR_FUNC		(1L << 8)
226662306a36Sopenharmony_ci#define ATTN_SW_TIMER_4_FUNC		(1L << 9)
226762306a36Sopenharmony_ci#define GPIO_2_FUNC			(1L << 10)
226862306a36Sopenharmony_ci#define GPIO_3_FUNC			(1L << 11)
226962306a36Sopenharmony_ci#define GPIO_4_FUNC			(1L << 12)
227062306a36Sopenharmony_ci#define ATTN_GENERAL_ATTN_1		(1L << 13)
227162306a36Sopenharmony_ci#define ATTN_GENERAL_ATTN_2		(1L << 14)
227262306a36Sopenharmony_ci#define ATTN_GENERAL_ATTN_3		(1L << 15)
227362306a36Sopenharmony_ci#define ATTN_GENERAL_ATTN_4		(1L << 13)
227462306a36Sopenharmony_ci#define ATTN_GENERAL_ATTN_5		(1L << 14)
227562306a36Sopenharmony_ci#define ATTN_GENERAL_ATTN_6		(1L << 15)
227662306a36Sopenharmony_ci
227762306a36Sopenharmony_ci#define ATTN_HARD_WIRED_MASK		0xff00
227862306a36Sopenharmony_ci#define ATTENTION_ID			4
227962306a36Sopenharmony_ci
228062306a36Sopenharmony_ci#define IS_MF_STORAGE_ONLY(bp) (IS_MF_STORAGE_PERSONALITY_ONLY(bp) || \
228162306a36Sopenharmony_ci				 IS_MF_FCOE_AFEX(bp))
228262306a36Sopenharmony_ci
228362306a36Sopenharmony_ci/* stuff added to make the code fit 80Col */
228462306a36Sopenharmony_ci
228562306a36Sopenharmony_ci#define BNX2X_PMF_LINK_ASSERT \
228662306a36Sopenharmony_ci	GENERAL_ATTEN_OFFSET(LINK_SYNC_ATTENTION_BIT_FUNC_0 + BP_FUNC(bp))
228762306a36Sopenharmony_ci
228862306a36Sopenharmony_ci#define BNX2X_MC_ASSERT_BITS \
228962306a36Sopenharmony_ci	(GENERAL_ATTEN_OFFSET(TSTORM_FATAL_ASSERT_ATTENTION_BIT) | \
229062306a36Sopenharmony_ci	 GENERAL_ATTEN_OFFSET(USTORM_FATAL_ASSERT_ATTENTION_BIT) | \
229162306a36Sopenharmony_ci	 GENERAL_ATTEN_OFFSET(CSTORM_FATAL_ASSERT_ATTENTION_BIT) | \
229262306a36Sopenharmony_ci	 GENERAL_ATTEN_OFFSET(XSTORM_FATAL_ASSERT_ATTENTION_BIT))
229362306a36Sopenharmony_ci
229462306a36Sopenharmony_ci#define BNX2X_MCP_ASSERT \
229562306a36Sopenharmony_ci	GENERAL_ATTEN_OFFSET(MCP_FATAL_ASSERT_ATTENTION_BIT)
229662306a36Sopenharmony_ci
229762306a36Sopenharmony_ci#define BNX2X_GRC_TIMEOUT	GENERAL_ATTEN_OFFSET(LATCHED_ATTN_TIMEOUT_GRC)
229862306a36Sopenharmony_ci#define BNX2X_GRC_RSV		(GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCR) | \
229962306a36Sopenharmony_ci				 GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCT) | \
230062306a36Sopenharmony_ci				 GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCN) | \
230162306a36Sopenharmony_ci				 GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCU) | \
230262306a36Sopenharmony_ci				 GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCP) | \
230362306a36Sopenharmony_ci				 GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RSVD_GRC))
230462306a36Sopenharmony_ci
230562306a36Sopenharmony_ci#define HW_INTERRUPT_ASSERT_SET_0 \
230662306a36Sopenharmony_ci				(AEU_INPUTS_ATTN_BITS_TSDM_HW_INTERRUPT | \
230762306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_TCM_HW_INTERRUPT | \
230862306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_TSEMI_HW_INTERRUPT | \
230962306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_BRB_HW_INTERRUPT | \
231062306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_PBCLIENT_HW_INTERRUPT)
231162306a36Sopenharmony_ci#define HW_PRTY_ASSERT_SET_0	(AEU_INPUTS_ATTN_BITS_BRB_PARITY_ERROR | \
231262306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_PARSER_PARITY_ERROR | \
231362306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_TSDM_PARITY_ERROR | \
231462306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_SEARCHER_PARITY_ERROR |\
231562306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_TSEMI_PARITY_ERROR |\
231662306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_TCM_PARITY_ERROR |\
231762306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_PBCLIENT_PARITY_ERROR)
231862306a36Sopenharmony_ci#define HW_INTERRUPT_ASSERT_SET_1 \
231962306a36Sopenharmony_ci				(AEU_INPUTS_ATTN_BITS_QM_HW_INTERRUPT | \
232062306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_TIMERS_HW_INTERRUPT | \
232162306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_XSDM_HW_INTERRUPT | \
232262306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_XCM_HW_INTERRUPT | \
232362306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_XSEMI_HW_INTERRUPT | \
232462306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_USDM_HW_INTERRUPT | \
232562306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_UCM_HW_INTERRUPT | \
232662306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_USEMI_HW_INTERRUPT | \
232762306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_UPB_HW_INTERRUPT | \
232862306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_CSDM_HW_INTERRUPT | \
232962306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_CCM_HW_INTERRUPT)
233062306a36Sopenharmony_ci#define HW_PRTY_ASSERT_SET_1	(AEU_INPUTS_ATTN_BITS_PBF_PARITY_ERROR |\
233162306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_QM_PARITY_ERROR | \
233262306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_TIMERS_PARITY_ERROR |\
233362306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_XSDM_PARITY_ERROR | \
233462306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_XCM_PARITY_ERROR |\
233562306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_XSEMI_PARITY_ERROR | \
233662306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_DOORBELLQ_PARITY_ERROR |\
233762306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_NIG_PARITY_ERROR |\
233862306a36Sopenharmony_ci			     AEU_INPUTS_ATTN_BITS_VAUX_PCI_CORE_PARITY_ERROR |\
233962306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_DEBUG_PARITY_ERROR | \
234062306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_USDM_PARITY_ERROR | \
234162306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_UCM_PARITY_ERROR |\
234262306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_USEMI_PARITY_ERROR | \
234362306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_UPB_PARITY_ERROR | \
234462306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_CSDM_PARITY_ERROR |\
234562306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_CCM_PARITY_ERROR)
234662306a36Sopenharmony_ci#define HW_INTERRUPT_ASSERT_SET_2 \
234762306a36Sopenharmony_ci				(AEU_INPUTS_ATTN_BITS_CSEMI_HW_INTERRUPT | \
234862306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_CDU_HW_INTERRUPT | \
234962306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_DMAE_HW_INTERRUPT | \
235062306a36Sopenharmony_ci			AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_HW_INTERRUPT |\
235162306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_MISC_HW_INTERRUPT)
235262306a36Sopenharmony_ci#define HW_PRTY_ASSERT_SET_2	(AEU_INPUTS_ATTN_BITS_CSEMI_PARITY_ERROR | \
235362306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_PXP_PARITY_ERROR | \
235462306a36Sopenharmony_ci			AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR |\
235562306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_CFC_PARITY_ERROR | \
235662306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_CDU_PARITY_ERROR | \
235762306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_DMAE_PARITY_ERROR |\
235862306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_IGU_PARITY_ERROR | \
235962306a36Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_MISC_PARITY_ERROR)
236062306a36Sopenharmony_ci
236162306a36Sopenharmony_ci#define HW_PRTY_ASSERT_SET_3_WITHOUT_SCPAD \
236262306a36Sopenharmony_ci		(AEU_INPUTS_ATTN_BITS_MCP_LATCHED_ROM_PARITY | \
236362306a36Sopenharmony_ci		 AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_RX_PARITY | \
236462306a36Sopenharmony_ci		 AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_TX_PARITY)
236562306a36Sopenharmony_ci
236662306a36Sopenharmony_ci#define HW_PRTY_ASSERT_SET_3 (HW_PRTY_ASSERT_SET_3_WITHOUT_SCPAD | \
236762306a36Sopenharmony_ci			      AEU_INPUTS_ATTN_BITS_MCP_LATCHED_SCPAD_PARITY)
236862306a36Sopenharmony_ci
236962306a36Sopenharmony_ci#define HW_PRTY_ASSERT_SET_4 (AEU_INPUTS_ATTN_BITS_PGLUE_PARITY_ERROR | \
237062306a36Sopenharmony_ci			      AEU_INPUTS_ATTN_BITS_ATC_PARITY_ERROR)
237162306a36Sopenharmony_ci
237262306a36Sopenharmony_ci#define MULTI_MASK			0x7f
237362306a36Sopenharmony_ci
237462306a36Sopenharmony_ci#define DEF_USB_FUNC_OFF	offsetof(struct cstorm_def_status_block_u, func)
237562306a36Sopenharmony_ci#define DEF_CSB_FUNC_OFF	offsetof(struct cstorm_def_status_block_c, func)
237662306a36Sopenharmony_ci#define DEF_XSB_FUNC_OFF	offsetof(struct xstorm_def_status_block, func)
237762306a36Sopenharmony_ci#define DEF_TSB_FUNC_OFF	offsetof(struct tstorm_def_status_block, func)
237862306a36Sopenharmony_ci
237962306a36Sopenharmony_ci#define DEF_USB_IGU_INDEX_OFF \
238062306a36Sopenharmony_ci			offsetof(struct cstorm_def_status_block_u, igu_index)
238162306a36Sopenharmony_ci#define DEF_CSB_IGU_INDEX_OFF \
238262306a36Sopenharmony_ci			offsetof(struct cstorm_def_status_block_c, igu_index)
238362306a36Sopenharmony_ci#define DEF_XSB_IGU_INDEX_OFF \
238462306a36Sopenharmony_ci			offsetof(struct xstorm_def_status_block, igu_index)
238562306a36Sopenharmony_ci#define DEF_TSB_IGU_INDEX_OFF \
238662306a36Sopenharmony_ci			offsetof(struct tstorm_def_status_block, igu_index)
238762306a36Sopenharmony_ci
238862306a36Sopenharmony_ci#define DEF_USB_SEGMENT_OFF \
238962306a36Sopenharmony_ci			offsetof(struct cstorm_def_status_block_u, segment)
239062306a36Sopenharmony_ci#define DEF_CSB_SEGMENT_OFF \
239162306a36Sopenharmony_ci			offsetof(struct cstorm_def_status_block_c, segment)
239262306a36Sopenharmony_ci#define DEF_XSB_SEGMENT_OFF \
239362306a36Sopenharmony_ci			offsetof(struct xstorm_def_status_block, segment)
239462306a36Sopenharmony_ci#define DEF_TSB_SEGMENT_OFF \
239562306a36Sopenharmony_ci			offsetof(struct tstorm_def_status_block, segment)
239662306a36Sopenharmony_ci
239762306a36Sopenharmony_ci#define BNX2X_SP_DSB_INDEX \
239862306a36Sopenharmony_ci		(&bp->def_status_blk->sp_sb.\
239962306a36Sopenharmony_ci					index_values[HC_SP_INDEX_ETH_DEF_CONS])
240062306a36Sopenharmony_ci
240162306a36Sopenharmony_ci#define CAM_IS_INVALID(x) \
240262306a36Sopenharmony_ci	(GET_FLAG(x.flags, \
240362306a36Sopenharmony_ci	MAC_CONFIGURATION_ENTRY_ACTION_TYPE) == \
240462306a36Sopenharmony_ci	(T_ETH_MAC_COMMAND_INVALIDATE))
240562306a36Sopenharmony_ci
240662306a36Sopenharmony_ci/* Number of u32 elements in MC hash array */
240762306a36Sopenharmony_ci#define MC_HASH_SIZE			8
240862306a36Sopenharmony_ci#define MC_HASH_OFFSET(bp, i)		(BAR_TSTRORM_INTMEM + \
240962306a36Sopenharmony_ci	TSTORM_APPROXIMATE_MATCH_MULTICAST_FILTERING_OFFSET(BP_FUNC(bp)) + i*4)
241062306a36Sopenharmony_ci
241162306a36Sopenharmony_ci#ifndef PXP2_REG_PXP2_INT_STS
241262306a36Sopenharmony_ci#define PXP2_REG_PXP2_INT_STS		PXP2_REG_PXP2_INT_STS_0
241362306a36Sopenharmony_ci#endif
241462306a36Sopenharmony_ci
241562306a36Sopenharmony_ci#ifndef ETH_MAX_RX_CLIENTS_E2
241662306a36Sopenharmony_ci#define ETH_MAX_RX_CLIENTS_E2		ETH_MAX_RX_CLIENTS_E1H
241762306a36Sopenharmony_ci#endif
241862306a36Sopenharmony_ci
241962306a36Sopenharmony_ci#define VENDOR_ID_LEN			4
242062306a36Sopenharmony_ci
242162306a36Sopenharmony_ci#define VF_ACQUIRE_THRESH		3
242262306a36Sopenharmony_ci#define VF_ACQUIRE_MAC_FILTERS		1
242362306a36Sopenharmony_ci#define VF_ACQUIRE_MC_FILTERS		10
242462306a36Sopenharmony_ci#define VF_ACQUIRE_VLAN_FILTERS		2 /* VLAN0 + 'real' VLAN */
242562306a36Sopenharmony_ci
242662306a36Sopenharmony_ci#define GOOD_ME_REG(me_reg) (((me_reg) & ME_REG_VF_VALID) && \
242762306a36Sopenharmony_ci			    (!((me_reg) & ME_REG_VF_ERR)))
242862306a36Sopenharmony_ciint bnx2x_compare_fw_ver(struct bnx2x *bp, u32 load_code, bool print_err);
242962306a36Sopenharmony_ci
243062306a36Sopenharmony_ci/* Congestion management fairness mode */
243162306a36Sopenharmony_ci#define CMNG_FNS_NONE			0
243262306a36Sopenharmony_ci#define CMNG_FNS_MINMAX			1
243362306a36Sopenharmony_ci
243462306a36Sopenharmony_ci#define HC_SEG_ACCESS_DEF		0   /*Driver decision 0-3*/
243562306a36Sopenharmony_ci#define HC_SEG_ACCESS_ATTN		4
243662306a36Sopenharmony_ci#define HC_SEG_ACCESS_NORM		0   /*Driver decision 0-1*/
243762306a36Sopenharmony_ci
243862306a36Sopenharmony_civoid bnx2x_set_ethtool_ops(struct bnx2x *bp, struct net_device *netdev);
243962306a36Sopenharmony_civoid bnx2x_notify_link_changed(struct bnx2x *bp);
244062306a36Sopenharmony_ci
244162306a36Sopenharmony_ci#define BNX2X_MF_SD_PROTOCOL(bp) \
244262306a36Sopenharmony_ci	((bp)->mf_config[BP_VN(bp)] & FUNC_MF_CFG_PROTOCOL_MASK)
244362306a36Sopenharmony_ci
244462306a36Sopenharmony_ci#define BNX2X_IS_MF_SD_PROTOCOL_ISCSI(bp) \
244562306a36Sopenharmony_ci	(BNX2X_MF_SD_PROTOCOL(bp) == FUNC_MF_CFG_PROTOCOL_ISCSI)
244662306a36Sopenharmony_ci
244762306a36Sopenharmony_ci#define BNX2X_IS_MF_SD_PROTOCOL_FCOE(bp) \
244862306a36Sopenharmony_ci	(BNX2X_MF_SD_PROTOCOL(bp) == FUNC_MF_CFG_PROTOCOL_FCOE)
244962306a36Sopenharmony_ci
245062306a36Sopenharmony_ci#define IS_MF_ISCSI_SD(bp) (IS_MF_SD(bp) && BNX2X_IS_MF_SD_PROTOCOL_ISCSI(bp))
245162306a36Sopenharmony_ci#define IS_MF_FCOE_SD(bp) (IS_MF_SD(bp) && BNX2X_IS_MF_SD_PROTOCOL_FCOE(bp))
245262306a36Sopenharmony_ci#define IS_MF_ISCSI_SI(bp) (IS_MF_SI(bp) && BNX2X_IS_MF_EXT_PROTOCOL_ISCSI(bp))
245362306a36Sopenharmony_ci
245462306a36Sopenharmony_ci#define IS_MF_ISCSI_ONLY(bp)    (IS_MF_ISCSI_SD(bp) ||  IS_MF_ISCSI_SI(bp))
245562306a36Sopenharmony_ci
245662306a36Sopenharmony_ci#define BNX2X_MF_EXT_PROTOCOL_MASK					\
245762306a36Sopenharmony_ci				(MACP_FUNC_CFG_FLAGS_ETHERNET |		\
245862306a36Sopenharmony_ci				 MACP_FUNC_CFG_FLAGS_ISCSI_OFFLOAD |	\
245962306a36Sopenharmony_ci				 MACP_FUNC_CFG_FLAGS_FCOE_OFFLOAD)
246062306a36Sopenharmony_ci
246162306a36Sopenharmony_ci#define BNX2X_MF_EXT_PROT(bp)	((bp)->mf_ext_config &			\
246262306a36Sopenharmony_ci				 BNX2X_MF_EXT_PROTOCOL_MASK)
246362306a36Sopenharmony_ci
246462306a36Sopenharmony_ci#define BNX2X_HAS_MF_EXT_PROTOCOL_FCOE(bp)				\
246562306a36Sopenharmony_ci		(BNX2X_MF_EXT_PROT(bp) & MACP_FUNC_CFG_FLAGS_FCOE_OFFLOAD)
246662306a36Sopenharmony_ci
246762306a36Sopenharmony_ci#define BNX2X_IS_MF_EXT_PROTOCOL_FCOE(bp)				\
246862306a36Sopenharmony_ci		(BNX2X_MF_EXT_PROT(bp) == MACP_FUNC_CFG_FLAGS_FCOE_OFFLOAD)
246962306a36Sopenharmony_ci
247062306a36Sopenharmony_ci#define BNX2X_IS_MF_EXT_PROTOCOL_ISCSI(bp)				\
247162306a36Sopenharmony_ci		(BNX2X_MF_EXT_PROT(bp) == MACP_FUNC_CFG_FLAGS_ISCSI_OFFLOAD)
247262306a36Sopenharmony_ci
247362306a36Sopenharmony_ci#define IS_MF_FCOE_AFEX(bp)						\
247462306a36Sopenharmony_ci		(IS_MF_AFEX(bp) && BNX2X_IS_MF_EXT_PROTOCOL_FCOE(bp))
247562306a36Sopenharmony_ci
247662306a36Sopenharmony_ci#define IS_MF_SD_STORAGE_PERSONALITY_ONLY(bp)				\
247762306a36Sopenharmony_ci				(IS_MF_SD(bp) &&			\
247862306a36Sopenharmony_ci				 (BNX2X_IS_MF_SD_PROTOCOL_ISCSI(bp) ||	\
247962306a36Sopenharmony_ci				  BNX2X_IS_MF_SD_PROTOCOL_FCOE(bp)))
248062306a36Sopenharmony_ci
248162306a36Sopenharmony_ci#define IS_MF_SI_STORAGE_PERSONALITY_ONLY(bp)				\
248262306a36Sopenharmony_ci				(IS_MF_SI(bp) &&			\
248362306a36Sopenharmony_ci				 (BNX2X_IS_MF_EXT_PROTOCOL_ISCSI(bp) ||	\
248462306a36Sopenharmony_ci				  BNX2X_IS_MF_EXT_PROTOCOL_FCOE(bp)))
248562306a36Sopenharmony_ci
248662306a36Sopenharmony_ci#define IS_MF_STORAGE_PERSONALITY_ONLY(bp)				\
248762306a36Sopenharmony_ci			(IS_MF_SD_STORAGE_PERSONALITY_ONLY(bp) ||	\
248862306a36Sopenharmony_ci			 IS_MF_SI_STORAGE_PERSONALITY_ONLY(bp))
248962306a36Sopenharmony_ci
249062306a36Sopenharmony_ci/* Determines whether BW configuration arrives in 100Mb units or in
249162306a36Sopenharmony_ci * percentages from actual physical link speed.
249262306a36Sopenharmony_ci */
249362306a36Sopenharmony_ci#define IS_MF_PERCENT_BW(bp) (IS_MF_SI(bp) || IS_MF_UFP(bp) || IS_MF_BD(bp))
249462306a36Sopenharmony_ci
249562306a36Sopenharmony_ci#define SET_FLAG(value, mask, flag) \
249662306a36Sopenharmony_ci	do {\
249762306a36Sopenharmony_ci		(value) &= ~(mask);\
249862306a36Sopenharmony_ci		(value) |= ((flag) << (mask##_SHIFT));\
249962306a36Sopenharmony_ci	} while (0)
250062306a36Sopenharmony_ci
250162306a36Sopenharmony_ci#define GET_FLAG(value, mask) \
250262306a36Sopenharmony_ci	(((value) & (mask)) >> (mask##_SHIFT))
250362306a36Sopenharmony_ci
250462306a36Sopenharmony_ci#define GET_FIELD(value, fname) \
250562306a36Sopenharmony_ci	(((value) & (fname##_MASK)) >> (fname##_SHIFT))
250662306a36Sopenharmony_ci
250762306a36Sopenharmony_cienum {
250862306a36Sopenharmony_ci	SWITCH_UPDATE,
250962306a36Sopenharmony_ci	AFEX_UPDATE,
251062306a36Sopenharmony_ci};
251162306a36Sopenharmony_ci
251262306a36Sopenharmony_ci#define NUM_MACS	8
251362306a36Sopenharmony_ci
251462306a36Sopenharmony_civoid bnx2x_set_local_cmng(struct bnx2x *bp);
251562306a36Sopenharmony_ci
251662306a36Sopenharmony_civoid bnx2x_update_mng_version(struct bnx2x *bp);
251762306a36Sopenharmony_ci
251862306a36Sopenharmony_civoid bnx2x_update_mfw_dump(struct bnx2x *bp);
251962306a36Sopenharmony_ci
252062306a36Sopenharmony_ci#define MCPR_SCRATCH_BASE(bp) \
252162306a36Sopenharmony_ci	(CHIP_IS_E1x(bp) ? MCP_REG_MCPR_SCRATCH : MCP_A_REG_MCPR_SCRATCH)
252262306a36Sopenharmony_ci
252362306a36Sopenharmony_ci#define E1H_MAX_MF_SB_COUNT (HC_SB_MAX_SB_E1X/(E1HVN_MAX * PORT_MAX))
252462306a36Sopenharmony_ci
252562306a36Sopenharmony_civoid bnx2x_init_ptp(struct bnx2x *bp);
252662306a36Sopenharmony_ciint bnx2x_configure_ptp_filters(struct bnx2x *bp);
252762306a36Sopenharmony_civoid bnx2x_set_rx_ts(struct bnx2x *bp, struct sk_buff *skb);
252862306a36Sopenharmony_civoid bnx2x_register_phc(struct bnx2x *bp);
252962306a36Sopenharmony_ci
253062306a36Sopenharmony_ci#define BNX2X_MAX_PHC_DRIFT 31000000
253162306a36Sopenharmony_ci#define BNX2X_PTP_TX_TIMEOUT
253262306a36Sopenharmony_ci
253362306a36Sopenharmony_ci/* Re-configure all previously configured vlan filters.
253462306a36Sopenharmony_ci * Meant for implicit re-load flows.
253562306a36Sopenharmony_ci */
253662306a36Sopenharmony_ciint bnx2x_vlan_reconfigure_vid(struct bnx2x *bp);
253762306a36Sopenharmony_ci#endif /* bnx2x.h */
2538