^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) =======================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) Configuring PCI Endpoint Using CONFIGFS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) =======================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) :Author: Kishon Vijay Abraham I <kishon@ti.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) The PCI Endpoint Core exposes configfs entry (pci_ep) to configure the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) PCI endpoint function and to bind the endpoint function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) with the endpoint controller. (For introducing other mechanisms to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) configure the PCI Endpoint Function refer to [1]).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) Mounting configfs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) =================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) The PCI Endpoint Core layer creates pci_ep directory in the mounted configfs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) directory. configfs can be mounted using the following command::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) mount -t configfs none /sys/kernel/config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) Directory Structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) ===================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) The pci_ep configfs has two directories at its root: controllers and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) functions. Every EPC device present in the system will have an entry in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) the *controllers* directory and every EPF driver present in the system
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) will have an entry in the *functions* directory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) /sys/kernel/config/pci_ep/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) .. controllers/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) .. functions/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) Creating EPF Device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) ===================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) Every registered EPF driver will be listed in controllers directory. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) entries corresponding to EPF driver will be created by the EPF core.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) /sys/kernel/config/pci_ep/functions/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) .. <EPF Driver1>/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) ... <EPF Device 11>/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) ... <EPF Device 21>/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) .. <EPF Driver2>/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) ... <EPF Device 12>/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) ... <EPF Device 22>/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) In order to create a <EPF device> of the type probed by <EPF Driver>, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) user has to create a directory inside <EPF DriverN>.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) Every <EPF device> directory consists of the following entries that can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) used to configure the standard configuration header of the endpoint function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) (These entries are created by the framework when any new <EPF Device> is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) created)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) .. <EPF Driver1>/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) ... <EPF Device 11>/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) ... vendorid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) ... deviceid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) ... revid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) ... progif_code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) ... subclass_code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) ... baseclass_code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) ... cache_line_size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) ... subsys_vendor_id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) ... subsys_id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) ... interrupt_pin
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) EPC Device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) ==========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) Every registered EPC device will be listed in controllers directory. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) entries corresponding to EPC device will be created by the EPC core.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) /sys/kernel/config/pci_ep/controllers/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) .. <EPC Device1>/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) ... <Symlink EPF Device11>/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) ... <Symlink EPF Device12>/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) ... start
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) .. <EPC Device2>/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) ... <Symlink EPF Device21>/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) ... <Symlink EPF Device22>/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) ... start
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) The <EPC Device> directory will have a list of symbolic links to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) <EPF Device>. These symbolic links should be created by the user to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) represent the functions present in the endpoint device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) The <EPC Device> directory will also have a *start* field. Once
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) "1" is written to this field, the endpoint device will be ready to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) establish the link with the host. This is usually done after
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) all the EPF devices are created and linked with the EPC device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) | controllers/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) | <Directory: EPC name>/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) | <Symbolic Link: Function>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) | start
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) | functions/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) | <Directory: EPF driver>/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) | <Directory: EPF device>/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) | vendorid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) | deviceid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) | revid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) | progif_code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) | subclass_code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) | baseclass_code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) | cache_line_size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) | subsys_vendor_id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) | subsys_id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) | interrupt_pin
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) | function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) [1] :doc:`pci-endpoint`