xref: /wlan-driver/fw-api/fw/epping_test.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2012 The Linux Foundation. All rights reserved.
3  *
4  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5  *
6  *
7  * Permission to use, copy, modify, and/or distribute this software for
8  * any purpose with or without fee is hereby granted, provided that the
9  * above copyright notice and this permission notice appear in all
10  * copies.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19  * PERFORMANCE OF THIS SOFTWARE.
20  */
21 
22 /*
23  * This file was originally distributed by Qualcomm Atheros, Inc.
24  * under proprietary terms before Copyright ownership was assigned
25  * to the Linux Foundation.
26  */
27 
28 /* This file contains shared definitions for the host/target endpoint ping test */
29 
30 #ifndef EPPING_TEST_H_
31 #define EPPING_TEST_H_
32 
33 #ifndef ATH_TARGET
34 #include "athstartpack.h"
35 #endif
36 
37 /* enable EPPING_TEST macro to enable endpoint ping */
38 //#define EPPING_TEST
39 extern unsigned int eppingtest;
40 extern unsigned int bypasswmi;
41 
42     /* alignment to 4-bytes */
43 #define EPPING_ALIGNMENT_PAD  (((sizeof(HTC_FRAME_HDR) + 3) & (~0x3)) - sizeof(HTC_FRAME_HDR))
44 
45 #ifndef A_OFFSETOF
46 #define A_OFFSETOF(type,field) (int)(&(((type *)NULL)->field))
47 #endif
48 
49 #define EPPING_RSVD_FILL                  0xCC
50 
51 #define HCI_RSVD_EXPECTED_PKT_TYPE_RECV_OFFSET  7
52 
53 typedef PREPACK struct {
54     A_UINT8     _HCIRsvd[8];           /* reserved for HCI packet header (GMBOX) testing */
55     A_UINT8     StreamEcho_h;          /* stream no. to echo this packet on (filled by host) */
56     A_UINT8     StreamEchoSent_t;      /* stream no. packet was echoed to (filled by target)
57                                           When echoed: StreamEchoSent_t == StreamEcho_h */
58     A_UINT8     StreamRecv_t;          /* stream no. that target received this packet on (filled by target) */
59     A_UINT8     StreamNo_h;            /* stream number to send on (filled by host) */
60     A_UINT8     Magic_h[4];            /* magic number to filter for this packet on the host*/
61     A_UINT8     _rsvd[6];              /* reserved fields that must be set to a "reserved" value
62                                           since this packet maps to a 14-byte ethernet frame we want
63                                           to make sure ethertype field is set to something unknown */
64 
65     A_UINT8     _pad[2];               /* padding for alignment */
66     A_UINT8     TimeStamp[8];          /* timestamp of packet (host or target) */
67     A_UINT32    HostContext_h;         /* 4 byte host context, target echos this back */
68     A_UINT32    SeqNo;                 /* sequence number (set by host or target) */
69     A_UINT16    Cmd_h;                 /* ping command (filled by host) */
70     A_UINT16    CmdFlags_h;            /* optional flags */
71     A_UINT8     CmdBuffer_h[8];        /* buffer for command (host -> target) */
72     A_UINT8     CmdBuffer_t[8];        /* buffer for command (target -> host) */
73     A_UINT16    DataLength;            /* length of data */
74     A_UINT16    DataCRC;               /* 16 bit CRC of data */
75     A_UINT16    HeaderCRC;             /* header CRC (fields : StreamNo_h to end, minus HeaderCRC) */
76 } POSTPACK EPPING_HEADER;
77 
78 #define EPPING_PING_MAGIC_0               0xAA
79 #define EPPING_PING_MAGIC_1               0x55
80 #define EPPING_PING_MAGIC_2               0xCE
81 #define EPPING_PING_MAGIC_3               0xEC
82 
83 
84 
85 #define IS_EPPING_PACKET(pPkt)   (((pPkt)->Magic_h[0] == EPPING_PING_MAGIC_0) && \
86                                   ((pPkt)->Magic_h[1] == EPPING_PING_MAGIC_1) && \
87                                   ((pPkt)->Magic_h[2] == EPPING_PING_MAGIC_2) && \
88                                   ((pPkt)->Magic_h[3] == EPPING_PING_MAGIC_3))
89 
90 #define SET_EPPING_PACKET_MAGIC(pPkt) { (pPkt)->Magic_h[0] = EPPING_PING_MAGIC_0; \
91                                         (pPkt)->Magic_h[1] = EPPING_PING_MAGIC_1; \
92                                         (pPkt)->Magic_h[2] = EPPING_PING_MAGIC_2; \
93                                         (pPkt)->Magic_h[3] = EPPING_PING_MAGIC_3;}
94 
95 #define CMD_FLAGS_DATA_CRC            (1 << 0)  /* DataCRC field is valid */
96 #define CMD_FLAGS_DELAY_ECHO          (1 << 1)  /* delay the echo of the packet */
97 #define CMD_FLAGS_NO_DROP             (1 << 2)  /* do not drop at HTC layer no matter what the stream is */
98 
99 #define IS_EPING_PACKET_NO_DROP(pPkt)  ((pPkt)->CmdFlags_h & CMD_FLAGS_NO_DROP)
100 
101 #define EPPING_CMD_ECHO_PACKET          1   /* echo packet test */
102 #define EPPING_CMD_RESET_RECV_CNT       2   /* reset recv count */
103 #define EPPING_CMD_CAPTURE_RECV_CNT     3   /* fetch recv count, 4-byte count returned in CmdBuffer_t */
104 #define EPPING_CMD_NO_ECHO              4   /* non-echo packet test (tx-only) */
105 #define EPPING_CMD_CONT_RX_START        5   /* continous RX packets, parameters are in CmdBuffer_h */
106 #define EPPING_CMD_CONT_RX_STOP         6   /* stop continuous RX packet transmission */
107 
108     /* test command parameters may be no more than 8 bytes */
109 typedef PREPACK struct {
110     A_UINT16  BurstCnt;       /* number of packets to burst together (for HTC 2.1 testing) */
111     A_UINT16  PacketLength;   /* length of packet to generate including header */
112     A_UINT16  Flags;          /* flags */
113 
114 #define EPPING_CONT_RX_DATA_CRC     (1 << 0)  /* Add CRC to all data */
115 #define EPPING_CONT_RX_RANDOM_DATA  (1 << 1)  /* randomize the data pattern */
116 #define EPPING_CONT_RX_RANDOM_LEN   (1 << 2)  /* randomize the packet lengths */
117 #define EPPING_CONT_RX_NO_DATA_FILL (1 << 3)  /* target will not fill buffers */
118     A_UINT16  Context;        /* flags */
119 
120 } POSTPACK EPPING_CONT_RX_PARAMS;
121 
122 #define EPPING_HDR_CRC_OFFSET    A_OFFSETOF(EPPING_HEADER,StreamNo_h)
123 #define EPPING_HDR_BYTES_CRC     (sizeof(EPPING_HEADER) - EPPING_HDR_CRC_OFFSET - (sizeof(A_UINT16)))
124 
125 #define HCI_TRANSPORT_STREAM_NUM  16  /* this number is higher than the define WMM AC classes so we
126                                          can use this to distinguish packets */
127 
128 #ifndef ATH_TARGET
129 #include "athendpack.h"
130 #endif
131 
132 
133 #endif /*EPPING_TEST_H_*/
134