epping_test.h 6.3 KB

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