~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/samples/bpf/ibumad_kern.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /samples/bpf/ibumad_kern.c (Version linux-6.12-rc7) and /samples/bpf/ibumad_kern.c (Version linux-6.9.12)


  1 // SPDX-License-Identifier: GPL-2.0 OR Linux-O      1 // SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
  2                                                     2 
  3 /*                                                  3 /*
  4  * ibumad BPF sample kernel side                    4  * ibumad BPF sample kernel side
  5  *                                                  5  *
  6  * This program is free software; you can redi      6  * This program is free software; you can redistribute it and/or
  7  * modify it under the terms of version 2 of t      7  * modify it under the terms of version 2 of the GNU General Public
  8  * License as published by the Free Software F      8  * License as published by the Free Software Foundation.
  9  *                                                  9  *
 10  * Copyright(c) 2018 Ira Weiny, Intel Corporat     10  * Copyright(c) 2018 Ira Weiny, Intel Corporation
 11  */                                                11  */
 12                                                    12 
 13 #define KBUILD_MODNAME "ibumad_count_pkts_by_c     13 #define KBUILD_MODNAME "ibumad_count_pkts_by_class"
 14 #include <uapi/linux/bpf.h>                        14 #include <uapi/linux/bpf.h>
 15                                                    15 
 16 #include <bpf/bpf_helpers.h>                       16 #include <bpf/bpf_helpers.h>
 17                                                    17 
 18                                                    18 
 19 struct {                                           19 struct {
 20         __uint(type, BPF_MAP_TYPE_ARRAY);          20         __uint(type, BPF_MAP_TYPE_ARRAY);
 21         __type(key, u32); /* class; u32 requir     21         __type(key, u32); /* class; u32 required */
 22         __type(value, u64); /* count of mads r     22         __type(value, u64); /* count of mads read */
 23         __uint(max_entries, 256); /* Room for      23         __uint(max_entries, 256); /* Room for all Classes */
 24 } read_count SEC(".maps");                         24 } read_count SEC(".maps");
 25                                                    25 
 26 struct {                                           26 struct {
 27         __uint(type, BPF_MAP_TYPE_ARRAY);          27         __uint(type, BPF_MAP_TYPE_ARRAY);
 28         __type(key, u32); /* class; u32 requir     28         __type(key, u32); /* class; u32 required */
 29         __type(value, u64); /* count of mads w     29         __type(value, u64); /* count of mads written */
 30         __uint(max_entries, 256); /* Room for      30         __uint(max_entries, 256); /* Room for all Classes */
 31 } write_count SEC(".maps");                        31 } write_count SEC(".maps");
 32                                                    32 
 33 #undef DEBUG                                       33 #undef DEBUG
 34 #ifndef DEBUG                                      34 #ifndef DEBUG
 35 #undef bpf_printk                                  35 #undef bpf_printk
 36 #define bpf_printk(fmt, ...)                       36 #define bpf_printk(fmt, ...)
 37 #endif                                             37 #endif
 38                                                    38 
 39 /* Taken from the current format defined in        39 /* Taken from the current format defined in
 40  * include/trace/events/ib_umad.h                  40  * include/trace/events/ib_umad.h
 41  * and                                             41  * and
 42  * /sys/kernel/tracing/events/ib_umad/ib_umad_     42  * /sys/kernel/tracing/events/ib_umad/ib_umad_read/format
 43  * /sys/kernel/tracing/events/ib_umad/ib_umad_     43  * /sys/kernel/tracing/events/ib_umad/ib_umad_write/format
 44  */                                                44  */
 45 struct ib_umad_rw_args {                           45 struct ib_umad_rw_args {
 46         u64 pad;                                   46         u64 pad;
 47         u8 port_num;                               47         u8 port_num;
 48         u8 sl;                                     48         u8 sl;
 49         u8 path_bits;                              49         u8 path_bits;
 50         u8 grh_present;                            50         u8 grh_present;
 51         u32 id;                                    51         u32 id;
 52         u32 status;                                52         u32 status;
 53         u32 timeout_ms;                            53         u32 timeout_ms;
 54         u32 retires;                               54         u32 retires;
 55         u32 length;                                55         u32 length;
 56         u32 qpn;                                   56         u32 qpn;
 57         u32 qkey;                                  57         u32 qkey;
 58         u8 gid_index;                              58         u8 gid_index;
 59         u8 hop_limit;                              59         u8 hop_limit;
 60         u16 lid;                                   60         u16 lid;
 61         u16 attr_id;                               61         u16 attr_id;
 62         u16 pkey_index;                            62         u16 pkey_index;
 63         u8 base_version;                           63         u8 base_version;
 64         u8 mgmt_class;                             64         u8 mgmt_class;
 65         u8 class_version;                          65         u8 class_version;
 66         u8 method;                                 66         u8 method;
 67         u32 flow_label;                            67         u32 flow_label;
 68         u16 mad_status;                            68         u16 mad_status;
 69         u16 class_specific;                        69         u16 class_specific;
 70         u32 attr_mod;                              70         u32 attr_mod;
 71         u64 tid;                                   71         u64 tid;
 72         u8 gid[16];                                72         u8 gid[16];
 73         u32 dev_index;                             73         u32 dev_index;
 74         u8 traffic_class;                          74         u8 traffic_class;
 75 };                                                 75 };
 76                                                    76 
 77 SEC("tracepoint/ib_umad/ib_umad_read_recv")        77 SEC("tracepoint/ib_umad/ib_umad_read_recv")
 78 int on_ib_umad_read_recv(struct ib_umad_rw_arg     78 int on_ib_umad_read_recv(struct ib_umad_rw_args *ctx)
 79 {                                                  79 {
 80         u64 zero = 0, *val;                        80         u64 zero = 0, *val;
 81         u8 class = ctx->mgmt_class;                81         u8 class = ctx->mgmt_class;
 82                                                    82 
 83         bpf_printk("ib_umad read recv : class      83         bpf_printk("ib_umad read recv : class 0x%x\n", class);
 84                                                    84 
 85         val = bpf_map_lookup_elem(&read_count,     85         val = bpf_map_lookup_elem(&read_count, &class);
 86         if (!val) {                                86         if (!val) {
 87                 bpf_map_update_elem(&read_coun     87                 bpf_map_update_elem(&read_count, &class, &zero, BPF_NOEXIST);
 88                 val = bpf_map_lookup_elem(&rea     88                 val = bpf_map_lookup_elem(&read_count, &class);
 89                 if (!val)                          89                 if (!val)
 90                         return 0;                  90                         return 0;
 91         }                                          91         }
 92                                                    92 
 93         (*val) += 1;                               93         (*val) += 1;
 94                                                    94 
 95         return 0;                                  95         return 0;
 96 }                                                  96 }
 97 SEC("tracepoint/ib_umad/ib_umad_read_send")        97 SEC("tracepoint/ib_umad/ib_umad_read_send")
 98 int on_ib_umad_read_send(struct ib_umad_rw_arg     98 int on_ib_umad_read_send(struct ib_umad_rw_args *ctx)
 99 {                                                  99 {
100         u64 zero = 0, *val;                       100         u64 zero = 0, *val;
101         u8 class = ctx->mgmt_class;               101         u8 class = ctx->mgmt_class;
102                                                   102 
103         bpf_printk("ib_umad read send : class     103         bpf_printk("ib_umad read send : class 0x%x\n", class);
104                                                   104 
105         val = bpf_map_lookup_elem(&read_count,    105         val = bpf_map_lookup_elem(&read_count, &class);
106         if (!val) {                               106         if (!val) {
107                 bpf_map_update_elem(&read_coun    107                 bpf_map_update_elem(&read_count, &class, &zero, BPF_NOEXIST);
108                 val = bpf_map_lookup_elem(&rea    108                 val = bpf_map_lookup_elem(&read_count, &class);
109                 if (!val)                         109                 if (!val)
110                         return 0;                 110                         return 0;
111         }                                         111         }
112                                                   112 
113         (*val) += 1;                              113         (*val) += 1;
114                                                   114 
115         return 0;                                 115         return 0;
116 }                                                 116 }
117 SEC("tracepoint/ib_umad/ib_umad_write")           117 SEC("tracepoint/ib_umad/ib_umad_write")
118 int on_ib_umad_write(struct ib_umad_rw_args *c    118 int on_ib_umad_write(struct ib_umad_rw_args *ctx)
119 {                                                 119 {
120         u64 zero = 0, *val;                       120         u64 zero = 0, *val;
121         u8 class = ctx->mgmt_class;               121         u8 class = ctx->mgmt_class;
122                                                   122 
123         bpf_printk("ib_umad write : class 0x%x    123         bpf_printk("ib_umad write : class 0x%x\n", class);
124                                                   124 
125         val = bpf_map_lookup_elem(&write_count    125         val = bpf_map_lookup_elem(&write_count, &class);
126         if (!val) {                               126         if (!val) {
127                 bpf_map_update_elem(&write_cou    127                 bpf_map_update_elem(&write_count, &class, &zero, BPF_NOEXIST);
128                 val = bpf_map_lookup_elem(&wri    128                 val = bpf_map_lookup_elem(&write_count, &class);
129                 if (!val)                         129                 if (!val)
130                         return 0;                 130                         return 0;
131         }                                         131         }
132                                                   132 
133         (*val) += 1;                              133         (*val) += 1;
134                                                   134 
135         return 0;                                 135         return 0;
136 }                                                 136 }
137                                                   137 
138 char _license[] SEC("license") = "GPL";           138 char _license[] SEC("license") = "GPL";
139                                                   139 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php