From nobody Wed Dec 17 10:50:36 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7FF771428E7; Fri, 9 May 2025 13:43:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746798237; cv=none; b=o2ifl4F5DfkZhwy26zbZFbZ8KIVzmiZPkFqETK1YDENQrir3bg5AUBFespHNSqQuUr5A0bcP2RjFWxii+rK51Zuxgn/PpZ5g9nXaiduQ7i2kkBeuWVUscZae+KnynSCCNiOMGEVUcadDfzyj9MyY/+YBZjAlgDkv8BsEqnyOc40= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746798237; c=relaxed/simple; bh=21asOJpwnzBZMsQrjuZZJGw16XdglQvvwCOfz0cesG8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YOTe1gedCMz4KkKB0vbKOHP+jKQDckbmdutp1KQ6f14wR+9Npq0+yuixpD9wSjqlqnwQQNz6+jrpkWxY3pgwewm+T9uAhzpksfF18+DPvNAAEaatW8GxtMunmRlDKKnERtS6t5aGa2MDFqRmBH770/VDwn0ckINO3wta84pX0ts= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=K9PgDnSA; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="K9PgDnSA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1746798235; x=1778334235; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=21asOJpwnzBZMsQrjuZZJGw16XdglQvvwCOfz0cesG8=; b=K9PgDnSAXFL/O/2WH7KhOC5uOiAaOyMIYhBOBn0pWXZpgcc3C/moiCcb Gebh+GipwBMfTHgr1Vy2Y/Nmu+OC7nFGAeqA9DDo++C4ren8//3efrqUE VYnZfG0UJpLe1iPbzJAUW31pVoLPNOJzU83bcG3s3v0jiy5z1oVDkPwzw bOikKcBe4gmeOlylEeo8oRpOnsXQ11x5VtFEPf/kCZ6ovpDnxXq1jYe6a dOp2h9/0Y1wGjRKK4OR4RCs3yJIxQFaMEffrA82I43VaiuJBWU6pTPAQW VCuxUti4QH7CC0SGoU91uGUh20ybuDhb53gJrpeFCw4cG83238g1yc9hf w==; X-CSE-ConnectionGUID: JOb4AyLJQcW/JTgnx/EyJQ== X-CSE-MsgGUID: GegW+kLLR0WW3pXT585eAQ== X-IronPort-AV: E=McAfee;i="6700,10204,11427"; a="48532959" X-IronPort-AV: E=Sophos;i="6.15,275,1739865600"; d="scan'208";a="48532959" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2025 06:43:54 -0700 X-CSE-ConnectionGUID: jvnej3wQRPGXV3Q8E/NMDw== X-CSE-MsgGUID: f9aT0SLBRT+ymFuXUuTYlA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,275,1739865600"; d="scan'208";a="136323284" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by orviesa009.jf.intel.com with ESMTP; 09 May 2025 06:43:48 -0700 Received: from mglak.igk.intel.com (mglak.igk.intel.com [10.237.112.146]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 1A29933BCC; Fri, 9 May 2025 14:43:46 +0100 (IST) From: Larysa Zaremba To: intel-wired-lan@lists.osuosl.org, Tony Nguyen Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Jonathan Corbet , Przemek Kitszel , Jiri Pirko , Tatyana Nikolova , Andrew Lunn , Alexander Lobakin , Michael Ellerman , Maciej Fijalkowski , Lee Trager , Madhavan Srinivasan , Larysa Zaremba , Sridhar Samudrala , Jacob Keller , Michal Swiatkowski , Mateusz Polchlopek , Ahmed Zaki , netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, "Karlsson, Magnus" , Emil Tantilov , Madhu Chittim , Josh Hay , Milena Olech , pavan.kumar.linga@intel.com, "Singhai, Anjali" Subject: [PATCH iwl-next v3 12/15] ixd: add basic driver framework for Intel(R) Control Plane Function Date: Fri, 9 May 2025 15:43:09 +0200 Message-ID: <20250509134319.66631-13-larysa.zaremba@intel.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20250509134319.66631-1-larysa.zaremba@intel.com> References: <20250509134319.66631-1-larysa.zaremba@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add module register and probe functionality. Add the required support to register IXD PCI driver, as well as probe and remove call backs. Enable the PCI device and request the kernel to reserve the memory resources that will be used by the driver. Finally map the BAR0 address space. For now, use devm_alloc() to allocate adapter, as it requires the least amount of code. In a later commit, it will be replaced with a devlink alternative. Co-developed-by: Amritha Nambiar Signed-off-by: Amritha Nambiar Reviewed-by: Maciej Fijalkowski Signed-off-by: Larysa Zaremba --- .../device_drivers/ethernet/index.rst | 1 + .../device_drivers/ethernet/intel/ixd.rst | 39 ++++++ drivers/net/ethernet/intel/Kconfig | 2 + drivers/net/ethernet/intel/Makefile | 1 + drivers/net/ethernet/intel/ixd/Kconfig | 13 ++ drivers/net/ethernet/intel/ixd/Makefile | 8 ++ drivers/net/ethernet/intel/ixd/ixd.h | 28 ++++ drivers/net/ethernet/intel/ixd/ixd_lan_regs.h | 28 ++++ drivers/net/ethernet/intel/ixd/ixd_main.c | 122 ++++++++++++++++++ 9 files changed, 242 insertions(+) create mode 100644 Documentation/networking/device_drivers/ethernet/intel/= ixd.rst create mode 100644 drivers/net/ethernet/intel/ixd/Kconfig create mode 100644 drivers/net/ethernet/intel/ixd/Makefile create mode 100644 drivers/net/ethernet/intel/ixd/ixd.h create mode 100644 drivers/net/ethernet/intel/ixd/ixd_lan_regs.h create mode 100644 drivers/net/ethernet/intel/ixd/ixd_main.c diff --git a/Documentation/networking/device_drivers/ethernet/index.rst b/D= ocumentation/networking/device_drivers/ethernet/index.rst index f9ed93c1da35..62c30e866a90 100644 --- a/Documentation/networking/device_drivers/ethernet/index.rst +++ b/Documentation/networking/device_drivers/ethernet/index.rst @@ -37,6 +37,7 @@ Contents: intel/igbvf intel/ixgbe intel/ixgbevf + intel/ixd intel/i40e intel/iavf intel/ice diff --git a/Documentation/networking/device_drivers/ethernet/intel/ixd.rst= b/Documentation/networking/device_drivers/ethernet/intel/ixd.rst new file mode 100644 index 000000000000..1387626e5d20 --- /dev/null +++ b/Documentation/networking/device_drivers/ethernet/intel/ixd.rst @@ -0,0 +1,39 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +iXD Linux* Base Driver for the Intel(R) Control Plane Function +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Intel iXD Linux driver. +Copyright(C) 2025 Intel Corporation. + +.. contents:: + +For questions related to hardware requirements, refer to the documentation +supplied with your Intel adapter. All hardware requirements listed apply t= o use +with Linux. + + +Identifying Your Adapter +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +For information on how to identify your adapter, and for the latest Intel +network drivers, refer to the Intel Support website: +http://www.intel.com/support + + +Support +=3D=3D=3D=3D=3D=3D=3D +For general information, go to the Intel support website at: +http://www.intel.com/support/ + +If an issue is identified with the released source code on a supported ker= nel +with a supported adapter, email the specific information related to the is= sue +to intel-wired-lan@lists.osuosl.org. + + +Trademarks +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Intel is a trademark or registered trademark of Intel Corporation or its +subsidiaries in the United States and/or other countries. + +* Other names and brands may be claimed as the property of others. diff --git a/drivers/net/ethernet/intel/Kconfig b/drivers/net/ethernet/inte= l/Kconfig index b05cc0d7a15d..4fd6d0ea1553 100644 --- a/drivers/net/ethernet/intel/Kconfig +++ b/drivers/net/ethernet/intel/Kconfig @@ -395,4 +395,6 @@ config IGC_LEDS =20 source "drivers/net/ethernet/intel/idpf/Kconfig" =20 +source "drivers/net/ethernet/intel/ixd/Kconfig" + endif # NET_VENDOR_INTEL diff --git a/drivers/net/ethernet/intel/Makefile b/drivers/net/ethernet/int= el/Makefile index 04c844ef4964..8de2222a0333 100644 --- a/drivers/net/ethernet/intel/Makefile +++ b/drivers/net/ethernet/intel/Makefile @@ -19,3 +19,4 @@ obj-$(CONFIG_IAVF) +=3D iavf/ obj-$(CONFIG_FM10K) +=3D fm10k/ obj-$(CONFIG_ICE) +=3D ice/ obj-$(CONFIG_IDPF) +=3D idpf/ +obj-$(CONFIG_IXD) +=3D ixd/ diff --git a/drivers/net/ethernet/intel/ixd/Kconfig b/drivers/net/ethernet/= intel/ixd/Kconfig new file mode 100644 index 000000000000..f5594efe292c --- /dev/null +++ b/drivers/net/ethernet/intel/ixd/Kconfig @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (C) 2025 Intel Corporation + +config IXD + tristate "Intel(R) Control Plane Function Support" + depends on PCI_MSI + select LIBETH + select LIBIE_PCI + help + This driver supports Intel(R) Control Plane PCI Function + of Intel E2100 and later IPUs and FNICs. + It facilitates a centralized control over multiple IDPF PFs/VFs/SFs + exposed by the same card. diff --git a/drivers/net/ethernet/intel/ixd/Makefile b/drivers/net/ethernet= /intel/ixd/Makefile new file mode 100644 index 000000000000..3849bc240600 --- /dev/null +++ b/drivers/net/ethernet/intel/ixd/Makefile @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (C) 2025 Intel Corporation + +# Intel(R) Control Plane Function Linux Driver + +obj-$(CONFIG_IXD) +=3D ixd.o + +ixd-y :=3D ixd_main.o diff --git a/drivers/net/ethernet/intel/ixd/ixd.h b/drivers/net/ethernet/in= tel/ixd/ixd.h new file mode 100644 index 000000000000..d813c27941a5 --- /dev/null +++ b/drivers/net/ethernet/intel/ixd/ixd.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright (C) 2025 Intel Corporation */ + +#ifndef _IXD_H_ +#define _IXD_H_ + +#include + +/** + * struct ixd_adapter - Data structure representing a CPF + * @hw: Device access data + */ +struct ixd_adapter { + struct libie_mmio_info hw; +}; + +/** + * ixd_to_dev - Get the corresponding device struct from an adapter + * @adapter: PCI device driver-specific private data + * + * Return: struct device corresponding to the given adapter + */ +static inline struct device *ixd_to_dev(struct ixd_adapter *adapter) +{ + return &adapter->hw.pdev->dev; +} + +#endif /* _IXD_H_ */ diff --git a/drivers/net/ethernet/intel/ixd/ixd_lan_regs.h b/drivers/net/et= hernet/intel/ixd/ixd_lan_regs.h new file mode 100644 index 000000000000..a991eaa8a2aa --- /dev/null +++ b/drivers/net/ethernet/intel/ixd/ixd_lan_regs.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright (C) 2025 Intel Corporation */ + +#ifndef _IXD_LAN_REGS_H_ +#define _IXD_LAN_REGS_H_ + +/* Control Plane Function PCI ID */ +#define IXD_DEV_ID_CPF 0x1453 + +/* Control Queue (Mailbox) */ +#define PF_FW_MBX_REG_LEN 4096 +#define PF_FW_MBX 0x08400000 + +/* Reset registers */ +#define PFGEN_RTRIG_REG_LEN 2048 +#define PFGEN_RTRIG 0x08407000 /* Device resets */ + +/** + * struct ixd_bar_region - BAR region description + * @offset: BAR region offset + * @size: BAR region size + */ +struct ixd_bar_region { + resource_size_t offset; + resource_size_t size; +}; + +#endif /* _IXD_LAN_REGS_H_ */ diff --git a/drivers/net/ethernet/intel/ixd/ixd_main.c b/drivers/net/ethern= et/intel/ixd/ixd_main.c new file mode 100644 index 000000000000..5b8b8258fec8 --- /dev/null +++ b/drivers/net/ethernet/intel/ixd/ixd_main.c @@ -0,0 +1,122 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Copyright (C) 2025 Intel Corporation */ + +#include "ixd.h" +#include "ixd_lan_regs.h" + +MODULE_DESCRIPTION("Intel(R) Control Plane Function Device Driver"); +MODULE_IMPORT_NS("LIBIE_PCI"); +MODULE_LICENSE("GPL"); + +/** + * ixd_remove - remove a CPF PCI device + * @pdev: PCI device being removed + */ +static void ixd_remove(struct pci_dev *pdev) +{ + struct ixd_adapter *adapter =3D pci_get_drvdata(pdev); + + libie_pci_unmap_all_mmio_regions(&adapter->hw); + libie_pci_deinit_dev(pdev); +} + +/** + * ixd_shutdown - shut down a CPF PCI device + * @pdev: PCI device being shut down + */ +static void ixd_shutdown(struct pci_dev *pdev) +{ + ixd_remove(pdev); + + if (system_state =3D=3D SYSTEM_POWER_OFF) + pci_set_power_state(pdev, PCI_D3hot); +} + +/** + * ixd_iomap_regions - iomap PCI BARs + * @adapter: adapter to map memory regions for + * + * Returns: %0 on success, negative on failure + */ +static int ixd_iomap_regions(struct ixd_adapter *adapter) +{ + const struct ixd_bar_region regions[] =3D { + { + .offset =3D PFGEN_RTRIG, + .size =3D PFGEN_RTRIG_REG_LEN, + }, + { + .offset =3D PF_FW_MBX, + .size =3D PF_FW_MBX_REG_LEN, + }, + }; + + for (int i =3D 0; i < ARRAY_SIZE(regions); i++) { + struct libie_mmio_info *mmio_info =3D &adapter->hw; + bool map_ok; + + map_ok =3D libie_pci_map_mmio_region(mmio_info, + regions[i].offset, + regions[i].size); + if (!map_ok) { + dev_err(ixd_to_dev(adapter), + "Failed to map PCI device MMIO region\n"); + + libie_pci_unmap_all_mmio_regions(mmio_info); + return -EIO; + } + } + + return 0; +} + +/** + * ixd_probe - probe a CPF PCI device + * @pdev: corresponding PCI device + * @ent: entry in ixd_pci_tbl + * + * Returns: %0 on success, negative errno code on failure + */ +static int ixd_probe(struct pci_dev *pdev, const struct pci_device_id *ent) +{ + struct ixd_adapter *adapter; + int err; + + adapter =3D devm_kzalloc(&pdev->dev, sizeof(*adapter), GFP_KERNEL); + if (!adapter) + return -ENOMEM; + adapter->hw.pdev =3D pdev; + INIT_LIST_HEAD(&adapter->hw.mmio_list); + + err =3D libie_pci_init_dev(pdev); + if (err) + return err; + + pci_set_drvdata(pdev, adapter); + + err =3D ixd_iomap_regions(adapter); + if (err) + goto deinit_dev; + + return 0; + +deinit_dev: + libie_pci_deinit_dev(pdev); + + return err; +} + +static const struct pci_device_id ixd_pci_tbl[] =3D { + { PCI_VDEVICE(INTEL, IXD_DEV_ID_CPF) }, + { } +}; +MODULE_DEVICE_TABLE(pci, ixd_pci_tbl); + +static struct pci_driver ixd_driver =3D { + .name =3D KBUILD_MODNAME, + .id_table =3D ixd_pci_tbl, + .probe =3D ixd_probe, + .remove =3D ixd_remove, + .shutdown =3D ixd_shutdown, +}; +module_pci_driver(ixd_driver); --=20 2.47.0