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  * @device_serial_number: DSN cached for collision detection on 32bit systems
36  */
37 struct ice_adapter {
38 	refcount_t refcount;
39 	/* For access to the GLTSYN_TIME register */
40 	spinlock_t ptp_gltsyn_time_lock;
41 
42 	struct ice_pf *ctrl_pf;
43 	struct ice_port_list ports;
44 	u64 device_serial_number;
45 };
46 
47 struct ice_adapter *ice_adapter_get(struct pci_dev *pdev);
48 void ice_adapter_put(struct pci_dev *pdev);
49 
50 #endif /* _ICE_ADAPTER_H */
51