get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2218411/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2218411,
    "url": "http://patchwork.ozlabs.org/api/patches/2218411/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/linux-pci/patch/20260401073022.215805-3-a-garg7@ti.com/",
    "project": {
        "id": 28,
        "url": "http://patchwork.ozlabs.org/api/projects/28/?format=api",
        "name": "Linux PCI development",
        "link_name": "linux-pci",
        "list_id": "linux-pci.vger.kernel.org",
        "list_email": "linux-pci@vger.kernel.org",
        "web_url": null,
        "scm_url": null,
        "webscm_url": null,
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20260401073022.215805-3-a-garg7@ti.com>",
    "list_archive_url": null,
    "date": "2026-04-01T07:30:20",
    "name": "[v2,2/4] PCI: endpoint: Add DOE mailbox support for endpoint functions",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "29461b9ca6e534a1a44bb8a0a580fb1c596c8ca0",
    "submitter": {
        "id": 92467,
        "url": "http://patchwork.ozlabs.org/api/people/92467/?format=api",
        "name": "Aksh Garg",
        "email": "a-garg7@ti.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/linux-pci/patch/20260401073022.215805-3-a-garg7@ti.com/mbox/",
    "series": [
        {
            "id": 498286,
            "url": "http://patchwork.ozlabs.org/api/series/498286/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/linux-pci/list/?series=498286",
            "date": "2026-04-01T07:30:19",
            "name": "PCI: Add DOE support for endpoint",
            "version": 2,
            "mbox": "http://patchwork.ozlabs.org/series/498286/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2218411/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2218411/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "\n <linux-pci+bounces-51648-incoming=patchwork.ozlabs.org@vger.kernel.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "linux-pci@vger.kernel.org"
        ],
        "Delivered-To": "patchwork-incoming@legolas.ozlabs.org",
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=ti.com header.i=@ti.com header.a=rsa-sha256\n header.s=selector1 header.b=nf8Jj+m4;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c09:e001:a7::12fc:5321; helo=sto.lore.kernel.org;\n envelope-from=linux-pci+bounces-51648-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)",
            "smtp.subspace.kernel.org;\n\tdkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=\"nf8Jj+m4\"",
            "smtp.subspace.kernel.org;\n arc=fail smtp.client-ip=40.107.200.7",
            "smtp.subspace.kernel.org;\n dmarc=pass (p=quarantine dis=none) header.from=ti.com",
            "smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=ti.com"
        ],
        "Received": [
            "from sto.lore.kernel.org (sto.lore.kernel.org\n [IPv6:2600:3c09:e001:a7::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4flxhV1Zvqz1yGH\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 01 Apr 2026 18:39:38 +1100 (AEDT)",
            "from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sto.lore.kernel.org (Postfix) with ESMTP id AC65D306502C\n\tfor <incoming@patchwork.ozlabs.org>; Wed,  1 Apr 2026 07:32:54 +0000 (UTC)",
            "from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 0B9A4399361;\n\tWed,  1 Apr 2026 07:30:54 +0000 (UTC)",
            "from CH5PR02CU005.outbound.protection.outlook.com\n (mail-northcentralusazon11012007.outbound.protection.outlook.com\n [40.107.200.7])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 73313396D2B;\n\tWed,  1 Apr 2026 07:30:51 +0000 (UTC)",
            "from BYAPR03CA0031.namprd03.prod.outlook.com (2603:10b6:a02:a8::44)\n by BY5PR10MB4243.namprd10.prod.outlook.com (2603:10b6:a03:210::23) with\n Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9769.16; Wed, 1 Apr\n 2026 07:30:48 +0000",
            "from SJ5PEPF000001E8.namprd05.prod.outlook.com\n (2603:10b6:a02:a8:cafe::c6) by BYAPR03CA0031.outlook.office365.com\n (2603:10b6:a02:a8::44) with Microsoft SMTP Server (version=TLS1_3,\n cipher=TLS_AES_256_GCM_SHA384) id 15.20.9745.29 via Frontend Transport; Wed,\n 1 Apr 2026 07:30:48 +0000",
            "from flwvzet200.ext.ti.com (198.47.21.194) by\n SJ5PEPF000001E8.mail.protection.outlook.com (10.167.242.196) with Microsoft\n SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n 15.20.9769.17 via Frontend Transport; Wed, 1 Apr 2026 07:30:47 +0000",
            "from DFLE210.ent.ti.com (10.64.6.68) by flwvzet200.ext.ti.com\n (10.248.192.31) with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 1 Apr\n 2026 02:30:38 -0500",
            "from DFLE211.ent.ti.com (10.64.6.69) by DFLE210.ent.ti.com\n (10.64.6.68) with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 1 Apr\n 2026 02:30:38 -0500",
            "from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE211.ent.ti.com\n (10.64.6.69) with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend\n Transport; Wed, 1 Apr 2026 02:30:38 -0500",
            "from a0507033-hp.dhcp.ti.com (a0507033-hp.dhcp.ti.com\n [172.24.231.225])\n\tby lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 6317UN3R3832504;\n\tWed, 1 Apr 2026 02:30:33 -0500"
        ],
        "ARC-Seal": [
            "i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775028653; cv=fail;\n b=CYvWHWksJ1AwkVkVvMYgMVSjFaI6srjE6CYkWUAxm6o7DYmfcrzuZjc1NjbJgvaLlZly+LDpH2qX6l/4NQP9SlLEoOuT5eeR//yjpk1hEbSIaCmQvkWY4s6ckDY7GbBE4LBPPg4oNRzDU6fc74C67K57/1EGAkwq3zVScC0zEz8=",
            "i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;\n b=ar8+4gOY2XR1JDvzBMg6LT8DfJYcEb37r14/SLHsjWDPhzRpkYuE7ssEGoeQFV3KMfliyvRfJBel2IDqUDHnQFNwDF+HiqXHq7Q11PSUc0XkdOeUDV+3X87JTJdZnOxcgvwLFA5y4/2HTmbUQ8m0G8sx19Bwmk59/49SRmAPGSVMe+bfm/ZAlxUbSAX19A9SmyMw4PZveJoXCp//iKqMNvCxWbwyInCb7PfEXzoWbWAUD/QhHB+ufayH3tJ6MYlDtLABS2SOBudRIbPh7SGzn+P+4W4ys5qFe3kCEuNNrdhW1aVIuQXKP3hAr30Mw4Pi1UK7osiC+AkDpvkGhiFiWQ=="
        ],
        "ARC-Message-Signature": [
            "i=2; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775028653; c=relaxed/simple;\n\tbh=0HzB0n+arXL6t2KuYiD02CH4uf6wtzDS9DQSFddQSTA=;\n\th=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version:Content-Type;\n b=MCweKctwRoKNvxLfinN5BVEB6OBOuQB2VA53HdxhIMD1kDFIqXTz1I4suM68mGaYgcttcULrj8Ux8e1D1ci/gaCBf9Wn7kKKqjiOw4Goyy4MUsUW1B8d+b+/nkxkYzackUcIIvNAlQoErwQM7LK80ILp3+VZTuRSu6aUCmcHCgc=",
            "i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;\n s=arcselector10001;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;\n bh=bFcn9Vxo4lGgPt20VnXBB3wQ1onkpxIBV9SkXwzmenU=;\n b=nSymMRcc4aoRMdecx5eW4KGZU0y8c1FLsXuUT2pAhjg8ENfLQU6hxrE7JVY7NRev7hHR42kSNmU6RjnMU/4F2LJ7LmNrlmrfihtufKbVWnpJtRKb+NwijUr3cmBLCdKLlx0PknJpThxZq5YeCbdwhY5a+lHbq3Zm0kDLdlSJkNRCZp389yoiJSF+yhL7uqFozfeM9fZ39JPArVoUko6HQ8Cnqin7kClD5Z5021pdEytaA7nuY6ARiAoQkBtq7g40Vq6YxUSQ5Mf9KhB3ydFDqlvUQNrbq6g6xey/G7XPsQPXN7dnfkk8hvNsjm9Ryxx8TQ4aKgrKLR4q4XbAnWyK1Q=="
        ],
        "ARC-Authentication-Results": [
            "i=2; smtp.subspace.kernel.org;\n dmarc=pass (p=quarantine dis=none) header.from=ti.com;\n spf=pass smtp.mailfrom=ti.com;\n dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=nf8Jj+m4;\n arc=fail smtp.client-ip=40.107.200.7",
            "i=1; mx.microsoft.com 1; spf=pass (sender ip is\n 198.47.21.194) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=ti.com;\n dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com;\n dkim=none (message not signed); arc=none (0)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n bh=bFcn9Vxo4lGgPt20VnXBB3wQ1onkpxIBV9SkXwzmenU=;\n b=nf8Jj+m4tudURpDDr0tjXGwtvE8H6w6ckmAGP/QpAnF+7z0ZlhyFNE7yE7AtCbRIUMDmUFWieC7MHPOKzntf9c3o2vL/vlgZAy5f/7lBEvBwrrJSKTu4Vrphd5/EGlEgdCHHn1vpB3yxMxJcwM4qglw3IBUs2XlL/O0UgqZ369g=",
        "X-MS-Exchange-Authentication-Results": "spf=pass (sender IP is 198.47.21.194)\n smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass\n action=none header.from=ti.com;",
        "Received-SPF": "Pass (protection.outlook.com: domain of ti.com designates\n 198.47.21.194 as permitted sender) receiver=protection.outlook.com;\n client-ip=198.47.21.194; helo=flwvzet200.ext.ti.com; pr=C",
        "From": "Aksh Garg <a-garg7@ti.com>",
        "To": "<linux-pci@vger.kernel.org>, <linux-doc@vger.kernel.org>,\n\t<mani@kernel.org>, <kwilczynski@kernel.org>, <bhelgaas@google.com>,\n\t<corbet@lwn.net>, <kishon@kernel.org>, <skhan@linuxfoundation.org>,\n\t<lukas@wunner.de>, <cassel@kernel.org>, <alistair@alistair23.me>",
        "CC": "<linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org>,\n\t<s-vadapalli@ti.com>, <danishanwar@ti.com>, <srk@ti.com>, <a-garg7@ti.com>",
        "Subject": "[PATCH v2 2/4] PCI: endpoint: Add DOE mailbox support for endpoint\n functions",
        "Date": "Wed, 1 Apr 2026 13:00:20 +0530",
        "Message-ID": "<20260401073022.215805-3-a-garg7@ti.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20260401073022.215805-1-a-garg7@ti.com>",
        "References": "<20260401073022.215805-1-a-garg7@ti.com>",
        "Precedence": "bulk",
        "X-Mailing-List": "linux-pci@vger.kernel.org",
        "List-Id": "<linux-pci.vger.kernel.org>",
        "List-Subscribe": "<mailto:linux-pci+subscribe@vger.kernel.org>",
        "List-Unsubscribe": "<mailto:linux-pci+unsubscribe@vger.kernel.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-C2ProcessedOrg": "333ef613-75bf-4e12-a4b1-8e3623f5dcea",
        "X-EOPAttributedMessage": "0",
        "X-MS-PublicTrafficType": "Email",
        "X-MS-TrafficTypeDiagnostic": "SJ5PEPF000001E8:EE_|BY5PR10MB4243:EE_",
        "X-MS-Office365-Filtering-Correlation-Id": "e40a16df-e489-4d3a-cb60-08de8fc09791",
        "X-MS-Exchange-SenderADCheck": "1",
        "X-MS-Exchange-AntiSpam-Relay": "0",
        "X-Microsoft-Antispam": "\n\tBCL:0;ARA:13230040|7416014|36860700016|376014|82310400026|1800799024|921020|18002099003|22082099003|56012099003;",
        "X-Microsoft-Antispam-Message-Info": "\n\tY3BiW5GWzA9bWJaMGObVAcGe1uyjGa655pXwVOyLt1E5lni1fNQdcEe4o146bHSPhmzTJ1N5te7N1ffWy5zeD2E7NsFNywHSLwvO4+Mjg0VTLMOnYuJNaYZSQn1+ngcVLb01OzL1nMVezV4JpP8zSbl307bJR1+17GG6l3XC1i3BG4X6fJmWa4icEy3i+srTtPaPG/TBLkHm/GLs8N0kZEAMSmTfyg/ibzK91ozaoRG3cYNY6l2/DTCUknfgOt9/8vRCUOTqdUwXul3z3uGC0+8bNZi90fj6iV5x2of6sLTunTW51Ij4SEbWzr4inQ4DLMPSmBC0dLQdF2NfeTlnEvLVceFPQtVYd7jBHuBSfQctulsmriere6jIdIKhJBR5PH9vzlvXmCEGOxoZsH4v7oF9PP0fdTcwxedAp7H+lUrkl4vRfDeP7yiek/rZu0yggkp0jlUhbvDYugxWeeRF2/+P7Jib8On5F4W33WieEfRf30RATxmq0x3yXkQwRjS0xnx+V0VzapKnpp5RaoOW01O+9mT/eoZIsqNj+U5PTFvWLuYYLAGMlRm93xv9dKhTMI73ygob3AvRS3WMg4vvISZ1NkjddoANOP/LYMtzS2zGyw87mdhAr7ZrbHyKq/VZcIV7Q7TDL28R0t33jv7lKTW4ecply4eSO9JdkqDRKVT+hIa44/Xi57xkgrdl1qLFRO0xJViW2KNi1pVmR+bzr0PSJcNjQmy59lT0Cp1mdKH2WW+wTAJQU1qL2Nc95kJkTtRpoDAVL1/nRNFAjZSV2g==",
        "X-Forefront-Antispam-Report": "\n\tCIP:198.47.21.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet200.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(7416014)(36860700016)(376014)(82310400026)(1800799024)(921020)(18002099003)(22082099003)(56012099003);DIR:OUT;SFP:1101;",
        "X-MS-Exchange-AntiSpam-MessageData-ChunkCount": "1",
        "X-MS-Exchange-AntiSpam-MessageData-0": "\n\tD+/1HxQ3EKaOkMaUvxlsnRg7A1pRA3G0keca2hUiGkTYX58mO+ie86iI810cW0T0I+yDLeTSy5cXbI6v5gmoqU/SERFVAgHdmOTFLFThzuX2Lt2bkyauuI2naM/aEPo2Osv5oBg7g6gWE0MkLXrFDPAJFTIk5nSfj1UYd7t1KFAf8oElD3hCr/w7WwOYDhG88D580/lM1VV63PWHY4tIEnvJTRdJz5pglJSuziydOTw7afQo/SmrRZJF4rz2a0c6M/dDIVnprwH/JcSdpjxlEVXE+fPTZdDmV95aPT71J/rVx4vG1rX4YHAgh+YW2usl5DKfKrZLbMjUyV/w9SHot058ER3pxu4n2+/1v2gwco09ecW90GO+p2C7moLq6nIroBeeO9YWIZkDeINibaIVzbmo6meGNvRyxgXvp+1ZeXXGDY8ywSNQibXAZPwpeXF7",
        "X-OriginatorOrg": "ti.com",
        "X-MS-Exchange-CrossTenant-OriginalArrivalTime": "01 Apr 2026 07:30:47.1221\n (UTC)",
        "X-MS-Exchange-CrossTenant-Network-Message-Id": "\n e40a16df-e489-4d3a-cb60-08de8fc09791",
        "X-MS-Exchange-CrossTenant-Id": "e5b49634-450b-4709-8abb-1e2b19b982b7",
        "X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp": "\n TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.194];Helo=[flwvzet200.ext.ti.com]",
        "X-MS-Exchange-CrossTenant-AuthSource": "\n\tSJ5PEPF000001E8.namprd05.prod.outlook.com",
        "X-MS-Exchange-CrossTenant-AuthAs": "Anonymous",
        "X-MS-Exchange-CrossTenant-FromEntityHeader": "HybridOnPrem",
        "X-MS-Exchange-Transport-CrossTenantHeadersStamped": "BY5PR10MB4243"
    },
    "content": "DOE (Data Object Exchange) is a standard PCIe extended capability\nfeature introduced in the Data Object Exchange (DOE) ECN for\nPCIe r5.0. It provides a communication mechanism primarily used for\nimplementing PCIe security features such as device authentication, and\nsecure link establishment. Think of DOE as a sophisticated mailbox\nsystem built into PCIe. The root complex can send structured requests\nto the endpoint device through DOE mailboxes, and the endpoint device\nresponds with appropriate data.\n\nAdd the DOE support for PCIe endpoint devices, enabling endpoint\nfunctions to process the DOE requests from the host. The implementation\nprovides framework APIs for EPC core driver and controller drivers to\nregister mailboxes, and request processing with workqueues ensuring\nsequential handling per mailbox, and parallel handling across mailboxes.\nThe Discovery protocol is handled internally by the DOE core.\n\nThis implementation complements the existing DOE implementation for\nroot complex in drivers/pci/doe.c.\n\nCo-developed-by: Siddharth Vadapalli <s-vadapalli@ti.com>\nSigned-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>\nSigned-off-by: Aksh Garg <a-garg7@ti.com>\n---\n\nChanges since v1:\n- Moved the DOE-EP core file to drivers/pci/endpoint/pci-ep-doe.c, and\n  corresponding Kconfig and Makefile to match the existing naming scheme,\n  as suggested by Niklas Cassel.\n- Renamed the config from PCI_DOE_EP to PCI_ENDPOINT_DOE\n- Moved the function declarations that need not be visible outside the\n  PCI core to drivers/pci/pci.h instead to include/linux/pci-doe.h as\n  suggested by Lukas Wunner\n- Converted from synchronous to asynchronous request processing:\n  * Removed wait_for_completion() from pci_ep_doe_process_request()\n  * Function returns immediately after queuing to workqueue, hence\n    removed private data for completion in the task structure\n  * Added completion callback as an additional argument to\n    pci_ep_doe_process_request(), which takes the response and status\n    parameters as arguments (along with other required arguments), hence\n    removed task_status in the task structure\n  * Created a typedef pci_ep_doe_complete_t for completion callback\n  * Removed the pci_ep_doe_task_complete() function, as it would not be\n    required anymore with these changes\n  * Moved from INIT_WORK_ONSTACK() to INIT_WORK(), to initialize the work\n    on heap instead of stack\n  * signal_task_complete() now invokes the completion callback, once the\n    protocol handler completes its task\n- Changed from dynamic xarray-based protocol registration to static array:\n  * Removed the register/unregister protocol APIs\n  * Replaced the dynamic xarray with static array of struct pci_doe_protocol\n  * Added discovery protocol to static array, instead of treating it specially,\n    hence removed the special handling for Discovery protocol in\n    doe_ep_task_work()\n  * Updated pci_ep_doe_handle_discovery() and pci_ep_doe_find_protocol()\n    accordingly.\n- Memory Management:\n  * DOE core frees request buffer in signal_task_complete()\n    or during error handling\n  * pci_ep_doe_process_request() defines response_pl and response_pl_sz\n    as NULL and 0 respectively, whose pointer is passed to the protocol\n    handler, hence removed the arguments void **response, size_t *response_sz\n    to this function.\n- Task structure refactoring:\n  * Response buffer: void **response_pl to void *response_pl\n  * Response size: size_t *response_pl_sz to size_t response_pl_sz\n  * Changed the completion callback to type pci_ep_doe_complete_t\n  * Removed void *private and int task_status\n- Updated documentation comments of the functions according to the changes \n\nv1: https://lore.kernel.org/all/20260213123603.420941-4-a-garg7@ti.com/\n\n drivers/pci/endpoint/Kconfig      |  14 +\n drivers/pci/endpoint/Makefile     |   1 +\n drivers/pci/endpoint/pci-ep-doe.c | 552 ++++++++++++++++++++++++++++++\n drivers/pci/pci.h                 |  38 ++\n include/linux/pci-doe.h           |   5 +\n include/linux/pci-epc.h           |   3 +\n 6 files changed, 613 insertions(+)\n create mode 100644 drivers/pci/endpoint/pci-ep-doe.c",
    "diff": "diff --git a/drivers/pci/endpoint/Kconfig b/drivers/pci/endpoint/Kconfig\nindex 8dad291be8b8..15ae16aaa58f 100644\n--- a/drivers/pci/endpoint/Kconfig\n+++ b/drivers/pci/endpoint/Kconfig\n@@ -36,6 +36,20 @@ config PCI_ENDPOINT_MSI_DOORBELL\n \t  doorbell. The RC can trigger doorbell in EP by writing data to a\n \t  dedicated BAR, which the EP maps to the controller's message address.\n \n+config PCI_ENDPOINT_DOE\n+\tbool \"PCI Endpoint Data Object Exchange (DOE) support\"\n+\tdepends on PCI_ENDPOINT\n+\thelp\n+\t  This enables support for Data Object Exchange (DOE) protocol\n+\t  on PCI Endpoint controllers. It provides a communication\n+\t  mechanism through mailboxes, primarily used for PCIe security\n+\t  features.\n+\n+\t  Say Y here if you want be able to communicate using PCIe DOE\n+\t  mailboxes.\n+\n+\t  If unsure, say N.\n+\n source \"drivers/pci/endpoint/functions/Kconfig\"\n \n endmenu\ndiff --git a/drivers/pci/endpoint/Makefile b/drivers/pci/endpoint/Makefile\nindex b4869d52053a..1fa176b6792b 100644\n--- a/drivers/pci/endpoint/Makefile\n+++ b/drivers/pci/endpoint/Makefile\n@@ -7,3 +7,4 @@ obj-$(CONFIG_PCI_ENDPOINT_CONFIGFS)\t+= pci-ep-cfs.o\n obj-$(CONFIG_PCI_ENDPOINT)\t\t+= pci-epc-core.o pci-epf-core.o\\\n \t\t\t\t\t   pci-epc-mem.o functions/\n obj-$(CONFIG_PCI_ENDPOINT_MSI_DOORBELL)\t+= pci-ep-msi.o\n+obj-$(CONFIG_PCI_ENDPOINT_DOE)\t\t+= pci-ep-doe.o\ndiff --git a/drivers/pci/endpoint/pci-ep-doe.c b/drivers/pci/endpoint/pci-ep-doe.c\nnew file mode 100644\nindex 000000000000..ded0290b15ed\n--- /dev/null\n+++ b/drivers/pci/endpoint/pci-ep-doe.c\n@@ -0,0 +1,552 @@\n+// SPDX-License-Identifier: GPL-2.0-only or MIT\n+/*\n+ * Data Object Exchange for PCIe Endpoint\n+ *\tPCIe r7.0, sec 6.30 DOE\n+ *\n+ * Copyright (C) 2026 Texas Instruments Incorporated - https://www.ti.com\n+ *\tAksh Garg <a-garg7@ti.com>\n+ *\tSiddharth Vadapalli <s-vadapalli@ti.com>\n+ */\n+\n+#define dev_fmt(fmt) \"DOE EP: \" fmt\n+\n+#include <linux/bitfield.h>\n+#include <linux/device.h>\n+#include <linux/pci.h>\n+#include <linux/pci-epc.h>\n+#include <linux/pci-doe.h>\n+#include <linux/slab.h>\n+#include <linux/workqueue.h>\n+#include <linux/xarray.h>\n+\n+#include \"../pci.h\"\n+\n+/* Forward declaration of discovery protocol handler */\n+static int pci_ep_doe_handle_discovery(const void *request, size_t request_sz,\n+\t\t\t\t       void **response, size_t *response_sz);\n+\n+/**\n+ * struct pci_doe_protocol - DOE protocol handler entry\n+ * @vid: Vendor ID\n+ * @type: Protocol type\n+ * @handler: Handler function pointer\n+ */\n+struct pci_doe_protocol {\n+\tu16 vid;\n+\tu8 type;\n+\tpci_doe_protocol_handler_t handler;\n+};\n+\n+/**\n+ * struct pci_ep_doe_mb - State for a single DOE mailbox on EP\n+ *\n+ * This state is used to manage a single DOE mailbox capability on the\n+ * endpoint side.\n+ *\n+ * @epc: PCI endpoint controller this mailbox belongs to\n+ * @func_no: Physical function number of the function this mailbox belongs to\n+ * @cap_offset: Capability offset\n+ * @work_queue: Queue of work items\n+ * @flags: Bit array of PCI_DOE_FLAG_* flags\n+ */\n+struct pci_ep_doe_mb {\n+\tstruct pci_epc *epc;\n+\tu8 func_no;\n+\tu16 cap_offset;\n+\tstruct workqueue_struct *work_queue;\n+\tunsigned long flags;\n+};\n+\n+/**\n+ * struct pci_ep_doe_task - Represents a single DOE request/response task\n+ *\n+ * @feat: DOE feature (vendor ID and type)\n+ * @request_pl: Request payload\n+ * @request_pl_sz: Size of request payload in bytes\n+ * @response_pl: Response buffer\n+ * @response_pl_sz: Size of response buffer in bytes\n+ * @complete: Completion callback\n+ * @work: Work structure for workqueue\n+ * @doe_mb: DOE mailbox handling this task\n+ */\n+struct pci_ep_doe_task {\n+\tstruct pci_doe_feature feat;\n+\tconst void *request_pl;\n+\tsize_t request_pl_sz;\n+\tvoid *response_pl;\n+\tsize_t response_pl_sz;\n+\tpci_ep_doe_complete_t complete;\n+\n+\t/* Initialized by pci_ep_doe_submit_task() */\n+\tstruct work_struct work;\n+\tstruct pci_ep_doe_mb *doe_mb;\n+};\n+\n+/*\n+ * Global registry of protocol handlers.\n+ * When a new DOE protocol, library is added, add an entry to this array.\n+ */\n+static const struct pci_doe_protocol pci_doe_protocols[] = {\n+\t{\n+\t\t.vid = PCI_VENDOR_ID_PCI_SIG,\n+\t\t.type = PCI_DOE_FEATURE_DISCOVERY,\n+\t\t.handler = pci_ep_doe_handle_discovery,\n+\t},\n+};\n+\n+/*\n+ * Combines function number and capability offset into a unique lookup key\n+ * for storing/retrieving DOE mailboxes in an xarray.\n+ */\n+#define PCI_DOE_MB_KEY(func, offset) \\\n+\t(((unsigned long)(func) << 16) | (offset))\n+#define PCI_DOE_PROTOCOL_COUNT        ARRAY_SIZE(pci_doe_protocols)\n+\n+/**\n+ * pci_ep_doe_init() - Initialize the DOE framework for a controller in EP mode\n+ * @epc: PCI endpoint controller\n+ *\n+ * Initialize the DOE framework data structures. This only initializes\n+ * the xarray that will hold the mailboxes.\n+ *\n+ * RETURNS: 0 on success, -errno on failure\n+ */\n+int pci_ep_doe_init(struct pci_epc *epc)\n+{\n+\tif (!epc)\n+\t\treturn -EINVAL;\n+\n+\txa_init(&epc->doe_mbs);\n+\treturn 0;\n+}\n+EXPORT_SYMBOL_GPL(pci_ep_doe_init);\n+\n+/**\n+ * pci_ep_doe_add_mailbox() - Add a DOE mailbox for a physical function\n+ * @epc: PCI endpoint controller\n+ * @func_no: Physical function number\n+ * @cap_offset: Offset of the DOE capability\n+ *\n+ * Create and register a DOE mailbox for the specified physical function\n+ * and capability offset.\n+ *\n+ * EPC core driver calls this for each DOE capability discovered in the config\n+ * space of each endpoint function through an API. The API is invoked by the\n+ * controller driver during initialization if DOE support is available.\n+ *\n+ * RETURNS: 0 on success, -errno on failure\n+ */\n+int pci_ep_doe_add_mailbox(struct pci_epc *epc, u8 func_no, u16 cap_offset)\n+{\n+\tstruct pci_ep_doe_mb *doe_mb;\n+\tunsigned long key;\n+\tint ret;\n+\n+\tif (!epc)\n+\t\treturn -EINVAL;\n+\n+\tdoe_mb = kzalloc_obj(*doe_mb, GFP_KERNEL);\n+\tif (!doe_mb)\n+\t\treturn -ENOMEM;\n+\n+\tdoe_mb->epc = epc;\n+\tdoe_mb->func_no = func_no;\n+\tdoe_mb->cap_offset = cap_offset;\n+\n+\tdoe_mb->work_queue = alloc_ordered_workqueue(\"pci_ep_doe[%s:pf%d:offset%x]\", 0,\n+\t\t\t\t\t\t     dev_name(&epc->dev),\n+\t\t\t\t\t\t     func_no, cap_offset);\n+\tif (!doe_mb->work_queue) {\n+\t\tdev_err(epc->dev.parent,\n+\t\t\t\"[pf%d:offset%x] failed to allocate work queue\\n\",\n+\t\t\tfunc_no, cap_offset);\n+\t\tret = -ENOMEM;\n+\t\tgoto err_free;\n+\t}\n+\n+\t/* Add to xarray with composite key */\n+\tkey = PCI_DOE_MB_KEY(func_no, cap_offset);\n+\tret = xa_insert(&epc->doe_mbs, key, doe_mb, GFP_KERNEL);\n+\tif (ret) {\n+\t\tdev_err(epc->dev.parent,\n+\t\t\t\"[pf%d:offset%x] failed to insert mailbox: %d\\n\",\n+\t\t\tfunc_no, cap_offset, ret);\n+\t\tgoto err_destroy;\n+\t}\n+\n+\tdev_dbg(epc->dev.parent,\n+\t\t\"DOE mailbox added: pf%d offset 0x%x\\n\",\n+\t\tfunc_no, cap_offset);\n+\n+\treturn 0;\n+\n+err_destroy:\n+\tdestroy_workqueue(doe_mb->work_queue);\n+err_free:\n+\tkfree(doe_mb);\n+\treturn ret;\n+}\n+EXPORT_SYMBOL_GPL(pci_ep_doe_add_mailbox);\n+\n+/**\n+ * pci_ep_doe_cancel_tasks() - Cancel all pending tasks\n+ * @doe_mb: DOE mailbox\n+ *\n+ * Cancel all pending tasks in the mailbox. Mark the mailbox as dead\n+ * so no new tasks can be submitted.\n+ */\n+static void pci_ep_doe_cancel_tasks(struct pci_ep_doe_mb *doe_mb)\n+{\n+\tif (!doe_mb)\n+\t\treturn;\n+\n+\t/* Mark the mailbox as dead */\n+\tset_bit(PCI_DOE_FLAG_DEAD, &doe_mb->flags);\n+\n+\t/* Stop all pending work items from starting */\n+\tset_bit(PCI_DOE_FLAG_CANCEL, &doe_mb->flags);\n+}\n+\n+/**\n+ * pci_ep_doe_get_mailbox() - Get DOE mailbox by function and offset\n+ * @epc: PCI endpoint controller\n+ * @func_no: Physical function number\n+ * @cap_offset: Offset of the DOE capability\n+ *\n+ * Internal helper to look up a DOE mailbox by its function number and\n+ * capability offset.\n+ *\n+ * RETURNS: Pointer to the mailbox or NULL if not found\n+ */\n+static struct pci_ep_doe_mb *pci_ep_doe_get_mailbox(struct pci_epc *epc,\n+\t\t\t\t\t\t    u8 func_no, u16 cap_offset)\n+{\n+\tunsigned long key;\n+\n+\tif (!epc)\n+\t\treturn NULL;\n+\n+\tkey = PCI_DOE_MB_KEY(func_no, cap_offset);\n+\treturn xa_load(&epc->doe_mbs, key);\n+}\n+\n+/**\n+ * pci_ep_doe_find_protocol() - Find protocol handler in static array\n+ * @vendor: Vendor ID\n+ * @type: Protocol type\n+ *\n+ * Look up a protocol handler in the static protocol array by matching vendor ID\n+ * and protocol type.\n+ *\n+ * RETURNS: Handler function pointer or NULL if not found\n+ */\n+static pci_doe_protocol_handler_t pci_ep_doe_find_protocol(u16 vendor, u8 type)\n+{\n+\tint i;\n+\n+\t/* Search static protocol array */\n+\tfor (i = 0; i < PCI_DOE_PROTOCOL_COUNT; i++) {\n+\t\tif (pci_doe_protocols[i].vid == vendor &&\n+\t\t    pci_doe_protocols[i].type == type)\n+\t\t\treturn pci_doe_protocols[i].handler;\n+\t}\n+\n+\treturn NULL;\n+}\n+\n+/**\n+ * pci_ep_doe_handle_discovery() - Handle Discovery protocol request\n+ * @request: Request payload\n+ * @request_sz: Request size\n+ * @response: Output pointer for response buffer\n+ * @response_sz: Output pointer for response size\n+ *\n+ * Handle the DOE Discovery protocol. The request contains an index specifying\n+ * which protocol to query. This function creates a response containing the\n+ * vendor ID and protocol type for the requested index, along with the next\n+ * index value for further discovery:\n+ *\n+ * - next_index = 0: Signals this is the last protocol supported\n+ * - next_index = n (non-zero): Signals more protocols available,\n+ *   query index n next\n+ *\n+ * RETURNS: 0 on success, -errno on failure\n+ */\n+static int pci_ep_doe_handle_discovery(const void *request, size_t request_sz,\n+\t\t\t\t       void **response, size_t *response_sz)\n+{\n+\tstruct pci_doe_protocol protocol;\n+\tu8 requested_index, next_index;\n+\tu32 *response_pl;\n+\tu32 request_pl;\n+\tu16 vendor;\n+\tu8 type;\n+\n+\tif (request_sz != sizeof(u32))\n+\t\treturn -EINVAL;\n+\n+\trequest_pl = *(u32 *)request;\n+\trequested_index = FIELD_GET(PCI_DOE_DATA_OBJECT_DISC_REQ_3_INDEX, request_pl);\n+\n+\tif (requested_index >= PCI_DOE_PROTOCOL_COUNT)\n+\t\treturn -EINVAL;\n+\n+\t/* Get protocol from array at requested_index */\n+\tprotocol = pci_doe_protocols[requested_index];\n+\tvendor = protocol.vid;\n+\ttype = protocol.type;\n+\n+\t/* Calculate next index */\n+\tnext_index = (requested_index + 1 < PCI_DOE_PROTOCOL_COUNT) ? requested_index + 1 : 0;\n+\n+\tresponse_pl = kzalloc_obj(*response_pl, GFP_KERNEL);\n+\tif (!response_pl)\n+\t\treturn -ENOMEM;\n+\n+\t/* Build response */\n+\t*response_pl = FIELD_PREP(PCI_DOE_DATA_OBJECT_DISC_RSP_3_VID, vendor) |\n+\t\t       FIELD_PREP(PCI_DOE_DATA_OBJECT_DISC_RSP_3_TYPE, type) |\n+\t\t       FIELD_PREP(PCI_DOE_DATA_OBJECT_DISC_RSP_3_NEXT_INDEX, next_index);\n+\n+\t*response = response_pl;\n+\t*response_sz = sizeof(*response_pl);\n+\n+\treturn 0;\n+}\n+\n+static void signal_task_complete(struct pci_ep_doe_task *task, int status)\n+{\n+\tkfree(task->request_pl);\n+\ttask->complete(task->doe_mb->func_no, task->doe_mb->cap_offset, status,\n+\t\t       task->feat.vid, task->feat.type,\n+\t\t       task->response_pl, task->response_pl_sz);\n+\tkfree(task);\n+}\n+\n+/**\n+ * doe_ep_task_work() - Work function for processing DOE EP tasks\n+ * @work: Work structure\n+ *\n+ * Process a DOE request by calling the appropriate protocol handler.\n+ */\n+static void doe_ep_task_work(struct work_struct *work)\n+{\n+\tstruct pci_ep_doe_task *task = container_of(work, struct pci_ep_doe_task,\n+\t\t\t\t\t\t    work);\n+\tstruct pci_ep_doe_mb *doe_mb = task->doe_mb;\n+\tpci_doe_protocol_handler_t handler;\n+\tint rc;\n+\n+\tif (test_bit(PCI_DOE_FLAG_DEAD, &doe_mb->flags)) {\n+\t\tsignal_task_complete(task, -EIO);\n+\t\treturn;\n+\t}\n+\n+\t/* Check if request was aborted */\n+\tif (test_bit(PCI_DOE_FLAG_CANCEL, &doe_mb->flags)) {\n+\t\tsignal_task_complete(task, -ECANCELED);\n+\t\treturn;\n+\t}\n+\n+\t/* Find protocol handler in the array */\n+\thandler = pci_ep_doe_find_protocol(task->feat.vid, task->feat.type);\n+\tif (!handler) {\n+\t\tdev_warn(doe_mb->epc->dev.parent,\n+\t\t\t \"[%d:%x] Unsupported protocol VID=%04x TYPE=%02x\\n\",\n+\t\t\t doe_mb->func_no, doe_mb->cap_offset,\n+\t\t\t task->feat.vid, task->feat.type);\n+\t\tsignal_task_complete(task, -EOPNOTSUPP);\n+\t\treturn;\n+\t}\n+\n+\t/* Call protocol handler */\n+\trc = handler(task->request_pl, task->request_pl_sz,\n+\t\t     &task->response_pl, &task->response_pl_sz);\n+\n+\tsignal_task_complete(task, rc);\n+}\n+\n+/**\n+ * pci_ep_doe_submit_task() - Submit a task to be processed\n+ * @doe_mb: DOE mailbox\n+ * @task: Task to submit\n+ *\n+ * Submit a DOE task to the workqueue for asynchronous processing.\n+ *\n+ * RETURNS: 0 on success, -errno on failure\n+ */\n+static int pci_ep_doe_submit_task(struct pci_ep_doe_mb *doe_mb,\n+\t\t\t\t  struct pci_ep_doe_task *task)\n+{\n+\tif (test_bit(PCI_DOE_FLAG_DEAD, &doe_mb->flags))\n+\t\treturn -EIO;\n+\n+\ttask->doe_mb = doe_mb;\n+\tINIT_WORK(&task->work, doe_ep_task_work);\n+\tqueue_work(doe_mb->work_queue, &task->work);\n+\treturn 0;\n+}\n+\n+/**\n+ * pci_ep_doe_process_request() - Process DOE request on endpoint\n+ * @epc: PCI endpoint controller\n+ * @func_no: Physical function number\n+ * @cap_offset: DOE capability offset\n+ * @vendor: Vendor ID from request header\n+ * @type: Protocol type from request header\n+ * @request: Request payload in CPU-native format\n+ * @request_sz: Size of request payload (bytes)\n+ * @complete: Callback to invoke upon completion\n+ *\n+ * Asynchronously process a DOE request received on the endpoint. The request\n+ * payload should not include the DOE header (vendor/type/length). The protocol\n+ * handler will allocate the response buffer, which the caller (controller driver)\n+ * must free after use.\n+ *\n+ * This function returns immediately after queuing the request. The completion\n+ * callback will be invoked asynchronously from workqueue context once the\n+ * request is processed. The callback receives the function number and capability\n+ * offset to identify the mailbox, along with a status code (0 on success, -errno\n+ * on failure), and other required arguments.\n+ *\n+ * As per DOE specification, a mailbox processes one request at a time.\n+ * Therefore, this function will never be called concurrently for the same\n+ * mailbox by different callers.\n+ *\n+ * The caller is responsible for the conversion of the received DOE request\n+ * with le32_to_cpu() before calling this function.\n+ * Similarly, it is responsible for converting the response payload with\n+ * cpu_to_le32() before sending it back over the DOE mailbox.\n+ *\n+ * The caller is also responsible for ensuring that the request size\n+ * is within the limits defined by PCI_DOE_MAX_LENGTH.\n+ *\n+ * RETURNS: 0 if the request was successfully queued, -errno on failure\n+ */\n+int pci_ep_doe_process_request(struct pci_epc *epc, u8 func_no, u16 cap_offset,\n+\t\t\t       u16 vendor, u8 type, const void *request, size_t request_sz,\n+\t\t\t       pci_ep_doe_complete_t complete)\n+{\n+\tstruct pci_ep_doe_mb *doe_mb;\n+\tstruct pci_ep_doe_task *task;\n+\tint rc;\n+\n+\tdoe_mb = pci_ep_doe_get_mailbox(epc, func_no, cap_offset);\n+\tif (!doe_mb) {\n+\t\tkfree(request);\n+\t\treturn -ENODEV;\n+\t}\n+\n+\ttask = kzalloc_obj(*task, GFP_KERNEL);\n+\tif (!task) {\n+\t\tkfree(request);\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\ttask->feat.vid = vendor;\n+\ttask->feat.type = type;\n+\ttask->request_pl = request;\n+\ttask->request_pl_sz = request_sz;\n+\ttask->response_pl = NULL;\n+\ttask->response_pl_sz = 0;\n+\ttask->complete = complete;\n+\n+\trc = pci_ep_doe_submit_task(doe_mb, task);\n+\tif (rc) {\n+\t\tkfree(request);\n+\t\tkfree(task);\n+\t\treturn rc;\n+\t}\n+\n+\treturn 0;\n+}\n+EXPORT_SYMBOL_GPL(pci_ep_doe_process_request);\n+\n+/**\n+ * pci_ep_doe_abort() - Abort DOE operations on a mailbox\n+ * @epc: PCI endpoint controller\n+ * @func_no: Physical function number\n+ * @cap_offset: DOE capability offset\n+ *\n+ * Abort all queued and wait for in-flight DOE operations to complete for the\n+ * specified mailbox. This function is called by the EP controller driver\n+ * when the RC sets the ABORT bit in the DOE Control register.\n+ *\n+ * The function will:\n+ *\n+ * - Set CANCEL flag to prevent new requests in the queue from starting\n+ * - Wait for the currently executing handler to complete (cannot interrupt)\n+ * - Flush the workqueue to wait for all requests to be handled appropriately\n+ * - Clear CANCEL flag to prepare for new requests\n+ *\n+ * RETURNS: 0 on success, -errno on failure\n+ */\n+int pci_ep_doe_abort(struct pci_epc *epc, u8 func_no, u16 cap_offset)\n+{\n+\tstruct pci_ep_doe_mb *doe_mb;\n+\n+\tif (!epc)\n+\t\treturn -EINVAL;\n+\n+\tdoe_mb = pci_ep_doe_get_mailbox(epc, func_no, cap_offset);\n+\tif (!doe_mb)\n+\t\treturn -ENODEV;\n+\n+\t/* Set CANCEL flag - worker will abort queued requests */\n+\tset_bit(PCI_DOE_FLAG_CANCEL, &doe_mb->flags);\n+\tflush_workqueue(doe_mb->work_queue);\n+\n+\t/* Clear CANCEL flag - mailbox ready for new requests */\n+\tclear_bit(PCI_DOE_FLAG_CANCEL, &doe_mb->flags);\n+\n+\tdev_dbg(epc->dev.parent,\n+\t\t\"DOE mailbox aborted: PF%d offset 0x%x\\n\",\n+\t\tfunc_no, cap_offset);\n+\n+\treturn 0;\n+}\n+EXPORT_SYMBOL_GPL(pci_ep_doe_abort);\n+\n+/**\n+ * pci_ep_doe_destroy_mb() - Destroy a single DOE mailbox\n+ * @doe_mb: DOE mailbox to destroy\n+ *\n+ * Internal function to destroy a mailbox and free its resources.\n+ */\n+static void pci_ep_doe_destroy_mb(struct pci_ep_doe_mb *doe_mb)\n+{\n+\tif (!doe_mb)\n+\t\treturn;\n+\n+\tpci_ep_doe_cancel_tasks(doe_mb);\n+\n+\tif (doe_mb->work_queue)\n+\t\tdestroy_workqueue(doe_mb->work_queue);\n+\n+\tkfree(doe_mb);\n+}\n+\n+/**\n+ * pci_ep_doe_destroy() - Destroy all DOE mailboxes\n+ * @epc: PCI endpoint controller\n+ *\n+ * Destroy all DOE mailboxes and free associated resources.\n+ *\n+ * The EPC core driver calls this through an API, invoked by the controller\n+ * driver during controller cleanup to free all DOE resources,\n+ * if DOE support is available.\n+ */\n+void pci_ep_doe_destroy(struct pci_epc *epc)\n+{\n+\tstruct pci_ep_doe_mb *doe_mb;\n+\tunsigned long index;\n+\n+\tif (!epc)\n+\t\treturn;\n+\n+\txa_for_each(&epc->doe_mbs, index, doe_mb)\n+\t\tpci_ep_doe_destroy_mb(doe_mb);\n+\n+\txa_destroy(&epc->doe_mbs);\n+}\n+EXPORT_SYMBOL_GPL(pci_ep_doe_destroy);\ndiff --git a/drivers/pci/pci.h b/drivers/pci/pci.h\nindex 66b7ec80f46f..456e0717dd54 100644\n--- a/drivers/pci/pci.h\n+++ b/drivers/pci/pci.h\n@@ -690,6 +690,12 @@ struct pci_doe_feature {\n \tu8 type;\n };\n \n+struct pci_epc;\n+\n+typedef void (*pci_ep_doe_complete_t)(u8 func_no, u16 cap_offset, int status,\n+\t\t\t\t      u16 vendor, u8 type, void *response_pl,\n+\t\t\t\t      size_t response_pl_sz);\n+\n #ifdef CONFIG_PCI_DOE\n void pci_doe_init(struct pci_dev *pdev);\n void pci_doe_destroy(struct pci_dev *pdev);\n@@ -700,6 +706,38 @@ static inline void pci_doe_destroy(struct pci_dev *pdev) { }\n static inline void pci_doe_disconnected(struct pci_dev *pdev) { }\n #endif\n \n+#ifdef CONFIG_PCI_ENDPOINT_DOE\n+int pci_ep_doe_init(struct pci_epc *epc);\n+int pci_ep_doe_add_mailbox(struct pci_epc *epc, u8 func_no, u16 cap_offset);\n+int pci_ep_doe_process_request(struct pci_epc *epc, u8 func_no, u16 cap_offset,\n+\t\t\t       u16 vendor, u8 type, const void *request,\n+\t\t\t       size_t request_sz, pci_ep_doe_complete_t complete);\n+int pci_ep_doe_abort(struct pci_epc *epc, u8 func_no, u16 cap_offset);\n+void pci_ep_doe_destroy(struct pci_epc *epc);\n+#else\n+static inline int pci_ep_doe_init(struct pci_epc *epc) { return -EOPNOTSUPP; }\n+static inline int pci_ep_doe_add_mailbox(struct pci_epc *epc, u8 func_no,\n+\t\t\t\t\t u16 cap_offset)\n+{\n+\treturn -EOPNOTSUPP;\n+}\n+\n+static inline int pci_ep_doe_process_request(struct pci_epc *epc, u8 func_no,\n+\t\t\t\t\t     u16 cap_offset, u16 vendor, u8 type,\n+\t\t\t\t\t     const void *request, size_t request_sz,\n+\t\t\t\t\t     pci_ep_doe_complete_t complete)\n+{\n+\treturn -EOPNOTSUPP;\n+}\n+\n+static inline int pci_ep_doe_abort(struct pci_epc *epc, u8 func_no, u16 cap_offset)\n+{\n+\treturn -EOPNOTSUPP;\n+}\n+\n+static inline void pci_ep_doe_destroy(struct pci_epc *epc) { }\n+#endif\n+\n #ifdef CONFIG_PCI_NPEM\n void pci_npem_create(struct pci_dev *dev);\n void pci_npem_remove(struct pci_dev *dev);\ndiff --git a/include/linux/pci-doe.h b/include/linux/pci-doe.h\nindex abb9b7ae8029..c46e42f3ce78 100644\n--- a/include/linux/pci-doe.h\n+++ b/include/linux/pci-doe.h\n@@ -22,6 +22,11 @@ struct pci_doe_mb;\n /* Max data object length is 2^18 dwords */\n #define PCI_DOE_MAX_LENGTH\t\t(1 << 18)\n \n+typedef int (*pci_doe_protocol_handler_t)(const void *request,\n+\t\t\t\t\t  size_t request_sz,\n+\t\t\t\t\t  void **response,\n+\t\t\t\t\t  size_t *response_sz);\n+\n struct pci_doe_mb *pci_find_doe_mailbox(struct pci_dev *pdev, u16 vendor,\n \t\t\t\t\tu8 type);\n \ndiff --git a/include/linux/pci-epc.h b/include/linux/pci-epc.h\nindex c021c7af175f..cfe74585be4c 100644\n--- a/include/linux/pci-epc.h\n+++ b/include/linux/pci-epc.h\n@@ -182,6 +182,9 @@ struct pci_epc {\n \tunsigned long\t\t\tfunction_num_map;\n \tint\t\t\t\tdomain_nr;\n \tbool\t\t\t\tinit_complete;\n+#ifdef CONFIG_PCI_ENDPOINT_DOE\n+\tstruct xarray\t\t\tdoe_mbs;\n+#endif\n };\n \n /**\n",
    "prefixes": [
        "v2",
        "2/4"
    ]
}