linux/drivers/net/ethernet/cavium/thunder/nic.h

/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (C) 2015 Cavium, Inc.
 */

#ifndef NIC_H
#define NIC_H

#include <linux/netdevice.h>
#include <linux/interrupt.h>
#include <linux/pci.h>
#include "thunder_bgx.h"

/* PCI device IDs */
#define PCI_DEVICE_ID_THUNDER_NIC_PF
#define PCI_DEVICE_ID_THUNDER_PASS1_NIC_VF
#define PCI_DEVICE_ID_THUNDER_NIC_VF
#define PCI_DEVICE_ID_THUNDER_BGX

/* Subsystem device IDs */
#define PCI_SUBSYS_DEVID_88XX_NIC_PF
#define PCI_SUBSYS_DEVID_81XX_NIC_PF
#define PCI_SUBSYS_DEVID_83XX_NIC_PF

#define PCI_SUBSYS_DEVID_88XX_PASS1_NIC_VF
#define PCI_SUBSYS_DEVID_88XX_NIC_VF
#define PCI_SUBSYS_DEVID_81XX_NIC_VF
#define PCI_SUBSYS_DEVID_83XX_NIC_VF


/* PCI BAR nos */
#define PCI_CFG_REG_BAR_NUM
#define PCI_MSIX_REG_BAR_NUM

/* NIC SRIOV VF count */
#define MAX_NUM_VFS_SUPPORTED
#define DEFAULT_NUM_VF_ENABLED

#define NIC_TNS_BYPASS_MODE
#define NIC_TNS_MODE

/* NIC priv flags */
#define NIC_SRIOV_ENABLED

/* Min/Max packet size */
#define NIC_HW_MIN_FRS
#define NIC_HW_MAX_FRS

/* Max pkinds */
#define NIC_MAX_PKIND

/* Max when CPI_ALG is IP diffserv */
#define NIC_MAX_CPI_PER_LMAC

/* NIC VF Interrupts */
#define NICVF_INTR_CQ
#define NICVF_INTR_SQ
#define NICVF_INTR_RBDR
#define NICVF_INTR_PKT_DROP
#define NICVF_INTR_TCP_TIMER
#define NICVF_INTR_MBOX
#define NICVF_INTR_QS_ERR

#define NICVF_INTR_CQ_SHIFT
#define NICVF_INTR_SQ_SHIFT
#define NICVF_INTR_RBDR_SHIFT
#define NICVF_INTR_PKT_DROP_SHIFT
#define NICVF_INTR_TCP_TIMER_SHIFT
#define NICVF_INTR_MBOX_SHIFT
#define NICVF_INTR_QS_ERR_SHIFT

#define NICVF_INTR_CQ_MASK
#define NICVF_INTR_SQ_MASK
#define NICVF_INTR_RBDR_MASK
#define NICVF_INTR_PKT_DROP_MASK
#define NICVF_INTR_TCP_TIMER_MASK
#define NICVF_INTR_MBOX_MASK
#define NICVF_INTR_QS_ERR_MASK

/* MSI-X interrupts */
#define NIC_PF_MSIX_VECTORS
#define NIC_VF_MSIX_VECTORS

#define NIC_PF_INTR_ID_ECC0_SBE
#define NIC_PF_INTR_ID_ECC0_DBE
#define NIC_PF_INTR_ID_ECC1_SBE
#define NIC_PF_INTR_ID_ECC1_DBE
#define NIC_PF_INTR_ID_ECC2_SBE
#define NIC_PF_INTR_ID_ECC2_DBE
#define NIC_PF_INTR_ID_ECC3_SBE
#define NIC_PF_INTR_ID_ECC3_DBE
#define NIC_PF_INTR_ID_MBOX0
#define NIC_PF_INTR_ID_MBOX1

/* Minimum FIFO level before all packets for the CQ are dropped
 *
 * This value ensures that once a packet has been "accepted"
 * for reception it will not get dropped due to non-availability
 * of CQ descriptor. An errata in HW mandates this value to be
 * atleast 0x100.
 */
#define NICPF_CQM_MIN_DROP_LEVEL

/* Global timer for CQ timer thresh interrupts
 * Calculated for SCLK of 700Mhz
 * value written should be a 1/16th of what is expected
 *
 * 1 tick per 0.025usec
 */
#define NICPF_CLK_PER_INT_TICK

/* Time to wait before we decide that a SQ is stuck.
 *
 * Since both pkt rx and tx notifications are done with same CQ,
 * when packets are being received at very high rate (eg: L2 forwarding)
 * then freeing transmitted skbs will be delayed and watchdog
 * will kick in, resetting interface. Hence keeping this value high.
 */
#define NICVF_TX_TIMEOUT

