From 745740617829dd41174add1ec5ed9231c036af5c Mon Sep 17 00:00:00 2001 From: Madhu Chittim Date: Fri, 1 Aug 2025 11:53:24 -0700 Subject: [PATCH 1/2] idpf: add IDPF PCI class ID support Current IDPF supports only the MEV device IDs. MMG has new set of device IDs and same might be the case for the future devices. Instead of adding new device IDs every time, make use of the IDPF PCI class ID to differentiate between PF and VF. Write and read the VF_ARQBAL register to find if the current device is a PF or a VF. Change-type: Other Signed-off-by: Madhu Chittim --- idpf/src/idpf_main.c | 150 +++++++++++++++++++++++++++++++++---------- 1 file changed, 116 insertions(+), 34 deletions(-) diff --git a/idpf/src/idpf_main.c b/idpf/src/idpf_main.c index df574c7..a7c8f4b 100644 --- a/idpf/src/idpf_main.c +++ b/idpf/src/idpf_main.c @@ -4,9 +4,16 @@ #include "kcompat.h" #include #include "idpf.h" +#include "idpf_lan_vf_regs.h" #include "idpf_virtchnl.h" #define DRV_SUMMARY "Intel(R) Infrastructure Data Path Function Linux Driver" + +#define IDPF_NETWORK_ETHERNET_PROGIF 0x01 +#define IDPF_CLASS_NETWORK_ETHERNET_PROGIF \ + (PCI_CLASS_NETWORK_ETHERNET << 8 | IDPF_NETWORK_ETHERNET_PROGIF) +#define IDPF_VF_TEST_VAL 0xfeed0000u + MODULE_VERSION(IDPF_DRV_VER); static const char idpf_driver_string[] = DRV_SUMMARY; static const char idpf_copyright[] = "Copyright (C) 2019-2025 Intel Corporation"; @@ -276,6 +283,105 @@ static int idpf_cfg_hw(struct idpf_adapter *adapter) static struct lock_class_key idpf_pf_vport_init_lock_key; static struct lock_class_key idpf_pf_work_lock_key; +/** + * idpf_get_device_type - Helper to find if it is a VF or PF device + * @pdev: PCI device information struct + * + * Return: PF/VF or -%errno on failure. + */ +static int idpf_get_device_type(struct pci_dev *pdev) +{ + void __iomem *addr; + int ret; + + addr = ioremap(pci_resource_start(pdev, 0) + VF_ARQBAL, 4); + if (!addr) { + pci_err(pdev, "Failed to allocate BAR0 mbx region\n"); + return -EIO; + } + + writel(IDPF_VF_TEST_VAL, addr); + if (readl(addr) == IDPF_VF_TEST_VAL) + ret = IDPF_DEV_ID_VF; + else + ret = IDPF_DEV_ID_PF; + + iounmap(addr); + + return ret; +} + +/** + * idpf_dev_init - Initialize device specific parameters + * @adapter: adapter to initialize + * @ent: entry in idpf_pci_tbl + * + * Return: %0 on success, -%errno on failure. + */ +static int idpf_dev_init(struct idpf_adapter *adapter, + const struct pci_device_id *ent) +{ + int ret; + + switch (ent->device) { + case IDPF_DEV_ID_VF_SIOV: + idpf_vf_dev_ops_init(adapter); + return 0; + case IDPF_DEV_ID_PF_SIMICS: + idpf_dev_ops_init(adapter); + lockdep_set_class(&adapter->vport_init_lock, + &idpf_pf_vport_init_lock_key); + lockdep_init_map(&adapter->vc_event_task.work.lockdep_map, + "idpf-PF-simics-vc-work", &idpf_pf_work_lock_key, 0); + return 0; + case IDPF_DEV_ID_VF_SIMICS: + idpf_vf_dev_ops_init(adapter); + return 0; + default: + break; + } + + if (ent->class == IDPF_CLASS_NETWORK_ETHERNET_PROGIF) { + ret = idpf_get_device_type(adapter->pdev); + switch (ret) { + case IDPF_DEV_ID_VF: + idpf_vf_dev_ops_init(adapter); + adapter->crc_enable = true; + break; + case IDPF_DEV_ID_PF: + idpf_dev_ops_init(adapter); + lockdep_set_class(&adapter->vport_init_lock, + &idpf_pf_vport_init_lock_key); + lockdep_init_map(&adapter->vc_event_task.work.lockdep_map, + "idpf-PF-vc-work", + &idpf_pf_work_lock_key, 0); + break; + default: + return ret; + } + + return 0; + } + + switch (ent->device) { + case IDPF_DEV_ID_PF: + idpf_dev_ops_init(adapter); + lockdep_set_class(&adapter->vport_init_lock, + &idpf_pf_vport_init_lock_key); + lockdep_init_map(&adapter->vc_event_task.work.lockdep_map, + "idpf-PF-vc-work", &idpf_pf_work_lock_key, 0); + break; + case IDPF_DEV_ID_VF: + idpf_vf_dev_ops_init(adapter); + adapter->crc_enable = true; + break; + default: + return -ENODEV; + } + + return 0; +} + /** * idpf_probe - Device initialization routine * @pdev: PCI device information struct @@ -337,38 +443,6 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) INIT_DELAYED_WORK(&adapter->stats_task, idpf_statistics_task); INIT_DELAYED_WORK(&adapter->vc_event_task, idpf_vc_event_task); - switch (ent->device) { - case IDPF_DEV_ID_PF: - idpf_dev_ops_init(adapter); - lockdep_set_class(&adapter->vport_init_lock, - &idpf_pf_vport_init_lock_key); - lockdep_init_map(&adapter->vc_event_task.work.lockdep_map, - "idpf-PF-vc-work", &idpf_pf_work_lock_key, 0); - break; - case IDPF_DEV_ID_VF: - idpf_vf_dev_ops_init(adapter); - adapter->crc_enable = true; - break; - case IDPF_DEV_ID_VF_SIOV: - idpf_vf_dev_ops_init(adapter); - break; - case IDPF_DEV_ID_PF_SIMICS: - idpf_dev_ops_init(adapter); - lockdep_set_class(&adapter->vport_init_lock, - &idpf_pf_vport_init_lock_key); - lockdep_init_map(&adapter->vc_event_task.work.lockdep_map, - "idpf-PF-simics-vc-work", &idpf_pf_work_lock_key, 0); - break; - case IDPF_DEV_ID_VF_SIMICS: - idpf_vf_dev_ops_init(adapter); - break; - default: - err = -ENODEV; - dev_err(&pdev->dev, "Unexpected dev ID 0x%x in idpf probe\n", - ent->device); - goto err_free; - } - if (!adapter->drv_name) { dev_err(dev, "Invalid configuration, no drv_name given\n"); err = -EINVAL; @@ -487,11 +561,18 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) /* setup msglvl */ adapter->msg_enable = netif_msg_init(-1, IDPF_AVAIL_NETIF_M); + err = idpf_dev_init(adapter, ent); + if (err) { + dev_err(&pdev->dev, "Unexpected dev ID 0x%x in idpf probe\n", + ent->device); + goto destroy_vc_event_wq; + } + err = idpf_cfg_hw(adapter); if (err) { dev_err(dev, "Failed to configure HW structure for adapter: %d\n", err); - goto err_cfg_hw; + goto destroy_vc_event_wq; } #if IS_ENABLED(CONFIG_VFIO_MDEV) && defined(HAVE_PASID_SUPPORT) @@ -510,7 +591,7 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) #endif /* DEVLINK_ENABLED */ return 0; -err_cfg_hw: +destroy_vc_event_wq: destroy_workqueue(adapter->vc_event_wq); err_vc_event_wq_alloc: if (IS_SILICON_DEVICE(adapter->hw.subsystem_device_id)) @@ -785,6 +866,7 @@ static const struct pci_device_id idpf_pci_tbl[] = { { PCI_VDEVICE(INTEL, IDPF_DEV_ID_VF_SIOV) }, { PCI_VDEVICE(INTEL, IDPF_DEV_ID_PF_SIMICS) }, { PCI_VDEVICE(INTEL, IDPF_DEV_ID_VF_SIMICS) }, + { PCI_DEVICE_CLASS(IDPF_CLASS_NETWORK_ETHERNET_PROGIF, ~0)}, { /* Sentinel */ } }; MODULE_DEVICE_TABLE(pci, idpf_pci_tbl); From 4b68693570a396ff2da12ffe315c1b029ef94f32 Mon Sep 17 00:00:00 2001 From: Madhu Chittim Date: Tue, 13 Jan 2026 09:53:13 -0800 Subject: [PATCH 2/2] idpf: bump driver version to 1.0.2 Bump version for MEV 2.9 release with device id changes Change-type: Other Signed-off-by: Madhu Chittim --- Makefile | 2 +- idpf.spec | 2 +- idpf/src/idpf.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 502ccd2..8d8e0fc 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ # Copyright (C) 2021 Intel Corporation TARGETS := idpf auxiliary -VERSION := 1.0.1 +VERSION := 1.0.2 # Shortcut version target ifneq ($(filter version,${MAKECMDGOALS}),) diff --git a/idpf.spec b/idpf.spec index cb5dcc6..16826d0 100644 --- a/idpf.spec +++ b/idpf.spec @@ -1,6 +1,6 @@ Name: idpf Summary: Infrastructure Data Path Function Linux Driver -Version: 1.0.1 +Version: 1.0.2 Release: 1 Source: %{name}-%{version}.tar.gz Vendor: Intel Corporation diff --git a/idpf/src/idpf.h b/idpf/src/idpf.h index f6e3d4c..e0e2eba 100644 --- a/idpf/src/idpf.h +++ b/idpf/src/idpf.h @@ -55,7 +55,7 @@ struct idpf_rss_data; #endif /* CONFIG_IOMMU_BYPASS */ #define IDPF_DRV_NAME "idpf" -#define IDPF_DRV_VER "1.0.1" +#define IDPF_DRV_VER "1.0.2" #define IDPF_M(m, s) ((m) << (s))