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 21ec8ee714SShannon Nelson #define DEVCMD_TIMEOUT 5 22a095e477SShannon Nelson #define IONIC_ADMINQ_TIME_SLICE msecs_to_jiffies(100) 23fbfb8031SShannon Nelson 2461db421dSShannon Nelson #define IONIC_PHC_UPDATE_NS 10000000000 /* 10s in nanoseconds */ 2561db421dSShannon Nelson #define NORMAL_PPB 1000000000 /* one billion parts per billion */ 2661db421dSShannon Nelson #define SCALED_PPM (1000000ull << 16) /* 2^16 million parts per 2^16 million */ 2761db421dSShannon Nelson 28fbb39807SShannon Nelson struct ionic_vf { 29fbb39807SShannon Nelson u16 index; 30fbb39807SShannon Nelson u8 macaddr[6]; 31fbb39807SShannon Nelson __le32 maxrate; 32fbb39807SShannon Nelson __le16 vlanid; 33fbb39807SShannon Nelson u8 spoofchk; 34fbb39807SShannon Nelson u8 trusted; 35fbb39807SShannon Nelson u8 linkstate; 36fbb39807SShannon Nelson dma_addr_t stats_pa; 37fbb39807SShannon Nelson struct ionic_lif_stats stats; 38fbb39807SShannon Nelson }; 39fbb39807SShannon Nelson 40df69ba43SShannon Nelson struct ionic { 41df69ba43SShannon Nelson struct pci_dev *pdev; 42df69ba43SShannon Nelson struct device *dev; 43beead698SShannon Nelson struct devlink_port dl_port; 44fbfb8031SShannon Nelson struct ionic_dev idev; 45fbfb8031SShannon Nelson struct mutex dev_cmd_lock; /* lock for dev_cmd operations */ 46fbfb8031SShannon Nelson struct dentry *dentry; 47fbfb8031SShannon Nelson struct ionic_dev_bar bars[IONIC_BARS_MAX]; 48fbfb8031SShannon Nelson unsigned int num_bars; 49fbfb8031SShannon Nelson struct ionic_identity ident; 5030b87ab4SShannon Nelson struct ionic_lif *lif; 511a58e196SShannon Nelson unsigned int nnqs_per_lif; 521a58e196SShannon Nelson unsigned int neqs_per_lif; 531a58e196SShannon Nelson unsigned int ntxqs_per_lif; 541a58e196SShannon Nelson unsigned int nrxqs_per_lif; 551a58e196SShannon Nelson unsigned int nintrs; 566461b446SShannon Nelson DECLARE_BITMAP(intrs, IONIC_INTR_CTRL_REGS_MAX); 57*d458d4b4SBrett Creeley cpumask_var_t *affinity_masks; 581a371ea1SShannon Nelson struct work_struct nb_work; 591a371ea1SShannon Nelson struct notifier_block nb; 60fbb39807SShannon Nelson struct rw_semaphore vf_op_lock; /* lock for VF operations */ 61fbb39807SShannon Nelson struct ionic_vf *vfs; 62fbb39807SShannon Nelson int num_vfs; 63089406bcSShannon Nelson struct timer_list watchdog_timer; 64089406bcSShannon Nelson int watchdog_period; 65df69ba43SShannon Nelson }; 66df69ba43SShannon Nelson 67938962d5SShannon Nelson struct ionic_admin_ctx { 68938962d5SShannon Nelson struct completion work; 69938962d5SShannon Nelson union ionic_adminq_cmd cmd; 70938962d5SShannon Nelson union ionic_adminq_comp comp; 71938962d5SShannon Nelson }; 72938962d5SShannon Nelson 734f1704faSShannon Nelson int ionic_adminq_post(struct ionic_lif *lif, struct ionic_admin_ctx *ctx); 748c9d956aSShannon Nelson int ionic_adminq_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx, 758c9d956aSShannon Nelson const int err, const bool do_msg); 76938962d5SShannon Nelson int ionic_adminq_post_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx); 778c9d956aSShannon Nelson int ionic_adminq_post_wait_nomsg(struct ionic_lif *lif, struct ionic_admin_ctx *ctx); 788c9d956aSShannon Nelson void ionic_adminq_netdev_err_print(struct ionic_lif *lif, u8 opcode, 798c9d956aSShannon Nelson u8 status, int err); 8065e548f6SShannon Nelson bool ionic_notifyq_service(struct ionic_cq *cq); 8165e548f6SShannon Nelson bool ionic_adminq_service(struct ionic_cq *cq); 828c9d956aSShannon Nelson 83fbfb8031SShannon Nelson int ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_wait); 84b640b552SBrett Creeley int ionic_dev_cmd_wait_nomsg(struct ionic *ionic, unsigned long max_wait); 85b640b552SBrett Creeley void ionic_dev_cmd_dev_err_print(struct ionic *ionic, u8 opcode, u8 status, 86b640b552SBrett Creeley int err); 87fbfb8031SShannon Nelson int ionic_setup(struct ionic *ionic); 88fbfb8031SShannon Nelson 89fbfb8031SShannon Nelson int ionic_identify(struct ionic *ionic); 90fbfb8031SShannon Nelson int ionic_init(struct ionic *ionic); 91fbfb8031SShannon Nelson int ionic_reset(struct ionic *ionic); 92fbfb8031SShannon Nelson 9304436595SShannon Nelson int ionic_port_identify(struct ionic *ionic); 9404436595SShannon Nelson int ionic_port_init(struct ionic *ionic); 9504436595SShannon Nelson int ionic_port_reset(struct ionic *ionic); 9604436595SShannon Nelson 97df69ba43SShannon Nelson #endif /* _IONIC_H_ */ 98