struct nicvf_cq_poll {};

#define NIC_MAX_RSS_HASH_BITS
#define NIC_MAX_RSS_IDR_TBL_SIZE
#define RSS_HASH_KEY_SIZE

struct nicvf_rss_info {} ____cacheline_aligned_in_smp;

struct nicvf_pfc {};

enum rx_stats_reg_offset {};

enum tx_stats_reg_offset {};

struct nicvf_hw_stats {};

struct nicvf_drv_stats {};

struct cavium_ptp;

struct xcast_addr_list {};

struct nicvf_work {};

struct nicvf {} ____cacheline_aligned_in_smp;

/* PF <--> VF Mailbox communication
 * Eight 64bit registers are shared between PF and VF.
 * Separate set for each VF.
 * Writing '1' into last register mbx7 means end of message.
 */

/* PF <--> VF mailbox communication */
#define NIC_PF_VF_MAILBOX_SIZE
#define NIC_MBOX_MSG_TIMEOUT

/* Mailbox message types */
#define NIC_MBOX_MSG_READY
#define NIC_MBOX_MSG_ACK
#define NIC_MBOX_MSG_NACK
#define NIC_MBOX_MSG_QS_CFG
#define NIC_MBOX_MSG_RQ_CFG
#define NIC_MBOX_MSG_SQ_CFG
#define NIC_MBOX_MSG_RQ_DROP_CFG
#define NIC_MBOX_MSG_SET_MAC
#define NIC_MBOX_MSG_SET_MAX_FRS
#define NIC_MBOX_MSG_CPI_CFG
#define NIC_MBOX_MSG_RSS_SIZE
#define NIC_MBOX_MSG_RSS_CFG
#define NIC_MBOX_MSG_RSS_CFG_CONT
#define NIC_MBOX_MSG_RQ_BP_CFG
#define NIC_MBOX_MSG_RQ_SW_SYNC
#define NIC_MBOX_MSG_BGX_STATS
#define NIC_MBOX_MSG_BGX_LINK_CHANGE
#define NIC_MBOX_MSG_ALLOC_SQS
#define NIC_MBOX_MSG_NICVF_PTR
#define NIC_MBOX_MSG_PNICVF_PTR
#define NIC_MBOX_MSG_SNICVF_PTR
#define NIC_MBOX_MSG_LOOPBACK
#define NIC_MBOX_MSG_RESET_STAT_COUNTER
#define NIC_MBOX_MSG_PFC
#define NIC_MBOX_MSG_PTP_CFG
#define NIC_MBOX_MSG_CFG_DONE
#define NIC_MBOX_MSG_SHUTDOWN
#define NIC_MBOX_MSG_RESET_XCAST
#define NIC_MBOX_MSG_ADD_MCAST
#define NIC_MBOX_MSG_SET_XCAST

struct nic_cfg_msg {};

/* Qset configuration */
struct qs_cfg_msg {};

/* Receive queue configuration */
struct rq_cfg_msg {};

/* Send queue configuration */
struct sq_cfg_msg {};

/* Set VF's MAC address */
struct set_mac_msg {};

/* Set Maximum frame size */
struct set_frs_msg {};

/* Set CPI algorithm type */
struct cpi_cfg_msg {};

/* Get RSS table size */
struct rss_sz_msg {};

/* Set RSS configuration */
struct rss_cfg_msg {};

struct bgx_stats_msg {};

/* Physical interface link status */
struct bgx_link_status {};

/* Get Extra Qset IDs */
struct sqs_alloc {};

struct nicvf_ptr {};

/* Set interface in loopback mode */
struct set_loopback {};

/* Reset statistics counters */
struct reset_stat_cfg {};

struct pfc {};

struct set_ptp {};

struct xcast {};

/* 128 bit shared memory between PF and each VF */
nic_mbx;

#define NIC_NODE_ID_MASK
#define NIC_NODE_ID_SHIFT

static inline int nic_get_node_id(struct pci_dev *pdev)
{}

static inline bool pass1_silicon(struct pci_dev *pdev)
{}

static inline bool pass2_silicon(struct pci_dev *pdev)
{}

int nicvf_set_real_num_queues(struct net_device *netdev,
			      int tx_queues, int rx_queues);
int nicvf_open(struct net_device *netdev);
int nicvf_stop(struct net_device *netdev);
int nicvf_send_msg_to_pf(struct nicvf *vf, union nic_mbx *mbx);
void nicvf_config_rss(struct nicvf *nic);
void nicvf_set_rss_key(struct nicvf *nic);
void nicvf_set_ethtool_ops(struct net_device *netdev);
void nicvf_update_stats(struct nicvf *nic);
void nicvf_update_lmac_stats(struct nicvf *nic);

#endif /* NIC_H */