103 lines · plain
1========================2Linux Switchtec Support3========================4 5Microsemi's "Switchtec" line of PCI switch devices is already6supported by the kernel with standard PCI switch drivers. However, the7Switchtec device advertises a special management endpoint which8enables some additional functionality. This includes:9 10* Packet and Byte Counters11* Firmware Upgrades12* Event and Error logs13* Querying port link status14* Custom user firmware commands15 16The switchtec kernel module implements this functionality.17 18 19Interface20=========21 22The primary means of communicating with the Switchtec management firmware is23through the Memory-mapped Remote Procedure Call (MRPC) interface.24Commands are submitted to the interface with a 4-byte command25identifier and up to 1KB of command specific data. The firmware will26respond with a 4-byte return code and up to 1KB of command-specific27data. The interface only processes a single command at a time.28 29 30Userspace Interface31===================32 33The MRPC interface will be exposed to userspace through a simple char34device: /dev/switchtec#, one for each management endpoint in the system.35 36The char device has the following semantics:37 38* A write must consist of at least 4 bytes and no more than 1028 bytes.39 The first 4 bytes will be interpreted as the Command ID and the40 remainder will be used as the input data. A write will send the41 command to the firmware to begin processing.42 43* Each write must be followed by exactly one read. Any double write will44 produce an error and any read that doesn't follow a write will45 produce an error.46 47* A read will block until the firmware completes the command and return48 the 4-byte Command Return Value plus up to 1024 bytes of output49 data. (The length will be specified by the size parameter of the read50 call -- reading less than 4 bytes will produce an error.)51 52* The poll call will also be supported for userspace applications that53 need to do other things while waiting for the command to complete.54 55The following IOCTLs are also supported by the device:56 57* SWITCHTEC_IOCTL_FLASH_INFO - Retrieve firmware length and number58 of partitions in the device.59 60* SWITCHTEC_IOCTL_FLASH_PART_INFO - Retrieve address and lengeth for61 any specified partition in flash.62 63* SWITCHTEC_IOCTL_EVENT_SUMMARY - Read a structure of bitmaps64 indicating all uncleared events.65 66* SWITCHTEC_IOCTL_EVENT_CTL - Get the current count, clear and set flags67 for any event. This ioctl takes in a switchtec_ioctl_event_ctl struct68 with the event_id, index and flags set (index being the partition or PFF69 number for non-global events). It returns whether the event has70 occurred, the number of times and any event specific data. The flags71 can be used to clear the count or enable and disable actions to72 happen when the event occurs.73 By using the SWITCHTEC_IOCTL_EVENT_FLAG_EN_POLL flag,74 you can set an event to trigger a poll command to return with75 POLLPRI. In this way, userspace can wait for events to occur.76 77* SWITCHTEC_IOCTL_PFF_TO_PORT and SWITCHTEC_IOCTL_PORT_TO_PFF convert78 between PCI Function Framework number (used by the event system)79 and Switchtec Logic Port ID and Partition number (which is more80 user friendly).81 82 83Non-Transparent Bridge (NTB) Driver84===================================85 86An NTB hardware driver is provided for the Switchtec hardware in87ntb_hw_switchtec. Currently, it only supports switches configured with88exactly 2 NT partitions and zero or more non-NT partitions. It also requires89the following configuration settings:90 91* Both NT partitions must be able to access each other's GAS spaces.92 Thus, the bits in the GAS Access Vector under Management Settings93 must be set to support this.94* Kernel configuration MUST include support for NTB (CONFIG_NTB needs95 to be set)96 97NT EP BAR 2 will be dynamically configured as a Direct Window, and98the configuration file does not need to configure it explicitly.99 100Please refer to Documentation/driver-api/ntb.rst in Linux source tree for an overall101understanding of the Linux NTB stack. ntb_hw_switchtec works as an NTB102Hardware Driver in this stack.103