0001 .. SPDX-License-Identifier: GPL-2.0
0002
0003 =======================================
0004 Configuring PCI Endpoint Using CONFIGFS
0005 =======================================
0006
0007 :Author: Kishon Vijay Abraham I <kishon@ti.com>
0008
0009 The PCI Endpoint Core exposes configfs entry (pci_ep) to configure the
0010 PCI endpoint function and to bind the endpoint function
0011 with the endpoint controller. (For introducing other mechanisms to
0012 configure the PCI Endpoint Function refer to [1]).
0013
0014 Mounting configfs
0015 =================
0016
0017 The PCI Endpoint Core layer creates pci_ep directory in the mounted configfs
0018 directory. configfs can be mounted using the following command::
0019
0020 mount -t configfs none /sys/kernel/config
0021
0022 Directory Structure
0023 ===================
0024
0025 The pci_ep configfs has two directories at its root: controllers and
0026 functions. Every EPC device present in the system will have an entry in
0027 the *controllers* directory and every EPF driver present in the system
0028 will have an entry in the *functions* directory.
0029 ::
0030
0031 /sys/kernel/config/pci_ep/
0032 .. controllers/
0033 .. functions/
0034
0035 Creating EPF Device
0036 ===================
0037
0038 Every registered EPF driver will be listed in controllers directory. The
0039 entries corresponding to EPF driver will be created by the EPF core.
0040 ::
0041
0042 /sys/kernel/config/pci_ep/functions/
0043 .. <EPF Driver1>/
0044 ... <EPF Device 11>/
0045 ... <EPF Device 21>/
0046 ... <EPF Device 31>/
0047 .. <EPF Driver2>/
0048 ... <EPF Device 12>/
0049 ... <EPF Device 22>/
0050
0051 In order to create a <EPF device> of the type probed by <EPF Driver>, the
0052 user has to create a directory inside <EPF DriverN>.
0053
0054 Every <EPF device> directory consists of the following entries that can be
0055 used to configure the standard configuration header of the endpoint function.
0056 (These entries are created by the framework when any new <EPF Device> is
0057 created)
0058 ::
0059
0060 .. <EPF Driver1>/
0061 ... <EPF Device 11>/
0062 ... vendorid
0063 ... deviceid
0064 ... revid
0065 ... progif_code
0066 ... subclass_code
0067 ... baseclass_code
0068 ... cache_line_size
0069 ... subsys_vendor_id
0070 ... subsys_id
0071 ... interrupt_pin
0072 ... <Symlink EPF Device 31>/
0073 ... primary/
0074 ... <Symlink EPC Device1>/
0075 ... secondary/
0076 ... <Symlink EPC Device2>/
0077
0078 If an EPF device has to be associated with 2 EPCs (like in the case of
0079 Non-transparent bridge), symlink of endpoint controller connected to primary
0080 interface should be added in 'primary' directory and symlink of endpoint
0081 controller connected to secondary interface should be added in 'secondary'
0082 directory.
0083
0084 The <EPF Device> directory can have a list of symbolic links
0085 (<Symlink EPF Device 31>) to other <EPF Device>. These symbolic links should
0086 be created by the user to represent the virtual functions that are bound to
0087 the physical function. In the above directory structure <EPF Device 11> is a
0088 physical function and <EPF Device 31> is a virtual function. An EPF device once
0089 it's linked to another EPF device, cannot be linked to a EPC device.
0090
0091 EPC Device
0092 ==========
0093
0094 Every registered EPC device will be listed in controllers directory. The
0095 entries corresponding to EPC device will be created by the EPC core.
0096 ::
0097
0098 /sys/kernel/config/pci_ep/controllers/
0099 .. <EPC Device1>/
0100 ... <Symlink EPF Device11>/
0101 ... <Symlink EPF Device12>/
0102 ... start
0103 .. <EPC Device2>/
0104 ... <Symlink EPF Device21>/
0105 ... <Symlink EPF Device22>/
0106 ... start
0107
0108 The <EPC Device> directory will have a list of symbolic links to
0109 <EPF Device>. These symbolic links should be created by the user to
0110 represent the functions present in the endpoint device. Only <EPF Device>
0111 that represents a physical function can be linked to a EPC device.
0112
0113 The <EPC Device> directory will also have a *start* field. Once
0114 "1" is written to this field, the endpoint device will be ready to
0115 establish the link with the host. This is usually done after
0116 all the EPF devices are created and linked with the EPC device.
0117 ::
0118
0119 | controllers/
0120 | <Directory: EPC name>/
0121 | <Symbolic Link: Function>
0122 | start
0123 | functions/
0124 | <Directory: EPF driver>/
0125 | <Directory: EPF device>/
0126 | vendorid
0127 | deviceid
0128 | revid
0129 | progif_code
0130 | subclass_code
0131 | baseclass_code
0132 | cache_line_size
0133 | subsys_vendor_id
0134 | subsys_id
0135 | interrupt_pin
0136 | function
0137
0138 [1] Documentation/PCI/endpoint/pci-endpoint.rst