linux/drivers/net/ethernet/emulex/benet/be.h

/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (C) 2005 - 2016 Broadcom
 * All rights reserved.
 *
 * Contact Information:
 * [email protected]
 *
 * Emulex
 * 3333 Susan Street
 * Costa Mesa, CA 92626
 */

#ifndef BE_H
#define BE_H

#include <linux/pci.h>
#include <linux/etherdevice.h>
#include <linux/delay.h>
#include <net/tcp.h>
#include <net/ip.h>
#include <net/ipv6.h>
#include <linux/if_vlan.h>
#include <linux/workqueue.h>
#include <linux/interrupt.h>
#include <linux/firmware.h>
#include <linux/slab.h>
#include <linux/u64_stats_sync.h>
#include <linux/cpumask.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>

#include "be_hw.h"
#include "be_roce.h"

#define DRV_NAME
#define BE_NAME
#define BE3_NAME
#define OC_NAME
#define OC_NAME_BE
#define OC_NAME_LANCER
#define OC_NAME_SH
#define DRV_DESC

#define BE_VENDOR_ID
#define EMULEX_VENDOR_ID
#define BE_DEVICE_ID1
#define BE_DEVICE_ID2
#define OC_DEVICE_ID1
#define OC_DEVICE_ID2
#define OC_DEVICE_ID3
#define OC_DEVICE_ID4
#define OC_DEVICE_ID5
#define OC_DEVICE_ID6
#define OC_SUBSYS_DEVICE_ID1
#define OC_SUBSYS_DEVICE_ID2
#define OC_SUBSYS_DEVICE_ID3
#define OC_SUBSYS_DEVICE_ID4

/* Number of bytes of an RX frame that are copied to skb->data */
#define BE_HDR_LEN
/* allocate extra space to allow tunneling decapsulation without head reallocation */
#define BE_RX_SKB_ALLOC_SIZE

#define BE_MAX_JUMBO_FRAME_SIZE
#define BE_MIN_MTU
#define BE_MAX_MTU

/* Accommodate for QnQ configurations where VLAN insertion is enabled in HW */
#define BE_MAX_GSO_SIZE

#define BE_NUM_VLANS_SUPPORTED
#define BE_MAX_EQD
#define BE_MAX_TX_FRAG_COUNT

#define EVNT_Q_LEN
#define TX_Q_LEN
#define TX_CQ_LEN
#define RX_Q_LEN
#define RX_CQ_LEN
#define MCC_Q_LEN
#define MCC_CQ_LEN

#define BE2_MAX_RSS_QS
#define BE3_MAX_RSS_QS
#define BE3_MAX_TX_QS
#define BE3_MAX_EVT_QS
#define BE3_SRIOV_MAX_EVT_QS
#define SH_VF_MAX_NIC_EQS

#define MAX_PORT_RSS_TABLES
#define MAX_NIC_FUNCS
#define MAX_RX_QS
#define MAX_EVT_QS
#define MAX_TX_QS

#define MAX_ROCE_EQS
#define MAX_MSIX_VECTORS
#define MIN_MSIX_VECTORS
#define MAX_RX_POST
#define RX_FRAGS_REFILL_WM
#define MAX_NUM_POST_ERX_DB

#define MAX_VFS
#define FW_VER_LEN
#define CNTL_SERIAL_NUM_WORDS
#define CNTL_SERIAL_NUM_WORD_SZ

#define RSS_INDIR_TABLE_LEN
#define RSS_HASH_KEY_LEN

#define BE_UNKNOWN_PHY_STATE

struct be_dma_mem {};

struct be_queue_info {};

static inline u32 MODULO(u32 val, u32 limit)
{}

static inline void index_adv(u32 *index, u32 val, u32 limit)
{}

static inline void index_inc(u32 *index, u32 limit)
{}

static inline void *queue_head_node(struct be_queue_info *q)
{}

static inline void *queue_tail_node(struct be_queue_info *q)
{}

static inline void *queue_index_node(struct be_queue_info *q, u16 index)
{}

static inline void queue_head_inc(struct be_queue_info *q)
{}

static inline void index_dec(u32 *index, u32 limit)
{}

static inline void queue_tail_inc(struct be_queue_info *q)
{}

struct be_eq_obj {} ____cacheline_aligned_in_smp;

struct be_aic_obj {};

struct be_mcc_obj {};

struct be_tx_stats {};

/* Structure to hold some data of interest obtained from a TX CQE */
struct be_tx_compl_info {};

struct be_tx_obj {} ____cacheline_aligned_in_smp;

/* Struct to remember the pages posted for rx frags */
struct be_rx_page_info {};

struct be_rx_stats {};

struct be_rx_compl_info {};

struct be_rx_obj {} ____cacheline_aligned_in_smp;

struct be_drv_stats {};

