switchtec.rst 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. ========================
  2. Linux Switchtec Support
  3. ========================
  4. Microsemi's "Switchtec" line of PCI switch devices is already
  5. supported by the kernel with standard PCI switch drivers. However, the
  6. Switchtec device advertises a special management endpoint which
  7. enables some additional functionality. This includes:
  8. * Packet and Byte Counters
  9. * Firmware Upgrades
  10. * Event and Error logs
  11. * Querying port link status
  12. * Custom user firmware commands
  13. The switchtec kernel module implements this functionality.
  14. Interface
  15. =========
  16. The primary means of communicating with the Switchtec management firmware is
  17. through the Memory-mapped Remote Procedure Call (MRPC) interface.
  18. Commands are submitted to the interface with a 4-byte command
  19. identifier and up to 1KB of command specific data. The firmware will
  20. respond with a 4-byte return code and up to 1KB of command-specific
  21. data. The interface only processes a single command at a time.
  22. Userspace Interface
  23. ===================
  24. The MRPC interface will be exposed to userspace through a simple char
  25. device: /dev/switchtec#, one for each management endpoint in the system.
  26. The char device has the following semantics:
  27. * A write must consist of at least 4 bytes and no more than 1028 bytes.
  28. The first 4 bytes will be interpreted as the Command ID and the
  29. remainder will be used as the input data. A write will send the
  30. command to the firmware to begin processing.
  31. * Each write must be followed by exactly one read. Any double write will
  32. produce an error and any read that doesn't follow a write will
  33. produce an error.
  34. * A read will block until the firmware completes the command and return
  35. the 4-byte Command Return Value plus up to 1024 bytes of output
  36. data. (The length will be specified by the size parameter of the read
  37. call -- reading less than 4 bytes will produce an error.)
  38. * The poll call will also be supported for userspace applications that
  39. need to do other things while waiting for the command to complete.
  40. The following IOCTLs are also supported by the device:
  41. * SWITCHTEC_IOCTL_FLASH_INFO - Retrieve firmware length and number
  42. of partitions in the device.
  43. * SWITCHTEC_IOCTL_FLASH_PART_INFO - Retrieve address and lengeth for
  44. any specified partition in flash.
  45. * SWITCHTEC_IOCTL_EVENT_SUMMARY - Read a structure of bitmaps
  46. indicating all uncleared events.
  47. * SWITCHTEC_IOCTL_EVENT_CTL - Get the current count, clear and set flags
  48. for any event. This ioctl takes in a switchtec_ioctl_event_ctl struct
  49. with the event_id, index and flags set (index being the partition or PFF
  50. number for non-global events). It returns whether the event has
  51. occurred, the number of times and any event specific data. The flags
  52. can be used to clear the count or enable and disable actions to
  53. happen when the event occurs.
  54. By using the SWITCHTEC_IOCTL_EVENT_FLAG_EN_POLL flag,
  55. you can set an event to trigger a poll command to return with
  56. POLLPRI. In this way, userspace can wait for events to occur.
  57. * SWITCHTEC_IOCTL_PFF_TO_PORT and SWITCHTEC_IOCTL_PORT_TO_PFF convert
  58. between PCI Function Framework number (used by the event system)
  59. and Switchtec Logic Port ID and Partition number (which is more
  60. user friendly).
  61. Non-Transparent Bridge (NTB) Driver
  62. ===================================
  63. An NTB hardware driver is provided for the Switchtec hardware in
  64. ntb_hw_switchtec. Currently, it only supports switches configured with
  65. exactly 2 NT partitions and zero or more non-NT partitions. It also requires
  66. the following configuration settings:
  67. * Both NT partitions must be able to access each other's GAS spaces.
  68. Thus, the bits in the GAS Access Vector under Management Settings
  69. must be set to support this.
  70. * Kernel configuration MUST include support for NTB (CONFIG_NTB needs
  71. to be set)
  72. NT EP BAR 2 will be dynamically configured as a Direct Window, and
  73. the configuration file does not need to configure it explicitly.
  74. Please refer to Documentation/driver-api/ntb.rst in Linux source tree for an overall
  75. understanding of the Linux NTB stack. ntb_hw_switchtec works as an NTB
  76. Hardware Driver in this stack.