blob: b8e6d01785c69c593aa644d86031abdb32f8de90 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
2 * Copyright (c) 2014 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 * This file was originally distributed by Qualcomm Atheros, Inc.
23 * under proprietary terms before Copyright ownership was assigned
24 * to the Linux Foundation.
25 */
26
27/* This file contains shared definitions for the host/target endpoint ping test */
28
29#ifndef EPPING_TEST_H
30#define EPPING_TEST_H
31
32#ifndef ATH_TARGET
33#include "athstartpack.h"
34#endif
35
36/* alignment to 4-bytes */
37#define EPPING_ALIGNMENT_PAD (((sizeof(HTC_FRAME_HDR) + 3) & (~0x3)) - sizeof(HTC_FRAME_HDR))
38
39#ifndef A_OFFSETOF
40#define A_OFFSETOF(type,field) (int)(&(((type *)NULL)->field))
41#endif
42
43#define EPPING_RSVD_FILL 0xCC
44
45#define HCI_RSVD_EXPECTED_PKT_TYPE_RECV_OFFSET 7
46
47typedef PREPACK struct {
48 A_UINT8 _HCIRsvd[8]; /* reserved for HCI packet header (GMBOX) testing */
49 A_UINT8 StreamEcho_h; /* stream no. to echo this packet on (filled by host) */
50 A_UINT8 StreamEchoSent_t; /* stream no. packet was echoed to (filled by target)
51 When echoed: StreamEchoSent_t == StreamEcho_h */
52 A_UINT8 StreamRecv_t; /* stream no. that target received this packet on (filled by target) */
53 A_UINT8 StreamNo_h; /* stream number to send on (filled by host) */
54 A_UINT8 Magic_h[4]; /* magic number to filter for this packet on the host */
55 A_UINT8 _rsvd[6]; /* reserved fields that must be set to a "reserved" value
56 since this packet maps to a 14-byte ethernet frame we want
57 to make sure ethertype field is set to something unknown */
58
59 A_UINT8 _pad[2]; /* padding for alignment */
60 A_UINT8 TimeStamp[8]; /* timestamp of packet (host or target) */
61 A_UINT32 HostContext_h; /* 4 byte host context, target echos this back */
62 A_UINT32 SeqNo; /* sequence number (set by host or target) */
63 A_UINT16 Cmd_h; /* ping command (filled by host) */
64 A_UINT16 CmdFlags_h; /* optional flags */
65 A_UINT8 CmdBuffer_h[8]; /* buffer for command (host -> target) */
66 A_UINT8 CmdBuffer_t[8]; /* buffer for command (target -> host) */
67 A_UINT16 DataLength; /* length of data */
68 A_UINT16 DataCRC; /* 16 bit CRC of data */
69 A_UINT16 HeaderCRC; /* header CRC (fields : StreamNo_h to end, minus HeaderCRC) */
70} POSTPACK EPPING_HEADER;
71
72#define EPPING_PING_MAGIC_0 0xAA
73#define EPPING_PING_MAGIC_1 0x55
74#define EPPING_PING_MAGIC_2 0xCE
75#define EPPING_PING_MAGIC_3 0xEC
76
77#define IS_EPPING_PACKET(pPkt) (((pPkt)->Magic_h[0] == EPPING_PING_MAGIC_0) && \
78 ((pPkt)->Magic_h[1] == EPPING_PING_MAGIC_1) && \
79 ((pPkt)->Magic_h[2] == EPPING_PING_MAGIC_2) && \
80 ((pPkt)->Magic_h[3] == EPPING_PING_MAGIC_3))
81
82#define SET_EPPING_PACKET_MAGIC(pPkt) { (pPkt)->Magic_h[0] = EPPING_PING_MAGIC_0; \
83 (pPkt)->Magic_h[1] = EPPING_PING_MAGIC_1; \
84 (pPkt)->Magic_h[2] = EPPING_PING_MAGIC_2; \
85 (pPkt)->Magic_h[3] = EPPING_PING_MAGIC_3; }
86
87#define CMD_FLAGS_DATA_CRC (1 << 0) /* DataCRC field is valid */
88#define CMD_FLAGS_DELAY_ECHO (1 << 1) /* delay the echo of the packet */
89#define CMD_FLAGS_NO_DROP (1 << 2) /* do not drop at HTC layer no matter what the stream is */
90
91#define IS_EPING_PACKET_NO_DROP(pPkt) ((pPkt)->CmdFlags_h & CMD_FLAGS_NO_DROP)
92
93#define EPPING_CMD_ECHO_PACKET 1 /* echo packet test */
94#define EPPING_CMD_RESET_RECV_CNT 2 /* reset recv count */
95#define EPPING_CMD_CAPTURE_RECV_CNT 3 /* fetch recv count, 4-byte count returned in CmdBuffer_t */
96#define EPPING_CMD_NO_ECHO 4 /* non-echo packet test (tx-only) */
97#define EPPING_CMD_CONT_RX_START 5 /* continous RX packets, parameters are in CmdBuffer_h */
98#define EPPING_CMD_CONT_RX_STOP 6 /* stop continuous RX packet transmission */
99
100/* test command parameters may be no more than 8 bytes */
101typedef PREPACK struct {
102 A_UINT16 BurstCnt; /* number of packets to burst together (for HTC 2.1 testing) */
103 A_UINT16 PacketLength; /* length of packet to generate including header */
104 A_UINT16 Flags; /* flags */
105
106#define EPPING_CONT_RX_DATA_CRC (1 << 0) /* Add CRC to all data */
107#define EPPING_CONT_RX_RANDOM_DATA (1 << 1) /* randomize the data pattern */
108#define EPPING_CONT_RX_RANDOM_LEN (1 << 2) /* randomize the packet lengths */
109#define EPPING_CONT_RX_NO_DATA_FILL (1 << 3) /* target will not fill buffers */
110 A_UINT16 Context; /* flags */
111
112} POSTPACK EPPING_CONT_RX_PARAMS;
113
114#define EPPING_HDR_CRC_OFFSET A_OFFSETOF(EPPING_HEADER,StreamNo_h)
115#define EPPING_HDR_BYTES_CRC (sizeof(EPPING_HEADER) - EPPING_HDR_CRC_OFFSET - (sizeof(A_UINT16)))
116
117#define HCI_TRANSPORT_STREAM_NUM 16 /* this number is higher than the define WMM AC classes so we
118 can use this to distinguish packets */
119
120#ifndef ATH_TARGET
121#include "athendpack.h"
122#endif
123
124#endif /* EPPING_TEST_H */