xref: /linux/drivers/net/ethernet/alibaba/eea/eea_pci.h (revision aa8bca4cf20027d5dd59a5de207ecb4720d910c8)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Driver for Alibaba Elastic Ethernet Adapter.
4  *
5  * Copyright (C) 2025 Alibaba Inc.
6  */
7 
8 #ifndef __EEA_PCI_H__
9 #define __EEA_PCI_H__
10 
11 #include <linux/pci.h>
12 
13 #include "eea_net.h"
14 #include "eea_ring.h"
15 
16 enum eea_pci_status {
17 	EEA_PCI_STATUS_NONE,
18 	EEA_PCI_STATUS_ERR,
19 	EEA_PCI_STATUS_READY,
20 	EEA_PCI_STATUS_DONE,
21 };
22 
23 struct eea_irq_blk;
24 
25 struct eea_pci_cap {
26 	__u8 cap_vndr;
27 	__u8 cap_next;
28 	__u8 cap_len;
29 	__u8 cfg_type;
30 };
31 
32 struct eea_pci_reset_reg {
33 	struct eea_pci_cap cap;
34 	__le16 driver;
35 	__le16 device;
36 };
37 
38 struct eea_pci_device;
39 
40 struct eea_device {
41 	struct eea_pci_device *ep_dev;
42 	struct device         *dma_dev;
43 	struct eea_net        *enet;
44 
45 	u64 features;
46 
47 	enum eea_pci_status status;
48 	bool ha_reset_netdev_running;
49 
50 	/* ha lock for the race between ha work and pci remove */
51 	struct mutex ha_lock;
52 
53 	u32 rx_num;
54 	u32 tx_num;
55 	u32 db_blk_size;
56 };
57 
58 const char *eea_pci_name(struct eea_device *edev);
59 int eea_pci_domain_nr(struct eea_device *edev);
60 u16 eea_pci_bdf(struct eea_device *edev);
61 
62 int eea_device_reset(struct eea_device *dev);
63 int eea_pci_set_aq_up(struct eea_device *dev);
64 int eea_pci_active_aq(struct eea_ring *ering, int msix_vec);
65 
66 int eea_pci_request_irq(struct eea_device *edev, struct eea_irq_blk *blk,
67 			irqreturn_t (*callback)(int irq, void *data));
68 void eea_pci_free_irq(struct eea_irq_blk *blk);
69 
70 u64 eea_pci_device_ts(struct eea_device *edev);
71 
72 void __iomem *eea_pci_db_addr(struct eea_device *edev, u32 off);
73 #endif
74