]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blame - tools/lib/traceevent/plugin_mac80211.c
tools lib traceevent, perf tools: Rename 'struct tep_event_format' to 'struct tep_event'
[mirror_ubuntu-eoan-kernel.git] / tools / lib / traceevent / plugin_mac80211.c
CommitLineData
de705e2e
JO
1/*
2 * Copyright (C) 2009 Johannes Berg <johannes@sipsolutions.net>
3 *
4 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation;
8 * version 2.1 of the License (not later!)
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this program; if not, see <http://www.gnu.org/licenses>
17 *
18 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 */
20#include <stdio.h>
21#include <stdlib.h>
22#include <string.h>
23
24#include "event-parse.h"
266b851c 25#include "trace-seq.h"
de705e2e
JO
26
27#define INDENT 65
28
97fbf3f0 29static void print_string(struct trace_seq *s, struct tep_event *event,
de705e2e
JO
30 const char *name, const void *data)
31{
2c92f982 32 struct tep_format_field *f = tep_find_field(event, name);
de705e2e
JO
33 int offset;
34 int length;
35
36 if (!f) {
37 trace_seq_printf(s, "NOTFOUND:%s", name);
38 return;
39 }
40
41 offset = f->offset;
42 length = f->size;
43
44 if (!strncmp(f->type, "__data_loc", 10)) {
45 unsigned long long v;
59c1baee 46 if (tep_read_number_field(f, data, &v)) {
de705e2e
JO
47 trace_seq_printf(s, "invalid_data_loc");
48 return;
49 }
50 offset = v & 0xffff;
51 length = v >> 16;
52 }
53
54 trace_seq_printf(s, "%.*s", length, (char *)data + offset);
55}
56
6a48dc29
TSV
57#define SF(fn) tep_print_num_field(s, fn ":%d", event, fn, record, 0)
58#define SFX(fn) tep_print_num_field(s, fn ":%#x", event, fn, record, 0)
de705e2e
JO
59#define SP() trace_seq_putc(s, ' ')
60
61static int drv_bss_info_changed(struct trace_seq *s,
cbc49b25 62 struct tep_record *record,
97fbf3f0 63 struct tep_event *event, void *context)
de705e2e
JO
64{
65 void *data = record->data;
66
67 print_string(s, event, "wiphy_name", data);
68 trace_seq_printf(s, " vif:");
69 print_string(s, event, "vif_name", data);
6a48dc29 70 tep_print_num_field(s, "(%d)", event, "vif_type", record, 1);
de705e2e
JO
71
72 trace_seq_printf(s, "\n%*s", INDENT, "");
73 SF("assoc"); SP();
74 SF("aid"); SP();
75 SF("cts"); SP();
76 SF("shortpre"); SP();
77 SF("shortslot"); SP();
78 SF("dtimper"); SP();
79 trace_seq_printf(s, "\n%*s", INDENT, "");
80 SF("bcnint"); SP();
81 SFX("assoc_cap"); SP();
82 SFX("basic_rates"); SP();
83 SF("enable_beacon");
84 trace_seq_printf(s, "\n%*s", INDENT, "");
85 SF("ht_operation_mode");
86
87 return 0;
88}
89
c32d52b4 90int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
de705e2e 91{
b843e9c3
TSV
92 tep_register_event_handler(pevent, -1, "mac80211",
93 "drv_bss_info_changed",
94 drv_bss_info_changed, NULL);
de705e2e
JO
95 return 0;
96}
ec7c6deb 97
c32d52b4 98void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
ec7c6deb 99{
b843e9c3
TSV
100 tep_unregister_event_handler(pevent, -1, "mac80211",
101 "drv_bss_info_changed",
102 drv_bss_info_changed, NULL);
ec7c6deb 103}