pci-endpoint-cfs.rst 4.3 KB

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