/* A vlan-id of 0xFFFF must be used to clear transparent vlan-tagging */
#define BE_RESET_VLAN_TAG_ID

struct be_vf_cfg {};

enum vf_state {};

#define BE_FLAGS_LINK_STATUS_INIT
#define BE_FLAGS_SRIOV_ENABLED
#define BE_FLAGS_WORKER_SCHEDULED
#define BE_FLAGS_NAPI_ENABLED
#define BE_FLAGS_QNQ_ASYNC_EVT_RCVD
#define BE_FLAGS_VXLAN_OFFLOADS
#define BE_FLAGS_SETUP_DONE
#define BE_FLAGS_PHY_MISCONFIGURED
#define BE_FLAGS_ERR_DETECTION_SCHEDULED
#define BE_FLAGS_OS2BMC
#define BE_FLAGS_TRY_RECOVERY

#define BE_UC_PMAC_COUNT
#define BE_VF_UC_PMAC_COUNT

#define MAX_ERR_RECOVERY_RETRY_COUNT
#define ERR_DETECTION_DELAY

/* Ethtool set_dump flags */
#define LANCER_INITIATE_FW_DUMP
#define LANCER_DELETE_FW_DUMP

struct phy_info {};

struct be_resources {};

/* These are port-wide values */
struct be_port_resources {};

#define be_is_os2bmc_enabled(adapter)

struct rss_info {};

#define BE_INVALID_DIE_TEMP
struct be_hwmon {};

/* Macros to read/write the 'features' word of be_wrb_params structure.
 */
#define BE_WRB_F_BIT(name)
#define BE_WRB_F_MASK(name)

#define BE_WRB_F_GET(word, name)

#define BE_WRB_F_SET(word, name, val)

/* Feature/offload bits */
enum {};

/* The structure below provides a HW-agnostic abstraction of WRB params
 * retrieved from a TX skb. This is in turn passed to chip specific routines
 * during transmit, to set the corresponding params in the WRB.
 */
struct be_wrb_params {};

struct be_eth_addr {};

#define BE_SEC
#define BE_MIN
#define BE_HOUR

#define ERR_RECOVERY_MAX_RETRY_COUNT
#define ERR_RECOVERY_DETECTION_DELAY
#define ERR_RECOVERY_RETRY_DELAY

/* UE-detection-duration in BEx/Skyhawk:
 * All PFs must wait for this duration after they detect UE before reading
 * SLIPORT_SEMAPHORE register. At the end of this duration, the Firmware
 * guarantees that the SLIPORT_SEMAPHORE register is updated to indicate
 * if the UE is recoverable.
 */
#define ERR_RECOVERY_UE_DETECT_DURATION

/* Initial idle time (in msec) to elapse after driver load,
 * before UE recovery is allowed.
 */
#define ERR_IDLE_HR
#define ERR_RECOVERY_IDLE_TIME

/* Time interval (in msec) after which UE recovery can be repeated */
#define ERR_INTERVAL_HR
#define ERR_RECOVERY_INTERVAL

/* BEx/SH UE recovery state machine */
enum {};

struct be_error_recovery {};

/* Ethtool priv_flags */
#define BE_DISABLE_TPE_RECOVERY

struct be_vxlan_port {};

struct be_adapter {};

/* Used for defered FW config cmds. Add fields to this struct as reqd */
struct be_cmd_work {};

#define be_physfn(adapter)
#define be_virtfn(adapter)
#define sriov_enabled(adapter)

#define for_all_vfs(adapter, vf_cfg, i)

#define ON
#define OFF

#define be_max_vlans(adapter)
#define be_max_uc(adapter)
#define be_max_mc(adapter)
#define be_max_vfs(adapter)
#define be_max_rss(adapter)
#define be_max_txqs(adapter)
#define be_max_prio_txqs(adapter)
#define be_max_rxqs(adapter)
/* Max number of EQs available for the function (NIC + RoCE (if enabled)) */
#define be_max_func_eqs(adapter)
/* Max number of EQs available avaialble only for NIC */
#define be_max_nic_eqs(adapter)
#define be_if_cap_flags(adapter)
#define be_max_pf_pool_rss_tables(adapter)
/* Max irqs avaialble for NIC */
#define be_max_irqs(adapter)

/* Max irqs *needed* for RX queues */
static inline u16 be_max_rx_irqs(struct be_adapter *adapter)
{}

/* Max irqs *needed* for TX queues */
static inline u16 be_max_tx_irqs(struct be_adapter *adapter)
{}

/* Max irqs *needed* for combined queues */
static inline u16 be_max_qp_irqs(struct be_adapter *adapter)
{}

/* Max irqs *needed* for RX and TX queues together */
static inline u16 be_max_any_irqs(struct be_adapter *adapter)
{}

/* Is BE in pvid_tagging mode */
#define be_pvid_tagging_enabled(adapter)

