18c2ecf20Sopenharmony_ci/* bnx2x.h: QLogic Everest network driver.
28c2ecf20Sopenharmony_ci *
38c2ecf20Sopenharmony_ci * Copyright (c) 2007-2013 Broadcom Corporation
48c2ecf20Sopenharmony_ci * Copyright (c) 2014 QLogic Corporation
58c2ecf20Sopenharmony_ci * All rights reserved
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or modify
88c2ecf20Sopenharmony_ci * it under the terms of the GNU General Public License as published by
98c2ecf20Sopenharmony_ci * the Free Software Foundation.
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * Maintained by: Ariel Elior <ariel.elior@qlogic.com>
128c2ecf20Sopenharmony_ci * Written by: Eliezer Tamir
138c2ecf20Sopenharmony_ci * Based on code from Michael Chan's bnx2 driver
148c2ecf20Sopenharmony_ci */
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#ifndef BNX2X_H
178c2ecf20Sopenharmony_ci#define BNX2X_H
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#include <linux/pci.h>
208c2ecf20Sopenharmony_ci#include <linux/netdevice.h>
218c2ecf20Sopenharmony_ci#include <linux/dma-mapping.h>
228c2ecf20Sopenharmony_ci#include <linux/types.h>
238c2ecf20Sopenharmony_ci#include <linux/pci_regs.h>
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci#include <linux/ptp_clock_kernel.h>
268c2ecf20Sopenharmony_ci#include <linux/net_tstamp.h>
278c2ecf20Sopenharmony_ci#include <linux/timecounter.h>
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci/* compilation time flags */
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci/* define this to make the driver freeze on error to allow getting debug info
328c2ecf20Sopenharmony_ci * (you will need to reboot afterwards) */
338c2ecf20Sopenharmony_ci/* #define BNX2X_STOP_ON_ERROR */
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci/* FIXME: Delete the DRV_MODULE_VERSION below, but please be warned
368c2ecf20Sopenharmony_ci * that it is not an easy task because such change has all chances
378c2ecf20Sopenharmony_ci * to break this driver due to amount of abuse of in-kernel interfaces
388c2ecf20Sopenharmony_ci * between modules and FW.
398c2ecf20Sopenharmony_ci *
408c2ecf20Sopenharmony_ci * DO NOT UPDATE DRV_MODULE_VERSION below.
418c2ecf20Sopenharmony_ci */
428c2ecf20Sopenharmony_ci#define DRV_MODULE_VERSION      "1.713.36-0"
438c2ecf20Sopenharmony_ci#define BNX2X_BC_VER            0x040200
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci#if defined(CONFIG_DCB)
468c2ecf20Sopenharmony_ci#define BCM_DCBNL
478c2ecf20Sopenharmony_ci#endif
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci#include "bnx2x_hsi.h"
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci#include "../cnic_if.h"
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci#define BNX2X_MIN_MSIX_VEC_CNT(bp)		((bp)->min_msix_vec_cnt)
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci#include <linux/mdio.h>
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci#include "bnx2x_reg.h"
588c2ecf20Sopenharmony_ci#include "bnx2x_fw_defs.h"
598c2ecf20Sopenharmony_ci#include "bnx2x_mfw_req.h"
608c2ecf20Sopenharmony_ci#include "bnx2x_link.h"
618c2ecf20Sopenharmony_ci#include "bnx2x_sp.h"
628c2ecf20Sopenharmony_ci#include "bnx2x_dcb.h"
638c2ecf20Sopenharmony_ci#include "bnx2x_stats.h"
648c2ecf20Sopenharmony_ci#include "bnx2x_vfpf.h"
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_cienum bnx2x_int_mode {
678c2ecf20Sopenharmony_ci	BNX2X_INT_MODE_MSIX,
688c2ecf20Sopenharmony_ci	BNX2X_INT_MODE_INTX,
698c2ecf20Sopenharmony_ci	BNX2X_INT_MODE_MSI
708c2ecf20Sopenharmony_ci};
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci/* error/debug prints */
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci#define DRV_MODULE_NAME		"bnx2x"
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci/* for messages that are currently off */
778c2ecf20Sopenharmony_ci#define BNX2X_MSG_OFF			0x0
788c2ecf20Sopenharmony_ci#define BNX2X_MSG_MCP			0x0010000 /* was: NETIF_MSG_HW */
798c2ecf20Sopenharmony_ci#define BNX2X_MSG_STATS			0x0020000 /* was: NETIF_MSG_TIMER */
808c2ecf20Sopenharmony_ci#define BNX2X_MSG_NVM			0x0040000 /* was: NETIF_MSG_HW */
818c2ecf20Sopenharmony_ci#define BNX2X_MSG_DMAE			0x0080000 /* was: NETIF_MSG_HW */
828c2ecf20Sopenharmony_ci#define BNX2X_MSG_SP			0x0100000 /* was: NETIF_MSG_INTR */
838c2ecf20Sopenharmony_ci#define BNX2X_MSG_FP			0x0200000 /* was: NETIF_MSG_INTR */
848c2ecf20Sopenharmony_ci#define BNX2X_MSG_IOV			0x0800000
858c2ecf20Sopenharmony_ci#define BNX2X_MSG_PTP			0x1000000
868c2ecf20Sopenharmony_ci#define BNX2X_MSG_IDLE			0x2000000 /* used for idle check*/
878c2ecf20Sopenharmony_ci#define BNX2X_MSG_ETHTOOL		0x4000000
888c2ecf20Sopenharmony_ci#define BNX2X_MSG_DCB			0x8000000
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci/* regular debug print */
918c2ecf20Sopenharmony_ci#define DP_INNER(fmt, ...)					\
928c2ecf20Sopenharmony_ci	pr_notice("[%s:%d(%s)]" fmt,				\
938c2ecf20Sopenharmony_ci		  __func__, __LINE__,				\
948c2ecf20Sopenharmony_ci		  bp->dev ? (bp->dev->name) : "?",		\
958c2ecf20Sopenharmony_ci		  ##__VA_ARGS__);
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci#define DP(__mask, fmt, ...)					\
988c2ecf20Sopenharmony_cido {								\
998c2ecf20Sopenharmony_ci	if (unlikely(bp->msg_enable & (__mask)))		\
1008c2ecf20Sopenharmony_ci		DP_INNER(fmt, ##__VA_ARGS__);			\
1018c2ecf20Sopenharmony_ci} while (0)
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci#define DP_AND(__mask, fmt, ...)				\
1048c2ecf20Sopenharmony_cido {								\
1058c2ecf20Sopenharmony_ci	if (unlikely((bp->msg_enable & (__mask)) == __mask))	\
1068c2ecf20Sopenharmony_ci		DP_INNER(fmt, ##__VA_ARGS__);			\
1078c2ecf20Sopenharmony_ci} while (0)
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci#define DP_CONT(__mask, fmt, ...)				\
1108c2ecf20Sopenharmony_cido {								\
1118c2ecf20Sopenharmony_ci	if (unlikely(bp->msg_enable & (__mask)))		\
1128c2ecf20Sopenharmony_ci		pr_cont(fmt, ##__VA_ARGS__);			\
1138c2ecf20Sopenharmony_ci} while (0)
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci/* errors debug print */
1168c2ecf20Sopenharmony_ci#define BNX2X_DBG_ERR(fmt, ...)					\
1178c2ecf20Sopenharmony_cido {								\
1188c2ecf20Sopenharmony_ci	if (unlikely(netif_msg_probe(bp)))			\
1198c2ecf20Sopenharmony_ci		pr_err("[%s:%d(%s)]" fmt,			\
1208c2ecf20Sopenharmony_ci		       __func__, __LINE__,			\
1218c2ecf20Sopenharmony_ci		       bp->dev ? (bp->dev->name) : "?",		\
1228c2ecf20Sopenharmony_ci		       ##__VA_ARGS__);				\
1238c2ecf20Sopenharmony_ci} while (0)
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ci/* for errors (never masked) */
1268c2ecf20Sopenharmony_ci#define BNX2X_ERR(fmt, ...)					\
1278c2ecf20Sopenharmony_cido {								\
1288c2ecf20Sopenharmony_ci	pr_err("[%s:%d(%s)]" fmt,				\
1298c2ecf20Sopenharmony_ci	       __func__, __LINE__,				\
1308c2ecf20Sopenharmony_ci	       bp->dev ? (bp->dev->name) : "?",			\
1318c2ecf20Sopenharmony_ci	       ##__VA_ARGS__);					\
1328c2ecf20Sopenharmony_ci} while (0)
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci#define BNX2X_ERROR(fmt, ...)					\
1358c2ecf20Sopenharmony_ci	pr_err("[%s:%d]" fmt, __func__, __LINE__, ##__VA_ARGS__)
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci/* before we have a dev->name use dev_info() */
1388c2ecf20Sopenharmony_ci#define BNX2X_DEV_INFO(fmt, ...)				 \
1398c2ecf20Sopenharmony_cido {								 \
1408c2ecf20Sopenharmony_ci	if (unlikely(netif_msg_probe(bp)))			 \
1418c2ecf20Sopenharmony_ci		dev_info(&bp->pdev->dev, fmt, ##__VA_ARGS__);	 \
1428c2ecf20Sopenharmony_ci} while (0)
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci/* Error handling */
1458c2ecf20Sopenharmony_civoid bnx2x_panic_dump(struct bnx2x *bp, bool disable_int);
1468c2ecf20Sopenharmony_ci#ifdef BNX2X_STOP_ON_ERROR
1478c2ecf20Sopenharmony_ci#define bnx2x_panic()				\
1488c2ecf20Sopenharmony_cido {						\
1498c2ecf20Sopenharmony_ci	bp->panic = 1;				\
1508c2ecf20Sopenharmony_ci	BNX2X_ERR("driver assert\n");		\
1518c2ecf20Sopenharmony_ci	bnx2x_panic_dump(bp, true);		\
1528c2ecf20Sopenharmony_ci} while (0)
1538c2ecf20Sopenharmony_ci#else
1548c2ecf20Sopenharmony_ci#define bnx2x_panic()				\
1558c2ecf20Sopenharmony_cido {						\
1568c2ecf20Sopenharmony_ci	bp->panic = 1;				\
1578c2ecf20Sopenharmony_ci	BNX2X_ERR("driver assert\n");		\
1588c2ecf20Sopenharmony_ci	bnx2x_panic_dump(bp, false);		\
1598c2ecf20Sopenharmony_ci} while (0)
1608c2ecf20Sopenharmony_ci#endif
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci#define bnx2x_mc_addr(ha)      ((ha)->addr)
1638c2ecf20Sopenharmony_ci#define bnx2x_uc_addr(ha)      ((ha)->addr)
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ci#define U64_LO(x)			((u32)(((u64)(x)) & 0xffffffff))
1668c2ecf20Sopenharmony_ci#define U64_HI(x)			((u32)(((u64)(x)) >> 32))
1678c2ecf20Sopenharmony_ci#define HILO_U64(hi, lo)		((((u64)(hi)) << 32) + (lo))
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci#define REG_ADDR(bp, offset)		((bp->regview) + (offset))
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci#define REG_RD(bp, offset)		readl(REG_ADDR(bp, offset))
1728c2ecf20Sopenharmony_ci#define REG_RD8(bp, offset)		readb(REG_ADDR(bp, offset))
1738c2ecf20Sopenharmony_ci#define REG_RD16(bp, offset)		readw(REG_ADDR(bp, offset))
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_ci#define REG_WR_RELAXED(bp, offset, val)	\
1768c2ecf20Sopenharmony_ci	writel_relaxed((u32)val, REG_ADDR(bp, offset))
1778c2ecf20Sopenharmony_ci
1788c2ecf20Sopenharmony_ci#define REG_WR16_RELAXED(bp, offset, val) \
1798c2ecf20Sopenharmony_ci	writew_relaxed((u16)val, REG_ADDR(bp, offset))
1808c2ecf20Sopenharmony_ci
1818c2ecf20Sopenharmony_ci#define REG_WR(bp, offset, val)		writel((u32)val, REG_ADDR(bp, offset))
1828c2ecf20Sopenharmony_ci#define REG_WR8(bp, offset, val)	writeb((u8)val, REG_ADDR(bp, offset))
1838c2ecf20Sopenharmony_ci#define REG_WR16(bp, offset, val)	writew((u16)val, REG_ADDR(bp, offset))
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci#define REG_RD_IND(bp, offset)		bnx2x_reg_rd_ind(bp, offset)
1868c2ecf20Sopenharmony_ci#define REG_WR_IND(bp, offset, val)	bnx2x_reg_wr_ind(bp, offset, val)
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_ci#define REG_RD_DMAE(bp, offset, valp, len32) \
1898c2ecf20Sopenharmony_ci	do { \
1908c2ecf20Sopenharmony_ci		bnx2x_read_dmae(bp, offset, len32);\
1918c2ecf20Sopenharmony_ci		memcpy(valp, bnx2x_sp(bp, wb_data[0]), (len32) * 4); \
1928c2ecf20Sopenharmony_ci	} while (0)
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci#define REG_WR_DMAE(bp, offset, valp, len32) \
1958c2ecf20Sopenharmony_ci	do { \
1968c2ecf20Sopenharmony_ci		memcpy(bnx2x_sp(bp, wb_data[0]), valp, (len32) * 4); \
1978c2ecf20Sopenharmony_ci		bnx2x_write_dmae(bp, bnx2x_sp_mapping(bp, wb_data), \
1988c2ecf20Sopenharmony_ci				 offset, len32); \
1998c2ecf20Sopenharmony_ci	} while (0)
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_ci#define REG_WR_DMAE_LEN(bp, offset, valp, len32) \
2028c2ecf20Sopenharmony_ci	REG_WR_DMAE(bp, offset, valp, len32)
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci#define VIRT_WR_DMAE_LEN(bp, data, addr, len32, le32_swap) \
2058c2ecf20Sopenharmony_ci	do { \
2068c2ecf20Sopenharmony_ci		memcpy(GUNZIP_BUF(bp), data, (len32) * 4); \
2078c2ecf20Sopenharmony_ci		bnx2x_write_big_buf_wb(bp, addr, len32); \
2088c2ecf20Sopenharmony_ci	} while (0)
2098c2ecf20Sopenharmony_ci
2108c2ecf20Sopenharmony_ci#define SHMEM_ADDR(bp, field)		(bp->common.shmem_base + \
2118c2ecf20Sopenharmony_ci					 offsetof(struct shmem_region, field))
2128c2ecf20Sopenharmony_ci#define SHMEM_RD(bp, field)		REG_RD(bp, SHMEM_ADDR(bp, field))
2138c2ecf20Sopenharmony_ci#define SHMEM_WR(bp, field, val)	REG_WR(bp, SHMEM_ADDR(bp, field), val)
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_ci#define SHMEM2_ADDR(bp, field)		(bp->common.shmem2_base + \
2168c2ecf20Sopenharmony_ci					 offsetof(struct shmem2_region, field))
2178c2ecf20Sopenharmony_ci#define SHMEM2_RD(bp, field)		REG_RD(bp, SHMEM2_ADDR(bp, field))
2188c2ecf20Sopenharmony_ci#define SHMEM2_WR(bp, field, val)	REG_WR(bp, SHMEM2_ADDR(bp, field), val)
2198c2ecf20Sopenharmony_ci#define MF_CFG_ADDR(bp, field)		(bp->common.mf_cfg_base + \
2208c2ecf20Sopenharmony_ci					 offsetof(struct mf_cfg, field))
2218c2ecf20Sopenharmony_ci#define MF2_CFG_ADDR(bp, field)		(bp->common.mf2_cfg_base + \
2228c2ecf20Sopenharmony_ci					 offsetof(struct mf2_cfg, field))
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_ci#define MF_CFG_RD(bp, field)		REG_RD(bp, MF_CFG_ADDR(bp, field))
2258c2ecf20Sopenharmony_ci#define MF_CFG_WR(bp, field, val)	REG_WR(bp,\
2268c2ecf20Sopenharmony_ci					       MF_CFG_ADDR(bp, field), (val))
2278c2ecf20Sopenharmony_ci#define MF2_CFG_RD(bp, field)		REG_RD(bp, MF2_CFG_ADDR(bp, field))
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_ci#define SHMEM2_HAS(bp, field)		((bp)->common.shmem2_base &&	\
2308c2ecf20Sopenharmony_ci					 (SHMEM2_RD((bp), size) >	\
2318c2ecf20Sopenharmony_ci					 offsetof(struct shmem2_region, field)))
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ci#define EMAC_RD(bp, reg)		REG_RD(bp, emac_base + reg)
2348c2ecf20Sopenharmony_ci#define EMAC_WR(bp, reg, val)		REG_WR(bp, emac_base + reg, val)
2358c2ecf20Sopenharmony_ci
2368c2ecf20Sopenharmony_ci/* SP SB indices */
2378c2ecf20Sopenharmony_ci
2388c2ecf20Sopenharmony_ci/* General SP events - stats query, cfc delete, etc  */
2398c2ecf20Sopenharmony_ci#define HC_SP_INDEX_ETH_DEF_CONS		3
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_ci/* EQ completions */
2428c2ecf20Sopenharmony_ci#define HC_SP_INDEX_EQ_CONS			7
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_ci/* FCoE L2 connection completions */
2458c2ecf20Sopenharmony_ci#define HC_SP_INDEX_ETH_FCOE_TX_CQ_CONS		6
2468c2ecf20Sopenharmony_ci#define HC_SP_INDEX_ETH_FCOE_RX_CQ_CONS		4
2478c2ecf20Sopenharmony_ci/* iSCSI L2 */
2488c2ecf20Sopenharmony_ci#define HC_SP_INDEX_ETH_ISCSI_CQ_CONS		5
2498c2ecf20Sopenharmony_ci#define HC_SP_INDEX_ETH_ISCSI_RX_CQ_CONS	1
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_ci/* Special clients parameters */
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_ci/* SB indices */
2548c2ecf20Sopenharmony_ci/* FCoE L2 */
2558c2ecf20Sopenharmony_ci#define BNX2X_FCOE_L2_RX_INDEX \
2568c2ecf20Sopenharmony_ci	(&bp->def_status_blk->sp_sb.\
2578c2ecf20Sopenharmony_ci	index_values[HC_SP_INDEX_ETH_FCOE_RX_CQ_CONS])
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ci#define BNX2X_FCOE_L2_TX_INDEX \
2608c2ecf20Sopenharmony_ci	(&bp->def_status_blk->sp_sb.\
2618c2ecf20Sopenharmony_ci	index_values[HC_SP_INDEX_ETH_FCOE_TX_CQ_CONS])
2628c2ecf20Sopenharmony_ci
2638c2ecf20Sopenharmony_ci/**
2648c2ecf20Sopenharmony_ci *  CIDs and CLIDs:
2658c2ecf20Sopenharmony_ci *  CLIDs below is a CLID for func 0, then the CLID for other
2668c2ecf20Sopenharmony_ci *  functions will be calculated by the formula:
2678c2ecf20Sopenharmony_ci *
2688c2ecf20Sopenharmony_ci *  FUNC_N_CLID_X = N * NUM_SPECIAL_CLIENTS + FUNC_0_CLID_X
2698c2ecf20Sopenharmony_ci *
2708c2ecf20Sopenharmony_ci */
2718c2ecf20Sopenharmony_cienum {
2728c2ecf20Sopenharmony_ci	BNX2X_ISCSI_ETH_CL_ID_IDX,
2738c2ecf20Sopenharmony_ci	BNX2X_FCOE_ETH_CL_ID_IDX,
2748c2ecf20Sopenharmony_ci	BNX2X_MAX_CNIC_ETH_CL_ID_IDX,
2758c2ecf20Sopenharmony_ci};
2768c2ecf20Sopenharmony_ci
2778c2ecf20Sopenharmony_ci/* use a value high enough to be above all the PFs, which has least significant
2788c2ecf20Sopenharmony_ci * nibble as 8, so when cnic needs to come up with a CID for UIO to use to
2798c2ecf20Sopenharmony_ci * calculate doorbell address according to old doorbell configuration scheme
2808c2ecf20Sopenharmony_ci * (db_msg_sz 1 << 7 * cid + 0x40 DPM offset) it can come up with a valid number
2818c2ecf20Sopenharmony_ci * We must avoid coming up with cid 8 for iscsi since according to this method
2828c2ecf20Sopenharmony_ci * the designated UIO cid will come out 0 and it has a special handling for that
2838c2ecf20Sopenharmony_ci * case which doesn't suit us. Therefore will will cieling to closes cid which
2848c2ecf20Sopenharmony_ci * has least signigifcant nibble 8 and if it is 8 we will move forward to 0x18.
2858c2ecf20Sopenharmony_ci */
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_ci#define BNX2X_1st_NON_L2_ETH_CID(bp)	(BNX2X_NUM_NON_CNIC_QUEUES(bp) * \
2888c2ecf20Sopenharmony_ci					 (bp)->max_cos)
2898c2ecf20Sopenharmony_ci/* amount of cids traversed by UIO's DPM addition to doorbell */
2908c2ecf20Sopenharmony_ci#define UIO_DPM				8
2918c2ecf20Sopenharmony_ci/* roundup to DPM offset */
2928c2ecf20Sopenharmony_ci#define UIO_ROUNDUP(bp)			(roundup(BNX2X_1st_NON_L2_ETH_CID(bp), \
2938c2ecf20Sopenharmony_ci					 UIO_DPM))
2948c2ecf20Sopenharmony_ci/* offset to nearest value which has lsb nibble matching DPM */
2958c2ecf20Sopenharmony_ci#define UIO_CID_OFFSET(bp)		((UIO_ROUNDUP(bp) + UIO_DPM) % \
2968c2ecf20Sopenharmony_ci					 (UIO_DPM * 2))
2978c2ecf20Sopenharmony_ci/* add offset to rounded-up cid to get a value which could be used with UIO */
2988c2ecf20Sopenharmony_ci#define UIO_DPM_ALIGN(bp)		(UIO_ROUNDUP(bp) + UIO_CID_OFFSET(bp))
2998c2ecf20Sopenharmony_ci/* but wait - avoid UIO special case for cid 0 */
3008c2ecf20Sopenharmony_ci#define UIO_DPM_CID0_OFFSET(bp)		((UIO_DPM * 2) * \
3018c2ecf20Sopenharmony_ci					 (UIO_DPM_ALIGN(bp) == UIO_DPM))
3028c2ecf20Sopenharmony_ci/* Properly DPM aligned CID dajusted to cid 0 secal case */
3038c2ecf20Sopenharmony_ci#define BNX2X_CNIC_START_ETH_CID(bp)	(UIO_DPM_ALIGN(bp) + \
3048c2ecf20Sopenharmony_ci					 (UIO_DPM_CID0_OFFSET(bp)))
3058c2ecf20Sopenharmony_ci/* how many cids were wasted  - need this value for cid allocation */
3068c2ecf20Sopenharmony_ci#define UIO_CID_PAD(bp)			(BNX2X_CNIC_START_ETH_CID(bp) - \
3078c2ecf20Sopenharmony_ci					 BNX2X_1st_NON_L2_ETH_CID(bp))
3088c2ecf20Sopenharmony_ci	/* iSCSI L2 */
3098c2ecf20Sopenharmony_ci#define	BNX2X_ISCSI_ETH_CID(bp)		(BNX2X_CNIC_START_ETH_CID(bp))
3108c2ecf20Sopenharmony_ci	/* FCoE L2 */
3118c2ecf20Sopenharmony_ci#define	BNX2X_FCOE_ETH_CID(bp)		(BNX2X_CNIC_START_ETH_CID(bp) + 1)
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_ci#define CNIC_SUPPORT(bp)		((bp)->cnic_support)
3148c2ecf20Sopenharmony_ci#define CNIC_ENABLED(bp)		((bp)->cnic_enabled)
3158c2ecf20Sopenharmony_ci#define CNIC_LOADED(bp)			((bp)->cnic_loaded)
3168c2ecf20Sopenharmony_ci#define FCOE_INIT(bp)			((bp)->fcoe_init)
3178c2ecf20Sopenharmony_ci
3188c2ecf20Sopenharmony_ci#define AEU_IN_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR \
3198c2ecf20Sopenharmony_ci	AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR
3208c2ecf20Sopenharmony_ci
3218c2ecf20Sopenharmony_ci#define SM_RX_ID			0
3228c2ecf20Sopenharmony_ci#define SM_TX_ID			1
3238c2ecf20Sopenharmony_ci
3248c2ecf20Sopenharmony_ci/* defines for multiple tx priority indices */
3258c2ecf20Sopenharmony_ci#define FIRST_TX_ONLY_COS_INDEX		1
3268c2ecf20Sopenharmony_ci#define FIRST_TX_COS_INDEX		0
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_ci/* rules for calculating the cids of tx-only connections */
3298c2ecf20Sopenharmony_ci#define CID_TO_FP(cid, bp)		((cid) % BNX2X_NUM_NON_CNIC_QUEUES(bp))
3308c2ecf20Sopenharmony_ci#define CID_COS_TO_TX_ONLY_CID(cid, cos, bp) \
3318c2ecf20Sopenharmony_ci				(cid + cos * BNX2X_NUM_NON_CNIC_QUEUES(bp))
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_ci/* fp index inside class of service range */
3348c2ecf20Sopenharmony_ci#define FP_COS_TO_TXQ(fp, cos, bp) \
3358c2ecf20Sopenharmony_ci			((fp)->index + cos * BNX2X_NUM_NON_CNIC_QUEUES(bp))
3368c2ecf20Sopenharmony_ci
3378c2ecf20Sopenharmony_ci/* Indexes for transmission queues array:
3388c2ecf20Sopenharmony_ci * txdata for RSS i CoS j is at location i + (j * num of RSS)
3398c2ecf20Sopenharmony_ci * txdata for FCoE (if exist) is at location max cos * num of RSS
3408c2ecf20Sopenharmony_ci * txdata for FWD (if exist) is one location after FCoE
3418c2ecf20Sopenharmony_ci * txdata for OOO (if exist) is one location after FWD
3428c2ecf20Sopenharmony_ci */
3438c2ecf20Sopenharmony_cienum {
3448c2ecf20Sopenharmony_ci	FCOE_TXQ_IDX_OFFSET,
3458c2ecf20Sopenharmony_ci	FWD_TXQ_IDX_OFFSET,
3468c2ecf20Sopenharmony_ci	OOO_TXQ_IDX_OFFSET,
3478c2ecf20Sopenharmony_ci};
3488c2ecf20Sopenharmony_ci#define MAX_ETH_TXQ_IDX(bp)	(BNX2X_NUM_NON_CNIC_QUEUES(bp) * (bp)->max_cos)
3498c2ecf20Sopenharmony_ci#define FCOE_TXQ_IDX(bp)	(MAX_ETH_TXQ_IDX(bp) + FCOE_TXQ_IDX_OFFSET)
3508c2ecf20Sopenharmony_ci
3518c2ecf20Sopenharmony_ci/* fast path */
3528c2ecf20Sopenharmony_ci/*
3538c2ecf20Sopenharmony_ci * This driver uses new build_skb() API :
3548c2ecf20Sopenharmony_ci * RX ring buffer contains pointer to kmalloc() data only,
3558c2ecf20Sopenharmony_ci * skb are built only after Hardware filled the frame.
3568c2ecf20Sopenharmony_ci */
3578c2ecf20Sopenharmony_cistruct sw_rx_bd {
3588c2ecf20Sopenharmony_ci	u8		*data;
3598c2ecf20Sopenharmony_ci	DEFINE_DMA_UNMAP_ADDR(mapping);
3608c2ecf20Sopenharmony_ci};
3618c2ecf20Sopenharmony_ci
3628c2ecf20Sopenharmony_cistruct sw_tx_bd {
3638c2ecf20Sopenharmony_ci	struct sk_buff	*skb;
3648c2ecf20Sopenharmony_ci	u16		first_bd;
3658c2ecf20Sopenharmony_ci	u8		flags;
3668c2ecf20Sopenharmony_ci/* Set on the first BD descriptor when there is a split BD */
3678c2ecf20Sopenharmony_ci#define BNX2X_TSO_SPLIT_BD		(1<<0)
3688c2ecf20Sopenharmony_ci#define BNX2X_HAS_SECOND_PBD		(1<<1)
3698c2ecf20Sopenharmony_ci};
3708c2ecf20Sopenharmony_ci
3718c2ecf20Sopenharmony_cistruct sw_rx_page {
3728c2ecf20Sopenharmony_ci	struct page	*page;
3738c2ecf20Sopenharmony_ci	DEFINE_DMA_UNMAP_ADDR(mapping);
3748c2ecf20Sopenharmony_ci	unsigned int	offset;
3758c2ecf20Sopenharmony_ci};
3768c2ecf20Sopenharmony_ci
3778c2ecf20Sopenharmony_ciunion db_prod {
3788c2ecf20Sopenharmony_ci	struct doorbell_set_prod data;
3798c2ecf20Sopenharmony_ci	u32		raw;
3808c2ecf20Sopenharmony_ci};
3818c2ecf20Sopenharmony_ci
3828c2ecf20Sopenharmony_ci/* dropless fc FW/HW related params */
3838c2ecf20Sopenharmony_ci#define BRB_SIZE(bp)		(CHIP_IS_E3(bp) ? 1024 : 512)
3848c2ecf20Sopenharmony_ci#define MAX_AGG_QS(bp)		(CHIP_IS_E1(bp) ? \
3858c2ecf20Sopenharmony_ci					ETH_MAX_AGGREGATION_QUEUES_E1 :\
3868c2ecf20Sopenharmony_ci					ETH_MAX_AGGREGATION_QUEUES_E1H_E2)
3878c2ecf20Sopenharmony_ci#define FW_DROP_LEVEL(bp)	(3 + MAX_SPQ_PENDING + MAX_AGG_QS(bp))
3888c2ecf20Sopenharmony_ci#define FW_PREFETCH_CNT		16
3898c2ecf20Sopenharmony_ci#define DROPLESS_FC_HEADROOM	100
3908c2ecf20Sopenharmony_ci
3918c2ecf20Sopenharmony_ci/* MC hsi */
3928c2ecf20Sopenharmony_ci#define BCM_PAGE_SHIFT		12
3938c2ecf20Sopenharmony_ci#define BCM_PAGE_SIZE		(1 << BCM_PAGE_SHIFT)
3948c2ecf20Sopenharmony_ci#define BCM_PAGE_MASK		(~(BCM_PAGE_SIZE - 1))
3958c2ecf20Sopenharmony_ci#define BCM_PAGE_ALIGN(addr)	(((addr) + BCM_PAGE_SIZE - 1) & BCM_PAGE_MASK)
3968c2ecf20Sopenharmony_ci
3978c2ecf20Sopenharmony_ci#define PAGES_PER_SGE_SHIFT	0
3988c2ecf20Sopenharmony_ci#define PAGES_PER_SGE		(1 << PAGES_PER_SGE_SHIFT)
3998c2ecf20Sopenharmony_ci#define SGE_PAGE_SHIFT		12
4008c2ecf20Sopenharmony_ci#define SGE_PAGE_SIZE		(1 << SGE_PAGE_SHIFT)
4018c2ecf20Sopenharmony_ci#define SGE_PAGE_MASK		(~(SGE_PAGE_SIZE - 1))
4028c2ecf20Sopenharmony_ci#define SGE_PAGE_ALIGN(addr)	(((addr) + SGE_PAGE_SIZE - 1) & SGE_PAGE_MASK)
4038c2ecf20Sopenharmony_ci#define SGE_PAGES		(SGE_PAGE_SIZE * PAGES_PER_SGE)
4048c2ecf20Sopenharmony_ci#define TPA_AGG_SIZE		min_t(u32, (min_t(u32, 8, MAX_SKB_FRAGS) * \
4058c2ecf20Sopenharmony_ci					    SGE_PAGES), 0xffff)
4068c2ecf20Sopenharmony_ci
4078c2ecf20Sopenharmony_ci/* SGE ring related macros */
4088c2ecf20Sopenharmony_ci#define NUM_RX_SGE_PAGES	2
4098c2ecf20Sopenharmony_ci#define RX_SGE_CNT		(BCM_PAGE_SIZE / sizeof(struct eth_rx_sge))
4108c2ecf20Sopenharmony_ci#define NEXT_PAGE_SGE_DESC_CNT	2
4118c2ecf20Sopenharmony_ci#define MAX_RX_SGE_CNT		(RX_SGE_CNT - NEXT_PAGE_SGE_DESC_CNT)
4128c2ecf20Sopenharmony_ci/* RX_SGE_CNT is promised to be a power of 2 */
4138c2ecf20Sopenharmony_ci#define RX_SGE_MASK		(RX_SGE_CNT - 1)
4148c2ecf20Sopenharmony_ci#define NUM_RX_SGE		(RX_SGE_CNT * NUM_RX_SGE_PAGES)
4158c2ecf20Sopenharmony_ci#define MAX_RX_SGE		(NUM_RX_SGE - 1)
4168c2ecf20Sopenharmony_ci#define NEXT_SGE_IDX(x)		((((x) & RX_SGE_MASK) == \
4178c2ecf20Sopenharmony_ci				  (MAX_RX_SGE_CNT - 1)) ? \
4188c2ecf20Sopenharmony_ci					(x) + 1 + NEXT_PAGE_SGE_DESC_CNT : \
4198c2ecf20Sopenharmony_ci					(x) + 1)
4208c2ecf20Sopenharmony_ci#define RX_SGE(x)		((x) & MAX_RX_SGE)
4218c2ecf20Sopenharmony_ci
4228c2ecf20Sopenharmony_ci/*
4238c2ecf20Sopenharmony_ci * Number of required  SGEs is the sum of two:
4248c2ecf20Sopenharmony_ci * 1. Number of possible opened aggregations (next packet for
4258c2ecf20Sopenharmony_ci *    these aggregations will probably consume SGE immediately)
4268c2ecf20Sopenharmony_ci * 2. Rest of BRB blocks divided by 2 (block will consume new SGE only
4278c2ecf20Sopenharmony_ci *    after placement on BD for new TPA aggregation)
4288c2ecf20Sopenharmony_ci *
4298c2ecf20Sopenharmony_ci * Takes into account NEXT_PAGE_SGE_DESC_CNT "next" elements on each page
4308c2ecf20Sopenharmony_ci */
4318c2ecf20Sopenharmony_ci#define NUM_SGE_REQ		(MAX_AGG_QS(bp) + \
4328c2ecf20Sopenharmony_ci					(BRB_SIZE(bp) - MAX_AGG_QS(bp)) / 2)
4338c2ecf20Sopenharmony_ci#define NUM_SGE_PG_REQ		((NUM_SGE_REQ + MAX_RX_SGE_CNT - 1) / \
4348c2ecf20Sopenharmony_ci						MAX_RX_SGE_CNT)
4358c2ecf20Sopenharmony_ci#define SGE_TH_LO(bp)		(NUM_SGE_REQ + \
4368c2ecf20Sopenharmony_ci				 NUM_SGE_PG_REQ * NEXT_PAGE_SGE_DESC_CNT)
4378c2ecf20Sopenharmony_ci#define SGE_TH_HI(bp)		(SGE_TH_LO(bp) + DROPLESS_FC_HEADROOM)
4388c2ecf20Sopenharmony_ci
4398c2ecf20Sopenharmony_ci/* Manipulate a bit vector defined as an array of u64 */
4408c2ecf20Sopenharmony_ci
4418c2ecf20Sopenharmony_ci/* Number of bits in one sge_mask array element */
4428c2ecf20Sopenharmony_ci#define BIT_VEC64_ELEM_SZ		64
4438c2ecf20Sopenharmony_ci#define BIT_VEC64_ELEM_SHIFT		6
4448c2ecf20Sopenharmony_ci#define BIT_VEC64_ELEM_MASK		((u64)BIT_VEC64_ELEM_SZ - 1)
4458c2ecf20Sopenharmony_ci
4468c2ecf20Sopenharmony_ci#define __BIT_VEC64_SET_BIT(el, bit) \
4478c2ecf20Sopenharmony_ci	do { \
4488c2ecf20Sopenharmony_ci		el = ((el) | ((u64)0x1 << (bit))); \
4498c2ecf20Sopenharmony_ci	} while (0)
4508c2ecf20Sopenharmony_ci
4518c2ecf20Sopenharmony_ci#define __BIT_VEC64_CLEAR_BIT(el, bit) \
4528c2ecf20Sopenharmony_ci	do { \
4538c2ecf20Sopenharmony_ci		el = ((el) & (~((u64)0x1 << (bit)))); \
4548c2ecf20Sopenharmony_ci	} while (0)
4558c2ecf20Sopenharmony_ci
4568c2ecf20Sopenharmony_ci#define BIT_VEC64_SET_BIT(vec64, idx) \
4578c2ecf20Sopenharmony_ci	__BIT_VEC64_SET_BIT((vec64)[(idx) >> BIT_VEC64_ELEM_SHIFT], \
4588c2ecf20Sopenharmony_ci			   (idx) & BIT_VEC64_ELEM_MASK)
4598c2ecf20Sopenharmony_ci
4608c2ecf20Sopenharmony_ci#define BIT_VEC64_CLEAR_BIT(vec64, idx) \
4618c2ecf20Sopenharmony_ci	__BIT_VEC64_CLEAR_BIT((vec64)[(idx) >> BIT_VEC64_ELEM_SHIFT], \
4628c2ecf20Sopenharmony_ci			     (idx) & BIT_VEC64_ELEM_MASK)
4638c2ecf20Sopenharmony_ci
4648c2ecf20Sopenharmony_ci#define BIT_VEC64_TEST_BIT(vec64, idx) \
4658c2ecf20Sopenharmony_ci	(((vec64)[(idx) >> BIT_VEC64_ELEM_SHIFT] >> \
4668c2ecf20Sopenharmony_ci	((idx) & BIT_VEC64_ELEM_MASK)) & 0x1)
4678c2ecf20Sopenharmony_ci
4688c2ecf20Sopenharmony_ci/* Creates a bitmask of all ones in less significant bits.
4698c2ecf20Sopenharmony_ci   idx - index of the most significant bit in the created mask */
4708c2ecf20Sopenharmony_ci#define BIT_VEC64_ONES_MASK(idx) \
4718c2ecf20Sopenharmony_ci		(((u64)0x1 << (((idx) & BIT_VEC64_ELEM_MASK) + 1)) - 1)
4728c2ecf20Sopenharmony_ci#define BIT_VEC64_ELEM_ONE_MASK	((u64)(~0))
4738c2ecf20Sopenharmony_ci
4748c2ecf20Sopenharmony_ci/*******************************************************/
4758c2ecf20Sopenharmony_ci
4768c2ecf20Sopenharmony_ci/* Number of u64 elements in SGE mask array */
4778c2ecf20Sopenharmony_ci#define RX_SGE_MASK_LEN			(NUM_RX_SGE / BIT_VEC64_ELEM_SZ)
4788c2ecf20Sopenharmony_ci#define RX_SGE_MASK_LEN_MASK		(RX_SGE_MASK_LEN - 1)
4798c2ecf20Sopenharmony_ci#define NEXT_SGE_MASK_ELEM(el)		(((el) + 1) & RX_SGE_MASK_LEN_MASK)
4808c2ecf20Sopenharmony_ci
4818c2ecf20Sopenharmony_ciunion host_hc_status_block {
4828c2ecf20Sopenharmony_ci	/* pointer to fp status block e1x */
4838c2ecf20Sopenharmony_ci	struct host_hc_status_block_e1x *e1x_sb;
4848c2ecf20Sopenharmony_ci	/* pointer to fp status block e2 */
4858c2ecf20Sopenharmony_ci	struct host_hc_status_block_e2  *e2_sb;
4868c2ecf20Sopenharmony_ci};
4878c2ecf20Sopenharmony_ci
4888c2ecf20Sopenharmony_cistruct bnx2x_agg_info {
4898c2ecf20Sopenharmony_ci	/*
4908c2ecf20Sopenharmony_ci	 * First aggregation buffer is a data buffer, the following - are pages.
4918c2ecf20Sopenharmony_ci	 * We will preallocate the data buffer for each aggregation when
4928c2ecf20Sopenharmony_ci	 * we open the interface and will replace the BD at the consumer
4938c2ecf20Sopenharmony_ci	 * with this one when we receive the TPA_START CQE in order to
4948c2ecf20Sopenharmony_ci	 * keep the Rx BD ring consistent.
4958c2ecf20Sopenharmony_ci	 */
4968c2ecf20Sopenharmony_ci	struct sw_rx_bd		first_buf;
4978c2ecf20Sopenharmony_ci	u8			tpa_state;
4988c2ecf20Sopenharmony_ci#define BNX2X_TPA_START			1
4998c2ecf20Sopenharmony_ci#define BNX2X_TPA_STOP			2
5008c2ecf20Sopenharmony_ci#define BNX2X_TPA_ERROR			3
5018c2ecf20Sopenharmony_ci	u8			placement_offset;
5028c2ecf20Sopenharmony_ci	u16			parsing_flags;
5038c2ecf20Sopenharmony_ci	u16			vlan_tag;
5048c2ecf20Sopenharmony_ci	u16			len_on_bd;
5058c2ecf20Sopenharmony_ci	u32			rxhash;
5068c2ecf20Sopenharmony_ci	enum pkt_hash_types	rxhash_type;
5078c2ecf20Sopenharmony_ci	u16			gro_size;
5088c2ecf20Sopenharmony_ci	u16			full_page;
5098c2ecf20Sopenharmony_ci};
5108c2ecf20Sopenharmony_ci
5118c2ecf20Sopenharmony_ci#define Q_STATS_OFFSET32(stat_name) \
5128c2ecf20Sopenharmony_ci			(offsetof(struct bnx2x_eth_q_stats, stat_name) / 4)
5138c2ecf20Sopenharmony_ci
5148c2ecf20Sopenharmony_cistruct bnx2x_fp_txdata {
5158c2ecf20Sopenharmony_ci
5168c2ecf20Sopenharmony_ci	struct sw_tx_bd		*tx_buf_ring;
5178c2ecf20Sopenharmony_ci
5188c2ecf20Sopenharmony_ci	union eth_tx_bd_types	*tx_desc_ring;
5198c2ecf20Sopenharmony_ci	dma_addr_t		tx_desc_mapping;
5208c2ecf20Sopenharmony_ci
5218c2ecf20Sopenharmony_ci	u32			cid;
5228c2ecf20Sopenharmony_ci
5238c2ecf20Sopenharmony_ci	union db_prod		tx_db;
5248c2ecf20Sopenharmony_ci
5258c2ecf20Sopenharmony_ci	u16			tx_pkt_prod;
5268c2ecf20Sopenharmony_ci	u16			tx_pkt_cons;
5278c2ecf20Sopenharmony_ci	u16			tx_bd_prod;
5288c2ecf20Sopenharmony_ci	u16			tx_bd_cons;
5298c2ecf20Sopenharmony_ci
5308c2ecf20Sopenharmony_ci	unsigned long		tx_pkt;
5318c2ecf20Sopenharmony_ci
5328c2ecf20Sopenharmony_ci	__le16			*tx_cons_sb;
5338c2ecf20Sopenharmony_ci
5348c2ecf20Sopenharmony_ci	int			txq_index;
5358c2ecf20Sopenharmony_ci	struct bnx2x_fastpath	*parent_fp;
5368c2ecf20Sopenharmony_ci	int			tx_ring_size;
5378c2ecf20Sopenharmony_ci};
5388c2ecf20Sopenharmony_ci
5398c2ecf20Sopenharmony_cienum bnx2x_tpa_mode_t {
5408c2ecf20Sopenharmony_ci	TPA_MODE_DISABLED,
5418c2ecf20Sopenharmony_ci	TPA_MODE_LRO,
5428c2ecf20Sopenharmony_ci	TPA_MODE_GRO
5438c2ecf20Sopenharmony_ci};
5448c2ecf20Sopenharmony_ci
5458c2ecf20Sopenharmony_cistruct bnx2x_alloc_pool {
5468c2ecf20Sopenharmony_ci	struct page	*page;
5478c2ecf20Sopenharmony_ci	unsigned int	offset;
5488c2ecf20Sopenharmony_ci};
5498c2ecf20Sopenharmony_ci
5508c2ecf20Sopenharmony_cistruct bnx2x_fastpath {
5518c2ecf20Sopenharmony_ci	struct bnx2x		*bp; /* parent */
5528c2ecf20Sopenharmony_ci
5538c2ecf20Sopenharmony_ci	struct napi_struct	napi;
5548c2ecf20Sopenharmony_ci
5558c2ecf20Sopenharmony_ci	union host_hc_status_block	status_blk;
5568c2ecf20Sopenharmony_ci	/* chip independent shortcuts into sb structure */
5578c2ecf20Sopenharmony_ci	__le16			*sb_index_values;
5588c2ecf20Sopenharmony_ci	__le16			*sb_running_index;
5598c2ecf20Sopenharmony_ci	/* chip independent shortcut into rx_prods_offset memory */
5608c2ecf20Sopenharmony_ci	u32			ustorm_rx_prods_offset;
5618c2ecf20Sopenharmony_ci
5628c2ecf20Sopenharmony_ci	u32			rx_buf_size;
5638c2ecf20Sopenharmony_ci	u32			rx_frag_size; /* 0 if kmalloced(), or rx_buf_size + NET_SKB_PAD */
5648c2ecf20Sopenharmony_ci	dma_addr_t		status_blk_mapping;
5658c2ecf20Sopenharmony_ci
5668c2ecf20Sopenharmony_ci	enum bnx2x_tpa_mode_t	mode;
5678c2ecf20Sopenharmony_ci
5688c2ecf20Sopenharmony_ci	u8			max_cos; /* actual number of active tx coses */
5698c2ecf20Sopenharmony_ci	struct bnx2x_fp_txdata	*txdata_ptr[BNX2X_MULTI_TX_COS];
5708c2ecf20Sopenharmony_ci
5718c2ecf20Sopenharmony_ci	struct sw_rx_bd		*rx_buf_ring;	/* BDs mappings ring */
5728c2ecf20Sopenharmony_ci	struct sw_rx_page	*rx_page_ring;	/* SGE pages mappings ring */
5738c2ecf20Sopenharmony_ci
5748c2ecf20Sopenharmony_ci	struct eth_rx_bd	*rx_desc_ring;
5758c2ecf20Sopenharmony_ci	dma_addr_t		rx_desc_mapping;
5768c2ecf20Sopenharmony_ci
5778c2ecf20Sopenharmony_ci	union eth_rx_cqe	*rx_comp_ring;
5788c2ecf20Sopenharmony_ci	dma_addr_t		rx_comp_mapping;
5798c2ecf20Sopenharmony_ci
5808c2ecf20Sopenharmony_ci	/* SGE ring */
5818c2ecf20Sopenharmony_ci	struct eth_rx_sge	*rx_sge_ring;
5828c2ecf20Sopenharmony_ci	dma_addr_t		rx_sge_mapping;
5838c2ecf20Sopenharmony_ci
5848c2ecf20Sopenharmony_ci	u64			sge_mask[RX_SGE_MASK_LEN];
5858c2ecf20Sopenharmony_ci
5868c2ecf20Sopenharmony_ci	u32			cid;
5878c2ecf20Sopenharmony_ci
5888c2ecf20Sopenharmony_ci	__le16			fp_hc_idx;
5898c2ecf20Sopenharmony_ci
5908c2ecf20Sopenharmony_ci	u8			index;		/* number in fp array */
5918c2ecf20Sopenharmony_ci	u8			rx_queue;	/* index for skb_record */
5928c2ecf20Sopenharmony_ci	u8			cl_id;		/* eth client id */
5938c2ecf20Sopenharmony_ci	u8			cl_qzone_id;
5948c2ecf20Sopenharmony_ci	u8			fw_sb_id;	/* status block number in FW */
5958c2ecf20Sopenharmony_ci	u8			igu_sb_id;	/* status block number in HW */
5968c2ecf20Sopenharmony_ci
5978c2ecf20Sopenharmony_ci	u16			rx_bd_prod;
5988c2ecf20Sopenharmony_ci	u16			rx_bd_cons;
5998c2ecf20Sopenharmony_ci	u16			rx_comp_prod;
6008c2ecf20Sopenharmony_ci	u16			rx_comp_cons;
6018c2ecf20Sopenharmony_ci	u16			rx_sge_prod;
6028c2ecf20Sopenharmony_ci	/* The last maximal completed SGE */
6038c2ecf20Sopenharmony_ci	u16			last_max_sge;
6048c2ecf20Sopenharmony_ci	__le16			*rx_cons_sb;
6058c2ecf20Sopenharmony_ci
6068c2ecf20Sopenharmony_ci	/* TPA related */
6078c2ecf20Sopenharmony_ci	struct bnx2x_agg_info	*tpa_info;
6088c2ecf20Sopenharmony_ci#ifdef BNX2X_STOP_ON_ERROR
6098c2ecf20Sopenharmony_ci	u64			tpa_queue_used;
6108c2ecf20Sopenharmony_ci#endif
6118c2ecf20Sopenharmony_ci	/* The size is calculated using the following:
6128c2ecf20Sopenharmony_ci	     sizeof name field from netdev structure +
6138c2ecf20Sopenharmony_ci	     4 ('-Xx-' string) +
6148c2ecf20Sopenharmony_ci	     4 (for the digits and to make it DWORD aligned) */
6158c2ecf20Sopenharmony_ci#define FP_NAME_SIZE		(sizeof(((struct net_device *)0)->name) + 8)
6168c2ecf20Sopenharmony_ci	char			name[FP_NAME_SIZE];
6178c2ecf20Sopenharmony_ci
6188c2ecf20Sopenharmony_ci	struct bnx2x_alloc_pool	page_pool;
6198c2ecf20Sopenharmony_ci};
6208c2ecf20Sopenharmony_ci
6218c2ecf20Sopenharmony_ci#define bnx2x_fp(bp, nr, var)	((bp)->fp[(nr)].var)
6228c2ecf20Sopenharmony_ci#define bnx2x_sp_obj(bp, fp)	((bp)->sp_objs[(fp)->index])
6238c2ecf20Sopenharmony_ci#define bnx2x_fp_stats(bp, fp)	(&((bp)->fp_stats[(fp)->index]))
6248c2ecf20Sopenharmony_ci#define bnx2x_fp_qstats(bp, fp)	(&((bp)->fp_stats[(fp)->index].eth_q_stats))
6258c2ecf20Sopenharmony_ci
6268c2ecf20Sopenharmony_ci/* Use 2500 as a mini-jumbo MTU for FCoE */
6278c2ecf20Sopenharmony_ci#define BNX2X_FCOE_MINI_JUMBO_MTU	2500
6288c2ecf20Sopenharmony_ci
6298c2ecf20Sopenharmony_ci#define	FCOE_IDX_OFFSET		0
6308c2ecf20Sopenharmony_ci
6318c2ecf20Sopenharmony_ci#define FCOE_IDX(bp)		(BNX2X_NUM_NON_CNIC_QUEUES(bp) + \
6328c2ecf20Sopenharmony_ci				 FCOE_IDX_OFFSET)
6338c2ecf20Sopenharmony_ci#define bnx2x_fcoe_fp(bp)	(&bp->fp[FCOE_IDX(bp)])
6348c2ecf20Sopenharmony_ci#define bnx2x_fcoe(bp, var)	(bnx2x_fcoe_fp(bp)->var)
6358c2ecf20Sopenharmony_ci#define bnx2x_fcoe_inner_sp_obj(bp)	(&bp->sp_objs[FCOE_IDX(bp)])
6368c2ecf20Sopenharmony_ci#define bnx2x_fcoe_sp_obj(bp, var)	(bnx2x_fcoe_inner_sp_obj(bp)->var)
6378c2ecf20Sopenharmony_ci#define bnx2x_fcoe_tx(bp, var)	(bnx2x_fcoe_fp(bp)-> \
6388c2ecf20Sopenharmony_ci						txdata_ptr[FIRST_TX_COS_INDEX] \
6398c2ecf20Sopenharmony_ci						->var)
6408c2ecf20Sopenharmony_ci
6418c2ecf20Sopenharmony_ci#define IS_ETH_FP(fp)		((fp)->index < BNX2X_NUM_ETH_QUEUES((fp)->bp))
6428c2ecf20Sopenharmony_ci#define IS_FCOE_FP(fp)		((fp)->index == FCOE_IDX((fp)->bp))
6438c2ecf20Sopenharmony_ci#define IS_FCOE_IDX(idx)	((idx) == FCOE_IDX(bp))
6448c2ecf20Sopenharmony_ci
6458c2ecf20Sopenharmony_ci/* MC hsi */
6468c2ecf20Sopenharmony_ci#define MAX_FETCH_BD		13	/* HW max BDs per packet */
6478c2ecf20Sopenharmony_ci#define RX_COPY_THRESH		92
6488c2ecf20Sopenharmony_ci
6498c2ecf20Sopenharmony_ci#define NUM_TX_RINGS		16
6508c2ecf20Sopenharmony_ci#define TX_DESC_CNT		(BCM_PAGE_SIZE / sizeof(union eth_tx_bd_types))
6518c2ecf20Sopenharmony_ci#define NEXT_PAGE_TX_DESC_CNT	1
6528c2ecf20Sopenharmony_ci#define MAX_TX_DESC_CNT		(TX_DESC_CNT - NEXT_PAGE_TX_DESC_CNT)
6538c2ecf20Sopenharmony_ci#define NUM_TX_BD		(TX_DESC_CNT * NUM_TX_RINGS)
6548c2ecf20Sopenharmony_ci#define MAX_TX_BD		(NUM_TX_BD - 1)
6558c2ecf20Sopenharmony_ci#define MAX_TX_AVAIL		(MAX_TX_DESC_CNT * NUM_TX_RINGS - 2)
6568c2ecf20Sopenharmony_ci#define NEXT_TX_IDX(x)		((((x) & MAX_TX_DESC_CNT) == \
6578c2ecf20Sopenharmony_ci				  (MAX_TX_DESC_CNT - 1)) ? \
6588c2ecf20Sopenharmony_ci					(x) + 1 + NEXT_PAGE_TX_DESC_CNT : \
6598c2ecf20Sopenharmony_ci					(x) + 1)
6608c2ecf20Sopenharmony_ci#define TX_BD(x)		((x) & MAX_TX_BD)
6618c2ecf20Sopenharmony_ci#define TX_BD_POFF(x)		((x) & MAX_TX_DESC_CNT)
6628c2ecf20Sopenharmony_ci
6638c2ecf20Sopenharmony_ci/* number of NEXT_PAGE descriptors may be required during placement */
6648c2ecf20Sopenharmony_ci#define NEXT_CNT_PER_TX_PKT(bds)	\
6658c2ecf20Sopenharmony_ci				(((bds) + MAX_TX_DESC_CNT - 1) / \
6668c2ecf20Sopenharmony_ci				 MAX_TX_DESC_CNT * NEXT_PAGE_TX_DESC_CNT)
6678c2ecf20Sopenharmony_ci/* max BDs per tx packet w/o next_pages:
6688c2ecf20Sopenharmony_ci * START_BD		- describes packed
6698c2ecf20Sopenharmony_ci * START_BD(splitted)	- includes unpaged data segment for GSO
6708c2ecf20Sopenharmony_ci * PARSING_BD		- for TSO and CSUM data
6718c2ecf20Sopenharmony_ci * PARSING_BD2		- for encapsulation data
6728c2ecf20Sopenharmony_ci * Frag BDs		- describes pages for frags
6738c2ecf20Sopenharmony_ci */
6748c2ecf20Sopenharmony_ci#define BDS_PER_TX_PKT		4
6758c2ecf20Sopenharmony_ci#define MAX_BDS_PER_TX_PKT	(MAX_SKB_FRAGS + BDS_PER_TX_PKT)
6768c2ecf20Sopenharmony_ci/* max BDs per tx packet including next pages */
6778c2ecf20Sopenharmony_ci#define MAX_DESC_PER_TX_PKT	(MAX_BDS_PER_TX_PKT + \
6788c2ecf20Sopenharmony_ci				 NEXT_CNT_PER_TX_PKT(MAX_BDS_PER_TX_PKT))
6798c2ecf20Sopenharmony_ci
6808c2ecf20Sopenharmony_ci/* The RX BD ring is special, each bd is 8 bytes but the last one is 16 */
6818c2ecf20Sopenharmony_ci#define NUM_RX_RINGS		8
6828c2ecf20Sopenharmony_ci#define RX_DESC_CNT		(BCM_PAGE_SIZE / sizeof(struct eth_rx_bd))
6838c2ecf20Sopenharmony_ci#define NEXT_PAGE_RX_DESC_CNT	2
6848c2ecf20Sopenharmony_ci#define MAX_RX_DESC_CNT		(RX_DESC_CNT - NEXT_PAGE_RX_DESC_CNT)
6858c2ecf20Sopenharmony_ci#define RX_DESC_MASK		(RX_DESC_CNT - 1)
6868c2ecf20Sopenharmony_ci#define NUM_RX_BD		(RX_DESC_CNT * NUM_RX_RINGS)
6878c2ecf20Sopenharmony_ci#define MAX_RX_BD		(NUM_RX_BD - 1)
6888c2ecf20Sopenharmony_ci#define MAX_RX_AVAIL		(MAX_RX_DESC_CNT * NUM_RX_RINGS - 2)
6898c2ecf20Sopenharmony_ci
6908c2ecf20Sopenharmony_ci/* dropless fc calculations for BDs
6918c2ecf20Sopenharmony_ci *
6928c2ecf20Sopenharmony_ci * Number of BDs should as number of buffers in BRB:
6938c2ecf20Sopenharmony_ci * Low threshold takes into account NEXT_PAGE_RX_DESC_CNT
6948c2ecf20Sopenharmony_ci * "next" elements on each page
6958c2ecf20Sopenharmony_ci */
6968c2ecf20Sopenharmony_ci#define NUM_BD_REQ		BRB_SIZE(bp)
6978c2ecf20Sopenharmony_ci#define NUM_BD_PG_REQ		((NUM_BD_REQ + MAX_RX_DESC_CNT - 1) / \
6988c2ecf20Sopenharmony_ci					      MAX_RX_DESC_CNT)
6998c2ecf20Sopenharmony_ci#define BD_TH_LO(bp)		(NUM_BD_REQ + \
7008c2ecf20Sopenharmony_ci				 NUM_BD_PG_REQ * NEXT_PAGE_RX_DESC_CNT + \
7018c2ecf20Sopenharmony_ci				 FW_DROP_LEVEL(bp))
7028c2ecf20Sopenharmony_ci#define BD_TH_HI(bp)		(BD_TH_LO(bp) + DROPLESS_FC_HEADROOM)
7038c2ecf20Sopenharmony_ci
7048c2ecf20Sopenharmony_ci#define MIN_RX_AVAIL		((bp)->dropless_fc ? BD_TH_HI(bp) + 128 : 128)
7058c2ecf20Sopenharmony_ci
7068c2ecf20Sopenharmony_ci#define MIN_RX_SIZE_TPA_HW	(CHIP_IS_E1(bp) ? \
7078c2ecf20Sopenharmony_ci					ETH_MIN_RX_CQES_WITH_TPA_E1 : \
7088c2ecf20Sopenharmony_ci					ETH_MIN_RX_CQES_WITH_TPA_E1H_E2)
7098c2ecf20Sopenharmony_ci#define MIN_RX_SIZE_NONTPA_HW   ETH_MIN_RX_CQES_WITHOUT_TPA
7108c2ecf20Sopenharmony_ci#define MIN_RX_SIZE_TPA		(max_t(u32, MIN_RX_SIZE_TPA_HW, MIN_RX_AVAIL))
7118c2ecf20Sopenharmony_ci#define MIN_RX_SIZE_NONTPA	(max_t(u32, MIN_RX_SIZE_NONTPA_HW,\
7128c2ecf20Sopenharmony_ci								MIN_RX_AVAIL))
7138c2ecf20Sopenharmony_ci
7148c2ecf20Sopenharmony_ci#define NEXT_RX_IDX(x)		((((x) & RX_DESC_MASK) == \
7158c2ecf20Sopenharmony_ci				  (MAX_RX_DESC_CNT - 1)) ? \
7168c2ecf20Sopenharmony_ci					(x) + 1 + NEXT_PAGE_RX_DESC_CNT : \
7178c2ecf20Sopenharmony_ci					(x) + 1)
7188c2ecf20Sopenharmony_ci#define RX_BD(x)		((x) & MAX_RX_BD)
7198c2ecf20Sopenharmony_ci
7208c2ecf20Sopenharmony_ci/*
7218c2ecf20Sopenharmony_ci * As long as CQE is X times bigger than BD entry we have to allocate X times
7228c2ecf20Sopenharmony_ci * more pages for CQ ring in order to keep it balanced with BD ring
7238c2ecf20Sopenharmony_ci */
7248c2ecf20Sopenharmony_ci#define CQE_BD_REL	(sizeof(union eth_rx_cqe) / sizeof(struct eth_rx_bd))
7258c2ecf20Sopenharmony_ci#define NUM_RCQ_RINGS		(NUM_RX_RINGS * CQE_BD_REL)
7268c2ecf20Sopenharmony_ci#define RCQ_DESC_CNT		(BCM_PAGE_SIZE / sizeof(union eth_rx_cqe))
7278c2ecf20Sopenharmony_ci#define NEXT_PAGE_RCQ_DESC_CNT	1
7288c2ecf20Sopenharmony_ci#define MAX_RCQ_DESC_CNT	(RCQ_DESC_CNT - NEXT_PAGE_RCQ_DESC_CNT)
7298c2ecf20Sopenharmony_ci#define NUM_RCQ_BD		(RCQ_DESC_CNT * NUM_RCQ_RINGS)
7308c2ecf20Sopenharmony_ci#define MAX_RCQ_BD		(NUM_RCQ_BD - 1)
7318c2ecf20Sopenharmony_ci#define MAX_RCQ_AVAIL		(MAX_RCQ_DESC_CNT * NUM_RCQ_RINGS - 2)
7328c2ecf20Sopenharmony_ci#define NEXT_RCQ_IDX(x)		((((x) & MAX_RCQ_DESC_CNT) == \
7338c2ecf20Sopenharmony_ci				  (MAX_RCQ_DESC_CNT - 1)) ? \
7348c2ecf20Sopenharmony_ci					(x) + 1 + NEXT_PAGE_RCQ_DESC_CNT : \
7358c2ecf20Sopenharmony_ci					(x) + 1)
7368c2ecf20Sopenharmony_ci#define RCQ_BD(x)		((x) & MAX_RCQ_BD)
7378c2ecf20Sopenharmony_ci
7388c2ecf20Sopenharmony_ci/* dropless fc calculations for RCQs
7398c2ecf20Sopenharmony_ci *
7408c2ecf20Sopenharmony_ci * Number of RCQs should be as number of buffers in BRB:
7418c2ecf20Sopenharmony_ci * Low threshold takes into account NEXT_PAGE_RCQ_DESC_CNT
7428c2ecf20Sopenharmony_ci * "next" elements on each page
7438c2ecf20Sopenharmony_ci */
7448c2ecf20Sopenharmony_ci#define NUM_RCQ_REQ		BRB_SIZE(bp)
7458c2ecf20Sopenharmony_ci#define NUM_RCQ_PG_REQ		((NUM_BD_REQ + MAX_RCQ_DESC_CNT - 1) / \
7468c2ecf20Sopenharmony_ci					      MAX_RCQ_DESC_CNT)
7478c2ecf20Sopenharmony_ci#define RCQ_TH_LO(bp)		(NUM_RCQ_REQ + \
7488c2ecf20Sopenharmony_ci				 NUM_RCQ_PG_REQ * NEXT_PAGE_RCQ_DESC_CNT + \
7498c2ecf20Sopenharmony_ci				 FW_DROP_LEVEL(bp))
7508c2ecf20Sopenharmony_ci#define RCQ_TH_HI(bp)		(RCQ_TH_LO(bp) + DROPLESS_FC_HEADROOM)
7518c2ecf20Sopenharmony_ci
7528c2ecf20Sopenharmony_ci/* This is needed for determining of last_max */
7538c2ecf20Sopenharmony_ci#define SUB_S16(a, b)		(s16)((s16)(a) - (s16)(b))
7548c2ecf20Sopenharmony_ci#define SUB_S32(a, b)		(s32)((s32)(a) - (s32)(b))
7558c2ecf20Sopenharmony_ci
7568c2ecf20Sopenharmony_ci#define BNX2X_SWCID_SHIFT	17
7578c2ecf20Sopenharmony_ci#define BNX2X_SWCID_MASK	((0x1 << BNX2X_SWCID_SHIFT) - 1)
7588c2ecf20Sopenharmony_ci
7598c2ecf20Sopenharmony_ci/* used on a CID received from the HW */
7608c2ecf20Sopenharmony_ci#define SW_CID(x)			(le32_to_cpu(x) & BNX2X_SWCID_MASK)
7618c2ecf20Sopenharmony_ci#define CQE_CMD(x)			(le32_to_cpu(x) >> \
7628c2ecf20Sopenharmony_ci					COMMON_RAMROD_ETH_RX_CQE_CMD_ID_SHIFT)
7638c2ecf20Sopenharmony_ci
7648c2ecf20Sopenharmony_ci#define BD_UNMAP_ADDR(bd)		HILO_U64(le32_to_cpu((bd)->addr_hi), \
7658c2ecf20Sopenharmony_ci						 le32_to_cpu((bd)->addr_lo))
7668c2ecf20Sopenharmony_ci#define BD_UNMAP_LEN(bd)		(le16_to_cpu((bd)->nbytes))
7678c2ecf20Sopenharmony_ci
7688c2ecf20Sopenharmony_ci#define BNX2X_DB_MIN_SHIFT		3	/* 8 bytes */
7698c2ecf20Sopenharmony_ci#define BNX2X_DB_SHIFT			3	/* 8 bytes*/
7708c2ecf20Sopenharmony_ci#if (BNX2X_DB_SHIFT < BNX2X_DB_MIN_SHIFT)
7718c2ecf20Sopenharmony_ci#error "Min DB doorbell stride is 8"
7728c2ecf20Sopenharmony_ci#endif
7738c2ecf20Sopenharmony_ci#define DOORBELL_RELAXED(bp, cid, val) \
7748c2ecf20Sopenharmony_ci	writel_relaxed((u32)(val), (bp)->doorbells + ((bp)->db_size * (cid)))
7758c2ecf20Sopenharmony_ci
7768c2ecf20Sopenharmony_ci/* TX CSUM helpers */
7778c2ecf20Sopenharmony_ci#define SKB_CS_OFF(skb)		(offsetof(struct tcphdr, check) - \
7788c2ecf20Sopenharmony_ci				 skb->csum_offset)
7798c2ecf20Sopenharmony_ci#define SKB_CS(skb)		(*(u16 *)(skb_transport_header(skb) + \
7808c2ecf20Sopenharmony_ci					  skb->csum_offset))
7818c2ecf20Sopenharmony_ci
7828c2ecf20Sopenharmony_ci#define pbd_tcp_flags(tcp_hdr)	(ntohl(tcp_flag_word(tcp_hdr))>>16 & 0xff)
7838c2ecf20Sopenharmony_ci
7848c2ecf20Sopenharmony_ci#define XMIT_PLAIN		0
7858c2ecf20Sopenharmony_ci#define XMIT_CSUM_V4		(1 << 0)
7868c2ecf20Sopenharmony_ci#define XMIT_CSUM_V6		(1 << 1)
7878c2ecf20Sopenharmony_ci#define XMIT_CSUM_TCP		(1 << 2)
7888c2ecf20Sopenharmony_ci#define XMIT_GSO_V4		(1 << 3)
7898c2ecf20Sopenharmony_ci#define XMIT_GSO_V6		(1 << 4)
7908c2ecf20Sopenharmony_ci#define XMIT_CSUM_ENC_V4	(1 << 5)
7918c2ecf20Sopenharmony_ci#define XMIT_CSUM_ENC_V6	(1 << 6)
7928c2ecf20Sopenharmony_ci#define XMIT_GSO_ENC_V4		(1 << 7)
7938c2ecf20Sopenharmony_ci#define XMIT_GSO_ENC_V6		(1 << 8)
7948c2ecf20Sopenharmony_ci
7958c2ecf20Sopenharmony_ci#define XMIT_CSUM_ENC		(XMIT_CSUM_ENC_V4 | XMIT_CSUM_ENC_V6)
7968c2ecf20Sopenharmony_ci#define XMIT_GSO_ENC		(XMIT_GSO_ENC_V4 | XMIT_GSO_ENC_V6)
7978c2ecf20Sopenharmony_ci
7988c2ecf20Sopenharmony_ci#define XMIT_CSUM		(XMIT_CSUM_V4 | XMIT_CSUM_V6 | XMIT_CSUM_ENC)
7998c2ecf20Sopenharmony_ci#define XMIT_GSO		(XMIT_GSO_V4 | XMIT_GSO_V6 | XMIT_GSO_ENC)
8008c2ecf20Sopenharmony_ci
8018c2ecf20Sopenharmony_ci/* stuff added to make the code fit 80Col */
8028c2ecf20Sopenharmony_ci#define CQE_TYPE(cqe_fp_flags)	 ((cqe_fp_flags) & ETH_FAST_PATH_RX_CQE_TYPE)
8038c2ecf20Sopenharmony_ci#define CQE_TYPE_START(cqe_type) ((cqe_type) == RX_ETH_CQE_TYPE_ETH_START_AGG)
8048c2ecf20Sopenharmony_ci#define CQE_TYPE_STOP(cqe_type)  ((cqe_type) == RX_ETH_CQE_TYPE_ETH_STOP_AGG)
8058c2ecf20Sopenharmony_ci#define CQE_TYPE_SLOW(cqe_type)  ((cqe_type) == RX_ETH_CQE_TYPE_ETH_RAMROD)
8068c2ecf20Sopenharmony_ci#define CQE_TYPE_FAST(cqe_type)  ((cqe_type) == RX_ETH_CQE_TYPE_ETH_FASTPATH)
8078c2ecf20Sopenharmony_ci
8088c2ecf20Sopenharmony_ci#define ETH_RX_ERROR_FALGS		ETH_FAST_PATH_RX_CQE_PHY_DECODE_ERR_FLG
8098c2ecf20Sopenharmony_ci
8108c2ecf20Sopenharmony_ci#define BNX2X_PRS_FLAG_OVERETH_IPV4(flags) \
8118c2ecf20Sopenharmony_ci				(((le16_to_cpu(flags) & \
8128c2ecf20Sopenharmony_ci				   PARSING_FLAGS_OVER_ETHERNET_PROTOCOL) >> \
8138c2ecf20Sopenharmony_ci				  PARSING_FLAGS_OVER_ETHERNET_PROTOCOL_SHIFT) \
8148c2ecf20Sopenharmony_ci				 == PRS_FLAG_OVERETH_IPV4)
8158c2ecf20Sopenharmony_ci#define BNX2X_RX_SUM_FIX(cqe) \
8168c2ecf20Sopenharmony_ci	BNX2X_PRS_FLAG_OVERETH_IPV4(cqe->fast_path_cqe.pars_flags.flags)
8178c2ecf20Sopenharmony_ci
8188c2ecf20Sopenharmony_ci#define FP_USB_FUNC_OFF	\
8198c2ecf20Sopenharmony_ci			offsetof(struct cstorm_status_block_u, func)
8208c2ecf20Sopenharmony_ci#define FP_CSB_FUNC_OFF	\
8218c2ecf20Sopenharmony_ci			offsetof(struct cstorm_status_block_c, func)
8228c2ecf20Sopenharmony_ci
8238c2ecf20Sopenharmony_ci#define HC_INDEX_ETH_RX_CQ_CONS		1
8248c2ecf20Sopenharmony_ci
8258c2ecf20Sopenharmony_ci#define HC_INDEX_OOO_TX_CQ_CONS		4
8268c2ecf20Sopenharmony_ci
8278c2ecf20Sopenharmony_ci#define HC_INDEX_ETH_TX_CQ_CONS_COS0	5
8288c2ecf20Sopenharmony_ci
8298c2ecf20Sopenharmony_ci#define HC_INDEX_ETH_TX_CQ_CONS_COS1	6
8308c2ecf20Sopenharmony_ci
8318c2ecf20Sopenharmony_ci#define HC_INDEX_ETH_TX_CQ_CONS_COS2	7
8328c2ecf20Sopenharmony_ci
8338c2ecf20Sopenharmony_ci#define HC_INDEX_ETH_FIRST_TX_CQ_CONS	HC_INDEX_ETH_TX_CQ_CONS_COS0
8348c2ecf20Sopenharmony_ci
8358c2ecf20Sopenharmony_ci#define BNX2X_RX_SB_INDEX \
8368c2ecf20Sopenharmony_ci	(&fp->sb_index_values[HC_INDEX_ETH_RX_CQ_CONS])
8378c2ecf20Sopenharmony_ci
8388c2ecf20Sopenharmony_ci#define BNX2X_TX_SB_INDEX_BASE BNX2X_TX_SB_INDEX_COS0
8398c2ecf20Sopenharmony_ci
8408c2ecf20Sopenharmony_ci#define BNX2X_TX_SB_INDEX_COS0 \
8418c2ecf20Sopenharmony_ci	(&fp->sb_index_values[HC_INDEX_ETH_TX_CQ_CONS_COS0])
8428c2ecf20Sopenharmony_ci
8438c2ecf20Sopenharmony_ci/* end of fast path */
8448c2ecf20Sopenharmony_ci
8458c2ecf20Sopenharmony_ci/* common */
8468c2ecf20Sopenharmony_ci
8478c2ecf20Sopenharmony_cistruct bnx2x_common {
8488c2ecf20Sopenharmony_ci
8498c2ecf20Sopenharmony_ci	u32			chip_id;
8508c2ecf20Sopenharmony_ci/* chip num:16-31, rev:12-15, metal:4-11, bond_id:0-3 */
8518c2ecf20Sopenharmony_ci#define CHIP_ID(bp)			(bp->common.chip_id & 0xfffffff0)
8528c2ecf20Sopenharmony_ci
8538c2ecf20Sopenharmony_ci#define CHIP_NUM(bp)			(bp->common.chip_id >> 16)
8548c2ecf20Sopenharmony_ci#define CHIP_NUM_57710			0x164e
8558c2ecf20Sopenharmony_ci#define CHIP_NUM_57711			0x164f
8568c2ecf20Sopenharmony_ci#define CHIP_NUM_57711E			0x1650
8578c2ecf20Sopenharmony_ci#define CHIP_NUM_57712			0x1662
8588c2ecf20Sopenharmony_ci#define CHIP_NUM_57712_MF		0x1663
8598c2ecf20Sopenharmony_ci#define CHIP_NUM_57712_VF		0x166f
8608c2ecf20Sopenharmony_ci#define CHIP_NUM_57713			0x1651
8618c2ecf20Sopenharmony_ci#define CHIP_NUM_57713E			0x1652
8628c2ecf20Sopenharmony_ci#define CHIP_NUM_57800			0x168a
8638c2ecf20Sopenharmony_ci#define CHIP_NUM_57800_MF		0x16a5
8648c2ecf20Sopenharmony_ci#define CHIP_NUM_57800_VF		0x16a9
8658c2ecf20Sopenharmony_ci#define CHIP_NUM_57810			0x168e
8668c2ecf20Sopenharmony_ci#define CHIP_NUM_57810_MF		0x16ae
8678c2ecf20Sopenharmony_ci#define CHIP_NUM_57810_VF		0x16af
8688c2ecf20Sopenharmony_ci#define CHIP_NUM_57811			0x163d
8698c2ecf20Sopenharmony_ci#define CHIP_NUM_57811_MF		0x163e
8708c2ecf20Sopenharmony_ci#define CHIP_NUM_57811_VF		0x163f
8718c2ecf20Sopenharmony_ci#define CHIP_NUM_57840_OBSOLETE		0x168d
8728c2ecf20Sopenharmony_ci#define CHIP_NUM_57840_MF_OBSOLETE	0x16ab
8738c2ecf20Sopenharmony_ci#define CHIP_NUM_57840_4_10		0x16a1
8748c2ecf20Sopenharmony_ci#define CHIP_NUM_57840_2_20		0x16a2
8758c2ecf20Sopenharmony_ci#define CHIP_NUM_57840_MF		0x16a4
8768c2ecf20Sopenharmony_ci#define CHIP_NUM_57840_VF		0x16ad
8778c2ecf20Sopenharmony_ci#define CHIP_IS_E1(bp)			(CHIP_NUM(bp) == CHIP_NUM_57710)
8788c2ecf20Sopenharmony_ci#define CHIP_IS_57711(bp)		(CHIP_NUM(bp) == CHIP_NUM_57711)
8798c2ecf20Sopenharmony_ci#define CHIP_IS_57711E(bp)		(CHIP_NUM(bp) == CHIP_NUM_57711E)
8808c2ecf20Sopenharmony_ci#define CHIP_IS_57712(bp)		(CHIP_NUM(bp) == CHIP_NUM_57712)
8818c2ecf20Sopenharmony_ci#define CHIP_IS_57712_VF(bp)		(CHIP_NUM(bp) == CHIP_NUM_57712_VF)
8828c2ecf20Sopenharmony_ci#define CHIP_IS_57712_MF(bp)		(CHIP_NUM(bp) == CHIP_NUM_57712_MF)
8838c2ecf20Sopenharmony_ci#define CHIP_IS_57800(bp)		(CHIP_NUM(bp) == CHIP_NUM_57800)
8848c2ecf20Sopenharmony_ci#define CHIP_IS_57800_MF(bp)		(CHIP_NUM(bp) == CHIP_NUM_57800_MF)
8858c2ecf20Sopenharmony_ci#define CHIP_IS_57800_VF(bp)		(CHIP_NUM(bp) == CHIP_NUM_57800_VF)
8868c2ecf20Sopenharmony_ci#define CHIP_IS_57810(bp)		(CHIP_NUM(bp) == CHIP_NUM_57810)
8878c2ecf20Sopenharmony_ci#define CHIP_IS_57810_MF(bp)		(CHIP_NUM(bp) == CHIP_NUM_57810_MF)
8888c2ecf20Sopenharmony_ci#define CHIP_IS_57810_VF(bp)		(CHIP_NUM(bp) == CHIP_NUM_57810_VF)
8898c2ecf20Sopenharmony_ci#define CHIP_IS_57811(bp)		(CHIP_NUM(bp) == CHIP_NUM_57811)
8908c2ecf20Sopenharmony_ci#define CHIP_IS_57811_MF(bp)		(CHIP_NUM(bp) == CHIP_NUM_57811_MF)
8918c2ecf20Sopenharmony_ci#define CHIP_IS_57811_VF(bp)		(CHIP_NUM(bp) == CHIP_NUM_57811_VF)
8928c2ecf20Sopenharmony_ci#define CHIP_IS_57840(bp)		\
8938c2ecf20Sopenharmony_ci		((CHIP_NUM(bp) == CHIP_NUM_57840_4_10) || \
8948c2ecf20Sopenharmony_ci		 (CHIP_NUM(bp) == CHIP_NUM_57840_2_20) || \
8958c2ecf20Sopenharmony_ci		 (CHIP_NUM(bp) == CHIP_NUM_57840_OBSOLETE))
8968c2ecf20Sopenharmony_ci#define CHIP_IS_57840_MF(bp)	((CHIP_NUM(bp) == CHIP_NUM_57840_MF) || \
8978c2ecf20Sopenharmony_ci				 (CHIP_NUM(bp) == CHIP_NUM_57840_MF_OBSOLETE))
8988c2ecf20Sopenharmony_ci#define CHIP_IS_57840_VF(bp)		(CHIP_NUM(bp) == CHIP_NUM_57840_VF)
8998c2ecf20Sopenharmony_ci#define CHIP_IS_E1H(bp)			(CHIP_IS_57711(bp) || \
9008c2ecf20Sopenharmony_ci					 CHIP_IS_57711E(bp))
9018c2ecf20Sopenharmony_ci#define CHIP_IS_57811xx(bp)		(CHIP_IS_57811(bp) || \
9028c2ecf20Sopenharmony_ci					 CHIP_IS_57811_MF(bp) || \
9038c2ecf20Sopenharmony_ci					 CHIP_IS_57811_VF(bp))
9048c2ecf20Sopenharmony_ci#define CHIP_IS_E2(bp)			(CHIP_IS_57712(bp) || \
9058c2ecf20Sopenharmony_ci					 CHIP_IS_57712_MF(bp) || \
9068c2ecf20Sopenharmony_ci					 CHIP_IS_57712_VF(bp))
9078c2ecf20Sopenharmony_ci#define CHIP_IS_E3(bp)			(CHIP_IS_57800(bp) || \
9088c2ecf20Sopenharmony_ci					 CHIP_IS_57800_MF(bp) || \
9098c2ecf20Sopenharmony_ci					 CHIP_IS_57800_VF(bp) || \
9108c2ecf20Sopenharmony_ci					 CHIP_IS_57810(bp) || \
9118c2ecf20Sopenharmony_ci					 CHIP_IS_57810_MF(bp) || \
9128c2ecf20Sopenharmony_ci					 CHIP_IS_57810_VF(bp) || \
9138c2ecf20Sopenharmony_ci					 CHIP_IS_57811xx(bp) || \
9148c2ecf20Sopenharmony_ci					 CHIP_IS_57840(bp) || \
9158c2ecf20Sopenharmony_ci					 CHIP_IS_57840_MF(bp) || \
9168c2ecf20Sopenharmony_ci					 CHIP_IS_57840_VF(bp))
9178c2ecf20Sopenharmony_ci#define CHIP_IS_E1x(bp)			(CHIP_IS_E1((bp)) || CHIP_IS_E1H((bp)))
9188c2ecf20Sopenharmony_ci#define USES_WARPCORE(bp)		(CHIP_IS_E3(bp))
9198c2ecf20Sopenharmony_ci#define IS_E1H_OFFSET			(!CHIP_IS_E1(bp))
9208c2ecf20Sopenharmony_ci
9218c2ecf20Sopenharmony_ci#define CHIP_REV_SHIFT			12
9228c2ecf20Sopenharmony_ci#define CHIP_REV_MASK			(0xF << CHIP_REV_SHIFT)
9238c2ecf20Sopenharmony_ci#define CHIP_REV_VAL(bp)		(bp->common.chip_id & CHIP_REV_MASK)
9248c2ecf20Sopenharmony_ci#define CHIP_REV_Ax			(0x0 << CHIP_REV_SHIFT)
9258c2ecf20Sopenharmony_ci#define CHIP_REV_Bx			(0x1 << CHIP_REV_SHIFT)
9268c2ecf20Sopenharmony_ci/* assume maximum 5 revisions */
9278c2ecf20Sopenharmony_ci#define CHIP_REV_IS_SLOW(bp)		(CHIP_REV_VAL(bp) > 0x00005000)
9288c2ecf20Sopenharmony_ci/* Emul versions are A=>0xe, B=>0xc, C=>0xa, D=>8, E=>6 */
9298c2ecf20Sopenharmony_ci#define CHIP_REV_IS_EMUL(bp)		((CHIP_REV_IS_SLOW(bp)) && \
9308c2ecf20Sopenharmony_ci					 !(CHIP_REV_VAL(bp) & 0x00001000))
9318c2ecf20Sopenharmony_ci/* FPGA versions are A=>0xf, B=>0xd, C=>0xb, D=>9, E=>7 */
9328c2ecf20Sopenharmony_ci#define CHIP_REV_IS_FPGA(bp)		((CHIP_REV_IS_SLOW(bp)) && \
9338c2ecf20Sopenharmony_ci					 (CHIP_REV_VAL(bp) & 0x00001000))
9348c2ecf20Sopenharmony_ci
9358c2ecf20Sopenharmony_ci#define CHIP_TIME(bp)			((CHIP_REV_IS_EMUL(bp)) ? 2000 : \
9368c2ecf20Sopenharmony_ci					((CHIP_REV_IS_FPGA(bp)) ? 200 : 1))
9378c2ecf20Sopenharmony_ci
9388c2ecf20Sopenharmony_ci#define CHIP_METAL(bp)			(bp->common.chip_id & 0x00000ff0)
9398c2ecf20Sopenharmony_ci#define CHIP_BOND_ID(bp)		(bp->common.chip_id & 0x0000000f)
9408c2ecf20Sopenharmony_ci#define CHIP_REV_SIM(bp)		(((CHIP_REV_MASK - CHIP_REV_VAL(bp)) >>\
9418c2ecf20Sopenharmony_ci					   (CHIP_REV_SHIFT + 1)) \
9428c2ecf20Sopenharmony_ci						<< CHIP_REV_SHIFT)
9438c2ecf20Sopenharmony_ci#define CHIP_REV(bp)			(CHIP_REV_IS_SLOW(bp) ? \
9448c2ecf20Sopenharmony_ci						CHIP_REV_SIM(bp) :\
9458c2ecf20Sopenharmony_ci						CHIP_REV_VAL(bp))
9468c2ecf20Sopenharmony_ci#define CHIP_IS_E3B0(bp)		(CHIP_IS_E3(bp) && \
9478c2ecf20Sopenharmony_ci					 (CHIP_REV(bp) == CHIP_REV_Bx))
9488c2ecf20Sopenharmony_ci#define CHIP_IS_E3A0(bp)		(CHIP_IS_E3(bp) && \
9498c2ecf20Sopenharmony_ci					 (CHIP_REV(bp) == CHIP_REV_Ax))
9508c2ecf20Sopenharmony_ci/* This define is used in two main places:
9518c2ecf20Sopenharmony_ci * 1. In the early stages of nic_load, to know if to configure Parser / Searcher
9528c2ecf20Sopenharmony_ci * to nic-only mode or to offload mode. Offload mode is configured if either the
9538c2ecf20Sopenharmony_ci * chip is E1x (where MIC_MODE register is not applicable), or if cnic already
9548c2ecf20Sopenharmony_ci * registered for this port (which means that the user wants storage services).
9558c2ecf20Sopenharmony_ci * 2. During cnic-related load, to know if offload mode is already configured in
9568c2ecf20Sopenharmony_ci * the HW or needs to be configured.
9578c2ecf20Sopenharmony_ci * Since the transition from nic-mode to offload-mode in HW causes traffic
9588c2ecf20Sopenharmony_ci * corruption, nic-mode is configured only in ports on which storage services
9598c2ecf20Sopenharmony_ci * where never requested.
9608c2ecf20Sopenharmony_ci */
9618c2ecf20Sopenharmony_ci#define CONFIGURE_NIC_MODE(bp)		(!CHIP_IS_E1x(bp) && !CNIC_ENABLED(bp))
9628c2ecf20Sopenharmony_ci
9638c2ecf20Sopenharmony_ci	int			flash_size;
9648c2ecf20Sopenharmony_ci#define BNX2X_NVRAM_1MB_SIZE			0x20000	/* 1M bit in bytes */
9658c2ecf20Sopenharmony_ci#define BNX2X_NVRAM_TIMEOUT_COUNT		30000
9668c2ecf20Sopenharmony_ci#define BNX2X_NVRAM_PAGE_SIZE			256
9678c2ecf20Sopenharmony_ci
9688c2ecf20Sopenharmony_ci	u32			shmem_base;
9698c2ecf20Sopenharmony_ci	u32			shmem2_base;
9708c2ecf20Sopenharmony_ci	u32			mf_cfg_base;
9718c2ecf20Sopenharmony_ci	u32			mf2_cfg_base;
9728c2ecf20Sopenharmony_ci
9738c2ecf20Sopenharmony_ci	u32			hw_config;
9748c2ecf20Sopenharmony_ci
9758c2ecf20Sopenharmony_ci	u32			bc_ver;
9768c2ecf20Sopenharmony_ci
9778c2ecf20Sopenharmony_ci	u8			int_block;
9788c2ecf20Sopenharmony_ci#define INT_BLOCK_HC			0
9798c2ecf20Sopenharmony_ci#define INT_BLOCK_IGU			1
9808c2ecf20Sopenharmony_ci#define INT_BLOCK_MODE_NORMAL		0
9818c2ecf20Sopenharmony_ci#define INT_BLOCK_MODE_BW_COMP		2
9828c2ecf20Sopenharmony_ci#define CHIP_INT_MODE_IS_NBC(bp)		\
9838c2ecf20Sopenharmony_ci			(!CHIP_IS_E1x(bp) &&	\
9848c2ecf20Sopenharmony_ci			!((bp)->common.int_block & INT_BLOCK_MODE_BW_COMP))
9858c2ecf20Sopenharmony_ci#define CHIP_INT_MODE_IS_BC(bp) (!CHIP_INT_MODE_IS_NBC(bp))
9868c2ecf20Sopenharmony_ci
9878c2ecf20Sopenharmony_ci	u8			chip_port_mode;
9888c2ecf20Sopenharmony_ci#define CHIP_4_PORT_MODE			0x0
9898c2ecf20Sopenharmony_ci#define CHIP_2_PORT_MODE			0x1
9908c2ecf20Sopenharmony_ci#define CHIP_PORT_MODE_NONE			0x2
9918c2ecf20Sopenharmony_ci#define CHIP_MODE(bp)			(bp->common.chip_port_mode)
9928c2ecf20Sopenharmony_ci#define CHIP_MODE_IS_4_PORT(bp) (CHIP_MODE(bp) == CHIP_4_PORT_MODE)
9938c2ecf20Sopenharmony_ci
9948c2ecf20Sopenharmony_ci	u32			boot_mode;
9958c2ecf20Sopenharmony_ci};
9968c2ecf20Sopenharmony_ci
9978c2ecf20Sopenharmony_ci/* IGU MSIX STATISTICS on 57712: 64 for VFs; 4 for PFs; 4 for Attentions */
9988c2ecf20Sopenharmony_ci#define BNX2X_IGU_STAS_MSG_VF_CNT 64
9998c2ecf20Sopenharmony_ci#define BNX2X_IGU_STAS_MSG_PF_CNT 4
10008c2ecf20Sopenharmony_ci
10018c2ecf20Sopenharmony_ci#define MAX_IGU_ATTN_ACK_TO       100
10028c2ecf20Sopenharmony_ci/* end of common */
10038c2ecf20Sopenharmony_ci
10048c2ecf20Sopenharmony_ci/* port */
10058c2ecf20Sopenharmony_ci
10068c2ecf20Sopenharmony_cistruct bnx2x_port {
10078c2ecf20Sopenharmony_ci	u32			pmf;
10088c2ecf20Sopenharmony_ci
10098c2ecf20Sopenharmony_ci	u32			link_config[LINK_CONFIG_SIZE];
10108c2ecf20Sopenharmony_ci
10118c2ecf20Sopenharmony_ci	u32			supported[LINK_CONFIG_SIZE];
10128c2ecf20Sopenharmony_ci
10138c2ecf20Sopenharmony_ci	u32			advertising[LINK_CONFIG_SIZE];
10148c2ecf20Sopenharmony_ci
10158c2ecf20Sopenharmony_ci	u32			phy_addr;
10168c2ecf20Sopenharmony_ci
10178c2ecf20Sopenharmony_ci	/* used to synchronize phy accesses */
10188c2ecf20Sopenharmony_ci	struct mutex		phy_mutex;
10198c2ecf20Sopenharmony_ci
10208c2ecf20Sopenharmony_ci	u32			port_stx;
10218c2ecf20Sopenharmony_ci
10228c2ecf20Sopenharmony_ci	struct nig_stats	old_nig_stats;
10238c2ecf20Sopenharmony_ci};
10248c2ecf20Sopenharmony_ci
10258c2ecf20Sopenharmony_ci/* end of port */
10268c2ecf20Sopenharmony_ci
10278c2ecf20Sopenharmony_ci#define STATS_OFFSET32(stat_name) \
10288c2ecf20Sopenharmony_ci			(offsetof(struct bnx2x_eth_stats, stat_name) / 4)
10298c2ecf20Sopenharmony_ci
10308c2ecf20Sopenharmony_ci/* slow path */
10318c2ecf20Sopenharmony_ci#define BNX2X_MAX_NUM_OF_VFS	64
10328c2ecf20Sopenharmony_ci#define BNX2X_VF_CID_WND	4 /* log num of queues per VF. HW config. */
10338c2ecf20Sopenharmony_ci#define BNX2X_CIDS_PER_VF	(1 << BNX2X_VF_CID_WND)
10348c2ecf20Sopenharmony_ci
10358c2ecf20Sopenharmony_ci/* We need to reserve doorbell addresses for all VF and queue combinations */
10368c2ecf20Sopenharmony_ci#define BNX2X_VF_CIDS		(BNX2X_MAX_NUM_OF_VFS * BNX2X_CIDS_PER_VF)
10378c2ecf20Sopenharmony_ci
10388c2ecf20Sopenharmony_ci/* The doorbell is configured to have the same number of CIDs for PFs and for
10398c2ecf20Sopenharmony_ci * VFs. For this reason the PF CID zone is as large as the VF zone.
10408c2ecf20Sopenharmony_ci */
10418c2ecf20Sopenharmony_ci#define BNX2X_FIRST_VF_CID	BNX2X_VF_CIDS
10428c2ecf20Sopenharmony_ci#define BNX2X_MAX_NUM_VF_QUEUES	64
10438c2ecf20Sopenharmony_ci#define BNX2X_VF_ID_INVALID	0xFF
10448c2ecf20Sopenharmony_ci
10458c2ecf20Sopenharmony_ci/* the number of VF CIDS multiplied by the amount of bytes reserved for each
10468c2ecf20Sopenharmony_ci * cid must not exceed the size of the VF doorbell
10478c2ecf20Sopenharmony_ci */
10488c2ecf20Sopenharmony_ci#define BNX2X_VF_BAR_SIZE	512
10498c2ecf20Sopenharmony_ci#if (BNX2X_VF_BAR_SIZE < BNX2X_CIDS_PER_VF * (1 << BNX2X_DB_SHIFT))
10508c2ecf20Sopenharmony_ci#error "VF doorbell bar size is 512"
10518c2ecf20Sopenharmony_ci#endif
10528c2ecf20Sopenharmony_ci
10538c2ecf20Sopenharmony_ci/*
10548c2ecf20Sopenharmony_ci * The total number of L2 queues, MSIX vectors and HW contexts (CIDs) is
10558c2ecf20Sopenharmony_ci * control by the number of fast-path status blocks supported by the
10568c2ecf20Sopenharmony_ci * device (HW/FW). Each fast-path status block (FP-SB) aka non-default
10578c2ecf20Sopenharmony_ci * status block represents an independent interrupts context that can
10588c2ecf20Sopenharmony_ci * serve a regular L2 networking queue. However special L2 queues such
10598c2ecf20Sopenharmony_ci * as the FCoE queue do not require a FP-SB and other components like
10608c2ecf20Sopenharmony_ci * the CNIC may consume FP-SB reducing the number of possible L2 queues
10618c2ecf20Sopenharmony_ci *
10628c2ecf20Sopenharmony_ci * If the maximum number of FP-SB available is X then:
10638c2ecf20Sopenharmony_ci * a. If CNIC is supported it consumes 1 FP-SB thus the max number of
10648c2ecf20Sopenharmony_ci *    regular L2 queues is Y=X-1
10658c2ecf20Sopenharmony_ci * b. In MF mode the actual number of L2 queues is Y= (X-1/MF_factor)
10668c2ecf20Sopenharmony_ci * c. If the FCoE L2 queue is supported the actual number of L2 queues
10678c2ecf20Sopenharmony_ci *    is Y+1
10688c2ecf20Sopenharmony_ci * d. The number of irqs (MSIX vectors) is either Y+1 (one extra for
10698c2ecf20Sopenharmony_ci *    slow-path interrupts) or Y+2 if CNIC is supported (one additional
10708c2ecf20Sopenharmony_ci *    FP interrupt context for the CNIC).
10718c2ecf20Sopenharmony_ci * e. The number of HW context (CID count) is always X or X+1 if FCoE
10728c2ecf20Sopenharmony_ci *    L2 queue is supported. The cid for the FCoE L2 queue is always X.
10738c2ecf20Sopenharmony_ci */
10748c2ecf20Sopenharmony_ci
10758c2ecf20Sopenharmony_ci/* fast-path interrupt contexts E1x */
10768c2ecf20Sopenharmony_ci#define FP_SB_MAX_E1x		16
10778c2ecf20Sopenharmony_ci/* fast-path interrupt contexts E2 */
10788c2ecf20Sopenharmony_ci#define FP_SB_MAX_E2		HC_SB_MAX_SB_E2
10798c2ecf20Sopenharmony_ci
10808c2ecf20Sopenharmony_ciunion cdu_context {
10818c2ecf20Sopenharmony_ci	struct eth_context eth;
10828c2ecf20Sopenharmony_ci	char pad[1024];
10838c2ecf20Sopenharmony_ci};
10848c2ecf20Sopenharmony_ci
10858c2ecf20Sopenharmony_ci/* CDU host DB constants */
10868c2ecf20Sopenharmony_ci#define CDU_ILT_PAGE_SZ_HW	2
10878c2ecf20Sopenharmony_ci#define CDU_ILT_PAGE_SZ		(8192 << CDU_ILT_PAGE_SZ_HW) /* 32K */
10888c2ecf20Sopenharmony_ci#define ILT_PAGE_CIDS		(CDU_ILT_PAGE_SZ / sizeof(union cdu_context))
10898c2ecf20Sopenharmony_ci
10908c2ecf20Sopenharmony_ci#define CNIC_ISCSI_CID_MAX	256
10918c2ecf20Sopenharmony_ci#define CNIC_FCOE_CID_MAX	2048
10928c2ecf20Sopenharmony_ci#define CNIC_CID_MAX		(CNIC_ISCSI_CID_MAX + CNIC_FCOE_CID_MAX)
10938c2ecf20Sopenharmony_ci#define CNIC_ILT_LINES		DIV_ROUND_UP(CNIC_CID_MAX, ILT_PAGE_CIDS)
10948c2ecf20Sopenharmony_ci
10958c2ecf20Sopenharmony_ci#define QM_ILT_PAGE_SZ_HW	0
10968c2ecf20Sopenharmony_ci#define QM_ILT_PAGE_SZ		(4096 << QM_ILT_PAGE_SZ_HW) /* 4K */
10978c2ecf20Sopenharmony_ci#define QM_CID_ROUND		1024
10988c2ecf20Sopenharmony_ci
10998c2ecf20Sopenharmony_ci/* TM (timers) host DB constants */
11008c2ecf20Sopenharmony_ci#define TM_ILT_PAGE_SZ_HW	0
11018c2ecf20Sopenharmony_ci#define TM_ILT_PAGE_SZ		(4096 << TM_ILT_PAGE_SZ_HW) /* 4K */
11028c2ecf20Sopenharmony_ci#define TM_CONN_NUM		(BNX2X_FIRST_VF_CID + \
11038c2ecf20Sopenharmony_ci				 BNX2X_VF_CIDS + \
11048c2ecf20Sopenharmony_ci				 CNIC_ISCSI_CID_MAX)
11058c2ecf20Sopenharmony_ci#define TM_ILT_SZ		(8 * TM_CONN_NUM)
11068c2ecf20Sopenharmony_ci#define TM_ILT_LINES		DIV_ROUND_UP(TM_ILT_SZ, TM_ILT_PAGE_SZ)
11078c2ecf20Sopenharmony_ci
11088c2ecf20Sopenharmony_ci/* SRC (Searcher) host DB constants */
11098c2ecf20Sopenharmony_ci#define SRC_ILT_PAGE_SZ_HW	0
11108c2ecf20Sopenharmony_ci#define SRC_ILT_PAGE_SZ		(4096 << SRC_ILT_PAGE_SZ_HW) /* 4K */
11118c2ecf20Sopenharmony_ci#define SRC_HASH_BITS		10
11128c2ecf20Sopenharmony_ci#define SRC_CONN_NUM		(1 << SRC_HASH_BITS) /* 1024 */
11138c2ecf20Sopenharmony_ci#define SRC_ILT_SZ		(sizeof(struct src_ent) * SRC_CONN_NUM)
11148c2ecf20Sopenharmony_ci#define SRC_T2_SZ		SRC_ILT_SZ
11158c2ecf20Sopenharmony_ci#define SRC_ILT_LINES		DIV_ROUND_UP(SRC_ILT_SZ, SRC_ILT_PAGE_SZ)
11168c2ecf20Sopenharmony_ci
11178c2ecf20Sopenharmony_ci#define MAX_DMAE_C		8
11188c2ecf20Sopenharmony_ci
11198c2ecf20Sopenharmony_ci/* DMA memory not used in fastpath */
11208c2ecf20Sopenharmony_cistruct bnx2x_slowpath {
11218c2ecf20Sopenharmony_ci	union {
11228c2ecf20Sopenharmony_ci		struct mac_configuration_cmd		e1x;
11238c2ecf20Sopenharmony_ci		struct eth_classify_rules_ramrod_data	e2;
11248c2ecf20Sopenharmony_ci	} mac_rdata;
11258c2ecf20Sopenharmony_ci
11268c2ecf20Sopenharmony_ci	union {
11278c2ecf20Sopenharmony_ci		struct eth_classify_rules_ramrod_data	e2;
11288c2ecf20Sopenharmony_ci	} vlan_rdata;
11298c2ecf20Sopenharmony_ci
11308c2ecf20Sopenharmony_ci	union {
11318c2ecf20Sopenharmony_ci		struct tstorm_eth_mac_filter_config	e1x;
11328c2ecf20Sopenharmony_ci		struct eth_filter_rules_ramrod_data	e2;
11338c2ecf20Sopenharmony_ci	} rx_mode_rdata;
11348c2ecf20Sopenharmony_ci
11358c2ecf20Sopenharmony_ci	union {
11368c2ecf20Sopenharmony_ci		struct mac_configuration_cmd		e1;
11378c2ecf20Sopenharmony_ci		struct eth_multicast_rules_ramrod_data  e2;
11388c2ecf20Sopenharmony_ci	} mcast_rdata;
11398c2ecf20Sopenharmony_ci
11408c2ecf20Sopenharmony_ci	struct eth_rss_update_ramrod_data	rss_rdata;
11418c2ecf20Sopenharmony_ci
11428c2ecf20Sopenharmony_ci	/* Queue State related ramrods are always sent under rtnl_lock */
11438c2ecf20Sopenharmony_ci	union {
11448c2ecf20Sopenharmony_ci		struct client_init_ramrod_data  init_data;
11458c2ecf20Sopenharmony_ci		struct client_update_ramrod_data update_data;
11468c2ecf20Sopenharmony_ci		struct tpa_update_ramrod_data tpa_data;
11478c2ecf20Sopenharmony_ci	} q_rdata;
11488c2ecf20Sopenharmony_ci
11498c2ecf20Sopenharmony_ci	union {
11508c2ecf20Sopenharmony_ci		struct function_start_data	func_start;
11518c2ecf20Sopenharmony_ci		/* pfc configuration for DCBX ramrod */
11528c2ecf20Sopenharmony_ci		struct flow_control_configuration pfc_config;
11538c2ecf20Sopenharmony_ci	} func_rdata;
11548c2ecf20Sopenharmony_ci
11558c2ecf20Sopenharmony_ci	/* afex ramrod can not be a part of func_rdata union because these
11568c2ecf20Sopenharmony_ci	 * events might arrive in parallel to other events from func_rdata.
11578c2ecf20Sopenharmony_ci	 * Therefore, if they would have been defined in the same union,
11588c2ecf20Sopenharmony_ci	 * data can get corrupted.
11598c2ecf20Sopenharmony_ci	 */
11608c2ecf20Sopenharmony_ci	union {
11618c2ecf20Sopenharmony_ci		struct afex_vif_list_ramrod_data	viflist_data;
11628c2ecf20Sopenharmony_ci		struct function_update_data		func_update;
11638c2ecf20Sopenharmony_ci	} func_afex_rdata;
11648c2ecf20Sopenharmony_ci
11658c2ecf20Sopenharmony_ci	/* used by dmae command executer */
11668c2ecf20Sopenharmony_ci	struct dmae_command		dmae[MAX_DMAE_C];
11678c2ecf20Sopenharmony_ci
11688c2ecf20Sopenharmony_ci	u32				stats_comp;
11698c2ecf20Sopenharmony_ci	union mac_stats			mac_stats;
11708c2ecf20Sopenharmony_ci	struct nig_stats		nig_stats;
11718c2ecf20Sopenharmony_ci	struct host_port_stats		port_stats;
11728c2ecf20Sopenharmony_ci	struct host_func_stats		func_stats;
11738c2ecf20Sopenharmony_ci
11748c2ecf20Sopenharmony_ci	u32				wb_comp;
11758c2ecf20Sopenharmony_ci	u32				wb_data[4];
11768c2ecf20Sopenharmony_ci
11778c2ecf20Sopenharmony_ci	union drv_info_to_mcp		drv_info_to_mcp;
11788c2ecf20Sopenharmony_ci};
11798c2ecf20Sopenharmony_ci
11808c2ecf20Sopenharmony_ci#define bnx2x_sp(bp, var)		(&bp->slowpath->var)
11818c2ecf20Sopenharmony_ci#define bnx2x_sp_mapping(bp, var) \
11828c2ecf20Sopenharmony_ci		(bp->slowpath_mapping + offsetof(struct bnx2x_slowpath, var))
11838c2ecf20Sopenharmony_ci
11848c2ecf20Sopenharmony_ci/* attn group wiring */
11858c2ecf20Sopenharmony_ci#define MAX_DYNAMIC_ATTN_GRPS		8
11868c2ecf20Sopenharmony_ci
11878c2ecf20Sopenharmony_cistruct attn_route {
11888c2ecf20Sopenharmony_ci	u32 sig[5];
11898c2ecf20Sopenharmony_ci};
11908c2ecf20Sopenharmony_ci
11918c2ecf20Sopenharmony_cistruct iro {
11928c2ecf20Sopenharmony_ci	u32 base;
11938c2ecf20Sopenharmony_ci	u16 m1;
11948c2ecf20Sopenharmony_ci	u16 m2;
11958c2ecf20Sopenharmony_ci	u16 m3;
11968c2ecf20Sopenharmony_ci	u16 size;
11978c2ecf20Sopenharmony_ci};
11988c2ecf20Sopenharmony_ci
11998c2ecf20Sopenharmony_cistruct hw_context {
12008c2ecf20Sopenharmony_ci	union cdu_context *vcxt;
12018c2ecf20Sopenharmony_ci	dma_addr_t cxt_mapping;
12028c2ecf20Sopenharmony_ci	size_t size;
12038c2ecf20Sopenharmony_ci};
12048c2ecf20Sopenharmony_ci
12058c2ecf20Sopenharmony_ci/* forward */
12068c2ecf20Sopenharmony_cistruct bnx2x_ilt;
12078c2ecf20Sopenharmony_ci
12088c2ecf20Sopenharmony_cistruct bnx2x_vfdb;
12098c2ecf20Sopenharmony_ci
12108c2ecf20Sopenharmony_cienum bnx2x_recovery_state {
12118c2ecf20Sopenharmony_ci	BNX2X_RECOVERY_DONE,
12128c2ecf20Sopenharmony_ci	BNX2X_RECOVERY_INIT,
12138c2ecf20Sopenharmony_ci	BNX2X_RECOVERY_WAIT,
12148c2ecf20Sopenharmony_ci	BNX2X_RECOVERY_FAILED,
12158c2ecf20Sopenharmony_ci	BNX2X_RECOVERY_NIC_LOADING
12168c2ecf20Sopenharmony_ci};
12178c2ecf20Sopenharmony_ci
12188c2ecf20Sopenharmony_ci/*
12198c2ecf20Sopenharmony_ci * Event queue (EQ or event ring) MC hsi
12208c2ecf20Sopenharmony_ci * NUM_EQ_PAGES and EQ_DESC_CNT_PAGE must be power of 2
12218c2ecf20Sopenharmony_ci */
12228c2ecf20Sopenharmony_ci#define NUM_EQ_PAGES		1
12238c2ecf20Sopenharmony_ci#define EQ_DESC_CNT_PAGE	(BCM_PAGE_SIZE / sizeof(union event_ring_elem))
12248c2ecf20Sopenharmony_ci#define EQ_DESC_MAX_PAGE	(EQ_DESC_CNT_PAGE - 1)
12258c2ecf20Sopenharmony_ci#define NUM_EQ_DESC		(EQ_DESC_CNT_PAGE * NUM_EQ_PAGES)
12268c2ecf20Sopenharmony_ci#define EQ_DESC_MASK		(NUM_EQ_DESC - 1)
12278c2ecf20Sopenharmony_ci#define MAX_EQ_AVAIL		(EQ_DESC_MAX_PAGE * NUM_EQ_PAGES - 2)
12288c2ecf20Sopenharmony_ci
12298c2ecf20Sopenharmony_ci/* depends on EQ_DESC_CNT_PAGE being a power of 2 */
12308c2ecf20Sopenharmony_ci#define NEXT_EQ_IDX(x)		((((x) & EQ_DESC_MAX_PAGE) == \
12318c2ecf20Sopenharmony_ci				  (EQ_DESC_MAX_PAGE - 1)) ? (x) + 2 : (x) + 1)
12328c2ecf20Sopenharmony_ci
12338c2ecf20Sopenharmony_ci/* depends on the above and on NUM_EQ_PAGES being a power of 2 */
12348c2ecf20Sopenharmony_ci#define EQ_DESC(x)		((x) & EQ_DESC_MASK)
12358c2ecf20Sopenharmony_ci
12368c2ecf20Sopenharmony_ci#define BNX2X_EQ_INDEX \
12378c2ecf20Sopenharmony_ci	(&bp->def_status_blk->sp_sb.\
12388c2ecf20Sopenharmony_ci	index_values[HC_SP_INDEX_EQ_CONS])
12398c2ecf20Sopenharmony_ci
12408c2ecf20Sopenharmony_ci/* This is a data that will be used to create a link report message.
12418c2ecf20Sopenharmony_ci * We will keep the data used for the last link report in order
12428c2ecf20Sopenharmony_ci * to prevent reporting the same link parameters twice.
12438c2ecf20Sopenharmony_ci */
12448c2ecf20Sopenharmony_cistruct bnx2x_link_report_data {
12458c2ecf20Sopenharmony_ci	u16 line_speed;			/* Effective line speed */
12468c2ecf20Sopenharmony_ci	unsigned long link_report_flags;/* BNX2X_LINK_REPORT_XXX flags */
12478c2ecf20Sopenharmony_ci};
12488c2ecf20Sopenharmony_ci
12498c2ecf20Sopenharmony_cienum {
12508c2ecf20Sopenharmony_ci	BNX2X_LINK_REPORT_FD,		/* Full DUPLEX */
12518c2ecf20Sopenharmony_ci	BNX2X_LINK_REPORT_LINK_DOWN,
12528c2ecf20Sopenharmony_ci	BNX2X_LINK_REPORT_RX_FC_ON,
12538c2ecf20Sopenharmony_ci	BNX2X_LINK_REPORT_TX_FC_ON,
12548c2ecf20Sopenharmony_ci};
12558c2ecf20Sopenharmony_ci
12568c2ecf20Sopenharmony_cienum {
12578c2ecf20Sopenharmony_ci	BNX2X_PORT_QUERY_IDX,
12588c2ecf20Sopenharmony_ci	BNX2X_PF_QUERY_IDX,
12598c2ecf20Sopenharmony_ci	BNX2X_FCOE_QUERY_IDX,
12608c2ecf20Sopenharmony_ci	BNX2X_FIRST_QUEUE_QUERY_IDX,
12618c2ecf20Sopenharmony_ci};
12628c2ecf20Sopenharmony_ci
12638c2ecf20Sopenharmony_cistruct bnx2x_fw_stats_req {
12648c2ecf20Sopenharmony_ci	struct stats_query_header hdr;
12658c2ecf20Sopenharmony_ci	struct stats_query_entry query[FP_SB_MAX_E1x+
12668c2ecf20Sopenharmony_ci		BNX2X_FIRST_QUEUE_QUERY_IDX];
12678c2ecf20Sopenharmony_ci};
12688c2ecf20Sopenharmony_ci
12698c2ecf20Sopenharmony_cistruct bnx2x_fw_stats_data {
12708c2ecf20Sopenharmony_ci	struct stats_counter		storm_counters;
12718c2ecf20Sopenharmony_ci	struct per_port_stats		port;
12728c2ecf20Sopenharmony_ci	struct per_pf_stats		pf;
12738c2ecf20Sopenharmony_ci	struct fcoe_statistics_params	fcoe;
12748c2ecf20Sopenharmony_ci	struct per_queue_stats		queue_stats[1];
12758c2ecf20Sopenharmony_ci};
12768c2ecf20Sopenharmony_ci
12778c2ecf20Sopenharmony_ci/* Public slow path states */
12788c2ecf20Sopenharmony_cienum sp_rtnl_flag {
12798c2ecf20Sopenharmony_ci	BNX2X_SP_RTNL_SETUP_TC,
12808c2ecf20Sopenharmony_ci	BNX2X_SP_RTNL_TX_TIMEOUT,
12818c2ecf20Sopenharmony_ci	BNX2X_SP_RTNL_FAN_FAILURE,
12828c2ecf20Sopenharmony_ci	BNX2X_SP_RTNL_AFEX_F_UPDATE,
12838c2ecf20Sopenharmony_ci	BNX2X_SP_RTNL_ENABLE_SRIOV,
12848c2ecf20Sopenharmony_ci	BNX2X_SP_RTNL_VFPF_MCAST,
12858c2ecf20Sopenharmony_ci	BNX2X_SP_RTNL_VFPF_CHANNEL_DOWN,
12868c2ecf20Sopenharmony_ci	BNX2X_SP_RTNL_RX_MODE,
12878c2ecf20Sopenharmony_ci	BNX2X_SP_RTNL_HYPERVISOR_VLAN,
12888c2ecf20Sopenharmony_ci	BNX2X_SP_RTNL_TX_STOP,
12898c2ecf20Sopenharmony_ci	BNX2X_SP_RTNL_GET_DRV_VERSION,
12908c2ecf20Sopenharmony_ci	BNX2X_SP_RTNL_UPDATE_SVID,
12918c2ecf20Sopenharmony_ci};
12928c2ecf20Sopenharmony_ci
12938c2ecf20Sopenharmony_cienum bnx2x_iov_flag {
12948c2ecf20Sopenharmony_ci	BNX2X_IOV_HANDLE_VF_MSG,
12958c2ecf20Sopenharmony_ci	BNX2X_IOV_HANDLE_FLR,
12968c2ecf20Sopenharmony_ci};
12978c2ecf20Sopenharmony_ci
12988c2ecf20Sopenharmony_cistruct bnx2x_prev_path_list {
12998c2ecf20Sopenharmony_ci	struct list_head list;
13008c2ecf20Sopenharmony_ci	u8 bus;
13018c2ecf20Sopenharmony_ci	u8 slot;
13028c2ecf20Sopenharmony_ci	u8 path;
13038c2ecf20Sopenharmony_ci	u8 aer;
13048c2ecf20Sopenharmony_ci	u8 undi;
13058c2ecf20Sopenharmony_ci};
13068c2ecf20Sopenharmony_ci
13078c2ecf20Sopenharmony_cistruct bnx2x_sp_objs {
13088c2ecf20Sopenharmony_ci	/* MACs object */
13098c2ecf20Sopenharmony_ci	struct bnx2x_vlan_mac_obj mac_obj;
13108c2ecf20Sopenharmony_ci
13118c2ecf20Sopenharmony_ci	/* Queue State object */
13128c2ecf20Sopenharmony_ci	struct bnx2x_queue_sp_obj q_obj;
13138c2ecf20Sopenharmony_ci
13148c2ecf20Sopenharmony_ci	/* VLANs object */
13158c2ecf20Sopenharmony_ci	struct bnx2x_vlan_mac_obj vlan_obj;
13168c2ecf20Sopenharmony_ci};
13178c2ecf20Sopenharmony_ci
13188c2ecf20Sopenharmony_cistruct bnx2x_fp_stats {
13198c2ecf20Sopenharmony_ci	struct tstorm_per_queue_stats old_tclient;
13208c2ecf20Sopenharmony_ci	struct ustorm_per_queue_stats old_uclient;
13218c2ecf20Sopenharmony_ci	struct xstorm_per_queue_stats old_xclient;
13228c2ecf20Sopenharmony_ci	struct bnx2x_eth_q_stats eth_q_stats;
13238c2ecf20Sopenharmony_ci	struct bnx2x_eth_q_stats_old eth_q_stats_old;
13248c2ecf20Sopenharmony_ci};
13258c2ecf20Sopenharmony_ci
13268c2ecf20Sopenharmony_cienum {
13278c2ecf20Sopenharmony_ci	SUB_MF_MODE_UNKNOWN = 0,
13288c2ecf20Sopenharmony_ci	SUB_MF_MODE_UFP,
13298c2ecf20Sopenharmony_ci	SUB_MF_MODE_NPAR1_DOT_5,
13308c2ecf20Sopenharmony_ci	SUB_MF_MODE_BD,
13318c2ecf20Sopenharmony_ci};
13328c2ecf20Sopenharmony_ci
13338c2ecf20Sopenharmony_cistruct bnx2x_vlan_entry {
13348c2ecf20Sopenharmony_ci	struct list_head link;
13358c2ecf20Sopenharmony_ci	u16 vid;
13368c2ecf20Sopenharmony_ci	bool hw;
13378c2ecf20Sopenharmony_ci};
13388c2ecf20Sopenharmony_ci
13398c2ecf20Sopenharmony_cienum bnx2x_udp_port_type {
13408c2ecf20Sopenharmony_ci	BNX2X_UDP_PORT_VXLAN,
13418c2ecf20Sopenharmony_ci	BNX2X_UDP_PORT_GENEVE,
13428c2ecf20Sopenharmony_ci	BNX2X_UDP_PORT_MAX,
13438c2ecf20Sopenharmony_ci};
13448c2ecf20Sopenharmony_ci
13458c2ecf20Sopenharmony_cistruct bnx2x {
13468c2ecf20Sopenharmony_ci	/* Fields used in the tx and intr/napi performance paths
13478c2ecf20Sopenharmony_ci	 * are grouped together in the beginning of the structure
13488c2ecf20Sopenharmony_ci	 */
13498c2ecf20Sopenharmony_ci	struct bnx2x_fastpath	*fp;
13508c2ecf20Sopenharmony_ci	struct bnx2x_sp_objs	*sp_objs;
13518c2ecf20Sopenharmony_ci	struct bnx2x_fp_stats	*fp_stats;
13528c2ecf20Sopenharmony_ci	struct bnx2x_fp_txdata	*bnx2x_txq;
13538c2ecf20Sopenharmony_ci	void __iomem		*regview;
13548c2ecf20Sopenharmony_ci	void __iomem		*doorbells;
13558c2ecf20Sopenharmony_ci	u16			db_size;
13568c2ecf20Sopenharmony_ci
13578c2ecf20Sopenharmony_ci	u8			pf_num;	/* absolute PF number */
13588c2ecf20Sopenharmony_ci	u8			pfid;	/* per-path PF number */
13598c2ecf20Sopenharmony_ci	int			base_fw_ndsb; /**/
13608c2ecf20Sopenharmony_ci#define BP_PATH(bp)			(CHIP_IS_E1x(bp) ? 0 : (bp->pf_num & 1))
13618c2ecf20Sopenharmony_ci#define BP_PORT(bp)			(bp->pfid & 1)
13628c2ecf20Sopenharmony_ci#define BP_FUNC(bp)			(bp->pfid)
13638c2ecf20Sopenharmony_ci#define BP_ABS_FUNC(bp)			(bp->pf_num)
13648c2ecf20Sopenharmony_ci#define BP_VN(bp)			((bp)->pfid >> 1)
13658c2ecf20Sopenharmony_ci#define BP_MAX_VN_NUM(bp)		(CHIP_MODE_IS_4_PORT(bp) ? 2 : 4)
13668c2ecf20Sopenharmony_ci#define BP_L_ID(bp)			(BP_VN(bp) << 2)
13678c2ecf20Sopenharmony_ci#define BP_FW_MB_IDX_VN(bp, vn)		(BP_PORT(bp) +\
13688c2ecf20Sopenharmony_ci	  (vn) * ((CHIP_IS_E1x(bp) || (CHIP_MODE_IS_4_PORT(bp))) ? 2  : 1))
13698c2ecf20Sopenharmony_ci#define BP_FW_MB_IDX(bp)		BP_FW_MB_IDX_VN(bp, BP_VN(bp))
13708c2ecf20Sopenharmony_ci
13718c2ecf20Sopenharmony_ci#ifdef CONFIG_BNX2X_SRIOV
13728c2ecf20Sopenharmony_ci	/* protects vf2pf mailbox from simultaneous access */
13738c2ecf20Sopenharmony_ci	struct mutex		vf2pf_mutex;
13748c2ecf20Sopenharmony_ci	/* vf pf channel mailbox contains request and response buffers */
13758c2ecf20Sopenharmony_ci	struct bnx2x_vf_mbx_msg	*vf2pf_mbox;
13768c2ecf20Sopenharmony_ci	dma_addr_t		vf2pf_mbox_mapping;
13778c2ecf20Sopenharmony_ci
13788c2ecf20Sopenharmony_ci	/* we set aside a copy of the acquire response */
13798c2ecf20Sopenharmony_ci	struct pfvf_acquire_resp_tlv acquire_resp;
13808c2ecf20Sopenharmony_ci
13818c2ecf20Sopenharmony_ci	/* bulletin board for messages from pf to vf */
13828c2ecf20Sopenharmony_ci	union pf_vf_bulletin   *pf2vf_bulletin;
13838c2ecf20Sopenharmony_ci	dma_addr_t		pf2vf_bulletin_mapping;
13848c2ecf20Sopenharmony_ci
13858c2ecf20Sopenharmony_ci	union pf_vf_bulletin		shadow_bulletin;
13868c2ecf20Sopenharmony_ci	struct pf_vf_bulletin_content	old_bulletin;
13878c2ecf20Sopenharmony_ci
13888c2ecf20Sopenharmony_ci	u16 requested_nr_virtfn;
13898c2ecf20Sopenharmony_ci#endif /* CONFIG_BNX2X_SRIOV */
13908c2ecf20Sopenharmony_ci
13918c2ecf20Sopenharmony_ci	struct net_device	*dev;
13928c2ecf20Sopenharmony_ci	struct pci_dev		*pdev;
13938c2ecf20Sopenharmony_ci
13948c2ecf20Sopenharmony_ci	const struct iro	*iro_arr;
13958c2ecf20Sopenharmony_ci#define IRO (bp->iro_arr)
13968c2ecf20Sopenharmony_ci
13978c2ecf20Sopenharmony_ci	enum bnx2x_recovery_state recovery_state;
13988c2ecf20Sopenharmony_ci	int			is_leader;
13998c2ecf20Sopenharmony_ci	struct msix_entry	*msix_table;
14008c2ecf20Sopenharmony_ci
14018c2ecf20Sopenharmony_ci	int			tx_ring_size;
14028c2ecf20Sopenharmony_ci
14038c2ecf20Sopenharmony_ci/* L2 header size + 2*VLANs (8 bytes) + LLC SNAP (8 bytes) */
14048c2ecf20Sopenharmony_ci#define ETH_OVERHEAD		(ETH_HLEN + 8 + 8)
14058c2ecf20Sopenharmony_ci#define ETH_MIN_PACKET_SIZE		(ETH_ZLEN - ETH_HLEN)
14068c2ecf20Sopenharmony_ci#define ETH_MAX_PACKET_SIZE		ETH_DATA_LEN
14078c2ecf20Sopenharmony_ci#define ETH_MAX_JUMBO_PACKET_SIZE	9600
14088c2ecf20Sopenharmony_ci/* TCP with Timestamp Option (32) + IPv6 (40) */
14098c2ecf20Sopenharmony_ci#define ETH_MAX_TPA_HEADER_SIZE		72
14108c2ecf20Sopenharmony_ci
14118c2ecf20Sopenharmony_ci	/* Max supported alignment is 256 (8 shift)
14128c2ecf20Sopenharmony_ci	 * minimal alignment shift 6 is optimal for 57xxx HW performance
14138c2ecf20Sopenharmony_ci	 */
14148c2ecf20Sopenharmony_ci#define BNX2X_RX_ALIGN_SHIFT		max(6, min(8, L1_CACHE_SHIFT))
14158c2ecf20Sopenharmony_ci
14168c2ecf20Sopenharmony_ci	/* FW uses 2 Cache lines Alignment for start packet and size
14178c2ecf20Sopenharmony_ci	 *
14188c2ecf20Sopenharmony_ci	 * We assume skb_build() uses sizeof(struct skb_shared_info) bytes
14198c2ecf20Sopenharmony_ci	 * at the end of skb->data, to avoid wasting a full cache line.
14208c2ecf20Sopenharmony_ci	 * This reduces memory use (skb->truesize).
14218c2ecf20Sopenharmony_ci	 */
14228c2ecf20Sopenharmony_ci#define BNX2X_FW_RX_ALIGN_START	(1UL << BNX2X_RX_ALIGN_SHIFT)
14238c2ecf20Sopenharmony_ci
14248c2ecf20Sopenharmony_ci#define BNX2X_FW_RX_ALIGN_END					\
14258c2ecf20Sopenharmony_ci	max_t(u64, 1UL << BNX2X_RX_ALIGN_SHIFT,			\
14268c2ecf20Sopenharmony_ci	    SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
14278c2ecf20Sopenharmony_ci
14288c2ecf20Sopenharmony_ci#define BNX2X_PXP_DRAM_ALIGN		(BNX2X_RX_ALIGN_SHIFT - 5)
14298c2ecf20Sopenharmony_ci
14308c2ecf20Sopenharmony_ci	struct host_sp_status_block *def_status_blk;
14318c2ecf20Sopenharmony_ci#define DEF_SB_IGU_ID			16
14328c2ecf20Sopenharmony_ci#define DEF_SB_ID			HC_SP_SB_ID
14338c2ecf20Sopenharmony_ci	__le16			def_idx;
14348c2ecf20Sopenharmony_ci	__le16			def_att_idx;
14358c2ecf20Sopenharmony_ci	u32			attn_state;
14368c2ecf20Sopenharmony_ci	struct attn_route	attn_group[MAX_DYNAMIC_ATTN_GRPS];
14378c2ecf20Sopenharmony_ci
14388c2ecf20Sopenharmony_ci	/* slow path ring */
14398c2ecf20Sopenharmony_ci	struct eth_spe		*spq;
14408c2ecf20Sopenharmony_ci	dma_addr_t		spq_mapping;
14418c2ecf20Sopenharmony_ci	u16			spq_prod_idx;
14428c2ecf20Sopenharmony_ci	struct eth_spe		*spq_prod_bd;
14438c2ecf20Sopenharmony_ci	struct eth_spe		*spq_last_bd;
14448c2ecf20Sopenharmony_ci	__le16			*dsb_sp_prod;
14458c2ecf20Sopenharmony_ci	atomic_t		cq_spq_left; /* ETH_XXX ramrods credit */
14468c2ecf20Sopenharmony_ci	/* used to synchronize spq accesses */
14478c2ecf20Sopenharmony_ci	spinlock_t		spq_lock;
14488c2ecf20Sopenharmony_ci
14498c2ecf20Sopenharmony_ci	/* event queue */
14508c2ecf20Sopenharmony_ci	union event_ring_elem	*eq_ring;
14518c2ecf20Sopenharmony_ci	dma_addr_t		eq_mapping;
14528c2ecf20Sopenharmony_ci	u16			eq_prod;
14538c2ecf20Sopenharmony_ci	u16			eq_cons;
14548c2ecf20Sopenharmony_ci	__le16			*eq_cons_sb;
14558c2ecf20Sopenharmony_ci	atomic_t		eq_spq_left; /* COMMON_XXX ramrods credit */
14568c2ecf20Sopenharmony_ci
14578c2ecf20Sopenharmony_ci	/* Counter for marking that there is a STAT_QUERY ramrod pending */
14588c2ecf20Sopenharmony_ci	u16			stats_pending;
14598c2ecf20Sopenharmony_ci	/*  Counter for completed statistics ramrods */
14608c2ecf20Sopenharmony_ci	u16			stats_comp;
14618c2ecf20Sopenharmony_ci
14628c2ecf20Sopenharmony_ci	/* End of fields used in the performance code paths */
14638c2ecf20Sopenharmony_ci
14648c2ecf20Sopenharmony_ci	int			panic;
14658c2ecf20Sopenharmony_ci	int			msg_enable;
14668c2ecf20Sopenharmony_ci
14678c2ecf20Sopenharmony_ci	u32			flags;
14688c2ecf20Sopenharmony_ci#define PCIX_FLAG			(1 << 0)
14698c2ecf20Sopenharmony_ci#define PCI_32BIT_FLAG			(1 << 1)
14708c2ecf20Sopenharmony_ci#define ONE_PORT_FLAG			(1 << 2)
14718c2ecf20Sopenharmony_ci#define NO_WOL_FLAG			(1 << 3)
14728c2ecf20Sopenharmony_ci#define USING_MSIX_FLAG			(1 << 5)
14738c2ecf20Sopenharmony_ci#define USING_MSI_FLAG			(1 << 6)
14748c2ecf20Sopenharmony_ci#define DISABLE_MSI_FLAG		(1 << 7)
14758c2ecf20Sopenharmony_ci#define NO_MCP_FLAG			(1 << 9)
14768c2ecf20Sopenharmony_ci#define MF_FUNC_DIS			(1 << 11)
14778c2ecf20Sopenharmony_ci#define OWN_CNIC_IRQ			(1 << 12)
14788c2ecf20Sopenharmony_ci#define NO_ISCSI_OOO_FLAG		(1 << 13)
14798c2ecf20Sopenharmony_ci#define NO_ISCSI_FLAG			(1 << 14)
14808c2ecf20Sopenharmony_ci#define NO_FCOE_FLAG			(1 << 15)
14818c2ecf20Sopenharmony_ci#define BC_SUPPORTS_PFC_STATS		(1 << 17)
14828c2ecf20Sopenharmony_ci#define TX_SWITCHING			(1 << 18)
14838c2ecf20Sopenharmony_ci#define BC_SUPPORTS_FCOE_FEATURES	(1 << 19)
14848c2ecf20Sopenharmony_ci#define USING_SINGLE_MSIX_FLAG		(1 << 20)
14858c2ecf20Sopenharmony_ci#define BC_SUPPORTS_DCBX_MSG_NON_PMF	(1 << 21)
14868c2ecf20Sopenharmony_ci#define IS_VF_FLAG			(1 << 22)
14878c2ecf20Sopenharmony_ci#define BC_SUPPORTS_RMMOD_CMD		(1 << 23)
14888c2ecf20Sopenharmony_ci#define HAS_PHYS_PORT_ID		(1 << 24)
14898c2ecf20Sopenharmony_ci#define AER_ENABLED			(1 << 25)
14908c2ecf20Sopenharmony_ci#define PTP_SUPPORTED			(1 << 26)
14918c2ecf20Sopenharmony_ci#define TX_TIMESTAMPING_EN		(1 << 27)
14928c2ecf20Sopenharmony_ci
14938c2ecf20Sopenharmony_ci#define BP_NOMCP(bp)			((bp)->flags & NO_MCP_FLAG)
14948c2ecf20Sopenharmony_ci
14958c2ecf20Sopenharmony_ci#ifdef CONFIG_BNX2X_SRIOV
14968c2ecf20Sopenharmony_ci#define IS_VF(bp)			((bp)->flags & IS_VF_FLAG)
14978c2ecf20Sopenharmony_ci#define IS_PF(bp)			(!((bp)->flags & IS_VF_FLAG))
14988c2ecf20Sopenharmony_ci#else
14998c2ecf20Sopenharmony_ci#define IS_VF(bp)			false
15008c2ecf20Sopenharmony_ci#define IS_PF(bp)			true
15018c2ecf20Sopenharmony_ci#endif
15028c2ecf20Sopenharmony_ci
15038c2ecf20Sopenharmony_ci#define NO_ISCSI(bp)		((bp)->flags & NO_ISCSI_FLAG)
15048c2ecf20Sopenharmony_ci#define NO_ISCSI_OOO(bp)	((bp)->flags & NO_ISCSI_OOO_FLAG)
15058c2ecf20Sopenharmony_ci#define NO_FCOE(bp)		((bp)->flags & NO_FCOE_FLAG)
15068c2ecf20Sopenharmony_ci
15078c2ecf20Sopenharmony_ci	u8			cnic_support;
15088c2ecf20Sopenharmony_ci	bool			cnic_enabled;
15098c2ecf20Sopenharmony_ci	bool			cnic_loaded;
15108c2ecf20Sopenharmony_ci	struct cnic_eth_dev	*(*cnic_probe)(struct net_device *);
15118c2ecf20Sopenharmony_ci
15128c2ecf20Sopenharmony_ci	/* Flag that indicates that we can start looking for FCoE L2 queue
15138c2ecf20Sopenharmony_ci	 * completions in the default status block.
15148c2ecf20Sopenharmony_ci	 */
15158c2ecf20Sopenharmony_ci	bool			fcoe_init;
15168c2ecf20Sopenharmony_ci
15178c2ecf20Sopenharmony_ci	int			mrrs;
15188c2ecf20Sopenharmony_ci
15198c2ecf20Sopenharmony_ci	struct delayed_work	sp_task;
15208c2ecf20Sopenharmony_ci	struct delayed_work	iov_task;
15218c2ecf20Sopenharmony_ci
15228c2ecf20Sopenharmony_ci	atomic_t		interrupt_occurred;
15238c2ecf20Sopenharmony_ci	struct delayed_work	sp_rtnl_task;
15248c2ecf20Sopenharmony_ci
15258c2ecf20Sopenharmony_ci	struct delayed_work	period_task;
15268c2ecf20Sopenharmony_ci	struct timer_list	timer;
15278c2ecf20Sopenharmony_ci	int			current_interval;
15288c2ecf20Sopenharmony_ci
15298c2ecf20Sopenharmony_ci	u16			fw_seq;
15308c2ecf20Sopenharmony_ci	u16			fw_drv_pulse_wr_seq;
15318c2ecf20Sopenharmony_ci	u32			func_stx;
15328c2ecf20Sopenharmony_ci
15338c2ecf20Sopenharmony_ci	struct link_params	link_params;
15348c2ecf20Sopenharmony_ci	struct link_vars	link_vars;
15358c2ecf20Sopenharmony_ci	u32			link_cnt;
15368c2ecf20Sopenharmony_ci	struct bnx2x_link_report_data last_reported_link;
15378c2ecf20Sopenharmony_ci	bool			force_link_down;
15388c2ecf20Sopenharmony_ci
15398c2ecf20Sopenharmony_ci	struct mdio_if_info	mdio;
15408c2ecf20Sopenharmony_ci
15418c2ecf20Sopenharmony_ci	struct bnx2x_common	common;
15428c2ecf20Sopenharmony_ci	struct bnx2x_port	port;
15438c2ecf20Sopenharmony_ci
15448c2ecf20Sopenharmony_ci	struct cmng_init	cmng;
15458c2ecf20Sopenharmony_ci
15468c2ecf20Sopenharmony_ci	u32			mf_config[E1HVN_MAX];
15478c2ecf20Sopenharmony_ci	u32			mf_ext_config;
15488c2ecf20Sopenharmony_ci	u32			path_has_ovlan; /* E3 */
15498c2ecf20Sopenharmony_ci	u16			mf_ov;
15508c2ecf20Sopenharmony_ci	u8			mf_mode;
15518c2ecf20Sopenharmony_ci#define IS_MF(bp)		(bp->mf_mode != 0)
15528c2ecf20Sopenharmony_ci#define IS_MF_SI(bp)		(bp->mf_mode == MULTI_FUNCTION_SI)
15538c2ecf20Sopenharmony_ci#define IS_MF_SD(bp)		(bp->mf_mode == MULTI_FUNCTION_SD)
15548c2ecf20Sopenharmony_ci#define IS_MF_AFEX(bp)		(bp->mf_mode == MULTI_FUNCTION_AFEX)
15558c2ecf20Sopenharmony_ci	u8			mf_sub_mode;
15568c2ecf20Sopenharmony_ci#define IS_MF_UFP(bp)		(IS_MF_SD(bp) && \
15578c2ecf20Sopenharmony_ci				 bp->mf_sub_mode == SUB_MF_MODE_UFP)
15588c2ecf20Sopenharmony_ci#define IS_MF_BD(bp)		(IS_MF_SD(bp) && \
15598c2ecf20Sopenharmony_ci				 bp->mf_sub_mode == SUB_MF_MODE_BD)
15608c2ecf20Sopenharmony_ci
15618c2ecf20Sopenharmony_ci	u8			wol;
15628c2ecf20Sopenharmony_ci
15638c2ecf20Sopenharmony_ci	int			rx_ring_size;
15648c2ecf20Sopenharmony_ci
15658c2ecf20Sopenharmony_ci	u16			tx_quick_cons_trip_int;
15668c2ecf20Sopenharmony_ci	u16			tx_quick_cons_trip;
15678c2ecf20Sopenharmony_ci	u16			tx_ticks_int;
15688c2ecf20Sopenharmony_ci	u16			tx_ticks;
15698c2ecf20Sopenharmony_ci
15708c2ecf20Sopenharmony_ci	u16			rx_quick_cons_trip_int;
15718c2ecf20Sopenharmony_ci	u16			rx_quick_cons_trip;
15728c2ecf20Sopenharmony_ci	u16			rx_ticks_int;
15738c2ecf20Sopenharmony_ci	u16			rx_ticks;
15748c2ecf20Sopenharmony_ci/* Maximal coalescing timeout in us */
15758c2ecf20Sopenharmony_ci#define BNX2X_MAX_COALESCE_TOUT		(0xff*BNX2X_BTR)
15768c2ecf20Sopenharmony_ci
15778c2ecf20Sopenharmony_ci	u32			lin_cnt;
15788c2ecf20Sopenharmony_ci
15798c2ecf20Sopenharmony_ci	u16			state;
15808c2ecf20Sopenharmony_ci#define BNX2X_STATE_CLOSED		0
15818c2ecf20Sopenharmony_ci#define BNX2X_STATE_OPENING_WAIT4_LOAD	0x1000
15828c2ecf20Sopenharmony_ci#define BNX2X_STATE_OPENING_WAIT4_PORT	0x2000
15838c2ecf20Sopenharmony_ci#define BNX2X_STATE_OPEN		0x3000
15848c2ecf20Sopenharmony_ci#define BNX2X_STATE_CLOSING_WAIT4_HALT	0x4000
15858c2ecf20Sopenharmony_ci#define BNX2X_STATE_CLOSING_WAIT4_DELETE 0x5000
15868c2ecf20Sopenharmony_ci
15878c2ecf20Sopenharmony_ci#define BNX2X_STATE_DIAG		0xe000
15888c2ecf20Sopenharmony_ci#define BNX2X_STATE_ERROR		0xf000
15898c2ecf20Sopenharmony_ci
15908c2ecf20Sopenharmony_ci#define BNX2X_MAX_PRIORITY		8
15918c2ecf20Sopenharmony_ci	int			num_queues;
15928c2ecf20Sopenharmony_ci	uint			num_ethernet_queues;
15938c2ecf20Sopenharmony_ci	uint			num_cnic_queues;
15948c2ecf20Sopenharmony_ci	int			disable_tpa;
15958c2ecf20Sopenharmony_ci
15968c2ecf20Sopenharmony_ci	u32			rx_mode;
15978c2ecf20Sopenharmony_ci#define BNX2X_RX_MODE_NONE		0
15988c2ecf20Sopenharmony_ci#define BNX2X_RX_MODE_NORMAL		1
15998c2ecf20Sopenharmony_ci#define BNX2X_RX_MODE_ALLMULTI		2
16008c2ecf20Sopenharmony_ci#define BNX2X_RX_MODE_PROMISC		3
16018c2ecf20Sopenharmony_ci#define BNX2X_MAX_MULTICAST		64
16028c2ecf20Sopenharmony_ci
16038c2ecf20Sopenharmony_ci	u8			igu_dsb_id;
16048c2ecf20Sopenharmony_ci	u8			igu_base_sb;
16058c2ecf20Sopenharmony_ci	u8			igu_sb_cnt;
16068c2ecf20Sopenharmony_ci	u8			min_msix_vec_cnt;
16078c2ecf20Sopenharmony_ci
16088c2ecf20Sopenharmony_ci	u32			igu_base_addr;
16098c2ecf20Sopenharmony_ci	dma_addr_t		def_status_blk_mapping;
16108c2ecf20Sopenharmony_ci
16118c2ecf20Sopenharmony_ci	struct bnx2x_slowpath	*slowpath;
16128c2ecf20Sopenharmony_ci	dma_addr_t		slowpath_mapping;
16138c2ecf20Sopenharmony_ci
16148c2ecf20Sopenharmony_ci	/* Mechanism protecting the drv_info_to_mcp */
16158c2ecf20Sopenharmony_ci	struct mutex		drv_info_mutex;
16168c2ecf20Sopenharmony_ci	bool			drv_info_mng_owner;
16178c2ecf20Sopenharmony_ci
16188c2ecf20Sopenharmony_ci	/* Total number of FW statistics requests */
16198c2ecf20Sopenharmony_ci	u8			fw_stats_num;
16208c2ecf20Sopenharmony_ci
16218c2ecf20Sopenharmony_ci	/*
16228c2ecf20Sopenharmony_ci	 * This is a memory buffer that will contain both statistics
16238c2ecf20Sopenharmony_ci	 * ramrod request and data.
16248c2ecf20Sopenharmony_ci	 */
16258c2ecf20Sopenharmony_ci	void			*fw_stats;
16268c2ecf20Sopenharmony_ci	dma_addr_t		fw_stats_mapping;
16278c2ecf20Sopenharmony_ci
16288c2ecf20Sopenharmony_ci	/*
16298c2ecf20Sopenharmony_ci	 * FW statistics request shortcut (points at the
16308c2ecf20Sopenharmony_ci	 * beginning of fw_stats buffer).
16318c2ecf20Sopenharmony_ci	 */
16328c2ecf20Sopenharmony_ci	struct bnx2x_fw_stats_req	*fw_stats_req;
16338c2ecf20Sopenharmony_ci	dma_addr_t			fw_stats_req_mapping;
16348c2ecf20Sopenharmony_ci	int				fw_stats_req_sz;
16358c2ecf20Sopenharmony_ci
16368c2ecf20Sopenharmony_ci	/*
16378c2ecf20Sopenharmony_ci	 * FW statistics data shortcut (points at the beginning of
16388c2ecf20Sopenharmony_ci	 * fw_stats buffer + fw_stats_req_sz).
16398c2ecf20Sopenharmony_ci	 */
16408c2ecf20Sopenharmony_ci	struct bnx2x_fw_stats_data	*fw_stats_data;
16418c2ecf20Sopenharmony_ci	dma_addr_t			fw_stats_data_mapping;
16428c2ecf20Sopenharmony_ci	int				fw_stats_data_sz;
16438c2ecf20Sopenharmony_ci
16448c2ecf20Sopenharmony_ci	/* For max 1024 cids (VF RSS), 32KB ILT page size and 1KB
16458c2ecf20Sopenharmony_ci	 * context size we need 8 ILT entries.
16468c2ecf20Sopenharmony_ci	 */
16478c2ecf20Sopenharmony_ci#define ILT_MAX_L2_LINES	32
16488c2ecf20Sopenharmony_ci	struct hw_context	context[ILT_MAX_L2_LINES];
16498c2ecf20Sopenharmony_ci
16508c2ecf20Sopenharmony_ci	struct bnx2x_ilt	*ilt;
16518c2ecf20Sopenharmony_ci#define BP_ILT(bp)		((bp)->ilt)
16528c2ecf20Sopenharmony_ci#define ILT_MAX_LINES		256
16538c2ecf20Sopenharmony_ci/*
16548c2ecf20Sopenharmony_ci * Maximum supported number of RSS queues: number of IGU SBs minus one that goes
16558c2ecf20Sopenharmony_ci * to CNIC.
16568c2ecf20Sopenharmony_ci */
16578c2ecf20Sopenharmony_ci#define BNX2X_MAX_RSS_COUNT(bp)	((bp)->igu_sb_cnt - CNIC_SUPPORT(bp))
16588c2ecf20Sopenharmony_ci
16598c2ecf20Sopenharmony_ci/*
16608c2ecf20Sopenharmony_ci * Maximum CID count that might be required by the bnx2x:
16618c2ecf20Sopenharmony_ci * Max RSS * Max_Tx_Multi_Cos + FCoE + iSCSI
16628c2ecf20Sopenharmony_ci */
16638c2ecf20Sopenharmony_ci
16648c2ecf20Sopenharmony_ci#define BNX2X_L2_CID_COUNT(bp)	(BNX2X_NUM_ETH_QUEUES(bp) * BNX2X_MULTI_TX_COS \
16658c2ecf20Sopenharmony_ci				+ CNIC_SUPPORT(bp) * (2 + UIO_CID_PAD(bp)))
16668c2ecf20Sopenharmony_ci#define BNX2X_L2_MAX_CID(bp)	(BNX2X_MAX_RSS_COUNT(bp) * BNX2X_MULTI_TX_COS \
16678c2ecf20Sopenharmony_ci				+ CNIC_SUPPORT(bp) * (2 + UIO_CID_PAD(bp)))
16688c2ecf20Sopenharmony_ci#define L2_ILT_LINES(bp)	(DIV_ROUND_UP(BNX2X_L2_CID_COUNT(bp),\
16698c2ecf20Sopenharmony_ci					ILT_PAGE_CIDS))
16708c2ecf20Sopenharmony_ci
16718c2ecf20Sopenharmony_ci	int			qm_cid_count;
16728c2ecf20Sopenharmony_ci
16738c2ecf20Sopenharmony_ci	bool			dropless_fc;
16748c2ecf20Sopenharmony_ci
16758c2ecf20Sopenharmony_ci	void			*t2;
16768c2ecf20Sopenharmony_ci	dma_addr_t		t2_mapping;
16778c2ecf20Sopenharmony_ci	struct cnic_ops	__rcu	*cnic_ops;
16788c2ecf20Sopenharmony_ci	void			*cnic_data;
16798c2ecf20Sopenharmony_ci	u32			cnic_tag;
16808c2ecf20Sopenharmony_ci	struct cnic_eth_dev	cnic_eth_dev;
16818c2ecf20Sopenharmony_ci	union host_hc_status_block cnic_sb;
16828c2ecf20Sopenharmony_ci	dma_addr_t		cnic_sb_mapping;
16838c2ecf20Sopenharmony_ci	struct eth_spe		*cnic_kwq;
16848c2ecf20Sopenharmony_ci	struct eth_spe		*cnic_kwq_prod;
16858c2ecf20Sopenharmony_ci	struct eth_spe		*cnic_kwq_cons;
16868c2ecf20Sopenharmony_ci	struct eth_spe		*cnic_kwq_last;
16878c2ecf20Sopenharmony_ci	u16			cnic_kwq_pending;
16888c2ecf20Sopenharmony_ci	u16			cnic_spq_pending;
16898c2ecf20Sopenharmony_ci	u8			fip_mac[ETH_ALEN];
16908c2ecf20Sopenharmony_ci	struct mutex		cnic_mutex;
16918c2ecf20Sopenharmony_ci	struct bnx2x_vlan_mac_obj iscsi_l2_mac_obj;
16928c2ecf20Sopenharmony_ci
16938c2ecf20Sopenharmony_ci	/* Start index of the "special" (CNIC related) L2 clients */
16948c2ecf20Sopenharmony_ci	u8				cnic_base_cl_id;
16958c2ecf20Sopenharmony_ci
16968c2ecf20Sopenharmony_ci	int			dmae_ready;
16978c2ecf20Sopenharmony_ci	/* used to synchronize dmae accesses */
16988c2ecf20Sopenharmony_ci	spinlock_t		dmae_lock;
16998c2ecf20Sopenharmony_ci
17008c2ecf20Sopenharmony_ci	/* used to protect the FW mail box */
17018c2ecf20Sopenharmony_ci	struct mutex		fw_mb_mutex;
17028c2ecf20Sopenharmony_ci
17038c2ecf20Sopenharmony_ci	/* used to synchronize stats collecting */
17048c2ecf20Sopenharmony_ci	int			stats_state;
17058c2ecf20Sopenharmony_ci
17068c2ecf20Sopenharmony_ci	/* used for synchronization of concurrent threads statistics handling */
17078c2ecf20Sopenharmony_ci	struct semaphore	stats_lock;
17088c2ecf20Sopenharmony_ci
17098c2ecf20Sopenharmony_ci	/* used by dmae command loader */
17108c2ecf20Sopenharmony_ci	struct dmae_command	stats_dmae;
17118c2ecf20Sopenharmony_ci	int			executer_idx;
17128c2ecf20Sopenharmony_ci
17138c2ecf20Sopenharmony_ci	u16			stats_counter;
17148c2ecf20Sopenharmony_ci	struct bnx2x_eth_stats	eth_stats;
17158c2ecf20Sopenharmony_ci	struct host_func_stats		func_stats;
17168c2ecf20Sopenharmony_ci	struct bnx2x_eth_stats_old	eth_stats_old;
17178c2ecf20Sopenharmony_ci	struct bnx2x_net_stats_old	net_stats_old;
17188c2ecf20Sopenharmony_ci	struct bnx2x_fw_port_stats_old	fw_stats_old;
17198c2ecf20Sopenharmony_ci	bool			stats_init;
17208c2ecf20Sopenharmony_ci
17218c2ecf20Sopenharmony_ci	struct z_stream_s	*strm;
17228c2ecf20Sopenharmony_ci	void			*gunzip_buf;
17238c2ecf20Sopenharmony_ci	dma_addr_t		gunzip_mapping;
17248c2ecf20Sopenharmony_ci	int			gunzip_outlen;
17258c2ecf20Sopenharmony_ci#define FW_BUF_SIZE			0x8000
17268c2ecf20Sopenharmony_ci#define GUNZIP_BUF(bp)			(bp->gunzip_buf)
17278c2ecf20Sopenharmony_ci#define GUNZIP_PHYS(bp)			(bp->gunzip_mapping)
17288c2ecf20Sopenharmony_ci#define GUNZIP_OUTLEN(bp)		(bp->gunzip_outlen)
17298c2ecf20Sopenharmony_ci
17308c2ecf20Sopenharmony_ci	struct raw_op		*init_ops;
17318c2ecf20Sopenharmony_ci	/* Init blocks offsets inside init_ops */
17328c2ecf20Sopenharmony_ci	u16			*init_ops_offsets;
17338c2ecf20Sopenharmony_ci	/* Data blob - has 32 bit granularity */
17348c2ecf20Sopenharmony_ci	u32			*init_data;
17358c2ecf20Sopenharmony_ci	u32			init_mode_flags;
17368c2ecf20Sopenharmony_ci#define INIT_MODE_FLAGS(bp)	(bp->init_mode_flags)
17378c2ecf20Sopenharmony_ci	/* Zipped PRAM blobs - raw data */
17388c2ecf20Sopenharmony_ci	const u8		*tsem_int_table_data;
17398c2ecf20Sopenharmony_ci	const u8		*tsem_pram_data;
17408c2ecf20Sopenharmony_ci	const u8		*usem_int_table_data;
17418c2ecf20Sopenharmony_ci	const u8		*usem_pram_data;
17428c2ecf20Sopenharmony_ci	const u8		*xsem_int_table_data;
17438c2ecf20Sopenharmony_ci	const u8		*xsem_pram_data;
17448c2ecf20Sopenharmony_ci	const u8		*csem_int_table_data;
17458c2ecf20Sopenharmony_ci	const u8		*csem_pram_data;
17468c2ecf20Sopenharmony_ci#define INIT_OPS(bp)			(bp->init_ops)
17478c2ecf20Sopenharmony_ci#define INIT_OPS_OFFSETS(bp)		(bp->init_ops_offsets)
17488c2ecf20Sopenharmony_ci#define INIT_DATA(bp)			(bp->init_data)
17498c2ecf20Sopenharmony_ci#define INIT_TSEM_INT_TABLE_DATA(bp)	(bp->tsem_int_table_data)
17508c2ecf20Sopenharmony_ci#define INIT_TSEM_PRAM_DATA(bp)		(bp->tsem_pram_data)
17518c2ecf20Sopenharmony_ci#define INIT_USEM_INT_TABLE_DATA(bp)	(bp->usem_int_table_data)
17528c2ecf20Sopenharmony_ci#define INIT_USEM_PRAM_DATA(bp)		(bp->usem_pram_data)
17538c2ecf20Sopenharmony_ci#define INIT_XSEM_INT_TABLE_DATA(bp)	(bp->xsem_int_table_data)
17548c2ecf20Sopenharmony_ci#define INIT_XSEM_PRAM_DATA(bp)		(bp->xsem_pram_data)
17558c2ecf20Sopenharmony_ci#define INIT_CSEM_INT_TABLE_DATA(bp)	(bp->csem_int_table_data)
17568c2ecf20Sopenharmony_ci#define INIT_CSEM_PRAM_DATA(bp)		(bp->csem_pram_data)
17578c2ecf20Sopenharmony_ci
17588c2ecf20Sopenharmony_ci#define PHY_FW_VER_LEN			20
17598c2ecf20Sopenharmony_ci	char			fw_ver[32];
17608c2ecf20Sopenharmony_ci	const struct firmware	*firmware;
17618c2ecf20Sopenharmony_ci
17628c2ecf20Sopenharmony_ci	struct bnx2x_vfdb	*vfdb;
17638c2ecf20Sopenharmony_ci#define IS_SRIOV(bp)		((bp)->vfdb)
17648c2ecf20Sopenharmony_ci
17658c2ecf20Sopenharmony_ci	/* DCB support on/off */
17668c2ecf20Sopenharmony_ci	u16 dcb_state;
17678c2ecf20Sopenharmony_ci#define BNX2X_DCB_STATE_OFF			0
17688c2ecf20Sopenharmony_ci#define BNX2X_DCB_STATE_ON			1
17698c2ecf20Sopenharmony_ci
17708c2ecf20Sopenharmony_ci	/* DCBX engine mode */
17718c2ecf20Sopenharmony_ci	int dcbx_enabled;
17728c2ecf20Sopenharmony_ci#define BNX2X_DCBX_ENABLED_OFF			0
17738c2ecf20Sopenharmony_ci#define BNX2X_DCBX_ENABLED_ON_NEG_OFF		1
17748c2ecf20Sopenharmony_ci#define BNX2X_DCBX_ENABLED_ON_NEG_ON		2
17758c2ecf20Sopenharmony_ci#define BNX2X_DCBX_ENABLED_INVALID		(-1)
17768c2ecf20Sopenharmony_ci
17778c2ecf20Sopenharmony_ci	bool dcbx_mode_uset;
17788c2ecf20Sopenharmony_ci
17798c2ecf20Sopenharmony_ci	struct bnx2x_config_dcbx_params		dcbx_config_params;
17808c2ecf20Sopenharmony_ci	struct bnx2x_dcbx_port_params		dcbx_port_params;
17818c2ecf20Sopenharmony_ci	int					dcb_version;
17828c2ecf20Sopenharmony_ci
17838c2ecf20Sopenharmony_ci	/* CAM credit pools */
17848c2ecf20Sopenharmony_ci	struct bnx2x_credit_pool_obj		vlans_pool;
17858c2ecf20Sopenharmony_ci
17868c2ecf20Sopenharmony_ci	struct bnx2x_credit_pool_obj		macs_pool;
17878c2ecf20Sopenharmony_ci
17888c2ecf20Sopenharmony_ci	/* RX_MODE object */
17898c2ecf20Sopenharmony_ci	struct bnx2x_rx_mode_obj		rx_mode_obj;
17908c2ecf20Sopenharmony_ci
17918c2ecf20Sopenharmony_ci	/* MCAST object */
17928c2ecf20Sopenharmony_ci	struct bnx2x_mcast_obj			mcast_obj;
17938c2ecf20Sopenharmony_ci
17948c2ecf20Sopenharmony_ci	/* RSS configuration object */
17958c2ecf20Sopenharmony_ci	struct bnx2x_rss_config_obj		rss_conf_obj;
17968c2ecf20Sopenharmony_ci
17978c2ecf20Sopenharmony_ci	/* Function State controlling object */
17988c2ecf20Sopenharmony_ci	struct bnx2x_func_sp_obj		func_obj;
17998c2ecf20Sopenharmony_ci
18008c2ecf20Sopenharmony_ci	unsigned long				sp_state;
18018c2ecf20Sopenharmony_ci
18028c2ecf20Sopenharmony_ci	/* operation indication for the sp_rtnl task */
18038c2ecf20Sopenharmony_ci	unsigned long				sp_rtnl_state;
18048c2ecf20Sopenharmony_ci
18058c2ecf20Sopenharmony_ci	/* Indication of the IOV tasks */
18068c2ecf20Sopenharmony_ci	unsigned long				iov_task_state;
18078c2ecf20Sopenharmony_ci
18088c2ecf20Sopenharmony_ci	/* DCBX Negotiation results */
18098c2ecf20Sopenharmony_ci	struct dcbx_features			dcbx_local_feat;
18108c2ecf20Sopenharmony_ci	u32					dcbx_error;
18118c2ecf20Sopenharmony_ci
18128c2ecf20Sopenharmony_ci#ifdef BCM_DCBNL
18138c2ecf20Sopenharmony_ci	struct dcbx_features			dcbx_remote_feat;
18148c2ecf20Sopenharmony_ci	u32					dcbx_remote_flags;
18158c2ecf20Sopenharmony_ci#endif
18168c2ecf20Sopenharmony_ci	/* AFEX: store default vlan used */
18178c2ecf20Sopenharmony_ci	int					afex_def_vlan_tag;
18188c2ecf20Sopenharmony_ci	enum mf_cfg_afex_vlan_mode		afex_vlan_mode;
18198c2ecf20Sopenharmony_ci	u32					pending_max;
18208c2ecf20Sopenharmony_ci
18218c2ecf20Sopenharmony_ci	/* multiple tx classes of service */
18228c2ecf20Sopenharmony_ci	u8					max_cos;
18238c2ecf20Sopenharmony_ci
18248c2ecf20Sopenharmony_ci	/* priority to cos mapping */
18258c2ecf20Sopenharmony_ci	u8					prio_to_cos[8];
18268c2ecf20Sopenharmony_ci
18278c2ecf20Sopenharmony_ci	int fp_array_size;
18288c2ecf20Sopenharmony_ci	u32 dump_preset_idx;
18298c2ecf20Sopenharmony_ci
18308c2ecf20Sopenharmony_ci	u8					phys_port_id[ETH_ALEN];
18318c2ecf20Sopenharmony_ci
18328c2ecf20Sopenharmony_ci	/* PTP related context */
18338c2ecf20Sopenharmony_ci	struct ptp_clock *ptp_clock;
18348c2ecf20Sopenharmony_ci	struct ptp_clock_info ptp_clock_info;
18358c2ecf20Sopenharmony_ci	struct work_struct ptp_task;
18368c2ecf20Sopenharmony_ci	struct cyclecounter cyclecounter;
18378c2ecf20Sopenharmony_ci	struct timecounter timecounter;
18388c2ecf20Sopenharmony_ci	bool timecounter_init_done;
18398c2ecf20Sopenharmony_ci	struct sk_buff *ptp_tx_skb;
18408c2ecf20Sopenharmony_ci	unsigned long ptp_tx_start;
18418c2ecf20Sopenharmony_ci	bool hwtstamp_ioctl_called;
18428c2ecf20Sopenharmony_ci	u16 tx_type;
18438c2ecf20Sopenharmony_ci	u16 rx_filter;
18448c2ecf20Sopenharmony_ci
18458c2ecf20Sopenharmony_ci	struct bnx2x_link_report_data		vf_link_vars;
18468c2ecf20Sopenharmony_ci	struct list_head vlan_reg;
18478c2ecf20Sopenharmony_ci	u16 vlan_cnt;
18488c2ecf20Sopenharmony_ci	u16 vlan_credit;
18498c2ecf20Sopenharmony_ci	bool accept_any_vlan;
18508c2ecf20Sopenharmony_ci
18518c2ecf20Sopenharmony_ci	/* Vxlan/Geneve related information */
18528c2ecf20Sopenharmony_ci	u16 udp_tunnel_ports[BNX2X_UDP_PORT_MAX];
18538c2ecf20Sopenharmony_ci
18548c2ecf20Sopenharmony_ci#define FW_CAP_INVALIDATE_VF_FP_HSI	BIT(0)
18558c2ecf20Sopenharmony_ci	u32 fw_cap;
18568c2ecf20Sopenharmony_ci
18578c2ecf20Sopenharmony_ci	u32 fw_major;
18588c2ecf20Sopenharmony_ci	u32 fw_minor;
18598c2ecf20Sopenharmony_ci	u32 fw_rev;
18608c2ecf20Sopenharmony_ci	u32 fw_eng;
18618c2ecf20Sopenharmony_ci};
18628c2ecf20Sopenharmony_ci
18638c2ecf20Sopenharmony_ci/* Tx queues may be less or equal to Rx queues */
18648c2ecf20Sopenharmony_ciextern int num_queues;
18658c2ecf20Sopenharmony_ci#define BNX2X_NUM_QUEUES(bp)	(bp->num_queues)
18668c2ecf20Sopenharmony_ci#define BNX2X_NUM_ETH_QUEUES(bp) ((bp)->num_ethernet_queues)
18678c2ecf20Sopenharmony_ci#define BNX2X_NUM_NON_CNIC_QUEUES(bp)	(BNX2X_NUM_QUEUES(bp) - \
18688c2ecf20Sopenharmony_ci					 (bp)->num_cnic_queues)
18698c2ecf20Sopenharmony_ci#define BNX2X_NUM_RX_QUEUES(bp)	BNX2X_NUM_QUEUES(bp)
18708c2ecf20Sopenharmony_ci
18718c2ecf20Sopenharmony_ci#define is_multi(bp)		(BNX2X_NUM_QUEUES(bp) > 1)
18728c2ecf20Sopenharmony_ci
18738c2ecf20Sopenharmony_ci#define BNX2X_MAX_QUEUES(bp)	BNX2X_MAX_RSS_COUNT(bp)
18748c2ecf20Sopenharmony_ci/* #define is_eth_multi(bp)	(BNX2X_NUM_ETH_QUEUES(bp) > 1) */
18758c2ecf20Sopenharmony_ci
18768c2ecf20Sopenharmony_ci#define RSS_IPV4_CAP_MASK						\
18778c2ecf20Sopenharmony_ci	TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV4_CAPABILITY
18788c2ecf20Sopenharmony_ci
18798c2ecf20Sopenharmony_ci#define RSS_IPV4_TCP_CAP_MASK						\
18808c2ecf20Sopenharmony_ci	TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV4_TCP_CAPABILITY
18818c2ecf20Sopenharmony_ci
18828c2ecf20Sopenharmony_ci#define RSS_IPV6_CAP_MASK						\
18838c2ecf20Sopenharmony_ci	TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_CAPABILITY
18848c2ecf20Sopenharmony_ci
18858c2ecf20Sopenharmony_ci#define RSS_IPV6_TCP_CAP_MASK						\
18868c2ecf20Sopenharmony_ci	TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_TCP_CAPABILITY
18878c2ecf20Sopenharmony_ci
18888c2ecf20Sopenharmony_cistruct bnx2x_func_init_params {
18898c2ecf20Sopenharmony_ci	/* dma */
18908c2ecf20Sopenharmony_ci	bool		spq_active;
18918c2ecf20Sopenharmony_ci	dma_addr_t	spq_map;
18928c2ecf20Sopenharmony_ci	u16		spq_prod;
18938c2ecf20Sopenharmony_ci
18948c2ecf20Sopenharmony_ci	u16		func_id;	/* abs fid */
18958c2ecf20Sopenharmony_ci	u16		pf_id;
18968c2ecf20Sopenharmony_ci};
18978c2ecf20Sopenharmony_ci
18988c2ecf20Sopenharmony_ci#define for_each_cnic_queue(bp, var) \
18998c2ecf20Sopenharmony_ci	for ((var) = BNX2X_NUM_ETH_QUEUES(bp); (var) < BNX2X_NUM_QUEUES(bp); \
19008c2ecf20Sopenharmony_ci	     (var)++) \
19018c2ecf20Sopenharmony_ci		if (skip_queue(bp, var))	\
19028c2ecf20Sopenharmony_ci			continue;		\
19038c2ecf20Sopenharmony_ci		else
19048c2ecf20Sopenharmony_ci
19058c2ecf20Sopenharmony_ci#define for_each_eth_queue(bp, var) \
19068c2ecf20Sopenharmony_ci	for ((var) = 0; (var) < BNX2X_NUM_ETH_QUEUES(bp); (var)++)
19078c2ecf20Sopenharmony_ci
19088c2ecf20Sopenharmony_ci#define for_each_nondefault_eth_queue(bp, var) \
19098c2ecf20Sopenharmony_ci	for ((var) = 1; (var) < BNX2X_NUM_ETH_QUEUES(bp); (var)++)
19108c2ecf20Sopenharmony_ci
19118c2ecf20Sopenharmony_ci#define for_each_queue(bp, var) \
19128c2ecf20Sopenharmony_ci	for ((var) = 0; (var) < BNX2X_NUM_QUEUES(bp); (var)++) \
19138c2ecf20Sopenharmony_ci		if (skip_queue(bp, var))	\
19148c2ecf20Sopenharmony_ci			continue;		\
19158c2ecf20Sopenharmony_ci		else
19168c2ecf20Sopenharmony_ci
19178c2ecf20Sopenharmony_ci/* Skip forwarding FP */
19188c2ecf20Sopenharmony_ci#define for_each_valid_rx_queue(bp, var)			\
19198c2ecf20Sopenharmony_ci	for ((var) = 0;						\
19208c2ecf20Sopenharmony_ci	     (var) < (CNIC_LOADED(bp) ? BNX2X_NUM_QUEUES(bp) :	\
19218c2ecf20Sopenharmony_ci		      BNX2X_NUM_ETH_QUEUES(bp));		\
19228c2ecf20Sopenharmony_ci	     (var)++)						\
19238c2ecf20Sopenharmony_ci		if (skip_rx_queue(bp, var))			\
19248c2ecf20Sopenharmony_ci			continue;				\
19258c2ecf20Sopenharmony_ci		else
19268c2ecf20Sopenharmony_ci
19278c2ecf20Sopenharmony_ci#define for_each_rx_queue_cnic(bp, var) \
19288c2ecf20Sopenharmony_ci	for ((var) = BNX2X_NUM_ETH_QUEUES(bp); (var) < BNX2X_NUM_QUEUES(bp); \
19298c2ecf20Sopenharmony_ci	     (var)++) \
19308c2ecf20Sopenharmony_ci		if (skip_rx_queue(bp, var))	\
19318c2ecf20Sopenharmony_ci			continue;		\
19328c2ecf20Sopenharmony_ci		else
19338c2ecf20Sopenharmony_ci
19348c2ecf20Sopenharmony_ci#define for_each_rx_queue(bp, var) \
19358c2ecf20Sopenharmony_ci	for ((var) = 0; (var) < BNX2X_NUM_QUEUES(bp); (var)++) \
19368c2ecf20Sopenharmony_ci		if (skip_rx_queue(bp, var))	\
19378c2ecf20Sopenharmony_ci			continue;		\
19388c2ecf20Sopenharmony_ci		else
19398c2ecf20Sopenharmony_ci
19408c2ecf20Sopenharmony_ci/* Skip OOO FP */
19418c2ecf20Sopenharmony_ci#define for_each_valid_tx_queue(bp, var)			\
19428c2ecf20Sopenharmony_ci	for ((var) = 0;						\
19438c2ecf20Sopenharmony_ci	     (var) < (CNIC_LOADED(bp) ? BNX2X_NUM_QUEUES(bp) :	\
19448c2ecf20Sopenharmony_ci		      BNX2X_NUM_ETH_QUEUES(bp));		\
19458c2ecf20Sopenharmony_ci	     (var)++)						\
19468c2ecf20Sopenharmony_ci		if (skip_tx_queue(bp, var))			\
19478c2ecf20Sopenharmony_ci			continue;				\
19488c2ecf20Sopenharmony_ci		else
19498c2ecf20Sopenharmony_ci
19508c2ecf20Sopenharmony_ci#define for_each_tx_queue_cnic(bp, var) \
19518c2ecf20Sopenharmony_ci	for ((var) = BNX2X_NUM_ETH_QUEUES(bp); (var) < BNX2X_NUM_QUEUES(bp); \
19528c2ecf20Sopenharmony_ci	     (var)++) \
19538c2ecf20Sopenharmony_ci		if (skip_tx_queue(bp, var))	\
19548c2ecf20Sopenharmony_ci			continue;		\
19558c2ecf20Sopenharmony_ci		else
19568c2ecf20Sopenharmony_ci
19578c2ecf20Sopenharmony_ci#define for_each_tx_queue(bp, var) \
19588c2ecf20Sopenharmony_ci	for ((var) = 0; (var) < BNX2X_NUM_QUEUES(bp); (var)++) \
19598c2ecf20Sopenharmony_ci		if (skip_tx_queue(bp, var))	\
19608c2ecf20Sopenharmony_ci			continue;		\
19618c2ecf20Sopenharmony_ci		else
19628c2ecf20Sopenharmony_ci
19638c2ecf20Sopenharmony_ci#define for_each_nondefault_queue(bp, var) \
19648c2ecf20Sopenharmony_ci	for ((var) = 1; (var) < BNX2X_NUM_QUEUES(bp); (var)++) \
19658c2ecf20Sopenharmony_ci		if (skip_queue(bp, var))	\
19668c2ecf20Sopenharmony_ci			continue;		\
19678c2ecf20Sopenharmony_ci		else
19688c2ecf20Sopenharmony_ci
19698c2ecf20Sopenharmony_ci#define for_each_cos_in_tx_queue(fp, var) \
19708c2ecf20Sopenharmony_ci	for ((var) = 0; (var) < (fp)->max_cos; (var)++)
19718c2ecf20Sopenharmony_ci
19728c2ecf20Sopenharmony_ci/* skip rx queue
19738c2ecf20Sopenharmony_ci * if FCOE l2 support is disabled and this is the fcoe L2 queue
19748c2ecf20Sopenharmony_ci */
19758c2ecf20Sopenharmony_ci#define skip_rx_queue(bp, idx)	(NO_FCOE(bp) && IS_FCOE_IDX(idx))
19768c2ecf20Sopenharmony_ci
19778c2ecf20Sopenharmony_ci/* skip tx queue
19788c2ecf20Sopenharmony_ci * if FCOE l2 support is disabled and this is the fcoe L2 queue
19798c2ecf20Sopenharmony_ci */
19808c2ecf20Sopenharmony_ci#define skip_tx_queue(bp, idx)	(NO_FCOE(bp) && IS_FCOE_IDX(idx))
19818c2ecf20Sopenharmony_ci
19828c2ecf20Sopenharmony_ci#define skip_queue(bp, idx)	(NO_FCOE(bp) && IS_FCOE_IDX(idx))
19838c2ecf20Sopenharmony_ci
19848c2ecf20Sopenharmony_ci/*self test*/
19858c2ecf20Sopenharmony_ciint bnx2x_idle_chk(struct bnx2x *bp);
19868c2ecf20Sopenharmony_ci
19878c2ecf20Sopenharmony_ci/**
19888c2ecf20Sopenharmony_ci * bnx2x_set_mac_one - configure a single MAC address
19898c2ecf20Sopenharmony_ci *
19908c2ecf20Sopenharmony_ci * @bp:			driver handle
19918c2ecf20Sopenharmony_ci * @mac:		MAC to configure
19928c2ecf20Sopenharmony_ci * @obj:		MAC object handle
19938c2ecf20Sopenharmony_ci * @set:		if 'true' add a new MAC, otherwise - delete
19948c2ecf20Sopenharmony_ci * @mac_type:		the type of the MAC to configure (e.g. ETH, UC list)
19958c2ecf20Sopenharmony_ci * @ramrod_flags:	RAMROD_XXX flags (e.g. RAMROD_CONT, RAMROD_COMP_WAIT)
19968c2ecf20Sopenharmony_ci *
19978c2ecf20Sopenharmony_ci * Configures one MAC according to provided parameters or continues the
19988c2ecf20Sopenharmony_ci * execution of previously scheduled commands if RAMROD_CONT is set in
19998c2ecf20Sopenharmony_ci * ramrod_flags.
20008c2ecf20Sopenharmony_ci *
20018c2ecf20Sopenharmony_ci * Returns zero if operation has successfully completed, a positive value if the
20028c2ecf20Sopenharmony_ci * operation has been successfully scheduled and a negative - if a requested
20038c2ecf20Sopenharmony_ci * operations has failed.
20048c2ecf20Sopenharmony_ci */
20058c2ecf20Sopenharmony_ciint bnx2x_set_mac_one(struct bnx2x *bp, u8 *mac,
20068c2ecf20Sopenharmony_ci		      struct bnx2x_vlan_mac_obj *obj, bool set,
20078c2ecf20Sopenharmony_ci		      int mac_type, unsigned long *ramrod_flags);
20088c2ecf20Sopenharmony_ci
20098c2ecf20Sopenharmony_ciint bnx2x_set_vlan_one(struct bnx2x *bp, u16 vlan,
20108c2ecf20Sopenharmony_ci		       struct bnx2x_vlan_mac_obj *obj, bool set,
20118c2ecf20Sopenharmony_ci		       unsigned long *ramrod_flags);
20128c2ecf20Sopenharmony_ci
20138c2ecf20Sopenharmony_ci/**
20148c2ecf20Sopenharmony_ci * bnx2x_del_all_macs - delete all MACs configured for the specific MAC object
20158c2ecf20Sopenharmony_ci *
20168c2ecf20Sopenharmony_ci * @bp:			driver handle
20178c2ecf20Sopenharmony_ci * @mac_obj:		MAC object handle
20188c2ecf20Sopenharmony_ci * @mac_type:		type of the MACs to clear (BNX2X_XXX_MAC)
20198c2ecf20Sopenharmony_ci * @wait_for_comp:	if 'true' block until completion
20208c2ecf20Sopenharmony_ci *
20218c2ecf20Sopenharmony_ci * Deletes all MACs of the specific type (e.g. ETH, UC list).
20228c2ecf20Sopenharmony_ci *
20238c2ecf20Sopenharmony_ci * Returns zero if operation has successfully completed, a positive value if the
20248c2ecf20Sopenharmony_ci * operation has been successfully scheduled and a negative - if a requested
20258c2ecf20Sopenharmony_ci * operations has failed.
20268c2ecf20Sopenharmony_ci */
20278c2ecf20Sopenharmony_ciint bnx2x_del_all_macs(struct bnx2x *bp,
20288c2ecf20Sopenharmony_ci		       struct bnx2x_vlan_mac_obj *mac_obj,
20298c2ecf20Sopenharmony_ci		       int mac_type, bool wait_for_comp);
20308c2ecf20Sopenharmony_ci
20318c2ecf20Sopenharmony_ci/* Init Function API  */
20328c2ecf20Sopenharmony_civoid bnx2x_func_init(struct bnx2x *bp, struct bnx2x_func_init_params *p);
20338c2ecf20Sopenharmony_civoid bnx2x_init_sb(struct bnx2x *bp, dma_addr_t mapping, int vfid,
20348c2ecf20Sopenharmony_ci		    u8 vf_valid, int fw_sb_id, int igu_sb_id);
20358c2ecf20Sopenharmony_ciint bnx2x_get_gpio(struct bnx2x *bp, int gpio_num, u8 port);
20368c2ecf20Sopenharmony_ciint bnx2x_set_gpio(struct bnx2x *bp, int gpio_num, u32 mode, u8 port);
20378c2ecf20Sopenharmony_ciint bnx2x_set_mult_gpio(struct bnx2x *bp, u8 pins, u32 mode);
20388c2ecf20Sopenharmony_ciint bnx2x_set_gpio_int(struct bnx2x *bp, int gpio_num, u32 mode, u8 port);
20398c2ecf20Sopenharmony_civoid bnx2x_read_mf_cfg(struct bnx2x *bp);
20408c2ecf20Sopenharmony_ci
20418c2ecf20Sopenharmony_ciint bnx2x_pretend_func(struct bnx2x *bp, u16 pretend_func_val);
20428c2ecf20Sopenharmony_ci
20438c2ecf20Sopenharmony_ci/* dmae */
20448c2ecf20Sopenharmony_civoid bnx2x_read_dmae(struct bnx2x *bp, u32 src_addr, u32 len32);
20458c2ecf20Sopenharmony_civoid bnx2x_write_dmae(struct bnx2x *bp, dma_addr_t dma_addr, u32 dst_addr,
20468c2ecf20Sopenharmony_ci		      u32 len32);
20478c2ecf20Sopenharmony_civoid bnx2x_post_dmae(struct bnx2x *bp, struct dmae_command *dmae, int idx);
20488c2ecf20Sopenharmony_ciu32 bnx2x_dmae_opcode_add_comp(u32 opcode, u8 comp_type);
20498c2ecf20Sopenharmony_ciu32 bnx2x_dmae_opcode_clr_src_reset(u32 opcode);
20508c2ecf20Sopenharmony_ciu32 bnx2x_dmae_opcode(struct bnx2x *bp, u8 src_type, u8 dst_type,
20518c2ecf20Sopenharmony_ci		      bool with_comp, u8 comp_type);
20528c2ecf20Sopenharmony_ci
20538c2ecf20Sopenharmony_civoid bnx2x_prep_dmae_with_comp(struct bnx2x *bp, struct dmae_command *dmae,
20548c2ecf20Sopenharmony_ci			       u8 src_type, u8 dst_type);
20558c2ecf20Sopenharmony_ciint bnx2x_issue_dmae_with_comp(struct bnx2x *bp, struct dmae_command *dmae,
20568c2ecf20Sopenharmony_ci			       u32 *comp);
20578c2ecf20Sopenharmony_ci
20588c2ecf20Sopenharmony_ci/* FLR related routines */
20598c2ecf20Sopenharmony_ciu32 bnx2x_flr_clnup_poll_count(struct bnx2x *bp);
20608c2ecf20Sopenharmony_civoid bnx2x_tx_hw_flushed(struct bnx2x *bp, u32 poll_count);
20618c2ecf20Sopenharmony_ciint bnx2x_send_final_clnup(struct bnx2x *bp, u8 clnup_func, u32 poll_cnt);
20628c2ecf20Sopenharmony_ciu8 bnx2x_is_pcie_pending(struct pci_dev *dev);
20638c2ecf20Sopenharmony_ciint bnx2x_flr_clnup_poll_hw_counter(struct bnx2x *bp, u32 reg,
20648c2ecf20Sopenharmony_ci				    char *msg, u32 poll_cnt);
20658c2ecf20Sopenharmony_ci
20668c2ecf20Sopenharmony_civoid bnx2x_calc_fc_adv(struct bnx2x *bp);
20678c2ecf20Sopenharmony_ciint bnx2x_sp_post(struct bnx2x *bp, int command, int cid,
20688c2ecf20Sopenharmony_ci		  u32 data_hi, u32 data_lo, int cmd_type);
20698c2ecf20Sopenharmony_civoid bnx2x_update_coalesce(struct bnx2x *bp);
20708c2ecf20Sopenharmony_ciint bnx2x_get_cur_phy_idx(struct bnx2x *bp);
20718c2ecf20Sopenharmony_ci
20728c2ecf20Sopenharmony_cibool bnx2x_port_after_undi(struct bnx2x *bp);
20738c2ecf20Sopenharmony_ci
20748c2ecf20Sopenharmony_cistatic inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms,
20758c2ecf20Sopenharmony_ci			   int wait)
20768c2ecf20Sopenharmony_ci{
20778c2ecf20Sopenharmony_ci	u32 val;
20788c2ecf20Sopenharmony_ci
20798c2ecf20Sopenharmony_ci	do {
20808c2ecf20Sopenharmony_ci		val = REG_RD(bp, reg);
20818c2ecf20Sopenharmony_ci		if (val == expected)
20828c2ecf20Sopenharmony_ci			break;
20838c2ecf20Sopenharmony_ci		ms -= wait;
20848c2ecf20Sopenharmony_ci		msleep(wait);
20858c2ecf20Sopenharmony_ci
20868c2ecf20Sopenharmony_ci	} while (ms > 0);
20878c2ecf20Sopenharmony_ci
20888c2ecf20Sopenharmony_ci	return val;
20898c2ecf20Sopenharmony_ci}
20908c2ecf20Sopenharmony_ci
20918c2ecf20Sopenharmony_civoid bnx2x_igu_clear_sb_gen(struct bnx2x *bp, u8 func, u8 idu_sb_id,
20928c2ecf20Sopenharmony_ci			    bool is_pf);
20938c2ecf20Sopenharmony_ci
20948c2ecf20Sopenharmony_ci#define BNX2X_ILT_ZALLOC(x, y, size)					\
20958c2ecf20Sopenharmony_ci	x = dma_alloc_coherent(&bp->pdev->dev, size, y, GFP_KERNEL)
20968c2ecf20Sopenharmony_ci
20978c2ecf20Sopenharmony_ci#define BNX2X_ILT_FREE(x, y, size) \
20988c2ecf20Sopenharmony_ci	do { \
20998c2ecf20Sopenharmony_ci		if (x) { \
21008c2ecf20Sopenharmony_ci			dma_free_coherent(&bp->pdev->dev, size, x, y); \
21018c2ecf20Sopenharmony_ci			x = NULL; \
21028c2ecf20Sopenharmony_ci			y = 0; \
21038c2ecf20Sopenharmony_ci		} \
21048c2ecf20Sopenharmony_ci	} while (0)
21058c2ecf20Sopenharmony_ci
21068c2ecf20Sopenharmony_ci#define ILOG2(x)	(ilog2((x)))
21078c2ecf20Sopenharmony_ci
21088c2ecf20Sopenharmony_ci#define ILT_NUM_PAGE_ENTRIES	(3072)
21098c2ecf20Sopenharmony_ci/* In 57710/11 we use whole table since we have 8 func
21108c2ecf20Sopenharmony_ci * In 57712 we have only 4 func, but use same size per func, then only half of
21118c2ecf20Sopenharmony_ci * the table in use
21128c2ecf20Sopenharmony_ci */
21138c2ecf20Sopenharmony_ci#define ILT_PER_FUNC		(ILT_NUM_PAGE_ENTRIES/8)
21148c2ecf20Sopenharmony_ci
21158c2ecf20Sopenharmony_ci#define FUNC_ILT_BASE(func)	(func * ILT_PER_FUNC)
21168c2ecf20Sopenharmony_ci/*
21178c2ecf20Sopenharmony_ci * the phys address is shifted right 12 bits and has an added
21188c2ecf20Sopenharmony_ci * 1=valid bit added to the 53rd bit
21198c2ecf20Sopenharmony_ci * then since this is a wide register(TM)
21208c2ecf20Sopenharmony_ci * we split it into two 32 bit writes
21218c2ecf20Sopenharmony_ci */
21228c2ecf20Sopenharmony_ci#define ONCHIP_ADDR1(x)		((u32)(((u64)x >> 12) & 0xFFFFFFFF))
21238c2ecf20Sopenharmony_ci#define ONCHIP_ADDR2(x)		((u32)((1 << 20) | ((u64)x >> 44)))
21248c2ecf20Sopenharmony_ci
21258c2ecf20Sopenharmony_ci/* load/unload mode */
21268c2ecf20Sopenharmony_ci#define LOAD_NORMAL			0
21278c2ecf20Sopenharmony_ci#define LOAD_OPEN			1
21288c2ecf20Sopenharmony_ci#define LOAD_DIAG			2
21298c2ecf20Sopenharmony_ci#define LOAD_LOOPBACK_EXT		3
21308c2ecf20Sopenharmony_ci#define UNLOAD_NORMAL			0
21318c2ecf20Sopenharmony_ci#define UNLOAD_CLOSE			1
21328c2ecf20Sopenharmony_ci#define UNLOAD_RECOVERY			2
21338c2ecf20Sopenharmony_ci
21348c2ecf20Sopenharmony_ci/* DMAE command defines */
21358c2ecf20Sopenharmony_ci#define DMAE_TIMEOUT			-1
21368c2ecf20Sopenharmony_ci#define DMAE_PCI_ERROR			-2	/* E2 and onward */
21378c2ecf20Sopenharmony_ci#define DMAE_NOT_RDY			-3
21388c2ecf20Sopenharmony_ci#define DMAE_PCI_ERR_FLAG		0x80000000
21398c2ecf20Sopenharmony_ci
21408c2ecf20Sopenharmony_ci#define DMAE_SRC_PCI			0
21418c2ecf20Sopenharmony_ci#define DMAE_SRC_GRC			1
21428c2ecf20Sopenharmony_ci
21438c2ecf20Sopenharmony_ci#define DMAE_DST_NONE			0
21448c2ecf20Sopenharmony_ci#define DMAE_DST_PCI			1
21458c2ecf20Sopenharmony_ci#define DMAE_DST_GRC			2
21468c2ecf20Sopenharmony_ci
21478c2ecf20Sopenharmony_ci#define DMAE_COMP_PCI			0
21488c2ecf20Sopenharmony_ci#define DMAE_COMP_GRC			1
21498c2ecf20Sopenharmony_ci
21508c2ecf20Sopenharmony_ci/* E2 and onward - PCI error handling in the completion */
21518c2ecf20Sopenharmony_ci
21528c2ecf20Sopenharmony_ci#define DMAE_COMP_REGULAR		0
21538c2ecf20Sopenharmony_ci#define DMAE_COM_SET_ERR		1
21548c2ecf20Sopenharmony_ci
21558c2ecf20Sopenharmony_ci#define DMAE_CMD_SRC_PCI		(DMAE_SRC_PCI << \
21568c2ecf20Sopenharmony_ci						DMAE_COMMAND_SRC_SHIFT)
21578c2ecf20Sopenharmony_ci#define DMAE_CMD_SRC_GRC		(DMAE_SRC_GRC << \
21588c2ecf20Sopenharmony_ci						DMAE_COMMAND_SRC_SHIFT)
21598c2ecf20Sopenharmony_ci
21608c2ecf20Sopenharmony_ci#define DMAE_CMD_DST_PCI		(DMAE_DST_PCI << \
21618c2ecf20Sopenharmony_ci						DMAE_COMMAND_DST_SHIFT)
21628c2ecf20Sopenharmony_ci#define DMAE_CMD_DST_GRC		(DMAE_DST_GRC << \
21638c2ecf20Sopenharmony_ci						DMAE_COMMAND_DST_SHIFT)
21648c2ecf20Sopenharmony_ci
21658c2ecf20Sopenharmony_ci#define DMAE_CMD_C_DST_PCI		(DMAE_COMP_PCI << \
21668c2ecf20Sopenharmony_ci						DMAE_COMMAND_C_DST_SHIFT)
21678c2ecf20Sopenharmony_ci#define DMAE_CMD_C_DST_GRC		(DMAE_COMP_GRC << \
21688c2ecf20Sopenharmony_ci						DMAE_COMMAND_C_DST_SHIFT)
21698c2ecf20Sopenharmony_ci
21708c2ecf20Sopenharmony_ci#define DMAE_CMD_C_ENABLE		DMAE_COMMAND_C_TYPE_ENABLE
21718c2ecf20Sopenharmony_ci
21728c2ecf20Sopenharmony_ci#define DMAE_CMD_ENDIANITY_NO_SWAP	(0 << DMAE_COMMAND_ENDIANITY_SHIFT)
21738c2ecf20Sopenharmony_ci#define DMAE_CMD_ENDIANITY_B_SWAP	(1 << DMAE_COMMAND_ENDIANITY_SHIFT)
21748c2ecf20Sopenharmony_ci#define DMAE_CMD_ENDIANITY_DW_SWAP	(2 << DMAE_COMMAND_ENDIANITY_SHIFT)
21758c2ecf20Sopenharmony_ci#define DMAE_CMD_ENDIANITY_B_DW_SWAP	(3 << DMAE_COMMAND_ENDIANITY_SHIFT)
21768c2ecf20Sopenharmony_ci
21778c2ecf20Sopenharmony_ci#define DMAE_CMD_PORT_0			0
21788c2ecf20Sopenharmony_ci#define DMAE_CMD_PORT_1			DMAE_COMMAND_PORT
21798c2ecf20Sopenharmony_ci
21808c2ecf20Sopenharmony_ci#define DMAE_CMD_SRC_RESET		DMAE_COMMAND_SRC_RESET
21818c2ecf20Sopenharmony_ci#define DMAE_CMD_DST_RESET		DMAE_COMMAND_DST_RESET
21828c2ecf20Sopenharmony_ci#define DMAE_CMD_E1HVN_SHIFT		DMAE_COMMAND_E1HVN_SHIFT
21838c2ecf20Sopenharmony_ci
21848c2ecf20Sopenharmony_ci#define DMAE_SRC_PF			0
21858c2ecf20Sopenharmony_ci#define DMAE_SRC_VF			1
21868c2ecf20Sopenharmony_ci
21878c2ecf20Sopenharmony_ci#define DMAE_DST_PF			0
21888c2ecf20Sopenharmony_ci#define DMAE_DST_VF			1
21898c2ecf20Sopenharmony_ci
21908c2ecf20Sopenharmony_ci#define DMAE_C_SRC			0
21918c2ecf20Sopenharmony_ci#define DMAE_C_DST			1
21928c2ecf20Sopenharmony_ci
21938c2ecf20Sopenharmony_ci#define DMAE_LEN32_RD_MAX		0x80
21948c2ecf20Sopenharmony_ci#define DMAE_LEN32_WR_MAX(bp)		(CHIP_IS_E1(bp) ? 0x400 : 0x2000)
21958c2ecf20Sopenharmony_ci
21968c2ecf20Sopenharmony_ci#define DMAE_COMP_VAL			0x60d0d0ae /* E2 and on - upper bit
21978c2ecf20Sopenharmony_ci						    * indicates error
21988c2ecf20Sopenharmony_ci						    */
21998c2ecf20Sopenharmony_ci
22008c2ecf20Sopenharmony_ci#define MAX_DMAE_C_PER_PORT		8
22018c2ecf20Sopenharmony_ci#define INIT_DMAE_C(bp)			(BP_PORT(bp) * MAX_DMAE_C_PER_PORT + \
22028c2ecf20Sopenharmony_ci					 BP_VN(bp))
22038c2ecf20Sopenharmony_ci#define PMF_DMAE_C(bp)			(BP_PORT(bp) * MAX_DMAE_C_PER_PORT + \
22048c2ecf20Sopenharmony_ci					 E1HVN_MAX)
22058c2ecf20Sopenharmony_ci
22068c2ecf20Sopenharmony_ci/* Following is the DMAE channel number allocation for the clients.
22078c2ecf20Sopenharmony_ci *   MFW: OCBB/OCSD implementations use DMAE channels 14/15 respectively.
22088c2ecf20Sopenharmony_ci *   Driver: 0-3 and 8-11 (for PF dmae operations)
22098c2ecf20Sopenharmony_ci *           4 and 12 (for stats requests)
22108c2ecf20Sopenharmony_ci */
22118c2ecf20Sopenharmony_ci#define BNX2X_FW_DMAE_C                 13 /* Channel for FW DMAE operations */
22128c2ecf20Sopenharmony_ci
22138c2ecf20Sopenharmony_ci/* PCIE link and speed */
22148c2ecf20Sopenharmony_ci#define PCICFG_LINK_WIDTH		0x1f00000
22158c2ecf20Sopenharmony_ci#define PCICFG_LINK_WIDTH_SHIFT		20
22168c2ecf20Sopenharmony_ci#define PCICFG_LINK_SPEED		0xf0000
22178c2ecf20Sopenharmony_ci#define PCICFG_LINK_SPEED_SHIFT		16
22188c2ecf20Sopenharmony_ci
22198c2ecf20Sopenharmony_ci#define BNX2X_NUM_TESTS_SF		7
22208c2ecf20Sopenharmony_ci#define BNX2X_NUM_TESTS_MF		3
22218c2ecf20Sopenharmony_ci#define BNX2X_NUM_TESTS(bp)		(IS_MF(bp) ? BNX2X_NUM_TESTS_MF : \
22228c2ecf20Sopenharmony_ci					     IS_VF(bp) ? 0 : BNX2X_NUM_TESTS_SF)
22238c2ecf20Sopenharmony_ci
22248c2ecf20Sopenharmony_ci#define BNX2X_PHY_LOOPBACK		0
22258c2ecf20Sopenharmony_ci#define BNX2X_MAC_LOOPBACK		1
22268c2ecf20Sopenharmony_ci#define BNX2X_EXT_LOOPBACK		2
22278c2ecf20Sopenharmony_ci#define BNX2X_PHY_LOOPBACK_FAILED	1
22288c2ecf20Sopenharmony_ci#define BNX2X_MAC_LOOPBACK_FAILED	2
22298c2ecf20Sopenharmony_ci#define BNX2X_EXT_LOOPBACK_FAILED	3
22308c2ecf20Sopenharmony_ci#define BNX2X_LOOPBACK_FAILED		(BNX2X_MAC_LOOPBACK_FAILED | \
22318c2ecf20Sopenharmony_ci					 BNX2X_PHY_LOOPBACK_FAILED)
22328c2ecf20Sopenharmony_ci
22338c2ecf20Sopenharmony_ci#define STROM_ASSERT_ARRAY_SIZE		50
22348c2ecf20Sopenharmony_ci
22358c2ecf20Sopenharmony_ci/* must be used on a CID before placing it on a HW ring */
22368c2ecf20Sopenharmony_ci#define HW_CID(bp, x)			((BP_PORT(bp) << 23) | \
22378c2ecf20Sopenharmony_ci					 (BP_VN(bp) << BNX2X_SWCID_SHIFT) | \
22388c2ecf20Sopenharmony_ci					 (x))
22398c2ecf20Sopenharmony_ci
22408c2ecf20Sopenharmony_ci#define SP_DESC_CNT		(BCM_PAGE_SIZE / sizeof(struct eth_spe))
22418c2ecf20Sopenharmony_ci#define MAX_SP_DESC_CNT			(SP_DESC_CNT - 1)
22428c2ecf20Sopenharmony_ci
22438c2ecf20Sopenharmony_ci#define BNX2X_BTR			4
22448c2ecf20Sopenharmony_ci#define MAX_SPQ_PENDING			8
22458c2ecf20Sopenharmony_ci
22468c2ecf20Sopenharmony_ci/* CMNG constants, as derived from system spec calculations */
22478c2ecf20Sopenharmony_ci/* default MIN rate in case VNIC min rate is configured to zero - 100Mbps */
22488c2ecf20Sopenharmony_ci#define DEF_MIN_RATE					100
22498c2ecf20Sopenharmony_ci/* resolution of the rate shaping timer - 400 usec */
22508c2ecf20Sopenharmony_ci#define RS_PERIODIC_TIMEOUT_USEC			400
22518c2ecf20Sopenharmony_ci/* number of bytes in single QM arbitration cycle -
22528c2ecf20Sopenharmony_ci * coefficient for calculating the fairness timer */
22538c2ecf20Sopenharmony_ci#define QM_ARB_BYTES					160000
22548c2ecf20Sopenharmony_ci/* resolution of Min algorithm 1:100 */
22558c2ecf20Sopenharmony_ci#define MIN_RES						100
22568c2ecf20Sopenharmony_ci/* how many bytes above threshold for the minimal credit of Min algorithm*/
22578c2ecf20Sopenharmony_ci#define MIN_ABOVE_THRESH				32768
22588c2ecf20Sopenharmony_ci/* Fairness algorithm integration time coefficient -
22598c2ecf20Sopenharmony_ci * for calculating the actual Tfair */
22608c2ecf20Sopenharmony_ci#define T_FAIR_COEF	((MIN_ABOVE_THRESH +  QM_ARB_BYTES) * 8 * MIN_RES)
22618c2ecf20Sopenharmony_ci/* Memory of fairness algorithm . 2 cycles */
22628c2ecf20Sopenharmony_ci#define FAIR_MEM					2
22638c2ecf20Sopenharmony_ci
22648c2ecf20Sopenharmony_ci#define ATTN_NIG_FOR_FUNC		(1L << 8)
22658c2ecf20Sopenharmony_ci#define ATTN_SW_TIMER_4_FUNC		(1L << 9)
22668c2ecf20Sopenharmony_ci#define GPIO_2_FUNC			(1L << 10)
22678c2ecf20Sopenharmony_ci#define GPIO_3_FUNC			(1L << 11)
22688c2ecf20Sopenharmony_ci#define GPIO_4_FUNC			(1L << 12)
22698c2ecf20Sopenharmony_ci#define ATTN_GENERAL_ATTN_1		(1L << 13)
22708c2ecf20Sopenharmony_ci#define ATTN_GENERAL_ATTN_2		(1L << 14)
22718c2ecf20Sopenharmony_ci#define ATTN_GENERAL_ATTN_3		(1L << 15)
22728c2ecf20Sopenharmony_ci#define ATTN_GENERAL_ATTN_4		(1L << 13)
22738c2ecf20Sopenharmony_ci#define ATTN_GENERAL_ATTN_5		(1L << 14)
22748c2ecf20Sopenharmony_ci#define ATTN_GENERAL_ATTN_6		(1L << 15)
22758c2ecf20Sopenharmony_ci
22768c2ecf20Sopenharmony_ci#define ATTN_HARD_WIRED_MASK		0xff00
22778c2ecf20Sopenharmony_ci#define ATTENTION_ID			4
22788c2ecf20Sopenharmony_ci
22798c2ecf20Sopenharmony_ci#define IS_MF_STORAGE_ONLY(bp) (IS_MF_STORAGE_PERSONALITY_ONLY(bp) || \
22808c2ecf20Sopenharmony_ci				 IS_MF_FCOE_AFEX(bp))
22818c2ecf20Sopenharmony_ci
22828c2ecf20Sopenharmony_ci/* stuff added to make the code fit 80Col */
22838c2ecf20Sopenharmony_ci
22848c2ecf20Sopenharmony_ci#define BNX2X_PMF_LINK_ASSERT \
22858c2ecf20Sopenharmony_ci	GENERAL_ATTEN_OFFSET(LINK_SYNC_ATTENTION_BIT_FUNC_0 + BP_FUNC(bp))
22868c2ecf20Sopenharmony_ci
22878c2ecf20Sopenharmony_ci#define BNX2X_MC_ASSERT_BITS \
22888c2ecf20Sopenharmony_ci	(GENERAL_ATTEN_OFFSET(TSTORM_FATAL_ASSERT_ATTENTION_BIT) | \
22898c2ecf20Sopenharmony_ci	 GENERAL_ATTEN_OFFSET(USTORM_FATAL_ASSERT_ATTENTION_BIT) | \
22908c2ecf20Sopenharmony_ci	 GENERAL_ATTEN_OFFSET(CSTORM_FATAL_ASSERT_ATTENTION_BIT) | \
22918c2ecf20Sopenharmony_ci	 GENERAL_ATTEN_OFFSET(XSTORM_FATAL_ASSERT_ATTENTION_BIT))
22928c2ecf20Sopenharmony_ci
22938c2ecf20Sopenharmony_ci#define BNX2X_MCP_ASSERT \
22948c2ecf20Sopenharmony_ci	GENERAL_ATTEN_OFFSET(MCP_FATAL_ASSERT_ATTENTION_BIT)
22958c2ecf20Sopenharmony_ci
22968c2ecf20Sopenharmony_ci#define BNX2X_GRC_TIMEOUT	GENERAL_ATTEN_OFFSET(LATCHED_ATTN_TIMEOUT_GRC)
22978c2ecf20Sopenharmony_ci#define BNX2X_GRC_RSV		(GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCR) | \
22988c2ecf20Sopenharmony_ci				 GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCT) | \
22998c2ecf20Sopenharmony_ci				 GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCN) | \
23008c2ecf20Sopenharmony_ci				 GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCU) | \
23018c2ecf20Sopenharmony_ci				 GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCP) | \
23028c2ecf20Sopenharmony_ci				 GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RSVD_GRC))
23038c2ecf20Sopenharmony_ci
23048c2ecf20Sopenharmony_ci#define HW_INTERRUPT_ASSERT_SET_0 \
23058c2ecf20Sopenharmony_ci				(AEU_INPUTS_ATTN_BITS_TSDM_HW_INTERRUPT | \
23068c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_TCM_HW_INTERRUPT | \
23078c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_TSEMI_HW_INTERRUPT | \
23088c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_BRB_HW_INTERRUPT | \
23098c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_PBCLIENT_HW_INTERRUPT)
23108c2ecf20Sopenharmony_ci#define HW_PRTY_ASSERT_SET_0	(AEU_INPUTS_ATTN_BITS_BRB_PARITY_ERROR | \
23118c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_PARSER_PARITY_ERROR | \
23128c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_TSDM_PARITY_ERROR | \
23138c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_SEARCHER_PARITY_ERROR |\
23148c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_TSEMI_PARITY_ERROR |\
23158c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_TCM_PARITY_ERROR |\
23168c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_PBCLIENT_PARITY_ERROR)
23178c2ecf20Sopenharmony_ci#define HW_INTERRUPT_ASSERT_SET_1 \
23188c2ecf20Sopenharmony_ci				(AEU_INPUTS_ATTN_BITS_QM_HW_INTERRUPT | \
23198c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_TIMERS_HW_INTERRUPT | \
23208c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_XSDM_HW_INTERRUPT | \
23218c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_XCM_HW_INTERRUPT | \
23228c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_XSEMI_HW_INTERRUPT | \
23238c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_USDM_HW_INTERRUPT | \
23248c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_UCM_HW_INTERRUPT | \
23258c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_USEMI_HW_INTERRUPT | \
23268c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_UPB_HW_INTERRUPT | \
23278c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_CSDM_HW_INTERRUPT | \
23288c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_CCM_HW_INTERRUPT)
23298c2ecf20Sopenharmony_ci#define HW_PRTY_ASSERT_SET_1	(AEU_INPUTS_ATTN_BITS_PBF_PARITY_ERROR |\
23308c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_QM_PARITY_ERROR | \
23318c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_TIMERS_PARITY_ERROR |\
23328c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_XSDM_PARITY_ERROR | \
23338c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_XCM_PARITY_ERROR |\
23348c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_XSEMI_PARITY_ERROR | \
23358c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_DOORBELLQ_PARITY_ERROR |\
23368c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_NIG_PARITY_ERROR |\
23378c2ecf20Sopenharmony_ci			     AEU_INPUTS_ATTN_BITS_VAUX_PCI_CORE_PARITY_ERROR |\
23388c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_DEBUG_PARITY_ERROR | \
23398c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_USDM_PARITY_ERROR | \
23408c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_UCM_PARITY_ERROR |\
23418c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_USEMI_PARITY_ERROR | \
23428c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_UPB_PARITY_ERROR | \
23438c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_CSDM_PARITY_ERROR |\
23448c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_CCM_PARITY_ERROR)
23458c2ecf20Sopenharmony_ci#define HW_INTERRUPT_ASSERT_SET_2 \
23468c2ecf20Sopenharmony_ci				(AEU_INPUTS_ATTN_BITS_CSEMI_HW_INTERRUPT | \
23478c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_CDU_HW_INTERRUPT | \
23488c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_DMAE_HW_INTERRUPT | \
23498c2ecf20Sopenharmony_ci			AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_HW_INTERRUPT |\
23508c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_MISC_HW_INTERRUPT)
23518c2ecf20Sopenharmony_ci#define HW_PRTY_ASSERT_SET_2	(AEU_INPUTS_ATTN_BITS_CSEMI_PARITY_ERROR | \
23528c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_PXP_PARITY_ERROR | \
23538c2ecf20Sopenharmony_ci			AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR |\
23548c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_CFC_PARITY_ERROR | \
23558c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_CDU_PARITY_ERROR | \
23568c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_DMAE_PARITY_ERROR |\
23578c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_IGU_PARITY_ERROR | \
23588c2ecf20Sopenharmony_ci				 AEU_INPUTS_ATTN_BITS_MISC_PARITY_ERROR)
23598c2ecf20Sopenharmony_ci
23608c2ecf20Sopenharmony_ci#define HW_PRTY_ASSERT_SET_3_WITHOUT_SCPAD \
23618c2ecf20Sopenharmony_ci		(AEU_INPUTS_ATTN_BITS_MCP_LATCHED_ROM_PARITY | \
23628c2ecf20Sopenharmony_ci		 AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_RX_PARITY | \
23638c2ecf20Sopenharmony_ci		 AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_TX_PARITY)
23648c2ecf20Sopenharmony_ci
23658c2ecf20Sopenharmony_ci#define HW_PRTY_ASSERT_SET_3 (HW_PRTY_ASSERT_SET_3_WITHOUT_SCPAD | \
23668c2ecf20Sopenharmony_ci			      AEU_INPUTS_ATTN_BITS_MCP_LATCHED_SCPAD_PARITY)
23678c2ecf20Sopenharmony_ci
23688c2ecf20Sopenharmony_ci#define HW_PRTY_ASSERT_SET_4 (AEU_INPUTS_ATTN_BITS_PGLUE_PARITY_ERROR | \
23698c2ecf20Sopenharmony_ci			      AEU_INPUTS_ATTN_BITS_ATC_PARITY_ERROR)
23708c2ecf20Sopenharmony_ci
23718c2ecf20Sopenharmony_ci#define MULTI_MASK			0x7f
23728c2ecf20Sopenharmony_ci
23738c2ecf20Sopenharmony_ci#define DEF_USB_FUNC_OFF	offsetof(struct cstorm_def_status_block_u, func)
23748c2ecf20Sopenharmony_ci#define DEF_CSB_FUNC_OFF	offsetof(struct cstorm_def_status_block_c, func)
23758c2ecf20Sopenharmony_ci#define DEF_XSB_FUNC_OFF	offsetof(struct xstorm_def_status_block, func)
23768c2ecf20Sopenharmony_ci#define DEF_TSB_FUNC_OFF	offsetof(struct tstorm_def_status_block, func)
23778c2ecf20Sopenharmony_ci
23788c2ecf20Sopenharmony_ci#define DEF_USB_IGU_INDEX_OFF \
23798c2ecf20Sopenharmony_ci			offsetof(struct cstorm_def_status_block_u, igu_index)
23808c2ecf20Sopenharmony_ci#define DEF_CSB_IGU_INDEX_OFF \
23818c2ecf20Sopenharmony_ci			offsetof(struct cstorm_def_status_block_c, igu_index)
23828c2ecf20Sopenharmony_ci#define DEF_XSB_IGU_INDEX_OFF \
23838c2ecf20Sopenharmony_ci			offsetof(struct xstorm_def_status_block, igu_index)
23848c2ecf20Sopenharmony_ci#define DEF_TSB_IGU_INDEX_OFF \
23858c2ecf20Sopenharmony_ci			offsetof(struct tstorm_def_status_block, igu_index)
23868c2ecf20Sopenharmony_ci
23878c2ecf20Sopenharmony_ci#define DEF_USB_SEGMENT_OFF \
23888c2ecf20Sopenharmony_ci			offsetof(struct cstorm_def_status_block_u, segment)
23898c2ecf20Sopenharmony_ci#define DEF_CSB_SEGMENT_OFF \
23908c2ecf20Sopenharmony_ci			offsetof(struct cstorm_def_status_block_c, segment)
23918c2ecf20Sopenharmony_ci#define DEF_XSB_SEGMENT_OFF \
23928c2ecf20Sopenharmony_ci			offsetof(struct xstorm_def_status_block, segment)
23938c2ecf20Sopenharmony_ci#define DEF_TSB_SEGMENT_OFF \
23948c2ecf20Sopenharmony_ci			offsetof(struct tstorm_def_status_block, segment)
23958c2ecf20Sopenharmony_ci
23968c2ecf20Sopenharmony_ci#define BNX2X_SP_DSB_INDEX \
23978c2ecf20Sopenharmony_ci		(&bp->def_status_blk->sp_sb.\
23988c2ecf20Sopenharmony_ci					index_values[HC_SP_INDEX_ETH_DEF_CONS])
23998c2ecf20Sopenharmony_ci
24008c2ecf20Sopenharmony_ci#define CAM_IS_INVALID(x) \
24018c2ecf20Sopenharmony_ci	(GET_FLAG(x.flags, \
24028c2ecf20Sopenharmony_ci	MAC_CONFIGURATION_ENTRY_ACTION_TYPE) == \
24038c2ecf20Sopenharmony_ci	(T_ETH_MAC_COMMAND_INVALIDATE))
24048c2ecf20Sopenharmony_ci
24058c2ecf20Sopenharmony_ci/* Number of u32 elements in MC hash array */
24068c2ecf20Sopenharmony_ci#define MC_HASH_SIZE			8
24078c2ecf20Sopenharmony_ci#define MC_HASH_OFFSET(bp, i)		(BAR_TSTRORM_INTMEM + \
24088c2ecf20Sopenharmony_ci	TSTORM_APPROXIMATE_MATCH_MULTICAST_FILTERING_OFFSET(BP_FUNC(bp)) + i*4)
24098c2ecf20Sopenharmony_ci
24108c2ecf20Sopenharmony_ci#ifndef PXP2_REG_PXP2_INT_STS
24118c2ecf20Sopenharmony_ci#define PXP2_REG_PXP2_INT_STS		PXP2_REG_PXP2_INT_STS_0
24128c2ecf20Sopenharmony_ci#endif
24138c2ecf20Sopenharmony_ci
24148c2ecf20Sopenharmony_ci#ifndef ETH_MAX_RX_CLIENTS_E2
24158c2ecf20Sopenharmony_ci#define ETH_MAX_RX_CLIENTS_E2		ETH_MAX_RX_CLIENTS_E1H
24168c2ecf20Sopenharmony_ci#endif
24178c2ecf20Sopenharmony_ci
24188c2ecf20Sopenharmony_ci#define BNX2X_VPD_LEN			128
24198c2ecf20Sopenharmony_ci#define VENDOR_ID_LEN			4
24208c2ecf20Sopenharmony_ci
24218c2ecf20Sopenharmony_ci#define VF_ACQUIRE_THRESH		3
24228c2ecf20Sopenharmony_ci#define VF_ACQUIRE_MAC_FILTERS		1
24238c2ecf20Sopenharmony_ci#define VF_ACQUIRE_MC_FILTERS		10
24248c2ecf20Sopenharmony_ci#define VF_ACQUIRE_VLAN_FILTERS		2 /* VLAN0 + 'real' VLAN */
24258c2ecf20Sopenharmony_ci
24268c2ecf20Sopenharmony_ci#define GOOD_ME_REG(me_reg) (((me_reg) & ME_REG_VF_VALID) && \
24278c2ecf20Sopenharmony_ci			    (!((me_reg) & ME_REG_VF_ERR)))
24288c2ecf20Sopenharmony_ciint bnx2x_compare_fw_ver(struct bnx2x *bp, u32 load_code, bool print_err);
24298c2ecf20Sopenharmony_ci
24308c2ecf20Sopenharmony_ci/* Congestion management fairness mode */
24318c2ecf20Sopenharmony_ci#define CMNG_FNS_NONE			0
24328c2ecf20Sopenharmony_ci#define CMNG_FNS_MINMAX			1
24338c2ecf20Sopenharmony_ci
24348c2ecf20Sopenharmony_ci#define HC_SEG_ACCESS_DEF		0   /*Driver decision 0-3*/
24358c2ecf20Sopenharmony_ci#define HC_SEG_ACCESS_ATTN		4
24368c2ecf20Sopenharmony_ci#define HC_SEG_ACCESS_NORM		0   /*Driver decision 0-1*/
24378c2ecf20Sopenharmony_ci
24388c2ecf20Sopenharmony_civoid bnx2x_set_ethtool_ops(struct bnx2x *bp, struct net_device *netdev);
24398c2ecf20Sopenharmony_civoid bnx2x_notify_link_changed(struct bnx2x *bp);
24408c2ecf20Sopenharmony_ci
24418c2ecf20Sopenharmony_ci#define BNX2X_MF_SD_PROTOCOL(bp) \
24428c2ecf20Sopenharmony_ci	((bp)->mf_config[BP_VN(bp)] & FUNC_MF_CFG_PROTOCOL_MASK)
24438c2ecf20Sopenharmony_ci
24448c2ecf20Sopenharmony_ci#define BNX2X_IS_MF_SD_PROTOCOL_ISCSI(bp) \
24458c2ecf20Sopenharmony_ci	(BNX2X_MF_SD_PROTOCOL(bp) == FUNC_MF_CFG_PROTOCOL_ISCSI)
24468c2ecf20Sopenharmony_ci
24478c2ecf20Sopenharmony_ci#define BNX2X_IS_MF_SD_PROTOCOL_FCOE(bp) \
24488c2ecf20Sopenharmony_ci	(BNX2X_MF_SD_PROTOCOL(bp) == FUNC_MF_CFG_PROTOCOL_FCOE)
24498c2ecf20Sopenharmony_ci
24508c2ecf20Sopenharmony_ci#define IS_MF_ISCSI_SD(bp) (IS_MF_SD(bp) && BNX2X_IS_MF_SD_PROTOCOL_ISCSI(bp))
24518c2ecf20Sopenharmony_ci#define IS_MF_FCOE_SD(bp) (IS_MF_SD(bp) && BNX2X_IS_MF_SD_PROTOCOL_FCOE(bp))
24528c2ecf20Sopenharmony_ci#define IS_MF_ISCSI_SI(bp) (IS_MF_SI(bp) && BNX2X_IS_MF_EXT_PROTOCOL_ISCSI(bp))
24538c2ecf20Sopenharmony_ci
24548c2ecf20Sopenharmony_ci#define IS_MF_ISCSI_ONLY(bp)    (IS_MF_ISCSI_SD(bp) ||  IS_MF_ISCSI_SI(bp))
24558c2ecf20Sopenharmony_ci
24568c2ecf20Sopenharmony_ci#define BNX2X_MF_EXT_PROTOCOL_MASK					\
24578c2ecf20Sopenharmony_ci				(MACP_FUNC_CFG_FLAGS_ETHERNET |		\
24588c2ecf20Sopenharmony_ci				 MACP_FUNC_CFG_FLAGS_ISCSI_OFFLOAD |	\
24598c2ecf20Sopenharmony_ci				 MACP_FUNC_CFG_FLAGS_FCOE_OFFLOAD)
24608c2ecf20Sopenharmony_ci
24618c2ecf20Sopenharmony_ci#define BNX2X_MF_EXT_PROT(bp)	((bp)->mf_ext_config &			\
24628c2ecf20Sopenharmony_ci				 BNX2X_MF_EXT_PROTOCOL_MASK)
24638c2ecf20Sopenharmony_ci
24648c2ecf20Sopenharmony_ci#define BNX2X_HAS_MF_EXT_PROTOCOL_FCOE(bp)				\
24658c2ecf20Sopenharmony_ci		(BNX2X_MF_EXT_PROT(bp) & MACP_FUNC_CFG_FLAGS_FCOE_OFFLOAD)
24668c2ecf20Sopenharmony_ci
24678c2ecf20Sopenharmony_ci#define BNX2X_IS_MF_EXT_PROTOCOL_FCOE(bp)				\
24688c2ecf20Sopenharmony_ci		(BNX2X_MF_EXT_PROT(bp) == MACP_FUNC_CFG_FLAGS_FCOE_OFFLOAD)
24698c2ecf20Sopenharmony_ci
24708c2ecf20Sopenharmony_ci#define BNX2X_IS_MF_EXT_PROTOCOL_ISCSI(bp)				\
24718c2ecf20Sopenharmony_ci		(BNX2X_MF_EXT_PROT(bp) == MACP_FUNC_CFG_FLAGS_ISCSI_OFFLOAD)
24728c2ecf20Sopenharmony_ci
24738c2ecf20Sopenharmony_ci#define IS_MF_FCOE_AFEX(bp)						\
24748c2ecf20Sopenharmony_ci		(IS_MF_AFEX(bp) && BNX2X_IS_MF_EXT_PROTOCOL_FCOE(bp))
24758c2ecf20Sopenharmony_ci
24768c2ecf20Sopenharmony_ci#define IS_MF_SD_STORAGE_PERSONALITY_ONLY(bp)				\
24778c2ecf20Sopenharmony_ci				(IS_MF_SD(bp) &&			\
24788c2ecf20Sopenharmony_ci				 (BNX2X_IS_MF_SD_PROTOCOL_ISCSI(bp) ||	\
24798c2ecf20Sopenharmony_ci				  BNX2X_IS_MF_SD_PROTOCOL_FCOE(bp)))
24808c2ecf20Sopenharmony_ci
24818c2ecf20Sopenharmony_ci#define IS_MF_SI_STORAGE_PERSONALITY_ONLY(bp)				\
24828c2ecf20Sopenharmony_ci				(IS_MF_SI(bp) &&			\
24838c2ecf20Sopenharmony_ci				 (BNX2X_IS_MF_EXT_PROTOCOL_ISCSI(bp) ||	\
24848c2ecf20Sopenharmony_ci				  BNX2X_IS_MF_EXT_PROTOCOL_FCOE(bp)))
24858c2ecf20Sopenharmony_ci
24868c2ecf20Sopenharmony_ci#define IS_MF_STORAGE_PERSONALITY_ONLY(bp)				\
24878c2ecf20Sopenharmony_ci			(IS_MF_SD_STORAGE_PERSONALITY_ONLY(bp) ||	\
24888c2ecf20Sopenharmony_ci			 IS_MF_SI_STORAGE_PERSONALITY_ONLY(bp))
24898c2ecf20Sopenharmony_ci
24908c2ecf20Sopenharmony_ci/* Determines whether BW configuration arrives in 100Mb units or in
24918c2ecf20Sopenharmony_ci * percentages from actual physical link speed.
24928c2ecf20Sopenharmony_ci */
24938c2ecf20Sopenharmony_ci#define IS_MF_PERCENT_BW(bp) (IS_MF_SI(bp) || IS_MF_UFP(bp) || IS_MF_BD(bp))
24948c2ecf20Sopenharmony_ci
24958c2ecf20Sopenharmony_ci#define SET_FLAG(value, mask, flag) \
24968c2ecf20Sopenharmony_ci	do {\
24978c2ecf20Sopenharmony_ci		(value) &= ~(mask);\
24988c2ecf20Sopenharmony_ci		(value) |= ((flag) << (mask##_SHIFT));\
24998c2ecf20Sopenharmony_ci	} while (0)
25008c2ecf20Sopenharmony_ci
25018c2ecf20Sopenharmony_ci#define GET_FLAG(value, mask) \
25028c2ecf20Sopenharmony_ci	(((value) & (mask)) >> (mask##_SHIFT))
25038c2ecf20Sopenharmony_ci
25048c2ecf20Sopenharmony_ci#define GET_FIELD(value, fname) \
25058c2ecf20Sopenharmony_ci	(((value) & (fname##_MASK)) >> (fname##_SHIFT))
25068c2ecf20Sopenharmony_ci
25078c2ecf20Sopenharmony_cienum {
25088c2ecf20Sopenharmony_ci	SWITCH_UPDATE,
25098c2ecf20Sopenharmony_ci	AFEX_UPDATE,
25108c2ecf20Sopenharmony_ci};
25118c2ecf20Sopenharmony_ci
25128c2ecf20Sopenharmony_ci#define NUM_MACS	8
25138c2ecf20Sopenharmony_ci
25148c2ecf20Sopenharmony_civoid bnx2x_set_local_cmng(struct bnx2x *bp);
25158c2ecf20Sopenharmony_ci
25168c2ecf20Sopenharmony_civoid bnx2x_update_mng_version(struct bnx2x *bp);
25178c2ecf20Sopenharmony_ci
25188c2ecf20Sopenharmony_civoid bnx2x_update_mfw_dump(struct bnx2x *bp);
25198c2ecf20Sopenharmony_ci
25208c2ecf20Sopenharmony_ci#define MCPR_SCRATCH_BASE(bp) \
25218c2ecf20Sopenharmony_ci	(CHIP_IS_E1x(bp) ? MCP_REG_MCPR_SCRATCH : MCP_A_REG_MCPR_SCRATCH)
25228c2ecf20Sopenharmony_ci
25238c2ecf20Sopenharmony_ci#define E1H_MAX_MF_SB_COUNT (HC_SB_MAX_SB_E1X/(E1HVN_MAX * PORT_MAX))
25248c2ecf20Sopenharmony_ci
25258c2ecf20Sopenharmony_civoid bnx2x_init_ptp(struct bnx2x *bp);
25268c2ecf20Sopenharmony_ciint bnx2x_configure_ptp_filters(struct bnx2x *bp);
25278c2ecf20Sopenharmony_civoid bnx2x_set_rx_ts(struct bnx2x *bp, struct sk_buff *skb);
25288c2ecf20Sopenharmony_civoid bnx2x_register_phc(struct bnx2x *bp);
25298c2ecf20Sopenharmony_ci
25308c2ecf20Sopenharmony_ci#define BNX2X_MAX_PHC_DRIFT 31000000
25318c2ecf20Sopenharmony_ci#define BNX2X_PTP_TX_TIMEOUT
25328c2ecf20Sopenharmony_ci
25338c2ecf20Sopenharmony_ci/* Re-configure all previously configured vlan filters.
25348c2ecf20Sopenharmony_ci * Meant for implicit re-load flows.
25358c2ecf20Sopenharmony_ci */
25368c2ecf20Sopenharmony_ciint bnx2x_vlan_reconfigure_vid(struct bnx2x *bp);
25378c2ecf20Sopenharmony_ci#endif /* bnx2x.h */
2538