xref: /linux/drivers/net/ethernet/pensando/ionic/ionic.h (revision a095e4775b7c86a26d111b66793ff91bff6e77ce)
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 
21fbfb8031SShannon Nelson #define DEVCMD_TIMEOUT  10
22*a095e477SShannon 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);
571a371ea1SShannon Nelson 	struct work_struct nb_work;
581a371ea1SShannon Nelson 	struct notifier_block nb;
59fbb39807SShannon Nelson 	struct rw_semaphore vf_op_lock;	/* lock for VF operations */
60fbb39807SShannon Nelson 	struct ionic_vf *vfs;
61fbb39807SShannon Nelson 	int num_vfs;
62089406bcSShannon Nelson 	struct timer_list watchdog_timer;
63089406bcSShannon Nelson 	int watchdog_period;
64df69ba43SShannon Nelson };
65df69ba43SShannon Nelson 
66938962d5SShannon Nelson struct ionic_admin_ctx {
67938962d5SShannon Nelson 	struct completion work;
68938962d5SShannon Nelson 	union ionic_adminq_cmd cmd;
69938962d5SShannon Nelson 	union ionic_adminq_comp comp;
70938962d5SShannon Nelson };
71938962d5SShannon Nelson 
724f1704faSShannon Nelson int ionic_adminq_post(struct ionic_lif *lif, struct ionic_admin_ctx *ctx);
734f1704faSShannon Nelson int ionic_adminq_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx, int err);
74938962d5SShannon Nelson int ionic_adminq_post_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx);
75fbfb8031SShannon Nelson int ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_wait);
76fbfb8031SShannon Nelson int ionic_set_dma_mask(struct ionic *ionic);
77fbfb8031SShannon Nelson int ionic_setup(struct ionic *ionic);
78fbfb8031SShannon Nelson 
79fbfb8031SShannon Nelson int ionic_identify(struct ionic *ionic);
80fbfb8031SShannon Nelson int ionic_init(struct ionic *ionic);
81fbfb8031SShannon Nelson int ionic_reset(struct ionic *ionic);
82fbfb8031SShannon Nelson 
8304436595SShannon Nelson int ionic_port_identify(struct ionic *ionic);
8404436595SShannon Nelson int ionic_port_init(struct ionic *ionic);
8504436595SShannon Nelson int ionic_port_reset(struct ionic *ionic);
8604436595SShannon Nelson 
87df69ba43SShannon Nelson #endif /* _IONIC_H_ */
88