/* Is BE in QNQ multi-channel mode */
#define be_is_qnq_mode(adapter)

#ifdef CONFIG_BE2NET_LANCER
#define lancer_chip(adapter)
#else
#define lancer_chip
#endif /* CONFIG_BE2NET_LANCER */

#ifdef CONFIG_BE2NET_SKYHAWK
#define skyhawk_chip(adapter)
#else
#define skyhawk_chip
#endif /* CONFIG_BE2NET_SKYHAWK */

#ifdef CONFIG_BE2NET_BE3
#define BE3_chip(adapter)
#else
#define BE3_chip
#endif /* CONFIG_BE2NET_BE3 */

#ifdef CONFIG_BE2NET_BE2
#define BE2_chip(adapter)
#else
#define BE2_chip
#endif /* CONFIG_BE2NET_BE2 */

#define BEx_chip(adapter)

#define be_roce_supported(adapter)

extern const struct ethtool_ops be_ethtool_ops;

#define msix_enabled(adapter)
#define num_irqs(adapter)
#define tx_stats(txo)
#define rx_stats(rxo)

/* The default RXQ is the last RXQ */
#define default_rxo(adpt)

#define for_all_rx_queues(adapter, rxo, i)

#define for_all_rss_queues(adapter, rxo, i)

#define for_all_tx_queues(adapter, txo, i)

#define for_all_evt_queues(adapter, eqo, i)

#define for_all_rx_queues_on_eq(adapter, eqo, rxo, i)

#define for_all_tx_queues_on_eq(adapter, eqo, txo, i)

#define is_mcc_eqo(eqo)
#define mcc_eqo(adapter)

#define PAGE_SHIFT_4K
#define PAGE_SIZE_4K

/* Returns number of pages spanned by the data starting at the given addr */
#define PAGES_4K_SPANNED(_address, size)

/* Returns bit offset within a DWORD of a bitfield */
#define AMAP_BIT_OFFSET(_struct, field)

/* Returns the bit mask of the field that is NOT shifted into location. */
static inline u32 amap_mask(u32 bitsize)
{}

static inline void
amap_set(void *ptr, u32 dw_offset, u32 mask, u32 offset, u32 value)
{}

#define AMAP_SET_BITS(_struct, field, ptr, val)

static inline u32 amap_get(void *ptr, u32 dw_offset, u32 mask, u32 offset)
{}

#define AMAP_GET_BITS(_struct, field, ptr)

#define GET_RX_COMPL_V0_BITS(field, ptr)

#define GET_RX_COMPL_V1_BITS(field, ptr)

#define GET_TX_COMPL_BITS(field, ptr)

#define SET_TX_WRB_HDR_BITS(field, ptr, val)

#define be_dws_cpu_to_le(wrb, len)
#define be_dws_le_to_cpu(wrb, len)
static inline void swap_dws(void *wrb, int len)
{}

#define be_cmd_status(status)

static inline u8 is_tcp_pkt(struct sk_buff *skb)
{}

static inline u8 is_udp_pkt(struct sk_buff *skb)
{}

static inline bool is_ipv4_pkt(struct sk_buff *skb)
{}

static inline bool is_ipv6_ext_hdr(struct sk_buff *skb)
{}

#define be_error_recovering(adapter)

#define BE_ERROR_EEH
#define BE_ERROR_UE
#define BE_ERROR_FW
#define BE_ERROR_TX
#define BE_ERROR_HW
#define BE_ERROR_ANY
#define BE_CLEAR_ALL

static inline u8 be_check_error(struct be_adapter *adapter, u32 err_type)
{}

static inline void be_set_error(struct be_adapter *adapter, int err_type)
{}

static inline void  be_clear_error(struct be_adapter *adapter, int err_type)
{}

static inline bool be_multi_rxq(const struct be_adapter *adapter)
{}

void be_cq_notify(struct be_adapter *adapter, u16 qid, bool arm,
		  u16 num_popped);
void be_link_status_update(struct be_adapter *adapter, u8 link_status);
void be_parse_stats(struct be_adapter *adapter);
int be_load_fw(struct be_adapter *adapter, u8 *func);
bool be_is_wol_supported(struct be_adapter *adapter);
bool be_pause_supported(struct be_adapter *adapter);
u32 be_get_fw_log_level(struct be_adapter *adapter);
int be_update_queues(struct be_adapter *adapter);
int be_poll(struct napi_struct *napi, int budget);
void be_eqd_update(struct be_adapter *adapter, bool force_update);

/*
 * internal function to initialize-cleanup roce device.
 */
void be_roce_dev_add(struct be_adapter *);
void be_roce_dev_remove(struct be_adapter *);

/*
 * internal function to open-close roce device during ifup-ifdown.
 */
void be_roce_dev_shutdown(struct be_adapter *);

#endif				/* BE_H */