1 /* SPDX-License-Identifier: GPL-2.0 */
4 * PCIe r6.0, sec 6.30 DOE
6 * Copyright (C) 2021 Huawei
9 * Copyright (C) 2022 Intel Corporation
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 * The payload sizes and rv are specified in bytes with the following
38 * restrictions concerning the protocol.
40 * 1) The request_pl_sz must be a multiple of double words (4 bytes)
41 * 2) The response_pl_sz must be >= a single double word (4 bytes)
42 * 3) rv is returned as bytes but it will be a multiple of double words
44 * NOTE there is no need for the caller to initialize work or doe_mb.
47 struct pci_doe_protocol prot;
51 size_t response_pl_sz;
53 void (*complete)(struct pci_doe_task *task);
56 /* No need for the user to initialize these fields */
57 struct work_struct work;
58 struct pci_doe_mb *doe_mb;
62 * pci_doe_for_each_off - Iterate each DOE capability
63 * @pdev: struct pci_dev to iterate
64 * @off: u16 of config space offset of each mailbox capability found
66 #define pci_doe_for_each_off(pdev, off) \
67 for (off = pci_find_next_ext_capability(pdev, off, \
68 PCI_EXT_CAP_ID_DOE); \
70 off = pci_find_next_ext_capability(pdev, off, \
73 struct pci_doe_mb *pcim_doe_create_mb(struct pci_dev *pdev, u16 cap_offset);
74 bool pci_doe_supports_prot(struct pci_doe_mb *doe_mb, u16 vid, u8 type);
75 int pci_doe_submit_task(struct pci_doe_mb *doe_mb, struct pci_doe_task *task);