MDUTrafficStats.c.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. <?xml version='1.0' encoding='iso-8859-1'?>
  2. <!doctype html public '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
  3. <html xmlns='http://www.w3c.org/1999/xhtml' lang='en-us'>
  4. <head>
  5. <title>
  6. MDUTrafficStats.c
  7. </title>
  8. <meta http-equiv='content-type' content='text/html;iso-8859-1'/>
  9. <meta name='generator' content='motley-tools 1.9.4 13:40:33 Feb 18 2015'/>
  10. <meta name='author' content='cmaier@cmassoc.net'/>
  11. <meta name='robots' content='noindex,nofollow'/>
  12. <link href='toolkit.css' rel='stylesheet' type='text/css'/>
  13. </head>
  14. <body>
  15. <div class='headerlink'>
  16. [<a href='mdustats.c.html' title=' mdustats.c '>PREV</a>]
  17. [<a href='toolkit.html' title=' Index '>HOME</a>]
  18. [<a href='memdecr.c.html' title=' memdecr.c '>NEXT</a>]
  19. </div>
  20. <pre>
  21. /*====================================================================*
  22. *
  23. * Copyright (c) 2013 Qualcomm Atheros, Inc.
  24. *
  25. * All rights reserved.
  26. *
  27. * Redistribution and use in source and binary forms, with or
  28. * without modification, are permitted (subject to the limitations
  29. * in the disclaimer below) provided that the following conditions
  30. * are met:
  31. *
  32. * * Redistributions of source code must retain the above copyright
  33. * notice, this list of conditions and the following disclaimer.
  34. *
  35. * * Redistributions in binary form must reproduce the above
  36. * copyright notice, this list of conditions and the following
  37. * disclaimer in the documentation and/or other materials
  38. * provided with the distribution.
  39. *
  40. * * Neither the name of Qualcomm Atheros nor the names of
  41. * its contributors may be used to endorse or promote products
  42. * derived from this software without specific prior written
  43. * permission.
  44. *
  45. * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
  46. * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE
  47. * COPYRIGHT HOLDERS AND CONTRIBUTORS &quot;AS IS&quot; AND ANY EXPRESS OR
  48. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  49. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  50. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
  51. * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  52. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  53. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  54. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  55. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  56. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  57. * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  58. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  59. *
  60. *--------------------------------------------------------------------*/
  61. /*====================================================================*
  62. *
  63. * signed MDUTrafficStats (struct plc * plc);
  64. *
  65. * plc.h
  66. *
  67. *
  68. * Contributor(s):
  69. * Charles Maier &lt;cmaier@qca.qualcomm.com&gt;
  70. *
  71. *--------------------------------------------------------------------*/
  72. #ifndef MDUTRAFFICSTATS_SOURCE
  73. #define MDUTRAFFICSTATS_SOURCE
  74. #include &lt;stdint.h&gt;
  75. #include &lt;memory.h&gt;
  76. #include &quot;../plc/plc.h&quot;
  77. #include &quot;../tools/flags.h&quot;
  78. #include &quot;../tools/error.h&quot;
  79. #include &quot;../tools/memory.h&quot;
  80. /*====================================================================*
  81. * constants;
  82. *--------------------------------------------------------------------*/
  83. #define CC1_RDRP (1 &lt;&lt; 0)
  84. #define CC1_RJBR (1 &lt;&lt; 1)
  85. #define CC1_RFRG (1 &lt;&lt; 2)
  86. #define CC1_ROVR (1 &lt;&lt; 3)
  87. #define CC1_RUND (1 &lt;&lt; 4)
  88. #define CC1_RCSE (1 &lt;&lt; 5)
  89. #define CC1_RCDE (1 &lt;&lt; 6)
  90. #define CC1_RFLR (1 &lt;&lt; 7)
  91. #define CC1_RALN (1 &lt;&lt; 8)
  92. #define CC1_RXUO (1 &lt;&lt; 9)
  93. #define CC1_RXPF (1 &lt;&lt; 10)
  94. #define CC1_RXCF (1 &lt;&lt; 11)
  95. #define CC1_RBCA (1 &lt;&lt; 12)
  96. #define CC1_RMCA (1 &lt;&lt; 13)
  97. #define CC1_RFCS (1 &lt;&lt; 14)
  98. #define CC1_RPTK (1 &lt;&lt; 15)
  99. #define CC1_TRMGV (1 &lt;&lt; 25)
  100. #define CC1_TRMAX (1 &lt;&lt; 26)
  101. #define CC1_TR1K (1 &lt;&lt; 27)
  102. #define CC1_TR511 (1 &lt;&lt; 28)
  103. #define CC1_TR255 (1 &lt;&lt; 29)
  104. #define CC1_TR127 (1 &lt;&lt; 30)
  105. #define CC1_TR64 (1 &lt;&lt; 31)
  106. #define CC2_TDRP (1 &lt;&lt; 0)
  107. #define CC2_TPFH (1 &lt;&lt; 1)
  108. #define CC2_TNCL (1 &lt;&lt; 2)
  109. #define CC2_TXCL (1 &lt;&lt; 3)
  110. #define CC2_TLCL (1 &lt;&lt; 4)
  111. #define CC2_TMCL (1 &lt;&lt; 5)
  112. #define CC2_TSCL (1 &lt;&lt; 6)
  113. #define CC2_TEDF (1 &lt;&lt; 7)
  114. #define CC2_TDFR (1 &lt;&lt; 8)
  115. #define CC2_TXPF (1 &lt;&lt; 9)
  116. #define CC2_TBCA (1 &lt;&lt; 10)
  117. #define CC2_TMCA (1 &lt;&lt; 11)
  118. #define CC2_TPKT (1 &lt;&lt; 12)
  119. #define CC2_TBYT (1 &lt;&lt; 13)
  120. #define CC2_TFRG (1 &lt;&lt; 14)
  121. #define CC2_TUND (1 &lt;&lt; 15)
  122. #define CC2_TOVR (1 &lt;&lt; 16)
  123. #define CC2_TXCF (1 &lt;&lt; 17)
  124. #define CC2_TFCS (1 &lt;&lt; 18)
  125. #define CC2_TJBR (1 &lt;&lt; 19)
  126. #define MASTER_TX_RX (1 &lt;&lt; 0)
  127. #define SLAVE_TX_RX (1 &lt;&lt; 1)
  128. #define MASTER_FETCH (1 &lt;&lt; 2)
  129. #define SLAVE_CLEAR (1 &lt;&lt; 3)
  130. #define ETHERNET_STATS (1 &lt;&lt; 4)
  131. /*====================================================================*
  132. * variables;
  133. *--------------------------------------------------------------------*/
  134. /*
  135. * Station Statistics;
  136. */
  137. #ifndef __GNUC__
  138. #pragma pack (push,1)
  139. #endif
  140. typedef struct __packed station_stats
  141. {
  142. uint8_t TEI;
  143. uint8_t RESULT_CODE;
  144. uint32_t UPSTREAM_MME_FRAMES;
  145. uint32_t UPSTREAM_ETH_FRAMES_UNI;
  146. uint32_t UPSTREAM_ETH_FRAMES_MULTI;
  147. uint32_t UPSTREAM_ETH_FRAMES_BROAD;
  148. uint32_t UPSTREAM_DROP_MME_FROM_HOST;
  149. uint32_t UPSTREAM_DROP_MME_FW_GEN;
  150. uint32_t UPSTREAM_DROP_ETH_FROM_HOST;
  151. uint32_t DOWNSTREAM_MME_FRAMES;
  152. uint32_t DOWNSTREAM_ETH_FRAMES_UNI;
  153. uint32_t DOWNSTREAM_ETH_FRAMES_MULTI;
  154. uint32_t DOWNSTREAM_ETH_FRAMES_BROAD;
  155. uint32_t DOWNSTREAM_DROP_MME_FROM_HOST;
  156. uint32_t DOWNSTREAM_DROP_MME_FW_GEN;
  157. uint32_t DOWNSTREAM_DROP_ETH_FROM_HOST;
  158. }
  159. statistics;
  160. #ifndef __GNUC__
  161. #pragma pack (pop)
  162. #endif
  163. /*
  164. * Ethernet Statistics;
  165. */
  166. #ifndef __GNUC__
  167. #pragma pack (push,1)
  168. #endif
  169. typedef struct __packed ethernet_stats
  170. {
  171. uint16_t HW_MODULE_TYPE;
  172. uint16_t HW_MODULE_STATS_LEN;
  173. uint32_t TR64;
  174. uint32_t TR127;
  175. uint32_t TR255;
  176. uint32_t TR511;
  177. uint32_t TR1K;
  178. uint32_t TRMAX;
  179. uint32_t TRMGV;
  180. uint32_t RBYT;
  181. uint32_t RBKT;
  182. uint32_t RFCS;
  183. uint32_t RFCA;
  184. uint32_t RBCA;
  185. uint32_t RXCF;
  186. uint32_t RXPF;
  187. uint32_t RXUO;
  188. uint32_t RALN;
  189. uint32_t RFLR;
  190. uint32_t RCDE;
  191. uint32_t RCSE;
  192. uint32_t RUND;
  193. uint32_t ROVR;
  194. uint32_t RFRG;
  195. uint32_t RJBR;
  196. uint32_t RDRP;
  197. uint32_t TBYT;
  198. uint32_t TPKT;
  199. uint32_t TMCA;
  200. uint32_t TBCA;
  201. uint32_t TXPF;
  202. uint32_t TDFR;
  203. uint32_t TEDF;
  204. uint32_t TSCL;
  205. uint32_t TMCL;
  206. uint32_t TLCL;
  207. uint32_t TXCL;
  208. uint32_t TNCL;
  209. uint32_t TPFH;
  210. uint32_t TDRP;
  211. uint32_t TJBR;
  212. uint32_t TFCS;
  213. uint32_t TXCF;
  214. uint32_t TOVR;
  215. uint32_t TUND;
  216. uint32_t TFRG;
  217. uint32_t CARRY1;
  218. uint32_t CARRY2;
  219. }
  220. ethernet_stats;
  221. #ifndef __GNUC__
  222. #pragma pack (pop)
  223. #endif
  224. /*
  225. * Classification Counters
  226. */
  227. #ifndef __GNUC__
  228. #pragma pack (push,1)
  229. #endif
  230. typedef struct __packed class_counters
  231. {
  232. uint16_t HW_MODULE_TYPE;
  233. uint16_t HW_MODULE_STATS_LEN;
  234. uint32_t IcvFailure;
  235. uint32_t InvalidMacFrame;
  236. uint32_t CorruptedMacFrameHeader;
  237. uint32_t MacDaCompareRule;
  238. uint32_t PriorityOrTHresholdLessWatermark;
  239. uint32_t OversizePacket;
  240. uint32_t Other;
  241. uint32_t SA_Learning;
  242. }
  243. class_counters;
  244. #ifndef __GNUC__
  245. #pragma pack (pop)
  246. #endif
  247. /*====================================================================*
  248. *
  249. * void StationStats (struct plc * plc, struct station_stats * stats);
  250. *
  251. * display station statistics in human readable format; there may
  252. * be one or more such functions depending on the audience; this
  253. * output was designed by the Product Verification Team in Ocala;
  254. *
  255. *
  256. *--------------------------------------------------------------------*/
  257. static void StationStats (struct plc * plc, struct station_stats * stats)
  258. {
  259. fprintf (stderr, &quot;TEI %d\n&quot;, stats-&gt;TEI);
  260. fprintf (stderr, &quot;ERR 0x%02X\n&quot;, stats-&gt;RESULT_CODE);
  261. fprintf (stderr, &quot;UPSTREAM_MME 0x%08X\n&quot;, stats-&gt;UPSTREAM_MME_FRAMES);
  262. fprintf (stderr, &quot;UPSTREAM_UNICAST 0x%08X\n&quot;, stats-&gt;UPSTREAM_ETH_FRAMES_UNI);
  263. fprintf (stderr, &quot;UPSTREAM_MULTICAST 0x%08X\n&quot;, stats-&gt;UPSTREAM_ETH_FRAMES_MULTI);
  264. fprintf (stderr, &quot;UPSTREAM_BROADCAST 0x%08X\n&quot;, stats-&gt;UPSTREAM_ETH_FRAMES_BROAD);
  265. fprintf (stderr, &quot;UPSTREAM_DROP_HOST_MME 0x%08X\n&quot;, stats-&gt;UPSTREAM_DROP_MME_FROM_HOST);
  266. fprintf (stderr, &quot;UPSTREAM_DROP_FW_MME 0x%08X\n&quot;, stats-&gt;UPSTREAM_DROP_MME_FW_GEN);
  267. fprintf (stderr, &quot;UPSTREAM_DROP_HOST_ETH 0x%08X\n&quot;, stats-&gt;UPSTREAM_DROP_ETH_FROM_HOST);
  268. fprintf (stderr, &quot;DOWNSTREAM_MME 0x%08X\n&quot;, stats-&gt;DOWNSTREAM_MME_FRAMES);
  269. fprintf (stderr, &quot;DOWNSTREAM_UNICAST 0x%08X\n&quot;, stats-&gt;DOWNSTREAM_ETH_FRAMES_UNI);
  270. fprintf (stderr, &quot;DOWNSTREAM_MULTICAST 0x%08X\n&quot;, stats-&gt;DOWNSTREAM_ETH_FRAMES_MULTI);
  271. fprintf (stderr, &quot;DOWNSTREAM_BROADCAST 0x%08X\n&quot;, stats-&gt;DOWNSTREAM_ETH_FRAMES_BROAD);
  272. fprintf (stderr, &quot;DOWNSTREAM_DROP_HOST_MME 0x%08X\n&quot;, stats-&gt;DOWNSTREAM_DROP_MME_FROM_HOST);
  273. fprintf (stderr, &quot;DOWNSTREAM_DROP_FW_MME 0x%08X\n&quot;, stats-&gt;DOWNSTREAM_DROP_MME_FW_GEN);
  274. fprintf (stderr, &quot;DOWNSTREAM_DROP_HOST_ETH 0x%08X\n&quot;, stats-&gt;DOWNSTREAM_DROP_ETH_FROM_HOST);
  275. fprintf (stderr, &quot;\n&quot;);
  276. return;
  277. }
  278. /*====================================================================*
  279. *
  280. * void EthernetStats (struct plc * plc, struct ethernet_stats * stats);
  281. *
  282. *
  283. *--------------------------------------------------------------------*/
  284. static void EthernetStats (struct plc * plc, struct ethernet_stats * stats)
  285. {
  286. return;
  287. }
  288. /*====================================================================*
  289. *
  290. * void ClassificationCounters (struct plc * plc, struct class_counters * counters);
  291. *
  292. *
  293. *--------------------------------------------------------------------*/
  294. #if 0
  295. static void ClassificationCounters (struct plc * plc, struct class_counters * counters)
  296. {
  297. return;
  298. }
  299. #endif
  300. /*====================================================================*
  301. *
  302. * signed MDUTrafficStats (struct plc * plc, uint8_t command, uint8_t session, uint8_t slave);
  303. *
  304. * request MDU traffic statistics using one VS_MDU_TRAFFIC_STATS
  305. * request type; different types of confirmations are returned
  306. * depending on the type of request;
  307. *
  308. *
  309. *--------------------------------------------------------------------*/
  310. signed MDUTrafficStats (struct plc * plc, uint8_t command, uint8_t session, uint8_t slave)
  311. {
  312. struct channel * channel = (struct channel *)(plc-&gt;channel);
  313. struct message * message = (struct message *)(plc-&gt;message);
  314. #ifndef __GNUC__
  315. #pragma pack (push,1)
  316. #endif
  317. struct __packed vs_mdu_station_stats_request
  318. {
  319. struct ethernet_hdr ethernet;
  320. struct qualcomm_hdr qualcomm;
  321. uint8_t COMMAND;
  322. uint8_t SESSION;
  323. uint32_t SLAVE_BITMAP [8];
  324. }
  325. * request = (struct vs_mdu_station_stats_request *) (message);
  326. struct __packed vs_mdu_traffic_master_confirm
  327. {
  328. struct ethernet_hdr ethernet;
  329. struct qualcomm_hdr qualcomm;
  330. uint8_t COMMAND;
  331. uint8_t SESSION;
  332. uint16_t RESERVED;
  333. uint8_t NUM_SLAVES;
  334. uint8_t NUM_SLAVES_LEFT;
  335. uint16_t STATS_LEN;
  336. struct station_stats STATS [1];
  337. }
  338. * master_confirm = (struct vs_mdu_traffic_master_confirm *) (message);
  339. struct __packed vs_mdu_traffic_slave_confirm
  340. {
  341. struct ethernet_hdr ethernet;
  342. struct qualcomm_hdr qualcomm;
  343. uint8_t COMMAND;
  344. uint8_t SESSION;
  345. uint16_t STATS_LEN;
  346. struct station_stats STATS [1];
  347. }
  348. * slave_confirm = (struct vs_mdu_traffic_slave_confirm *) (message);
  349. #if 1
  350. struct __packed vs_eth_hardware_stats_confirm
  351. {
  352. struct ethernet_hdr ethernet;
  353. struct qualcomm_hdr qualcomm;
  354. uint8_t COMMAND;
  355. uint8_t SESSION;
  356. uint8_t CHIPTYPE;
  357. uint8_t STATUS;
  358. uint16_t STATS_LEN;
  359. struct ethernet_stats STATS [1];
  360. }
  361. * ether_confirm = (struct vs_eth_hardware_stats_confirm *) (message);
  362. #endif
  363. #ifndef __GNUC__
  364. #pragma pack (pop)
  365. #endif
  366. Request (plc, &quot;Request MDU Traffic Statistics (1)&quot;);
  367. memset (message, 0, sizeof (* message));
  368. EthernetHeader (&amp;request-&gt;ethernet, channel-&gt;peer, channel-&gt;host, channel-&gt;type);
  369. QualcommHeader (&amp;request-&gt;qualcomm, 0, (VS_MDU_TRAFFIC_STATS | MMTYPE_REQ));
  370. request-&gt;COMMAND = command;
  371. request-&gt;SESSION = session;
  372. set32bitmap (request-&gt;SLAVE_BITMAP, slave);
  373. plc-&gt;packetsize = sizeof (* request);
  374. if (SendMME (plc) &lt;= 0)
  375. {
  376. error (PLC_EXIT (plc), errno, CHANNEL_CANTSEND);
  377. return (-1);
  378. }
  379. while (ReadMME (plc, 0, (VS_MDU_TRAFFIC_STATS | MMTYPE_CNF)) &gt; 0)
  380. {
  381. if ((request-&gt;COMMAND &gt; 0x00) &amp;&amp; (request-&gt;COMMAND &lt; 0x0020))
  382. {
  383. struct station_stats * stats;
  384. unsigned count;
  385. if (_anyset (request-&gt;COMMAND, MASTER_TX_RX | SLAVE_TX_RX))
  386. {
  387. stats = master_confirm-&gt;STATS;
  388. count = LE16TOH (master_confirm-&gt;STATS_LEN);
  389. }
  390. else
  391. {
  392. stats = slave_confirm-&gt;STATS;
  393. count = LE16TOH (slave_confirm-&gt;STATS_LEN);
  394. }
  395. while (count &gt;= sizeof (struct station_stats))
  396. {
  397. StationStats (plc, stats++);
  398. count -= sizeof (struct station_stats);
  399. }
  400. continue;
  401. }
  402. if ((request-&gt;COMMAND &gt;= 0x20) &amp;&amp; (request-&gt;COMMAND &lt; 0x24))
  403. {
  404. EthernetStats (plc, ether_confirm-&gt;STATS);
  405. continue;
  406. }
  407. if ((request-&gt;COMMAND &gt;= 0x24) &amp;&amp; (request-&gt;COMMAND &lt; 0x28))
  408. {
  409. EthernetStats (plc, ether_confirm-&gt;STATS);
  410. continue;
  411. }
  412. if ((request-&gt;COMMAND &gt;= 0x28) &amp;&amp; (request-&gt;COMMAND &lt; 0x32))
  413. {
  414. EthernetStats (plc, ether_confirm-&gt;STATS);
  415. continue;
  416. }
  417. }
  418. return (0);
  419. }
  420. #endif
  421. </pre>
  422. <div class='footerlink'>
  423. [<a href='mdustats.c.html' title=' mdustats.c '>PREV</a>]
  424. [<a href='toolkit.html' title=' Index '>HOME</a>]
  425. [<a href='memdecr.c.html' title=' memdecr.c '>NEXT</a>]
  426. </div>
  427. </body>
  428. </html>