Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: LGPL-2.1
0002 /*
0003  * Copyright (C) 2009 Johannes Berg <johannes@sipsolutions.net>
0004  */
0005 #include <stdio.h>
0006 #include <stdlib.h>
0007 #include <string.h>
0008 
0009 #include "event-parse.h"
0010 #include "trace-seq.h"
0011 
0012 #define INDENT 65
0013 
0014 static void print_string(struct trace_seq *s, struct tep_event *event,
0015              const char *name, const void *data)
0016 {
0017     struct tep_format_field *f = tep_find_field(event, name);
0018     int offset;
0019     int length;
0020 
0021     if (!f) {
0022         trace_seq_printf(s, "NOTFOUND:%s", name);
0023         return;
0024     }
0025 
0026     offset = f->offset;
0027     length = f->size;
0028 
0029     if (!strncmp(f->type, "__data_loc", 10)) {
0030         unsigned long long v;
0031         if (tep_read_number_field(f, data, &v)) {
0032             trace_seq_printf(s, "invalid_data_loc");
0033             return;
0034         }
0035         offset = v & 0xffff;
0036         length = v >> 16;
0037     }
0038 
0039     trace_seq_printf(s, "%.*s", length, (char *)data + offset);
0040 }
0041 
0042 #define SF(fn)  tep_print_num_field(s, fn ":%d", event, fn, record, 0)
0043 #define SFX(fn) tep_print_num_field(s, fn ":%#x", event, fn, record, 0)
0044 #define SP()    trace_seq_putc(s, ' ')
0045 
0046 static int drv_bss_info_changed(struct trace_seq *s,
0047                 struct tep_record *record,
0048                 struct tep_event *event, void *context)
0049 {
0050     void *data = record->data;
0051 
0052     print_string(s, event, "wiphy_name", data);
0053     trace_seq_printf(s, " vif:");
0054     print_string(s, event, "vif_name", data);
0055     tep_print_num_field(s, "(%d)", event, "vif_type", record, 1);
0056 
0057     trace_seq_printf(s, "\n%*s", INDENT, "");
0058     SF("assoc"); SP();
0059     SF("aid"); SP();
0060     SF("cts"); SP();
0061     SF("shortpre"); SP();
0062     SF("shortslot"); SP();
0063     SF("dtimper"); SP();
0064     trace_seq_printf(s, "\n%*s", INDENT, "");
0065     SF("bcnint"); SP();
0066     SFX("assoc_cap"); SP();
0067     SFX("basic_rates"); SP();
0068     SF("enable_beacon");
0069     trace_seq_printf(s, "\n%*s", INDENT, "");
0070     SF("ht_operation_mode");
0071 
0072     return 0;
0073 }
0074 
0075 int TEP_PLUGIN_LOADER(struct tep_handle *tep)
0076 {
0077     tep_register_event_handler(tep, -1, "mac80211",
0078                    "drv_bss_info_changed",
0079                    drv_bss_info_changed, NULL);
0080     return 0;
0081 }
0082 
0083 void TEP_PLUGIN_UNLOADER(struct tep_handle *tep)
0084 {
0085     tep_unregister_event_handler(tep, -1, "mac80211",
0086                      "drv_bss_info_changed",
0087                      drv_bss_info_changed, NULL);
0088 }