History

cxl: Add mechanism for delivering AFU driver specific events

This adds an afu_driver_ops structure with fetch_event() and event_delivered() callbacks. An AFU driver such as cxlflash can fill this out and associate it with a context to enable passing custom AFU specific events to userspace. This also adds a new kernel API function cxl_context_pending_events(), that the AFU driver can use to notify the cxl driver that new specific events are ready to be delivered, and wake up anyone waiting on the context wait queue. The current count of AFU driver specific events is stored in the field afu_driver_events of the context structure. The cxl driver checks the afu_driver_events count during poll, select, read, etc. calls to check if an AFU driver specific event is pending, and calls fetch_event() to obtain and deliver that event. This way, the cxl driver takes care of all the usual locking semantics around these calls and handles all the generic cxl events, so that the AFU driver only needs to worry about it's own events. fetch_event() return a struct cxl_event_afu_driver_reserved, allocated by the AFU driver, and filled in with the specific event information and size. Total event size (header + data) should not be greater than CXL_READ_MIN_SIZE (4K). Th cxl driver prepends an appropriate cxl event header, copies the event to userspace, and finally calls event_delivered() to return the status of the operation to the AFU driver. The event is identified by the context and cxl_event_afu_driver_reserved pointers. Since AFU drivers provide their own means for userspace to obtain the AFU file descriptor (i.e. cxlflash uses an ioctl on their scsi file descriptor to obtain the AFU file descriptor) and the generic cxl driver will never use this event, the ABI of the event is up to each individual AFU driver.

Philippe Bergheaud committed 10 years ago

Commit b8102531 parent 6e8a9276 files · +149 −9Browse files

Showing the changes to include/uapi (1 of 6 files). Show all

Unified · Split

include/uapi/misc/cxl.h+17−0
@@ -93,6 +93,7 @@ enum cxl_event_type { · 92 unmodified lines
9393 CXL_EVENT_AFU_INTERRUPT = 1,
9494 CXL_EVENT_DATA_STORAGE = 2,
9595 CXL_EVENT_AFU_ERROR = 3,
96+ CXL_EVENT_AFU_DRIVER = 4,
9697 };
9798
9899 struct cxl_event_header {
@@ -124,12 +125,28 @@ struct cxl_event_afu_error { · 25 unmodified lines
124125 __u64 error;
125126 };
126127
128+struct cxl_event_afu_driver_reserved {
129+ /*
130+ * Defines the buffer passed to the cxl driver by the AFU driver.
131+ *
132+ * This is not ABI since the event header.size passed to the user for
133+ * existing events is set in the read call to sizeof(cxl_event_header)
134+ * + sizeof(whatever event is being dispatched) and the user is already
135+ * required to use a 4K buffer on the read call.
136+ *
137+ * Of course the contents will be ABI, but that's up the AFU driver.
138+ */
139+ size_t data_size;
140+ u8 data[];
141+};
142+
127143 struct cxl_event {
128144 struct cxl_event_header header;
129145 union {
130146 struct cxl_event_afu_interrupt irq;
131147 struct cxl_event_data_storage fault;
132148 struct cxl_event_afu_error afu_error;
149+ struct cxl_event_afu_driver_reserved afu_driver_event;
133150 };
134151 };
135152

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t