Skip to contentSkip to conversation

ieee802154: Add trace events for rdev->ops

PATCH Superseded Guido Günther 3 participants 8 messages Apr 12, 2015 – Apr 20, 2015

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ieee802154: Add trace events for rdev->ops

This is based on the rdev->ops tracing code from net/wireless/.

---
 net/ieee802154/Makefile   |   4 +-
 net/ieee802154/rdev-ops.h |  77 ++++++++++++---
 net/ieee802154/trace.c    |   7 ++
 net/ieee802154/trace.h    | 243 ++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 319 insertions(+), 12 deletions(-)
 create mode 100644 net/ieee802154/trace.c
 create mode 100644 net/ieee802154/trace.h
net/ieee802154/Makefile +3 -1
index 05dab29..4adfd4d 100644
@@ -3,7 +3,9 @@ obj-$(CONFIG_IEEE802154_SOCKET) += ieee802154_socket.o
 obj-y += 6lowpan/
 
 ieee802154-y := netlink.o nl-mac.o nl-phy.o nl_policy.o core.o \
-                header_ops.o sysfs.o nl802154.o
+                header_ops.o sysfs.o nl802154.o trace.o
 ieee802154_socket-y := socket.o
 
+CFLAGS_trace.o := -I$(src)
+
 ccflags-y += -D__CHECK_ENDIAN__
net/ieee802154/rdev-ops.h +66 -11

145 lines not on this page · raw message

net/ieee802154/trace.c new file +7 -0
new file mode 100644
index 0000000..95f997f
@@ -0,0 +1,7 @@
+#include <linux/module.h>
+
+#ifndef __CHECKER__
+#define CREATE_TRACE_POINTS
+#include "trace.h"
+
+#endif
net/ieee802154/trace.h new file +243 -0

243 lines not on this page · raw message

Signature · 1 line
2.1.4
maintainer
#1 lore raw

Hi,

Quoted 2 lines · Guido Günther

This is based on the rdev->ops tracing code from net/wireless/.

this patch looks good. I tested it with trace-cmd:

1. trace-cmd record -e cfg802154:802154_rdev_set_pan_id

2. iwpan dev wpan0 set pan_id 0xbeaa

3. trace-cmd report

result:

version = 6
cpus=1

           iwpan-1266  [000]   892.921639: 802154_rdev_set_pan_id: phy0, wpan_dev(1), pan id: 0xbeaa

also test it with channel and it works pretty well. (I am not a trace-cmd export at the moment, my previous use-case was enough to use the raw ftrace interface).

I looked again for the byteorder handling and detected that trace-cmd has a cfg802154 plugin [0]. It looks like the plugin is there, to doing byteorder translation in userspace instead kernelspace.

Looking into "__le16_to_cpup" stuff in wireless trace.h show something like [1].

Do you think we can do this in the same way? Then we need some plugin_cfg802154 in trace-cmd tool.

- Alex

[0] http://git.kernel.org/cgit/linux/kernel/git/rostedt/trace-cmd.git/tree/plugin_cfg80211.c
[1] http://lxr.free-electrons.com/source/net/wireless/trace.h?v=3.19#L2160

maintainer
#3 lore raw
In reply to Guido Günther

On Sun, Apr 12, 2015 at 02:07:33PM +0200, Guido Günther wrote:
...

net/ieee802154/trace.h line 121

Quoted 13 lines
net/ieee802154/trace.h new file +13 -0
+DECLARE_EVENT_CLASS(802154_le16_template,
+	TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
+		 __le16 le16arg),
+	TP_ARGS(wpan_phy, wpan_dev, le16arg),
+	TP_STRUCT__entry(
+		WPAN_PHY_ENTRY
+		WPAN_DEV_ENTRY
+		__field(__le16, le16arg)
+	),
+	TP_fast_assign(
+		WPAN_PHY_ASSIGN;
+		WPAN_DEV_ASSIGN;
+		__entry->le16arg = __le16_to_cpu(le16arg);

When "__entry->le16arg" is type of "__le16" which is given by "__field(__le16, le16arg)". Then translation of __le16_to_cpu is here wrong because __le16_to_cpu return u16.

net/ieee802154/trace.h line 124

Quoted 3 lines
net/ieee802154/trace.h new file +3 -0
+	),
+	TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT ", pan id: 0x%04x",
+		  WPAN_PHY_PR_ARG, WPAN_DEV_PR_ARG, __entry->le16arg)

