iwl-devtrace.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /******************************************************************************
  3. *
  4. * Copyright(c) 2009 - 2014 Intel Corporation. All rights reserved.
  5. * Copyright(C) 2016 Intel Deutschland GmbH
  6. * Copyright(c) 2018 Intel Corporation
  7. *****************************************************************************/
  8. #ifndef __IWLWIFI_DEVICE_TRACE
  9. #include <linux/skbuff.h>
  10. #include <linux/ieee80211.h>
  11. #include <net/cfg80211.h>
  12. #include "iwl-trans.h"
  13. #if !defined(__IWLWIFI_DEVICE_TRACE)
  14. static inline bool iwl_trace_data(struct sk_buff *skb)
  15. {
  16. struct ieee80211_hdr *hdr = (void *)skb->data;
  17. __le16 fc = hdr->frame_control;
  18. int offs = 24; /* start with normal header length */
  19. if (!ieee80211_is_data(fc))
  20. return false;
  21. /* Try to determine if the frame is EAPOL. This might have false
  22. * positives (if there's no RFC 1042 header and we compare to some
  23. * payload instead) but since we're only doing tracing that's not
  24. * a problem.
  25. */
  26. if (ieee80211_has_a4(fc))
  27. offs += 6;
  28. if (ieee80211_is_data_qos(fc))
  29. offs += 2;
  30. /* don't account for crypto - these are unencrypted */
  31. /* also account for the RFC 1042 header, of course */
  32. offs += 6;
  33. return skb->len <= offs + 2 ||
  34. *(__be16 *)(skb->data + offs) != cpu_to_be16(ETH_P_PAE);
  35. }
  36. static inline size_t iwl_rx_trace_len(const struct iwl_trans *trans,
  37. void *rxbuf, size_t len,
  38. size_t *out_hdr_offset)
  39. {
  40. struct iwl_cmd_header *cmd = (void *)((u8 *)rxbuf + sizeof(__le32));
  41. struct ieee80211_hdr *hdr = NULL;
  42. size_t hdr_offset;
  43. if (cmd->cmd != trans->rx_mpdu_cmd)
  44. return len;
  45. hdr_offset = sizeof(struct iwl_cmd_header) +
  46. trans->rx_mpdu_cmd_hdr_size;
  47. if (out_hdr_offset)
  48. *out_hdr_offset = hdr_offset;
  49. hdr = (void *)((u8 *)cmd + hdr_offset);
  50. if (!ieee80211_is_data(hdr->frame_control))
  51. return len;
  52. /* maybe try to identify EAPOL frames? */
  53. return sizeof(__le32) + sizeof(*cmd) + trans->rx_mpdu_cmd_hdr_size +
  54. ieee80211_hdrlen(hdr->frame_control);
  55. }
  56. #endif
  57. #define __IWLWIFI_DEVICE_TRACE
  58. #include <linux/tracepoint.h>
  59. #include <linux/device.h>
  60. #if !defined(CONFIG_IWLWIFI_DEVICE_TRACING) || defined(__CHECKER__)
  61. #undef TRACE_EVENT
  62. #define TRACE_EVENT(name, proto, ...) \
  63. static inline void trace_ ## name(proto) {}
  64. #undef DECLARE_EVENT_CLASS
  65. #define DECLARE_EVENT_CLASS(...)
  66. #undef DEFINE_EVENT
  67. #define DEFINE_EVENT(evt_class, name, proto, ...) \
  68. static inline void trace_ ## name(proto) {}
  69. #endif
  70. #define DEV_ENTRY __string(dev, dev_name(dev))
  71. #define DEV_ASSIGN __assign_str(dev, dev_name(dev))
  72. #include "iwl-devtrace-io.h"
  73. #include "iwl-devtrace-ucode.h"
  74. #include "iwl-devtrace-msg.h"
  75. #include "iwl-devtrace-data.h"
  76. #include "iwl-devtrace-iwlwifi.h"
  77. #endif /* __IWLWIFI_DEVICE_TRACE */