1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-or-later */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com> 4*4882a593Smuzhiyun <http://rt2x00.serialmonkey.com> 5*4882a593Smuzhiyun 6*4882a593Smuzhiyun */ 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun /* 9*4882a593Smuzhiyun Module: rt2x00dump 10*4882a593Smuzhiyun Abstract: 11*4882a593Smuzhiyun Data structures for the rt2x00debug & userspace. 12*4882a593Smuzhiyun 13*4882a593Smuzhiyun The declarations in this file can be used by both rt2x00 14*4882a593Smuzhiyun and userspace and therefore should be kept together in 15*4882a593Smuzhiyun this file. 16*4882a593Smuzhiyun */ 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun #ifndef RT2X00DUMP_H 19*4882a593Smuzhiyun #define RT2X00DUMP_H 20*4882a593Smuzhiyun 21*4882a593Smuzhiyun /** 22*4882a593Smuzhiyun * DOC: Introduction 23*4882a593Smuzhiyun * 24*4882a593Smuzhiyun * This header is intended to be exported to userspace, 25*4882a593Smuzhiyun * to make the structures and enumerations available to userspace 26*4882a593Smuzhiyun * applications. This means that all data types should be exportable. 27*4882a593Smuzhiyun * 28*4882a593Smuzhiyun * When rt2x00 is compiled with debugfs support enabled, 29*4882a593Smuzhiyun * it is possible to capture all data coming in and out of the device 30*4882a593Smuzhiyun * by reading the frame dump file. This file can have only a single reader. 31*4882a593Smuzhiyun * The following frames will be reported: 32*4882a593Smuzhiyun * - All incoming frames (rx) 33*4882a593Smuzhiyun * - All outgoing frames (tx, including beacon and atim) 34*4882a593Smuzhiyun * - All completed frames (txdone including atim) 35*4882a593Smuzhiyun * 36*4882a593Smuzhiyun * The data is send to the file using the following format: 37*4882a593Smuzhiyun * 38*4882a593Smuzhiyun * [rt2x00dump header][hardware descriptor][ieee802.11 frame] 39*4882a593Smuzhiyun * 40*4882a593Smuzhiyun * rt2x00dump header: The description of the dumped frame, as well as 41*4882a593Smuzhiyun * additional information useful for debugging. See &rt2x00dump_hdr. 42*4882a593Smuzhiyun * hardware descriptor: Descriptor that was used to receive or transmit 43*4882a593Smuzhiyun * the frame. 44*4882a593Smuzhiyun * ieee802.11 frame: The actual frame that was received or transmitted. 45*4882a593Smuzhiyun */ 46*4882a593Smuzhiyun 47*4882a593Smuzhiyun /** 48*4882a593Smuzhiyun * enum rt2x00_dump_type - Frame type 49*4882a593Smuzhiyun * 50*4882a593Smuzhiyun * These values are used for the @type member of &rt2x00dump_hdr. 51*4882a593Smuzhiyun * @DUMP_FRAME_RXDONE: This frame has been received by the hardware. 52*4882a593Smuzhiyun * @DUMP_FRAME_TX: This frame is queued for transmission to the hardware. 53*4882a593Smuzhiyun * @DUMP_FRAME_TXDONE: This frame indicates the device has handled 54*4882a593Smuzhiyun * the tx event which has either succeeded or failed. A frame 55*4882a593Smuzhiyun * with this type should also have been reported with as a 56*4882a593Smuzhiyun * %DUMP_FRAME_TX frame. 57*4882a593Smuzhiyun * @DUMP_FRAME_BEACON: This beacon frame is queued for transmission to the 58*4882a593Smuzhiyun * hardware. 59*4882a593Smuzhiyun */ 60*4882a593Smuzhiyun enum rt2x00_dump_type { 61*4882a593Smuzhiyun DUMP_FRAME_RXDONE = 1, 62*4882a593Smuzhiyun DUMP_FRAME_TX = 2, 63*4882a593Smuzhiyun DUMP_FRAME_TXDONE = 3, 64*4882a593Smuzhiyun DUMP_FRAME_BEACON = 4, 65*4882a593Smuzhiyun }; 66*4882a593Smuzhiyun 67*4882a593Smuzhiyun /** 68*4882a593Smuzhiyun * struct rt2x00dump_hdr - Dump frame header 69*4882a593Smuzhiyun * 70*4882a593Smuzhiyun * Each frame dumped to the debugfs file starts with this header 71*4882a593Smuzhiyun * attached. This header contains the description of the actual 72*4882a593Smuzhiyun * frame which was dumped. 73*4882a593Smuzhiyun * 74*4882a593Smuzhiyun * New fields inside the structure must be appended to the end of 75*4882a593Smuzhiyun * the structure. This way userspace tools compiled for earlier 76*4882a593Smuzhiyun * header versions can still correctly handle the frame dump 77*4882a593Smuzhiyun * (although they will not handle all data passed to them in the dump). 78*4882a593Smuzhiyun * 79*4882a593Smuzhiyun * @version: Header version should always be set to %DUMP_HEADER_VERSION. 80*4882a593Smuzhiyun * This field must be checked by userspace to determine if it can 81*4882a593Smuzhiyun * handle this frame. 82*4882a593Smuzhiyun * @header_length: The length of the &rt2x00dump_hdr structure. This is 83*4882a593Smuzhiyun * used for compatibility reasons so userspace can easily determine 84*4882a593Smuzhiyun * the location of the next field in the dump. 85*4882a593Smuzhiyun * @desc_length: The length of the device descriptor. 86*4882a593Smuzhiyun * @data_length: The length of the frame data (including the ieee802.11 header. 87*4882a593Smuzhiyun * @chip_rt: RT chipset 88*4882a593Smuzhiyun * @chip_rf: RF chipset 89*4882a593Smuzhiyun * @chip_rev: Chipset revision 90*4882a593Smuzhiyun * @type: The frame type (&rt2x00_dump_type) 91*4882a593Smuzhiyun * @queue_index: The index number of the data queue. 92*4882a593Smuzhiyun * @entry_index: The index number of the entry inside the data queue. 93*4882a593Smuzhiyun * @timestamp_sec: Timestamp - seconds 94*4882a593Smuzhiyun * @timestamp_usec: Timestamp - microseconds 95*4882a593Smuzhiyun */ 96*4882a593Smuzhiyun struct rt2x00dump_hdr { 97*4882a593Smuzhiyun __le32 version; 98*4882a593Smuzhiyun #define DUMP_HEADER_VERSION 3 99*4882a593Smuzhiyun 100*4882a593Smuzhiyun __le32 header_length; 101*4882a593Smuzhiyun __le32 desc_length; 102*4882a593Smuzhiyun __le32 data_length; 103*4882a593Smuzhiyun 104*4882a593Smuzhiyun __le16 chip_rt; 105*4882a593Smuzhiyun __le16 chip_rf; 106*4882a593Smuzhiyun __le16 chip_rev; 107*4882a593Smuzhiyun 108*4882a593Smuzhiyun __le16 type; 109*4882a593Smuzhiyun __u8 queue_index; 110*4882a593Smuzhiyun __u8 entry_index; 111*4882a593Smuzhiyun 112*4882a593Smuzhiyun __le32 timestamp_sec; 113*4882a593Smuzhiyun __le32 timestamp_usec; 114*4882a593Smuzhiyun }; 115*4882a593Smuzhiyun 116*4882a593Smuzhiyun #endif /* RT2X00DUMP_H */ 117