1*1ccea77eSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */ 233aca94dSKalle Valo /* 333aca94dSKalle Valo Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com> 433aca94dSKalle Valo <http://rt2x00.serialmonkey.com> 533aca94dSKalle Valo 633aca94dSKalle Valo */ 733aca94dSKalle Valo 833aca94dSKalle Valo /* 933aca94dSKalle Valo Module: rt2x00dump 1033aca94dSKalle Valo Abstract: 1133aca94dSKalle Valo Data structures for the rt2x00debug & userspace. 1233aca94dSKalle Valo 1333aca94dSKalle Valo The declarations in this file can be used by both rt2x00 1433aca94dSKalle Valo and userspace and therefore should be kept together in 1533aca94dSKalle Valo this file. 1633aca94dSKalle Valo */ 1733aca94dSKalle Valo 1833aca94dSKalle Valo #ifndef RT2X00DUMP_H 1933aca94dSKalle Valo #define RT2X00DUMP_H 2033aca94dSKalle Valo 2133aca94dSKalle Valo /** 2233aca94dSKalle Valo * DOC: Introduction 2333aca94dSKalle Valo * 2433aca94dSKalle Valo * This header is intended to be exported to userspace, 2533aca94dSKalle Valo * to make the structures and enumerations available to userspace 2633aca94dSKalle Valo * applications. This means that all data types should be exportable. 2733aca94dSKalle Valo * 2833aca94dSKalle Valo * When rt2x00 is compiled with debugfs support enabled, 2933aca94dSKalle Valo * it is possible to capture all data coming in and out of the device 3033aca94dSKalle Valo * by reading the frame dump file. This file can have only a single reader. 3133aca94dSKalle Valo * The following frames will be reported: 3233aca94dSKalle Valo * - All incoming frames (rx) 3333aca94dSKalle Valo * - All outgoing frames (tx, including beacon and atim) 3433aca94dSKalle Valo * - All completed frames (txdone including atim) 3533aca94dSKalle Valo * 3633aca94dSKalle Valo * The data is send to the file using the following format: 3733aca94dSKalle Valo * 3833aca94dSKalle Valo * [rt2x00dump header][hardware descriptor][ieee802.11 frame] 3933aca94dSKalle Valo * 4033aca94dSKalle Valo * rt2x00dump header: The description of the dumped frame, as well as 4133aca94dSKalle Valo * additional information useful for debugging. See &rt2x00dump_hdr. 4233aca94dSKalle Valo * hardware descriptor: Descriptor that was used to receive or transmit 4333aca94dSKalle Valo * the frame. 4433aca94dSKalle Valo * ieee802.11 frame: The actual frame that was received or transmitted. 4533aca94dSKalle Valo */ 4633aca94dSKalle Valo 4733aca94dSKalle Valo /** 4833aca94dSKalle Valo * enum rt2x00_dump_type - Frame type 4933aca94dSKalle Valo * 5033aca94dSKalle Valo * These values are used for the @type member of &rt2x00dump_hdr. 5133aca94dSKalle Valo * @DUMP_FRAME_RXDONE: This frame has been received by the hardware. 5233aca94dSKalle Valo * @DUMP_FRAME_TX: This frame is queued for transmission to the hardware. 5333aca94dSKalle Valo * @DUMP_FRAME_TXDONE: This frame indicates the device has handled 5433aca94dSKalle Valo * the tx event which has either succeeded or failed. A frame 5533aca94dSKalle Valo * with this type should also have been reported with as a 5633aca94dSKalle Valo * %DUMP_FRAME_TX frame. 5733aca94dSKalle Valo * @DUMP_FRAME_BEACON: This beacon frame is queued for transmission to the 5833aca94dSKalle Valo * hardware. 5933aca94dSKalle Valo */ 6033aca94dSKalle Valo enum rt2x00_dump_type { 6133aca94dSKalle Valo DUMP_FRAME_RXDONE = 1, 6233aca94dSKalle Valo DUMP_FRAME_TX = 2, 6333aca94dSKalle Valo DUMP_FRAME_TXDONE = 3, 6433aca94dSKalle Valo DUMP_FRAME_BEACON = 4, 6533aca94dSKalle Valo }; 6633aca94dSKalle Valo 6733aca94dSKalle Valo /** 6833aca94dSKalle Valo * struct rt2x00dump_hdr - Dump frame header 6933aca94dSKalle Valo * 7033aca94dSKalle Valo * Each frame dumped to the debugfs file starts with this header 7133aca94dSKalle Valo * attached. This header contains the description of the actual 7233aca94dSKalle Valo * frame which was dumped. 7333aca94dSKalle Valo * 7433aca94dSKalle Valo * New fields inside the structure must be appended to the end of 7533aca94dSKalle Valo * the structure. This way userspace tools compiled for earlier 7633aca94dSKalle Valo * header versions can still correctly handle the frame dump 7733aca94dSKalle Valo * (although they will not handle all data passed to them in the dump). 7833aca94dSKalle Valo * 7933aca94dSKalle Valo * @version: Header version should always be set to %DUMP_HEADER_VERSION. 8033aca94dSKalle Valo * This field must be checked by userspace to determine if it can 8133aca94dSKalle Valo * handle this frame. 8233aca94dSKalle Valo * @header_length: The length of the &rt2x00dump_hdr structure. This is 8333aca94dSKalle Valo * used for compatibility reasons so userspace can easily determine 8433aca94dSKalle Valo * the location of the next field in the dump. 8533aca94dSKalle Valo * @desc_length: The length of the device descriptor. 8633aca94dSKalle Valo * @data_length: The length of the frame data (including the ieee802.11 header. 8733aca94dSKalle Valo * @chip_rt: RT chipset 8833aca94dSKalle Valo * @chip_rf: RF chipset 8933aca94dSKalle Valo * @chip_rev: Chipset revision 9033aca94dSKalle Valo * @type: The frame type (&rt2x00_dump_type) 9133aca94dSKalle Valo * @queue_index: The index number of the data queue. 9233aca94dSKalle Valo * @entry_index: The index number of the entry inside the data queue. 9333aca94dSKalle Valo * @timestamp_sec: Timestamp - seconds 9433aca94dSKalle Valo * @timestamp_usec: Timestamp - microseconds 9533aca94dSKalle Valo */ 9633aca94dSKalle Valo struct rt2x00dump_hdr { 9733aca94dSKalle Valo __le32 version; 98f87eba99SArnd Bergmann #define DUMP_HEADER_VERSION 3 9933aca94dSKalle Valo 10033aca94dSKalle Valo __le32 header_length; 10133aca94dSKalle Valo __le32 desc_length; 10233aca94dSKalle Valo __le32 data_length; 10333aca94dSKalle Valo 10433aca94dSKalle Valo __le16 chip_rt; 10533aca94dSKalle Valo __le16 chip_rf; 10633aca94dSKalle Valo __le16 chip_rev; 10733aca94dSKalle Valo 10833aca94dSKalle Valo __le16 type; 10933aca94dSKalle Valo __u8 queue_index; 11033aca94dSKalle Valo __u8 entry_index; 11133aca94dSKalle Valo 11233aca94dSKalle Valo __le32 timestamp_sec; 11333aca94dSKalle Valo __le32 timestamp_usec; 11433aca94dSKalle Valo }; 11533aca94dSKalle Valo 11633aca94dSKalle Valo #endif /* RT2X00DUMP_H */ 117