xref: /openbmc/linux/include/trace/events/bridge.h (revision 9b12f050)
1 #undef TRACE_SYSTEM
2 #define TRACE_SYSTEM bridge
3 
4 #if !defined(_TRACE_BRIDGE_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define _TRACE_BRIDGE_H
6 
7 #include <linux/netdevice.h>
8 #include <linux/tracepoint.h>
9 
10 #include "../../../net/bridge/br_private.h"
11 
12 TRACE_EVENT(br_fdb_add,
13 
14 	TP_PROTO(struct ndmsg *ndm, struct net_device *dev,
15 		 const unsigned char *addr, u16 vid, u16 nlh_flags),
16 
17 	TP_ARGS(ndm, dev, addr, vid, nlh_flags),
18 
19 	TP_STRUCT__entry(
20 		__field(u8, ndm_flags)
21 		__string(dev, dev->name)
22 		__array(unsigned char, addr, ETH_ALEN)
23 		__field(u16, vid)
24 		__field(u16, nlh_flags)
25 	),
26 
27 	TP_fast_assign(
28 		__assign_str(dev, dev->name);
29 		memcpy(__entry->addr, addr, ETH_ALEN);
30 		__entry->vid = vid;
31 		__entry->nlh_flags = nlh_flags;
32 		__entry->ndm_flags = ndm->ndm_flags;
33 	),
34 
35 	TP_printk("dev %s addr %02x:%02x:%02x:%02x:%02x:%02x vid %u nlh_flags %04x ndm_flags %02x",
36 		  __get_str(dev), __entry->addr[0], __entry->addr[1],
37 		  __entry->addr[2], __entry->addr[3], __entry->addr[4],
38 		  __entry->addr[5], __entry->vid,
39 		  __entry->nlh_flags, __entry->ndm_flags)
40 );
41 
42 TRACE_EVENT(br_fdb_external_learn_add,
43 
44 	TP_PROTO(struct net_bridge *br, struct net_bridge_port *p,
45 		 const unsigned char *addr, u16 vid),
46 
47 	TP_ARGS(br, p, addr, vid),
48 
49 	TP_STRUCT__entry(
50 		__string(br_dev, br->dev->name)
51 		__string(dev, p ? p->dev->name : "null")
52 		__array(unsigned char, addr, ETH_ALEN)
53 		__field(u16, vid)
54 	),
55 
56 	TP_fast_assign(
57 		__assign_str(br_dev, br->dev->name);
58 		__assign_str(dev, p ? p->dev->name : "null");
59 		memcpy(__entry->addr, addr, ETH_ALEN);
60 		__entry->vid = vid;
61 	),
62 
63 	TP_printk("br_dev %s port %s addr %02x:%02x:%02x:%02x:%02x:%02x vid %u",
64 		  __get_str(br_dev), __get_str(dev), __entry->addr[0],
65 		  __entry->addr[1], __entry->addr[2], __entry->addr[3],
66 		  __entry->addr[4], __entry->addr[5], __entry->vid)
67 );
68 
69 TRACE_EVENT(fdb_delete,
70 
71 	TP_PROTO(struct net_bridge *br, struct net_bridge_fdb_entry *f),
72 
73 	TP_ARGS(br, f),
74 
75 	TP_STRUCT__entry(
76 		__string(br_dev, br->dev->name)
77 		__string(dev, f->dst ? f->dst->dev->name : "null")
78 		__array(unsigned char, addr, ETH_ALEN)
79 		__field(u16, vid)
80 	),
81 
82 	TP_fast_assign(
83 		__assign_str(br_dev, br->dev->name);
84 		__assign_str(dev, f->dst ? f->dst->dev->name : "null");
85 		memcpy(__entry->addr, f->key.addr.addr, ETH_ALEN);
86 		__entry->vid = f->key.vlan_id;
87 	),
88 
89 	TP_printk("br_dev %s dev %s addr %02x:%02x:%02x:%02x:%02x:%02x vid %u",
90 		  __get_str(br_dev), __get_str(dev), __entry->addr[0],
91 		  __entry->addr[1], __entry->addr[2], __entry->addr[3],
92 		  __entry->addr[4], __entry->addr[5], __entry->vid)
93 );
94 
95 TRACE_EVENT(br_fdb_update,
96 
97 	TP_PROTO(struct net_bridge *br, struct net_bridge_port *source,
98 		 const unsigned char *addr, u16 vid, unsigned long flags),
99 
100 	TP_ARGS(br, source, addr, vid, flags),
101 
102 	TP_STRUCT__entry(
103 		__string(br_dev, br->dev->name)
104 		__string(dev, source->dev->name)
105 		__array(unsigned char, addr, ETH_ALEN)
106 		__field(u16, vid)
107 		__field(unsigned long, flags)
108 	),
109 
110 	TP_fast_assign(
111 		__assign_str(br_dev, br->dev->name);
112 		__assign_str(dev, source->dev->name);
113 		memcpy(__entry->addr, addr, ETH_ALEN);
114 		__entry->vid = vid;
115 		__entry->flags = flags;
116 	),
117 
118 	TP_printk("br_dev %s source %s addr %02x:%02x:%02x:%02x:%02x:%02x vid %u flags 0x%lx",
119 		  __get_str(br_dev), __get_str(dev), __entry->addr[0],
120 		  __entry->addr[1], __entry->addr[2], __entry->addr[3],
121 		  __entry->addr[4], __entry->addr[5], __entry->vid,
122 		  __entry->flags)
123 );
124 
125 TRACE_EVENT(br_mdb_full,
126 
127 	TP_PROTO(const struct net_device *dev,
128 		 const struct br_ip *group),
129 
130 	TP_ARGS(dev, group),
131 
132 	TP_STRUCT__entry(
133 		__string(dev, dev->name)
134 		__field(int, af)
135 		__field(u16, vid)
136 		__array(__u8, src, 16)
137 		__array(__u8, grp, 16)
138 		__array(__u8, grpmac, ETH_ALEN) /* For af == 0. */
139 	),
140 
141 	TP_fast_assign(
142 		struct in6_addr *in6;
143 
144 		__assign_str(dev, dev->name);
145 		__entry->vid = group->vid;
146 
147 		if (!group->proto) {
148 			__entry->af = 0;
149 
150 			memset(__entry->src, 0, sizeof(__entry->src));
151 			memset(__entry->grp, 0, sizeof(__entry->grp));
152 			memcpy(__entry->grpmac, group->dst.mac_addr, ETH_ALEN);
153 		} else if (group->proto == htons(ETH_P_IP)) {
154 			__entry->af = AF_INET;
155 
156 			in6 = (struct in6_addr *)__entry->src;
157 			ipv6_addr_set_v4mapped(group->src.ip4, in6);
158 
159 			in6 = (struct in6_addr *)__entry->grp;
160 			ipv6_addr_set_v4mapped(group->dst.ip4, in6);
161 
162 			memset(__entry->grpmac, 0, ETH_ALEN);
163 
164 #if IS_ENABLED(CONFIG_IPV6)
165 		} else {
166 			__entry->af = AF_INET6;
167 
168 			in6 = (struct in6_addr *)__entry->src;
169 			*in6 = group->src.ip6;
170 
171 			in6 = (struct in6_addr *)__entry->grp;
172 			*in6 = group->dst.ip6;
173 
174 			memset(__entry->grpmac, 0, ETH_ALEN);
175 #endif
176 		}
177 	),
178 
179 	TP_printk("dev %s af %u src %pI6c grp %pI6c/%pM vid %u",
180 		  __get_str(dev), __entry->af, __entry->src, __entry->grp,
181 		  __entry->grpmac, __entry->vid)
182 );
183 
184 #endif /* _TRACE_BRIDGE_H */
185 
186 /* This part must be outside protection */
187 #include <trace/define_trace.h>
188