mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-04 20:19:47 +08:00

Use Device Serial Number instead of PCI bus/device/function for
the index of struct ice_adapter.
Functions on the same physical device should point to the very same
ice_adapter instance, but with two PFs, when at least one of them is
PCI-e passed-through to a VM, it is no longer the case - PFs will get
seemingly random PCI BDF values, and thus indices, what finally leds to
each of them being on their own instance of ice_adapter. That causes them
to don't attempt any synchronization of the PTP HW clock usage, or any
other future resources.
DSN works nicely in place of the index, as it is "immutable" in terms of
virtualization.
Fixes: 0e2bddf9e5
("ice: add ice_adapter for shared data across PFs on the same NIC")
Suggested-by: Jacob Keller <jacob.e.keller@intel.com>
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Suggested-by: Jiri Pirko <jiri@resnulli.us>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Tested-by: Rinitha S <sx.rinitha@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Link: https://patch.msgid.link/20250505161939.2083581-1-anthony.l.nguyen@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
51 lines
1.3 KiB
C
51 lines
1.3 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/* SPDX-FileCopyrightText: Copyright Red Hat */
|
|
|
|
#ifndef _ICE_ADAPTER_H_
|
|
#define _ICE_ADAPTER_H_
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/spinlock_types.h>
|
|
#include <linux/refcount_types.h>
|
|
|
|
struct pci_dev;
|
|
struct ice_pf;
|
|
|
|
/**
|
|
* struct ice_port_list - data used to store the list of adapter ports
|
|
*
|
|
* This structure contains data used to maintain a list of adapter ports
|
|
*
|
|
* @ports: list of ports
|
|
* @lock: protect access to the ports list
|
|
*/
|
|
struct ice_port_list {
|
|
struct list_head ports;
|
|
/* To synchronize the ports list operations */
|
|
struct mutex lock;
|
|
};
|
|
|
|
/**
|
|
* struct ice_adapter - PCI adapter resources shared across PFs
|
|
* @ptp_gltsyn_time_lock: Spinlock protecting access to the GLTSYN_TIME
|
|
* register of the PTP clock.
|
|
* @refcount: Reference count. struct ice_pf objects hold the references.
|
|
* @ctrl_pf: Control PF of the adapter
|
|
* @ports: Ports list
|
|
* @device_serial_number: DSN cached for collision detection on 32bit systems
|
|
*/
|
|
struct ice_adapter {
|
|
refcount_t refcount;
|
|
/* For access to the GLTSYN_TIME register */
|
|
spinlock_t ptp_gltsyn_time_lock;
|
|
|
|
struct ice_pf *ctrl_pf;
|
|
struct ice_port_list ports;
|
|
u64 device_serial_number;
|
|
};
|
|
|
|
struct ice_adapter *ice_adapter_get(struct pci_dev *pdev);
|
|
void ice_adapter_put(struct pci_dev *pdev);
|
|
|
|
#endif /* _ICE_ADAPTER_H */
|