iwl-devtrace.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2009 - 2014 Intel Corporation. All rights reserved.
  4. * Copyright(C) 2016 Intel Deutschland GmbH
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of version 2 of the GNU General Public License as
  8. * published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along with
  16. * this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  18. *
  19. * The full GNU General Public License is included in this distribution in the
  20. * file called LICENSE.
  21. *
  22. * Contact Information:
  23. * Intel Linux Wireless <linuxwifi@intel.com>
  24. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  25. *
  26. *****************************************************************************/
  27. #ifndef __IWLWIFI_DEVICE_TRACE
  28. #include <linux/skbuff.h>
  29. #include <linux/ieee80211.h>
  30. #include <net/cfg80211.h>
  31. #include "iwl-trans.h"
  32. #if !defined(__IWLWIFI_DEVICE_TRACE)
  33. static inline bool iwl_trace_data(struct sk_buff *skb)
  34. {
  35. struct ieee80211_hdr *hdr = (void *)skb->data;
  36. __le16 fc = hdr->frame_control;
  37. int offs = 24; /* start with normal header length */
  38. if (!ieee80211_is_data(fc))
  39. return false;
  40. /* Try to determine if the frame is EAPOL. This might have false
  41. * positives (if there's no RFC 1042 header and we compare to some
  42. * payload instead) but since we're only doing tracing that's not
  43. * a problem.
  44. */
  45. if (ieee80211_has_a4(fc))
  46. offs += 6;
  47. if (ieee80211_is_data_qos(fc))
  48. offs += 2;
  49. /* don't account for crypto - these are unencrypted */
  50. /* also account for the RFC 1042 header, of course */
  51. offs += 6;
  52. return skb->len > offs + 2 &&
  53. *(__be16 *)(skb->data + offs) == cpu_to_be16(ETH_P_PAE);
  54. }
  55. static inline size_t iwl_rx_trace_len(const struct iwl_trans *trans,
  56. void *rxbuf, size_t len)
  57. {
  58. struct iwl_cmd_header *cmd = (void *)((u8 *)rxbuf + sizeof(__le32));
  59. struct ieee80211_hdr *hdr;
  60. if (cmd->cmd != trans->rx_mpdu_cmd)
  61. return len;
  62. hdr = (void *)((u8 *)cmd + sizeof(struct iwl_cmd_header) +
  63. trans->rx_mpdu_cmd_hdr_size);
  64. if (!ieee80211_is_data(hdr->frame_control))
  65. return len;
  66. /* maybe try to identify EAPOL frames? */
  67. return sizeof(__le32) + sizeof(*cmd) + trans->rx_mpdu_cmd_hdr_size +
  68. ieee80211_hdrlen(hdr->frame_control);
  69. }
  70. #endif
  71. #define __IWLWIFI_DEVICE_TRACE
  72. #include <linux/tracepoint.h>
  73. #include <linux/device.h>
  74. #include "iwl-trans.h"
  75. #if !defined(CONFIG_IWLWIFI_DEVICE_TRACING) || defined(__CHECKER__)
  76. #undef TRACE_EVENT
  77. #define TRACE_EVENT(name, proto, ...) \
  78. static inline void trace_ ## name(proto) {}
  79. #undef DECLARE_EVENT_CLASS
  80. #define DECLARE_EVENT_CLASS(...)
  81. #undef DEFINE_EVENT
  82. #define DEFINE_EVENT(evt_class, name, proto, ...) \
  83. static inline void trace_ ## name(proto) {}
  84. #endif
  85. #define DEV_ENTRY __string(dev, dev_name(dev))
  86. #define DEV_ASSIGN __assign_str(dev, dev_name(dev))
  87. #include "iwl-devtrace-io.h"
  88. #include "iwl-devtrace-ucode.h"
  89. #include "iwl-devtrace-msg.h"
  90. #include "iwl-devtrace-data.h"
  91. #include "iwl-devtrace-iwlwifi.h"
  92. #endif /* __IWLWIFI_DEVICE_TRACE */