xref: /linux/drivers/net/ethernet/pensando/ionic/ionic.h (revision 61db421da31b6fb3767df46c9963e87f2a1d2418)
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
22fbfb8031SShannon Nelson 
23*61db421dSShannon Nelson #define IONIC_PHC_UPDATE_NS	10000000000	    /* 10s in nanoseconds */
24*61db421dSShannon Nelson #define NORMAL_PPB		1000000000	    /* one billion parts per billion */
25*61db421dSShannon Nelson #define SCALED_PPM		(1000000ull << 16)  /* 2^16 million parts per 2^16 million */
26*61db421dSShannon Nelson 
27fbb39807SShannon Nelson struct ionic_vf {
28fbb39807SShannon Nelson 	u16	 index;
29fbb39807SShannon Nelson 	u8	 macaddr[6];
30fbb39807SShannon Nelson 	__le32	 maxrate;
31fbb39807SShannon Nelson 	__le16	 vlanid;
32fbb39807SShannon Nelson 	u8	 spoofchk;
33fbb39807SShannon Nelson 	u8	 trusted;
34fbb39807SShannon Nelson 	u8	 linkstate;
35fbb39807SShannon Nelson 	dma_addr_t       stats_pa;
36fbb39807SShannon Nelson 	struct ionic_lif_stats stats;
37fbb39807SShannon Nelson };
38fbb39807SShannon Nelson 
39df69ba43SShannon Nelson struct ionic {
40df69ba43SShannon Nelson 	struct pci_dev *pdev;
41df69ba43SShannon Nelson 	struct device *dev;
42beead698SShannon Nelson 	struct devlink_port dl_port;
43fbfb8031SShannon Nelson 	struct ionic_dev idev;
44fbfb8031SShannon Nelson 	struct mutex dev_cmd_lock;	/* lock for dev_cmd operations */
45fbfb8031SShannon Nelson 	struct dentry *dentry;
46fbfb8031SShannon Nelson 	struct ionic_dev_bar bars[IONIC_BARS_MAX];
47fbfb8031SShannon Nelson 	unsigned int num_bars;
48fbfb8031SShannon Nelson 	struct ionic_identity ident;
4930b87ab4SShannon Nelson 	struct ionic_lif *lif;
501a58e196SShannon Nelson 	unsigned int nnqs_per_lif;
511a58e196SShannon Nelson 	unsigned int neqs_per_lif;
521a58e196SShannon Nelson 	unsigned int ntxqs_per_lif;
531a58e196SShannon Nelson 	unsigned int nrxqs_per_lif;
541a58e196SShannon Nelson 	unsigned int nintrs;
556461b446SShannon Nelson 	DECLARE_BITMAP(intrs, IONIC_INTR_CTRL_REGS_MAX);
561a371ea1SShannon Nelson 	struct work_struct nb_work;
571a371ea1SShannon Nelson 	struct notifier_block nb;
58fbb39807SShannon Nelson 	struct rw_semaphore vf_op_lock;	/* lock for VF operations */
59fbb39807SShannon Nelson 	struct ionic_vf *vfs;
60fbb39807SShannon Nelson 	int num_vfs;
61089406bcSShannon Nelson 	struct timer_list watchdog_timer;
62089406bcSShannon Nelson 	int watchdog_period;
63df69ba43SShannon Nelson };
64df69ba43SShannon Nelson 
65938962d5SShannon Nelson struct ionic_admin_ctx {
66938962d5SShannon Nelson 	struct completion work;
67938962d5SShannon Nelson 	union ionic_adminq_cmd cmd;
68938962d5SShannon Nelson 	union ionic_adminq_comp comp;
69938962d5SShannon Nelson };
70938962d5SShannon Nelson 
714f1704faSShannon Nelson int ionic_adminq_post(struct ionic_lif *lif, struct ionic_admin_ctx *ctx);
724f1704faSShannon Nelson int ionic_adminq_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx, int err);
73938962d5SShannon Nelson int ionic_adminq_post_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx);
74fbfb8031SShannon Nelson int ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_wait);
75fbfb8031SShannon Nelson int ionic_set_dma_mask(struct ionic *ionic);
76fbfb8031SShannon Nelson int ionic_setup(struct ionic *ionic);
77fbfb8031SShannon Nelson 
78fbfb8031SShannon Nelson int ionic_identify(struct ionic *ionic);
79fbfb8031SShannon Nelson int ionic_init(struct ionic *ionic);
80fbfb8031SShannon Nelson int ionic_reset(struct ionic *ionic);
81fbfb8031SShannon Nelson 
8204436595SShannon Nelson int ionic_port_identify(struct ionic *ionic);
8304436595SShannon Nelson int ionic_port_init(struct ionic *ionic);
8404436595SShannon Nelson int ionic_port_reset(struct ionic *ionic);
8504436595SShannon Nelson 
86df69ba43SShannon Nelson #endif /* _IONIC_H_ */
87