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