xref: /linux/drivers/net/ethernet/pensando/ionic/ionic.h (revision 26fbb4c8c7c3ee9a4c3b4de555a8587b5a19154e)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2017 - 2019 Pensando Systems, Inc */
3 
4 #ifndef _IONIC_H_
5 #define _IONIC_H_
6 
7 struct ionic_lif;
8 
9 #include "ionic_if.h"
10 #include "ionic_dev.h"
11 #include "ionic_devlink.h"
12 
13 #define IONIC_DRV_NAME		"ionic"
14 #define IONIC_DRV_DESCRIPTION	"Pensando Ethernet NIC Driver"
15 
16 #define PCI_VENDOR_ID_PENSANDO			0x1dd8
17 
18 #define PCI_DEVICE_ID_PENSANDO_IONIC_ETH_PF	0x1002
19 #define PCI_DEVICE_ID_PENSANDO_IONIC_ETH_VF	0x1003
20 
21 #define DEVCMD_TIMEOUT  10
22 
23 struct ionic_vf {
24 	u16	 index;
25 	u8	 macaddr[6];
26 	__le32	 maxrate;
27 	__le16	 vlanid;
28 	u8	 spoofchk;
29 	u8	 trusted;
30 	u8	 linkstate;
31 	dma_addr_t       stats_pa;
32 	struct ionic_lif_stats stats;
33 };
34 
35 struct ionic {
36 	struct pci_dev *pdev;
37 	struct device *dev;
38 	struct devlink_port dl_port;
39 	struct ionic_dev idev;
40 	struct mutex dev_cmd_lock;	/* lock for dev_cmd operations */
41 	struct dentry *dentry;
42 	struct ionic_dev_bar bars[IONIC_BARS_MAX];
43 	unsigned int num_bars;
44 	struct ionic_identity ident;
45 	struct ionic_lif *lif;
46 	unsigned int nnqs_per_lif;
47 	unsigned int neqs_per_lif;
48 	unsigned int ntxqs_per_lif;
49 	unsigned int nrxqs_per_lif;
50 	unsigned int nintrs;
51 	DECLARE_BITMAP(intrs, IONIC_INTR_CTRL_REGS_MAX);
52 	struct work_struct nb_work;
53 	struct notifier_block nb;
54 	struct rw_semaphore vf_op_lock;	/* lock for VF operations */
55 	struct ionic_vf *vfs;
56 	int num_vfs;
57 	struct timer_list watchdog_timer;
58 	int watchdog_period;
59 };
60 
61 struct ionic_admin_ctx {
62 	struct completion work;
63 	union ionic_adminq_cmd cmd;
64 	union ionic_adminq_comp comp;
65 };
66 
67 int ionic_adminq_post_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx);
68 int ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_wait);
69 int ionic_set_dma_mask(struct ionic *ionic);
70 int ionic_setup(struct ionic *ionic);
71 
72 int ionic_identify(struct ionic *ionic);
73 int ionic_init(struct ionic *ionic);
74 int ionic_reset(struct ionic *ionic);
75 
76 int ionic_port_identify(struct ionic *ionic);
77 int ionic_port_init(struct ionic *ionic);
78 int ionic_port_reset(struct ionic *ionic);
79 
80 #endif /* _IONIC_H_ */
81