History

firewire: cdev: add new event to notify request subaction with time stamp

This commit adds new event to notify event of request subaction with time stamp field. Current compiler implementation of System V ABI selects one of structure members which has the maximum alignment size in the structure to decide the size of structure. In the case of fw_cdev_event_request3 structure, it is closure member which has 8 byte storage. The size of alignment for the type of 8 byte storage differs depending on architectures; 4 byte for i386 architecture and 8 byte for the others including x32 architecture. It is inconvenient to device driver developer to use structure layout which varies between architectures since the developer takes care of ioctl compat layer. This commit adds 32 bit member for padding to keep the size of structure as multiples of 8.

Takashi Sakamoto committed 3 years ago

Commit 7c22d4a1 parent 6add87e2 files · +71 −2Browse files

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

Unified · Split

include/uapi/linux/firewire-cdev.h+51−2
@@ -46,6 +46,9 @@ · 45 unmodified lines
46#define FW_CDEV_EVENT_PHY_PACKET_RECEIVED 0x0846#define FW_CDEV_EVENT_PHY_PACKET_RECEIVED 0x08
47#define FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL 0x0947#define FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL 0x09
48 48
49/* available since kernel version 6.5 */
50#define FW_CDEV_EVENT_REQUEST3 0x0a
51
49/**52/**
50 * struct fw_cdev_event_common - Common part of all fw_cdev_event_* types53 * struct fw_cdev_event_common - Common part of all fw_cdev_event_* types
51 * @closure: For arbitrary use by userspace54 * @closure: For arbitrary use by userspace
@@ -159,6 +162,38 @@ struct fw_cdev_event_request { · 107 unmodified lines
159 * @length: Data length, i.e. the request's payload size in bytes162 * @length: Data length, i.e. the request's payload size in bytes
160 * @data: Incoming data, if any163 * @data: Incoming data, if any
161 *164 *
165 * This event is sent instead of &fw_cdev_event_request3 if the kernel or the client implements
166 * ABI version <= 5. It has the lack of time stamp field comparing to &fw_cdev_event_request3.
167 */
168struct fw_cdev_event_request2 {
169 __u64 closure;
170 __u32 type;
171 __u32 tcode;
172 __u64 offset;
173 __u32 source_node_id;
174 __u32 destination_node_id;
175 __u32 card;
176 __u32 generation;
177 __u32 handle;
178 __u32 length;
179 __u32 data[];
180};
181
182/**
183 * struct fw_cdev_event_request3 - Sent on incoming request to an address region
184 * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_ALLOCATE ioctl
185 * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_REQUEST2
186 * @tcode: Transaction code of the incoming request
187 * @offset: The offset into the 48-bit per-node address space
188 * @source_node_id: Sender node ID
189 * @destination_node_id: Destination node ID
190 * @card: The index of the card from which the request came
191 * @generation: Bus generation in which the request is valid
192 * @handle: Reference to the kernel-side pending request
193 * @length: Data length, i.e. the request's payload size in bytes
194 * @tstamp: The time stamp of isochronous cycle at which the request arrived.
195 * @data: Incoming data, if any
196 *
162 * This event is sent when the stack receives an incoming request to an address197 * This event is sent when the stack receives an incoming request to an address
163 * region registered using the %FW_CDEV_IOC_ALLOCATE ioctl. The request is198 * region registered using the %FW_CDEV_IOC_ALLOCATE ioctl. The request is
164 * guaranteed to be completely contained in the specified region. Userspace is199 * guaranteed to be completely contained in the specified region. Userspace is
@@ -191,10 +226,14 @@ struct fw_cdev_event_request { · 26 unmodified lines
191 * sent.226 * sent.
192 *227 *
193 * If the client subsequently needs to initiate requests to the sender node of228 * If the client subsequently needs to initiate requests to the sender node of
194 * an &fw_cdev_event_request2, it needs to use a device file with matching229 * an &fw_cdev_event_request3, it needs to use a device file with matching
195 * card index, node ID, and generation for outbound requests.230 * card index, node ID, and generation for outbound requests.
231 *
232 * @tstamp is isochronous cycle at which the request arrived. It is 16 bit integer value and the
233 * higher 3 bits expresses three low order bits of second field in the format of CYCLE_TIME
234 * register and the rest 13 bits expresses cycle field.
196 */235 */
197struct fw_cdev_event_request2 {236struct fw_cdev_event_request3 {
198 __u64 closure;237 __u64 closure;
199 __u32 type;238 __u32 type;
200 __u32 tcode;239 __u32 tcode;
@@ -205,6 +244,12 @@ struct fw_cdev_event_request2 { · 4 unmodified lines
205 __u32 generation;244 __u32 generation;
206 __u32 handle;245 __u32 handle;
207 __u32 length;246 __u32 length;
247 __u32 tstamp;
248 /*
249 * Padding to keep the size of structure as multiples of 8 in various architectures since
250 * 4 byte alignment is used for 8 byte of object type in System V ABI for i386 architecture.
251 */
252 __u32 padding;
208 __u32 data[];253 __u32 data[];
209};254};
210 255
@@ -375,6 +420,8 @@ struct fw_cdev_event_phy_packet { · 164 unmodified lines
375 * %FW_CDEV_EVENT_PHY_PACKET_SENT or420 * %FW_CDEV_EVENT_PHY_PACKET_SENT or
376 * %FW_CDEV_EVENT_PHY_PACKET_RECEIVED421 * %FW_CDEV_EVENT_PHY_PACKET_RECEIVED
377 *422 *
423 * @request3: Valid if @common.type == %FW_CDEV_EVENT_REQUEST3
424 *
378 * Convenience union for userspace use. Events could be read(2) into an425 * Convenience union for userspace use. Events could be read(2) into an
379 * appropriately aligned char buffer and then cast to this union for further426 * appropriately aligned char buffer and then cast to this union for further
380 * processing. Note that for a request, response or iso_interrupt event,427 * processing. Note that for a request, response or iso_interrupt event,
@@ -393,6 +440,7 @@ union fw_cdev_event { · 12 unmodified lines
393 struct fw_cdev_event_iso_interrupt_mc iso_interrupt_mc; /* added in 2.6.36 */440 struct fw_cdev_event_iso_interrupt_mc iso_interrupt_mc; /* added in 2.6.36 */
394 struct fw_cdev_event_iso_resource iso_resource; /* added in 2.6.30 */441 struct fw_cdev_event_iso_resource iso_resource; /* added in 2.6.30 */
395 struct fw_cdev_event_phy_packet phy_packet; /* added in 2.6.36 */442 struct fw_cdev_event_phy_packet phy_packet; /* added in 2.6.36 */
443 struct fw_cdev_event_request3 request3; /* added in 6.5 */
396};444};
397 445
398/* available since kernel version 2.6.22 */446/* available since kernel version 2.6.22 */
@@ -458,6 +506,7 @@ union fw_cdev_event { · 59 unmodified lines
458 * avoid dropping data506 * avoid dropping data
459 * - added %FW_CDEV_IOC_FLUSH_ISO507 * - added %FW_CDEV_IOC_FLUSH_ISO
460 * 6 (6.5) - added some event for subactions of asynchronous transaction with time stamp508 * 6 (6.5) - added some event for subactions of asynchronous transaction with time stamp
509 * - %FW_CDEV_EVENT_REQUEST3
461 */510 */
462 511
463/**512/**

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