1 /* SPDX-License-Identifier: GPL-2.0 */
4 * PCIe r6.0, sec 6.30 DOE
6 * Copyright (C) 2021 Huawei
7 * Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 * Copyright (C) 2022 Intel Corporation
10 * Ira Weiny <ira.weiny@intel.com>
13 #ifndef LINUX_PCI_DOE_H
14 #define LINUX_PCI_DOE_H
16 struct pci_doe_protocol {
24 * struct pci_doe_task - represents a single query/response
27 * @request_pl: The request payload
28 * @request_pl_sz: Size of the request payload (bytes)
29 * @response_pl: The response payload
30 * @response_pl_sz: Size of the response payload (bytes)
31 * @rv: Return value. Length of received response or error (bytes)
32 * @complete: Called when task is complete
33 * @private: Private data for the consumer
34 * @work: Used internally by the mailbox
35 * @doe_mb: Used internally by the mailbox
37 * Payloads are treated as opaque byte streams which are transmitted verbatim,
38 * without byte-swapping. If payloads contain little-endian register values,
39 * the caller is responsible for conversion with cpu_to_le32() / le32_to_cpu().
41 * The payload sizes and rv are specified in bytes with the following
42 * restrictions concerning the protocol.
44 * 1) The request_pl_sz must be a multiple of double words (4 bytes)
45 * 2) The response_pl_sz must be >= a single double word (4 bytes)
46 * 3) rv is returned as bytes but it will be a multiple of double words
48 * NOTE there is no need for the caller to initialize work or doe_mb.
51 struct pci_doe_protocol prot;
55 size_t response_pl_sz;
57 void (*complete)(struct pci_doe_task *task);
60 /* No need for the user to initialize these fields */
61 struct work_struct work;
62 struct pci_doe_mb *doe_mb;
66 * pci_doe_for_each_off - Iterate each DOE capability
67 * @pdev: struct pci_dev to iterate
68 * @off: u16 of config space offset of each mailbox capability found
70 #define pci_doe_for_each_off(pdev, off) \
71 for (off = pci_find_next_ext_capability(pdev, off, \
72 PCI_EXT_CAP_ID_DOE); \
74 off = pci_find_next_ext_capability(pdev, off, \
77 struct pci_doe_mb *pcim_doe_create_mb(struct pci_dev *pdev, u16 cap_offset);
78 bool pci_doe_supports_prot(struct pci_doe_mb *doe_mb, u16 vid, u8 type);
79 int pci_doe_submit_task(struct pci_doe_mb *doe_mb, struct pci_doe_task *task);