Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Data Object Exchange
0004  *  PCIe r6.0, sec 6.30 DOE
0005  *
0006  * Copyright (C) 2021 Huawei
0007  *     Jonathan Cameron <Jonathan.Cameron@huawei.com>
0008  *
0009  * Copyright (C) 2022 Intel Corporation
0010  *  Ira Weiny <ira.weiny@intel.com>
0011  */
0012 
0013 #ifndef LINUX_PCI_DOE_H
0014 #define LINUX_PCI_DOE_H
0015 
0016 struct pci_doe_protocol {
0017     u16 vid;
0018     u8 type;
0019 };
0020 
0021 struct pci_doe_mb;
0022 
0023 /**
0024  * struct pci_doe_task - represents a single query/response
0025  *
0026  * @prot: DOE Protocol
0027  * @request_pl: The request payload
0028  * @request_pl_sz: Size of the request payload (bytes)
0029  * @response_pl: The response payload
0030  * @response_pl_sz: Size of the response payload (bytes)
0031  * @rv: Return value.  Length of received response or error (bytes)
0032  * @complete: Called when task is complete
0033  * @private: Private data for the consumer
0034  * @work: Used internally by the mailbox
0035  * @doe_mb: Used internally by the mailbox
0036  *
0037  * The payload sizes and rv are specified in bytes with the following
0038  * restrictions concerning the protocol.
0039  *
0040  *  1) The request_pl_sz must be a multiple of double words (4 bytes)
0041  *  2) The response_pl_sz must be >= a single double word (4 bytes)
0042  *  3) rv is returned as bytes but it will be a multiple of double words
0043  *
0044  * NOTE there is no need for the caller to initialize work or doe_mb.
0045  */
0046 struct pci_doe_task {
0047     struct pci_doe_protocol prot;
0048     u32 *request_pl;
0049     size_t request_pl_sz;
0050     u32 *response_pl;
0051     size_t response_pl_sz;
0052     int rv;
0053     void (*complete)(struct pci_doe_task *task);
0054     void *private;
0055 
0056     /* No need for the user to initialize these fields */
0057     struct work_struct work;
0058     struct pci_doe_mb *doe_mb;
0059 };
0060 
0061 /**
0062  * pci_doe_for_each_off - Iterate each DOE capability
0063  * @pdev: struct pci_dev to iterate
0064  * @off: u16 of config space offset of each mailbox capability found
0065  */
0066 #define pci_doe_for_each_off(pdev, off) \
0067     for (off = pci_find_next_ext_capability(pdev, off, \
0068                     PCI_EXT_CAP_ID_DOE); \
0069         off > 0; \
0070         off = pci_find_next_ext_capability(pdev, off, \
0071                     PCI_EXT_CAP_ID_DOE))
0072 
0073 struct pci_doe_mb *pcim_doe_create_mb(struct pci_dev *pdev, u16 cap_offset);
0074 bool pci_doe_supports_prot(struct pci_doe_mb *doe_mb, u16 vid, u8 type);
0075 int pci_doe_submit_task(struct pci_doe_mb *doe_mb, struct pci_doe_task *task);
0076 
0077 #endif