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/mutex.h> 9 #include <linux/spinlock_types.h> 10 #include <linux/refcount_types.h> 11 12 #include "ice_type.h" 13 14 struct pci_dev; 15 struct ice_pf; 16 17 /** 18 * struct ice_port_list - data used to store the list of adapter ports 19 * 20 * This structure contains data used to maintain a list of adapter ports 21 * 22 * @ports: list of ports 23 * @lock: protect access to the ports list 24 */ 25 struct ice_port_list { 26 struct list_head ports; 27 /* To synchronize the ports list operations */ 28 struct mutex lock; 29 }; 30 31 /** 32 * struct ice_adapter - PCI adapter resources shared across PFs 33 * @refcount: Reference count. struct ice_pf objects hold the references. 34 * @ptp_gltsyn_time_lock: Spinlock protecting access to the GLTSYN_TIME 35 * register of the PTP clock. 36 * @txq_ctx_lock: Spinlock protecting access to the GLCOMM_QTX_CNTX_CTL register 37 * @cpi_phy_lock: Per-PHY mutex serializing CPI REQ/ACK transactions. 38 * Index 0 = PHY0, index 1 = PHY1. Used on E825C devices. 39 * @ctrl_pf: Control PF of the adapter 40 * @ports: Ports list 41 * @index: 64-bit index cached for collision detection on 32bit systems 42 */ 43 struct ice_adapter { 44 refcount_t refcount; 45 /* For access to the GLTSYN_TIME register */ 46 spinlock_t ptp_gltsyn_time_lock; 47 /* For access to GLCOMM_QTX_CNTX_CTL register */ 48 spinlock_t txq_ctx_lock; 49 /* Serialize CPI REQ/ACK transactions per PHY (E825C only) */ 50 struct mutex cpi_phy_lock[ICE_E825_MAX_PHYS]; 51 52 struct ice_pf *ctrl_pf; 53 struct ice_port_list ports; 54 u64 index; 55 }; 56 57 struct ice_adapter *ice_adapter_get(struct pci_dev *pdev); 58 void ice_adapter_put(struct pci_dev *pdev); 59 60 #endif /* _ICE_ADAPTER_H */ 61