When then we need to do the translation here. The format string requires a host byte-order type. So it's __le16_to_cpu(__entry->le16arg), I don't know why sparse (the C=2) doesn't report about that.

This is like wireless it does at [0], but with a pointer. When wireless do that in kernelspace, then I have no idea why there is a cfg80211 plugin which doing byte order translation at [1]. I think this not for parsing the argument, it's for correct handling of handling the display of __le16_to_cpup (We use __le16_to_cpu here).

Then we need a cfg802154 plugin in trace_cmd for handling "__le16_to_cpu" correct.

- Alex

[0] http://lxr.free-electrons.com/source/net/wireless/trace.h?v=3.19#L2160
[1] http://git.kernel.org/cgit/linux/kernel/git/rostedt/trace-cmd.git/tree/plugin_cfg80211.c

maintainer
#2 lore raw
In reply to Alexander Aring
Quoted 20 lines · Alexander Aring

Hi,

Quoted 2 lines · Guido Günther

This is based on the rdev->ops tracing code from net/wireless/.

this patch looks good. I tested it with trace-cmd:

1. trace-cmd record -e cfg802154:802154_rdev_set_pan_id

2. iwpan dev wpan0 set pan_id 0xbeaa

3. trace-cmd report

result:

version = 6
cpus=1

           iwpan-1266  [000]   892.921639: 802154_rdev_set_pan_id: phy0, wpan_dev(1), pan id: 0xbeaa
Quoted 7 lines

also test it with channel and it works pretty well. (I am not a trace-cmd export at the moment, my previous use-case was enough to use the raw ftrace interface).

I looked again for the byteorder handling and detected that trace-cmd has a cfg802154 plugin [0]. It looks like the plugin is there, to doing

s/cfg802154/cfg80211/

Quoted 8 lines

byteorder translation in userspace instead kernelspace.

Looking into "__le16_to_cpup" stuff in wireless trace.h show something like [1].

Do you think we can do this in the same way? Then we need some plugin_cfg802154 in trace-cmd tool.

Please read the other mail which I also mark an issue and we should move the byteorder translation into the format string argument. I suppose, what wireless do with the cfg80211 plugin is to printout the handling of function __le16_to_cpup (in our case __le16_to_cpu) more correct. So we need both, translation byteorder in kernelspace (for the __le16 parameter) and (to show the __le16_to_cpu in userspace correct).

- Alex

#5 lore raw
In reply to Guido Günther
Quoted 1 line · Guido Günther

This is based on the rdev->ops tracing code from net/wireless/.

Instead of writing the above commit message its better to write what exactly this code is for and how can we use this from the user space (if possible with commands).

If you want to write your above commit message put it in trace.c/h file

Quoted 15 lines
---
 net/ieee802154/Makefile   |   4 +-
 net/ieee802154/rdev-ops.h |  77 ++++++++++++---
 net/ieee802154/trace.c    |   7 ++
 net/ieee802154/trace.h    | 243 ++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 319 insertions(+), 12 deletions(-)
 create mode 100644 net/ieee802154/trace.c
 create mode 100644 net/ieee802154/trace.h
net/ieee802154/Makefile +0 -0
index 05dab29..4adfd4d 100644

net/ieee802154/Makefile obj-$(CONFIG_IEEE802154_SOCKET) += ieee802154_socket.o · line 9

Quoted 8 lines
net/ieee802154/Makefile +2 -1
@@ -3,7 +3,9 @@ obj-$(CONFIG_IEEE802154_SOCKET) += ieee802154_socket.o
 obj-y += 6lowpan/
 
 ieee802154-y := netlink.o nl-mac.o nl-phy.o nl_policy.o core.o \
-                header_ops.o sysfs.o nl802154.o
+                header_ops.o sysfs.o nl802154.o trace.o
 ieee802154_socket-y := socket.o
 
+CFLAGS_trace.o := -I$(src)

What is this for..?

Signature · 1 line
Varka Bhadram
#6 lore raw
Quoted 6 lines · Varka Bhadram
Quoted 1 line · Guido Günther

This is based on the rdev->ops tracing code from net/wireless/.

