1df69ba43SShannon Nelson /* SPDX-License-Identifier: GPL-2.0 */ 2df69ba43SShannon Nelson /* Copyright(c) 2017 - 2019 Pensando Systems, Inc */ 3df69ba43SShannon Nelson 4df69ba43SShannon Nelson #ifndef _IONIC_H_ 5df69ba43SShannon Nelson #define _IONIC_H_ 6df69ba43SShannon Nelson 76461b446SShannon Nelson struct ionic_lif; 86461b446SShannon Nelson 9fbfb8031SShannon Nelson #include "ionic_if.h" 10fbfb8031SShannon Nelson #include "ionic_dev.h" 11df69ba43SShannon Nelson #include "ionic_devlink.h" 12df69ba43SShannon Nelson 13df69ba43SShannon Nelson #define IONIC_DRV_NAME "ionic" 14df69ba43SShannon Nelson #define IONIC_DRV_DESCRIPTION "Pensando Ethernet NIC Driver" 15df69ba43SShannon Nelson 16df69ba43SShannon Nelson #define PCI_VENDOR_ID_PENSANDO 0x1dd8 17df69ba43SShannon Nelson 18df69ba43SShannon Nelson #define PCI_DEVICE_ID_PENSANDO_IONIC_ETH_PF 0x1002 19df69ba43SShannon Nelson #define PCI_DEVICE_ID_PENSANDO_IONIC_ETH_VF 0x1003 20df69ba43SShannon Nelson 21*da0262c2SBrett Creeley #define IONIC_ASIC_TYPE_ELBA 2 22*da0262c2SBrett Creeley 23ec8ee714SShannon Nelson #define DEVCMD_TIMEOUT 5 24a095e477SShannon Nelson #define IONIC_ADMINQ_TIME_SLICE msecs_to_jiffies(100) 25fbfb8031SShannon Nelson 2661db421dSShannon Nelson #define IONIC_PHC_UPDATE_NS 10000000000 /* 10s in nanoseconds */ 2761db421dSShannon Nelson #define NORMAL_PPB 1000000000 /* one billion parts per billion */ 2861db421dSShannon Nelson #define SCALED_PPM (1000000ull << 16) /* 2^16 million parts per 2^16 million */ 2961db421dSShannon Nelson 30fbb39807SShannon Nelson struct ionic_vf { 31fbb39807SShannon Nelson u16 index; 32fbb39807SShannon Nelson u8 macaddr[6]; 33fbb39807SShannon Nelson __le32 maxrate; 34fbb39807SShannon Nelson __le16 vlanid; 35fbb39807SShannon Nelson u8 spoofchk; 36fbb39807SShannon Nelson u8 trusted; 37fbb39807SShannon Nelson u8 linkstate; 38fbb39807SShannon Nelson dma_addr_t stats_pa; 39fbb39807SShannon Nelson struct ionic_lif_stats stats; 40fbb39807SShannon Nelson }; 41fbb39807SShannon Nelson 42df69ba43SShannon Nelson struct ionic { 43df69ba43SShannon Nelson struct pci_dev *pdev; 44df69ba43SShannon Nelson struct device *dev; 45beead698SShannon Nelson struct devlink_port dl_port; 46fbfb8031SShannon Nelson struct ionic_dev idev; 47fbfb8031SShannon Nelson struct mutex dev_cmd_lock; /* lock for dev_cmd operations */ 48fbfb8031SShannon Nelson struct dentry *dentry; 49fbfb8031SShannon Nelson struct ionic_dev_bar bars[IONIC_BARS_MAX]; 50fbfb8031SShannon Nelson unsigned int num_bars; 51fbfb8031SShannon Nelson struct ionic_identity ident; 529e25450dSShannon Nelson struct workqueue_struct *wq; 5330b87ab4SShannon Nelson struct ionic_lif *lif; 541a58e196SShannon Nelson unsigned int nnqs_per_lif; 551a58e196SShannon Nelson unsigned int neqs_per_lif; 561a58e196SShannon Nelson unsigned int ntxqs_per_lif; 571a58e196SShannon Nelson unsigned int nrxqs_per_lif; 581a58e196SShannon Nelson unsigned int nintrs; 596461b446SShannon Nelson DECLARE_BITMAP(intrs, IONIC_INTR_CTRL_REGS_MAX); 60d458d4b4SBrett Creeley cpumask_var_t *affinity_masks; 614ded136cSShannon Nelson struct delayed_work doorbell_check_dwork; 621a371ea1SShannon Nelson struct work_struct nb_work; 631a371ea1SShannon Nelson struct notifier_block nb; 64fbb39807SShannon Nelson struct rw_semaphore vf_op_lock; /* lock for VF operations */ 65fbb39807SShannon Nelson struct ionic_vf *vfs; 66fbb39807SShannon Nelson int num_vfs; 67089406bcSShannon Nelson struct timer_list watchdog_timer; 68089406bcSShannon Nelson int watchdog_period; 69df69ba43SShannon Nelson }; 70df69ba43SShannon Nelson 71938962d5SShannon Nelson struct ionic_admin_ctx { 72938962d5SShannon Nelson struct completion work; 73938962d5SShannon Nelson union ionic_adminq_cmd cmd; 74938962d5SShannon Nelson union ionic_adminq_comp comp; 75938962d5SShannon Nelson }; 76938962d5SShannon Nelson 774f1704faSShannon Nelson int ionic_adminq_post(struct ionic_lif *lif, struct ionic_admin_ctx *ctx); 788c9d956aSShannon Nelson int ionic_adminq_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx, 798c9d956aSShannon Nelson const int err, const bool do_msg); 80938962d5SShannon Nelson int ionic_adminq_post_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx); 818c9d956aSShannon Nelson int ionic_adminq_post_wait_nomsg(struct ionic_lif *lif, struct ionic_admin_ctx *ctx); 828c9d956aSShannon Nelson void ionic_adminq_netdev_err_print(struct ionic_lif *lif, u8 opcode, 838c9d956aSShannon Nelson u8 status, int err); 8465e548f6SShannon Nelson bool ionic_notifyq_service(struct ionic_cq *cq); 8565e548f6SShannon Nelson bool ionic_adminq_service(struct ionic_cq *cq); 868c9d956aSShannon Nelson 87fbfb8031SShannon Nelson int ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_wait); 88b640b552SBrett Creeley int ionic_dev_cmd_wait_nomsg(struct ionic *ionic, unsigned long max_wait); 89b640b552SBrett Creeley void ionic_dev_cmd_dev_err_print(struct ionic *ionic, u8 opcode, u8 status, 90b640b552SBrett Creeley int err); 91fbfb8031SShannon Nelson int ionic_setup(struct ionic *ionic); 92fbfb8031SShannon Nelson 93fbfb8031SShannon Nelson int ionic_identify(struct ionic *ionic); 94fbfb8031SShannon Nelson int ionic_init(struct ionic *ionic); 95fbfb8031SShannon Nelson int ionic_reset(struct ionic *ionic); 96fbfb8031SShannon Nelson 9704436595SShannon Nelson int ionic_port_identify(struct ionic *ionic); 9804436595SShannon Nelson int ionic_port_init(struct ionic *ionic); 9904436595SShannon Nelson int ionic_port_reset(struct ionic *ionic); 10004436595SShannon Nelson 101*da0262c2SBrett Creeley bool ionic_doorbell_wa(struct ionic *ionic); 102*da0262c2SBrett Creeley 103df69ba43SShannon Nelson #endif /* _IONIC_H_ */ 104