switchtec: Add IOCTLs to the Switchtec driver

Add a couple of special IOCTLs to:

* Inform userspace of firmware partition locations
* Pass event counts and allow userspace to wait on events
* Translate PFF numbers used by the switch to port numbers

[Dan Carpenter <[email protected]>: fix off-by-one in
ioctl_event_ctl()]
Tested-by: Krishna Dhulipala <[email protected]>
Signed-off-by: Logan Gunthorpe <[email protected]>
Signed-off-by: Stephen Bates <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Reviewed-by: Wei Zhang <[email protected]>
Reviewed-by: Jens Axboe <[email protected]>
This commit is contained in:
Logan Gunthorpe 2017-03-02 16:24:34 -07:00 • committed by Bjorn Helgaas
commit 52eabba5bc
5 changed files with 642 additions and 0 deletions

View file

@ -51,3 +51,30 @@ The char device has the following semantics:
* The poll call will also be supported for userspace applications that
need to do other things while waiting for the command to complete.
The following IOCTLs are also supported by the device:
* SWITCHTEC_IOCTL_FLASH_INFO - Retrieve firmware length and number
of partitions in the device.
* SWITCHTEC_IOCTL_FLASH_PART_INFO - Retrieve address and lengeth for
any specified partition in flash.
* SWITCHTEC_IOCTL_EVENT_SUMMARY - Read a structure of bitmaps
indicating all uncleared events.
* SWITCHTEC_IOCTL_EVENT_CTL - Get the current count, clear and set flags
for any event. This ioctl takes in a switchtec_ioctl_event_ctl struct
with the event_id, index and flags set (index being the partition or PFF
number for non-global events). It returns whether the event has
occurred, the number of times and any event specific data. The flags
can be used to clear the count or enable and disable actions to
happen when the event occurs.
By using the SWITCHTEC_IOCTL_EVENT_FLAG_EN_POLL flag,
you can set an event to trigger a poll command to return with
POLLPRI. In this way, userspace can wait for events to occur.
* SWITCHTEC_IOCTL_PFF_TO_PORT and SWITCHTEC_IOCTL_PORT_TO_PFF convert
between PCI Function Framework number (used by the event system)
and Switchtec Logic Port ID and Partition number (which is more
user friendly).