Instead of writing the above commit message its better to write what exactly this code is for and how can we use this from the user space (if possible with commands).

Adjusted in v2.

Quoted 20 lines

If you want to write your above commit message put it in trace.c/h file

Quoted 17 lines
---
 net/ieee802154/Makefile   |   4 +-
 net/ieee802154/rdev-ops.h |  77 ++++++++++++---
 net/ieee802154/trace.c    |   7 ++
 net/ieee802154/trace.h    | 243 ++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 319 insertions(+), 12 deletions(-)
 create mode 100644 net/ieee802154/trace.c
 create mode 100644 net/ieee802154/trace.h
net/ieee802154/Makefile +0 -0
index 05dab29..4adfd4d 100644
@@ -3,7 +3,9 @@ obj-$(CONFIG_IEEE802154_SOCKET) += ieee802154_socket.o
 obj-y += 6lowpan/
 
Quoted 8 lines

net/ieee802154/Makefile obj-$(CONFIG_IEEE802154_SOCKET) += ieee802154_socket.o · line 9

Quoted 6 lines
net/ieee802154/Makefile +2 -1
 ieee802154-y := netlink.o nl-mac.o nl-phy.o nl_policy.o core.o \
-                header_ops.o sysfs.o nl802154.o
+                header_ops.o sysfs.o nl802154.o trace.o
 ieee802154_socket-y := socket.o
 
+CFLAGS_trace.o := -I$(src)

What is this for..?

So trace.h is found due to the ftrace magic. See
samples/trace_events/Makefile.

Cheers,
-- Guido

#4 lore raw
In reply to Alexander Aring

Hi Alexander,

Quoted 28 lines · Alexander Aring

On Sun, Apr 12, 2015 at 02:07:33PM +0200, Guido Günther wrote:
...

net/ieee802154/trace.h line 121

Quoted 13 lines
net/ieee802154/trace.h new file +13 -0
+DECLARE_EVENT_CLASS(802154_le16_template,
+	TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
+		 __le16 le16arg),
+	TP_ARGS(wpan_phy, wpan_dev, le16arg),
+	TP_STRUCT__entry(
+		WPAN_PHY_ENTRY
+		WPAN_DEV_ENTRY
+		__field(__le16, le16arg)
+	),
+	TP_fast_assign(
+		WPAN_PHY_ASSIGN;
+		WPAN_DEV_ASSIGN;
+		__entry->le16arg = __le16_to_cpu(le16arg);

When "__entry->le16arg" is type of "__le16" which is given by "__field(__le16, le16arg)". Then translation of __le16_to_cpu is here wrong because __le16_to_cpu return u16.

net/ieee802154/trace.h line 124

Quoted 3 lines
net/ieee802154/trace.h new file +3 -0
+	),
+	TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT ", pan id: 0x%04x",
+		  WPAN_PHY_PR_ARG, WPAN_DEV_PR_ARG, __entry->le16arg)

When then we need to do the translation here. The format string requires a host byte-order type. So it's __le16_to_cpu(__entry->le16arg), I don't know why sparse (the C=2) doesn't report about that.

Quoted 5 lines

This is like wireless it does at [0], but with a pointer. When wireless do that in kernelspace, then I have no idea why there is a cfg80211 plugin which doing byte order translation at [1]. I think this not for parsing the argument, it's for correct handling of handling the display of __le16_to_cpup (We use __le16_to_cpu here).

Agreed. If we want to keep this le until it's printed we should delay conversion up to the format string.

Quoted 2 lines

Then we need a cfg802154 plugin in trace_cmd for handling "__le16_to_cpu" correct.

I think this is only needed you don't use the kernel's built in printing so this could be done as a follow up once this is in. Cheers,
-- Guido

maintainer
#7 lore raw
In reply to Guido Günther
Quoted 10 lines · Guido Günther
Quoted 6 lines · Varka Bhadram
Quoted 1 line · Guido Günther

This is based on the rdev->ops tracing code from net/wireless/.

Instead of writing the above commit message its better to write what exactly this code is for and how can we use this from the user space (if possible with commands).

Adjusted in v2.

or you can steal it from 14e8a3c47e808772a5ba8118ef1f9a8d604dbbe5 ("cfg80211: add tracing to rdev-ops").

Or refer this commit in your commit message, but keeping style then $ID ("$MSG").

- Alex