[RFC PATCH 2/4] PCI/DOE: Move common definitions to the header file

Aksh Garg a-garg7 at ti.com
Fri Feb 13 04:36:01 PST 2026


From: Aksh Garg <a-garg7 at ti.com>

Move common macros and structures from drivers/pci/doe.c to
include/linux/pci-doe.h to allow reuse across root complex and
endpoint DOE implementations.

Also add CONFIG_PCI_DOE guards around the root complex DOE APIs to
maintain proper conditional compilation.

These changes prepare the groundwork for the DOE endpoint implementation
that will reuse these common definitions.

Co-developed-by: Siddharth Vadapalli <s-vadapalli at ti.com>
Signed-off-by: Siddharth Vadapalli <s-vadapalli at ti.com>
Signed-off-by: Aksh Garg <a-garg7 at ti.com>
---
 drivers/pci/doe.c       | 11 -----------
 include/linux/pci-doe.h | 38 +++++++++++++++++++++++++++++++++-----
 2 files changed, 33 insertions(+), 16 deletions(-)

diff --git a/drivers/pci/doe.c b/drivers/pci/doe.c
index 62be9c8dbc52..0171ef3215a7 100644
--- a/drivers/pci/doe.c
+++ b/drivers/pci/doe.c
@@ -28,12 +28,6 @@
 #define PCI_DOE_TIMEOUT HZ
 #define PCI_DOE_POLL_INTERVAL	(PCI_DOE_TIMEOUT / 128)
 
-#define PCI_DOE_FLAG_CANCEL	0
-#define PCI_DOE_FLAG_DEAD	1
-
-/* Max data object length is 2^18 dwords */
-#define PCI_DOE_MAX_LENGTH	(1 << 18)
-
 /**
  * struct pci_doe_mb - State for a single DOE mailbox
  *
@@ -63,11 +57,6 @@ struct pci_doe_mb {
 #endif
 };
 
-struct pci_doe_feature {
-	u16 vid;
-	u8 type;
-};
-
 /**
  * struct pci_doe_task - represents a single query/response
  *
diff --git a/include/linux/pci-doe.h b/include/linux/pci-doe.h
index bd4346a7c4e7..a966626c47f9 100644
--- a/include/linux/pci-doe.h
+++ b/include/linux/pci-doe.h
@@ -13,12 +13,25 @@
 #ifndef LINUX_PCI_DOE_H
 #define LINUX_PCI_DOE_H
 
-struct pci_doe_mb;
+/* Mailbox state flags */
+#define PCI_DOE_FLAG_CANCEL		0
+#define PCI_DOE_FLAG_DEAD		1
+
+/* Max data object length is 2^18 dwords */
+#define PCI_DOE_MAX_LENGTH		(1 << 18)
 
-#define PCI_DOE_FEATURE_DISCOVERY 0
-#define PCI_DOE_FEATURE_CMA 1
-#define PCI_DOE_FEATURE_SSESSION 2
+#define PCI_DOE_FEATURE_DISCOVERY	0
+#define PCI_DOE_FEATURE_CMA		1
+#define PCI_DOE_FEATURE_SSESSION	2
 
+struct pci_doe_feature {
+	u16 vid;
+	u8 type;
+};
+
+struct pci_doe_mb;
+
+#ifdef CONFIG_PCI_DOE
 struct pci_doe_mb *pci_find_doe_mailbox(struct pci_dev *pdev, u16 vendor,
 					u8 type);
 
@@ -26,4 +39,19 @@ int pci_doe(struct pci_doe_mb *doe_mb, u16 vendor, u8 type,
 	    const void *request, size_t request_sz,
 	    void *response, size_t response_sz);
 
-#endif
+#else
+static inline struct pci_doe_mb *pci_find_doe_mailbox(struct pci_dev *pdev,
+						      u16 vendor, u8 type)
+{
+	return NULL;
+}
+
+static inline int pci_doe(struct pci_doe_mb *doe_mb, u16 vendor, u8 type,
+			  const void *request, size_t request_sz,
+			  void *response, size_t response_sz)
+{
+	return -EOPNOTSUPP;
+}
+#endif /* CONFIG_PCI_DOE */
+
+#endif /* LINUX_PCI_DOE_H */
-- 
2.34.1




More information about the linux-arm-kernel mailing list