root/net/tipc/trace.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * net/tipc/trace.h: TIPC tracepoints
   3  *
   4  * Copyright (c) 2018, Ericsson AB
   5  * All rights reserved.
   6  *
   7  * Redistribution and use in source and binary forms, with or without
   8  * modification, are permitted provided that the following conditions are met:
   9  *
  10  * 1. Redistributions of source code must retain the above copyright
  11  *    notice, this list of conditions and the following disclaimer.
  12  * 2. Redistributions in binary form must reproduce the above copyright
  13  *    notice, this list of conditions and the following disclaimer in the
  14  *    documentation and/or other materials provided with the distribution.
  15  * 3. Neither the names of the copyright holders nor the names of its
  16  *    contributors may be used to endorse or promote products derived from
  17  *    this software without specific prior written permission.
  18  *
  19  * Alternatively, this software may be distributed under the terms of the
  20  * GNU General Public License ("GPL") version 2 as published by the Free
  21  * Software Foundation.
  22  *
  23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "ASIS"
  24  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,THE
  25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  27  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  30  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  31  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  33  * POSSIBILITY OF SUCH DAMAGE.
  34  */
  35 
  36 #undef TRACE_SYSTEM
  37 #define TRACE_SYSTEM tipc
  38 
  39 #if !defined(_TIPC_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
  40 #define _TIPC_TRACE_H
  41 
  42 #include <linux/tracepoint.h>
  43 #include "core.h"
  44 #include "link.h"
  45 #include "socket.h"
  46 #include "node.h"
  47 
  48 #define SKB_LMIN        (100)
  49 #define SKB_LMAX        (SKB_LMIN * 2)
  50 #define LIST_LMIN       (SKB_LMIN * 3)
  51 #define LIST_LMAX       (SKB_LMIN * 11)
  52 #define SK_LMIN         (SKB_LMIN * 2)
  53 #define SK_LMAX         (SKB_LMIN * 11)
  54 #define LINK_LMIN       (SKB_LMIN)
  55 #define LINK_LMAX       (SKB_LMIN * 16)
  56 #define NODE_LMIN       (SKB_LMIN)
  57 #define NODE_LMAX       (SKB_LMIN * 11)
  58 
  59 #ifndef __TIPC_TRACE_ENUM
  60 #define __TIPC_TRACE_ENUM
  61 enum {
  62         TIPC_DUMP_NONE          = 0,
  63 
  64         TIPC_DUMP_TRANSMQ       = 1,
  65         TIPC_DUMP_BACKLOGQ      = (1 << 1),
  66         TIPC_DUMP_DEFERDQ       = (1 << 2),
  67         TIPC_DUMP_INPUTQ        = (1 << 3),
  68         TIPC_DUMP_WAKEUP        = (1 << 4),
  69 
  70         TIPC_DUMP_SK_SNDQ       = (1 << 8),
  71         TIPC_DUMP_SK_RCVQ       = (1 << 9),
  72         TIPC_DUMP_SK_BKLGQ      = (1 << 10),
  73         TIPC_DUMP_ALL           = 0xffffu
  74 };
  75 #endif
  76 
  77 /* Link & Node FSM states: */
  78 #define state_sym(val)                                                    \
  79         __print_symbolic(val,                                             \
  80                         {(0xe),         "ESTABLISHED"                   },\
  81                         {(0xe << 4),    "ESTABLISHING"                  },\
  82                         {(0x1 << 8),    "RESET"                         },\
  83                         {(0x2 << 12),   "RESETTING"                     },\
  84                         {(0xd << 16),   "PEER_RESET"                    },\
  85                         {(0xf << 20),   "FAILINGOVER"                   },\
  86                         {(0xc << 24),   "SYNCHING"                      },\
  87                         {(0xdd),        "SELF_DOWN_PEER_DOWN"           },\
  88                         {(0xaa),        "SELF_UP_PEER_UP"               },\
  89                         {(0xd1),        "SELF_DOWN_PEER_LEAVING"        },\
  90                         {(0xac),        "SELF_UP_PEER_COMING"           },\
  91                         {(0xca),        "SELF_COMING_PEER_UP"           },\
  92                         {(0x1d),        "SELF_LEAVING_PEER_DOWN"        },\
  93                         {(0xf0),        "FAILINGOVER"                   },\
  94                         {(0xcc),        "SYNCHING"                      })
  95 
  96 /* Link & Node FSM events: */
  97 #define evt_sym(val)                                                      \
  98         __print_symbolic(val,                                             \
  99                         {(0xec1ab1e),   "ESTABLISH_EVT"                 },\
 100                         {(0x9eed0e),    "PEER_RESET_EVT"                },\
 101                         {(0xfa110e),    "FAILURE_EVT"                   },\
 102                         {(0x10ca1d0e),  "RESET_EVT"                     },\
 103                         {(0xfa110bee),  "FAILOVER_BEGIN_EVT"            },\
 104                         {(0xfa110ede),  "FAILOVER_END_EVT"              },\
 105                         {(0xc1ccbee),   "SYNCH_BEGIN_EVT"               },\
 106                         {(0xc1ccede),   "SYNCH_END_EVT"                 },\
 107                         {(0xece),       "SELF_ESTABL_CONTACT_EVT"       },\
 108                         {(0x1ce),       "SELF_LOST_CONTACT_EVT"         },\
 109                         {(0x9ece),      "PEER_ESTABL_CONTACT_EVT"       },\
 110                         {(0x91ce),      "PEER_LOST_CONTACT_EVT"         },\
 111                         {(0xfbe),       "FAILOVER_BEGIN_EVT"            },\
 112                         {(0xfee),       "FAILOVER_END_EVT"              },\
 113                         {(0xcbe),       "SYNCH_BEGIN_EVT"               },\
 114                         {(0xcee),       "SYNCH_END_EVT"                 })
 115 
 116 /* Bearer, net device events: */
 117 #define dev_evt_sym(val)                                                  \
 118         __print_symbolic(val,                                             \
 119                         {(NETDEV_CHANGE),       "NETDEV_CHANGE"         },\
 120                         {(NETDEV_GOING_DOWN),   "NETDEV_GOING_DOWN"     },\
 121                         {(NETDEV_UP),           "NETDEV_UP"             },\
 122                         {(NETDEV_CHANGEMTU),    "NETDEV_CHANGEMTU"      },\
 123                         {(NETDEV_CHANGEADDR),   "NETDEV_CHANGEADDR"     },\
 124                         {(NETDEV_UNREGISTER),   "NETDEV_UNREGISTER"     },\
 125                         {(NETDEV_CHANGENAME),   "NETDEV_CHANGENAME"     })
 126 
 127 extern unsigned long sysctl_tipc_sk_filter[5] __read_mostly;
 128 
 129 int tipc_skb_dump(struct sk_buff *skb, bool more, char *buf);
 130 int tipc_list_dump(struct sk_buff_head *list, bool more, char *buf);
 131 int tipc_sk_dump(struct sock *sk, u16 dqueues, char *buf);
 132 int tipc_link_dump(struct tipc_link *l, u16 dqueues, char *buf);
 133 int tipc_node_dump(struct tipc_node *n, bool more, char *buf);
 134 bool tipc_sk_filtering(struct sock *sk);
 135 
 136 DECLARE_EVENT_CLASS(tipc_skb_class,
 137 
 138         TP_PROTO(struct sk_buff *skb, bool more, const char *header),
 139 
 140         TP_ARGS(skb, more, header),
 141 
 142         TP_STRUCT__entry(
 143                 __string(header, header)
 144                 __dynamic_array(char, buf, (more) ? SKB_LMAX : SKB_LMIN)
 145         ),
 146 
 147         TP_fast_assign(
 148                 __assign_str(header, header);
 149                 tipc_skb_dump(skb, more, __get_str(buf));
 150         ),
 151 
 152         TP_printk("%s\n%s", __get_str(header), __get_str(buf))
 153 )
 154 
 155 #define DEFINE_SKB_EVENT(name) \
 156 DEFINE_EVENT(tipc_skb_class, name, \
 157         TP_PROTO(struct sk_buff *skb, bool more, const char *header), \
 158         TP_ARGS(skb, more, header))
 159 DEFINE_SKB_EVENT(tipc_skb_dump);
 160 DEFINE_SKB_EVENT(tipc_proto_build);
 161 DEFINE_SKB_EVENT(tipc_proto_rcv);
 162 
 163 DECLARE_EVENT_CLASS(tipc_list_class,
 164 
 165         TP_PROTO(struct sk_buff_head *list, bool more, const char *header),
 166 
 167         TP_ARGS(list, more, header),
 168 
 169         TP_STRUCT__entry(
 170                 __string(header, header)
 171                 __dynamic_array(char, buf, (more) ? LIST_LMAX : LIST_LMIN)
 172         ),
 173 
 174         TP_fast_assign(
 175                 __assign_str(header, header);
 176                 tipc_list_dump(list, more, __get_str(buf));
 177         ),
 178 
 179         TP_printk("%s\n%s", __get_str(header), __get_str(buf))
 180 );
 181 
 182 #define DEFINE_LIST_EVENT(name) \
 183 DEFINE_EVENT(tipc_list_class, name, \
 184         TP_PROTO(struct sk_buff_head *list, bool more, const char *header), \
 185         TP_ARGS(list, more, header))
 186 DEFINE_LIST_EVENT(tipc_list_dump);
 187 
 188 DECLARE_EVENT_CLASS(tipc_sk_class,
 189 
 190         TP_PROTO(struct sock *sk, struct sk_buff *skb, u16 dqueues,
 191                  const char *header),
 192 
 193         TP_ARGS(sk, skb, dqueues, header),
 194 
 195         TP_STRUCT__entry(
 196                 __string(header, header)
 197                 __field(u32, portid)
 198                 __dynamic_array(char, buf, (dqueues) ? SK_LMAX : SK_LMIN)
 199                 __dynamic_array(char, skb_buf, (skb) ? SKB_LMIN : 1)
 200         ),
 201 
 202         TP_fast_assign(
 203                 __assign_str(header, header);
 204                 __entry->portid = tipc_sock_get_portid(sk);
 205                 tipc_sk_dump(sk, dqueues, __get_str(buf));
 206                 if (skb)
 207                         tipc_skb_dump(skb, false, __get_str(skb_buf));
 208                 else
 209                         *(__get_str(skb_buf)) = '\0';
 210         ),
 211 
 212         TP_printk("<%u> %s\n%s%s", __entry->portid, __get_str(header),
 213                   __get_str(skb_buf), __get_str(buf))
 214 );
 215 
 216 #define DEFINE_SK_EVENT_FILTER(name) \
 217 DEFINE_EVENT_CONDITION(tipc_sk_class, name, \
 218         TP_PROTO(struct sock *sk, struct sk_buff *skb, u16 dqueues, \
 219                  const char *header), \
 220         TP_ARGS(sk, skb, dqueues, header), \
 221         TP_CONDITION(tipc_sk_filtering(sk)))
 222 DEFINE_SK_EVENT_FILTER(tipc_sk_dump);
 223 DEFINE_SK_EVENT_FILTER(tipc_sk_create);
 224 DEFINE_SK_EVENT_FILTER(tipc_sk_sendmcast);
 225 DEFINE_SK_EVENT_FILTER(tipc_sk_sendmsg);
 226 DEFINE_SK_EVENT_FILTER(tipc_sk_sendstream);
 227 DEFINE_SK_EVENT_FILTER(tipc_sk_poll);
 228 DEFINE_SK_EVENT_FILTER(tipc_sk_filter_rcv);
 229 DEFINE_SK_EVENT_FILTER(tipc_sk_advance_rx);
 230 DEFINE_SK_EVENT_FILTER(tipc_sk_rej_msg);
 231 DEFINE_SK_EVENT_FILTER(tipc_sk_drop_msg);
 232 DEFINE_SK_EVENT_FILTER(tipc_sk_release);
 233 DEFINE_SK_EVENT_FILTER(tipc_sk_shutdown);
 234 
 235 #define DEFINE_SK_EVENT_FILTER_COND(name, cond) \
 236 DEFINE_EVENT_CONDITION(tipc_sk_class, name, \
 237         TP_PROTO(struct sock *sk, struct sk_buff *skb, u16 dqueues, \
 238                  const char *header), \
 239         TP_ARGS(sk, skb, dqueues, header), \
 240         TP_CONDITION(tipc_sk_filtering(sk) && (cond)))
 241 DEFINE_SK_EVENT_FILTER_COND(tipc_sk_overlimit1, tipc_sk_overlimit1(sk, skb));
 242 DEFINE_SK_EVENT_FILTER_COND(tipc_sk_overlimit2, tipc_sk_overlimit2(sk, skb));
 243 
 244 DECLARE_EVENT_CLASS(tipc_link_class,
 245 
 246         TP_PROTO(struct tipc_link *l, u16 dqueues, const char *header),
 247 
 248         TP_ARGS(l, dqueues, header),
 249 
 250         TP_STRUCT__entry(
 251                 __string(header, header)
 252                 __array(char, name, TIPC_MAX_LINK_NAME)
 253                 __dynamic_array(char, buf, (dqueues) ? LINK_LMAX : LINK_LMIN)
 254         ),
 255 
 256         TP_fast_assign(
 257                 __assign_str(header, header);
 258                 tipc_link_name_ext(l, __entry->name);
 259                 tipc_link_dump(l, dqueues, __get_str(buf));
 260         ),
 261 
 262         TP_printk("<%s> %s\n%s", __entry->name, __get_str(header),
 263                   __get_str(buf))
 264 );
 265 
 266 #define DEFINE_LINK_EVENT(name) \
 267 DEFINE_EVENT(tipc_link_class, name, \
 268         TP_PROTO(struct tipc_link *l, u16 dqueues, const char *header), \
 269         TP_ARGS(l, dqueues, header))
 270 DEFINE_LINK_EVENT(tipc_link_dump);
 271 DEFINE_LINK_EVENT(tipc_link_conges);
 272 DEFINE_LINK_EVENT(tipc_link_timeout);
 273 DEFINE_LINK_EVENT(tipc_link_reset);
 274 
 275 #define DEFINE_LINK_EVENT_COND(name, cond) \
 276 DEFINE_EVENT_CONDITION(tipc_link_class, name, \
 277         TP_PROTO(struct tipc_link *l, u16 dqueues, const char *header), \
 278         TP_ARGS(l, dqueues, header), \
 279         TP_CONDITION(cond))
 280 DEFINE_LINK_EVENT_COND(tipc_link_too_silent, tipc_link_too_silent(l));
 281 
 282 DECLARE_EVENT_CLASS(tipc_link_transmq_class,
 283 
 284         TP_PROTO(struct tipc_link *r, u16 f, u16 t, struct sk_buff_head *tq),
 285 
 286         TP_ARGS(r, f, t, tq),
 287 
 288         TP_STRUCT__entry(
 289                 __array(char, name, TIPC_MAX_LINK_NAME)
 290                 __field(u16, from)
 291                 __field(u16, to)
 292                 __field(u32, len)
 293                 __field(u16, fseqno)
 294                 __field(u16, lseqno)
 295         ),
 296 
 297         TP_fast_assign(
 298                 tipc_link_name_ext(r, __entry->name);
 299                 __entry->from = f;
 300                 __entry->to = t;
 301                 __entry->len = skb_queue_len(tq);
 302                 __entry->fseqno = msg_seqno(buf_msg(skb_peek(tq)));
 303                 __entry->lseqno = msg_seqno(buf_msg(skb_peek_tail(tq)));
 304         ),
 305 
 306         TP_printk("<%s> retrans req: [%u-%u] transmq: %u [%u-%u]\n",
 307                   __entry->name, __entry->from, __entry->to,
 308                   __entry->len, __entry->fseqno, __entry->lseqno)
 309 );
 310 
 311 DEFINE_EVENT(tipc_link_transmq_class, tipc_link_retrans,
 312         TP_PROTO(struct tipc_link *r, u16 f, u16 t, struct sk_buff_head *tq),
 313         TP_ARGS(r, f, t, tq)
 314 );
 315 
 316 DEFINE_EVENT_PRINT(tipc_link_transmq_class, tipc_link_bc_ack,
 317         TP_PROTO(struct tipc_link *r, u16 f, u16 t, struct sk_buff_head *tq),
 318         TP_ARGS(r, f, t, tq),
 319         TP_printk("<%s> acked: [%u-%u] transmq: %u [%u-%u]\n",
 320                   __entry->name, __entry->from, __entry->to,
 321                   __entry->len, __entry->fseqno, __entry->lseqno)
 322 );
 323 
 324 DECLARE_EVENT_CLASS(tipc_node_class,
 325 
 326         TP_PROTO(struct tipc_node *n, bool more, const char *header),
 327 
 328         TP_ARGS(n, more, header),
 329 
 330         TP_STRUCT__entry(
 331                 __string(header, header)
 332                 __field(u32, addr)
 333                 __dynamic_array(char, buf, (more) ? NODE_LMAX : NODE_LMIN)
 334         ),
 335 
 336         TP_fast_assign(
 337                 __assign_str(header, header);
 338                 __entry->addr = tipc_node_get_addr(n);
 339                 tipc_node_dump(n, more, __get_str(buf));
 340         ),
 341 
 342         TP_printk("<%x> %s\n%s", __entry->addr, __get_str(header),
 343                   __get_str(buf))
 344 );
 345 
 346 #define DEFINE_NODE_EVENT(name) \
 347 DEFINE_EVENT(tipc_node_class, name, \
 348         TP_PROTO(struct tipc_node *n, bool more, const char *header), \
 349         TP_ARGS(n, more, header))
 350 DEFINE_NODE_EVENT(tipc_node_dump);
 351 DEFINE_NODE_EVENT(tipc_node_create);
 352 DEFINE_NODE_EVENT(tipc_node_delete);
 353 DEFINE_NODE_EVENT(tipc_node_lost_contact);
 354 DEFINE_NODE_EVENT(tipc_node_timeout);
 355 DEFINE_NODE_EVENT(tipc_node_link_up);
 356 DEFINE_NODE_EVENT(tipc_node_link_down);
 357 DEFINE_NODE_EVENT(tipc_node_reset_links);
 358 DEFINE_NODE_EVENT(tipc_node_check_state);
 359 
 360 DECLARE_EVENT_CLASS(tipc_fsm_class,
 361 
 362         TP_PROTO(const char *name, u32 os, u32 ns, int evt),
 363 
 364         TP_ARGS(name, os, ns, evt),
 365 
 366         TP_STRUCT__entry(
 367                 __string(name, name)
 368                 __field(u32, os)
 369                 __field(u32, ns)
 370                 __field(u32, evt)
 371         ),
 372 
 373         TP_fast_assign(
 374                 __assign_str(name, name);
 375                 __entry->os = os;
 376                 __entry->ns = ns;
 377                 __entry->evt = evt;
 378         ),
 379 
 380         TP_printk("<%s> %s--(%s)->%s\n", __get_str(name),
 381                   state_sym(__entry->os), evt_sym(__entry->evt),
 382                   state_sym(__entry->ns))
 383 );
 384 
 385 #define DEFINE_FSM_EVENT(fsm_name) \
 386 DEFINE_EVENT(tipc_fsm_class, fsm_name, \
 387         TP_PROTO(const char *name, u32 os, u32 ns, int evt), \
 388         TP_ARGS(name, os, ns, evt))
 389 DEFINE_FSM_EVENT(tipc_link_fsm);
 390 DEFINE_FSM_EVENT(tipc_node_fsm);
 391 
 392 TRACE_EVENT(tipc_l2_device_event,
 393 
 394         TP_PROTO(struct net_device *dev, struct tipc_bearer *b,
 395                  unsigned long evt),
 396 
 397         TP_ARGS(dev, b, evt),
 398 
 399         TP_STRUCT__entry(
 400                 __string(dev_name, dev->name)
 401                 __string(b_name, b->name)
 402                 __field(unsigned long, evt)
 403                 __field(u8, b_up)
 404                 __field(u8, carrier)
 405                 __field(u8, oper)
 406         ),
 407 
 408         TP_fast_assign(
 409                 __assign_str(dev_name, dev->name);
 410                 __assign_str(b_name, b->name);
 411                 __entry->evt = evt;
 412                 __entry->b_up = test_bit(0, &b->up);
 413                 __entry->carrier = netif_carrier_ok(dev);
 414                 __entry->oper = netif_oper_up(dev);
 415         ),
 416 
 417         TP_printk("%s on: <%s>/<%s> oper: %s carrier: %s bearer: %s\n",
 418                   dev_evt_sym(__entry->evt), __get_str(dev_name),
 419                   __get_str(b_name), (__entry->oper) ? "up" : "down",
 420                   (__entry->carrier) ? "ok" : "notok",
 421                   (__entry->b_up) ? "up" : "down")
 422 );
 423 
 424 #endif /* _TIPC_TRACE_H */
 425 
 426 /* This part must be outside protection */
 427 #undef TRACE_INCLUDE_PATH
 428 #define TRACE_INCLUDE_PATH .
 429 #undef TRACE_INCLUDE_FILE
 430 #define TRACE_INCLUDE_FILE trace
 431 #include <trace/define_trace.h>

/* [<][>][^][v][top][bottom][index][help] */