xref: /linux/drivers/net/ethernet/intel/ice/ice_adapter.h (revision 7f4f3b14e8079ecde096bd734af10e30d40c27b7)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* SPDX-FileCopyrightText: Copyright Red Hat */
3 
4 #ifndef _ICE_ADAPTER_H_
5 #define _ICE_ADAPTER_H_
6 
7 #include <linux/types.h>
8 #include <linux/spinlock_types.h>
9 #include <linux/refcount_types.h>
10 
11 struct pci_dev;
12 struct ice_pf;
13 
14 /**
15  * struct ice_port_list - data used to store the list of adapter ports
16  *
17  * This structure contains data used to maintain a list of adapter ports
18  *
19  * @ports: list of ports
20  * @lock: protect access to the ports list
21  */
22 struct ice_port_list {
23 	struct list_head ports;
24 	/* To synchronize the ports list operations */
25 	struct mutex lock;
26 };
27 
28 /**
29  * struct ice_adapter - PCI adapter resources shared across PFs
30  * @ptp_gltsyn_time_lock: Spinlock protecting access to the GLTSYN_TIME
31  *                        register of the PTP clock.
32  * @refcount: Reference count. struct ice_pf objects hold the references.
33  * @ctrl_pf: Control PF of the adapter
34  * @ports: Ports list
35  */
36 struct ice_adapter {
37 	refcount_t refcount;
38 	/* For access to the GLTSYN_TIME register */
39 	spinlock_t ptp_gltsyn_time_lock;
40 
41 	struct ice_pf *ctrl_pf;
42 	struct ice_port_list ports;
43 };
44 
45 struct ice_adapter *ice_adapter_get(const struct pci_dev *pdev);
46 void ice_adapter_put(const struct pci_dev *pdev);
47 
48 #endif /* _ICE_ADAPTER_H */
49